Big player

This commit is contained in:
2026-02-17 09:26:32 -05:00
parent e992cd6ae2
commit 2eb3aec80e
2 changed files with 55 additions and 31 deletions

BIN
plat.nes

Binary file not shown.

86
plat.s
View File

@@ -335,7 +335,7 @@ level:
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,0 .byte 0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,0
.byte 0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0 .byte 0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0
@@ -362,8 +362,10 @@ example_palette:
.segment "ZEROPAGE" .segment "ZEROPAGE"
buttons: .res 1 buttons: .res 1
vel_x: .res 1 player_pos_x: .res 1
vel_y: .res 1 player_pos_y: .res 1
player_vel_x: .res 1
player_vel_y: .res 1
cursor_x: .res 1 cursor_x: .res 1
cursor_y: .res 1 cursor_y: .res 1
@@ -411,10 +413,32 @@ main:
@draw: @draw:
jsr update_background jsr update_background
jsr draw_player
jsr ppu_update jsr ppu_update
jmp @loop jmp @loop
draw_player:
lda player_pos_y
sec
sbc #1
sta oam + (4 * 2) + 0
sta oam + (4 * 3) + 0
sec
sbc #8
sta oam + (4 * 0) + 0
sta oam + (4 * 1) + 0
lda player_pos_x
sta oam + (4 * 1) + 3
sta oam + (4 * 3) + 3
sec
sbc #8
sta oam + (4 * 0) + 3
sta oam + (4 * 2) + 3
rts
init_objects: init_objects:
lda #0 lda #0
sta var_n sta var_n
@@ -425,8 +449,8 @@ init_objects:
adc #8 adc #8
sta var_n sta var_n
sta oam+0, X ; Set Y position sta player_pos_y, X ; Set Y position
sta oam+3, X ; Set X position sta player_pos_x, X ; Set X position
txa txa
lsr lsr
@@ -441,8 +465,8 @@ init_objects:
bne :- bne :-
lda #0 lda #0
sta vel_x sta player_vel_x
sta vel_y sta player_vel_y
rts rts
@@ -458,7 +482,7 @@ movement:
beq :+ beq :+
ldx #1 ldx #1
lda #3 lda #3
sta vel_x sta player_vel_x
: :
jsr btn_left jsr btn_left
@@ -466,7 +490,7 @@ movement:
beq :+ beq :+
ldx #1 ldx #1
lda #253 lda #253
sta vel_x sta player_vel_x
: :
cpx #1 cpx #1
@@ -477,20 +501,20 @@ movement:
bne @end bne @end
lda #0 lda #0
cmp vel_x cmp player_vel_x
beq @end ; If vel_x = 0, skip decay beq @end ; If player_vel_x = 0, skip decay
; If vel_x > 0, decrement ; If player_vel_x > 0, decrement
bpl :+ bpl :+
ldx vel_x ldx player_vel_x
dex dex
stx vel_x stx player_vel_x
jmp @end jmp @end
: :
; Else if vel_x < 0, increment ; Else if player_vel_x < 0, increment
ldx vel_x ldx player_vel_x
inx inx
stx vel_x stx player_vel_x
@end: @end:
; Jump ; Jump
@@ -503,7 +527,7 @@ movement:
; Jump newly pressed this frame ; Jump newly pressed this frame
lda #250 lda #250
sta vel_y sta player_vel_y
@fail_jump: @fail_jump:
@@ -516,42 +540,42 @@ movement:
and #1 and #1
cmp #0 cmp #0
bne :+ bne :+
lda vel_y lda player_vel_y
clc clc
adc #1 ; Add 2 to velocity adc #1 ; Add 2 to velocity
sta vel_y sta player_vel_y
: :
; Apply Y velocity ; Apply Y velocity
lda oam+0 lda player_pos_y
clc clc
adc vel_y adc player_vel_y
sta oam+0 sta player_pos_y
; Keep grounded ; Keep grounded
cmp #200 cmp #200
bcc :+ bcc :+
lda #0 lda #0
sta vel_y sta player_vel_y
lda #200 lda #200
sta oam+0 sta player_pos_y
: :
; Bonk ; Bonk
lda #8 lda #8
cmp oam+0 cmp player_pos_y
bcc :+ bcc :+
lda #0 lda #0
sta vel_y sta player_vel_y
lda #8 lda #8
sta oam+0 sta player_pos_y
: :
; Apply X velocity ; Apply X velocity
lda oam+3 lda player_pos_x
clc clc
adc vel_x adc player_vel_x
sta oam+3 sta player_pos_x
rts rts