Move to the new build environment

This commit is contained in:
Jeremy Rand 2017-09-11 23:14:06 -04:00
parent 46bbabc8f9
commit e49487532a
124 changed files with 6119 additions and 6 deletions

BIN
.DS_Store vendored

Binary file not shown.

6
.gitignore vendored
View File

@ -1,6 +0,0 @@
.*.swp
*.o
*.r
*.root
abCalc
abCalcNDA

21
abCalc/Makefile Normal file
View File

@ -0,0 +1,21 @@
all:
make -f nda.mk gen
make -f nda.mk build
make -f shell.mk gen
make -f shell.mk build
gen:
make -f nda.mk gen
make -f shell.mk gen
build:
make -f nda.mk build
make -f shell.mk build
clean:
make -f shell.mk clean
make -f nda.mk clean
execute:
make -f nda.mk execute
# make -f shell.mk execute

75
abCalc/abCError.c Normal file
View File

@ -0,0 +1,75 @@
/*
abCError.c
By: Jeremy Rand
*/
#include <stdio.h>
#include <stdlib.h>
#include "abCError.h"
static char *gErrorStrings[abCalcErrorTypeMax];
static abCalcErrorType gCurrErrorType = abCalcNoError;
static char *gCurrErrorOpName = NULL;
char gErrorBuffer[128];
void abCalcErrorInit(void)
{
gErrorStrings[abCalcNoError] = NULL;
gErrorStrings[abCalcSyntaxError] = "Syntax Error";
gErrorStrings[abCalcBadArgTypeError] = "Bad Argument Type";
gErrorStrings[abCalcBadArgValueError] = "Bad Argument Value";
gErrorStrings[abCalcTooFewArgsError] = "Too Few Arguments";
gErrorStrings[abCalcStackFullError] = "Stack Full";
gErrorStrings[abCalcInfiniteResultError] = "Infinite Result";
gErrorStrings[abCalcComplexResultError] = "Complex Result";
}
void abCalcRaiseError(abCalcErrorType type, char *opName)
{
if ((type < abCalcErrorTypeMin) ||
(type >= abCalcErrorTypeMax))
return;
if (gCurrErrorType == abCalcNoError) {
gCurrErrorType = type;
gCurrErrorOpName = opName;
}
}
char *abCalcGetError(void)
{
char *errorString;
if ((gCurrErrorType < abCalcErrorTypeMin) ||
(gCurrErrorType >= abCalcErrorTypeMax))
return NULL;
errorString = gErrorStrings[gCurrErrorType];
if (errorString == NULL)
return NULL;
if (gCurrErrorOpName != NULL) {
sprintf(gErrorBuffer, "%s Error: %s", gCurrErrorOpName, gErrorStrings[gCurrErrorType]);
} else {
sprintf(gErrorBuffer, "Error: %s", gErrorStrings[gCurrErrorType]);
}
return gErrorBuffer;
}
void abCalcClearError(void)
{
gCurrErrorType = abCalcNoError;
gCurrErrorOpName = NULL;
}

35
abCalc/abCError.h Normal file
View File

@ -0,0 +1,35 @@
/*
abCError.h
By: Jeremy Rand
*/
#ifndef ABCERROR_H
#define ABCERROR_H
typedef enum abCalcErrorType {
abCalcErrorTypeMin = 0,
abCalcNoError,
abCalcSyntaxError,
abCalcBadArgTypeError,
abCalcBadArgValueError,
abCalcTooFewArgsError,
abCalcStackFullError,
abCalcInfiniteResultError,
abCalcComplexResultError,
abCalcErrorTypeMax
} abCalcErrorType;
void abCalcErrorInit(void);
void abCalcRaiseError(abCalcErrorType type, char *opName);
char *abCalcGetError(void);
void abCalcClearError(void);
#endif

47
abCalc/abCMode.c Normal file
View File

@ -0,0 +1,47 @@
/*
abCMode.c
By: Jeremy Rand
*/
#include "abCMode.h"
static abCalcModeIntBase gBase = abCalcModeDecBase;
static int gIntWidth = AB_CALC_EXPR_MAX_INT_WIDTH;
void abCalcModeInit(void)
{
}
abCalcModeIntBase abCalcModeGetBase(void)
{
return gBase;
}
void abCalcModeSetBase(abCalcModeIntBase base)
{
if ((base >= abCalcModeIntBaseMin) &&
(base < abCalcModeIntBaseMax)) {
gBase = base;
}
}
int abCalcModeGetIntWidth(void)
{
return gIntWidth;
}
void abCalcModeSetIntWidth(int width)
{
if ((width > 0) &&
(width <= AB_CALC_EXPR_MAX_INT_WIDTH)) {
gIntWidth = width;
}
}

