You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 21, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: Makefile.nw
+95Lines changed: 95 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -445,6 +445,101 @@ What's the difference?
445
445
A variable assigned with \texttt{:=} has its value \emph{immediately} computed; however, \texttt{=} instead has the variable's value computed each time it it referenced.
446
446
In particular, this allows the variables to reference variables that don't exist yet (\texttt{PADVALUE} is defined after \texttt{ASFLAGS}, in \texttt{project.mk}).
447
447
448
+
\subsection{Project-specific configuration}
449
+
450
+
Let's detail the contents of that file.
451
+
\href{https://rgbds.gbdev.io/docs/rgbfix.1}{The description of RGBFIX's options} can be useful to understand what all of these options do, and especially the syntax that they accept.
452
+
453
+
\subsubsection{ROM header}
454
+
455
+
The following control the various options passed to RGBFIX, which set \href{https://gbdev.io/pandocs/The_Cartridge_Header}{the fields of the ROM's header}.
456
+
Emulators \emph{do} rely on some of these; but it can be cool to customise even the “useless” ones, since they show up here and there.
457
+
Some people \emph{will} notice, and find it cute or clever!
458
+
\\
459
+
460
+
This is \href{https://gbdev.io/pandocs/The_Cartridge_Header#014c--mask-rom-version-number}{the ROM's version}.
461
+
This typically starts at 0, and is incremented for each published version.
462
+
<<project.mk>>=
463
+
VERSION := 0
464
+
@
465
+
466
+
This is \href{https://gbdev.io/pandocs/The_Cartridge_Header#013f-0142--manufacturer-code}{the game's ID}, which should be 4 characters (preferably unaccented letters and/or digits).
467
+
<<project.mk>>=
468
+
GAMEID := BOIL
469
+
@
470
+
471
+
\href{https://gbdev.io/pandocs/The_Cartridge_Header#0134-0143--title}{The game's title} can be up to 11 characters, again preferably unaccented letters and/or digits.
472
+
<<project.mk>>=
473
+
TITLE := BOILERPLATE
474
+
@
475
+
476
+
These two control \href{https://gbdev.io/pandocs/The_Cartridge_Header#01440145--new-licensee-code}{the licensee code}, which should be two characters (like usual).
477
+
You should keep \href{https://gbdev.io/pandocs/The_Cartridge_Header.html#014b--old-licensee-code}{the old code} at 0x33, as this is required \href{https://gbdev.io/pandocs/SGB_Unlocking}{to get SGB compatibility} (with no drawbacks).
478
+
The default is meant to mean “\textbf{h}ome\textbf{b}rew game”! \twemoji{wink}
479
+
<<project.mk>>=
480
+
LICENSEE := HB
481
+
OLDLIC := 0x33
482
+
@
483
+
484
+
The \href{https://gbdev.io/pandocs/The_Cartridge_Header#0147--cartridge-type}{cartridge type} controls the available features of the emulated cartridge, especially ROM and SRAM banking.
485
+
You can get a list of valid values by running \texttt{rgbfix -m help}.
486
+
(If using a no-MBC setup, consider enabling \texttt{-t} in \autoref{sec:compat-settings}.)
487
+
<<project.mk>>=
488
+
MBC := MBC5
489
+
@
490
+
491
+
This is the \href{https://gbdev.io/pandocs/The_Cartridge_Header#0149--ram-size}{size of the on-board SRAM}.
492
+
It needs to be consistent with the MBC type above: this should be zero if and only if the MBC type doesn't include “RAM”\footnote{This indicates the size of a separate (“discrete”) RAM chip, so MBC2's built-in SRAM doesn't count and this should be set to 0.}, and vice-versa.
493
+
<<project.mk>>=
494
+
SRAMSIZE := 0x00
495
+
@
496
+
497
+
If you're wondering where the \href{https://gbdev.io/pandocs/The_Cartridge_Header#0148--rom-size}{ROM size} parameter is---that one is automatically computed by RGBFIX.
Uncomment any of these to apply them, or comment them to remove them; please refer to \href{https://rgbds.gbdev.io/docs/rgbasm.1}{RGBDS' documentation} (offline: \texttt{man 1 rgbasm})
502
+
The defaults should be sensible for most projects, though.
503
+
\\
504
+
505
+
These two control \href{https://gbdev.io/pandocs/The_Cartridge_Header#0143--cgb-flag}{the Game Boy Color compatibility byte}.
506
+
If your game is intended to run on GBC \emph{and} monochrome consoles (including possibly SGB), uncomment the \texttt{-c} line.
507
+
If it is intended to run on GBC \emph{only}, then you should uncomment the \texttt{-C} line \textbf{and} still present some kind of fallback screen \href{https://gbdev.io/pandocs/CGB_Registers#detecting-cgb-and-gba-functions}{if detecting a non-Color Game Boy}: the monochrome consoles themselves \textbf{do not} check the header!
508
+
<<project.mk>>=
509
+
# FIXFLAGS += -c
510
+
# FIXFLAGS += -C
511
+
@
512
+
513
+
This flag simply sets \href{https://gbdev.io/pandocs/The_Cartridge_Header#0146--sgb-flag}{the SGB compatibility flag}.
514
+
<<project.mk>>=
515
+
# FIXFLAGS += -s
516
+
@
517
+
518
+
If you only intend your game to run on monochrome systems, these two flags can be useful: they set up RGBDS' memory layout to be more convenient for you.
519
+
<<project.mk>>=
520
+
# LDFLAGS += -d
521
+
# LDFLAGS += -w
522
+
@
523
+
524
+
And, finally, if you don't want to use a MBC, this sets RGBDS' memory layout in “tiny” mode, which is more appropriate and convenient for such projects.
525
+
<<project.mk>>=
526
+
# LDFLAGS += -t
527
+
@
528
+
529
+
\subsubsection{Miscellanea}
530
+
531
+
This defines the value that the ROM will be filled with.
532
+
The default value of \texttt{0xFF} is actually significant: it encodes the \texttt{rst \$38} instruction, which helps catch runaway execution (say, dereferencing a bad jump table index, or forgetting a \texttt{ret}...) by making it jump to \texttt{\$0038}, where a crash handler is located (by default).
533
+
<<project.mk>>=
534
+
PADVALUE := 0xFF
535
+
@
536
+
537
+
This sets the ROM's file name.
538
+
<<project.mk>>=
539
+
ROMNAME := boilerplate
540
+
ROMEXT := gb
541
+
@
542
+
448
543
\section{Overall structure}\label{sec:overall}
449
544
450
545
Here is where we collect all the things we have seen thus far.
0 commit comments