nathanielbabiak 2020-11-24 12:26 (Edited)
I thought someone might find these useful, figured I'd share my notes on how LowRes NX works (and common mistakes I keep making)...
^ | - | * / \ | MOD | + - | = <> | NOT | AND | OR XOR
\
), integer modulus (MOD
), boolean operators (NOT, AND, OR, XOR
), and array indexes each typecast to int
before operating.int
and float
.NOT
can yield a negative value, and TRUE
is a negative value (-1
).X\2^N
) predictably. They're signed!X*2^N
) predictably.X\2^N
) or rightwards (X*2^N
) predictably.CHR$(10)
prints/traces a new line, VAL("0X"+NUMERALS$)
converts hex.ROM(0)
and ROM(2)
, but not yet...float
(never int
), thus so-called integers are limited to 24 sequential bits (i.e., maybe avoid PEEKL
, POKEL
).POKEW
doesn't count as memory modification, just one cc.CALL subprogram
is 1 cc.CALL subprogram(0)
is 2 cc (it's just a regular argument).SUB SUBPROGRAM
is 0 cc, even with arguments.END SUB
is 1 cc (counts towards raster interrupt subprogram's cc).'True False Description (each count includes all assembly jumps, excludes ? evaluation.)
' 1 1 IF ? THEN ...
' 2 1 IF ? THEN ... END IF
' 2 1 IF ? THEN ... ELSE ...
' 2 2 IF ? THEN ... ELSE ... END IF
' 2 t3 f2 IF ? THEN ... ELSE IF ? THEN ... END IF
' 3 t3 f3 IF ? THEN ... ELSE IF ? THEN ... ELSE ... END IF
'Constant "FOR X = LO TO HI ... NEXT X" loops cost 4 cc initially and 3 cc per iter.
'Iter inner cc per iter inner cc total cc total outer cc
' 0 0 0 4 4
' 1 3 3 10 7
' 2 3 6 16 10
' 3 3 9 22 13
' 1 4 4 11 7
' 2 4 8 18 10
' 3 4 12 25 13
' 1 5 5 12 7
' 2 5 10 20 10
' 3 5 15 28 13
'Expr "FOR X = LO TO HI-1 ... NEXT X" loops cost 6 cc initially and 5 cc per iter.
'Iter inner cc per iter inner cc total cc total outer cc
' 0 0 0 6 6
' 1 3 3 14 11
' 2 3 6 22 16
' 3 3 9 30 21
' 1 4 4 15 11
rilden 2020-11-24 16:40
Another thing I found out:
LowRes NX waits 2 frames when PRINT causes text to scroll up. So if you print a lot of lines, the text will scroll at 30 frames per second.
was8bit 2020-11-24 17:13
Unless you use PRINT TEXT$;
Then it only scrolls when it reaches the end of the screen
was8bit 2020-11-24 17:15
Plus, if you already use WAIT VBL in a DO LOOP, that will also add to the timing of things..
Timo 2020-11-26 18:39
"Boolean (AND/OR/NOT) operators treat any float as 0."
What do you mean? I believe both values are casted to integer and then the operator is applied. All logical operators are also binary operators by the way. That's why "true" is -1 (all bits set).
"VAL("0X"+NUMERALS$) converts hex."
This one is not on purpose. I just used the C function internally. I didn't know it does this :O
"Figure out display order of PRINT vs BG 0/1 and PRIO 0/1, but not yet..."
PRINT uses the current WINDOW. And the window command lets you set the BG.
nathanielbabiak 2020-11-27 00:23
Yep - my mistake. I only ever tested floats between 0 and 0.9999, never 1.0 or higher.
qwaffe 2020-11-27 05:28 (Edited)
this post can really benefit from some markdown formatting.
i thought they were random numbers at first.
nathanielbabiak 2020-11-27 16:03 (Edited)
How do I add monospace? I tried double back-quotes (``) but it didn't work :-(
qwaffe 2020-11-28 02:36 (Edited)
put the text inside the back-quotes like normal quotes on single lines. (can be in-line.)
but code blocks are also possible. this can be quite helpful (:
nathanielbabiak 2020-11-28 03:34 (Edited)
Timo, I had to look up that emoji! Can you keep the hex conversion feature and the TRACE CHR$(10) feature? It'd be really nice to make them official...
was8bit 2020-11-28 05:28
I kinda would like to see VAL("%10") =2 and not 0... but its prolly not worth the effort to put it in...
Timo 2020-11-28 08:50 (Edited)
CHR$(10) is as expected so it’s official.
VAL(“0xFF”) doesn’t really make sense in the BASIC world as 0x is not the way here to indicate hex (it’s #).
I will probably not remove it, but I won’t add a binary version.
The only reason I see for it would be doing binary operations using strings instead of bit operators (AND OR XOR), but this is bad for performance and I won’t do this favor for was8bit ;)
was8bit 2020-11-28 09:12
oh my poor bit-brain 0o0 ;)
qwaffe 2020-11-28 11:19
isn't the way to indicate hex in nx "$" and not "#"?
was8bit 2020-11-28 12:25 (Edited)
Corerect, # and $ are side by side on the keyboard, i am sure that was just a typo... just for the record....
Hexadecimal and binary notation can be used for number values:
$FF02
%11001011
Timo 2020-11-28 12:59
Sorry, yes it's $. Wasn't a typo, I really don't know how my language works :O
was8bit 2020-11-28 15:08
You are busy with real life, its ok :)