Skip to content

Commit

Permalink
fill GB cartridge header using RGBFIX
Browse files Browse the repository at this point in the history
  • Loading branch information
pinobatch committed Mar 10, 2024
1 parent 0f9834d commit b661c8a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 49 deletions.
3 changes: 2 additions & 1 deletion gameboy/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ objlisto := $(foreach o,$(objlist),obj/gb/$(o).o)

$(title).gb: $(objlisto)
$(RGBLINK) -w -p 0xFF -m$(title).map -n$(title).sym -o$@ $^
$(RGBFIX) -p0 -v $@
cp $(title).gb $(title).beforefix
$(RGBFIX) -p 0xFF -m 'ROM' -vjcst '144P TEST' -kP8 -l0x33 $@

#obj/gb/%.o: obj/gb/%-dedent.z80 src/gb.inc src/hardware.inc src/global.inc
# $(RGBASM) -o $@ $<
Expand Down
50 changes: 2 additions & 48 deletions gameboy/src/header.z80
Original file line number Diff line number Diff line change
Expand Up @@ -33,57 +33,11 @@ SECTION "rst00", ROM0[$0000]

; $18-$38 and $50-$60 not used and omitted to save space
; Caution: If you set a bit in IE, you MUST have a handler for that
; interrupt. VisualBoyAdvance is known to call interrupt handlers
; on DI HALT.
; interrupt. VisualBoyAdvance calls interrupt handlers on DI HALT.

SECTION "header", ROM0[$0100]
; All licensed games begin with NOP JP. It may have had to do with
; the debugger used in the era.
nop
jp reset_handler

; IPL uses this header to ensure D7-D0, A15, A5-A0, and /RD are
; connected before calling something in the game that might
; corrupt battery-backed save RAM. The data inserted by RGBFIX
; spells "Nintendo" when deinterleaved to tiles.
ds 48,$00

; TODO: Figure out how much of this RGBFIX can fill in for me

; 11-character title
DB "144P TEST"
DS 2,$00

; Serial code (is ADME Doom or Animal Crossing?)
DS 4,$00

; Execution mode (GBC runs in GBC mode if bit 7 is true)
DB CART_COMPATIBLE_DMG_GBC

; $0144: Developer ID
DB "OK"

; SGB mode
DB CART_INDICATOR_SGB

; Mapper
DB CART_ROM

; $0148: ceil(log2(ROM size / 32768))
DB $00
; log2(RAM size / 512)/2
DB $00

; Region code
DB CART_DEST_NON_JAPANESE

; Old hex developer ID: $33 means "see $0144"
; Must be $33 for SGB support
DB $33
; ROM version number
DB $00

; Leave space for header checksum to be filled in by rgbfix
DS 3
ds 76, $00

0 comments on commit b661c8a

Please sign in to comment.