mirror of
https://github.com/autc04/Retro68.git
synced 2024-12-13 18:34:45 +00:00
Switch tab-indented files to 4-space indent
This commit is contained in:
parent
9cb90cb3b0
commit
e5185d23c3
@ -6,6 +6,9 @@ indent_style = space
|
||||
tab_width = 4
|
||||
charset = utf-8
|
||||
|
||||
[InterfacesAndLibraries/**/*]
|
||||
indent_style = tab
|
||||
|
||||
[gcc/**/*]
|
||||
indent_style = tab
|
||||
tab_width = 8
|
||||
@ -16,5 +19,15 @@ indent_style = tab
|
||||
tab_width = 8
|
||||
indent_width = 2
|
||||
|
||||
[libelf/**/*]
|
||||
indent_style = tab
|
||||
tab_width = 8
|
||||
indent_width = 2
|
||||
|
||||
[hfsutils/**/*]
|
||||
indent_style = tab
|
||||
tab_width = 8
|
||||
indent_width = 2
|
||||
|
||||
[**/Makefile]
|
||||
indent_style=tab
|
||||
|
@ -1,20 +1,20 @@
|
||||
find_program(LAUNCH_APPL LaunchAPPL PATH "${CMAKE_INSTALL_PREFIX}/../bin/")
|
||||
execute_process(COMMAND ${LAUNCH_APPL} --list-emulators
|
||||
OUTPUT_VARIABLE EMULATOR_LIST)
|
||||
OUTPUT_VARIABLE EMULATOR_LIST)
|
||||
string(REPLACE "\n" ";" EMULATOR_LIST "${EMULATOR_LIST}")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "RetroCarbon")
|
||||
if("carbon" IN_LIST EMULATOR_LIST)
|
||||
set(RETRO68_LAUNCH_METHOD carbon CACHE STRING "How to launch Mac applications (for automated testing)")
|
||||
else()
|
||||
set(RETRO68_LAUNCH_METHOD NONE CACHE STRING "How to launch Mac applications (for automated testing)")
|
||||
endif()
|
||||
if("carbon" IN_LIST EMULATOR_LIST)
|
||||
set(RETRO68_LAUNCH_METHOD carbon CACHE STRING "How to launch Mac applications (for automated testing)")
|
||||
else()
|
||||
set(RETRO68_LAUNCH_METHOD NONE CACHE STRING "How to launch Mac applications (for automated testing)")
|
||||
endif()
|
||||
else()
|
||||
if("classic" IN_LIST EMULATOR_LIST)
|
||||
set(RETRO68_LAUNCH_METHOD classic CACHE STRING "How to launch Mac applications (for automated testing)")
|
||||
else()
|
||||
set(RETRO68_LAUNCH_METHOD NONE CACHE STRING "How to launch Mac applications (for automated testing)")
|
||||
endif()
|
||||
if("classic" IN_LIST EMULATOR_LIST)
|
||||
set(RETRO68_LAUNCH_METHOD classic CACHE STRING "How to launch Mac applications (for automated testing)")
|
||||
else()
|
||||
set(RETRO68_LAUNCH_METHOD NONE CACHE STRING "How to launch Mac applications (for automated testing)")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "RetroCarbon")
|
||||
@ -33,17 +33,17 @@ set(LAUNCH_METHOD_FLAG)
|
||||
if(RETRO68_LAUNCH_METHOD MATCHES "NONE")
|
||||
else()
|
||||
set(LAUNCH_METHOD_FLAG "-e${RETRO68_LAUNCH_METHOD}")
|
||||
endif() # RETRO68_LAUNCH_METHOD
|
||||
endif() # RETRO68_LAUNCH_METHOD
|
||||
|
||||
enable_testing()
|
||||
|
||||
|
||||
|
||||
function(test FILE)
|
||||
get_filename_component(NAME ${FILE} NAME_WE)
|
||||
get_filename_component(NAME ${FILE} NAME_WE)
|
||||
add_application(${NAME} ${FILE} Test.h Test.c)
|
||||
target_include_directories(${NAME} PRIVATE .)
|
||||
add_test(NAME ${TESTCASE_PREFIX}${NAME} COMMAND ${LAUNCH_APPL}
|
||||
add_test(NAME ${TESTCASE_PREFIX}${NAME} COMMAND ${LAUNCH_APPL}
|
||||
${LAUNCH_METHOD_FLAG} ${RETRO68_TEST_CONFIG} ${NAME}.bin)
|
||||
if(ARGN)
|
||||
set_tests_properties(${TESTCASE_PREFIX}${NAME} ${ARGN})
|
||||
@ -51,8 +51,8 @@ function(test FILE)
|
||||
endfunction()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Retro68")
|
||||
test(ReallyEmpty.c)
|
||||
set_target_properties(ReallyEmpty PROPERTIES LINK_FLAGS "-Wl,-gc-sections -Wl,--mac-single")
|
||||
test(ReallyEmpty.c)
|
||||
set_target_properties(ReallyEmpty PROPERTIES LINK_FLAGS "-Wl,-gc-sections -Wl,--mac-single")
|
||||
endif()
|
||||
|
||||
test(Empty.c)
|
||||
@ -70,10 +70,10 @@ test(Init.cc PROPERTIES PASS_REGULAR_EXPRESSION "constructor\nmain\ndestructor")
|
||||
test(StdIO.c PROPERTIES PASS_REGULAR_EXPRESSION "OK")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES Retro68)
|
||||
add_application(Segments Segment1.c Segment2.c Segments.segmap Test.h Test.c)
|
||||
set_target_properties(Segments PROPERTIES
|
||||
LINK_FLAGS "-Wl,-gc-sections -Wl,--mac-segments -Wl,${CMAKE_CURRENT_SOURCE_DIR}/Segments.segmap")
|
||||
add_test(NAME ${TESTCASE_PREFIX}Segments COMMAND ${LAUNCH_APPL}
|
||||
add_application(Segments Segment1.c Segment2.c Segments.segmap Test.h Test.c)
|
||||
set_target_properties(Segments PROPERTIES
|
||||
LINK_FLAGS "-Wl,-gc-sections -Wl,--mac-segments -Wl,${CMAKE_CURRENT_SOURCE_DIR}/Segments.segmap")
|
||||
add_test(NAME ${TESTCASE_PREFIX}Segments COMMAND ${LAUNCH_APPL}
|
||||
${LAUNCH_METHOD_FLAG} ${RETRO68_TEST_CONFIG} Segments.bin)
|
||||
endif()
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
int main()
|
||||
{
|
||||
// Test: do things work well enough for us to get to main()?
|
||||
return 0;
|
||||
// Test: do things work well enough for us to get to main()?
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,5 +2,5 @@
|
||||
|
||||
int main()
|
||||
{
|
||||
TEST_LOG_OK();
|
||||
TEST_LOG_OK();
|
||||
}
|
||||
|
@ -3,20 +3,20 @@
|
||||
class Constructed
|
||||
{
|
||||
public:
|
||||
Constructed()
|
||||
{
|
||||
TestLog("constructor");
|
||||
}
|
||||
~Constructed()
|
||||
{
|
||||
TestLog("destructor");
|
||||
}
|
||||
Constructed()
|
||||
{
|
||||
TestLog("constructor");
|
||||
}
|
||||
~Constructed()
|
||||
{
|
||||
TestLog("destructor");
|
||||
}
|
||||
};
|
||||
|
||||
Constructed thing;
|
||||
|
||||
int main()
|
||||
{
|
||||
TestLog("main");
|
||||
return 0;
|
||||
TestLog("main");
|
||||
return 0;
|
||||
}
|
||||
|
@ -4,10 +4,10 @@ char readWriteData[6] = "Three";
|
||||
|
||||
int main()
|
||||
{
|
||||
// constant initialized data
|
||||
TEST_LOG_SIZED("One",3);
|
||||
TEST_LOG_SIZED("Two",3);
|
||||
// read-write initialized data
|
||||
TEST_LOG_SIZED(readWriteData,5);
|
||||
return 0;
|
||||
// constant initialized data
|
||||
TEST_LOG_SIZED("One",3);
|
||||
TEST_LOG_SIZED("Two",3);
|
||||
// read-write initialized data
|
||||
TEST_LOG_SIZED(readWriteData,5);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
void _start()
|
||||
{
|
||||
// Test: do things work well enough for us to get to a startup function?
|
||||
// Note: this won't work for multisegment 68K apps, as the startup function will be in the wrong segment.
|
||||
// Test: do things work well enough for us to get to a startup function?
|
||||
// Note: this won't work for multisegment 68K apps, as the startup function will be in the wrong segment.
|
||||
}
|
||||
|
||||
|
@ -10,87 +10,87 @@ void Bar();
|
||||
|
||||
Boolean Test(Boolean unloadFoo, Boolean unloadBar, Boolean compact)
|
||||
{
|
||||
variable = 6;
|
||||
Foo();
|
||||
if(variable != 54)
|
||||
{
|
||||
TestLog("Expected 54 after Foo().");
|
||||
return false;
|
||||
}
|
||||
variable = 6;
|
||||
Foo();
|
||||
if(variable != 54)
|
||||
{
|
||||
TestLog("Expected 54 after Foo().");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(unloadFoo)
|
||||
UnloadSeg(&Foo);
|
||||
if(unloadBar)
|
||||
UnloadSeg(&Bar);
|
||||
if(unloadFoo)
|
||||
UnloadSeg(&Foo);
|
||||
if(unloadBar)
|
||||
UnloadSeg(&Bar);
|
||||
|
||||
Size grow;
|
||||
if(compact)
|
||||
MaxMem(&grow);
|
||||
Size grow;
|
||||
if(compact)
|
||||
MaxMem(&grow);
|
||||
|
||||
Bar();
|
||||
if(variable != 42)
|
||||
{
|
||||
TestLog("Expected 42 after Bar().");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
Bar();
|
||||
if(variable != 42)
|
||||
{
|
||||
TestLog("Expected 42 after Bar().");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
Size grow, maxblock, maxblock2, freemem, freemem2;
|
||||
Size grow, maxblock, maxblock2, freemem, freemem2;
|
||||
|
||||
MaxApplZone(); // just to keep things simple and predictable
|
||||
MoreMasters();
|
||||
MaxApplZone(); // just to keep things simple and predictable
|
||||
MoreMasters();
|
||||
|
||||
maxblock = MaxMem(&grow);
|
||||
freemem = FreeMem();
|
||||
maxblock = MaxMem(&grow);
|
||||
freemem = FreeMem();
|
||||
|
||||
TestLog("1. No unloading");
|
||||
if(!Test(false, false, false))
|
||||
return 1;
|
||||
TestLog("1. No unloading");
|
||||
if(!Test(false, false, false))
|
||||
return 1;
|
||||
|
||||
maxblock2 = MaxMem(&grow);
|
||||
maxblock2 = MaxMem(&grow);
|
||||
|
||||
|
||||
TestLog("2. UnloadSeg(&Foo)");
|
||||
if(!Test(true, false, false))
|
||||
return 1;
|
||||
TestLog("3. UnloadSeg(&Bar)");
|
||||
if(!Test(false, true, false))
|
||||
return 1;
|
||||
TestLog("4. UnloadSeg(&Foo); UnloadSeg(&Bar)");
|
||||
if(!Test(true, true, false))
|
||||
return 1;
|
||||
TestLog("2. UnloadSeg(&Foo)");
|
||||
if(!Test(true, false, false))
|
||||
return 1;
|
||||
TestLog("3. UnloadSeg(&Bar)");
|
||||
if(!Test(false, true, false))
|
||||
return 1;
|
||||
TestLog("4. UnloadSeg(&Foo); UnloadSeg(&Bar)");
|
||||
if(!Test(true, true, false))
|
||||
return 1;
|
||||
|
||||
TestLog("5. UnloadSeg(&Foo); MaxMem()");
|
||||
if(!Test(true, false, true))
|
||||
return 1;
|
||||
TestLog("6. UnloadSeg(&Bar); MaxMem()");
|
||||
if(!Test(false, true, true))
|
||||
return 1;
|
||||
TestLog("7. UnloadSeg(&Foo); UnloadSeg(&Bar); MaxMem()");
|
||||
if(!Test(true, true, true))
|
||||
return 1;
|
||||
TestLog("5. UnloadSeg(&Foo); MaxMem()");
|
||||
if(!Test(true, false, true))
|
||||
return 1;
|
||||
TestLog("6. UnloadSeg(&Bar); MaxMem()");
|
||||
if(!Test(false, true, true))
|
||||
return 1;
|
||||
TestLog("7. UnloadSeg(&Foo); UnloadSeg(&Bar); MaxMem()");
|
||||
if(!Test(true, true, true))
|
||||
return 1;
|
||||
|
||||
UnloadSeg(&Foo);
|
||||
UnloadSeg(&Foo);
|
||||
|
||||
maxblock2 = MaxMem(&grow);
|
||||
freemem2 = FreeMem();
|
||||
maxblock2 = MaxMem(&grow);
|
||||
freemem2 = FreeMem();
|
||||
|
||||
if(maxblock2 < maxblock || freemem2 < freemem)
|
||||
{
|
||||
TestLog("Leak");
|
||||
char s[256];
|
||||
sprintf(s, "maxblock: %d (delta %d), freemem: %d (delta %d)",
|
||||
maxblock2, maxblock2-maxblock, freemem2, freemem2-freemem);
|
||||
TestLog(s);
|
||||
return 1;
|
||||
}
|
||||
else if(maxblock2 > maxblock || freemem2 > freemem)
|
||||
TestLog("Magic Memory");
|
||||
if(maxblock2 < maxblock || freemem2 < freemem)
|
||||
{
|
||||
TestLog("Leak");
|
||||
char s[256];
|
||||
sprintf(s, "maxblock: %d (delta %d), freemem: %d (delta %d)",
|
||||
maxblock2, maxblock2-maxblock, freemem2, freemem2-freemem);
|
||||
TestLog(s);
|
||||
return 1;
|
||||
}
|
||||
else if(maxblock2 > maxblock || freemem2 > freemem)
|
||||
TestLog("Magic Memory");
|
||||
|
||||
TestLog("OK");
|
||||
TestLog("OK");
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,11 +2,11 @@ extern int variable;
|
||||
#include <SegLoad.h>
|
||||
void Foo()
|
||||
{
|
||||
variable *= 9;
|
||||
variable *= 9;
|
||||
}
|
||||
|
||||
void Bar()
|
||||
{
|
||||
variable /= 9;
|
||||
variable *= 7;
|
||||
variable /= 9;
|
||||
variable *= 7;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
int main()
|
||||
{
|
||||
FILE *f = fopen("out", "w");
|
||||
fprintf(f, "OK\n");
|
||||
fclose(f);
|
||||
FILE *f = fopen("out", "w");
|
||||
fprintf(f, "OK\n");
|
||||
fclose(f);
|
||||
}
|
||||
|
@ -2,5 +2,5 @@
|
||||
|
||||
void TestLog(const char *str)
|
||||
{
|
||||
TEST_LOG_SIZED(str, strlen(str));
|
||||
TEST_LOG_SIZED(str, strlen(str));
|
||||
}
|
||||
|
@ -22,52 +22,52 @@ void TestLog(const char *str);
|
||||
/* The same thing as a macro. String length has to be given explicitly,
|
||||
* to avoid a call to strlen(). */
|
||||
#define TEST_LOG_SIZED(str, size) \
|
||||
do { \
|
||||
HParamBlockRec _hpb; \
|
||||
\
|
||||
unsigned char _fileName[4]; \
|
||||
short _ref;\
|
||||
_fileName[0] = 3; \
|
||||
_fileName[1] = 'o'; \
|
||||
_fileName[2] = 'u'; \
|
||||
_fileName[3] = 't'; \
|
||||
\
|
||||
_hpb.ioParam.ioCompletion = NULL; \
|
||||
_hpb.ioParam.ioNamePtr = (StringPtr)_fileName; \
|
||||
_hpb.ioParam.ioVRefNum = 0; \
|
||||
_hpb.fileParam.ioDirID = 0; \
|
||||
_hpb.ioParam.ioPermssn = fsRdWrPerm; \
|
||||
_hpb.ioParam.ioMisc = NULL; \
|
||||
PBHOpenSync(&_hpb); \
|
||||
_ref = _hpb.ioParam.ioRefNum; \
|
||||
\
|
||||
_hpb.ioParam.ioCompletion = NULL; \
|
||||
_hpb.ioParam.ioBuffer = (Ptr)str; \
|
||||
_hpb.ioParam.ioReqCount = size; \
|
||||
_hpb.ioParam.ioPosMode = fsFromLEOF; \
|
||||
_hpb.ioParam.ioPosOffset = 0; \
|
||||
_hpb.ioParam.ioRefNum = _ref; \
|
||||
_hpb.ioParam.ioMisc = NULL; \
|
||||
PBWriteSync((ParmBlkPtr)&_hpb); \
|
||||
char _newline = '\n'; \
|
||||
_hpb.ioParam.ioCompletion = NULL; \
|
||||
_hpb.ioParam.ioBuffer = &_newline; \
|
||||
_hpb.ioParam.ioReqCount = 1; \
|
||||
_hpb.ioParam.ioPosMode = fsFromLEOF; \
|
||||
_hpb.ioParam.ioPosOffset = 0; \
|
||||
_hpb.ioParam.ioRefNum = _ref; \
|
||||
_hpb.ioParam.ioMisc = NULL; \
|
||||
PBWriteSync((ParmBlkPtr)&_hpb); \
|
||||
_hpb.ioParam.ioCompletion = NULL; \
|
||||
_hpb.ioParam.ioRefNum = _ref; \
|
||||
_hpb.ioParam.ioMisc = NULL; \
|
||||
PBCloseSync((ParmBlkPtr)&_hpb); \
|
||||
_hpb.ioParam.ioCompletion = NULL; \
|
||||
_hpb.ioParam.ioNamePtr = NULL; \
|
||||
_hpb.ioParam.ioVRefNum = 0; \
|
||||
_hpb.ioParam.ioMisc = NULL; \
|
||||
PBFlushVolSync((ParmBlkPtr)&_hpb); \
|
||||
} while(0);
|
||||
do { \
|
||||
HParamBlockRec _hpb; \
|
||||
\
|
||||
unsigned char _fileName[4]; \
|
||||
short _ref;\
|
||||
_fileName[0] = 3; \
|
||||
_fileName[1] = 'o'; \
|
||||
_fileName[2] = 'u'; \
|
||||
_fileName[3] = 't'; \
|
||||
\
|
||||
_hpb.ioParam.ioCompletion = NULL; \
|
||||
_hpb.ioParam.ioNamePtr = (StringPtr)_fileName; \
|
||||
_hpb.ioParam.ioVRefNum = 0; \
|
||||
_hpb.fileParam.ioDirID = 0; \
|
||||
_hpb.ioParam.ioPermssn = fsRdWrPerm; \
|
||||
_hpb.ioParam.ioMisc = NULL; \
|
||||
PBHOpenSync(&_hpb); \
|
||||
_ref = _hpb.ioParam.ioRefNum; \
|
||||
\
|
||||
_hpb.ioParam.ioCompletion = NULL; \
|
||||
_hpb.ioParam.ioBuffer = (Ptr)str; \
|
||||
_hpb.ioParam.ioReqCount = size; \
|
||||
_hpb.ioParam.ioPosMode = fsFromLEOF; \
|
||||
_hpb.ioParam.ioPosOffset = 0; \
|
||||
_hpb.ioParam.ioRefNum = _ref; \
|
||||
_hpb.ioParam.ioMisc = NULL; \
|
||||
PBWriteSync((ParmBlkPtr)&_hpb); \
|
||||
char _newline = '\n'; \
|
||||
_hpb.ioParam.ioCompletion = NULL; \
|
||||
_hpb.ioParam.ioBuffer = &_newline; \
|
||||
_hpb.ioParam.ioReqCount = 1; \
|
||||
_hpb.ioParam.ioPosMode = fsFromLEOF; \
|
||||
_hpb.ioParam.ioPosOffset = 0; \
|
||||
_hpb.ioParam.ioRefNum = _ref; \
|
||||
_hpb.ioParam.ioMisc = NULL; \
|
||||
PBWriteSync((ParmBlkPtr)&_hpb); \
|
||||
_hpb.ioParam.ioCompletion = NULL; \
|
||||
_hpb.ioParam.ioRefNum = _ref; \
|
||||
_hpb.ioParam.ioMisc = NULL; \
|
||||
PBCloseSync((ParmBlkPtr)&_hpb); \
|
||||
_hpb.ioParam.ioCompletion = NULL; \
|
||||
_hpb.ioParam.ioNamePtr = NULL; \
|
||||
_hpb.ioParam.ioVRefNum = 0; \
|
||||
_hpb.ioParam.ioMisc = NULL; \
|
||||
PBFlushVolSync((ParmBlkPtr)&_hpb); \
|
||||
} while(0);
|
||||
|
||||
/*
|
||||
* Output either "OK" or "NO".
|
||||
@ -75,23 +75,23 @@ void TestLog(const char *str);
|
||||
* we might not want to test them yet.
|
||||
*/
|
||||
|
||||
#define TEST_LOG_OK() \
|
||||
do { \
|
||||
char ok[3]; \
|
||||
ok[0] = 'O'; \
|
||||
ok[1] = 'K'; \
|
||||
ok[2] = '\0'; \
|
||||
TEST_LOG_SIZED(ok, 2); \
|
||||
} while(0)
|
||||
#define TEST_LOG_OK() \
|
||||
do { \
|
||||
char ok[3]; \
|
||||
ok[0] = 'O'; \
|
||||
ok[1] = 'K'; \
|
||||
ok[2] = '\0'; \
|
||||
TEST_LOG_SIZED(ok, 2); \
|
||||
} while(0)
|
||||
|
||||
#define TEST_LOG_NO() \
|
||||
do { \
|
||||
char no[3]; \
|
||||
no[0] = 'O'; \
|
||||
no[1] = 'K'; \
|
||||
no[2] = '\0'; \
|
||||
TEST_LOG_SIZED(no, 2); \
|
||||
} while(0)
|
||||
#define TEST_LOG_NO() \
|
||||
do { \
|
||||
char no[3]; \
|
||||
no[0] = 'O'; \
|
||||
no[1] = 'K'; \
|
||||
no[2] = '\0'; \
|
||||
TEST_LOG_SIZED(no, 2); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#endif // TEST_H
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
int main()
|
||||
{
|
||||
TEST_LOG_SIZED("One",3);
|
||||
TEST_LOG_SIZED("Two",3);
|
||||
for(;;)
|
||||
;
|
||||
TEST_LOG_SIZED("Three",5);
|
||||
return 0;
|
||||
TEST_LOG_SIZED("One",3);
|
||||
TEST_LOG_SIZED("Two",3);
|
||||
for(;;)
|
||||
;
|
||||
TEST_LOG_SIZED("Three",5);
|
||||
return 0;
|
||||
}
|
||||
|
@ -10,45 +10,45 @@ EventRecord e;
|
||||
|
||||
int main()
|
||||
{
|
||||
int i;
|
||||
if(commonSymbol)
|
||||
{
|
||||
TEST_LOG_NO();
|
||||
return 1;
|
||||
}
|
||||
if(zeroInited)
|
||||
{
|
||||
TEST_LOG_NO();
|
||||
return 1;
|
||||
}
|
||||
for(i = 0; i < 32768; i++)
|
||||
{
|
||||
if(zeroInitedArray[i])
|
||||
{
|
||||
TEST_LOG_NO();
|
||||
return 1;
|
||||
}
|
||||
zeroInitedArray[i] = 42;
|
||||
}
|
||||
|
||||
int i;
|
||||
if(commonSymbol)
|
||||
{
|
||||
TEST_LOG_NO();
|
||||
return 1;
|
||||
}
|
||||
if(zeroInited)
|
||||
{
|
||||
TEST_LOG_NO();
|
||||
return 1;
|
||||
}
|
||||
for(i = 0; i < 32768; i++)
|
||||
{
|
||||
if(zeroInitedArray[i])
|
||||
{
|
||||
TEST_LOG_NO();
|
||||
return 1;
|
||||
}
|
||||
zeroInitedArray[i] = 42;
|
||||
}
|
||||
|
||||
// Initialize some of the Macintosh Toolbox
|
||||
// and maybe trigger a context switch, so we can be sure
|
||||
// our global variables were put in the right placce.
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
InitGraf(&qd.thePort);
|
||||
InitFonts();
|
||||
InitWindows();
|
||||
InitGraf(&qd.thePort);
|
||||
InitFonts();
|
||||
InitWindows();
|
||||
#endif
|
||||
GetNextEvent(everyEvent, &e);
|
||||
GetNextEvent(everyEvent, &e);
|
||||
|
||||
for(i = 0; i < 32768; i++)
|
||||
{
|
||||
if(zeroInitedArray[i] != 42)
|
||||
{
|
||||
TEST_LOG_NO();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
TEST_LOG_OK();
|
||||
return 0;
|
||||
for(i = 0; i < 32768; i++)
|
||||
{
|
||||
if(zeroInitedArray[i] != 42)
|
||||
{
|
||||
TEST_LOG_NO();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
TEST_LOG_OK();
|
||||
return 0;
|
||||
}
|
||||
|
@ -16,15 +16,15 @@
|
||||
# along with Retro68. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
add_library(RetroConsole
|
||||
retro/Console.cc
|
||||
retro/Console.h
|
||||
retro/ConsoleWindow.cc
|
||||
retro/ConsoleWindow.h
|
||||
retro/MacUtils.h
|
||||
retro/InitConsole.cc
|
||||
)
|
||||
retro/Console.cc
|
||||
retro/Console.h
|
||||
retro/ConsoleWindow.cc
|
||||
retro/ConsoleWindow.h
|
||||
retro/MacUtils.h
|
||||
retro/InitConsole.cc
|
||||
)
|
||||
set_target_properties(retrocrt
|
||||
PROPERTIES
|
||||
PROPERTIES
|
||||
COMPILE_OPTIONS -ffunction-sections)
|
||||
|
||||
# different library name for Carbon
|
||||
@ -37,6 +37,6 @@ target_include_directories(RetroConsole PUBLIC .)
|
||||
install(TARGETS RetroConsole DESTINATION lib)
|
||||
|
||||
add_application(ConsoleTest
|
||||
ConsoleTest.cc
|
||||
)
|
||||
ConsoleTest.cc
|
||||
)
|
||||
target_link_libraries(ConsoleTest RetroConsole)
|
||||
|
@ -3,21 +3,21 @@
|
||||
|
||||
namespace retro
|
||||
{
|
||||
void InitConsole();
|
||||
void InitConsole();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
retro::InitConsole();
|
||||
std::string out = "Hello, world.\nEnter \"exit\" to quit.\n";
|
||||
retro::Console::currentInstance->write(out.data(), out.size());
|
||||
|
||||
std::string in;
|
||||
do
|
||||
{
|
||||
in = retro::Console::currentInstance->ReadLine();
|
||||
out = "You Entered: " + in;
|
||||
retro::Console::currentInstance->write(out.data(), out.size());
|
||||
} while(in != "exit\n");
|
||||
return 0;
|
||||
retro::InitConsole();
|
||||
std::string out = "Hello, world.\nEnter \"exit\" to quit.\n";
|
||||
retro::Console::currentInstance->write(out.data(), out.size());
|
||||
|
||||
std::string in;
|
||||
do
|
||||
{
|
||||
in = retro::Console::currentInstance->ReadLine();
|
||||
out = "You Entered: " + in;
|
||||
retro::Console::currentInstance->write(out.data(), out.size());
|
||||
} while(in != "exit\n");
|
||||
return 0;
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ std::string Console::ReadLine()
|
||||
char c;
|
||||
|
||||
do
|
||||
{
|
||||
{
|
||||
c = WaitNextChar();
|
||||
if(!c)
|
||||
{
|
||||
|
@ -25,66 +25,66 @@
|
||||
|
||||
namespace retro
|
||||
{
|
||||
class Console
|
||||
{
|
||||
public:
|
||||
Console();
|
||||
Console(GrafPtr port, Rect r);
|
||||
~Console();
|
||||
class Console
|
||||
{
|
||||
public:
|
||||
Console();
|
||||
Console(GrafPtr port, Rect r);
|
||||
~Console();
|
||||
|
||||
void Reshape(Rect newBounds);
|
||||
void Reshape(Rect newBounds);
|
||||
|
||||
void Draw(Rect r);
|
||||
void Draw() { Draw(bounds); }
|
||||
void putch(char c);
|
||||
void Draw(Rect r);
|
||||
void Draw() { Draw(bounds); }
|
||||
void putch(char c);
|
||||
|
||||
void write(const char *s, int n);
|
||||
std::string ReadLine();
|
||||
void write(const char *s, int n);
|
||||
std::string ReadLine();
|
||||
|
||||
static Console *currentInstance;
|
||||
static Console *currentInstance;
|
||||
|
||||
short GetRows() const { return rows; }
|
||||
short GetCols() const { return cols; }
|
||||
|
||||
void Idle();
|
||||
short GetRows() const { return rows; }
|
||||
short GetCols() const { return cols; }
|
||||
|
||||
void Idle();
|
||||
|
||||
bool IsEOF() const { return eof; }
|
||||
private:
|
||||
GrafPtr consolePort = nullptr;
|
||||
Rect bounds;
|
||||
private:
|
||||
GrafPtr consolePort = nullptr;
|
||||
Rect bounds;
|
||||
|
||||
std::vector<char> chars, onscreen;
|
||||
std::vector<char> chars, onscreen;
|
||||
|
||||
short cellSizeX;
|
||||
short cellSizeY;
|
||||
short cellSizeX;
|
||||
short cellSizeY;
|
||||
|
||||
short rows = 0, cols = 0;
|
||||
short rows = 0, cols = 0;
|
||||
|
||||
short cursorX, cursorY;
|
||||
short cursorX, cursorY;
|
||||
|
||||
Rect dirtyRect = {};
|
||||
|
||||
long blinkTicks = 0;
|
||||
bool cursorDrawn = false;
|
||||
bool cursorVisible = true;
|
||||
Rect dirtyRect = {};
|
||||
|
||||
long blinkTicks = 0;
|
||||
bool cursorDrawn = false;
|
||||
bool cursorVisible = true;
|
||||
bool eof = false;
|
||||
|
||||
void PutCharNoUpdate(char c);
|
||||
void Update();
|
||||
void PutCharNoUpdate(char c);
|
||||
void Update();
|
||||
|
||||
Rect CellRect(short x, short y);
|
||||
void DrawCell(short x, short y, bool erase = true);
|
||||
void DrawCells(short x1, short x2, short y, bool erase = true);
|
||||
void ScrollUp(short n = 1);
|
||||
|
||||
void InvalidateCursor();
|
||||
Rect CellRect(short x, short y);
|
||||
void DrawCell(short x, short y, bool erase = true);
|
||||
void DrawCells(short x1, short x2, short y, bool erase = true);
|
||||
void ScrollUp(short n = 1);
|
||||
|
||||
void InvalidateCursor();
|
||||
|
||||
virtual char WaitNextChar();
|
||||
|
||||
protected:
|
||||
void Init(GrafPtr port, Rect r);
|
||||
|
||||
};
|
||||
virtual char WaitNextChar();
|
||||
|
||||
protected:
|
||||
void Init(GrafPtr port, Rect r);
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
@ -25,103 +25,103 @@ using namespace retro;
|
||||
|
||||
namespace
|
||||
{
|
||||
std::unordered_map<WindowPtr, ConsoleWindow*> *windows = NULL;
|
||||
std::unordered_map<WindowPtr, ConsoleWindow*> *windows = NULL;
|
||||
}
|
||||
|
||||
ConsoleWindow::ConsoleWindow(Rect r, ConstStr255Param title)
|
||||
{
|
||||
GrafPtr port;
|
||||
GrafPtr port;
|
||||
|
||||
win = NewWindow(NULL, &r, "\pRetro68 Console", true, 0, (WindowPtr)-1, false, 0);
|
||||
win = NewWindow(NULL, &r, "\pRetro68 Console", true, 0, (WindowPtr)-1, false, 0);
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
port = win;
|
||||
Rect portRect = port->portRect;
|
||||
port = win;
|
||||
Rect portRect = port->portRect;
|
||||
#else
|
||||
port = GetWindowPort(win);
|
||||
Rect portRect;
|
||||
GetPortBounds(port, &portRect);
|
||||
port = GetWindowPort(win);
|
||||
Rect portRect;
|
||||
GetPortBounds(port, &portRect);
|
||||
#endif
|
||||
|
||||
SetPort(port);
|
||||
EraseRect(&portRect);
|
||||
SetPort(port);
|
||||
EraseRect(&portRect);
|
||||
|
||||
if(!windows)
|
||||
windows = new std::unordered_map<WindowPtr, ConsoleWindow*>();
|
||||
(*windows)[win] = this;
|
||||
if(!windows)
|
||||
windows = new std::unordered_map<WindowPtr, ConsoleWindow*>();
|
||||
(*windows)[win] = this;
|
||||
|
||||
Init(port, portRect);
|
||||
Init(port, portRect);
|
||||
}
|
||||
|
||||
ConsoleWindow::~ConsoleWindow()
|
||||
{
|
||||
windows->erase(win);
|
||||
DisposeWindow(win);
|
||||
windows->erase(win);
|
||||
DisposeWindow(win);
|
||||
}
|
||||
|
||||
char ConsoleWindow::WaitNextChar()
|
||||
{
|
||||
EventRecord event;
|
||||
WindowPtr eventWin;
|
||||
ConsoleWindow *realConsole;
|
||||
EventRecord event;
|
||||
WindowPtr eventWin;
|
||||
ConsoleWindow *realConsole;
|
||||
#if TARGET_API_MAC_CARBON
|
||||
Rect *boundsPtr = NULL;
|
||||
Rect *boundsPtr = NULL;
|
||||
#else
|
||||
Rect *boundsPtr = &qd.screenBits.bounds;
|
||||
Rect *boundsPtr = &qd.screenBits.bounds;
|
||||
#endif
|
||||
|
||||
do
|
||||
{
|
||||
#if TARGET_API_MAC_CARBON
|
||||
#define SystemTask()
|
||||
#endif
|
||||
SystemTask();
|
||||
Idle();
|
||||
while(!GetNextEvent(everyEvent, &event))
|
||||
{
|
||||
SystemTask();
|
||||
Idle();
|
||||
}
|
||||
|
||||
switch(event.what)
|
||||
{
|
||||
case updateEvt:
|
||||
eventWin = (WindowPtr)event.message;
|
||||
realConsole = (*windows)[(WindowPtr)event.message];
|
||||
if(realConsole)
|
||||
{
|
||||
Rect updateRect;
|
||||
BeginUpdate(eventWin);
|
||||
|
||||
do
|
||||
{
|
||||
#if TARGET_API_MAC_CARBON
|
||||
#define SystemTask()
|
||||
#endif
|
||||
SystemTask();
|
||||
Idle();
|
||||
while(!GetNextEvent(everyEvent, &event))
|
||||
{
|
||||
SystemTask();
|
||||
Idle();
|
||||
}
|
||||
|
||||
switch(event.what)
|
||||
{
|
||||
case updateEvt:
|
||||
eventWin = (WindowPtr)event.message;
|
||||
realConsole = (*windows)[(WindowPtr)event.message];
|
||||
if(realConsole)
|
||||
{
|
||||
Rect updateRect;
|
||||
BeginUpdate(eventWin);
|
||||
#if TARGET_API_MAC_CARBON
|
||||
RgnHandle rgn = NewRgn();
|
||||
GetPortVisibleRegion(GetWindowPort(eventWin), rgn);
|
||||
GetRegionBounds(rgn, &updateRect);
|
||||
DisposeRgn(rgn);
|
||||
RgnHandle rgn = NewRgn();
|
||||
GetPortVisibleRegion(GetWindowPort(eventWin), rgn);
|
||||
GetRegionBounds(rgn, &updateRect);
|
||||
DisposeRgn(rgn);
|
||||
#else
|
||||
updateRect = (*qd.thePort->visRgn)->rgnBBox; // Life was simple back then.
|
||||
updateRect = (*qd.thePort->visRgn)->rgnBBox; // Life was simple back then.
|
||||
#endif
|
||||
realConsole->Draw(updateRect);
|
||||
EndUpdate(eventWin);
|
||||
}
|
||||
break;
|
||||
case mouseDown:
|
||||
|
||||
switch(FindWindow(event.where, &eventWin))
|
||||
{
|
||||
case inDrag:
|
||||
DragWindow(eventWin, event.where, boundsPtr);
|
||||
break;
|
||||
case inGrow:
|
||||
{
|
||||
long growResult = GrowWindow(eventWin, event.where, boundsPtr);
|
||||
SizeWindow(eventWin, growResult & 0xFFFF, growResult >> 16, false);
|
||||
Reshape(Rect {0, 0, (short) (growResult >> 16), (short) (growResult & 0xFFFF) });
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} while(event.what != keyDown && event.what != autoKey);
|
||||
|
||||
return event.message & charCodeMask;
|
||||
realConsole->Draw(updateRect);
|
||||
EndUpdate(eventWin);
|
||||
}
|
||||
break;
|
||||
case mouseDown:
|
||||
|
||||
switch(FindWindow(event.where, &eventWin))
|
||||
{
|
||||
case inDrag:
|
||||
DragWindow(eventWin, event.where, boundsPtr);
|
||||
break;
|
||||
case inGrow:
|
||||
{
|
||||
long growResult = GrowWindow(eventWin, event.where, boundsPtr);
|
||||
SizeWindow(eventWin, growResult & 0xFFFF, growResult >> 16, false);
|
||||
Reshape(Rect {0, 0, (short) (growResult >> 16), (short) (growResult & 0xFFFF) });
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} while(event.what != keyDown && event.what != autoKey);
|
||||
|
||||
return event.message & charCodeMask;
|
||||
}
|
||||
|
@ -25,14 +25,14 @@
|
||||
|
||||
namespace retro
|
||||
{
|
||||
class ConsoleWindow : public Console
|
||||
{
|
||||
public:
|
||||
ConsoleWindow(Rect r, ConstStr255Param title);
|
||||
~ConsoleWindow();
|
||||
private:
|
||||
WindowPtr win;
|
||||
class ConsoleWindow : public Console
|
||||
{
|
||||
public:
|
||||
ConsoleWindow(Rect r, ConstStr255Param title);
|
||||
~ConsoleWindow();
|
||||
private:
|
||||
WindowPtr win;
|
||||
|
||||
virtual char WaitNextChar();
|
||||
};
|
||||
virtual char WaitNextChar();
|
||||
};
|
||||
}
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2014 Wolfgang Thaller.
|
||||
Copyright 2014 Wolfgang Thaller.
|
||||
|
||||
This file is part of Retro68.
|
||||
This file is part of Retro68.
|
||||
|
||||
Retro68 is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
Retro68 is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Retro68 is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
Retro68 is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Retro68. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Retro68. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
@ -34,26 +34,26 @@
|
||||
|
||||
namespace retro
|
||||
{
|
||||
void InitConsole();
|
||||
void InitConsole();
|
||||
}
|
||||
|
||||
using namespace retro;
|
||||
|
||||
void retro::InitConsole()
|
||||
{
|
||||
if(Console::currentInstance)
|
||||
return;
|
||||
if(Console::currentInstance)
|
||||
return;
|
||||
Console::currentInstance = (Console*) -1;
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
InitGraf(&qd.thePort);
|
||||
InitFonts();
|
||||
InitWindows();
|
||||
InitMenus();
|
||||
InitGraf(&qd.thePort);
|
||||
InitFonts();
|
||||
InitWindows();
|
||||
InitMenus();
|
||||
|
||||
Rect r = qd.screenBits.bounds;
|
||||
Rect r = qd.screenBits.bounds;
|
||||
#else
|
||||
Rect r = (*GetMainDevice())->gdRect;
|
||||
Rect r = (*GetMainDevice())->gdRect;
|
||||
#endif
|
||||
{
|
||||
// give MultiFinder a chance to bring the App to front
|
||||
@ -71,41 +71,41 @@ void retro::InitConsole()
|
||||
EventAvail(everyEvent, &event);
|
||||
}
|
||||
|
||||
r.top += 40;
|
||||
InsetRect(&r, 5,5);
|
||||
|
||||
Console::currentInstance = new ConsoleWindow(r, "\pRetro68 Console");
|
||||
InitCursor();
|
||||
r.top += 40;
|
||||
InsetRect(&r, 5,5);
|
||||
|
||||
Console::currentInstance = new ConsoleWindow(r, "\pRetro68 Console");
|
||||
InitCursor();
|
||||
}
|
||||
|
||||
extern "C" ssize_t _consolewrite(int fd, const void *buf, size_t count)
|
||||
{
|
||||
if(!Console::currentInstance)
|
||||
InitConsole();
|
||||
if(Console::currentInstance == (Console*)-1)
|
||||
return 0;
|
||||
if(!Console::currentInstance)
|
||||
InitConsole();
|
||||
if(Console::currentInstance == (Console*)-1)
|
||||
return 0;
|
||||
|
||||
Console::currentInstance->write((const char*)buf, count);
|
||||
return count;
|
||||
Console::currentInstance->write((const char*)buf, count);
|
||||
return count;
|
||||
}
|
||||
|
||||
extern "C" ssize_t _consoleread(int fd, void *buf, size_t count)
|
||||
{
|
||||
if(!Console::currentInstance)
|
||||
InitConsole();
|
||||
if(Console::currentInstance == (Console*)-1)
|
||||
return 0;
|
||||
if(!Console::currentInstance)
|
||||
InitConsole();
|
||||
if(Console::currentInstance == (Console*)-1)
|
||||
return 0;
|
||||
|
||||
static std::string consoleBuf;
|
||||
if(consoleBuf.size() == 0)
|
||||
{
|
||||
consoleBuf = Console::currentInstance->ReadLine();
|
||||
static std::string consoleBuf;
|
||||
if(consoleBuf.size() == 0)
|
||||
{
|
||||
consoleBuf = Console::currentInstance->ReadLine();
|
||||
if(!Console::currentInstance->IsEOF())
|
||||
consoleBuf += "\n";
|
||||
}
|
||||
if(count > consoleBuf.size())
|
||||
count = consoleBuf.size();
|
||||
memcpy(buf, consoleBuf.data(), count);
|
||||
consoleBuf = consoleBuf.substr(count);
|
||||
return count;
|
||||
}
|
||||
if(count > consoleBuf.size())
|
||||
count = consoleBuf.size();
|
||||
memcpy(buf, consoleBuf.data(), count);
|
||||
consoleBuf = consoleBuf.substr(count);
|
||||
return count;
|
||||
}
|
||||
|
@ -25,22 +25,22 @@ bool dataSections = true;
|
||||
bool dataInText = false;
|
||||
|
||||
using stringid = int;
|
||||
unordered_map<stringid,stringid> sectionMap;
|
||||
unordered_map<stringid,string> stringDictionary;
|
||||
unordered_map<stringid,stringid> sectionMap;
|
||||
unordered_map<stringid,string> stringDictionary;
|
||||
unordered_set<stringid> localLabels;
|
||||
|
||||
enum RecordType {
|
||||
kPad = 0,
|
||||
kFirst = 1,
|
||||
kLast = 2,
|
||||
kPad = 0,
|
||||
kFirst = 1,
|
||||
kLast = 2,
|
||||
kComment = 3,
|
||||
kDictionary = 4,
|
||||
kModule = 5,
|
||||
kEntryPoint = 6,
|
||||
kSize = 7,
|
||||
kContent = 8,
|
||||
kReference = 9,
|
||||
kComputedRef = 10,
|
||||
kDictionary = 4,
|
||||
kModule = 5,
|
||||
kEntryPoint = 6,
|
||||
kSize = 7,
|
||||
kContent = 8,
|
||||
kReference = 9,
|
||||
kComputedRef = 10,
|
||||
kFilename = 11
|
||||
};
|
||||
|
||||
@ -49,19 +49,19 @@ enum ModuleFlags {
|
||||
kExtern = 0x08 // default local
|
||||
};
|
||||
|
||||
enum ReferenceFlags { // flags field of kReference
|
||||
k16BitPatch = 0x10, // default 32Bit
|
||||
kFromData = 0x01, // default fromCode
|
||||
kA5Relative = 0x80, // default absolute
|
||||
enum ReferenceFlags { // flags field of kReference
|
||||
k16BitPatch = 0x10, // default 32Bit
|
||||
kFromData = 0x01, // default fromCode
|
||||
kA5Relative = 0x80, // default absolute
|
||||
|
||||
kUnknownReferenceFlags = 0x6E // rather a lot, isn't it?
|
||||
// The following flags are known to exist from DumpOBJ,
|
||||
// but their value is unkown as I haven't actually seen them yet:
|
||||
// k32BitOffsets (default k16BitOffsets)
|
||||
kUnknownReferenceFlags = 0x6E // rather a lot, isn't it?
|
||||
// The following flags are known to exist from DumpOBJ,
|
||||
// but their value is unkown as I haven't actually seen them yet:
|
||||
// k32BitOffsets (default k16BitOffsets)
|
||||
};
|
||||
|
||||
enum ComputedReferenceFlags {
|
||||
kDifference = 0x80
|
||||
kDifference = 0x80
|
||||
};
|
||||
|
||||
enum ContentFlags {
|
||||
@ -73,97 +73,97 @@ enum ContentFlags {
|
||||
string encodeIdentifier(stringid id)
|
||||
{
|
||||
const string& s = stringDictionary[id];
|
||||
std::ostringstream ss;
|
||||
std::ostringstream ss;
|
||||
|
||||
if(localLabels.find(id) != localLabels.end())
|
||||
ss << "L" << id << ".";
|
||||
|
||||
if(s.empty() || isdigit(s[0]))
|
||||
ss << "__z";
|
||||
ss << "__z";
|
||||
|
||||
for(char c : s)
|
||||
{
|
||||
if(c == '_' || isalnum(c))
|
||||
ss << c;
|
||||
else
|
||||
{
|
||||
ss << "__z" << (int) c << "_";
|
||||
}
|
||||
}
|
||||
for(char c : s)
|
||||
{
|
||||
if(c == '_' || isalnum(c))
|
||||
ss << c;
|
||||
else
|
||||
{
|
||||
ss << "__z" << (int) c << "_";
|
||||
}
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
struct Reloc
|
||||
{
|
||||
int size;
|
||||
stringid name1 = -1;
|
||||
stringid name2 = -1;
|
||||
int size;
|
||||
stringid name1 = -1;
|
||||
stringid name2 = -1;
|
||||
|
||||
int write(std::ostream& out, uint8_t *p);
|
||||
int write(std::ostream& out, uint8_t *p);
|
||||
};
|
||||
|
||||
int Reloc::write(std::ostream& out, uint8_t *p)
|
||||
{
|
||||
if(size == 2)
|
||||
{
|
||||
out << "\t.short ";
|
||||
int val = (int)p[0] * 256 + p[1];
|
||||
if(size == 2)
|
||||
{
|
||||
out << "\t.short ";
|
||||
int val = (int)p[0] * 256 + p[1];
|
||||
|
||||
out << encodeIdentifier(name1);
|
||||
if(name2 != -1)
|
||||
out << " - " << encodeIdentifier(name2);
|
||||
if(val > 0)
|
||||
out << " + " << val;
|
||||
else if(val < 0)
|
||||
out << " - " << -val;
|
||||
if(name2 == -1)
|
||||
out << "-.";
|
||||
out << std::endl;
|
||||
return 2;
|
||||
}
|
||||
else if(size == 4)
|
||||
{
|
||||
out << "\t.long ";
|
||||
int val = ((int)p[0] << 24) | ((int)p[1] << 16) | ((int)p[2] << 8) | p[3];
|
||||
out << encodeIdentifier(name1);
|
||||
if(name2 != -1)
|
||||
out << " - " << encodeIdentifier(name2);
|
||||
if(val > 0)
|
||||
out << " + " << val;
|
||||
else if(val < 0)
|
||||
out << " - " << -val;
|
||||
if(name2 == -1)
|
||||
out << "-.";
|
||||
out << std::endl;
|
||||
return 2;
|
||||
}
|
||||
< |