Skip to content

Commit

Permalink
chore(*): vblank count passed now in crt0 and 32 bits
Browse files Browse the repository at this point in the history
  • Loading branch information
alekmaul committed Mar 28, 2024
1 parent adc3168 commit 2fe3893
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pvsneslib/include/snes/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) */

Expand Down
8 changes: 1 addition & 7 deletions pvsneslib/source/consoles.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand Down
18 changes: 16 additions & 2 deletions pvsneslib/source/crt0_snes.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2fe3893

Please sign in to comment.