Skip to content

Commit

Permalink
gameover: lighten player B if both have the same skin
Browse files Browse the repository at this point in the history
  • Loading branch information
sgadrat committed Apr 24, 2024
1 parent e51fe16 commit 75d41f4
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 29 deletions.
29 changes: 0 additions & 29 deletions game/logic/game_states/game/game_extra_logic.asm
Expand Up @@ -1108,35 +1108,6 @@ stage_generic_init:
; No return, jump to subroutine
.)

; Change a color value to a lighter version
; A - Original color value
;
; Output
; A - Lightened color value
;
; Overwrites A
+lighten_color:
.(
; Skip if cannot be lightened, special handling for black
cmp #$0f
beq lighten_black
cmp #$30
bcs end

ligthen_normal:
; Up color to the lighter value
clc
adc #$10
rts

lighten_black:
; Change to dark-grey
lda #$00

end:
rts
.)

; Lighten a player palette
; X - Offset of the palette from players_palette
;
Expand Down
Expand Up @@ -131,6 +131,40 @@ init_gameover_screen_extra:
sta tmpfield1
TRAMPOLINE(copy_palette_to_ppu, characters_bank_number COMMA y, #CURRENT_BANK_NUMBER)

; If both players have the same character with same colors, lighten player B's colors
.(
lda config_player_a_character
cmp config_player_b_character
bne ok
lda config_player_a_character_palette
cmp config_player_b_character_palette
bne ok
ldx #$19
ldy #3
lighten_one_color:
.(
lda PPUSTATUS
lda #$3f
sta PPUADDR
stx PPUADDR

lda PPUDATA
jsr lighten_color
pha

lda #$3f
sta PPUADDR
stx PPUADDR

pla : sta PPUDATA

inx
dey
bne lighten_one_color
.)
ok:
.)

; Write winner's name
lda PPUSTATUS
lda #$20
Expand Down
29 changes: 29 additions & 0 deletions game/logic/utils.asm
Expand Up @@ -1426,3 +1426,32 @@ wait_vbi:
bpl vblankwait
rts
.)

; Change a color value to a lighter version
; A - Original color value
;
; Output
; A - Lightened color value
;
; Overwrites A
+lighten_color:
.(
; Skip if cannot be lightened, special handling for black
cmp #$0f
beq lighten_black
cmp #$30
bcs end

ligthen_normal:
; Up color to the lighter value
clc
adc #$10
rts

lighten_black:
; Change to dark-grey
lda #$00

end:
rts
.)

0 comments on commit 75d41f4

Please sign in to comment.