;------------------------------------------------------------------------------------ ;Test 12 - DMA Fill to VSRAM V2 ;-In: ; D3.b = Increment data ; D4.b = Text display number ; D5.b = DMA mode ;------------------------------------------------------------------------------------ TestDMAFillToVSRAMV2Text: dc.b 'DMA Fill to VSRAM inc=0 ' dc.b 'DMA Fill to VSRAM inc=1 ' dc.b 'DMA Fill to VSRAM inc=2 ' dc.b 'DMA Fill to VSRAM inc=4 ' dc.b 'DMA Fill to VSRAM CD4=1 inc=0 ' dc.b 'DMA Fill to VSRAM CD4=1 inc=1 ' dc.b 'DMA Fill to VSRAM CD4=1 inc=2 ' dc.b 'DMA Fill to VSRAM CD4=1 inc=4 ' TestDMAFillToVSRAMV2ExpectedResult: dc.w $0123, $0123, $03EA, $04E8, $05E6, $06E4, $07E2, $01E0, $02CE, $03CC, $04CA, $05C8, $06C6, $07C4, $01C2, $02C0 dc.w $0604, $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 $0604, $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 $0604, $0604, $0604, $0604, $0604, $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 $00AC, $0604, $0604, $0604, $0604, $0604, $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 $00AC, $0604, $0604, $0604, $0604, $0604, $0604, $0604, $0604, $0604, $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 $00AC, $0604, $0604, $0604, $0604, $0604, $0604, $0604, $0604, $0604, $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 $00AC, $04AC, $0604, $06A8, $0604, $01A4, $0604, $03A0, $0604, $058C, $0604, $0788, $0604, $0284, $0604, $0480 dc.w $0604, $066C, $0604, $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 $00AC, $04AC, $0604, $06A8, $0604, $01A4, $0604, $03A0, $0604, $058C, $0604, $0788, $0604, $0284, $0604, $0480 dc.w $0604, $066C, $0604, $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 $0604, $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 $0604, $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 $0604, $0604, $0604, $0604, $0604, $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 $00AC, $0604, $0604, $0604, $0604, $0604, $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 $00AC, $0604, $0604, $0604, $0604, $0604, $0604, $0604, $0604, $0604, $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 $00AC, $0604, $0604, $0604, $0604, $0604, $0604, $0604, $0604, $0604, $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 $00AC, $04AC, $0604, $06A8, $0604, $01A4, $0604, $03A0, $0604, $058C, $0604, $0788, $0604, $0284, $0604, $0480 dc.w $0604, $066C, $0604, $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 $00AC, $04AC, $0604, $06A8, $0604, $01A4, $0604, $03A0, $0604, $058C, $0604, $0788, $0604, $0284, $0604, $0480 dc.w $0604, $066C, $0604, $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 $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $20AC, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $20AC, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $20AC, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $20AC, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $20AC, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 dc.w $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222, $2222 TestDMAFillToVSRAMV2: ;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 TestDMAFillToVSRAMV2Text,A1 move.w D4,D1 mulu.w D7,D1 add.l D1,A1 sub.w #1,D7 TestDMAFillToVSRAMV2WriteText: move.b (A1)+,(A0)+ dbf D7,TestDMAFillToVSRAMV2WriteText move.w #1,(A0)+ ;Set the expected result data present flag lea TestDMAFillToVSRAMV2ExpectedResult,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 TestDMAFillToVSRAMV2WriteExpectedResultData: move.b (A1)+,(A0)+ dbf D6,TestDMAFillToVSRAMV2WriteExpectedResultData ;Initialize VSRAM move.l #$40000010,$C00004 move.w #$3F,D0 lea TestDMAFillToVSRAMV2TestData,A1 TestDMAFillToVSRAMV2VSRAMLoop: ; move.w #$2222,$C00000 move.w (A1)+,$C00000 dbf D0,TestDMAFillToVSRAMV2VSRAMLoop ;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, just in case it is used in some way. move.w #$9600,$C00004 move.w #$9700, D2 move.b D5,D2 move.w D2,$C00004 move.l #$40200090,(A0) ;DMA fill at VSRAM address 0x20 cmp.b #$3,D4 ble TestDMAFillToVSRAMV2DMASettingSelect1 move.l #$402000D0,(A0) ;DMA fill at VSRAM address 0x20 with CD5-CD4=11 TestDMAFillToVSRAMV2DMASettingSelect1: 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. TestDMAFillToVSRAMV2DelayLoop1: dbf D7,TestDMAFillToVSRAMV2DelayLoop1 move.w #$68AC,$C00000 ;Start DMA fill with 0x68AC TestDMAFillToVSRAMV2DMAWaitLoop1: move.w $C00004,D7 btst #1,D7 bne TestDMAFillToVSRAMV2DMAWaitLoop1 move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Dump VSRAM move.l #$00000010,$C00004 move.w #$3F,D0 TestDMAFillToVSRAMV2VSRAMLoop2: move.w $C00000,(A0)+ dbf D0,TestDMAFillToVSRAMV2VSRAMLoop2 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 TestDMAFillToVSRAMV2TestData,A1 TestDMAFillToVSRAMV2VSRAMLoop3: ; move.w #$2222,$C00000 move.w (A1)+,$C00000 dbf D0,TestDMAFillToVSRAMV2VSRAMLoop3 ;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, just in case it is used in some way. move.w #$9600,$C00004 move.w #$9700, D2 move.b D5,D2 move.w D2,$C00004 move.l #$40210090,(A0) ;DMA fill at VSRAM address 0x21 cmp.b #$4,D4 ble TestDMAFillToVSRAMV2DMASettingSelect2 move.l #$402100D0,(A0) ;DMA fill at VSRAM address 0x21 with CD5-CD4=11 TestDMAFillToVSRAMV2DMASettingSelect2: 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. TestDMAFillToVSRAMV2DelayLoop2: dbf D7,TestDMAFillToVSRAMV2DelayLoop2 move.w #$68AC,$C00000 ;Start DMA fill with 0x68AC TestDMAFillToVSRAMV2DMAWaitLoop2: move.w $C00004,D7 btst #1,D7 bne TestDMAFillToVSRAMV2DMAWaitLoop2 move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Dump VSRAM move.l #$00000010,$C00004 move.w #$3F,D0 TestDMAFillToVSRAMV2VSRAMLoop4: move.w $C00000,(A0)+ dbf D0,TestDMAFillToVSRAMV2VSRAMLoop4 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 TestDMAFillToVSRAMV2VSRAMLoop5: move.w #$0000,$C00000 dbf D0,TestDMAFillToVSRAMV2VSRAMLoop5 rts TestDMAFillToVSRAMV2TestData: 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