Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .begin $0A00
- ; Simple ASM game by Lewisk3
- ; Define key input controls
- define key $FF
- define rng $FE
- define up $11
- define down $1F
- define left $1E
- define right $20
- define button_a $1C
- define button_b $28
- define button_start $2B
- define button_select $1B
- define ppos_msb $03
- define ppos_lsb $62
- define last_block $18
- jmp init
- ; Define player graphic, and block graphic
- graphics:
- dcb $BF, $'@', $78, $'H'
- init:
- lda #ppos_lsb ; Load player locations into memory
- sta $15
- lda #ppos_msb
- sta $16
- jsr drawplayer
- jmp loop
- undrawplayer:
- ldx #$00
- lda #$FF ; Load empty graphic
- sta ($15, x) ; Store colors on screen
- inx ; Increment graphic location
- lda #$00 ; Load empty graphic into A
- ldy #$01 ; Setup to write to next position on screen
- sta ($15), y ; Write graphic.
- rts
- absadd: ; Takes X and Y, overwrites whit result
- pha
- txa
- clc
- adc #$66
- tax
- pla
- bcs absaddmore
- rts
- absaddmore:
- pha
- tya
- clc
- adc #$01
- tay
- pla
- rts
- abssub: ; Takes X and Y, overwrites whit result
- pha
- txa
- sec
- sbc #$66
- tax
- pla
- bcc abssubmore
- rts
- abssubmore:
- pha
- clc
- tya
- sbc #$01
- tay
- pla
- rts
- placeblock:
- ldx $15 ; Get Player position
- ldy $16
- jsr abssub ; Move 1 up
- stx $18 ; Store block coords
- sty $19
- ldx #$02 ; Get block colors
- lda graphics, x ; Load block colors
- ldy #$00 ; Move 0 into X
- sta ($18), y ; Put block colors on screen
- ldx #$03 ; Get Block char
- lda graphics, x ; Load block char
- ldy #$01
- sta ($18), y ; Put block on screen
- lda #$00
- sta key
- rts
- breakblock:
- ldx $15 ; Get Player position
- ldy $16
- jsr abssub ; Move 1 up
- stx $18 ; Store block coords
- sty $19
- ldx #$02 ; Get block colors
- lda #$FF ; Load block colors
- ldy #$00 ; Move 0 into X
- sta ($18), y ; Put block colors on screen
- ldx #$03 ; Get Block char
- lda #$00 ; Load block char
- ldy #$01
- sta ($18), y ; Put block on screen
- lda #$00
- sta key
- rts
- drawplayer:
- ldy #$00
- ldx #$00
- lda graphics, x ; Load player graphic
- sta ($15, x) ; Store player colors on screen
- inx ; Increment to player graphic
- lda graphics, x ; Load player graphic into A
- ldy #$01 ; Setup to write to next position on screen
- sta ($15), y ; Write player.
- lda #$00
- sta key
- rts
- p_a:
- jsr placeblock
- jmp getinput
- p_b:
- jsr breakblock
- jmp getinput
- coly:
- ldy #$FF
- rts
- collide:
- ldy #$00
- ldx #$00
- lda ($15), y
- cmp #$FF
- beq colret
- cmp #$00
- bne coly
- colret:
- rts
- movedown:
- jsr undrawplayer
- movedown_r:
- lda $15
- clc
- adc #$66
- sta $15
- bcs downmore
- jsr collide
- cpy #$FF
- beq moveup_r
- jsr drawplayer
- jmp getinput
- downmore:
- lda $16
- adc #$01
- sta $16
- jsr collide
- cpy #$FF
- beq moveup_r
- jsr drawplayer
- jmp getinput
- getinput:
- lda key ; Load key input
- cmp #up
- beq moveup
- cmp #down
- beq movedown
- cmp #left
- beq moveleft
- cmp #right
- beq moveright
- cmp #button_a
- beq p_a
- cmp #button_b
- beq p_b
- ; cmp #button_start
- ; beq p_start
- ; cmp #button_select
- ; beq p_select
- rts
- moveup:
- jsr undrawplayer
- moveup_r:
- lda $15
- sec
- sbc #$66
- sta $15
- bcc upmore
- jsr collide
- cpy #$FF
- beq movedownbranch
- jsr drawplayer
- rts
- upmore:
- lda $16
- clc
- sbc #$01
- sta $16
- jsr collide
- cpy #$FF
- beq movedownbranch
- jsr drawplayer
- rts
- moveright:
- jsr undrawplayer
- moveright_r:
- lda $15
- clc
- adc #$02
- sta $15
- bcs rightmore
- jsr collide
- cpy #$FF
- beq moveleft_r
- jsr drawplayer
- rts
- rightmore:
- lda $16
- clc
- adc #$01
- sta $16
- jsr collide
- cpy #$FF
- beq moveleft_r
- jsr drawplayer
- rts
- moveleft:
- jsr undrawplayer
- moveleft_r:
- lda $15
- sec
- sbc #$02
- sta $15
- bcc leftmore
- jsr collide
- cpy #$FF
- beq moveright_r
- jsr drawplayer
- rts
- leftmore:
- lda $16
- sbc #$01
- sta $16
- jsr collide
- cpy #$FF
- beq moveright_r
- jsr drawplayer
- rts
- movedownbranch:
- jmp movedown_r
- loop:
- jsr getinput
- jmp loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement