Advertisement
Guest User

Untitled

a guest
May 17th, 2019
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .macro Init_APU
  2.             sep     #$20            ; 8 bit A
  3.  
  4.     ; Wait until the APU is ready to start transferring
  5.  
  6. @Loop:      ldx     $2140
  7.             cpx     #$BBAA
  8.             bne     @Loop
  9.  
  10.     ; Initialize the transfer
  11.  
  12.             ldx     #$0200          ; Transfer data to address $0200 in the APU
  13.             stx     $2142
  14.             lda     #1
  15.             sta     $2141
  16.             lda     #$CC
  17.             sta     $2140
  18. @Loop2:     cmp     $2140
  19.             bne     @Loop2
  20.  
  21.     ; Start transferring the first chunk of the driver
  22.  
  23.             ldx     #0
  24.             ldy     #SPCData1Len
  25.  
  26.             phb                     ; Backup the DBR
  27.  
  28.             lda     #$04            ; Put new value in DBR
  29.             pha
  30.             plb
  31.  
  32. @Next:      lda     SPCData1, x     ; Send next byte of data
  33.             sta     $2141
  34.             txa
  35.             sta     $2140
  36. @Wait:      cmp     $2140           ; Wait for transfer
  37.             bne     @Wait
  38.             inx
  39.             dey
  40.             bne     @Next
  41.  
  42.     ; Continue transferring the second chunk of the driver
  43.  
  44.             ldx     #0
  45.             ldy     #SPCData2Len
  46.  
  47.             lda     #$05            ; Put new value in DBR
  48.             pha
  49.             plb
  50.  
  51. @Next2:     lda     SPCData2, x     ; Send next byte of data
  52.             sta     $2141
  53.             lda     $2140
  54.             inc
  55.             sta     $2140
  56. @Wait2:     cmp     $2140           ; Wait for transfer
  57.             bne     @Wait2
  58.             inx
  59.             dey
  60.             bne     @Next2
  61.  
  62.             plb                     ; Restore the DBR
  63.  
  64.     ; End transfer
  65.  
  66.             ldx     #$0200          ; Starting address of execution
  67.             stx     $2142
  68.  
  69.             stz     $2141           ; Jump to execution address
  70.  
  71.             lda     $2140           ; Break transfer cycle
  72.             adc     #2
  73.             sta     $2140
  74.  
  75. .endmacro
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement