|
#21
|
|||
|
|||
|
Hmm, one of us doesn't understand tables(arrays) correctly. From my understanding:
Code:
for h=1,240 do
BUFFER[h] = {};
for l=1,400 do
BUFFER[h][l] = 255;
end;
end;
|
|
|
|||
|
|
|
#22
|
||||
|
||||
|
Looks like this works.
It load data from a Gif file 4 bytes at the time and transfer them to the buffer and display the content in BUFFFER[1][1] = GIF8 0x47494638 Code:
color_black = color.new(0,0,0);
color_white = color.new(255,255,255);
text.color(color_white);
text.size(16);
screen.fillrect(0,0,400,240,color_black);
screen.update();
size = 4;
io.input("image.gif");
BUFFER = {} ;
for h=1,2 do
BUFFER[h] = {};
for l=1,20 do
x = io.read(size);
BUFFER[h][l] = x;
end;
screen.fillrect(0,0,400,240,color_black);
text.draw(20,20,"BUFFER = "..h );
screen.update();
end;
text.draw(20,50,"BUFFER[1][1] = "..BUFFER[1][1]);
text.draw(20,70,"BUFFER[1][2] = "..BUFFER[1][2]);
text.draw(20,90,"BUFFER[1][3] = "..BUFFER[1][3]);
screen.update();
os.sleep(1000);
Jan_DK |
|
#23
|
||||
|
||||
|
That's properly me, I think I'm really not programming in Lua, but trying
to force my C programming knowledge about array's through in Lua. Quote:
Matrices and Multi-Dimensional Arrays. I get the impression that Lua is even more effective and flexible than c when it comes to arrays. I'm confused ![]() Then how do we create a buffer the size of 400x240x3 bytes in Creative Lua ? Jan_DK |
|
#24
|
|||
|
|||
|
This is where I get confused also: http://www.wowwiki.com/Lua_object_memory_sizes
"As indexes are added, the table will allocate space for new indexes at an exponential rate" "If a table is indexed by sequential integers, each index will take 16 bytes (not including any memory allocated for the value)." "A new, empty table will consume 40 bytes." So with that information you get somethine like (32768 * (16 + 4)) + 40. Which is closer to the 800kb limit i notied here: http://www.anythingbutipod.com/forum...4&postcount=13 |
|
#25
|
||||
|
||||
|
Just tried this to be sure, it's not a indexing overflow problem but memory.
This is stopping at aprox. 16100 with an error. Code:
for index=1,32000 do
BUFFER[index] = 0xFF01FA02;
BUFFER2[index] = 0xFA01FA22;
end;
single dim array and 251K 157*400*4 out of a 2d, then what about adding more dimensions. Jan_DK |
|
#26
|
|||
|
|||
|
WOW i have no god damn clue what any of this means. But I think i get the gist of it. I just don't understand what you want in the long run of this.
|
|
#27
|
||||
|
||||
|
ThievingSix>>"So with that information you get somethine like (32768 * (16 + 4)) + 40. Which is closer to the 800kb limit i notied"
There is something very weird, that's for sure, adding one more dimension to the array, makes is possible to allocate more than 288.000 bytes as the screen require, but a 3 part loop and 4 bytes per read makes it unusable. I've created a 400x240x3 288.000 bytes raw image data file, with the first bytes = ABCDEFG(so there is something to print) as a test file. The loops allocates 290304 bytes, but what 288000 will be in BUFFER[?][?][?] i have no clue, for I would like to print the content of the last byte, like the first one. A 2 dimensional array the size of the screen make sense, but this 3 loops stuff is to weird. :-) Code:
color_black = color.new(0,0,0);
color_white = color.new(255,255,255);
text.color(color_white);
text.size(16);
screen.fillrect(0,0,400,240,color_black);
screen.update();
size = 4;
io.input("image_400x240x3.raw");
BUFFER = {} ;
for d=1,18 do
BUFFER[d] = {};
for h=1,63 do
BUFFER[d][h] = {};
for l=1,64 do
if d*h*l*4 ~= 288000 then
local x = io.read(size);
BUFFER[d][h][l] = x;
end;
end;
end;
screen.fillrect(0,0,400,240,color_black);
text.draw(20,20,"BUFFER = "..d*63*64*4 );
screen.update();
end;
text.draw(20,50,"BUFFER[1][1][1] = "..BUFFER[1][1][1]);
screen.update();
os.sleep(500);
In order to do anything beyond what the "SDK" provide eg. displaying gif animation I think one needs to allocate some memory to work with. And some of the threads above is an attempt to do just that, and then running into problems. :-) Jan_DK Last edited by Jan_DK; 01-22-2010 at 11:24 AM. Reason: changed: pixel to byte |
|
#28
|
||||
|
||||
|
This code load the file into one string, and then extract the content and convert it to numbers for use in color function(r,g,b)
for drawing a pixel with the data from the file. What I don't know is if the file is loaded into the 880kb memory or not. Shit ! It' only works in the simulator, on the X-fi2 read("*all") generate an error, so we can not load a 280kb file in lua. ![]() Edit: changing the file size to 157kb and then it works on the X-Fi2. Code:
color_black = color.new(0,0,0);
color_white = color.new(255,255,255);
text.color(color_white);
text.size(16);
screen.fillrect(0,0,400,240,color_black);
screen.update();
size = 4;
text.draw(10,10,"Loading File...");screen.update();
io.input("image_400x240x3.raw");
filedata = io.read("*all");
print(string.len(filedata));
text.draw(10,30,"File size = "..string.len(filedata).." Bytes");
byte_R_string = string.sub (filedata, 1,1 );
byte_G_string = string.sub (filedata, 2,2 );
byte_B_string = string.sub (filedata, 3,3 );
print(byte_R_string);
print(byte_G_string);
print(byte_B_string);
byte_R = string.byte(byte_R_string);
byte_G = string.byte(byte_G_string);
byte_B = string.byte(byte_B_string);
print(byte_R);
print(byte_G);
print(byte_B);
color_data = color.new(byte_R,byte_G,byte_B);
screen.drawpixel(200,120,color_data);
screen.update();
os.sleep(500);
Last edited by Jan_DK; 01-21-2010 at 01:03 PM. |
|
#29
|
|||
|
|||
|
Can you output garbagecollect("count")? I'm curious to see if we get just about the size of the file or if it's much more. If it's the former I'd be pretty sad..
__________________
Only ONE more functions in the Wiki need addressing! Zen X-Fi2 LUA Wiki Want to protect your applications? Click Here! Tower Defense Thread Zen Lock - Protect Your Zen! |
|
#30
|
||||
|
||||
|
Quote:
garbagecollect("count"); Jan_DK |
|
#31
|
|||
|
|||
|
OIASJOIASHEQOIUIUQWH(*@!Y**LWK
sorry. collectgarbage("count") <-- dyslectic.
__________________
Only ONE more functions in the Wiki need addressing! Zen X-Fi2 LUA Wiki Want to protect your applications? Click Here! Tower Defense Thread Zen Lock - Protect Your Zen! |
|
#32
|
||||
|
||||
|
Quote:
but what do the numbers tell us ? In the sim and loading a 288.000 bytes file. print(collectgarbage("count")); or text.draw(10,50,"CollectGarbage = "..collectgarbage("count")); output-> 450.5361328125 In the sim and loading a 154.007 bytes file. output-> 254.3543xxx On the X-Fi2 and loading a 154.007 bytes file. text.draw(10,50,"CollectGarbageCount = "..collectgarbage("count")); outputs-> 251.5322265625 Jan_DK |
|
#33
|
|||
|
|||
|
It's the total amount of memory in use by lua in kilobytes.
__________________
Only ONE more functions in the Wiki need addressing! Zen X-Fi2 LUA Wiki Want to protect your applications? Click Here! Tower Defense Thread Zen Lock - Protect Your Zen! |
|
#34
|
||||
|
||||
|
The maximum file size is somewhere between 203-237kb
203 work 237 don't work I'm watching a doc called 'BBS the Documentary' I could not help my self when i saw this Computer comparison table. What about a 1565.00 dollar PC with 16kb RAM ![]() I guess we should not complain about only having what we got ![]() Jan_DK |
|
#35
|
|||
|
|||
|
Well if we were using 2 bit image files I wouldn't complain!
__________________
Only ONE more functions in the Wiki need addressing! Zen X-Fi2 LUA Wiki Want to protect your applications? Click Here! Tower Defense Thread Zen Lock - Protect Your Zen! |
|
#36
|
||||
|
||||
|
You're right ! maybe we should check the X-Fi2's font for interesting chars
for making AscII art ![]() But there is no problem loading a screen size image thru the image function so it's not that bad. ![]() Jan_DK |
|
#37
|
|||
|
|||
|
that commie 64 actually has 64k upgradeable to 128k with the ram cartridge.
|
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 06:34 AM.

















Linear Mode
