Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
28ab2c9
MMC1 512K PRG support
sebastienvezina Apr 28, 2025
17b9b48
Fixed double __ in register names
sebastienvezina Apr 28, 2025
88e2cb5
vscode plugin ignore - not needed
sebastienvezina Apr 28, 2025
a00393e
skip set CHR bits if switch to bank < 16
sebastienvezina Apr 28, 2025
9993ac2
fix switching to a high bank was exiting early in the middle of the b…
sebastienvezina Apr 28, 2025
d11ec30
replaced cmp/bne w and/beq
sebastienvezina Apr 28, 2025
085fec1
update actual registers
sebastienvezina Apr 28, 2025
659a4a0
nes-mmc1 prg 512 unit tests
sebastienvezina Apr 28, 2025
2610b30
hex to lowercase + removed references to prg 15
sebastienvezina Apr 28, 2025
cc334b9
jrowboy's set_prg_bank
sebastienvezina Apr 29, 2025
af1dc55
review https://github.com/llvm-mos/llvm-mos-sdk/pull/396#discussion_r…
sebastienvezina Apr 29, 2025
1661294
fix https://github.com/llvm-mos/llvm-mos-sdk/pull/396#discussion_r206…
sebastienvezina Apr 29, 2025
a93c409
fix https://github.com/llvm-mos/llvm-mos-sdk/pull/396#discussion_r206…
sebastienvezina Apr 29, 2025
48992f0
latest version of set_prg_bank but still use prg_rom_is_512 which sho…
sebastienvezina Apr 29, 2025
a1a1df2
attempt at fixing the fixed bank output format
sebastienvezina Apr 29, 2025
ed2856d
added __ prefix to prg_rom_is_512
sebastienvezina Apr 29, 2025
181ecda
try to preserve the PRG RAM bit
sebastienvezina Apr 29, 2025
500564c
Added prg-rom-512 test to list
sebastienvezina Apr 30, 2025
b62a60f
banked_call fiddling because set_prg_bank clobbers rc2 and/or rc3
sebastienvezina May 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions mos-platform/nes-mmc1/mapper.s
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,34 @@ __set_prg_bank:
set_prg_bank:
tay
.Lset:
lda _PRG_BANK ; Load the value of _PRG_BANK into the accumulator
and #%00010000 ; Compare it with 16
beq set_bits_to_0 ; If _PRG_BANK is less than 16, branch to set_bits_to_0

.set_bits_to_1:
lda _CHR_BANK0 ; Load the value of _CHR_BANK0
ora #%00010000 ; Set the 4th bit
sta _CHR_BANK0 ; Store the updated value back
mmc1_register_write MMC1_CHR0

lda _CHR_BANK1 ; Load the value of _CHR_BANK1
ora #%00010000 ; Set the 4th bit
sta _CHR_BANK1 ; Store the updated value back
mmc1_register_write MMC1_CHR1
bne .continue_bankswitch

.set_bits_to_0:
lda _CHR_BANK0 ; Load the value of _CHR_BANK0
and #%11101111 ; Clear the 4th bit
sta _CHR_BANK0 ; Store the updated value back
mmc1_register_write MMC1_CHR0

lda _CHR_BANK1 ; Load the value of _CHR_BANK1
and #%11101111 ; Clear the 4th bit
sta _CHR_BANK1 ; Store the updated value back
mmc1_register_write MMC1_CHR1

.continue_bankswitch:
inc __reset_mmc1_byte
ldx #1
stx _IN_PROGRESS
Expand Down
84 changes: 83 additions & 1 deletion mos-platform/nes-mmc1/prg-rom-banked.ld
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ __prg_rom_11_lma = 0x0b8000;
__prg_rom_12_lma = 0x0c8000;
__prg_rom_13_lma = 0x0d8000;
__prg_rom_14_lma = 0x0e8000;
__prg_rom_15_lma = 0x0f8000;
__prg_rom_16_lma = 0x108000;
__prg_rom_17_lma = 0x118000;
__prg_rom_18_lma = 0x128000;
__prg_rom_19_lma = 0x138000;
__prg_rom_20_lma = 0x148000;
__prg_rom_21_lma = 0x158000;
__prg_rom_22_lma = 0x168000;
__prg_rom_23_lma = 0x178000;
__prg_rom_24_lma = 0x188000;
__prg_rom_25_lma = 0x198000;
__prg_rom_26_lma = 0x1A8000;
__prg_rom_27_lma = 0x1B8000;
__prg_rom_28_lma = 0x1C8000;
__prg_rom_29_lma = 0x1D8000;
__prg_rom_30_lma = 0x1E8000;
__prg_rom_fixed_lma = 0xc000;

