New instructions PEEK and POKE to call outside routines.

To use PEEK and POKE initialize uBASIC from your program with
ubasic_init_peek_poke(program, &peek, &poke) where "peek" is a
function peek(VARIABLE_TYPE addr) that returns VARIABLE_TYPE
and "poke" is a procedure void poke(VARIABLE_TYPE addr,
VARIABLE_TYPE value).

Use "PEEK addr, var" to set the value of the variable var to the
result of calling peek(addr). Use "POKE addr, value" to call
poke(addr, value);

The argument name "addr" is arbitrary; it doesn't mean you should
necessarily use it to pass your routines a memory address.
This commit is contained in:
Danyil Bohdan 2013-12-23 18:46:25 +02:00
parent f9ea3c6e6b
commit 93bb242eb0
6 changed files with 85 additions and 2 deletions

View file

@ -32,6 +32,9 @@
#include "vartype.h"
typedef VARIABLE_TYPE (*peek_func)(VARIABLE_TYPE);
typedef void (*poke_func)(VARIABLE_TYPE, VARIABLE_TYPE);
void ubasic_init(const char *program);
void ubasic_run(void);
int ubasic_finished(void);