From 0ab099077a160dad8815b6674ec28f4063305c82 Mon Sep 17 00:00:00 2001 From: Matt Harlum Date: Thu, 15 Jul 2021 15:21:14 +0200 Subject: [PATCH] slow-to-chip: Fixup agnus detection Write to VPOSW before reading Agnus id seems to fix cold boot Agnus id read failure Add "force-move-slow-to-chip" config option to force-disable Agnus check in case issue persists --- emulator.c | 1 + platforms/amiga/amiga-platform.c | 12 ++++++++++-- platforms/amiga/amiga-registers.h | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/emulator.c b/emulator.c index fee4e5f..f71056c 100644 --- a/emulator.c +++ b/emulator.c @@ -45,6 +45,7 @@ int cpu_emulation_running = 1; int swap_df0_with_dfx = 0; int spoof_df0_id = 0; int move_slow_to_chip = 0; +int force_move_slow_to_chip = 0; uint8_t mouse_dx = 0, mouse_dy = 0; uint8_t mouse_buttons = 0; diff --git a/platforms/amiga/amiga-platform.c b/platforms/amiga/amiga-platform.c index 5808d8a..3e64ed8 100644 --- a/platforms/amiga/amiga-platform.c +++ b/platforms/amiga/amiga-platform.c @@ -61,6 +61,7 @@ extern int mouse_hook_enabled; extern int swap_df0_with_dfx; extern int spoof_df0_id; extern int move_slow_to_chip; +extern int force_move_slow_to_chip; #define min(a, b) (a < b) ? a : b #define max(a, b) (a > b) ? a : b @@ -540,6 +541,11 @@ void setvar_amiga(struct emulator_config *cfg, char *var, char *val) { move_slow_to_chip = 1; printf("[AMIGA] Slow ram moved to Chip.\n"); } + + if CHKVAR("force-move-slow-to-chip") { + force_move_slow_to_chip = 1; + printf("[AMIGA] Forcing slowram move to chip, bypassing Agnus version check.\n"); + } } void handle_reset_amiga(struct emulator_config *cfg) { @@ -556,8 +562,9 @@ void handle_reset_amiga(struct emulator_config *cfg) { if (piscsi_enabled) piscsi_refresh_drives(); - if (move_slow_to_chip) { - int agnus_rev = ((ps_read_16(0xDFF004) >> 8) & 0x6F); + if (move_slow_to_chip && !force_move_slow_to_chip) { + ps_write_16(VPOSW,0x00); // Poke poke... wake up Agnus! + int agnus_rev = ((ps_read_16(VPOSR) >> 8) & 0x6F); if (agnus_rev != 0x20) { move_slow_to_chip = 0; printf("[AMIGA] Requested move slow ram to chip but 8372 Agnus not found - Disabling.\n"); @@ -610,6 +617,7 @@ void shutdown_platform_amiga(struct emulator_config *cfg) { swap_df0_with_dfx = 0; spoof_df0_id = 0; move_slow_to_chip = 0; + force_move_slow_to_chip = 0; autoconfig_reset_all(); printf("[AMIGA] Platform shutdown completed.\n"); diff --git a/platforms/amiga/amiga-registers.h b/platforms/amiga/amiga-registers.h index c42a8f7..e41684f 100644 --- a/platforms/amiga/amiga-registers.h +++ b/platforms/amiga/amiga-registers.h @@ -43,6 +43,8 @@ void adjust_gayle_1200(); #define POTGOR 0xDFF016 #define SERDAT 0xDFF030 +#define VPOSR 0xDFF004 +#define VPOSW 0xDFF02A #define DMACON 0xDFF096 #define DMACONR 0xDFF002