;----------------------------------------------------------------------------------------- ;-Description: ; This test verifies the behaviour of the VDP in regards to when the VDP latches a control ; port write as the second half of a control port write pair, and when the control port ; write is interpreted as the first half of a control port write pair. If the control port ; is read, or the data port is written to, the write pending flag is reset. Note that ; hardware tests have also shown that data port reads reset the write pending flag, but ; since hardware tests have shown that performing data port reads after a partial control ; port write is unsafe, and will often cause hardware lockups, we can't reliably test for ; this. A test can be constructed to verify data port reads reset the write pending flag ; however, it can just lock up sometimes on the hardware depending on the timing. ;##NOTE## It seems attempting to write to the HV counter locks up the system. Not ;sure if it's the VDP or just the M68000 that locks at this point. ;##TODO## Since another test has shown partial command port writes appear to set CD4, ;we can only reliably demonstrate that data port writes reset the control port write ;pending state. Previous tests indicate data port reads have the same effect however. ;----------------------------------------------------------------------------------------- TestCPWritePendingResetText: dc.b 'CP Write Pending Reset ' TestCPWritePendingResetTextEnd: TestCPWritePendingResetExpectedResult: dc.w $08AC, $0246, $FFFF, $0246, $F357, $FFFF, $F357, $FFFF, $F357, $FFFF, $F357, $FFFF, $F357, $FFFF, $F357, $FFFF TestCPWritePendingReset: ;Initialize the text result block move.w #(TestCPWritePendingResetTextEnd-TestCPWritePendingResetText),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 TestCPWritePendingResetText,A1 sub.w #1,D7 TestCPWritePendingResetWriteText: move.b (A1)+,(A0)+ dbf D7,TestCPWritePendingResetWriteText move.w #1,(A0)+ ;Set the expected result data present flag lea TestCPWritePendingResetExpectedResult,A1 ;Write the expected result data to the buffer sub.w #1,D6 TestCPWritePendingResetWriteExpectedResultData: move.b (A1)+,(A0)+ dbf D6,TestCPWritePendingResetWriteExpectedResultData ;Initialize target memory move.l #$40000002,$C00004 ;Write to VRAM at 0x8000 move.w #$FFFF,$C00000 move.w #$FFFF,$C00000 move.l #$C0000002,$C00004 ;Write to CRAM at 0x8000 move.w #$0EEE,$C00000 move.w #$0EEE,$C00000 ;Test data port writes - Should clear write pending flag move.l #$C0020002,$C00004 ;Write to CRAM at 0x8002 move.w #$C002,$C00004 ;Partial CP write, write to CRAM at 0x8002 move.w #$08AC,$C00000 move.w #$4002,$C00004 ;Partial CP write, write to VRAM at 0x8002 move.w #$0246,$C00000 move.w #$8F02,$C00004 ;Resync the control port if an emulator mucked partial writes up move.w #$8F02,$C00004 move.l #$00020022,$C00004 ;Read from CRAM at 0x8002 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 #$00020002,$C00004 ;Read from VRAM at 0x8002 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 target memory move.l #$40000002,$C00004 ;Write to VRAM at 0x8000 move.w #$FFFF,$C00000 move.w #$FFFF,$C00000 move.l #$C0000002,$C00004 ;Write to CRAM at 0x8000 move.w #$0EEE,$C00000 move.w #$0EEE,$C00000 ;Test status register reads - Should clear write pending flag move.l #$C0020002,$C00004 ;Write to CRAM at 0x8002 move.w #$C002,$C00004 ;Partial CP write, write to CRAM at 0x8002 move.w $C00004,D7 ;Read the status register move.w #$4002,$C00004 ;Partial CP write, write to VRAM at 0x8002 move.w #$0246,$C00000 move.w #$8F02,$C00004 ;Resync the control port if an emulator mucked partial writes up move.w #$8F02,$C00004 move.l #$00020022,$C00004 ;Read from CRAM at 0x8002 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 #$00020002,$C00004 ;Read from VRAM at 0x8002 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 target memory move.l #$40000002,$C00004 ;Write to VRAM at 0x8000 move.w #$FFFF,$C00000 move.w #$FFFF,$C00000 move.l #$C0000002,$C00004 ;Write to CRAM at 0x8000 move.w #$0EEE,$C00000 move.w #$0EEE,$C00000 ;Test control port writes - Should not clear write pending flag move.l #$C0020002,$C00004 ;Write to CRAM at 0x8002 move.w #$C002,$C00004 ;Partial CP write, write to CRAM at 0x8002 move.w #$4002,$C00004 ;Partial CP write, write to VRAM at 0x8002 move.w #$0246,$C00000 move.w #$8F02,$C00004 ;Resync the control port if an emulator mucked partial writes up move.w #$8F02,$C00004 move.l #$00020022,$C00004 ;Read from CRAM at 0x8002 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 #$00020002,$C00004 ;Read from VRAM at 0x8002 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 target memory move.l #$40000002,$C00004 ;Write to VRAM at 0x8000 move.w #$FFFF,$C00000 move.w #$FFFF,$C00000 move.l #$C0000002,$C00004 ;Write to CRAM at 0x8000 move.w #$0EEE,$C00000 move.w #$0EEE,$C00000 ;Test HV counter reads - Should not clear write pending flag move.l #$C0020002,$C00004 ;Write to CRAM at 0x8002 move.w #$C002,$C00004 ;Partial CP write, write to CRAM at 0x8002 move.w $C00008,D7 ;Read the HV counter move.w #$4002,$C00004 ;Partial CP write, write to VRAM at 0x8002 move.w #$0246,$C00000 move.w #$8F02,$C00004 ;Resync the control port if an emulator mucked partial writes up move.w #$8F02,$C00004 move.l #$00020022,$C00004 ;Read from CRAM at 0x8002 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 #$00020002,$C00004 ;Read from VRAM at 0x8002 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 target memory move.l #$40000002,$C00004 ;Write to VRAM at 0x8000 move.w #$FFFF,$C00000 move.w #$FFFF,$C00000 move.l #$C0000002,$C00004 ;Write to CRAM at 0x8000 move.w #$0EEE,$C00000 move.w #$0EEE,$C00000 ;Test unused register reads - Should not clear write pending flag move.l #$C0020002,$C00004 ;Write to CRAM at 0x8002 move.w #$C002,$C00004 ;Partial CP write, write to CRAM at 0x8002 move.w $C00018,D7 ;Read the unused register move.w #$4002,$C00004 ;Partial CP write, write to VRAM at 0x8002 move.w #$0246,$C00000 move.w #$8F02,$C00004 ;Resync the control port if an emulator mucked partial writes up move.w #$8F02,$C00004 move.l #$00020022,$C00004 ;Read from CRAM at 0x8002 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 #$00020002,$C00004 ;Read from VRAM at 0x8002 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 target memory move.l #$40000002,$C00004 ;Write to VRAM at 0x8000 move.w #$FFFF,$C00000 move.w #$FFFF,$C00000 move.l #$C0000002,$C00004 ;Write to CRAM at 0x8000 move.w #$0EEE,$C00000 move.w #$0EEE,$C00000 ;Test unused register writes - Should not clear write pending flag move.l #$C0020002,$C00004 ;Write to CRAM at 0x8002 move.w #$C002,$C00004 ;Partial CP write, write to CRAM at 0x8002 move.w #$0000,$C00018 ;Write the unused register move.w #$4002,$C00004 ;Partial CP write, write to VRAM at 0x8002 move.w #$0246,$C00000 move.w #$8F02,$C00004 ;Resync the control port if an emulator mucked partial writes up move.w #$8F02,$C00004 move.l #$00020022,$C00004 ;Read from CRAM at 0x8002 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 #$00020002,$C00004 ;Read from VRAM at 0x8002 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 target memory move.l #$40000002,$C00004 ;Write to VRAM at 0x8000 move.w #$FFFF,$C00000 move.w #$FFFF,$C00000 move.l #$C0000002,$C00004 ;Write to CRAM at 0x8000 move.w #$0EEE,$C00000 move.w #$0EEE,$C00000 ;Test register reads - Should not clear write pending flag move.l #$C0020002,$C00004 ;Write to CRAM at 0x8002 move.w #$C002,$C00004 ;Partial CP write, write to CRAM at 0x8002 move.w $C0001C,D7 ;Read the test register move.w #$4002,$C00004 ;Partial CP write, write to VRAM at 0x8002 move.w #$0246,$C00000 move.w #$8F02,$C00004 ;Resync the control port if an emulator mucked partial writes up move.w #$8F02,$C00004 move.l #$00020022,$C00004 ;Read from CRAM at 0x8002 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 #$00020002,$C00004 ;Read from VRAM at 0x8002 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 target memory move.l #$40000002,$C00004 ;Write to VRAM at 0x8000 move.w #$FFFF,$C00000 move.w #$FFFF,$C00000 move.l #$C0000002,$C00004 ;Write to CRAM at 0x8000 move.w #$0EEE,$C00000 move.w #$0EEE,$C00000 ;Test register writes - Should not clear write pending flag move.l #$C0020002,$C00004 ;Write to CRAM at 0x8002 move.w #$C002,$C00004 ;Partial CP write, write to CRAM at 0x8002 move.w #$0000,$C0001C ;Write to the test register move.w #$4002,$C00004 ;Partial CP write, write to VRAM at 0x8002 move.w #$0246,$C00000 move.w #$8F02,$C00004 ;Resync the control port if an emulator mucked partial writes up move.w #$8F02,$C00004 move.l #$00020022,$C00004 ;Read from CRAM at 0x8002 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 #$00020002,$C00004 ;Read from VRAM at 0x8002 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 target memory move.l #$40000002,$C00004 ;Write to VRAM at 0x8000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.l #$C0000002,$C00004 ;Write to CRAM at 0x8000 move.w #$0000,$C00000 move.w #$0000,$C00000 rts