37
abCalc/abCMode.h Normal file
View File

@ -0,0 +1,37 @@
/*
abCMode.h
By: Jeremy Rand
*/
#ifndef ABCMODE_H
#define ABCMODE_H
#include "expr/abCExpr.h"
typedef enum abCalcModeIntBase
{
abCalcModeIntBaseMin = 0,
abCalcModeBinBase = 0,
abCalcModeOctBase,
abCalcModeDecBase,
abCalcModeHexBase,
abCalcModeIntBaseMax
} abCalcModeIntBase;
void abCalcModeInit(void);
abCalcModeIntBase abCalcModeGetBase(void);
void abCalcModeSetBase(abCalcModeIntBase base);
int abCalcModeGetIntWidth(void);
void abCalcModeSetIntWidth(int width);
#endif

103
abCalc/abCStack.c Normal file
View File

@ -0,0 +1,103 @@
/*
abCStack.c
By: Jeremy Rand
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "abCStack.h"
#include "abCError.h"
abCalcExpr gStack[AB_CALC_STACK_DEPTH];
static int gStackNumItems = 0;
void abCalcStackInit(void)
{
}
abCalcExpr *abCalcStackExprPush(abCalcExpr *expr)
{
abCalcExpr *result = NULL;
if (gStackNumItems >= AB_CALC_STACK_DEPTH) {
abCalcRaiseError(abCalcStackFullError, NULL);
return NULL;
}
if ((gStackNumItems < AB_CALC_STACK_DEPTH) &&
(expr != NULL)) {
result = &(gStack[gStackNumItems]);
memcpy(result, expr, sizeof(*expr));
gStackNumItems++;
}
return result;
}
abCalcExpr *abCalcStackExprPop(abCalcExpr *expr)
{
abCalcExpr *result = NULL;
if (gStackNumItems < 1)
return NULL;
gStackNumItems--;
if (expr != NULL) {
result = expr;
memcpy(expr, &(gStack[gStackNumItems]), sizeof(*expr));
}
return result;
}
int abCalcStackNumItems(void)
{
return gStackNumItems;
}
abCalcExpr *abCalcStackExprAt(int depth)
{
abCalcExpr *result = NULL;
if (depth < gStackNumItems) {
result = &(gStack[gStackNumItems - 1 - depth]);
}
return result;
}
char *abCalcStackExprStringAt(int depth, char *buffer, int addPrefix)
{
static char tmpBuffer[AB_CALC_EXPR_STRING_MAX];
if (buffer == NULL)
return NULL;
if (addPrefix) {
sprintf(buffer, "%3d: ", depth + 1);
} else {
buffer[0] = '\0';
}
if (depth < gStackNumItems) {
if (abCalcFormatExpr(&(gStack[gStackNumItems - 1 - depth]), tmpBuffer) != NULL) {
strcat(buffer, tmpBuffer);
}
}
return buffer;
}
void abCalcStackClear(void)
{
gStackNumItems = 0;
}

32
abCalc/abCStack.h Normal file
View File

@ -0,0 +1,32 @@
/*
abCStack.h
By: Jeremy Rand
*/
#ifndef ABCSTACK_H
#define ABCSTACK_H
#include "expr/abCExpr.h"
#define AB_CALC_STACK_DEPTH 128
void abCalcStackInit(void);
abCalcExpr *abCalcStackExprPush(abCalcExpr *expr);
abCalcExpr *abCalcStackExprPop(abCalcExpr *expr);
abCalcExpr *abCalcStackExprAt(int depth);
char *abCalcStackExprStringAt(int depth, char *buffer, int addPrefix);
int abCalcStackNumItems(void);
void abCalcStackClear(void);
#endif

32
abCalc/abCalc.c Normal file
View File

@ -0,0 +1,32 @@
/*
abCalc.c
By: Jeremy Rand
*/
#include "abCMode.h"
#include "abCStack.h"
#include "abCError.h"
#include "expr/abCExpr.h"
#include "expr/abCExprInt.h"
#include "expr/abCExpReal.h"
#include "ops/abCOp.h"
void abCalcInit(void)
{
abCalcExprInit();
abCalcExprRealInit();
abCalcExprIntInit();
abCalcModeInit();
abCalcStackInit();
abCalcOpInit();
abCalcErrorInit();
}

14
abCalc/abCalc.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCalc.h
By: Jeremy Rand
*/
#ifndef ABCALC_H
#define ABCALC_H
void abCalcInit(void);
#endif

