Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .macro Init_APU
- sep #$20 ; 8 bit A
- ; Wait until the APU is ready to start transferring
- @Loop: ldx $2140
- cpx #$BBAA
- bne @Loop
- ; Initialize the transfer
- ldx #$0200 ; Transfer data to address $0200 in the APU
- stx $2142
- lda #1
- sta $2141
- lda #$CC
- sta $2140
- @Loop2: cmp $2140
- bne @Loop2
- ; Start transferring the first chunk of the driver
- ldx #0
- ldy #SPCData1Len
- phb ; Backup the DBR
- lda #$04 ; Put new value in DBR
- pha
- plb
- @Next: lda SPCData1, x ; Send next byte of data
- sta $2141
- txa
- sta $2140
- @Wait: cmp $2140 ; Wait for transfer
- bne @Wait
- inx
- dey
- bne @Next
- ; Continue transferring the second chunk of the driver
- ldx #0
- ldy #SPCData2Len
- lda #$05 ; Put new value in DBR
- pha
- plb
- @Next2: lda SPCData2, x ; Send next byte of data
- sta $2141
- lda $2140
- inc
- sta $2140
- @Wait2: cmp $2140 ; Wait for transfer
- bne @Wait2
- inx
- dey
- bne @Next2
- plb ; Restore the DBR
- ; End transfer
- ldx #$0200 ; Starting address of execution
- stx $2142
- stz $2141 ; Jump to execution address
- lda $2140 ; Break transfer cycle
- adc #2
- sta $2140
- .endmacro
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement