Jump to content
kisrael

data statement?

Recommended Posts

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

Share this post


Link to post
Share on other sites

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

post-17-0-50243100-1516018833_thumb.png

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

 

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

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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.

 

 

post-887-0-15032200-1516198073_thumb.png

 

/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 by mojofltr

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...