Skip to content

Commit

Permalink
loading fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xrip committed Oct 6, 2023
1 parent ae98e74 commit 218ac73
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
8 changes: 5 additions & 3 deletions drivers/vga/vga_vmode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
// ****************************************************************************

#include "include.h"

#ifndef OVERCLOCKING
#define OVERCLOCKING 270
#endif
sVmode Vmode; // videomode setup
sVgaCfg Cfg; // required configuration

Expand Down Expand Up @@ -213,8 +215,8 @@ void VgaCfgDef(sVgaCfg* cfg)
cfg->height = 480; // height in lines
cfg->wfull = 0; // width of full screen, corresponding to 'hfull' time (0=use 'width' parameter)
cfg->video = &VideoVGA; // used video timings
cfg->freq = 396*1000; // required minimal system frequency in kHz (real frequency can be higher)
cfg->fmax = 396*1000; // maximal system frequency in kHz (limit resolution if needed)
cfg->freq = OVERCLOCKING*1000; // required minimal system frequency in kHz (real frequency can be higher)
cfg->fmax = OVERCLOCKING*1000; // maximal system frequency in kHz (limit resolution if needed)
cfg->dbly = False; // double in Y direction
cfg->lockfreq = True; // lock required frequency, do not change it
}
Expand Down
25 changes: 15 additions & 10 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#define USE_PS2_KBD 1
#define USE_NESPAD 1
#define SHOW_FPS 1
#ifndef OVERCLOCKING
#define OVERCLOCKING 270
#endif

/* C Headers */
#include <cstdio>
Expand Down Expand Up @@ -294,11 +297,11 @@ void __time_critical_func(render_loop)() {
for (uint_fast8_t x = 0; x < LCD_WIDTH * 4; x += 4) {

pixel = SCREEN[(y - 8)][x / 4];
// if (gb.cgb.cgbMode) { // CGB
// (uint32_t &) linebuf->line[x] = X4(gb.cgb.fixPalette[pixel]);
// } else {
if (gb.cgb.cgbMode) { // CGB
(uint32_t &) linebuf->line[x] = X4(gb.cgb.fixPalette[pixel]);
} else {
(uint32_t &) linebuf->line[x] = X4(palette[(pixel & LCD_PALETTE_ALL) >> 4][pixel & 3]);
// }
}

}
} else {
Expand Down Expand Up @@ -473,7 +476,7 @@ void fileselector_load(char *pathname) {
* Function used by the rom file selector to display one page of .gb rom files
*/
uint16_t fileselector_display_page(char filenames[28][256], uint16_t page_number) {
#define ROWS TEXTMODE_ROWS-1
#define ROWS (TEXTMODE_ROWS-1)
// Dirty screen cleanup
memset(&textmode, 0x00, sizeof(textmode));
memset(&colors, 0x00, sizeof(colors));
Expand All @@ -492,7 +495,7 @@ uint16_t fileselector_display_page(char filenames[28][256], uint16_t page_number
}

/* clear the filenames array */
for (uint8_t ifile = 0; ifile < (TEXTMODE_ROWS - 1); ifile++) {
for (uint8_t ifile = 0; ifile < ROWS; ifile++) {
strcpy(filenames[ifile], "");
}

Expand Down Expand Up @@ -670,6 +673,11 @@ void menu() {
int current_item = 0;
char item[80];

#if ENABLE_SDCARD
write_cart_ram_file(&gb);
sleep_ms(100);
#endif

while (!exit) {
#if USE_PS2_KBD
ps2kbd.tick();
Expand Down Expand Up @@ -734,9 +742,6 @@ void menu() {
if (!gamepad_bits.start || !gamepad_bits.a || !gamepad_bits.b) {
switch (current_item) {
case MENU_ITEMS_NUMBER - 2:
#if ENABLE_SDCARD
write_cart_ram_file(&gb);
#endif
restart = true;
case MENU_ITEMS_NUMBER - 1:
exit = true;
Expand Down Expand Up @@ -773,7 +778,7 @@ int main() {
hw_set_bits(&vreg_and_chip_reset_hw->vreg, VREG_AND_CHIP_RESET_VREG_VSEL_BITS);
sleep_ms(33);

set_sys_clock_khz(396*1000, true);
set_sys_clock_khz(OVERCLOCKING * 1000, true);

gpio_init(PICO_DEFAULT_LED_PIN);
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
Expand Down

0 comments on commit 218ac73

Please sign in to comment.