From 2eb3aec80edc91a4c8bcf26770ff361a7f0b718b Mon Sep 17 00:00:00 2001 From: Trevor Maze Date: Tue, 17 Feb 2026 09:26:32 -0500 Subject: [PATCH] Big player --- plat.nes | Bin 40976 -> 40976 bytes plat.s | 86 +++++++++++++++++++++++++++++++++++-------------------- 2 files changed, 55 insertions(+), 31 deletions(-) diff --git a/plat.nes b/plat.nes index d7c9069fca771318dca6aca18cfb4193b8398dee..bdb305d7c17521e5d6a44292f65dc1ff128f7584 100644 GIT binary patch delta 430 zcmZutJxc>Y5Z&E7&2hVDjx&;NgtfG?wet%^L%_d~CXoCFK~3TW2^^jT!6p_58{AX@ z3qc5^2_&h~X(L3NoZVSyAqZ}wc1|(Oy!Yla=#rpI+86kE9~#Jv#v*tZjk0(RvV8Z=NzJQH!ye#=D9-z^Z zLOm8IU8~84RhHcPQ+$>a9iW4LVCkuj>H}3) zj|SHCQb$=prOopU?D`Se*madF9xFWWwmJu=;heayv^pE$Cq!p+>IxPFi=d}IK!mQ_NC?8lULr7JVWkly z!46#nFM$eyr#c1OArQK3hb}_UXm#s74D-zMdzk072gDwb?l~@}c@wEqAM8&!slrD^ z9PnknA`nl)o#`d@5|+0o3tmh(n)~@HQ<`xXd2ziITY4eZ?q^Qj5L{aA{uY-&ALeJVJ@wh-*+uni?LTyTf$lgdrJG^( ztU!8!jVCkCifxY>0vU3R^#KajIJ@|9&lc{D#~h-*I(BHc7YQlH&On78t%Ttl%=4Q7 diff --git a/plat.s b/plat.s index aeef160..561c1b4 100644 --- a/plat.s +++ b/plat.s @@ -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,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,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 @@ -362,8 +362,10 @@ example_palette: .segment "ZEROPAGE" buttons: .res 1 -vel_x: .res 1 -vel_y: .res 1 +player_pos_x: .res 1 +player_pos_y: .res 1 +player_vel_x: .res 1 +player_vel_y: .res 1 cursor_x: .res 1 cursor_y: .res 1 @@ -411,10 +413,32 @@ main: @draw: jsr update_background + jsr draw_player jsr ppu_update 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: lda #0 sta var_n @@ -425,8 +449,8 @@ init_objects: adc #8 sta var_n - sta oam+0, X ; Set Y position - sta oam+3, X ; Set X position + sta player_pos_y, X ; Set Y position + sta player_pos_x, X ; Set X position txa lsr @@ -441,8 +465,8 @@ init_objects: bne :- lda #0 - sta vel_x - sta vel_y + sta player_vel_x + sta player_vel_y rts @@ -458,7 +482,7 @@ movement: beq :+ ldx #1 lda #3 - sta vel_x + sta player_vel_x : jsr btn_left @@ -466,7 +490,7 @@ movement: beq :+ ldx #1 lda #253 - sta vel_x + sta player_vel_x : cpx #1 @@ -477,20 +501,20 @@ movement: bne @end lda #0 - cmp vel_x - beq @end ; If vel_x = 0, skip decay + cmp player_vel_x + beq @end ; If player_vel_x = 0, skip decay - ; If vel_x > 0, decrement + ; If player_vel_x > 0, decrement bpl :+ - ldx vel_x + ldx player_vel_x dex - stx vel_x + stx player_vel_x jmp @end : - ; Else if vel_x < 0, increment - ldx vel_x + ; Else if player_vel_x < 0, increment + ldx player_vel_x inx - stx vel_x + stx player_vel_x @end: ; Jump @@ -503,7 +527,7 @@ movement: ; Jump newly pressed this frame lda #250 - sta vel_y + sta player_vel_y @fail_jump: @@ -516,42 +540,42 @@ movement: and #1 cmp #0 bne :+ - lda vel_y + lda player_vel_y clc adc #1 ; Add 2 to velocity - sta vel_y + sta player_vel_y : ; Apply Y velocity - lda oam+0 + lda player_pos_y clc - adc vel_y - sta oam+0 + adc player_vel_y + sta player_pos_y ; Keep grounded cmp #200 bcc :+ lda #0 - sta vel_y + sta player_vel_y lda #200 - sta oam+0 + sta player_pos_y : ; Bonk lda #8 - cmp oam+0 + cmp player_pos_y bcc :+ lda #0 - sta vel_y + sta player_vel_y lda #8 - sta oam+0 + sta player_pos_y : ; Apply X velocity - lda oam+3 + lda player_pos_x clc - adc vel_x - sta oam+3 + adc player_vel_x + sta player_pos_x rts