Posted: Sat Jun 18, 2011 6:24 am
Lets wait until i have some gameplay before a creative name (that doenst have to do with anything sexual you freaks)!
Code: Select all
.rsset $0000
shooting .rs 1 ;this reserves one bit to this var, correct?
Code: Select all
Snakes = $0500 ; Number of snakes (8-bit)
Rocks = $0501 ; Number of rocks (16-bit)
Kites = $0503 ; Number of kites (8-bit)
.org $c000 ; Our program starts at $C000 in ROM (PRG)
; Variable initialisation
lda #0 ; We don't want any kites
sta Kites
lda #8 ; We want 8 rocks (low byte of 16-bit value)
sta Rocks
lda #0 ; Upper byte of 16-bit value
sta Rocks+1
lda #$2a ; We want 42 snakes
sta Snakes
; Let's do something with Kites, which is easy since it's an
; 8-bit value
lda Kites ; Load number of kites (from $0503) into accumulator
clc
adc #4 ; Add 4 to it (so we should now have 4 kites)
sta Kites ; ...and store it back in $0503
Code: Select all
; Initialisation
init:
lda #254
sta Kites
lda Kites
clc
adc #4
sta Kites
; Show results in middle of screen as a pixel
; colour ANDed with $0F (see Help)
sta $3EF
; Infinitely loop
jmp init
Kites: dcb 0
Code: Select all
lda #122 ; We want 378 rocks, so store 122 (378-256) in the low byte
sta Rocks
lda #1 ; ...and store 1 (e.g. 256) in the upper byte
sta Rocks+1
Sorry, but I have to disagree. Declaring variables like this is fine in small programs, but once your games get complex and you have hundreds of variables this is hell to manage. Every time you need to move variables around (and you will need to do this a few times during development, I assure you) you'll have to manually change hundreds of addresses. Not cool. Not to mention that it's really easy to make mistakes and end up with overlapping variables.koitsu wrote:Code: Select all
Snakes = $0500 ; Number of snakes (8-bit) Rocks = $0501 ; Number of rocks (16-bit) Kites = $0503 ; Number of kites (8-bit)
Not really true (if I'm not misunderstanding how to use .rsset and .rs -- it has been ~5 years ago since the last time I used NESASM...)koitsu wrote:I STRONGLY suggest avoiding using .RSSET and .RS. These pseudo-ops are confusing as hell; I've read the documentation (and its examples) 4 or 5 times now, and although I think I get it, they really don't make any sense. Awful awful awful.
Code: Select all
.rsset $500
Snakes .rs 1
Rocks .rs 2
Kites .rs 1
Code: Select all
ReadA:
LDA $4016
AND #%00000001
BEQ ReadADone
if shooting = $00 ;how would i do this typoe of line in 6502 ASM?
LDA #$01
STA shooting
ReadADone:
Code: Select all
If shooting = $01 then
LDA $0207
CLC
ADC #$01
STA $0207
Code: Select all
if $0207 < $00
LDA #$00
STA shooting
Code: Select all
lda ControllerState
and #%00000001 ;<- change this depending on the button you want to check
beq ButtonNotPressed
;BUTTON IS PRESSED
jmp Done ;<- this is needed to skip over the "not pressed" code
ButtonNotPressed:
;BUTTON IS NOT PRESSED
Done:Code: Select all
ldx #$00 ;assume "Shooting" will be 0
lda ControllerState
and #BUTTON_A ;I'm using a constant here
beq StoreShooting ;branch if it really is supposed to be 0
inx ;A is pressed, so "Shooting" needs to be 1
StoreShooting:
stx Shooting