dirkwhoffmann / vAmiga

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

Flicker bug #189

Closed dirkwhoffmann closed 4 years ago

dirkwhoffmann commented 4 years ago

Various programs that work well in SAE cause vAmiga to flicker (R-Type II, Black Lamp etc.). I am hunting this "flickering bug" for a long time now without success (I expect the Copper to be the culprit, but I am not 100% sure).

I've found a demo that flickers, too. Demo 6 from the "Abnormal Demo Pack 4":

Abnormal-DemoPack04.zip

Bildschirmfoto 2019-10-12 um 12 59 47

The blue imprint at the bottom flickers like hell in vAmiga:

Bildschirmfoto 2019-10-12 um 12 58 05

Debugging intros is usually much easier than debugging games. Hence, we now have a good chance to find the root cause of the flickering bug.

dirkwhoffmann commented 4 years ago

For reference: DMA debugger view

Bildschirmfoto 2019-10-13 um 08 33 29

Further findings: Copper changes the Copper program counter manually in line 99 and 200:

[3962] (  0,  0)  01417A BCBS-A 4020 0120 Copper: switchToCopperList(1) coppc: 16020 -> 15a28
[3962] ( 99, 16)  014172 BCBS-A 4020 0140 [015C28] Copper: switchToCopperList(1) coppc: 15c28 -> 6719e
[3962] (200, 44)  01417A BCBS-A 4020 0140 [06B816] Copper: switchToCopperList(1) coppc: 6b816 -> 15e00

Line 99 and 200 marked by red lines:

Bildschirmfoto 2019-10-13 um 14 41 56

Hence, we have three distinct Copper lists: One for the upper part (synthesizer), one for the logo in the middle, and one for the moving imprint at the bottom.

dirkwhoffmann commented 4 years ago

🥴 This bug hides itself very well, like a phantom. The Copper list in the bottom area is pretty simple and straight-forward:

...
WAIT ($D1,$0E)
MOVE $9204, BPLCON0
MOVE $0000, COLOR01
MOVE $A65E, BPL1PTL
MOVE $00AF, BPLCON1
MOVE $0000, NO-OP
WAIT ($D6,$0E)
MOVE $9204, BPLCON0
MOVE $0000, COLOR01
MOVE $07D0, BPL1PTL
MOVE $00AF, BPLCON1
MOVE $0000, NO-OP
WAIT ($DB,$0E)
...

Maybe the shift values(BPLCON1) in hires mode (blue imprint is drawn hires)? 🤔 Let's write some test cases for that...

dirkwhoffmann commented 4 years ago

Due to @mithrendal's advice (and the help of xdftool of course which is great), I am now able to convert exe files to ADFs 🥳.

#!/bin/bash
xdftool kyrios.adf format kyrios
xdftool kyrios.adf write kyrios.exe
xdftool kyrios.adf write s
xdftool kyrios.adf boot install
hoff$ ls s
startup-sequence
hoff$ cat s/startup-sequence 
kyrios.exe

The script creates an ADF that boots the Kyrios demo automatically.

kyrios.adf.zip

This is valuable for debugging, because the demo now starts in a deterministic way (no user interaction).

Next step will be to dump all Blitter checksums to a file and compare them against SAE (deterministic startup-behaviour of the test case is crucial to make this work).

BTW, the demo is really nice. And it is even nicer in the DMA debugger 😎.

dirkwhoffmann commented 4 years ago

Just verified the first 7000 blit operations when booting kurios.adf as well as all disk operations. All checksum are identical. This means we have to acquit both the Blitter and the Disk controller.

😠 So the question is: Where is this beep flicker bug hiding????

Next step: Dump all modifications of the bitplane pointer registers.

dirkwhoffmann commented 4 years ago

OMG, some days ago I wrote a bunch of vAmigaTS tests for the BPLCON1 register. Embarrassingly, I've forgotten the most important thing: to run vAmiga against them 😳.

And guess what: There are indeed issues in hires mode... 🤓

dirkwhoffmann commented 4 years ago

Woohoo 🥳. Fixed by #192.

There is a sound issue though. Paula refuses to sing when the demo boots 😬.

mithrendal commented 4 years ago

Amazing stuff 🤤