Jump to content



0

question about data_length


8 replies to this topic

#1 diogoandrei OFFLINE  

diogoandrei

    Chopper Commander

  • 210 posts
  • Location:Brazil

Posted Tue Jan 18, 2011 6:35 PM

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!

#2 RevEng OFFLINE  

RevEng

    River Patroller

  • 2,010 posts
  • bit shoveler
  • Location:Canada

Posted Tue Jan 18, 2011 9:01 PM

Can you attach the .asm file that was generated when you compiled the basic file?

For some reason my bB version doesn't have _length attributes, but I did something equivalent in assembly and your code worked as expected. (012000, 012001, etc.)

#3 diogoandrei OFFLINE  

diogoandrei

    Chopper Commander

  • 210 posts
  • Location:Brazil

Posted Wed Jan 19, 2011 6:59 AM

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!

Attached Files



#4 RevEng OFFLINE  

RevEng

    River Patroller

  • 2,010 posts
  • bit shoveler
  • Location:Canada

Posted Wed Jan 19, 2011 7:30 AM

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.

#5 diogoandrei OFFLINE  

diogoandrei

    Chopper Commander

  • 210 posts
  • Location:Brazil

Posted Wed Jan 19, 2011 8:05 AM

View PostRevEng, on Wed Jan 19, 2011 7:30 AM, said:

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.

Yeah, I'll stick to that. Thx! :thumbsup:

#6 RevEng OFFLINE  

RevEng

    River Patroller

  • 2,010 posts
  • bit shoveler
  • Location:Canada

Posted Wed Jan 19, 2011 8:59 AM

You're welcome!

#7 diogoandrei OFFLINE  

diogoandrei

    Chopper Commander

  • 210 posts
  • Location:Brazil

Posted Wed Jan 19, 2011 1:37 PM

Should I report this "may be a bug" to someone? What's the best thing to do when running into something like this?

#8 RevEng OFFLINE  

RevEng

    River Patroller

  • 2,010 posts
  • bit shoveler
  • Location:Canada

Posted Wed Jan 19, 2011 1:43 PM

You can report it here: http://www.atariage....-report-thread/

#9 batari OFFLINE  

batari

    )66]U('=I;B$*

  • 6,236 posts
  • begin 644 contest

Posted Thu Jan 20, 2011 4:20 PM

I posted about it in the bug report thread.

http://www.atariage....45#entry2188545




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users