File diff suppressed because one or more lines are too long

217
abCalc/expr/abCExpReal.c Normal file
View File

@ -0,0 +1,217 @@
/*
abCExpReal.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "expr/abCExpr.h"
static abCalcExpr *abCalcExprRealParse(abCalcExpr *expr, char *buffer);
static char *abCalcExprRealFormat(abCalcExpr *expr, char *buffer);
static abCalcExprCallbacks gRealCallbacks = {
abCalcExprRealParse,
abCalcExprRealFormat
};
void abCalcExprRealInit(void)
{
abCalcRegisterExprType(abCalcExprTypeReal, &gRealCallbacks);
}
abCalcExpr *abCalcExprRealParse(abCalcExpr *expr, char *buffer)
{
int offset;
int expOffset = -1;
int periodOffset = -1;
int len;
int numOffset = -1;
/* First validate */
if (buffer == NULL)
return NULL;
if (expr == NULL)
return NULL;
len = strlen(buffer);
for (offset = 0; offset < len; offset++) {
switch (buffer[offset]) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
numOffset = offset;
break;
case '.':
if (periodOffset != -1)
return NULL;
if (expOffset != -1)
return NULL;
periodOffset = offset;
break;
case '-':
if (offset == 0)
break;
/* Fallthrough */
case '+':
if ((expOffset == -1) ||
((expOffset + 1) != offset))
return NULL;
break;
case 'e':
case 'E':
if (expOffset != -1)
return NULL;
expOffset = offset;
numOffset = -1;
break;
default:
return NULL;
}
}
if (numOffset == -1)
return NULL;
expr->type = abCalcExprTypeReal;
expr->u.real = atof(buffer);
return expr;
}
char *abCalcExprRealFormat(abCalcExpr *expr, char *buffer)
{
abCalcRealType exp;
abCalcRealType value;
static char format[16];
int numDecDigits;
int periodPos = -1;
int zerosStart = -1;
int spaceStart = -1;
int expPos = -1;
int len;
int i;
if (expr == NULL)
return NULL;
if (buffer == NULL)
return NULL;
if (expr->type != abCalcExprTypeReal)
return NULL;
value = expr->u.real;
if (value == 0.0) {
exp = 0.0;
} else {
exp = floor(log10(fabs(value)));
}
if (exp >= 0)
exp++;
if ((exp > 12) ||
(exp < -12)) {
strcpy(format, "%-25.11E");
} else if (exp <= -2) {
double shiftedValue = value * 1.0e12;
if (shiftedValue == floor(shiftedValue)) {
strcpy(format, "%-18.12f");
} else {
strcpy(format, "%-25.11E");
}
} else {
int numDecDigits = (int)(12 - exp);
if (numDecDigits > 12) {
numDecDigits = 12;
}
sprintf(format, "%%-28.%df", numDecDigits);
}
sprintf(buffer, format, value);
len = strlen(buffer);
for (i = 0; i < len; i++) {
switch (buffer[i]) {
case '.':
periodPos = i;
break;
case '0':
if (expPos != -1) {
break;
}
if ((periodPos != -1) &&
(zerosStart == -1)) {
if (periodPos == i - 1) {
zerosStart = periodPos;
} else {
zerosStart = i;
}
}
break;
case 'E':
expPos = i;
break;
case ' ':
spaceStart = i;
break;
default:
if (expPos == -1)
zerosStart = -1;
break;
}
if (spaceStart != -1)
break;
}
if (spaceStart != -1) {
buffer[spaceStart] = '\0';
len = spaceStart;
}
if (zerosStart != -1) {
if (expPos != -1) {
memmove(&buffer[zerosStart], &buffer[expPos], len - expPos + 1);
len = expPos - zerosStart;
}
else {
buffer[zerosStart] = '\0';
}
}
return buffer;
}
void abCalcExprRealSet(abCalcExpr *expr, abCalcRealType value)
{
if (expr == NULL)
return;
expr->type = abCalcExprTypeReal;
expr->u.real = value;
}

17
abCalc/expr/abCExpReal.h Normal file
View File

@ -0,0 +1,17 @@
/*
abCExpReal.h
By: Jeremy Rand
*/
#ifndef ABCEXPREAL_H
#define ABCEXPREAL_H
struct abCalcExpr;
void abCalcExprRealInit(void);
void abCalcExprRealSet(struct abCalcExpr *expr, abCalcRealType value);
#endif

61
abCalc/expr/abCExpr.c Normal file
View File

