;------------------------------------------------------------------------------------ ;Test 9 - Partial CP Writes ;------------------------------------------------------------------------------------ TestPartialCPWritesText: dc.b 'Partial CP Writes ' TestPartialCPWritesTextEnd: TestPartialCPWritesExpectedResult: dc.w $F357, $0123, $0246, $FFFF, $FFFF, $0246, $0123, $FFFF, $47FF, $0D67, $0000, $0123, $6745, $FFFF ; dc.w $F357, $0123, $0246, $FFFF, $FFFF, $0246, $0123, $FFFF, $47FF, $0D67, $FFFF, $0123, $6745, $FFFF ;##FIX## We're seeing this test give the following results sometimes: ; dc.w $F357, $0123, $0246, $FFFF, $FFFF, $0246, $0123, $FFFF, $47FF, $0D67, $0000, $01DC, $6745, $FFFF TestPartialCPWrites: ;Initialize the text result block move.w #(TestPartialCPWritesTextEnd-TestPartialCPWritesText),D7 move.w #2,(A0)+ ;Set the number of display lines move.w D7,(A0)+ ;Set the text length move.w #$001C,D6 ;Set the data length move.w D6,(A0)+ lea TestPartialCPWritesText,A1 sub.w #1,D7 TestPartialCPWritesWriteText: move.b (A1)+,(A0)+ dbf D7,TestPartialCPWritesWriteText move.w #1,(A0)+ ;Set the expected result data present flag lea TestPartialCPWritesExpectedResult,A1 ;Write the expected result data to the buffer sub.w #1,D6 TestPartialCPWritesWriteExpectedResultData: move.b (A1)+,(A0)+ dbf D6,TestPartialCPWritesWriteExpectedResultData ;Initialize target memory move.l #$C0000002,$C00004 ;Write to CRAM at 0x8000 move.w #$0EEE,$C00000 move.l #$C0200002,$C00004 ;Write to CRAM at 0x8020 move.w #$0EEE,$C00000 move.l #$40000002,$C00004 ;Write to VRAM at 0x8000 move.w #$FFFF,$C00000 move.l #$40200002,$C00004 ;Write to VRAM at 0x8020 move.w #$FFFF,$C00000 move.l #$40200010,$C00004 ;Write to VSRAM at 0x20 move.w #$07FF,$C00000 move.l #$C0200002,$C00004 ;Write to CRAM at 0x8020 move.w #$0246,$C00000 move.w #$4000,$C00004 ;Partial CP write, write to VRAM at 0x8000 move.w #$0123,$C00000 move.l #$00200022,$C00004 ;Read from CRAM at 0x8020 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 #$00000002,$C00004 ;Read from VRAM at 0x8000 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.w #$8F02,$C00004 ;Resync the control port if an emulator mucked partial writes up move.w #$8F02,$C00004 ;Initialize target memory move.l #$40000002,$C00004 ;Write to VRAM at 0x8000 move.w #$FFFF,$C00000 move.l #$40200002,$C00004 ;Write to VRAM at 0x8020 move.w #$FFFF,$C00000 move.l #$C0000000,$C00004 ;Write to CRAM at 0x00 move.w #$0EEE,$C00000 move.l #$C0200000,$C00004 ;Write to CRAM at 0x20 move.w #$0EEE,$C00000 move.l #$40200010,$C00004 ;Write to VSRAM at 0x20 move.w #$07FF,$C00000 move.l #$40200002,$C00004 ;Write to VRAM at 0x8020 move.w #$C020,$C00004 ;Partial CP write, write to CRAM at 0x8020 move.w #$0246,$C00000 move.l #$00200020,$C00004 ;Read from CRAM at 0x20 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 #$00200002,$C00004 ;Read from VRAM at 0x8020 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.w #$8F02,$C00004 ;Resync the control port if an emulator mucked partial writes up move.w #$8F02,$C00004 ;Initialize target memory move.l #$40000002,$C00004 ;Write to VRAM at 0x8000 move.w #$FFFF,$C00000 move.l #$40200002,$C00004 ;Write to VRAM at 0x8020 move.w #$FFFF,$C00000 move.l #$C0000000,$C00004 ;Write to CRAM at 0x00 move.w #$0EEE,$C00000 move.l #$C0200000,$C00004 ;Write to CRAM at 0x20 move.w #$0EEE,$C00000 move.l #$40200010,$C00004 ;Write to VSRAM at 0x20 move.w #$07FF,$C00000 move.l #$00000002,$C00004 ;Read from VRAM at 0x8000 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.w #$C020,$C00004 ;Partial CP write, write to CRAM at 0x8020 move.w #$0246,$C00000 move.w #$4000,$C00004 ;Partial CP write, write to VRAM at 0x8000 move.w #$0123,$C00000 move.l #$00200020,$C00004 ;Read from CRAM at 0x20 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 #$00000002,$C00004 ;Read from VRAM at 0x8000 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.w #$8F02,$C00004 ;Resync the control port if an emulator mucked partial writes up move.w #$8F02,$C00004 ;Initialize target memory move.l #$40000002,$C00004 ;Write to VRAM at 0x8000 move.w #$FFFF,$C00000 move.l #$40200002,$C00004 ;Write to VRAM at 0x8020 move.w #$FFFF,$C00000 move.l #$C0000000,$C00004 ;Write to CRAM at 0x00 move.w #$0EEE,$C00000 move.l #$C0200000,$C00004 ;Write to CRAM at 0x20 move.w #$0EEE,$C00000 move.l #$40200010,$C00004 ;Write to VSRAM at 0x20 move.w #$07FF,$C00000 move.l #$00000022,$C00004 ;Read from CRAM at 0x8000 move.w #$4000,$C00004 ;Partial CP write, write to invalid at 0x8000 move.w #$0246,$C00000 move.l #$00000002,$C00004 ;Read from VRAM at 0x8000 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.w #$8F02,$C00004 ;Resync the control port if an emulator mucked partial writes up move.w #$8F02,$C00004 ;Initialize target memory move.l #$40200002,$C00004 ;Write to VRAM at 0x8020 ; move.w #$FFFF,$C00000 move.w #$2222,$C00000 move.w #$3333,$C00000 move.l #$40000002,$C00004 ;Write to VRAM at 0x8000 ; move.w #$FFFF,$C00000 move.w #$1111,$C00000 move.w #$4444,$C00000 move.l #$C0000000,$C00004 ;Write to CRAM at 0x00 move.w #$0EEE,$C00000 move.l #$C0200000,$C00004 ;Write to CRAM at 0x20 move.w #$0EEE,$C00000 move.l #$40200010,$C00004 ;Write to VSRAM at 0x20 move.w #$07FF,$C00000 move.l #$00200010,$C00004 ;Read from VSRAM at 0x20 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.w #$4020,$C00004 ;Partial CP write, write to VSRAM at 0x20 move.w #$0567,$C00000 move.l #$00200010,$C00004 ;Read from VSRAM at 0x20 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.w #$8F02,$C00004 ;Resync the control port if an emulator mucked partial writes up move.w #$8F02,$C00004 ;Initialize target memory move.l #$40200002,$C00004 ;Write to VRAM at 0x8020 move.w #$0123,$C00000 move.w #$4567,$C00000 move.w #$89AB,$C00000 move.w #$CDEF,$C00000 move.l #$40000002,$C00004 ;Write to VRAM at 0x8000 move.w #$FEDC,$C00000 move.w #$BA98,$C00000 move.w #$7654,$C00000 move.w #$3210,$C00000 move.l #$C0000000,$C00004 ;Write to CRAM at 0x00 move.w #$0EEE,$C00000 move.l #$C0200000,$C00004 ;Write to CRAM at 0x20 move.w #$0EEE,$C00000 move.l #$40200010,$C00004 ;Write to VSRAM at 0x20 move.w #$07FF,$C00000 ;##TODO## This causes a lockup. It appears that attempting to switch from the VRAM write ;target to the VRAM read target using a partial control port write does not work, which ;is interesting. In fact, we haven't been able to switch from any write target to a read ;target without getting a lockup. The same thing, switching from a VSRAM write target to ;a VSRAM read target, or switching from a CRAM write target to a VRAM read target, causes ;a lockup. We've also found we're getting intermittent lockups when switching from a VRAM ;read target written with a full control port write to the same read target written with ;a partial control port write. ; move.l #$40200002,$C00004 ;Write to VRAM at 0x8020 ; move.w #$0000,$C00004 ;Partial CP write, read from VRAM at 0x8000 ; move.w $C00000,(A0)+ ; move.l #$40200012,$C00004 ;Write to VSRAM at 0x8020 ; move.w #$0020,$C00004 ;Partial CP write, read from VSRAM at 0x8020 ; move.w $C00000,(A0)+ ;##NOTE## Further testing has shown that simply doing a partial control port write, not ;modifying any settings, attempting to re-write the first command word of a read target, ;causes the read target to stop working. If the data port read follows immediately after ;the partial control port write, the read usually works, however intermittent lockups ;still occur, and in addition, occasionally the data is returned from the original read ;target address, not the new address after the partial control port write. Additionally, ;If 10 NOP instructions are inserted between the original full control port write which ;setup the original read target, and the partial control port write to modify it, a ;lockup then always occurs if the control port is read. In other words, after a partial ;control port write is made, the system behaves as if CD4 has been set, and no read ;targets are valid. Most likely, the only reason reads work at all after a partial ;port write is if there was prevously a valid read target selected, and the read ;pre-cache operation had not yet completed. ;##NOTE## Further testing has discovered something very interesting. We're preserving ;all the relevant code below for further analysis: ;Initialize target memory ; move.l #$40000002,$C00004 ;Write to VRAM at 0x8000 ; move.w #$89AB,$C00000 ; move.w #$1532,$C00000 ; move.l #$40220002,$C00004 ;Write to VRAM at 0x8022 ; move.w #$CDEF,$C00000 ; move.l #$C0000000,$C00004 ;Write to CRAM at 0x00 ; move.w #$0EEE,$C00000 ; move.l #$C0200000,$C00004 ;Write to CRAM at 0x20 ; move.w #$0EEE,$C00000 ; move.l #$40200010,$C00004 ;Write to VSRAM at 0x20 ; move.w #$07FF,$C00000 ;##FIX## This still locks up sometimes ; move.l #$00200002,$C00004 ;Read from VRAM at 0x8020 ; move.w #$0000,$C00004 ;Partial CP write, 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 ;This code is testing the strange behaviour we're getting when doing a partial control ;port write immediately following a full control port write for a VRAM read target, as ;described above. What is interesting is the results we get from this code. Three ;possible things occur: ;1. The VDP locks up ;2. The reads all occur from VRAM 0x8000 exactly as desired ;3. The first read happens from VRAM 0x8020, then following reads happen from 0x8000 onwards. ;Most of the time, with no wait cycles between the full control port write and the ;following partial control port write, the second option occurs, however if we insert ;wait cycles between the two (we tested 6 NOPs), the third option becomes much more ;likely than the first. We also twice saw a case where it appeared all the reads occurred ;from 0x8020 onwards, however this seems exceedingly rare, with 6 NOP instructions at ;least. Note that we have also seen intermittently a case of reg 0 being cleared to 0, so ;that the palette select bit is cleared, however we do not know for sure if this is as a ;result of this code or even this test, as it could be due to another test on the same ;screen. Putting 10 NOPs made the first option more likely, and 12 seems to make it a ;certainty. Actually, further testing showed no lockups even at 12 sometimes. ;-Note that further to the testing above, for reasons we haven't been able to determine, ;it appears that inserting extra writes to the target VRAM addresses so that 4 words are ;written to at each address, before we perform our control port writes below, affects the ;outcome. When we inserted extra writes, we were then not able to reproduce result 3. ;This suggests that pending writes in the FIFO have an impact. When we then went further ;and inserted a massive number of NOPs between the data port writes and setting up the ;control port writes, the results changed. We now get lockups much more frequently, ;almost every time. This was with 6 NOPs between the control port writes. What we appear ;to have done with the NOPs is clear the FIFO, so that the read pre-cache runs much ;sooner than it did before, which increases the likelihood of a collision with the second ;control port write. ;-We've removed the NOP cycles between the control port writes, and now getting a really ;bizarre result. We're now seeing the first read return 0xFFFF, with either VRAM 0x8000 ;or 0x8020 onwards from then on, with occasional lockups. In other words, the three ;possible results are the same, except that the first read returns 0xFFFF rather than ;actually reading from the selected target, and the read after that happens as though the ;first read had not taken place at all. The thing is, 0xFFFF isn't in the FIFO buffer at ;the time, nor was it the last data read, nor was it the next data to be read from the ;previously selected read target. It's not clear at this stage where the value came from. ;-Actually, now it is clear where the 0xFFFF value came from. The value returned is the ;previous value of VRAM at 0x8020, and we confirmed this by modifying this data from the ;previous test. By setting VRAM 0x8000 to 0x1111, and 0x8020 to 0x2222, we always got the ;value of 0x2222 back for the first read, whether the following reads came from 0x8000 or ;0x8020, except one time, where we saw the first read and all following ones come from ;0x8000 like we were getting before. ;-This is very interesting. It doesn't seem to be a FIFO quirk either, because we ;inserted an extra write to VRAM after our 0x2222 write, and it made no difference to the ;result. The value of 0x2222 is being returned, even though that value not only was never ;requested to be read earlier, it was also overwritten in VRAM before the read request ;was even setup. We have a massive number of NOP cycles between the data port writes and ;the control port writes now, so it shouldn't have been sitting suspended in the write ;FIFO either, it should actually have been written. We have just added around 300 NOP ;cycles between the data port writes and the control port writes, and it made no ;difference at all. ;-We have just done more testing and confirmed that the value of 0x2222 being returned ;is nothing related to it being cached in a write queue anywhere, as even when that value ;is not the last value to be written to VRAM, or even the first or last within the VRAM ;write block that caused it to be written, the value is still returned. Whatever is ;written to VRAM at 0x8020 is returned. ;-I have just discovered an error which may invalidate all the above findings about ;returning 0x2222. We were not overwriting the data at 0x8020, we were writing from ;0x8022 onwards. We have just fixed this, and the results are now a lot more logical. We ;are now back to our previous behaviour, where we have three possible results. ;-I theorize that the three possible results correlate with three possible states of the ;previous VRAM read cache operation: ;1. Both bytes of the data have been read and are available for reading. In this case, ; the partial CP write seems to clear the flag that says data is available, and as ; testing has indicated CD4 is now set, so no data gets cached, so the VDP locks up if ; we read from it. ;2. No bytes have been read from VRAM, but the pre-cache read request has already been ; dispatched. This most likely occurs immediately when the CP is read. By the time the ; pre-cache operation runs, the address data has been changed, so when the data is ; latched in order to perform the VRAM read, it is read from the new address. This is ; supported by the fact that this is more common the less time is between the two CP ; writes. ;3. A single byte has been read from VRAM for the original read target, or at least, the ; read has begun in some way and the address has been latched, but the read operation ; has not been flagged as completed, so when the partial CP write clears the read data ; available flag, it has no effect. The read pre-cache from the original target now ; runs to completion, but when it finishes and the data port is read, the next read now ; occurs from the new read target. ;-Note that we have done more testing, and found that we can get results 2 and 3 simply ;by following two full CP writes back to back, both specifying VRAM read targets with ;different addresses. No lockups occur with this case that we have seen, but we do get ;the same cutover of the address being read from, which is logical based on our theory of ;the cause. ;-Note that we have now been able to determine, from analyzing the corrupted output, that ;it is in fact this test which is resulting in the VDP register which controls increment ;data occasionally ending up set to 4 rather than 2, just after this test has run. It ;seems to happen more often now with our current setup. It is also most likely this test ;which results in register 0 occasionally being set to 0. We don't seem to get our ;increment data problem if we comment out our problematic data port reads, but we still ;get the reg 0 problem. ;-It is obvious from all our testing that partial control port writes cannot be used to ;setup reads, and that reading from the data port after a partial control port write ;locks up the system, unless we manage to interfere with a read cache operation already ;in progress and hijack it. In order to emulate this behaviour, I suggest we set CD4 when ;a partial control port write occurs. Note that we were already setting CD4 when a ;register write is made. It now seems clear that CD4 is simply set when a partial control ;port write is made, be that a register write or not. ;##NOTE## If CD4 really is set when a partial control port write is made, we should test ;this theory. I suggest attempting a register write while a DMA fill operation is setup ;and waiting for a data port write to trigger it. The register write should switch the ;DMA mode to a DMA copy operation. See if we can successfully trigger a DMA copy in this ;case, and if we can, check both with and without CD4 set on the initial DMA fill setup, ;and see if it works both ways. Also note that it is possible a partial control port ;write clears CD5. Check with a DMA fill first and see if this is the case, by simply ;changing the increment register and see if the DMA in progress bit is still set in the ;status register afterwards. TestPartialCPWritesFIFOWaitLoop1: move.w $C00004,D5 btst #9,D5 beq TestPartialCPWritesFIFOWaitLoop1 ; move.l #$00200002,$C00004 ;Read from VRAM at 0x8020 move.l #$00000002,$C00004 ;Read from VRAM at 0x8000 ; nop ; nop ; nop ; nop ; nop ; nop ; nop ; nop ; nop ; nop ; nop ; nop ; nop ; nop ; move.w #$0000,$C00004 ;Partial CP write, read from VRAM at 0x8000 ; move.w $C00000,(A0)+ ; move.w $C00000,(A0)+ ; move.w $C00000,(A0)+ ; move.w $C00000,(A0)+ move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; move.w #$0000,(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.w #$4000,$C00004 ;Partial CP write, write to VRAM at 0x8000 move.w #$0123,$C00000 nop ;These wait states were shown to be required, otherwise we sometimes read back nop ;a value of 0x01DC for the first read value, instead of 0x0123, when the previous nop ;VRAM contents were 0xFEDC. This shows we were for some reason able to read from nop ;this address when only half of the write operation had been completed. This nop ;requires further testing and investigation, and we should build a test nop ;specifically to check for it over a number of iterations. nop nop nop nop move.l #$00000002,$C00004 ;Read from VRAM at 0x8000 ;##NOTE## The notes below are old, the bad reads have been fixed by inserting wait states above move.w $C00000,(A0)+ ;##NOTE## Has been seen to read back 0x01DC, with previous VRAM contents of 0xFEDC. ;##NOTE## The above behaviour, with the read returning 0x01DC, is still occurring on the hardware, ;in particular we observed it on the LaserActive. Is it possible that a read cache operation occurs before ;pending writes? Or maybe a read cache for the lower byte from VRAM occurs before, while the upper byte occurs ;after. See if we can ever get a read back of 0xFEDC. ;##NOTE## It seems quite possible that what's going on here is, one half of the word-wide write to VRAM is ;being completed, and then, before the second half of the write is completed, the read cache operation is ;being performed, which of course then reads the first byte as the new data, and the second byte as the old ;data. Fixing this should be as simple as inserting some wait states between the write and the read. We should ;perform more testing on this behaviour however. Construct a proper test to show its occurrence. 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.w #$8F02,$C00004 ;Resync the control port if an emulator mucked partial writes up move.w #$8F02,$C00004 ;##DEBUG## ; move.w #$0000,(A0)+ ; move.w #$0000,(A0)+ ; rts ;Initialize target memory move.l #$40000002,$C00004 ;Write to VRAM at 0x8000 move.w #$FFFF,$C00000 move.l #$40020002,$C00004 ;Write to VRAM at 0x8002 move.w #$FFFF,$C00000 move.l #$C0000000,$C00004 ;Write to CRAM at 0x00 move.w #$0EEE,$C00000 move.l #$C0200000,$C00004 ;Write to CRAM at 0x20 move.w #$0EEE,$C00000 move.l #$40200010,$C00004 ;Write to VSRAM at 0x20 move.w #$07FF,$C00000 move.w #$8F01,$C00004 ;Set increment register to 0x01 move.l #$40000002,$C00004 ;Write to VRAM at 0x8000 move.w #$4000,$C00004 ;Partial CP write, write to VRAM at 0x8000 move.w #$8F02,$C00004 ;Dummy register write to set increment register to 0x02. This will ;actually be latched as the second half of a control port write. move.w #$0123,$C00000 move.w #$4567,$C00000 move.w #$8F02,$C00004 ;Set increment register to 0x02 move.l #$00000002,$C00004 ;Read from VRAM at 0x8000 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.w #$8F02,$C00004 ;Resync the control port if an emulator mucked partial writes up move.w #$8F02,$C00004 ;Clear target memory move.l #$40000002,$C00004 ;Write to VRAM at 0x8000 move.w #$0000,$C00000 move.l #$40200002,$C00004 ;Write to VRAM at 0x8020 move.w #$0000,$C00000 move.l #$C0000000,$C00004 ;Write to CRAM at 0x00 move.w #$0000,$C00000 move.l #$C0200000,$C00004 ;Write to CRAM at 0x20 move.w #$0000,$C00000 move.l #$40200010,$C00004 ;Write to VSRAM at 0x20 move.w #$0000,$C00000 rts