Why not to DMA this?
Posted: Sat Dec 26, 2015 8:42 pm
In a while I'll try to do some effect based in Hblank. First of all I went on analyzing some other code, and this is the code that Sonic the Hedgehog uses for reloading the palette for the water:
Why doesn't it reload the CRAM with DMA? Does it have anything to do with the CRAM dots bug? (oh, and is there any available emulator that shows this behavior?). I really think it has a great purpose, from VBlank the engine just does reload the CRAM with DMA...
What should I take care of, while working with CRAM on HBlank?
Code: Select all
DrawWater:
move #$2700,sr
tst.w (f_hbla_pal).w ; is palette set to change?
beq.s @nochg ; if not, branch
move.w #0,(f_hbla_pal).w
lea ($C00000).l,a1
lea (v_waterpal).w,a0 ; get palette from RAM
move.l #$C0000000,4(a1) ; set VDP to CRAM write
move.l (a0)+,(a1) ; move palette to CRAM
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.l (a0)+,(a1)
move.w #$8A00+223,4(a1) ; reset HBlank register
@nochg:
What should I take care of, while working with CRAM on HBlank?