Given all the RasPi copros that seemed to arrive as Christmas presents, I thought I'd spend some time messing about with 6502 second processor code to see what might be possible. Thanks to Tom Seddon for his great write up of how the Tube works and JGH for his meticulous documentation.
After investigating the usual methods of data transfer (hooking into oswrch mostly) this was too slow for my particular application, so I moved on to using the fast 256 byte Tube transfer protocol. However, I've come to an impasse and cannot get it to work. Can anyone help me figure out what I'm doing wrong please?
Code: Select all
.host_param_block
{
EQUW parasite_draw_buffer
EQUW 0
}
.host_read256
{
IF _DEBUG_RASTERS
LDX #&00 + PAL_green
STX &FE21
ENDIF
\\ Claim Tube
.claim
LDA #&C0 + &10
JSR &406
BCC claim
\\ 256 byte read
{
LDA #LO(parasite_draw_buffer)
STA host_param_block+0
LDA #HI(parasite_draw_buffer)
STA host_param_block+1
LDX #LO(host_param_block)
LDY #HI(host_param_block)
LDA #&6
JSR &406
\\ Initial delay
LDX #6
.initial_delay
DEX
BNE initial_delay
LDY #0
LDX #0
.loop
LDA &FEE5 ; 4c
STA &71 ; 3c
NOP ; 2c
NOP ; 2c
NOP ; 2c
NOP ; 2c
NOP ; 2c
INX ; 2c
BNE loop ; 3c
}
\\ Release Tube
.release
LDA #&80 + &10
JSR &406 ; <---- BLOCKED HERE
IF _DEBUG_RASTERS
LDX #&00 + PAL_black
STX &FE21
ENDIF
RTS
}
For now this code is just throwing the data transferred into a sink (&71) for test purposes but it is supposed to be an array of addresses and byte masks for a particle system. However I am getting a hang during the release Tube call, specifically the Tube code is spinning waiting for R4 to be free whilst attempting to send the Tube ID over to the parasite:
Code: Select all
\ Release Tube
\ ------------
ORA #&40 :\ Ensure release ID same as claim ID
CMP &15:BNE L0434 :\ Not same as the claim ID, exit
.L0414
PHP:SEI :\ Disable IRQs
LDA #05:JSR L069E :\ Send &05 via R4 to CoPro
JSR L069C :\ Send Tube ID to notify a Tube release
...
\ Send Tube ID via R4
\ ===================
.L069C
LDA &15 :\ Get Tube ID
:
\ Send byte in A via R4
\ =====================
.L069E
BIT TUBES4:BVC L069E :\ Loop until R4 free <---- BLOCKED HERE
STA TUBER4:RTS :\ Send byte
Any Tube experts have any thoughts? It doesn't matter if I call the read function in an osbyte callback or the vsync event handler on the host, I still get the same result. This is in B-Em BTW, I haven't been able to test on real hardware yet (my Master Turbo or PiZero copro). It doesn't hang on BeebEm but the debugger isn't much help (unresponsive) so I can't tell what's going on.
I have a whole separate thread to start on why there aren't (m)any 2nd processor apps or games - it's certainly not designed for parallelism, it's designed to allow a different processor to utilise the I/O of the host Beeb, without wanting to state the obvious..!