Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     include "pgsdz80_support.asm"
  2.  
  3. ; LoadPGSD [TODO add a0/a1 as DAC tables ptrs]
  4. LoadPGSD:
  5.     movem.l d0/a0/a1,-(sp)
  6.  
  7.     move.w  #$100,($A11100).l                   ; bus req on
  8.     move.w  #$100,($A11200).l                   ; reset off
  9.    
  10.     lea     __PGSDZ80,a0
  11.     move.l  #$A00000,a1
  12.     move.w  #__PGSDZ80End-__PGSDZ80,d0      ; TODO -1?
  13. -
  14.     move.b  (a0)+,(a1)+
  15.     dbf     d0,-
  16.  
  17.     move.b  ($A10001).l,d0                      ; get flag state for NTSC/PAL
  18.     move.b  d0,(__PGSD_NewPlaying).l
  19.  
  20.     move.b  #0,(__PGSD_PointerFrom68000).l  ; keep this unset for the handshake
  21.  
  22.     move.w  #0,($A11200).l                      ; START THE Z80: reset on
  23.     move.w  #0,($A11100).l                      ; bus req off
  24.     move.w  #$100,($A11200).l                   ; reset off - Z80 STARTS
  25.  
  26.     ; now to actually handshake
  27. $$handshake:
  28.     move.w  #$100,($A11100).l                   ; bus req on
  29. $$handshake_waitbusreq:
  30.     btst.b  #0,($A11100).l
  31.     bne.s   $$handshake_waitbusreq
  32.     tst.b   (__PGSD_PointerFrom68000).l     ; is it zero?
  33.     beq.s   $$handshake_keeptrying          ; yep; keep handshaking
  34.     move.b  #0,(__PGSD_PointerFrom68000).l  ; NOPE! WE'RE READY TO GO
  35.     move.w  #0,($A11100).l                      ; bus req off
  36.     movem.l (sp)+,d0/a0/a1                      ; and return.
  37.     rts
  38. $$handshake_keeptrying:
  39.     move.w  #0,($A11100).l                      ; bus req off
  40.     bra.s   $$handshake
  41.  
  42. ; PlaySong (a0 -- ) - play song at address a0
  43. PlaySong:
  44.     movem.l d0/a0/a1,-(sp)
  45.  
  46.     move.w  #$100,($A11100).l               ; bus req on
  47. -
  48.     btst.b  #0,($A11100).l
  49.     bne.s   -
  50.  
  51.     move.l  a0,d0
  52.     move.l  #__PGSD_PointerFrom68000,a1 ; write pointer
  53.     move.b  d0,(a1)
  54.     REPT 3
  55.     sub.l   #1,a1
  56.     lsr.l   #4,d0
  57.     move.b  d0,(a1)
  58.     ENDM
  59.     move.b  #1,(__PGSD_NewPlaying).l        ; mark to play music!
  60.  
  61.     move.w  #0,($A11100).l                  ; bus req off
  62.  
  63.     movem.l (sp)+,d0/a0/a1
  64.     rts
  65.  
  66. ; PlaySFX (a0 -- ) - play SFX at address a0
  67. PlaySFX:
  68.     ; TODO
  69.     rts
  70.  
  71. __PGSDZ80:
  72.     binclude    "pgsdz80.bin"
  73. __PGSDZ80End:
  74.  
  75. ; and the handshake code Z80 side is simple:
  76.     ld      hl,PointerFrom68000
  77.     ld      (hl),$FF            ; set it to $FF
  78.     xor     a
  79. -
  80.     cp      (hl)                ; the 68000 sees the $FF and sets it to 0
  81.     jr      nz,-
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement