Skip to content
Permalink
Browse files

add palette and SID model options

  • Loading branch information...
rsn8887 committed Feb 27, 2019
1 parent f743ff7 commit 2200dacad4d3f73857e1428e787505f41e6e6a2c
Showing with 94 additions and 5 deletions.
  1. +1 −1 Makefile_C64.psp
  2. +75 −0 arch/psp/c64ui.c
  3. +7 −4 arch/psp/lib/Makefile
  4. +5 −0 arch/psp/ui.h
  5. +6 −0 arch/psp/video.c
@@ -8,7 +8,7 @@ PSP_FW_VERSION=200
export PSP_FW_VERSION

PSP_APP_NAME=VICE PSP C64
PSP_APP_VER=3.2.3
PSP_APP_VER=3.2.4
TARGET=vicepsp
#BUILD_PRX = 1
EXTRA_TARGETS=EBOOT.PBP
@@ -81,6 +81,7 @@
#define OPTION_SHOW_BORDER 0x0B
#define OPTION_REFRESH_RATE 0x0C
#define OPTION_VSYNC 0x0D
#define OPTION_PALETTE 0x0E

#define SYSTEM_SCRNSHOT 0x11
#define SYSTEM_RESET 0x12
@@ -89,6 +90,7 @@
#define SYSTEM_SND_ENGINE 0x15
#define SYSTEM_TRUE_DRIVE 0x16
#define SYSTEM_VIDEO_STD 0x17
#define SYSTEM_SND_CHIP 0x18

#define SYSTEM_CART 0x26
#define SYSTEM_TAPE 0x27
@@ -134,6 +136,14 @@ static const char *TabLabel[] =
"About"
};

/* Palettes */
static const char *PaletteNames[] =
{
"none",
"pepto-pal",
"colodore"
};

