;----------------------------------------------------------------------------------------- ;-Description: ; The purpose of this test is to verify some points of behaviour with how the code and ; address registers are implemented within the VDP. In particular, we verify several ; points where code and address register data should and should not be modified by various ; VDP operations. ;----------------------------------------------------------------------------------------- TestCodeAndAddressRegistersText: dc.b 'VDP Code and Address Registers ' TestCodeAndAddressRegistersTextEnd: TestCodeAndAddressRegistersExpectedResult: dc.w $0123, $4567, $89AB, $CDEF, $FEDC, $BA98, $89AB, $CDEF, $0777, $0666, $0333, $0444, $FEDC, $BA98, $89AB, $CDEF dc.w $0123, $4567, $89AB, $CDEF, $FEDC, $AABB, $CCDD, $EEFF, $1100, $3322, $5544, $7766, $9988, $BBAA, $DDCC, $FFEE dc.w $0123, $4567, $89AB, $CDEF, $FEDC, $AABB, $CCDD, $EEFF, $1100, $3322, $5544, $7766, $9988, $BBAA, $DDCC, $FFEE dc.w $FEDC, $BA98, $7654, $3210, $FFEE, $DDCC, $89AB, $CDEF, $1032, $5476, $98BA, $DCFE TestCodeAndAddressRegisters: ;Initialize the text result block move.w #(TestCodeAndAddressRegistersTextEnd-TestCodeAndAddressRegistersText),D7 move.w #5,(A0)+ ;Set the number of display lines move.w D7,(A0)+ ;Set the text length move.w #$0078,D6 ;Set the data length move.w D6,(A0)+ lea TestCodeAndAddressRegistersText,A1 ;Write the text to the buffer sub.w #1,D7 TestCodeAndAddressRegistersWriteText: move.b (A1)+,(A0)+ dbf D7,TestCodeAndAddressRegistersWriteText move.w #1,(A0)+ ;Set the expected result data present flag lea TestCodeAndAddressRegistersExpectedResult,A1 ;Write the expected result data to the buffer sub.w #1,D6 TestCodeAndAddressRegistersWriteExpectedResultData: move.b (A1)+,(A0)+ dbf D6,TestCodeAndAddressRegistersWriteExpectedResultData ;Test set 1 - Nothing anymore. This was going to test partial control port writes to setup read targets, ;but hardware tests have shown read targets are always invalidated after a partial control port write. ;Attempting a read following a partial control port write causes the VDP to lock up. ;Initialize data at VRAM 0x7FFE move.l #$7FFE0001,$C00004 move.w #$0123,$C00000 move.w #$4567,$C00000 move.w #$89AB,$C00000 move.w #$CDEF,$C00000 move.l #$3FFE0001,$C00004 ;Read from VRAM at 0x7FFE 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 set 2 - Nothing anymore. Same as above. ;Initialize data at VRAM 0x7FFE move.l #$7FFE0001,$C00004 move.w #$0123,$C00000 move.w #$4567,$C00000 move.w #$89AB,$C00000 move.w #$CDEF,$C00000 ;Write to VRAM at 0x7FFE move.l #$7FFE0001,$C00004 move.w #$FEDC,$C00000 move.w #$BA98,$C00000 move.l #$3FFE0001,$C00004 ;Read from VRAM at 0x7FFE 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 set 3 - Register writes don't clear code register data ;Initialize data at VSRAM 0x00 move.l #$40000010,$C00004 move.w #$0111,$C00000 move.w #$0222,$C00000 move.w #$0333,$C00000 move.w #$0444,$C00000 ;Wait for the FIFO to be empty TestCodeAndAddressRegistersWaitFIFOEmpty2: move.w $C00004,D7 btst #9,D7 beq TestCodeAndAddressRegistersWaitFIFOEmpty2 ;Perform a register write move.w #$8F02,$C00004 ;Partial CP, write to VSRAM at 0x00 move.w #$4000,$C00004 move.w #$0777,$C00000 move.w #$0666,$C00000 move.l #$00000010,$C00004 ;Read from VSRAM at 0x00 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 set 4 - Register writes don't clear address register data ;Initialize data at VRAM 0x8000 move.l #$40000002,$C00004 move.w #$0123,$C00000 move.w #$4567,$C00000 move.w #$89AB,$C00000 move.w #$CDEF,$C00000 ;Wait for the FIFO to be empty TestCodeAndAddressRegistersWaitFIFOEmpty3: move.w $C00004,D7 btst #9,D7 beq TestCodeAndAddressRegistersWaitFIFOEmpty3 ;Perform a register write move.w #$8F02,$C00004 ;Partial CP, write to VRAM at 0x8000 move.w #$4000,$C00004 move.w #$FEDC,$C00000 move.w #$BA98,$C00000 move.l #$00000002,$C00004 ;Read from VRAM 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 ;Test set 5 - Address register is copied and reloaded on CP write ;Initialize data at VRAM 0xBFFE move.l #$7FFE0002,$C00004 move.w #$1100,$C00000 move.w #$3322,$C00000 move.w #$5544,$C00000 move.w #$7766,$C00000 move.w #$9988,$C00000 move.w #$BBAA,$C00000 move.w #$DDCC,$C00000 move.w #$FFEE,$C00000 ;Initialize data at VRAM 0x7FFE move.l #$7FFE0001,$C00004 move.w #$0011,$C00000 move.w #$2233,$C00000 move.w #$4455,$C00000 move.w #$6677,$C00000 move.w #$8899,$C00000 move.w #$AABB,$C00000 move.w #$CCDD,$C00000 move.w #$EEFF,$C00000 ;Wait for the FIFO to be empty TestCodeAndAddressRegistersWaitFIFOEmpty4: move.w $C00004,D7 btst #9,D7 beq TestCodeAndAddressRegistersWaitFIFOEmpty4 ;Partial CP, write to VRAM at 0x7FFE move.w #$7FFE,$C00004 move.w #$0123,$C00000 move.w #$4567,$C00000 move.w #$89AB,$C00000 move.w #$CDEF,$C00000 move.w #$FEDC,$C00000 move.l #$3FFE0001,$C00004 ;Read from VRAM at 0x7FFE 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 move.l #$3FFE0002,$C00004 ;Read from VRAM at 0xBFFE 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 set 6 - Address register is copied and reloaded on CP write, after being incremented ;by a read. ;Initialize data at VRAM 0xBFFE move.l #$7FFE0002,$C00004 move.w #$1100,$C00000 move.w #$3322,$C00000 move.w #$5544,$C00000 move.w #$7766,$C00000 move.w #$9988,$C00000 move.w #$BBAA,$C00000 move.w #$DDCC,$C00000 move.w #$FFEE,$C00000 ;Initialize data at VRAM 0x7FFE move.l #$7FFE0001,$C00004 move.w #$0011,$C00000 move.w #$2233,$C00000 move.w #$4455,$C00000 move.w #$6677,$C00000 move.w #$8899,$C00000 move.w #$AABB,$C00000 move.w #$CCDD,$C00000 move.w #$EEFF,$C00000 move.l #$3FFE0001,$C00004 ;Read from VRAM at 0x7FFE move.w $C00000,D7 move.w $C00000,D7 move.w $C00000,D7 move.w $C00000,D7 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 FIFO to be empty TestCodeAndAddressRegistersWaitFIFOEmpty5: move.w $C00004,D7 btst #9,D7 beq TestCodeAndAddressRegistersWaitFIFOEmpty5 ;Partial CP, write to VRAM at 0x7FFE move.w #$7FFE,$C00004 move.w #$0123,$C00000 move.w #$4567,$C00000 move.w #$89AB,$C00000 move.w #$CDEF,$C00000 move.w #$FEDC,$C00000 move.l #$3FFE0001,$C00004 ;Read from VRAM at 0x7FFE 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 move.l #$3FFE0002,$C00004 ;Read from VRAM at 0xBFFE 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 set 7 - More advanced version of test set 5 ;Initialize data at VRAM 0x3FFE move.l #$7FFE0000,$C00004 move.w #$FEDC,$C00000 move.w #$BA98,$C00000 move.w #$7654,$C00000 move.w #$3210,$C00000 ;Initialize data at VRAM 0xBFFE move.l #$7FFE0002,$C00004 move.w #$1032,$C00000 move.w #$5476,$C00000 move.w #$98BA,$C00000 move.w #$DCFE,$C00000 ;Initialize data at VRAM 0x7FFE move.l #$7FFE0001,$C00004 move.w #$0123,$C00000 move.w #$4567,$C00000 move.w #$89AB,$C00000 move.w #$CDEF,$C00000 ;Wait for the FIFO to be empty TestCodeAndAddressRegistersWaitFIFOEmpty1: move.w $C00004,D7 btst #9,D7 beq TestCodeAndAddressRegistersWaitFIFOEmpty1 ;Partial CP, write to VRAM at 0x7FFE (incorrect processing gives 0xBFFE or 0x3FFE) move.w #$7FFE,$C00004 move.w #$FFEE,$C00000 move.w #$DDCC,$C00000 move.l #$3FFE0000,$C00004 ;Read from VRAM at 0x3FFE 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 #$3FFE0001,$C00004 ;Read from VRAM at 0x7FFE 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 #$3FFE0002,$C00004 ;Read from VRAM at 0xBFFE 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 rts