
This is my current hobby. It’s giving me a much clearer understanding how to actually use assembler to do common programming tasks. While there is little call for 6502 programmers these days, I feel like I can better understand general purpose CPU programming now.
This code is a moderate hack of the kernel code shown here.
;; Built with: http://www.atari2600.org/DASM/DASM22010b.zip ;; bin\DOS\DASm.exe playfield2.asm \ ;; -IDASM\Machines\ATARI2600 \ ;; -f3 -v5 -o..\ROMS\a.bin ;; processor 6502 include "VCS.h" include "macro.h" PATTERN = $80 ; first byte of RAM SHAPE = $55 BGCOLOR_ADDR = $81 BGCOLOR = $0A BGTIMER_ADDR = $82 BGTIMER = 40 PLAYFIELD_COLOR = $0 TIMETOCHANGE = 20 SEG ORG $F000 Reset ;; Zero out RAM, TIA ;; RAM - $80-$FF ;; TIA - 0 - $7F ldx #0 lda #0 RAMLoop sta 0,x inx bne RAMLoop ;; ------- ;; Init playfield ;; ------- lda SHAPE sta PATTERN lda #PLAYFIELD_COLOR sta COLUPF ldy #0 ; animation clock lda #$10 ; Remember, ; high nibble ; is read ; backwards sta PF0 lda #$80 ; Entire byte ; read backwards sta PF2 lda #$01 sta CTRLPF ;; setup the bgcolor stuff ldx #BGTIMER stx BGTIMER_ADDR ldx #BGCOLOR stx BGCOLOR_ADDR stx COLUBK StartOfFrame ; Start of vblank processing lda #0 sta VBLANK lda #2 sta VSYNC ; 3 scanlines of VSYNCH sta WSYNC sta WSYNC sta WSYNC lda #0 sta VSYNC ; 37 lines of vertical blank ldx #$CA VertBlank inx sta WSYNC bne VertBlank ;; Playfield animation iny cpy #TIMETOCHANGE bne NOTYET ldy #0 ; reset ani clock ;; bit shift the pattern asl PATTERN bne NOTYET ;; Reset pattern lda SHAPE sta PATTERN NOTYET lda PATTERN sta PF1 ;; Change the color by adding ;; the aniclock tick to the ;; base color clc tya adc PLAYFIELD_COLOR sta COLUPF ;; 192 scanlines of picture ldx #$C0 MainPicture sta WSYNC ; strobe Wait for Sync dex bne MainPicture ;; Is it time to change ;; the BG COLOR? dec BGTIMER_ADDR bne LOAD_BGCOLOR ;; Yes - restore timer, ;; change color ldx #BGTIMER stx BGTIMER_ADDR asl BGCOLOR_ADDR bne LOAD_BGCOLOR ;; Reset BGCOLOR ldx #BGCOLOR stx BGCOLOR_ADDR LOAD_BGCOLOR ldx BGCOLOR_ADDR stx COLUBK ;; Vertical Blanking lda #%01000010 sta VBLANK ; 30 scanlines of overscan... ; #D2 = 226, 256-30 ldx #$D2 OverScanLoop inx sta WSYNC bne OverScanLoop jmp StartOfFrame ORG $FFFA ;; Interrupt Vectors .word Reset ; NMI .word Reset ; RESET .word Reset ; IRQ END
I’d like to make some playable game for the atari 2600 some day. That would bring my childhood dreams to life.