griddle / fred now build, but crash on startup

main
Jeremy Penner 2024-01-03 11:58:44 -05:00
parent a5b8712ec8
commit 0a4762f758
18 changed files with 2735 additions and 751 deletions

5
.gitignore vendored
View File

@ -1,3 +1,6 @@
*.o
down
mamelink/down
mamelink/griddle/fred
mamelink/griddle/griddle
y.output
console_history

View File

@ -1,7 +1,7 @@
.SUFFIXES: .o .c .h .run .y .l
GOBJ = griddle.o gmain.o glexer.o build.o cv.o gexpr.o gexec.o debug.o indir.o
FOBJ = griddle.o fmain.o flexer.o build.o cv.o fexpr.o fexec.o debug.o fred.o fred2.o fscreen.o sun.o map.o
FOBJ = ../mamelink.o griddle.o fmain.o flexer.o build.o cv.o fexpr.o fexec.o debug.o fred.o fred2.o fscreen.o # sun.o map.o
.c.o:
cc -c -g -DYYDEBUG $*.c
@ -21,7 +21,7 @@ griddle: $(GOBJ)
cc -g $(GOBJ) -o griddle
fred: $(FOBJ)
cc -g $(FOBJ) -o fred -lcurses -ltermlib
cc -g $(FOBJ) -o fred -lcurses
all: griddle fred
@ -82,3 +82,6 @@ fred.o: fred.c griddleDefs.h prot.h
fred2.o: fred2.c griddleDefs.h
fscreen.o: fscreen.c griddleDefs.h
clean:
rm -f *.o griddle fred

View File

@ -1,6 +1,6 @@
#include "griddleDefs.h"
value *evaluate();
value *evaluate(expression *expr);
genericListHead *
buildGenericList(list, new)
@ -75,11 +75,11 @@ buildStringList(list, new)
}
expression *
buildExpr(type, arg1, arg2, arg3)
exprType type;
int arg1;
int arg2;
int arg3;
buildExpr(
exprType type,
intptr_t arg1,
intptr_t arg2,
intptr_t arg3)
{
expression *result;
@ -91,6 +91,26 @@ buildExpr(type, arg1, arg2, arg3)
return(result);
}
expression *
buildExprI(exprType type, intptr_t arg1) {
return buildExpr(type, arg1, 0, 0);
}
expression *
buildExprP(exprType type, void *arg1) {
return buildExpr(type, (intptr_t)arg1, 0, 0);
}
expression *
buildExprIP(exprType type, intptr_t arg1, void *arg2) {
return buildExpr(type, arg1, (intptr_t)arg2, 0);
}
expression *
buildExprPIP(exprType type, void *arg1, intptr_t arg2, void *arg3) {
return buildExpr(type, (intptr_t)arg1, arg2, (intptr_t)arg3);
}
property *
buildProperty(fieldName, data)
symbol *fieldName;
@ -166,8 +186,8 @@ buildField(name, dimension, type, initList)
}
field *
invisifyField(aField)
field *aField;
invisifyField(
field *aField)
{
aField->invisible = TRUE;
return(aField);

BIN
mamelink/griddle/class.dat Normal file

Binary file not shown.

View File

@ -0,0 +1,430 @@
define -1 'object'
# ident: objid
# class: bin31
container: entity
x: bin15
y: bin15
style: bin15
gr_state: bin15
orient: bin15
gr_width: bin15
restricted: bit
nitty_bits(31): bit
# fillers(5): bin15
# prop_length: bin15
# property_data: bin15
enddefine
define 0 'region'
ident: regid
owner: avaid = -1
light_level: bin15 = 1
depth: bin15 = 32
east_neighbor: regid
west_neighbor: regid
north_neighbor: regid
south_neighbor: regid
class_group: bin15
orient: bin15
entry_proc: bin15
exit_proc: bin15
east_exit: bin15
west_exit: bin15
north_exit: bin15
south_exit: bin15
east_restriction: bit
west_restriction: bit
north_restriction: bit
south_restriction: bit
weapons_free: bit
theft_free: bit
nitty_bits(26): bit
name(20): character = ""
avatars: byte
town_dir: character
port_dir: character
# filler(33): character
enddefine
define 1 'avatar'
# ident: avaid
region: regid
container: objid
x: bin15
y: bin15
# not_really_turf: regid
gr_state: bin15
gr_width: bin15
genl_flags(32): bit
orient: bin15
# prof_length: bin15
style: byte
# filler(27): character
name(10): character = ""
screen_name(10): character = ""
activity: bin15
action: bin15
health: bin15
restrainer: bin15
custom(3): bin15
bank_balance: bin31
turf: regid
stun_count: bin15
nitty_bits(31): bit
curse_immune: bit
true_orient: bin15
true_head_style: bin15
true_custom(3): bin15
curse_type: bin15
curse_counter: bin15
last_on: bin31
enddefine
define 2 'amulet'
magic_type: bin15
magic_data: bin31
enddefine
define 129 'aquarium'
state: bin15
enddefine
define 4 'atm'
enddefine
define 6 'bag'
open_flags: bin15 = 0
key: fatword = 0
enddefine
define 7 'ball'
enddefine
define 130 'bed'
open_flags: bin15 = 3
enddefine
define 10 'book'
current_page: bin15 = 1
text_id: bin31 = 1
last_page: bin15 = 1
enddefine
define 12 'bottle'
filled: bin15
enddefine
define 13 'box'
open_flags: bin15 = 0
key: fatword = 0
enddefine
define 131 'bridge'
width: bin15
length: bin15
enddefine
define 132 'building'
# filler(3): bin15
connection: regid = -1
enddefine
define 158 'bureaucrat'
open_flags: bin15 = 3
enddefine
define 133 'bush'
enddefine
define 134 'chair'
open_flags: bin15 = 3
enddefine
define 84 'changomatic'
enddefine
define 135 'chest'
open_flags: bin15 = 0
key: fatword = 0
enddefine
define 16 'club'
enddefine
define 136 'coke machine'
take: bin31 = 0
enddefine
define 17 'compass'
enddefine
define 137 'couch'
open_flags: bin15 = 3
enddefine
define 18 'countertop'
open_flags: bin15 = 3
key: fatword = 0
whoput(5): avaid = 0, 0, 0, 0, 0
enddefine
define 20 'crystal ball'
live: bit
# filler(15): bit
enddefine
define 21 'die'
state: bin15 = 1
enddefine
define 22 'display case'
open_flags: bin15 = 3
key: fatword = 0
owner: avaid = 0
locked(5): bit = 0, 0, 0, 0, 0
# filler(11): bit
enddefine
define 23 'door'
open_flags: bin15 = 2
key: fatword = 0
connection: regid = -1
enddefine
define 24 'dropbox'
enddefine
define 25 'drugs'
count: bin15 = 5
effect: bin15 = 1
enddefine
define 28 'elevator'
state: bin15 = 0
take: bin31 = 0
address(20): character = ""
enddefine
define 26 'escape dev'
charge: bin15 = 10
enddefine
define 27 'fake gun'
state: bin15
enddefine
define 138 'fence'
enddefine
define 29 'flag'
mass: bin15 = 1
enddefine
define 30 'flashlight'
on: bin15 = 0
enddefine
define 93 'flat'
flat_type: bin15 = 0
enddefine
define 139 'floor lamp'
on: bin15 = 0
enddefine
define 140 'fortune machine'
take: bin31 = 0
enddefine
define 141 'fountain'
live: bit = 0
# filler(15): bit
enddefine
define 31 'frisbee'
enddefine
define 5 'game piece'
state: bin15
enddefine
define 32 'garbage can'
open_flags: bin15 = 3
key: fatword = 0
enddefine
define 33 'gemstone'
magic_type: bin15
magic_data: bin31
enddefine
define 3 'ghost'
enddefine
define 98 'glue'
open_flags: bin15 = 3
key: fatword = 0
x_offset_1: bin15
y_offset_1: bin15
x_offset_2: bin15
y_offset_2: bin15
x_offset_3: bin15
y_offset_3: bin15
x_offset_4: bin15
y_offset_4: bin15
x_offset_5: bin15
y_offset_5: bin15
x_offset_6: bin15
y_offset_6: bin15
enddefine
define 35 'grenade'
pinpulled: bin15
enddefine
define 36 'ground'
enddefine
define 37 'gun'
enddefine
define 38 'hand of god'
state: bin15
enddefine
define 39 'hat'
enddefine
define 127 'head'
enddefine
define 88 'hole'
open_flags: bin15 = 2
key: fatword = 0
enddefine
define 144 'hot tub'
enddefine
define 143 'house cat'
enddefine
define 40 'instant object'
instant_what: bin15
enddefine
define 145 'jukebox'
enddefine
define 42 'key'
key_number: fatword = 1
enddefine
define 43 'knick knack'
is_magic: bin15
enddefine
define 44 'knife'
enddefine
define 45 'magic lamp'
lamp_state: bin15
wisher: bin15
# filler: bin31
live: bit
# fillerx(15): bit
enddefine
define 46 'magic staff'
magic_type: bin15
magic_data: bin31
enddefine
define 47 'magic wand'
magic_type: bin15
magic_data: bin31
enddefine
define 48 'mailbox'
mail_arrived: bin15
owner: avaid
enddefine
define 49 'matchbook'
mtext(84): varstring
enddefine
define 52 'movie camera'
on: bin15
enddefine
define 54 'paper'
text_id: bin31 = 0
enddefine
define 96 'pawn machine'
open_flags: bin15 = 3
key: fatword = 0
enddefine
define 152 'picture'
mass: bin15 = 1
picture: bin15
enddefine
define 58 'plant'
mass: bin15 = 1
enddefine
define 55 'plaque'
current_page: bin15 = 1
text_id: bin31 = 1
last_page: bin15 = 1
enddefine
define 147 'pond'
enddefine
define 60 'ring'
magic_type: bin15
magic_data: bin31
enddefine
define 148 'river'
enddefine
define 61 'rock'
mass: bin15 = 1
enddefine
define 149 'roof'
base: bin15
pattern: bin15
enddefine
define 150 'safe'
open_flags: bin15 = 0
key: fatword = 0
enddefine
define 63 'security dev'
on: bin15
enddefine
define 64 'sensor'
scan_type: bin15 = 0
enddefine
define 90 'sex changer'
enddefine
define 56 'short sign'
text(10): words = ""
enddefine
define 89 'shovel'
enddefine
define 57 'sign'
text(40): words = ""
enddefine
define 69 'sky'
enddefine
define 95 'spray can'
charge: bin15
enddefine
define 70 'stereo'
on: bin15
tape: bin15
enddefine
define 153 'street'
width: bin15
height: bin15
enddefine
define 154 'streetlamp'
enddefine
define 91 'stun gun'
enddefine
define 92 'super trapezoid'
trapezoid_type: bin15
upper_left_x: bin15
upper_right_x: bin15
lower_left_x: bin15
lower_right_x: bin15
height: bin15
pattern_x_size: bin15
pattern_y_size: bin15
pattern(32): bin15
enddefine
define 97 'switch'
magic_type: bin15
magic_data: bin31
enddefine
define 155 'table'
open_flags: bin15 = 3
key: fatword = 0
enddefine
define 71 'tape'
enddefine
define 74 'teleport'
state: bin15 = 0
take: bin31 = 0
address(20): character = ""
enddefine
define 94 'test'
enddefine
define 75 'ticket'
event: bin15 = 0
enddefine
define 76 'tokens'
denom: fatword = 1
enddefine
define 87 'trapezoid'
trapezoid_type: bin15
upper_left_x: bin15
upper_right_x: bin15
lower_left_x: bin15
lower_right_x: bin15
height: bin15
enddefine
define 156 'tree'
enddefine
define 85 'vendo front'
open_flags: bin15 = 3
key: fatword = 0
item_price: bin15
display_item: bin15
prices(10): bin15
enddefine
define 86 'vendo inside'
open_flags: bin15 = 3
key: fatword = 0
enddefine
define 80 'wall'
length: bin15
height: bin15
pattern: bin15
enddefine
define 157 'window'
enddefine
define 82 'windup toy'
wind_level: bin15
enddefine

View File

@ -1,8 +1,8 @@
#include "griddleDefs.h"
void
executeInclude(filename)
char *filename;
executeInclude(
char *filename)
{
fileList *newFile;
@ -25,13 +25,13 @@ executeInclude(filename)
free(filename);
}
void
executeAssignment(name, expr)
symbol *name;
expression *expr;
{
value *evaluate();
value *evaluate(expression *expr);
void
executeAssignment(
symbol *name,
expression *expr)
{
if (name->type != NON_SYM && name->type != VARIABLE_SYM) {
error("illegal assignment to '%s'\n", name->name);
} else {
@ -43,29 +43,29 @@ executeAssignment(name, expr)
}
void
fillByte(buf, offset, value)
byte *buf;
int offset;
int value;
fillByte(
byte *buf,
int offset,
int value)
{
buf[offset] = value & 0xFF;
}
void
fillWord(buf, offset, value)
byte *buf;
int offset;
int value;
fillWord(
byte *buf,
int offset,
int value)
{
buf[offset ] = (value >> 8) & 0xFF;
buf[offset + 1] = value & 0xFF;
}
void
fillLong(buf, offset, value)
byte *buf;
int offset;
long value;
fillLong(
byte *buf,
int offset,
long value)
{
buf[offset ] = (value >> 24) & 0xFF;
buf[offset + 1] = (value >> 16) & 0xFF;
@ -73,13 +73,14 @@ fillLong(buf, offset, value)
buf[offset + 3] = value & 0xFF;
}
value *buildNumber(int val);
value *
nextValue(dataptr)
exprList **dataptr;
nextValue(
exprList **dataptr)
{
exprList *data;
value *val;
value *buildNumber();
if (dataptr == NULL || *dataptr == NULL)
return(buildNumber(0));
@ -90,8 +91,8 @@ nextValue(dataptr)
}
value *
nextIntValue(dataptr)
exprList **dataptr;
nextIntValue(
exprList **dataptr)
{
value *val;
@ -102,8 +103,8 @@ nextIntValue(dataptr)
}
char *
nextStringValue(dataptr)
exprList **dataptr;
nextStringValue(
exprList **dataptr)
{
value *val;
char *result;
@ -120,8 +121,8 @@ nextStringValue(dataptr)
}
int
contNum(vtype)
valueType vtype;
contNum(
valueType vtype)
{
if (vtype == VAL_AVATAR) return (1);
else if (vtype == VAL_OBJECT) return (2);
@ -129,21 +130,21 @@ contNum(vtype)
}
void
adjustValue(val)
value *val;
adjustValue(
value *val)
{
if (indirFile != NULL && val->value < -1000)
val->value -= globalIdAdjustment;
}
void
fillField(buf, data, aField, nextInt, nextString, nextBit)
byte *buf;
exprList *data;
field *aField;
value *(*nextInt)();
char *(*nextString)();
value *(*nextBit)();
fillField(
byte *buf,
exprList *data,
field *aField,
value *(*nextInt)(),
char *(*nextString)(),
value *(*nextBit)())
{
int i, j;
int offset, bitOffset;
@ -287,10 +288,10 @@ fillField(buf, data, aField, nextInt, nextString, nextBit)
}
void
fillPrototype(buf, fields, class)
byte *buf;
fieldList *fields;
int class;
fillPrototype(
byte *buf,
fieldList *fields,
int class)
{
while (fields != NULL) {
fillField(buf, fields->field->initValues, fields->field,
@ -300,11 +301,11 @@ fillPrototype(buf, fields, class)
}
void
fillProperty(buf, prop, fields, class)
byte *buf;
property *prop;
fieldList *fields;
int class;
fillProperty(
byte *buf,
property *prop,
fieldList *fields,
int class)
{
while (fields != NULL) {
if (fields->field->name == prop->fieldName) {
@ -517,8 +518,8 @@ generateScratchId(class, id, relativeId)
}
void
executeRawline(obj)
object *obj;
executeRawline(
object *obj)
{
if (assignRelativeIds)
generateScratchId(obj->class, getLong(obj->stateVector, 0),

View File

@ -1,13 +1,14 @@
#include "y.tab.h"
#include "griddleDefs.h"
value *buildNumber(int val);
value *
integerize(val)
value *val;
{
char *string;
int i;
value *buildNumber();
if (val == NULL) {
val = buildNumber(0);

View File

@ -150,7 +150,7 @@ readFredStats()
FILE *statFyle;
int i;
if ((statFyle = fopen("/u0/habitat/fredStats", "r")) != NULL) {
if ((statFyle = fopen("fredStats", "r")) != NULL) {
for (i=0; i<128; ++i)
fredStats[i] = getw(statFyle);
fclose(statFyle);
@ -167,7 +167,7 @@ writeFredStats()
FILE *statFyle;
int i;
if ((statFyle = fopen("/u0/habitat/fredStats", "w")) != NULL) {
if ((statFyle = fopen("fredStats", "w")) != NULL) {
for (i=0; i<128; ++i)
putw(fredStats[i], statFyle);
fclose(statFyle);
@ -270,7 +270,7 @@ revalueField(firstc, buf)
char firstc;
byte *buf;
{
ungetch(firstc);
ungetchar(firstc);
fredModeLexingOn();
fillFieldPrompt(editY, editX, editField, buf, TRUE);
fredModeLexingOff();
@ -512,11 +512,12 @@ generateFredObject(class, twinFlag)
editOneObject(noid);
}
void displayRegion();
boolean
createObject()
{
int class;
void displayRegion();
class = promptInt("-- class", previousClass);
if (class == -1)
@ -651,7 +652,7 @@ revaluePath(firstc)
{
char temp[80];
ungetch(firstc);
ungetchar(firstc);
mvaddstr(selectedPath + 1, 0, " ");
clrtoeol();
refresh();
@ -724,27 +725,7 @@ quit()
void
setupFastlinkPort()
{
char *portstr;
portstr = getenv("FASTPORT");
if (portstr != NULL) {
if (strlen(portstr) < 3) {
error("FASTPORT env variable must be of form: c;p\n");
exit(1);
} else {
card = portstr[0] - '0';
port = portstr[2] - '0';
}
}
if (card < 0 || NCARDS <= card) {
error("card number out of range\n");
exit(1);
}
if (port < 0 || 2 < port) {
error("port number out of range\n");
exit(1);
}
if (!testMode && !Init(card, port)) {
if (!testMode && !Init(NULL)) {
error("unable to access device\n");
Finish();
exit(1);
@ -770,7 +751,7 @@ doFredStuff()
undeleteBuffer = NULL;
previousClass = 2;
strcpy(regionName, "/u0/habitat/empty.raw");
strcpy(regionName, "empty.raw");
echoLine("Fred version 1.0 (%s) -- type 'h' for help", DATE);
while (processCommand())
;
@ -782,7 +763,7 @@ doFredStuff()
initC64editor()
{
/* system("down -S < /u0/aric/mic/Gr/all.out");*/
system("down -S < /u0/habitat/reno.out");
system("../down -S < reno.out");
/* system("down -S < /u0/chip/reno.out");*/
return(TRUE);
}

View File

@ -8,27 +8,35 @@ static char unsavedChar;
extern int yylval;
void
echoLine(fmt, arg1, arg2, arg3)
char *fmt;
int arg1;
int arg2;
int arg3;
echoLine(char *fmt, ...)
{
va_list ap;
move(0, 0);
refresh();
clrtoeol();
printw(fmt, arg1, arg2, arg3);
va_start(ap, fmt);
vw_printw(NULL, fmt, ap);
va_end(ap);
refresh();
}
void
lineError(fmt, arg1, arg2, arg3)
char *fmt;
int arg1;
int arg2;
int arg3;
lineError(char *fmt, ...)
{
echoLine(fmt, arg1, arg2, arg3);
va_list ap;
move(0, 0);
refresh();
clrtoeol();
va_start(ap, fmt);
vw_printw(NULL, fmt, ap);
va_end(ap);
refresh();
putchar('\7');
}
@ -43,7 +51,7 @@ mygetch()
}
void
ungetch(c)
ungetchar(c)
char c;
{
unsavedChar = c;

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,7 @@
%{
#define DEFINE_EXTERNS
#include "griddleDefs.h"
#define YYSTYPE intptr_t
%}
%token Name Number String BitString Rawline
@ -54,11 +56,11 @@ includeStatement:
defineStatement:
DEFINE expr String fieldList ENDDEFINE
{
$$ = executeDefine($2, $3, $4);
executeDefine($2, $3, $4);
}
| DEFINE expr String ENDDEFINE
{
$$ = executeDefine($2, $3, NULL);
executeDefine($2, $3, NULL);
}
;
@ -87,7 +89,7 @@ field:
basicField:
Name ':' fieldType
{
$$ = buildField($1, buildExpr(NUM_EXPR, 1), $3, NULL);
$$ = buildField($1, buildExprI(NUM_EXPR, 1), $3, NULL);
}
| Name '(' expr ')' ':' fieldType
{
@ -95,7 +97,7 @@ basicField:
}
| Name ':' fieldType '=' exprList
{
$$ = buildField($1, buildExpr(NUM_EXPR, 1), $3, $5);
$$ = buildField($1, buildExprI(NUM_EXPR, 1), $3, $5);
}
| Name '(' expr ')' ':' fieldType '=' exprList
{
@ -172,74 +174,74 @@ exprList:
expr:
Name
{
$$ = buildExpr(ID_EXPR, $1);
$$ = buildExprP(ID_EXPR, $1);
}
| Number
{
$$ = buildExpr(NUM_EXPR, $1);
$$ = buildExprI(NUM_EXPR, $1);
}
| String
{
$$ = buildExpr(STRING_EXPR, $1);
$$ = buildExprP(STRING_EXPR, $1);
}
| BitString
{
$$ = buildExpr(BITSTRING_EXPR, $1);
$$ = buildExprP(BITSTRING_EXPR, $1);
}
| '(' expr ')'
{
$$ = buildExpr(EXPR_EXPR, $2);
$$ = buildExprP(EXPR_EXPR, $2);
}
| SUB expr %prec UMINUS
{
$$ = buildExpr(UNOP_EXPR, UMINUS, $2);
$$ = buildExprIP(UNOP_EXPR, UMINUS, $2);
}
| NOT expr
{
$$ = buildExpr(UNOP_EXPR, NOT, $2);
$$ = buildExprIP(UNOP_EXPR, NOT, $2);
}
| A expr
{
$$ = buildExpr(UNOP_EXPR, A, $2);
$$ = buildExprIP(UNOP_EXPR, A, $2);
}
| O expr
{
$$ = buildExpr(UNOP_EXPR, O, $2);
$$ = buildExprIP(UNOP_EXPR, O, $2);
}
| R expr
{
$$ = buildExpr(UNOP_EXPR, R, $2);
$$ = buildExprIP(UNOP_EXPR, R, $2);
}
| expr ADD expr
{
$$ = buildExpr(BIN_EXPR, $1, ADD, $3);
$$ = buildExprPIP(BIN_EXPR, $1, ADD, $3);
}
| expr SUB expr
{
$$ = buildExpr(BIN_EXPR, $1, SUB, $3);
$$ = buildExprPIP(BIN_EXPR, $1, SUB, $3);
}
| expr MUL expr
{
$$ = buildExpr(BIN_EXPR, $1, MUL, $3);
$$ = buildExprPIP(BIN_EXPR, $1, MUL, $3);
}
| expr DIV expr
{
$$ = buildExpr(BIN_EXPR, $1, DIV, $3);
$$ = buildExprPIP(BIN_EXPR, $1, DIV, $3);
}
| expr MOD expr
{
$$ = buildExpr(BIN_EXPR, $1, MOD, $3);
$$ = buildExprPIP(BIN_EXPR, $1, MOD, $3);
}
| expr AND expr
{
$$ = buildExpr(BIN_EXPR, $1, AND, $3);
$$ = buildExprPIP(BIN_EXPR, $1, AND, $3);
}
| expr OR expr
{
$$ = buildExpr(BIN_EXPR, $1, OR, $3);
$$ = buildExprPIP(BIN_EXPR, $1, OR, $3);
}
| expr XOR expr
{
$$ = buildExpr(BIN_EXPR, $1, XOR, $3);
$$ = buildExprPIP(BIN_EXPR, $1, XOR, $3);
}
;

View File

@ -1,4 +1,8 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#define Case break; case
#define Default break; default
@ -74,11 +78,12 @@ typedef enum {
VAL_REGION, VAL_BITSTRING
} valueType;
// TODO: Nope, this absolutely does not work
typedef struct {
exprType type;
int part1;
int part2;
int part3;
intptr_t part1;
intptr_t part2;
intptr_t part3;
} expression;
typedef struct exprListStruct {
@ -176,10 +181,14 @@ typedef struct {
byte *prototype;
} classDescriptor;
#define HASH_MAX 512
symbol *symbolTable[HASH_MAX];
#ifdef DEFINE_EXTERNS
#define EXTERN
#else
#define EXTERN extern
#endif
char *malloc();
#define HASH_MAX 512
EXTERN symbol *symbolTable[HASH_MAX];
#define typeAlloc(t) ((t *)malloc(sizeof(t)))
#define typeAllocMulti(t,n) ((t *)malloc((n)*sizeof(t)))
@ -192,50 +201,49 @@ typedef struct fileListStruct {
char *saveName;
} fileList;
fileList *inputStack;
fileList *bottomOfInputStack;
FILE *currentInput;
int currentLineNumber;
char *currentFileName;
int globalIdCounter;
int globalIdAdjustment;
int objectBase;
EXTERN fileList *inputStack;
EXTERN fileList *bottomOfInputStack;
EXTERN FILE *currentInput;
EXTERN int currentLineNumber;
EXTERN char *currentFileName;
EXTERN int globalIdCounter;
EXTERN int globalIdAdjustment;
EXTERN int objectBase;
FILE *griFile;
FILE *rawFile;
FILE *cvFile;
FILE *indirFile;
int indirectPass;
stringList *cvInput;
char *classFileName;
boolean debug;
boolean testMode;
boolean assignRelativeIds;
int useStartCount;
boolean insideDefinition;
boolean announceIncludes;
EXTERN FILE *griFile;
EXTERN FILE *rawFile;
EXTERN FILE *cvFile;
EXTERN FILE *indirFile;
EXTERN int indirectPass;
EXTERN stringList *cvInput;
EXTERN char *classFileName;
EXTERN boolean debug;
EXTERN boolean testMode;
EXTERN boolean assignRelativeIds;
EXTERN int useStartCount;
EXTERN boolean insideDefinition;
EXTERN boolean announceIncludes;
#define MAXCLASS 256
classDescriptor *classDefs[MAXCLASS+1];
EXTERN classDescriptor *classDefs[MAXCLASS+1];
#define MAXNOID 256
int objectCount;
int rawCount;
object *noidArray[MAXNOID];
object *altNoidArray[MAXNOID];
boolean noidAlive[MAXNOID];
boolean fredModeLexing;
char *fredLexString;
boolean promptDefault;
char pathname[80];
char regionName[80];
byte cv[512];
int cvLength;
int displayNoid;
object *undeleteBuffer;
int previousClass;
EXTERN int objectCount;
EXTERN int rawCount;
EXTERN object *noidArray[MAXNOID];
EXTERN object *altNoidArray[MAXNOID];
EXTERN boolean noidAlive[MAXNOID];
EXTERN boolean fredModeLexing;
EXTERN char *fredLexString;
EXTERN boolean promptDefault;
EXTERN char pathname[80];
EXTERN char regionName[80];
extern byte cv[512];
extern int cvLength;
EXTERN int displayNoid;
EXTERN object *undeleteBuffer;
EXTERN int previousClass;
/* C64 locations */
#define KEYBOARD_OVERRIDE (word)0x0010
@ -289,10 +297,23 @@ typedef struct {
int region;
} indirectEntry;
indirectEntry *indirTable;
int indirCount;
char indirName[80];
int indirArgc;
char *indirArgv[50];
int indirRegion;
boolean sortObjects;
EXTERN indirectEntry *indirTable;
EXTERN int indirCount;
EXTERN char indirName[80];
EXTERN int indirArgc;
EXTERN char *indirArgv[50];
EXTERN int indirRegion;
EXTERN boolean sortObjects;
void executeRawline(object *obj);
void executeAssignment(symbol *name, expression *expr);
void executeInclude(char *filename);
void executeDefine(expression *classExpr, char *name, fieldList *fields);
fieldList *buildFieldList(fieldList *list, field *new);
field *invisifyField(field *aField);
field *buildField(symbol *name, expression *dimension, fieldType type, exprList *initList);
expression *buildExpr(exprType type, intptr_t arg1, intptr_t arg2, intptr_t arg3);
expression *buildExprI(exprType type, intptr_t arg1);
expression *buildExprP(exprType type, void *arg1);
expression *buildExprIP(exprType type, intptr_t arg1, void *arg2);
expression *buildExprPIP(exprType type, void *arg1, intptr_t arg2, void *arg3);

View File

@ -2,7 +2,7 @@
#include "y.tab.h"
extern int yylval;
int yydebug;
extern int yydebug;
typedef enum {
C_SKIP, C_ZERO, C_DIG, C_ALPH, C_QUOTE, C_APOSTROPHE, C_LIT, C_SLASH,
@ -563,6 +563,7 @@ setKeywordMinlengths()
int i;
for (i = 0; keywords[i].string != NULL; ++i) {
keywords[i].string = strdup(keywords[i].string);
trailer = index(keywords[i].string, '/');
if (trailer == NULL) {
keywords[i].minlength = strlen(keywords[i].string);

View File

@ -3,7 +3,7 @@
*/
#include "griddleDefs.h"
int yydebug;
extern int yydebug;
#define argcheck(i,m) if (++i >= argc) { error(m); exit(1); }
#define argfile(fd,m,t) { \
@ -108,11 +108,11 @@ initialize(argc, argv)
args = argv + 1;
if ((defineFileName = getenv("GHUDEFINES")) == NULL)
queueInputFile("/u0/habitat/defines.ghu");
queueInputFile("defines.ghu");
else
queueInputFile(defineFileName);
if ((classFileName = getenv("CLASSINFO")) == NULL)
classFileName = "/u0/habitat/class.dat";
classFileName = "class.dat";
for (i=1; i<argc; i++) {
arg = *args++;
if (*arg != '-') {
@ -315,19 +315,22 @@ openFirstFile(fredMode)
return(TRUE);
}
error(msg, arg1, arg2, arg3)
char *msg;
int arg1, arg2, arg3;
void error(char *msg, ...)
{
fprintf(stderr, "error: ");
fprintf(stderr, msg, arg1, arg2, arg3);
va_list ap;
va_start(ap, msg);
vfprintf(stderr, msg, ap);
va_end(ap);
}
systemError(msg, arg1, arg2, arg3)
char *msg;
int arg1, arg2, arg3;
void systemError(char *msg, ...)
{
error(msg, arg1, arg2, arg3);
fprintf(stderr, "error: ");
va_list ap;
va_start(ap, msg);
vfprintf(stderr, msg, ap);
va_end(ap);
perror("Unix says");
exit(1);
}

View File

@ -1,41 +1,42 @@
#include "../mamelink.h"
extern char readc();
#define SC 033
#define REPLY 0
#define STORE 1
#define LOW 2
#define HIGH 3
#define JUMP 4
#define LOAD 5
#define BADREPLY 6
#define CONT 7
#define HALTMAIN 8
#define HALTALL 9
#define HALTCONT 10
#define JUMPSUB 11
#define RESET 12
// extern char readc();
// #define SC 033
// #define REPLY 0
// #define STORE 1
// #define LOW 2
// #define HIGH 3
// #define JUMP 4
// #define LOAD 5
// #define BADREPLY 6
// #define CONT 7
// #define HALTMAIN 8
// #define HALTALL 9
// #define HALTCONT 10
// #define JUMPSUB 11
// #define RESET 12
typedef int Boolean;
typedef struct
{
byte portB;
byte portA;
byte control;
byte portC;
} Port;
// typedef int Boolean;
// typedef struct
// {
// byte portB;
// byte portA;
// byte control;
// byte portC;
// } Port;
extern Port *portopen();
#define CLOWIN 1
#define CLOWOUT 0
#define BIN 02
#define BOUT 0
#define AIN 0x10
#define AOUT 0
#define CUPOUT 0
#define CUPIN 08
#define BMODE0 0
#define AMODE0 0
#define MODESET 0x80
// extern Port *portopen();
// #define CLOWIN 1
// #define CLOWOUT 0
// #define BIN 02
// #define BOUT 0
// #define AIN 0x10
// #define AOUT 0
// #define CUPOUT 0
// #define CUPIN 08
// #define BMODE0 0
// #define AMODE0 0
// #define MODESET 0x80
#define NCARDS 3
#define PADDR { 0x70l, 0x60l }
// #define NCARDS 3
// #define PADDR { 0x70l, 0x60l }

View File

@ -43,9 +43,9 @@ readFredStats(argc, argv)
char temp[256];
if (argc > 1)
sprintf(temp, "%s/u0/habitat/fredStats", argv[1]);
sprintf(temp, "%sfredStats", argv[1]);
else
strcpy(temp, "/u0/habitat/fredStats");
strcpy(temp, "fredStats");
if ((statFyle = fopen(temp, "r")) != NULL) {
for (i=0; i<128; ++i)
fredStats[i] = getw(statFyle);

View File

@ -5,7 +5,7 @@ main()
FILE *statFyle;
int i;
if ((statFyle = fopen("/u0/habitat/fredStats", "w")) != NULL) {
if ((statFyle = fopen("fredStats", "w")) != NULL) {
for (i=0; i<128; ++i)
putw(0, statFyle);
fclose(statFyle);

148
mamelink/griddle/y.tab.h Normal file
View File

@ -0,0 +1,148 @@
/* A Bison parser, made by GNU Bison 3.8.2. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
Inc.
This program 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.
This program 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 this program. If not, see <https://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
especially those whose name start with YY_ or yy_. They are
private implementation details that can be changed or removed. */
#ifndef YY_YY_Y_TAB_H_INCLUDED
# define YY_YY_Y_TAB_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int yydebug;
#endif
/* Token kinds. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
YYEMPTY = -2,
YYEOF = 0, /* "end of file" */
YYerror = 256, /* error */
YYUNDEF = 257, /* "invalid token" */
Name = 258, /* Name */
Number = 259, /* Number */
String = 260, /* String */
BitString = 261, /* BitString */
Rawline = 262, /* Rawline */
INCLUDE = 263, /* INCLUDE */
DEFINE = 264, /* DEFINE */
ENDDEFINE = 265, /* ENDDEFINE */
USE = 266, /* USE */
AVAID = 267, /* AVAID */
BIN15 = 268, /* BIN15 */
BIN31 = 269, /* BIN31 */
BIT = 270, /* BIT */
BYTE = 271, /* BYTE */
CHARACTER = 272, /* CHARACTER */
ENTITY = 273, /* ENTITY */
FATWORD = 274, /* FATWORD */
OBJID = 275, /* OBJID */
REGID = 276, /* REGID */
VARSTRING = 277, /* VARSTRING */
WORDS = 278, /* WORDS */
A = 279, /* A */
O = 280, /* O */
R = 281, /* R */
OR = 282, /* OR */
XOR = 283, /* XOR */
AND = 284, /* AND */
ADD = 285, /* ADD */
SUB = 286, /* SUB */
MUL = 287, /* MUL */
DIV = 288, /* DIV */
MOD = 289, /* MOD */
UMINUS = 290, /* UMINUS */
NOT = 291 /* NOT */
};
typedef enum yytokentype yytoken_kind_t;
#endif
/* Token kinds. */
#define YYEMPTY -2
#define YYEOF 0
#define YYerror 256
#define YYUNDEF 257
#define Name 258
#define Number 259
#define String 260
#define BitString 261
#define Rawline 262
#define INCLUDE 263
#define DEFINE 264
#define ENDDEFINE 265
#define USE 266
#define AVAID 267
#define BIN15 268
#define BIN31 269
#define BIT 270
#define BYTE 271
#define CHARACTER 272
#define ENTITY 273
#define FATWORD 274
#define OBJID 275
#define REGID 276
#define VARSTRING 277
#define WORDS 278
#define A 279
#define O 280
#define R 281
#define OR 282
#define XOR 283
#define AND 284
#define ADD 285
#define SUB 286
#define MUL 287
#define DIV 288
#define MOD 289
#define UMINUS 290
#define NOT 291
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef int YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE yylval;
int yyparse (void);
#endif /* !YY_YY_Y_TAB_H_INCLUDED */