Jump to content
IGNORED

Do Functions Play Nice with Banks?


Gemintronic

Recommended Posts

So, I'm trying to convert Game Maker 5 constants, subroutines and functions over to Batari BASIC. I'm trying to keep my library of routines in the second bank. How do functions work with multi-banked games? Do they at all?

Functions are like subroutines, so I think there would be a problem calling them if they're in a different bank. This is a good question, and I don't have a good answer, but it might be necessary to create a multibanked version of user functions. Otherwise, you'd probably need to find a way to work around the problem of calling them from different banks. Like I said, I don't have an answer. If I can think of something, I'll let you know. :ponder:

 

Michael

Link to comment
Share on other sites

Thanks for the replies so far. I'd like to use functions multi-bank if possible.

 

I noticed Batari's Platformer example seems to only call the functions from the same bank. So it still doesn't prove functions can work across banks.

 

Workaround seems to be setting aside a variable or two as arguments and then calling a gosub that uses those variables.

Edited by theloon
Link to comment
Share on other sites

Thanks for the replies so far. I'd like to use functions multi-bank if possible.

 

I noticed Batari's Platformer example seems to only call the functions from the same bank. So it still doesn't prove functions can work across banks.

 

Workaround seems to be setting aside a variable or two as arguments and then calling a gosub that uses those variables.

You can make a cross-bank wrapper to do this.

 

For example, if this function is in bank 2 (note this is modified a bit from the platformer source - the return is used to go back to the calling bank):

 function blockread
 temp1=temp1-16:temp1=temp1/4
 temp2=temp2+1
 temp2=temp2/4-3
 temp1=romPFpixel(temp1,temp2)
 return

To call it from bank 1, do something like this in bank 1:

 

  function blockread_bank1_wrapper
 goto blockread bank2

 

Untested, but I think this will work. If it does not, let me know.

 

That said, cross-bank subroutines should be minimized as they use perhaps 30-60 more cycles than in-bank subroutines.

Edited by batari
Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...