and+cmp -> bit where possible
This commit is contained in:
parent
7b637436b8
commit
325006664b
70
pewpew.asm
70
pewpew.asm
@ -221,13 +221,10 @@ LoadPaletteAndTileData:
|
|||||||
sta $00
|
sta $00
|
||||||
ldx #$0000 ; This is a blank tile.
|
ldx #$0000 ; This is a blank tile.
|
||||||
; 1 in 8 chance that we choose a non-blank tile.
|
; 1 in 8 chance that we choose a non-blank tile.
|
||||||
and #%00000111
|
bit #%00000111
|
||||||
cmp #%00000111
|
|
||||||
bne +
|
bne +
|
||||||
ldx #$0002
|
ldx #$0002
|
||||||
lda $00
|
bit #%10000000
|
||||||
and #%10000000
|
|
||||||
cmp #%10000000
|
|
||||||
bne +
|
bne +
|
||||||
ldx #$8002 ; Flip vertically.
|
ldx #$8002 ; Flip vertically.
|
||||||
+
|
+
|
||||||
@ -324,9 +321,8 @@ JoypadHandler:
|
|||||||
; TODO(mcmillen): handle joystick using 16-bit loads?
|
; TODO(mcmillen): handle joystick using 16-bit loads?
|
||||||
JoypadUp:
|
JoypadUp:
|
||||||
lda JOY1H
|
lda JOY1H
|
||||||
and #$08 ; Up
|
bit #$08 ; Up
|
||||||
cmp #$08
|
beq JoypadDown ; Button not pressed.
|
||||||
bne JoypadDown ; Button not pressed.
|
|
||||||
lda playerY
|
lda playerY
|
||||||
cmp #0
|
cmp #0
|
||||||
beq JoypadDown ; Value saturated.
|
beq JoypadDown ; Value saturated.
|
||||||
@ -335,9 +331,8 @@ JoypadUp:
|
|||||||
|
|
||||||
JoypadDown:
|
JoypadDown:
|
||||||
lda JOY1H
|
lda JOY1H
|
||||||
and #$04
|
bit #$04 ; Down
|
||||||
cmp #$04
|
beq JoypadLeft ; Button not pressed.
|
||||||
bne JoypadLeft ; Button not pressed.
|
|
||||||
lda playerY
|
lda playerY
|
||||||
cmp #(224 - 32)
|
cmp #(224 - 32)
|
||||||
beq JoypadLeft ; Value saturated.
|
beq JoypadLeft ; Value saturated.
|
||||||
@ -346,9 +341,8 @@ JoypadDown:
|
|||||||
|
|
||||||
JoypadLeft:
|
JoypadLeft:
|
||||||
lda JOY1H
|
lda JOY1H
|
||||||
and #$02 ; Left
|
bit #$02 ; Left
|
||||||
cmp #$02
|
beq JoypadRight ; Button not pressed.
|
||||||
bne JoypadRight ; Button not pressed.
|
|
||||||
lda playerX
|
lda playerX
|
||||||
cmp #0
|
cmp #0
|
||||||
beq JoypadRight ; Value saturated.
|
beq JoypadRight ; Value saturated.
|
||||||
@ -357,9 +351,8 @@ JoypadLeft:
|
|||||||
|
|
||||||
JoypadRight:
|
JoypadRight:
|
||||||
lda JOY1H
|
lda JOY1H
|
||||||
and #$01
|
bit #$01 ; Right
|
||||||
cmp #$01 ; Right
|
beq JoypadStart ; Button not pressed.
|
||||||
bne JoypadStart ; Button not pressed.
|
|
||||||
lda playerX
|
lda playerX
|
||||||
cmp #(256 - 32)
|
cmp #(256 - 32)
|
||||||
beq JoypadStart ; Value saturated.
|
beq JoypadStart ; Value saturated.
|
||||||
@ -368,29 +361,26 @@ JoypadRight:
|
|||||||
|
|
||||||
JoypadStart:
|
JoypadStart:
|
||||||
lda JOY1H
|
lda JOY1H
|
||||||
and #$10 ; Start
|
bit #$10 ; Start
|
||||||
cmp #$10
|
beq JoypadSelect ; Button not pressed.
|
||||||
bne JoypadSelect ; Button not pressed.
|
|
||||||
lda backgroundRed
|
lda backgroundRed
|
||||||
cmp #0
|
cmp #31
|
||||||
beq JoypadSelect ; Value saturated.
|
beq JoypadSelect ; Value saturated.
|
||||||
dec backgroundRed
|
inc backgroundRed
|
||||||
|
|
||||||
JoypadSelect:
|
JoypadSelect:
|
||||||
lda JOY1H
|
lda JOY1H
|
||||||
and #$20 ; Select
|
bit #$20 ; Select
|
||||||
cmp #$20
|
beq JoypadY ; Button not pressed.
|
||||||
bne JoypadY ; Button not pressed.
|
|
||||||
lda backgroundRed
|
lda backgroundRed
|
||||||
cmp #31
|
cmp #0
|
||||||
beq JoypadY ; Value saturated.
|
beq JoypadY ; Value saturated.
|
||||||
inc backgroundRed
|
dec backgroundRed
|
||||||
|
|
||||||
JoypadY:
|
JoypadY:
|
||||||
lda JOY1H
|
lda JOY1H
|
||||||
and #$40 ; Y
|
bit #$40 ; Y
|
||||||
cmp #$40
|
beq JoypadX ; Button not pressed.
|
||||||
bne JoypadX ; Button not pressed.
|
|
||||||
lda backgroundGreen
|
lda backgroundGreen
|
||||||
cmp #0
|
cmp #0
|
||||||
beq JoypadX ; Value saturated.
|
beq JoypadX ; Value saturated.
|
||||||
@ -398,9 +388,8 @@ JoypadY:
|
|||||||
|
|
||||||
JoypadX:
|
JoypadX:
|
||||||
lda JOY1L
|
lda JOY1L
|
||||||
and #$40 ; X
|
bit #$40 ; X
|
||||||
cmp #$40
|
beq JoypadL ; Button not pressed.
|
||||||
bne JoypadL ; Button not pressed.
|
|
||||||
lda backgroundGreen
|
lda backgroundGreen
|
||||||
cmp #31
|
cmp #31
|
||||||
beq JoypadL ; Value saturated.
|
beq JoypadL ; Value saturated.
|
||||||
@ -408,9 +397,8 @@ JoypadX:
|
|||||||
|
|
||||||
JoypadL:
|
JoypadL:
|
||||||
lda JOY1L
|
lda JOY1L
|
||||||
and #$20 ; L
|
bit #$20 ; L
|
||||||
cmp #$20
|
beq JoypadR ; Button not pressed.
|
||||||
bne JoypadR ; Button not pressed.
|
|
||||||
lda backgroundBlue
|
lda backgroundBlue
|
||||||
cmp #0
|
cmp #0
|
||||||
beq JoypadR ; Value saturated.
|
beq JoypadR ; Value saturated.
|
||||||
@ -418,9 +406,8 @@ JoypadL:
|
|||||||
|
|
||||||
JoypadR:
|
JoypadR:
|
||||||
lda JOY1L
|
lda JOY1L
|
||||||
and #$10 ; R
|
bit #$10 ; R
|
||||||
cmp #$10
|
beq JoypadB ; Button not pressed.
|
||||||
bne JoypadB ; Button not pressed.
|
|
||||||
lda backgroundBlue
|
lda backgroundBlue
|
||||||
cmp #31
|
cmp #31
|
||||||
beq JoypadB ; Value saturated.
|
beq JoypadB ; Value saturated.
|
||||||
@ -428,9 +415,8 @@ JoypadR:
|
|||||||
|
|
||||||
JoypadB:
|
JoypadB:
|
||||||
lda JOY1H
|
lda JOY1H
|
||||||
and #$80 ; B
|
bit #$80 ; B
|
||||||
cmp #$80
|
beq JoypadDone
|
||||||
bne JoypadDone
|
|
||||||
jsr MaybeShoot
|
jsr MaybeShoot
|
||||||
|
|
||||||
JoypadDone:
|
JoypadDone:
|
||||||
|
Loading…
Reference in New Issue
Block a user