Skip to content

Free some space in the Home BANK

Vortyne edited this page Aug 4, 2023 · 2 revisions

All credits go to Vortiene for having me guided through this, and all mistakes&errors are to be attributed to me.

This is a 2-step simple procedure:

  1. open home/header.asm and modify the following:
SECTION "rst0", ROM0[$0000]
-	rst $38
+_Bankswitch::
+    jp Bankswitch
  1. open macros/farcall.asm and modify the following:
MACRO farcall
	ld b, BANK(\1)
	ld hl, \1
-	call Bankswitch
+	rst _Bankswitch
ENDM

MACRO callfar
	ld hl, \1
	ld b, BANK(\1)
-	call Bankswitch
+	rst _Bankswitch
ENDM

Done :) This should free at least ("citation needed") $60 = 96 bytes. Not bad.

Note from Vortiene: What this change does is make it so every callfar and farcall in the code calls Bankswitch with a special command. The rst command. rst is basically a more compact version of the call command that can only target a specific set of addresses right at the start of the ROM data. An rst command takes up 1 byte when added to code, whereas a call command takes up 3 bytes. So every instance of the callfar or farcall macro being used in the ROM now takes up 2 less bytes.