layout | title |
---|---|
default |
Chipset |
Predefined routines are a new set of routines that simplify application development.
Macros are usually the best way for libraries. They define a block of code which is never allocated in memory until you call them.
Macros can also have parameters which can modify behavior. These are the main reason for high usage in c128lib
.
Cons of macros is that everytime you call them, a new block of code is allocated and this is againts Dry software principle.
In this term, subroutine is a better solution because it's defined only once and can be called a number of time without affecting memory allocation. But, cons is that when defined, subroutine uses you memory space, even if don't use it.
So chipset
uses a solution that provide subroutine support behind a guard. Every subroutine is allocated (and available) only if guard is defined in your code. Let's see an example.
In Vdc module there is a subroutine called FillScreen
.
When you include vdc.asm, this subroutine is not available because its guard FILLSCREEN
it's not defined (and you'll get an error).
If you define guard like this in your code:
...
#define FILLSCREEN
...
you can use subroutine with this statement
...
jsr c128lib.Vdc.FillScreen
...
Every subroutine defines guard needed for its code so you only have to define subroutine guard.
So it's up to you to define guard only for subroutines that you really use and need.