
FixedDMACRAM: macro src, dest, len
    dc.l  #$94009300|(((\len)<<7)&$FF0000)|(((\len)>>1)&$FF)
    dc.l  #$96009500|(((\src)<<7)&$FF0000)|(((\src)>>1)&$FF)
    dc.w  #$9700|(((\src)>>17)&$FF)
    dc.l  #$C0000080|((\dest)&$3FFF)<<16|(\dest)>>14
    endm

ReloadHBL:
	move.w #$8114, VDPCONTROL
	move.l (a6)+, VDPCONTROL
	move.l (a6)+, VDPCONTROL
	move.w (a6)+, VDPCONTROL
	move.l (a6)+, VDPCONTROL
	move.w #$8174, VDPCONTROL
	rte
ReloadHBL_End:

ReloadVBL:
	lea 8*2(a5), a5
	lea a5, a6
	bra.s RELOADHBL
	rte
	


	
PalPix:
	move.w #$9001, VDPCONTROL
    disableints
		move.l #reloadVBL, (RAM_VINTLOC+2)
        lea (ReloadHBL), a0
        lea (RAM_HInt), a1
        move.l #((reloadHBL_End-ReloadHBL)/2)-1,d0   
@CopyHINT:
        move.w (a0)+, (a1)+
        dbf d0, @CopyHINT 
	
	singledmavram Megascrolltiles, 32, 40*32, VDPCONTROL
	lea DMATABLE, a5
	enableints
	
	jmp *
	rts
	
DMATable:
x = 0

	rept 512
		rept 24
			Fixeddmacram MegaScroll+32*x, 0, 32
		endr
x = x+1
	endr
	
	even
	

Megascroll:
	incbin ./palpix/palpix.pal
	even
MegascrollTiles:
	incbin ./palpix/palpix.bin
	even
	

PalPixMap:
x = 0
	rept 32
	rept 40
		
		dc.w x+1
x = x+1
	endr
	rept 24
		dc.w 0
	endr
	endr
	endr