Jump to content

Photo

Drawscreen in a gosub


4 replies to this topic

#1 bjbest60 OFFLINE  

bjbest60

    Space Invader

  • 26 posts

Posted Sat Feb 4, 2017 12:01 AM

Hello everyone,

 

I'm trying to finalize a game with the DPC+ kernel.  It's got a procedurally generated playfield (among other things), which means I need to call drawscreen a lot to prevent the screen from rolling.  To minimize code space, I set up a gosub that looks like this:

screenrefresh
 DF6FRACINC = 32 
 DF4FRACINC = 32 
 DF0FRACINC = 16 
 DF1FRACINC = 16 
 DF2FRACINC = 16 
 DF3FRACINC = 16 
 drawscreen
 return

This code works perfectly as a gosub in Stella.  But when I put it on my Harmony cart, the game crashes once its reaches it.  I'm baffled by the difference.  I really, really need this code to work as I'm down to < 100 bytes in each of my banks (many are < 30), and according to my tests, each new drawscreen call takes up 24 bytes.  I know I could instead do this with a labyrinthine system of gotos, but that won't be as efficient as I need it to be, either.

 

I'd really appreciate any advice.  Thanks.



#2 Mountain King OFFLINE  

Mountain King

    Dragonstomper

  • 603 posts
  • Location:Philadelphia, PA

Posted Sat Feb 4, 2017 4:07 AM

Are you returning to the same bank or a different bank?

 

You might try using:

 

return thisbank

 

or

 

return otherbank

 

depending on which condition you are using.



#3 bjbest60 OFFLINE  

bjbest60

    Space Invader

  • Topic Starter
  • 26 posts

Posted Sat Feb 4, 2017 8:22 AM

The subroutine is called in every bank.  But I just quickly tried thisbank with bank 2, and all the code within that bank seems to be executing properly.  With some judicious pruning, I think I'll be able to get enough room to copy that gosub routine into the other banks and adjust the calls accordingly.  I think this might work!  I'll give an update once I'm able to go through all the code, but thank you so much!

 

UPDATE:  That's exactly what I did, and everything works again!  This completely rescued my game.  Should be able to go to beta now pretty soon.  Thanks again!


Edited by bjbest60, Sat Feb 4, 2017 9:15 AM.


#4 bogax OFFLINE  

bogax

    Dragonstomper

  • 692 posts

Posted Sat Feb 4, 2017 5:03 PM

Hello everyone,

 

I'm trying to finalize a game with the DPC+ kernel.  It's got a procedurally generated playfield (among other things), which means I need to call drawscreen a lot to prevent the screen from rolling.  To minimize code space, I set up a gosub that looks like this:

screenrefresh
 DF6FRACINC = 32 
 DF4FRACINC = 32 
 DF0FRACINC = 16 
 DF1FRACINC = 16 
 DF2FRACINC = 16 
 DF3FRACINC = 16 
 drawscreen
 return

This code works perfectly as a gosub in Stella.  But when I put it on my Harmony cart, the game crashes once its reaches it.  I'm baffled by the difference.  I really, really need this code to work as I'm down to < 100 bytes in each of my banks (many are < 30), and according to my tests, each new drawscreen call takes up 24 bytes.  I know I could instead do this with a labyrinthine system of gotos, but that won't be as efficient as I need it to be, either.

 

I'd really appreciate any advice.  Thanks.

 

 

I don't know if this would work given the problem you're having

 

but you don't need a labyrinthine system of gotos

 

you'd put a single instance of the screenrefresh routine in some bank and return otherbank

 

then in each bank you'd put a single goto screenrefresh bankx

 

then when you want to refresh you'd gosub to the goto

 

 

edit

 

I don't know how it works with DPC+

 

if you're just bank switching and if you're in

the appropriate bank you can use

 

   asm

   jsr drawscreen

end

 

and save the bank switch for the drawscreen

 

at least that works in stella


Edited by bogax, Sat Feb 4, 2017 5:56 PM.


#5 bjbest60 OFFLINE  

bjbest60

    Space Invader

  • Topic Starter
  • 26 posts

Posted Mon Feb 6, 2017 9:12 AM

Cool.  Thanks for the ideas.  I'm in a phase where I'm trying to limit both code size and cycles, so I'll play around a bit and see what's most efficient.






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users