;------------------------------------------------------------------------------------ ;Test 12 - DMA Fill to CRAM V2 ;-In: ; D3.b = Increment data ; D4.b = Text display number ; D5.b = DMA mode ;------------------------------------------------------------------------------------ TestDMAFillToVRAMV2Text: dc.b 'DMA Fill to VRAM inc=0 ' dc.b 'DMA Fill to VRAM inc=1 ' dc.b 'DMA Fill to VRAM inc=2 ' dc.b 'DMA Fill to VRAM inc=4 ' dc.b 'DMA Fill to VRAM CD4=1 inc=0 ' dc.b 'DMA Fill to VRAM CD4=1 inc=1 ' dc.b 'DMA Fill to VRAM CD4=1 inc=2 ' dc.b 'DMA Fill to VRAM CD4=1 inc=4 ' TestDMAFillToVRAMV2ExpectedResult: dc.w $02EE, $6868, $06EA, $08E8, $0AE6, $0CE4, $0EE2, $02E0, $04CE, $06CC, $08CA, $0AC8, $0CC6, $0EC4, $02C2, $04C0 dc.w $02EE, $6868, $06EA, $08E8, $0AE6, $0CE4, $0EE2, $02E0, $04CE, $06CC, $08CA, $0AC8, $0CC6, $0EC4, $02C2, $04C0 dc.w $02EE, $68AC, $6868, $6868, $0AE6, $0CE4, $0EE2, $02E0, $04CE, $06CC, $08CA, $0AC8, $0CC6, $0EC4, $02C2, $04C0 dc.w $02EE, $AC68, $6868, $6868, $0A68, $0CE4, $0EE2, $02E0, $04CE, $06CC, $08CA, $0AC8, $0CC6, $0EC4, $02C2, $04C0 dc.w $02EE, $68AC, $0668, $0868, $0A68, $0C68, $0E68, $02E0, $04CE, $06CC, $08CA, $0AC8, $0CC6, $0EC4, $02C2, $04C0 dc.w $02EE, $AC68, $68EA, $68E8, $68E6, $68E4, $68E2, $02E0, $04CE, $06CC, $08CA, $0AC8, $0CC6, $0EC4, $02C2, $04C0 dc.w $02EE, $68AC, $06EA, $0868, $0AE6, $0C68, $0EE2, $0268, $04CE, $0668, $08CA, $0A68, $0CC6, $0EC4, $02C2, $04C0 dc.w $02EE, $AC68, $06EA, $68E8, $0AE6, $68E4, $0EE2, $68E0, $04CE, $68CC, $08CA, $68C8, $0CC6, $0EC4, $02C2, $04C0 dc.w $02EE, $6868, $06EA, $08E8, $0AE6, $0CE4, $0EE2, $02E0, $04CE, $06CC, $08CA, $0AC8, $0CC6, $0EC4, $02C2, $04C0 dc.w $02EE, $6868, $06EA, $08E8, $0AE6, $0CE4, $0EE2, $02E0, $04CE, $06CC, $08CA, $0AC8, $0CC6, $0EC4, $02C2, $04C0 dc.w $02EE, $68AC, $6868, $6868, $0AE6, $0CE4, $0EE2, $02E0, $04CE, $06CC, $08CA, $0AC8, $0CC6, $0EC4, $02C2, $04C0 dc.w $02EE, $AC68, $6868, $6868, $0A68, $0CE4, $0EE2, $02E0, $04CE, $06CC, $08CA, $0AC8, $0CC6, $0EC4, $02C2, $04C0 dc.w $02EE, $68AC, $0668, $0868, $0A68, $0C68, $0E68, $02E0, $04CE, $06CC, $08CA, $0AC8, $0CC6, $0EC4, $02C2, $04C0 dc.w $02EE, $AC68, $68EA, $68E8, $68E6, $68E4, $68E2, $02E0, $04CE, $06CC, $08CA, $0AC8, $0CC6, $0EC4, $02C2, $04C0 dc.w $02EE, $68AC, $06EA, $0868, $0AE6, $0C68, $0EE2, $0268, $04CE, $0668, $08CA, $0A68, $0CC6, $0EC4, $02C2, $04C0 dc.w $02EE, $AC68, $06EA, $68E8, $0AE6, $68E4, $0EE2, $68E0, $04CE, $68CC, $08CA, $68C8, $0CC6, $0EC4, $02C2, $04C0 TestDMAFillToVRAMV2: ;Initialize the text result block move.w #36,D7 move.w #3,(A0)+ ;Set the number of display lines move.w D7,(A0)+ ;Set the text length move.w #$0040,D6 ;Set the data length move.w D6,(A0)+ lea TestDMAFillToVRAMV2Text,A1 move.w D4,D1 mulu.w D7,D1 add.l D1,A1 sub.w #1,D7 TestDMAFillToVRAMV2WriteText: move.b (A1)+,(A0)+ dbf D7,TestDMAFillToVRAMV2WriteText move.w #1,(A0)+ ;Set the expected result data present flag lea TestDMAFillToVRAMV2ExpectedResult,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 TestDMAFillToVRAMV2WriteExpectedResultData: move.b (A1)+,(A0)+ dbf D6,TestDMAFillToVRAMV2WriteExpectedResultData ;Initialize VRAM move.l #$40000002,$C00004 move.w #$0F,D0 lea TestDMAFillToVRAMV2TestData,A1 TestDMAFillToVRAMV2CRAMLoop: ; move.w #$2222,$C00000 move.w (A1)+,$C00000 dbf D0,TestDMAFillToVRAMV2CRAMLoop ;Do a DMA fill operation to VRAM address 0x8002 move.w #$0005,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 #$40020082,(A0) ;DMA fill at VRAM address 0x8002 cmp.b #$3,D4 ble TestDMAFillToVRAMV2DMASettingSelect1 move.l #$400200C2,(A0) ;DMA fill at VRAM address 0x8002 with CD5-CD4=11 TestDMAFillToVRAMV2DMASettingSelect1: 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. TestDMAFillToVRAMV2DelayLoop1: dbf D7,TestDMAFillToVRAMV2DelayLoop1 move.w #$68AC,$C00000 ;Start DMA fill with 0x68AC TestDMAFillToVRAMV2DMAWaitLoop1: move.w $C00004,D7 btst #1,D7 bne TestDMAFillToVRAMV2DMAWaitLoop1 move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Dump VRAM move.l #$00000002,$C00004 move.w #$0F,D0 TestDMAFillToVRAMV2VRAMLoop2: move.w $C00000,(A0)+ dbf D0,TestDMAFillToVRAMV2VRAMLoop2 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 VRAM move.l #$40000002,$C00004 move.w #$0F,D0 lea TestDMAFillToVRAMV2TestData,A1 TestDMAFillToVRAMV2CRAMLoop3: ; move.w #$2222,$C00000 move.w (A1)+,$C00000 dbf D0,TestDMAFillToVRAMV2CRAMLoop3 ;Do a DMA fill operation to VRAM address 0x8003 move.w #$0005,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 #$40030082,(A0) ;DMA fill at VRAM address 0x8003 cmp.b #$4,D4 ble TestDMAFillToVRAMV2DMASettingSelect2 move.l #$400300C2,(A0) ;DMA fill at VRAM address 0x8003 with CD5-CD4=11 TestDMAFillToVRAMV2DMASettingSelect2: 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. TestDMAFillToVRAMV2DelayLoop2: dbf D7,TestDMAFillToVRAMV2DelayLoop2 move.w #$68AC,$C00000 ;Start DMA fill with 0x68AC TestDMAFillToVRAMV2DMAWaitLoop2: move.w $C00004,D7 btst #1,D7 bne TestDMAFillToVRAMV2DMAWaitLoop2 move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Dump VRAM move.l #$00000002,$C00004 move.w #$0F,D0 TestDMAFillToVRAMV24RAMLoop4: move.w $C00000,(A0)+ dbf D0,TestDMAFillToVRAMV24RAMLoop4 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 VRAM move.l #$40000002,$C00004 move.w #$0F,D0 TestDMAFillToVRAMV2CRAMLoop5: move.w #$0000,$C00000 dbf D0,TestDMAFillToVRAMV2CRAMLoop5 rts TestDMAFillToVRAMV2TestData: dc.w $02EE, $04EC, $06EA, $08E8, $0AE6, $0CE4, $0EE2, $02E0, $04CE, $06CC, $08CA, $0AC8, $0CC6, $0EC4, $02C2, $04C0