;------------------------------------------------------------------------------------ ; Test - ;-Description: ;------------------------------------------------------------------------------------ TestDMABusyFlagDMAEnableToggleCopyText: dc.b 'DMA Busy Flag DMA Toggle Copy ' TestDMABusyFlagDMAEnableToggleCopyTextEnd: TestDMABusyFlagDMAEnableToggleCopyExpectedResult: dc.w $0200, $4E00, $0200, $4E00, $0200, $4E00, $0200, $4E00, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 TestDMABusyFlagDMAEnableToggleCopy: ;Initialize the text result block move.w #(TestDMABusyFlagDMAEnableToggleCopyTextEnd-TestDMABusyFlagDMAEnableToggleCopyText),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 TestDMABusyFlagDMAEnableToggleCopyText,A1 sub.w #1,D7 TestDMABusyFlagDMAEnableToggleCopyWriteText: move.b (A1)+,(A0)+ dbf D7,TestDMABusyFlagDMAEnableToggleCopyWriteText move.w #1,(A0)+ ;Set the expected result data present flag lea TestDMABusyFlagDMAEnableToggleCopyExpectedResult,A1 ;Write the expected result data to the buffer sub.w #1,D6 TestDMABusyFlagDMAEnableToggleCopyWriteExpectedResultData: move.b (A1)+,(A0)+ dbf D6,TestDMABusyFlagDMAEnableToggleCopyWriteExpectedResultData ;Load data in VRAM at 0x8000 move.l #$40000002,$C00004 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 ;Clear data in VRAM at 0x8150 move.l #$41500002,$C00004 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 ;Load data in VRAM at 0x9000 move.l #$50000002,$C00004 move.w #$0123,$C00000 move.w #$4567,$C00000 move.w #$89AB,$C00000 move.w #$CDEF,$C00000 move.w #$0123,$C00000 move.w #$4567,$C00000 move.w #$89AB,$C00000 move.w #$CDEF,$C00000 ;Wait a few cycles, to ensure the FIFO is empty before we proceed. nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ;Do a DMA copy operation from VRAM address 0x9000 to 0x8002 with the DMA enable bit disabled move.w #$0100,D1 move.w #$8F01,$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 move.w #$9690,$C00004 move.w #$97C0,$C00004 move.l #$000200C2,(A0) ;DMA copy to VRAM address 0x8002 move.l (A0),$C00004 ;Test status register move.w $C00004,D5 and.w #$FF02,D5 move.w D5,(A0)+ move.w $C00004,D5 nop and.w #$FF02,D5 move.w D5,(A0)+ ;Wait a long time to give the DMA operation sufficient time to complete move.w #$7FFF,D6 TestDMABusyFlagDMAEnableToggleCopyDMAWaitLoop1: dbf D6,TestDMABusyFlagDMAEnableToggleCopyDMAWaitLoop1 ;Test status register move.w $C00004,D5 and.w #$FF02,D5 move.w D5,(A0)+ move.w $C00004,D5 nop and.w #$FF02,D5 move.w D5,(A0)+ ;Enable DMA. Note that this will modify the address and code registers, but we account for that. move.w #$8154,$C00004 ;##TODO## Consider inserting some wait cycles in here ;Test status register move.w $C00004,D5 and.w #$FF02,D5 move.w D5,(A0)+ move.w $C00004,D5 nop and.w #$FF02,D5 move.w D5,(A0)+ ;Wait a long time to give the DMA operation sufficient time to complete move.w #$7FFF,D6 TestDMABusyFlagDMAEnableToggleCopyDMAWaitLoop2: dbf D6,TestDMABusyFlagDMAEnableToggleCopyDMAWaitLoop2 ;Test status register move.w $C00004,D5 and.w #$FF02,D5 move.w D5,(A0)+ move.w $C00004,D5 nop and.w #$FF02,D5 move.w D5,(A0)+ ;Disable DMA, and restore the increment data. move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Test target memory move.l #$00000002,$C00004 ;Read from VRAM at 0x8000 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 move.l #$01520002,$C00004 ;Read from VRAM at 0x8152 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 ;Clear data in VRAM at 0x8000-0xA000 move.l #$40000002,$C00004 move.w #$1000,D7 TestDMABusyFlagDMAEnableToggleCopyClearVRAMLoop: move.w #$0000,$C00000 dbf D7,TestDMABusyFlagDMAEnableToggleCopyClearVRAMLoop rts