Example

Draw Recreation

2

The Emerald Derp Leader 2018-11-10 18:08 (Edited)

***************************************************
README:
- Use d-pad to move, A to switch color, and B to change size
- There are only 4 (including background) colors for now
- Max of 127 for X and Y
- Top right cell is not assigned because only 255 sprites are allowed
- Bottom left is origin (0,0)
- Debug mode shows coordinates
- DRAW , is now called PIX and takes (X,Y,COLOUR)
***************************************************

Roadmap:
=Find how to add more than 255 sprites
~~four colors~~
=five colors by synchronizing Palettes and ATTR
———————————————————
Versions:
0.2: two more colors, size change, no entering top right cell
0.1: release, on and off colors


Timo 2018-11-11 12:08 (Edited)

I posted my own demo called "Sine Drawing". Have a look how I set the pixels using binary operators. I use 4 colors, but I actually handle each bitplane separately so I get some kind of transparency effect when the two sine lines overlap.


The Emerald Derp Leader 2018-11-17 01:58

Read versions ^


was8bit 2018-11-17 06:50

Instead of adding your updated as a comment below, try editing your original top entry, it will auto replace the original with the updated version, bump the original down below it...,check out some of mine like the tank one :)


The Emerald Derp Leader 2018-11-17 14:08

Thanks


was8bit 2018-11-17 16:24

TIMO told me about it, I was doing like you too :)


The Emerald Derp Leader 2018-11-20 02:15

I’m might end up finding how to do this before anyone responds...similar to when asking for how to translate binary LOL... but I will ask anyway:

How does PEEK and POKE work for character data that is not in disk storage number 2 (i.e. main characters). To clarify, I want to use PEEK and POKE for the other disk spaces.


was8bit 2018-11-20 03:49

ROM(n) Where n= any file number 2-15
So, FILE5ADD=ROM(5) is the starting memory addresss for file 5
And FILE5LEN=SIZE(5) is the size of the file...

FOR I=1 TO FILE5LEN
B=PEEK(FILE5ADD+I
NEXT I

WOULD READ ALL THE DATA...


was8bit 2018-11-20 03:54

I handle data to and from a file in my MESSAGE FILE PRO, but you may only WRITE to a file when your program is installed as a TOOL and the source file is in another program... while in that other program you open up your installed TOOL program, and then the tool can edit your file, just like character editor and background editor work


was8bit 2018-11-20 03:55

So, in other words, you won't be able to POKE directly into a file...


Timo 2018-11-20 07:27

That's not really precise. A little definition:

ROM entries: The 16 data blocks which are in the same program.
Files: The 16 data blocks which are on the current virtual disk.
Virtual disk: Another .nx file. By default it's a file called "Disk.nx", or it's the program you are editing using a tool.

ROM entries and virtual files have the same format, but they work differently depending on their use.

You can use PEEK to read data from ROM, but you cannot edit it (it's read-only-memory).
You can PEEK and POKE into RAM (see memory map) and save the result into a virtual file (SAVE command).

Not sure if this explanation is better, but I tried ;)


Timo 2018-11-20 07:32

Ah, also important: The character data from ROM entry 2 is copied to video RAM automatically. You can PEEK and POKE into video RAM. You can copy a different ROM entry to video RAM manually using the COPY command.
Check the manual for "Memory Map" and "Memory Access".


was8bit 2018-11-20 10:11

Thanks for the very important info :D

It is all really cool how it all works, but it takes getting used to it by trying it out...

... even though I manage to get it right as I'm using it, it can still get a little confusing and I have to think about it for awhile ... with A LOT of practice it will eventually become second nature :)


The Emerald Derp Leader 2018-11-20 18:29

The main reason I was asking was so I could find out how to use more than 255 characters. However I can’t find a way to get around this. Any help would be appreciated, because this program is dead once again :(


Timo 2018-11-20 20:27

The only way is using a raster interrupt (ON RASTER CALL) and copy characters to the video memory.


The Emerald Derp Leader 2018-11-20 22:27

What do you mean?


was8bit 2018-11-21 05:30

graphics are drawn to the screen top to bottom, a single pixel high screen width line of graphics is called a raster line...

A raster interrupt allows you to change the graphics IN THE MIDDLE of a screen being drawn, allowing for tricks you couldn't do after the whole screen is already drawn..


Timo 2018-11-21 06:44

Check my Mario Parallax Demo to see examples what you can do with it.


The Emerald Derp Leader 2018-11-21 16:19 (Edited)

Ok I will try that. My phone restricts me from the games section and forums (until recently, it worked before), so I can’t view any games unless I have my computer; furthermore, I am on a vacation so I don’t have my computer.


was8bit 2018-11-23 06:29

Hey, I love this program :) I made a remix of it with touch control :)


