mirror of
https://github.com/libretro/Mu.git
synced 2026-09-24 23:56:23 +00:00
Try to make c89 compliant and remove stdbool.h which conflicts with PalmOS.h
This commit is contained in:
@@ -13,7 +13,6 @@ PRC=$APPNAME.prc
|
||||
|
||||
SRCS="testSuite.c viewer.c ugui.c"
|
||||
DEFINES="-DHW_TEST"
|
||||
CSFLAGS="-O2 -S $DEFINES $INCLUDES"
|
||||
CFLAGS="-O2 -g $DEFINES $INCLUDES"
|
||||
|
||||
if [ "$1" = "clean" ]; then
|
||||
|
||||
9
hwTestSuite/readme.md
Normal file
9
hwTestSuite/readme.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# Palm OS Hardware Test Suite
|
||||
|
||||
The tests available in the end will be:
|
||||
Dump Bootloader(Original, EZ, VZ)
|
||||
Rom Writes
|
||||
|
||||
|
||||
## Warning
|
||||
The version of gcc avalible for Palm OS is very old, any change you make must be c89 compatible or it wont compile!
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <PalmOS.h>
|
||||
#include <PalmCompatibility.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "ugui.h"
|
||||
#include "testSuiteConfig.h"
|
||||
#include "testSuite.h"
|
||||
@@ -24,12 +23,57 @@
|
||||
#define FRCM *((unsigned char *)0xFFFFFA31)
|
||||
#define LGPMR *((unsigned short *)0xFFFFFA32)
|
||||
|
||||
//exports
|
||||
|
||||
/*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*)(thisVar.value & 0xFFFFFFFF);
|
||||
}
|
||||
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;
|
||||
}
|
||||
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 (palmButtonsLastFrame & button) && !(palmButtonsLastFrame & button);
|
||||
}
|
||||
Boolean getButtonReleased(uint16_t button){
|
||||
return !(palmButtonsLastFrame & button) && (palmButtonsLastFrame & button);
|
||||
}
|
||||
|
||||
|
||||
/*exports*/
|
||||
uint16_t palmButtons;
|
||||
uint16_t palmButtonsLastFrame;
|
||||
|
||||
|
||||
//video stuff
|
||||
/*video stuff*/
|
||||
static UG_GUI uguiStruct;
|
||||
static uint8_t* framebuffer;
|
||||
static uint8_t* oldFramebuffer;
|
||||
@@ -38,47 +82,47 @@ static uint8_t oldPicf;
|
||||
static uint8_t oldVpw;
|
||||
static uint8_t oldLlbar;
|
||||
|
||||
//other
|
||||
/*other*/
|
||||
static activity_t parentSubprograms[MAX_SUBPROGRAMS];
|
||||
static uint32_t subprogramIndex;
|
||||
static activity_t currentSubprogram;
|
||||
static var subprogramData[MAX_SUBPROGRAMS];
|
||||
static var subprogramArgs;//optional arguments when one subprogram calls another
|
||||
static bool subprogramArgsSet;
|
||||
static bool applicationRunning;
|
||||
static var subprogramArgs;/*optional arguments when one subprogram calls another*/
|
||||
static Boolean subprogramArgsSet;
|
||||
static Boolean applicationRunning;
|
||||
|
||||
|
||||
static var errorSubprogramStackOverflow(){
|
||||
static bool wipedScreen = false;
|
||||
static Boolean wipedScreen = false;
|
||||
if(!wipedScreen){
|
||||
UG_FillScreen(C_WHITE);
|
||||
UG_PutString(0, 0, "Subprogram stack overflow!\nYou must close the program.");
|
||||
wipedScreen = true;
|
||||
}
|
||||
if(getButtonPressed(buttonBack)){
|
||||
//force kill when back pressed
|
||||
/*force kill when back pressed*/
|
||||
applicationRunning = false;
|
||||
}
|
||||
//do nothing, this is a safe crash
|
||||
/*do nothing, this is a safe crash*/
|
||||
}
|
||||
|
||||
var memoryAllocationError(){
|
||||
static bool wipedScreen = false;
|
||||
static Boolean wipedScreen = false;
|
||||
if(!wipedScreen){
|
||||
UG_FillScreen(C_WHITE);
|
||||
UG_PutString(0, 0, "Could not allocate memory!\nYou must close the program.");
|
||||
wipedScreen = true;
|
||||
}
|
||||
if(getButtonPressed(buttonBack)){
|
||||
//force kill when back pressed
|
||||
/*force kill when back pressed*/
|
||||
applicationRunning = false;
|
||||
}
|
||||
//do nothing, this is a safe crash
|
||||
/*do nothing, this is a safe crash*/
|
||||
}
|
||||
|
||||
|
||||
void uguiDrawPixel(UG_S16 x, UG_S16 y, UG_COLOR color){
|
||||
//using 1bit grayscale
|
||||
/*using 1bit grayscale*/
|
||||
int pixel = x + y * SCREEN_WIDTH;
|
||||
int byte = pixel / 8;
|
||||
int bit = pixel % 8;
|
||||
@@ -97,11 +141,11 @@ void callSubprogram(activity_t activity){
|
||||
currentSubprogram = activity;
|
||||
if(!subprogramArgsSet)
|
||||
subprogramArgs = makeVar(LENGTH_0, TYPE_NULL, 0);
|
||||
subprogramArgsSet = false;//clear to prevent next subprogram called from inheriting the args
|
||||
subprogramArgsSet = false;/*clear to prevent next subprogram called from inheriting the args*/
|
||||
}
|
||||
else{
|
||||
currentSubprogram = errorSubprogramStackOverflow;
|
||||
//cant recover from this
|
||||
/*cant recover from this*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +155,7 @@ void exitSubprogram(){
|
||||
currentSubprogram = parentSubprograms[subprogramIndex];
|
||||
}
|
||||
else{
|
||||
//last subprogram is complete, exit application
|
||||
/*last subprogram is complete, exit application*/
|
||||
applicationRunning = false;
|
||||
}
|
||||
}
|
||||
@@ -199,7 +243,7 @@ DWord PilotMain(Word cmd, Ptr cmdBPB, Word launchFlags){
|
||||
applicationRunning = true;
|
||||
while(applicationRunning){
|
||||
testerFrameLoop();
|
||||
SysTaskDelay(4);//30 fps
|
||||
SysTaskDelay(4);/*30 fps*/
|
||||
}
|
||||
|
||||
testerExit();
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
#define TESTSUITE_HEADER
|
||||
|
||||
#include <PalmOS.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
//defines
|
||||
/*defines*/
|
||||
#define buttonLeft keyBitHard1
|
||||
#define buttonRight keyBitHard2
|
||||
#define buttonUp keyBitPageUp
|
||||
@@ -15,23 +14,23 @@
|
||||
#define buttonSelect keyBitHard4
|
||||
|
||||
#define TYPE_NULL 0x00
|
||||
#define TYPE_BOOL 0x01//bool can share with uint
|
||||
#define TYPE_BOOL 0x01/*bool can share with uint*/
|
||||
#define TYPE_UINT 0x01
|
||||
#define TYPE_INT 0x02
|
||||
#define TYPE_FLOAT 0x03
|
||||
#define TYPE_POINTER 0x04
|
||||
#define LENGTH_0 0x00//for null
|
||||
#define LENGTH_0 0x00/*for null*/
|
||||
#define LENGTH_1 0x10
|
||||
#define LENGTH_8 0x20
|
||||
#define LENGTH_16 0x30
|
||||
#define LENGTH_32 0x40
|
||||
#define LENGTH_64 0x50
|
||||
#define LENGTH_PTR 0x60//first half of 64bit value is length, second is pointer
|
||||
#define LENGTH_STR 0xF0//for pointers to string
|
||||
#define LENGTH_PTR 0x60/*first half of 64bit value is length, second is pointer*/
|
||||
#define LENGTH_STR 0xF0/*for pointers to string*/
|
||||
|
||||
|
||||
//types
|
||||
typedef uint64_t var_value;//can hold all other types
|
||||
/*types*/
|
||||
typedef uint64_t var_value;/*can hold all other types*/
|
||||
|
||||
typedef struct{
|
||||
uint8_t type;
|
||||
@@ -41,41 +40,58 @@ typedef struct{
|
||||
typedef var (*activity_t)();
|
||||
|
||||
typedef struct{
|
||||
bool isSimpleTest;//if simple run once, if complex take control over user input and runloop
|
||||
Boolean isSimpleTest;/*if simple run once, if complex take control over user input and runloop*/
|
||||
var expectedResult;
|
||||
activity_t callTest;
|
||||
}test_t;
|
||||
|
||||
|
||||
//variables
|
||||
/*variables*/
|
||||
extern uint16_t palmButtons;
|
||||
extern uint16_t palmButtonsLastFrame;
|
||||
|
||||
|
||||
//functions
|
||||
//no inline functions
|
||||
//old gcc versions have broken handling of inline functions where variables with the same name
|
||||
//inside the function and outside can result in the outside variable being written
|
||||
/*
|
||||
functions
|
||||
no inline functions
|
||||
old gcc versions have broken handling of inline functions where variables with the same name
|
||||
inside the function and outside can result in the outside variable being written
|
||||
c89 also doesnt support them
|
||||
*/
|
||||
/*
|
||||
#define getButton(button) ((palmButtons & button) != 0)
|
||||
#define getButtonLastFrame(button) ((palmButtonsLastFrame & button) != 0)
|
||||
#define getButtonChanged(button) (getButton(button) != getButtonLastFrame(button))
|
||||
#define getButtonPressed(button) (getButton(button) && !getButtonLastFrame(button));
|
||||
#define getButtonReleased(button) (!getButton(button) && getButtonLastFrame(button))
|
||||
#define getButtonChanged(button) ((palmButtons & button) != (palmButtonsLastFrame & button))
|
||||
#define getButtonPressed(button) ((palmButtons & button) && !(palmButtonsLastFrame & button));
|
||||
#define getButtonReleased(button) (!(palmButtons & button) && (palmButtonsLastFrame & button))
|
||||
|
||||
#define getVarType(thisVar) (thisVar.type & 0x0F)
|
||||
#define getVarLength(thisVar) (thisVar.type >> 4)
|
||||
#define getVarLength(thisVar) (thisVar.type & 0xF0)
|
||||
#define getVarDataLength(thisVar) (thisVar.value >> 32)
|
||||
#define getVarPointer(thisVar) (thisVar.value & 0xFFFFFFFF);
|
||||
#define getVarValue(thisVar) (thisVar.value);
|
||||
#define makeVar(length, type, value) {(uint8_t)((length & 0xF0) | (type & 0x0F)), (uint64_t)value}
|
||||
*/
|
||||
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);
|
||||
|
||||
uint8_t getVarType(var thisVar);
|
||||
uint8_t getVarLength(var thisVar);
|
||||
uint32_t getVarDataLength(var thisVar);
|
||||
void* getVarPointer(var thisVar);
|
||||
var_value getVarValue(var thisVar);
|
||||
var makeVar(uint8_t length, uint8_t type, uint64_t value);
|
||||
Boolean varsEqual(var var1, var var2);
|
||||
|
||||
void callSubprogram(activity_t activity);
|
||||
void exitSubprogram();
|
||||
void execSubprogram(activity_t activity);//replace current subprogram with a new one
|
||||
void execSubprogram(activity_t activity);/*replace current subprogram with a new one*/
|
||||
var getSubprogramArgs();
|
||||
void setSubprogramArgs(var args);
|
||||
var subprogramGetData();//for subprograms to get data they stored
|
||||
void subprogramSetData(var data);//for subprograms to save data when calling a new subprogram
|
||||
var subprogramGetData();/*for subprograms to get data they stored*/
|
||||
void subprogramSetData(var data);/*for subprograms to save data when calling a new subprogram*/
|
||||
|
||||
var memoryAllocationError();
|
||||
|
||||
|
||||
@@ -9,19 +9,19 @@
|
||||
|
||||
#define MAX_OBJECTS 50
|
||||
|
||||
#define TEXTBOX_PIXEL_MARGIN 1 //add 1 pixel border around text
|
||||
#define TEXTBOX_PIXEL_WIDTH (SCREEN_WIDTH / 4 * 3) //3/4 of the screen
|
||||
#define TEXTBOX_PIXEL_MARGIN 1 /*add 1 pixel border around text*/
|
||||
#define TEXTBOX_PIXEL_WIDTH (SCREEN_WIDTH / 4 * 3) /*3/4 of the screen*/
|
||||
#define TEXTBOX_PIXEL_HEIGHT (FONT_HEIGHT + (TEXTBOX_PIXEL_MARGIN * 2))
|
||||
#define TEXTBOX_DEFAULT_COLOR C_WHITE
|
||||
#define TEXTBOX_DEFAULT_TEXT_COLOR C_BLACK
|
||||
#define TEXTBOX_CURSOR_COLOR C_BLACK
|
||||
#define TEXTBOX_CURSOR_TEXT_COLOR C_WHITE
|
||||
|
||||
#define ITEM_listEntrys (SCREEN_HEIGHT / TEXTBOX_PIXEL_HEIGHT - 1)
|
||||
#define ITEM_LIST_ENTRYS (SCREEN_HEIGHT / TEXTBOX_PIXEL_HEIGHT - 1)
|
||||
#define ITEM_STRING_SIZE (TEXTBOX_PIXEL_WIDTH / (FONT_WIDTH + FONT_SPACING))
|
||||
|
||||
|
||||
bool viewerInitialized = false;
|
||||
Boolean viewerInitialized = false;
|
||||
int32_t listLength;
|
||||
int32_t selectedEntry;
|
||||
|
||||
@@ -29,9 +29,13 @@ UG_GUI fbGui;
|
||||
UG_WINDOW fbWindow;
|
||||
UG_OBJECT fbObjects[MAX_OBJECTS];
|
||||
UG_TEXTBOX listEntrys[ITEM_LIST_ENTRYS];
|
||||
char textboxString[ITEM_listEntrys][ITEM_STRING_SIZE];
|
||||
char textboxString[ITEM_LIST_ENTRYS][ITEM_STRING_SIZE];
|
||||
|
||||
|
||||
static void windowCallback(UG_MESSAGE* message){
|
||||
/*do nothing*/
|
||||
}
|
||||
|
||||
static void listModeFrame(){
|
||||
int32_t page;
|
||||
int32_t index;
|
||||
@@ -48,44 +52,44 @@ static void listModeFrame(){
|
||||
selectedEntry++;
|
||||
}
|
||||
|
||||
if (getButtonPressed(buttonLeft) && listLength > ITEM_listEntrys){
|
||||
if(selectedEntry - ITEM_listEntrys >= 0)
|
||||
selectedEntry -= ITEM_listEntrys;//flip the page
|
||||
if (getButtonPressed(buttonLeft) && listLength > ITEM_LIST_ENTRYS){
|
||||
if(selectedEntry - ITEM_LIST_ENTRYS >= 0)
|
||||
selectedEntry -= ITEM_LIST_ENTRYS;/*flip the page*/
|
||||
else
|
||||
selectedEntry = 0;
|
||||
}
|
||||
|
||||
if (getButtonPressed(buttonRight) && listLength > ITEM_listEntrys){
|
||||
if(selectedEntry + ITEM_listEntrys < listLength)
|
||||
selectedEntry += ITEM_listEntrys;//flip the page
|
||||
if (getButtonPressed(buttonRight) && listLength > ITEM_LIST_ENTRYS){
|
||||
if(selectedEntry + ITEM_LIST_ENTRYS < listLength)
|
||||
selectedEntry += ITEM_LIST_ENTRYS;/*flip the page*/
|
||||
else
|
||||
selectedEntry = listLength - 1;
|
||||
}
|
||||
|
||||
page = selectedEntry / ITEM_listEntrys;
|
||||
index = selectedEntry % ITEM_listEntrys;
|
||||
page = selectedEntry / ITEM_LIST_ENTRYS;
|
||||
index = selectedEntry % ITEM_LIST_ENTRYS;
|
||||
|
||||
/*
|
||||
if (page != last_page || index != last_index && list_handler){
|
||||
listLength = list_handler(page * ITEM_listEntrys);
|
||||
listLength = list_handler(page * ITEM_LIST_ENTRYS);
|
||||
}
|
||||
*/
|
||||
|
||||
if (getButtonPressed(buttonSelect)){
|
||||
//select
|
||||
//run_action(list_index_action[index]);
|
||||
//nothing yet
|
||||
/*select*/
|
||||
/*run_action(list_index_action[index]);*/
|
||||
/*nothing yet*/
|
||||
}
|
||||
|
||||
if (getButtonPressed(buttonBack)){
|
||||
//go back
|
||||
/*go back*/
|
||||
exitSubprogram();
|
||||
}
|
||||
|
||||
|
||||
if (index != lastIndex)
|
||||
{
|
||||
//update item colors
|
||||
/*update item colors*/
|
||||
UG_TextboxSetForeColor(&fbWindow, lastIndex, TEXTBOX_DEFAULT_TEXT_COLOR);
|
||||
UG_TextboxSetBackColor(&fbWindow, lastIndex, TEXTBOX_DEFAULT_COLOR);
|
||||
|
||||
@@ -103,14 +107,15 @@ static void listModeFrame(){
|
||||
var initViewer(){
|
||||
UG_RESULT passed = UG_WindowCreate(&fbWindow, fbObjects, MAX_OBJECTS, windowCallback);
|
||||
if (passed != UG_RESULT_OK)
|
||||
return {LENGTH_1 | TYPE_BOOL, false};
|
||||
return makeVar(LENGTH_1, TYPE_BOOL, false);
|
||||
|
||||
UG_WindowSetStyle(&fbWindow, WND_STYLE_HIDE_TITLE | WND_STYLE_2D);
|
||||
UG_WindowSetForeColor(&fbWindow, TEXTBOX_DEFAULT_TEXT_COLOR);
|
||||
UG_WindowSetBackColor(&fbWindow, TEXTBOX_DEFAULT_COLOR);
|
||||
|
||||
int newTextboxY = 0;
|
||||
for (int entry = 0; entry < ITEM_listEntrys; entry++)
|
||||
int entry;
|
||||
for (entry = 0; entry < ITEM_LIST_ENTRYS; entry++)
|
||||
{
|
||||
UG_TextboxCreate(&fbWindow, &listEntrys[entry], entry, 0/*x start*/, newTextboxY, TEXTBOX_PIXEL_WIDTH - 1/*x end*/, newTextboxY + TEXTBOX_PIXEL_HEIGHT - 1);
|
||||
UG_TextboxSetAlignment(&fbWindow, entry, ALIGN_CENTER);
|
||||
@@ -118,16 +123,16 @@ var initViewer(){
|
||||
UG_TextboxShow(&fbWindow, entry);
|
||||
newTextboxY += TEXTBOX_PIXEL_HEIGHT;
|
||||
}
|
||||
//set_main_window
|
||||
/*set_main_window*/
|
||||
UG_WindowShow(&fbWindow);
|
||||
return {LENGTH_1 | TYPE_BOOL, true};
|
||||
return makeVar(LENGTH_1, TYPE_BOOL, true);
|
||||
}
|
||||
|
||||
|
||||
var hexViewer(){
|
||||
if(!viewerInitialized){
|
||||
var passFail = initViewer();
|
||||
if(passFail != makeVar(LENGTH_1, TYPE_BOOL, true)){
|
||||
if(varsEqual(passFail, makeVar(LENGTH_1, TYPE_BOOL, true)){
|
||||
callSubprogram(memoryAllocationError);
|
||||
return makeVar(LENGTH_1, TYPE_BOOL, false);
|
||||
}
|
||||
@@ -139,7 +144,7 @@ var hexViewer(){
|
||||
|
||||
}
|
||||
|
||||
//make hex value list
|
||||
/*make hex value list*/
|
||||
|
||||
listModeFrame();
|
||||
|
||||
@@ -149,14 +154,14 @@ var hexViewer(){
|
||||
var testViewer(){
|
||||
if(!viewerInitialized){
|
||||
var passFail = initViewer();
|
||||
if(passFail != makeVar(LENGTH_1, TYPE_BOOL, true)){
|
||||
if(varsEqual(passFail, makeVar(LENGTH_1, TYPE_BOOL, true)){
|
||||
callSubprogram(memoryAllocationError);
|
||||
return makeVar(LENGTH_1, TYPE_BOOL, false);
|
||||
}
|
||||
viewerInitialized = true;
|
||||
}
|
||||
|
||||
//make test list
|
||||
/*make test list*/
|
||||
|
||||
listModeFrame();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user