;##NOTE## When we didn't have wait states after VSRAM reads in this test, we saw VDP ;lockups, but not such that a reset didn't work, and we saw the case of the palette select ;bit apparently being cleared in register 0. Note that further testing indicates the lockup ;wasn't VDP related, but was caused by a bug in our code. ;##NOTE## First tests don't work, seems like disabling the display doesn't stop VSRAM ;reads by render process. Line 3 works correctly, with tests in line 4 working most of the ;time, but some start values failing sometimes. ;##NOTE## The "Genesis 3" behaves differently. It appears to have an 0x80 byte VSRAM, with ;reads and writes to otherwise invalid addresses in VSRAM correctly returning the written ;data. We also saw the "Genesis 3" get a different result for the 8-bit VRAM read target ;test. ;##NOTE## H32 mode is also returning values $056E and $0266, which we only expected to be ;returned in H40 mode. ;##TODO## In order to actually test whether VSRAM reads and writes affect the data cache, ;we probably have to perform both accesses to VRAM after the very last VSRAM render read ;on a line, but before the first read on the next line. The hblank flag is the best way to ;find this point, although this does leave us with wasted time. We may have to poll the ;hcounter instead, although we may lose more time than we gain by doing this. ;Test 1 - Normal VSRAM reads and writes ;Test 2 - VSRAM reads off end of VSRAM using last read value ;Test 3 - Writes to valid VSRAM addresses overwrite VSRAM read cache ;Test 4 - Writes to invalid VSRAM addresses overwrite VSRAM read cache ;Test 5 - Disable display register doesn't prevent VSRAM reads during rendering ;Test 6 - Undocumented Reg 1 Bit 0 set doesn't prevent VSRAM reads during rendering ;Test 7 - VSRAM data cache not modified by rendering outside active scan ;Test 8 - Same as the above, except test with render VSRAM reads happening after our writes ;Test 9 - VSRAM data cache actively modified by rendering during active scan - Overall H32 ;Test 10 - VSRAM data cache actively modified by rendering during active scan - Overall H40 ;Test 11 - Final VSRAM data cache value during vblank - H32 ;Test 12 - Final VSRAM data cache value during vblank - H40 ;Test 13 - VSRAM data cache actively modified by rendering during active scan - 2-cell scroll H32 ;Test 14 - VSRAM data cache actively modified by rendering during active scan - 2-cell scroll H40 ;Expected results 2012-11-14 ;dc.w $0000, $0111, $0222, $0333, $0444, $0555, $0666, $0777, $0000, $0111, $0222, $0333, $0333, $0333, $0333, $0333 ;dc.w $0000, $0111, $0222, $0333, $0456, $0456, $0456, $0456, $0000, $0111, $0222, $0333, $0456, $0456, $0456, $0456 ;dc.w $0000, $0111, $0222, $0333, $0765, $0765, $0765, $0765, $0000, $0111, $0222, $0333, $0765, $0765, $0765, $0765 ;dc.w $0000, $0111, $0222, $0333, $0333, $0333, $0333, $0333, $0000, $0111, $0222, $0333, $0333, $0333, $0333, $0333 ;dc.w $0000, $0111, $0222, $0333, $0456, $0456, $0456, $0456, $0000, $0111, $0222, $0333, $0456, $0456, $0456, $0456 ;dc.w $0000, $0111, $0222, $0333, $0765, $0765, $0765, $0765, $0000, $0111, $0222, $0333, $0765, $0765, $0765, $0765 ;dc.w $01EE, $03EA, $05E6, $02CE, $04CA, $06C6, $03AE, $05AA, $07A6, $048E, $068A, $0186, $0480, $0000, $0000, $0000 ;dc.w $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 ;dc.w $01EE, $03EA, $05E6, $02CE, $04CA, $06C6, $03AE, $05AA, $07A6, $048E, $068A, $0186, $056E, $076A, $0266, $0560 ;dc.w $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 ;Actual results 2012-11-14 ;dc.w $0000, $0111, $0222, $0333, $0444, $0555, $0666, $0777, $0000, $0111, $0222, $0333, $****, $****, $****, $**** ;dc.w $0000, $0111, $0222, $0333, $****, $****, $****, $****, $0000, $0111, $0222, $0333, $****, $****, $****, $**** ;dc.w $0000, $0111, $0222, $0333, $0765, $0765, $0765, $0765, $0000, $0111, $0222, $0333, $0765, $0765, $0765, $0765 ;dc.w $0000, $0111, $0222, $0333, $****, $****, $****, $****, $0000, $0111, $0222, $0333, $****, $****, $****, $**** ;dc.w $0000, $0111, $0222, $0333, $0456, $0456, $0456, $0456, $0000, $0111, $0222, $0333, $0456, $0456, $0456, $0456 ;dc.w $0000, $0111, $0222, $0333, $****, $****, $****, $****, $0000, $0111, $0222, $0333, $****, $****, $****, $**** ;dc.w $01EE, $03EA, $05E6, $02CE, $04CA, $06C6, $03AE, $05AA, $07A6, $048E, $068A, $0186,!$0000, $0000, $0000, $0000 ;dc.w!$0266,!$056E, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 ;dc.w!$0000, $03EA, $05E6, $02CE, $04CA, $06C6, $03AE, $05AA, $07A6, $048E, $068A, $0186, $056E, $076A, $0266,!$0000 ;dc.w!$0100,!$0460, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 ;----------------------------------------------------------------------------------------- TestVSRAMDataCacheNewText: dc.b 'VSRAM Data Cache ' TestVSRAMDataCacheNewTextEnd: TestVSRAMDataCacheNewExpectedResult: ;Test 1 - Normal VSRAM reads and writes ;Test 2 - VSRAM reads off end of VSRAM using last read value ;Test 3 - Writes to valid VSRAM addresses overwrite VSRAM read cache ;Test 4 - Writes to invalid VSRAM addresses overwrite VSRAM read cache ;Test 5 - Disable display register doesn't prevent VSRAM reads during rendering ;Test 6 - Undocumented Reg 1 Bit 0 set doesn't prevent VSRAM reads during rendering ;Test 7 - VSRAM data cache not modified by rendering outside active scan ;Test 8 - Same as the above, except test with render VSRAM reads happening after our writes ;Test 9 - VSRAM data cache actively modified by rendering during active scan - Overall H32 ;Test 10 - VSRAM data cache actively modified by rendering during active scan - Overall H40 ;Test 11 - Final VSRAM data cache value during vblank - H32 ;Test 12 - Final VSRAM data cache value during vblank - H40 ;Test 13 - VSRAM data cache actively modified by rendering during active scan - 2-cell scroll H32 ;Test 14 - VSRAM data cache actively modified by rendering during active scan - 2-cell scroll H40 ;Tests 2,3,4,7,8,11,12 dont give expected results. Tests 13 and 14 still lock up. ;Tests 2, 3, and 4 change between 0321 and 0765 ;Tests 11 and 12 both exhibit alternations between 0x0444, 0x0456, and 0x0765. Test 12 was observed with pattern 0x0456, 0x0444, 0x0456, 0x0444. ;Running tests 13 and 14, the last value is never read, and we do get unexpected read values. ; dc.w $0000, $0111, $0222, $0333, $0444, $0555, $0666, $0777, $0000, $0111, $0222, $0333, $0321, $0765, $0765, $0765 ; dc.w $0000, $0111, $0222, $0333, $0321, $0765, $0765, $0765, $0000, $0111, $0222, $0333, $0321, $0765, $0765, $0765 ; dc.w $0000, $0111, $0222, $0333, $0765, $0765, $0765, $0765, $0000, $0111, $0222, $0333, $0765, $0765, $0765, $0765 ; dc.w $0000, $0111, $0222, $0333, $0321, $0321, $0321, $0765, $0000, $0111, $0222, $0333, $0321, $0321, $0321, $0321 ; dc.w $0000, $0111, $0222, $0333, $0456, $0456, $0456, $0456, $0000, $0111, $0222, $0333, $0456, $0456, $0456, $0456 ; dc.w $0000, $0111, $0222, $0333, $0456, $0765, $0465, $0765, $0000, $0111, $0222, $0333, $0444, $0765, $0456, $0444 ; dc.w $01EE, $03EA, $05E6, $02CE, $04CA, $06C6, $03AE, $05AA, $07A6, $048E, $068A, $0186, $0480, $0000, $0000, $0000 ; dc.w $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 ; dc.w $01EE, $03EA, $05E6, $02CE, $04CA, $06C6, $03AE, $05AA, $07A6, $048E, $068A, $0186, $056E, $076A, $0266, $0560 ; dc.w $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 dc.w $0000, $0111, $0222, $0333, $0444, $0555, $0666, $0777, $0000, $0111, $0222, $0333, $0333, $0333, $0333, $0333 dc.w $0000, $0111, $0222, $0333, $0456, $0456, $0456, $0456, $0000, $0111, $0222, $0333, $0456, $0456, $0456, $0456 dc.w $0000, $0111, $0222, $0333, $0765, $0765, $0765, $0765, $0000, $0111, $0222, $0333, $0765, $0765, $0765, $0765 dc.w $0000, $0111, $0222, $0333, $0333, $0333, $0333, $0333, $0000, $0111, $0222, $0333, $0333, $0333, $0333, $0333 dc.w $0000, $0111, $0222, $0333, $0456, $0456, $0456, $0456, $0000, $0111, $0222, $0333, $0456, $0456, $0456, $0456 dc.w $0000, $0111, $0222, $0333, $0765, $0765, $0765, $0765, $0000, $0111, $0222, $0333, $0765, $0765, $0765, $0765 dc.w $01EE, $03EA, $05E6, $02CE, $04CA, $06C6, $03AE, $05AA, $07A6, $048E, $068A, $0186, $0480, $0000, $0000, $0000 dc.w $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 dc.w $01EE, $03EA, $05E6, $02CE, $04CA, $06C6, $03AE, $05AA, $07A6, $048E, $068A, $0186, $056E, $076A, $0266, $0560 dc.w $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 TestVSRAMDataCacheNew: ;Initialize the text result block move.w #(TestVSRAMDataCacheNewTextEnd-TestVSRAMDataCacheNewText),D7 move.w #11,(A0)+ ;Set the number of display lines move.w D7,(A0)+ ;Set the text length move.w #$0140,D6 ;Set the data length move.w D6,(A0)+ lea TestVSRAMDataCacheNewText,A1 sub.w #1,D7 TestVSRAMDataCacheNewWriteText: move.b (A1)+,(A0)+ dbf D7,TestVSRAMDataCacheNewWriteText move.w #1,(A0)+ ;Set the expected result data present flag lea TestVSRAMDataCacheNewExpectedResult,A1 ;Write the expected result data to the buffer sub.w #1,D6 TestVSRAMDataCacheNewWriteExpectedResultData: move.b (A1)+,(A0)+ dbf D6,TestVSRAMDataCacheNewWriteExpectedResultData ;Test 1 - Normal VSRAM reads and writes move.l #$40000010,$C00004 ;Perform some writes to VSRAM at 0x00 move.w #$0321,$C00000 move.w #$0765,$C00000 move.l #$40400010,$C00004 ;Perform some writes to VSRAM at 0x40 move.w #$0000,$C00000 move.w #$0111,$C00000 move.w #$0222,$C00000 move.w #$0333,$C00000 move.w #$0444,$C00000 move.w #$0555,$C00000 move.w #$0666,$C00000 move.w #$0777,$C00000 move.l #$00400010,$C00004 ;Read from VSRAM at 0x40 move.w $C00000,(A0)+ move.w $C00000,(A0)+ move.w $C00000,(A0)+ move.w $C00000,(A0)+ 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 ;Test 2 - VSRAM reads off end of VSRAM using last read value move.l #$40000010,$C00004 ;Perform some writes to VSRAM at 0x00 move.w #$0321,$C00000 move.w #$0765,$C00000 move.l #$40480010,$C00004 ;Perform some writes to VSRAM at 0x48 move.w #$0000,$C00000 move.w #$0111,$C00000 move.w #$0222,$C00000 move.w #$0333,$C00000 move.w #$0444,$C00000 move.w #$0555,$C00000 move.w #$0666,$C00000 move.w #$0777,$C00000 ;Wait for the end of active scan TestVSRAMDataCacheNewWaitVBlankClear2: move.w $C00004,D7 btst #3,D7 bne TestVSRAMDataCacheNewWaitVBlankClear2 TestVSRAMDataCacheNewWaitVBlankSet2: move.w $C00004,D7 btst #3,D7 beq TestVSRAMDataCacheNewWaitVBlankSet2 ;Add a small delay loop move.w #$0008,D7 TestVSRAMDataCacheNewDelayLoop2: dbf D7,TestVSRAMDataCacheNewDelayLoop2 move.l #$00480010,$C00004 ;Read from VSRAM at 0x48 move.w $C00000,(A0)+ move.w $C00000,(A0)+ move.w $C00000,(A0)+ move.w $C00000,(A0)+ 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 ;Test 3 - Writes to valid VSRAM addresses overwrite VSRAM read cache move.l #$40000010,$C00004 ;Perform some writes to VSRAM at 0x00 move.w #$0321,$C00000 move.w #$0765,$C00000 move.l #$40480010,$C00004 ;Perform some writes to VSRAM at 0x48 move.w #$0000,$C00000 move.w #$0111,$C00000 move.w #$0222,$C00000 move.w #$0333,$C00000 move.w #$0444,$C00000 move.w #$0555,$C00000 move.w #$0666,$C00000 move.w #$0777,$C00000 ;Wait for the end of active scan TestVSRAMDataCacheNewWaitVBlankClear3: move.w $C00004,D7 btst #3,D7 bne TestVSRAMDataCacheNewWaitVBlankClear3 TestVSRAMDataCacheNewWaitVBlankSet3: move.w $C00004,D7 btst #3,D7 beq TestVSRAMDataCacheNewWaitVBlankSet3 ;Add a small delay loop move.w #$0008,D7 TestVSRAMDataCacheNewDelayLoop3: dbf D7,TestVSRAMDataCacheNewDelayLoop3 move.l #$00480010,$C00004 ;Read from VSRAM at 0x48 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 move.l #$40480010,$C00004 ;Perform some writes to VSRAM at 0x48 move.w #$0123,$C00000 move.w #$0456,$C00000 move.l #$00500010,$C00004 ;Read from VSRAM at 0x50 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 ;Test 4 - Writes to invalid VSRAM addresses overwrite VSRAM read cache move.l #$40000010,$C00004 ;Perform some writes to VSRAM at 0x00 move.w #$0321,$C00000 move.w #$0765,$C00000 move.l #$40480010,$C00004 ;Perform some writes to VSRAM at 0x48 move.w #$0000,$C00000 move.w #$0111,$C00000 move.w #$0222,$C00000 move.w #$0333,$C00000 move.w #$0444,$C00000 move.w #$0555,$C00000 move.w #$0666,$C00000 move.w #$0777,$C00000 ;Wait for the end of active scan TestVSRAMDataCacheNewWaitVBlankClear4: move.w $C00004,D7 btst #3,D7 bne TestVSRAMDataCacheNewWaitVBlankClear4 TestVSRAMDataCacheNewWaitVBlankSet4: move.w $C00004,D7 btst #3,D7 beq TestVSRAMDataCacheNewWaitVBlankSet4 ;Add a small delay loop move.w #$0008,D7 TestVSRAMDataCacheNewDelayLoop4: dbf D7,TestVSRAMDataCacheNewDelayLoop4 move.l #$00480010,$C00004 ;Read from VSRAM at 0x48 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 move.l #$40500010,$C00004 ;Perform some writes to VSRAM at 0x50 move.w #$0123,$C00000 move.w #$0456,$C00000 move.l #$00500010,$C00004 ;Read from VSRAM at 0x50 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 ;Test 5 - Disable display register doesn't prevent VSRAM reads during rendering move.l #$40000010,$C00004 ;Perform some writes to VSRAM at 0x00 move.w #$0765,$C00000 move.w #$0765,$C00000 move.l #$40480010,$C00004 ;Perform some writes to VSRAM at 0x48 move.w #$0000,$C00000 move.w #$0111,$C00000 move.w #$0222,$C00000 move.w #$0333,$C00000 move.w #$0444,$C00000 move.w #$0555,$C00000 move.w #$0666,$C00000 move.w #$0777,$C00000 move.l #$00480010,$C00004 ;Read from VSRAM at 0x48 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 ;Wait for the beginning of active scan ;##FIX## Regen and Kega both behave as if VBLANK is asserted forever when the disable ;display register is set, which would make sense. Perform hardware tests to verify if ;this is the case. I don't think we emulate this currently. TestVSRAMDataCacheNewWaitVBlankSet5: move.w $C00004,D7 btst #3,D7 beq TestVSRAMDataCacheNewWaitVBlankSet5 TestVSRAMDataCacheNewWaitVBlankClear5: move.w $C00004,D7 btst #3,D7 bne TestVSRAMDataCacheNewWaitVBlankClear5 move.w #$8104,$C00004 ;Disable display ;Perform a small delay, to make sure we're a few lines into the render process. move.w #$0020,D7 TestVSRAMDataCacheNewDelayLoop5: dbf D7,TestVSRAMDataCacheNewDelayLoop5 move.l #$00500010,$C00004 ;Read from VSRAM at 0x50 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 move.w #$8144,$C00004 ;Enable display ;Test 6 - Undocumented Reg 1 Bit 0 set doesn't prevent VSRAM reads during rendering move.l #$40000010,$C00004 ;Perform some writes to VSRAM at 0x00 move.w #$0765,$C00000 move.w #$0765,$C00000 move.l #$40480010,$C00004 ;Perform some writes to VSRAM at 0x48 move.w #$0000,$C00000 move.w #$0111,$C00000 move.w #$0222,$C00000 move.w #$0333,$C00000 move.w #$0444,$C00000 move.w #$0555,$C00000 move.w #$0666,$C00000 move.w #$0777,$C00000 move.l #$00480010,$C00004 ;Read from VSRAM at 0x48 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 ;Wait for the beginning of active scan TestVSRAMDataCacheNewWaitVBlankSet6: move.w $C00004,D7 btst #3,D7 beq TestVSRAMDataCacheNewWaitVBlankSet6 TestVSRAMDataCacheNewWaitVBlankClear6: move.w $C00004,D7 btst #3,D7 bne TestVSRAMDataCacheNewWaitVBlankClear6 move.w #$8005,$C00004 ;Disable display ;Perform a small delay, to make sure we're a few lines into the render process. move.w #$0020,D7 TestVSRAMDataCacheNewDelayLoop6: dbf D7,TestVSRAMDataCacheNewDelayLoop6 move.l #$00500010,$C00004 ;Read from VSRAM at 0x50 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 move.w #$8004,$C00004 ;Enable display ;Test 7 - VSRAM data cache not modified by rendering outside active scan move.l #$40000010,$C00004 ;Perform some writes to VSRAM at 0x00 move.w #$0321,$C00000 move.w #$0765,$C00000 move.l #$40480010,$C00004 ;Perform some writes to VSRAM at 0x48 move.w #$0000,$C00000 move.w #$0111,$C00000 move.w #$0222,$C00000 move.w #$0333,$C00000 ;Wait for the end of active scan TestVSRAMDataCacheNewWaitVBlankClear7: move.w $C00004,D7 btst #3,D7 bne TestVSRAMDataCacheNewWaitVBlankClear7 TestVSRAMDataCacheNewWaitVBlankSet7: move.w $C00004,D7 btst #3,D7 beq TestVSRAMDataCacheNewWaitVBlankSet7 ;Add a small delay loop move.w #$0008,D7 TestVSRAMDataCacheNewDelayLoop7: dbf D7,TestVSRAMDataCacheNewDelayLoop7 move.l #$40500010,$C00004 ;Perform some writes to VSRAM at 0x50 move.w #$0444,$C00000 move.w #$0555,$C00000 move.w #$0666,$C00000 move.w #$0777,$C00000 move.l #$00480010,$C00004 ;Read from VSRAM at 0x48 move.w $C00000,(A0)+ move.w $C00000,(A0)+ move.w $C00000,(A0)+ move.w $C00000,(A0)+ 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 ;Initialize VSRAM move.l #$40400010,$C00004 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 ;Test 8 - Same as the above, except test with render VSRAM reads happening after our writes move.l #$40000010,$C00004 ;Perform some writes to VSRAM at 0x00 move.w #$0321,$C00000 move.w #$0765,$C00000 move.l #$40480010,$C00004 ;Perform some writes to VSRAM at 0x48 move.w #$0000,$C00000 move.w #$0111,$C00000 move.w #$0222,$C00000 move.w #$0333,$C00000 move.w #$0444,$C00000 move.w #$0555,$C00000 move.w #$0666,$C00000 move.w #$0777,$C00000 ;Wait for the end of active scan TestVSRAMDataCacheNewWaitVBlankClear8: move.w $C00004,D7 btst #3,D7 bne TestVSRAMDataCacheNewWaitVBlankClear8 TestVSRAMDataCacheNewWaitVBlankSet8: move.w $C00004,D7 btst #3,D7 beq TestVSRAMDataCacheNewWaitVBlankSet8 ;Add a small delay loop move.w #$0008,D7 TestVSRAMDataCacheNewDelayLoop8: dbf D7,TestVSRAMDataCacheNewDelayLoop8 move.l #$00480010,$C00004 ;Read from VSRAM at 0x48 move.w $C00000,(A0)+ move.w $C00000,(A0)+ move.w $C00000,(A0)+ move.w $C00000,(A0)+ 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 ;Initialize VSRAM move.l #$40400010,$C00004 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 ;Test 9 - VSRAM data cache actively modified by rendering during active scan - Overall H32 move.w #$8B00,$C00004 ;Set VScroll mode to overall move.w #$8C00,$C00004 ;Enable H32 mode move.l #$40000010,$C00004 ;Perform some writes to VSRAM at 0x00 move.w #$0456,$C00000 move.w #$0456,$C00000 move.l #$40480010,$C00004 ;Perform some writes to VSRAM at 0x48 move.w #$0000,$C00000 move.w #$0111,$C00000 move.w #$0222,$C00000 move.w #$0333,$C00000 move.w #$0444,$C00000 move.w #$0555,$C00000 move.w #$0666,$C00000 move.w #$0777,$C00000 ;Wait for the beginning of active scan TestVSRAMDataCacheNewWaitVBlankSet9: move.w $C00004,D7 btst #3,D7 beq TestVSRAMDataCacheNewWaitVBlankSet9 TestVSRAMDataCacheNewWaitVBlankClear9: move.w $C00004,D7 btst #3,D7 bne TestVSRAMDataCacheNewWaitVBlankClear9 ;Perform a small delay, to make sure we're a few lines into the render process. move.w #$0020,D7 TestVSRAMDataCacheNewDelayLoop9: dbf D7,TestVSRAMDataCacheNewDelayLoop9 move.l #$00480010,$C00004 ;Read from VSRAM at 0x48 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 move.w #$0020,D7 ;Perform a small delay, to ensure that the render TestVSRAMDataCacheNewDelayLoop91: ;process has a chance to update the VSRAM cache. dbf D7,TestVSRAMDataCacheNewDelayLoop91 move.l #$00500010,$C00004 ;Read from VSRAM at 0x50 (Invalidate read cache) 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 ;Test 10 - VSRAM data cache actively modified by rendering during active scan - Overall H40 move.w #$8B00,$C00004 ;Set VScroll mode to overall move.w #$8C81,$C00004 ;Enable H40 mode move.l #$40000010,$C00004 ;Perform some writes to VSRAM at 0x00 move.w #$0456,$C00000 move.w #$0456,$C00000 move.l #$40480010,$C00004 ;Perform some writes to VSRAM at 0x48 move.w #$0000,$C00000 move.w #$0111,$C00000 move.w #$0222,$C00000 move.w #$0333,$C00000 move.w #$0444,$C00000 move.w #$0555,$C00000 move.w #$0666,$C00000 move.w #$0777,$C00000 ;Wait for the beginning of active scan TestVSRAMDataCacheNewWaitVBlankSet10: move.w $C00004,D7 btst #3,D7 beq TestVSRAMDataCacheNewWaitVBlankSet10 TestVSRAMDataCacheNewWaitVBlankClear10: move.w $C00004,D7 btst #3,D7 bne TestVSRAMDataCacheNewWaitVBlankClear10 ;Perform a small delay, to make sure we're a few lines into the render process. move.w #$0020,D7 TestVSRAMDataCacheNewDelayLoop10: dbf D7,TestVSRAMDataCacheNewDelayLoop10 move.l #$00480010,$C00004 ;Read from VSRAM at 0x48 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 move.w #$0020,D7 ;Perform a small delay, to ensure that the render TestVSRAMDataCacheNewDelayLoop101: ;process has a chance to update the VSRAM cache. dbf D7,TestVSRAMDataCacheNewDelayLoop101 move.l #$00500010,$C00004 ;Read from VSRAM at 0x50 (Invalidate read cache) 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 ;Test 11 - Final VSRAM data cache value during vblank - H32 move.w #$8B00,$C00004 ;Set VScroll mode to overall move.w #$8C00,$C00004 ;Enable H32 mode move.l #$40000010,$C00004 ;Perform some writes to VSRAM at 0x00 move.w #$0456,$C00000 move.w #$0765,$C00000 move.l #$40480010,$C00004 ;Perform some writes to VSRAM at 0x48 move.w #$0000,$C00000 move.w #$0111,$C00000 move.w #$0222,$C00000 move.w #$0333,$C00000 move.w #$0444,$C00000 move.w #$0555,$C00000 move.w #$0666,$C00000 move.w #$0777,$C00000 move.l #$00480010,$C00004 ;Read from VSRAM at 0x48 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 ;Wait for the end of active scan TestVSRAMDataCacheNewWaitVBlankClear11: move.w $C00004,D7 btst #3,D7 bne TestVSRAMDataCacheNewWaitVBlankClear11 TestVSRAMDataCacheNewWaitVBlankSet11: move.w $C00004,D7 btst #3,D7 beq TestVSRAMDataCacheNewWaitVBlankSet11 ;Add a small delay loop move.w #$0008,D7 TestVSRAMDataCacheNewDelayLoop11: dbf D7,TestVSRAMDataCacheNewDelayLoop11 move.l #$00500010,$C00004 ;Read from VSRAM at 0x50 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 ;Test 12 - Final VSRAM data cache value during vblank - H40 move.w #$8B00,$C00004 ;Set VScroll mode to overall move.w #$8C81,$C00004 ;Enable H40 mode move.l #$40000010,$C00004 ;Perform some writes to VSRAM at 0x00 move.w #$0456,$C00000 move.w #$0765,$C00000 move.l #$40480010,$C00004 ;Perform some writes to VSRAM at 0x48 move.w #$0000,$C00000 move.w #$0111,$C00000 move.w #$0222,$C00000 move.w #$0333,$C00000 move.w #$0444,$C00000 move.w #$0555,$C00000 move.w #$0666,$C00000 move.w #$0777,$C00000 move.l #$00480010,$C00004 ;Read from VSRAM at 0x48 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 ;Wait for the end of active scan TestVSRAMDataCacheNewWaitVBlankClear12: move.w $C00004,D7 btst #3,D7 bne TestVSRAMDataCacheNewWaitVBlankClear12 TestVSRAMDataCacheNewWaitVBlankSet12: move.w $C00004,D7 btst #3,D7 beq TestVSRAMDataCacheNewWaitVBlankSet12 ;Add a small delay loop move.w #$0008,D7 TestVSRAMDataCacheNewDelayLoop12: dbf D7,TestVSRAMDataCacheNewDelayLoop12 move.l #$00500010,$C00004 ;Read from VSRAM at 0x50 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 ;Test 13 - VSRAM data cache actively modified by rendering during active scan - 2-cell scroll H32 move.w #$8B04,$C00004 ;Set VScroll mode set to 2-cell column move.w #$8C00,$C00004 ;Enable H32 mode ;Initialize the RAM region where we're loading our sample data move.l A0,A1 add.l #$100,A1 move.w #$0800,D7 TestVSRAMDataCacheNewReadLoopInitializeRAM13: move.w #$0000,(A1)+ dbf D7,TestVSRAMDataCacheNewReadLoopInitializeRAM13 ;Initialize VSRAM move.l #$40000010,$C00004 move.w #$3F,D0 lea TestVSRAMDataCacheNewTestData,A1 TestVSRAMDataCacheNewInitializeVSRAMLoop13: move.w (A1)+,$C00000 dbf D0,TestVSRAMDataCacheNewInitializeVSRAMLoop13 ;Wait for the start of active scan TestVSRAMDataCacheNewWaitVBlankSet13: move.w $C00004,D7 btst #3,D7 beq TestVSRAMDataCacheNewWaitVBlankSet13 TestVSRAMDataCacheNewWaitVBlankClear13: move.w $C00004,D7 btst #3,D7 bne TestVSRAMDataCacheNewWaitVBlankClear13 ;Wait for another full frame to pass, to make sure a transition between H32/H40 mode ;hasn't left a value in the VSRAM read cache which hasn't been overwritten yet. TestVSRAMDataCacheNewWaitVBlankSet132: move.w $C00004,D7 btst #3,D7 beq TestVSRAMDataCacheNewWaitVBlankSet132 TestVSRAMDataCacheNewWaitVBlankClear132: move.w $C00004,D7 btst #3,D7 bne TestVSRAMDataCacheNewWaitVBlankClear132 ;Read from VSRAM until all possible values are found, or we exceed the timeout. move.l A0,A1 ;Set the sample data output location add.l #$100,A1 move.w #$0080,D6 ;Number of frames to loop for TestVSRAMDataCacheNewReadLoop13: TestVSRAMDataCacheNewWaitVBlankClear133: move.w $C00004,D7 btst #3,D7 bne TestVSRAMDataCacheNewWaitVBlankClear133 move.w #$8F00,$C00004 ;Set increment data to 0 move.l #$00500010,$C00004 ;Read from VSRAM at 0x50 ;Read a block of samples from this frame move.w #$0400,D5 TestVSRAMDataCacheNewReadLoopInner13: move.w $C00000,D7 andi.w #$07FF,D7 move.w D7,(A1,D7.w) ; move.w $C00008,(A1,D7.w) dbf D5,TestVSRAMDataCacheNewReadLoopInner13 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 ;Setup a VRAM write target, just to invalidate the read pre-cache data. move.l #$40000002,$C00004 TestVSRAMDataCacheNewWaitVBlankSet133: move.w $C00004,D7 btst #3,D7 beq TestVSRAMDataCacheNewWaitVBlankSet133 ;Check if all the known correct read values were found ; dc.w $01EE, $03EA, $05E6, $02CE, $04CA, $06C6, $03AE, $05AA, $07A6, $048E, $068A, $0186, $0480 tst.w ($01EE,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound13 tst.w ($03EA,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound13 tst.w ($05E6,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound13 tst.w ($02CE,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound13 tst.w ($04CA,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound13 tst.w ($06C6,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound13 tst.w ($03AE,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound13 tst.w ($05AA,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound13 tst.w ($07A6,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound13 tst.w ($048E,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound13 tst.w ($068A,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound13 tst.w ($0186,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound13 tst.w ($0480,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound13 bra TestVSRAMDataCacheNewAllSamplesFound13 TestVSRAMDataCacheNewAllSamplesNotFound13: dbf D6,TestVSRAMDataCacheNewReadLoop13 ;If we've finished the search for samples, output the found sample data ; dc.w $01EE, $03EA, $05E6, $02CE, $04CA, $06C6, $03AE, $05AA, $07A6, $048E, $068A, $0186, $0480 TestVSRAMDataCacheNewAllSamplesFound13: 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.w ($01EE,A1),(A0)+ move.w ($03EA,A1),(A0)+ move.w ($05E6,A1),(A0)+ move.w ($02CE,A1),(A0)+ move.w ($04CA,A1),(A0)+ move.w ($06C6,A1),(A0)+ move.w ($03AE,A1),(A0)+ move.w ($05AA,A1),(A0)+ move.w ($07A6,A1),(A0)+ move.w ($048E,A1),(A0)+ move.w ($068A,A1),(A0)+ move.w ($0186,A1),(A0)+ move.w ($0480,A1),(A0)+ move.w #$0000,(A0)+ move.w #$0000,(A0)+ move.w #$0000,(A0)+ ;Clear the source locations for the valid samples move.w #$0000,($01EE,A1) move.w #$0000,($03EA,A1) move.w #$0000,($05E6,A1) move.w #$0000,($02CE,A1) move.w #$0000,($04CA,A1) move.w #$0000,($06C6,A1) move.w #$0000,($03AE,A1) move.w #$0000,($05AA,A1) move.w #$0000,($07A6,A1) move.w #$0000,($048E,A1) move.w #$0000,($068A,A1) move.w #$0000,($0186,A1) move.w #$0000,($0480,A1) ;Check if we found any other samples other than what we should have encountered, ;and output the first 16 available ones if we did, padding the buffer with 0's. ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ move.w #$0010,D1 move.w #$0800,D7 TestVSRAMDataCacheNewReadLoopFindBadSamplesLoop13: move.w (A1)+,D0 beq TestVSRAMDataCacheNewReadLoopFindBadSamplesLoopSampleEmpty13 move.w D0,(A0)+ ;Decrement the count of samples to find subq.w #1,D1 beq TestVSRAMDataCacheNewReadLoopFindBadSamplesBufferFull13 TestVSRAMDataCacheNewReadLoopFindBadSamplesLoopSampleEmpty13: dbf D7,TestVSRAMDataCacheNewReadLoopFindBadSamplesLoop13 subq.w #1,D1 TestVSRAMDataCacheNewReadLoopFindBadSamplesFillBuffer13: move.w #$0000,(A0)+ ;Pad the output sample buffer dbf D1,TestVSRAMDataCacheNewReadLoopFindBadSamplesFillBuffer13 TestVSRAMDataCacheNewReadLoopFindBadSamplesBufferFull13: ;Test 14 - VSRAM data cache actively modified by rendering during active scan - 2-cell scroll H40 move.w #$8B04,$C00004 ;Set VScroll mode set to 2-cell column move.w #$8C81,$C00004 ;Enable H40 mode ;Initialize the RAM region where we're loading our sample data move.l A0,A1 add.l #$100,A1 move.w #$0800,D7 TestVSRAMDataCacheNewReadLoopInitializeRAM14: move.w #$0000,(A1)+ dbf D7,TestVSRAMDataCacheNewReadLoopInitializeRAM14 ;Initialize VSRAM move.l #$40000010,$C00004 move.w #$3F,D0 lea TestVSRAMDataCacheNewTestData,A1 TestVSRAMDataCacheNewInitializeVSRAMLoop14: move.w (A1)+,$C00000 dbf D0,TestVSRAMDataCacheNewInitializeVSRAMLoop14 ;Wait for the start of active scan TestVSRAMDataCacheNewWaitVBlankSet14: move.w $C00004,D7 btst #3,D7 beq TestVSRAMDataCacheNewWaitVBlankSet14 TestVSRAMDataCacheNewWaitVBlankClear14: move.w $C00004,D7 btst #3,D7 bne TestVSRAMDataCacheNewWaitVBlankClear14 ;Wait for another full frame to pass, to make sure a transition between H32/H40 mode ;hasn't left a value in the VSRAM read cache which hasn't been overwritten yet. TestVSRAMDataCacheNewWaitVBlankSet142: move.w $C00004,D7 btst #3,D7 beq TestVSRAMDataCacheNewWaitVBlankSet142 TestVSRAMDataCacheNewWaitVBlankClear142: move.w $C00004,D7 btst #3,D7 bne TestVSRAMDataCacheNewWaitVBlankClear142 ;Read from VSRAM until all possible values are found, or we exceed the timeout. move.l A0,A1 ;Set the sample data output location add.l #$100,A1 move.w #$0080,D6 ;Number of frames to loop for TestVSRAMDataCacheNewReadLoop14: TestVSRAMDataCacheNewWaitVBlankClear143: move.w $C00004,D7 btst #3,D7 bne TestVSRAMDataCacheNewWaitVBlankClear143 move.w #$8F00,$C00004 ;Set increment data to 0 move.l #$00500010,$C00004 ;Read from VSRAM at 0x50 ;Read a block of samples from this frame move.w #$0400,D5 TestVSRAMDataCacheNewReadLoopInner14: move.w $C00000,D7 andi.w #$07FF,D7 move.w D7,(A1,D7.w) ; move.w $C00008,(A1,D7.w) dbf D5,TestVSRAMDataCacheNewReadLoopInner14 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 ;Setup a VRAM write target, just to invalidate the read pre-cache data. move.l #$40000002,$C00004 ;Wait for the end of this frame to be reached before proceeding TestVSRAMDataCacheNewWaitVBlankSet143: move.w $C00004,D7 btst #3,D7 beq TestVSRAMDataCacheNewWaitVBlankSet143 ;Check if all the known correct read values were found ; dc.w $01EE, $03EA, $05E6, $02CE, $04CA, $06C6, $03AE, $05AA, $07A6, $048E, $068A, $0186, $056E, $076A, $0266, $0560 tst.w ($01EE,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound14 tst.w ($03EA,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound14 tst.w ($05E6,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound14 tst.w ($02CE,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound14 tst.w ($04CA,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound14 tst.w ($06C6,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound14 tst.w ($03AE,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound14 tst.w ($05AA,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound14 tst.w ($07A6,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound14 tst.w ($048E,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound14 tst.w ($068A,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound14 tst.w ($0186,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound14 tst.w ($056E,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound14 tst.w ($076A,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound14 tst.w ($0266,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound14 tst.w ($0560,A1) beq TestVSRAMDataCacheNewAllSamplesNotFound14 bra TestVSRAMDataCacheNewAllSamplesFound14 TestVSRAMDataCacheNewAllSamplesNotFound14: dbf D6,TestVSRAMDataCacheNewReadLoop14 ;If we've finished the search for samples, output the found sample data ; dc.w $01EE, $03EA, $05E6, $02CE, $04CA, $06C6, $03AE, $05AA, $07A6, $048E, $068A, $0186, $056E, $076A, $0266, $0560 TestVSRAMDataCacheNewAllSamplesFound14: 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.w #$8F02,$C00004 ;Set increment data to 2 move.w ($01EE,A1),(A0)+ move.w ($03EA,A1),(A0)+ move.w ($05E6,A1),(A0)+ move.w ($02CE,A1),(A0)+ move.w ($04CA,A1),(A0)+ move.w ($06C6,A1),(A0)+ move.w ($03AE,A1),(A0)+ move.w ($05AA,A1),(A0)+ move.w ($07A6,A1),(A0)+ move.w ($048E,A1),(A0)+ move.w ($068A,A1),(A0)+ move.w ($0186,A1),(A0)+ move.w ($056E,A1),(A0)+ move.w ($076A,A1),(A0)+ move.w ($0266,A1),(A0)+ move.w ($0560,A1),(A0)+ ;Clear the source locations for the valid samples move.w #$0000,($01EE,A1) move.w #$0000,($03EA,A1) move.w #$0000,($05E6,A1) move.w #$0000,($02CE,A1) move.w #$0000,($04CA,A1) move.w #$0000,($06C6,A1) move.w #$0000,($03AE,A1) move.w #$0000,($05AA,A1) move.w #$0000,($07A6,A1) move.w #$0000,($048E,A1) move.w #$0000,($068A,A1) move.w #$0000,($0186,A1) move.w #$0000,($056E,A1) move.w #$0000,($076A,A1) move.w #$0000,($0266,A1) move.w #$0000,($0560,A1) ;Check if we found any other samples other than what we should have encountered, ;and output the first 16 available ones if we did, padding the buffer with 0's. ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ move.w #$0010,D1 move.w #$0800,D7 TestVSRAMDataCacheNewReadLoopFindBadSamplesLoop14: move.w (A1)+,D0 beq TestVSRAMDataCacheNewReadLoopFindBadSamplesLoopSampleEmpty14 move.w D0,(A0)+ ;Decrement the count of samples to find subq.w #1,D1 beq TestVSRAMDataCacheNewReadLoopFindBadSamplesBufferFull14 TestVSRAMDataCacheNewReadLoopFindBadSamplesLoopSampleEmpty14: dbf D7,TestVSRAMDataCacheNewReadLoopFindBadSamplesLoop14 subq.w #1,D1 TestVSRAMDataCacheNewReadLoopFindBadSamplesFillBuffer14: move.w #$0000,(A0)+ ;Pad the output sample buffer dbf D1,TestVSRAMDataCacheNewReadLoopFindBadSamplesFillBuffer14 TestVSRAMDataCacheNewReadLoopFindBadSamplesBufferFull14: ;Restore register settings move.w #$8B00,$C00004 ;Set VScroll mode set to overall scrolling move.w #$8C81,$C00004 ;Enable H40 mode ;Initialize VSRAM move.l #$40000010,$C00004 move.w #$3F,D0 TestVSRAMDataCacheNewInitializeVSRAMLoopFinish99: move.w #$0000,$C00000 dbf D0,TestVSRAMDataCacheNewInitializeVSRAMLoopFinish99 rts TestVSRAMDataCacheNewTestData: dc.w $01EE, $02EC, $03EA, $04E8, $05E6, $06E4, $07E2, $01E0, $02CE, $03CC, $04CA, $05C8, $06C6, $07C4, $01C2, $02C0 dc.w $03AE, $04AC, $05AA, $06A8, $07A6, $01A4, $02A2, $03A0, $048E, $058C, $068A, $0788, $0186, $0284, $0382, $0480 dc.w $056E, $066C, $076A, $0168, $0266, $0364, $0462, $0560, $064E, $074C, $014A, $0248, $0346, $0444, $0542, $0640 dc.w $072E, $012C, $022A, $0328, $0426, $0524, $0622, $0720, $010E, $020C, $030A, $0408, $0506, $0604, $0702, $0100 ; H32: ; dc.w $01EE, $XXXX, $03EA, $XXXX, $05E6, $XXXX, $XXXX, $XXXX, $02CE, $XXXX, $04CA, $XXXX, $06C6, $XXXX, $XXXX, $XXXX ; dc.w $03AE, $XXXX, $05AA, $XXXX, $07A6, $XXXX, $XXXX, $XXXX, $048E, $XXXX, $068A, $XXXX, $0186, $XXXX, $XXXX, $0480 ; Trimmed: ; dc.w $01EE, $03EA, $05E6, $02CE, $04CA, $06C6, $03AE, $05AA, $07A6, $048E, $068A, $0186, $0480 ; H32 - Real: ; dc.w $01EE, $XXXX, $03EA, $XXXX, $05E6, $XXXX, $XXXX, $XXXX, $02CE, $XXXX, $04CA, $XXXX, $06C6, $XXXX, $XXXX, $XXXX ; dc.w $03AE, $XXXX, $05AA, $XXXX, $07A6, $XXXX, $XXXX, $XXXX, $048E, $XXXX, $068A, $XXXX, $0186, $XXXX, $XXXX, $XXXX ; dc.w $056E, $XXXX, $XXXX, $XXXX, $0266, $XXXX, $XXXX, $XXXX, $XXXX, $XXXX, $XXXX, $XXXX, $XXXX, $XXXX, $XXXX, $XXXX ; dc.w $XXXX, $XXXX, $XXXX, $XXXX, $XXXX, $XXXX, $XXXX, $XXXX, $XXXX, $XXXX, $XXXX, $XXXX, $XXXX, $XXXX, $XXXX, $XXXX ; Trimmed: ; dc.w $01EE, $03EA, $05E6, $02CE, $04CA, $06C6, $03AE, $05AA, $07A6, $048E, $068A, $0186, $056E, $0266 ; Unexpected: ; dc.w $0266, $056E ; Timing Unexpected: ; $0266 - 8107, 06, 05, 08, 04 (04-07) ; $056E - 81F0, EF, F1, EE (EE-F1) ; H40: ; dc.w $01EE, $XXXX, $03EA, $XXXX, $05E6, $XXXX, $XXXX, $XXXX, $02CE, $XXXX, $04CA, $XXXX, $06C6, $XXXX, $XXXX, $XXXX ; dc.w $03AE, $XXXX, $05AA, $XXXX, $07A6, $XXXX, $XXXX, $XXXX, $048E, $XXXX, $068A, $XXXX, $0186, $XXXX, $XXXX, $XXXX ; dc.w $056E, $XXXX, $076A, $XXXX, $0266, $XXXX, $XXXX, $0560 ; Trimmed: ; dc.w $01EE, $03EA, $05E6, $02CE, $04CA, $06C6, $03AE, $05AA, $07A6, $048E, $068A, $0186, $056E, $076A, $0266, $0560 ; H40 - Real: ; dc.w $XXXX, $XXXX, $03EA, $XXXX, $05E6, $XXXX, $XXXX, $XXXX, $02CE, $XXXX, $04CA, $XXXX, $06C6, $XXXX, $XXXX, $XXXX ; dc.w $03AE, $XXXX, $05AA, $XXXX, $07A6, $XXXX, $XXXX, $XXXX, $048E, $XXXX, $068A, $XXXX, $0186, $XXXX, $XXXX, $XXXX ; dc.w $056E, $XXXX, $076A, $XXXX, $0266, $XXXX, $XXXX, $XXXX ; Trimmed: ; dc.w $03EA, $05E6, $02CE, $04CA, $06C6, $03AE, $05AA, $07A6, $048E, $068A, $0186, $056E, $076A, $0266 ; Unexpected: ; dc.w $0100, $0460 ; Timing Unexpected: ; $0100 - 811E, 1A, 1C, 15, 18, 14, 10, 1B, 1D, 20 (10-20) (Last VSRAM written value, first access slot in normal cell read block) ; $0460 - 820B, 04, 05, FC, 00, FE, 06, 07 (FC-0B) (Last two VSRAM entries ANDed together, all access slots after end of visible display, last one always overrides previous hcounter location) ;$0266, $056E, no last entry ;No entry 0, $0100, $0460, no last entry ;-We have confirmed that vscroll data continues to be read after the end of H32 active scan, and that during the vscroll area, ; valid scroll data is read which is past the end of the H32 scroll data. ;-The real results for H32 mode show that the layer A mapping for cell block 3 is fully loaded during the middle access slot, ; at the second layer B pattern block read. This means that vscroll data is latched before the layer A mapping read slot. It ; seems likely that the vscroll data latching is completely independent from the H32/H40 scroll mode, and that the hcounter ; is used to trigger latching of vscroll data. ;-If the hcounter value is used to latch vscroll data, it should be noted that there is a 3 hcounter value offset difference ; between H32 and H40 scroll modes. This could explain why the vscroll data is latched ahead of the expected point. I expect ; most likely that the first vscroll data is latched at hcounter 0x000, with a new value being latched every 0x008 hcounter ; clock cycles thereafter. ;To do: ;-Try replacing entries $0462, $0560, and $0100, and see if it affect the unexpected read data from H40 mode in test 14 ;-Try setting entry $0560 to $07FF and see if we get $0555 and $02AA back as the alternating patterns. This would ; indicate the last read value of $0560 for H40 mode is being split into odd and even bits. ;-Try replacing entries $0266 and $056E and see if it affects the unexpected read data from H32 mode in test 13 ;82E5,82FB,8113 ;819F,82FF,8118 ;82A8,8209,811F ;Results: ;-Very very strange results. In H40 mode, the last expected read of $0560 is returning $0460 when the preceeding value in VSRAM ; is $0462. It appears that the reason for that is that the preceeding value is acting as an AND mask. If it is set to $FFFF, we ; read back the correct value of $0562. If it is set to $0000, we read back $0000. If it is set to $03AF, we read back $0120. ;-The second unusual read is even stranger. The unexpected read of $0100 is in fact coming from the value we wrote to the last ; VSRAM address. This value is returned every time, perfectly and consistently, regardless of what we wrote to any other address, ; unless the value we write has the LSB set to 1. In other words, writing $07FE or $0002 will work, but $07FF or $0001 will cause ; a lockup. We have also confimed that it is in fact the last value to only VSRAM that is returned. Performing a write to another ; target such as VRAM after the last write to VSRAM will not affect the value returned. ;-We have also seen that setting the LSB of entry 0 to 1 causes the H32 mode test to lockup. In fact, it seems lots of cases of ; setting values with an LSB of 1 can cause lockups. Our original test data set didn't have any set values in the LSB. ;-Doing more testing on the strange return from H40 mode, it appears the second unusual read is returning the last value to be ; written to VSRAM, regardless of which address it was written to and whether that address was valid or not. It returns that ; value consistently and reliably. Note that this value cannot have the LSB set however, otherwise we get the lockup mentioned ; before. ;-Note that this lockup is actually caused by our code. We assume that the result is even, so that we can directly use it as an ; index for an address register.