Atari 8Bit

From SizeCoding
Revision as of 16:32, 28 March 2024 by Superogue (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Atari 8-bit family

The systems in this family are: Atari 400, 800, 5200, 1200XL, 600XL, 800XL, 130XE, 65XE, 800XE and XEGS.

The Atari 8-bit systems consists of the 6502 with custom hardware for graphics and sound.

Setting up

Setting up your development platform for the Atari 8bit systems is quite easy, first get the following tools:

  • Assembler: MADS Assembler - This assembler can create atari XEX files out of the box. Download it at https://mads.atari8.info/
  • Emulator(s): I Found Altirra to work best for my usecases. Make sure to use the original Rev2 rom for best compatibility.

Special Memory Adresses

  • FRAMECOUNTER_HIGH = 19
  • FRAMECOUNTER_LOW = 20

Video display

Video display on the Atari 8bit systems use the ANTIC and GTIA chips. Information can be found here:

Graphics Modes

The Atari 8-bit has many different video modes to take advantage of, here is an overview.

; mode ANTIC width  height colors DL     screen_mem
;  3    8    40     24     4      $be50  $be70
;  4    9    80     48     2      $bd48  $bd80
;  5   10    80     48     4      $bb68  $bba0
;  6   11    160    96     2      $b778  $b7e0
;  7   13    160    96     4      $af98  $b060
;  8   15    320   192     2      $a036  $a150,$b000
;  9   15    80    192     16*    $a036  $a150,$b000
; 10   15    80    192     9 *    $a036  $a150,$b000
; 11   15    80    192     16*    $a036  $a150,$b000
; 14   12    160   192     2      $af38  $b060
; 15   14    160   192     4      $a036  $a150,$b000
;
; * GTIA modes 
;  9: 4-bit pixel luminance only
; 11: 4-bit pixel color only
; 10: 9 colors set in location 704..712

Sync with frame

      lda 20
waitframe:
      cmp 20
      beq waitframe

Or a shorter version if you don't mind trashing RTCLOK (20)

waitframe
      lsr 20
      bcc waitframe

ROM-Routines

The atari 8-bit has various slow ROM routines to draw pixels and lines. Here is an example that draws an XOR pattern in graphics 7 mode using ROM calls:

To be added

Direct-to-screen textmodes

Fill screen with charset, (88,89)=address

 org $600; free 6th page:600-6ff
 ldy #0
fill: 
 tya
 sta(88),y
 iny
 bne fill
 jmp *

Player-Missile Sprites

The atari 8-bit has access to 4(+1) customisable player sprites and/or 4 missile sprites. Here is some example code that shows you how to use them.

SDMCTL	= $022f
HPOSP0  = $d000
SIZEP0  = $d008
GRAFP0  = $d00d
COLPM0  = $d012

FRAMECOUNTER_HIGH = 19
FRAMECOUNTER = 20
WSYNC	= $d40a
VCOUNT	= $d40b

sinewave	= $0600		; to $06ff

		org $80

main	
	; disable all graphics/colors
	ldx #0
	stx SDMCTL	

	ldy #$7f
	sty SIZEP0	; size p0=127
		
	ldx #0
	ldy #$3f
make_sine:
value_lo
			lda #0
			clc
delta_lo
			adc #0
			sta value_lo+1
value_hi
			lda #0
delta_hi
			adc #0
			sta value_hi+1
 
			sta sinewave+$c0,x
			sta sinewave+$80,y
			eor #$7f
			sta sinewave+$40,x
			sta sinewave+$00,y
 
			lda delta_lo+1
			adc #8
			sta delta_lo+1
			bcc nothing
			inc delta_hi+1
nothing
			inx
			dey
			bpl make_sine

updateloop:
		; vblank
		lda VCOUNT
		bne updateloop

		; clear graphics
		sta HPOSP0
		sta GRAFP0

		ldy #0
		lda #47
		sta COLPM0
yloop:
		tya           ; graphics shape = y
		sta WSYNC
		sta GRAFP0

		; a = sin(frame+y)+48
		tya	
		adc FRAMECOUNTER
		tax
		lda sinewave,x
		adc #48
		sta HPOSP0
                
                iny
                bne yloop
		jmp updateloop

		run main

Sound

The Atari 8-bit use the POKEY chip to generate sound.

Make some noise

; from Analog, 1985-09,pp.25-32
*=$2000
AUDF1=$D200
AUDC1=$D201
AUDCTL=$D208
SKCTL=$D20F

.MACRO SOUND ; voice,pitch,dist,vol;,dur
	lda #%2
	sta AUDF1+2*%1
    lda #[[%3 * 16] | %4] ;lda #[[%3 shl 4] or %4]
    sta AUDC1+2*%1
.ENDM

 lda #0
 sta AUDCTL
 lda #3
 sta SKCTL

 SOUND 0,121,10,8

 jmp *

Additional Resources

Sizecoding resource for the Atari 8bit are: