;----------------------------------------------------------------------------------------- ;-Description: ; This test checks how VRAM responds to reads and writes to and from odd addresses. ;##TODO## We're getting inconsistent results on the real hardware when doing reads from ;odd addresses. Sometimes the data is read the same as if the LSB of the address was ;unset. Sometimes the data is read with the upper byte the same as an even read, and the ;lower byte the same as for an even read at address-2. We have also observed the ;behaviour switching after the first word, both from and to the unusual address-2 ;behaviour. More tests are required. ;##NOTE## This test has also now been seen to lock up on the real hardware, but only now ;that we've changed the timing of the preceeding test. ;##NOTE## We've eliminated our lockups and inconsistent results now, but only by ;inserting some extra wait states. ;-Expected result: ;315-5313: 1122 3344 5000 5000 1100 3322 5000 5000 2211 4433 5000 5000 2200 4411 5000 5000 ;315-5313A: 1122 3344 5000 5000 1122 3344 5000 5000 2211 4433 5000 5000 2211 4433 5000 5000 ;----------------------------------------------------------------------------------------- TestVRAMByteswappingText: dc.b 'VRAM Byteswapping ' TestVRAMByteswappingTextEnd: TestVRAMByteswappingExpectedResult: dc.w $1122, $3344, $5000, $5000, $1122, $3344, $5000, $5000, $2211, $4433, $5000, $5000, $2211, $4433, $5000, $5000 dc.w $1122, $3344, $5000, $5000, $1100, $3322, $5000, $5000, $2211, $4433, $5000, $5000, $2200, $4411, $5000, $5000 dc.w $1122, $3344, $5000, $5000, $1122, $3344, $5000, $5000, $2211, $4433, $5000, $5000, $2211, $4433, $5000, $5000 dc.w $1122, $3344, $5000, $5000, $1122, $3344, $5000, $5000, $2211, $4433, $5000, $5000, $2211, $4433, $5000, $5000 dc.w $1122, $3344, $5000, $5000, $1100, $3322, $5000, $5000, $2211, $4433, $5000, $5000, $2200, $4433, $5000, $5000 dc.w $1122, $3344, $5000, $5000, $1100, $3322, $5000, $5000, $2211, $4433, $5000, $5000, $2200, $4431, $5000, $5000 TestVRAMByteswapping: ;Initialize the text result block move.w #(TestVRAMByteswappingTextEnd-TestVRAMByteswappingText),D7 move.w #2,(A0)+ ;Set the number of display lines move.w D7,(A0)+ ;Set the text length move.w #$0020,D6 ;Set the data length move.w D6,(A0)+ lea TestVRAMByteswappingText,A1 sub.w #1,D7 TestVRAMByteswappingWriteText: move.b (A1)+,(A0)+ dbf D7,TestVRAMByteswappingWriteText move.w #1,(A0)+ ;Set the expected result data present flag lea TestVRAMByteswappingExpectedResult,A1 ;Write the expected result data to the buffer sub.w #1,D6 TestVRAMByteswappingWriteExpectedResultData: move.b (A1)+,(A0)+ dbf D6,TestVRAMByteswappingWriteExpectedResultData ;Fill the FIFO buffer with some writes to VRAM at 0x8000 move.l #$40000002,$C00004 move.w #$1122,$C00000 move.w #$3344,$C00000 move.w #$5566,$C00000 move.w #$7788,$C00000 move.w #$99AA,$C00000 move.w #$BBCC,$C00000 move.l #$00000002,$C00004 ;Read from VRAM at 0x8000 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 #$00000010,$C00004 ;Read from VSRAM 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 #$00010002,$C00004 ;Read from VRAM at 0x8001 nop ;Wait for a few cycles before reading from the data port, to avoid intermittent nop ;read errors when reading from odd VRAM addresses. Without this delay, the real nop ;hardware may return incomplete data, where the upper byte is correct, but the nop ;lower byte is set the same as the previously read data. Where back to back reads nop ;occur without a delay between any of them, this can result in a chain effect, nop ;where the lower byte of each subsequent read actually contains the contents of nop ;what the lower byte should have been from the previous read. This effect appears nop ;to only occur during active scan, when the full 16-bit value cannot be cached nop ;before the data port is read. Adding 24 NOP cycles before each read was not nop ;enough to make this stable. We only got consistently valid readings when 28 NOP nop ;cycles were added. nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop move.w $C00000,(A0)+ ;##NOTE## Sometimes read as 0x1122! nop ;Wait for a few cycles before reading from the data port, to avoid intermittent nop ;read errors when reading from odd VRAM addresses. Without this delay, the real nop ;hardware may return incomplete data, where the upper byte is correct, but the nop ;lower byte is set the same as the previously read data. Where back to back reads nop ;occur without a delay between any of them, this can result in a chain effect, nop ;where the lower byte of each subsequent read actually contains the contents of nop ;what the lower byte should have been from the previous read. This effect appears nop ;to only occur during active scan, when the full 16-bit value cannot be cached nop ;before the data port is read. Adding 24 NOP cycles before each read was not nop ;enough to make this stable. We only got consistently valid readings when 28 NOP nop ;cycles were added. nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop move.w $C00000,(A0)+ ;##NOTE## Sometimes read as 0x3344! 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 #$00000010,$C00004 ;Read from VSRAM 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 ;Fill the FIFO buffer with some writes to VRAM at 0x8001 move.l #$40010002,$C00004 move.w #$1122,$C00000 move.w #$3344,$C00000 move.w #$5566,$C00000 move.w #$7788,$C00000 move.w #$99AA,$C00000 move.w #$BBCC,$C00000 move.l #$00000002,$C00004 ;Read from VRAM at 0x8000 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 #$00000010,$C00004 ;Read from VSRAM 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 #$00010002,$C00004 ;Read from VRAM at 0x8001 nop ;Wait for a few cycles before reading from the data port, to avoid intermittent nop ;read errors when reading from odd VRAM addresses. Without this delay, the real nop ;hardware may return incomplete data, where the upper byte is correct, but the nop ;lower byte is set the same as the previously read data. Where back to back reads nop ;occur without a delay between any of them, this can result in a chain effect, nop ;where the lower byte of each subsequent read actually contains the contents of nop ;what the lower byte should have been from the previous read. This effect appears nop ;to only occur during active scan, when the full 16-bit value cannot be cached nop ;before the data port is read. Adding 24 NOP cycles before each read was not nop ;enough to make this stable. We only got consistently valid readings when 28 NOP nop ;cycles were added. nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop move.w $C00000,(A0)+ ;##NOTE## Sometimes read as 0x2211! nop ;Wait for a few cycles before reading from the data port, to avoid intermittent nop ;read errors when reading from odd VRAM addresses. Without this delay, the real nop ;hardware may return incomplete data, where the upper byte is correct, but the nop ;lower byte is set the same as the previously read data. Where back to back reads nop ;occur without a delay between any of them, this can result in a chain effect, nop ;where the lower byte of each subsequent read actually contains the contents of nop ;what the lower byte should have been from the previous read. This effect appears nop ;to only occur during active scan, when the full 16-bit value cannot be cached nop ;before the data port is read. Adding 24 NOP cycles before each read was not nop ;enough to make this stable. We only got consistently valid readings when 28 NOP nop ;cycles were added. nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop move.w $C00000,(A0)+ ;##NOTE## Sometimes read as 0x4433! 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 #$00000010,$C00004 ;Read from VSRAM 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 rts