Skip to content

Commit

Permalink
Fix displaying of credits in-game
Browse files Browse the repository at this point in the history
  • Loading branch information
kandowontu committed Jan 14, 2025
1 parent 666e48e commit de735e1
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 6 deletions.
40 changes: 39 additions & 1 deletion LIB/asm/nesdash.s
Original file line number Diff line number Diff line change
Expand Up @@ -3655,9 +3655,47 @@ bank:

numsize_loop:
dey
beq use_one_vram_buffer ; If Y decrements to 0, we are just printing the last digit
lda _attemptCounter, y
beq numsize_loop

; now we have the (amount of digits to print - 1) in Y
vram_write_header:
sty tmp1

txa ;
ora #$40 ; NT_UPD_HORZ
ldx VRAM_INDEX ;
sta VRAM_BUF+0, x ; Calculate the vram address of the leftmost digit
pla ; and store in the buffer
sec ;
sbc tmp1 ;
sta VRAM_BUF+1, x ;__
iny ;
tya ; The amount of bytes needs to be incremented
sta VRAM_BUF+2, x ;__

clc
vram_write_main:
lda _attemptCounter-1, y
; clc should not be needed as the writes SHOULD NOT overflow
adc zeroChr
sta VRAM_BUF+3, x
inx
dey
bne vram_write_main

vram_write_finish:
lda #$FF
sta VRAM_BUF+3, x
txa
clc
adc #3
sta VRAM_INDEX
rts

use_one_vram_buffer:
lda _coins_inserted+0
lda _attemptCounter+0
clc
adc zeroChr
sta sreg ; doesn't matter, it's not used anymore anyway
Expand Down
11 changes: 9 additions & 2 deletions LIB/asm/neslib.s
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,18 @@ nmi:

@skipAll:

ldx #0
lda _CREDITS1_PREV
and #%00100000
beq @check_slot_2_creds
lda $4016
and #%00100000
bne @check_slot_2_creds
lda _coins_inserted
cmp #$FF
beq @skip1
inc _coins_inserted
ldx #0
@skip1:
lda #sfx_coin
JSR __sfx_play

Expand All @@ -175,8 +179,11 @@ nmi:
lda $4016
and #%01000000
bne @done_credit_check
lda _coins_inserted
cmp #$FF
beq @skip2
inc _coins_inserted
ldx #0
@skip2:
lda #sfx_coin
JSR __sfx_play

Expand Down
2 changes: 1 addition & 1 deletion SAUCE/famidash.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void main(){
//mmc3_set_prg_bank_1(GET_BANK(playPCM));
//playPCM(0);


memfill(attemptCounter, 0, sizeof(attemptCounter));
pal_spr(paletteDefaultSP);
menuMusicCurrentlyPlaying = 0;
crossPRGBankJump0(gameboy_check);
Expand Down
8 changes: 6 additions & 2 deletions SAUCE/functions/level_loading.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,17 @@ void unrle_first_screen(){ // run-length decode the first screen of a level
// register unsigned char i;
#define i (*((uint8_t *)&ii))
register uint16_t ii;
mmc3_set_prg_bank_1(GET_BANK(increment_attempt_count));
increment_attempt_count();

coins = 0;
outline_color = 0x30;
cube_data[0] = 0;
cube_data[1] = 0;

memfill(attemptCounter, 0, sizeof(attemptCounter));
for (tmp2 = 0; tmp2 < coins_inserted; tmp2++) {
crossPRGBankJump0(increment_attempt_count);
}

mmc3_set_prg_bank_1(level_data_bank);

// If practice mode has set a scroll position to restart from
Expand Down

0 comments on commit de735e1

Please sign in to comment.