From 1b370daf04cd5ed85f39d766664416e4cc14cd06 Mon Sep 17 00:00:00 2001 From: Logan McNaughton Date: Fri, 1 Jan 2021 03:33:45 +0000 Subject: [PATCH] update core --- mupen64plus-core/data/mupen64plus.ini | 7 ++- mupen64plus-core/projects/unix/Makefile | 2 +- mupen64plus-core/src/device/dd/disk.c | 4 +- mupen64plus-core/tools/gen_asm_script.cmd | 61 ++++++++++++----------- mupen64plus-core/tools/gen_asm_script.sh | 42 +++++++++++----- 5 files changed, 70 insertions(+), 46 deletions(-) diff --git a/mupen64plus-core/data/mupen64plus.ini b/mupen64plus-core/data/mupen64plus.ini index 8aea248..2fef7b4 100644 --- a/mupen64plus-core/data/mupen64plus.ini +++ b/mupen64plus-core/data/mupen64plus.ini @@ -13895,11 +13895,16 @@ CRC=9A6CF2F5 D5F365EE GoodName=SmashRemix0.9.4 CRC=1B5AAD82 368B88C1 Status=3 -Players=4 SaveType=SRAM +Players=4 Rumble=Yes CountPerOp=1 +[983F8A1D9A8D6AA1A6500AF413CE1FF] +GoodName=SmashRemix0.9.5b +CRC=B9CDC5C3 0D2F4668 +RefMD5=5AAC6E652C5CF1E37A466AC0073E88CA + [B8D4B92E66A312708626B3216DE07A3A] GoodName=Snobow Kids (J) [!] CRC=84FC04FF B1253CE9 diff --git a/mupen64plus-core/projects/unix/Makefile b/mupen64plus-core/projects/unix/Makefile index f7d4ad3..c84b59b 100755 --- a/mupen64plus-core/projects/unix/Makefile +++ b/mupen64plus-core/projects/unix/Makefile @@ -782,7 +782,7 @@ $(ASM_DEFINES_OBJ): $(SRCDIR)/asm_defines/asm_defines.c # Script hackery for generating ASM include files for the new dynarec assembly code $(SRCDIR)/asm_defines/asm_defines_gas.h: $(SRCDIR)/asm_defines/asm_defines_nasm.h $(SRCDIR)/asm_defines/asm_defines_nasm.h: $(ASM_DEFINES_OBJ) $(SRCDIR)/../tools/gen_asm_script.sh - sh $(SRCDIR)/../tools/gen_asm_script.sh "$(SRCDIR)/asm_defines" "$(ASM_DEFINES_OBJ)" + bash $(SRCDIR)/../tools/gen_asm_script.sh "$(SRCDIR)/asm_defines" "$(ASM_DEFINES_OBJ)" # standard build rules $(OBJDIR)/%.o: $(SRCDIR)/%.asm $(SRCDIR)/asm_defines/asm_defines_nasm.h diff --git a/mupen64plus-core/src/device/dd/disk.c b/mupen64plus-core/src/device/dd/disk.c index 14127e5..c58558d 100644 --- a/mupen64plus-core/src/device/dd/disk.c +++ b/mupen64plus-core/src/device/dd/disk.c @@ -251,7 +251,7 @@ static uint8_t* get_sector_base_mame(const struct dd_disk* disk, + sector * sector_size; /* Access to protected LBA should return an error */ - if (sector == 0) + if (sector == 0 && track < (SYSTEM_LBAS / 2)) { uint16_t lblock = offset / BLOCKSIZE(0); uint16_t lblock_sys = disk->offset_sys / BLOCKSIZE(0); @@ -287,7 +287,7 @@ static uint8_t* get_sector_base_sdk(const struct dd_disk* disk, unsigned int offset = LBAToByte(sys_data, 0, lba) + sector * sector_size; /* Handle Errors for wrong System Data */ - if (sector == 0) + if (sector == 0 && lba < SYSTEM_LBAS) { uint16_t lblock = offset / BLOCKSIZE(0); uint16_t lblock_sys = disk->offset_sys / BLOCKSIZE(0); diff --git a/mupen64plus-core/tools/gen_asm_script.cmd b/mupen64plus-core/tools/gen_asm_script.cmd index 18234dd..710aec2 100644 --- a/mupen64plus-core/tools/gen_asm_script.cmd +++ b/mupen64plus-core/tools/gen_asm_script.cmd @@ -1,11 +1,10 @@ @echo off setlocal enableextensions - :: Validating arguments passed from Visual Studio to use as variables: :: -:: * Arguments with conflicting syntax can terminate the script abruptly. -:: * 'GAS_EXTRA' argument isn't initialized/used in some cases. +:: * Arguments with conflicting syntax can terminate the script abruptly +:: * 'GAS_EXTRA' argument isn't used in some cases :: set GAS_EXTRA= for /f "tokens=1,2*" %%A in ('echo %*') do ( @@ -16,53 +15,55 @@ set GAS_EXTRA=%%C set GAS_CLARG=%GAS_OBJDIR% if defined GAS_EXTRA set GAS_CLARG=%GAS_OBJDIR% %GAS_EXTRA% - :: "Anti-PEBCAK": :: -:: * Ensures that "Item A" and "Item B" exist, and send an error signal if not. -:: * The sole purpose of this code is to make the script fail outside VS. +:: * Ensures that "Item A" and "Item B" exist, and send an error signal if not +:: * The sole purpose of this code is to make the script fail outside VS :: if not exist mupen64plus-core.vcxproj exit /b 202 if not exist "%GAS_SRCDIR%asm_defines.c" exit /b 303 - :: Legacy code adaptation for this script: :: -:: * Delete the libraries previously generated by gawk and/or this script. -:: * CL's stuff/witchcraft, if all goes well it will generate "Item C". +:: * Delete the libraries previously generated by 'gawk' or this script +:: * CL's stuff/witchcraft, if all goes well it will generate "Item C" :: -del "%GAS_SRCDIR%asm_defines_*" +del /f /q "%GAS_SRCDIR%asm_defines_*" 2>nul cl /c /Fo%GAS_CLARG% /I ..\..\src "%GAS_SRCDIR%asm_defines.c" - -:: If "Item C" does not exist, send error: -:: +:: If "Item C" does not exist, send error if not exist "%GAS_OBJDIR%asm_defines.obj" exit /b 404 +if "%USE_GAWK%" NEQ "1" goto native +:: Legacy code adaptation for 'gawk': +:: +:: * Define 'USE_GAWK=1' to use 'gawk' +:: * A POSIX version of 'GAS_SRCDIR' is required for 'dest_dir' argument +:: +set "GAS_SRCDIR2=%GAS_SRCDIR:\=/%" +set GAWK=..\..\..\mupen64plus-win32-deps\gawk-3.1.6-1\bin\gawk.exe +"%GAWK%" -v dest_dir="%GAS_SRCDIR2%" -f "%~dp0gen_asm_defines.awk" "%GAS_OBJDIR%asm_defines.obj" +goto log +:native -:: Legacy code adaptation for 'gawk', currently disabled: +:: Adaptation of 'gen_asm_defines.awk' / 'gen_asm_script.sh': :: -:: * A "POSIX version" of 'GAS_SRCDIR' is required in the 'dest_dir' parameter. +:: 1. Display 'asm_defines.obj' (aka "Item C") as a list, looking only +:: for patterns '@ASM_DEFINE' +:: 2. Sort for easy reading, the result is interpreted as an array +:: with ' ' as default delimiter in the 'for' command +:: 3. The for's 'tokens=2,3' ignores pattern "1" (@ASM_DEFINE) and anything +:: beyond "3", take "2" (offset* value) as 'J' and "3" (hex* value) as 'K' +:: 4. Print current values and repeat steps 3 and 4 on the next line +:: until EOL is reached :: -REM "..\..\..\mupen64plus-win32-deps\gawk-3.1.6-1\bin\gawk.exe" -v dest_dir="../../src/asm_defines" -f ..\..\tools\gen_asm_defines.awk "%GAS_OBJDIR%asm_defines.obj" - - -:: Simplified adaptation of 'gen_asm_defines.awk': -:: -:: * Display 'asm_defines.obj' (aka "Item C") as a list. -:: * Look for the '@ASM_DEFINE' pattern. -:: * Take element '$2' and '$3' on that line. -:: * Print '%define "$2" ("$3")' to 'asm_defines_nasm.h'. -:: * Print '#define "$2" ("$3")' to 'asm_defines_gas.h'. -:: -for /f "tokens=2,3" %%J in ('type "%GAS_OBJDIR%asm_defines.obj" ^| find "@ASM_DEFINE"') do ( +for /f "tokens=2,3" %%J in ('type "%GAS_OBJDIR%asm_defines.obj" ^| find "@ASM_DEFINE" ^| sort') do ( echo %%define %%J ^(%%K^)>>"%GAS_SRCDIR%asm_defines_nasm.h" echo #define %%J ^(%%K^)>>"%GAS_SRCDIR%asm_defines_gas.h" ) +:log - -:: Display 'asm_defines_nasm.h' for logging purposes: -:: +:: Display 'asm_defines_nasm.h' in the log echo. type "%GAS_SRCDIR%asm_defines_nasm.h" echo. diff --git a/mupen64plus-core/tools/gen_asm_script.sh b/mupen64plus-core/tools/gen_asm_script.sh index 6692dc4..6120ad0 100755 --- a/mupen64plus-core/tools/gen_asm_script.sh +++ b/mupen64plus-core/tools/gen_asm_script.sh @@ -1,20 +1,38 @@ -#!/bin/sh +#!/bin/bash set -e +set +f -if [ -z "$TR" ]; then TR=tr; fi +# Set the "print" outputs NASM_FILE="$1/asm_defines_nasm.h" GAS_FILE="$1/asm_defines_gas.h" -rm -f $NASM_FILE $GAS_FILE +rm -f "$1/asm_defines_*" -GAS_BOOL=0 -GAS_LOOP="$(LC_ALL=C grep -a @ASM_DEFINE "$2" | sed 's/@ASM_DEFINE offsetof_struct_//g' | $TR -s '\n' ' ')" -for GAS_CUR in ${GAS_LOOP}; do - if [ "${GAS_BOOL}" = "0" ]; then - GAS_BOOL=1 - GAS_STR=${GAS_CUR} +# Adaptation of 'gen_asm_defines.awk' / 'gen_asm_script.cmd': +# +# 1. Display 'asm_defines.o' as a list, looking only for +# patterns '@ASM_DEFINE' +# 2. Sort for easy reading, the result is interpreted as an array or +# worksheet with ' ' as a self-imposed delimiter in the 'cut' command +# 3. The cut's '-f2,3' discards column "1" (@ASM_DEFINE) and anything +# beyond "3", take "2" (offset* column), the delimiters and +# "3" (hex* column) to be kept +# 4. After setting 'GAS_OBJSTR', all the next lines (LF) are degraded +# to ' ' and thus all patterns in columns "2" and "3" become a +# predictable text sequence +GAS_OBJSTR=$(LC_ALL=C grep -a "@ASM_DEFINE" "$2" | sort | cut -d ' ' -f2,3) +for GAS_CURSTR in ${GAS_OBJSTR}; do + +# 5. If the current value doesn't contain a hex glob (pattern matching), +# it must be a "offset* value" + if [ "${GAS_CURSTR:0:2}" != "0x" ]; then + +# 6. Save current value and repeat step 5 on the next value + GAS_OFFSET=${GAS_CURSTR} else - GAS_BOOL=0 - echo "%define offsetof_struct_${GAS_STR} (${GAS_CUR})">>$NASM_FILE - echo "#define offsetof_struct_${GAS_STR} (${GAS_CUR})">>$GAS_FILE + +# 7. Print current values and repeat steps 5-7 on the next value +# until EOL is reached + echo "%define ${GAS_OFFSET} (${GAS_CURSTR})" >> "$NASM_FILE" + echo "#define ${GAS_OFFSET} (${GAS_CURSTR})" >> "$GAS_FILE" fi done