diff --git a/examples/overlay/overlay.c b/examples/overlay/overlay.c index 5e4643c..66d5276 100644 --- a/examples/overlay/overlay.c +++ b/examples/overlay/overlay.c @@ -21,21 +21,17 @@ */ -#include "f256.h" -#include "f256.c" - - -#include - - -#define test(...) ( *(volatile byte *)(0x000D) = 8; REAL_test(__VA_ARGS__); *(volatile byte *)(0x000D) = 5; ) +#define SEGMENT_TEST void test(int arg1, int arg2) { } +#define SEGMENT_MAIN + + int main(int argc, char *argv[]) { - test(test); + test(1, 2); return 0; } diff --git a/tools/overlay/src/overlay.c b/tools/overlay/src/overlay.c index 05fc7be..42c1e25 100644 --- a/tools/overlay/src/overlay.c +++ b/tools/overlay/src/overlay.c @@ -92,7 +92,6 @@ void parseCFile(char *filename, char *targetFile, FILE *trampoline, char *trampo * This parser sucks. * * - It only handles C, not C++. - * - It should scan for function names backwards from the '(' and not by skipping possible modifiers like 'static' and 'struct'. * - It can only handle single-line function definitions with the opening '{' on the same line as the function. * - It can be borked by comments. * - It always generates trampolines, not just when they're needed. @@ -152,26 +151,14 @@ void parseCFile(char *filename, char *targetFile, FILE *trampoline, char *trampo if (buffer[strlen(buffer) - 1] == ')') { // Function. Annotate it! fprintf(out, "__attribute__((noinline, section(\".block%d\")))\n", _currentBank); - // Scan forward to find function name. - found = false; - start = buffer; - do { - b = start; - while (*b != ' ') b++; - // This could be 'struct' or 'static'. Put a null there and check. (Then put the space back!) - *b = 0; - if ((strcmp(start, "struct") == 0) || (strcmp(start, "static") == 0)) { - // Keep looking. - start = ++b; - found = true; - } - *b = ' '; - } while (found); - // Now that we could have a 'static struct' or something, put the zero back for later. - *b = 0; - // We're past the types. Now find the '(' after the function name. - start = ++b; + + // Scan forward to find the '(' after the function name. + b = buffer; while (*b != '(') b++; + // Now go backwards and look for a space. + start = b; + while (*start != ' ') start--; + *start++ = 0; // Yank the function name out. *b = 0; temp = strdup(start); @@ -314,9 +301,9 @@ int main(int argc, char *argv[]) { fprintf(out, "#define TRAMPOLINE_H\n\n"); // Find common inital path so we can remove it later. - sourceDir = strdup(argv[x]); + sourceDir = strdup(argv[3]); utilFixPathSeparators(&sourceDir, true); - sourceDirOffset = strlen(sourceDir); + sourceDirOffset = strlen(sourceDir) - 1; if (argc > 4) { for (x=4; x %s\n", cFile, targetFile); free(cFile); free(targetFile); }