Jump to content
IGNORED

question about data_length


diogoandrei

Recommended Posts

Hello there all, what's up?

 

I am doing this small study on data arrays. I ran into a problem with the _lenght constant of the read-only data. My data has 12 elements and it's not returning this value. Here's the code:

 

 dim pixelPointer = a
dim pixelTimer = b
dim pixelX = c
dim pixelY = d

pixelPointer = $ff

COLUPF = $40
COLUBK = $00
scorecolor = $40

MainLoop

pixelTimer = pixelTimer + 1
if pixelTimer = 50 then pixelTimer = 0 : gosub pixelLocation

pfpixel pixelX pixelY on

rem ********************************************************************
rem TESTING VARIABLES

f = pixelData_length

score = 0
temp5 = f
if temp5 > 0 then for temp6 = 1 to temp5 : score = score + 1000 : next
temp5 = pixelY
if temp5 > 0 then for temp6 = 1 to temp5 : score = score + 1 : next

drawscreen
goto MainLoop

pixelLocation
pfpixel pixelX pixelY off
pixelPointer = pixelPointer + 1 : if pixelPointer = 12 then pixelPointer = 0
pixelX = pixelData[pixelPointer]
pixelPointer = pixelPointer + 1
pixelY = pixelData[pixelPointer]
return

data pixelData
1,1,2,2,3,3,4,4,5,5,6,6
end

 

Actually, when I test this:

 

 f = pixelData_length

score = 0
temp5 = f
if temp5 > 0 then for temp6 = 1 to temp5 : score = score + 1000 : next

 

...the playfield even changes color and the score shows 140. :?

 

So I had to hand code the value to avoid the pointers going beyond the number of elements...

 

if pixelPointer = 12 then pixelPointer = 0

 

Any help would be great! Thanks!

Link to comment
Share on other sites

Hello RevEng, what's up?

 

Attached follows the .asm files (there was one for the project and one entitled bB.asm - I wasn't sure so I put both in there).

 

Regarding the _length attribute, I did read about it at Random Terrain, this section. From there I assumed it would be in bB. Can it be possible that this is a small bug?

 

Once again, thanks for your time and attention!

PF_pixels.zip

Link to comment
Share on other sites

Yeah, it's definitely a valid attribute. I just need to update my local bB, I guess.

 

I didn't learn anything from the PF_pixels.bas.asm. I guess the *_length constants are introduced in one of the included .asm files.

 

I do think this is probably a bB bug; my workaround produced correct results, so there aren't any bugs in your basic program.

 

Personally, I'd just workaround it by using your own constant. You could define it right above the data statement so you won't forget to update it if you update the values.

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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