Mrlegoboy 2019-06-04 17:07
How do cpu cycles get counted?
Timo 2019-06-04 19:10
It’s explained in the manual in the chapter “Advanced Topics > CPU Cycles” quite at the bottom.
If something is unclear just ask.
was8bit 2019-06-05 05:31
I just run DEBUG mode and watch the CPU %... if it goes to MAX then you are doing too much per WAIT VBL
Mrlegoboy 2019-06-06 17:58
I cant tell though what would this code take:
The wording suggests it could be anywhere from 2 to 4 cpu cycles
Mrlegoboy 2019-06-06 18:00
I say 2 because you access 1 variable and apply an operation, but it could be as much as 4 because you could say you access a variable, do an operation with a constant, and access the variable again to save that change
Timo 2019-06-06 18:19
Actually I think it’s 5. Of course in assembly/machine code you could do this in only one cycle. I already thought about adding an ADD command to have less variable accesses.
But I don’t want to add commands all the time. Some day in the future I will make a big update with several new commands.
Mrlegoboy 2019-06-06 20:43
What? How is it 5?
was8bit 2019-06-06 22:25 (Edited)
How about adding new operators...
X+=23 would be the same as x=x+23
X++ same as X=X+1 or INC in assembly
X-=23 same as X=X-23
X- - (without the space) same as X=X-1 or DEC
Timo 2019-06-07 07:56
These are the cycles:
- command (assign/LET)
- read target variable
- read variable
- plus operator
- read constant
That's a lot... I will read about CPUs to see if it makes sense to count constants. And in the future I might add simpler commands for incr/decr.
was8bit: I prefer commands with words, otherwise it doesn't look like BASIC ;)
Timo 2019-06-07 08:58
Ok, yes it makes sense. In assembly you usually have to load constants to a CPU register before you can calculate with them. At least on 8-bit CPUs like the one used in the Game Boy. So the simulation of CPU cycles in NX is more or less realistic (although very simplified).
Anyway I will add some optimized commands.
was8bit 2019-06-07 12:03
INC and DEC always felt logical to me, I always liked them... but like you said they always operated on whatever was loaded into the register...
an application to basic might be something like INC X , DEC X
the other might be X ADD 23, X MINUS 23
Timo 2019-06-07 15:44
I will steel them from AMOS Basic:
ADD v,exp [,base TO top]
IF v>top THEN v=base
IF v<base THEN v=top
was8bit 2019-06-07 17:25
Oooo, I've not seen the base,top portion, that's cool :)
Mrlegoboy 2019-06-09 16:36
Woah no way! You’re actually gonna add these? Thats wicked cool!
Timo 2019-06-15 11:14
Coming in the next update (core v0.15):
INC, DEC, ADD
was8bit 2019-06-15 16:18
Super cool :)
Mrlegoboy 2019-06-15 18:22
Cool! And one more thing, you might get annoyed from me asking, but can we please get the option to have a larger gamepad? I can’t use the small gamepad and I really liked the one on original lowres
Timo 2019-06-16 19:52
Changing the size of the gamepad is more work than it seems... I'll explain it later in another post.
was8bit 2019-06-16 20:16
How about programmable keypads... the virtual keypad could be created much like sprites are.. and each arrow and button keys would be the size of an 8x8 cell... and come preloaded with your images (kinda like fonts are) but users could load images from the character set by assigning new character# to each keypad image.. ???
... just thinking WAAAY outside the box... it’s not a request :)
moechofe 2019-06-22 20:00
@timo Did you know AMOS? I thought you was too young for that.
Timo 2019-06-23 07:57
I learned programming with AMOS, yes :) And it was a big inspiration for LowRes Coder and NX.
Mrlegoboy 2019-06-24 14:36 (Edited)
Lmao, Looking at the amos editor, its just like lowres