Code: Select all
lda X_POS
ADC #20
ASL a
asl a
sTA X_POS
lda Y_POS
ADC #80
ASL a
asl a
sTA Y_POS
BNE infiniteThanks in Advance
EL
Moderator: Moderators
Code: Select all
lda X_POS
ADC #20
ASL a
asl a
sTA X_POS
lda Y_POS
ADC #80
ASL a
asl a
sTA Y_POS
BNE infiniteDon't be constantly checking button presses. NMIs will occur at a steady 60 FPS. If you want your game to move at a constant, steady rate, let NMIs drive your program logic.nineTENdo wrote:WHats a good way to slow down movement of sprites on button presses.
Code: Select all
infinite
waitblank:
lda $2002
bpl waitblank
lda #$00 ; these lines tell $2003
sta $2003 ; to tell
lda #$00 ; $2004 to start
sta $2003 ; at $0000.
lda #40 ; load Y value
sta $2004 ; store Y value
lda #$02 ; tile number 0
sta $2004 ; store tile number
lda #$00 ; no special junk
sta $2004 ; store special junk
lda X_Pos ; load X value
sta $2004 ; store X value
; and yes, it MUST go in that order.
lda #$01 ; directly loads the Accumulator with 1
sta $4016 ; stores the Accumulator value (1) into $4016
lda #$00 ; directly loads the Accumulator with 0
sta $4016
lda $4016
and #1
bne KEYDN
lda $4016
lda $4016
lda $4016
lda $4016
lda $4016
lda $4016
lda $4016
JMP infiniteCode: Select all
waitblank:
lda $2002
bpl waitblankCode: Select all
.segment "ZEROPAGE"
vblanked: .res 1
.segment "CODE"
nmiHandler:
inc vblanked
rti
waitVblank:
lda vblanked
beq waitVblank
lda #0
sta vblanked
lda $2002 ; reset $2006 sub address
rts
2.vbl_timing
------------
Tests timing of VBL being set, and special case where reading VBL flag
as it would be set causes it to not be set for that frame.
8) Reading 1 PPU clock before VBL should suppress setting
5.nmi_suppression
-----------------
Tests timing of NMI suppression when reading VBL flag just as it's set,
and that this doesn't occur when reading one clock before or after.
3) Reading flag when it's set should suppress NMI
6) Reading flag 1 PPU clock after set should suppress NMI
9) Reading flag 1 PPU clock before set should suppress NMI
Great idea!! That will help with experimenting. But i cant seem to get an NMI to run. Do i need certain conditions to run it? Do you know of a simple algorithm to just add X of a sprite movement?Disch wrote:let NMIs drive your program logic.