Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}/boards )
#set(PICO_PLATFORM "rp2040" CACHE STRING "Chip type")
set(PICO_PLATFORM "rp2350" CACHE STRING "Chip type")

#set(PICO_BOARD "murmulator" CACHE STRING "Board type")
set(PICO_BOARD "murmulator" CACHE STRING "Board type")
#set(PICO_BOARD "murmulator2" CACHE STRING "Board type")
#set(PICO_BOARD "olimex-pico-pc" CACHE STRING "Board type")
#set(PICO_BOARD "waveshare_rp2040_pizero" CACHE STRING "Board type")
set(PICO_BOARD "waveshare_rp2350_pizero" CACHE STRING "Board type")
#set(PICO_BOARD "waveshare_rp2350_pizero" CACHE STRING "Board type")
Comment on lines +22 to +26

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These changes to PICO_BOARD and the HDMI option (on line 51) appear to be local development configurations. They switch the default target board to murmulator and disable HDMI output.

Are these changes intended to be part of this pull request? If not, they should be reverted to avoid altering the default build configuration for other developers.


include(pico_sdk_import.cmake)

Expand All @@ -48,7 +48,7 @@ set(I2S ON)

#set(TFT ON)
#set(ILI9341 ON)
set(HDMI ON)
#set(HDMI ON)
#set(TV ON)
#set(SOFTTV ON)

