dirkwhoffmann / tiara2600

A user-friendly Atari 2600 emulator for macOS
Other
0 stars 0 forks source link

Logbook no. 1 #1

Open dirkwhoffmann opened 4 days ago

dirkwhoffmann commented 4 days ago

After watching the lovely movie Atari: Game Over, I imagined how cool it would be to play the "worst game of all times" in my self-written emulator.

Bildschirmfoto 2024-09-25 um 22 09 24

Unfortunately, with the Commodore 64 and the Commodore Amiga, my emulators imitate the wrong machines. Thus, before playing the game, we must transform a Commodore computer into an Atari. As the Commodore C64 and the Atari 2600 share an almost identical CPU, it is straightforward to commence this project with the latest version of VirtualC64.

In this thread, I am going to document the first steps in transforming VirtualC64 into an Atari 2600 emulator. I've already checked in the latest VirtualC64 code and renamed some stuff. The next big step will be to remove unnecessary components. For example, the AtariC64 has no keyboard and does not support floppy drives. Thus, before adding any Atari-specific components, let's start trashing some existing code.

So, let the heavy equipment roll…

Bildschirmfoto 2024-09-25 um 22 13 28
dirkwhoffmann commented 3 days ago

After trashing lots of unneeded stuff, we can put the heavy machinery out of business for now. In the next step, let us adjust the texture size to the screen dimensions of the Atari 2600. The following image is well known to all with some knowledge about the A2600 and basically says it all:

atari-screen-setup

Changing the texture size was comparably easy as VirtualC64 utilizes two constants called Texture::width and Texture::height instead of hard-coded values. As each machine cycle (CPU cycle) corresponds to 3 color clocks of the A2600, changing Texture::width to 76 * 3 = 228 is what we need. After the adjustment, the emulator comes up like this:

Bildschirmfoto 2024-09-27 um 16 36 02

I have already added a TIA component to the code base. However, it is only a stub at the moment. It emulates nothing but the dual-phase horizontal counter, which produces the $\phi_1$ and $\phi_2$ signals used all over the place inside the TIA. Internally, my counter is a reimplementation of the jigo2600 counter found here. I did not know how to implement it better, so my code is mainly a reimplementation in my programming style. 

I have also hacked VirtualC64’s DMA debugger to ensure the counter counts.  Instead of visualizing the accesses of the C64 data bus, it now displays $\phi_1$ and $\phi_2$:

Bildschirmfoto 2024-09-27 um 16 07 54

In the image above, $\phi_1$ is drawn in red and $\phi_2$ in yellow.