@ -0,0 +1,61 @@
/*
abCExpr.c
By: Jeremy Rand
*/
#include <stdlib.h>
#include "expr/abCExpr.h"
static abCalcExprCallbacks *gCallbacks[abCalcExprTypeMax];
#define AB_CALC_EXPR_TYPE_INVALID(type) (((type) < abCalcExprTypeMin) || ((type) >= abCalcExprTypeMax))
void abCalcExprInit(void)
{
abCalcExprType type;
for (type = abCalcExprTypeMin; type < abCalcExprTypeMax; type++) {
gCallbacks[type] = NULL;
}
}
void abCalcRegisterExprType(abCalcExprType type, abCalcExprCallbacks *callbacks)
{
if (AB_CALC_EXPR_TYPE_INVALID(type))
return;
gCallbacks[type] = callbacks;
}
abCalcExpr *abCalcParseExpr(abCalcExpr *expr, char *buffer)
{
abCalcExpr *result = NULL;
abCalcExprType type;
for (type = abCalcExprTypeMin; type < abCalcExprTypeMax; type++) {
if (gCallbacks[type] != NULL) {
result = (gCallbacks[type]->parseExpr)(expr, buffer);
if (result != NULL)
return result;
}
}
return result;
}
char *abCalcFormatExpr(abCalcExpr *expr, char *buffer)
{
if (AB_CALC_EXPR_TYPE_INVALID(expr->type))
return NULL;
if (gCallbacks[expr->type] == NULL)
return NULL;
return (gCallbacks[expr->type]->formatExpr(expr, buffer));
}

51
abCalc/expr/abCExpr.h Normal file
View File

@ -0,0 +1,51 @@
/*
abCExpr.h
By: Jeremy Rand
*/
#ifndef ABCEXPR_H
#define ABCEXPR_H
typedef enum abCalcExprType {
abCalcExprTypeMin = 0,
abCalcExprTypeReal = 0,
abCalcExprTypeInt,
abCalcExprTypeMax
} abCalcExprType;
typedef double abCalcRealType;
typedef unsigned long abCalcIntType;
#define AB_CALC_EXPR_MAX_INT_WIDTH ((sizeof(abCalcIntType) * 8))
#define AB_CALC_EXPR_STRING_MAX (AB_CALC_EXPR_MAX_INT_WIDTH + 8)
typedef struct abCalcExpr {
abCalcExprType type;
union {
abCalcRealType real;
abCalcIntType integer;
} u;
} abCalcExpr;
typedef struct abCalcExprCallbacks {
abCalcExpr * (*parseExpr)(abCalcExpr *expr, char *buffer);
char * (*formatExpr)(abCalcExpr *expr, char *buffer);
} abCalcExprCallbacks;
void abCalcExprInit(void);
void abCalcRegisterExprType(abCalcExprType type, abCalcExprCallbacks *callbacks);
abCalcExpr *abCalcParseExpr(abCalcExpr *expr, char *buffer);
char *abCalcFormatExpr(abCalcExpr *expr, char *buffer);
#endif

272
abCalc/expr/abCExprInt.c Normal file
View File

