kisrael Posted January 15, 2018 Share Posted January 15, 2018 Can anyone see what I'm doing wrong here? I'd like to use data to build some graphics, this is a simplified excerpt from my program... if I hardcode pixels 20,21,22 in row 5 it's fine, but when I try to use simple data/offsets on line 7 or slightly more complex usage for line 9, I get odd, flickering results dim ptr = a mainloop COLUBK=$00 COLUPF=$08 pfpixel 20 5 on pfpixel 21 5 on pfpixel 22 5 on pfpixel golemShape[0] 7 on pfpixel golemShape[1] 7 on pfpixel golemShape[2] 7 on ptr = 0 pfpixel golemShape[ptr] 9 on ptr = ptr + 1 pfpixel golemShape[ptr] 9 on ptr = ptr + 1 pfpixel golemShape[ptr] 9 on drawscreen goto mainloop data golemShape 20, 21, 22 end dataweird.bas dataweird.bas.bin Quote Link to comment Share on other sites More sharing options...
Mountain King Posted January 15, 2018 Share Posted January 15, 2018 Sorry I'm stumped on this as well. It just does not like data statements. Quote Link to comment Share on other sites More sharing options...
bogax Posted January 15, 2018 Share Posted January 15, 2018 try something like this temp1 = golemShape[0] pfpixel temp1 7 on Quote Link to comment Share on other sites More sharing options...
Mountain King Posted January 15, 2018 Share Posted January 15, 2018 It kind of worked. The flicker is gone. But it still doesn't look right. dim ptr = a mainloop temp1=golemShape[ptr] temp2=golemShape[0] temp3=golemShape[1] temp4=golemShape[2] COLUBK=$00 COLUPF=$08 pfpixel 20 5 on pfpixel 21 5 on pfpixel 22 5 on pfpixel temp2 7 on pfpixel temp3 7 on pfpixel temp4 7 on ptr = 0 pfpixel temp1 9 on ptr = ptr + 1 pfpixel temp1 9 on ptr = ptr + 1 pfpixel temp1 9 on drawscreen goto mainloop data golemShape 20, 21, 22 end Quote Link to comment Share on other sites More sharing options...
kisrael Posted January 15, 2018 Author Share Posted January 15, 2018 bogax has the right idea, I think. somehing like this seems to work dim ptr = a dim reader = b rem ................ ptr = 0 reader = golemShape[ptr] pfpixel reader 9 on ptr = ptr + 1 reader = golemShape[ptr] pfpixel reader 9 on ptr = ptr + 1 reader = golemShape[ptr] pfpixel reader 9 on I think the general principle is "don't assume you can put in a 'array like data read' anywhere you can use a normal variable". This sort of makes sense to me based on what I remember of addressing modes etc in straight assembly@RandomTerrain I wonder if the command list #dataarrays section should say something like Please note that you will often need to use a temporary variable to hold the value being read via the array-like syntax, for example _temp = _My_Data[3] and then use the _temp variable in the actual command. (Many commands support use of simple variables inline, but not more complex looks up like this.) Quote Link to comment Share on other sites More sharing options...
bogax Posted January 16, 2018 Share Posted January 16, 2018 It kind of worked. The flicker is gone. But it still doesn't look right. dim ptr = a mainloop temp1=golemShape[ptr] temp2=golemShape[0] temp3=golemShape[1] temp4=golemShape[2] COLUBK=$00 COLUPF=$08 pfpixel 20 5 on pfpixel 21 5 on pfpixel 22 5 on pfpixel temp2 7 on pfpixel temp3 7 on pfpixel temp4 7 on ptr = 0 pfpixel temp1 9 on ptr = ptr + 1 pfpixel temp1 9 on ptr = ptr + 1 pfpixel temp1 9 on drawscreen goto mainloop data golemShape 20, 21, 22 end pfpixel uses temp1 and temp2 Quote Link to comment Share on other sites More sharing options...
kisrael Posted January 16, 2018 Author Share Posted January 16, 2018 Sorry, what? Quote Link to comment Share on other sites More sharing options...
Mr SQL Posted January 16, 2018 Share Posted January 16, 2018 The pfpixel command uses the temp variables for calculations so their initial values are lost. Quote Link to comment Share on other sites More sharing options...
kisrael Posted January 16, 2018 Author Share Posted January 16, 2018 does that apply to my first example? is there some memory bleed in that? Quote Link to comment Share on other sites More sharing options...
Mr SQL Posted January 16, 2018 Share Posted January 16, 2018 From Mountain Kings example, " pfpixel temp2 7 on" On the first example I think you are right about not always being able to pass array variables in place of regular variables in Batari BASIC. Flashback and SuperCharger BASIC support passing array members, here is a simple example in old-school mode: 10 data myarray 9,4 20 vwpixel(myarray(0),myarray(1),on) Quote Link to comment Share on other sites More sharing options...
uosipa llamxew Posted January 17, 2018 Share Posted January 17, 2018 (edited) It's early, so I may be completely missing the point. I played with your .bas file and found that I was able to draw a shape with data and a data statement. The playfield and background colors were hosed if the for loop ran every frame. So I labeled a bit to limit the for loop. This fixed the colors, so I went ahead and added some player control to set some offset values to move the shape around the screen. I don't know if this will at all be helpful. If not, please disregard. /edit I noticed the for loop has a duplicated line... duh. It was meant to be: for i=0 to 35 temp3=xData+xOffset : temp4=yData+yOffset pfpixel temp3 temp4 on next Even so, it seems that each time the for loop is called, the fps gets messed up slightly. dataweird.bas Edited January 18, 2018 by mojofltr Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted January 20, 2018 Share Posted January 20, 2018 @RandomTerrain I wonder if the command list #dataarrays section should say something like Please note that you will often need to use a temporary variable to hold the value being read via the array-like syntax, for example _temp = _My_Data[3] and then use the _temp variable in the actual command. (Many commands support use of simple variables inline, but not more complex looks up like this.) I've been away from my computer for a while, so I'm just now getting to this. I stupidly played with your program without scrolling down first and reinvented the wheel: dataweird_2018y_01m_20d_1723t.bas dataweird_2018y_01m_20d_1723t.bin I basically did the same thing you guys did, except I used temp5. It would be nice if any commands that use temp variables had them listed next to them on the bB page so we would know how far down the list (6, 5, 4, 3, 2, 1) we can go with our own use of temp variables when using a certain command. If we're using a command that uses temp1 and temp2, we'd know it's safe to use temp6, temp5, temp4, and temp3, then use them the way you mentioned above. Quote Link to comment Share on other sites More sharing options...
CurtisP Posted February 13, 2018 Share Posted February 13, 2018 It would be nice if any commands that use temp variables had them listed next to them on the bB page so we would know how far down the list (6, 5, 4, 3, 2, 1) we can go with our own use of temp variables when using a certain command. If we're using a command that uses temp1 and temp2, we'd know it's safe to use temp6, temp5, temp4, and temp3, then use them the way you mentioned above. I did this in the documentation for the standard libraries in C02 (http://atariage.com/forums/topic/267074-c02-compiler/). It may not be too hard to figure this out for batari Basic. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.