Difference between revisions of "6502"

From SizeCoding
Jump to: navigation, search
 
(63 intermediate revisions by 9 users not shown)
Line 7: Line 7:
  
 
=== The 6502 processor  ===
 
=== The 6502 processor  ===
The 6502 processor can be seen as the 8bit micro ARM chip.  
+
The 6502 processor can be seen as the 8-bit micro ARM chip.  
It has only has 3 registers (Accumilator, IX and IY registers) and only a handful of instructions to work with.
+
It has only has 3 registers (Accumulator, X and Y registers) and a handful of instructions to work with.
 +
 
 +
=== Adressing modes ===
 +
To be added.
  
 
=== Zero page ===
 
=== Zero page ===
 
When using the 6502 for sizecoding, you'll mostly be working from zeropage
 
When using the 6502 for sizecoding, you'll mostly be working from zeropage
  
== Atari 8bit family ==
+
== 6502 Based Platforms ==
The Atari XE/XL systems consists of the 6502 with custom hardware for graphics and sound.
+
*'''[[Atari 8Bit]]''' - Atari 8-Bit Family (Atari XL/XE, etc.)
 
+
*'''[[Apple II]]''' - Apple II(e)
=== Setting up ===
+
*'''[[Commodore 64]]''' - Commodore 64
Setting up your development platform for the Atari 8bit systems is quite easy, first get the following tools:
+
*'''[[BBC Micro]]''' - Acorn BBC Micro/Master/Electron.
 
+
*'''[[Atari Lynx]]''' - Atari Lynx Handheld
* Assembler: MADS Assembler - This assembler has nice macros for creating Binaries and SNA snapshot files out of the box. You can download it at https://mads.atari8.info/
 
* Emulator(s): I Found Altirra to work best for my usecase. 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 TIA chip, it has the following video modes:
 
 
 
To be added soon.
 
 
 
==== Getting something on screen ====
 
To be added soon.
 
 
 
<syntaxhighlight lang="6502">
 
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
+
== Generic 6502 sinus table generator ==
sty SIZEP0 ; size p0=127
+
<syntaxhighlight lang="">
 
 
ldx #0
 
ldx #0
 
ldy #$3f
 
ldy #$3f
Line 73: Line 40:
 
sta value_hi+1
 
sta value_hi+1
 
   
 
   
sta sinewave+$c0,x
+
sta sintab+$c0,x
sta sinewave+$80,y
+
sta sintab+$80,y
 
eor #$7f
 
eor #$7f
sta sinewave+$40,x
+
sta sintab+$40,x
sta sinewave+$00,y
+
sta sintab+$00,y
 
   
 
   
 
lda delta_lo+1
 
lda delta_lo+1
Line 88: Line 55:
 
dey
 
dey
 
bpl make_sine
 
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
 
</syntaxhighlight>
 
 
=== Sound ===
 
The Atari 8bit systems use the Pokey chip to generate sound.
 
To be added soon.
 
 
==== Make some noise ====
 
To be added soon.
 
 
 
 
=== Additional Resources ===
 
Sizecoding resource for the Atari 8bit are sparse
 
* Fready's github (link to be added)
 
 
== Atari Lynx ==
 
The Atari Lynx consists of the 6502 with custom hardware for graphics and sound.
 
 
=== Setting up ===
 
Setting up your development platform for the Atari Lynx:
 
 
* Assembler: -
 
* Emulator(s): -
 
 
=== Video display ===
 
To be added soon.
 
 
==== Getting something on screen ====
 
To be added soon.
 
 
 
=== Sound ===
 
To be added soon.
 
 
==== Make some noise ====
 
To be added soon.
 
 
=== Additional Resources ===
 
Sizecoding resource for the Atari Lynx are sparse
 
* 42Bastian's website (link to be added)
 
 
== Commodore 64 ==
 
The Commodore systems consists of the 6502 with custom hardware for graphics and sound.
 
 
=== Setting up ===
 
Setting up your development platform for the Commodore systems is quite easy, first get the following tools:
 
 
* Assembler: To be added
 
* Emulator(s): VICE is the way to go
 
 
=== Autoboot ===
 
<syntaxhighlight lang="6502">
 
*=$0326
 
        .word start             
 
        .byte $ed,$f6
 
start
 
; rest of code
 
 
</syntaxhighlight>
 
</syntaxhighlight>
Will give you autoboot and more space directly. (though writing through to $0400 will load it onto the screen unless you move the pointers)
 
 
=== Video display ===
 
Video display on the Commodore, it has the following video modes:
 
 
To be added soon.
 
 
==== Getting something on screen ====
 
To be added soon.
 
 
 
=== Sound ===
 
The Commodore 64 uses the famous SID chip to generate sound.
 
To be added soon.
 
 
==== Make some noise ====
 
To be added soon.
 
 
=== Additional Resources ===
 
* links to be added
 
 
 
== Apple II ==
 
The Apple II is an 8-bit home computer and one of the world's first highly successful mass-produced microcomputer products. It was designed primarily by Steve Wozniak.
 
 
=== Display ===
 
For sizecoding, you almost never want to do direct-access to graphics for Apple II in size-coding because the Apple II graphics modes are horrible.  The only fast way to do things is with large lookup tables.  To do hires you need to divide by 7 which as you can imagine is a bit difficult to do compactly on 6502. Double-hires is even crazier on top of that.  Deater did manage a color-bar style effect in double-hires in 128B but that was doing some crazy tricks with the firmware BASIC routines, definitely not direct-access.
 
 
==== Sound  ====
 
To be added soon.
 
  
=== Additional Resources ===
+
=== General 6502 Resources ===
* Deater's page on Apple II sizecoding http://www.deater.net/weave/vmwprod/demos/sizecoding.html
+
* 6502.org http://www.6502.org/
 +
* 6502 instruction reference http://www.6502.org/tutorials/6502opcodes.html
 +
* 6502 books http://retro.hansotten.nl/6502-sbc/
 +
* 6502 Assembler tutorial https://dwheeler.com/6502/oneelkruns/asm1step.html
 +
* Easy 6502 code tester https://skilldrick.github.io/easy6502/
 +
* Synthetic instructions https://wiki.nesdev.com/w/index.php/Synthetic_instructions#8-bit_rotate

Latest revision as of 12:55, 8 April 2024

Introduction

Wanting to start sizecoding on a 6502 platform in this day and age can be tough.

6502.jpg

So here is a bit of help to get you started:

The 6502 processor

The 6502 processor can be seen as the 8-bit micro ARM chip. It has only has 3 registers (Accumulator, X and Y registers) and a handful of instructions to work with.

Adressing modes

To be added.

Zero page

When using the 6502 for sizecoding, you'll mostly be working from zeropage

6502 Based Platforms

Generic 6502 sinus table generator

	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 sintab+$c0,x
			sta sintab+$80,y
			eor #$7f
			sta sintab+$40,x
			sta sintab+$00,y
 
			lda delta_lo+1
			adc #8
			sta delta_lo+1
			bcc nothing
			inc delta_hi+1
nothing
			inx
			dey
			bpl make_sine

General 6502 Resources