mirror of
https://github.com/libretro/Mu.git
synced 2026-09-23 23:25:04 +00:00
Fix initialization order in emulatorInit
This commit is contained in:
@@ -52,12 +52,12 @@ double palmClk32Sysclks;//how many SYSCLKs have happened in the current CLK32
|
||||
|
||||
uint32_t emulatorInit(buffer_t palmRomDump, buffer_t palmBootDump, uint32_t specialFeatures){
|
||||
if(emulatorInitialized)
|
||||
return EMU_ERROR_NONE;
|
||||
return EMU_ERROR_RESOURCE_LOCKED;
|
||||
|
||||
if(!palmRomDump.data)
|
||||
return EMU_ERROR_INVALID_PARAMETER;
|
||||
|
||||
//allocate the buffers, add 4 to memory regions to prevent SIGSEGV from accessing off the end
|
||||
//allocate buffers, add 4 to memory regions to prevent SIGSEGV from accessing off the end
|
||||
palmRam = malloc(((specialFeatures & FEATURE_RAM_HUGE) ? SUPERMASSIVE_RAM_SIZE : RAM_SIZE) + 4);
|
||||
palmRom = malloc(ROM_SIZE + 4);
|
||||
palmReg = malloc(REG_SIZE + 4);
|
||||
@@ -79,11 +79,7 @@ uint32_t emulatorInit(buffer_t palmRomDump, buffer_t palmBootDump, uint32_t spec
|
||||
return EMU_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
//CPU
|
||||
flx68000Init();
|
||||
palmCycleCounter = 0.0;
|
||||
|
||||
//memory
|
||||
//set default values
|
||||
memset(palmRam, 0x00, specialFeatures & FEATURE_RAM_HUGE ? SUPERMASSIVE_RAM_SIZE : RAM_SIZE);
|
||||
memcpy(palmRom, palmRomDump.data, u64Min(palmRomDump.size, ROM_SIZE));
|
||||
if(palmRomDump.size < ROM_SIZE)
|
||||
@@ -105,22 +101,24 @@ uint32_t emulatorInit(buffer_t palmRomDump, buffer_t palmBootDump, uint32_t spec
|
||||
memcpy(palmExtendedFramebuffer + 320 * 320, silkscreen320x120, 320 * 120 * sizeof(uint16_t));
|
||||
}
|
||||
memset(palmAudio, 0x00, AUDIO_SAMPLES_PER_FRAME * 2/*channels*/ * sizeof(int16_t));
|
||||
memset(&palmInput, 0x00, sizeof(palmInput));
|
||||
memset(&palmMisc, 0x00, sizeof(palmMisc));
|
||||
palmMisc.batteryLevel = 100;
|
||||
palmCycleCounter = 0.0;
|
||||
palmClockMultiplier = (specialFeatures & FEATURE_FAST_CPU) ? 2.00 : 1.00;//overclock
|
||||
palmSpecialFeatures = specialFeatures;
|
||||
|
||||
//initialize components
|
||||
blip_set_rates(palmAudioResampler, AUDIO_CLOCK_RATE, AUDIO_SAMPLE_RATE);
|
||||
flx68000Init();
|
||||
sandboxInit();
|
||||
|
||||
//reset everything
|
||||
flx68000Reset();
|
||||
sed1376Reset();
|
||||
ads7846Reset();
|
||||
pdiUsbD12Reset();
|
||||
sdCardReset();
|
||||
sandboxInit();
|
||||
|
||||
memset(&palmInput, 0x00, sizeof(palmInput));
|
||||
memset(&palmMisc, 0x00, sizeof(palmMisc));
|
||||
palmMisc.batteryLevel = 100;
|
||||
|
||||
//config
|
||||
palmClockMultiplier = (specialFeatures & FEATURE_FAST_CPU) ? 2.00 : 1.00;//overclock
|
||||
//palmClockMultiplier *= 0.80;//run at 80% speed, 20% is likely memory waitstates
|
||||
palmSpecialFeatures = specialFeatures;
|
||||
setRtc(0, 0, 0, 0);//RTCTIME and DAYR are not cleared by reset, clear them manually in case the frontend doesnt set the RTC
|
||||
|
||||
emulatorInitialized = true;
|
||||
|
||||
17
src/sdCard.c
17
src/sdCard.c
@@ -34,8 +34,10 @@ static bool sdCardCmdIsCrcValid(uint64_t command){
|
||||
uint8_t crc = palmSdCard.command >> 1 & 0x7F;
|
||||
|
||||
//add real check
|
||||
if(true)
|
||||
return true;
|
||||
|
||||
return true;
|
||||
return false;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
@@ -53,8 +55,13 @@ bool sdCardExchangeBit(bool bit){
|
||||
|
||||
//make sure SD is actually plugged in
|
||||
if(palmSdCard.flashChip.data){
|
||||
#if !defined(EMU_NO_SAFETY)
|
||||
//check validity of incoming bit
|
||||
|
||||
#if defined(EMU_DEBUG)
|
||||
//since logs go to the debug window I can use the console to dump the raw SPI bitstream
|
||||
printf("%d", bit);
|
||||
#endif
|
||||
|
||||
//check validity of incoming bit, needed even when safety checks are disabled to determine command start
|
||||
switch(palmSdCard.commandBitsRemaining - 1){
|
||||
case 47:
|
||||
if(bit)
|
||||
@@ -67,6 +74,10 @@ bool sdCardExchangeBit(bool bit){
|
||||
sdCardCmdInvalidFormat();
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(EMU_DEBUG)
|
||||
//mark this bit as valid
|
||||
printf("V");
|
||||
#endif
|
||||
|
||||
//add the bit
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define SD_CARD_COMMAND_SPEC_HEADER
|
||||
/*SD Card Commands*/
|
||||
/*Command Format:01IIIIIIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACCCCCCC1*/
|
||||
/*I = index, A = argument, C = CRC*/
|
||||
/*48 bits, I = index, A = argument, C = CRC*/
|
||||
/*see http://elm-chan.org/docs/mmc/mmc_e.html for more command information*/
|
||||
|
||||
#define GO_IDLE_STATE 0/*software reset*/
|
||||
|
||||
Reference in New Issue
Block a user