;---------------------------------------------------------------------------------------- TestFIFOFullDMATransferDataBlock: dc.w $1122, $3344, $5566, $7788, $99AA, $BBCC, $DDEE TestFIFOFullDMATransferText: dc.b 'FIFO Full Before DMA Transfer ' TestFIFOFullDMATransferTextEnd: TestFIFOFullDMATransferExpectedResult: dc.w $1234, $1122, $3344, $5566, $7788, $99AA, $BBCC, $DDEE, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 TestFIFOFullDMATransfer: ;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 TestFIFOFullDMATransferText,A1 ;Write the text to the buffer move.w D3,D5 mulu.w D7,D5 add.l D5,A1 sub.w #1,D7 TestFIFOFullDMATransferWriteText: move.b (A1)+,(A0)+ dbf D7,TestFIFOFullDMATransferWriteText move.w #1,(A0)+ ;Set the expected result data present flag lea TestFIFOFullDMATransferExpectedResult,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 TestFIFOFullDMATransferWriteExpectedResultData: move.b (A1)+,(A0)+ dbf D6,TestFIFOFullDMATransferWriteExpectedResultData ;Initialize 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 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 ;Do a DMA transfer to the target move.l #TestFIFOFullDMATransferDataBlock,D0 move.w #$0007,D1 move.w #$8F02,$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, D2 lsr.l #1,D0 move.b D0,D2 move.w D2,$C00004 move.w #$9600, D2 lsr.l #8,D0 move.b D0,D2 move.w D2,$C00004 move.w #$9700, D2 lsr.l #8,D0 move.b D0,D2 move.l #$40020082,(A0) ;DMA transfer to VRAM address 0x8002 move.w #$0100,D6 TestFIFOFullDMATransferAttempt: sub.w #1,D6 beq TestFIFOFullDMATransferAttemptAbort ;Wait for the FIFO to be empty TestFIFOFullDMATransferWaitFIFOEmpty: btst #1,$C00004 beq TestFIFOFullDMATransferWaitFIFOEmpty ;Load test data into VRAM at 0x8000 move.l #$40000002,$C00004 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.l #$40000002,$C00004 move.w #$1234,$C00000 move.w #$5678,$C00000 move.w #$9ABC,$C00000 move.w #$DEF0,$C00000 ;Make sure the FIFO is full before we start the DMA transfer btst #0,$C00004 beq TestFIFOFullDMATransferAttempt ;We do the transfer to initiate the DMA operation using RAM here, otherwise we almost ;always get a lockup on the real hardware. move.w #$8154,$C00004 move.w D2,$C00004 move.l (A0),$C00004 move.w #$8F02,$C00004 move.w #$8144,$C00004 TestFIFOFullDMATransferAttemptAbort: ;Do some writes to VRAM at 0x9000 to clear the FIFO move.l #$50000002,$C00004 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 move.w #$0000,$C00000 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)+ 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)+ 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