Jump to content

Photo

data statement?


12 replies to this topic

#1 kisrael OFFLINE  

kisrael

    HMBL 2600 coder

  • 4,058 posts
  • Location:Boston Burbs, MA

Posted Sun Jan 14, 2018 9:26 PM

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


Attached Files



#2 Mountain King OFFLINE  

Mountain King

    Dragonstomper

  • 673 posts
  • Location:Philadelphia, PA

Posted Mon Jan 15, 2018 5:01 AM

Sorry I'm stumped on this as well. It just does not like data statements.



#3 bogax ONLINE  

bogax

    Dragonstomper

  • 738 posts

Posted Mon Jan 15, 2018 5:07 AM

try something like this

 

  temp1 = golemShape[0]
  pfpixel temp1 7 on


#4 Mountain King OFFLINE  

Mountain King

    Dragonstomper

  • 673 posts
  • Location:Philadelphia, PA

Posted Mon Jan 15, 2018 6:20 AM

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

Attached Thumbnails

  • dataweird.bas.png


#5 kisrael OFFLINE  

kisrael

    HMBL 2600 coder

  • Topic Starter
  • 4,058 posts
  • Location:Boston Burbs, MA

Posted Mon Jan 15, 2018 6:42 AM

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.)



#6 bogax ONLINE  

bogax

    Dragonstomper

  • 738 posts

Posted Mon Jan 15, 2018 7:45 PM

 

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 



#7 kisrael OFFLINE  

kisrael

    HMBL 2600 coder

  • Topic Starter
  • 4,058 posts
  • Location:Boston Burbs, MA

Posted Tue Jan 16, 2018 8:35 AM

Sorry, what?



#8 Mr SQL OFFLINE  

Mr SQL

    Stargunner

  • 1,779 posts

Posted Tue Jan 16, 2018 10:29 AM

The pfpixel command uses the temp variables for calculations so their initial values are lost. 



#9 kisrael OFFLINE  

kisrael

    HMBL 2600 coder

  • Topic Starter
  • 4,058 posts
  • Location:Boston Burbs, MA

Posted Tue Jan 16, 2018 10:57 AM

does that apply to my first example? is there some memory bleed in that?



#10 Mr SQL OFFLINE  

Mr SQL

    Stargunner

  • 1,779 posts

Posted Tue Jan 16, 2018 12:50 PM

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)



#11 mojofltr ONLINE  

mojofltr

    River Patroller

  • 2,626 posts

Posted Wed Jan 17, 2018 8:03 AM

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.  

 

 

dataweird.png

 

/edit

 

I noticed the for loop has a duplicated line... duh.  It was meant to be:

 

 for i=0 to 35
 temp3=xData[i]+xOffset : temp4=yData[i]+yOffset
 pfpixel temp3 temp4 on
 next
 
Even so, it seems that each time the for loop is called, the fps gets messed up slightly. 

Attached Files


Edited by mojofltr, Thu Jan 18, 2018 7:56 AM.


#12 Random Terrain ONLINE  

Random Terrain

    Visual batari Basic User

  • 28,510 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Sat Jan 20, 2018 4:49 PM

@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:

 

Attached File  dataweird_2018y_01m_20d_1723t.bas   621bytes   9 downloads

Attached File  dataweird_2018y_01m_20d_1723t.bin   4KB   10 downloads

 

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.



#13 CurtisP OFFLINE  

CurtisP

    Chopper Commander

  • 249 posts

Posted Mon Feb 12, 2018 8:39 PM

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/...4-c02-compiler/). 

 

It may not be too hard to figure this out for batari Basic.






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users