dirkwhoffmann / vAmiga

vAmiga is a user-friendly Amiga 500, 1000, 2000 emulator for macOS
https://dirkwhoffmann.github.io/vAmiga
Other
299 stars 25 forks source link

CIA access does not require free bus from Agnus #696

Closed mras0 closed 2 years ago

mras0 commented 2 years ago

As I mentioned in a comment to another issue:

Regarding CIA access, I had a look at Agnus::executeUntilBusIsFreeForCIA - I don't think CIA requires chip bus to be free.

Attached is a test case that tries to show this:

ciatest.zip

Core of the test is to start a D=A blit (w/o blitter nasty) and then write the current value of ciab todlo to color00 (via unrolled move.w (a3), (a2) instructions) until the blit is finished. Shorter area with color changes means the code ran too slow (or well, in principle it could be that it ran too fast, but that's unlikely to be the cause).

Copper is used to highlight the expected area and trigger the code. Note that the display isn't stable, but I expect more or less the entire area between the two white lines to be filled.

vAmiga 2.0 code (tested with vAmigaSDL, same result in the online versions): image

WinUAE 4.9.1 (Note: It seems like WinUAE does not give the right value for word reads from the CIA): image

Stock A1200 (just for reference): image

EDIT: Version with stable start: ciatest_stable.zip

dirkwhoffmann commented 2 years ago

Very cool test case!

I haven't had time to look into the details yet, but I have run it on my A500 (with the ACA500+ plugged in). Interestingly, the colors are completely different:

https://user-images.githubusercontent.com/12561945/168664168-c8d17119-7446-475e-97a6-616f573a797b.mov

This is what I get in vAmiga if the code for waiting for a free bus is removed for CIA accesses:

https://user-images.githubusercontent.com/12561945/168664617-343633b8-5950-4088-8c77-0b4f281caade.mov

mras0 commented 2 years ago

Interestingly, the colors are completely different:

My initial statement about WinUAE being wrong with regards to word reads was too harsh. Reality is more complicated (on my a1200 the undefined bits are either $7f or $ff depending on value written to the other CIA).

Here's a version that doesn't rely on undefined values and uses value of a CIA timer for the colors instead ciatest_stable2.zip

It's still not 100% stable because Eclocks/frame is not a whole number (this is only emulated in pre-release versions of winuae), so it'll jump between 5 different start positions.

dirkwhoffmann commented 2 years ago

Test ciastest_stable2:

Amiga 500: 🥰 IMG_2762

Latest vAmiga: 😎

Bildschirmfoto 2022-05-17 um 18 02 40

Looks like a perfect match to me.

dirkwhoffmann commented 2 years ago

Fixed in v2.1b1.