mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Refactor section assignment in linker
Deduplicates and generalises a lot of code in assign.c: - Replace area_AllocAbs*AnyBank() with area_AllocAbsAnyBank() function that accepts a section type parameter - Replace area_Alloc*AnyBank() with area_AllocAnyBank() - Replace FindLargest*() with FindLargestSection() - Replace Assign*Sections() with AssignBankedSections() - Add VerifyAndSetBank(), which enables bank checks (and addition with BANK_*) to be centralised - Refactor the initialisation of AssignSections(), removing some magic numbers and only setting MaxAvail[i] once - Overhaul the duplicated cases throughout AssignSections()
This commit is contained in:
@@ -5,13 +5,26 @@
|
||||
|
||||
enum eBankDefine {
|
||||
BANK_ROM0 = 0,
|
||||
BANK_ROMX,
|
||||
BANK_WRAM0 = 512,
|
||||
BANK_WRAMX,
|
||||
BANK_VRAM = 520,
|
||||
BANK_HRAM = 522,
|
||||
BANK_SRAM = 523
|
||||
};
|
||||
#define MAXBANKS 527
|
||||
|
||||
enum eBankCount {
|
||||
BANK_COUNT_ROM0 = 1,
|
||||
BANK_COUNT_ROMX = 511,
|
||||
BANK_COUNT_WRAM0 = 1,
|
||||
BANK_COUNT_WRAMX = 7,
|
||||
BANK_COUNT_VRAM = 2,
|
||||
BANK_COUNT_HRAM = 1,
|
||||
BANK_COUNT_SRAM = 4
|
||||
};
|
||||
|
||||
#define MAXBANKS (BANK_COUNT_ROM0 + BANK_COUNT_ROMX + BANK_COUNT_WRAM0 + BANK_COUNT_WRAMX \
|
||||
+ BANK_COUNT_VRAM + BANK_COUNT_HRAM + BANK_COUNT_SRAM)
|
||||
|
||||
extern SLONG area_Avail(SLONG bank);
|
||||
extern void AssignSections(void);
|
||||
|
||||
Reference in New Issue
Block a user