Skip to content

Commit 13ff83d

Browse files
committed
Refactor iNES header.
1 parent 432ecbd commit 13ff83d

File tree

20 files changed

+164
-172
lines changed

20 files changed

+164
-172
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
11
platform(nes-nrom-128 COMPLETE PARENT nes-nrom)
2+
3+
if(NOT CMAKE_CROSSCOMPILING)
4+
return()
5+
endif()
6+
7+
add_platform_object_file(nes-nrom-128-crt0-o crt0.o ines.s)
8+
merge_libraries(nes-nrom-128-crt0-o nes-nrom-crt0-o)

mos-platform/nes-nrom-128/ines.s

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
; Settings in the iNES 2.0 header.
2+
3+
.global __prg_rom_size
4+
__prg_rom_size = 1

mos-platform/nes-nrom-128/link.ld

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,3 @@ MEMORY {
99
}
1010

1111
INCLUDE nes-nrom.ld
12-
13-
OUTPUT_FORMAT {
14-
INCLUDE ines-header.ld
15-
16-
/* PRG-ROM size LSB (counting by 16K) */
17-
BYTE(1)
18-
/* CHR-ROM size LSB (counting by 8K) */
19-
BYTE(1)
20-
21-
INCLUDE ines-flags.ld
22-
23-
FULL(prg_rom)
24-
FULL(chr_rom)
25-
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
11
platform(nes-nrom-256 COMPLETE PARENT nes-nrom)
2+
3+
if(NOT CMAKE_CROSSCOMPILING)
4+
return()
5+
endif()
6+
7+
add_platform_object_file(nes-nrom-256-crt0-o crt0.o ines.s)
8+
merge_libraries(nes-nrom-256-crt0-o nes-nrom-crt0-o)

mos-platform/nes-nrom-256/ines.s

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
; Settings in the iNES 2.0 header.
2+
3+
.global __prg_rom_size
4+
__prg_rom_size = 2

mos-platform/nes-nrom-256/link.ld

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,3 @@ MEMORY {
66
}
77

88
INCLUDE nes-nrom.ld
9-
10-
OUTPUT_FORMAT {
11-
INCLUDE ines-header.ld
12-
13-
/* PRG-ROM size LSB (counting by 16K) */
14-
BYTE(2)
15-
/* CHR-ROM size LSB (counting by 8K) */
16-
BYTE(1)
17-
18-
INCLUDE ines-flags.ld
19-
20-
FULL(prg_rom)
21-
FULL(chr_rom)
22-
}

mos-platform/nes-nrom/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ if(NOT CMAKE_CROSSCOMPILING)
44
return()
55
endif()
66

7-
install(FILES
8-
nes-nrom.ld
9-
ines-flags.ld
10-
TYPE LIB)
7+
install(FILES nes-nrom.ld TYPE LIB)
118

129
add_platform_object_file(nes-nrom-crt0-o crt0.o ines.s)
1310
merge_libraries(nes-nrom-crt0-o nes-crt0-o)

mos-platform/nes-nrom/ines-flags.ld

Lines changed: 0 additions & 50 deletions
This file was deleted.

mos-platform/nes-nrom/ines.s

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
; Defaults for settings in the iNES 2.0 header.
1+
; Settings in the iNES 2.0 header.
22

3-
.weak __hard_wired_mirroring
4-
; Default to horizontal hard-wired mirroring (or N/A)
5-
__hard_wired_mirroring = 0
6-
7-
.weak __timing
8-
; Default to RP2C02 ("NTSC NES")
9-
__timing = 0
3+
.global __mapper
4+
__mapper = 0
5+
.global __chr_rom_size
6+
__chr_rom_size = 1

mos-platform/nes-nrom/nes-nrom.ld

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
/* NES-NROM iNES file linker script. */
22

3-
MEMORY {
4-
/* CPU address space. */
5-
ram (w) : ORIGIN = 0x0200, LENGTH = 0x0600
6-
7-
/* CHR-ROM VMA. */
8-
ppu_chr_rom : ORIGIN = 0x0000, LENGTH = 0x2000
3+
INCLUDE nes.ld
94

5+
MEMORY {
106
/**
117
* CHR-ROM LMA. Doesn't correspond to anything at runtime; this is beyond
128
* 0xffff to make sure that all LMAs are unique.
@@ -23,9 +19,9 @@ SECTIONS {
2319
INCLUDE bss.ld
2420
INCLUDE noinit.ld
2521

26-
.chr_rom : { *(.chr_rom) } >ppu_chr_rom AT>chr_rom
22+
.chr_rom : { *(.chr_rom) } >chr_rom
2723

2824
.vector 0xfffa : { SHORT(nmi) SHORT(_start) SHORT(irq) } >prg_rom
2925
}
3026

31-
INCLUDE nes-imag-regs.ld
27+
INCLUDE ines.ld

0 commit comments

Comments
 (0)