Directmode Test


#1

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

Directmode%20Test

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


#2

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.

1

Directmode Test 2.bin (42.2 KB)

Main.java (10.7 KB)


#3

Very nice. Have you tested these on HW?


#4

Sorry, no hardware to test, only emulator. Everything is using the femto.mode.direct API for drawing to screen without going through a framebuffer except the scanline thing, which uses low level function calls included in ST7775.java 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.


#5

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


#6

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!


#7

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


#8

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.


#9

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.

1

Directmode Test 3.bin (51.0 KB)

Main.java (21.9 KB)


#10

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:

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

#11

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 Main.java 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.


#12

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;
System.memory.LDRB(offset++);

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

pointer data =  Balloon.bin();

#13

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.

2

Directmode Ham8.bin (225.8 KB)

Directmode Ham8.zip (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:


#14

Oh lovely!

Amiga, home of the finest ham in the world.


#15

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.


#16

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.

2

Directmode BitmapRotation.bin (163.8 KB)

Directmode BitmapRotation.zip (1.8 MB)


#17

Next: Rotozooming + crossfade :sweat_smile:

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

1

Directmode Crossfade.bin (100.3 KB)

Directmode Crossfade.zip (1.8 MB)


#18

Lol. Ok. That’s fine by me!


#19

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

1

Directmode Plasma.bin (36.7 KB)

Directmode Plasma.zip (93.3 KB)


#20

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

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