;------------------------------------------------------------------------------------ TestDMAFillDataPortWritesVSRAMText: dc.b 'DP Writes During DMA Fill VSRAM ' TestDMAFillDataPortWritesVSRAMTextEnd: TestDMAFillDataPortWritesVSRAMExpectedResult: dc.w $0444, $0444, $0444, $0444, $0444, $0444, $0000, $0000, $0444, $0000, $0444, $0000, $0C44, $0000, $0C44, $0000 dc.w $0444, $0444, $0444, $0444, $0666, $0666, $0666, $0000, $0444, $0000, $0C44, $0000, $0C44, $0000, $0C44, $0000 dc.w $0C44, $0C44, $0C44, $0C44, $0888, $0888, $0888, $0800, $0C44, $0000, $0C44, $0000, $0C44, $0000, $0C44, $0000 TestDMAFillDataPortWritesVSRAM: ;Initialize the text result block move.w #(TestDMAFillDataPortWritesVSRAMTextEnd-TestDMAFillDataPortWritesVSRAMText),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 TestDMAFillDataPortWritesVSRAMText,A1 sub.w #1,D7 TestDMAFillDataPortWritesVSRAMWriteText: move.b (A1)+,(A0)+ dbf D7,TestDMAFillDataPortWritesVSRAMWriteText move.w #1,(A0)+ ;Set the expected result data present flag lea TestDMAFillDataPortWritesVSRAMExpectedResult,A1 ;Write the expected result data to the buffer sub.w #1,D6 TestDMAFillDataPortWritesVSRAMWriteExpectedResultData: move.b (A1)+,(A0)+ dbf D6,TestDMAFillDataPortWritesVSRAMWriteExpectedResultData ;Clear data in VSRAM move.l #$40000010,$C00004 move.w #$003F,D0 TestDMAFillDataPortWritesVSRAMClearLoop1: move.w #$0000,$C00000 dbf D0,TestDMAFillDataPortWritesVSRAMClearLoop1 ;Perform some writes to VRAM at 0x8000, just to fill the FIFO buffer with some data. move.l #$40000002,$C00004 move.w #$0222,$C00000 move.w #$0444,$C00000 move.w #$0666,$C00000 move.w #$0888,$C00000 ;Wait for the FIFO to be empty TestDMAFillDataPortWritesVSRAMWaitFIFOEmpty1: move.w $C00004,D7 btst #9,D7 beq TestDMAFillDataPortWritesVSRAMWaitFIFOEmpty1 ;Do a DMA fill operation to VSRAM move.w #$003B,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 #$40000090,(A0) ;DMA fill at VSRAM address 0x0 move.l (A0),$C00004 move.w #$0AAA,$C00000 ;Start DMA fill with 0x0AAA ;Wait for the DMA operation to complete TestDMAFillDataPortWritesVSRAMDMAWaitLoop1: move.w $C00004,D5 btst #1,D5 bne TestDMAFillDataPortWritesVSRAMDMAWaitLoop1 ;Disable DMA, and restore the increment data. move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Read from VSRAM at 0x0 move.l #$00000010,$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 VSRAM at 0x38 move.l #$00380010,$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 VSRAM move.l #$40000010,$C00004 move.w #$003F,D0 TestDMAFillDataPortWritesVSRAMClearLoop2: move.w #$0000,$C00000 dbf D0,TestDMAFillDataPortWritesVSRAMClearLoop2 ;Perform some writes to VRAM at 0x8000, just to fill the FIFO buffer with some data. move.l #$40000002,$C00004 move.w #$0222,$C00000 move.w #$0444,$C00000 move.w #$0666,$C00000 move.w #$0888,$C00000 ;Wait for the FIFO to be empty TestDMAFillDataPortWritesVSRAMWaitFIFOEmpty2: move.w $C00004,D7 btst #9,D7 beq TestDMAFillDataPortWritesVSRAMWaitFIFOEmpty2 ;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. TestDMAFillDataPortWritesVSRAMWaitVBlankSet2: move.w $C00004,D7 btst #3,D7 beq TestDMAFillDataPortWritesVSRAMWaitVBlankSet2 TestDMAFillDataPortWritesVSRAMWaitVBlankClear2: move.w $C00004,D7 btst #3,D7 bne TestDMAFillDataPortWritesVSRAMWaitVBlankClear2 ;Do a DMA fill operation to VSRAM move.w #$003B,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 #$40000090,(A0) ;DMA fill at VSRAM address 0x0 move.l (A0),$C00004 move.w #$0AAA,$C00000 ;Start DMA fill with 0x0AAA ;Add a small delay loop, to give the DMA fill operation a chance to run a little way along move.w #$0018,D7 TestDMAFillDataPortWritesVSRAMDelayLoop: dbf D7,TestDMAFillDataPortWritesVSRAMDelayLoop ;Perform a data port write during the DMA fill operation. This should update the fill ;data being used. move.w #$0CCC,$C00000 ;Wait for the DMA operation to complete TestDMAFillDataPortWritesVSRAMDMAWaitLoop2: move.w $C00004,D5 btst #1,D5 bne TestDMAFillDataPortWritesVSRAMDMAWaitLoop2 ;Disable DMA, and restore the increment data. move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Read from VSRAM at 0x0 move.l #$00000010,$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 VSRAM at 0x38 move.l #$00380010,$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 VSRAM move.l #$40000010,$C00004 move.w #$003F,D0 TestDMAFillDataPortWritesVSRAMClearLoop3: move.w #$0000,$C00000 dbf D0,TestDMAFillDataPortWritesVSRAMClearLoop3 ;Perform some writes to VRAM at 0x8000, just to fill the FIFO buffer with some data. move.l #$40000002,$C00004 move.w #$0222,$C00000 move.w #$0444,$C00000 move.w #$0666,$C00000 move.w #$0888,$C00000 ;Wait for the FIFO to be empty TestDMAFillDataPortWritesVSRAMWaitFIFOEmpty3: move.w $C00004,D7 btst #9,D7 beq TestDMAFillDataPortWritesVSRAMWaitFIFOEmpty3 ;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. TestDMAFillDataPortWritesVSRAMWaitVBlankSet3: move.w $C00004,D7 btst #3,D7 beq TestDMAFillDataPortWritesVSRAMWaitVBlankSet3 TestDMAFillDataPortWritesVSRAMWaitVBlankClear3: move.w $C00004,D7 btst #3,D7 bne TestDMAFillDataPortWritesVSRAMWaitVBlankClear3 ;Do a DMA fill operation to VSRAM move.w #$003B,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 #$40000090,(A0) ;DMA fill at VSRAM address 0x0 move.l (A0),$C00004 move.w #$0AAA,$C00000 ;Start DMA fill with 0x0AAA ;Add a small delay loop, to give the DMA fill operation a chance to run a little way along move.w #$0018,D7 TestDMAFillDataPortWritesVSRAMDelayLoop2: dbf D7,TestDMAFillDataPortWritesVSRAMDelayLoop2 ;Perform two data port writes during the DMA fill operation. This should update the fill ;data being used twice. move.w #$0CCC,$C00000 move.w #$0001,D7 TestDMAFillDataPortWritesVSRAMDelayLoop3: dbf D7,TestDMAFillDataPortWritesVSRAMDelayLoop3 move.w #$0EEE,$C00000 ;Wait for the DMA operation to complete TestDMAFillDataPortWritesVSRAMDMAWaitLoop3: move.w $C00004,D5 btst #1,D5 bne TestDMAFillDataPortWritesVSRAMDMAWaitLoop3 ;Disable DMA, and restore the increment data. move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Read from VSRAM at 0x0 move.l #$00000010,$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 VSRAM at 0x38 move.l #$00380010,$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 VSRAM move.l #$40000010,$C00004 move.w #$003F,D0 TestDMAFillDataPortWritesVSRAMClearLoop4: move.w #$0000,$C00000 dbf D0,TestDMAFillDataPortWritesVSRAMClearLoop4 rts