2020-02-23 06:11:43 +11:00
|
|
|
.equ COM_DRV_ADDR 0x0238 ; replace with *CL's DCB addr
|
|
|
|
.equ DEST_ADDR 0x3000 ; memory address where to put contents.
|
|
|
|
|
|
|
|
; We process the 0x20 exception by pre-putting a mask in the (HL) we're going
|
|
|
|
; to write to. If it wasn't a 0x20, we put a 0xff mask. If it was a 0x20, we
|
|
|
|
; put a 0x7f mask.
|
|
|
|
|
|
|
|
ld hl, DEST_ADDR
|
2020-01-12 14:45:22 +11:00
|
|
|
loop:
|
2020-02-23 06:11:43 +11:00
|
|
|
ld a, 0xff
|
|
|
|
ld (hl), a ; default mask
|
|
|
|
loop2:
|
2020-01-12 14:45:22 +11:00
|
|
|
ld a, 0x03 ; @GET
|
2020-02-23 06:11:43 +11:00
|
|
|
ld de, COM_DRV_ADDR
|
2020-01-12 14:45:22 +11:00
|
|
|
rst 0x28
|
|
|
|
jr nz, maybeerror
|
|
|
|
or a
|
|
|
|
ret z ; Sending a straight NULL ends the comm.
|
|
|
|
; @PUT that char back
|
|
|
|
ld c, a
|
|
|
|
ld a, 0x04 ; @PUT
|
|
|
|
rst 0x28
|
|
|
|
jr nz, error
|
|
|
|
ld a, c
|
|
|
|
cp 0x20
|
2020-02-23 06:11:43 +11:00
|
|
|
jr z, escapechar
|
|
|
|
; not an escape char, just apply the mask and write
|
|
|
|
and (hl)
|
2020-01-12 14:45:22 +11:00
|
|
|
ld (hl), a
|
|
|
|
inc hl
|
|
|
|
jr loop
|
2020-02-23 06:11:43 +11:00
|
|
|
escapechar:
|
|
|
|
; adjust by setting (hl) to 0x7f
|
|
|
|
res 7, (hl)
|
|
|
|
jr loop2
|
2020-01-12 14:45:22 +11:00
|
|
|
maybeerror:
|
|
|
|
; was it an error?
|
|
|
|
or a
|
2020-02-23 06:11:43 +11:00
|
|
|
jr z, loop2 ; not an error, just loop
|
2020-01-12 14:45:22 +11:00
|
|
|
; error
|
|
|
|
error:
|
|
|
|
ld c, a ; Error code from @GET/@PUT
|
|
|
|
ld a, 0x1a ; @ERROR
|
|
|
|
rst 0x28
|
|
|
|
ret
|