M-HT / SR

A project to statically recompile following games to create Windows or Linux (x86 or arm) versions of the games - Albion, X-Com: UFO Defense (UFO: Enemy Unknown), X-Com: Terror from the Deep, Warcraft: Orcs & Humans, Septerra Core: Legacy of the Creator, Battle Isle 3: Shadow of the Emperor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build.sh problem with WAR.EXE

xcom169 opened this issue · comments

I think I copied the SR.EXE and the WAR.EXE to the good and same dir, but I still got this error:

./build-x86.sh
Traceback (most recent call last):
File "./compact_source.py", line 58, in
Compact(cPath + "seg01.inc")
File "./compact_source.py", line 8, in Compact
fIn = open(cFile, "rt")
FileNotFoundError: [Errno 2] No such file or directory: './seg01.inc'
Traceback (most recent call last):
File "./repair_short_jumps.py", line 19, in
iErr = int( cErrLine[iTemp1 + 1 : iTemp2] )
ValueError: invalid literal for int() with base 10: ' line 7'
Traceback (most recent call last):
File "./repair_short_jumps.py", line 19, in
iErr = int( cErrLine[iTemp1 + 1 : iTemp2] )
ValueError: invalid literal for int() with base 10: ' line 9'

My WAR.EXE is corrupted?

pwd
/home/...xyx/Documents/SR/SR-games/Warcraft/SR-cd-gog

commented

Instead of ./build-x86.sh, can you run these commands (in the same directory - SR/SR-games/Warcraft/SR-cd-gog) and post the output:

cp x86/*.sci ./
./SR.exe WAR.EXE war-asm-cdgog.asm
rm *.sci

The output should be something like this:

Output type: X86 version(s)
esp dword aligned: yes
ebp dword aligned: yes
2020-12-22 10:59:00.943: Loading EXE file...
	Sections in file: 3
2020-12-22 10:59:00.945: Loading source code information...
	Loading fixup_interpret_as_code.sci...
	Loading code16_areas.sci...
	Loading fixup_do_not_interpret_as_code.sci...
	Loading external_procedures.sci...
	Loading global_aliases.sci...
	Loading instruction_replacements.sci...
2020-12-22 10:59:00.945: Initial disassembly...
2020-12-22 10:59:00.968: Applying fixup...
2020-12-22 10:59:00.975: Full disassembly...
2020-12-22 10:59:01.032: Writing output...
2020-12-22 10:59:01.044: Finishing...

Hello!

Sure. I have the proper GOG version, so it's strange:

x45% cp x86/*.sci ./
x45% ./SR.exe WAR.EXE war-asm-cdgog.asm
Output type: X86 version(s)
esp dword aligned: yes
ebp dword aligned: yes
2020-12-22 11:10:59.887: Loading EXE file...
Sections in file: 3
2020-12-22 11:10:59.892: Loading source code information...
Loading fixup_interpret_as_code.sci...
Loading code16_areas.sci...
Loading fixup_do_not_interpret_as_code.sci...
Loading external_procedures.sci...
Loading global_aliases.sci...
Loading instruction_replacements.sci...
2020-12-22 11:10:59.892: Initial disassembly...
2020-12-22 11:10:59.954: Applying fixup...
2020-12-22 11:10:59.977: Full disassembly...
fixup: 2 - 0x2287 - 0x5a7c7
op type: 1369102216 - 2016434976 - 0
op size: 77 - 53 - 0
Error: -51

commented

Just to make sure - does your WAR.exe match the expected parameters ?

  • file size: 319291 bytes
  • md5: 03c8e5bff6772eca8d4be8a22c243fd2
  • sha1: b32ef7d87d1e51f3f0b20ce7911053f32a0d509a
  • sha256: 1e966220bf09ab007c49c5ea5ebc42eb494f5cf2f74f894d3969b6115df8d8a9

Yes, I have the very same WAR.exe .
SR.exe I compiled for myself from the git source.

commented

When compiling SR, are you using the udis86 library which is in SR/udis86-1.6/ ? Or do you have another udis86 library installed ?

No, I used https://aur.archlinux.org/packages/udis86/ .
With your Udis86, the SR.exe works better.
I got the ' war-asm-cdgog.asm ' file.

However the rest of the Python script still gives some errors:

~/.../Warcraft/SR-cd-gog >>> ./build-x86.sh
Traceback (most recent call last):
File "./repair_short_jumps.py", line 19, in
iErr = int( cErrLine[iTemp1 + 1 : iTemp2] )
ValueError: invalid literal for int() with base 10: ' line 7'
Traceback (most recent call last):
File "./repair_short_jumps.py", line 19, in
iErr = int( cErrLine[iTemp1 + 1 : iTemp2] )
ValueError: invalid literal for int() with base 10: ' line 9'

commented

Can you post the output of the command nasm -felf32 -O1 -w+orphan-labels -w-number-overflow -ix86/ war-asm-cdgog.asm (in the directory SR/SR-games/Warcraft/SR-cd-gog) ?

The expected output is:

seg01.inc:211: error: short jump is out of range
seg01.inc:571: error: short jump is out of range
seg01.inc:11288: error: short jump is out of range
seg01.inc:14371: error: short jump is out of range
seg01.inc:15447: error: short jump is out of range
seg01.inc:18321: error: short jump is out of range
seg01.inc:19145: error: short jump is out of range
seg01.inc:20607: error: short jump is out of range
seg01.inc:21917: error: short jump is out of range
seg01.inc:22481: error: short jump is out of range
seg01.inc:23886: error: short jump is out of range
seg01.inc:25552: error: short jump is out of range
seg01.inc:26037: error: short jump is out of range
seg01.inc:27947: error: short jump is out of range
seg01.inc:42593: error: short jump is out of range
seg01.inc:45300: error: short jump is out of range
seg01.inc:59804: error: short jump is out of range
seg01.inc:59807: error: short jump is out of range
seg01.inc:60870: error: short jump is out of range
seg01.inc:64673: error: short jump is out of range

Oh, I didn't have nasm on my system.
So Nasm, and Judy are needed from the repo.

Now I got:
war-asm-cdgog.asm:242: error: short jump is out of range
war-asm-cdgog.asm:602: error: short jump is out of range
war-asm-cdgog.asm:11319: error: short jump is out of range
war-asm-cdgog.asm:14402: error: short jump is out of range
war-asm-cdgog.asm:15478: error: short jump is out of range
war-asm-cdgog.asm:18352: error: short jump is out of range
war-asm-cdgog.asm:19176: error: short jump is out of range
war-asm-cdgog.asm:20638: error: short jump is out of range
war-asm-cdgog.asm:21948: error: short jump is out of range
war-asm-cdgog.asm:22512: error: short jump is out of range
war-asm-cdgog.asm:23917: error: short jump is out of range
war-asm-cdgog.asm:25583: error: short jump is out of range
war-asm-cdgog.asm:26068: error: short jump is out of range
war-asm-cdgog.asm:27978: error: short jump is out of range
war-asm-cdgog.asm:42624: error: short jump is out of range
war-asm-cdgog.asm:45331: error: short jump is out of range
war-asm-cdgog.asm:59835: error: short jump is out of range
war-asm-cdgog.asm:59838: error: short jump is out of range
war-asm-cdgog.asm:60901: error: short jump is out of range
war-asm-cdgog.asm:64704: error: short jump is out of range
war-asm-cdgog.asm:56: warning: label alone on a line without a colon might be in error [-w+label-orphan]

./build-x86.sh succeeded .

I copied the right seg01.inc, seg02.inc, seg03.inc, war-asm-cdgog.asm, files to the x86 dir , and it almost Ok, however the building still fails:

~/.../Warcraft/SR-War >>> scons sdl2=1 version=cdgog
scons: Reading SConscript files ...

You didn't set any target device (parameter 'device').
'pc-linux' will be used for compiling.

scons: done reading SConscript files.
scons: Building targets ...
gcc -o Game_config.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Game_config.c
gcc -o Game_thread.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Game_thread.c
gcc -o Warcraft-in2.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-in2.c
gcc -o Warcraft-inout.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-inout.c
gcc -o Warcraft-int.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-int.c
gcc -o Warcraft-int2.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-int2.c
gcc -o Warcraft-music-midiplugin.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-music-midiplugin.c
gcc -o Warcraft-music-midiplugin2.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-music-midiplugin2.c
gcc -o Warcraft-music.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-music.c
gcc -o Warcraft-out2.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-out2.c
gcc -o Warcraft-proc-events.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-proc-events.c
gcc -o Warcraft-proc-vfs.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-proc-vfs.c
gcc -o Warcraft-proc.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-proc.c
gcc -o Warcraft-sound.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-sound.c
gcc -o Warcraft-timer.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-timer.c
gcc -o main.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE main.c
gcc -o virtualfs.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE virtualfs.c
gcc -o xmi2mid.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE xmi2mid.c
gcc -o display/pc.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE display/pc.c
gcc -o audio/pc.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE audio/pc.c
gcc -o input/pc.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE input/pc.c
nasm -felf32 -O1 -w+orphan-labels -w-number-overflow -ix86/ -o x86/war-asm-cdgog.o x86/war-asm-cdgog.asm
x86/war-asm-cdgog.asm:242: error: short jump is out of range
x86/war-asm-cdgog.asm:602: error: short jump is out of range
x86/war-asm-cdgog.asm:11319: error: short jump is out of range
x86/war-asm-cdgog.asm:14402: error: short jump is out of range
x86/war-asm-cdgog.asm:15478: error: short jump is out of range
x86/war-asm-cdgog.asm:18352: error: short jump is out of range
x86/war-asm-cdgog.asm:19176: error: short jump is out of range
x86/war-asm-cdgog.asm:20638: error: short jump is out of range
x86/war-asm-cdgog.asm:21948: error: short jump is out of range
x86/war-asm-cdgog.asm:22512: error: short jump is out of range
x86/war-asm-cdgog.asm:23917: error: short jump is out of range
x86/war-asm-cdgog.asm:25583: error: short jump is out of range
x86/war-asm-cdgog.asm:26068: error: short jump is out of range
x86/war-asm-cdgog.asm:27978: error: short jump is out of range
x86/war-asm-cdgog.asm:42624: error: short jump is out of range
x86/war-asm-cdgog.asm:45331: error: short jump is out of range
x86/war-asm-cdgog.asm:59835: error: short jump is out of range
x86/war-asm-cdgog.asm:59838: error: short jump is out of range
x86/war-asm-cdgog.asm:60901: error: short jump is out of range
x86/war-asm-cdgog.asm:64704: error: short jump is out of range
scons: *** [x86/war-asm-cdgog.o] Error 1
scons: building terminated because of errors.

commented

That's strange. These errors should be fix by calling repair_short_jumps.py from build-x86.sh. Did you run the original, unmodified build-x86.sh to generate seg*.inc files ?

Yes, I used the original build-x86.sh . It gave me no errors.
My nasm version is:
~/.../Warcraft/SR-cd-gog >>> nasm -v
NASM version 2.15.05 compiled on Sep 24 2020

~/.../Warcraft/SR-cd-gog >>> sha256sum build-x86.sh seg*inc war-asm-cdgog.asm
da7cbafebb53559ac0047ce629129f5951980025a253fbf98954c7c0b89e98d3 build-x86.sh
779bd9b60cc5d65be117d21494c4c34eeffa5b6e1ede7411c1e3ccaf22d0c5f8 seg01.inc
550a4d1ccdec128f54e65f0d0863ca496a8c72919a37d2e6fa4c00dda6175e43 seg02.inc
5a91b6c0779cdf45059214ef85cb6699929c38a365f37aae38a64a607bde2d61 seg03.inc
202bdcb5d0f99e63da8adf8a52f4eab8f300e00cc0ab723753f209e2f8d5beb7 war-asm-cdgog.asm

commented

The problem is nasm. The error reporting was changed in version 2.15.03, which doesn't work with my code. In latest git, the error reporting works like in version 2.15.02.

The solution for now is to use nasm version 2.15.02 or lower or to compile nasm from git.

You were right! With :
https://archive.org/download/archlinux_pkg_nasm/nasm-2.15.02-1-x86_64.pkg.tar.zst

the nasm part was OK.

Now I have problems with SDL . It look it's really complicated to create this build.

My version is:
x45% sudo pacman -Q sdl2_mixer
sdl2_mixer 2.0.4-5

You didn't set any target device (parameter 'device').
'pc-linux' will be used for compiling.

scons: done reading SConscript files.
scons: Building targets ...
gcc -o Game_config.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Game_config.c
gcc -o Game_thread.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Game_thread.c
gcc -o Warcraft-in2.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-in2.c
gcc -o Warcraft-inout.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-inout.c
gcc -o Warcraft-int.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-int.c
gcc -o Warcraft-int2.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-int2.c
gcc -o Warcraft-music-midiplugin.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-music-midiplugin.c
gcc -o Warcraft-music-midiplugin2.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-music-midiplugin2.c
gcc -o Warcraft-music.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-music.c
gcc -o Warcraft-out2.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-out2.c
gcc -o Warcraft-proc-events.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-proc-events.c
gcc -o Warcraft-proc-vfs.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-proc-vfs.c
gcc -o Warcraft-proc.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-proc.c
gcc -o Warcraft-sound.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-sound.c
gcc -o Warcraft-timer.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE Warcraft-timer.c
gcc -o main.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE main.c
gcc -o virtualfs.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE virtualfs.c
gcc -o xmi2mid.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE xmi2mid.c
gcc -o display/pc.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE display/pc.c
gcc -o audio/pc.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE audio/pc.c
gcc -o input/pc.o -c -m32 -O2 -DALLOW_OPENGL -fno-PIE input/pc.c
nasm -felf32 -Ox -w+orphan-labels -w-number-overflow -ix86/ -o x86/Game-asm.o x86/Game-asm.asm
nasm -felf32 -Ox -w+orphan-labels -w-number-overflow -ix86/ -o x86/SR-asm-calls.o x86/SR-asm-calls.asm
nasm -felf32 -Ox -w+orphan-labels -w-number-overflow -ix86/ -o x86/SR-asm.o x86/SR-asm.asm
nasm -felf32 -Ox -w+orphan-labels -w-number-overflow -ix86/ -o x86/asm_inout.o x86/asm_inout.asm
nasm -felf32 -Ox -w+orphan-labels -w-number-overflow -ix86/ -o x86/asm_int.o x86/asm_int.asm
gcc -o SR-War -m32 -Wl,-z,noexecstack -no-pie -s Game_config.o Game_thread.o Warcraft-in2.o Warcraft-inout.o Warcraft-int.o Warcraft-int2.o Warcraft-music-midiplugin.o Warcraft-music-midiplugin2.o Warcraft-music.o Warcraft-out2.o Warcraft-proc-events.o Warcraft-proc-vfs.o Warcraft-proc.o Warcraft-sound.o Warcraft-timer.o main.o virtualfs.o xmi2mid.o display/pc.o audio/pc.o input/pc.o x86/war-asm-cdgog.o x86/Game-asm.o x86/SR-asm-calls.o x86/SR-asm.o x86/asm_inout.o x86/asm_int.o -lSDL_mixer -lSDL -lpthread -ldl -lGL
/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../libSDL_mixer.so when searching for -lSDL_mixer
/bin/ld: skipping incompatible /usr/lib/libSDL_mixer.so when searching for -lSDL_mixer
/bin/ld: cannot find -lSDL_mixer
/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../libSDL_mixer.so when searching for -lSDL_mixer
/bin/ld: skipping incompatible /usr/lib/libSDL_mixer.so when searching for -lSDL_mixer
/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../libSDL.so when searching for -lSDL
/bin/ld: skipping incompatible /usr/lib/libSDL.so when searching for -lSDL
/bin/ld: cannot find -lSDL
/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../libSDL.so when searching for -lSDL
/bin/ld: skipping incompatible /usr/lib/libSDL.so when searching for -lSDL
collect2: error: ld returned 1 exit status
scons: *** [SR-War] Error 1
scons: building terminated because of errors.

commented

You need 32-bit versions of SDL and SDL_mixer libraries.

You were right again. It worked!

However.. I feel strange about the SDL version.
I wanted to use SDL2 , but I think the build system used the 32 bit version of SDL 1.2 .

x45% scons sdl2=1 version=cdgog

I used right the SDL2=1 flag ?

commented

At the moment Warcraft and X-COM games can only use SDL 1.2. Albion can use SDL 1.2 or SDL2. Septerra Core can only use SDL2.

Thanks! pc-linux version worked finally!
This project is really ingenious. You were able to convert all old DOS system calls to SDL1.2?

The same setup can generate the win32 binary with scons device=pc-windows version=cdgog ?

I need to download the windows version of SDL1.2 ?
/bin/ld: cannot find -lSDL_mixer-1.2
/bin/ld: cannot find -lSDL-1.2

commented

This project is really ingenious. You were able to convert all old DOS system calls to SDL1.2?

In part. There's also replacing parts of the original C library with native C library, replacing parts of the original code, etc.

The same setup can generate the win32 binary with scons device=pc-windows version=cdgog ?

In theory. It's supposed to be run on windows and I haven't used it for many years.

Maybe I'll try in MSYS2 32 bit. Hopefully the build process can be done.

Theoretically a good C developer could generate the original C source code from your assemblies like it was done in OpenDune ( https://github.com/OpenDUNE/OpenDUNE ) ?