bjbest60 #1 Posted February 4, 2017 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. Quote Share this post Link to post Share on other sites
Mountain King #2 Posted February 4, 2017 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. 1 Quote Share this post Link to post Share on other sites
bjbest60 #3 Posted February 4, 2017 (edited) 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 February 4, 2017 by bjbest60 1 Quote Share this post Link to post Share on other sites
bogax #4 Posted February 4, 2017 (edited) 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 February 4, 2017 by bogax 1 Quote Share this post Link to post Share on other sites
bjbest60 #5 Posted February 6, 2017 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. Quote Share this post Link to post Share on other sites