mirror of
https://github.com/libretro/Mu.git
synced 2026-09-23 07:05:37 +00:00
function macros seem to work as long as they dont call eachother
Also add a shared buffer to reduce stack usage.
This commit is contained in:
@@ -12,52 +12,12 @@
|
||||
#include "TstSuiteRsc.h"
|
||||
|
||||
|
||||
/*functions that should be macros but are screwed up by c89*/
|
||||
uint8_t getVarType(var thisVar){
|
||||
return thisVar.type & 0x0F;
|
||||
}
|
||||
uint8_t getVarLength(var thisVar){
|
||||
return thisVar.type & 0xF0;
|
||||
}
|
||||
uint32_t getVarDataLength(var thisVar){
|
||||
return thisVar.value >> 32;
|
||||
}
|
||||
void* getVarPointer(var thisVar){
|
||||
return (void*)(uint32_t)(thisVar.value & 0xFFFFFFFF);
|
||||
}
|
||||
uint32_t getVarPointerSize(var thisVar){
|
||||
return thisVar.value >> 32;
|
||||
}
|
||||
var_value getVarValue(var thisVar){
|
||||
return thisVar.value;
|
||||
}
|
||||
var makeVar(uint8_t length, uint8_t type, uint64_t value){
|
||||
var newVar;
|
||||
newVar.type = (length & 0xF0) | (type & 0x0F);
|
||||
newVar.value = value;
|
||||
return newVar;
|
||||
}
|
||||
Boolean varsEqual(var var1, var var2){
|
||||
if(var1.type == var2.type && var1.value == var2.value)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
Boolean getButton(uint16_t button){
|
||||
return (palmButtons & button) != 0;
|
||||
}
|
||||
Boolean getButtonLastFrame(uint16_t button){
|
||||
return (palmButtonsLastFrame & button) != 0;
|
||||
}
|
||||
Boolean getButtonChanged(uint16_t button){
|
||||
return (palmButtons & button) != (palmButtonsLastFrame & button);
|
||||
}
|
||||
Boolean getButtonPressed(uint16_t button){
|
||||
return (palmButtons & button) && !(palmButtonsLastFrame & button);
|
||||
}
|
||||
Boolean getButtonReleased(uint16_t button){
|
||||
return !(palmButtons & button) && (palmButtonsLastFrame & button);
|
||||
}
|
||||
|
||||
uint8_t readArbitraryMemory8(uint32_t address){
|
||||
return *((uint8_t*)address);
|
||||
@@ -83,6 +43,7 @@ void writeArbitraryMemory32(uint32_t address, uint32_t value){
|
||||
uint16_t palmButtons;
|
||||
uint16_t palmButtonsLastFrame;
|
||||
Boolean unsafeMode;
|
||||
uint8_t* sharedDataBuffer;
|
||||
|
||||
|
||||
/*video stuff*/
|
||||
@@ -212,26 +173,27 @@ static Boolean testerInit(){
|
||||
Err error;
|
||||
|
||||
FtrGet(sysFtrCreator, sysFtrNumROMVersion, &osVer);
|
||||
|
||||
if (osVer < PalmOS35) {
|
||||
FrmCustomAlert(alt_err, "TestSuite requires at least PalmOS 3.5", 0, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
KeySetMask(~(keyBitPageUp | keyBitPageDown |
|
||||
keyBitHard1 | keyBitHard2 |
|
||||
keyBitHard3 | keyBitHard4 ));
|
||||
|
||||
WinSetActiveWindow(WinGetDisplayWindow());
|
||||
sharedDataBuffer = MemPtrNew(SHARED_DATA_BUFFER_SIZE);
|
||||
if(sharedDataBuffer == NULL){
|
||||
FrmCustomAlert(alt_err, "Cant create memory buffer", 0, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
offscreenBitmap = BmpCreate(SCREEN_WIDTH, SCREEN_HEIGHT, 1, NULL, &error);
|
||||
|
||||
if(error){
|
||||
FrmCustomAlert(alt_err, "Cant create bitmap", 0, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
KeySetMask(~(keyBitPageUp | keyBitPageDown | keyBitHard1 | keyBitHard2 | keyBitHard3 | keyBitHard4 ));
|
||||
|
||||
framebuffer = BmpGetBits(offscreenBitmap);
|
||||
WinSetActiveWindow(WinGetDisplayWindow());
|
||||
|
||||
UG_Init(&uguiStruct, uguiDrawPixel, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
UG_FontSelect(&FONT_8X8);
|
||||
@@ -241,12 +203,11 @@ static Boolean testerInit(){
|
||||
UG_ConsoleSetForecolor(C_BLACK);
|
||||
UG_FillScreen(C_WHITE);
|
||||
|
||||
unsafeMode = false;
|
||||
|
||||
/*make test list*/
|
||||
initViewer();
|
||||
|
||||
/*load first subprogram*/
|
||||
unsafeMode = false;
|
||||
subprogramIndex = 0;
|
||||
subprogramArgsSet = false;
|
||||
lastSubprogramReturnValue = makeVar(LENGTH_0, TYPE_NULL, 0);
|
||||
@@ -257,7 +218,7 @@ static Boolean testerInit(){
|
||||
}
|
||||
|
||||
static void testerExit(){
|
||||
/*nothing right now*/
|
||||
MemPtrFree(sharedDataBuffer);
|
||||
}
|
||||
|
||||
static void testerFrameLoop(){
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
|
||||
/*defines*/
|
||||
#define SHARED_DATA_BUFFER_SIZE 1000
|
||||
|
||||
#define PalmOS35 sysMakeROMVersion(3,5,0,sysROMStageRelease,0)
|
||||
#define PalmOS50 sysMakeROMVersion(5,0,0,sysROMStageRelease,0)
|
||||
|
||||
@@ -54,6 +56,7 @@ typedef struct{
|
||||
extern uint16_t palmButtons;
|
||||
extern uint16_t palmButtonsLastFrame;
|
||||
extern Boolean unsafeMode;
|
||||
extern uint8_t* sharedDataBuffer;
|
||||
|
||||
/*
|
||||
functions
|
||||
@@ -63,21 +66,20 @@ inside the function and outside can result in the outside variable being written
|
||||
c89 also doesnt support them
|
||||
*/
|
||||
/*hardware buttons*/
|
||||
Boolean getButton(uint16_t button);
|
||||
Boolean getButtonLastFrame(uint16_t button);
|
||||
Boolean getButtonChanged(uint16_t button);
|
||||
Boolean getButtonPressed(uint16_t button);
|
||||
Boolean getButtonReleased(uint16_t button);
|
||||
#define getButton(x) ((palmButtons & x) != 0)
|
||||
#define getButtonLastFrame(x) ((palmButtonsLastFrame & x) != 0)
|
||||
#define getButtonChanged(x) ((palmButtons & x) != (palmButtonsLastFrame & x))
|
||||
#define getButtonPressed(x) ((palmButtons & x) && !(palmButtonsLastFrame & x))
|
||||
#define getButtonReleased(x) (!(palmButtons & x) && (palmButtonsLastFrame & x))
|
||||
|
||||
/*var type operators*/
|
||||
uint8_t getVarType(var thisVar);
|
||||
uint8_t getVarLength(var thisVar);
|
||||
uint32_t getVarDataLength(var thisVar);
|
||||
void* getVarPointer(var thisVar);
|
||||
uint32_t getVarPointerSize(var thisVar);
|
||||
var_value getVarValue(var thisVar);
|
||||
var makeVar(uint8_t length, uint8_t type, uint64_t value);
|
||||
Boolean varsEqual(var var1, var var2);
|
||||
#define getVarType(x) (x.type & 0x0F)
|
||||
#define getVarValue(x) (x.value)
|
||||
#define getVarLength(x) (x.type & 0xF0)
|
||||
#define getVarPointer(x) ((void*)(uint32_t)(x.value & 0xFFFFFFFF))
|
||||
#define getVarDataLength(x) ((uint32_t)(x.value >> 32))
|
||||
#define varsEqual(x, y) (x.type == y.type && x.value == y.value)
|
||||
var makeVar(uint8_t length, uint8_t type, uint64_t value);
|
||||
|
||||
/*kernel memory access*/
|
||||
uint8_t readArbitraryMemory8(uint32_t address);
|
||||
|
||||
@@ -6,24 +6,24 @@
|
||||
|
||||
|
||||
Err makeFile(uint8_t* data, uint32_t size, char* fileName){
|
||||
FileHand file;
|
||||
Err error;
|
||||
uint8_t dataBuffer[100];//used to anonymize data source
|
||||
uint32_t count;
|
||||
FileHand file;
|
||||
Err error;
|
||||
uint32_t count;
|
||||
|
||||
file = FileOpen(0 /*cardNo*/, fileName, (uint32_t)'DATA', (uint32_t)'GuiC', fileModeReadWrite | fileModeAnyTypeCreator, &error);
|
||||
if(file == fileNullHandle || error)
|
||||
return error;
|
||||
|
||||
/*the copy is used to anonymize the data source*/
|
||||
count = size;
|
||||
while(count != 0){
|
||||
uint32_t chunkSize = count > 100 ? 100 : count;
|
||||
uint32_t chunkSize = count > SHARED_DATA_BUFFER_SIZE ? SHARED_DATA_BUFFER_SIZE : count;
|
||||
int32_t bytesWritten;
|
||||
uint32_t i;
|
||||
for(i = 0; i < chunkSize; i++){
|
||||
dataBuffer[i] = data[i + size - count];
|
||||
sharedDataBuffer[i] = data[i + size - count];
|
||||
}
|
||||
bytesWritten = FileWrite(file, dataBuffer, 1, chunkSize, &error);
|
||||
bytesWritten = FileWrite(file, sharedDataBuffer, 1, chunkSize, &error);
|
||||
if(bytesWritten != chunkSize || error)
|
||||
return error;
|
||||
count -= chunkSize;
|
||||
@@ -39,7 +39,6 @@ var hexRamBrowser(){
|
||||
static Boolean clearScreen = true;
|
||||
static uint32_t nibble = UINT32_C(0x10000000);
|
||||
static uint32_t pointerValue = UINT32_C(0x77777777);/*in the middle of the address space*/
|
||||
static char hexString[100];
|
||||
|
||||
if(getButtonPressed(buttonUp)){
|
||||
pointerValue += nibble;
|
||||
@@ -78,8 +77,8 @@ var hexRamBrowser(){
|
||||
clearScreen = false;
|
||||
}
|
||||
|
||||
StrPrintF(hexString, "Open Hex Viewer At:\n0x%08lX", pointerValue);
|
||||
UG_PutString(0, 0, hexString);
|
||||
StrPrintF(sharedDataBuffer, "Open Hex Viewer At:\n0x%08lX", pointerValue);
|
||||
UG_PutString(0, 0, sharedDataBuffer);
|
||||
|
||||
return makeVar(LENGTH_0, TYPE_NULL, 0);
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ var hexViewer(){
|
||||
var where = getSubprogramArgs();
|
||||
|
||||
resetListHandler();
|
||||
listLength = getVarPointerSize(where);
|
||||
listLength = getVarDataLength(where);
|
||||
if(listLength){
|
||||
/*displaying a result buffer*/
|
||||
selectedEntry = 0;
|
||||
|
||||
Reference in New Issue
Block a user