AW: fix flash sector size. Implement SB_SFRES soft reset

Fixes Atomiswave freezing when exiting the service menu and problems
when saving to flash.
This commit is contained in:
Flyinghead 2019-03-26 11:54:03 +01:00
parent d6fd3e0781
commit cce5028ed3
3 changed files with 35 additions and 15 deletions

View File

@ -378,19 +378,19 @@ struct DCFlashChip : MemChip
else if ((val & 0xff) == 0x30)
{
// sector erase
addr = max(addr, write_protect_size);
#if DC_PLATFORM != DC_PLATFORM_ATOMISWAVE
printf("Erase Sector %08X! (%08X)\n",addr,addr&(~0x3FFF));
memset(&data[addr&(~0x3FFF)],0xFF,0x4000);
#else
// AtomisWave's Macronix 29L001mc has 64k blocks
printf("Erase Sector %08X! (%08X)\n",addr,addr&(~0xFFFF));
u8 save[0x2000];
// this area is write-protected on AW
memcpy(save, data + 0x1a000, 0x2000);
memset(&data[addr&(~0xFFFF)], 0xFF, 0x10000);
memcpy(data + 0x1a000, save, 0x2000);
if (addr >= write_protect_size)
{
#if DC_PLATFORM == DC_PLATFORM_ATOMISWAVE
u8 save[0x2000];
// this area is write-protected on AW
memcpy(save, data + 0x1a000, 0x2000);
#endif
printf("Erase Sector %08X! (%08X)\n",addr,addr&(~0x3FFF));
memset(&data[addr&(~0x3FFF)],0xFF,0x4000);
#if DC_PLATFORM == DC_PLATFORM_ATOMISWAVE
memcpy(data + 0x1a000, save, 0x2000);
#endif
}
state = FS_Normal;
}
else

View File

@ -14,6 +14,8 @@
#include "hw/naomi/naomi.h"
extern void dc_request_reset();
Array<RegisterStruct> sb_regs(0x540);
//(addr>= 0x005F6800) && (addr<=0x005F7CFF) -> 0x1500 bytes -> 0x540 possible registers , 125 actually exist only
@ -194,7 +196,8 @@ void SB_SFRES_write32(u32 addr, u32 data)
{
if ((u16)data==0x7611)
{
printf("SB/HOLLY: System reset requested -- but cannot SOFT_RESET\n");
printf("SB/HOLLY: System reset requested\n");
dc_request_reset();
}
}
void sb_Init()

View File

@ -259,6 +259,7 @@ void dc_reset()
}
static bool init_done;
static bool reset_requested;
int reicast_init(int argc, char* argv[])
{
@ -414,9 +415,18 @@ void* dc_run(void*)
Get_Sh4Interpreter(&sh4_cpu);
printf("Using Interpreter\n");
}
sh4_cpu.Run();
do {
reset_requested = false;
sh4_cpu.Run();
SaveRomFiles(get_writable_data_path("/data/"));
if (reset_requested)
{
dc_reset();
}
} while (reset_requested);
SaveRomFiles(get_writable_data_path("/data/"));
TermAudio();
return NULL;
@ -444,6 +454,13 @@ void dc_stop()
emu_thread.WaitToEnd();
}
// Called on the emulator thread for soft reset
void dc_request_reset()
{
reset_requested = true;
sh4_cpu.Stop();
}
void dc_exit()
{
dc_stop();