
RAM_Waveform EQU $FF0500
RAM_SPRTABLE: EQU $FF1000
waveform:
    

    singledmacram wpal, 32, 32, vdpcontrol
    singledmavram wtiles, 32, 64, vdpcontrol
    singledmavram wmap, $E000+64*2*0, 64*2*2, vdpcontrol

    move.w #$8B00|%00000100, vdpcontrol
    
    
    
@getwave
    move.l d7, -(sp)
    lea  $a011f0, a1
    lea  RAM_WAVEFORM, a0
    rept 16
    Echo_Z80Request
    move.b (a1), (a0)+
    Echo_Z80Release
    move.w #500, d7
    jsr delayD7
    endr
    move.w #$8F04, vdpcontrol
    move.w #16, d7
    setvsramaddr 2, vdpcontrol
    lea (RAM_WAVEFORM), a0
@waveparse
    
    move.b (a0)+, d0
    and.w #$00FF, d0
    
    lsr.b #1, d0
    add.w #$60, d0
    
;    sub.w #$80, d0
;    neg.w d0
    move.w d0, (vdpdata)
    dbf d7, @waveparse
    
    waitframe 
    move.l (sp)+, d7
    
    move.w #$8F02, vdpcontrol
    bra.w @getwave
    
    jmp *
    
    rts
DelayD7:
    nop
    dbf d7, delayd7
    rts
wmap:

    rept 64
    dc.w 1|%0010000000000000
    endr
    rept 64
    dc.w 2|%0010000000000000
    endr
    
wtiles:

    hex 11111111
    hex 22222222
    hex 33333333
    hex 44444444
    hex 55555555
    hex 66666666
    hex 77777777
    hex 88888888
    
    hex 88888888
    hex 99999999
    hex aaaaaaaa
    hex bbbbbbbb
    hex cccccccc
    hex dddddddd
    hex eeeeeeee
    hex ffffffff

        align 131072
wpal:
    hex 00000222024404440446066606880888
    hex 088a0aaa0abb0bbb0bbc0ccc0cdd0ddd