Expand Down
30 changes: 13 additions & 17 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ SETTINGS settings = {
.version = 1,
.swap_ab = false,
.aspect_ratio = false,
.ghosting = 8,
.ghosting = 4,
.palette = SV_COLOR_SCHEME_WATAROO,
.save_slot = 0,
.rgb0 = 0xCCFFFF,
Expand Down Expand Up @@ -187,8 +187,6 @@ Ps2Kbd_Mrmltr ps2kbd(
process_kbd_report
);



static const uint8 palettes[SV_COLOR_SCHEME_COUNT][12] = {
{ /* SV_COLOR_SCHEME_DEFAULT */
252, 252, 252,
Expand Down Expand Up @@ -813,7 +811,6 @@ void load_config() {
FIL file;
char pathname[256];
sprintf(pathname, "%s\\emulator.cfg", HOME_DIR);

if (FR_OK == f_mount(&fs, "", 1) && FR_OK == f_open(&file, pathname, FA_READ)) {
UINT bytes_read;
f_read(&file, &settings, sizeof(settings), &bytes_read);
Expand All @@ -823,6 +820,7 @@ void load_config() {
rgb1 = settings.rgb1;
rgb2 = settings.rgb2;
rgb3 = settings.rgb3;
if (settings.ghosting > 6) settings.ghosting = 4;
}

void save_config() {
Expand Down Expand Up @@ -864,7 +862,7 @@ bool toggle_color() {
const MenuItem menu_items[] = {
{"Swap AB <> BA: %s", ARRAY, &settings.swap_ab, nullptr, 1, {"NO ", "YES"}},
{},
{ "Ghosting pix: %i ", INT, &settings.ghosting, nullptr, 8 },
{ "Ghosting pix: %i ", INT, &settings.ghosting, nullptr, 6 },
{ "Palette: %s ", ARRAY, &settings.palette, nullptr, SV_COLOR_SCHEME_COUNT, {
"DEFAULT "
, "AMBER "
Expand Down Expand Up @@ -968,16 +966,19 @@ void menu() {
uint32_t vc = *value;
vc &= ~(0xF << (5 - hex_digit) * 4);
vc |= ((uint32_t)h_code << (5 - hex_digit) * 4);
if (vc < item->max_value) *value = vc;
if (++hex_digit == 6) {
hex_digit = 0;
h_code = -1;
hex_digit = -1;
keyboard.h_code = -1;
current_item++;
}
if (vc < item->max_value) *value = vc;
settings.rgb0 = rgb0;
settings.rgb1 = rgb1;
settings.rgb2 = rgb2;
settings.rgb3 = rgb3;
update_palette();
sleep_ms(125);
break;
}
if (gamepad1.bits.right && hex_digit == 5) {
Expand Down Expand Up @@ -1064,26 +1065,23 @@ void menu() {
draw_text(result, x, y, color, bg_color);
}

if (gamepad1.bits.b)
if (gamepad1.bits.b || (gamepad1.bits.select && !gamepad1.bits.start))
exit = true;

if (gamepad1.bits.down) {
if (gamepad1.bits.down && hex_digit < 0) {
current_item = (current_item + 1) % MENU_ITEMS_NUMBER;

if (menu_items[current_item].type == NONE)
current_item++;
}
if (gamepad1.bits.up) {
if (gamepad1.bits.up && hex_digit < 0) {
current_item = (current_item - 1 + MENU_ITEMS_NUMBER) % MENU_ITEMS_NUMBER;

if (menu_items[current_item].type == NONE)
current_item--;
}

sleep_ms(125);
}

update_palette();
#if VGA
if (settings.aspect_ratio) {
graphics_set_offset(40, 20);
Expand All @@ -1101,7 +1099,6 @@ void menu() {
graphics_set_mode(GRAPHICSMODE_DEFAULT);
memcpy(SCREEN, (void *)bezel, sizeof(bezel));
#endif
supervision_set_ghosting(settings.ghosting);
if (count_of(palettes) <= settings.palette) {
settings.rgb0 = rgb0;
settings.rgb1 = rgb1;
Expand Down Expand Up @@ -1212,7 +1209,6 @@ int __time_critical_func(main)() {

if (supervision_load((uint8_t *)rom, rom_size) ) {
update_palette();
supervision_set_ghosting(settings.ghosting);
}

#if VGA
Expand Down Expand Up @@ -1249,9 +1245,9 @@ int __time_critical_func(main)() {
}
#if VGA
if (settings.aspect_ratio) {
supervision_exec_ex((uint8_t *) SCREEN + 240 * 20 + 40, 240, 0);
supervision_exec_ex((uint8_t *) SCREEN + 240 * 20 + 40, 240, 0, settings.ghosting);
} else {
supervision_exec_ex((uint8_t *) SCREEN, SV_W, 0);
supervision_exec_ex((uint8_t *) SCREEN, SV_W, 0, settings.ghosting);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The function signature for supervision_exec_ex has been updated to include a ghosting parameter, but not all call sites have been updated. The call within the #else block for non-VGA builds is still using the old signature, which will cause a compilation error.

// Around line 1253 in the new file
#else
    supervision_exec_ex((uint8_t *) SCREEN + 240 * 20 + 40, 240, 0);
#endif

Please update all calls to supervision_exec_ex to match the new four-argument signature.

}
#else
supervision_exec_ex((uint8_t *) SCREEN + 240 * 20 + 40, 240, 0);
Expand Down
111 changes: 0 additions & 111 deletions src/potator/gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ static SV_MapRGBFunc mapRGB = rgb555;

//uint32 watara_palette[4];

int ghostCount = 8;

/*
static uint8 screenBuffer8[SV_H][SV_W] = { 0 };

Expand All @@ -51,123 +49,14 @@ void gpu_init(void) {

void gpu_reset(void) {
gpu_set_map_func(NULL);
// gpu_set_ghosting(0);
}

void gpu_done(void) {
// free(watara_palette); watara_palette = NULL;
// gpu_set_ghosting(0);
}

void gpu_set_map_func(SV_MapRGBFunc func) {
// mapRGB = func;
// if (mapRGB == NULL)
// mapRGB = rgb555;
}

/*

void __time_critical_func(gpu_render_scanline2)(uint32 scanline, uint8 *backbuffer, uint8 innerx, uint8 size) {
uint8 *vram_line = memorymap_getUpperRamPointer() + scanline;
uint8 x, j = innerx, b = 0;

// #1
if (j & 3) {
b = *vram_line++;
b >>= (j & 3) * 2;
}
//#pragma GCC unroll 320
if (ghostCount) {
for (x = 0; x < size; x++, j++) {
if (!(j & 3)) {
b = *(vram_line++);
}
//int color = (b & 3); // curr. state in 2 bits format
{
int c8 = backbuffer[x] - 4; // prev. state in 8 bit format (reduced to 1/gh)
int c8n = (b & 3) << 4; // new state in 8 bit format
if (c8n < c8) c8n = c8;
backbuffer[x] = c8n;

// save it to next step
b >>= 2;
}
}
} else {
for (x = 0; x < size; x++, j++) {
if (!(j & 3)) {
b = *(vram_line++);
}
backbuffer[x] = (b & 3) << 4;
// save it to next step
b >>= 2;
}
}

}

*/
void __time_critical_func(gpu_render_scanline)(uint32 scanline, uint8 *backbuffer, uint8 innerx, uint8 size) {
uint8 *vram_line = memorymap_getUpperRamPointer() + scanline;
uint8 x = 0, j = innerx & 3;
static int previous_color, current_color = 0;

uint8 b = *vram_line++;

if (j) {
b >>= j * 2;
}

if (ghostCount) {
#pragma GCC unroll 4
while (x < size) {
backbuffer[x++] = (b & 3) << 4;
b >>= 2;
backbuffer[x++] = (b & 3) << 4;
b >>= 2;
backbuffer[x++] = (b & 3) << 4;
b >>= 2;
backbuffer[x++] = (b & 3) << 4;

b = *vram_line++;
}
} else {
#pragma GCC unroll 4
while (x < size) {
previous_color = backbuffer[x] - 4; // prev. state in 8 bit format (reduced to 1/gh)
current_color = (b & 3) << 4; // new state in 8 bit format
if (current_color < previous_color) current_color = previous_color;
backbuffer[x++] = current_color;
b >>= 2;

previous_color = backbuffer[x] - 4; // prev. state in 8 bit format (reduced to 1/gh)
current_color = (b & 3) << 4; // new state in 8 bit format
if (current_color < previous_color) current_color = previous_color;
backbuffer[x++] = current_color;
b >>= 2;

previous_color = backbuffer[x] - 4; // prev. state in 8 bit format (reduced to 1/gh)
current_color = (b & 3) << 4; // new state in 8 bit format
if (current_color < previous_color) current_color = previous_color;
backbuffer[x++] = current_color;
b >>= 2;

previous_color = backbuffer[x] - 4; // prev. state in 8 bit format (reduced to 1/gh)
current_color = (b & 3) << 4; // new state in 8 bit format
if (current_color < previous_color) current_color = previous_color;
backbuffer[x++] = current_color;

b = *vram_line++;
}
}
}

void gpu_set_ghosting(int frameCount) {
int i;
if (frameCount < 0)
ghostCount = 0;
else if (frameCount > SV_GHOSTING_MAX)
ghostCount = SV_GHOSTING_MAX;
else
ghostCount = frameCount;
}
2 changes: 0 additions & 2 deletions src/potator/gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@ void gpu_init(void);
void gpu_reset(void);
void gpu_done(void);
void gpu_set_map_func(SV_MapRGBFunc func);
void gpu_render_scanline(uint32 scanline, uint8 *backbuffer, uint8 innerx, uint8 size);
void gpu_set_ghosting(int frameCount);

#endif
11 changes: 1 addition & 10 deletions src/potator/supervision.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ enum SV_COLOR {
, SV_COLOR_SCHEME_COUNT
};

/*!
* \sa supervision_set_ghosting()
*/
#define SV_GHOSTING_MAX 8
/*!
* \sa supervision_update_sound()
*/
Expand All @@ -77,7 +73,7 @@ void supervision_done(void);
* \return TRUE - success, FALSE - error
*/
BOOL supervision_load(const uint8 *rom, uint32 romSize);
void supervision_exec_ex(uint8 *backbuffer, int16 backbufferWidth, BOOL skipFrame);
void supervision_exec_ex(uint8 *backbuffer, int16 backbufferWidth, BOOL skipFrame, uint8_t ghosting);

/*!
* \param data Bits 0-7: Right, Left, Down, Up, B, A, Select, Start.
Expand All @@ -87,11 +83,6 @@ void supervision_set_input(uint8 data);
* \param func Default: RGB888 -> RGB555 (RGBA5551), R - least significant.
*/
void supervision_set_map_func(SV_MapRGBFunc func);
/*!
* Add ghosting (blur). It reduces flickering.
* \param frameCount in range [0, SV_GHOSTING_MAX]. 0 - disable.
*/
void supervision_set_ghosting(int frameCount);

uint32 supervision_save_state_buf_size(void);
BOOL supervision_save_state_buf(uint8 *data, uint32 size);
Expand Down
Loading