dfl
New Member
Posts: 4
|
Post by dfl on Jun 18, 2018 14:58:42 GMT -8
Hey guys, hope you can help me.
I have (maybe) a basic question about the bitmap handlers. I can't use the GD2 library, so I wrote my own stuff. Most of the functions I need are already working, except the "bitmap_handler". I can't figured out how it works.
With this snipet, it's ok.
cmd_dl( BITMAP_HANDLE(0) ); cmd_dl( VERTEX2F(0, 0)); cmd_dl( BITMAP_SIZE(NEAREST, BORDER,BORDER, 16, 16) ); cmd_dl( BITMAP_LAYOUT(RGB332, 16, 16) );
cmd_inflate(0L, img_data, sizeof(img_data));
cmd_dl(DL_DISPLAY); cmd_dl(CMD_SWAP);
cmd_start();
I can load the "img_data" array, that was created using "g2asset" tool and removing the first 40 bytes (the inialization). Anyway, this part is the first 5 lines of this snipet. My array is 60 16x16 sprites.
Ok, so far, so good, it's working as expected.
But now, I need to add ten more 36x46 images. Using the "g2asset", I got a bigger asset file and then I added a few more lines to my code.
//handle 0 cmd_dl( BITMAP_HANDLE(0) ); cmd_dl( VERTEX2F(0, 0)); cmd_dl( BITMAP_SIZE(NEAREST, BORDER,BORDER, 16, 16) ); cmd_dl( BITMAP_LAYOUT(RGB332, 16, 16) );
//handle 1 cmd_dl( BITMAP_HANDLE(1) ); cmd_dl( VERTEX2F(0, 0)); cmd_dl( BITMAP_SIZE(NEAREST, BORDER,BORDER, 36, 43) ); cmd_dl( BITMAP_LAYOUT(RGB332, 36, 43) );
cmd_inflate(0L, img_data, sizeof(img_data));
cmd_dl(DL_DISPLAY); cmd_dl(CMD_SWAP); cmd_start();
Almost the same code, with a proper block, according to the "g2asset" tool (I just followed the 40 bytes init data). But at this point none of the images are working anymore, even the first ones that was working before. I imagine it could be the RAM_CMD buffer, around 4k, and my transfer is going to 6k+ or so. But I can't see anything on GD2 library to prevent this buffer overflow (or I just didn't understood how it works).
Then I tested a slightly different version.
//handle 0 cmd_dl( BITMAP_HANDLE(0) ); cmd_dl( VERTEX2F(0, 0)); cmd_dl( BITMAP_SIZE(NEAREST, BORDER,BORDER, 16, 16) ); cmd_dl( BITMAP_LAYOUT(RGB332, 16, 16) );
cmd_inflate(0L, img_data, sizeof(img_data));
cmd_dl(DL_DISPLAY); cmd_dl(CMD_SWAP); cmd_start(); //handle 1 cmd_dl( BITMAP_HANDLE(1) ); cmd_dl( VERTEX2F(0, 0)); cmd_dl( BITMAP_SIZE(NEAREST, BORDER,BORDER, 36, 43) ); cmd_dl( BITMAP_LAYOUT(RGB332, 36, 43) );
cmd_inflate(20000L, img2_data, sizeof(img2_data));
cmd_dl(DL_DISPLAY); cmd_dl(CMD_SWAP); cmd_start(); This one was splited in two blocks. The first read the 16x16 and the second load the extras images at 0x20000, an address from the top of my head, just to avoid the overlap (around 0x15000).
This one loads, but when I try to show an image from the handle "1" it just shows a white block. (it needs some address setting, maybe??)
Anyway, can someone more experienced point me some directions?
Thanks!
|
|
|
Post by jamesbowman on Jun 18, 2018 15:55:09 GMT -8
The gd2asset tool (like gd3asset for GD3) outputs a list of commands, not compressed data. These commands do all the setup for the bitmap handles.
Just to be clear: gd2asset outputs commands, not image data. These commands include image data, but also do all the BITMAP_SIZE and BITMAP_LAYOUT setup.
So you should probably be doing something like:
<send whole gd2asset block to the EVE>
cmd_dl( BITMAP_HANDLE(0) ); cmd_dl( VERTEX2F(0, 0));
cmd_dl( BITMAP_HANDLE(1) ); cmd_dl( VERTEX2F(16 * 100, 0));
cmd_dl(DL_DISPLAY); cmd_dl(CMD_SWAP);
cmd_start(); Does this make sense?
|
|
dfl
New Member
Posts: 4
|
Post by dfl on Jun 19, 2018 2:56:46 GMT -8
James, thanks for the reply. Those commands on my snippet comes from some analysis on the gd2assets output. My asset header is
static unsigned char img_data[] = { /* 0, 0, 0, 5, // BITMAP_HANDLE(0) 0, 0, 0, 1, // VERTEX2F (0,0) 16, 32, 0, 8, // BITMAP_SIZE 16, 32, 32, 7, // BITMAP_LAYOUT
1, 0, 0, 5, // BITMAP_HANDLE(1) 0, 60, 0, 1, // VERTEX2F (60,0) 43, 72, 0, 8, // BITMAP_SIZE 43, 72, 32, 7, // BITMAP_LAYOUT
34, 255, 255, 255, // INFLATE 0, 0, 0, 0, //PTR to 0x00000000 */ 120, 218, 237, 91, 191, 143, 27, 199, 146, 102, 96, 2, 135, 149, 2, (...) }
I'm assuming after the PTR all the rest is the data compressed. Is this correct? After read your reply, I tried to send all the data to the FT, using cs_set(); addr = 0x308000UL; // RAM_CMD
spi_transmit((0x80 | (addr >> 16)) & 0xff); spi_transmit((addr >> 8) & 0xff); spi_transmit((addr >> 0) & 0xff);
for (i = 0; i<sizeof(__assets); i++) { spi_transmit(__assets[i]); } cs_clear();
cmd_start(); But, nothing happened. Maybe a wrong address? Anyway, I tried send as you suggested too, all the data, then the init block, then execute, but nothing either. In your reply you include cmd_dl( VERTEX2F(16 * 100, 0)); maybe the "16" is the height in pixels, but why "100"? Is this the number of cells? should be "60", I guess. Is this the way to point the handler to the correct address on the image data on the RAM? Thanks for the help
|
|
dfl
New Member
Posts: 4
|
Post by dfl on Jun 19, 2018 5:10:50 GMT -8
i finally came to something that works
//handle 0 cmd_dl( BITMAP_HANDLE(0) ); cmd_dl( VERTEX2F(0, 0)); cmd_dl( BITMAP_SIZE(NEAREST, BORDER,BORDER, 16, 16) ); cmd_dl( BITMAP_LAYOUT(RGB332, 16, 16) );
//handle 1 cmd_dl( BITMAP_HANDLE(1) ); cmd_dl( VERTEX2F(0, 0)); cmd_dl( BITMAP_SOURCE(15360L) ); cmd_dl( BITMAP_SIZE(NEAREST, BORDER,BORDER, 36, 43) ); cmd_dl( BITMAP_LAYOUT(RGB332, 36, 43) ); cmd_inflate(0L, img_data, sizeof(img_data));
cmd_dl(DL_DISPLAY); cmd_dl(CMD_SWAP); cmd_start();
cmd_inflate(15360L, img2_data, sizeof(img2_data));
cmd_dl(DL_DISPLAY); cmd_dl(CMD_SWAP); cmd_start();
Note that I use two cmd_inflate for two separated assets array. The position addr 15360 is the next available address after the first decompression, so I pointed the handler "1" to this position using BITMAP_SOURCE and did a second inflate there.
So, to use a single array for all the assets I may have one of these two problems (or both).
1 - The cmd_inflate is overflowing the CMD_RAM (my combined arrays are around 6K and the buffer just 4k) 2 - g2asset generate more EVE commands between each of the data images sets and not only the header when I supposed before.
Is g2asset source code availabe?
|
|
dfl
New Member
Posts: 4
|
Post by dfl on Jun 20, 2018 14:07:16 GMT -8
Just to conclude, the problem was the overflow on the command buffer. After sending the data in blocks no more than 4k the above code worked.
|
|