mirror of
https://github.com/libretro/Mu.git
synced 2026-09-24 23:56:23 +00:00
Start adding SD command parsing
This commit is contained in:
@@ -5,7 +5,7 @@ Nothing can be installed(theres no memory card, hotsync emulation or direct inst
|
||||
When running OS commands through callFunction() it can crash
|
||||
Holding the buttons emulates pressing them like a turbo button(may be caused by the lack of sound emulation, a sound plays on app switch and may block the CPU while waiting for the button to release)
|
||||
State manager goes bezerk and crashes when saving on android, also can't close the window or it won't open again(also only on Android)
|
||||
If there is no userdata-en-m515.ram on Android the emu won't create it
|
||||
If there is no userdata-en-m515.ram on Android the emu won't create it(this is likely because theres no graceful exit being done on Android only goto home menu and kill process)
|
||||
|
||||
Fixed:
|
||||
Only runs in debug mode because the touchscreen can only be pushed with a jump to OS function hack
|
||||
|
||||
@@ -104,8 +104,7 @@ bool ads7846ExchangeBit(bool bitIn){
|
||||
ads7846ControlByte <<= 1;
|
||||
ads7846ControlByte |= bitIn;
|
||||
}
|
||||
|
||||
if(ads7846BitsToNextControl == 6){
|
||||
else if(ads7846BitsToNextControl == 6){
|
||||
//control byte and busy cycle finished, get output value
|
||||
bool bitMode = ads7846ControlByte & 0x08;
|
||||
//bool differentialMode = !(ads7846ControlByte & 0x04);
|
||||
|
||||
@@ -106,7 +106,7 @@ uint32_t emulatorInit(buffer_t palmRomDump, buffer_t palmBootDump, uint32_t spec
|
||||
|
||||
//config
|
||||
palmClockMultiplier = (specialFeatures & FEATURE_FAST_CPU) ? 2.0 : 1.0;//overclock
|
||||
palmClockMultiplier *= 0.80;//run at 80% speed, 20% is likely memory waitstates, at 100% it crashes on the spinning Palm welcome screen, 90% works though
|
||||
palmClockMultiplier *= 0.80;//run at 80% speed, 20% is likely memory waitstates, at 100% it crashes on the spinning Palm welcome screen, 90% crashes at the digitizer test
|
||||
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
|
||||
|
||||
@@ -170,7 +170,8 @@ uint64_t emulatorGetStateSize(){
|
||||
size += sizeof(uint16_t) * 9;//TX 8 * 16 SPI1 FIFO, 1 index is for FIFO full
|
||||
size += sizeof(uint8_t) * 4;//spi1(R/T)x(Read/Write)Position
|
||||
size += sizeof(uint8_t) * 7;//palmMisc
|
||||
size += sizeof(uint8_t);//palmSdCard.response
|
||||
size += sizeof(uint32_t);//palmSdCard.command
|
||||
size += sizeof(uint8_t) * 2;//palmSdCard.response / palmSdCard.commandBitsRemaining
|
||||
size += sizeof(palmSdCard.dataPacket);//palmSdCard.dataPacket
|
||||
size += palmSdCard.flashChip.size;//palmSdCard.flashChip.data
|
||||
|
||||
@@ -294,6 +295,10 @@ bool emulatorSaveState(buffer_t buffer){
|
||||
offset += sizeof(uint8_t);
|
||||
|
||||
//SD card
|
||||
writeStateValueUint32(buffer.data + offset, palmSdCard.command);
|
||||
offset += sizeof(uint32_t);
|
||||
writeStateValueUint8(buffer.data + offset, palmSdCard.commandBitsRemaining);
|
||||
offset += sizeof(uint8_t);
|
||||
writeStateValueUint8(buffer.data + offset, palmSdCard.response);
|
||||
offset += sizeof(uint8_t);
|
||||
memcpy(buffer.data + offset, palmSdCard.dataPacket, sizeof(palmSdCard.dataPacket));
|
||||
@@ -423,6 +428,10 @@ bool emulatorLoadState(buffer_t buffer){
|
||||
offset += sizeof(uint8_t);
|
||||
|
||||
//SD card
|
||||
palmSdCard.command = readStateValueUint32(buffer.data + offset);
|
||||
offset += sizeof(uint32_t);
|
||||
palmSdCard.commandBitsRemaining = readStateValueUint8(buffer.data + offset);
|
||||
offset += sizeof(uint8_t);
|
||||
palmSdCard.response = readStateValueUint8(buffer.data + offset);
|
||||
offset += sizeof(uint8_t);
|
||||
memcpy(palmSdCard.dataPacket, buffer.data + offset, sizeof(palmSdCard.dataPacket));
|
||||
|
||||
@@ -91,8 +91,14 @@ typedef struct{
|
||||
}input_t;
|
||||
|
||||
typedef struct{
|
||||
//CPU -> SD
|
||||
uint64_t command;
|
||||
uint8_t commandBitsRemaining;
|
||||
|
||||
//SD -> CPU
|
||||
uint8_t response;
|
||||
uint8_t dataPacket[1 + 2048 + 2];
|
||||
|
||||
buffer_t flashChip;
|
||||
}sd_card_t;
|
||||
|
||||
|
||||
41
src/sdCard.c
41
src/sdCard.c
@@ -4,7 +4,48 @@
|
||||
#include "emulator.h"
|
||||
|
||||
|
||||
//command format:01IIIIIIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACCCCCCC1//I = index, A = argument, C = CRC
|
||||
|
||||
static inline void sdCardInvalidFormat(){
|
||||
palmSdCard.commandBitsRemaining = 63;
|
||||
}
|
||||
|
||||
|
||||
bool sdCardExchangeBit(bool bit){
|
||||
//check validity of incoming bit
|
||||
switch(palmSdCard.commandBitsRemaining){
|
||||
case 47:
|
||||
if(bit)
|
||||
sdCardInvalidFormat();
|
||||
return true;
|
||||
|
||||
case 46:
|
||||
case 0:
|
||||
if(!bit)
|
||||
sdCardInvalidFormat();
|
||||
return true;
|
||||
}
|
||||
|
||||
if(palmSdCard.commandBitsRemaining == 0){
|
||||
//process command
|
||||
uint8_t command = palmSdCard.command >> 40 & 0x3F;
|
||||
uint32_t argument = palmSdCard.command >> 8 & 0xFFFFFFFF;
|
||||
uint8_t crc = palmSdCard.command >> 1 & 0x7F;
|
||||
|
||||
switch(command){
|
||||
|
||||
default:
|
||||
debugLog("SD command:cmd:0x%02X, arg:0x%08X, CRC:0x%02X\n", command, argument, crc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else{
|
||||
//more data still needed
|
||||
palmSdCard.command <<= 1;
|
||||
palmSdCard.command |= bit;
|
||||
palmSdCard.commandBitsRemaining--;
|
||||
}
|
||||
|
||||
//not done
|
||||
return true;//eek
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user