Difference between revisions of "Atari 8Bit"

From SizeCoding
Jump to: navigation, search
Line 34: Line 34:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==== Getting something on screen ====
+
==== 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:
 +
<syntaxhighlight lang="6502">
 +
To be added
 +
</syntaxhighlight>
 +
 
 +
==== Direct-to-screen textmodes ====
 +
Fill screen with charset, (88,89)=address
 +
 
 
<syntaxhighlight lang="6502">
 
<syntaxhighlight lang="6502">
;fill screen with charset,(88,89)=an address
 
 
  org $600; free 6th page:600-6ff
 
  org $600; free 6th page:600-6ff
 
  ldy #0
 
  ldy #0
fl: tya
+
fill:  
 +
tya
 
  sta(88),y
 
  sta(88),y
 
  iny
 
  iny
  bne fl
+
  bne fill
 
  jmp *
 
  jmp *
 
</syntaxhighlight>
 
</syntaxhighlight>
  
To be added soon.
+
==== 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.
  
 
<syntaxhighlight lang="6502">
 
<syntaxhighlight lang="6502">

Revision as of 16:28, 28 March 2024

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:

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: