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

The Black Lotus - Graphics and sound errors #179

Closed dirkwhoffmann closed 4 years ago

dirkwhoffmann commented 4 years ago

Hence, if anybody stumbles across such an intro that doesn't work, please let me know.

Hi dirk I found some cool demo scener demos from 2019. These are no hacker intros but maybe also interesting, as these demo scener guys seem always try to get all out of the OCS chips at their code competition parties. Top Number 1 and 2 are pure A500 demos. (Winners don't use ...) some AGA๐Ÿ™„ demos (in which we are not interested in), but in total there 4 pure OCS demos listed. Which may serve as test candidates.

I just tried the number one, the winner demo from 2019 called "eon party version by the black lotus".

And the good news is ๐Ÿฅณ!! There are indeed sound problems from the very beginning and some graphic glitches later on when vAmiga runs the Black Lotus Eon Party Version. The sound runs not synchron and not all channels in parallel. I just run it again and there was no sound, but the inspector showed waveforms...๐Ÿ‘€

You could see the youtube video as reference https://www.youtube.com/watch?v=iD9xk3SDSYc

and compare it when inserting the following two floppies into vAmiga ... tbl_eon_party_version.zip

Originally posted by @mithrendal in https://github.com/dirkwhoffmann/vAmiga/issues/174#issuecomment-538691283

dirkwhoffmann commented 4 years ago

Thank you so much for bringing this demo to my attention. It is really cool ๐Ÿ˜Ž.

On my machine, it seems like the sound issues only appear in later stages of the demo. I had the impression that they go hand in hand with the graphics glitches.

I think we should run the demo from time to time to check if the graphical issues are still there. Once they are gone, we should tackle the sound issues.

vAmiga's Paula chip also has the limitation that it doesn't support channel modulation yet (don't know if the demo uses it though). This should also be fixed before digging deeper here.

dirkwhoffmann commented 4 years ago

For reference: Graphics errors in vAmiga ๐Ÿ™ˆ

Bildschirmfoto 2019-10-06 um 08 19 06 Bildschirmfoto 2019-10-06 um 08 27 44

DMA debugger view:

Bildschirmfoto 2019-10-06 um 08 27 39
mithrendal commented 4 years ago

vAmiga's Paula chip also has the limitation that it doesn't support channel modulation yet (don't know if the demo uses it though). This should also be fixed before digging deeper here.

Maybe @emoon from the black lotus can tell us whether the sound in eon is using channel modulation. At my machine the sound was not correct from the beginning... Did you run vAmiga in debug or release mode ? Did you listen and comparing it to the original in the youtube video ? Also maybe I have enabled some different compatibility settings in vAmiga...

emoon commented 4 years ago

We don't use any channel modulation in the demo. Also the above graphics glitches can happen if disk 2 isn't inserted in time after disk 2 icon/sprite is up (in final version the issue with not inserting disk 2 in time is fixed)

dirkwhoffmann commented 4 years ago

Hi Daniel,

thanks a lot for helping us out and congratulations for the really cool demo ๐Ÿ‘.

@mithrendal, here are my hardware settings:

I did run the debug build on the dev branch with the following compatibility options:

Bildschirmfoto 2019-10-06 um 11 06 35

Please check the Blitter settings first (all levels above 0 have issues). Please also check that the emulator runs at 7 MHz. BTW, you can disable auto warp mode by clicking the hourglass icon in the status bar. It'll change to a lock symbol as shown in the screenshot.

mithrendal commented 4 years ago

in vAmiga I can hear the ringing of the cell phone but parallel to it should be some background noise and it is not there. After the ring tones are over, there should be a melody from a piano, I can not hear it. It seems as if some audio channels are disabled๐Ÿคจ...

when I enable stereo as mono in the settings ... I can hear the sound

strange ๐Ÿง....

Switched some earphones into the mac mini and everthing is ok.๐Ÿค”

Oh no. It was a cable on the right physical speaker which had no contact. ๐Ÿ˜ฌ I am so sorry for the false alarm on the sound capabilities of vAmiga ...๐Ÿคญ

So I only can spot these white graphic anomalies sometimes when the lightening comes from heaven. No sound problems anymore....

I am wondering how long my setup had this problem.. maybe years ? .... Have to enjoy the rink a dink demo with all 4 channels now ๐Ÿ˜‚...

dirkwhoffmann commented 4 years ago

It was a cable on the right physical speaker which had no contact. ๐Ÿ˜ฌ

๐Ÿ˜† No worries. Self-solving bugs are the best.

Overall, today is a good day for the emulator: Sound bug solved, R-Type II bug identified, more sprite bugs found.

Unfortunately, horizontal sprite multiplexing requires some architectural changes. It has to be done though, because I expect more programs to rely on that "feature" than just R-Type II.

mithrendal commented 4 years ago

the readme of the demo says

Fun facts:
- We hit every documented hardware bug on OCS in this demo more than once 
...

so maybe vAmiga got these small glitches and anomalies because vAmiga has no bugs ๐Ÿค”?

So I think a strategy in closing the issue is ... does vAmiga needs more bugs? ๐Ÿ™ˆ This is truly a paradoxon ๐Ÿค–...

dirkwhoffmann commented 4 years ago

every documented hardware bug on OCS

๐Ÿ˜ฒ The hardware bugs are documented? Seriously? WHERE??? ๐Ÿ˜ณ

emoon commented 4 years ago

Documented meaning being written down somewhere on the net or in some forum posts. I can't remember all of them but

1. Sometimes if don't wait for blitter finish *twice* when using blitter from copperlist the wait will be missed (UAE doesn't implement this)
2. If you switch copperlist while the blitter is running the D register for the blitter will point at the copperlist and trash it (UAE implements this)

Even if UAE implements 2 the timing can be different on original hardware so it may or may not occur in the emulator but happens on hardware.

mithrendal commented 4 years ago

I searched the net and found a thread where Toni Wilen documented loads of strange undocumented alternative hardware behaviour also less poetic known as bugs. Uh it is epic long ... We could look at it as a treasure map which gives vAmiga some shortcuts to get those bugs implemented? No?
Undocumented Amiga hardware stuff

Hey dirk on page 2 of it, interesting insights ... toni does explain ddfstrt and ddfstop logic of Agnus 8367R0๐Ÿ’“. But he says it is buggy ๐Ÿ˜ญand yours Agnus8372A logic is fixed ๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ค.

At the Eon demo, did you insert disk 2 when it asked you to? Content of Disk2 is simply mindblowing ... What a great demo ๐Ÿคค!!

dirkwhoffmann commented 4 years ago

found a thread where Toni Wilen documented loads of strange undocumented alternative hardware behaviour

That's a great thread!! Although I have only read the first view posts yet, I already spotted a lot of odd stuff that can be seen in my test cases, too. For example that one:

Also some "illegal" DDFSTOP values can cause complete display corruption, syncs get messed up etc... (don't remember the exact values now)

It can be seen in my test case with the shifting red lines.

I think this tread can keep me busy for a long time ๐Ÿ˜.

At the Eon demo, did you insert disk 2 when it asked you to? Content of Disk2 is simply mindblowing ... What a great demo ๐Ÿคค!!

Yes, I did. Amazing what Denise is capable of when programmed the right way. Awesome ๐Ÿ˜Ž!!!

emoon commented 4 years ago

Thanks :) we are also doing tech write-ups currently for the demo over at http://tbl.nu/posts/ if you are interested in reading more about it.

dirkwhoffmann commented 4 years ago

Update (vAmiga v0.55, Musashi replaced by Moira):

Demo part 1 (first disk) looks pretty good to me.

Demo part 2 (second disk) has two major issues:

Noticeable graphics glitch here ๐Ÿ™ˆ:

Bildschirmfoto 2020-01-15 um 06 25 12

Furthermore, this girl seems to have taken too many sleeping pills, because she doesn't wake up in vAmiga. Interrupts still seems to work (music keeps playing).

Bildschirmfoto 2020-01-15 um 06 27 51
dirkwhoffmann commented 4 years ago

Update: Graphics glitches on sinister street seem to be gone in v0.56 (in this scene they probably used BLTPRI = 0 wich was broken in previous releases):

Bildschirmfoto 2020-01-24 um 18 48 46

Girl is still sleeping. I can see timer CIAB::A running, but it doesn't wake her up... maybe if I turn the speaker volume up ๐Ÿค”.... no, didn't help ... ๐Ÿ˜ข

dirkwhoffmann commented 4 years ago

I'm still trying to figure out why the girl is in a coma. First examination results (for reference):

X-ray image (aka DMA):

Bildschirmfoto 2020-02-04 um 15 31 58

Looks pretty standard to me.

Pulse (aka CIAs):

Bildschirmfoto 2020-02-04 um 12 22 13

There is some CIAB activity going on. Both timers A and B are running. Interestingly, timer B is a one-shot timer that gets restarted in the interrupt handler (but not always). CIAA is unused in this part of the demo.

Heart rate (aka Copper):

Bildschirmfoto 2020-02-04 um 15 33 09

There is some unusual stuff going on here. At the end of the Copper list, the Copper sets the start address of Cop list 1 to $73344 and halts in the next line. When the VBLANK happens, it starts executing at that address and writes to BLTDAT (the two yellow dots on top of the DMA debugger view). Due to the current CDANG settings, this halts the Copper.

The Copper is then activated manually in the IRQ handler of a CIAB interrupt:

[12301] (  3,226)  C3287C BCB-DA 0000 1780 Memory: peekCustom16(DFF002 [DMACONR]) = 3DF
[12301] (  4,  9)  C32884 BCB-DA 0000 1780 Memory: pokeCustom16(DFF096 [DMACON], 40)
[12301] (  4, 15)  C32888 BC--DA 0000 1780 Memory: pokeCustom16(DFF080 [COP1LCH], 7)
[12301] (  4, 17)  C32888 BC--DA 0000 1780 Memory: pokeCustom16(DFF082 [COP1LCL], 87D8)
[12301] (  4, 25)  C3288E BC--DA 0000 1780 Memory: pokeCustom16(DFF088 [COPJMP1], 0)
[12301] (  4, 32)  C32892 BC--DA 0000 1780 Memory: pokeCustom16(DFF1FE [NO-OP], FFFE)
[12301] (  4, 32)  C32892 BC--DA 0000 1780 Memory: peekCustom16(DFF1FE [NO-OP]) = FFFF
[12301] (  4, 38)  C32896 BC--DA 0000 1780 Memory: pokeCustom16(DFF1FE [NO-OP], 8E7C)
[12301] (  4, 38)  C32896 BC--DA 0000 1780 Memory: peekCustom16(DFF1FE [NO-OP]) = FFFF

After that there are two accesses to register NO-OP which shouldnโ€™t have any effect.

Havenโ€™t found a smoking gun yet... Iโ€™ll keep on lookingโ€ฆ

mithrendal commented 4 years ago

Oh ๐Ÿ™ˆ. There is a rock band who made a song about black lotus demo on vAmiga.

https://youtu.be/3GhoWZ5qTwI

I really hope she will pull through!!!

emoon commented 4 years ago

I can take a look at the copperlist today and see if I can spot something odd with it. What happens in this part is that the polygons that fills over the the image is done with copper kicking of blitter work. When switching to the full 3D thing the blits are interrupt driven (two blits per frame (clear and fill) line rendering is done on the CPU)

dirkwhoffmann commented 4 years ago

I really hope she will pull through!!!

Considering the intact CPU activity, she may suffer a severe locked-in syndrome. Poor girl ๐Ÿ˜ข.

dirkwhoffmann commented 4 years ago

When switching to the full 3D thing

This is exactly where it hangs. After filling all polygons, it doesn't activate the code that implements the 3D rotation.

emoon commented 4 years ago

I don't see anything obvious in the code. I will have to investigate a bit more later tonight

dirkwhoffmann commented 4 years ago

Don't know if this is related, but different Agnus revisions seems to handle the CDANG bit differently (which is not implemented yet):

http://eab.abime.net/showthread.php?t=38014&page=2

I wrote test program that uses copper to "write" to DFF006 continuously (because it is read-only, you will see contents of the register in databus)

Copper DFF006 write trick unfortunately can't be used with OCS Agnus because copper stops (COPDANG is more restricted on OCS than ECS+)

I'll write a test case for that...

emoon commented 4 years ago

Not sure. The demo runs fine on OCS, ECS and AGA (with some stuff not working correctly on AGA which we have fixed in the (no yet released) final version)

dirkwhoffmann commented 4 years ago

Not sure. The demo runs fine on OCS, ECS and AGA

OK, I can confirm that the CDANG bit in combination with the MOVE BLTDAT command has nothing to do with the girlโ€™s coma. Nevertheless, vAmiga handles it correctly now. If the CDANG bit is set, an ECS Agnus allows the Copper to write into all custom registers whereas an OCS Agnus blocks all writes to registers below $40.

BTW, I wouldn't be surprised if there is no MOVE 0,BLTDAT command in the original Copper list. This command has bit pattern 0000 0000 which makes me think that I simply see uninitialised memory here.

However, I found something else. Under certain circumstances, vAmiga mistakenly starts the Copper when Copper DMA gets switched on. Yet, I donโ€™t know if this is what I am looking for, but I already have a clean test case that exploits the bug:

Bildschirmfoto 2020-02-05 um 16 32 35 Bildschirmfoto 2020-02-05 um 16 34 34
dirkwhoffmann commented 4 years ago

The good: I've found and fixed two bugs today (Copper DMA, CDANG ECS behaviour). The bad: None of them wakes up the girl.

BTW, I've watched the rest of the demo on the real machine. There's great stuff coming up after the "coma scene" ๐Ÿ‘.

Bildschirmfoto 2020-02-05 um 19 24 58
emoon commented 4 years ago

I looked over the code and I can't spot anything weird and it does run in UAE and on real hw so it might be that the code uses some "edge case" but it's a bit hard to know for sure.

dirkwhoffmann commented 4 years ago

I looked over the code and I can't spot anything weird

Thanks a lot for having this done! Can you give me a hint how the 3D part of coma girl is getting triggered? Is it triggered by one of the CIAs? Knowing this would help me a lot to narrow down my search.

emoon commented 4 years ago

The thing is that the 2d -> 3d "morph" and the 3d rendering is in the same "part" (i.e we don't switch code) we do start to use blitter interrupts at this point so if they don't work for some reason the code will be stalled on waiting for the blitter to finish.

dirkwhoffmann commented 4 years ago

(i.e we don't switch code) we do start to use blitter interrupts

OK, thanks a lot! I'll keep an eye on Paula's interrupt logic.

dirkwhoffmann commented 4 years ago

After performing a few surgical procedures in the Copper and the CIA code today, she finally woke up from her coma ๐Ÿ˜ท.

Bildschirmfoto 2020-02-09 um 13 51 33

The fix also eliminates some graphics glitches that occurred early in the demo (when the mobile phone is shown). Now, the demo runs through till the end ๐Ÿฅณ.

Bildschirmfoto 2020-02-09 um 13 51 41 Bildschirmfoto 2020-02-09 um 13 43 49
dirkwhoffmann commented 4 years ago

Oh no, she's fallen back into a coma ๐Ÿ™ˆ. It's the Blitter accuracy level. When running in level 0 (which is supposed to be the least accurate one, everything is fine). When running in level 2, the graphics glitches reoccur and the girl doesn't wake up.

Bildschirmfoto 2020-02-09 um 14 37 33

Anyway, now I know exactly where to look at...

dirkwhoffmann commented 4 years ago

More findings (for reference).

I did run the demo with different Blitter levels. Here are the results:

Level Mobile Girl
0 ๐Ÿ‘ OK ๐Ÿ‘ Awake
0* ๐Ÿ‘ OK ๐Ÿ‘ Awake
1 ๐Ÿ‘ OK ๐Ÿ˜ท Coma
2 ๐Ÿ™ˆ Red ๐Ÿ˜ท Coma

Level 0* is an โ€žunofficialโ€œ Blitter level (compiled with debug option SLOW_BLT_DEBUG and run in level 2). It runs the slow Blitterโ€™s micro programs in a single chunk. Hence, itโ€™s like level 0 with the accurate micro programs used instead of the Fast Blitter code.

Conclusion:

The result of the second run (level 0*) suggests that itโ€™s not a functional error. I guess the whole thing is about timing. This doesnโ€™t mean that Blitter timing is wrong. It could also be a CIA timing issue.

dirkwhoffmann commented 4 years ago

Finally. Coma girl has been cured in v0.60.1 ๐Ÿ˜Ž.

vAmiga did terminate an ongoing Blitter operation if DMA was switched off in the middle. On a real Amiga, the Blitter just pauses and continues when DMA is switched on again.

The demo works pretty well now.

I am looking forward to the final version as this is one of the coolest Amiga demos Iโ€™ve watched so far. Is there already a release date?

emoon commented 4 years ago

Thanks!

No release date yet (I'm pretty much waiting for the final graphics to be finished and the artist doing it has been busy with real life and such)

dirkwhoffmann commented 4 years ago

I close this thread for now, because all major issue seem to be fixed. Thanks to all who helped me to debug this.