The Emerald Derp Leader 2018-12-03 01:00

how many cpu cycles do each of these use up?

1: var = 0
2: var = var + 1
3: cell var,0,1
4: if var = 1 then
5: for var = 0 to 1
6: trace var


Timo 2018-12-03 07:50 (Edited)

This is from the manual. If it's unclear, I'll try to improve the description:

Each execution of a command, function or operator, as well as access to a variable or a constant count 1 cycle. Some operations have additional costs:

- String creation and modification count 1 cycle per letter.
- Array initialization counts 1 cycle per element.
- Memory area modification counts 1 cycle per byte (not single byte modifications like POKE).
-BG area modification and text output count 2 cycles per cell (not single cell modifications like CELL).

...actually with some of your examples I'm not sure neither...
but for example "var = var + 1" should be 5 cycles.


The Emerald Derp Leader 2018-12-03 16:45 (Edited)

I don’t think it will be possible to handle all 20*16 cells, so one cell—namely that evil top right cell— will be my goal.

I think that the top 12 rows could be handled without raster interrupt, but all of the last 4 rows (80 cells) could not be handled within raster interrupt.

Not to say that there would probably be multiple raster interrupt subprograms that are switched between just to optimize cpu cycles.


Timo 2018-12-03 20:33

It is possible, but complicated. Someone at the "Fantasy Consoles" Discord server made it (it's not from me)

FrameBuffer.nx | Open in app
2018-12-03 20:33

Timo 2018-12-03 20:36

Note: It's a nice challenge to make it work, but it's still not the preferred way to make game graphics in NX, as it's much slower than using tiles and sprites. Might be useful for a drawing tool though.


The Emerald Derp Leader 2018-12-03 23:46

I thought I was going to be the first to make this, but I can still be the first to implement multiple colors :)

Well, at least I know that it is possible


The Emerald Derp Leader 2018-12-11 19:12 (Edited)

Oh, one more CPU cycle question:

How many are used in... y = SQR(x)

If this is only 4, then what would happen if a lot of the cycles were only calculating the square roots of non prefect squares?


Timo 2018-12-11 20:50

Hm, I don't really understand what you mean, but yes, your example are 4 CPU cycles. All math functions cost the same, it's very simplified (and unrealistic).


The Emerald Derp Leader 2018-12-12 11:16 (Edited)

I thought square roots took more CPU to calculate and should be avoided from doing multiple times for many frames.

Edit: I mean in general programming


was8bit 2018-12-12 12:13

You can do what I've done, create an extreme test program that runs an intense test with an extreme iteration cycle, capture the TIMER amount at the beginning and end, don't use any WAIT or PRINT or anything during the test, and compare the time for that extreme test against the same empty iteration cycle....

I've done this for regular LowRes to test different approaches with complex loops and such and i went with the approach that took less time :)


was8bit 2018-12-12 12:15

You have to run the same test a few times, a side I've noticed that on my iPad it doesn't always dedicate itself to running LowRes, some times will vary slightly as you rerrun the test....take an average time of a few runs...


Timo 2018-12-12 17:38

Ok, in "real" programming square roots are more expensive, but in LowRes NX it's just one cycle like all functions.


Timo 2019-01-24 20:02

This needs a little update to work with v0.11.


Log in to reply.