asar icon indicating copy to clipboard operation
asar copied to clipboard

Mapping mode detection is always lorom

Open spooonsss opened this issue 2 years ago • 0 comments
trafficstars

The manual states "When no mapping mode is specified, Asar tries to determine the mapping mode from the output ROM." but it doesn't work.

Asar detects the mapping mode, then overwrites it with lorom.

>	asar.exe!setmapper() Line 110	C++
 	asar.exe!main(int argc, char * * argv) Line 360	C++
 	asar.exe!invoke_main() Line 79	C++
 	asar.exe!__scrt_common_main_seh() Line 288	C++
 	asar.exe!__scrt_common_main() Line 331	C++
 	asar.exe!mainCRTStartup(void * __formal) Line 17	C++
 	kernel32.dll!BaseThreadInitThunk()	Unknown
 	ntdll.dll!RtlUserThreadStart()	Unknown


>	asar.exe!initstuff() Line 689	C++
 	asar.exe!main(int argc, char * * argv) Line 417	C++
 	asar.exe!invoke_main() Line 79	C++
 	asar.exe!__scrt_common_main_seh() Line 288	C++
 	asar.exe!__scrt_common_main() Line 331	C++
 	asar.exe!mainCRTStartup(void * __formal) Line 17	C++
 	kernel32.dll!BaseThreadInitThunk()	Unknown
 	ntdll.dll!RtlUserThreadStart()	Unknown

Additionally, bigsa1rom isn't detected. I'd suggest setting it based on ROM size:

diff --git a/src/asar/main.cpp b/src/asar/main.cpp
index 0e49980..922988b 100644
--- a/src/asar/main.cpp
+++ b/src/asar/main.cpp
@@ -104,7 +104,14 @@ bool setmapper()
 	int romtypebyte=romdata[snestopc(0x00FFD6)];
 	if (mapper==lorom)
 	{
-		if (mapperbyte==0x23 && (romtypebyte==0x32 || romtypebyte==0x34 || romtypebyte==0x35)) mapper=sa1rom;
+		if (mapperbyte == 0x23 && (romtypebyte == 0x32 || romtypebyte == 0x34 || romtypebyte == 0x35))
+		{
+			mapper = sa1rom;
+			if (romlen >= 0x400000)
+			{
+				mapper = bigsa1rom;
+			}
+		}
 	}
 	return (maxscore>=0);
 }

spooonsss avatar Sep 08 '23 13:09 spooonsss