Skip to content

Instantly share code, notes, and snippets.

@tstone
Created October 23, 2014 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tstone/f87d2d73cd7eda28cb55 to your computer and use it in GitHub Desktop.
Save tstone/f87d2d73cd7eda28cb55 to your computer and use it in GitHub Desktop.
My first shot at 6502 assembler, circa 2002
; INES header
.inesprg 1 ; how many program banks
.ineschr 1 ; how many picture banks
.inesmap 0 ; mapper 0
.inesmir 1 ; mirror to 1
.bank 1 ; bank 1
.org $FFFA ; start address
.dw 0 ; dw = define word!
.dw Start ; give address of start of our code for rest of NES
.dw 0 ; vblank
.bank 0 ; bank 0 - place of code
.org $8000 ; code starts at $8000
Start:
lda #%00001000 ; setup of PPU
sta $2000
lda #%00011110
sta $2001
ldx #$00 ; clear register x
lda #$3F
sta $2006
lda #$00
sta $2006
loadpal: ; loop to load palette
lda tilepal, x
sta $2007
inx
cpx #32
bne loadpal ; if x isn't =32 then goto "loadpal"
waitblank: ; wait for vblank
lda $2002
bpl waitblank
lda #$00
sta $2003
lda #$00
sta $2003
; Load "T"
lda #$77 ; load sprite Y value
sta $2004
lda #$00 ; load tile number 0
sta $2004
lda #$00
sta $2004
lda #$68 ; load sprite X value
sta $2004
; Load "i"
lda #$77 ; load sprite Y value
sta $2004
lda #$01 ; load tile number 0
sta $2004
lda #$00
sta $2004
lda #$70 ; load sprite X value
sta $2004
; Load "T"
lda #$77 ; load sprite Y value
sta $2004
lda #$00 ; load tile number 0
sta $2004
lda #$00
sta $2004
lda #$77 ; load sprite X value
sta $2004
; Load "u"
lda #$77 ; load sprite Y value
sta $2004
lda #$02 ; load tile number 0
sta $2004
lda #$00
sta $2004
lda #$80 ; load sprite X value
sta $2004
; Load "s"
lda #$77 ; load sprite Y value
sta $2004
lda #$03 ; load tile number 0
sta $2004
lda #$00
sta $2004
lda #$89 ; load sprite X value
sta $2004
; Load upper left corner
lda #$70 ; Y
sta $2004
lda #$04 ; tile #
sta $2004
lda #$00
sta $2004
lda #$60
sta $2004
; Load upper right corner
lda #$70 ; Y
sta $2004
lda #$06 ; tile #
sta $2004
lda #$00
sta $2004
lda #$90
sta $2004
; Load lower left corner
lda #$78 ; Y
sta $2004
lda #$07 ; tile #
sta $2004
lda #$00
sta $2004
lda #$60
sta $2004
; Load lower right corner
lda #$78 ; Y
sta $2004
lda #$09 ; tile #
sta $2004
lda #$00
sta $2004
lda #$90
sta $2004
; Load top horizontal line
lda #$70 ; Y
sta $2004
lda #$05 ; tile #
sta $2004
lda #$00
sta $2004
lda #$68
sta $2004
; Load top horizontal line
lda #$70 ; Y
sta $2004
lda #$05 ; tile #
sta $2004
lda #$00
sta $2004
lda #$70
sta $2004
; Load top horizontal line
lda #$70 ; Y
sta $2004
lda #$05 ; tile #
sta $2004
lda #$00
sta $2004
lda #$76
sta $2004
; Load top horizontal line
lda #$70 ; Y
sta $2004
lda #$05 ; tile #
sta $2004
lda #$00
sta $2004
lda #$78
sta $2004
; Load top horizontal line
lda #$70 ; Y
sta $2004
lda #$05 ; tile #
sta $2004
lda #$00
sta $2004
lda #$80
sta $2004
; Load top horizontal line
lda #$70 ; Y
sta $2004
lda #$05 ; tile #
sta $2004
lda #$00
sta $2004
lda #$84
sta $2004
; Load top horizontal line
lda #$70 ; Y
sta $2004
lda #$05 ; tile #
sta $2004
lda #$00
sta $2004
lda #$88
sta $2004
infin:
jmp infin ; jump to invinity (program loop)
tilepal: .incbin "our.pal"
.bank 2 ; switch to bank 2
.org $0000 ; start 'em at $0000
.incbin "our.bkg" ; empy bg
.incbin "titus.spr" ; titus sprite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment