;----------------------------------------------------------------------------------------- ; Test - DMA Copy ;-Description: ; This test is designed to examine the behaviour of a DMA copy operation in some edge ; cases. ;-Expected result: ; 1. 9800 9100 B800 B100 D800 D100 F800 F100 1122 3344 5566 7788 F0AA F00D F00D F00D (0x9000 to 0x8000 for 0x09) ; 2. 9800 9100 B800 B100 D800 D100 F800 F100 220D 4411 6633 8855 AA77 F00D F00D F00D (0x9000 to 0x8001 for 0x09) ; 3. 9800 9100 B800 B100 D800 D100 F800 F100 4411 6633 8855 AA77 F099 F00D F00D F00D (0x9001 to 0x8000 for 0x09) ; 4. 9800 9100 B800 B100 D800 D100 F800 F100 110D 3344 5566 7788 99AA F00D F00D F00D (0x9001 to 0x8001 for 0x09) ; 5. 9800 9100 B800 B100 D800 D100 F800 F100 1122 3344 5566 7788 99AA F00D F00D F00D (0x9000 to 0x8000 for 0x0A) ; 6. 9800 9100 B800 B100 D800 D100 F800 F100 220D 4411 6633 8855 AA77 F099 F00D F00D (0x9000 to 0x8001 for 0x0A) ; 7. 9800 9100 B800 B100 D800 D100 F800 F100 4411 6633 8855 AA77 CC99 F00D F00D F00D (0x9001 to 0x8000 for 0x0A) ; 8. 9800 9100 B800 B100 D800 D100 F800 F100 110D 3344 5566 7788 99AA F0CC F00D F00D (0x9001 to 0x8001 for 0x0A) ; 9. 9800 9100 B800 B100 D800 D100 F800 F100 1122 1122 1122 1122 1122 DDEE FF00 F00D (0x8000 to 0x8002 for 0x0A) ;10. 9800 9100 B800 B100 D800 D100 F800 F100 2222 2222 2222 2222 2222 BB22 DDEE FF00 (0x8000 to 0x8001 for 0x0A) ;-In: ; D0 = VRAM source address ; D1 = VRAM target address ; D2 = Copy count ; D3 = Text display number ;-Out: ; D6 = Invalid ; D7 = Invalid ;##NOTE## This is the only test we still see locking up the hardware ;##NOTE## We've seen only once or twice, a different result read. Confirmed alteration is as follows: ; 7. 9800 9100 B800 B100 DD00 D100 F800 F100 4411 6633 8855 AA77 CC99 F00D F00D F00D (0x9001 to 0x8000 for 0x0A) ;10. 9800 9100 B800 B100 DD00 D100 F800 F100 2222 2222 2222 2222 2222 BB22 DDEE FF00 (0x8000 to 0x8001 for 0x0A) ;----------------------------------------------------------------------------------------- TestDMACopyText: dc.b 'DMA Copy 9000 to 8000 for 09 ' dc.b 'DMA Copy 9000 to 8001 for 09 ' dc.b 'DMA Copy 9001 to 8000 for 09 ' dc.b 'DMA Copy 9001 to 8001 for 09 ' dc.b 'DMA Copy 9000 to 8000 for 0A ' dc.b 'DMA Copy 9000 to 8001 for 0A ' dc.b 'DMA Copy 9001 to 8000 for 0A ' dc.b 'DMA Copy 9001 to 8001 for 0A ' dc.b 'DMA Copy 8000 to 8002 for 0A ' dc.b 'DMA Copy 8000 to 8001 for 0A ' TestDMACopyExpectedResult: dc.w $9800, $9100, $B800, $B100, $D800, $D100, $F800, $F100, $1122, $3344, $5566, $7788, $F0AA, $F00D, $F00D, $F00D dc.w $9800, $9100, $B800, $B100, $D800, $D100, $F800, $F100, $220D, $4411, $6633, $8855, $AA77, $F00D, $F00D, $F00D dc.w $9800, $9100, $B800, $B100, $D800, $D100, $F800, $F100, $4411, $6633, $8855, $AA77, $F099, $F00D, $F00D, $F00D dc.w $9800, $9100, $B800, $B100, $D800, $D100, $F800, $F100, $110D, $3344, $5566, $7788, $99AA, $F00D, $F00D, $F00D dc.w $9800, $9100, $B800, $B100, $D800, $D100, $F800, $F100, $1122, $3344, $5566, $7788, $99AA, $F00D, $F00D, $F00D dc.w $9800, $9100, $B800, $B100, $D800, $D100, $F800, $F100, $220D, $4411, $6633, $8855, $AA77, $F099, $F00D, $F00D dc.w $9800, $9100, $B800, $B100, $D800, $D100, $F800, $F100, $4411, $6633, $8855, $AA77, $CC99, $F00D, $F00D, $F00D dc.w $9800, $9100, $B800, $B100, $D800, $D100, $F800, $F100, $110D, $3344, $5566, $7788, $99AA, $F0CC, $F00D, $F00D dc.w $9800, $9100, $B800, $B100, $D800, $D100, $F800, $F100, $1122, $1122, $1122, $1122, $1122, $DDEE, $FF00, $F00D dc.w $9800, $9100, $B800, $B100, $D800, $D100, $F800, $F100, $2222, $2222, $2222, $2222, $2222, $BB22, $DDEE, $FF00 TestDMACopy: ;Initialize the text result block move.w #36,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 TestDMACopyText,A1 ;Write the text to the buffer move.w D3,D5 mulu.w D7,D5 add.l D5,A1 sub.w #1,D7 TestDMACopyWriteText: move.b (A1)+,(A0)+ dbf D7,TestDMACopyWriteText move.w #1,(A0)+ ;Set the expected result data present flag lea TestDMACopyExpectedResult,A1 ;Write the expected result data to the buffer move.w D3,D5 mulu.w D6,D5 add.l D5,A1 sub.w #1,D6 TestDMACopyWriteExpectedResultData: move.b (A1)+,(A0)+ dbf D6,TestDMACopyWriteExpectedResultData ;Clear data in VRAM at the target address move.w D1,D6 and.w #$FFFE,D6 ;Mask the LSB of the address move.w D6,D7 lsl.l #8,D7 lsl.l #8,D7 lsr.w #8,D6 lsr.w #6,D6 move.w D6,D7 and.l #$3FFF0003,D7 or.l #$40000000,D7 move.l D7,$C00004 move.w #$F00D,$C00000 move.w #$F00D,$C00000 move.w #$F00D,$C00000 move.w #$F00D,$C00000 move.w #$F00D,$C00000 move.w #$F00D,$C00000 move.w #$F00D,$C00000 move.w #$F00D,$C00000 ;Load data in VRAM at the source address move.w D0,D6 and.w #$FFFE,D6 ;Mask the LSB of the address move.w D6,D7 lsl.l #8,D7 lsl.l #8,D7 lsr.w #8,D6 lsr.w #6,D6 move.w D6,D7 and.l #$3FFF0003,D7 or.l #$40000000,D7 move.l D7,$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 #$FF00,$C00000 ;Do a DMA copy operation from the source VRAM address to the target VRAM address move.w #$8154,$C00004 move.w #$8F01,$C00004 move.w #$9300, D7 move.w D2,D6 move.b D6,D7 move.w D7,$C00004 move.w #$9400, D7 lsr.l #8,D6 move.b D6,D7 move.w D7,$C00004 move.w #$9500, D7 move.w D0,D6 move.b D6,D7 move.w D7,$C00004 move.w #$9600, D7 lsr.l #8,D6 move.b D6,D7 move.w D7,$C00004 move.w #$97C0,$C00004 ;Convert the VRAM target address into the form needed for the control port writes move.w D1,D6 move.w D6,D7 lsl.l #8,D7 lsl.l #8,D7 lsr.w #8,D6 lsr.w #6,D6 move.w D6,D7 and.l #$3FFF0003,D7 ;Combine the VRAM write mask with the build address or.l #$000000C0,D7 move.l D7,(A0) ;DMA copy to target VRAM address move.l (A0),$C00004 ; nop ; nop ; nop ; nop DMAWaitLoop3: move.w $C00004,D5 btst #1,D5 bne DMAWaitLoop3 move.w #$8144,$C00004 move.w #$8F02,$C00004 ; 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.l #$00000010,$C00004 ;Read from VSRAM 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 #$00000020,$C00004 ;Read from CRAM 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 #$00000010,$C00004 ;Read from VSRAM 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 #$00000020,$C00004 ;Read from CRAM 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 #$00000010,$C00004 ;Read from VSRAM 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 #$00000020,$C00004 ;Read from CRAM 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 #$00000010,$C00004 ;Read from VSRAM 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 #$00000020,$C00004 ;Read from CRAM 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 D1,D6 ;Read from VRAM at the target address and.w #$FFFE,D6 ;Mask the LSB of the address move.w D6,D7 lsl.l #8,D7 lsl.l #8,D7 lsr.w #8,D6 lsr.w #6,D6 move.w D6,D7 and.l #$3FFF0003,D7 or.l #$00000000,D7 move.l D7,$C00004 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 rts