__prg_rom_0_offset = 0x00000;
Expand All @@ -32,6 +48,22 @@ __prg_rom_11_offset = 0x2c000;
__prg_rom_12_offset = 0x30000;
__prg_rom_13_offset = 0x34000;
__prg_rom_14_offset = 0x38000;
__prg_rom_15_offset = 0x3C000;
__prg_rom_16_offset = 0x40000;
__prg_rom_17_offset = 0x44000;
__prg_rom_18_offset = 0x48000;
__prg_rom_19_offset = 0x4c000;
__prg_rom_20_offset = 0x50000;
__prg_rom_21_offset = 0x54000;
__prg_rom_22_offset = 0x58000;
__prg_rom_23_offset = 0x5c000;
__prg_rom_24_offset = 0x60000;
__prg_rom_25_offset = 0x64000;
__prg_rom_26_offset = 0x68000;
__prg_rom_27_offset = 0x6c000;
__prg_rom_28_offset = 0x70000;
__prg_rom_29_offset = 0x74000;
__prg_rom_30_offset = 0x78000;
__prg_rom_fixed_offset = __prg_rom_size * 1024 - 0x4000;

MEMORY {
Expand All @@ -51,6 +83,22 @@ MEMORY {
prg_rom_12 : ORIGIN = __prg_rom_12_lma, LENGTH = __prg_rom_size >= 256 ? 0x4000 - 12 : 0
prg_rom_13 : ORIGIN = __prg_rom_13_lma, LENGTH = __prg_rom_size >= 256 ? 0x4000 - 12 : 0
prg_rom_14 : ORIGIN = __prg_rom_14_lma, LENGTH = __prg_rom_size >= 256 ? 0x4000 - 12 : 0
prg_rom_15 : ORIGIN = __prg_rom_15_lma, LENGTH = __prg_rom_size >= 512 ? 0x4000 - 12 : 0
prg_rom_16 : ORIGIN = __prg_rom_16_lma, LENGTH = __prg_rom_size >= 512 ? 0x4000 - 12 : 0
prg_rom_17 : ORIGIN = __prg_rom_17_lma, LENGTH = __prg_rom_size >= 512 ? 0x4000 - 12 : 0
prg_rom_18 : ORIGIN = __prg_rom_18_lma, LENGTH = __prg_rom_size >= 512 ? 0x4000 - 12 : 0
prg_rom_19 : ORIGIN = __prg_rom_19_lma, LENGTH = __prg_rom_size >= 512 ? 0x4000 - 12 : 0
prg_rom_20 : ORIGIN = __prg_rom_20_lma, LENGTH = __prg_rom_size >= 512 ? 0x4000 - 12 : 0
prg_rom_21 : ORIGIN = __prg_rom_21_lma, LENGTH = __prg_rom_size >= 512 ? 0x4000 - 12 : 0
prg_rom_22 : ORIGIN = __prg_rom_22_lma, LENGTH = __prg_rom_size >= 512 ? 0x4000 - 12 : 0
prg_rom_23 : ORIGIN = __prg_rom_23_lma, LENGTH = __prg_rom_size >= 512 ? 0x4000 - 12 : 0
prg_rom_24 : ORIGIN = __prg_rom_24_lma, LENGTH = __prg_rom_size >= 512 ? 0x4000 - 12 : 0
prg_rom_25 : ORIGIN = __prg_rom_25_lma, LENGTH = __prg_rom_size >= 512 ? 0x4000 - 12 : 0
prg_rom_26 : ORIGIN = __prg_rom_26_lma, LENGTH = __prg_rom_size >= 512 ? 0x4000 - 12 : 0
prg_rom_27 : ORIGIN = __prg_rom_27_lma, LENGTH = __prg_rom_size >= 512 ? 0x4000 - 12 : 0
prg_rom_28 : ORIGIN = __prg_rom_28_lma, LENGTH = __prg_rom_size >= 512 ? 0x4000 - 12 : 0
prg_rom_29 : ORIGIN = __prg_rom_29_lma, LENGTH = __prg_rom_size >= 512 ? 0x4000 - 12 : 0
prg_rom_30 : ORIGIN = __prg_rom_30_lma, LENGTH = __prg_rom_size >= 512 ? 0x4000 - 12 : 0
prg_rom_fixed : ORIGIN = __prg_rom_fixed_lma, LENGTH = 0x4000 - 12

/* Reset stub. Arbitrarily put its VMA in the first bank. */
Expand Down Expand Up @@ -78,6 +126,22 @@ SECTIONS {
.prg_rom_12 : { *(.prg_rom_12 .prg_rom_12.*) } >prg_rom_12
.prg_rom_13 : { *(.prg_rom_13 .prg_rom_13.*) } >prg_rom_13
.prg_rom_14 : { *(.prg_rom_14 .prg_rom_14.*) } >prg_rom_14
.prg_rom_15 : { *(.prg_rom_15 .prg_rom_15.*) } >prg_rom_15
.prg_rom_16 : { *(.prg_rom_16 .prg_rom_16.*) } >prg_rom_16
.prg_rom_17 : { *(.prg_rom_17 .prg_rom_17.*) } >prg_rom_17
.prg_rom_18 : { *(.prg_rom_18 .prg_rom_18.*) } >prg_rom_18
.prg_rom_19 : { *(.prg_rom_19 .prg_rom_19.*) } >prg_rom_19
.prg_rom_20 : { *(.prg_rom_20 .prg_rom_20.*) } >prg_rom_20
.prg_rom_21 : { *(.prg_rom_21 .prg_rom_21.*) } >prg_rom_21
.prg_rom_22 : { *(.prg_rom_22 .prg_rom_22.*) } >prg_rom_22
.prg_rom_23 : { *(.prg_rom_23 .prg_rom_23.*) } >prg_rom_23
.prg_rom_24 : { *(.prg_rom_24 .prg_rom_24.*) } >prg_rom_24
.prg_rom_25 : { *(.prg_rom_25 .prg_rom_25.*) } >prg_rom_25
.prg_rom_26 : { *(.prg_rom_26 .prg_rom_26.*) } >prg_rom_26
.prg_rom_27 : { *(.prg_rom_27 .prg_rom_27.*) } >prg_rom_27
.prg_rom_28 : { *(.prg_rom_28 .prg_rom_28.*) } >prg_rom_28
.prg_rom_29 : { *(.prg_rom_29 .prg_rom_29.*) } >prg_rom_29
.prg_rom_30 : { *(.prg_rom_30 .prg_rom_30.*) } >prg_rom_30
.prg_rom_fixed : { *(.prg_rom_fixed .prg_rom_fixed.*) } >prg_rom_fixed
}

Expand All @@ -88,7 +152,7 @@ SECTIONS {
.reset_fixed : { KEEP(*(.reset_fixed)) } >reset_fixed
}

PROVIDE(__prg_rom_size = 256);
PROVIDE(__prg_rom_size = 512);

OUTPUT_FORMAT {
INCLUDE ines-header.ld
Expand All @@ -108,5 +172,23 @@ OUTPUT_FORMAT {
FULL(prg_rom_13) FULL(reset, 0, LENGTH(prg_rom_13) ? LENGTH(reset) : 0)
FULL(prg_rom_14) FULL(reset, 0, LENGTH(prg_rom_14) ? LENGTH(reset) : 0)
FULL(prg_rom_fixed) FULL(reset_fixed)

FULL(prg_rom_16) FULL(reset, 0, LENGTH(prg_rom_16) ? LENGTH(reset) : 0)
FULL(prg_rom_17) FULL(reset, 0, LENGTH(prg_rom_17) ? LENGTH(reset) : 0)
FULL(prg_rom_18) FULL(reset, 0, LENGTH(prg_rom_18) ? LENGTH(reset) : 0)
FULL(prg_rom_19) FULL(reset, 0, LENGTH(prg_rom_19) ? LENGTH(reset) : 0)
FULL(prg_rom_20) FULL(reset, 0, LENGTH(prg_rom_20) ? LENGTH(reset) : 0)
FULL(prg_rom_21) FULL(reset, 0, LENGTH(prg_rom_21) ? LENGTH(reset) : 0)
FULL(prg_rom_22) FULL(reset, 0, LENGTH(prg_rom_22) ? LENGTH(reset) : 0)
FULL(prg_rom_23) FULL(reset, 0, LENGTH(prg_rom_23) ? LENGTH(reset) : 0)
FULL(prg_rom_24) FULL(reset, 0, LENGTH(prg_rom_24) ? LENGTH(reset) : 0)
FULL(prg_rom_25) FULL(reset, 0, LENGTH(prg_rom_25) ? LENGTH(reset) : 0)
FULL(prg_rom_26) FULL(reset, 0, LENGTH(prg_rom_26) ? LENGTH(reset) : 0)
FULL(prg_rom_27) FULL(reset, 0, LENGTH(prg_rom_27) ? LENGTH(reset) : 0)
FULL(prg_rom_28) FULL(reset, 0, LENGTH(prg_rom_28) ? LENGTH(reset) : 0)
FULL(prg_rom_29) FULL(reset, 0, LENGTH(prg_rom_29) ? LENGTH(reset) : 0)
FULL(prg_rom_30) FULL(reset, 0, LENGTH(prg_rom_30) ? LENGTH(reset) : 0)
FULL(prg_rom_fixed) FULL(reset_fixed)

FULL(chr_rom)
}