’Cause all games were better on the GBC

You are not logged in.

#1 2014-09-14 15:36:03

Registered: 2013-12-04
Post 143/344

Pros/Cons of Predef functions?

In the Gen 1 games, there's a big array of functions called the "Predef" functions.  It's a list of common functions used throughout the game, and the Predef routine allows to you call any of the functions from any ROM bank, which is convenient.  However, you can also easily call any function in the ROM by using Bankswitch.  I'm not really sure what the advantages and disadvantages of these two methods are.  They seem equivalent to me, except Predef has a hard limit on the number of functions it can be used for.  Any insights on why one is better than the other?  Or should they be used in different situations?


#2 2014-09-14 16:18:18

Registered: 2013-12-31
Post 85/119

Re: Pros/Cons of Predef functions?

Predef functions consume 3-bytes.

FarCall fuction consume 6-bytes.

The number of bytes used can be considerable.


#3 2014-09-14 18:11:59

Registered: 2012-04-09
Post 476/679

Re: Pros/Cons of Predef functions?

Predefs free up hl and are shorter than Red's 8-byte farcalls.

A better way to handle farcalls would be to use an rst vector as a pseudoinstruction, like so:

farcall: macro
    rst $30
    dw \1
    db BANK(\1)

Then you can pop off the return address, increment it past the pointer and push it back. This should let you preserve all registers (even a!) and keep the call to 4 bytes (down from Predef's 5) without the abstraction.


Board footer

Powered by FluxBB