Check if sed1376 clock is connected before reading or writing its addresses

Also start boot loader dumper
This commit is contained in:
meepingsnesroms
2018-03-30 10:49:53 -07:00
parent 5cf299d8ba
commit 6d5d7791cb
21 changed files with 143 additions and 17 deletions

View File

@@ -78,7 +78,7 @@ void emulatorInit(uint8_t* palmRomDump, uint16_t specialFeatures){
palmMisc.batteryLevel = 100;
//config
palmClockMultiplier = 1.0;//Overclock disabled
palmClockMultiplier = (specialFeatures & INACCURATE_FAST_CPU) ? 2.0 : 1.0;//Overclock disabled
//start running
m68k_pulse_reset();

View File

@@ -41,13 +41,14 @@ typedef struct{
uint8_t batteryLevel;
}misc_hw_t;
//special features, these make the emulator inaccurate in a good way, but still inaccurate and are therefore optional, they dont do anything yet
//special features, these make the emulator inaccurate in a good way, but still inaccurate and are therefore optional
#define ACCURATE 0x0000//no hacks/addons
#define INACCURATE_RAM_HUGE 0x0001//128 mb ram
#define INACCURATE_FAST_CPU 0x0002//doubles cpu speed
#define INACCURATE_HYBRID_CPU 0x0004//allows running arm opcodes in an OS 4 enviroment
#define INACCURATE_320x320 0x0008//creates a 320x320 frambuffer for hires mode, the 320x320 framebuffer is a transparent overlay over the 160x160 one and covers it where its pixels are enabled
#define INACCURATE_SYNCED_RTC 0x0010//rtc always equals host system time
#define INACCURATE_HLE_APIS 0x0020//memcpy, memcmp, wait on timer will be replaced with the hosts function
//config options
#define EMU_FPS 60.0

View File

@@ -658,6 +658,11 @@ int interruptAcknowledge(int intLevel){
return vector;
}
bool sed1376ClockConnected(){
//this is the clock output pin for the sed1376, if its disabled so is the lcd controller
return !(registerArrayRead8(PFSEL) & 0x04);
}
unsigned int getHwRegister8(unsigned int address){
switch(address){

View File

@@ -46,7 +46,8 @@ void clk32();//also checks all interrupts
//cpu
bool cpuIsOn();
int interruptAcknowledge(int intLevel);
int interruptAcknowledge(int intLevel);
bool sed1376ClockConnected();
//config
void resetHwRegisters();

View File

@@ -16,9 +16,9 @@ unsigned int m68k_read_memory_8(unsigned int address){
return palmRom[address - ROM_START_ADDRESS];
else if(address >= REG_START_ADDRESS && address < REG_START_ADDRESS + REG_SIZE)
return getHwRegister8(address - REG_START_ADDRESS);
else if(address >= SED1376_REG_START_ADDRESS && address < SED1376_REG_START_ADDRESS + SED1376_REG_SIZE)
else if(address >= SED1376_REG_START_ADDRESS && address < SED1376_REG_START_ADDRESS + SED1376_REG_SIZE && sed1376ClockConnected())
return sed1376GetRegister(address - SED1376_REG_START_ADDRESS);
else if(address >= SED1376_FB_START_ADDRESS && address < SED1376_FB_START_ADDRESS + SED1376_FB_SIZE)
else if(address >= SED1376_FB_START_ADDRESS && address < SED1376_FB_START_ADDRESS + SED1376_FB_SIZE && sed1376ClockConnected())
printf("Attempted 8 bit read on sed1376 framebuffer at 0x%08X.\n", address - SED1376_FB_START_ADDRESS);
//printf("Invalid 8 bit read at 0x%08X.\n", address);
@@ -33,9 +33,9 @@ unsigned int m68k_read_memory_16(unsigned int address){
return palmRom[address - ROM_START_ADDRESS] << 8 | palmRom[address - ROM_START_ADDRESS + 1];
else if(address >= REG_START_ADDRESS && address < REG_START_ADDRESS + REG_SIZE)
return getHwRegister16(address - REG_START_ADDRESS);
else if(address >= SED1376_REG_START_ADDRESS && address < SED1376_REG_START_ADDRESS + SED1376_REG_SIZE)
else if(address >= SED1376_REG_START_ADDRESS && address < SED1376_REG_START_ADDRESS + SED1376_REG_SIZE && sed1376ClockConnected())
return sed1376GetRegister(address - SED1376_REG_START_ADDRESS);
else if(address >= SED1376_FB_START_ADDRESS && address < SED1376_FB_START_ADDRESS + SED1376_FB_SIZE)
else if(address >= SED1376_FB_START_ADDRESS && address < SED1376_FB_START_ADDRESS + SED1376_FB_SIZE && sed1376ClockConnected())
printf("Attempted 16 bit read on sed1376 framebuffer at 0x%08X.\n", address - SED1376_FB_START_ADDRESS);
//printf("Invalid 16 bit read at 0x%08X.\n", address);
@@ -50,9 +50,9 @@ unsigned int m68k_read_memory_32(unsigned int address){
return palmRom[address - ROM_START_ADDRESS] << 24 | palmRom[address - ROM_START_ADDRESS + 1] << 16 | palmRom[address - ROM_START_ADDRESS + 2] << 8 | palmRom[address - ROM_START_ADDRESS + 3];
else if(address >= REG_START_ADDRESS && address < REG_START_ADDRESS + REG_SIZE)
return getHwRegister32(address - REG_START_ADDRESS);
else if(address >= SED1376_REG_START_ADDRESS && address < SED1376_REG_START_ADDRESS + SED1376_REG_SIZE)
else if(address >= SED1376_REG_START_ADDRESS && address < SED1376_REG_START_ADDRESS + SED1376_REG_SIZE && sed1376ClockConnected())
return sed1376GetRegister(address - SED1376_REG_START_ADDRESS);
else if(address >= SED1376_FB_START_ADDRESS && address < SED1376_FB_START_ADDRESS + SED1376_FB_SIZE)
else if(address >= SED1376_FB_START_ADDRESS && address < SED1376_FB_START_ADDRESS + SED1376_FB_SIZE && sed1376ClockConnected())
printf("Attempted 32 bit read on sed1376 framebuffer at 0x%08X.\n", address - SED1376_FB_START_ADDRESS);
//printf("Invalid 32 bit read at 0x%08X.\n", address);
@@ -72,10 +72,10 @@ void m68k_write_memory_8(unsigned int address, unsigned int value){
else if(address >= REG_START_ADDRESS && address < REG_START_ADDRESS + REG_SIZE){
setHwRegister8(address - REG_START_ADDRESS, value);
}
else if(address >= SED1376_REG_START_ADDRESS && address < SED1376_REG_START_ADDRESS + SED1376_REG_SIZE){
else if(address >= SED1376_REG_START_ADDRESS && address < SED1376_REG_START_ADDRESS + SED1376_REG_SIZE && sed1376ClockConnected()){
sed1376SetRegister(address - SED1376_REG_START_ADDRESS, value);
}
else if(address >= SED1376_FB_START_ADDRESS && address < SED1376_FB_START_ADDRESS + SED1376_FB_SIZE){
else if(address >= SED1376_FB_START_ADDRESS && address < SED1376_FB_START_ADDRESS + SED1376_FB_SIZE && sed1376ClockConnected()){
printf("Attempted 8 bit write on sed1376 framebuffer at 0x%08X with value of 0x%02X.\n", address - SED1376_FB_START_ADDRESS, value);
}
else{
@@ -95,10 +95,10 @@ void m68k_write_memory_16(unsigned int address, unsigned int value){
else if(address >= REG_START_ADDRESS && address < REG_START_ADDRESS + REG_SIZE){
setHwRegister16(address - REG_START_ADDRESS, value);
}
else if(address >= SED1376_REG_START_ADDRESS && address < SED1376_REG_START_ADDRESS + SED1376_REG_SIZE){
else if(address >= SED1376_REG_START_ADDRESS && address < SED1376_REG_START_ADDRESS + SED1376_REG_SIZE && sed1376ClockConnected()){
sed1376SetRegister(address - SED1376_REG_START_ADDRESS, value & 0xFF);
}
else if(address >= SED1376_FB_START_ADDRESS && address < SED1376_FB_START_ADDRESS + SED1376_FB_SIZE){
else if(address >= SED1376_FB_START_ADDRESS && address < SED1376_FB_START_ADDRESS + SED1376_FB_SIZE && sed1376ClockConnected()){
printf("Attempted 16 bit write on sed1376 framebuffer at 0x%08X with value of 0x%04X.\n", address - SED1376_FB_START_ADDRESS, value);
}
else{
@@ -120,10 +120,10 @@ void m68k_write_memory_32(unsigned int address, unsigned int value){
else if(address >= REG_START_ADDRESS && address < REG_START_ADDRESS + REG_SIZE){
setHwRegister32(address - REG_START_ADDRESS, value);
}
else if(address >= SED1376_REG_START_ADDRESS && address < SED1376_REG_START_ADDRESS + SED1376_REG_SIZE){
else if(address >= SED1376_REG_START_ADDRESS && address < SED1376_REG_START_ADDRESS + SED1376_REG_SIZE && sed1376ClockConnected()){
sed1376SetRegister(address - SED1376_REG_START_ADDRESS, value & 0xFF);
}
else if(address >= SED1376_FB_START_ADDRESS && address < SED1376_FB_START_ADDRESS + SED1376_FB_SIZE){
else if(address >= SED1376_FB_START_ADDRESS && address < SED1376_FB_START_ADDRESS + SED1376_FB_SIZE && sed1376ClockConnected()){
printf("Attempted 32 bit write on sed1376 framebuffer at 0x%08X with value of 0x%08X.\n", address - SED1376_FB_START_ADDRESS, value);
}
else{
@@ -149,11 +149,11 @@ void m68k_write_memory_32_pd(unsigned int address, unsigned int value){
//I dont know the interaction between the hw registers and the malformed opcode
printf("Possibly fatal error: Predecrement swaped 32bit write to hw register: 0x%08X, at PC: 0x%08X\n", address, m68k_get_reg(NULL, M68K_REG_PC));
}
else if(address >= SED1376_REG_START_ADDRESS && address < SED1376_REG_START_ADDRESS + SED1376_REG_SIZE){
else if(address >= SED1376_REG_START_ADDRESS && address < SED1376_REG_START_ADDRESS + SED1376_REG_SIZE && sed1376ClockConnected()){
//I dont know the interaction between sed1376 registers and the malformed opcode
printf("Predecrement swapped 32 bit write at sed1376 register 0x%08X with value of 0x%08X.\n", address - SED1376_REG_START_ADDRESS, value);
}
else if(address >= SED1376_FB_START_ADDRESS && address < SED1376_FB_START_ADDRESS + SED1376_FB_SIZE){
else if(address >= SED1376_FB_START_ADDRESS && address < SED1376_FB_START_ADDRESS + SED1376_FB_SIZE && sed1376ClockConnected()){
printf("Attempted 32 bit predecrement swapped write on sed1376 framebuffer at 0x%08X with value of 0x%08X.\n", address - SED1376_FB_START_ADDRESS, value);
}
else{

View File

@@ -0,0 +1,48 @@
APPNAME = BootExtract
ICONTEXT = "VZBootEX"
APPID = Bdmp
SRCS = bootloaderExtractor.c
# Tool locations
CC = m68k-palmos-gcc -palmos3.5
BUILDPRC = build-prc
PILRC = pilrc
OBJRES = m68k-palmos-obj-res
# File names
RESFILE = $(APPNAME).rcp
PRC = ../$(APPNAME).prc
OBJS = $(SRCS:.c=.o)
# Compile options
DEFINES = -DHW_TEST
CSFLAGS = -O2 -S $(DEFINES) $(INCLUDES)
CFLAGS = -O2 -g $(DEFINES) $(INCLUDES)
# Makefile targets
all:
.S.o:
$(CC) $(TARGETFLAGS) -c $<
.c.s:
$(CC) $(CSFLAGS) $<
$(PRC): code.stamp bin.stamp
$(BUILDPRC) $@ $(ICONTEXT) $(APPID) *.grc *.bin
code.stamp: $(APPNAME)
$(OBJRES) $(APPNAME)
touch code.stamp
bin.stamp: $(RESFILE)
$(PILRC) $(RESFILE)
touch bin.stamp
$(APPNAME): $(OBJS)
$(CC) $(CFLAGS) $(OBJS) $(LIBS) -o $@
clean::
rm -rf *.[oa] $(APPNAME) *.bin *.stamp *.grc *~

View File

@@ -0,0 +1,71 @@
#include <PalmOS.h>
//#include <PalmCompatibility.h>
//#include <System/DLServer.h>
static Boolean StartApplication(void);
static void EventLoop(void);
static Boolean MyHandleEvent(EventType* event){
return false;
}
/////////////////////////
// EventLoop
/////////////////////////
static void EventLoop(void){
EventType event;
Word error;
do{
EvtGetEvent(&event, 1);
if(!SysHandleEvent(&event)){
if(!MenuHandleEvent(0, &event, &error)){
if(!MyHandleEvent(&event)){
FrmDispatchEvent(&event);
}
}
}
}
while(event.eType != appStopEvent);
}
/************************************************************/
/** global init and cleanup */
static Boolean StartApplication(void) {
/* Mask hardware keys */
KeySetMask(~(keyBitPageUp | keyBitPageDown |
keyBitHard1 | keyBitHard2 |
keyBitHard3 | keyBitHard4 ));
SysRandom(TimGetTicks());
return true;
}
static void StopApplication(void){
}
/////////////////////////
// PilotMain
/////////////////////////
DWord PilotMain(Word cmd, Ptr cmdBPB, Word launchFlags){
if (cmd == sysAppLaunchCmdNormalLaunch){
if(StartApplication()){
EventLoop();
StopApplication();
}
}
return(0);
}