Jump to content


DPC+ Memory push and pulling not working

5 replies to this topic

#1 Sprybug OFFLINE  



  • 519 posts

Posted Thu Dec 29, 2016 3:45 PM

Hey guys,


Using RevEng's latest 64k Batari BASIC mod.  Having an issue with DPC+ and memory pushing and pulling.  No matter what I push into memory, I always get back 0's when pulling it out.  I've run a few test programs and the stuff I am storing rather never gets stored, or is lost.  In my game I have multiple enemies and objects on screen and the only way to be able to keep track of all the info is to push and pull values for these objects into the ARM's memory using the stack, push, and pull commands.  For example I do something like:




 if a>100 then a=0

 stack 0 ' have tried other values, same results

 push a c r j



 more code


 stack 0

 pull a c r j

 score=score+a ' Just to see what the a variable's doing


 goto main


Always 0.  I first noticed this in my main game program whenever I tried to do anything with the enemy players, everything always reset to 0.  Is this just a thing with Stella, something wrong with Batari, or something I am doing wrong?


Thanks for any help you can give so I can continue with Robot Zed.  I am really liking what I am getting with DPC+ so far.


#2 SpiceWare OFFLINE  



  • 10,947 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Thu Dec 29, 2016 3:52 PM

Have you seen this topic by Random Terrain?  I created some Get/SetValue functions that are posted in that topic.  They'll allow you to easily access up to 768 bytes of DPC+ RAM for variable use.  


You'll want to read through that topic then use the routines in reply #20 and reply 26.  I posted a more detailed example on using them in reply 27.  I also show how to see them in action in Stella's debugger in reply 22.

#3 Sprybug OFFLINE  



  • Topic Starter
  • 519 posts

Posted Thu Dec 29, 2016 3:58 PM

Thanks Darrell!  I'll check it out for sure.  If it doesn't work out or have any other questions, I'll be sure to let you guys know.

#4 RevEng OFFLINE  


    River Patroller

  • 4,448 posts
  • Bitnik
  • Location:Canada

Posted Thu Dec 29, 2016 7:45 PM

There aren't problems with stella or bB. Stacks just don't work the way your code assumes they do.

Take the example of when the stack pointer is set to position 255, and then you push 4 values to the stack. The new top of stack (and the top of these 4 new elements) is at stack position 251. (the bB DPC+ stack grows toward 0, which is why it went from 255 to 251 when stuff was added)

When you want to pull these 4 items off the stack, you'll want to ensure the stack pointer is pointing to the top of these 4 items... at position 251.

If you try substituting "stack 255" and "stack 251" in your example, and it should work as expected.

If this still doesn't make sense, try a bit of general research on stacks, and come back and re-read what I've said.

(and none of this is meant to say you shouldn't use Darrell's method)

#5 Sprybug OFFLINE  



  • Topic Starter
  • 519 posts

Posted Fri Dec 30, 2016 2:38 AM

OOOOH.  I had no idea it worked that way.  Did I not read Random Terrain's section of it correctly, or is it not properly documented?  Because I completely forgot how a stack works.  Thanks for the reminder.  I will definitely give this a go first and if it doesn't work out, I'll give Darrell's a shot.  I probably only need 50 bytes of this stack at most, since every object only needs about 4 bytes when they are on the screen being transferred to Riot RAM and back for each one.  I always appreciate the geniuses here at AtariAge.  Without you guys, none of my games would have ever been completed.

#6 RevEng OFFLINE  


    River Patroller

  • 4,448 posts
  • Bitnik
  • Location:Canada

Posted Fri Dec 30, 2016 11:59 AM

You're welcome. Random Terrain's section on the DPC+ stack is correct, but it presently only provides an example for 1 item being pushed. You probably missed that the stack location pulled from was -1 from the location the value was pushed to.

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users