Jump to content
Sign in to follow this  
bjbest60

Drawscreen in a gosub

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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.

  • Like 1

Share this post


Link to post
Share on other sites

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
  • Like 1

Share this post


Link to post
Share on other sites

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
  • Like 1

Share this post


Link to post
Share on other sites

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.

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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...