;------------------------------------------------------------------------------------ ;##NOTE## We know from developing this test that when the data port is written to, it ;does cause the actual write to be performed at the current incremented address that ;the fill operation is up to. ;------------------------------------------------------------------------------------ TestDMAFillDataPortWritesCRAMText: dc.b 'DP Writes During DMA Fill CRAM ' TestDMAFillDataPortWritesCRAMTextEnd: TestDMAFillDataPortWritesCRAMExpectedResult: dc.w $0444, $0444, $0444, $0444, $0444, $0444, $0000, $0000, $0000, $0444, $0000, $0444, $0800, $0444, $0800, $0444 dc.w $0444, $0444, $0444, $0444, $0666, $0666, $0666, $0000, $0000, $0444, $0800, $0444, $0800, $0444, $0800, $0444 dc.w $0444, $0444, $0444, $0444, $0888, $0888, $0888, $0000, $0800, $0444, $0800, $0444, $0800, $0444, $0800, $0444 TestDMAFillDataPortWritesCRAM: ;Initialize the text result block move.w #(TestDMAFillDataPortWritesCRAMTextEnd-TestDMAFillDataPortWritesCRAMText),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 TestDMAFillDataPortWritesCRAMText,A1 sub.w #1,D7 TestDMAFillDataPortWritesCRAMWriteText: move.b (A1)+,(A0)+ dbf D7,TestDMAFillDataPortWritesCRAMWriteText move.w #1,(A0)+ ;Set the expected result data present flag lea TestDMAFillDataPortWritesCRAMExpectedResult,A1 ;Write the expected result data to the buffer sub.w #1,D6 TestDMAFillDataPortWritesCRAMWriteExpectedResultData: move.b (A1)+,(A0)+ dbf D6,TestDMAFillDataPortWritesCRAMWriteExpectedResultData ;Clear data in CRAM move.l #$C0000000,$C00004 move.w #$003F,D0 TestDMAFillDataPortWritesCRAMClearLoop1: move.w #$0000,$C00000 dbf D0,TestDMAFillDataPortWritesCRAMClearLoop1 ;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 TestDMAFillDataPortWritesCRAMWaitFIFOEmpty1: move.w $C00004,D7 btst #9,D7 beq TestDMAFillDataPortWritesCRAMWaitFIFOEmpty1 ;Do a DMA fill operation to CRAM 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 #$C0000080,(A0) ;DMA fill at CRAM address 0x0 move.l (A0),$C00004 move.w #$0AAA,$C00000 ;Start DMA fill with 0x0AAA ;Wait for the DMA operation to complete TestDMAFillDataPortWritesCRAMDMAWaitLoop1: move.w $C00004,D5 btst #1,D5 bne TestDMAFillDataPortWritesCRAMDMAWaitLoop1 ;Disable DMA, and restore the increment data. move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Read from CRAM at 0x0 move.l #$00000020,$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 CRAM at 0x38 move.l #$00380020,$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 CRAM move.l #$C0000000,$C00004 move.w #$003F,D0 TestDMAFillDataPortWritesCRAMClearLoop2: move.w #$0000,$C00000 dbf D0,TestDMAFillDataPortWritesCRAMClearLoop2 ;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 TestDMAFillDataPortWritesCRAMWaitFIFOEmpty2: move.w $C00004,D7 btst #9,D7 beq TestDMAFillDataPortWritesCRAMWaitFIFOEmpty2 ;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. TestDMAFillDataPortWritesCRAMWaitVBlankSet2: move.w $C00004,D7 btst #3,D7 beq TestDMAFillDataPortWritesCRAMWaitVBlankSet2 TestDMAFillDataPortWritesCRAMWaitVBlankClear2: move.w $C00004,D7 btst #3,D7 bne TestDMAFillDataPortWritesCRAMWaitVBlankClear2 ;Do a DMA fill operation to CRAM 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 #$C0000080,(A0) ;DMA fill at CRAM 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 TestDMAFillDataPortWritesCRAMDelayLoop: dbf D7,TestDMAFillDataPortWritesCRAMDelayLoop ;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 TestDMAFillDataPortWritesCRAMDMAWaitLoop2: move.w $C00004,D5 btst #1,D5 bne TestDMAFillDataPortWritesCRAMDMAWaitLoop2 ;Disable DMA, and restore the increment data. move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Read from CRAM at 0x0 move.l #$00000020,$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 CRAM at 0x38 move.l #$00380020,$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 CRAM move.l #$C0000000,$C00004 move.w #$003F,D0 TestDMAFillDataPortWritesCRAMClearLoop3: move.w #$0000,$C00000 dbf D0,TestDMAFillDataPortWritesCRAMClearLoop3 ;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 TestDMAFillDataPortWritesCRAMWaitFIFOEmpty3: move.w $C00004,D7 btst #9,D7 beq TestDMAFillDataPortWritesCRAMWaitFIFOEmpty3 ;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. TestDMAFillDataPortWritesCRAMWaitVBlankSet3: move.w $C00004,D7 btst #3,D7 beq TestDMAFillDataPortWritesCRAMWaitVBlankSet3 TestDMAFillDataPortWritesCRAMWaitVBlankClear3: move.w $C00004,D7 btst #3,D7 bne TestDMAFillDataPortWritesCRAMWaitVBlankClear3 ;Do a DMA fill operation to CRAM 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 #$C0000080,(A0) ;DMA fill at CRAM 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 TestDMAFillDataPortWritesCRAMDelayLoop2: dbf D7,TestDMAFillDataPortWritesCRAMDelayLoop2 ;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 TestDMAFillDataPortWritesCRAMDelayLoop3: dbf D7,TestDMAFillDataPortWritesCRAMDelayLoop3 move.w #$0EEE,$C00000 ;Wait for the DMA operation to complete TestDMAFillDataPortWritesCRAMDMAWaitLoop3: move.w $C00004,D5 btst #1,D5 bne TestDMAFillDataPortWritesCRAMDMAWaitLoop3 ;Disable DMA, and restore the increment data. move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Read from CRAM at 0x0 move.l #$00000020,$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 CRAM at 0x38 move.l #$00380020,$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 CRAM move.l #$C0000000,$C00004 move.w #$003F,D0 TestDMAFillDataPortWritesCRAMClearLoop4: move.w #$0000,$C00000 dbf D0,TestDMAFillDataPortWritesCRAMClearLoop4 rts