Uhm, yes got a point there, what about the rest though?
I meant that middle loop to be as fast as possible without being too fast for the hardware (so the ret is after that out)
It seems to me that my way is faster besides being more straightforward. And there’s at least one obvious way to make the loop faster. Check out input.inc in the AG source, or look below for a copy of the code.
The main loss in your case is using both a ret and a jump to take care of the loop. You should really believe that djnz is your friend.
ReadKeyboard: ; Fills 7 bytes at KeyPressed; if a key is pressed, the corresponding
ld hl,KeyPressed ; bit is set to ZERO. Works with disabled interrupts as well.
ld b,7
ld c,$fe
RK_Loop:
ld a,$ff
out (1),a
ld a,c
out (1),a
in a,(1)
ld (hl),a
inc hl
rlc c
djnz RK_Loop
ret
That code is too big fit into my brains properly..
But I'll give it a try (it'll be the first time I'll get to see inir and otir in action so it'll be worth it )
SendLoop:
ld b,d ;Send max size
ld a,e
sub d ;Unless bytes left - max packet carries
ld e,a
jr nc,$f
; ld b,e
add a,d
ld b,a
ld e,0 ;This is the last packet
$$:
LOG DataStart,b
IF LOGGING_ON=0
otir
ELSE
$$:
ld a,(hl)
LOG Data,a
out (c),a
inc hl
; dec b
djnz $b
ENDIF
push bc
ld a,c
sub 0A0h
ld b,a
ld c,01
not the end of the sendloop but no one wants to see all that on a forum anyway..
OTIR is frequently used on the Master System to dump data into VRAM. (You only need to be careful about timing during the active display period). It would be nice if we could do something similar with the TI display driver...
It would be uber cool if we could just OTIR a buffer to the screen! stupid slow lcd
Apparently the USB ports are fast enough though, it's a pity they're not fully documented (or are they? It's not all on wikiTI.. maybe someone is keeping it secret)