Programming Atari

8-bit Atari computers (referred to as “Atari” from now on) were created to bring entertainment and simplify work in the households in the eighties and early nineties. The Atari catchphrase “Power without the price” was surprisingly well related to reality. Computers were quite cheap as for that times (not for the people living in constrained market conditions in Poland, though) and well-designed to actually provide the promised power.

The Atari catchphrase

Architecture
There were several Atari 8-bit models available on the marked across the years, although the internal architecture did not significantly vary. Among the most important changes are:

  • Internal RAM extended from 64 KiB to 128 KiB in most modern models (130XE)
  • Chip optimization (several chips replaced with single, more integrated one)
  • Cosmetic changes (the chassis was visually adapted to match the more modern 16-bit Atari computers while retaining the same internals

Atari was (and still is) powered with MOS 6502C CPU clocked at 1,733 MHz (PAL, 50 fps) or 1,79 MHz (NTSC, 60 fps). Most computers of that era had to be aligned with TV-signal frequency for the sake of simplicity. It means that most of the software runs faster on the NTSC based machines (music plays quicker, games are more difficult, etc.).


Atari 65 XE mainboard (source: http://oldcomputer.info)

The main CPU is supported by several auxiliary chips. At least three of them together with their functionalities are worth mentioning:

POKEY that provides:

  • Four independent sound generators (channels)
  • Keyboard handler
  • Serial input/output
  • Pseudorandom number generator

ANTIC:

  • Programmable GPU with its own opcodes, registers, etc.
  • Generates graphical output
  • Manages character sets
  • Could be temporarily disabled to speed up CPU processing (disabled ANTIC didn’t steal CPU cycles and didn’t block memory bus)

GTIA

  • Translates data provided by ANTIC to TV-signal
  • Could add an overlay with its own graphic elements (players and missiles, also known as “sprites”)
  • Detects collisions between screen elements (sprite vs sprite, sprite vs playfield – the feature of great meaning for all game developers).

Since the creators of Atari wanted it to be much more than just another toy to play games, they decided to equip the computer with fully fledged and extensible software. Each Atari computer came with an integrated BASIC interpreter that made it easy for everyone to write its own programs, for instance, for home budget management. You could start programming after one second from flipping the power switch.

Also, the bundled Atari Operating System had a lot of innovative features, including but not limited to:

  • The ability to be disabled. Yes, at any point you could decide to turn the OS off and work with the bare machine, having a lot more resources at your disposal (OS is not occupying memory and is not stealing precious CPU cycles)
  • Support for device drivers. Communication with external devices could be done via a driver installed in on of the available slots. The driver was assigned a letter (A:, B:, etc. – just like MS-DOS) and had to implement the standard interface. Thanks to that approach, even the decades-old software could easily communicate with modern devices (SD cards, Bluetooth, network, laser printers).
  • Floating point math package. MOS 6502C was not capable of doing the floating point math at all, but thanks to the mathematical package included in the operating system one could immediately start doing some serious math (trigonometry, logarithms, square roots or just floating point multiplication and division). Some of the math procedures were created by Steve Wozniak himself.

Community
Atari community is still very active these days. Poland belongs to the top countries in terms of the number of community members, gatherings and software created. There are several gatherings in Poland that are organized in regular, most often annual, basis. Among the major ones are:

  • SillyVenture – world’s biggest Atari community gathering organized annually in Gdańsk. In 2017 there were more than 200 visitors from various different countries joining the party. Just for this single occasion, they created 116 different software pieces (games, demonstration, etc.). SillyVenture also hosts talks and lectures from the legends of the Atari scene
  • WapNiak – Small and placid party with long tradition organized annually in Warsaw
  • Ironia – Annual gathering of Atarians organized near Wrocław
  • Forever – Huge Atari gathering organized by our fellows from Slovakia

The most important part of each gathering is so-called “competitions”. They consist of few different categories (music, graphics, game, etc.) so that every participant could prepare something he would like to present to the whole community. All works are then presented (usually during Saturday night) and everyone votes for his favourite creation. Winning such competition guarantees lifetime glory and provides recognition among the community members from around the world.


Recently released game Tensor Trzaskowskiego – winner of Ironia 2017 Atari Party

And when I say that community is active, I mean active. To give you some numbers: just for the 8-bit Atari alone, there were 81 new games created in 2015 and 87 games in 2016. That gives nearly 2 new games per week.

Besides the big gatherings, there are also smaller, local ones organized ad-hoc without much planning. They are more or less regular in every region of Poland with strong Atari community (Trójmiasto, Warszawa, Kraków, Wrocław, Górny Śląsk).

It’s not only software that is actively created, also the hardware guys are very prolific and are constantly creating devices that make it easier to use Atari with modern hardware and technologies like hard disks, ethernet, LCD TVs, etc. The devices and extensions that I consider most valuable for every Atari users are:

  • Stereo – gives Atari one additional POKEY chip to drive left and right sound channels separately
  • SIO2SD – with this device and single SD card you can emulate up to 16 disk drives and quickly load any piece of software
  • SIDE2 – similar to SIO2SD, but sacrifices a little bit of compatibility for much greater, nearly instant, loading speeds
  • VBXE – so-called “new graphics card” that enables Atari to manipulate graphics in the 16-bit way (blitters, big and colourful sprites, sharp picture).
  • RAM extensions – different kinds of devices that extend the standard 64 KiB memory up to 4 MiB
  • DragonCart / WiFi Cart – with these devices you can connect Atari to ethernet or WiFi network
  • Rapidus – Turbo card that equips Atari with 20 MHz CPU and 32 MiB of linear memory

Programming Atari
There are not many people who actively use Atari for doing the actual software development. Machines of that kind are so severely limited that creating comfortable tools (editors, debuggers, etc.) is nearly impossible. Naturally, such tools exist, but they tend to use all available resources, leaving barely any place for the program is actually developed. Sure, we have hard-drives, memory expansions, RAM-disks, 80-column text mode, but it’s very easily beaten by a modern PC with contemporary tools. So if you’re not the nostalgia-driven nerd but want to do some real job, configure cross-compiler for Atari on your PC.

Debugging with Altirra emulator
Such cross-compiler will crunch the 6502 assembly code and create a binary file that could easily be loaded on Atari. Actually, you don’t even need Atari, because there are several emulators in the wild, some of them still developed and maintained until this very day. Most emulators provide powerful tools that greatly improve the speed of development and debugging. Step-by-step program execution, processor execution history, CRT laser beam location preview, breakpoints, integration with modern IDE, real-time memory manipulation just to name a few. In addition, such an emulator (when asked to) could be orders of magnitude faster than real Atari in terms of CPU processing or I/O operations.

Besides emulators, one has the following tools at his disposal:

  • Wudsn! – Eclipse IDE plugin that integrates the 6502 cross-compilers and Eclipse IDE
  • g2f / Rastaconverter – tools for creating graphics for Atari. They use the power of modern PC to optimize graphics in such way that the old hardware could generate colourful and detailed images. You could just drop some .jpg graphics at these tools, wait several hours and receive the 6502 code that displays beautiful graphics on Atari. Yes, you receive “a code” since creating graphics on Atari is, in fact, a programming task since you need to take care of interrupts, changing colours on the fly, tracing the CRT laser beam, etc.
  • RMT / other music trackers – tools for creating music for Atari, taking advantage of 4 or 8 (stereo) independent music channels. Also in case of music one can use the power of modern PC to optimize track layout and instrument definitions just to minimize the memory footprint of the music track. Every single byte counts.
  • CC65 – C compiler for 6502. The decent option if the speed of pure assembly is not required, yet the easiest approach via Basic is too slow.
  • MadPascal – brand new cross-compiler that creates 6502 assembly from Pascal language

 


Atari image automatically generated from .jpg file

It is worth mentioning that also in the past when Atari was on the spot, big software houses like Lucasarts or our domestic L. K. Avalon used bigger machines like Amiga to develop their games for 8-bit Atari.

Curiosities
Despite having relatively simple architecture and being a nearly 40-year-old computer, Atari still doesn’t cease to amaze people who actively use it. Most motivated guys still reach behind the well established limits and keep discovering features that would render the creators of Atari speechless. Some of the tricks are possible only due to bugs in the hardware design and are very volatile, i.e. could be easily reproduced only on a particular piece of Atari or only when using Atari with chips produced at particular point in time.

Here are some of the most interesting examples:

  • “Hairdryer mode” – it turned out that some of the internal integrated circuits behave differently than expected when they reach certain temperatures. The effects are not noticeable during normal usage, but could be exploited by programmer to achieve otherwise impossible results that include: shifting image half-pixel left or right or generate additional colors. During normal operation Atari would require 3 to 4 hours to reach target temperature, but using hairdryer it only takes 10 to 15 minutes – hence the effect name
  • 60 fps video playback – thanks to two different and unique features on board, Atari could be used to perform 60 fps video playback with 192×160 resolution. First necessary feature is remappable video memory – ANTIC chip could be instructed to read video memory data from any place. Second necessary feature is the cartridge slot that allows the cartridge memory to be mapped directly into Atari address space. These two features together with some software wizardry allow programmer to replace video frames in memory with intervals so cleverly calculated to provide seamless video experience
  • Atari was famous for its long loading times and data transfer fragility, especially when transfer from cassette was considered. It was said that when you load from cassette you should leave the room, do not sneeze and do not make loud noises. Only recently, after the Atari operating system was reverse engineered it turned out that there is a nasty bug that sometimes prevents correct data transfer even in perfect conditions and with perfect hardware. During the transfer Atari constantly measures the speed of a moving magnetic tape and compensates for cassette recorder engine fluctuations. Unfortunately there are some corner cases not covered in the algorithm that could cause Atari to calculate some totally incorrect speed and crash the loading process, whenever you’re sneezing or not.