2020#define USE_PS2_KBD 1
2121#define USE_NESPAD 1
2222#define SHOW_FPS 1
23+ #ifndef OVERCLOCKING
24+ #define OVERCLOCKING 270
25+ #endif
2326
2427/* C Headers */
2528#include < cstdio>
@@ -294,11 +297,11 @@ void __time_critical_func(render_loop)() {
294297 for (uint_fast8_t x = 0 ; x < LCD_WIDTH * 4 ; x += 4 ) {
295298
296299 pixel = SCREEN[(y - 8 )][x / 4 ];
297- // if (gb.cgb.cgbMode) { // CGB
298- // (uint32_t &) linebuf->line[x] = X4(gb.cgb.fixPalette[pixel]);
299- // } else {
300+ if (gb.cgb .cgbMode ) { // CGB
301+ (uint32_t &) linebuf->line [x] = X4 (gb.cgb .fixPalette [pixel]);
302+ } else {
300303 (uint32_t &) linebuf->line [x] = X4 (palette[(pixel & LCD_PALETTE_ALL) >> 4 ][pixel & 3 ]);
301- // }
304+ }
302305
303306 }
304307 } else {
@@ -473,7 +476,7 @@ void fileselector_load(char *pathname) {
473476 * Function used by the rom file selector to display one page of .gb rom files
474477 */
475478uint16_t fileselector_display_page (char filenames[28 ][256 ], uint16_t page_number) {
476- #define ROWS TEXTMODE_ROWS-1
479+ #define ROWS ( TEXTMODE_ROWS-1 )
477480 // Dirty screen cleanup
478481 memset (&textmode, 0x00 , sizeof (textmode));
479482 memset (&colors, 0x00 , sizeof (colors));
@@ -492,7 +495,7 @@ uint16_t fileselector_display_page(char filenames[28][256], uint16_t page_number
492495 }
493496
494497 /* clear the filenames array */
495- for (uint8_t ifile = 0 ; ifile < (TEXTMODE_ROWS - 1 ) ; ifile++) {
498+ for (uint8_t ifile = 0 ; ifile < ROWS ; ifile++) {
496499 strcpy (filenames[ifile], " " );
497500 }
498501
@@ -670,6 +673,11 @@ void menu() {
670673 int current_item = 0 ;
671674 char item[80 ];
672675
676+ #if ENABLE_SDCARD
677+ write_cart_ram_file (&gb);
678+ sleep_ms (100 );
679+ #endif
680+
673681 while (!exit) {
674682#if USE_PS2_KBD
675683 ps2kbd.tick ();
@@ -734,9 +742,6 @@ void menu() {
734742 if (!gamepad_bits.start || !gamepad_bits.a || !gamepad_bits.b ) {
735743 switch (current_item) {
736744 case MENU_ITEMS_NUMBER - 2 :
737- #if ENABLE_SDCARD
738- write_cart_ram_file (&gb);
739- #endif
740745 restart = true ;
741746 case MENU_ITEMS_NUMBER - 1 :
742747 exit = true ;
@@ -773,7 +778,7 @@ int main() {
773778 hw_set_bits (&vreg_and_chip_reset_hw->vreg , VREG_AND_CHIP_RESET_VREG_VSEL_BITS);
774779 sleep_ms (33 );
775780
776- set_sys_clock_khz (396 * 1000 , true );
781+ set_sys_clock_khz (OVERCLOCKING * 1000 , true );
777782
778783 gpio_init (PICO_DEFAULT_LED_PIN);
779784 gpio_set_dir (PICO_DEFAULT_LED_PIN, GPIO_OUT);
0 commit comments