/* Menu definitions */
PL_MENU_OPTIONS_BEGIN(ToggleOptions)
PL_MENU_OPTION("Disabled", 0)
@@ -144,6 +154,11 @@ PL_MENU_OPTIONS_BEGIN(ScreenSizeOptions)
PL_MENU_OPTION("4:3 scaled (fit height)", DISPLAY_MODE_FIT_HEIGHT)
PL_MENU_OPTION("16:9 scaled (fit screen)", DISPLAY_MODE_FILL_SCREEN)
PL_MENU_OPTIONS_END
PL_MENU_OPTIONS_BEGIN(PaletteOptions)
PL_MENU_OPTION("None", PALETTE_NONE)
PL_MENU_OPTION("Pepto-PAL", PALETTE_PEPTO_PAL)
PL_MENU_OPTION("Colodore", PALETTE_COLODORE)
PL_MENU_OPTIONS_END
PL_MENU_OPTIONS_BEGIN(PspClockFreqOptions)
PL_MENU_OPTION("222 MHz", 222)
PL_MENU_OPTION("266 MHz", 266)
@@ -168,6 +183,10 @@ PL_MENU_OPTIONS_BEGIN(SoundEngineOptions)
PL_MENU_OPTION("ReSID", SID_ENGINE_RESID)
#endif
PL_MENU_OPTIONS_END
PL_MENU_OPTIONS_BEGIN(SoundChipOptions)
PL_MENU_OPTION("6581", SID_MODEL_6581)
PL_MENU_OPTION("8580", SID_MODEL_8580)
PL_MENU_OPTIONS_END
PL_MENU_OPTIONS_BEGIN(VideoStandardOptions)
PL_MENU_OPTION("PAL-G", MACHINE_SYNC_PAL)
PL_MENU_OPTION("NTSC-M", MACHINE_SYNC_NTSC)
@@ -288,6 +307,8 @@ PL_MENU_ITEMS_BEGIN(SystemMenuDef)
"\026\250\020 Enable/disable sound playback")
PL_MENU_ITEM("SID engine",SYSTEM_SND_ENGINE,SoundEngineOptions,
"\026\250\020 Select sound engine")
PL_MENU_ITEM("SID chip",SYSTEM_SND_CHIP,SoundChipOptions,
"\026\250\020 Select sound chip")
PL_MENU_HEADER("Input")
PL_MENU_ITEM("Joystick port",SYSTEM_JOYPORT,JoyPortOptions,
"\026\250\020 Select joystick port")
@@ -312,6 +333,8 @@ PL_MENU_ITEMS_BEGIN(OptionMenuDef)
"\026\250\020 Change screen size")
PL_MENU_ITEM("Border",OPTION_SHOW_BORDER,ToggleOptions,
"\026\250\020 Show/hide border surrounding the main display area")
PL_MENU_ITEM("Color Palette",OPTION_PALETTE,PaletteOptions,
"\026\250\020 Select color palette")
PL_MENU_HEADER("Input")
PL_MENU_ITEM("Virtual keyboard mode",OPTION_TOGGLE_VK,VkModeOptions,
"\026\250\020 Select virtual keyboard mode")
@@ -727,6 +750,9 @@ static void psp_display_system_tab()
resources_get_int("SidEngine", &setting);
item = pl_menu_find_item_by_id(&SystemUiMenu.Menu, SYSTEM_SND_ENGINE);
pl_menu_select_option_by_value(item, (void*)setting);
resources_get_int("SidModel", &setting);
item = pl_menu_find_item_by_id(&SystemUiMenu.Menu, SYSTEM_SND_CHIP);
pl_menu_select_option_by_value(item, (void*)setting);
resources_get_int("Sound", &setting);
item = pl_menu_find_item_by_id(&SystemUiMenu.Menu, SYSTEM_SOUND);
pl_menu_select_option_by_value(item, (void*)setting);
@@ -930,6 +956,8 @@ static void psp_load_options()
int vice_setting;
vice_setting = pl_ini_get_int(&file, "VICE", "SidEngine", SID_ENGINE_FASTSID);
resources_set_int("SidEngine", vice_setting);
vice_setting = pl_ini_get_int(&file, "VICE", "SidModel", SID_MODEL_6581);
resources_set_int("SidModel", vice_setting);
vice_setting = pl_ini_get_int(&file, "VICE", "DriveTrueEmulation", 1);
resources_set_int("DriveTrueEmulation", vice_setting);
// Device traps needed if DriveTrueEmulation is 0, otherwise we get device not present error
@@ -940,6 +968,13 @@ static void psp_load_options()
resources_set_int("MachineVideoStandard", vice_setting);
vice_setting = pl_ini_get_int(&file, "VICE", "RefreshRate", MACHINE_SYNC_PAL);
resources_set_int("RefreshRate", vice_setting);
vice_setting = pl_ini_get_int(&file, "VICE", "Palette", PALETTE_PEPTO_PAL);
if (vice_setting == 0 || vice_setting < 0 || vice_setting >= NUM_PALETTE_ENTRIES)
resources_set_int("VICIIExternalPalette", 0);
else {
resources_set_int("VICIIExternalPalette", 1);
resources_set_string_sprintf("%sPaletteFile", PaletteNames[vice_setting], "VICII");
}

/* Clean up */
pl_ini_destroy(&file);
@@ -979,6 +1014,8 @@ static int psp_save_options()
int vice_setting;
resources_get_int("SidEngine", &vice_setting);
pl_ini_set_int(&file, "VICE", "SidEngine", vice_setting);
resources_get_int("SidModel", &vice_setting);
pl_ini_set_int(&file, "VICE", "SidModel", vice_setting);
resources_get_int("DriveTrueEmulation", &vice_setting);
pl_ini_set_int(&file, "VICE", "DriveTrueEmulation", vice_setting);
resources_get_int("Sound", &vice_setting);
@@ -988,6 +1025,20 @@ static int psp_save_options()
resources_get_int("RefreshRate", &vice_setting);
pl_ini_set_int(&file, "VICE", "RefreshRate", vice_setting);

