I thought it might benefit some other new programmers to have a nice template to start off with instead of writing everything from scratch. I'm not sure if I left anything out and got all the info 100% correct, but it can always be updated if need be
Here you go:
;****************************************************************************
;* Atari 2600 Template (NTSC)
;* STARTED (Project start date here)
;* COMPLETED (date completed here)
;* PROGRAMMED BY (insert name here)
;****************************************************************************
processor 6502
include "vcs.h"
include "macro.h"
SEG
ORG $F000
RESET:
CLEAN_START ;macro.h
; ----------------------------------------------------------------------------------------------------
;[VARIABLES]
; ----------------------------------------------------------------------------------------------------
;Add variables here
; ----------------------------------------------------------------------------------------------------
;[INITIALIZATION]
; ----------------------------------------------------------------------------------------------------
;Add any needed initialization here
; ----------------------------------------------------------------------------------------------------
;[KERNAL]/[VSYNC] ;3 scanlines of VSYNC
; ----------------------------------------------------------------------------------------------------
KERNAL: lda #%1110 ;Taken from macro.h
VS_LOOP: sta WSYNC ;3 scanlines VSYNC
sta VSYNC ;Each '1' bits generates
lsr ;a VSYNC ON line (bits 1..3)
bne VS_LOOP ;1st '0' bit resets Vsync,
; ----------------------------------------------------------------------------------------------------
;[VBLANK] ;2812 Cycles for use
;76 per scanline
;37 scanlines VBLANK
; ----------------------------------------------------------------------------------------------------
lda #45 ;Set timer to 37 scanlines
sta TIM64T ;worth of time ((37*76)/64)
VB_LOOP: lda INTIM ;Read timer
;*****************
;Insert Logic here
;*****************
bne VB_LOOP ;Loop if not 0
sta WSYNC ;Rollover to scanline 38
sta VBLANK ;Enable beam/stop VBLANK
; ----------------------------------------------------------------------------------------------------
;[PLAYFIELD];Starts drawing on 38th scanline
;14,592 Cycles for use
;76 per scanline
;22.6 in Hblank
;53.3 in Visible area
; ----------------------------------------------------------------------------------------------------
ldy #191 ;192 Visible scanlines
PF_LOOP: ;*****************
;Insert Logic here
sty COLUBK ;example color gradient
;*****************
dey
sta WSYNC
bne PF_LOOP
; ----------------------------------------------------------------------------------------------------
;[OVERSCAN] ;2280 Cycles for use
;76 per scanline
;30 scanlines
; ----------------------------------------------------------------------------------------------------
lda #$42 ;Disable beam/Start VBLANK
sta VBLANK
OVERSCAN: lda #35 ;Set timer to 30 scanlines
sta TIM64T ;worth of time ((30*76)/64)
OS_LOOP: lda INTIM ;Read timer
;*****************
;Insert Logic here
;*****************
bne OS_LOOP
sta WSYNC ;Rollover to scanline 1
jmp KERNAL ;End of Kernal/loop back up
; ----------------------------------------------------------------------------------------------------
;[LOGIC SECTION]
; ----------------------------------------------------------------------------------------------------
;Fill in game logic routines here
; ----------------------------------------------------------------------------------------------------
;[INTERRUPTS]
; ----------------------------------------------------------------------------------------------------
ORG $FFFA
INTERRUPTS:
.word RESET ;NMI
.word RESET ;RESET
.word RESET ;IRQ
END
Everything look right so far?
I plan to do a port or complete remake of Temple of Apshai. I always liked that game and thought it would be a fun first project to do.
I'm getting the hang of the TIA and how much I can hammer it per scanline
I'm very happy to have found this great site!
Cya all around
*edit* corrected code formatting (replaced tabs with spaces)
Edited by ScumSoft, Wed Sep 16, 2009 3:16 PM.














