Skip to content

Commit da558fc

Browse files
committed
[NES] Set shift count to zero if RAM size is zero.
Zero needs to be special cased, since the equation that computes the shift count for a given size doesn't work with zero. Fixes #98.
1 parent beb2b9a commit da558fc

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

mos-platform/nes/ines-header.ld

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,21 @@ BYTE(
3535
)
3636

3737
BYTE(
38-
((__prg_ram_size_raw ? __prg_ram_size_raw :
39-
LOG2CEIL(__prg_ram_size*1024)-6) & 0xf) << 0 |
40-
((__prg_nvram_size_raw ? __prg_nvram_size_raw :
41-
LOG2CEIL(__prg_nvram_size*1024)-6) & 0xf) << 4
38+
((__prg_ram_size_raw ?
39+
__prg_ram_size_raw :
40+
__prg_ram_size ? LOG2CEIL(__prg_ram_size*1024)-6 : 0) & 0xf) << 0 |
41+
((__prg_nvram_size_raw ?
42+
__prg_nvram_size_raw :
43+
__prg_nvram_size ? LOG2CEIL(__prg_nvram_size*1024)-6 : 0) & 0xf) << 4
4244
)
4345

4446
BYTE(
45-
((__chr_ram_size_raw ? __chr_ram_size_raw :
46-
LOG2CEIL(__chr_ram_size*1024)-6) & 0xf) << 0 |
47-
((__chr_nvram_size_raw ? __chr_nvram_size_raw :
48-
LOG2CEIL(__chr_nvram_size*1024)-6) & 0xf) << 4
47+
((__chr_ram_size_raw ?
48+
__chr_ram_size_raw :
49+
__chr_ram_size ? LOG2CEIL(__chr_ram_size*1024)-6 : 0) & 0xf) << 0 |
50+
((__chr_nvram_size_raw ?
51+
__chr_nvram_size_raw :
52+
__chr_nvram_size ? LOG2CEIL(__chr_nvram_size*1024)-6 : 0) & 0xf) << 4
4953
)
5054

5155
BYTE(__timing & 3)

0 commit comments

Comments
 (0)