@ -0,0 +1,272 @@
/*
abCExprInt.c
By: Jeremy Rand
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "abCMode.h"
#include "expr/abCExpr.h"
static abCalcExpr *abCalcExprIntParse(abCalcExpr *expr, char *buffer);
static char *abCalcExprIntFormat(abCalcExpr *expr, char *buffer);
static abCalcExprCallbacks gIntCallbacks = {
abCalcExprIntParse,
abCalcExprIntFormat
};
void abCalcExprIntInit(void)
{
abCalcRegisterExprType(abCalcExprTypeInt, &gIntCallbacks);
}
abCalcExpr *abCalcExprIntParse(abCalcExpr *expr, char *buffer)
{
abCalcModeIntBase base = abCalcModeGetBase();
abCalcIntType value = 0;
int len;
int offset = 1;
if (buffer == NULL)
return NULL;
if (expr == NULL)
return NULL;
len = strlen(buffer);
if (len < 2)
return NULL;
if (buffer[0] == '$') {
base = abCalcModeHexBase;
} else if ((buffer[0] == '0') &&
(buffer[1] == 'x')) {
base = abCalcModeHexBase;
offset = 2;
} else if (buffer[0] != '#')
return NULL;
switch (base) {
case abCalcModeBinBase:
for ( ; offset < len; offset++) {
value <<= 1;
switch (buffer[offset]) {
case '1':
value++;
break;
case '0':
break;
default:
return NULL;
}
}
break;
case abCalcModeOctBase:
for ( ; offset < len; offset++) {
value <<= 3;
switch (buffer[offset]) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
value += (buffer[offset] - '0');;
break;
default:
return NULL;
}
}
break;
case abCalcModeDecBase:
for ( ; offset < len; offset++) {
value *= 10;
switch (buffer[offset]) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
value += (buffer[offset] - '0');;
break;
default:
return NULL;
}
}
break;
case abCalcModeHexBase:
for ( ; offset < len; offset++) {
value <<= 4;
switch (buffer[offset]) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
value += (buffer[offset] - '0');;
break;
case 'a':
case 'A':
value += 10;
break;
case 'b':
case 'B':
value += 11;
break;
case 'c':
case 'C':
value += 12;
break;
case 'd':
case 'D':
value += 13;
break;
case 'e':
case 'E':
value += 14;
break;
case 'f':
case 'F':
value += 15;
break;
default:
return NULL;
}
}
break;
default:
return NULL;
}
expr->type = abCalcExprTypeInt;
expr->u.integer = value;
return expr;
}
char *abCalcExprIntFormat(abCalcExpr *expr, char *buffer)
{
abCalcModeIntBase base = abCalcModeGetBase();
int width = abCalcModeGetIntWidth();
abCalcIntType value;
char *ptr;
int gotFirstOne;
int i;
if (expr == NULL)
return NULL;
if (buffer == NULL)
return NULL;
if (expr->type != abCalcExprTypeInt)
return NULL;
value = expr->u.integer;
if (width < AB_CALC_EXPR_MAX_INT_WIDTH) {
value &= ((1l << width) - 1);
}
switch (base) {
case abCalcModeBinBase:
gotFirstOne = 0;
ptr = buffer;
*ptr = '#';
ptr++;
for (i = width - 1; i >= 0; i--) {
if ((value >> i) & 1) {
*ptr = '1';
ptr++;
gotFirstOne = 1;
} else {
if (gotFirstOne) {
*ptr = '0';
ptr++;
}
}
}
if (!gotFirstOne) {
*ptr = '0';
ptr++;
}
*ptr = ' ';
ptr++;
*ptr = 'b';
ptr++;
*ptr = '\0';
break;
case abCalcModeOctBase:
sprintf(buffer, "#%lo o", value);
break;
case abCalcModeDecBase:
sprintf(buffer, "#%lu d", value);
break;
case abCalcModeHexBase:
sprintf(buffer, "#%lX h", value);
break;
default:
return NULL;
}
return buffer;
}
void abCalcExprIntSet(abCalcExpr *expr, abCalcIntType value)
{
int width;
if (expr == NULL)
return;
width = abCalcModeGetIntWidth();
expr->type = abCalcExprTypeInt;
expr->u.integer = value;
if (width < AB_CALC_EXPR_MAX_INT_WIDTH) {
expr->u.integer &= ((1l << width) - 1);
}
}

19
abCalc/expr/abCExprInt.h Normal file
View File

@ -0,0 +1,19 @@
/*
abCExprInt.h
By: Jeremy Rand
*/
#ifndef ABCEXPRINT_H
#define ABCEXPRINT_H
struct abCalcExpr;
void abCalcExprIntInit(void);
void abCalcExprIntSet(struct abCalcExpr *expr, abCalcIntType value);
#endif

46
abCalc/make/config.txt Normal file
View File

@ -0,0 +1,46 @@
# GSplus configuration file version 0.13
s5d1 =
s5d2 =
s6d1 =
s6d2 =
s7d1 = ../abCalcNDA.2mg
g_limit_speed = 0
bram1[00] = 00 00 00 01 00 00 0d 06 02 01 01 00 01 00 00 00
bram1[10] = 00 00 07 06 02 01 01 00 00 00 0f 06 06 00 05 06
bram1[20] = 01 00 00 00 00 00 00 01 00 00 00 00 03 02 02 02
bram1[30] = 00 00 00 00 00 00 00 00 08 00 01 02 03 04 05 06
bram1[40] = 07 0a 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d
bram1[50] = 0e 0f ff ff ff ff ff ff ff 00 ff ff ff ff ff 81
bram1[60] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
bram1[70] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
bram1[80] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
bram1[90] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
bram1[a0] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
bram1[b0] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
bram1[c0] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
bram1[d0] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
bram1[e0] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
bram1[f0] = ff ff ff ff ff ff ff ff ff ff ff ff 52 06 f8 ac
bram3[00] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
bram3[10] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
bram3[20] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
bram3[30] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
bram3[40] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
bram3[50] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
bram3[60] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
bram3[70] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
bram3[80] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
bram3[90] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
bram3[a0] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
bram3[b0] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
bram3[c0] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
bram3[d0] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
bram3[e0] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
bram3[f0] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

