Advertisement
Guest User

Untitled

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