Skip to main content

Wozmon for Atari

Wozmon for Atari

Wozmon for Atari is, as the name suggest, an implementation of Wozmon for Atari 8 bit computer. Wozmon for Atari is made to be used in an cartridge file. Cartridge files are very handy for use use with emulators and real Atari computer provided you have a Side 3 or similar cartridge emulator.

The Wozmon source is relocatable and can be used to create EXE files or be embedded in an application. With only 259 bytes it won’t take up much space.

Source #

Wozmon for Atari uses the CA65 macro assembler which can create relocatable object file for a large variety of 6502 bases computer systems. In order to properly assemble the source a few extra informations are need which have been added to the file header.

Note that the object files are moved to the final location by the ld65. The finished CAR or EXE file is not relocatable any more.

Header

Page 0 Variables #

Use .RES to automatically allocate the page 0 variables instead of static allocation. That makes it possible to embed Wozmon into other applications.

Page 0 Variables

Other Variables #

Unlike the Apple I the Atari is not writing one character at a time but uses a character buffer for both input and output. The original Wozmon uses a generous 128 input buffer. The Atari allows only 120 (3*40) character input. With EOL the maximum buffer needed on the Atari is 121 character. I still reserve 128 bytes for the input buffer to ease up debugging.

The output buffer could theoretically be just one character however I’m planning an optimized version so for now I allocate 128 for output as well.

Other Variables

RESET and GETLINE #

On the Atari the reset and screen IO is handled by the operating system so the code is now fairly short.

Reset and get line

Or is it? Get_Line IN,IN_Len is a macro and once expanded it’s a total of 12 statements being 30 bytes long. This is the reason Wozmon for Atari is longer then the Apple I version.

Get_Line macro

Input Parser #

The Apple one uses a 7 bit ASCII character set with bit 7 set to 1. Which is very unusual. Atari uses the ATASCII character set where each character exist in normal and inverse. The normal version has bit 7 set to 0. The Atari also uses an unusual end of line marker.

So every Apple I character code used needs to be replaced with the Atari equivalent. To make the code more readable the advanced literals from the CA65 macro assembler are used. Also an additional ASL is needed to set the correct bit of the block mode.

Input Parser

One of the more tricky parts is understanding the ADC #$88 which is unchanged from the Apple I code. The way it works is as follows:

The upper case characters ‘A’ to ‘F’ have the hex code $41 … $46. After the EOR #'0' they are now mapped to $71 … $76. Just before the ADC #$88 there is the BCC DIG so when the addition is executed the carry flag is always set and a total of $89 is added resulting in a final value of $FA … $FF for the codes.

Output formatter #

Just like with the parser the character codes need to be adjusted from Apple I ASCII to ATASCII:

Output formatter

The print hex subroutine too only has the character codes adjusted. The echo subroutine now used the Atari operating system to output the character. One problem is that the OS will change the Y register which contains the current character processed so Y need to be saved and restored.

Print hex and echo character

The print hex subroutine uses the same BCC ECHO and ADD #$06 trick relying on the carry flag to be set actually adding $07.

Just like Get_Line Put_String is a macro.

Put_String

Since most real Atari computer uses the first generation 6502 they don’t have the PLY and PHA operations. Those are also macros:

PHY PLY

Interrupt Vectors #

The Atari Wozmon is compiled for a removable ROM cartridge and as such doesn’t need the interrupt vectors or the two BRK for that matter. The BRK are left in so the diff output is easier to read.

Interrupt Vectors

Cartridge run and init #

However the cartridge does needs it’s own run and init vectors. Those are generated by the ld65 linker from the cartstart and cartinit labels so we need to provide those methods so the linker has something to set.

Cartridge run and init

Not jumping right into Wozmon makes it possible to embed Wozmon into your own project.