;------------------------------------------------------------------------------------ TestDMATransferBusLockDataBlock: dc.w $0011, $2233, $4455, $6677, $8899 TestDMATransferBusLockText: dc.b 'DMA Transfer Bus Locking ' TestDMATransferBusLockTextEnd: TestDMATransferBusLockExpectedResult: dc.w $0000, $0011, $2233, $4455, $6677, $8899, $FFEE, $0000, $0000, $0011, $2233, $4455, $6677, $8899, $0000, $0000 dc.w $0000, $0011, $2233, $4455, $6677, $8899, $FFEE, $0000, $0000, $0011, $2233, $4455, $6677, $8899, $0000, $0000 dc.w $0000, $0011, $2233, $4455, $6677, $8899, $FFEE, $0000, $0000, $0011, $2233, $4455, $6677, $8899, $0000, $0000 dc.w $0000, $0011, $2233, $4455, $6677, $8899, $0000, $0000, $0000, $0011, $2233, $4455, $6677, $8899, $0000, $0000 TestDMATransferBusLock: ;Initialize the text result block move.w #(TestDMATransferBusLockTextEnd-TestDMATransferBusLockText),D7 move.w #5,(A0)+ ;Set the number of display lines move.w D7,(A0)+ ;Set the text length move.w #$0080,D6 ;Set the data length move.w D6,(A0)+ lea TestDMATransferBusLockText,A1 sub.w #1,D7 TestDMATransferBusLockWriteText: move.b (A1)+,(A0)+ dbf D7,TestDMATransferBusLockWriteText move.w #1,(A0)+ ;Set the expected result data present flag lea TestDMATransferBusLockExpectedResult,A1 ;Write the expected result data to the buffer sub.w #1,D6 TestDMATransferBusLockWriteExpectedResultData: move.b (A1)+,(A0)+ dbf D6,TestDMATransferBusLockWriteExpectedResultData ;---------------------------Test block 1----------------------------------- ;Clear 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 ;Do a DMA transfer operation from the source data block to 0x8002 move.l #TestDMATransferBusLockDataBlock,D0 move.w #$0005,D1 move.w #$8154,$C00004 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.w D2,$C00004 ;We do the transfer to initiate the DMA operation using RAM here, otherwise we almost ;always get a lockup on the real hardware. move.l #$40020082,(A0) ;DMA transfer to VRAM address 0x8002 move.l (A0),$C00004 move.w #$FFEE,$C00000 ;Data port write to incremented address after DMA transfer ;Disable DMA, and restore the increment data. move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Read from VRAM at 0x8000 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)+ 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 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 ;Do a DMA transfer operation from the source data block to 0x8002 move.l #TestDMATransferBusLockDataBlock,D0 move.w #$0005,D1 move.w #$8154,$C00004 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.w D2,$C00004 ;We do the transfer to initiate the DMA operation using RAM here, otherwise we almost ;always get a lockup on the real hardware. move.l #$40020082,(A0) ;DMA transfer to VRAM address 0x8002 move.l (A0),$C00004 move.w #$8F01,$C00004 ;Register write after DMA transfer ;Disable DMA, and restore the increment data. move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Read from VRAM at 0x8000 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)+ 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 ;---------------------------Test block 2----------------------------------- ;Clear 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 ;Do a DMA transfer operation from the source data block to 0x8002 move.l #TestDMATransferBusLockDataBlock,D0 move.w #$0005,D1 move.w #$8154,$C00004 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.w D2,$C00004 ;DMA transfer to VRAM address 0x8002, followed by data port write of 0xFFEE to ;incremented address. Note that this test relies both on the VDP being able to ;obtain the bus between the two halves of the long-word write, as well as the fact ;that the M68000 implements a move.l to a pre-decremented address with the lower word ;written first, and the upper word written second. move.w #$4002,$C00004 move.l #$FFEE0082,(A0) move.l #$C00006,A1 move.l (A0),-(A1) ;Disable DMA, and restore the increment data. move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Read from VRAM at 0x8000 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)+ 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 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 ;Do a DMA transfer operation from the source data block to 0x8002 move.l #TestDMATransferBusLockDataBlock,D0 move.w #$0005,D1 move.w #$8154,$C00004 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.w D2,$C00004 ;DMA transfer to VRAM address 0x8002, followed by a register write. ;Note that this test relies both on the VDP being able to ;obtain the bus between the two halves of the long-word write, as well as the fact ;that the M68000 implements a move.l to a pre-decremented address with the lower word ;written first, and the upper word written second. move.w #$4002,$C00004 move.l #$8F010082,(A0) move.l #$C00008,A1 move.l (A0),-(A1) ;Disable DMA, and restore the increment data. move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Read from VRAM at 0x8000 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)+ 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 ;---------------------------Test block 3----------------------------------- ;Clear 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 ;Do a DMA transfer operation from the source data block to 0x8002 move.l #TestDMATransferBusLockDataBlock,D0 move.w #$0005,D1 move.w #$8154,$C00004 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.w D2,$C00004 ;DMA transfer to VRAM address 0x8002, followed by write to incremented address. move.w #$4002,$C00004 move.w #$0082,(A0) move.w (A0),$C00004 move.w #$FFEE,$C00000 ;Disable DMA, and restore the increment data. move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Read from VRAM at 0x8000 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)+ 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 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 ;Do a DMA transfer operation from the source data block to 0x8002 move.l #TestDMATransferBusLockDataBlock,D0 move.w #$0005,D1 move.w #$8154,$C00004 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.w D2,$C00004 ;DMA transfer to VRAM address 0x8002, followed by register write. move.w #$4002,$C00004 move.l #$00828F01,(A0) move.l #$C00004,A1 move.l (A0),(A1)+ ;Disable DMA, and restore the increment data. move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Read from VRAM at 0x8000 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)+ 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 ;---------------------------Test block 4----------------------------------- ;Clear 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 ;Do a DMA transfer operation from the source data block to 0x8002 move.l #TestDMATransferBusLockDataBlock,D0 move.w #$0005,D1 move.w #$8154,$C00004 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.w D2,$C00004 ;DMA transfer to VRAM address 0x8002, followed by register write. move.w #$4002,$C00004 move.l #$00828F01,(A0)+ move.l #$C00004,A1 move.l -(A0),(A1) ;Disable DMA, and restore the increment data. move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Read from VRAM at 0x8000 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)+ 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 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 ;Do a DMA transfer operation from the source data block to 0x8002 move.l #TestDMATransferBusLockDataBlock,D0 move.w #$0005,D1 move.w #$8154,$C00004 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.w D2,$C00004 ;DMA transfer to VRAM address 0x8002, followed by register write. move.w #$4002,$C00004 move.l #$8F010082,(A0)+ move.l #$C00008,A1 move.l -(A0),-(A1) ;Disable DMA, and restore the increment data. move.w #$8144,$C00004 move.w #$8F02,$C00004 ;Read from VRAM at 0x8000 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)+ 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 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 rts