Permalink
Browse files

Feature: global initial cheat enable/disable

  • Loading branch information...
mrehkopf committed Sep 3, 2018
1 parent da99d6f commit e894661926b3776ee59410c191561a2111c37c2b
Showing with 26 additions and 1 deletion.
  1. +2 −0 snes/const.a65
  2. +1 −0 snes/memmap.i65
  3. +15 −0 snes/menudata.a65
  4. +5 −0 src/cfg.c
  5. +2 −0 src/cfg.h
  6. +1 −1 src/cheat.c
View
@@ -206,6 +206,7 @@ mtext_browser_hide_ext .byt "Hide file extensions", 0
mtext_browser_screensaver .byt "Screensaver", 0
mtext_browser_screensaver_timeout .byt "Fade screen after", 0
mtext_browser_ledbright .byt "LED brightness", 0
mtext_ingame_cheats .byt "Start with cheats enabled", 0
mtext_ingame_shortreset .byt "Reset to menu", 0
mtext_ingame_enable .byt "In-game hook", 0
mtext_ingame_buttons .byt " ",129,"In-game buttons", 0
@@ -236,6 +237,7 @@ mdesc_browser_hide_ext .byt "Choose whether to hide file extensions",
mdesc_browser_screensaver .byt "Fade-out the screen after some time", 0
mdesc_browser_screensaver_timeout .byt "Set time after which to fade the screen", 0
mdesc_browser_ledbright .byt "Change brightness of LEDs", 0
mdesc_ingame_cheats .byt "Whether to start out with cheats enabled. Can be changed using in-game buttons", 0
mdesc_ingame_shortreset .byt "Go back to menu on short reset if enabled", 0
mdesc_ingame_enable .byt "Required for in-game buttons and 7E/7F cheats", 0
mdesc_ingame_buttons .byt "Enable in-game buttons (reset, en/disable cheats", 127, 128, "). Requires in-game hook to be enabled.", 0
View
@@ -103,6 +103,7 @@
#define CFG_GSU_SPEED CFG_ADDR+$009E
#define CFG_ENABLE_RST_TO_MENU CFG_ADDR+$009F
#define CFG_LED_BRIGHTNESS CFG_ADDR+$00A0
#define CFG_ENABLE_CHEATS CFG_ADDR+$00A1
#define MENU_ENTRY_SIZE 23
View
@@ -360,6 +360,21 @@ menu_enttab_ingame:
.word !mtext_cfg_ingame
.byt ^mtext_cfg_ingame
; ENTRIES
.byt MTYPE_VALUE
.word !mtext_ingame_cheats
.byt ^mtext_ingame_cheats
.word !kv_yesno
.byt ^kv_yesno
.byt OPTTYPE_KVBYTE
.word !CFG_ENABLE_CHEATS
.byt ^CFG_ENABLE_CHEATS
.word !mdesc_ingame_cheats
.byt ^mdesc_ingame_cheats
.byt 0,0,0
.byt 0,0,0
.byt 0,0,0
.byt MTYPE_VALUE
.word !mtext_ingame_shortreset
.byt ^mtext_ingame_shortreset
View
@@ -63,6 +63,8 @@ int cfg_save() {
f_printf(&file_handle, "%s: %d\n", CFG_BRIGHTNESS_LIMIT, CFG.brightness_limit);
f_puts("\n# Reset to menu on short reset\n", &file_handle);
f_printf(&file_handle, "%s: %s\n", CFG_ENABLE_RST_TO_MENU, CFG.reset_to_menu ? "true" : "false");
f_puts("\n# Initial cheats state when loading a game (true: enabled, false: disabled)\n", &file_handle);
f_printf(&file_handle, "%s: %s\n", CFG_ENABLE_CHEATS, CFG.enable_cheats ? "true" : "false");
f_puts("\n\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_INGAME_HOOK);
f_printf(&file_handle, "# %s: Enable in-game buttons (en/disable cheats, reset sd2snes...)\n", CFG_ENABLE_INGAME_BUTTONS);
@@ -165,6 +167,9 @@ int cfg_load() {
CFG.led_brightness = 15;
}
}
if(yaml_get_itemvalue(CFG_ENABLE_CHEATS, &tok)) {
CFG.enable_cheats = tok.boolvalue ? 1 : 0;
}
}
yaml_file_close();
return err;
View
@@ -29,6 +29,7 @@
#define CFG_BRIGHTNESS_LIMIT ("BrightnessLimit")
#define CFG_ENABLE_RST_TO_MENU ("ShortReset2Menu")
#define CFG_LED_BRIGHTNESS ("LEDBrightness")
#define CFG_ENABLE_CHEATS ("EnableCheats")
typedef enum {
VIDMODE_60 = 0,
@@ -59,6 +60,7 @@ typedef struct __attribute__ ((__packed__)) _cfg_block {
uint8_t gsu_speed; /* GSU speed (0: original, 1: no waitstates */
uint8_t reset_to_menu; /* Go back to menu on short reset */
uint8_t led_brightness; /* LED brightness (0..15) */
uint8_t enable_cheats; /* initial cheat enable state */
} cfg_t;
int cfg_save(void);
View
@@ -55,7 +55,7 @@ void cheat_program() {
snescmd_writebyte(wram_index, SNESCMD_NMI_WRAM_PATCH_COUNT);
printf("enable mask=%02x\n", enable_mask);
fpga_write_cheat(6, enable_mask);
cheat_enable(1);
cheat_enable(CFG.enable_cheats);
//cheat_nmi_enable(romprops.has_gsu ? 0 : CFG.enable_irq_hook);
cheat_nmi_enable(CFG.enable_ingame_hook);
//cheat_irq_enable(romprops.has_gsu ? 0 : CFG.enable_irq_hook);

0 comments on commit e894661

Please sign in to comment.