Minimig settings and reset cleanup and refactoring.
This commit is contained in:
@@ -31,8 +31,8 @@ extern int iFirstEntry;
|
||||
|
||||
// options flags
|
||||
#define SCAN_DIR 1 // include subdirectories
|
||||
#define SCAN_UMOUNT 2 // include subdirectories
|
||||
#define SCAN_SDIR 4 // include subdirectories
|
||||
#define SCAN_UMOUNT 2
|
||||
#define SCAN_SDIR 4
|
||||
#define SCAN_ROOT 8
|
||||
#define SCAN_HERE 16
|
||||
|
||||
|
||||
237
menu.cpp
237
menu.cpp
@@ -71,8 +71,6 @@ enum MENU
|
||||
MENU_SETTINGS1,
|
||||
MENU_SETTINGS2,
|
||||
MENU_ROMFILE_SELECTED,
|
||||
MENU_ROMFILE_SELECTED1,
|
||||
MENU_ROMFILE_SELECTED2,
|
||||
MENU_SETTINGS_VIDEO1,
|
||||
MENU_SETTINGS_VIDEO2,
|
||||
MENU_SETTINGS_MEMORY1,
|
||||
@@ -86,9 +84,6 @@ enum MENU
|
||||
MENU_HARDFILE_SELECT1,
|
||||
MENU_HARDFILE_SELECT2,
|
||||
MENU_HARDFILE_SELECTED,
|
||||
MENU_HARDFILE_EXIT,
|
||||
MENU_HARDFILE_CHANGED1,
|
||||
MENU_HARDFILE_CHANGED2,
|
||||
MENU_LOADCONFIG_1,
|
||||
MENU_LOADCONFIG_2,
|
||||
MENU_SAVECONFIG_1,
|
||||
@@ -2193,7 +2188,6 @@ void HandleUI(void)
|
||||
{
|
||||
OsdDisable();
|
||||
LoadConfiguration(menusub);
|
||||
MinimigReset();
|
||||
menustate = MENU_NONE1;
|
||||
}
|
||||
else
|
||||
@@ -2551,7 +2545,7 @@ void HandleUI(void)
|
||||
}
|
||||
else if (left)
|
||||
{
|
||||
menustate = MENU_SETTINGS_VIDEO1;
|
||||
menustate = MENU_SETTINGS_HARDFILE1;
|
||||
menusub = 0;
|
||||
}
|
||||
break;
|
||||
@@ -2567,23 +2561,23 @@ void HandleUI(void)
|
||||
OsdSetTitle("Memory", OSD_ARROW_LEFT | OSD_ARROW_RIGHT);
|
||||
|
||||
OsdWrite(0, "", 0, 0);
|
||||
strcpy(s, " CHIP : ");
|
||||
strcpy(s, " CHIP : ");
|
||||
strcat(s, config_memory_chip_msg[config.memory & 0x03]);
|
||||
OsdWrite(1, s, menusub == 0, 0);
|
||||
strcpy(s, " SLOW : ");
|
||||
strcpy(s, " SLOW : ");
|
||||
strcat(s, config_memory_slow_msg[config.memory >> 2 & 0x03]);
|
||||
OsdWrite(2, s, menusub == 1, 0);
|
||||
strcpy(s, " FAST : ");
|
||||
strcpy(s, " FAST : ");
|
||||
strcat(s, config_memory_fast_msg[config.memory >> 4 & 0x03]);
|
||||
OsdWrite(3, s, menusub == 2, 0);
|
||||
|
||||
OsdWrite(4, "", 0, 0);
|
||||
|
||||
strcpy(s, " ROM : ");
|
||||
strncat(s, config.kickstart, 15);
|
||||
strcpy(s, " ROM : ");
|
||||
strncat(s, config.kickstart, 25);
|
||||
OsdWrite(5, s, menusub == 3, 0);
|
||||
|
||||
strcpy(s, " HRTmon: ");
|
||||
strcpy(s, " HRTmon: ");
|
||||
strcat(s, (config.memory & 0x40) ? "enabled " : "disabled");
|
||||
OsdWrite(6, s, menusub == 4, 0);
|
||||
|
||||
@@ -2600,19 +2594,16 @@ void HandleUI(void)
|
||||
{
|
||||
config.memory = ((config.memory + 1) & 0x03) | (config.memory & ~0x03);
|
||||
menustate = MENU_SETTINGS_MEMORY1;
|
||||
ConfigMemory(config.memory);
|
||||
}
|
||||
else if (menusub == 1)
|
||||
{
|
||||
config.memory = ((config.memory + 4) & 0x0C) | (config.memory & ~0x0C);
|
||||
menustate = MENU_SETTINGS_MEMORY1;
|
||||
ConfigMemory(config.memory);
|
||||
}
|
||||
else if (menusub == 2)
|
||||
{
|
||||
config.memory = ((config.memory + 0x10) & 0x30) | (config.memory & ~0x30);
|
||||
menustate = MENU_SETTINGS_MEMORY1;
|
||||
ConfigMemory(config.memory);
|
||||
}
|
||||
else if (menusub == 3)
|
||||
{
|
||||
@@ -2621,7 +2612,6 @@ void HandleUI(void)
|
||||
else if (menusub == 4)
|
||||
{
|
||||
config.memory ^= 0x40;
|
||||
ConfigMemory(config.memory);
|
||||
menustate = MENU_SETTINGS_MEMORY1;
|
||||
}
|
||||
else if (menusub == 5)
|
||||
@@ -2648,6 +2638,11 @@ void HandleUI(void)
|
||||
}
|
||||
break;
|
||||
|
||||
case MENU_ROMFILE_SELECTED:
|
||||
SetKickstart(SelectedPath);
|
||||
menustate = MENU_SETTINGS_MEMORY1;
|
||||
break;
|
||||
|
||||
/******************************************************************/
|
||||
/* hardfile settings menu */
|
||||
/******************************************************************/
|
||||
@@ -2658,7 +2653,7 @@ void HandleUI(void)
|
||||
// not on rejection.
|
||||
case MENU_SETTINGS_HARDFILE1:
|
||||
helptext = helptexts[HELPTEXT_HARDFILE];
|
||||
OsdSetTitle("Harddisks", 0);
|
||||
OsdSetTitle("Harddisks", OSD_ARROW_LEFT | OSD_ARROW_RIGHT);
|
||||
|
||||
parentstate = menustate;
|
||||
menumask = 0x21; // b00100001 - On/off & exit enabled by default...
|
||||
@@ -2673,14 +2668,14 @@ void HandleUI(void)
|
||||
strcpy(s, " Master : ");
|
||||
strcat(s, config.hardfile[0].enabled ? "Enabled" : "Disabled");
|
||||
OsdWrite(3, s, config.enable_ide ? (menusub == 1) : 0, config.enable_ide == 0);
|
||||
if (config.hardfile[0].present)
|
||||
if (config.hardfile[0].filename[0])
|
||||
{
|
||||
strcpy(s, " ");
|
||||
strncpy(&s[7], config.hardfile[0].long_name, 21);
|
||||
strncpy(&s[7], config.hardfile[0].filename, 21);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(s, " ** file not found **");
|
||||
strcpy(s, " ** not selected **");
|
||||
}
|
||||
enable = config.enable_ide && config.hardfile[0].enabled;
|
||||
if (enable) menumask |= 0x04; // Make hardfile selectable
|
||||
@@ -2690,14 +2685,14 @@ void HandleUI(void)
|
||||
strcpy(s, " Slave : ");
|
||||
strcat(s, config.hardfile[1].enabled ? "Enabled" : "Disabled");
|
||||
OsdWrite(6, s, config.enable_ide ? (menusub == 3) : 0, config.enable_ide == 0);
|
||||
if (config.hardfile[1].present)
|
||||
if (config.hardfile[1].filename[0])
|
||||
{
|
||||
strcpy(s, " ");
|
||||
strncpy(&s[7], config.hardfile[1].long_name, 21);
|
||||
strncpy(&s[7], config.hardfile[1].filename, 21);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(s, " ** file not found **");
|
||||
strcpy(s, " ** not selected **");
|
||||
}
|
||||
enable = config.enable_ide && config.hardfile[1].enabled;
|
||||
if (enable) menumask |= 0x10; // Make hardfile selectable
|
||||
@@ -2724,7 +2719,7 @@ void HandleUI(void)
|
||||
}
|
||||
else if (menusub == 2)
|
||||
{
|
||||
SelectFile("HDF", SCAN_DIR, MENU_HARDFILE_SELECTED, MENU_SETTINGS_HARDFILE1, 1);
|
||||
SelectFile("HDFVHDIMGDSK", SCAN_DIR | SCAN_UMOUNT, MENU_HARDFILE_SELECTED, MENU_SETTINGS_HARDFILE1, 1);
|
||||
}
|
||||
else if (menusub == 3)
|
||||
{
|
||||
@@ -2733,17 +2728,29 @@ void HandleUI(void)
|
||||
}
|
||||
else if (menusub == 4)
|
||||
{
|
||||
SelectFile("HDF", SCAN_DIR, MENU_HARDFILE_SELECTED, MENU_SETTINGS_HARDFILE1, 1);
|
||||
SelectFile("HDFVHDIMGDSK", SCAN_DIR | SCAN_UMOUNT, MENU_HARDFILE_SELECTED, MENU_SETTINGS_HARDFILE1, 1);
|
||||
}
|
||||
else if (menusub == 5) // return to previous menu
|
||||
{
|
||||
menustate = MENU_HARDFILE_EXIT;
|
||||
menustate = MENU_MAIN1;
|
||||
menusub = 5;
|
||||
}
|
||||
}
|
||||
|
||||
if (menu) // return to previous menu
|
||||
{
|
||||
menustate = MENU_HARDFILE_EXIT;
|
||||
menustate = MENU_MAIN1;
|
||||
menusub = 5;
|
||||
}
|
||||
else if (right)
|
||||
{
|
||||
menustate = MENU_SETTINGS_CHIPSET1;
|
||||
menusub = 0;
|
||||
}
|
||||
else if (left)
|
||||
{
|
||||
menustate = MENU_SETTINGS_VIDEO1;
|
||||
menusub = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -2753,96 +2760,23 @@ void HandleUI(void)
|
||||
case MENU_HARDFILE_SELECTED:
|
||||
if (menusub == 2) // master drive selected
|
||||
{
|
||||
// Read RDB from selected drive and determine type...
|
||||
memcpy((void*)config.hardfile[0].long_name, SelectedPath, sizeof(config.hardfile[0].long_name));
|
||||
config.hardfile[0].present = 1;
|
||||
int len = strlen(SelectedPath);
|
||||
if (len > sizeof(config.hardfile[0].filename) - 1) len = sizeof(config.hardfile[0].filename) - 1;
|
||||
if(len) memcpy(config.hardfile[0].filename, SelectedPath, len);
|
||||
config.hardfile[0].filename[len] = 0;
|
||||
menustate = MENU_SETTINGS_HARDFILE1;
|
||||
}
|
||||
else
|
||||
if (menusub == 4) // slave drive selected
|
||||
{
|
||||
memcpy((void*)config.hardfile[1].long_name, SelectedPath, sizeof(config.hardfile[1].long_name));
|
||||
config.hardfile[1].present = 1;
|
||||
int len = strlen(SelectedPath);
|
||||
if (len > sizeof(config.hardfile[1].filename) - 1) len = sizeof(config.hardfile[1].filename) - 1;
|
||||
if (len) memcpy(config.hardfile[1].filename, SelectedPath, len);
|
||||
config.hardfile[1].filename[len] = 0;
|
||||
menustate = MENU_SETTINGS_HARDFILE1;
|
||||
}
|
||||
break;
|
||||
|
||||
// check if hardfile configuration has changed
|
||||
case MENU_HARDFILE_EXIT:
|
||||
if (memcmp(config.hardfile, t_hardfile, sizeof(t_hardfile)) != 0)
|
||||
{
|
||||
menustate = MENU_HARDFILE_CHANGED1;
|
||||
menusub = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
menustate = MENU_MAIN1;
|
||||
menusub = 5;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// hardfile configuration has changed, ask user if he wants to use the new settings
|
||||
case MENU_HARDFILE_CHANGED1:
|
||||
menumask = 0x03;
|
||||
parentstate = menustate;
|
||||
OsdSetTitle("Confirm", 0);
|
||||
|
||||
OsdWrite(0, "", 0, 0);
|
||||
OsdWrite(1, " Changing configuration", 0, 0);
|
||||
OsdWrite(2, " requires reset.", 0, 0);
|
||||
OsdWrite(3, "", 0, 0);
|
||||
OsdWrite(4, " Reset Minimig?", 0, 0);
|
||||
OsdWrite(5, "", 0, 0);
|
||||
OsdWrite(6, " yes", menusub == 0, 0);
|
||||
OsdWrite(7, " no", menusub == 1, 0);
|
||||
|
||||
for (int i = 8; i < OsdGetSize(); i++) OsdWrite(i, "", 0, 0);
|
||||
|
||||
menustate = MENU_HARDFILE_CHANGED2;
|
||||
break;
|
||||
|
||||
case MENU_HARDFILE_CHANGED2:
|
||||
if (select)
|
||||
{
|
||||
if (menusub == 0) // yes
|
||||
{
|
||||
// FIXME - waiting for user-confirmation increases the window of opportunity for file corruption!
|
||||
|
||||
if ((config.hardfile[0].enabled != t_hardfile[0].enabled)
|
||||
|| (strcmp(config.hardfile[0].long_name, t_hardfile[0].long_name) != 0))
|
||||
{
|
||||
OpenHardfile(0);
|
||||
}
|
||||
if (config.hardfile[1].enabled != t_hardfile[1].enabled
|
||||
|| (strcmp(config.hardfile[1].long_name, t_hardfile[1].long_name) != 0))
|
||||
{
|
||||
OpenHardfile(1);
|
||||
}
|
||||
|
||||
if (menustate == MENU_HARDFILE_CHANGED2)
|
||||
{
|
||||
MinimigReset();
|
||||
menustate = MENU_NONE1;
|
||||
}
|
||||
}
|
||||
else if (menusub == 1) // no
|
||||
{
|
||||
memcpy(config.hardfile, t_hardfile, sizeof(t_hardfile)); // restore configuration
|
||||
menustate = MENU_MAIN1;
|
||||
menusub = 3;
|
||||
}
|
||||
}
|
||||
|
||||
if (menu)
|
||||
{
|
||||
memcpy(config.hardfile, t_hardfile, sizeof(t_hardfile)); // restore configuration
|
||||
menustate = MENU_MAIN1;
|
||||
menusub = 3;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
/******************************************************************/
|
||||
/* video settings menu */
|
||||
/******************************************************************/
|
||||
@@ -2853,21 +2787,20 @@ void HandleUI(void)
|
||||
|
||||
OsdSetTitle("Video", OSD_ARROW_LEFT | OSD_ARROW_RIGHT);
|
||||
OsdWrite(0, "", 0, 0);
|
||||
OsdWrite(1, "", 0, 0);
|
||||
strcpy(s, " Scanlines : ");
|
||||
strcat(s, config_scanlines_msg[config.scanlines & 0x3]);
|
||||
OsdWrite(2, s, menusub == 0, 0);
|
||||
OsdWrite(1, s, menusub == 0, 0);
|
||||
strcpy(s, " Video area by : ");
|
||||
strcat(s, config_blank_msg[(config.scanlines >> 6) & 3]);
|
||||
OsdWrite(3, s, menusub == 1, 0);
|
||||
OsdWrite(2, s, menusub == 1, 0);
|
||||
strcpy(s, " Aspect Ratio : ");
|
||||
strcat(s, config_ar_msg[(config.scanlines >> 4) & 1]);
|
||||
OsdWrite(4, s, menusub == 2, 0);
|
||||
OsdWrite(5, "", 0, 0);
|
||||
OsdWrite(3, s, menusub == 2, 0);
|
||||
OsdWrite(4, "", 0, 0);
|
||||
strcpy(s, " Stereo mix : ");
|
||||
strcat(s, config_stereo_msg[config.audio & 3]);
|
||||
OsdWrite(6, s, menusub == 3, 0);
|
||||
for (int i = 7; i < OsdGetSize() - 1; i++) OsdWrite(i, "", 0, 0);
|
||||
OsdWrite(5, s, menusub == 3, 0);
|
||||
for (int i = 6; i < OsdGetSize() - 1; i++) OsdWrite(i, "", 0, 0);
|
||||
OsdWrite(OsdGetSize() - 1, STD_EXIT, menusub == 4, 0);
|
||||
|
||||
menustate = MENU_SETTINGS_VIDEO2;
|
||||
@@ -2879,8 +2812,7 @@ void HandleUI(void)
|
||||
if (menusub == 0)
|
||||
{
|
||||
config.scanlines = ((config.scanlines + 1) & 0x03) | (config.scanlines & 0xfc);
|
||||
if ((config.scanlines & 0x03) > 2)
|
||||
config.scanlines = config.scanlines & 0xfc;
|
||||
if ((config.scanlines & 0x03) > 2) config.scanlines = config.scanlines & 0xfc;
|
||||
menustate = MENU_SETTINGS_VIDEO1;
|
||||
ConfigVideo(config.filter.hires, config.filter.lores, config.scanlines);
|
||||
}
|
||||
@@ -2918,7 +2850,7 @@ void HandleUI(void)
|
||||
}
|
||||
else if (right)
|
||||
{
|
||||
menustate = MENU_SETTINGS_CHIPSET1;
|
||||
menustate = MENU_SETTINGS_HARDFILE1;
|
||||
menusub = 0;
|
||||
}
|
||||
else if (left)
|
||||
@@ -2928,73 +2860,6 @@ void HandleUI(void)
|
||||
}
|
||||
break;
|
||||
|
||||
/******************************************************************/
|
||||
/* rom file selected menu */
|
||||
/******************************************************************/
|
||||
case MENU_ROMFILE_SELECTED:
|
||||
menusub = 1;
|
||||
menustate = MENU_ROMFILE_SELECTED1;
|
||||
// no break intended
|
||||
|
||||
case MENU_ROMFILE_SELECTED1:
|
||||
menumask = 0x03;
|
||||
parentstate = menustate;
|
||||
OsdSetTitle("Confirm", 0);
|
||||
OsdWrite(0, "", 0, 0);
|
||||
OsdWrite(1, " Reload Kickstart?", 0, 0);
|
||||
OsdWrite(2, "", 0, 0);
|
||||
OsdWrite(3, " yes", menusub == 0, 0);
|
||||
OsdWrite(4, " no", menusub == 1, 0);
|
||||
OsdWrite(5, "", 0, 0);
|
||||
OsdWrite(6, "", 0, 0);
|
||||
OsdWrite(7, "", 0, 0);
|
||||
for (int i = 8; i < OsdGetSize(); i++) OsdWrite(i, "", 0, 0);
|
||||
|
||||
menustate = MENU_ROMFILE_SELECTED2;
|
||||
break;
|
||||
|
||||
case MENU_ROMFILE_SELECTED2:
|
||||
if (select)
|
||||
{
|
||||
if (menusub == 0)
|
||||
{
|
||||
memcpy((void*)config.kickstart, SelectedPath, sizeof(config.kickstart));
|
||||
// reset bootscreen cursor position
|
||||
BootHome();
|
||||
OsdDisable();
|
||||
EnableOsd();
|
||||
spi8(OSD_CMD_RST);
|
||||
rstval = (SPI_RST_CPU | SPI_CPU_HLT);
|
||||
spi8(rstval);
|
||||
DisableOsd();
|
||||
UploadKickstart(config.kickstart);
|
||||
EnableOsd();
|
||||
spi8(OSD_CMD_RST);
|
||||
rstval = (SPI_RST_USR | SPI_RST_CPU);
|
||||
spi8(rstval);
|
||||
DisableOsd();
|
||||
EnableOsd();
|
||||
spi8(OSD_CMD_RST);
|
||||
rstval = 0;
|
||||
spi8(rstval);
|
||||
DisableOsd();
|
||||
|
||||
menustate = MENU_NONE1;
|
||||
}
|
||||
else if (menusub == 1)
|
||||
{
|
||||
menustate = MENU_SETTINGS_MEMORY1;
|
||||
menusub = 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (menu)
|
||||
{
|
||||
menustate = MENU_SETTINGS_MEMORY1;
|
||||
menusub = 2;
|
||||
}
|
||||
break;
|
||||
|
||||
/******************************************************************/
|
||||
/* firmware menu */
|
||||
/******************************************************************/
|
||||
|
||||
@@ -42,7 +42,6 @@ void BootHome()
|
||||
bootscreen_adr = 0x80000 + /*120*/112 * 640 / 8;
|
||||
}
|
||||
|
||||
//// boot font ////
|
||||
static const char boot_font[96][8] =
|
||||
{
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // SPACE
|
||||
@@ -143,9 +142,7 @@ static const char boot_font[96][8] =
|
||||
{ 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0x00 } //
|
||||
};
|
||||
|
||||
|
||||
//// BootEnableMem() ////
|
||||
void BootEnableMem()
|
||||
static void BootEnableMem()
|
||||
{
|
||||
// TEMP enable 1MB memory
|
||||
spi_osd_cmd8(OSD_CMD_MEM, 0x5);
|
||||
@@ -158,8 +155,7 @@ void BootEnableMem()
|
||||
//while ((read32(REG_SYS_STAT_ADR) & 0x2));
|
||||
}
|
||||
|
||||
//// BootClearScreen() ////
|
||||
void BootClearScreen(int adr, int size)
|
||||
static void BootClearScreen(int adr, int size)
|
||||
{
|
||||
int i;
|
||||
mem_upload_init(adr);
|
||||
@@ -171,9 +167,7 @@ void BootClearScreen(int adr, int size)
|
||||
mem_upload_fini();
|
||||
}
|
||||
|
||||
|
||||
//// BootUploadLogo() ////
|
||||
void BootUploadLogo()
|
||||
static void BootUploadLogo()
|
||||
{
|
||||
fileTYPE file = { 0 };
|
||||
int x, y;
|
||||
@@ -232,9 +226,7 @@ void BootUploadLogo()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// BootUploadBall() ////
|
||||
void BootUploadBall()
|
||||
static void BootUploadBall()
|
||||
{
|
||||
fileTYPE file = { 0 };
|
||||
int x;
|
||||
@@ -264,9 +256,7 @@ void BootUploadBall()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// BootUploadCopper() ////
|
||||
void BootUploadCopper()
|
||||
static void BootUploadCopper()
|
||||
{
|
||||
fileTYPE file = { 0 };
|
||||
int x;
|
||||
@@ -306,9 +296,7 @@ void BootUploadCopper()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// BootCustomInit() ////
|
||||
void BootCustomInit()
|
||||
static void BootCustomInit()
|
||||
{
|
||||
//move.w #$0000,$dff1fc ; FMODE, slow fetch mode for AGA compatibility
|
||||
mem_upload_init(0xdff1fc);
|
||||
@@ -410,9 +398,6 @@ void BootCustomInit()
|
||||
mem_upload_fini();
|
||||
}
|
||||
|
||||
extern adfTYPE df[4];
|
||||
|
||||
//// BootInit() ////
|
||||
void BootInit()
|
||||
{
|
||||
puts("Running minimig setup");
|
||||
@@ -459,18 +444,10 @@ void BootInit()
|
||||
BootPrintEx(" ");
|
||||
}
|
||||
|
||||
//eject all disk
|
||||
df[0].status = 0;
|
||||
df[1].status = 0;
|
||||
df[2].status = 0;
|
||||
df[3].status = 0;
|
||||
|
||||
config.kickstart[0] = 0;
|
||||
LoadConfiguration(0);
|
||||
}
|
||||
|
||||
|
||||
//// BootPrint() ////
|
||||
void BootPrintEx(const char * str)
|
||||
{
|
||||
unsigned char i, j;
|
||||
@@ -497,4 +474,3 @@ void BootPrintEx(const char * str)
|
||||
bootscreen_adr += 640 / 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,13 +16,11 @@
|
||||
#include "input.h"
|
||||
|
||||
configTYPE config = { 0 };
|
||||
char DebugMode = 0;
|
||||
unsigned char romkey[3072];
|
||||
|
||||
void SendFileV2(fileTYPE* file, unsigned char* key, int keysize, int address, int size)
|
||||
static void SendFileV2(fileTYPE* file, unsigned char* key, int keysize, int address, int size)
|
||||
{
|
||||
static uint8_t buf[512];
|
||||
int i, j;
|
||||
unsigned int keyidx = 0;
|
||||
printf("File size: %dkB\n", size >> 1);
|
||||
printf("[");
|
||||
@@ -31,14 +29,16 @@ void SendFileV2(fileTYPE* file, unsigned char* key, int keysize, int address, in
|
||||
// read header
|
||||
FileReadAdv(file, buf, 0xb);
|
||||
}
|
||||
for (i = 0; i<size; i++)
|
||||
|
||||
for (int i = 0; i<size; i++)
|
||||
{
|
||||
if (!(i & 31)) printf("*");
|
||||
FileReadAdv(file, buf, 512);
|
||||
|
||||
if (keysize)
|
||||
{
|
||||
// decrypt ROM
|
||||
for (j = 0; j<512; j++)
|
||||
for (int j = 0; j<512; j++)
|
||||
{
|
||||
buf[j] ^= key[keyidx++];
|
||||
if (keyidx >= keysize) keyidx -= keysize;
|
||||
@@ -51,7 +51,7 @@ void SendFileV2(fileTYPE* file, unsigned char* key, int keysize, int address, in
|
||||
spi8(adr & 0xff); adr = adr >> 8;
|
||||
spi8(adr & 0xff); adr = adr >> 8;
|
||||
spi8(adr & 0xff); adr = adr >> 8;
|
||||
for (j = 0; j<512; j = j + 4)
|
||||
for (int j = 0; j<512; j = j + 4)
|
||||
{
|
||||
spi8(buf[j + 0]);
|
||||
spi8(buf[j + 1]);
|
||||
@@ -60,11 +60,11 @@ void SendFileV2(fileTYPE* file, unsigned char* key, int keysize, int address, in
|
||||
}
|
||||
DisableOsd();
|
||||
}
|
||||
|
||||
printf("]\n");
|
||||
}
|
||||
|
||||
//// UploadKickstart() ////
|
||||
char UploadKickstart(char *name)
|
||||
static char UploadKickstart(char *name)
|
||||
{
|
||||
fileTYPE file = { 0 };
|
||||
int keysize = 0;
|
||||
@@ -146,9 +146,7 @@ char UploadKickstart(char *name)
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
//// UploadActionReplay() ////
|
||||
char UploadActionReplay()
|
||||
static char UploadActionReplay()
|
||||
{
|
||||
fileTYPE file = { 0 };
|
||||
if(FileOpen(&file, "Amiga/HRTMON.ROM") || FileOpen(&file, "HRTMON.ROM"))
|
||||
@@ -220,8 +218,6 @@ char UploadActionReplay()
|
||||
if (num) sprintf(str, "MINIMIG%d.CFG", num); \
|
||||
else strcpy(str, "MINIMIG.CFG");
|
||||
|
||||
|
||||
//// ConfigurationExists() ////
|
||||
unsigned char ConfigurationExists(int num)
|
||||
{
|
||||
static char path[256];
|
||||
@@ -237,7 +233,86 @@ unsigned char ConfigurationExists(int num)
|
||||
return(0);
|
||||
}
|
||||
|
||||
//// LoadConfiguration() ////
|
||||
static int force_reload_kickstart = 0;
|
||||
static void ApplyConfiguration(char reloadkickstart)
|
||||
{
|
||||
if (force_reload_kickstart) reloadkickstart = 1;
|
||||
force_reload_kickstart = 0;
|
||||
|
||||
ConfigCPU(config.cpu);
|
||||
|
||||
if (!reloadkickstart)
|
||||
{
|
||||
ConfigChipset(config.chipset);
|
||||
ConfigFloppy(config.floppy.drives, config.floppy.speed);
|
||||
}
|
||||
|
||||
printf("CPU clock : %s\n", config.chipset & 0x01 ? "turbo" : "normal");
|
||||
printf("Chip RAM size : %s\n", config_memory_chip_msg[config.memory & 0x03]);
|
||||
printf("Slow RAM size : %s\n", config_memory_slow_msg[config.memory >> 2 & 0x03]);
|
||||
printf("Fast RAM size : %s\n", config_memory_fast_msg[config.memory >> 4 & 0x03]);
|
||||
|
||||
printf("Floppy drives : %u\n", config.floppy.drives + 1);
|
||||
printf("Floppy speed : %s\n", config.floppy.speed ? "fast" : "normal");
|
||||
|
||||
printf("\n");
|
||||
|
||||
printf("\nA600/A1200 IDE is %s.\n", config.enable_ide ? "enabled" : "disabled");
|
||||
if (config.enable_ide)
|
||||
{
|
||||
printf("Master HDD is %s.\n", config.hardfile[0].enabled ? "enabled" : "disabled");
|
||||
printf("Slave HDD is %s.\n", config.hardfile[1].enabled ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
rstval = SPI_CPU_HLT;
|
||||
spi_osd_cmd8(OSD_CMD_RST, rstval);
|
||||
spi_osd_cmd8(OSD_CMD_HDD, (config.enable_ide ? 1 : 0) | (OpenHardfile(0) ? 2 : 0) | (OpenHardfile(1) ? 4 : 0));
|
||||
|
||||
ConfigMemory(config.memory);
|
||||
ConfigCPU(config.cpu);
|
||||
|
||||
ConfigChipset(config.chipset);
|
||||
ConfigFloppy(config.floppy.drives, config.floppy.speed);
|
||||
|
||||
if (config.memory & 0x40) UploadActionReplay();
|
||||
|
||||
if (reloadkickstart)
|
||||
{
|
||||
printf("Reloading kickstart ...\n");
|
||||
rstval |= (SPI_RST_CPU | SPI_CPU_HLT);
|
||||
spi_osd_cmd8(OSD_CMD_RST, rstval);
|
||||
if (!UploadKickstart(config.kickstart))
|
||||
{
|
||||
strcpy(config.kickstart, "Amiga/KICK.ROM");
|
||||
if (!UploadKickstart(config.kickstart))
|
||||
{
|
||||
strcpy(config.kickstart, "KICK.ROM");
|
||||
if (!UploadKickstart(config.kickstart))
|
||||
{
|
||||
BootPrintEx("No Kickstart loaded. Press F12 for settings.");
|
||||
BootPrintEx("** Halted! **");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
rstval |= (SPI_RST_USR | SPI_RST_CPU);
|
||||
spi_osd_cmd8(OSD_CMD_RST, rstval);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Resetting ...\n");
|
||||
rstval |= (SPI_RST_USR | SPI_RST_CPU);
|
||||
spi_osd_cmd8(OSD_CMD_RST, rstval);
|
||||
}
|
||||
|
||||
rstval = 0;
|
||||
spi_osd_cmd8(OSD_CMD_RST, rstval);
|
||||
|
||||
ConfigVideo(config.filter.hires, config.filter.lores, config.scanlines);
|
||||
ConfigAudio(config.audio);
|
||||
ConfigAutofire(config.autofire, 0xC);
|
||||
}
|
||||
|
||||
unsigned char LoadConfiguration(int num)
|
||||
{
|
||||
static const char config_id[] = "MNMGCFG0";
|
||||
@@ -293,9 +368,9 @@ unsigned char LoadConfiguration(int num)
|
||||
config.floppy.drives = 1;
|
||||
config.enable_ide = 0;
|
||||
config.hardfile[0].enabled = 1;
|
||||
config.hardfile[0].long_name[0] = 0;
|
||||
config.hardfile[0].filename[0] = 0;
|
||||
config.hardfile[1].enabled = 1;
|
||||
config.hardfile[1].long_name[0] = 0;
|
||||
config.hardfile[1].filename[0] = 0;
|
||||
updatekickstart = true;
|
||||
BootPrintEx(">>> No config found. Using defaults. <<<");
|
||||
}
|
||||
@@ -326,128 +401,6 @@ unsigned char LoadConfiguration(int num)
|
||||
return(result);
|
||||
}
|
||||
|
||||
void IDE_setup()
|
||||
{
|
||||
OpenHardfile(0);
|
||||
OpenHardfile(1);
|
||||
spi_osd_cmd8(OSD_CMD_HDD, ((config.hardfile[1].present && config.hardfile[1].enabled) ? 4 : 0) | ((config.hardfile[0].present && config.hardfile[0].enabled) ? 2 : 0) | (config.enable_ide ? 1 : 0));
|
||||
}
|
||||
|
||||
void MinimigReset()
|
||||
{
|
||||
spi_osd_cmd8(OSD_CMD_RST, 0x01);
|
||||
IDE_setup();
|
||||
spi_osd_cmd8(OSD_CMD_RST, 0x00);
|
||||
user_io_rtc_reset();
|
||||
}
|
||||
|
||||
//// ApplyConfiguration() ////
|
||||
void ApplyConfiguration(char reloadkickstart)
|
||||
{
|
||||
ConfigCPU(config.cpu);
|
||||
|
||||
if (reloadkickstart)
|
||||
{
|
||||
|
||||
}
|
||||
else {
|
||||
ConfigChipset(config.chipset);
|
||||
ConfigFloppy(config.floppy.drives, config.floppy.speed);
|
||||
}
|
||||
|
||||
// Whether or not we uploaded a kickstart image we now need to set various parameters from the config.
|
||||
IDE_setup();
|
||||
|
||||
printf("CPU clock : %s\n", config.chipset & 0x01 ? "turbo" : "normal");
|
||||
printf("Chip RAM size : %s\n", config_memory_chip_msg[config.memory & 0x03]);
|
||||
printf("Slow RAM size : %s\n", config_memory_slow_msg[config.memory >> 2 & 0x03]);
|
||||
printf("Fast RAM size : %s\n", config_memory_fast_msg[config.memory >> 4 & 0x03]);
|
||||
|
||||
printf("Floppy drives : %u\n", config.floppy.drives + 1);
|
||||
printf("Floppy speed : %s\n", config.floppy.speed ? "fast" : "normal");
|
||||
|
||||
printf("\n");
|
||||
|
||||
printf("\nA600/A1200 IDE HDC is %s.\n", config.enable_ide ? "enabled" : "disabled");
|
||||
printf("Master HDD is %s.\n", config.hardfile[0].present ? config.hardfile[0].enabled ? "enabled" : "disabled" : "not present");
|
||||
printf("Slave HDD is %s.\n", config.hardfile[1].present ? config.hardfile[1].enabled ? "enabled" : "disabled" : "not present");
|
||||
|
||||
#if 0
|
||||
if (cluster_size < 64) {
|
||||
BootPrint("\n***************************************************");
|
||||
BootPrint("* It's recommended to reformat your memory card *");
|
||||
BootPrint("* using 32 KB clusters to improve performance *");
|
||||
BootPrint("* when using large hardfiles. *"); // AMR
|
||||
BootPrint("***************************************************");
|
||||
}
|
||||
printf("Bootloading is complete.\n");
|
||||
#endif
|
||||
|
||||
printf("\nExiting bootloader...\n");
|
||||
|
||||
ConfigMemory(config.memory);
|
||||
ConfigCPU(config.cpu);
|
||||
|
||||
ConfigChipset(config.chipset);
|
||||
ConfigFloppy(config.floppy.drives, config.floppy.speed);
|
||||
|
||||
if (reloadkickstart)
|
||||
{
|
||||
UploadActionReplay();
|
||||
|
||||
printf("Reloading kickstart ...\n");
|
||||
WaitTimer(1000);
|
||||
EnableOsd();
|
||||
spi8(OSD_CMD_RST);
|
||||
rstval |= (SPI_RST_CPU | SPI_CPU_HLT);
|
||||
spi8(rstval);
|
||||
DisableOsd();
|
||||
if (!UploadKickstart(config.kickstart))
|
||||
{
|
||||
strcpy(config.kickstart, "Amiga/KICK.ROM");
|
||||
if (!UploadKickstart(config.kickstart))
|
||||
{
|
||||
strcpy(config.kickstart, "KICK.ROM");
|
||||
if (!UploadKickstart(config.kickstart))
|
||||
{
|
||||
BootPrintEx("No Kickstart loaded. Press F12 for settings.");
|
||||
BootPrintEx("** Halted! **");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
EnableOsd();
|
||||
spi8(OSD_CMD_RST);
|
||||
rstval |= (SPI_RST_USR | SPI_RST_CPU);
|
||||
spi8(rstval);
|
||||
DisableOsd();
|
||||
EnableOsd();
|
||||
spi8(OSD_CMD_RST);
|
||||
rstval = 0;
|
||||
spi8(rstval);
|
||||
DisableOsd();
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Resetting ...\n");
|
||||
EnableOsd();
|
||||
spi8(OSD_CMD_RST);
|
||||
rstval |= (SPI_RST_USR | SPI_RST_CPU);
|
||||
spi8(rstval);
|
||||
DisableOsd();
|
||||
EnableOsd();
|
||||
spi8(OSD_CMD_RST);
|
||||
rstval = 0;
|
||||
spi8(rstval);
|
||||
DisableOsd();
|
||||
}
|
||||
|
||||
ConfigVideo(config.filter.hires, config.filter.lores, config.scanlines);
|
||||
ConfigAudio(config.audio);
|
||||
ConfigAutofire(config.autofire, 0xC);
|
||||
}
|
||||
|
||||
//// SaveConfiguration() ////
|
||||
unsigned char SaveConfiguration(int num)
|
||||
{
|
||||
static char filename[256];
|
||||
@@ -455,3 +408,18 @@ unsigned char SaveConfiguration(int num)
|
||||
|
||||
return FileSaveConfig(filename, &config, sizeof(config));
|
||||
}
|
||||
|
||||
void MinimigReset()
|
||||
{
|
||||
ApplyConfiguration(0);
|
||||
user_io_rtc_reset();
|
||||
}
|
||||
|
||||
void SetKickstart(char *name)
|
||||
{
|
||||
int len = strlen(name);
|
||||
if (len > (sizeof(config.kickstart) - 1)) len = sizeof(config.kickstart) - 1;
|
||||
memcpy(config.kickstart, name, len);
|
||||
config.kickstart[len] = 0;
|
||||
force_reload_kickstart = 1;
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char enabled; // 0: Disabled, 1: Hard file, 2: MMC (entire card), 3-6: Partition 1-4 of MMC card
|
||||
unsigned char present;
|
||||
char long_name[1024];
|
||||
unsigned char enabled;
|
||||
unsigned char reserved;
|
||||
char filename[1024];
|
||||
} hardfileTYPE;
|
||||
|
||||
typedef struct
|
||||
@@ -42,14 +42,12 @@ typedef struct
|
||||
} configTYPE;
|
||||
|
||||
extern configTYPE config;
|
||||
extern char DebugMode;
|
||||
|
||||
char UploadKickstart(char *name);
|
||||
char UploadActionReplay();
|
||||
unsigned char LoadConfiguration(int num); // Can supply NULL to use filename previously set by slot number
|
||||
unsigned char SaveConfiguration(int num); // Can supply NULL to use filename previously set by slot number
|
||||
unsigned char LoadConfiguration(int num);
|
||||
unsigned char SaveConfiguration(int num);
|
||||
unsigned char ConfigurationExists(int num);
|
||||
void ApplyConfiguration(char reloadkickstart);
|
||||
|
||||
void MinimigReset();
|
||||
void SetKickstart(char *name);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -35,7 +35,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
unsigned char drives = 0; // number of active drives reported by FPGA (may change only during reset)
|
||||
adfTYPE *pdfx; // drive select pointer
|
||||
adfTYPE df[4]; // drive 0 information structure
|
||||
adfTYPE df[4] = { 0 }; // drive information structure
|
||||
|
||||
static uint8_t sector_buffer[512];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user