Download data/Basic1/TinyVT52/basic.h from introvoyz041/tinybasic: direct link, hf CLI and curl.
- Browser
- Download file 31.4 kB
-
https://huggingface.co/datasets/introvoyz041/tinybasic/resolve/main/data/Basic1/TinyVT52/basic.h
- Command line
-
hf download hf://datasets/introvoyz041/tinybasic/data/Basic1/TinyVT52/basic.h
-
curl -L -o basic.h https://huggingface.co/datasets/introvoyz041/tinybasic/resolve/main/data/Basic1/TinyVT52/basic.h
31.4 kB
| /* | |
| * | |
| * $Id: basic.h,v 1.9 2022/08/15 18:08:56 stefan Exp stefan $ | |
| * | |
| * Stefan's basic interpreter | |
| * | |
| * Playing around with frugal programming. See the licence file on | |
| * https://github.com/slviajero/tinybasic for copyright/left. | |
| * (GNU GENERAL PUBLIC LICENSE, Version 3, 29 June 2007) | |
| * | |
| * Author: Stefan Lenz, sl001@serverfabrik.de | |
| * | |
| * basic.h are the core defintions and function protypes | |
| * | |
| */ | |
| /* | |
| * if the PROGMEM macro is define we compile on the Arduino IDE | |
| * we undef all hardware settings otherwise a little odd | |
| */ | |
| /* | |
| * MSDOS, Mac, Linux and Windows | |
| */ | |
| typedef unsigned char uint8_t; | |
| /* the small memory model with shallow stacks and small buffers */ | |
| /* the for larger microcontrollers and real computers */ | |
| /* more duffers and vars */ | |
| /* default sizes of arrays and strings if they are not DIMed */ | |
| /* | |
| * the time intervall in ms needed for | |
| * ESP8266 yields, network client loops | |
| * and other timing related functions | |
| */ | |
| /* the default EEPROM dummy size */ | |
| /* | |
| * The tokens for the BASIC keywords | |
| * | |
| * All single character operators are their own tokens | |
| * ASCII values above 0x7f are used for tokens of keywords. | |
| * EOL is a token | |
| */ | |
| /* multi character tokens - BASEKEYWORD (3) */ | |
| /* this is the Palo Alto Language Set (19) */ | |
| /* this is the Apple 1 language set in addition to Palo Alto (14) */ | |
| /* Stefan's tinybasic additions (12) */ | |
| /* Arduino functions (10) */ | |
| /* the DOS functions (5) */ | |
| /* low level access of internal routines (2) */ | |
| /* mathematical functions (7) */ | |
| /* graphics - experimental - rudimentary (7) */ | |
| /* the Dartmouth extensions (6) */ | |
| /* the latecomer ELSE */ | |
| /* darkarts (3) */ | |
| /* iot extensions (9) */ | |
| /* constants used for some obscure purposes */ | |
| /* UNKNOWN is not used in the current code, the | |
| * lexer tokenizes everything blindly. There is a UNKNOWN hook | |
| * in statement for a grammar aware lexer */ | |
| /* the number of keywords, and the base index of the keywords */ | |
| /* | |
| * Interpreter states | |
| * SRUN means running from a programm | |
| * SINT means interactive mode | |
| * SERUN means running directly from EEPROM | |
| * (enum would be the right way of doing this.) | |
| * BREAKCHAR is the character stopping the program on Ardunios | |
| * BREAKPIN can be set, it is a pin that needs to go to low to stop a BASIC program | |
| * This should be done in hardware*.h | |
| * | |
| */ | |
| /* | |
| * Arduino input and output channels | |
| */ | |
| /* | |
| * All BASIC keywords for the tokens | |
| */ | |
| const char sge[] PROGMEM = "=>"; | |
| const char sle[] PROGMEM = "<="; | |
| const char sne[] PROGMEM = "<>"; | |
| /* Palo Alto language set */ | |
| const char sprint[] PROGMEM = "PRINT"; | |
| const char slet[] PROGMEM = "LET"; | |
| const char sinput[] PROGMEM = "INPUT"; | |
| const char sgoto[] PROGMEM = "GOTO"; | |
| const char sgosub[] PROGMEM = "GOSUB"; | |
| const char sreturn[] PROGMEM = "RETURN"; | |
| const char sif[] PROGMEM = "IF"; | |
| const char sfor[] PROGMEM = "FOR"; | |
| const char sto[] PROGMEM = "TO"; | |
| const char sstep[] PROGMEM = "STEP"; | |
| const char snext[] PROGMEM = "NEXT"; | |
| const char sstop[] PROGMEM = "STOP"; | |
| const char slist[] PROGMEM = "LIST"; | |
| const char snew[] PROGMEM = "NEW"; | |
| const char srun[] PROGMEM = "RUN"; | |
| const char sabs[] PROGMEM = "ABS"; | |
| const char srnd[] PROGMEM = "RND"; | |
| const char ssize[] PROGMEM = "SIZE"; | |
| const char srem[] PROGMEM = "REM"; | |
| /* Apple 1 language set */ | |
| const char snot[] PROGMEM = "NOT"; | |
| const char sand[] PROGMEM = "AND"; | |
| const char sor[] PROGMEM = "OR"; | |
| const char slen[] PROGMEM = "LEN"; | |
| const char ssgn[] PROGMEM = "SGN"; | |
| const char speek[] PROGMEM = "PEEK"; | |
| const char sdim[] PROGMEM = "DIM"; | |
| const char sclr[] PROGMEM = "CLR"; | |
| const char shimem[] PROGMEM = "HIMEM"; | |
| const char stab[] PROGMEM = "TAB"; | |
| const char sthen[] PROGMEM = "THEN"; | |
| const char sbend[] PROGMEM = "END"; | |
| const char spoke[] PROGMEM = "POKE"; | |
| /* Stefan's basic additions */ | |
| const char scont[] PROGMEM = "CONT"; | |
| const char ssqr[] PROGMEM = "SQR"; | |
| const char spow[] PROGMEM = "POW"; | |
| const char smap[] PROGMEM = "MAP"; | |
| const char sdump[] PROGMEM = "DUMP"; | |
| const char sbreak[] PROGMEM = "BREAK"; | |
| /* LOAD and SAVE is always there */ | |
| const char ssave[] PROGMEM = "SAVE"; | |
| const char sload[] PROGMEM = "LOAD"; | |
| const char sget[] PROGMEM = "GET"; | |
| const char sput[] PROGMEM = "PUT"; | |
| const char sset[] PROGMEM = "SET"; | |
| const char scls[] PROGMEM = "CLS"; | |
| /* Arduino functions */ | |
| const char spinm[] PROGMEM = "PINM"; | |
| const char sdwrite[] PROGMEM = "DWRITE"; | |
| const char sdread[] PROGMEM = "DREAD"; | |
| const char sawrite[] PROGMEM = "AWRITE"; | |
| const char saread[] PROGMEM = "AREAD"; | |
| const char sdelay[] PROGMEM = "DELAY"; | |
| const char smillis[] PROGMEM = "MILLIS"; | |
| const char sazero[] PROGMEM = "AZERO"; | |
| const char sled[] PROGMEM = "LED"; | |
| const char stone[] PROGMEM = "PLAY"; | |
| const char splusein[] PROGMEM = "PULSEIN"; | |
| /* DOS functions */ | |
| const char scatalog[] PROGMEM = "CATALOG"; | |
| const char sdelete[] PROGMEM = "DELETE"; | |
| const char sfopen[] PROGMEM = "OPEN"; | |
| const char sfclose[] PROGMEM = "CLOSE"; | |
| const char sfdisk[] PROGMEM = "FDISK"; | |
| /* low level access functions */ | |
| const char susr[] PROGMEM = "USR"; | |
| const char scall[] PROGMEM = "CALL"; | |
| /* mathematics */ | |
| const char ssin[] PROGMEM = "SIN"; | |
| const char scos[] PROGMEM = "COS"; | |
| const char stan[] PROGMEM = "TAN"; | |
| const char satan[] PROGMEM = "ATAN"; | |
| const char slog[] PROGMEM = "LOG"; | |
| const char sexp[] PROGMEM = "EXP"; | |
| /* INT is always needed to make float/int programs compatible */ | |
| const char sint[] PROGMEM = "INT"; | |
| /* elemetars graphics */ | |
| const char scolor[] PROGMEM = "COLOR"; | |
| const char splot[] PROGMEM = "PLOT"; | |
| const char sline[] PROGMEM = "LINE"; | |
| const char scircle[] PROGMEM = "CIRCLE"; | |
| const char srect[] PROGMEM = "RECT"; | |
| const char sfcircle[] PROGMEM = "FCIRCLE"; | |
| const char sfrect[] PROGMEM = "FRECT"; | |
| /* Dartmouth BASIC extensions */ | |
| const char sdata[] PROGMEM = "DATA"; | |
| const char sread[] PROGMEM = "READ"; | |
| const char srestore[] PROGMEM = "RESTORE"; | |
| const char sdef[] PROGMEM = "DEF"; | |
| const char sfn[] PROGMEM = "FN"; | |
| const char son[] PROGMEM = "ON"; | |
| /* a latecomer the ELSE command */ | |
| const char selse[] PROGMEM = "ELSE"; | |
| /* The Darkarts commands unthinkable in Dartmouth */ | |
| const char smalloc[] PROGMEM = "MALLOC"; | |
| const char sfind[] PROGMEM = "FIND"; | |
| const char seval[] PROGMEM = "EVAL"; | |
| /* iot extensions */ | |
| const char sassign[] PROGMEM = "ASSIGN"; | |
| const char savail[] PROGMEM = "AVAIL"; | |
| const char sstr[] PROGMEM = "STR"; | |
| const char sinstr[] PROGMEM = "INSTR"; | |
| const char sval[] PROGMEM = "VAL"; | |
| const char snetstat[] PROGMEM = "NETSTAT"; | |
| const char ssensor[] PROGMEM = "SENSOR"; | |
| const char swire[] PROGMEM = "WIRE"; | |
| const char ssleep[] PROGMEM = "SLEEP"; | |
| /* zero terminated keyword storage */ | |
| const char* const keyword[] PROGMEM = { | |
| sge, sle, sne, sprint, slet, sinput, | |
| sgoto, sgosub, sreturn, sif, sfor, sto, | |
| sstep, snext, sstop, slist, snew, srun, | |
| sabs, srnd, ssize, srem, | |
| snot, sand, sor, slen, ssgn, speek, sdim, | |
| sclr, shimem, stab, sthen, | |
| sbend, spoke, | |
| scont, ssqr, spow, smap, sdump, sbreak, | |
| ssave, sload, | |
| sget, sput, sset, scls, | |
| spinm, sdwrite, sdread, sawrite, saread, | |
| sdelay, smillis, sazero, sled, | |
| stone, | |
| splusein, | |
| scatalog, sdelete, sfopen, sfclose, sfdisk, | |
| susr, scall, | |
| ssin, scos, stan, satan, slog, sexp, | |
| sint, | |
| scolor, splot, sline, scircle, srect, | |
| sfcircle, sfrect, | |
| sdata, sread, srestore, sdef, sfn, son, | |
| selse, | |
| smalloc, sfind, seval, | |
| sassign, savail, sstr, sinstr, sval, | |
| snetstat, ssensor, swire, ssleep, | |
| 0 | |
| }; | |
| /* the zero terminated token dictonary needed for scalability */ | |
| const signed char tokens[] PROGMEM = { | |
| GREATEREQUAL, LESSEREQUAL, NOTEQUAL, TPRINT, TLET, | |
| TINPUT, TGOTO, TGOSUB, TRETURN, TIF, TFOR, TTO, TSTEP, | |
| TNEXT, TSTOP, TLIST, TNEW, TRUN, TABS, TRND, TSIZE, TREM, | |
| TNOT, TAND, TOR, TLEN, TSGN, TPEEK, TDIM, TCLR, | |
| THIMEM, TTAB, TTHEN, TEND, TPOKE, | |
| TCONT, TSQR, TPOW, TMAP, TDUMP, TBREAK, | |
| TSAVE, TLOAD, | |
| TGET, TPUT, TSET, TCLS, | |
| TPINM, TDWRITE, TDREAD, TAWRITE, TAREAD, TDELAY, TMILLIS, | |
| TAZERO, TLED, | |
| TTONE, | |
| TPULSEIN, | |
| TCATALOG, TDELETE, TOPEN, TCLOSE, TFDISK, | |
| TUSR, TCALL, | |
| TSIN, TCOS, TTAN, TATAN, TLOG, TEXP, | |
| TINT, | |
| TCOLOR, TPLOT, TLINE, TCIRCLE, TRECT, | |
| TFCIRCLE, TFRECT, | |
| TDATA, TREAD, TRESTORE, TDEF, TFN, TON, | |
| TELSE, | |
| TMALLOC, TFIND, TEVAL, | |
| TASSIGN, TAVAIL, TSTR, TINSTR, TVAL, TNETSTAT, | |
| TSENSOR, TWIRE, TSLEEP, | |
| 0 | |
| }; | |
| /* | |
| * the message catalog | |
| */ | |
| const char mfile[] PROGMEM = "file.bas"; | |
| const char mprompt[] PROGMEM = "> "; | |
| const char mgreet[] PROGMEM = "Stefan's Basic 1.4a"; | |
| const char mline[] PROGMEM = "LINE"; | |
| const char mnumber[] PROGMEM = "NUMBER"; | |
| const char mvariable[] PROGMEM = "VARIABLE"; | |
| const char marray[] PROGMEM = "ARRAY"; | |
| const char mstring[] PROGMEM = "STRING"; | |
| const char mstringv[] PROGMEM = "STRINGVAR"; | |
| const char egeneral[] PROGMEM = "Error"; | |
| const char eunknown[] PROGMEM = "Syntax"; | |
| const char enumber[] PROGMEM = "Number"; | |
| const char edivide[] PROGMEM = "Div by 0"; | |
| const char eline[] PROGMEM = "Unknown Line"; | |
| const char ereturn[] PROGMEM = "Return"; | |
| const char enext[] PROGMEM = "Next"; | |
| const char egosub[] PROGMEM = "GOSUB"; | |
| const char efor[] PROGMEM = "FOR"; | |
| const char emem[] PROGMEM = "Memory"; | |
| const char estack[] PROGMEM = "Stack"; | |
| const char edim[] PROGMEM = "DIM"; | |
| const char erange[] PROGMEM = "Range"; | |
| const char estring[] PROGMEM = "String"; | |
| const char evariable[] PROGMEM = "Variable"; | |
| const char efile[] PROGMEM = "File"; | |
| const char efun[] PROGMEM = "Function"; | |
| const char eargs[] PROGMEM = "Args"; | |
| const char eeeprom[] PROGMEM = "EEPROM"; | |
| const char esdcard[] PROGMEM = "SD card"; | |
| const char* const message[] PROGMEM = { | |
| mfile, mprompt, mgreet, | |
| mline, mnumber, mvariable, marray, | |
| mstring, mstringv, | |
| egeneral | |
| , eunknown, enumber, edivide, eline, ereturn, | |
| enext, egosub, efor, emem, estack, edim, erange, | |
| estring, evariable, efile, efun, eargs, | |
| eeeprom, esdcard | |
| }; | |
| /* | |
| * code for variable numbers and addresses sizes | |
| * the original code was 16 bit but can be extended here | |
| * to arbitrary types | |
| * | |
| * number_t is the type for numerical work - either float or int | |
| * wnumber_t is the type containing the largest printable integer, | |
| * for float keep this int on 32 bit and long on 8 bit unless you | |
| * want to use very long integers, like 64 or 128 bit types. | |
| * address_t is an unsigned type adddressing memory | |
| * mem_t is a SIGNED 8bit character type. | |
| * index_t is a SIGNED minimum 16 bit integer type | |
| * | |
| * works with the tacit assumption that | |
| * sizeof(number_t) >= sizeof(address_t) | |
| * and that the entire memory is smaller than the positive | |
| * part of number type (!!) | |
| * | |
| * we assume that float >= 4 bytes in the following | |
| * | |
| * maxnum: the maximum accurate(!) integer of a | |
| * 32 bit float | |
| * strindexsize: the index size of strings either | |
| * 1 byte or 2 bytes - no other values supported | |
| * | |
| * | |
| */ | |
| typedef float number_t; | |
| const number_t maxnum=16777216; | |
| typedef long wnumber_t; | |
| typedef int number_t; | |
| typedef int wnumber_t; | |
| const number_t maxnum=(number_t)~((number_t)1<<(sizeof(number_t)*8-1)); | |
| typedef unsigned short address_t; /* this type addresses memory */ | |
| const int numsize=sizeof(number_t); | |
| const int addrsize=sizeof(address_t); | |
| const int eheadersize=sizeof(address_t)+1; | |
| const int strindexsize=2; /* default in the meantime, strings up to unsigned 16 bit length */ | |
| const address_t maxaddr=(address_t)(~0); | |
| typedef signed char mem_t; /* a signed 8 bit type for the memory */ | |
| typedef short index_t; /* this type counts at least 16 bit */ | |
| /* | |
| * system type identifiers | |
| */ | |
| /* | |
| * The basic interpreter is implemented as a stack machine | |
| * with global variable for the interpreter state, the memory | |
| * and the arithmetic during run time. | |
| * | |
| * stack is the stack memory and sp controls the stack. | |
| * | |
| * ibuffer is an input buffer and *bi a pointer to it. | |
| * | |
| * sbuffer is a short buffer for arduino progmem access. | |
| * | |
| * vars is a static array of 26 single character variables. | |
| * | |
| * mem is the working memory of the basic interperter. | |
| * | |
| * x, y, xc, yc are two n*8 bit and two 8 bit accumulators. | |
| * | |
| * ax, ax are address type accumulators. | |
| * | |
| * z is a mixed n*8 bit accumulator | |
| * | |
| * ir, ir2 are general index registers for string processing. | |
| * | |
| * token contains the actually processes token. | |
| * | |
| * er is the nontrapable error status | |
| * | |
| * ert is the trapable error status | |
| * | |
| * st, here and top are the interpreter runtime controls. | |
| * | |
| * nvars is the number of vars the interpreter has stored. | |
| * | |
| * form is used for number formation Palo Alto BASIC style. | |
| * | |
| * charcount counts the printed characters to create a real TAB | |
| * only implemented on the serial stream | |
| * reltab controls if the relative char mechanisms is active | |
| * | |
| * rd is the random number storage. | |
| * | |
| * fnc counts the depth of for - next loop nesting | |
| * | |
| * args is the global arg count variable | |
| * | |
| * id and od are the input and output model for an arduino | |
| * they are set to serial by default | |
| * | |
| * idd and odd are the default values of the above | |
| * | |
| * debuglevel is the statement loop debug level | |
| * | |
| * data is the data pointer of the READ/DATA mechanism | |
| * | |
| * static keyword here is obsolete on most platforms | |
| * | |
| */ | |
| static number_t stack[STACKSIZE]; | |
| static address_t sp=0; | |
| static char sbuffer[SBUFSIZE]; | |
| static char ibuffer[BUFSIZE] = "\0"; | |
| static char *bi; | |
| static number_t vars[VARSIZE]; | |
| static mem_t mem[MEMSIZE]; | |
| static mem_t* mem; | |
| static address_t himem, memsize; | |
| static struct {mem_t varx; mem_t vary; address_t here; number_t to; number_t step;} forstack[FORDEPTH]; | |
| static index_t forsp = 0; | |
| static mem_t fnc; | |
| static address_t gosubstack[GOSUBDEPTH]; | |
| static index_t gosubsp = 0; | |
| static number_t x, y; | |
| static mem_t xc, yc; | |
| static address_t ax, ay; | |
| /* this union is used to store larger objects into byte oriented memory */ | |
| struct twobytes {mem_t l; mem_t h;}; | |
| static union accunumber { number_t i; address_t a; struct twobytes b; mem_t c[sizeof(number_t)]; } z; | |
| static char *ir, *ir2; | |
| static mem_t token; | |
| static mem_t er; | |
| static mem_t ert; | |
| static mem_t st; | |
| static address_t here; | |
| static address_t top; | |
| static address_t nvars = 0; | |
| static mem_t form = 0; | |
| static mem_t charcount = 0; | |
| static mem_t reltab = 0; | |
| static address_t arraylimit = 1; | |
| const static address_t arraylimit = 1; | |
| static mem_t args; | |
| /* this is unsigned hence address_t */ | |
| static address_t rd; | |
| /* output and input vector */ | |
| static mem_t id; | |
| static mem_t od; | |
| /* default IO - not constant, can be changed at runtime | |
| through a user call */ | |
| static mem_t idd = ISERIAL; | |
| static mem_t odd = OSERIAL; | |
| /* the runtime debuglevel */ | |
| static mem_t debuglevel = 0; | |
| /* data pointer */ | |
| static address_t data = 0; | |
| /* | |
| * process command line arguments in the POSIX world | |
| * bnointafterrun is a flag to remember if called as command | |
| * line argument, in this case we don't return to interactive | |
| */ | |
| int bargc; | |
| char** bargv; | |
| mem_t bnointafterrun = 0; | |
| /* | |
| * Yield counter, we count when we did yield the last time | |
| * lastyield controlls the client loops of network functions | |
| * like mqtt, scanned keyboard, and USB. | |
| * | |
| * lastlongyield controls longterm functions like DHCP lease | |
| * renewal in Ethernet | |
| * | |
| * there variables are only needed if the platform has background | |
| * tasks | |
| */ | |
| static long lastyield=0; | |
| static long lastlongyield=0; | |
| /* formaters lastouttoken and spaceafterkeyword to make a nice LIST */ | |
| static mem_t lastouttoken; | |
| static mem_t spaceafterkeyword; | |
| /* | |
| * the cache for the heap search - helps the string code | |
| * the last found object on the heap is remembered. This is needed | |
| * because the string code sometime searches the heap twice during the | |
| * same operation. | |
| */ | |
| static mem_t bfindc, bfindd, bfindt; | |
| static address_t bfinda, bfindz; | |
| /* the interrupt vector - not yet implemented */ | |
| static short interruptvector; | |
| /* | |
| * Function prototypes, ordered by layers | |
| * HAL - hardware abstraction | |
| * Layer 0 - memory and I/O | |
| * Layer 1 - Program storage and control | |
| * Layer 2 - Where stuff happens | |
| */ | |
| /* | |
| * HAL - see hardware-*.h | |
| * This is the hardware abstraction layer of the BASIC | |
| * interpreter | |
| */ | |
| /* setup codes */ | |
| void timeinit(); | |
| void wiringbegin(); | |
| /* low level mem and hardware features */ | |
| long freeRam(); | |
| long freememorysize(); | |
| void restartsystem(); | |
| void activatesleep(long t); | |
| /* start the spi bus */ | |
| void spibegin(); | |
| /* | |
| * the hardware interface display driver functions, need to be | |
| * implemented for the display driver to work | |
| * dspupdate() only for display like Epapers | |
| */ | |
| void dspbegin(); | |
| void dspprintchar(char, mem_t, mem_t); | |
| void dspclear(); | |
| void dspupdate(); | |
| /* keyboard code */ | |
| void kbdbegin(); | |
| int kbdstat(char); | |
| char kbdavailable(); | |
| char kbdread(); | |
| char kbdcheckch(); | |
| /* graphics functions */ | |
| void rgbcolor(int, int, int); | |
| void vgacolor(short c); | |
| void vgascale(int*, int*); | |
| void plot(int, int); | |
| void line(int, int, int, int); | |
| void rect(int, int, int, int); | |
| void frect(int, int, int, int); | |
| void circle(int, int, int); | |
| void fcircle(int, int, int); | |
| /* text output to a VGA display */ | |
| void vgabegin(); | |
| int vgastat(char); | |
| void vgawrite(char); | |
| /* generic display code */ | |
| void dspwrite(char); | |
| void dspbegin(); | |
| int dspstat(char); | |
| char dspwaitonscroll(); | |
| char dspactive(); | |
| void dspsetupdatemode(char); | |
| char dspgetupdatemode(); | |
| void dspgraphupdate(); | |
| void dspsetscrollmode(char, short); | |
| void dspsetcursor(short, short); | |
| void dspbufferclear(); | |
| void dspscroll(mem_t, mem_t); | |
| void dspreversescroll(mem_t); | |
| void dspvt52(char *); | |
| /* real time clock */ | |
| char* rtcmkstr(); | |
| void rtcset(uint8_t, short); | |
| short rtcget(short); | |
| /* network and mqtt functions */ | |
| void netbegin(); | |
| char netconnected(); | |
| void mqttsetname(); | |
| void mqttbegin(); | |
| int mqttstat(char); | |
| int mqttstate(); | |
| void mqttsubscribe(char*); | |
| void mqttsettopic(char*); | |
| void mqttouts(char *, short); | |
| void mqttins(char *, short); | |
| char mqttinch(); | |
| /* low level EEPROM handling */ | |
| void ebegin(); | |
| void eflush(); | |
| address_t elength(); | |
| short eread(address_t); | |
| void eupdate(address_t, short); | |
| /* arduino io functions */ | |
| void aread(); | |
| void dread(); | |
| void awrite(number_t, number_t); | |
| void dwrite(number_t, number_t); | |
| void pinm(number_t, number_t); | |
| void bmillis(); | |
| void bpulsein(); | |
| void btone(short); | |
| /* timing control for ESP and network */ | |
| void byield(); | |
| void yieldfunction(); | |
| void longyieldfunction(); | |
| /* the file interface */ | |
| char* mkfilename(const char*); | |
| const char* rmrootfsprefix(const char*); | |
| void fsbegin(char); | |
| int fsstat(char); | |
| void filewrite(char); | |
| char fileread(); | |
| char ifileopen(const char*); | |
| void ifileclose(); | |
| char ofileopen(char*, const char*); | |
| void ofileclose(); | |
| int fileavailable(); | |
| void rootopen(); | |
| int rootnextfile(); | |
| int rootisfile(); | |
| const char* rootfilename(); | |
| int rootfilesize(); | |
| void rootfileclose(); | |
| void rootclose(); | |
| void formatdisk(short i); | |
| /* low level serial code */ | |
| void picogetchar(char); | |
| void picowrite(char); | |
| void picobegin(uint32_t); | |
| void picoins(char, short); | |
| void serialbegin(); | |
| int serialstat(char); | |
| char serialread(); | |
| void serialwrite(char); | |
| short serialcheckch(); | |
| short serialavailable(); | |
| void consins(char*, short); | |
| void prtbegin(); | |
| int prtstat(char); | |
| void prtset(int); | |
| char prtopen(char *, int); | |
| void prtclose(); | |
| char prtread(); | |
| void prtwrite(char); | |
| short prtcheckch(); | |
| short prtavailable(); | |
| /* generic wire access */ | |
| void wirebegin(); | |
| int wirestat(char); | |
| void wireopen(char, char); | |
| void wireins(char*, uint8_t); | |
| void wireouts(char*, uint8_t); | |
| short wireavailable(); | |
| /* RF24 radio input */ | |
| int radiostat(char); | |
| void radioset(int); | |
| uint64_t pipeaddr(char*); | |
| long pipeaddr(char*); | |
| void iradioopen(char*); | |
| void oradioopen(char*); | |
| void radioins(char*, short); | |
| void radioouts(char* , short); | |
| short radioavailable(); | |
| /* sensor control */ | |
| void sensorbegin(); | |
| number_t sensorread(short, short); | |
| /* SPI RAM code */ | |
| address_t spirambegin(); | |
| void spiramrawwrite(address_t, mem_t); | |
| mem_t spiramrawread(address_t ); | |
| /* | |
| * Layer 0 functions - I/O and memory management | |
| */ | |
| /* make room for BASIC */ | |
| address_t ballocmem(); | |
| /* handle files im EEPROM */ | |
| void eload(); | |
| void esave(); | |
| char autorun(); | |
| /* the variable heap from Apple 1 BASIC */ | |
| address_t bmalloc(mem_t, mem_t, mem_t, address_t); | |
| address_t bfind(mem_t, mem_t, mem_t); | |
| address_t blength (mem_t, mem_t, mem_t); | |
| /* normal variables of number_t */ | |
| void createvar(mem_t, mem_t); | |
| number_t getvar(mem_t, mem_t); | |
| void setvar(mem_t, mem_t, number_t); | |
| void clrvars(); | |
| /* low level memory access packing n*8bit bit into n 8 bit objects | |
| e* is for Arduino EEPROM */ | |
| void getnumber(address_t, mem_t); | |
| void setnumber(address_t, mem_t); | |
| void egetnumber(address_t, mem_t); | |
| void esetnumber(address_t, mem_t); | |
| /* array and string handling */ | |
| /* the multidim extension is experimental, here only 2 array dimensions implemented as test */ | |
| address_t createarray(mem_t, mem_t, address_t, address_t); | |
| void array(mem_t, mem_t, mem_t, address_t, address_t, number_t*); | |
| address_t createstring(char, char, address_t, address_t); | |
| char* getstring(char, char, address_t, address_t); | |
| number_t arraydim(char, char); | |
| address_t stringdim(char, char); | |
| address_t lenstring(char, char, address_t); | |
| void setstringlength(char, char, address_t, address_t); | |
| void setstring(char, char, address_t, char *, address_t, address_t); | |
| /* get keywords and tokens from PROGMEM */ | |
| char* getkeyword(unsigned short); | |
| char* getmessage(char); | |
| signed char gettokenvalue(char); | |
| void printmessage(char); | |
| /* error handling */ | |
| void error(mem_t); | |
| void reseterror(); | |
| void debugtoken(); | |
| void bdebug(const char*); | |
| /* the arithemtic stack */ | |
| void push(number_t); | |
| number_t pop(); | |
| void drop(); | |
| void clearst(); | |
| /* READ DATA handling */ | |
| void clrdata(); | |
| /* FOR NEXT GOSUB stacks */ | |
| void pushforstack(); | |
| void popforstack(); | |
| void dropforstack(); | |
| void clrforstack(); | |
| void pushgosubstack(); | |
| void popgosubstack(); | |
| void dropgosubstack(); | |
| void clrgosubstack(); | |
| /* general I/O initialisation */ | |
| void ioinit(); | |
| void iodefaults(); | |
| /* character and string I/O functions */ | |
| /* input */ | |
| char inch(); | |
| char checkch(); | |
| short availch(); | |
| void inb(char*, short); | |
| void ins(char*, address_t); | |
| /* output */ | |
| void outch(char); | |
| void outcr(); | |
| void outspc(); | |
| void outs(char*, address_t); | |
| void outsc(const char*); | |
| void outscf(const char *, short); | |
| /* I/O of number_t - floats and integers */ | |
| address_t parsenumber(char*, number_t*); | |
| address_t parsenumber2(char*, number_t*); | |
| address_t writenumber(char*, wnumber_t); | |
| address_t writenumber2(char*, number_t); | |
| char innumber(number_t*); | |
| void outnumber(number_t); | |
| /* | |
| * Layer 1 functions, provide data and do the heavy lifting | |
| * for layer 2 including lexical analysis, storing programs | |
| * and expression evaluation | |
| */ | |
| /* lexical analysis */ | |
| void whitespaces(); | |
| void nexttoken(); | |
| /* storing and retrieving programs */ | |
| char nomemory(number_t); | |
| void storetoken(); | |
| mem_t memread(address_t); | |
| mem_t memread2(address_t); | |
| void memwrite2(address_t, mem_t); | |
| void gettoken(); | |
| void firstline(); | |
| void nextline(); | |
| void clrlinecache(); | |
| void addlinecache(address_t, address_t); | |
| address_t findinlinecache(address_t); | |
| void findline(address_t); | |
| address_t myline(address_t); | |
| void moveblock(address_t, address_t, address_t); | |
| void zeroblock(address_t, address_t); | |
| void diag(); | |
| void storeline(); | |
| /* read arguments from the token stream and process them */ | |
| char termsymbol(); | |
| char expect(mem_t, mem_t); | |
| char expectexpr(); | |
| void parsearguments(); | |
| void parsenarguments(char); | |
| void parsesubscripts(); | |
| void parsefunction(void (*)(), short); | |
| void parseoperator(void (*)()); | |
| void parsesubstring(); | |
| /* mathematics and other functions for int and float */ | |
| void xabs(); | |
| void xsgn(); | |
| void xpeek(); | |
| void xmap(); | |
| void rnd(); | |
| void sqr(); | |
| void xpow(); | |
| /* string values and string evaluation */ | |
| char stringvalue(); | |
| void streval(); | |
| /* floating point functions */ | |
| void xsin(); | |
| void xcos(); | |
| void xtan(); | |
| void xatan(); | |
| void xlog(); | |
| void xexp(); | |
| void xint(); | |
| /* expression evaluation */ | |
| void factor(); | |
| void term(); | |
| void addexpression(); | |
| void compexpression(); | |
| void notexpression(); | |
| void andexpression(); | |
| void expression(); | |
| /* | |
| * Layer 2 - statements and functions | |
| * use the global variables | |
| */ | |
| /* basic commands of the core language set */ | |
| void xprint(); | |
| void lefthandside(address_t*, address_t*, address_t*, mem_t*); | |
| void assignnumber(signed char, char, char, address_t, address_t, char); | |
| void assignment(); | |
| void showprompt(); | |
| void xinput(); | |
| void xgoto(); | |
| void xreturn(); | |
| void xif(); | |
| /* optional FOR NEXT loops */ | |
| void findnextcmd(); | |
| void xfor(); | |
| void xbreak(); | |
| void xcont(); | |
| void xnext(); | |
| /* control commands and misc */ | |
| void outputtoken(); | |
| void xlist(); | |
| void xrun(); | |
| void xnew(); | |
| void xrem(); | |
| void xclr(); | |
| void xdim(); | |
| void xpoke(); | |
| void xtab(); | |
| void xdump(); | |
| void dumpmem(address_t, address_t); | |
| /* file access and other i/o */ | |
| void stringtobuffer(); | |
| void getfilename(char*, char); | |
| void xsave(); | |
| void xload(const char* f); | |
| void xget(); | |
| void xput(); | |
| void xset(); | |
| void xnetstat(); | |
| /* Arduino IO control interface */ | |
| void xdwrite(); | |
| void xawrite(); | |
| void xpinm(); | |
| void xdelay(); | |
| void xtone(); | |
| /* graphics commands */ | |
| void xcolor(); | |
| void xplot(); | |
| void xline(); | |
| void xrect(); | |
| void xcircle(); | |
| void xfrect(); | |
| void xfcircle(); | |
| /* the darkarts */ | |
| void xmalloc(); | |
| void xfind(); | |
| void xfind2(); | |
| void xeval(); | |
| /* IoT commands */ | |
| void xassign(); | |
| void xavail(); | |
| void xfsensor(); | |
| void xsleep(); | |
| /* File I/O functions */ | |
| char streq(const char*, char*); | |
| void xcatalog(); | |
| void xdelete(); | |
| void xopen(); | |
| void xfopen(); | |
| void xclose(); | |
| void xfdisk(); | |
| /* low level access functions */ | |
| void xcall(); | |
| void xusr(); | |
| /* the dartmouth stuff */ | |
| void xdata(); | |
| void nextdatarecord(); | |
| void xread(); | |
| void xrestore(); | |
| void xdef(); | |
| void xfn(); | |
| void xon(); | |
| /* the statement loop */ | |
| void statement(); | |
| /* stub for the interrupt code */ | |
| void handleinterrupt(); | |