Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- InitSPC:
- php
- sep #$20
- lda #$01
- sta $199c
- lda #$cc
- bra .WaitForReadySignal
- - ldx #$00fc
- stx !APUIO0
- rep #$10
- .WaitForReadySignal
- ldx #$bbaa
- cpx !APUIO0
- bne -
- bra .InitTransfer
- .TransferLoop
- jsr .LoadNextByte
- xba
- lda #$00
- bra +
- .loop
- xba
- jsr .LoadNextByte
- xba
- - cmp !APUIO0 ; Wait for SPC to echo data
- bne -
- inc
- + rep #$20
- sta !APUIO0
- sep #$20
- dex ; Are we done sending this data chunk?
- bne .loop
- - cmp !APUIO0 ; Wait for SPC to echo data
- bne -
- - adc #$03 ; Not sure what the purpose of this is
- beq -
- .InitTransfer
- pha
- jsr .LoadNextByte ; Data size (LSB)
- xba
- jsr .LoadNextByte ; Data size (MSB)
- xba
- rep #$20
- tax
- sep #$20
- jsr .LoadNextByte ; Transfer address (LSB)
- xba
- jsr .LoadNextByte ; Transfer address (MSB)
- xba
- rep #$20
- sta !APUIO2 ; Send transfer address to SPC
- sep #$20
- cpx #$0001 ; Set carry if X is equal to 0
- lda #$00
- rol
- sta !APUIO1
- adc #$7f
- pla
- sta !APUIO0 ; Tell the SPC we're about to upload data
- - cmp !APUIO0 ; and wait for it to acknowledge
- bne -
- bvs .TransferLoop ; If X was not 0 when we checked,
- ; start transferring next block of data
- sep #$20
- - lda !APUIO0
- bne -
- lda !APUIO1
- bne -
- lda !APUIO2
- bne -
- lda !APUIO3
- bne -
- sta $199c
- plp
- rts
- .LoadNextByte
- lda [!ReadAddr],y
- iny
- bne + ; Are we still in the same bank?
- inc.b !ReadBank ; Start reading from
- ldy #$8000 ; the start of the next bank
- + rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement