From 245459ae8c15554418d6d54ba0ab220b9eba0620 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Tue, 17 Apr 2012 18:23:52 +0000 Subject: cleanup, make it build on linux (freebsd-make) --- Makefile | 2 +- dcpu16.h | 4 +++- gramar.y | 18 ++++++++++++++---- main.c | 2 +- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 6021e10..482290f 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # $Id$ PROG= dcpu -SRCS= gramar.y lexer.l emu.c main.c tui.c +SRCS= gramar.y lexer.l emu.c main.c tui.c y.tab.h NOMAN= LDADD+= -lcurses #DEBUG= -Wall -ggdb -pg diff --git a/dcpu16.h b/dcpu16.h index 646dd5c..9ede832 100644 --- a/dcpu16.h +++ b/dcpu16.h @@ -41,7 +41,9 @@ enum { Res, JSR, BRK, nExt }; /* display: 32x12 (128x96) + 16 pixel boarder, font 8x4 */ -unsigned short *compile(FILE *); +unsigned short *compile(FILE *, size_t); int step(unsigned short *, unsigned short *); +void tuiemu(unsigned short *, unsigned short *); + #endif diff --git a/gramar.y b/gramar.y index 61fdd1a..806917d 100644 --- a/gramar.y +++ b/gramar.y @@ -18,13 +18,18 @@ %{ #include #include +#include #include -#include "dcpu16.h" extern int yylineno; extern FILE *yyin; int yylex(void); int yyparse(void); +void yyerror(const char *); +void push(int, char *); +void popop(int); +void popall(void); +void addref(char *); #if YYDEBUG extern int yydebug; @@ -39,8 +44,8 @@ int sp = 0; int rp = 0; int pc = 0; -unsigned short buffer[MEMSZ]; -char *label[MEMSZ]; +unsigned short *buffer; +char **label; %} @@ -267,14 +272,19 @@ restorerefs(void) } unsigned short * -compile(FILE *fd) +compile(FILE *fd, size_t sz) { + buffer = calloc(sz, sizeof(unsigned short)); + label = calloc(sz, sizeof(char *)); + #if YYDEBUG yydebug = 1; #endif + yyin = fd; yyparse(); restorerefs(); + free(label); return buffer; } diff --git a/main.c b/main.c index 35a7411..d7cbfa0 100644 --- a/main.c +++ b/main.c @@ -81,7 +81,7 @@ main(int argc, char **argv) if (!fd) err(1, "cannot open file"); - m = compile(fd); + m = compile(fd, MEMSZ); fclose(fd); if (e_flag) -- cgit v1.2.3