sms: implement (spix) in z80 asm

Doing SPI bit-banging through a controller port is already really
slow, but doing so with the Forth version of (spix) was really,
really slow.

With this pure z80 version of (spix), it's more bearable.
This commit is contained in:
Virgil Dupras 2020-11-17 13:41:44 -05:00
parent 4d26f1c490
commit 959382c079

View File

@ -151,15 +151,20 @@ TL. When the '164 is full, TL is low. Port A TL is bit 4 )
2 _THB! ( TH input ) ; 2 _THB! ( TH input ) ;
( ----- 622 ) ( ----- 622 )
: (spie) DROP ; ( always enabled ) : (spie) DROP ; ( always enabled )
: (spix) ( x -- x, for port B ) CODE (spix) ( x -- x, for port B ) HL POP, chkPS,
0 SWAP ( rx tx ) 8 0 DO ( TR = DATA TH = CLK )
( send current bit to TRB, TR's output bit ) CPORT_MEM LDA(i), 0xf3 ANDi, ( TR/TH output )
DUP 7 I - RSHIFT 1 AND _TRB! H 8 LDri, BEGIN,
1 _THB! ( CLK hi ) 0xbf ANDi, ( TR lo ) L RL, ( --> C )
( read into rx ) SWAP 1 LSHIFT _D1@ ( tx rx<< x ) IFC, 0x40 ORi, ( TR hi ) THEN,
0 _THB! ( CLK lo ) CPORT_CTL OUTiA, ( clic! ) 0x80 ORi, ( TH hi )
( out bit is the 6th ) 6 RSHIFT 1 AND OR CPORT_CTL OUTiA, ( clac! )
SWAP LOOP ( rx tx ) DROP ; EXAFAF', CPORT_D1 INAi, ( Up Btn is B6 ) RLA, RLA,
E RL, EXAFAF',
0x7f ANDi, ( TH lo ) CPORT_CTL OUTiA, ( cloc! )
H DECr, JRNZ, AGAIN, CPORT_MEM LD(i)A,
L E LDrr, HL PUSH,
;CODE
( ----- 625 ) ( ----- 625 )
( Routines for interacting with SMS controller ports. ( Routines for interacting with SMS controller ports.
Requires CPORT_MEM, CPORT_CTL, CPORT_D1 and CPORT_D2 to be Requires CPORT_MEM, CPORT_CTL, CPORT_D1 and CPORT_D2 to be