aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@trantor.hos.anvin.org>2009-01-09 21:28:31 -0800
committerH. Peter Anvin <hpa@trantor.hos.anvin.org>2009-01-09 21:28:31 -0800
commit1457902db0ee5e39d0d8cde8cf37da854d75f07c (patch)
tree7c2ff94df50d1ddfb956a4b14872189c531fd843
parent53acd7741afbf5be3e2b2042ce5ff085e90ebec8 (diff)
downloadabc80-1457902db0ee5e39d0d8cde8cf37da854d75f07c.tar.gz
abc80-1457902db0ee5e39d0d8cde8cf37da854d75f07c.tar.xz
abc80-1457902db0ee5e39d0d8cde8cf37da854d75f07c.zip
fileop: Now input pra: seems to work, too...
-rw-r--r--data/printer.asm79
-rw-r--r--tools/fileop.c10
2 files changed, 64 insertions, 25 deletions
diff --git a/data/printer.asm b/data/printer.asm
index 55e5e52..1a19b16 100644
--- a/data/printer.asm
+++ b/data/printer.asm
@@ -23,12 +23,12 @@ pr_jptable:
jp pr_open ; OPEN
jp pr_open ; PREPARE
jp pr_close ; CLOSE
- jp nothere ; INPUT
+ jp notthere ; INPUT
jp pr_print ; PRINT
- jp nothere ; Block to buf
- jp nothere ; Block from buf
- jp nothere ; DELETE???
- jp nothere ; RENAME???
+ jp notthere ; Block to buf
+ jp notthere ; Block from buf
+ jp notthere ; DELETE???
+ jp notthere ; RENAME???
prab_jp_init:
jp prab_init
@@ -92,13 +92,10 @@ wb_loop:
pop af
ret
-nothere:
- rst 0x10
- defb 128+52 ; Err 52 = ej till denna enhet
-
-notready:
- rst 0x10
- defb 128+51 ; Err 51 = enheten upptagen
+notthere:
+ ld a,128+52
+ scf
+ ret
done:
xor a
@@ -110,6 +107,10 @@ done_err:
pop af
and a
ret p
+ cp 128+34 ; ERR 34 = end of file
+ jr nz,not_eof
+ xor a ; ... end of file is signalled by A=0
+not_eof:
scf
ret
@@ -120,10 +121,10 @@ pra_jptable:
jp pra_close ; CLOSE
jp pra_input ; INPUT
jp pra_print ; PRINT
- jp nothere ; Block to buf
- jp nothere ; Block from buf
- jp nothere ; DELETE???
- jp nothere ; RENAME???
+ jp notthere ; Block to buf
+ jp notthere ; Block from buf
+ jp notthere ; DELETE???
+ jp notthere ; RENAME???
prb_jptable:
jp prb_open ; OPEN
@@ -133,8 +134,8 @@ prb_jptable:
jp 001Bh ; PRINT
jp prb_rdblk ; Block to buf
jp prb_wrblk ; Block from buf
- jp nothere ; DELETE???
- jp nothere ; RENAME???
+ jp notthere ; DELETE???
+ jp notthere ; RENAME???
pra_open:
ld c,0xA0
@@ -206,10 +207,47 @@ done_err2:
jp done_err
pra_input:
+ call select
+ ld a,0xA4 ; INPUT
+ call send_cmd
+ call recv_reply
+ and a
+ jr nz,done_err2
+ call recv_byte
+ jr c,prai_timeout
+ ld e,a
+ call recv_byte
+ jr c,prai_timeout
+ ld d,a
+ ; Now HL -> target buf; DE -> expected byte count;
+ ; BC -> buffer size
+prai_loop:
+ ld a,d
+ or e
+ jp z,done
+ dec de
+ ld a,b
+ or c
+ jr nz,prai_space
+ ld hl,ram_dummy
+ inc c
+prai_space:
+ dec bc
+ call recv_byte
+ jr c,prai_timeout
+ ld (hl),a
+ inc hl
+ jr prai_loop
+prai_skip:
+ pop af
+ jr prai_loop
+prai_timeout:
+ ld a,128+42
+ jr done_err2
+
prb_wrblk:
prb_rdblk:
- scf ; Not implemented yet
- ret
+ jp notthere
; Set up a BUF for PRB:
prb_setup_buf:
@@ -342,6 +380,7 @@ ram_devlst: equ 7B00h
ram_select: equ 7B0Eh ; Previous select code
ram_cmd: equ 7B0Fh ; Latest sent command
ram_serial: equ 7B10h ; Latest serial number
+ram_dummy: equ 7B11h ; Scratch byte
prab_init:
ld hl,prab_device
diff --git a/tools/fileop.c b/tools/fileop.c
index 9237c49..a9a49a5 100644
--- a/tools/fileop.c
+++ b/tools/fileop.c
@@ -261,7 +261,7 @@ static void do_input(int fd, uint16_t ix)
struct file_data *fm = filemap[ix];
int err;
char data[BUF_SIZE], data1[2*BUF_SIZE];
- char *p, *q;
+ char *p, *q, c;
int dlen;
if (!fm) {
@@ -288,20 +288,19 @@ static void do_input(int fd, uint16_t ix)
err = 128+34; /* Slut på filen */
}
send_reply(fd, err);
- free(data);
return;
}
/* Strip CR and change LF -> CR LF */
- for (p = data, q = data1+2 ; *p ; p++) {
- switch (*p) {
+ for (p = data, q = data1+2 ; (c = *p) ; p++) {
+ switch (c) {
case '\r':
break;
case '\n':
*q++ = '\r';
/* fall through */
default:
- *q++ = *p;
+ *q++ = c;
break;
}
}
@@ -309,6 +308,7 @@ static void do_input(int fd, uint16_t ix)
data1[0] = dlen;
data1[1] = dlen >> 8;
send_reply(fd, 0);
+ fprintf(stderr, "input: sending %d bytes\n", dlen);
xwrite(fd, data1, dlen+2);
}