Skip to content

Commit 218ac73

Browse files
committed
loading fix
1 parent ae98e74 commit 218ac73

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

drivers/vga/vga_vmode.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
// ****************************************************************************
1010

1111
#include "include.h"
12-
12+
#ifndef OVERCLOCKING
13+
#define OVERCLOCKING 270
14+
#endif
1315
sVmode Vmode; // videomode setup
1416
sVgaCfg Cfg; // required configuration
1517

@@ -213,8 +215,8 @@ void VgaCfgDef(sVgaCfg* cfg)
213215
cfg->height = 480; // height in lines
214216
cfg->wfull = 0; // width of full screen, corresponding to 'hfull' time (0=use 'width' parameter)
215217
cfg->video = &VideoVGA; // used video timings
216-
cfg->freq = 396*1000; // required minimal system frequency in kHz (real frequency can be higher)
217-
cfg->fmax = 396*1000; // maximal system frequency in kHz (limit resolution if needed)
218+
cfg->freq = OVERCLOCKING*1000; // required minimal system frequency in kHz (real frequency can be higher)
219+
cfg->fmax = OVERCLOCKING*1000; // maximal system frequency in kHz (limit resolution if needed)
218220
cfg->dbly = False; // double in Y direction
219221
cfg->lockfreq = True; // lock required frequency, do not change it
220222
}

src/main.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
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
*/
475478
uint16_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

Comments
 (0)