dirkwhoffmann / vAmiga

vAmiga is a user-friendly Amiga 500, 1000, 2000 emulator for macOS

Home Page:https://dirkwhoffmann.github.io/vAmiga

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Call the line drawing code at the beginning of the HSYNC area

dirkwhoffmann opened this issue · comments

Quote from #656

Originally, I wanted to solve the issue by drawing a scanline not at the end of a DMA line, but at the beginning of the HBLANK area. However, this causes lots of problems which finally made me jeopardise this idea.

I am somewhat unhappy with my imperfect NTSC implementation. In order to do it right, I need to resurrect my original plan to draw every scanline in a single chunk. This means that the drawing code must no longer be called at the end of a DMA line but a few cycles later (at the beginning of the HBLANK area).

Update: The new code architecture seems to work. In v2.1 there will be two repeating horizontal events: EOL and HSYNC. EOL replaces the old HSYNC event and is called at the end of a DMA line (just like the HSYNC event before). The new HSYNC event is called around the beginning of the HBLANK area (around cycle 0x11). It triggers the line drawing code in Denise and the DMA debugger.

The new architecture is slightly more complicated than the old one. E.g., the DMA debugger has to mix DMA data from the previous line and the current line to get things right. On the positive side, some hacks are obsolete now. E.g., no more magic is required to emulate overscan.

The following image shows an NTSC frame drawn by the new code:

Bildschirmfoto 2022-06-06 um 15 53 06

To the right, alternating short and long lines are visible. The red vertical bars visualise memory refresh cycles. In short lines, they start at $E2, in long lines at $E3.

Don't get confused by the thin white line at the very left. This pixel indicates if a line is drawn in lores or hires. It is picked up by the GPU upscaling shader. Maybe I can encode this information in the alpha channel, so it won't be visible in the DMA debugger any more.

Fixed in v2.1b2