From da558fcbfc729f702b24e4bf6f1a30da94e5cbf2 Mon Sep 17 00:00:00 2001 From: Daniel Thornburgh Date: Fri, 23 Dec 2022 11:11:07 -0800 Subject: [PATCH] [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. --- mos-platform/nes/ines-header.ld | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/mos-platform/nes/ines-header.ld b/mos-platform/nes/ines-header.ld index 6807aee4a..6916be801 100644 --- a/mos-platform/nes/ines-header.ld +++ b/mos-platform/nes/ines-header.ld @@ -35,17 +35,21 @@ BYTE( ) BYTE( - ((__prg_ram_size_raw ? __prg_ram_size_raw : - LOG2CEIL(__prg_ram_size*1024)-6) & 0xf) << 0 | - ((__prg_nvram_size_raw ? __prg_nvram_size_raw : - LOG2CEIL(__prg_nvram_size*1024)-6) & 0xf) << 4 + ((__prg_ram_size_raw ? + __prg_ram_size_raw : + __prg_ram_size ? LOG2CEIL(__prg_ram_size*1024)-6 : 0) & 0xf) << 0 | + ((__prg_nvram_size_raw ? + __prg_nvram_size_raw : + __prg_nvram_size ? LOG2CEIL(__prg_nvram_size*1024)-6 : 0) & 0xf) << 4 ) BYTE( - ((__chr_ram_size_raw ? __chr_ram_size_raw : - LOG2CEIL(__chr_ram_size*1024)-6) & 0xf) << 0 | - ((__chr_nvram_size_raw ? __chr_nvram_size_raw : - LOG2CEIL(__chr_nvram_size*1024)-6) & 0xf) << 4 + ((__chr_ram_size_raw ? + __chr_ram_size_raw : + __chr_ram_size ? LOG2CEIL(__chr_ram_size*1024)-6 : 0) & 0xf) << 0 | + ((__chr_nvram_size_raw ? + __chr_nvram_size_raw : + __chr_nvram_size ? LOG2CEIL(__chr_nvram_size*1024)-6 : 0) & 0xf) << 4 ) BYTE(__timing & 3)