Permalink
Browse files

Firmware: 1chip brightness patching (config+enabling)

  • Loading branch information...
mrehkopf committed Apr 22, 2018
1 parent 41ed0fe commit 58f592f8e039c78b4517c415d1315dde5b2bef8e
Showing with 58 additions and 36 deletions.
  1. +14 −1 src/cfg.c
  2. +38 −34 src/cfg.h
  3. +1 −1 src/fpga_spi.c
  4. +1 −0 src/fpga_spi.h
  5. +4 −0 src/memory.c
View
@@ -27,7 +27,8 @@ cfg_t CFG_DEFAULT = {
.cx4_speed = 0,
.skin_name = "sd2snes.skin",
.control_type = 0,
.msu_volume_boost = 0
.msu_volume_boost = 0,
.patch_1chip_brightness = 0
};
cfg_t CFG;
@@ -52,6 +53,8 @@ int cfg_save() {
f_printf(&file_handle, "%s: %06lX%08lX\n", CFG_BSX_TIME, (uint32_t)(bcdtime>>32), (uint32_t)(bcdtime & 0xffffffffLL));
f_puts("\n# Enable PPU region flag patching\n", &file_handle);
f_printf(&file_handle, "%s: %s\n", CFG_R213F_OVERRIDE, CFG.r213f_override ? "true" : "false");
f_puts("\n# Enable 1CHIP brightness patching (experimental)\n", &file_handle);
f_printf(&file_handle, "%s: %s\n", CFG_1CHIP_BRIGHTNESS_PATCH, CFG.patch_1chip_brightness ? "true" : "false");
f_puts("\n# IRQ hook related settings\n", &file_handle);
f_printf(&file_handle, "# %s: Overall enable IRQ hooks (required for in-game buttons & WRAM cheats)\n", CFG_ENABLE_IRQ_HOOK);
f_printf(&file_handle, "# %s: Enable in-game buttons (en/disable cheats, reset sd2snes...)\n", CFG_ENABLE_IRQ_BUTTONS);
@@ -132,6 +135,9 @@ int cfg_load() {
if(yaml_get_itemvalue(CFG_MSU_VOLUME_BOOST, &tok)) {
CFG.msu_volume_boost = tok.longvalue;
}
if(yaml_get_itemvalue(CFG_1CHIP_BRIGHTNESS_PATCH, &tok)) {
CFG.patch_1chip_brightness = tok.boolvalue ? 1 : 0;
}
}
yaml_file_close();
return err;
@@ -260,6 +266,13 @@ uint8_t cfg_is_r213f_override_enabled() {
return CFG.r213f_override;
}
void cfg_set_patch_1chip_brightness(uint8_t enable) {
CFG.patch_1chip_brightness = enable;
}
uint8_t cfg_is_patch_1chip_brightness() {
return CFG.patch_1chip_brightness;
}
void cfg_set_vidmode_game(cfg_vidmode_t vidmode) {
CFG.vidmode_game = vidmode;
}
View
@@ -7,23 +7,24 @@
#define LAST_FILE ((const uint8_t*)"/sd2snes/lastgame.cfg")
#define LAST_FILE_BAK ((const uint8_t*)"/sd2snes/~lastgame.cfg")
#define CFG_VIDMODE_MENU ("VideoModeMenu")
#define CFG_VIDMODE_GAME ("VideoModeGame")
#define CFG_PAIR_MODE_ALLOWED ("PairModeAllowed")
#define CFG_BSX_USE_USERTIME ("BSXUseUsertime")
#define CFG_BSX_TIME ("BSXTime")
#define CFG_R213F_OVERRIDE ("R213fOverride")
#define CFG_ENABLE_IRQ_HOOK ("EnableIRQHook")
#define CFG_ENABLE_IRQ_BUTTONS ("EnableIRQButtons")
#define CFG_ENABLE_IRQ_HOLDOFF ("EnableIRQHoldoff")
#define CFG_ENABLE_SCREENSAVER ("EnableScreensaver")
#define CFG_SCREENSAVER_TIMEOUT ("ScreensaverTimeout")
#define CFG_SORT_DIRECTORIES ("SortDirectories")
#define CFG_HIDE_EXTENSIONS ("HideExtensions")
#define CFG_CX4_SPEED ("Cx4Speed")
#define CFG_SKIN_NAME ("SkinName")
#define CFG_CONTROL_TYPE ("ControlType")
#define CFG_MSU_VOLUME_BOOST ("MSUVolumeBoost")
#define CFG_VIDMODE_MENU ("VideoModeMenu")
#define CFG_VIDMODE_GAME ("VideoModeGame")
#define CFG_PAIR_MODE_ALLOWED ("PairModeAllowed")
#define CFG_BSX_USE_USERTIME ("BSXUseUsertime")
#define CFG_BSX_TIME ("BSXTime")
#define CFG_R213F_OVERRIDE ("R213fOverride")
#define CFG_ENABLE_IRQ_HOOK ("EnableIRQHook")
#define CFG_ENABLE_IRQ_BUTTONS ("EnableIRQButtons")
#define CFG_ENABLE_IRQ_HOLDOFF ("EnableIRQHoldoff")
#define CFG_ENABLE_SCREENSAVER ("EnableScreensaver")
#define CFG_SCREENSAVER_TIMEOUT ("ScreensaverTimeout")
#define CFG_SORT_DIRECTORIES ("SortDirectories")
#define CFG_HIDE_EXTENSIONS ("HideExtensions")
#define CFG_CX4_SPEED ("Cx4Speed")
#define CFG_SKIN_NAME ("SkinName")
#define CFG_CONTROL_TYPE ("ControlType")
#define CFG_MSU_VOLUME_BOOST ("MSUVolumeBoost")
#define CFG_1CHIP_BRIGHTNESS_PATCH ("1CHIPBrightnessPatch")
typedef enum {
VIDMODE_60 = 0,
@@ -32,23 +33,24 @@ typedef enum {
} cfg_vidmode_t;
typedef struct __attribute__ ((__packed__)) _cfg_block {
uint8_t vidmode_menu; /* menu video mode */
uint8_t vidmode_game; /* game video mode */
uint8_t pair_mode_allowed; /* use pair mode if available */
uint8_t bsx_use_usertime; /* use user defined time for BS */
uint8_t bsx_time[12]; /* user setting for BS time (in S-RTC format)*/
uint8_t r213f_override; /* override register 213f bit 4 */
uint8_t enable_irq_hook; /* enable hook routines */
uint8_t enable_irq_buttons; /* enable in-game buttons in hook routines */
uint8_t enable_irq_holdoff; /* enable temp hook disable after reset */
uint8_t enable_screensaver; /* enable screen saver */
uint16_t screensaver_timeout; /* screensaver activate timeout in frames */
uint8_t sort_directories; /* sort directories (slower) (default: on) */
uint8_t hide_extensions; /* hide file extensions (default: off) */
uint8_t cx4_speed; /* Cx4 speed (0: original, 1: no waitstates */
uint8_t skin_name[128]; /* file name of selected skin */
uint8_t control_type; /* control type (0: A=OK, B=Cancel; 1: A=Cancel, B=OK) */
uint8_t msu_volume_boost; /* volume boost (0: none; 1=+3.5dB; 2=+6dB; 3=+9dB; 4=+12dB) */
uint8_t vidmode_menu; /* menu video mode */
uint8_t vidmode_game; /* game video mode */
uint8_t pair_mode_allowed; /* use pair mode if available */
uint8_t bsx_use_usertime; /* use user defined time for BS */
uint8_t bsx_time[12]; /* user setting for BS time (in S-RTC format)*/
uint8_t r213f_override; /* override register 213f bit 4 */
uint8_t enable_irq_hook; /* enable hook routines */
uint8_t enable_irq_buttons; /* enable in-game buttons in hook routines */
uint8_t enable_irq_holdoff; /* enable temp hook disable after reset */
uint8_t enable_screensaver; /* enable screen saver */
uint16_t screensaver_timeout; /* screensaver activate timeout in frames */
uint8_t sort_directories; /* sort directories (slower) (default: on) */
uint8_t hide_extensions; /* hide file extensions (default: off) */
uint8_t cx4_speed; /* Cx4 speed (0: original, 1: no waitstates */
uint8_t skin_name[128]; /* file name of selected skin */
uint8_t control_type; /* control type (0: A=OK, B=Cancel; 1: A=Cancel, B=OK) */
uint8_t msu_volume_boost; /* volume boost (0: none; 1=+3.5dB; 2=+6dB; 3=+9dB; 4=+12dB) */
uint8_t patch_1chip_brightness; /* override register 2100 bits 3-0 */
} cfg_t;
int cfg_save(void);
@@ -77,4 +79,6 @@ uint8_t cfg_is_pair_mode_allowed(void);
void cfg_set_r213f_override(uint8_t);
uint8_t cfg_is_r213f_override_enabled(void);
void cfg_set_patch_1chip_brightness(uint8_t);
uint8_t cfg_is_patch_1chip_brightness(void);
#endif
View
@@ -128,7 +128,7 @@
bit function
==========================================================================
7 -
6 -
6 enable $2100 DAC fix for 1CHIP
5 enable permanent snescmd unlock (during load handshake)
4 enable $213F override
3 enable MSU1 registers
View
@@ -47,6 +47,7 @@
#define FPGA_TX_BLOCK(x,y) spi_tx_block(x,y)
#define FPGA_RX_BLOCK(x,y) spi_rx_block(x,y)
#define FEAT_2100 (1 << 6)
#define FEAT_CMD_UNLOCK (1 << 5)
#define FEAT_213F (1 << 4)
#define FEAT_MSU1 (1 << 3)
View
@@ -368,6 +368,10 @@ uint32_t load_rom(uint8_t* filename, uint32_t base_addr, uint8_t flags) {
}
}
if(cfg_is_patch_1chip_brightness() && (filename != (uint8_t*)"/sd2snes/menu.bin")) {
romprops.fpga_features |= FEAT_2100;
}
if(flags & LOADROM_WAIT_SNES) {
while(snes_get_mcu_cmd() != SNES_CMD_RESET) cli_entrycheck();
}

0 comments on commit 58f592f

Please sign in to comment.