outmdm:\r
push hl\r
ld hl,(outptr)\r
- ld (hl),e ;return buffered char\r
+ ld (hl),e ;save char in buffer\r
inc hl\r
ld (outptr),hl\r
ld a,(outcnt)\r
ld a,2 ;start write transaction\r
out (VI2C_CTRL),a\r
\r
- ld hl,outbuf+2\r
- ld (outptr),hl\r
+ ld hl,outbuf+2 ;buffer start\r
ld a,(outcnt)\r
- sub c\r
+ sub c ;buffer now empty?\r
ld (outcnt),a\r
jr z,omfex\r
\r
- push de\r
- ld d,h\r
+ push de ;no, shift remaining chars down\r
+ ld d,h ;dest = buffer start\r
ld e,l\r
ld b,0\r
- add hl,bc\r
+ add hl,bc ;src = buffer start + num chars last transmitted\r
ld c,a\r
ldir\r
+ ex de,hl\r
pop de\r
omfex:\r
+ ld (outptr),hl\r
pop bc\r
pop hl\r
ret\r