Atari Missiles Programming

Atari Missiles Programming

There is an chip in the Atari computer called GTIA that is used to process the video signal display. The memory registers exist between $D000 – $D0FF (53248-53505). Our focus within these registers will be on Atari Missiles Programming to demonstrate how this works. 

Simply put, an Atari Player Missile Graphic is a raster line that can move over the screen display without creating an impact on the background, so nothing gets erased. They operate independent of everything they pass over, even other Player Missile Graphics do not conflict with each other.

Atari Missiles Programming

The purpose of this article is to demonstrate how to create a simple program in Atari Assembly language that will produce a missile display on the screen that can be controlled with a joystick controller. The missiles do not have any yet defined shape, but will appear as long bars on the screen. This is the fastest way to get a display on the screen without modifying the bits to create characters from them.

The program will be also broken into parts. This is the easiest way to learn Atari Assembly language programming and coding in general. By dividing up the functions into little sections, you can begin to extract important concepts that build upon the main program’s core.

Displaying a Player Missile

The program below will initialize the compiler area to place the bytes into memory using the .OPT OBJ,NO LIST (using the Atari MAC/65 Assembler/Editor) and the program counter is set to $8000 (32768). This is the memory area our program will be contained in.

The next part changes the color of the Player Missile (704), places it at a horizontal position (53248), and turns on the graphic missile (53261) within our Atari Missiles Programming example! By placing the value of 255 here we are turning on all the bits in our player, which is why we get the solid lines seen in the featured screenshot.

10 .OPT OBJ,NO LIST
20 ;
30 ; JOYSTICK ROUTINE
40 ;
50 *= $8000
60 PMG
70 LDA #$48
80 STA $2C0
90 LDA #$64
100 STA $D000
110 LDA #$FF
120 STA $D00D

Reading the Atari Joystick

After this we begin the first part of our main loop (JOY) and read all 2 positions of the joystick going right (CMP #7) and left (CMP #11). 

The next part will check for the fire button (LDA 644) to be pressed and wait for an action. Otherwise it stays in the main loop to keep the program running. 

130 JOY
140 LDA $0278  ;read joystick
150 CMP #$07
160 BEQ RGT ;moved right
170 CMP #$B
180 BEQ LFT ;moved left
190 LDA $0284
200 BEQ FIRE ;fire button pressed
210 JMP JOY

Moving the Atari Player Missile

The next part of our program creates a label called RGT (“Right”) to manage the right movement of the joystick. It will increment (INC) the missile (53248) horizontally. There is also a slight delay to slow down the program and finally it returns back to read the joystick routine (JOY).

The next set of lines to the right of this code repeats the same thing, except it is used to move the left player.

220 RGT
230 INC SCX
240 LDA SCX
250 STA $D000
260 JSR DELAY
270 JMP JOY
280 LFT
290 DEC SCX
300 LDA SCX
310 STA $D000
320 JSR DELAY
330 JMP JOY

Slowing down the Assembly language program

Earlier when the joystick was being moved a function call was made to slow the program down (DELAY). In this section the accumulator is using two nested loops to create a lot of cycles to manage a delay for the main program. Without this, the Atari Missile would move to fast for the human eye to see clearly.  I’ll admit this is a bad method to programming a delay, and it is better to use timers, but that is more of an advanced lesson, which we could cover later.

At the end contains the variables that manage the movement (SCX and SCY). These could be used to track a location later and are necessary since the Atari byte at 53248 is contained in ROM.

340 DELAY
350 LDA #$FF
360 LP1 LDY #$01
370 LP2 DEY
380 BNE LP2
390 DEX
400 BNE LP1
410 FIRE RTS
420 SCX .BYTE $2D
430 SCY .BYTE 0