Directmode Test


My first “Directmode” quick test coded in FemtoIDE (Java?).


Directmode Test.bin (38.1 KB) (6.2 KB)


Another direct mode test. I’ve added a few basic old-school gfx effects. Clearing previous frame produces some flicker, as there’s no “double buffering” nor “vertical retrace interrupt” available AFAIK. Scanline copy seems to work it out though it’s not much flexible and would need its own API.


Directmode Test 2.bin (42.2 KB) (10.7 KB)


Very nice. Have you tested these on HW?


Sorry, no hardware to test, only emulator. Everything is using the API for drawing to screen without going through a framebuffer except the scanline thing, which uses low level function calls included in in order to send a full RGB565 screen row. It seems emulator can’t keep a stable framerate (there’s a lot of stuttering) and I suppose timing data is not accurate, but hey, it works.


I tested on hardware, looks just like the emulator to me.


Hi @FManga, you did a very nice work with the emulator and also the FemtoIDE thing. I find it very user friendly, easy to setup and start hacking. IMHO, that was exactly what this platform needed. Congrats!


Good job on the demos, btw. It’s good to see things being done in Direct mode, we don’t use it enough.


Thanks! Not sure if Direct mode could be very useful for games, although I think currently there’s at least one game not using RAM framebuffer and it’s a very good game.

But I have some big ideas for some “advanced” demoscene-ish things once I get some more experience and understanding of the HW and APIs. For some of those ideas, I can’t afford to waste precious RAM on a framebuffer.


Third Direct mode graphics test. Some more 3d objects wireframe drawn and another funny use for the scanline buffer. Using Math.sin() and Math.cos() in inner loops, so framerate isn’t good. Also wireframe graphics flicker a lot due to erasing and redrawing on top.
Even without a full framebuffer, it seems I’m hitting memory allocation problems when I try objects with higher vertex counts. The ‘arrays’ I’m using are not very memory efficient and maybe I could use smaller size integer types, but I’m not sure if that’s the solution.

Definitely, I need to add my own static data. Currently I don’t know how to add look-up tables to be read directly from flash memory… FemtoIDE Java does allow it? I suppose the included images are automatically enclosed in a special class to be used through class functions but I need to include my own arrays of integers and access them directly from code.


Directmode Test 3.bin (51.0 KB) (21.9 KB)


Unfortunately, the Java language doesn’t have a good way of specifying a large amount of immutable data in code other than strings… but there is an alternative: you can import .bin files containing raw binary data:

pointer data = Binfile.bin();
byte b = (byte) System.memory.LDRB(data); // read 1 byte


Thanks, @FManga. I think I have a use case for it. Unfortunately I cannot get it to work. When I try to build, I get error ‘TypeError: right.isOfType is not a function’.
I have a binary file called Balloon.bin in the same folder as and my code looks like this:

import Balloon;
class Main extends State {
    pointer data = (new Balloon()).bin();
    void update(){
            byte w = (byte) System.memory.LDRB( data );

I have also tried to put ‘pointer data = (new Balloon()).bin();’ into the update() function, which could make sense as I don’t know how to move the pointer nor seek to start nor do random access.


Try adding a cast: pointer data = (pointer) (new Balloon()).bin();
That error message is a bug, I’m looking into it.
Edit: Fixed it, will do some more testing.

The import shouldn’t be necessary, since it’s in the same package.

To move the pointer you can simply add to it:

pointer data = Balloon.bin();
pointer offset = data + 1;

Edit 2:
Just remembered that the bin() method is static, shouldn’t need to instance Balloon. :man_facepalming:

pointer data =  Balloon.bin();


Thanks again, @FManga. I got it working!
Only for your eyes :wink:… the first (and only) HAM8 sw decoder for this platform. The demo packs 5 RGB666 (18 bit) images HAM8 “compressed” from 18 bit/pixel to 8 bit/pixel in just one binary.
Important: it runs ok on the emulator, but perhaps it doesn’t work on real hardware as the bin is pretty big and current loader might not leave enough room in flash. If that happens, dropping just one image and rebuilding should solve this issue. Also, don’t expect amazing image quality: in most real world pictures, conversion to 8 bit/pixel 256-color with good presets gives far better results.


Directmode Ham8.bin (225.8 KB)

Directmode (1.2 MB)

Just one more question: has anybody ever tried to enable LCD RGB666 mode in hardware? Does it work? Does the emulator support it? :sweat_smile:


Oh lovely!

Amiga, home of the finest ham in the world.


Hey, that looks really good!
It also runs ok on hardware, loaded over USB since it overwrites the loader.
As for RGB666, it can’t be used on the Pokitto. The screen is connected to the MCU by a 16-bit-wide bus.


Fifth Directmode test: full screen bitmap rotation of a 256x256 16bits RGB image. I wasn’t sure if 24.8 fixed point would give enough accuracy as updates in u/v coordinates are done incremental for speed. Textures are tiled to avoid off-limit tests.


Directmode BitmapRotation.bin (163.8 KB)

Directmode (1.8 MB)


Next: Rotozooming + crossfade :sweat_smile:

@jonne: I can change assets if you are not happy with current ones.


Directmode Crossfade.bin (100.3 KB)

Directmode (1.8 MB)


Lol. Ok. That’s fine by me!


Next: Plasma. Not as good as it used to be… I can’t remember how I did it years ago.


Directmode Plasma.bin (36.7 KB)

Directmode (93.3 KB)


Will you be adding licences to these at a later date?

Also, there is already an abs function, it’s Math.abs.