resources_get_int("VICIIExternalPalette", &vice_setting);
if (vice_setting == 1) {
vice_setting = 0;
resources_set_int("VICIIExternalPalette", 1);
const char *palette_name;
resources_get_string_sprintf("%sPaletteFile", &palette_name, "VICII");
int i = 0;
for (i = 0; i < NUM_PALETTE_ENTRIES; i++)
if (!strncmp(palette_name, PaletteNames[i], 50))
vice_setting = i;
}
pl_ini_set_int(&file, "VICE", "Palette", vice_setting);


int status = pl_ini_save(&file, path);
pl_ini_destroy(&file);

@@ -1184,6 +1235,19 @@ void psp_display_menu()
if ((item = pl_menu_find_item_by_id(&OptionUiMenu.Menu, OPTION_REFRESH_RATE)))
pl_menu_select_option_by_value(item, (void*)setting);

resources_get_int("VICIIExternalPalette", &setting);
if (setting == 1) {
setting = 0;
const char *palette_name;
resources_get_string_sprintf("%sPaletteFile", &palette_name, "VICII");
int i = 0;
for (i = 0; i < NUM_PALETTE_ENTRIES; i++)
if (!strncmp(palette_name, PaletteNames[i], 50))
setting = i;
}
if ((item = pl_menu_find_item_by_id(&OptionUiMenu.Menu, OPTION_PALETTE)))
pl_menu_select_option_by_value(item, (void*)setting);

pspUiOpenMenu(&OptionUiMenu, NULL);
break;
case TAB_STATE:
@@ -1623,13 +1687,24 @@ static int OnMenuItemChanged(const struct PspUiMenu *uimenu,
case OPTION_REFRESH_RATE:
resources_set_int("RefreshRate", (int)option->value);
break;
case OPTION_PALETTE:
if ((int)option->value == 0) {
resources_set_int("VICIIExternalPalette", 0);
} else {
resources_set_int("VICIIExternalPalette", 1);
resources_set_string_sprintf("%sPaletteFile", PaletteNames[(int)option->value], "VICII");
}
break;
case OPTION_VSYNC:
psp_options.vsync = (int)option->value;
resources_set_int("VBLANKSync", (int)option->value);
break;
case SYSTEM_SND_ENGINE:
resources_set_int("SidEngine", (int)option->value);
break;
case SYSTEM_SND_CHIP:
resources_set_int("SidModel", (int)option->value);
break;
case SYSTEM_SOUND:
resources_set_int("Sound", (int)option->value);
break;
@@ -101,8 +101,11 @@ pl_rewind.o: pl_rewind.c pl_rewind.h
pl_ctl.o: pl_ctl.c pl_ctl.h
$(CC) $(DEFINES) $(CFLAGS) -c -o $@ $<

stockfont.h: stockfont.fd genfont
./genfont < $< > $@
stockfont.h:
cp -f ./stockfont.h_backup ./stockfont.h

genfont: genfont.c
cc $< -o $@
#stockfont.h: stockfont.fd genfont
# ./genfont < $< > $@

#genfont: genfont.c
# cc $< -o $@
@@ -15,6 +15,11 @@
#define DISPLAY_MODE_FIT_HEIGHT 1
#define DISPLAY_MODE_FILL_SCREEN 2

#define PALETTE_NONE 0
#define PALETTE_PEPTO_PAL 1
#define PALETTE_COLODORE 2
#define NUM_PALETTE_ENTRIES 3

#define MAP_BUTTONS 28
#define MAP_SHIFT_START_POS 18 /* Shift buttons start here */

@@ -430,6 +430,12 @@ void psp_refresh_screen()
pspVideoFillRect(0, 0, SCR_WIDTH, line_height, PSP_COLOR_BLACK);
}

// Needed for palette
if (!activeCanvas->videoconfig->color_tables.updated)
{ /* update colors as necessary */
video_color_update_palette(activeCanvas);
}

/* Draw the screen */
pl_gfx_put_image(Screen, screen_x, screen_y, screen_w, screen_h);

0 comments on commit 2200dac

Please sign in to comment.
You can’t perform that action at this time.