;------------------------------------------------------------------------------------ ;Test 12 - DMA Copy to VSRAM V2 ;-In: ; D3.b = Increment data ; D4.b = Text display number ; D5.b = DMA mode ;------------------------------------------------------------------------------------ TestDMACopyToVSRAMV2Text: dc.b 'DMA Copy to VSRAM inc=1 ' dc.b 'DMA Copy to VSRAM inc=2 ' dc.b 'DMA Copy to VSRAM inc=4 ' TestDMACopyToVSRAMV2ExpectedResult: 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, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123 dc.w $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123 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, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123 dc.w $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123 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, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123 dc.w $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123 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, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123 dc.w $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123 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, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123 dc.w $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123 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, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123 dc.w $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123, $0123 TestDMACopyToVSRAMV2: ;Initialize the text result block move.w #36,D7 move.w #9,(A0)+ ;Set the number of display lines move.w D7,(A0)+ ;Set the text length move.w #$0100,D6 ;Set the data length move.w D6,(A0)+ lea TestDMACopyToVSRAMV2Text,A1 move.w D4,D1 mulu.w D7,D1 add.l D1,A1 sub.w #1,D7 TestDMACopyToVSRAMV2WriteText: move.b (A1)+,(A0)+ dbf D7,TestDMACopyToVSRAMV2WriteText move.w #1,(A0)+ ;Set the expected result data present flag lea TestDMACopyToVSRAMV2ExpectedResult,A1 ;Write the expected result data to the buffer move.w D4,D1 mulu.w D6,D1 add.l D1,A1 sub.w #1,D6 TestDMACopyToVSRAMV2WriteExpectedResultData: move.b (A1)+,(A0)+ dbf D6,TestDMACopyToVSRAMV2WriteExpectedResultData ;Initialize VSRAM move.l #$40000010,$C00004 move.w #$3F,D0 lea TestDMACopyToVSRAMV2TestData,A1 TestDMACopyToVSRAMV2VSRAMLoop: ; move.w #$2222,$C00000 move.w (A1)+,$C00000 dbf D0,TestDMACopyToVSRAMV2VSRAMLoop ;Do a DMA fill operation to VSRAM address 0x20 move.w #$0009,D1 move.w #$8F00, D2 move.b D3,D2 move.w D2,$C00004 move.w #$8154,$C00004 move.w #$9300, D2 move.b D1,D2 move.w D2,$C00004 move.w #$9400, D2 lsr.l #8,D1 move.b D1,D2 move.w D2,$C00004 move.w #$9500,$C00004 ;Set the DMA source register to 0x0000 move.w #$9600,$C00004 move.w #$9700, D2 move.b D5,D2 move.w D2,$C00004 move.l #$002000D0,(A0) ;DMA copy to VSRAM address 0x20 nop ;If we uncomment this block, we get corrupted write data at the start of the nop ;fill. If we don't have any wait cycles between the control port write and the nop ;data port write, the written data is usually correct, with the exception that nop ;the byte order of the first write is reversed. If we do insert wait states nop ;between the control port write and the data port write, without any wait states nop ;before the control port write, the fill starts with a fill data of 0x00, and at nop ;some point during the fill operation, usually 4 or 5 bytes in, the data port nop ;write then occurs, and the fill operation from then on picks up the correct fill nop ;data from that data port write. In other words, if we don't insert a wait state nop ;between when we set all our registers for a fill above, and when we actually nop ;perform the control port write to setup for the fill operation, the fill can nop ;inadvertantly trigger immediately when the control port write is made, without nop ;waiting for the data port write to occur. We have found from testing that at nop ;least 20 NOP cycles are required in order to get reliable results, when the nop ;control port write occurs as a long word write from RAM. nop nop nop nop nop move.l (A0),$C00004 move.w #$0080,D7 ;Add a small delay loop before writing to the data port, just in case we actually kicked off a DMA copy operation. TestDMACopyToVSRAMV2DelayLoop1: dbf D7,TestDMACopyToVSRAMV2DelayLoop1 move.w #$68AC,$C00000 ;Start DMA fill with 0x68AC TestDMACopyToVSRAMV2DMAWaitLoop1: move.w $C00004,D7 btst #1,D7 bne TestDMACopyToVSRAMV2DMAWaitLoop1 move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Dump VSRAM move.l #$00000010,$C00004 move.w #$3F,D0 TestDMACopyToVSRAMV2VSRAMLoop2: move.w $C00000,(A0)+ dbf D0,TestDMACopyToVSRAMV2VSRAMLoop2 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 VSRAM move.l #$40000010,$C00004 move.w #$3F,D0 lea TestDMACopyToVSRAMV2TestData,A1 TestDMACopyToVSRAMV2VSRAMLoop3: ; move.w #$2222,$C00000 move.w (A1)+,$C00000 dbf D0,TestDMACopyToVSRAMV2VSRAMLoop3 ;Do a DMA fill operation to VSRAM address 0x21 move.w #$0009,D1 move.w #$8F00, D2 move.b D3,D2 move.w D2,$C00004 move.w #$8154,$C00004 move.w #$9300, D2 move.b D1,D2 move.w D2,$C00004 move.w #$9400, D2 lsr.l #8,D1 move.b D1,D2 move.w D2,$C00004 move.w #$9500,$C00004 ;Set the DMA source register to 0x0000 move.w #$9600,$C00004 move.w #$9700, D2 move.b D5,D2 move.w D2,$C00004 move.l #$002100D0,(A0) ;DMA copy to VSRAM address 0x21 nop ;If we uncomment this block, we get corrupted write data at the start of the nop ;fill. If we don't have any wait cycles between the control port write and the nop ;data port write, the written data is usually correct, with the exception that nop ;the byte order of the first write is reversed. If we do insert wait states nop ;between the control port write and the data port write, without any wait states nop ;before the control port write, the fill starts with a fill data of 0x00, and at nop ;some point during the fill operation, usually 4 or 5 bytes in, the data port nop ;write then occurs, and the fill operation from then on picks up the correct fill nop ;data from that data port write. In other words, if we don't insert a wait state nop ;between when we set all our registers for a fill above, and when we actually nop ;perform the control port write to setup for the fill operation, the fill can nop ;inadvertantly trigger immediately when the control port write is made, without nop ;waiting for the data port write to occur. We have found from testing that at nop ;least 20 NOP cycles are required in order to get reliable results, when the nop ;control port write occurs as a long word write from RAM. nop nop nop nop nop move.l (A0),$C00004 move.w #$0080,D7 ;Add a small delay loop before writing to the data port, just in case we actually kicked off a DMA copy operation. TestDMACopyToVSRAMV2DelayLoop2: dbf D7,TestDMACopyToVSRAMV2DelayLoop2 move.w #$68AC,$C00000 ;Start DMA fill with 0x68AC TestDMACopyToVSRAMV2DMAWaitLoop2: move.w $C00004,D7 btst #1,D7 bne TestDMACopyToVSRAMV2DMAWaitLoop2 move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Dump VSRAM move.l #$00000010,$C00004 move.w #$3F,D0 TestDMACopyToVSRAMV2VSRAMLoop4: move.w $C00000,(A0)+ dbf D0,TestDMACopyToVSRAMV2VSRAMLoop4 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 VSRAM move.l #$40000010,$C00004 move.w #$3F,D0 TestDMACopyToVSRAMV2VSRAMLoop5: move.w #$0000,$C00000 dbf D0,TestDMACopyToVSRAMV2VSRAMLoop5 rts TestDMACopyToVSRAMV2TestData: 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