@@ -60,6 +60,8 @@ void fast_mem_clr_256(void *addr, uint32_t value, unsigned count);
6060void set_entrypoint_hook (bool process_cheats );
6161uint32_t * get_cheat_table ();
6262
63+ #define MAX_SPEED_OPTS 6 // Sync with common.h
64+
6365#define MAX_DISK_SLOTS 5
6466#define MAX_MEM_SLOTS 32
6567
@@ -85,6 +87,7 @@ uint32_t *get_cheat_table();
8587static unsigned submenu ;
8688static unsigned copt ;
8789static t_dec_date rtc_date ;
90+ static unsigned rtc_speed ;
8891static struct {
8992 const char * msg ;
9093 void (* callback )();
@@ -630,24 +633,33 @@ void draw_rtc_menu(uint8_t *fb, unsigned framen) {
630633 char tmont [3 ] = {'0' + rtc_date .month /10 , '0' + rtc_date .month %10 , 0 };
631634 char tyear [5 ] = {'2' , '0' , '0' + rtc_date .year /10 , '0' + rtc_date .year %10 , 0 };
632635
633- draw_text (tyear , fb , 54 , 70 , copt == 0 ? HI_COLOR : FG_COLOR );
634- draw_text ("-" , fb , 86 , 70 , FG_COLOR );
635- draw_text (tmont , fb , 95 , 70 , copt == 1 ? HI_COLOR : FG_COLOR );
636- draw_text ("-" , fb , 111 , 70 , FG_COLOR );
637- draw_text (tdays , fb , 120 , 70 , copt == 2 ? HI_COLOR : FG_COLOR );
638- draw_text (thour , fb , 148 , 70 , copt == 3 ? HI_COLOR : FG_COLOR );
639- draw_text (":" , fb , 165 , 70 , FG_COLOR );
640- draw_text (tmins , fb , 170 , 70 , copt == 4 ? HI_COLOR : FG_COLOR );
636+ draw_text (tyear , fb , 54 , 56 , copt == 0 ? HI_COLOR : FG_COLOR );
637+ draw_text ("-" , fb , 86 , 56 , FG_COLOR );
638+ draw_text (tmont , fb , 95 , 56 , copt == 1 ? HI_COLOR : FG_COLOR );
639+ draw_text ("-" , fb , 111 , 56 , FG_COLOR );
640+ draw_text (tdays , fb , 120 , 56 , copt == 2 ? HI_COLOR : FG_COLOR );
641+ draw_text (thour , fb , 148 , 56 , copt == 3 ? HI_COLOR : FG_COLOR );
642+ draw_text (":" , fb , 165 , 56 , FG_COLOR );
643+ draw_text (tmins , fb , 170 , 56 , copt == 4 ? HI_COLOR : FG_COLOR );
641644
642645 if (copt < 5 ) {
643646 const uint8_t cox [] = {
644647 68 , 103 , 127 , 156 , 178
645648 };
646- draw_text_center ("⯅" , fb , cox [copt ], 54 , HI_COLOR );
647- draw_text_center ("⯆" , fb , cox [copt ], 84 , HI_COLOR );
649+ draw_text_center ("⯅" , fb , cox [copt ], 40 , HI_COLOR );
650+ draw_text_center ("⯆" , fb , cox [copt ], 70 , HI_COLOR );
651+ } else if (copt == 5 ) {
652+ draw_text_center ("⯅" , fb , SCREEN_WIDTH /2 , 77 , HI_COLOR );
653+ draw_text_center ("⯆" , fb , SCREEN_WIDTH /2 , 107 , HI_COLOR );
648654 }
649655
650- draw_text_center (msgs [ingame_menu_lang ][IMENU_UPDAT_RTC ], fb , SCREEN_WIDTH /2 , 120 , copt == 5 ? HI_COLOR : FG_COLOR );
656+ char tmp [64 ];
657+ npf_snprintf (tmp , sizeof (tmp ), "%s: %s" ,
658+ msgs [ingame_menu_lang ][IMENU_RTCSPD ],
659+ msgs [ingame_menu_lang ][rtc_speed ? (IMENU_SPD0 + rtc_speed - 1 ) : IMENU_FRZRTC ]);
660+ draw_text_center (tmp , fb , SCREEN_WIDTH /2 , 92 , copt == 5 ? HI_COLOR : FG_COLOR );
661+
662+ draw_text_center (msgs [ingame_menu_lang ][IMENU_UPDAT_RTC ], fb , SCREEN_WIDTH /2 , 130 , copt == 6 ? HI_COLOR : FG_COLOR );
651663}
652664
653665void draw_cheats_menu (uint8_t * fb , unsigned framen ) {
@@ -1031,13 +1043,19 @@ void rtckey(uint16_t keyp) {
10311043 rval [copt ]-- ;
10321044
10331045 fixdate (& rtc_date );
1046+ } else if (copt == 5 ) {
1047+ if (keyp & KEY_BUTTUP )
1048+ rtc_speed ++ ;
1049+ if (keyp & KEY_BUTTDOWN )
1050+ rtc_speed -- ;
1051+
1052+ rtc_speed = rtc_speed % MAX_SPEED_OPTS ;
10341053 }
10351054}
10361055
10371056bool action_write_rtc () {
10381057 // Write to the emulated RTC register
1039- // TODO: Allow changing the RTC speed.
1040- set_undef_lrsp (date2timestamp (& rtc_date ), get_undef_sp ());
1058+ set_undef_lrsp (date2timestamp (& rtc_date ), rtc_speed );
10411059
10421060 submenu = MenuMain ;
10431061 copt = 0 ;
@@ -1078,6 +1096,7 @@ const menu_action_fn rtcacts[] = {
10781096 NULL ,
10791097 NULL ,
10801098 NULL ,
1099+ NULL ,
10811100 action_write_rtc , // Apply RTC time.
10821101};
10831102
@@ -1103,7 +1122,7 @@ const t_menu_def menudata [] = {
11031122 { draw_reset_menu , resetacts , NULL , 4 , NULL , true },
11041123 { draw_save_menu , saveacts , NULL , 4 , NULL , true },
11051124 { draw_states_menu , statesacts , sstkey , 3 , NULL , true },
1106- { draw_rtc_menu , rtcacts , rtckey , 6 , NULL , false },
1125+ { draw_rtc_menu , rtcacts , rtckey , 7 , NULL , false },
11071126 { draw_cheats_menu , cheatsacts , NULL , 0 , cheats_cnt , true },
11081127};
11091128
@@ -1191,8 +1210,9 @@ void ingame_menu_loop(uint32_t *use_cheats_hook) {
11911210 num_mem_savestates = MIN (MAX_MEM_SLOTS , (scratch_size >> 10 ) / SAVESTATE_SIZE_KB );
11921211 num_dsk_savestates = savestate_pattern [0 ] ? MAX_DISK_SLOTS : 0 ;
11931212
1194- // Read RTC values
1213+ // Read RTC values and speed
11951214 timestamp2date (get_undef_lr (), & rtc_date );
1215+ rtc_speed = get_undef_sp ();
11961216
11971217 // Lazy intialization of the SD card, to avoid blocking the menu
11981218 FATFS fs ;
0 commit comments