From 2fe38931864f7358b31ffc5294b8482e0ec6f5ee Mon Sep 17 00:00:00 2001 From: Alekmaul Date: Thu, 28 Mar 2024 05:42:48 +0100 Subject: [PATCH] chore(*): vblank count passed now in crt0 and 32 bits --- pvsneslib/include/snes/console.h | 2 +- pvsneslib/source/consoles.asm | 8 +------- pvsneslib/source/crt0_snes.asm | 18 ++++++++++++++++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/pvsneslib/include/snes/console.h b/pvsneslib/include/snes/console.h index ad157229..03bac2ed 100644 --- a/pvsneslib/include/snes/console.h +++ b/pvsneslib/include/snes/console.h @@ -45,7 +45,7 @@ extern u8 scr_txt_font_map[0x800]; /*!< \brief tilemap used for text display */ extern u8 scr_txt_dirty; /*!< \brief flag to redraw text during vblank */ -extern u16 snes_vblank_count; /*!< \brief Number of VBL since consoleInit called */ +extern u32 snes_vblank_count; /*!< \brief Number of VBL since consoleInit called */ extern u8 snes_50hz; /*!< \brief 1 if on a PAL/50Hz SNES */ extern u8 snes_fps; /*!< \brief 50 if PAL console (50 Hz) or 60 if NTSC console (60Hz) */ diff --git a/pvsneslib/source/consoles.asm b/pvsneslib/source/consoles.asm index 294493f9..b8139762 100644 --- a/pvsneslib/source/consoles.asm +++ b/pvsneslib/source/consoles.asm @@ -41,8 +41,6 @@ .BASE $00 .RAMSECTION ".reg_cons7e" BANK $7E SLOT RAMSLOT_0 -snes_vblank_count DW ; to count number of vblank - snes_50hz DB ; 1 if PAL console (50 Hz) instead of NTSC (60Hz) snes_fps DB ; 50 if PAL console (50 Hz) or 60 if NTSC console (60Hz) @@ -418,11 +416,7 @@ cvbloam: stz scr_txt_dirty ; no more transfer of text - ; Count frame number -+ rep #$20 - inc.w snes_vblank_count - - plb ++: plb plp rtl diff --git a/pvsneslib/source/crt0_snes.asm b/pvsneslib/source/crt0_snes.asm index 91e8013a..48b7e3c6 100644 --- a/pvsneslib/source/crt0_snes.asm +++ b/pvsneslib/source/crt0_snes.asm @@ -26,9 +26,12 @@ tcc__f3h dsb 2 move_insn dsb 4 ; 3 bytes mvn + 1 byte rts move_backwards_insn dsb 4 ; 3 bytes mvp + 1 byte rts nmi_handler dsb 4 - + tcc__registers_irq dsb 0 tcc__regs_irq dsb 48 + +snes_vblank_count dsb 4 ; 4 bytes to count number of vblank + .ENDS ; sections "globram.data" and "glob.data" can stay here in the file @@ -231,7 +234,15 @@ FVBlank: pea $7e7e plb plb - lda.w #tcc__registers_irq + rep #$20 + + ; Count frame number + lda.w #$1 + inc.w snes_vblank_count + bne + + inc.w snes_vblank_count+2 + ++: lda.w #tcc__registers_irq tad lda.l nmi_handler sta.b tcc__r10 @@ -327,6 +338,9 @@ fast_start: stz.b tcc__r0 stz.b tcc__r1 + stz.w snes_vblank_count + stz.w snes_vblank_count+2 + jsr.l main ; write exit code to $fffd