109
abCalc/make/createDiskImage Executable file
View File

@ -0,0 +1,109 @@
#!/bin/sh
set -x
MOUNTDIR=/tmp/a2gs_mount.$$
TMPDISKIMAGE=/tmp/a2gs_diskimage_$$.2mg
TEMPLATEDISKIMAGE=make/system601.2mg
if [ $# -lt 3 ]
then
echo USAGE: $0 diskimage file directory
exit 1
fi
DISKIMAGE="$1"
shift
FILE="$1"
shift
DISKIMAGEDEST="$1"
shift
DEST="${MOUNTDIR}/${DISKIMAGEDEST}"
COPYDIRS=$*
cleanupAndExit()
{
umount "$MOUNTDIR" 2> /dev/null
rm -f "$TMPDISKIMAGE" 2> /dev/null
rm -f "$DISKIMAGE" 2> /dev/null
rmdir "$MOUNTDIR" 2> /dev/null
exit 1
}
if [ ! -f "$TEMPLATEDISKIMAGE" ]
then
echo Unable to find the template disk image, $TEMPLATEDISKIMAGE
cleanupAndExit
fi
cp "$TEMPLATEDISKIMAGE" "$TMPDISKIMAGE"
if [ $? != 0 ]
then
echo Unable to copy template disk image.
cleanupAndExit
fi
mkdir "$MOUNTDIR"
if [ $? != 0 ]
then
echo Unable to create the mount directory.
cleanupAndExit
fi
profuse -orw "$TMPDISKIMAGE" "$MOUNTDIR"
if [ $? != 0 ]
then
echo Unable to mount the disk image.
cleanupAndExit
fi
cp "$FILE" "$DEST"
if [ $? != 0 ]
then
echo Unable to copy the file to the disk image.
cleanupAndExit
fi
OLDDIR=`pwd`
for COPYDIR in $COPYDIRS
do
cd "$COPYDIR"
if [ $? != 0 ]
then
echo Unable to find $COPYDIR
cleanupAndExit
fi
find . -print | while read FILEORDIR
do
if [ -d "$FILEORDIR" ]
then
mkdir -p "${MOUNTDIR}/$FILEORDIR"
elif [ -f "$FILEORDIR" ]
then
cp "$FILEORDIR" "${MOUNTDIR}/$FILEORDIR"
fi
done
cd "$OLDDIR"
done
umount "$MOUNTDIR"
if [ $? != 0 ]
then
echo Unable to unmount the disk image.
cleanupAndExit
fi
cp "$TMPDISKIMAGE" "$DISKIMAGE"
if [ $? != 0 ]
then
echo Unable to copy the disk image to the destination.
cleanupAndExit
fi
rm -f "$TMPDISKIMAGE"
rmdir "$MOUNTDIR"
exit 0

52
abCalc/make/head.mk Normal file
View File

@ -0,0 +1,52 @@
#
# head.mk
#
ORCA_HOME := $(HOME)/orca
ORCA_BINDIR = /usr/local/bin
export ORCA=$(ORCA_BINDIR)/orca
AC=make/AppleCommander.jar
TARGETTYPE=shell
SRCDIRS=.
COMPILE=make/orca-cc
CFLAGS= -P -I
ROOTCFILE=main.c
DEFINES=
INCLUDE_PATHS=
REZ=make/orca-rez
REZFLAGS=
MACGEN=make/orca-macgen
MACGENFLAGS=-P
MACGENMACROS=13/ORCAInclude/m=
ASSEMBLE=make/orca-asm
ASMFLAGS=-P
LINK=$(ORCA) link
LDFLAGS=-P
CHTYP=$(ORCA) chtyp
RM=rm -f
CP=cp
GSPLUS=/Applications/GSplus.app/Contents/MacOS/gsplus
GSPORT=/Applications/GSport/GSport.app/Contents/MacOS/GSport
export GSPLUS
export GSPORT
.PHONY: all gen genclean
all:
@make gen
@make build

29
abCalc/make/launchEmulator Executable file
View File

@ -0,0 +1,29 @@
#!/bin/sh
if [ ! -z "$GSPLUS" ] && [ -x "$GSPLUS" ]
then
EMULATORPATH="$GSPLUS"
elif [ ! -z "$GSPORT" ] && [ -x "$GSPORT" ]
then
EMULATORPATH="$GSPORT"
fi
if [ -z "$EMULATORPATH" ]
then
echo Unable to find GSplus or GSport at these locations.
echo " GSPLUS=$GSPLUS"
echo " GSPORT=$GSPORT"
exit 1
fi
cd make
# This magic ensure that clicking stop in Xcode results in the emulator terminating.
$EMULATORPATH &
PID=$!
trap 'kill $PID' SIGTERM SIGINT SIGHUP EXIT
wait
exit 0

18
abCalc/make/orca-asm Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
FILENAME="$1"
shift
if echo $FILENAME | grep -v '\.s$' > /dev/null
then
echo Expected first argument to be a *.s file but got $FILENAME
exit 1
fi
DIRNAME=`dirname $FILENAME`
BASENAME=`basename $FILENAME .s`
cd "$DIRNAME"
$ORCA assemble $* keep="${BASENAME}" "${BASENAME}.s"
RESULT=$?
exit $RESULT

66
abCalc/make/orca-cc Executable file
View File

@ -0,0 +1,66 @@
#!/bin/bash
TMPFILE=/tmp/orca-cc.$$
FILENAME="$1"
shift
if echo $FILENAME | grep -v '\.c$' > /dev/null
then
echo Expected first argument to be a *.c file but got $FILENAME
exit 1
fi
CCARGS=""
COMPILEARGS=""
for ARG in $*
do
if echo $ARG | grep '^-[id]' > /dev/null
then
CCARGS="$CCARGS cc=$ARG"
else
COMPILEARGS="$COMPILEARGS $ARG"
fi
done
BASENAME=`echo $FILENAME | sed 's/\.c$//'`
DEPSNAME="${BASENAME}.d"
OBJSNAME="${BASENAME}.a"
ROOTNAME="${BASENAME}.root"
$ORCA --trace-gsos compile $COMPILEARGS "$FILENAME" keep="${BASENAME}" $CCARGS 2> $TMPFILE
RESULT=$?
sed '/^[A-Za-z][A-Za-z]*(.*)$/d' $TMPFILE >&2
if [ "$RESULT" -ne 0 ]
then
rm -f $TMPFILE
rm -f $OBJSNAME
rm -f $ROOTNAME
exit $RESULT
fi
DEPS=`awk '
/^FastFileLoad/ {
sub(/^FastFileLoad\(/, "");
sub(/\)$/, "");
print}' $TMPFILE | sort -u | while read FILE
do
if [ -f "$FILE" ]
then
echo $FILE
fi
done | tr '\012' ' '`
rm -f $TMPFILE
# We add a dependency for both the .o and the .root file. If this is the
# main.c file being compiled, we need the dependency on the .root file.
cat > $DEPSNAME << EOF
$OBJSNAME: $DEPS
$ROOTNAME: $DEPS
EOF
exit 0

50
abCalc/make/orca-macgen Executable file
View File

@ -0,0 +1,50 @@
#!/bin/bash
TMPFILE=/tmp/orca-macgen.$$
MACGENFLAGS="$1"
FILENAME="$2"
shift
shift
if echo $FILENAME | grep -v '\.s$' > /dev/null
then
echo Expected second argument to be a *.s file but got $FILENAME
exit 1
fi
BASENAME=`echo $FILENAME | sed 's/\.s$//'`
MACROSNAME="${BASENAME}.macros"
DEPSNAME="${MACROSNAME}.d"
$ORCA --trace-gsos macgen $MACGENFLAGS "$FILENAME" $* < /dev/null 2> $TMPFILE
RESULT=$?
sed '/^[A-Za-z][A-Za-z]*(.*)$/d' $TMPFILE >&2
if [ "$RESULT" -ne 0 ]
then
rm -f $TMPFILE
rm -f $MACROSNAME
exit $RESULT
fi
DEPS=`awk '
/^FastFileLoad/ {
sub(/^FastFileLoad\(/, "");
sub(/\)$/, "");
print}' $TMPFILE | sort -u | while read FILE
do
if [ -f "$FILE" ]
then
echo $FILE
fi
done | tr '\012' ' '`
rm -f $TMPFILE
cat > $DEPSNAME << EOF
$MACROSNAME: $DEPS
EOF
exit 0

45
abCalc/make/orca-rez Executable file
View File

@ -0,0 +1,45 @@
#!/bin/bash
TMPFILE=/tmp/orca-rez.$$
FILENAME="$1"
shift
if echo $FILENAME | grep -v '\.rez$' > /dev/null
then
echo Expected first argument to be a *.rez file but got $FILENAME
exit 1
fi
BASENAME=`echo $FILENAME | sed 's/\.rez$//'`
DEPSNAME="${BASENAME}.rez.d"
OBJSNAME="${BASENAME}.r"
$ORCA --trace-gsos compile $* keep="${OBJSNAME}" "$FILENAME" 2> $TMPFILE
RESULT=$?
sed '/^[A-Za-z][A-Za-z]*(.*)$/d' $TMPFILE >&2
if [ "$RESULT" -ne 0 ]
then
rm -f $TMPFILE
rm -f $OBJSNAME
exit $RESULT
fi
DEPS=`awk '
/^FastFileLoad/ {
sub(/^FastFileLoad\(/, "");
sub(/\)$/, "");
print}' $TMPFILE | sort -u | while read FILE
do
if [ -f "$FILE" ]
then
echo $FILE
fi
done`
echo $OBJSNAME: $DEPS > $DEPSNAME
rm -f $TMPFILE
exit 0

BIN
abCalc/make/system601.2mg Normal file

Binary file not shown.

155
abCalc/make/tail.mk Normal file
View File

@ -0,0 +1,155 @@
#
# tail.mk
#
export PATH := $(PATH):$(ORCA_BIN)
CWD=$(shell pwd)
DISKIMAGE=$(PGM).2mg
BUILDTARGET=$(DISKIMAGE)
EXECTARGET=executeGUI
DISKIMAGEDEST=.
ifeq ($(TARGETTYPE),shell)
FILETYPE=exe
EXECTARGET=executeShell
BUILDTARGET=$(PGM)
else ifeq ($(TARGETTYPE),desktop)
FILETYPE=s16
else ifeq ($(TARGETTYPE),cda)
FILETYPE=cda
DISKIMAGEDEST=System/Desk.Accs
else ifeq ($(TARGETTYPE),cdev)
BINTARGET=$(PGM).bin
FILETYPE=199
DISKIMAGEDEST=System/CDevs
else ifeq ($(TARGETTYPE),nba)
FILETYPE=exe
BUILDTARGET=$(PGM)
else ifeq ($(TARGETTYPE),nda)
FILETYPE=nda
DISKIMAGEDEST=System/Desk.Accs
else ifeq ($(TARGETTYPE),xcmd)
FILETYPE=exe
BUILDTARGET=$(PGM)
endif
ifeq ($(wildcard $(ROOTCFILE)),)
ROOTCFILE=
endif
C_ROOTS=$(ROOTCFILE:.c=.root)
C_SRCS+=$(filter-out $(ROOTCFILE), $(patsubst ./%, %, $(wildcard $(addsuffix /*.c, $(SRCDIRS)))))
C_OBJS=$(C_SRCS:.c=.a)
C_DEPS=$(ROOTCFILE:.c=.d) $(C_SRCS:.c=.d)
ASM_SRCS=$(patsubst ./%, %, $(wildcard $(addsuffix /*.s, $(SRCDIRS))))
ASM_MACROS=$(ASM_SRCS:.s=.macros)
ASM_DEPS=$(ASM_SRCS:.s=.macros.d)
ASM_ROOTS=$(ASM_SRCS:.s=.ROOT)
ASM_OBJS=$(ASM_SRCS:.s=.a)
REZ_SRCS=$(patsubst ./%, %, $(wildcard $(addsuffix /*.rez, $(SRCDIRS))))
REZ_DEPS=$(REZ_SRCS:.rez=.rez.d)
REZ_OBJS=$(REZ_SRCS:.rez=.r)
ifneq ($(firstword $(REZ_SRCS)), $(lastword $(REZ_SRCS)))
$(error Only a single resource file supported, found $(REZ_SRCS))
endif
BUILD_OBJS=$(C_ROOTS) $(C_OBJS) $(ASM_ROOTS)
ifeq ($(BINTARGET),)
BUILD_OBJS+=$(REZ_OBJS)
endif
BUILD_OBJS_NOSUFFIX=$(C_ROOTS:.root=) $(C_OBJS:.a=) $(ASM_ROOTS:.ROOT=)
ALL_OBJS=$(C_ROOTS:.root=.a) $(C_OBJS) $(ASM_OBJS) $(REZ_OBJS)
ALL_ROOTS=$(C_ROOTS) $(C_OBJS:.a=.root) $(ASM_ROOTS)
ALL_DEPS=$(C_DEPS) $(ASM_DEPS) $(REZ_DEPS)
EXECCMD=
.PHONY: build execute executeShell executeGUI clean
.PRECIOUS: $(ASM_MACROS)
build: $(BUILDTARGET)
clean: genclean
$(RM) "$(PGM)" $(BINTARGET)
$(RM) $(ALL_OBJS)
$(RM) $(ALL_ROOTS)