;------------------------------------------------------------------------------------ TestDMAFillDataPortWritesVRAMText: dc.b 'DP Writes During DMA Fill VRAM ' TestDMAFillDataPortWritesVRAMTextEnd: TestDMAFillDataPortWritesVRAMExpectedResult: ;##FIX## Sometimes on the hardware, both this test and the CRAM test show cases where the extra ;write we expect to be inserted by our control port write doesn't seem to occur, or rather, ;where the write occurs but is entirely overwritten by the DMA fill operation, so the total ;length of the fill is unaltered. dc.w $1234, $1212, $1212, $1212, $1212, $1212, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $1000, $1010 dc.w $1234, $1212, $1212, $1212, $5656, $5656, $0056, $0000, $0000, $0000, $0000, $0000, $1000, $1010, $5000, $5010 dc.w $1234, $1212, $1212, $1212, $9A9A, $9A9A, $9A9A, $0000, $0000, $0000, $1000, $1010, $5000, $5010, $9800, $9010 TestDMAFillDataPortWritesVRAM: ;Initialize the text result block move.w #(TestDMAFillDataPortWritesVRAMTextEnd-TestDMAFillDataPortWritesVRAMText),D7 move.w #4,(A0)+ ;Set the number of display lines move.w D7,(A0)+ ;Set the text length move.w #$0060,D6 ;Set the data length move.w D6,(A0)+ lea TestDMAFillDataPortWritesVRAMText,A1 sub.w #1,D7 TestDMAFillDataPortWritesVRAMWriteText: move.b (A1)+,(A0)+ dbf D7,TestDMAFillDataPortWritesVRAMWriteText move.w #1,(A0)+ ;Set the expected result data present flag lea TestDMAFillDataPortWritesVRAMExpectedResult,A1 ;Write the expected result data to the buffer sub.w #1,D6 TestDMAFillDataPortWritesVRAMWriteExpectedResultData: move.b (A1)+,(A0)+ dbf D6,TestDMAFillDataPortWritesVRAMWriteExpectedResultData ;Clear data in VRAM at 0x8000-0x9000 move.l #$40000002,$C00004 move.w #$07FF,D0 TestDMAFillDataPortWritesVRAMVRAMClearLoop1: move.w #$0000,$C00000 dbf D0,TestDMAFillDataPortWritesVRAMVRAMClearLoop1 ;Wait for the FIFO to be empty TestDMAFillDataPortWritesVRAMWaitFIFOEmpty1: move.w $C00004,D7 btst #9,D7 beq TestDMAFillDataPortWritesVRAMWaitFIFOEmpty1 ;Do a DMA fill operation to VRAM address 0x8000 move.w #$0FFB,D1 move.w #$8F01,$C00004 move.w #$8154,$C00004 move.w #$9300, D2 move.b D1,D2 move.w D2,$C00004 move.w #$9400, D2 lsr.l #8,D1 move.b D1,D2 move.w D2,$C00004 move.w #$9780,$C00004 move.l #$40000082,(A0) ;DMA fill at VRAM address 0x8000 move.l (A0),$C00004 move.w #$1234,$C00000 ;Start DMA fill with 0x1234 ;Wait for the DMA operation to complete TestDMAFillDataPortWritesVRAMDMAWaitLoop1: move.w $C00004,D5 btst #1,D5 bne TestDMAFillDataPortWritesVRAMDMAWaitLoop1 ;Disable DMA, and restore the increment data. move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Read from VRAM at 0x8000 move.l #$00000002,$C00004 move.w $C00000,(A0)+ move.w $C00000,(A0)+ move.w $C00000,(A0)+ move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop ;Read from VRAM at 0x8FF8 move.l #$0FF80002,$C00004 move.w $C00000,(A0)+ move.w $C00000,(A0)+ move.w $C00000,(A0)+ move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop ;Examine the FIFO buffer contents move.l #$00000010,$C00004 ;Read from VSRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop move.l #$00000020,$C00004 ;Read from CRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop move.l #$C0200000,$C00004 ;Advance the FIFO buffer move.w #$FFFF,$C00000 move.l #$00000010,$C00004 ;Read from VSRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop move.l #$00000020,$C00004 ;Read from CRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop move.l #$C0200000,$C00004 ;Advance the FIFO buffer move.w #$FFFF,$C00000 move.l #$00000010,$C00004 ;Read from VSRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop move.l #$00000020,$C00004 ;Read from CRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop move.l #$C0200000,$C00004 ;Advance the FIFO buffer move.w #$FFFF,$C00000 move.l #$00000010,$C00004 ;Read from VSRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop move.l #$00000020,$C00004 ;Read from CRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop ;Clear data in VRAM at 0x8000-0x9000 move.l #$40000002,$C00004 move.w #$07FF,D0 TestDMAFillDataPortWritesVRAMVRAMClearLoop2: move.w #$0000,$C00000 dbf D0,TestDMAFillDataPortWritesVRAMVRAMClearLoop2 ;Wait for the FIFO to be empty TestDMAFillDataPortWritesVRAMWaitFIFOEmpty2: move.w $C00004,D7 btst #9,D7 beq TestDMAFillDataPortWritesVRAMWaitFIFOEmpty2 ;Wait for the start of active scan. We do this so that we can predict the length of ;time the DMA operation will run for. TestDMAFillDataPortWritesVRAMWaitVBlankSet2: move.w $C00004,D7 btst #3,D7 beq TestDMAFillDataPortWritesVRAMWaitVBlankSet2 TestDMAFillDataPortWritesVRAMWaitVBlankClear2: move.w $C00004,D7 btst #3,D7 bne TestDMAFillDataPortWritesVRAMWaitVBlankClear2 ;Do a DMA fill operation to VRAM address 0x8000 move.w #$0FFB,D1 move.w #$8F01,$C00004 move.w #$8154,$C00004 move.w #$9300, D2 move.b D1,D2 move.w D2,$C00004 move.w #$9400, D2 lsr.l #8,D1 move.b D1,D2 move.w D2,$C00004 move.w #$9780,$C00004 move.l #$40000082,(A0) ;DMA fill at VRAM address 0x8000 move.l (A0),$C00004 move.w #$1234,$C00000 ;Start DMA fill with 0x1234 ;Add a small delay loop, to give the DMA fill operation a chance to run a little way along move.w #$0020,D7 TestDMAFillDataPortWritesVRAMDelayLoop: dbf D7,TestDMAFillDataPortWritesVRAMDelayLoop ;Perform a data port write during the DMA fill operation. This should update the fill ;data being used. move.w #$5678,$C00000 ;Wait for the DMA operation to complete TestDMAFillDataPortWritesVRAMDMAWaitLoop2: move.w $C00004,D5 btst #1,D5 bne TestDMAFillDataPortWritesVRAMDMAWaitLoop2 ;Disable DMA, and restore the increment data. move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Read from VRAM at 0x8000 move.l #$00000002,$C00004 move.w $C00000,(A0)+ move.w $C00000,(A0)+ move.w $C00000,(A0)+ move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop ;Read from VRAM at 0x8FF8 move.l #$0FF80002,$C00004 move.w $C00000,(A0)+ move.w $C00000,(A0)+ move.w $C00000,(A0)+ move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop ;Examine the FIFO buffer contents move.l #$00000010,$C00004 ;Read from VSRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop move.l #$00000020,$C00004 ;Read from CRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop move.l #$C0200000,$C00004 ;Advance the FIFO buffer move.w #$FFFF,$C00000 move.l #$00000010,$C00004 ;Read from VSRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop move.l #$00000020,$C00004 ;Read from CRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop move.l #$C0200000,$C00004 ;Advance the FIFO buffer move.w #$FFFF,$C00000 move.l #$00000010,$C00004 ;Read from VSRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop move.l #$00000020,$C00004 ;Read from CRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop move.l #$C0200000,$C00004 ;Advance the FIFO buffer move.w #$FFFF,$C00000 move.l #$00000010,$C00004 ;Read from VSRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop move.l #$00000020,$C00004 ;Read from CRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop ;Clear data in VRAM at 0x8000-0x9000 move.l #$40000002,$C00004 move.w #$07FF,D0 TestDMAFillDataPortWritesVRAMVRAMClearLoop3: move.w #$0000,$C00000 dbf D0,TestDMAFillDataPortWritesVRAMVRAMClearLoop3 ;Wait for the FIFO to be empty TestDMAFillDataPortWritesVRAMWaitFIFOEmpty3: move.w $C00004,D7 btst #9,D7 beq TestDMAFillDataPortWritesVRAMWaitFIFOEmpty3 ;Wait for the start of active scan. We do this so that we can predict the length of ;time the DMA operation will run for. TestDMAFillDataPortWritesVRAMWaitVBlankSet3: move.w $C00004,D7 btst #3,D7 beq TestDMAFillDataPortWritesVRAMWaitVBlankSet3 TestDMAFillDataPortWritesVRAMWaitVBlankClear3: move.w $C00004,D7 btst #3,D7 bne TestDMAFillDataPortWritesVRAMWaitVBlankClear3 ;Do a DMA fill operation to VRAM address 0x8000 move.w #$0FFB,D1 move.w #$8F01,$C00004 move.w #$8154,$C00004 move.w #$9300, D2 move.b D1,D2 move.w D2,$C00004 move.w #$9400, D2 lsr.l #8,D1 move.b D1,D2 move.w D2,$C00004 move.w #$9780,$C00004 move.l #$40000082,(A0) ;DMA fill at VRAM address 0x8000 move.l (A0),$C00004 move.w #$1234,$C00000 ;Start DMA fill with 0x1234 ;Add a small delay loop, to give the DMA fill operation a chance to run a little way along move.w #$0020,D7 TestDMAFillDataPortWritesVRAMDelayLoop2: dbf D7,TestDMAFillDataPortWritesVRAMDelayLoop2 ;Perform two data port writes during the DMA fill operation. This should update the fill ;data being used twice. move.w #$5678,$C00000 move.w #$0020,D7 TestDMAFillDataPortWritesVRAMDelayLoop3: dbf D7,TestDMAFillDataPortWritesVRAMDelayLoop3 move.w #$9ABC,$C00000 ;Wait for the DMA operation to complete TestDMAFillDataPortWritesVRAMDMAWaitLoop3: move.w $C00004,D5 btst #1,D5 bne TestDMAFillDataPortWritesVRAMDMAWaitLoop3 ;Disable DMA, and restore the increment data. move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Read from VRAM at 0x8000 move.l #$00000002,$C00004 move.w $C00000,(A0)+ move.w $C00000,(A0)+ move.w $C00000,(A0)+ move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop ;Read from VRAM at 0x8FF8 move.l #$0FF80002,$C00004 move.w $C00000,(A0)+ move.w $C00000,(A0)+ move.w $C00000,(A0)+ move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop ;Examine the FIFO buffer contents move.l #$00000010,$C00004 ;Read from VSRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop move.l #$00000020,$C00004 ;Read from CRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop move.l #$C0200000,$C00004 ;Advance the FIFO buffer move.w #$FFFF,$C00000 move.l #$00000010,$C00004 ;Read from VSRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop move.l #$00000020,$C00004 ;Read from CRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop move.l #$C0200000,$C00004 ;Advance the FIFO buffer move.w #$FFFF,$C00000 move.l #$00000010,$C00004 ;Read from VSRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop move.l #$00000020,$C00004 ;Read from CRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop move.l #$C0200000,$C00004 ;Advance the FIFO buffer move.w #$FFFF,$C00000 move.l #$00000010,$C00004 ;Read from VSRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop move.l #$00000020,$C00004 ;Read from CRAM move.w $C00000,(A0)+ nop ;Wait for a few cycles after a read before modifying any VDP settings. On the nop ;real hardware, if a control port write occurs immediately after a data port nop ;read, the VDP can lock up. Most likely, this occurs due to the read target nop ;being modified to an invalid target before a read pre-cache is complete. nop nop nop nop nop nop ;Clear data in VRAM at 0x8000-0x9000 move.l #$40000002,$C00004 move.w #$07FF,D0 TestDMAFillDataPortWritesVRAMVRAMClearLoop4: move.w #$0000,$C00000 dbf D0,TestDMAFillDataPortWritesVRAMVRAMClearLoop4 rts