After watching this video and seeing this can be achieved, https://www.youtube.com/watch?v=nt-AxAqlrOo i was trying to replicate the scrolling floor effect. So i decided to debug that level in regen emulator. After a few minutes i discovered that the game does not use interruptions so i tried to write my version of the code using polling, that looks like it's more accurate than h-interrupts. The idea is to swap 16 colors on only 1 hblank.
Code: Select all
*interrupts are disabled.
LEA $00C00005,A5
LEA $00C00004,A6
LEA $C00008,A1
FNLP
WLN MOVE.B (A5),D0
BTST #3,D0
BEQ.S WLN *wait until vscan = 0
DMA2CR 16,PAL1,0 *load default pallete
BSR DMAWAIT
WLF MOVE.B (A5),D0
BTST #3,D0
BNE.S WLF *wait until vscan = 1 *wait until frame starts drawing
MOVEQ.L #50,D1 *set d1 to 51 just for testing
HD CMP.B #43,(A1) *take a look to hv counter. I wait until line 43 to perform de pallete swap.
BNE.S HD
NL STVDPREG 19,((16)&$ff) *
STVDPREG 20,(((16)>>8)&$ff) *
MOVE.W #$9600+(((PAL2>>1)&$FF00)>>8),(A6)
MOVE.W #$9500+((PAL2>>1)&$FF),(A6)
MOVE.W #$9700+((((PAL2>>1)&$FF0000)>>16)&$7F),(A6)
MOVE.W D5,(a6) *completely crazy here as i dont understand why write values
MOVE.W D5,(a6) * to vdp sometimes looks like it perform faster operations
MOVE.W D5,(a6) * this is just 4 enable displays
MOVE.W D5,(a6)
WL1 MOVE.B (A5),D0
BTST #2,D0
BNE.S WL1 *wait until hscan = 0
MOVE.B (A5),D0
OR.B #%100,D0
MOVE.W #$8000+((1)<<8)|(%00110100),D4 *disable display to d4
MOVE.L #$C0000080|(((0)&$3FFF)<<16)|(((0)&$C000)>>14),D6 *dma destination address to d6
MOVE.W #$8000+((1)<<8)|(%01110100),D5 *enable display to d5
WL CMP.B (A5),D0
BNE.S WL *wait until hscan = 1
MOVE.W D4,(a6) *disable display for faster dma
MOVE.L D6,(a6) *write dma destination. At this moment 16 colors should be updated while the hscan
MOVE.W D5,(a6) *enable display again
STVDPREG 19,((16)&$ff) *write again dma values so i only have to write destination at hblank on the next loop.
STVDPREG 20,(((16)>>8)&$ff) *
MOVE.W #$9600+(((PAL2>>1)&$FF00)>>8),(A6) *write source to vdp
MOVE.W #$9500+((PAL2>>1)&$FF),(A6)
MOVE.W #$9700+((((PAL2>>1)&$FF0000)>>16)&$7F),(A6)
DBRA.W D1,WL1 *repeat process 51 hscans
JMP FNLP *wait until next frame
Thank you.
You can download the rom if you want to have a look at it.
https://uploadfiles.io/lloc6