;----------------------------------------------------------------------------------------- ; Test - 8-bit VRAM Read target 01100 ;-Description: ; This test is designed to demonstrate the behaviour of the undocumented 01100 VRAM read ; target, which performs a true 8-bit read from VRAM. ;----------------------------------------------------------------------------------------- TestReadTarget01100Text: dc.b '8-bit VRAM Read target 01100 ' TestReadTarget01100TextEnd: TestReadTarget01100ExpectedResult: dc.w $9922, $9944, $BB66, $BB88, $DDAA, $DDCC, $12EE, $1234, $FF22, $FF11, $FF44, $FF33, $FF11, $FF44, $FF33, $FF66 TestReadTarget01100: ;Initialize the text result block move.w #(TestReadTarget01100TextEnd-TestReadTarget01100Text),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 TestReadTarget01100Text,A1 sub.w #1,D7 TestReadTarget01100WriteText: move.b (A1)+,(A0)+ dbf D7,TestReadTarget01100WriteText move.w #1,(A0)+ ;Set the expected result data present flag lea TestReadTarget01100ExpectedResult,A1 ;Write the expected result data to the buffer sub.w #1,D6 TestReadTarget01100WriteExpectedResultData: move.b (A1)+,(A0)+ dbf D6,TestReadTarget01100WriteExpectedResultData ;Initialize VRAM data 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.w #$DDEE,$C00000 move.w #$1234,$C00000 ;Read our data from the undocumented 8-bit VRAM read target 01100 move.l #$00000032,$C00004 ;Read from the 8-bit VRAM read target 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 #$C0200002,$C00004 ;Advance the FIFO buffer move.w #$FFFF,$C00000 move.l #$00040032,$C00004 ;Read from the 8-bit VRAM read target 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 #$C0200002,$C00004 ;Advance the FIFO buffer move.w #$FFFF,$C00000 move.l #$00080032,$C00004 ;Read from the 8-bit VRAM read target 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 #$C0200002,$C00004 ;Advance the FIFO buffer move.w #$FFFF,$C00000 move.l #$000C0032,$C00004 ;Read from the 8-bit VRAM read target 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 #$C0200000,$C00004 ;Advance the FIFO buffer move.w #$FFFF,$C00000 move.w #$8F01,$C00004 ;Set the address increment to 1 move.l #$00000032,$C00004 ;Read from the 8-bit VRAM read target at 0x8000 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 #$C0200000,$C00004 ;Advance the FIFO buffer move.w #$FFFF,$C00000 move.l #$00010032,$C00004 ;Read from the 8-bit VRAM read target at 0x8001 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 ;##NOTE## Further testing has shown that if we remove the wait cycles above after the ;data port read before we perform this control port write, what happens is that ;intermittently, the control port write is ignored, leaving the address increment set ;to 1. Two NOP instructions appears to almost, but not quite, be enough to stop this ;occurring. ;##NOTE## With only 4 NOP wait cycles enabled after each data port read, we don't get ;lockups anymore, but we do get data read errors. These errors only occur after our ;data port writes to invalid targets. Is the data port write still in the FIFO? I thought ;control port writes were only allowed once the FIFO was empty? At any rate, what happens ;is that the first read following these data port writes sometimes returns a value with ;the lower byte set to 0, either due to no data being read or data being read from the ;wrong address. Each read that follows this bad read works, but the first read is ;effectively ignored, and the second read actually occurs at the first address, the ;third read at the second address, and so on. Increasing the wait cycles from 4 to 8 ;eliminated the read errors, but in their place with a similar frequency, we got hard ;lockups instead. It was only when we increased the wait cycles to from 8 to 10 that we ;finally got both stability and correct read results. move.w #$8F02,$C00004 ;Restore the address increment to 2 rts