Skip to content

Commit 3edf4bc

Browse files
mpharoahgheskett
authored andcommitted
Add support for realtime clock (#889)
1 parent 48ecd1d commit 3edf4bc

File tree

6 files changed

+985
-7
lines changed

6 files changed

+985
-7
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ ACTOR_DIR := actors
384384
LEVEL_DIRS := $(patsubst levels/%,%,$(dir $(wildcard levels/*/header.h)))
385385

386386
# Directories containing source files
387-
SRC_DIRS += src src/boot src/game src/engine src/audio src/menu src/buffers actors levels bin data assets asm lib sound
387+
SRC_DIRS += src src/boot src/game src/engine src/audio src/menu src/buffers lib/librtc actors levels bin data assets asm lib sound
388388
LIBZ_SRC_DIRS := src/libz
389389
GODDARD_SRC_DIRS := src/goddard src/goddard/dynlists
390390
BIN_DIRS := bin bin/$(VERSION)

asm/rom_header.s

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
.word 0x00000000 /* Unknown */
2323
#endif
2424
.word 0x0000004E /* Cartridge */
25-
#if defined(EEP4K) && !defined(EMU_DEFAULT_TO_GCN)
25+
#if defined(EEP4K) && !defined(EMU_DEFAULT_TO_GCN) && !defined(USE_RTC)
2626
.ascii "SM" /* Cartridge ID */
2727
#else
2828
.ascii "ED" /* Cartridge ID */
@@ -35,14 +35,21 @@
3535
.ascii "E" /* NTSC-U (North America) */
3636
#endif
3737

38+
#if defined(USE_RTC)
39+
#define RTC_BIT 0x1
40+
#else
41+
#define RTC_BIT 0x0
42+
#endif
43+
44+
/* Savetype, region, and RTC */
3845
#if defined(SRAM)
39-
.byte 0x32 /* Version */
46+
.byte 0x32 | RTC_BIT
4047
#elif defined(EEP16K)
41-
.byte 0x22 /* Version */
48+
.byte 0x22 | RTC_BIT
4249
#elif defined(SRAM768K)
43-
.byte 0x42 /* Version */
50+
.byte 0x42 | RTC_BIT
4451
#elif defined(FLASHRAM)
45-
.byte 0x52 /* Version */
52+
.byte 0x52 | RTC_BIT
4653
#else
47-
.byte 0x12 /* Version */
54+
.byte 0x12 | RTC_BIT
4855
#endif

include/config/config_rom.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
*/
1111
#define INTERNAL_ROM_NAME "HackerSM64 "
1212

13+
/**
14+
* Enable the realtime clock (RTC)
15+
* See lib/librtc/librtc.h for RTC related functions
16+
*/
17+
// #define USE_RTC
18+
1319
/**
1420
* Force the game to delete any existing save data originating from a different hack. This requires INTERNAL_ROM_NAME to be unique to work properly.
1521
* It is recommended to enable this if any significant changes to the save file are made that could cause issues with this or other hacks.

0 commit comments

Comments
 (0)