Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Sept 5, 2011 23:39:11 GMT -5
Alright, so I'm trying to load things from a bunch of data statements, and I've run into a snag.
dim arr(69,69) as integer, x as integer, y as integer, z as integer
reload dataline for y = 0 to 69 for x = 0 to 69
read z arr(x,y) = z
next next
dataline: data 100,100,100, etc
Now, there are 70 data statements, each holding numbers. The first row is all 100, the rest are zeros (trying to pin point the issue). Doing this, it will only read up to 62 if a row has all 100's in it (if there are zero's, 8 or more, it will read the whole thing). I can't figure out what is causing this issue. Any help would be greatly appreciated, as well as an explanation on why this might be happening.
Thanks!
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Sept 6, 2011 3:06:34 GMT -5
The BEX compiler has trouble with data statements that contain allot of elements in a single line. Use a DATAFILE instead
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Sept 6, 2011 8:37:15 GMT -5
Alright, so this is what I did to try out what you suggested:
Created an external text file with just 1 line, 70 items separated by comma's (like a data statement), and used datafile blah.dat
This resulted in an error. Open up the help file, see that if I include it as a text file, it must be like an ASM text file. I added in a ";" before the first element, same results as using the data statement. Tossed in the ",BIN" at the end. Ran the loop, saw that it appeared to be putting out the ASC values of the numbers instead. So I then try not using comma's, but just single characters. I used ½ 70 times (171) and it resulted in 189. Then I added in û (150), and it loads it as 251. I'm somewhat at a loss here.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Sept 6, 2011 8:45:29 GMT -5
Not sure what's going on .. in any case, here's a example. The ( attached ) binary file contains a 2D map of 128x128 with a row of X's at the top, and the rest is all O's. dim bar(127,127) as integer reload foo for y = 0 to 127 for x = 0 to 127 read z bar(x,y) = z next next for y = 0 to 27 for x = 0 to 39 drawtile bar(x,y),x,y next next
foo: datafile foo.bin,bin Attachments:
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Sept 6, 2011 9:08:40 GMT -5
Your example worked fine, but I need to hit a range from 0 to 255. Here's what I'm doing: dim bar(74,74) as integer reload foo for x = 0 to 74 read z bar(x,y) = z locate 1,1: print " " locate 1,1: print bar(x,y); " "; x sleep 20 next
foo: datafile test.dat,BIN
The first 2 characters in the bin file are ascii codes 181 and 150, the rest are 171. printing out what they are, they are not those values. Any ideas? Attachments:
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Sept 6, 2011 9:16:30 GMT -5
Your example worked fine, but I need to hit a range from 0 to 255. I'm using the 0 to 255 range Attached is a updated foo.bin to go with my example that starts with tile 0,1,2,3 and 252,253,254,255 in the upper row. + Just checked your test.dat. The values in your file are 166,251,189 .. so they are read & printed onto the screen correctly. Attachments:
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Sept 6, 2011 9:24:16 GMT -5
Alright, so it's the creating the file process that I'm messing up on. What are you doing to create the characters? I was using the old DOS trick of holding ALT then typing in the character codes on the number pad.
Thanks moon!
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Sept 6, 2011 9:30:02 GMT -5
Well, depending on what kind of data you're creating, you normally would use a image / map / animation editor to generate the data. If you for some reason want to do this by hand ( like in this case, quickly generating some test data ) it's most convenient to use a HEX editor. My personal favorite is XVI32
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Sept 6, 2011 9:33:15 GMT -5
Gracias moon. Thanks for all the help and info. Greatly appreciated
|
|
|
Post by jlf65 on Sept 12, 2011 21:10:31 GMT -5
|
|