-
Notifications
You must be signed in to change notification settings - Fork 19
Upgrade to NES2.0 header #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 8 commits
cd437ac
1d6e2fc
6975403
10484d4
350a063
2ce34c4
9feb891
201056f
81ec479
17561c4
ae3a49d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,26 @@ | ||
; | ||
; iNES header | ||
; NES2.0 header | ||
; https://www.nesdev.org/wiki/NES_2.0 | ||
; | ||
|
||
; This iNES header is from Brad Smith (rainwarrior) | ||
; iNES header adapted from Brad Smith (rainwarrior) | ||
; https://github.com/bbbradsmith/NES-ca65-example | ||
|
||
.segment "HEADER" | ||
|
||
.include "constants.asm" ; for INES_HEADER | ||
|
||
INES_MIRROR = 0 ; 0 = horizontal mirroring, 1 = vertical mirroring (ignored in MMC1) | ||
INES_SRAM = 1 ; 1 = battery backed SRAM at $6000-7FFF | ||
INES_SRAM = SAVE_HIGHSCORES ; 1 = battery backed SRAM at $6000-7FFF | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should probably add a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should that flag be a new addition, or should it replace an existing flag? I think replacing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should be an additional flag so the saving highscores can be disabled separately if needed. In a newer version we might decide to remove or replace it and leaving the name makes it easier to remove. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added the |
||
NES2_SRAM_SHIFT = INES_SRAM * 7 ; if SRAM present, set shift to 7 for (64 << 7) = 8KiB size | ||
NES2_REGION = 2 ; 0 = NTSC, 1 = PAL, 2 = multi-region, 3 = UA6538 ("Dendy") | ||
|
||
; Pick default expansion device | ||
.if KEYBOARD = 1 | ||
NES2_INPUT = $23 ; Family BASIC Keyboard | ||
.else | ||
NES2_INPUT = 1 ; standard NES/FC controllers | ||
.endif | ||
|
||
; Override INES_MAPPER for mode 1000 (auto detect) | ||
.if INES_MAPPER = 1000 | ||
|
@@ -20,12 +30,31 @@ INES_SRAM = 1 ; 1 = battery backed SRAM at $6000-7FFF | |
_INES_MAPPER = 1 ; MMC1 for Emulator/Flashcart | ||
.endif | ||
.else | ||
_INES_MAPPER = INES_MAPPER ; use actual INES_MAPPER otherwise | ||
_INES_MAPPER = INES_MAPPER ; use actual INES_MAPPER otherwise | ||
.endif | ||
|
||
; Pick the appropriate NES2_SUBMAPPER | ||
.if _INES_MAPPER = 1 | ||
NES2_SUBMAPPER = 5 ; MMC1 fixed PRG | ||
.elseif _INES_MAPPER = 3 | ||
NES2_SUBMAPPER = 2 ; CNROM bus conflicts | ||
.else | ||
NES2_SUBMAPPER = 0 ; otherwise don't specify submapper | ||
.endif | ||
|
||
; Construct header | ||
.byte 'N', 'E', 'S', $1A ; ID | ||
.byte $02 ; 16k PRG chunk count | ||
.byte $02 ; 8k CHR chunk count | ||
.byte INES_MIRROR | (INES_SRAM << 1) | ((_INES_MAPPER & $f) << 4) | ||
.byte (_INES_MAPPER & %11110000) | ||
.byte $0, $0, $0, $0, $0, $0, $0, $0 ; padding | ||
|
||
.if INES_OVERRIDE = 0 | ||
.byte (_INES_MAPPER & %11110000) | %00001000 ; NES2.0 header identifier | ||
.byte ((NES2_SUBMAPPER & $f) << 4) | ((_INES_MAPPER & $f00) >> 8) ; submapper/mapper MSB | ||
.byte $0, (NES2_SRAM_SHIFT << 4) ; PRG MSB, SRAM shift count | ||
.byte $0, NES2_REGION, $0, $0, NES2_INPUT ; misc. fields, region, input device | ||
.else | ||
.byte (_INES_MAPPER & %11110000) | ||
.byte $0, $0, $0, $0, $0, $0, $0, $0 ; padding | ||
.endif | ||
|
Uh oh!
There was an error while loading. Please reload this page.