Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
wooster0 committed Sep 19, 2021
0 parents commit bf9a4c2
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 0 deletions.
68 changes: 68 additions & 0 deletions blinking_ball.asm
@@ -0,0 +1,68 @@
; a blinking ball controllable with WASD

define W 119
define S 115
define A 97
define D 100

jsr init

loop:
jsr draw_player
jsr clear_player
jsr handle_movement
jmp loop

init:
ldx #0 ; player position
stx $1 ; make sure $1 is zeroed
lda #1 ; color
rts

handle_movement:
lda $ff ; load last pressed key

; reset the last pressed key so that we only move on new input
ldy #0
sty $ff

cmp #W
beq move_up
cmp #S
beq move_down
cmp #A
beq move_left
cmp #D
beq move_right

rts

move_up:
txa
sbc #$20
tax
rts

move_down:
txa
adc #$1f
tax
rts

move_left:
dex
rts

move_right:
inx
rts

draw_player:
lda #1 ; white
sta $0200, X
rts

clear_player:
lda #0 ; black
sta $0200, X
rts
14 changes: 14 additions & 0 deletions colors.asm
@@ -0,0 +1,14 @@
; A = color to draw
LDA #0

; X = graphics index
LDX #0

draw:
STA $0200, X ; store A (the color) at $0200 + X

ADC #1

CPX #$ff
INX
BNE draw
19 changes: 19 additions & 0 deletions mirrored_colors.asm
@@ -0,0 +1,19 @@
LDA #0 ; color and index

first_draw_pass:
TAX
STA $0200, X
PHA ; push for the second pass
ADC #1
CMP #$10
BNE first_draw_pass

TAX
DEX

second_draw_pass:
PLA
INX
STA $0200, X
CPX #$20
BNE second_draw_pass

0 comments on commit bf9a4c2

Please sign in to comment.