Advertisement
atm959

Code

Jul 26th, 2018
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. UploadAndExecuteSoundEngine:
  2.     sei         ;Disable interrupts
  3.  
  4. @WaitReady1:
  5.     lda $2140
  6.     cmp #$AA
  7.     bne @WaitReady1
  8. @WaitReady2:
  9.     lda $2141
  10.     cmp #$BB
  11.     bne @WaitReady2 ;"Is the SPC700 ready?"
  12.  
  13.     lda #$01
  14.     sta $2141
  15.     lda #$00
  16.     sta $2142
  17.     lda #$05
  18.     sta $2143
  19.     lda #$CC
  20.     sta $2140       ;Send the transfer begin bytes
  21.  
  22. @WaitEcho1:
  23.     lda $2140
  24.     cmp #$CC
  25.     bne @WaitEcho1  ;Wait for PORT0 to echo
  26.  
  27.     ldx SoundEngineEnd-SoundEngine
  28.     ldy #$0000
  29. @TransferFirst:
  30.     lda SoundEngine, y
  31.     sta $2141       ;Write the first byte to PORT1
  32.  
  33.     lda #$00
  34.     sta $2140       ;Write 0 to PORT0
  35.  
  36. @WaitEcho2:
  37.     lda $2140
  38.     cmp #$00
  39.     bne @WaitEcho2  ;Wait for PORT0 to echo
  40.  
  41.     dex
  42.     iny
  43.  
  44. @TransferRest:
  45.     lda SoundEngine, y
  46.     sta $2141       ;Write the next byte to PORT1
  47.  
  48.     lda $2140
  49.     inc a
  50.     sta $2140       ;Increase the byte in PORT0 and send it back
  51.     sta $0000
  52.  
  53. @WaitEcho3:
  54.     lda $2140
  55.     cmp $0000
  56.     bne @WaitEcho3
  57.  
  58.     dex
  59.     iny
  60.  
  61.     txa
  62.     cmp #$00
  63.     bne @TransferRest
  64.  
  65.     lda #$00
  66.     sta $2141   ;0 in PORT1
  67.     lda #$00
  68.     sta $2142
  69.     lda #$05
  70.     sta $2143   ;Execute address in PORT2 and PORT3
  71.     lda $2140
  72.     clc
  73.     adc #$02
  74.     sta $2140   ;Increase PORT0 by 2 and store it in PORT0
  75.  
  76.     stz $0000
  77.     lda #$00
  78.     ldx #$0000
  79.     ldy #$0000
  80.  
  81.     cli         ;Enable interrupts
  82.     rtl
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement