-
Notifications
You must be signed in to change notification settings - Fork 2
7.0 Misc
There are a number of capabilities which do not fit in to the other categories, so for completeness, here they are.
Like a normal BASIC, statements with a line number will be stored in line-number sequence, overwriting any statements with the same line number. To delete a line entirely, just enter the line number without any statements.
To list a program use the list keyword as follows;
-
list <n>
- lists the whole program. Listing can be paused by pressing the space bar and un-paused with any other key. Using ctrl-c will stop the listing. If n is supplied then the listing starts from the first line number >=n rather than the first line -
list *
- lists all the procedure definitions in the order they were referenced or found (i.e. not sorted in any way) -
list <def>
- lists the defined procedure from thedef
to theenddef
the underscore is needed e.g.list _procName
(There was a renum feature that is lost to support sd card I/O)
dflat provides for rudimentary timers to help with game speed etc. There is an internal 50Hz counter which is based off a timer interrupt. The key thing to note is that as the counter is incremented during interrupts, the counter loses time whenever interrupts are disabled (e.g. during tape load/save). So do not rely on it as a precise counter.
-
reset variable:int
- this command snapshots the counter to the given variable. Note that the counter is 24 bit but variables are only 16 -
t=elapsed(variable:int)
- this function returns the number of 50Hz ticks (simply subtracts the 16 lowest bits of the counter from the variable)
Using reset
and elapsed
allows specific time period to be measured e.g.;
reset t:repeat:until elapsed(t)>50
will pause for 1 second. The value of this is of course that some other code can run inside the loop.
If what is needed is a simple synchronous delay, the simply use wait <int>
which will pause execution for the specific number of ticks.
dflat provides a pseudo random number generator that provides numbers between 0..255. The generator should be seeded before getting numbers from it.
-
a=rnd(0)
: generates the next number between 0..255 -
a=rnd(n)
: sets the random number seed to 'n'
It can be useful to use timers to initially seed the generator e.g.
; Load t with system ticks
t=reset t
; Initialise random number generator with t
t=rnd(t)
To get a number in a certain range, simply use the remainder operator or bitwise and operator.
No BASIC is complete without peeking and poking (unless you are using TI99/4a BASIC!);
-
peek(addr:int)
returns the byte value at the specified memory location -
poke addr:int,val:int
writes to memory address addr the low 8 bits of val -
deek(addr:int)
returns the 2 byte word value at the specific memory location -
doke addr:int,val:int
writes the memory address addr the two byte word val
I saw deek
and doke
first in Oric BASIC and thought it was a really useful feature, so here it is too!
Other features:
-
sgn(x:int)
is a sign function returning -1 if the number is <0, 0 if the number =0, and 1 if the number if >0