;----------------------------------------------------------------------------------------- ; 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 ; D4 = Write mask ;-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 inc=0 ' dc.b 'DMA Copy 9000 to 8000 inc=1 ' dc.b 'DMA Copy 9000 to 8000 inc=2 ' dc.b 'DMA Copy 9000 to 8000 inc=4 ' dc.b 'DMA Copy 8000 to 8002 for 0A ' dc.b 'DMA Copy 8000 to 8001 for 0A ' dc.b 'DMA Copy 8001 to 8003 for 0A ' 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 9000 to 8000 CD0-3=0000 ' dc.b 'DMA Copy 9000 to 8000 CD0-3=0001 ' dc.b 'DMA Copy 9000 to 8000 CD0-3=0011 ' dc.b 'DMA Copy 9000 to 8000 CD0-3=0100 ' dc.b 'DMA Copy 9000 to 8000 CD0-3=0101 ' dc.b 'DMA Copy 9000 to 8000 CD0-3=0111 ' dc.b 'DMA Copy 9000 to 8000 CD0-3=1000 ' dc.b 'DMA Copy 9000 to 8000 CD0-3=1001 ' dc.b 'DMA Copy 9000 to 8000 CD0-3=1011 ' dc.b 'DMA Copy 9000 to 8000 CD0-3=1100 ' dc.b 'DMA Copy 9000 to 8000 CD0-3=1101 ' dc.b 'DMA Copy 9000 to 8000 CD0-3=1111 ' TestDMACopyExpectedResult: dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $F044, $F00D, $F00D, $F00D, $F00D, $F00D, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $1122, $F044, $F00D, $F00D, $F00D, $F00D, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $F022, $F011, $F044, $F00D, $F00D, $F00D, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $F022, $F00D, $F011, $F00D, $F044, $F00D, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $1122, $1122, $1122, $1122, $1122, $DDEE, $FF00, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $2222, $2222, $2222, $2222, $2222, $BB22, $DDEE, $FF00 dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $1144, $1144, $1144, $1144, $1144, $DD44, $FF00, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $1122, $3344, $5566, $7788, $F0AA, $F00D, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $220D, $4411, $6633, $8855, $AA77, $F00D, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $4411, $6633, $8855, $AA77, $F099, $F00D, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $110D, $3344, $5566, $7788, $99AA, $F00D, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $1122, $3344, $5566, $7788, $99AA, $F00D, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $220D, $4411, $6633, $8855, $AA77, $F099, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $4411, $6633, $8855, $AA77, $CC99, $F00D, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $110D, $3344, $5566, $7788, $99AA, $F0CC, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $1122, $3344, $5566, $7788, $F0AA, $F00D, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $1122, $3344, $5566, $7788, $F0AA, $F00D, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $1122, $3344, $5566, $7788, $F0AA, $F00D, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $1122, $3344, $5566, $7788, $F0AA, $F00D, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $1122, $3344, $5566, $7788, $F0AA, $F00D, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $1122, $3344, $5566, $7788, $F0AA, $F00D, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $1122, $3344, $5566, $7788, $F0AA, $F00D, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $1122, $3344, $5566, $7788, $F0AA, $F00D, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $1122, $3344, $5566, $7788, $F0AA, $F00D, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $1122, $3344, $5566, $7788, $F0AA, $F00D, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $1122, $3344, $5566, $7788, $F0AA, $F00D, $F00D, $F00D dc.w $9923, $93EE, $B923, $B3EE, $D923, $D3EE, $F923, $F3EE, $1122, $3344, $5566, $7788, $F0AA, $F00D, $F00D, $F00D 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 ;Initialize CRAM move.l #$C0000000,$C00004 move.w #$3F,D7 lea TestDMACopyCRAMTestData,A1 TestDMACopyCRAMLoop: ; move.w #$2222,$C00000 move.w (A1)+,$C00000 dbf D7,TestDMACopyCRAMLoop ;Initialize VSRAM move.l #$40000010,$C00004 move.w #$3F,D7 lea TestDMACopyVSRAMTestData,A1 TestDMACopyVSRAMLoop: ; move.w #$2222,$C00000 move.w (A1)+,$C00000 dbf D7,TestDMACopyVSRAMLoop ;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 ;Select the increment data to use with this test move.w #$8F00,$C00004 cmp.b #0,D3 ble TestDMACopyStartCopy move.w #$8F01,$C00004 cmp.b #1,D3 ble TestDMACopyStartCopy move.w #$8F02,$C00004 cmp.b #2,D3 ble TestDMACopyStartCopy move.w #$8F04,$C00004 cmp.b #3,D3 ble TestDMACopyStartCopy move.w #$8F01,$C00004 ;Do a DMA copy operation from the source VRAM address to the target VRAM address TestDMACopyStartCopy: 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 write mask with the build address or.l D4,D7 ; move.l D7,(A0) ;DMA copy to target VRAM address ; move.l (A0),$C00004 move.l D7,$C00004 ;DMA copy to target VRAM address TestDMACopyDMAWaitLoop3: move.w $C00004,D5 btst #1,D5 bne TestDMACopyDMAWaitLoop3 move.w #$8144,$C00004 move.w #$8F02,$C00004 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 TestDMACopyCRAMTestData: dc.w $02EE, $04EC, $06EA, $08E8, $0AE6, $0CE4, $0EE2, $02E0, $04CE, $06CC, $08CA, $0AC8, $0CC6, $0EC4, $02C2, $04C0 dc.w $06AE, $08AC, $0AAA, $0CA8, $0EA6, $02A4, $04A2, $06A0, $088E, $0A8C, $0C8A, $0E88, $0286, $0484, $0682, $0880 dc.w $0A6E, $0C6C, $0E6A, $0268, $0466, $0664, $0862, $0A60, $0C4E, $0E4C, $024A, $0448, $0646, $0844, $0A42, $0C40 dc.w $0E2E, $022C, $042A, $0628, $0826, $0A24, $0C22, $0E20, $020E, $040C, $060A, $0808, $0A06, $0C04, $0E02, $0200 TestDMACopyVSRAMTestData: dc.w $0123, $0123, $03EA, $04E8, $05E6, $06E4, $07E2, $01E0, $02CE, $03CC, $04CA, $05C8, $06C6, $07C4, $01C2, $02C0 dc.w $03AE, $04AC, $05AA, $06A8, $07A6, $01A4, $02A2, $03A0, $048E, $058C, $068A, $0788, $0186, $0284, $0382, $0480 dc.w $056E, $066C, $076A, $0168, $0266, $0364, $0462, $0560, $064E, $074C, $014A, $0248, $0346, $0444, $0542, $0640 dc.w $072E, $012C, $022A, $0328, $0426, $0524, $0622, $0720, $010E, $020C, $030A, $0408, $0506, $0604, $0702, $0100