My Browser made new topics instead of Editing the old one's so pls delete the other ones.
At first sorry for bad English, I'm a 15 year old from Germany^^
Hiho Guy's I register nearly one year ago , because I wanted to learn asm for the 6502.
After 1 day or so I lost the intrest and distanced me from programming for the NES.
Yeasterday I realy read myself into asm again and wanted to programm a little "Game" where you could move around(with an animated Sprite) and shoot.
So I used the sourcecode of realy bad prototype of Pong(It has Marios cap as ball and no Sprite movement at all) and began to write my little "Game"
Today I reached my goals.(I must say in my opinion it's pretty good to learn asm and code a little game in 2 days.)
My sourcecode is pretty much a mess,
all the vblank NMI stuff is from the Pong prototype and all of my code isn't realy commented and all over the place.
So I want you to ignore my inaccuracy and rate my work (in realationship with that I learned asm yesterday) and recommend me stuff I could do next.
Game Rom
EDIT: Like i said it's not realy a game, it's just thea first thing I did with asm. I just want some advice how to go on and maybe do a sidescroller or a shmup like Galaga. I realy ask myself how to do this whole backgroudstuff, cause I didn't realy found a tutorial in wich is explain where you have to store the tilenumber for it etc.
I also ask myself how to do collisiondeceting with the background, and do a little game engine.
At first sorry for bad English, I'm a 15 year old from Germany^^
Hiho Guy's I register nearly one year ago , because I wanted to learn asm for the 6502.
After 1 day or so I lost the intrest and distanced me from programming for the NES.
Yeasterday I realy read myself into asm again and wanted to programm a little "Game" where you could move around(with an animated Sprite) and shoot.
So I used the sourcecode of realy bad prototype of Pong(It has Marios cap as ball and no Sprite movement at all) and began to write my little "Game"
Today I reached my goals.(I must say in my opinion it's pretty good to learn asm and code a little game in 2 days.)
My sourcecode is pretty much a mess,
all the vblank NMI stuff is from the Pong prototype and all of my code isn't realy commented and all over the place.
So I want you to ignore my inaccuracy and rate my work (in realationship with that I learned asm yesterday) and recommend me stuff I could do next.
Game Rom
EDIT: Like i said it's not realy a game, it's just thea first thing I did with asm. I just want some advice how to go on and maybe do a sidescroller or a shmup like Galaga. I realy ask myself how to do this whole backgroudstuff, cause I didn't realy found a tutorial in wich is explain where you have to store the tilenumber for it etc.
I also ask myself how to do collisiondeceting with the background, and do a little game engine.
Code:
.inesprg 1 ; 1x 16KB PRG code
.ineschr 1 ; 1x 8KB CHR data
.inesmap 0 ; mapper 0 = NROM, no bank swapping
.inesmir 1 ; background mirroring
;;;;;;;;;;;;;;;
;; Variabeln
.rsset $0000
gamestate .rs 1 ; Gamestatus
buttons1 .rs 1 ; player 1 gamepad buttons, one bit per button
buttons2 .rs 1 ; player 2 gamepad buttons, one bit per button
left .rs 1 ; Bewegung Links
right .rs 1 ; Bewegung Rechts
posx .rs 1 ; Spielerposition
posy .rs 1 ; -- ,, --
ani .rs 1 ; Spieleranimation
shoot .rs 1 ; Schuss oder nicht
face .rs 1 ; Blickrichtung
face2 .rs 1 ; Schussrichtung
sposx .rs 1 ; Schussposition
sani .rs 1 ; Spieleranimation
sposxs .rs 1 ; Schussstartposition
;; Konstanten (Noch nicht benutzt)
STATETITLE = $00 ; Titelbildschirm
STATEPLAYING = $01 ; Spielbildschirm
STATEGAMEOVER = $02 ; Game Over Bildschrim
;; Vblank, Clearmem etc.
.bank 0
.org $C000
RESET:
SEI ; disable IRQs
CLD ; disable decimal mode
LDX #$40
STX $4017 ; disable APU frame IRQ
LDX #$FF
TXS ; Set up stack
INX ; now X = 0
STX $2000 ; disable NMI
STX $2001 ; disable rendering
STX $4010 ; disable DMC IRQs
vblankwait1: ; First wait for vblank to make sure PPU is ready
BIT $2002
BPL vblankwait1
clrmem:
LDA #$00
STA $0000, x
STA $0100, x
STA $0300, x
STA $0400, x
STA $0500, x
STA $0600, x
STA $0700, x
LDA #$FE
STA $0200, x
INX
BNE clrmem
vblankwait2: ; Second wait for vblank, PPU is ready after this
BIT $2002
BPL vblankwait2
;; Sprites+Palleten
LoadPalettes:
LDA $2002
LDA #$3F
STA $2006
LDA #$00
STA $2006
LDX #$00
LoadPalettesLoop:
LDA palette, x
STA $2007
INX
CPX #$20
BNE LoadPalettesLoop
LoadSprites:
;;;;;; Spielecharakter
LDA #$09
STA $201
LDA #$19
STA $205
LDA #$08
STA $209
LDA #$18
STA $20D
LDA #$00
STA $202
STA $206
STA $20A
STA $20E
STA ani
;; Spielerposition(Start)
LDA #$80
STA posx
LDA #$30
STA posy
;; Spielstatus auf Spiel (später auf Titel)
LDA #STATEPLAYING
STA gamestate
;; NMI etc.
LDA #%10010000 ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1
STA $2000
LDA #%00011110 ; enable sprites, enable background, no clipping on left side
STA $2001
Forever:
JMP Forever ;jump back to Forever, infinite loop, waiting for NMI
NMI:
LDA #$00
STA $2003 ; set the low byte (00) of the RAM address
LDA #$02
STA $4014 ; set the high byte (02) of the RAM address, start the transfer
JSR DrawScore
;;This is the PPU clean up section, so rendering the next frame starts properly.
LDA #%10010000 ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1
STA $2000
LDA #%00011110 ; enable sprites, enable background, no clipping on left side
STA $2001
LDA #$00 ;;tell the ppu there is no background scrolling
STA $2005
STA $2005
;;;all graphics updates done by here, run game engine
;; Zu Controller Abfrage springen
JSR ReadController1 ;; Controller 1
JSR ReadController2 ;; Controller 2
GameEngine:
LDA gamestate
CMP #STATETITLE
BEQ EngineTitle ;;Check ob Title
LDA gamestate
CMP #STATEGAMEOVER
BEQ EngineGameOver ;;-- ,, -- Game Over
LDA gamestate
CMP #STATEPLAYING
BEQ EnginePlaying ;; -- ,, -- Laufendes Spiel
GameEngineDone:
JSR UpdateSprites ;;Sprite Updating
RTI
;; Titel + Game Over Screen, noch nicht fertig
EngineTitle:
JMP GameEngineDone
EngineGameOver:
JMP GameEngineDone
EnginePlaying:
JMP GameEngineDone
UpdateSprites:
JSR Moveguy
Lda shoot
beq Shootdone2
LDA face
sta face2
lda posx
sta sposx
sta sposxs
lda #00
sta shoot
sta $212
LDA #$0a
sta $211
Shootdone2:
Leftb:
LDA left
BEQ Leftdone
LDA posx
SEC
SBC #$01
STA posx
LDA #01
clc
adc ani
STA ani
LDA #01
STA face
Leftdone:
Rightb:
LDA right
BEQ Rightdone
LDA posx
CLC
ADC #01
STA posx
LDA #01
clc
adc ani
STA ani
lda #02
sta face
Rightdone:
LDA posy
STA $200
LDA posx
STA $203
LDA posy
CLC
ADC #08
STA $204
LDA posx
STA $207
LDA posx
SEC
SBC #08
STA $20b
LDA posy
STA $208
LDA posx
SEC
SBC #08
STA $20f
LDA posy
CLC
ADC #08
STA $20c
Lda #00
sta left
sta right
Shootcompare:
LDA sposxs
SEC
SBC sposx
CMP #$50
BCC ShootcompareDone
CMP #$C0
BCS ShootcompareDone
LDA #$FE
STA $212
STA $211
STA $213
STA $214
ShootcompareDone:
Shootright:
LDA face2
cmp #01
BEQ ShootRightDone
LDA sposx
CLC
ADc #02
STA sposx
ShootRightDone:
Shootleft:
LDA face2
cmp #02
BEQ ShootLeftDone
LDA sposx
SEC
SBC #02
STA sposx
ShootLeftDone:
LDA posy
STA $210
LDA sposx
STA $213
LDX ani
CPX #08
Beq Animation
LDY sani
clc
adc #01
sta sani
RTS
DrawScore:
RTS
Moveguy:
CheckLeft:
LDA buttons1
and #%00000010
Cmp #%00000010
BNE CheckLeftDone
LDA #$01
STA left
CheckLeftDone:
CheckRight:
LDA buttons1
and #%00000001
CMP #%00000001
BNE CheckRightDone
LDA #$01
STA right
CheckRightDone:
CheckShoot:
LDA buttons1
and #%10000000
Cmp #%10000000
BNE CheckShootDone
LDA #$01
STA shoot
CheckShootDone:
RTS
ReadController1:
LDA #$01
STA $4016
LDA #$00
STA $4016
LDX #$08
ReadController1Loop:
LDA $4016
LSR A
ROL buttons1
DEX
BNE ReadController1Loop
RTS
ReadController2:
LDA #$01
STA $4016
LDA #$00
STA $4016
LDX #$08
ReadController2Loop:
LDA $4017
LSR A
ROL buttons2
DEX
BNE ReadController2Loop
RTS
Animation:
LDX $205
CPX #$19
BNE Animation2
LDA #$1B
STA $205
LDA #$1A
STA $20d
LDA #00
sta ani
RTS
Animation2:
LDA #$19
sta $205
LDA #$18
sta $20d
lda #00
sta ani
rts
;;;;;;;;;;;;;;
.bank 1
.org $E000
palette:
.db $0f,$0f,$0f,$0F, $0f,$0f,$0f,$0F, $0f,$0f,$0f,$0F, $0f,$0f,$0f,$0F
.db $0f,$06,$2a,$30, $22,$08,$0f,$3C, $22,$1C,$15,$14, $22,$02,$38,$3C
.org $FFFA ;first of the three vectors starts here
.dw NMI ;when an NMI happens (once per frame if enabled) the
;processor will jump to the label NMI:
.dw RESET ;when the processor first turns on or is reset, it will jump
;to the label RESET:
.dw 0 ;external interrupt IRQ is not used in this tutorial
;;;;;;;;;;;;;;
.bank 2
.org $0000
.incbin "mario.chr" ;includes 8KB graphics file from SMB1
.ineschr 1 ; 1x 8KB CHR data
.inesmap 0 ; mapper 0 = NROM, no bank swapping
.inesmir 1 ; background mirroring
;;;;;;;;;;;;;;;
;; Variabeln
.rsset $0000
gamestate .rs 1 ; Gamestatus
buttons1 .rs 1 ; player 1 gamepad buttons, one bit per button
buttons2 .rs 1 ; player 2 gamepad buttons, one bit per button
left .rs 1 ; Bewegung Links
right .rs 1 ; Bewegung Rechts
posx .rs 1 ; Spielerposition
posy .rs 1 ; -- ,, --
ani .rs 1 ; Spieleranimation
shoot .rs 1 ; Schuss oder nicht
face .rs 1 ; Blickrichtung
face2 .rs 1 ; Schussrichtung
sposx .rs 1 ; Schussposition
sani .rs 1 ; Spieleranimation
sposxs .rs 1 ; Schussstartposition
;; Konstanten (Noch nicht benutzt)
STATETITLE = $00 ; Titelbildschirm
STATEPLAYING = $01 ; Spielbildschirm
STATEGAMEOVER = $02 ; Game Over Bildschrim
;; Vblank, Clearmem etc.
.bank 0
.org $C000
RESET:
SEI ; disable IRQs
CLD ; disable decimal mode
LDX #$40
STX $4017 ; disable APU frame IRQ
LDX #$FF
TXS ; Set up stack
INX ; now X = 0
STX $2000 ; disable NMI
STX $2001 ; disable rendering
STX $4010 ; disable DMC IRQs
vblankwait1: ; First wait for vblank to make sure PPU is ready
BIT $2002
BPL vblankwait1
clrmem:
LDA #$00
STA $0000, x
STA $0100, x
STA $0300, x
STA $0400, x
STA $0500, x
STA $0600, x
STA $0700, x
LDA #$FE
STA $0200, x
INX
BNE clrmem
vblankwait2: ; Second wait for vblank, PPU is ready after this
BIT $2002
BPL vblankwait2
;; Sprites+Palleten
LoadPalettes:
LDA $2002
LDA #$3F
STA $2006
LDA #$00
STA $2006
LDX #$00
LoadPalettesLoop:
LDA palette, x
STA $2007
INX
CPX #$20
BNE LoadPalettesLoop
LoadSprites:
;;;;;; Spielecharakter
LDA #$09
STA $201
LDA #$19
STA $205
LDA #$08
STA $209
LDA #$18
STA $20D
LDA #$00
STA $202
STA $206
STA $20A
STA $20E
STA ani
;; Spielerposition(Start)
LDA #$80
STA posx
LDA #$30
STA posy
;; Spielstatus auf Spiel (später auf Titel)
LDA #STATEPLAYING
STA gamestate
;; NMI etc.
LDA #%10010000 ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1
STA $2000
LDA #%00011110 ; enable sprites, enable background, no clipping on left side
STA $2001
Forever:
JMP Forever ;jump back to Forever, infinite loop, waiting for NMI
NMI:
LDA #$00
STA $2003 ; set the low byte (00) of the RAM address
LDA #$02
STA $4014 ; set the high byte (02) of the RAM address, start the transfer
JSR DrawScore
;;This is the PPU clean up section, so rendering the next frame starts properly.
LDA #%10010000 ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1
STA $2000
LDA #%00011110 ; enable sprites, enable background, no clipping on left side
STA $2001
LDA #$00 ;;tell the ppu there is no background scrolling
STA $2005
STA $2005
;;;all graphics updates done by here, run game engine
;; Zu Controller Abfrage springen
JSR ReadController1 ;; Controller 1
JSR ReadController2 ;; Controller 2
GameEngine:
LDA gamestate
CMP #STATETITLE
BEQ EngineTitle ;;Check ob Title
LDA gamestate
CMP #STATEGAMEOVER
BEQ EngineGameOver ;;-- ,, -- Game Over
LDA gamestate
CMP #STATEPLAYING
BEQ EnginePlaying ;; -- ,, -- Laufendes Spiel
GameEngineDone:
JSR UpdateSprites ;;Sprite Updating
RTI
;; Titel + Game Over Screen, noch nicht fertig
EngineTitle:
JMP GameEngineDone
EngineGameOver:
JMP GameEngineDone
EnginePlaying:
JMP GameEngineDone
UpdateSprites:
JSR Moveguy
Lda shoot
beq Shootdone2
LDA face
sta face2
lda posx
sta sposx
sta sposxs
lda #00
sta shoot
sta $212
LDA #$0a
sta $211
Shootdone2:
Leftb:
LDA left
BEQ Leftdone
LDA posx
SEC
SBC #$01
STA posx
LDA #01
clc
adc ani
STA ani
LDA #01
STA face
Leftdone:
Rightb:
LDA right
BEQ Rightdone
LDA posx
CLC
ADC #01
STA posx
LDA #01
clc
adc ani
STA ani
lda #02
sta face
Rightdone:
LDA posy
STA $200
LDA posx
STA $203
LDA posy
CLC
ADC #08
STA $204
LDA posx
STA $207
LDA posx
SEC
SBC #08
STA $20b
LDA posy
STA $208
LDA posx
SEC
SBC #08
STA $20f
LDA posy
CLC
ADC #08
STA $20c
Lda #00
sta left
sta right
Shootcompare:
LDA sposxs
SEC
SBC sposx
CMP #$50
BCC ShootcompareDone
CMP #$C0
BCS ShootcompareDone
LDA #$FE
STA $212
STA $211
STA $213
STA $214
ShootcompareDone:
Shootright:
LDA face2
cmp #01
BEQ ShootRightDone
LDA sposx
CLC
ADc #02
STA sposx
ShootRightDone:
Shootleft:
LDA face2
cmp #02
BEQ ShootLeftDone
LDA sposx
SEC
SBC #02
STA sposx
ShootLeftDone:
LDA posy
STA $210
LDA sposx
STA $213
LDX ani
CPX #08
Beq Animation
LDY sani
clc
adc #01
sta sani
RTS
DrawScore:
RTS
Moveguy:
CheckLeft:
LDA buttons1
and #%00000010
Cmp #%00000010
BNE CheckLeftDone
LDA #$01
STA left
CheckLeftDone:
CheckRight:
LDA buttons1
and #%00000001
CMP #%00000001
BNE CheckRightDone
LDA #$01
STA right
CheckRightDone:
CheckShoot:
LDA buttons1
and #%10000000
Cmp #%10000000
BNE CheckShootDone
LDA #$01
STA shoot
CheckShootDone:
RTS
ReadController1:
LDA #$01
STA $4016
LDA #$00
STA $4016
LDX #$08
ReadController1Loop:
LDA $4016
LSR A
ROL buttons1
DEX
BNE ReadController1Loop
RTS
ReadController2:
LDA #$01
STA $4016
LDA #$00
STA $4016
LDX #$08
ReadController2Loop:
LDA $4017
LSR A
ROL buttons2
DEX
BNE ReadController2Loop
RTS
Animation:
LDX $205
CPX #$19
BNE Animation2
LDA #$1B
STA $205
LDA #$1A
STA $20d
LDA #00
sta ani
RTS
Animation2:
LDA #$19
sta $205
LDA #$18
sta $20d
lda #00
sta ani
rts
;;;;;;;;;;;;;;
.bank 1
.org $E000
palette:
.db $0f,$0f,$0f,$0F, $0f,$0f,$0f,$0F, $0f,$0f,$0f,$0F, $0f,$0f,$0f,$0F
.db $0f,$06,$2a,$30, $22,$08,$0f,$3C, $22,$1C,$15,$14, $22,$02,$38,$3C
.org $FFFA ;first of the three vectors starts here
.dw NMI ;when an NMI happens (once per frame if enabled) the
;processor will jump to the label NMI:
.dw RESET ;when the processor first turns on or is reset, it will jump
;to the label RESET:
.dw 0 ;external interrupt IRQ is not used in this tutorial
;;;;;;;;;;;;;;
.bank 2
.org $0000
.incbin "mario.chr" ;includes 8KB graphics file from SMB1