diff --git a/README.md b/README.md index 41c3eb6..ac20f95 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Following DOS games are supported: Following Windows games are supported: * [Septerra Core: Legacy of the Creator](https://en.wikipedia.org/wiki/Septerra_Core "Septerra Core: Legacy of the Creator") +* [Battle Isle 3: Shadow of the Emperor (Battle Isle 2220: Shadow of the Emperor)](https://en.wikipedia.org/wiki/Battle_Isle_2220 "Battle Isle 3: Shadow of the Emperor (Battle Isle 2220: Shadow of the Emperor)") The source code is released with MIT license (except libraries, etc. by other people, which have their own license). For the purpose of using the code in GPL projects, the source code is also released with GPLv2 or later and LGPLv2.1 or later. @@ -37,11 +38,11 @@ The projects consists of following subprojects (read the readmes in subproject d * **games** * Game specific source code. * Together with the generated assembler versions of the executables, these files can be used to build Windows or Linux (x86 or arm) versions of the games. - * Uses plugins to play (or play better) music (in DOS games). + * Uses plugins to play (or play better) music. * **midi-libs** * Libraries that are used by plugins in *midi-plugins* subproject to play MIDI music. * **midi-plugins** - * Plugins used by the DOS games to play MIDI (and other types) music. + * Plugins used by the games to play MIDI (and other types) music. * **scaler-plugins** * Plugins used by the DOS games to enlarge/enhance the displayed image. * **pycfg** diff --git a/SRW-games/Battle Isle 3/SRW-ms_figtr/SR.cfg b/SRW-games/Battle Isle 3/SRW-ms_figtr/SR.cfg new file mode 100644 index 0000000..d3657b1 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-ms_figtr/SR.cfg @@ -0,0 +1,2 @@ +esp_dword_aligned=yes +ebp_dword_aligned=yes diff --git a/SRW-games/Battle Isle 3/SRW-ms_figtr/build-llasm.sh b/SRW-games/Battle Isle 3/SRW-ms_figtr/build-llasm.sh new file mode 100755 index 0000000..6d08bf5 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-ms_figtr/build-llasm.sh @@ -0,0 +1,7 @@ +#! /bin/sh +cd "`echo $0 | sed 's/\/[^\/]*$//'`" +cp llasm/*.sci ./ +./SRW.exe MS_FIGTR.DLL MS_FIGTR.llasm >a.a 2>b.a +rm *.sci +./compact_source_llasm.py +rm *.a diff --git a/SRW-games/Battle Isle 3/SRW-ms_figtr/build-x86.sh b/SRW-games/Battle Isle 3/SRW-ms_figtr/build-x86.sh new file mode 100755 index 0000000..5d5b610 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-ms_figtr/build-x86.sh @@ -0,0 +1,8 @@ +#! /bin/sh +cd "`echo $0 | sed 's/\/[^\/]*$//'`" +cp x86/*.sci ./ +./SRW.exe MS_FIGTR.DLL MS_FIGTR.asm >a.a 2>b.a +rm *.sci +./compact_source.py +rm *.a +rm MS_FIGTR.def diff --git a/SRW-games/Battle Isle 3/SRW-ms_figtr/compact_source.py b/SRW-games/Battle Isle 3/SRW-ms_figtr/compact_source.py new file mode 100755 index 0000000..3411fee --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-ms_figtr/compact_source.py @@ -0,0 +1,61 @@ +#! /usr/bin/python +cPath = "./" + +import os + +def Compact (cFile): + cTmpFile = cFile + "tmp" + fIn = open(cFile, "rt") + fOut = open(cTmpFile, "wt") + + iNum = 0 + cRepStr = "" + + for cLine in fIn: + if iNum != 0: + if cLine == cRepStr: + iNum = iNum + 1 + else: + if iNum == 1: + fOut.write(cRepStr) + elif cRepStr.startswith("resb"): + fOut.write("resb " + str(iNum) + "\n") + elif iNum == 2: + fOut.write(cRepStr) + fOut.write(cRepStr) + else: + fOut.write("times " + str(iNum) + " " + cRepStr) + iNum = 0 + #cRepStr = "" + + if iNum == 0: + if cLine.startswith("db "): + iNum = 1 + cRepStr = cLine + elif cLine.strip() == "resb 1": + iNum = 1 + cRepStr = cLine + else: + fOut.write(cLine) + + if iNum != 0: + if iNum == 1: + fOut.write(cRepStr) + elif cRepStr.startswith("resb"): + fOut.write("resb " + str(iNum) + "\n") + elif iNum == 2: + fOut.write(cRepStr) + fOut.write(cRepStr) + else: + fOut.write("times " + str(iNum) + " " + cRepStr) + + fOut.close() + fIn.close() + + os.remove(cFile) + os.rename(cTmpFile, cFile) + +Compact(cPath + "seg01.inc") +Compact(cPath + "seg02.inc") +Compact(cPath + "seg03.inc") +Compact(cPath + "seg04.inc") diff --git a/SRW-games/Battle Isle 3/SRW-ms_figtr/compact_source_llasm.py b/SRW-games/Battle Isle 3/SRW-ms_figtr/compact_source_llasm.py new file mode 100755 index 0000000..b287121 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-ms_figtr/compact_source_llasm.py @@ -0,0 +1,61 @@ +#! /usr/bin/python +cPath = "./" + +import os + +def Compact (cFile): + cTmpFile = cFile + "tmp" + fIn = open(cFile, "rt") + fOut = open(cTmpFile, "wt") + + iNum = 0 + cRepStr = "" + + for cLine in fIn: + if iNum != 0: + if cLine == cRepStr: + iNum = iNum + 1 + else: + if iNum == 1: + fOut.write(cRepStr) + elif cRepStr.startswith("dskip"): + fOut.write("dskip " + str(iNum) + "\n") + elif iNum == 2: + fOut.write(cRepStr) + fOut.write(cRepStr) + else: + fOut.write(cRepStr.rstrip() + " dup " + str(iNum) + cRepStr[len(cRepStr.rstrip()):]) + iNum = 0 + #cRepStr = "" + + if iNum == 0: + if cLine.startswith("db "): + iNum = 1 + cRepStr = cLine + elif cLine.strip() == "dskip 1": + iNum = 1 + cRepStr = cLine + elif iNum == 2: + fOut.write(cRepStr) + fOut.write(cRepStr) + else: + fOut.write(cLine) + + if iNum != 0: + if iNum == 1: + fOut.write(cRepStr) + elif cRepStr.startswith("dskip"): + fOut.write("dskip " + str(iNum) + "\n") + else: + fOut.write(cRepStr.rstrip() + " dup " + str(iNum) + cRepStr[len(cRepStr.rstrip()):]) + + fOut.close() + fIn.close() + + os.remove(cFile) + os.rename(cTmpFile, cFile) + +Compact(cPath + "seg01_data.llinc") +Compact(cPath + "seg02_data.llinc") +Compact(cPath + "seg03_data.llinc") +Compact(cPath + "seg04_data.llinc") diff --git a/SRW-games/Battle Isle 3/SRW-ms_figtr/llasm/external_procedures.sci b/SRW-games/Battle Isle 3/SRW-ms_figtr/llasm/external_procedures.sci new file mode 100644 index 0000000..0eee017 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-ms_figtr/llasm/external_procedures.sci @@ -0,0 +1,6 @@ +loc_10004600,ms_strcpy_asm2c +loc_10004690,ms_strlen_asm2c +loc_100046e0,ms_memcpy_asm2c +loc_10004830,ms_memset_asm2c +loc_10004874,ms__ftol_asm2c +loc_10007C36,ms__ltoa_asm2c diff --git a/SRW-games/Battle Isle 3/SRW-ms_figtr/llasm/fixup_interpret_as_code.sci b/SRW-games/Battle Isle 3/SRW-ms_figtr/llasm/fixup_interpret_as_code.sci new file mode 100644 index 0000000..7c3bcb0 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-ms_figtr/llasm/fixup_interpret_as_code.sci @@ -0,0 +1 @@ +loc_10004EB8 diff --git a/SRW-games/Battle Isle 3/SRW-ms_figtr/llasm/ignored_areas.sci b/SRW-games/Battle Isle 3/SRW-ms_figtr/llasm/ignored_areas.sci new file mode 100644 index 0000000..48029c2 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-ms_figtr/llasm/ignored_areas.sci @@ -0,0 +1,15 @@ +loc_100013D7,11 + +loc_10004507,46 + +loc_100045EE,14 +loc_100045FC,14468 + +loc_10009554,12 + +loc_100095DC,788 + +loc_1000B2D8,3452 +loc_1000C054,4012 + +loc_10008D20,28 diff --git a/SRW-games/Battle Isle 3/SRW-ms_figtr/llasm/instruction_replacements.sci b/SRW-games/Battle Isle 3/SRW-ms_figtr/llasm/instruction_replacements.sci new file mode 100644 index 0000000..7b4028e --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-ms_figtr/llasm/instruction_replacements.sci @@ -0,0 +1,34 @@ +loc_100016B4,13,tcall loc_100016C1|endp ; unused stock object +loc_10001832,12,tcall loc_1000183E|endp ; unused stock object +loc_1000B01C,28, ; unused stock object + +loc_100027BE,71, ; unused device context +loc_10002B74,18, ; unused device context +loc_10008D80,4, ; unused device context +loc_1000B284,32, ; unused device context + +loc_1000277E,64, ; unused window handle +loc_100045BE,6, ; unused window handle +loc_10008D84,4, ; unused window handle +loc_1000B264,32, ; unused window handle + +loc_10001510,6,;call __Fight|PUSH loc_10001510_after|tcall __Fight|endp|proc loc_10001510_after ; call __Fight directly +loc_100017BE,6,;call __Fight|PUSH loc_100017BE_after|tcall __Fight|endp|proc loc_100017BE_after ; call __Fight directly +loc_10002B26,6,;call __Fight|PUSH loc_10002B26_after|tcall __Fight|endp|proc loc_10002B26_after ; call __Fight directly + +loc_10001487,83, ; remove dynamic load of __Fight +loc_1000B00C,4, ; remove dynamic load of __Fight +loc_1000B164,32, ; remove dynamic load of __Fight + +loc_10001450,55, ; remove dynamic load of wc_figtr.dll +loc_1000158B,12, ; remove dynamic load of wc_figtr.dll +loc_100015FD,12, ; remove dynamic load of wc_figtr.dll +loc_1000180C,25, ; remove dynamic load of wc_figtr.dll +loc_10002AC5,12, ; remove dynamic load of wc_figtr.dll +loc_1000B008,4, ; remove dynamic load of wc_figtr.dll +loc_1000B134,48, ; remove dynamic load of wc_figtr.dll + +loc_10003FF2,63,;push eax|PUSH eax|;call FGT_SystemTask_End_asm2c|PUSH loc_10003FF2_after|tcall FGT_SystemTask_End_asm2c|endp|proc loc_10003FF2_after ; replace end of function FGT_SystemTask +loc_10004036,49,;push dword 0|PUSH 0|;call FGT_SystemTask_End_asm2c|PUSH loc_10004036_after|tcall FGT_SystemTask_End_asm2c|endp|proc loc_10004036_after|tcall loc_10004067|endp ; replace end of function FGT_SystemTask + +loc_10002C1B,5,;push dword 0|PUSH 0|;call FGT_CheckTicksDelay_asm2c|PUSH loc_10002C1B_after1|tcall FGT_CheckTicksDelay_asm2c|endp|proc loc_10002C1B_after1|;call SYSTEM_GetTicks|PUSH loc_10002C1B_after2|tcall SYSTEM_GetTicks|endp|proc loc_10002C1B_after2 ; insert delays into active waiting diff --git a/SRW-games/Battle Isle 3/SRW-ms_figtr/x86/external_procedures.sci b/SRW-games/Battle Isle 3/SRW-ms_figtr/x86/external_procedures.sci new file mode 100644 index 0000000..0eee017 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-ms_figtr/x86/external_procedures.sci @@ -0,0 +1,6 @@ +loc_10004600,ms_strcpy_asm2c +loc_10004690,ms_strlen_asm2c +loc_100046e0,ms_memcpy_asm2c +loc_10004830,ms_memset_asm2c +loc_10004874,ms__ftol_asm2c +loc_10007C36,ms__ltoa_asm2c diff --git a/SRW-games/Battle Isle 3/SRW-ms_figtr/x86/fixup_interpret_as_code.sci b/SRW-games/Battle Isle 3/SRW-ms_figtr/x86/fixup_interpret_as_code.sci new file mode 100644 index 0000000..7c3bcb0 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-ms_figtr/x86/fixup_interpret_as_code.sci @@ -0,0 +1 @@ +loc_10004EB8 diff --git a/SRW-games/Battle Isle 3/SRW-ms_figtr/x86/ignored_areas.sci b/SRW-games/Battle Isle 3/SRW-ms_figtr/x86/ignored_areas.sci new file mode 100644 index 0000000..48029c2 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-ms_figtr/x86/ignored_areas.sci @@ -0,0 +1,15 @@ +loc_100013D7,11 + +loc_10004507,46 + +loc_100045EE,14 +loc_100045FC,14468 + +loc_10009554,12 + +loc_100095DC,788 + +loc_1000B2D8,3452 +loc_1000C054,4012 + +loc_10008D20,28 diff --git a/SRW-games/Battle Isle 3/SRW-ms_figtr/x86/instruction_replacements.sci b/SRW-games/Battle Isle 3/SRW-ms_figtr/x86/instruction_replacements.sci new file mode 100644 index 0000000..004d641 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-ms_figtr/x86/instruction_replacements.sci @@ -0,0 +1,34 @@ +loc_100016B4,13, ; unused stock object +loc_10001832,12, ; unused stock object +loc_1000B01C,28, ; unused stock object + +loc_100027BE,71, ; unused device context +loc_10002B74,18, ; unused device context +loc_10008D80,4, ; unused device context +loc_1000B284,32, ; unused device context + +loc_1000277E,64, ; unused window handle +loc_100045BE,6, ; unused window handle +loc_10008D84,4, ; unused window handle +loc_1000B264,32, ; unused window handle + +loc_10001510,6,call __Fight ; call __Fight directly +loc_100017BE,6,call __Fight ; call __Fight directly +loc_10002B26,6,call __Fight ; call __Fight directly + +loc_10001487,83, ; remove dynamic load of __Fight +loc_1000B00C,4, ; remove dynamic load of __Fight +loc_1000B164,32, ; remove dynamic load of __Fight + +loc_10001450,55, ; remove dynamic load of wc_figtr.dll +loc_1000158B,12, ; remove dynamic load of wc_figtr.dll +loc_100015FD,12, ; remove dynamic load of wc_figtr.dll +loc_1000180C,25, ; remove dynamic load of wc_figtr.dll +loc_10002AC5,12, ; remove dynamic load of wc_figtr.dll +loc_1000B008,4, ; remove dynamic load of wc_figtr.dll +loc_1000B134,48, ; remove dynamic load of wc_figtr.dll + +loc_10003FF2,63,push eax|call FGT_SystemTask_End_asm2c ; replace end of function FGT_SystemTask +loc_10004036,49,push dword 0|call FGT_SystemTask_End_asm2c ; replace end of function FGT_SystemTask + +loc_10002C1B,5,push dword 0|call FGT_CheckTicksDelay_asm2c|call SYSTEM_GetTicks ; insert delays into active waiting diff --git a/SRW-games/Battle Isle 3/SRW-sdi_1r/SR.cfg b/SRW-games/Battle Isle 3/SRW-sdi_1r/SR.cfg new file mode 100644 index 0000000..d3657b1 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-sdi_1r/SR.cfg @@ -0,0 +1,2 @@ +esp_dword_aligned=yes +ebp_dword_aligned=yes diff --git a/SRW-games/Battle Isle 3/SRW-sdi_1r/build-llasm.sh b/SRW-games/Battle Isle 3/SRW-sdi_1r/build-llasm.sh new file mode 100755 index 0000000..4a0b456 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-sdi_1r/build-llasm.sh @@ -0,0 +1,8 @@ +#! /bin/sh +cd "`echo $0 | sed 's/\/[^\/]*$//'`" +cp llasm/*.sci ./ +./SRW.exe SDI_1R.EXE SDI_1R.llasm >a.a 2>b.a +rm *.sci +./compact_source_llasm.py +rm *.a +rm SDI_1R.resdump diff --git a/SRW-games/Battle Isle 3/SRW-sdi_1r/build-x86.sh b/SRW-games/Battle Isle 3/SRW-sdi_1r/build-x86.sh new file mode 100755 index 0000000..ea9c95b --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-sdi_1r/build-x86.sh @@ -0,0 +1,8 @@ +#! /bin/sh +cd "`echo $0 | sed 's/\/[^\/]*$//'`" +cp x86/*.sci ./ +./SRW.exe SDI_1R.EXE SDI_1R.asm >a.a 2>b.a +rm *.sci +./compact_source.py +rm *.a +rm SDI_1R.resdump SDI_1R.def diff --git a/SRW-games/Battle Isle 3/SRW-sdi_1r/compact_source.py b/SRW-games/Battle Isle 3/SRW-sdi_1r/compact_source.py new file mode 100755 index 0000000..3411fee --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-sdi_1r/compact_source.py @@ -0,0 +1,61 @@ +#! /usr/bin/python +cPath = "./" + +import os + +def Compact (cFile): + cTmpFile = cFile + "tmp" + fIn = open(cFile, "rt") + fOut = open(cTmpFile, "wt") + + iNum = 0 + cRepStr = "" + + for cLine in fIn: + if iNum != 0: + if cLine == cRepStr: + iNum = iNum + 1 + else: + if iNum == 1: + fOut.write(cRepStr) + elif cRepStr.startswith("resb"): + fOut.write("resb " + str(iNum) + "\n") + elif iNum == 2: + fOut.write(cRepStr) + fOut.write(cRepStr) + else: + fOut.write("times " + str(iNum) + " " + cRepStr) + iNum = 0 + #cRepStr = "" + + if iNum == 0: + if cLine.startswith("db "): + iNum = 1 + cRepStr = cLine + elif cLine.strip() == "resb 1": + iNum = 1 + cRepStr = cLine + else: + fOut.write(cLine) + + if iNum != 0: + if iNum == 1: + fOut.write(cRepStr) + elif cRepStr.startswith("resb"): + fOut.write("resb " + str(iNum) + "\n") + elif iNum == 2: + fOut.write(cRepStr) + fOut.write(cRepStr) + else: + fOut.write("times " + str(iNum) + " " + cRepStr) + + fOut.close() + fIn.close() + + os.remove(cFile) + os.rename(cTmpFile, cFile) + +Compact(cPath + "seg01.inc") +Compact(cPath + "seg02.inc") +Compact(cPath + "seg03.inc") +Compact(cPath + "seg04.inc") diff --git a/SRW-games/Battle Isle 3/SRW-sdi_1r/compact_source_llasm.py b/SRW-games/Battle Isle 3/SRW-sdi_1r/compact_source_llasm.py new file mode 100755 index 0000000..b287121 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-sdi_1r/compact_source_llasm.py @@ -0,0 +1,61 @@ +#! /usr/bin/python +cPath = "./" + +import os + +def Compact (cFile): + cTmpFile = cFile + "tmp" + fIn = open(cFile, "rt") + fOut = open(cTmpFile, "wt") + + iNum = 0 + cRepStr = "" + + for cLine in fIn: + if iNum != 0: + if cLine == cRepStr: + iNum = iNum + 1 + else: + if iNum == 1: + fOut.write(cRepStr) + elif cRepStr.startswith("dskip"): + fOut.write("dskip " + str(iNum) + "\n") + elif iNum == 2: + fOut.write(cRepStr) + fOut.write(cRepStr) + else: + fOut.write(cRepStr.rstrip() + " dup " + str(iNum) + cRepStr[len(cRepStr.rstrip()):]) + iNum = 0 + #cRepStr = "" + + if iNum == 0: + if cLine.startswith("db "): + iNum = 1 + cRepStr = cLine + elif cLine.strip() == "dskip 1": + iNum = 1 + cRepStr = cLine + elif iNum == 2: + fOut.write(cRepStr) + fOut.write(cRepStr) + else: + fOut.write(cLine) + + if iNum != 0: + if iNum == 1: + fOut.write(cRepStr) + elif cRepStr.startswith("dskip"): + fOut.write("dskip " + str(iNum) + "\n") + else: + fOut.write(cRepStr.rstrip() + " dup " + str(iNum) + cRepStr[len(cRepStr.rstrip()):]) + + fOut.close() + fIn.close() + + os.remove(cFile) + os.rename(cTmpFile, cFile) + +Compact(cPath + "seg01_data.llinc") +Compact(cPath + "seg02_data.llinc") +Compact(cPath + "seg03_data.llinc") +Compact(cPath + "seg04_data.llinc") diff --git a/SRW-games/Battle Isle 3/SRW-sdi_1r/llasm/displaced_labels.sci b/SRW-games/Battle Isle 3/SRW-sdi_1r/llasm/displaced_labels.sci new file mode 100644 index 0000000..2aca263 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-sdi_1r/llasm/displaced_labels.sci @@ -0,0 +1 @@ +loc_4B6FA8,32 diff --git a/SRW-games/Battle Isle 3/SRW-sdi_1r/llasm/external_procedures.sci b/SRW-games/Battle Isle 3/SRW-sdi_1r/llasm/external_procedures.sci new file mode 100644 index 0000000..e39246c --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-sdi_1r/llasm/external_procedures.sci @@ -0,0 +1,25 @@ +loc_486268,ms_strlen_asm2c +loc_4862C8,ms_strcat_asm2c +loc_4862CC,ms_strcpy_asm2c +loc_48637D,ms_atol_asm2c +loc_486437,ms_atoi_asm2c +loc_486447,ms_printf_asm2c +loc_486494,ms_strncpy_asm2c +loc_4864C4,ms_strcmp_asm2c +loc_48656C,ms_memcpy_asm2c +loc_486710,ms__ftol_asm2c +loc_4867A8,ms_memset_asm2c +loc_4867FC,ms_memcmp_asm2c +loc_486822,ms_srand_asm2c +loc_48682E,ms_rand_asm2c +loc_486854,ms__alloca_probe_asm2c +loc_48688C,ms_strstr_asm2c +loc_48CC74,ms__strnicmp_asm2c +loc_48CD8A,ms__ltoa_asm2c + +loc_486168,ms__except_handler3_asm2c + +loc_401E06,cmdline_ContainsOption_asm2c + +loc_48605E,mciGetErrorStringA_asm2c +loc_48606A,mciSendCommandA_asm2c diff --git a/SRW-games/Battle Isle 3/SRW-sdi_1r/llasm/fixup_interpret_as_code.sci b/SRW-games/Battle Isle 3/SRW-sdi_1r/llasm/fixup_interpret_as_code.sci new file mode 100644 index 0000000..402b1e1 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-sdi_1r/llasm/fixup_interpret_as_code.sci @@ -0,0 +1,97 @@ +loc_40102D +loc_401041 +loc_401050 +loc_40109B +loc_4010F0 +loc_401186 +loc_4011A4 +loc_4011F4 +loc_4011F9 +loc_401221 +loc_4012B2 +loc_4012D5 +loc_4012E4 +loc_40143D +loc_401474 +loc_4014BA +loc_4014BF +loc_4014E7 +loc_40152D +loc_401596 +loc_4015A5 +loc_4015AA +loc_4015C3 +loc_4015DC +loc_4015E1 +loc_4015F5 +loc_4015FA +loc_40162C +loc_40164F +loc_401668 +loc_4016D6 +loc_4016E0 +loc_40170D +loc_401762 +loc_4017CB +loc_4017DF +loc_4017F8 +loc_401811 +loc_40181B +loc_40182F +loc_40185C +loc_40186B +loc_401901 +loc_401924 +loc_401947 +loc_401960 +loc_401983 +loc_4019B0 +loc_4019D8 +loc_4019FB +loc_401A4B +loc_401AA5 +loc_401AC3 +loc_401AE1 +loc_401AEB +loc_401B0E +loc_401B22 +loc_401B27 +loc_401B31 +loc_401B6D +loc_401B8B +loc_401BB8 +loc_401C26 +loc_401C58 +loc_401C85 +loc_401C8A +loc_401CD0 +loc_401CDF +loc_401CEE +loc_401CFD +loc_401D39 +loc_401D6B +loc_401D70 +loc_401D8E +loc_401DA7 +loc_401DCF +loc_401DD4 +loc_401E0B +loc_401E1A +loc_401EE7 +loc_401F69 +loc_401F87 +loc_401FAF +loc_401FE6 +loc_47526C +loc_47591F +loc_475D03 +loc_4761B6 +loc_4767A7 +loc_476A4F +loc_476E1C +loc_478842 +loc_4793A5 +loc_486088 +loc_486090 +loc_486168 +loc_487D31 diff --git a/SRW-games/Battle Isle 3/SRW-sdi_1r/llasm/global_aliases.sci b/SRW-games/Battle Isle 3/SRW-sdi_1r/llasm/global_aliases.sci new file mode 100644 index 0000000..6e7acd2 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-sdi_1r/llasm/global_aliases.sci @@ -0,0 +1,22 @@ +loc_48CA30,WinMain_ +loc_4B4C3E,SYSTEM_QuitProgramFlag_SDI_1R + +loc_4A2B58,video_PRE_avi +loc_4A2B7A,video_PRE_mciId +loc_4CF328,video_PRE_dword_4CF328 +loc_4CF32C,video_PRE_dword_4CF32C +loc_4CF330,video_PRE_stru_4CF330 +loc_4CF540,video_PRE_dword_4CF540 +loc_4CF544,video_PRE_byte_4CF544 +loc_4CF548,video_PRE_byte_4CF548 +loc_4CF54C,video_PRE_dword_4CF54C +loc_4CF550,video_PRE_byte_4CF550 + +loc_4A3540,video_POST_avi +loc_4A3562,video_POST_mciId +loc_4CFA40,video_POST_stru_4CFA40 +loc_4CFA70,video_POST_dword_4CFA70 +loc_4CFA74,video_POST_byte_4CFA74 +loc_4CFA78,video_POST_byte_4CFA78 +loc_4CFA7C,video_POST_dword_4CFA7C +loc_4CFA80,video_POST_byte_4CFA80 diff --git a/SRW-games/Battle Isle 3/SRW-sdi_1r/llasm/ignored_areas.sci b/SRW-games/Battle Isle 3/SRW-sdi_1r/llasm/ignored_areas.sci new file mode 100644 index 0000000..993a839 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-sdi_1r/llasm/ignored_areas.sci @@ -0,0 +1,118 @@ +loc_40200E,4114 + +loc_409E5D,6915 + +loc_40C2FF,557 + +loc_40DBB6,2794 + +loc_4127F1,4191 + +loc_4149B2,4654 + +loc_41A924,4956 + +loc_41C15D,339 + +loc_41EFD7,921 + +loc_423B1B,4085 + +loc_425BD5,1211 + +loc_427C3D,1779 + +loc_42AC1F,5313 + +loc_42EB08,2024 + +loc_42F599,295 + +loc_433173,3757 + +loc_434DAA,870 + +loc_436CBA,1542 + +loc_438C96,1658 + +loc_43A4D8,424 + +loc_43CF2A,2614 + +loc_43F585,1803 + +loc_443BD2,4062 + +loc_4470DB,2389 + +loc_4489FF,1025 + +loc_44B025,2187 + +loc_44CC7A,1270 + +loc_4506A4,3420 + +loc_452714,1228 + +loc_4533FB,181 + +loc_45495A,1334 + +loc_455EC2,1038 + +loc_457024,860 + +loc_458D68,856 + +loc_459CC1,783 + +loc_45B4B7,1337 + +loc_45DCA5,2235 + +loc_4609E0,2336 + +loc_46BC2C,10836 + +loc_46F5E8,1000 + +loc_471614,1148 + +loc_472FCA,1366 + +loc_474668,1112 + +loc_476E32,1598 + +loc_479B9A,2518 + +loc_47B645,1083 + +loc_47E0FE,2466 + +loc_480C2F,1601 + +loc_482364,1100 + +loc_4851E1,2701 + +loc_485EFC,348 + +loc_486070,32 +loc_48610C,26916 +loc_48CBFF,495 + +loc_4B4C40,4900 + +loc_4B6FB8,4168 + +loc_4D0444,5916 + +loc_4D1CD0,108 +loc_4D1D3C,708 + +loc_401AEB,5 +loc_4019B0,5 +loc_40146F,10 diff --git a/SRW-games/Battle Isle 3/SRW-sdi_1r/llasm/instruction_replacements.sci b/SRW-games/Battle Isle 3/SRW-sdi_1r/llasm/instruction_replacements.sci new file mode 100644 index 0000000..edfc277 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-sdi_1r/llasm/instruction_replacements.sci @@ -0,0 +1,92 @@ +loc_477BD1,18, ; isalnum macro +loc_477BF6,52,;call ms_isalnum_asm2c|PUSH loc_477BF6_after|tcall ms_isalnum_asm2c|endp|proc loc_477BF6_after|;add esp, byte 4|add esp, esp, 4 ; isalnum macro + +loc_403AD9,104, ; skip CDROM check +loc_4B8F20,64, ; skip CDROM check + +loc_44BF06,82, ; skip looking for file on CD +loc_4011C7,10, ; skip looking for file on CD +loc_427A39,281, ; skip looking for file on CD +loc_4BFDCC,12, ; skip looking for file on CD + +loc_47EBF0,47,;call midi_OpenSDIMusic_asm2c|PUSH loc_47EBF0_after|tcall midi_OpenSDIMusic_asm2c|endp|proc loc_47EBF0_after ; midi - OpenSong +loc_47EC77,5,;call midi_GetErrorString_asm2c|PUSH loc_47EC77_after|tcall midi_GetErrorString_asm2c|endp|proc loc_47EC77_after ; midi - OpenSong +loc_47ECD2,10,;call midi_GetSDIMusicID_asm2c|PUSH loc_47ECD2_after|tcall midi_GetSDIMusicID_asm2c|endp|proc loc_47ECD2_after ; midi - OpenSong +loc_4CF1A4,36, ; midi - OpenSong + +loc_47ED3B,28, ; midi - IsSongPlaying +loc_47ED5D,65,;call midi_IsPlaying_asm2c|PUSH loc_47ED9E|tcall midi_IsPlaying_asm2c|endp ; midi - IsSongPlaying + +loc_47EE4B,24,;call midi_CloseSDIMusic_asm2c|PUSH loc_47EE4B_after|tcall midi_CloseSDIMusic_asm2c|endp|proc loc_47EE4B_after ; midi - ProcessSong +loc_47EEA9,24,;call midi_CloseSDIMusic_asm2c|PUSH loc_47EEA9_after|tcall midi_CloseSDIMusic_asm2c|endp|proc loc_47EEA9_after ; midi - ProcessSong +loc_47EF96,24,;call midi_CloseSDIMusic_asm2c|PUSH loc_47EF96_after|tcall midi_CloseSDIMusic_asm2c|endp|proc loc_47EF96_after ; midi - ProcessSong +loc_47F013,24,;call midi_PlaySDIMusic_asm2c|PUSH loc_47F013_after|tcall midi_PlaySDIMusic_asm2c|endp|proc loc_47F013_after ; midi - ProcessSong +loc_47F05B,5,;call midi_GetErrorString_asm2c|PUSH loc_47F05B_after|tcall midi_GetErrorString_asm2c|endp|proc loc_47F05B_after ; midi - ProcessSong +loc_4CF250,72, ; midi - ProcessSong + +loc_47F0C0,21,;call midi_CloseSDIMusic_asm2c|PUSH loc_47F0C0_after|tcall midi_CloseSDIMusic_asm2c|endp|proc loc_47F0C0_after ; midi - CloseSong +loc_4CF2A8,16, ; midi - CloseSong + +loc_484E3A,24,;call midi_OpenTestMusic_asm2c|PUSH loc_484E3A_after|tcall midi_OpenTestMusic_asm2c|endp|proc loc_484E3A_after ; midi - TestSong +loc_484EEB,5,;call midi_GetErrorString_asm2c|PUSH loc_484EEB_after|tcall midi_GetErrorString_asm2c|endp|proc loc_484EEB_after ; midi - TestSong +loc_484F29,24,;call midi_PlayTestMusic_asm2c|PUSH loc_484F29_after|tcall midi_PlayTestMusic_asm2c|endp|proc loc_484F29_after ; midi - TestSong +loc_484FC9,5,;call midi_GetErrorString_asm2c|PUSH loc_484FC9_after|tcall midi_GetErrorString_asm2c|endp|proc loc_484FC9_after ; midi - TestSong +loc_4850AD,24,;call midi_CloseTestMusic_asm2c|PUSH loc_4850C5|tcall midi_CloseTestMusic_asm2c|endp ; midi - TestSong +loc_4D0318,64, ; midi - TestSong +loc_4D0394,16, ; midi - TestSong + +loc_486058,6,proc loc_48605E ; midi - winapi +loc_486064,6,proc loc_48606A ; midi - winapi + +loc_4830C0,103,tcall loc_483127|endp ; skip VfW (Video for Windows) installation +loc_4A40A0,16, ; skip VfW (Video for Windows) installation +loc_4CFC88,68, ; skip VfW (Video for Windows) installation + +loc_401E06,5, ; cmdline - ContainsOption +loc_427905,308, ; cmdline - ContainsOption + +loc_44BA35,147,;push loc_4C2E54|PUSH loc_4C2E54|;call cmdline_ReadLanguageOption_asm2c|PUSH loc_44BA35_after|tcall cmdline_ReadLanguageOption_asm2c|endp|proc loc_44BA35_after ; cmdline - ReadLanguageOption + +loc_47FA4E,81,;call video_RegisterClass_PRE_Video_asm2c|PUSH loc_47FA4E_after|tcall video_RegisterClass_PRE_Video_asm2c|endp|proc loc_47FA4E_after ; video - RegisterClass_PRE_Video +loc_4CF654,16, ; video - RegisterClass_PRE_Video +loc_401AEB,5, ; video - PRE_VideoCallback +loc_47F17A,981, ; video - PRE_VideoCallback + +loc_48176D,81,;call video_RegisterClass_POST_Video_asm2c|PUSH loc_48176D_after|tcall video_RegisterClass_POST_Video_asm2c|endp|proc loc_48176D_after ; video - RegisterClass_POST_Video +loc_4CFAF8,16, ; video - RegisterClass_POST_Video +loc_4019B0,5, ; video - POST_VideoCallback +loc_481270,471, ; video - POST_VideoCallback + +loc_482DF5,114,;call video_RegisterClass_SS_Video_asm2c|PUSH loc_482DF5_after|tcall video_RegisterClass_SS_Video_asm2c|endp|proc loc_482DF5_after ; video - RegisterClass_SS_Video +loc_4CFEF0,12, ; video - RegisterClass_SS_Video +loc_40146F,10, ; video - SS_VideoCallback +loc_482A3E,159, ; video - SS_VideoCallback + +loc_480B11,1,;cmp dword [Intro_Play], 0|load tmp0, Intro_Play, 4|;jnz loc_480B11_after|ctcallnz tmp0, loc_480B11_after|tcall loc_480B11_after2|endp|proc loc_480B11_after2|;retn|POP tmp1|tcall tmp1|endp|;loc_480B11_after:|proc loc_480B11_after|;push ebp|PUSH ebp ; skip Intro videos +loc_48183D,1,;cmp dword [Outro_Play], 0|load tmp0, Outro_Play, 4|;jnz loc_48183D_after|ctcallnz tmp0, loc_48183D_after|tcall loc_48183D_after2|endp|proc loc_48183D_after2|;retn|POP tmp1|tcall tmp1|endp|;loc_48183D_after:|proc loc_48183D_after|;push ebp|PUSH ebp ; skip Outro videos + +loc_47F62C,3,;add esp, byte 8|add esp, esp, 8|;push dword [ebp+8]|add tmpadr, ebp, 8|load tmp0, tmpadr, 4|PUSH tmp0|;call video_Open_PRE_Video_asm2c|PUSH loc_47F62C_after|tcall video_Open_PRE_Video_asm2c|endp|proc loc_47F62C_after|;or eax, eax|cmovslt eax, 0, tmp0, 0, 1|;jge loc_47F93F|ctcallnz tmp0, loc_47F93F|tcall loc_47F62C_after2|endp|proc loc_47F62C_after2 ; video - Open_PRE_Video +loc_47F973,1,;push edi|PUSH edi|;call video_Close_PRE_Video_asm2c|PUSH loc_47F973_after|tcall video_Close_PRE_Video_asm2c|endp|proc loc_47F973_after|;or eax, eax|cmovslt eax, 0, tmp0, 0, 1|;jge loc_47F9DD|ctcallnz tmp0, loc_47F9DD|tcall loc_47F973_after2|endp|proc loc_47F973_after2 ; video - Close_PRE_Video +loc_47FC27,3,;add esp, byte 4|add esp, esp, 4|;push dword [ebp+12]|add tmpadr, ebp, 12|load tmp0, tmpadr, 4|PUSH tmp0|;call video_Play_PRE_Video_asm2c|PUSH loc_47FC27_after|tcall video_Play_PRE_Video_asm2c|endp|proc loc_47FC27_after|;or eax, eax|cmovslt eax, 0, tmp0, 0, 1|;jge loc_480ADC|ctcallnz tmp0, loc_480ADC|tcall loc_47FC27_after2|endp|proc loc_47FC27_after2 ; video - Play_PRE_Video + +loc_481504,3,;add esp, byte 8|add esp, esp, 8|;push dword [ebp+8]|add tmpadr, ebp, 8|load tmp0, tmpadr, 4|PUSH tmp0|;call video_Open_POST_Video_asm2c|PUSH loc_481504_after|tcall video_Open_POST_Video_asm2c|endp|proc loc_481504_after|;or eax, eax|cmovslt eax, 0, tmp0, 0, 1|;jge loc_4816D9|ctcallnz tmp0, loc_4816D9|tcall loc_481504_after2|endp|proc loc_481504_after2 ; video - Open_POST_Video +loc_4816E6,1,;push edi|PUSH edi|;call video_Close_POST_Video_asm2c|PUSH loc_4816E6_after|tcall video_Close_POST_Video_asm2c|endp|proc loc_4816E6_after|;or eax, eax|cmovslt eax, 0, tmp0, 0, 1|;jge loc_481705|ctcallnz tmp0, loc_481705|tcall loc_4816E6_after2|endp|proc loc_4816E6_after2 ; video - Close_POST_Video +loc_481705,2,;loc_481705:|;push byte 0|PUSH 0 ; video - Close_POST_Video +loc_481954,3,;add esp, byte 4|add esp, esp, 4|;push dword [ebp+8]|add tmpadr, ebp, 8|load tmp0, tmpadr, 4|PUSH tmp0|;call video_Play_POST_Video_asm2c|PUSH loc_481954_after|tcall video_Play_POST_Video_asm2c|endp|proc loc_481954_after|;or eax, eax|cmovslt eax, 0, tmp0, 0, 1|;jge loc_482332|ctcallnz tmp0, loc_482332|tcall loc_481954_after2|endp|proc loc_481954_after2 ; video - Play_POST_Video +loc_482332,2,;loc_482332:|;push byte 1|PUSH 1 ; video - Play_POST_Video + +loc_407F73,3,;add esp, byte 4|add esp, esp, 4|;push dword 0|PUSH 0|;call SDI_CheckTicksDelay_asm2c|PUSH loc_407F73_after|tcall SDI_CheckTicksDelay_asm2c|endp|proc loc_407F73_after ; insert delays into active waiting +loc_40FB6B,5,;push dword 1|PUSH 1|;call SDI_CheckTicksDelay_asm2c|PUSH loc_40FB5C_after1|tcall SDI_CheckTicksDelay_asm2c|endp|proc loc_40FB5C_after1|;call SYSTEM_GetTicks|PUSH loc_40FB5C_after2|tcall SYSTEM_GetTicks|endp|proc loc_40FB5C_after2 ; insert delays into active waiting +loc_410BBD,5,;push dword 2|PUSH 2|;call SDI_CheckTicksDelay_asm2c|PUSH loc_410BBD_after1|tcall SDI_CheckTicksDelay_asm2c|endp|proc loc_410BBD_after1|;call SYSTEM_GetTicks|PUSH loc_410BBD_after2|tcall SYSTEM_GetTicks|endp|proc loc_410BBD_after2 ; insert delays into active waiting +loc_410E4B,3,;add esp, byte 3*4|add esp, esp, 3*4|;push dword 3|PUSH 3|;call SDI_CheckTicksDelay_asm2c|PUSH loc_410E4B_after|tcall SDI_CheckTicksDelay_asm2c|endp|proc loc_410E4B_after ; insert delays into active waiting +loc_411674,5,;push dword 4|PUSH 4|;call SDI_CheckTicksDelay_asm2c|PUSH loc_411674_after1|tcall SDI_CheckTicksDelay_asm2c|endp|proc loc_411674_after1|;call SYSTEM_GetTicks|PUSH loc_411674_after2|tcall SYSTEM_GetTicks|endp|proc loc_411674_after2 ; insert delays into active waiting +loc_430FCF,5,;push dword 5|PUSH 5|;call SDI_CheckTicksDelay_asm2c|PUSH loc_430FCF_after1|tcall SDI_CheckTicksDelay_asm2c|endp|proc loc_430FCF_after1|;call SYSTEM_GetTicks|PUSH loc_430FCF_after2|tcall SYSTEM_GetTicks|endp|proc loc_430FCF_after2 ; insert delays into active waiting +loc_44E706,5,;push dword 6|PUSH 6|;call SDI_CheckTicksDelay_asm2c|PUSH loc_44E706_after1|tcall SDI_CheckTicksDelay_asm2c|endp|proc loc_44E706_after1|;call SYSTEM_GetTicks|PUSH loc_44E706_after2|tcall SYSTEM_GetTicks|endp|proc loc_44E706_after2 ; insert delays into active waiting +loc_4630CE,3,;add ebx, byte 4|add ebx, ebx, 4|;push dword 7|PUSH 7|;call SDI_CheckTicksDelay_asm2c|PUSH loc_4630CE_after|tcall SDI_CheckTicksDelay_asm2c|endp|proc loc_4630CE_after ; insert delays into active waiting +loc_467353,5,;push dword 8|PUSH 8|;call SDI_CheckTicksDelay_asm2c|PUSH loc_467353_after1|tcall SDI_CheckTicksDelay_asm2c|endp|proc loc_467353_after1|;call SYSTEM_GetTicks|PUSH loc_467353_after2|tcall SYSTEM_GetTicks|endp|proc loc_467353_after2 ; insert delays into active waiting +loc_47B0CA,5,;push dword 9|PUSH 9|;call SDI_CheckTicksDelay_asm2c|PUSH loc_47B0CA_after1|tcall SDI_CheckTicksDelay_asm2c|endp|proc loc_47B0CA_after1|;call SYSTEM_GetTicks|PUSH loc_47B0CA_after2|tcall SYSTEM_GetTicks|endp|proc loc_47B0CA_after2 ; insert delays into active waiting +loc_47B197,5,;push dword 10|PUSH 10|;call SDI_CheckTicksDelay_asm2c|PUSH loc_47B197_after1|tcall SDI_CheckTicksDelay_asm2c|endp|proc loc_47B197_after1|;call SYSTEM_GetTicks|PUSH loc_47B197_after2|tcall SYSTEM_GetTicks|endp|proc loc_47B197_after2 ; insert delays into active waiting +loc_47EF2B,5,;push dword 11|PUSH 11|;call SDI_CheckTicksDelay_asm2c|PUSH loc_47EF2B_after1|tcall SDI_CheckTicksDelay_asm2c|endp|proc loc_47EF2B_after1|;call SYSTEM_GetTicks|PUSH loc_47EF2B_after2|tcall SYSTEM_GetTicks|endp|proc loc_47EF2B_after2 ; insert delays into active waiting +loc_484C8F,5,;push dword 12|PUSH 12|;call SDI_CheckTicksDelay_asm2c|PUSH loc_484C8F_after1|tcall SDI_CheckTicksDelay_asm2c|endp|proc loc_484C8F_after1|;call SYSTEM_GetTicks|PUSH loc_484C8F_after2|tcall SYSTEM_GetTicks|endp|proc loc_484C8F_after2 ; insert delays into active waiting + +loc_476A31,7,PUSH loc_476A31_after|tcall sync_asm2c|endp|proc loc_476A31_after|;mov byte [ebp-0x18c], 0x1|add tmpadr, ebp, -396|mov tmp1, 0x1|store8 tmp1, tmpadr, 4|tcall loc_476A38|endp ; sync after save diff --git a/SRW-games/Battle Isle 3/SRW-sdi_1r/x86/displaced_labels.sci b/SRW-games/Battle Isle 3/SRW-sdi_1r/x86/displaced_labels.sci new file mode 100644 index 0000000..2aca263 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-sdi_1r/x86/displaced_labels.sci @@ -0,0 +1 @@ +loc_4B6FA8,32 diff --git a/SRW-games/Battle Isle 3/SRW-sdi_1r/x86/external_procedures.sci b/SRW-games/Battle Isle 3/SRW-sdi_1r/x86/external_procedures.sci new file mode 100644 index 0000000..e39246c --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-sdi_1r/x86/external_procedures.sci @@ -0,0 +1,25 @@ +loc_486268,ms_strlen_asm2c +loc_4862C8,ms_strcat_asm2c +loc_4862CC,ms_strcpy_asm2c +loc_48637D,ms_atol_asm2c +loc_486437,ms_atoi_asm2c +loc_486447,ms_printf_asm2c +loc_486494,ms_strncpy_asm2c +loc_4864C4,ms_strcmp_asm2c +loc_48656C,ms_memcpy_asm2c +loc_486710,ms__ftol_asm2c +loc_4867A8,ms_memset_asm2c +loc_4867FC,ms_memcmp_asm2c +loc_486822,ms_srand_asm2c +loc_48682E,ms_rand_asm2c +loc_486854,ms__alloca_probe_asm2c +loc_48688C,ms_strstr_asm2c +loc_48CC74,ms__strnicmp_asm2c +loc_48CD8A,ms__ltoa_asm2c + +loc_486168,ms__except_handler3_asm2c + +loc_401E06,cmdline_ContainsOption_asm2c + +loc_48605E,mciGetErrorStringA_asm2c +loc_48606A,mciSendCommandA_asm2c diff --git a/SRW-games/Battle Isle 3/SRW-sdi_1r/x86/fixup_interpret_as_code.sci b/SRW-games/Battle Isle 3/SRW-sdi_1r/x86/fixup_interpret_as_code.sci new file mode 100644 index 0000000..402b1e1 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-sdi_1r/x86/fixup_interpret_as_code.sci @@ -0,0 +1,97 @@ +loc_40102D +loc_401041 +loc_401050 +loc_40109B +loc_4010F0 +loc_401186 +loc_4011A4 +loc_4011F4 +loc_4011F9 +loc_401221 +loc_4012B2 +loc_4012D5 +loc_4012E4 +loc_40143D +loc_401474 +loc_4014BA +loc_4014BF +loc_4014E7 +loc_40152D +loc_401596 +loc_4015A5 +loc_4015AA +loc_4015C3 +loc_4015DC +loc_4015E1 +loc_4015F5 +loc_4015FA +loc_40162C +loc_40164F +loc_401668 +loc_4016D6 +loc_4016E0 +loc_40170D +loc_401762 +loc_4017CB +loc_4017DF +loc_4017F8 +loc_401811 +loc_40181B +loc_40182F +loc_40185C +loc_40186B +loc_401901 +loc_401924 +loc_401947 +loc_401960 +loc_401983 +loc_4019B0 +loc_4019D8 +loc_4019FB +loc_401A4B +loc_401AA5 +loc_401AC3 +loc_401AE1 +loc_401AEB +loc_401B0E +loc_401B22 +loc_401B27 +loc_401B31 +loc_401B6D +loc_401B8B +loc_401BB8 +loc_401C26 +loc_401C58 +loc_401C85 +loc_401C8A +loc_401CD0 +loc_401CDF +loc_401CEE +loc_401CFD +loc_401D39 +loc_401D6B +loc_401D70 +loc_401D8E +loc_401DA7 +loc_401DCF +loc_401DD4 +loc_401E0B +loc_401E1A +loc_401EE7 +loc_401F69 +loc_401F87 +loc_401FAF +loc_401FE6 +loc_47526C +loc_47591F +loc_475D03 +loc_4761B6 +loc_4767A7 +loc_476A4F +loc_476E1C +loc_478842 +loc_4793A5 +loc_486088 +loc_486090 +loc_486168 +loc_487D31 diff --git a/SRW-games/Battle Isle 3/SRW-sdi_1r/x86/global_aliases.sci b/SRW-games/Battle Isle 3/SRW-sdi_1r/x86/global_aliases.sci new file mode 100644 index 0000000..6e7acd2 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-sdi_1r/x86/global_aliases.sci @@ -0,0 +1,22 @@ +loc_48CA30,WinMain_ +loc_4B4C3E,SYSTEM_QuitProgramFlag_SDI_1R + +loc_4A2B58,video_PRE_avi +loc_4A2B7A,video_PRE_mciId +loc_4CF328,video_PRE_dword_4CF328 +loc_4CF32C,video_PRE_dword_4CF32C +loc_4CF330,video_PRE_stru_4CF330 +loc_4CF540,video_PRE_dword_4CF540 +loc_4CF544,video_PRE_byte_4CF544 +loc_4CF548,video_PRE_byte_4CF548 +loc_4CF54C,video_PRE_dword_4CF54C +loc_4CF550,video_PRE_byte_4CF550 + +loc_4A3540,video_POST_avi +loc_4A3562,video_POST_mciId +loc_4CFA40,video_POST_stru_4CFA40 +loc_4CFA70,video_POST_dword_4CFA70 +loc_4CFA74,video_POST_byte_4CFA74 +loc_4CFA78,video_POST_byte_4CFA78 +loc_4CFA7C,video_POST_dword_4CFA7C +loc_4CFA80,video_POST_byte_4CFA80 diff --git a/SRW-games/Battle Isle 3/SRW-sdi_1r/x86/ignored_areas.sci b/SRW-games/Battle Isle 3/SRW-sdi_1r/x86/ignored_areas.sci new file mode 100644 index 0000000..993a839 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-sdi_1r/x86/ignored_areas.sci @@ -0,0 +1,118 @@ +loc_40200E,4114 + +loc_409E5D,6915 + +loc_40C2FF,557 + +loc_40DBB6,2794 + +loc_4127F1,4191 + +loc_4149B2,4654 + +loc_41A924,4956 + +loc_41C15D,339 + +loc_41EFD7,921 + +loc_423B1B,4085 + +loc_425BD5,1211 + +loc_427C3D,1779 + +loc_42AC1F,5313 + +loc_42EB08,2024 + +loc_42F599,295 + +loc_433173,3757 + +loc_434DAA,870 + +loc_436CBA,1542 + +loc_438C96,1658 + +loc_43A4D8,424 + +loc_43CF2A,2614 + +loc_43F585,1803 + +loc_443BD2,4062 + +loc_4470DB,2389 + +loc_4489FF,1025 + +loc_44B025,2187 + +loc_44CC7A,1270 + +loc_4506A4,3420 + +loc_452714,1228 + +loc_4533FB,181 + +loc_45495A,1334 + +loc_455EC2,1038 + +loc_457024,860 + +loc_458D68,856 + +loc_459CC1,783 + +loc_45B4B7,1337 + +loc_45DCA5,2235 + +loc_4609E0,2336 + +loc_46BC2C,10836 + +loc_46F5E8,1000 + +loc_471614,1148 + +loc_472FCA,1366 + +loc_474668,1112 + +loc_476E32,1598 + +loc_479B9A,2518 + +loc_47B645,1083 + +loc_47E0FE,2466 + +loc_480C2F,1601 + +loc_482364,1100 + +loc_4851E1,2701 + +loc_485EFC,348 + +loc_486070,32 +loc_48610C,26916 +loc_48CBFF,495 + +loc_4B4C40,4900 + +loc_4B6FB8,4168 + +loc_4D0444,5916 + +loc_4D1CD0,108 +loc_4D1D3C,708 + +loc_401AEB,5 +loc_4019B0,5 +loc_40146F,10 diff --git a/SRW-games/Battle Isle 3/SRW-sdi_1r/x86/instruction_replacements.sci b/SRW-games/Battle Isle 3/SRW-sdi_1r/x86/instruction_replacements.sci new file mode 100644 index 0000000..67c4c29 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-sdi_1r/x86/instruction_replacements.sci @@ -0,0 +1,92 @@ +loc_477BD1,18, ; isalnum macro +loc_477BF6,52,call ms_isalnum_asm2c|add esp, byte 4 ; isalnum macro + +loc_403AD9,104, ; skip CDROM check +loc_4B8F20,64, ; skip CDROM check + +loc_44BF06,82, ; skip looking for file on CD +loc_4011C7,10, ; skip looking for file on CD +loc_427A39,281, ; skip looking for file on CD +loc_4BFDCC,12, ; skip looking for file on CD + +loc_47EBF0,47,call midi_OpenSDIMusic_asm2c ; midi - OpenSong +loc_47EC77,5,call midi_GetErrorString_asm2c ; midi - OpenSong +loc_47ECD2,10,call midi_GetSDIMusicID_asm2c ; midi - OpenSong +loc_4CF1A4,36, ; midi - OpenSong + +loc_47ED3B,28, ; midi - IsSongPlaying +loc_47ED5D,65,call midi_IsPlaying_asm2c ; midi - IsSongPlaying + +loc_47EE4B,24,call midi_CloseSDIMusic_asm2c ; midi - ProcessSong +loc_47EEA9,24,call midi_CloseSDIMusic_asm2c ; midi - ProcessSong +loc_47EF96,24,call midi_CloseSDIMusic_asm2c ; midi - ProcessSong +loc_47F013,24,call midi_PlaySDIMusic_asm2c ; midi - ProcessSong +loc_47F05B,5,call midi_GetErrorString_asm2c ; midi - ProcessSong +loc_4CF250,72, ; midi - ProcessSong + +loc_47F0C0,21,call midi_CloseSDIMusic_asm2c ; midi - CloseSong +loc_4CF2A8,16, ; midi - CloseSong + +loc_484E3A,24,call midi_OpenTestMusic_asm2c ; midi - TestSong +loc_484EEB,5,call midi_GetErrorString_asm2c ; midi - TestSong +loc_484F29,24,call midi_PlayTestMusic_asm2c ; midi - TestSong +loc_484FC9,5,call midi_GetErrorString_asm2c ; midi - TestSong +loc_4850AD,24,call midi_CloseTestMusic_asm2c ; midi - TestSong +loc_4D0318,64, ; midi - TestSong +loc_4D0394,16, ; midi - TestSong + +loc_486058,6, ; midi - winapi +loc_486064,6, ; midi - winapi + +loc_4830C0,103, ; skip VfW (Video for Windows) installation +loc_4A40A0,16, ; skip VfW (Video for Windows) installation +loc_4CFC88,68, ; skip VfW (Video for Windows) installation + +loc_401E06,5, ; cmdline - ContainsOption +loc_427905,308, ; cmdline - ContainsOption + +loc_44BA35,147,push loc_4C2E54|call cmdline_ReadLanguageOption_asm2c ; cmdline - ReadLanguageOption + +loc_47FA4E,81,call video_RegisterClass_PRE_Video_asm2c ; video - RegisterClass_PRE_Video +loc_4CF654,16, ; video - RegisterClass_PRE_Video +loc_401AEB,5, ; video - PRE_VideoCallback +loc_47F17A,981, ; video - PRE_VideoCallback + +loc_48176D,81,call video_RegisterClass_POST_Video_asm2c ; video - RegisterClass_POST_Video +loc_4CFAF8,16, ; video - RegisterClass_POST_Video +loc_4019B0,5, ; video - POST_VideoCallback +loc_481270,471, ; video - POST_VideoCallback + +loc_482DF5,114,call video_RegisterClass_SS_Video_asm2c ; video - RegisterClass_SS_Video +loc_4CFEF0,12, ; video - RegisterClass_SS_Video +loc_40146F,10, ; video - SS_VideoCallback +loc_482A3E,159, ; video - SS_VideoCallback + +loc_480B11,1,cmp dword [Intro_Play], 0|jnz loc_480B11_after|retn|loc_480B11_after:|push ebp ; skip Intro videos +loc_48183D,1,cmp dword [Outro_Play], 0|jnz loc_48183D_after|retn|loc_48183D_after:|push ebp ; skip Outro videos + +loc_47F62C,3,add esp, byte 8|push dword [ebp+8]|call video_Open_PRE_Video_asm2c|or eax, eax|jge loc_47F93F ; video - Open_PRE_Video +loc_47F973,1,push edi|call video_Close_PRE_Video_asm2c|or eax, eax|jge loc_47F9DD ; video - Close_PRE_Video +loc_47FC27,3,add esp, byte 4|push dword [ebp+12]|call video_Play_PRE_Video_asm2c|or eax, eax|jge loc_480ADC ; video - Play_PRE_Video + +loc_481504,3,add esp, byte 8|push dword [ebp+8]|call video_Open_POST_Video_asm2c|or eax, eax|jge loc_4816D9 ; video - Open_POST_Video +loc_4816E6,1,push edi|call video_Close_POST_Video_asm2c|or eax, eax|jge loc_481705 ; video - Close_POST_Video +loc_481705,2,loc_481705:|push byte 0 ; video - Close_POST_Video +loc_481954,3,add esp, byte 4|push dword [ebp+8]|call video_Play_POST_Video_asm2c|or eax, eax|jge loc_482332 ; video - Play_POST_Video +loc_482332,2,loc_482332:|push byte 1 ; video - Play_POST_Video + +loc_407F73,3,add esp, byte 4|push dword 0|call SDI_CheckTicksDelay_asm2c ; insert delays into active waiting +loc_40FB6B,5,push dword 1|call SDI_CheckTicksDelay_asm2c|call SYSTEM_GetTicks ; insert delays into active waiting +loc_410BBD,5,push dword 2|call SDI_CheckTicksDelay_asm2c|call SYSTEM_GetTicks ; insert delays into active waiting +loc_410E4B,3,add esp, byte 3*4|push dword 3|call SDI_CheckTicksDelay_asm2c ; insert delays into active waiting +loc_411674,5,push dword 4|call SDI_CheckTicksDelay_asm2c|call SYSTEM_GetTicks ; insert delays into active waiting +loc_430FCF,5,push dword 5|call SDI_CheckTicksDelay_asm2c|call SYSTEM_GetTicks ; insert delays into active waiting +loc_44E706,5,push dword 6|call SDI_CheckTicksDelay_asm2c|call SYSTEM_GetTicks ; insert delays into active waiting +loc_4630CE,3,add ebx, byte 4|push dword 7|call SDI_CheckTicksDelay_asm2c ; insert delays into active waiting +loc_467353,5,push dword 8|call SDI_CheckTicksDelay_asm2c|call SYSTEM_GetTicks ; insert delays into active waiting +loc_47B0CA,5,push dword 9|call SDI_CheckTicksDelay_asm2c|call SYSTEM_GetTicks ; insert delays into active waiting +loc_47B197,5,push dword 10|call SDI_CheckTicksDelay_asm2c|call SYSTEM_GetTicks ; insert delays into active waiting +loc_47EF2B,5,push dword 11|call SDI_CheckTicksDelay_asm2c|call SYSTEM_GetTicks ; insert delays into active waiting +loc_484C8F,5,push dword 12|call SDI_CheckTicksDelay_asm2c|call SYSTEM_GetTicks ; insert delays into active waiting + +loc_476A31,7,call sync_asm2c|mov byte [ebp-0x18c], 0x1 ; sync after save diff --git a/SRW-games/Battle Isle 3/SRW-wc_figtr/SR.cfg b/SRW-games/Battle Isle 3/SRW-wc_figtr/SR.cfg new file mode 100644 index 0000000..d3657b1 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-wc_figtr/SR.cfg @@ -0,0 +1,2 @@ +esp_dword_aligned=yes +ebp_dword_aligned=yes diff --git a/SRW-games/Battle Isle 3/SRW-wc_figtr/build-llasm.sh b/SRW-games/Battle Isle 3/SRW-wc_figtr/build-llasm.sh new file mode 100755 index 0000000..a1e3e3e --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-wc_figtr/build-llasm.sh @@ -0,0 +1,7 @@ +#! /bin/sh +cd "`echo $0 | sed 's/\/[^\/]*$//'`" +cp llasm/*.sci ./ +./SRW.exe WC_FIGTR.DLL WC_FIGTR.llasm >a.a 2>b.a +rm *.sci +./compact_source_llasm.py +rm *.a diff --git a/SRW-games/Battle Isle 3/SRW-wc_figtr/build-x86.sh b/SRW-games/Battle Isle 3/SRW-wc_figtr/build-x86.sh new file mode 100755 index 0000000..d3c2496 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-wc_figtr/build-x86.sh @@ -0,0 +1,10 @@ +#! /bin/sh +cd "`echo $0 | sed 's/\/[^\/]*$//'`" +cp x86/*.sci ./ +./SRW.exe WC_FIGTR.DLL WC_FIGTR.asm >a.a 2>b.a +rm *.sci +./compact_source.py +nasm -felf32 -O1 -w+orphan-labels -w-number-overflow -ix86/ WC_FIGTR.asm 2>a.a +./repair_short_jumps.py +rm *.a +rm WC_FIGTR.def diff --git a/SRW-games/Battle Isle 3/SRW-wc_figtr/compact_source.py b/SRW-games/Battle Isle 3/SRW-wc_figtr/compact_source.py new file mode 100755 index 0000000..1e5dd1b --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-wc_figtr/compact_source.py @@ -0,0 +1,70 @@ +#! /usr/bin/python +cPath = "./" + +import os + +def Compact (cFile): + cTmpFile = cFile + "tmp" + fIn = open(cFile, "rt") + fOut = open(cTmpFile, "wt") + + iNum = 0 + cRepStr = "" + + for cLine in fIn: + if iNum != 0: + if cLine == cRepStr: + iNum = iNum + 1 + else: + if iNum == 1: + fOut.write(cRepStr) + elif cRepStr.startswith("resb"): + fOut.write("resb " + str(iNum) + "\n") + elif iNum == 2: + fOut.write(cRepStr) + fOut.write(cRepStr) + else: + fOut.write("times " + str(iNum) + " " + cRepStr) + iNum = 0 + #cRepStr = "" + + if iNum == 0: + if cLine.startswith("db "): + iNum = 1 + cRepStr = cLine + elif cLine.strip() == "resb 1": + iNum = 1 + cRepStr = cLine + else: + fOut.write(cLine) + + if iNum != 0: + if iNum == 1: + fOut.write(cRepStr) + elif cRepStr.startswith("resb"): + fOut.write("resb " + str(iNum) + "\n") + elif iNum == 2: + fOut.write(cRepStr) + fOut.write(cRepStr) + else: + fOut.write("times " + str(iNum) + " " + cRepStr) + + fOut.close() + fIn.close() + + os.remove(cFile) + os.rename(cTmpFile, cFile) + +Compact(cPath + "seg01.inc") +Compact(cPath + "seg02.inc") +Compact(cPath + "seg03.inc") +Compact(cPath + "seg04.inc") +Compact(cPath + "seg05.inc") +Compact(cPath + "seg06.inc") +Compact(cPath + "seg07.inc") +Compact(cPath + "seg08.inc") +Compact(cPath + "seg09.inc") +Compact(cPath + "seg10.inc") +Compact(cPath + "seg11.inc") +Compact(cPath + "seg12.inc") +Compact(cPath + "seg13.inc") diff --git a/SRW-games/Battle Isle 3/SRW-wc_figtr/compact_source_llasm.py b/SRW-games/Battle Isle 3/SRW-wc_figtr/compact_source_llasm.py new file mode 100755 index 0000000..07ede74 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-wc_figtr/compact_source_llasm.py @@ -0,0 +1,64 @@ +#! /usr/bin/python +cPath = "./" + +import os + +def Compact (cFile): + cTmpFile = cFile + "tmp" + fIn = open(cFile, "rt") + fOut = open(cTmpFile, "wt") + + iNum = 0 + cRepStr = "" + + for cLine in fIn: + if iNum != 0: + if cLine == cRepStr: + iNum = iNum + 1 + else: + if iNum == 1: + fOut.write(cRepStr) + elif cRepStr.startswith("dskip"): + fOut.write("dskip " + str(iNum) + "\n") + elif iNum == 2: + fOut.write(cRepStr) + fOut.write(cRepStr) + else: + fOut.write(cRepStr.rstrip() + " dup " + str(iNum) + cRepStr[len(cRepStr.rstrip()):]) + iNum = 0 + #cRepStr = "" + + if iNum == 0: + if cLine.startswith("db "): + iNum = 1 + cRepStr = cLine + elif cLine.strip() == "dskip 1": + iNum = 1 + cRepStr = cLine + elif iNum == 2: + fOut.write(cRepStr) + fOut.write(cRepStr) + else: + fOut.write(cLine) + + if iNum != 0: + if iNum == 1: + fOut.write(cRepStr) + elif cRepStr.startswith("dskip"): + fOut.write("dskip " + str(iNum) + "\n") + else: + fOut.write(cRepStr.rstrip() + " dup " + str(iNum) + cRepStr[len(cRepStr.rstrip()):]) + + fOut.close() + fIn.close() + + os.remove(cFile) + os.rename(cTmpFile, cFile) + +Compact(cPath + "seg01_data.llinc") +Compact(cPath + "seg08_data.llinc") +Compact(cPath + "seg09_data.llinc") +Compact(cPath + "seg10_data.llinc") +Compact(cPath + "seg11_data.llinc") +Compact(cPath + "seg12_data.llinc") +Compact(cPath + "seg13_data.llinc") diff --git a/SRW-games/Battle Isle 3/SRW-wc_figtr/llasm/displaced_labels.sci b/SRW-games/Battle Isle 3/SRW-wc_figtr/llasm/displaced_labels.sci new file mode 100644 index 0000000..534f0a5 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-wc_figtr/llasm/displaced_labels.sci @@ -0,0 +1 @@ +loc_49FFFC,4 diff --git a/SRW-games/Battle Isle 3/SRW-wc_figtr/llasm/external_procedures.sci b/SRW-games/Battle Isle 3/SRW-wc_figtr/llasm/external_procedures.sci new file mode 100644 index 0000000..bd7ccb4 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-wc_figtr/llasm/external_procedures.sci @@ -0,0 +1,5 @@ +loc_4231B0,wc_memset_asm2c +loc_4231E0,wc_strcmp_asm2c +loc_42328C,wc_strcpy_asm2c +loc_4232C8,wc_sprintf_asm2c +loc_423305,wc_rand_asm2c diff --git a/SRW-games/Battle Isle 3/SRW-wc_figtr/llasm/fixup_interpret_as_code.sci b/SRW-games/Battle Isle 3/SRW-wc_figtr/llasm/fixup_interpret_as_code.sci new file mode 100644 index 0000000..f564e39 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-wc_figtr/llasm/fixup_interpret_as_code.sci @@ -0,0 +1,56 @@ +loc_4232B1 +loc_42415E +loc_424185 +loc_4241E0 +loc_424205 +loc_424213 +loc_424221 +loc_42423A +loc_424253 +loc_424261 +loc_42428E +loc_424298 +loc_4242A2 +loc_4242AC +loc_4242B6 +loc_4242C0 +loc_4242CA +loc_4242D4 +loc_4242DE +loc_4243D3 +loc_4247E4 +loc_424984 +loc_425253 +loc_42525C +loc_425D23 +loc_430000 +loc_4302C4 +loc_440C71 +loc_440CE4 +loc_440CF9 +loc_440D0E +loc_440D65 +loc_440D7A +loc_440D8F +loc_440E35 +loc_44148F +loc_441B06 +loc_441C37 +loc_441DFD +loc_441FDE +loc_44200C +loc_4422B2 +loc_442739 +loc_442796 +loc_443E96 +loc_44432C +loc_44434B +loc_44435F +loc_444388 +loc_45003F +loc_450071 +loc_45088A +loc_454DEB +loc_46004B +loc_470089 +loc_480000 diff --git a/SRW-games/Battle Isle 3/SRW-wc_figtr/llasm/ignored_areas.sci b/SRW-games/Battle Isle 3/SRW-wc_figtr/llasm/ignored_areas.sci new file mode 100644 index 0000000..353b151 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-wc_figtr/llasm/ignored_areas.sci @@ -0,0 +1,48 @@ +loc_410000,16 + +loc_4106B0,3 + +loc_41BCA9,87 + +loc_41BE28,56 + +loc_422C4E,434 + +loc_4230DF,85 +loc_423134,52940 + +loc_424DF2,167 + +loc_4302FC,64772 + +loc_4431A6,3238 + +loc_440000,1552 + +loc_4443AC,48212 + +loc_450000,63 + +loc_454D64,135 + +loc_4556FC,43268 + +loc_460000,75 + +loc_460C2D,2076 + +loc_462183,56957 + +loc_470000,137 + +loc_47F11C,3812 + +loc_484EE8,192 + +loc_48505C,44964 + +loc_49C058,1064 +loc_49C480,15232 + +loc_4A6AD0,304 + diff --git a/SRW-games/Battle Isle 3/SRW-wc_figtr/llasm/instruction_flags.sci b/SRW-games/Battle Isle 3/SRW-wc_figtr/llasm/instruction_flags.sci new file mode 100644 index 0000000..3486344 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-wc_figtr/llasm/instruction_flags.sci @@ -0,0 +1,85 @@ +loc_43001F,0x01,0 ; cmc - FL_CARRY +loc_430021,0x01,0 ; cmc - FL_CARRY +loc_430023,0 ,0x01 ; cmc - FL_CARRY + +loc_45022E,0x10,0 ; jns - FL_SIGN +loc_450234,0 ,0x10 ; jns - FL_SIGN + +loc_450578,0x10,0 ; jns - FL_SIGN +loc_45057E,0 ,0x10 ; jns - FL_SIGN + +loc_450780,0x10,0 ; jns - FL_SIGN +loc_450786,0 ,0x10 ; jns - FL_SIGN + +loc_450A3C,0x10,0 ; jns - FL_SIGN +loc_450A42,0 ,0x10 ; jns - FL_SIGN + +loc_450A66,0x10,0 ; jns - FL_SIGN +loc_450A6C,0 ,0x10 ; jns - FL_SIGN + +loc_450CAE,0x10,0 ; jns - FL_SIGN +loc_450CB4,0 ,0x10 ; jns - FL_SIGN + +loc_450CDA,0x10,0 ; jns - FL_SIGN +loc_450CE0,0 ,0x10 ; jns - FL_SIGN + +loc_450EB6,0x10,0 ; jns - FL_SIGN +loc_450EBC,0 ,0x10 ; jns - FL_SIGN + +loc_450EE0,0x10,0 ; jns - FL_SIGN +loc_450EE6,0 ,0x10 ; jns - FL_SIGN + +loc_45100A,0x01,0 ; jb - FL_CARRY +loc_45100C,0x01,0 ; jb - FL_CARRY +loc_450F10,0 ,0x01 ; jb - FL_CARRY + +loc_4510FC,0x09,0 ; ja - FL_ZERO | FL_CARRY +loc_451167,0 ,0x09 ; ja - FL_ZERO | FL_CARRY + +loc_45129A,0x09,0 ; ja - FL_ZERO | FL_CARRY +loc_451305,0 ,0x09 ; ja - FL_ZERO | FL_CARRY + +loc_451403,0x09,0 ; ja - FL_ZERO | FL_CARRY +loc_452076,0 ,0x09 ; ja - FL_ZERO | FL_CARRY + +loc_4524B2,0x09,0 ; ja - FL_ZERO | FL_CARRY +loc_4546EF,0 ,0x09 ; ja - FL_ZERO | FL_CARRY + +loc_4603D6,0x10,0 ; jns - FL_SIGN +loc_4603DC,0 ,0x10 ; jns - FL_SIGN + +loc_460BDC,0x10,0 ; jns - FL_SIGN +loc_460BE2,0 ,0x10 ; jns - FL_SIGN + +loc_461B5F,0x10,0 ; jns - FL_SIGN +loc_461B65,0 ,0x10 ; jns - FL_SIGN + +loc_47045F,0x10,0 ; jns - FL_SIGN +loc_470465,0 ,0x10 ; jns - FL_SIGN + +loc_470985,0x10,0 ; jns - FL_SIGN +loc_47098B,0 ,0x10 ; jns - FL_SIGN + +loc_470D60,0x10,0 ; jns - FL_SIGN +loc_470D66,0 ,0x10 ; jns - FL_SIGN + +loc_4715BF,0x10,0 ; jns - FL_SIGN +loc_4715C5,0 ,0x10 ; jns - FL_SIGN + +loc_471E2F,0x10,0 ; jns - FL_SIGN +loc_471E35,0 ,0x10 ; jns - FL_SIGN + +loc_4725D2,0x10,0 ; jns - FL_SIGN +loc_4725D8,0 ,0x10 ; jns - FL_SIGN + +loc_4727EF,0x10,0 ; jns - FL_SIGN +loc_4727F5,0 ,0x10 ; jns - FL_SIGN + +loc_472893,0x10,0 ; jns - FL_SIGN +loc_472899,0 ,0x10 ; jns - FL_SIGN + +loc_475338,0 ,0x01 ; adc - FL_CARRY + +loc_47873A,0 ,0x01 ; adc - FL_CARRY + +loc_47D2EC,0 ,0x01 ; adc - FL_CARRY diff --git a/SRW-games/Battle Isle 3/SRW-wc_figtr/llasm/instruction_replacements.sci b/SRW-games/Battle Isle 3/SRW-wc_figtr/llasm/instruction_replacements.sci new file mode 100644 index 0000000..0b58b2e --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-wc_figtr/llasm/instruction_replacements.sci @@ -0,0 +1,24 @@ +loc_410665,80, ; replace thunk function __Fight with function _Fight + +loc_4129B1,5,;push dword 1|PUSH 1|;call FGT_CheckTicksDelay_asm2c|PUSH loc_4129B1_after1|tcall FGT_CheckTicksDelay_asm2c|endp|proc loc_4129B1_after1|;call SYSTEM_GetTicks|PUSH loc_4129B1_after2|tcall SYSTEM_GetTicks|endp|proc loc_4129B1_after2 ; insert delays into active waiting +loc_41B9D2,5,;push dword 2|PUSH 2|;call FGT_CheckTicksDelay_asm2c|PUSH loc_41B9D2_after1|tcall FGT_CheckTicksDelay_asm2c|endp|proc loc_41B9D2_after1|;call SYSTEM_GetTicks|PUSH loc_41B9D2_after2|tcall SYSTEM_GetTicks|endp|proc loc_41B9D2_after2 ; insert delays into active waiting + +loc_41299E,7,;mov [loc_4A56AE], dx|store16 edx, loc_4A56AE, 2|;push dword 1|PUSH 1|;call FGT_CheckTicksDelay_asm2c|PUSH loc_41299E_after|tcall FGT_CheckTicksDelay_asm2c|endp|proc loc_41299E_after ; insert delays into active waiting +loc_41B9BF,7,;mov [loc_4A56AE], dx|store16 edx, loc_4A56AE, 2|;push dword 2|PUSH 2|;call FGT_CheckTicksDelay_asm2c|PUSH loc_41B9BF_after|tcall FGT_CheckTicksDelay_asm2c|endp|proc loc_41B9BF_after ; insert delays into active waiting + +loc_451432,3017,and ecx, ecx, 0xfffffffc|ctcallz ecx, loc_451432_after|tcall loc_451432_loop|endp|proc loc_451432_loop|add tmpadr, edi, ecx|sub tmpadr, tmpadr, 4|load tmp1, tmpadr, 1|and tmp1, tmp1, 0x1f1f1f1f|or tmp1, tmp1, eax|store tmp1, tmpadr, 1|sub ecx, ecx, 4|ctcallnz ecx, loc_451432_loop|tcall loc_451432_after|endp|proc loc_451432_after ; roll back unrolled loop +loc_4520A7,801, ; remove unrolled loop offsets + +loc_4524CB,8635,and ecx, ecx, 0xfffffffe|ctcallz ecx, loc_4524CB_after|tcall loc_4524CB_loop|endp|proc loc_4524CB_loop|add tmpadr, edi, ecx|sub tmpadr, tmpadr, 2|load16z tmp0, tmpadr, 1|ins8lh eax, eax, tmp0|load8z tmp2, eax, 1|ins8ll eax, eax, tmp0|load8z tmp1, eax, 1|shl tmp2, tmp2, 8|or tmp1, tmp1, tmp2|store16 tmp1, tmpadr, 1|sub ecx, ecx, 2|ctcallnz ecx, loc_4524CB_loop|tcall loc_4524CB_after|endp|proc loc_4524CB_after ; roll back unrolled loop +loc_454721,1738, ; remove unrolled loop offsets + +loc_4729A4,10644,and eflags, eflags, ~CF|ctcallz ebx, loc_4729A4_after|tcall loc_4729A4_loop|endp|proc loc_4729A4_loop|ins8hl eax, eax, edx|ins8ll eax, eax, ecx|load8z tmp0, eax, 1|and tmp5, eflags, CF|and eflags, eflags, ~CF|add tmp3, esi, tmp5|add ecx, ecx, tmp3|cmovz tmp3, tmp5, tmp5, 0|cmovult ecx, tmp3, tmp5, CF, tmp5|add tmp3, ebp, tmp5|add edx, edx, tmp3|cmovz tmp3, tmp5, tmp5, 0|cmovult edx, tmp3, tmp5, CF, tmp5|or eflags, eflags, tmp5|add tmpadr, edi, ebx|sub tmpadr, tmpadr, 1|store8 tmp0, tmpadr, 1|sub ebx, ebx, 1|ctcallnz ebx, loc_4729A4_loop|tcall loc_4729A4_after|endp|proc loc_4729A4_after ; roll back unrolled loop + +loc_47543C,13054,and eflags, eflags, ~CF|ctcallz ebx, loc_47543C_after_loop|tcall loc_47543C_loop|endp|proc loc_47543C_loop|ins8hl eax, eax, edx|ins8ll eax, eax, ecx|and tmp5, eflags, CF|and eflags, eflags, ~CF|add tmp3, esi, tmp5|add ecx, ecx, tmp3|cmovz tmp3, tmp5, tmp5, 0|cmovult ecx, tmp3, tmp5, CF, tmp5|add tmp3, ebp, tmp5|add edx, edx, tmp3|cmovz tmp3, tmp5, tmp5, 0|cmovult edx, tmp3, tmp5, CF, tmp5|or eflags, eflags, tmp5|load tmp0, loc_4C32A8, 4|load8z tmp1, eax, 1|and tmp0, tmp0, 0xffffff00|or tmp0, tmp0, tmp1|load8z tmp2, tmp0, 1|add tmpadr, edi, ebx|sub tmpadr, tmpadr, 1|store8 tmp2, tmpadr, 1|sub ebx, ebx, 1|ctcallnz ebx, loc_47543C_loop|tcall loc_47543C_after_loop|endp|proc loc_47543C_after_loop|load ebx, loc_4C32A8, 4 ; roll back unrolled loop +loc_4787BA,6000, ; remove unrolled loop offsets + +loc_479FEE,13054,and eflags, eflags, ~CF|ctcallz ebx, loc_479FEE_after_loop|tcall loc_479FEE_loop|endp|proc loc_479FEE_loop|ins8hl eax, eax, edx|ins8ll eax, eax, ecx|and tmp5, eflags, CF|and eflags, eflags, ~CF|add tmp3, esi, tmp5|add ecx, ecx, tmp3|cmovz tmp3, tmp5, tmp5, 0|cmovult ecx, tmp3, tmp5, CF, tmp5|add tmp3, ebp, tmp5|add edx, edx, tmp3|cmovz tmp3, tmp5, tmp5, 0|cmovult edx, tmp3, tmp5, CF, tmp5|or eflags, eflags, tmp5|load tmp0, loc_4C32A8, 4|load8z tmp1, eax, 1|and tmp0, tmp0, 0xffffff00|or tmp0, tmp0, tmp1|load8z tmp2, tmp0, 1|add tmpadr, edi, ebx|sub tmpadr, tmpadr, 1|store8 tmp2, tmpadr, 1|sub ebx, ebx, 1|ctcallnz ebx, loc_479FEE_loop|tcall loc_479FEE_after_loop|endp|proc loc_479FEE_after_loop|load ebx, loc_4C32A8, 4 ; roll back unrolled loop +loc_47D36C,7600, ; remove unrolled loop offsets + +loc_480221,16426,ctcallz edx, loc_48424B|tcall loc_480221_loop|endp|proc loc_480221_loop|add eax, eax, ebx|cmovult eax, ebx, tmp2, 1, 0|add eax, eax, tmp2|ext16s tmp1, eax|add tmpadr, tmp1, esi|load8z tmp0, tmpadr, 1|ifnz tmp0|add tmpadr, edi, edx|sub tmpadr, tmpadr, 1|store8 tmp0, tmpadr, 1|endif|sub edx, edx, 1|ctcallnz edx, loc_480221_loop|tcall loc_48424B|endp ; roll back unrolled loop +loc_484266,3394,;pop ebp|POP ebp|;retn|POP tmp1|tcall tmp1|endp ; remove unrolled loop offsets diff --git a/SRW-games/Battle Isle 3/SRW-wc_figtr/llasm/unaligned_ebp_areas.sci b/SRW-games/Battle Isle 3/SRW-wc_figtr/llasm/unaligned_ebp_areas.sci new file mode 100644 index 0000000..9d6bb9c --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-wc_figtr/llasm/unaligned_ebp_areas.sci @@ -0,0 +1,8 @@ +loc_4425D4,670 +loc_442ECB,203 +loc_443FDB,25 +loc_4556B9,66 +loc_460C5B,93 +loc_461FEE,260 +loc_4716B8,53 +loc_480000,516 diff --git a/SRW-games/Battle Isle 3/SRW-wc_figtr/repair_short_jumps.py b/SRW-games/Battle Isle 3/SRW-wc_figtr/repair_short_jumps.py new file mode 100755 index 0000000..0d211f0 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-wc_figtr/repair_short_jumps.py @@ -0,0 +1,64 @@ +#! /usr/bin/python +cPath = "./" +cErrFile = "a.a" + +import os + +fErr = open(cPath + cErrFile, "rt") + +iErr = 0 +cInFile = "" +cFile = "" +iLine = 0 + +for cErrLine in fErr: + if cErrLine != "": + iTemp1 = cErrLine.find(":") + iTemp2 = cErrLine.find(":", iTemp1 + 1) + cFile = cErrLine[ : iTemp1] + iErr = int( cErrLine[iTemp1 + 1 : iTemp2] ) + + if cErrLine[iTemp2 + 1 : ].startswith(" error: short jump is out of range"): + if cFile != cInFile: + if cInFile != "": + for cLine in fIn: + fOut.write(cLine) + fOut.close() + fIn.close() + + os.remove(cPath + cInFile) + os.rename(cPath + cInFile + "tmp", cPath + cInFile) + + fIn = open(cPath + cFile, "rt") + fOut = open(cPath + cFile + "tmp", "wt") + cInFile = cFile + iLine = 0 + + while iLine + 1 < iErr: + fOut.write(fIn.readline()) + iLine = iLine + 1 + + cLine = fIn.readline() + iLine = iLine + 1 + + if cLine.startswith("jmp short"): + # if line begins "jmp short" then remove "short" keyword + cLine = "jmp" + cLine[9:] + else: + # else insert "next" keyword after first word + iTemp = cLine.find(" ") + cLine = cLine[ : iTemp + 1] + "near" + cLine[iTemp : ] + + fOut.write(cLine) + +if cInFile != "": + for cLine in fIn: + fOut.write(cLine) + fOut.close() + fIn.close() + + os.remove(cPath + cInFile) + os.rename(cPath + cInFile + "tmp", cPath + cInFile) + +fErr.close() + diff --git a/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/displaced_labels.sci b/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/displaced_labels.sci new file mode 100644 index 0000000..534f0a5 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/displaced_labels.sci @@ -0,0 +1 @@ +loc_49FFFC,4 diff --git a/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/extern.inc b/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/extern.inc new file mode 100644 index 0000000..5d9215b --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/extern.inc @@ -0,0 +1,29 @@ +;; +;; Copyright (C) 2019-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +extern wc_memset_asm2c +extern wc_strcmp_asm2c +extern wc_strcpy_asm2c +extern wc_sprintf_asm2c +extern wc_rand_asm2c + +extern FGT_CheckTicksDelay_asm2c diff --git a/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/external_procedures.sci b/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/external_procedures.sci new file mode 100644 index 0000000..bd7ccb4 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/external_procedures.sci @@ -0,0 +1,5 @@ +loc_4231B0,wc_memset_asm2c +loc_4231E0,wc_strcmp_asm2c +loc_42328C,wc_strcpy_asm2c +loc_4232C8,wc_sprintf_asm2c +loc_423305,wc_rand_asm2c diff --git a/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/fixup_interpret_as_code.sci b/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/fixup_interpret_as_code.sci new file mode 100644 index 0000000..f564e39 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/fixup_interpret_as_code.sci @@ -0,0 +1,56 @@ +loc_4232B1 +loc_42415E +loc_424185 +loc_4241E0 +loc_424205 +loc_424213 +loc_424221 +loc_42423A +loc_424253 +loc_424261 +loc_42428E +loc_424298 +loc_4242A2 +loc_4242AC +loc_4242B6 +loc_4242C0 +loc_4242CA +loc_4242D4 +loc_4242DE +loc_4243D3 +loc_4247E4 +loc_424984 +loc_425253 +loc_42525C +loc_425D23 +loc_430000 +loc_4302C4 +loc_440C71 +loc_440CE4 +loc_440CF9 +loc_440D0E +loc_440D65 +loc_440D7A +loc_440D8F +loc_440E35 +loc_44148F +loc_441B06 +loc_441C37 +loc_441DFD +loc_441FDE +loc_44200C +loc_4422B2 +loc_442739 +loc_442796 +loc_443E96 +loc_44432C +loc_44434B +loc_44435F +loc_444388 +loc_45003F +loc_450071 +loc_45088A +loc_454DEB +loc_46004B +loc_470089 +loc_480000 diff --git a/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/ignored_areas.sci b/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/ignored_areas.sci new file mode 100644 index 0000000..353b151 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/ignored_areas.sci @@ -0,0 +1,48 @@ +loc_410000,16 + +loc_4106B0,3 + +loc_41BCA9,87 + +loc_41BE28,56 + +loc_422C4E,434 + +loc_4230DF,85 +loc_423134,52940 + +loc_424DF2,167 + +loc_4302FC,64772 + +loc_4431A6,3238 + +loc_440000,1552 + +loc_4443AC,48212 + +loc_450000,63 + +loc_454D64,135 + +loc_4556FC,43268 + +loc_460000,75 + +loc_460C2D,2076 + +loc_462183,56957 + +loc_470000,137 + +loc_47F11C,3812 + +loc_484EE8,192 + +loc_48505C,44964 + +loc_49C058,1064 +loc_49C480,15232 + +loc_4A6AD0,304 + diff --git a/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/instruction_replacements.sci b/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/instruction_replacements.sci new file mode 100644 index 0000000..ab5c394 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/instruction_replacements.sci @@ -0,0 +1,4 @@ +loc_410665,80, ; replace thunk function __Fight with function _Fight + +loc_4129B1,5,push dword 1|call FGT_CheckTicksDelay_asm2c|call SYSTEM_GetTicks ; insert delays into active waiting +loc_41B9D2,5,push dword 2|call FGT_CheckTicksDelay_asm2c|call SYSTEM_GetTicks ; insert delays into active waiting diff --git a/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/misc.inc b/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/misc.inc new file mode 100644 index 0000000..7099e3b --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/misc.inc @@ -0,0 +1,25 @@ +;; +;; Copyright (C) 2016 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%define tbyte tword + +%define NDEBUG diff --git a/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/x86inc.inc b/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/x86inc.inc new file mode 100644 index 0000000..8768898 --- /dev/null +++ b/SRW-games/Battle Isle 3/SRW-wc_figtr/x86/x86inc.inc @@ -0,0 +1,26 @@ +;part of static recompiler -- do not edit + +;; +;; Copyright (C) 2019 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +extern x86_read_fs_dword +extern x86_write_fs_dword diff --git a/SRW-games/README.md b/SRW-games/README.md index 136058e..56bd031 100644 --- a/SRW-games/README.md +++ b/SRW-games/README.md @@ -21,3 +21,45 @@ The original executable is *Septerra104.exe* from the English version 1.04. The generated files should be moved to *Septerra Core/SR-Septerra/x86* (or *llasm*) subdirectory in *games* subproject. +## Battle Isle 3 + +#### SRW-ms_figtr + +The original executable is *MS_FIGTR.DLL* from the English version. + +* file size: 39936 bytes +* md5: f5f46e6841dce6fc92eb07d1743eec7a +* sha1: 160ed7fe442bc8a37eff0a36220a177cd9c6ebb1 +* sha256: e9e69b1fb8e18d546f769204303a046dbe083e19ad1280a67bd40723b9e284e0 + +The generated files should be moved to *Battle Isle 3/SR-BI3/x86/ms_figtr* (or *llasm/ms_figtr*) subdirectory in *games* subproject. + +#### SRW-sdi_1r + +The original executable is *SDI_1R.EXE* from the English version. + +* file size: 774144 bytes +* md5: a7778d5f4d1c9fd8017d8da80c85bb44 +* sha1: ca6322a80552161fb61ba40a3955af4d166359be +* sha256: 1b6d69b54548588a37eb5919193f8ab01328208c91822079a77e6f42d2b34f51 + +Also accepted executable is *SDI_1R.EXE* from the English version (from GOG.com). + +* file size: 774144 bytes +* md5: c0ea37923b18e67fa982e63319337dc2 +* sha1: 6d861add8c93c6ccb1a5b6438a646e4be2df085c +* sha256: 03c64aba3bd305cefcf947795afbdb3b3a58f1598517ebdb15cc0fdfe63f438a + +The generated files should be moved to *Battle Isle 3/SR-BI3/x86/sdi_1r* (or *llasm/sdi_1r*) subdirectory in *games* subproject. + +#### SRW-wc_figtr + +The original executable is *WC_FIGTR.DLL* from the English version. + +* file size: 463939 bytes +* md5: a3a416cc07c6590c4865e2b76ea0c240 +* sha1: 94572b4e599a91164c03a1ae9e5e0456bb30cd14 +* sha256: f92da9d96138115c308fb096f16ed12c900e7832befa4f8e4425014d2cff6e44 + +The generated files should be moved to *Battle Isle 3/SR-BI3/x86/wc_figtr* (or *llasm/wc_figtr*) subdirectory in *games* subproject. + diff --git a/games/Battle Isle 3/SR-BI3/BBAVI.c b/games/Battle Isle 3/SR-BI3/BBAVI.c new file mode 100644 index 0000000..35410d4 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBAVI.c @@ -0,0 +1,1829 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if defined(__WINE__) || !defined(OLDVIDEO) +#define USE_QUICKTIMELIB +#else +#undef USE_QUICKTIMELIB +#endif + +#include "BBAVI.h" +#include "BBDSA.h" +#include "BBMEM.h" +#include "BBSYSTEM.h" +#include "BBDBG.h" +#include "BBFX.h" +#include "BBBLEV.h" +#if defined(USE_QUICKTIMELIB) +#include +#include +#include +#endif +#include +#if !defined(USE_QUICKTIMELIB) +#include +#include +#endif + + +// exported variables +#ifdef __cplusplus +extern "C" { +#endif +extern uint32_t w_avi_device_id; +#ifdef __cplusplus +} +#endif + + +extern HPALETTE DSA_hPalette; + + +typedef struct { + HWND hWnd; + char alias[30]; +#if defined(USE_QUICKTIMELIB) + uint16_t reserved; + + quicktime_t *qt; + + int play_video; + int video_width; + int video_height; + int video_depth; + int64_t video_duration; + long video_frames; + int video_time_scale; + int colormodel; + int read_compressed_video; + int palette_colors; + + int play_audio; + int audio_channels; + long audio_sample_rate; + int audio_format_size; + int decode_raw_audio; + int64_t audio_length; + + RGBQUAD video_palette[256]; +#else + MCIDEVICEID wDeviceID; +#endif + DSA_Palette palette1; + DSA_Palette palette2; +} AVI_Video; + + +static int AVI_initialized = 0; +static int AVI_wasApplicationActive = 0; +static int AVI_destortionLevel = 0; +static int AVI_numVideos = 0; +static const char AVI_windowClass[] = "BB_AVICALLBACK"; +static AVI_Video *AVI_videos[5]; +static int32_t AVI_desktopWidth; +static volatile int AVI_cancelPlayback; +static int AVI_stopPlayback; +static volatile int AVI_playbackFinished; +static int32_t AVI_desktopHeight; + + +#if defined(USE_QUICKTIMELIB) + +static int compare_fourcc(const uint8_t *str1, const uint8_t *str2) +{ + if ((str1[0] == str2[0]) && + (str1[1] == str2[1]) && + (str1[2] == str2[2]) && + (str1[3] == str2[3]) + ) + { + return 1; + } + return 0; +} + +static uint32_t read_32le(const uint8_t *ptr) +{ + return ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24); +} + +static void close_video(AVI_Video *video) +{ + if (video->qt != NULL) + { + quicktime_close(video->qt); + video->qt = NULL; + } +} + +static int open_video(const char *path, AVI_Video *video) +{ +#if defined(__WINE__) + WCHAR pathW[MAX_PATH]; + char *pathUnix; +#endif + + static const uint8_t fourcc_rle8[4] = {1, 0, 0, 0}; + +#if defined(__WINE__) + MultiByteToWideChar(CP_ACP, 0, path, -1, pathW, MAX_PATH); + pathUnix = wine_get_unix_file_name(pathW); + + video->qt = lqt_open_read(pathUnix); +#else + video->qt = lqt_open_read(path); +#endif + if (video->qt == NULL) return 1; + + if (quicktime_video_tracks(video->qt) <= 0) + { + close_video(video); + return 2; + } + + video->play_video = 0; + if (quicktime_supported_video(video->qt, 0)) + { + video->play_video = 1; + video->read_compressed_video = 0; + } + else if (compare_fourcc((const uint8_t *)quicktime_video_compressor(video->qt, 0), fourcc_rle8)) + { + video->play_video = 1; + video->read_compressed_video = 1; + } + + video->video_time_scale = lqt_video_time_scale(video->qt, 0); + video->video_duration = lqt_video_duration(video->qt, 0); + video->video_frames = quicktime_video_length(video->qt, 0); + + if (video->play_video) + { + video->video_width = quicktime_video_width(video->qt, 0); + video->video_height = quicktime_video_height(video->qt, 0); + video->video_depth = quicktime_video_depth(video->qt, 0); + + if (video->read_compressed_video) + { + video->colormodel = BC_BGR8888; + } + else + { + int color_models[3]; + + color_models[0] = BC_BGR888; + color_models[1] = BC_BGR8888; + color_models[2] = LQT_COLORMODEL_NONE; + video->colormodel = lqt_get_best_colormodel(video->qt, 0, color_models); + + lqt_set_cmodel(video->qt, 0, video->colormodel); + } + } + + video->play_audio = 0; + if (quicktime_audio_tracks(video->qt) > 0) + { + if (quicktime_supported_audio(video->qt, 0)) + { + video->audio_channels = quicktime_track_channels(video->qt, 0); + video->audio_sample_rate = quicktime_sample_rate(video->qt, 0); + + if (((video->audio_channels == 1) || + (video->audio_channels == 2) + ) && + (video->audio_sample_rate > 0) && + (video->audio_sample_rate <= 48000) + ) + { + video->play_audio = 1; + } + } + } + + if (video->play_audio) + { + lqt_sample_format_t format; + + format = lqt_get_sample_format(video->qt, 0); + if ((format == LQT_SAMPLE_UINT8) || (format == LQT_SAMPLE_INT16)) + { + video->audio_format_size = (format == LQT_SAMPLE_UINT8)?1:2; + video->decode_raw_audio = 1; + } + else + { + video->audio_format_size = 2; + video->decode_raw_audio = 0; + } + + video->audio_length = quicktime_audio_length(video->qt, 0); + } + + return 0; +} + +static int read_palette(const char *path, AVI_Video *video) +{ + int index, is_video, num_colors; + HANDLE hAvi; + uint8_t buffer[12]; + DWORD dwBytesRead; + unsigned int cur_riff_offset, max_riff_offset, chunk_size; + unsigned int cur_hdrl_offset, max_hdrl_offset; + unsigned int cur_strl_offset, max_strl_offset; + BITMAPINFOHEADER bmih; + + static const uint8_t fourcc_riff[4] = {'R', 'I', 'F', 'F'}; + static const uint8_t fourcc_avi[4] = {'A', 'V', 'I', ' '}; + static const uint8_t fourcc_list[4] = {'L', 'I', 'S', 'T'}; + static const uint8_t fourcc_hdrl[4] = {'h', 'd', 'r', 'l'}; + static const uint8_t fourcc_strl[4] = {'s', 't', 'r', 'l'}; + static const uint8_t fourcc_strh[4] = {'s', 't', 'r', 'h'}; + static const uint8_t fourcc_strf[4] = {'s', 't', 'r', 'f'}; + static const uint8_t fourcc_vids[4] = {'v', 'i', 'd', 's'}; + + video->palette_colors = 0; + for (index = 0; index < 256; index++) + { + video->video_palette[index].rgbBlue = 0; + video->video_palette[index].rgbGreen = 0; + video->video_palette[index].rgbRed = 0; + video->video_palette[index].rgbReserved = 0; + } + + if (!video->play_video) return 0; + if ((video->video_depth <= 0) || (video->video_depth > 8)) return 0; + + hAvi = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); + if (hAvi == INVALID_HANDLE_VALUE) return (video->read_compressed_video)?1:0; + + if (!ReadFile(hAvi, buffer, 12, &dwBytesRead, NULL) || (dwBytesRead != 12)) goto read_error; + if (!compare_fourcc(buffer, fourcc_riff) || !compare_fourcc(buffer + 8, fourcc_avi)) goto read_error; + + cur_riff_offset = 12; + max_riff_offset = 8 + read_32le(buffer + 4); + + // loop over 1st level chunks + while (cur_riff_offset < max_riff_offset) + { + if (INVALID_SET_FILE_POINTER == SetFilePointer(hAvi, cur_riff_offset, NULL, FILE_BEGIN)) goto read_error; + if (!ReadFile(hAvi, buffer, 8, &dwBytesRead, NULL) || (dwBytesRead != 8)) goto read_error; + + if (!compare_fourcc(buffer, fourcc_list)) + { + chunk_size = read_32le(buffer + 4); + cur_riff_offset += 8 + chunk_size + (chunk_size & 1); + continue; + } + + if (!ReadFile(hAvi, buffer + 8, 4, &dwBytesRead, NULL) || (dwBytesRead != 4)) goto read_error; + + if (!compare_fourcc(buffer + 8, fourcc_hdrl)) + { + chunk_size = read_32le(buffer + 4); + cur_riff_offset += 8 + chunk_size + (chunk_size & 1); + continue; + } + + chunk_size = read_32le(buffer + 4); + cur_hdrl_offset = cur_riff_offset + 12; + max_hdrl_offset = cur_riff_offset + 8 + chunk_size; + cur_riff_offset += 8 + chunk_size + (chunk_size & 1); + + // loop over 2nd level chunks + while (cur_hdrl_offset < max_hdrl_offset) + { + if (INVALID_SET_FILE_POINTER == SetFilePointer(hAvi, cur_hdrl_offset, NULL, FILE_BEGIN)) goto read_error; + if (!ReadFile(hAvi, buffer, 8, &dwBytesRead, NULL) || (dwBytesRead != 8)) goto read_error; + + if (!compare_fourcc(buffer, fourcc_list)) + { + chunk_size = read_32le(buffer + 4); + cur_hdrl_offset += 8 + chunk_size + (chunk_size & 1); + continue; + } + + if (!ReadFile(hAvi, buffer + 8, 4, &dwBytesRead, NULL) || (dwBytesRead != 4)) goto read_error; + + if (!compare_fourcc(buffer + 8, fourcc_strl)) + { + chunk_size = read_32le(buffer + 4); + cur_hdrl_offset += 8 + chunk_size + (chunk_size & 1); + continue; + } + + chunk_size = read_32le(buffer + 4); + cur_strl_offset = cur_hdrl_offset + 12; + max_strl_offset = cur_hdrl_offset + 8 + chunk_size; + cur_hdrl_offset += 8 + chunk_size + (chunk_size & 1); + + is_video = 0; + + // loop over 3rd level chunks + while (cur_strl_offset < max_strl_offset) + { + if (INVALID_SET_FILE_POINTER == SetFilePointer(hAvi, cur_strl_offset, NULL, FILE_BEGIN)) goto read_error; + if (!ReadFile(hAvi, buffer, 8, &dwBytesRead, NULL) || (dwBytesRead != 8)) goto read_error; + + if (compare_fourcc(buffer, fourcc_strh)) + { + if (!ReadFile(hAvi, buffer + 8, 4, &dwBytesRead, NULL) || (dwBytesRead != 4)) goto read_error; + + if (!compare_fourcc(buffer + 8, fourcc_vids)) break; + + is_video = 1; + } + else if (compare_fourcc(buffer, fourcc_strf) && is_video) + { + if (!ReadFile(hAvi, &bmih, sizeof(BITMAPINFOHEADER), &dwBytesRead, NULL) || (dwBytesRead != sizeof(BITMAPINFOHEADER))) goto read_error; + + if (bmih.biSize != sizeof(BITMAPINFOHEADER)) break; + + if ((bmih.biCompression == BI_RGB) && (bmih.biBitCount <= 8)) + { + num_colors = bmih.biClrUsed; + if (bmih.biClrUsed == 0) + { + bmih.biClrUsed = 1 << bmih.biBitCount; + } + } + else if ((bmih.biCompression == BI_RLE8) || (bmih.biCompression == BI_RLE4)) + { + num_colors = bmih.biClrUsed; + } + else num_colors = 0; + + if (num_colors) + { + if (!ReadFile(hAvi, video->video_palette, num_colors * sizeof(RGBQUAD), &dwBytesRead, NULL) || (dwBytesRead != num_colors * sizeof(RGBQUAD))) goto read_error; + + video->palette_colors = num_colors; + } + } + + chunk_size = read_32le(buffer + 4); + cur_strl_offset += 8 + chunk_size + (chunk_size & 1); + continue; + } + } + } + +read_error: + CloseHandle(hAvi); + + return (video->read_compressed_video && !video->palette_colors)?2:0; +} + +static void decode_rle8(uint8_t *src, int length, int width, int height, uint8_t **rows) +{ + uint8_t *row; + int x, y, num, index; + uint8_t b1, b2; + + // https://wiki.multimedia.cx/index.php/Microsoft_RLE + + x = y = 0; + row = rows[0]; + while (1) + { + if (length < 2) break; + + b1 = src[0]; + b2 = src[1]; + src += 2; + length -= 2; + + if (b1 != 0) + { + // Encoded Mode + num = (x + b1 > width)?width - x:b1; + for (index = 0; index < num; index++) + { + row[x + index] = b2; + } + + x += num; + continue; + } + + if (b2 >= 3) + { + // Absolute Mode + if (b2 > length) break; + + num = (x + b2 > width)?width - x:b2; + for (index = 0; index < num; index++) + { + row[x + index] = src[index]; + } + + x += num; + src += b2 + (b2 & 1); + length -= b2 + (b2 & 1); + continue; + } + + if (b2 == 0) + { + // End of line + x = 0; + y++; + if (y >= height) break; + row = rows[y]; + } + else if (b2 == 1) + { + // End of bitmap + break; + } + else + { + // Delta + if (length < 2) break; + + b1 = src[0]; + b2 = src[1]; + src += 2; + length -= 2; + + x += b1; + if (x > width) x = width; + y += b2; + if (y >= height) break; + row = rows[y]; + } + } +} + +#endif + + +static LRESULT WINAPI AVI_VideoCallback_c(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + PAINTSTRUCT paint; + + uMsg = uMsg & 0xffff; + + switch (uMsg) + { +#if !defined(USE_QUICKTIMELIB) + case MM_MCINOTIFY: + AVI_playbackFinished = 1; + return 0; +#endif + + case WM_KEYUP: + if (wParam != VK_ESCAPE) + { + return uMsg; + } + // @fallthrough@ + case WM_LBUTTONUP: + case WM_RBUTTONUP: + AVI_cancelPlayback = 1; + return 0; + + case WM_ERASEBKGND: + return 0; + + case WM_PAINT: + BeginPaint(hWnd, &paint); + EndPaint(hWnd, &paint); + return 0; + + default: + return DefWindowProcA(hWnd, uMsg, wParam, lParam); + } +} + +int AVI_Init_c(void) +{ + WNDCLASSA wndClass; +#if !defined(USE_QUICKTIMELIB) + MCI_OPEN_PARMS mciOpenParams; + MCIERROR mcierr; + char errorText[1024]; +#endif + int index; + + if (!AVI_initialized) + { + for (index = 0; index < 5; index++) + { + AVI_videos[index] = NULL; + } + + wndClass.style = CS_NOCLOSE | CS_DBLCLKS; + wndClass.lpfnWndProc = (WNDPROC)AVI_VideoCallback_c; + wndClass.cbClsExtra = 0; + wndClass.cbWndExtra = 0; + wndClass.hInstance = DSAWIN_GetInstance_c(); + wndClass.hIcon = NULL; + wndClass.hCursor = NULL; + wndClass.hbrBackground = NULL; + wndClass.lpszMenuName = NULL; + wndClass.lpszClassName = AVI_windowClass; + if (!RegisterClassA(&wndClass)) + { + return 0; + } + +#if defined(USE_QUICKTIMELIB) + lqt_registry_init(); +#else + mciOpenParams.dwCallback = 0; + mciOpenParams.lpstrDeviceType = "avivideo"; + mcierr = mciSendCommandA(0, MCI_OPEN, MCI_OPEN_TYPE, (uintptr_t)&mciOpenParams); + if (mcierr) + { + mciGetErrorStringA(mcierr, errorText, 1024); + MessageBoxA(DSAWIN_GetMainWindowHandle_c(), errorText, "MCI-Error", MB_OK); + UnregisterClassA(AVI_windowClass, DSAWIN_GetInstance_c()); + return 0; + } + w_avi_device_id = mciOpenParams.wDeviceID; +#endif + + DSA_GetScreenExtends_c(&AVI_desktopWidth, &AVI_desktopHeight); + } + + AVI_initialized++; + return 1; +} + +void AVI_Exit_c(void) +{ +#if !defined(USE_QUICKTIMELIB) + MCI_CLOSE_PARMS mciCloseParams; +#endif + int index; + + AVI_initialized--; + if (AVI_initialized > 0) + { + return; + } + + for (index = 0; index < 5; index++) + { + // change: fixed error + //AVI_videos[index] == NULL; + AVI_videos[index] = NULL; + } + +#if defined(USE_QUICKTIMELIB) + lqt_registry_destroy(); +#else + mciCloseParams.dwCallback = 0; + mciSendCommandA(w_avi_device_id, MCI_CLOSE, MCI_WAIT, (uintptr_t)&mciCloseParams); +#endif + + UnregisterClassA(AVI_windowClass, DSAWIN_GetInstance_c()); +} + +void AVI_SetDestortionLevel_c(int destortionLevel) +{ + AVI_destortionLevel = destortionLevel; +} + +void AVI_SystemTask_c(void) +{ + int isApplicationActive, index; + + isApplicationActive = SYSTEM_IsApplicationActive_c(); + + // change: removed unneeded + //if (isApplicationActive || !AVI_wasApplicationActive) + { + // change: removed unneeded + //if (isApplicationActive || AVI_wasApplicationActive) + { + if (isApplicationActive && !AVI_wasApplicationActive) + { + for (index = 0; index < 5; index++) + { + if (AVI_videos[index] != NULL) + { + ShowWindow(AVI_videos[index]->hWnd, SW_HIDE); + } + } + } + } + } + + AVI_wasApplicationActive = isApplicationActive; +} + +void *AVI_OpenVideo_c(const char *path, const uint8_t *param2) +{ +#if !defined(USE_QUICKTIMELIB) + MCIERROR mcierr; + MCI_SET_PARMS mciSetParams; + MCI_STATUS_PARMS mciStatusParams; + MCI_OPEN_PARMS mciOpenParams; + MCI_CLOSE_PARMS mciCloseParams; + HPALETTE hAviPalette; +#endif + int index2; + int video_index; + int palette_index; + AVI_Video *video; + unsigned int os; + int index; + char tempText[100]; + PALETTEENTRY dsaPalEntries[256]; + PALETTEENTRY aviPalEntries[256]; + + if (!SYSTEM_IsApplicationActive_c()) + { + return (void *)(intptr_t)-1; + } + + os = SYSTEM_GetOS_c(); + + for (video_index = 0; video_index < 5; video_index++) + { + if (AVI_videos[video_index] == NULL) + { + break; + } + } + + if (video_index == 5) + { + DBG_Panic_c("C:\\DATA\\BBLIB\\SRC\\BASE\\AVI.c", 1082); + return NULL; + } + + video = (AVI_Video *)MEM_malloc_c(sizeof(AVI_Video), "C:\\DATA\\BBLIB\\SRC\\BASE\\AVI.c", "AVI-STRUCTURE", 1089, 1); + if (video == NULL) + { + DBG_Panic_c("C:\\DATA\\BBLIB\\SRC\\BASE\\AVI.c", 1092); + return NULL; + } + + video->hWnd = CreateWindowExA( + 0, + AVI_windowClass, + AVI_windowClass, + WS_POPUP, + 0, + 0, + 320, + 240, + DSAWIN_GetMainWindowHandle_c(), + NULL, + DSAWIN_GetInstance_c(), + 0 + ); + if (video->hWnd == NULL) + { + UnregisterClassA(AVI_windowClass, DSAWIN_GetInstance_c()); + return NULL; + } + + strcpy(video->alias, "bbvideo"); + wsprintfA(tempText, "%d", SYSTEM_GetTicks_c()); + strcat(video->alias, tempText); + if (AVI_destortionLevel >= 1) + { + DSA_FreeStaticColors_c(0xFFFFFFFF); + } + +#if defined(USE_QUICKTIMELIB) + if (open_video(path, video)) + { + MessageBoxA(DSAWIN_GetMainWindowHandle_c(), "Error opening video file", "MCI-Error OPEN", MB_OK); + SendMessageA(video->hWnd, WM_CLOSE, 0, 0); + if (AVI_destortionLevel >= 1) + { + DSA_ReuseStaticColors_c(0xFFFFFFFF); + } + return NULL; + } + + if (read_palette(path, video)) + { + close_video(video); + SendMessageA(video->hWnd, WM_CLOSE, 0, 0); + if (AVI_destortionLevel >= 1) + { + DSA_ReuseStaticColors_c(0xFFFFFFFF); + } + return NULL; + } + + for (index = 0; index < 256; index++) + { + aviPalEntries[index].peRed = video->video_palette[index].rgbRed; + aviPalEntries[index].peGreen = video->video_palette[index].rgbGreen; + aviPalEntries[index].peBlue = video->video_palette[index].rgbBlue; + aviPalEntries[index].peFlags = 0; + } +#else + // open video + mciOpenParams.dwCallback = (uintptr_t)video->hWnd; + mciOpenParams.lpstrElementName = path; + mciOpenParams.lpstrAlias = video->alias; + mcierr = mciSendCommandA(w_avi_device_id, MCI_OPEN, MCI_OPEN_ALIAS | MCI_OPEN_ELEMENT, (uintptr_t)&mciOpenParams); + if (mcierr) + { + mciGetErrorStringA(mcierr, tempText, 100); + MessageBoxA(DSAWIN_GetMainWindowHandle_c(), tempText, "MCI-Error OPEN", MB_OK); + SendMessageA(video->hWnd, WM_CLOSE, 0, 0); + if (AVI_destortionLevel >= 1) + { + DSA_ReuseStaticColors_c(0xFFFFFFFF); + } + return NULL; + } + + video->wDeviceID = mciOpenParams.wDeviceID; + + // get video palette handle + mciStatusParams.dwCallback = (uintptr_t)video->hWnd; + mciStatusParams.dwItem = MCI_DGV_STATUS_HPAL; + mcierr = mciSendCommandA(video->wDeviceID, MCI_STATUS, MCI_STATUS_ITEM, (uintptr_t)&mciStatusParams); + if (mcierr) + { + mciGetErrorStringA(mcierr, tempText, 100); + mciCloseParams.dwCallback = (uintptr_t)video->hWnd; + mciSendCommandA(video->wDeviceID, MCI_CLOSE, MCI_WAIT, (uintptr_t)&mciCloseParams); + SendMessageA(video->hWnd, WM_CLOSE, 0, 0); + if (AVI_destortionLevel >= 1) + { + DSA_ReuseStaticColors_c(0xFFFFFFFF); + } + return NULL; + } + + hAviPalette = (HPALETTE)mciStatusParams.dwReturn; + + GetPaletteEntries(hAviPalette, 0, 256, aviPalEntries); +#endif + + GetPaletteEntries(DSA_hPalette, 0, 256, dsaPalEntries); + + for (index = 0; index < 256; index++) + { + if (aviPalEntries[index].peRed > 254) + { + aviPalEntries[index].peRed = 254; + } + if (aviPalEntries[index].peRed == 0) + { + aviPalEntries[index].peRed = 1; + } + if (aviPalEntries[index].peGreen > 254) + { + aviPalEntries[index].peGreen = 254; + } + if (aviPalEntries[index].peGreen == 0) + { + aviPalEntries[index].peGreen = 1; + } + if (aviPalEntries[index].peBlue > 254) + { + aviPalEntries[index].peBlue = 254; + } + if (aviPalEntries[index].peBlue == 0) + { + aviPalEntries[index].peBlue = 1; + } + } + + for (index = 0; index < 256; index++) + { + if (param2[index] == 1) + { + video->palette2.palPalEntry[index].peRed = dsaPalEntries[index].peRed; + video->palette2.palPalEntry[index].peGreen = dsaPalEntries[index].peGreen; + video->palette2.palPalEntry[index].peBlue = dsaPalEntries[index].peBlue; + } + else + { + video->palette2.palPalEntry[index].peRed = aviPalEntries[index].peRed; + video->palette2.palPalEntry[index].peGreen = aviPalEntries[index].peGreen; + video->palette2.palPalEntry[index].peBlue = aviPalEntries[index].peBlue; + } + video->palette1.palPalEntry[index].peRed = dsaPalEntries[index].peRed; + video->palette1.palPalEntry[index].peGreen = dsaPalEntries[index].peGreen; + video->palette1.palPalEntry[index].peBlue = dsaPalEntries[index].peBlue; + } + + palette_index = 10; + for (index2 = 0; index2 < 10; index2++) + { + if (param2[index2] == 1) + { + while (( palette_index < 246) && (param2[palette_index] == 1)) + { + palette_index++; + } + + if (palette_index < 246) + { + if (os == 4) + { + if (dsaPalEntries[index2].peRed >= 254) + { + video->palette2.palPalEntry[palette_index].peRed = dsaPalEntries[index2].peRed - 1; + } + else + { + video->palette2.palPalEntry[palette_index].peRed = dsaPalEntries[index2].peRed + 1; + } + } + else + { + video->palette2.palPalEntry[palette_index].peRed = dsaPalEntries[index2].peRed; + } + video->palette2.palPalEntry[palette_index].peGreen = dsaPalEntries[index2].peGreen; + video->palette2.palPalEntry[palette_index].peBlue = dsaPalEntries[index2].peBlue; + palette_index++; + } + } + } + + palette_index = 244; + for (index2 = 255; index2 > 244; index2--) + { + if (param2[index2] == 1) + { + while ((palette_index > 10) && (param2[palette_index] == 1)) + { + palette_index--; + } + + if (palette_index > 10) + { + if (os == 4) + { + if (dsaPalEntries[index2].peRed >= 254) + { + video->palette2.palPalEntry[palette_index].peRed = dsaPalEntries[index2].peRed - 1; + } + else + { + video->palette2.palPalEntry[palette_index].peRed = dsaPalEntries[index2].peRed + 1; + } + } + else + { + video->palette2.palPalEntry[palette_index].peRed = dsaPalEntries[index2].peRed; + } + video->palette2.palPalEntry[palette_index].peGreen = dsaPalEntries[index2].peGreen; + video->palette2.palPalEntry[palette_index--].peBlue = dsaPalEntries[index2].peBlue; + } + } + } + + video->palette1.palNumEntries = 256; + video->palette1.palVersion = 1; + video->palette2.palNumEntries = 256; + video->palette2.palVersion = 1; + +#if !defined(USE_QUICKTIMELIB) + // use frames for timing + mciSetParams.dwCallback = 0; + mciSetParams.dwTimeFormat = MCI_FORMAT_FRAMES; + mcierr = mciSendCommandA(video->wDeviceID, MCI_SET, MCI_SET_TIME_FORMAT, (uintptr_t)&mciSetParams); + if (mcierr) + { + mciGetErrorStringA(mcierr, tempText, 100); + MessageBoxA(DSAWIN_GetMainWindowHandle_c(), tempText, "MCI-Error SETTIMEBASE", MB_OK); + mciCloseParams.dwCallback = 0; + mciSendCommandA(video->wDeviceID, MCI_CLOSE, MCI_WAIT, (uintptr_t)&mciCloseParams); + SendMessageA(video->hWnd, WM_CLOSE, 0, 0); + if (AVI_destortionLevel >= 1) + { + DSA_ReuseStaticColors_c(0xFFFFFFFF); + } + return NULL; + } + + // seek to keyframes (don't seek exactly) + mciSetParams.dwCallback = 0; + mcierr = mciSendCommandA(video->wDeviceID, MCI_SET, MCI_DGV_SET_SEEK_EXACTLY | MCI_SET_OFF, (uintptr_t)&mciSetParams); + if (mcierr) + { + mciGetErrorStringA(mcierr, tempText, 100); + MessageBoxA(DSAWIN_GetMainWindowHandle_c(), tempText, "MCI-Error SETTIMEBASE", MB_OK); + mciCloseParams.dwCallback = 0; + mciSendCommandA(video->wDeviceID, MCI_CLOSE, MCI_WAIT, (uintptr_t)&mciCloseParams); + SendMessageA(video->hWnd, WM_CLOSE, 0, 0); + if (AVI_destortionLevel >= 1) + { + DSA_ReuseStaticColors_c(0xFFFFFFFF); + } + return NULL; + } +#endif + + AVI_videos[video_index] = video; + AVI_numVideos++; + return video; +} + +void AVI_CloseVideo_c(void *video) +{ +#if !defined(USE_QUICKTIMELIB) + MCI_CLOSE_PARMS mciCloseParams; +#endif + AVI_Video *video2; + int index; + + if (video == NULL) + { + return; + } + + video2 = (AVI_Video *)video; + for (index = 0; index < 5; index++) + { + if (AVI_videos[index] == video2) + { + AVI_videos[index] = NULL; + break; + } + } + +#if defined(USE_QUICKTIMELIB) + close_video(video2); +#else + // close video + mciCloseParams.dwCallback = (uintptr_t)video2->hWnd; + mciSendCommandA(video2->wDeviceID, MCI_CLOSE, MCI_WAIT, (uintptr_t)&mciCloseParams); +#endif + + SendMessageA(video2->hWnd, WM_CLOSE, 0, 0); + DSA_ReuseStaticColors_c(1); + MEM_free_c(video); + AVI_numVideos--; +} + +int AVI_PlayVideo_c(void *video, int x, int y, int param4, int param5, int volume, unsigned int flags) +{ +#if defined(USE_QUICKTIMELIB) + struct { + BITMAPINFOHEADER bmiHeader; + RGBQUAD bmiColors[256]; + } bmi; + HDC hAviDC; + HBITMAP hAviFrame; + HGDIOBJ hAviSelected; + void *pAviData; + uint8_t** rows; + DSA_Palette *video_palette; + uint8_t *buffer; + int rowspan, index, diff_time, blit_mode, old_blt_mode, buffer_alloc, buffer_length; + unsigned int last_frame, next_frame, first_frame; + int64_t next_frame_time, frame_num; + int audio_buffer_size, audio_temp_buffer_samples, audio_eof, current_header, samples_available; + uint8_t *audio_buffer; + int16_t *audio_temp_buffer[2]; + int64_t last_position; + HWAVEOUT hWaveOut; + WAVEFORMATEX waveFormat; + WAVEHDR waveHeader[16]; +#else + MCI_GENERIC_PARMS mciStopParams; + MCI_PLAY_PARMS mciPlayParams; + MCI_DGV_WINDOW_PARMS mciWindowParams; + unsigned int mciPlayFlags; + MCIERROR mcierr; + MCI_DGV_PUT_PARMS mciPutParams; + MCI_STATUS_PARMS mciStatusParams; + MCI_DGV_WHERE_PARMS mciWhereParams; + char tempText[1024]; +#endif + BLEV_Event event; + int returnValue; + int width; + int height; + HDC hDC; + HPALETTE hPrevPal; + AVI_Video *video2; + int volume2; + + returnValue = 0; + if (!SYSTEM_IsApplicationActive_c()) + { + return 0; + } + + if (video == NULL) + { + return 0; + } + + video2 = (AVI_Video *)video; + FX_ReserveDevices_c(0); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + + if ((SYSTEM_GetOS_c() == 1) && (flags & 2)) + { + flags = (flags & 0xFFFFFFFD) | 4; + } + + if (!(flags & 0x40000000)) + { + DSA_SetPal_c(0, &(video2->palette2), 0, 256, 0); + DSA_ActivatePal_c(); + } + + hDC = GetDC(video2->hWnd); + hPrevPal = SelectPalette(hDC, (HPALETTE)DSA_hPalette, FALSE); + if (hPrevPal == NULL) + { + DSA_ReuseStaticColors_c(1); + FX_ReserveDevices_c(1); + return 0; + } + RealizePalette(hDC); + SelectPalette(hDC, hPrevPal, FALSE); + ReleaseDC(video2->hWnd, hDC); + +#if defined(USE_QUICKTIMELIB) + hAviDC = NULL; + hAviFrame = NULL; + rows = NULL; + buffer = NULL; + buffer_alloc = 0; + if (video2->play_video) + { + bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bmi.bmiHeader.biWidth = video2->video_width; + bmi.bmiHeader.biHeight = (video2->read_compressed_video)?video2->video_height:-video2->video_height; + bmi.bmiHeader.biPlanes = 1; + bmi.bmiHeader.biBitCount = (video2->read_compressed_video)?8:((video2->colormodel == BC_BGR888)?24:32); + bmi.bmiHeader.biCompression = BI_RGB; + bmi.bmiHeader.biSizeImage = 0; + bmi.bmiHeader.biXPelsPerMeter = 0; + bmi.bmiHeader.biYPelsPerMeter = 0; + bmi.bmiHeader.biClrUsed = (video2->read_compressed_video)?video2->palette_colors:256; + bmi.bmiHeader.biClrImportant = 0; + + if (video2->read_compressed_video) + { + for (index = 0; index < 256; index++) + { + bmi.bmiColors[index] = video2->video_palette[index]; + } + } + else + { + video_palette = (flags & 0x40000000)?(&(video2->palette1)):(&(video2->palette2)); + for (index = 0; index < 256; index++) + { + bmi.bmiColors[index].rgbBlue = video_palette->palPalEntry[index].peBlue; + bmi.bmiColors[index].rgbGreen = video_palette->palPalEntry[index].peGreen; + bmi.bmiColors[index].rgbRed = video_palette->palPalEntry[index].peRed; + bmi.bmiColors[index].rgbReserved = 0; + } + } + + pAviData = NULL; + rows = (uint8_t **) HeapAlloc(GetProcessHeap(), 0, video2->video_height * sizeof(uint8_t*)); + if (rows != NULL) + { + hAviDC = CreateCompatibleDC(NULL); + if (hAviDC != NULL) + { + hAviFrame = CreateDIBSection(hAviDC, (const BITMAPINFO *)&bmi, DIB_RGB_COLORS, &pAviData, NULL, 0); + if (hAviFrame != NULL) + { + hAviSelected = SelectObject(hAviDC, hAviFrame); + if (hAviSelected == NULL) + { + DeleteObject(hAviFrame); + DeleteDC(hAviDC); + pAviData = NULL; + } + } + else + { + DeleteDC(hAviDC); + pAviData = NULL; + } + } + } + + if (pAviData == NULL) + { + if (rows != NULL) + { + HeapFree(GetProcessHeap(), 0, rows); + } + MessageBoxA(DSAWIN_GetMainWindowHandle_c(), "Error creating bitmap", "MCI-Error SETVIDEO", MB_OK); + FX_ReserveDevices_c(1); + DSA_ReuseStaticColors_c(1); + DSA_SetPal_c(0, &(video2->palette1), 0, 256, 0); + DSA_ActivatePal_c(); + DSA_TotalRepaint_c(); + return 0; + } + + rowspan = ((video2->video_width * bmi.bmiHeader.biBitCount + 31) & ~31) >> 3; + + rows[0] = (uint8_t *)pAviData; + for (index = 1; index < video2->video_height; index++) + { + rows[index] = rows[0] + index * rowspan; + } + + if (!video2->read_compressed_video) + { + lqt_set_row_span(video2->qt, 0, rowspan); + } + } + + audio_temp_buffer_samples = 0; + audio_buffer = NULL; + audio_temp_buffer[0] = NULL; + hWaveOut = NULL; + if (video2->play_audio) + { + audio_temp_buffer_samples = (video2->audio_sample_rate < 8000)?1024:(1024 * (video2->audio_sample_rate / 11025)); + audio_buffer_size = 16 * audio_temp_buffer_samples * video2->audio_format_size * video2->audio_channels; + + audio_buffer = (uint8_t *) HeapAlloc(GetProcessHeap(), 0, audio_buffer_size); + if (audio_buffer != NULL) + { + if ((video2->audio_channels > 1) && !video2->decode_raw_audio) + { + audio_temp_buffer[0] = (int16_t *) HeapAlloc(GetProcessHeap(), 0, video2->audio_channels * audio_temp_buffer_samples * sizeof(int16_t)); + if (audio_temp_buffer[0] == NULL) + { + HeapFree(GetProcessHeap(), 0, audio_buffer); + audio_buffer = NULL; + + } + else + { + audio_temp_buffer[1] = audio_temp_buffer[0] + audio_temp_buffer_samples; + } + } + } + + if (audio_buffer != NULL) + { + // initialize waveout + waveFormat.wFormatTag = WAVE_FORMAT_PCM; + waveFormat.nChannels = video2->audio_channels; + waveFormat.nSamplesPerSec = video2->audio_sample_rate; + waveFormat.nAvgBytesPerSec = video2->audio_channels * video2->audio_format_size * video2->audio_sample_rate; + waveFormat.nBlockAlign = video2->audio_channels * video2->audio_format_size; + waveFormat.wBitsPerSample = video2->audio_format_size * 8; + waveFormat.cbSize = 0; + + if (MMSYSERR_NOERROR != waveOutOpen(&hWaveOut, WAVE_MAPPER, &waveFormat, 0, 0, WAVE_ALLOWSYNC)) + { + hWaveOut = NULL; + } + else + { + for (index = 0; index < 16; index++) + { + waveHeader[index].dwBufferLength = audio_temp_buffer_samples * video2->audio_format_size * video2->audio_channels; + waveHeader[index].lpData = (LPSTR)(audio_buffer + index * waveHeader[index].dwBufferLength); + waveHeader[index].dwFlags = 0; + + if (MMSYSERR_NOERROR != waveOutPrepareHeader(hWaveOut, &(waveHeader[index]), sizeof(WAVEHDR))) + { + for (index--; index >= 0; index--) + { + waveOutUnprepareHeader(hWaveOut, &(waveHeader[index]), sizeof(WAVEHDR)); + } + + waveOutClose(hWaveOut); + hWaveOut = NULL; + break; + } + + waveHeader[index].dwFlags |= WHDR_DONE; + } + } + } + } +#else + wsprintfA(tempText, "setvideo %s palette handle to %d", video2->alias, DSA_hPalette); + mcierr = mciSendStringA(tempText, NULL, 0, NULL); + if (mcierr) + { + mciGetErrorStringA(mcierr, tempText, 1024); + MessageBoxA(DSAWIN_GetMainWindowHandle_c(), tempText, "MCI-Error SETVIDEO", MB_OK); + FX_ReserveDevices_c(1); + DSA_ReuseStaticColors_c(1); + DSA_SetPal_c(0, &(video2->palette1), 0, 256, 0); + DSA_ActivatePal_c(); + DSA_TotalRepaint_c(); + return 0; + } +#endif + + if (volume > 0) + { +#if defined(USE_QUICKTIMELIB) + if (hWaveOut != NULL) + { + volume2 = volume; + if (volume2 >= 65536) + { + volume2 = 65535; + } + if (MMSYSERR_NOERROR != waveOutSetVolume(hWaveOut, volume2 | ((uint32_t)volume2 << 16))) + { + MessageBoxA(DSAWIN_GetMainWindowHandle_c(), "Error setting volume", "MCI-Error SETVIDEO", MB_OK); + } + } +#else + volume2 = volume / 64; + if (volume2 >= 1000) + { + volume2 = 999; + } + wsprintfA(tempText, "setaudio %s volume to %d", video2->alias, volume2); + mcierr = mciSendStringA(tempText, NULL, 0, NULL); + if (mcierr) + { + mciGetErrorStringA(mcierr, tempText, 1024); + MessageBoxA(DSAWIN_GetMainWindowHandle_c(), tempText, "MCI-Error SETVIDEO", MB_OK); + } +#endif + } + +#if defined(USE_QUICKTIMELIB) + width = video2->video_width; + height = video2->video_height; +#else + mciWhereParams.dwCallback = (uintptr_t)video2->hWnd; + SetRectEmpty(&(mciWhereParams.rc)); + mcierr = mciSendCommandA(video2->wDeviceID, MCI_WHERE, MCI_OVLY_WHERE_DESTINATION, (uintptr_t)&mciWhereParams); + if (mcierr) + { + mciGetErrorStringA(mcierr, tempText, 1024); + MessageBoxA(DSAWIN_GetMainWindowHandle_c(), tempText, "MCI-Error WHERE", MB_OK); + ShowWindow(video2->hWnd, SW_HIDE); + FX_ReserveDevices_c(1); + DSA_ReuseStaticColors_c(1); + DSA_SetPal_c(0, &(video2->palette1), 0, 256, 0); + DSA_ActivatePal_c(); + DSA_TotalRepaint_c(); + return 0; + } + + width = mciWhereParams.rc.right - mciWhereParams.rc.left; + height = mciWhereParams.rc.bottom - mciWhereParams.rc.top; +#endif + + if ((width > 320) && (flags & 2)) + { + flags = (flags & 0xFFFFFFFD) | 4; + } + + switch (flags & 7) + { + case 1: + if (x < 0) + { + x = ((unsigned int)(AVI_desktopWidth - width)) >> 1; + } + if (y < 0) + { + y = ((unsigned int)(AVI_desktopHeight - height)) >> 1; + } + + MoveWindow( + video2->hWnd, + x, + y, + width, + height, + FALSE + ); + +#if defined(USE_QUICKTIMELIB) + blit_mode = 0; +#else + mciWindowParams.dwCallback = (uintptr_t)video2->hWnd; + mciWindowParams.hWnd = video2->hWnd; + mcierr = mciSendCommandA(video2->wDeviceID, MCI_WINDOW, MCI_DGV_WINDOW_HWND | MCI_WAIT, (uintptr_t)&mciWindowParams); + if (mcierr) + { + mciGetErrorStringA(mcierr, tempText, 1024); + MessageBoxA(DSAWIN_GetMainWindowHandle_c(), tempText, "MCI-Error WINDOW", MB_OK); + ShowWindow(video2->hWnd, SW_HIDE); + FX_ReserveDevices_c(1); + DSA_ReuseStaticColors_c(1); + DSA_SetPal_c(0, &(video2->palette1), 0, 256, 0); + MoveWindow(video2->hWnd, AVI_desktopWidth, AVI_desktopHeight, 100, 100, FALSE); + DSA_ActivatePal_c(); + DSA_TotalRepaint_c(); + return 0; + } + + mciPlayFlags = 0; +#endif + + break; + + case 2: + MoveWindow(video2->hWnd, 0, 0, 100, 100, FALSE); +#if defined(USE_QUICKTIMELIB) + blit_mode = 2; +#else + mciPlayFlags = MCI_MCIAVI_PLAY_FULLSCREEN; +#endif + break; + + case 4: + width = (AVI_desktopWidth <= 1024)?AVI_desktopWidth:1024; + height = (AVI_desktopHeight <= 768)?AVI_desktopHeight:768; + + MoveWindow( + video2->hWnd, + ((unsigned int)(AVI_desktopWidth - width)) >> 1, + AVI_desktopHeight - height, + width, + height, + FALSE + ); + +#if defined(USE_QUICKTIMELIB) + blit_mode = 1; +#else + mciPutParams.dwCallback = (uintptr_t)video2->hWnd; + mciPutParams.rc.left = 0; + mciPutParams.rc.top = 0; + mciPutParams.rc.right = width; + mciPutParams.rc.bottom = height; + mcierr = mciSendCommandA(video2->wDeviceID, MCI_PUT, MCI_DGV_PUT_DESTINATION | MCI_DGV_RECT | MCI_WAIT, (uintptr_t)&mciPutParams); + if (mcierr) + { + mciGetErrorStringA(mcierr, tempText, 1024); + MessageBoxA(DSAWIN_GetMainWindowHandle_c(), tempText, "MCI-Error PUT Destination", MB_OK); + ShowWindow(video2->hWnd, SW_HIDE); + FX_ReserveDevices_c(1); + DSA_ReuseStaticColors_c(1); + DSA_SetPal_c(0, &(video2->palette1), 0, 256, 0); + DSA_ActivatePal_c(); + DSA_TotalRepaint_c(); + MoveWindow(video2->hWnd, AVI_desktopWidth, AVI_desktopHeight, 100, 100, FALSE); + return 0; + } + + mciPutParams.dwCallback = (uintptr_t)video2->hWnd; + mciPutParams.rc = mciWhereParams.rc; + mcierr = mciSendCommandA(video2->wDeviceID, MCI_PUT, MCI_DGV_PUT_SOURCE | MCI_DGV_RECT | MCI_WAIT, (uintptr_t)&mciPutParams); + if (mcierr) + { + mciGetErrorStringA(mcierr, tempText, 1024); + MessageBoxA(DSAWIN_GetMainWindowHandle_c(), tempText, "MCI-Error PUT SOURCE", MB_OK); + ShowWindow(video2->hWnd, SW_HIDE); + FX_ReserveDevices_c(1); + DSA_ReuseStaticColors_c(1); + DSA_SetPal_c(0, &(video2->palette1), 0, 256, 0); + DSA_ActivatePal_c(); + DSA_TotalRepaint_c(); + MoveWindow(video2->hWnd, AVI_desktopWidth, AVI_desktopHeight, 100, 100, FALSE); + return 0; + } + + mciWindowParams.dwCallback = (uintptr_t)video2->hWnd; + mciWindowParams.hWnd = video2->hWnd; + mcierr = mciSendCommandA(video2->wDeviceID, MCI_WINDOW, MCI_DGV_WINDOW_HWND | MCI_WAIT, (uintptr_t)&mciWindowParams); + if (mcierr) + { + mciGetErrorStringA(mcierr, tempText, 1024); + MessageBoxA(DSAWIN_GetMainWindowHandle_c(), tempText, "MCI-Error WINDOW", MB_OK); + ShowWindow(video2->hWnd, SW_HIDE); + FX_ReserveDevices_c(1); + DSA_ReuseStaticColors_c(1); + DSA_SetPal_c(0, &(video2->palette1), 0, 256, 0); + DSA_ActivatePal_c(); + DSA_TotalRepaint_c(); + MoveWindow(video2->hWnd, AVI_desktopWidth, AVI_desktopHeight, 100, 100, FALSE); + return 0; + } + + mciPlayFlags = 0; +#endif + + break; + + default: +#if defined(USE_QUICKTIMELIB) + blit_mode = 0; +#else + mciPlayFlags = 0; +#endif + break; + } + +#if defined(USE_QUICKTIMELIB) + if (video2->play_video && !video2->read_compressed_video) + { + lqt_seek_video(video2->qt, 0, 0); + } + if (hWaveOut != NULL) + { + quicktime_set_audio_position(video2->qt, 0, 0); + } +#else + mciStatusParams.dwCallback = 0; + mciStatusParams.dwItem = MCI_STATUS_POSITION; + mciStatusParams.dwTrack = 1; + mcierr = mciSendCommandA(video2->wDeviceID, MCI_STATUS, MCI_STATUS_ITEM, (uintptr_t)&mciStatusParams); + if (mcierr) + { + mciStatusParams.dwReturn = -1; + } + + mciPlayParams.dwCallback = (uintptr_t)video2->hWnd; +#endif + + AVI_playbackFinished = 0; + AVI_stopPlayback = 0; + AVI_cancelPlayback = 0; + ShowWindow(video2->hWnd, SW_SHOWNORMAL); + +#if defined(USE_QUICKTIMELIB) + // decode first frame + if (video2->play_video) + { + frame_num = 0; + + if (video2->read_compressed_video) + { + buffer_length = lqt_read_video_frame(video2->qt, &buffer, &buffer_alloc, frame_num, &next_frame_time, 0); + if (0 == buffer_length) + { + AVI_playbackFinished = 1; + } + else + { + decode_rle8(buffer, buffer_length, video2->video_width, video2->video_height, rows); + } + } + else + { + if (lqt_decode_video(video2->qt, rows, 0)) + { + AVI_playbackFinished = 1; + } + } + } + audio_eof = ((hWaveOut != NULL) && !AVI_playbackFinished)?0:1; + current_header = 0; + + first_frame = GetTickCount(); + next_frame = first_frame; + last_frame = first_frame + (int)((((double)video2->video_duration) / video2->video_time_scale) * 1000); + + while (!AVI_playbackFinished) + { + diff_time = GetTickCount() - last_frame; + if (diff_time >= 0) + { + AVI_playbackFinished = 1; + break; + } + + if (!audio_eof) + { + if (waveHeader[current_header].dwFlags & WHDR_DONE) + { + samples_available = audio_temp_buffer_samples; + + last_position = lqt_last_audio_position(video2->qt, 0); + + if (samples_available >= video2->audio_length - last_position) + { + samples_available = video2->audio_length - last_position; + audio_eof = 1; + } + + if (video2->decode_raw_audio) + { + samples_available = lqt_decode_audio_raw(video2->qt, waveHeader[current_header].lpData, samples_available, 0); + } + else if (video2->audio_channels == 1) + { + audio_temp_buffer[1] = (int16_t *) waveHeader[current_header].lpData; + if (lqt_decode_audio_track(video2->qt, &(audio_temp_buffer[1]), NULL, samples_available, 0)) + { + samples_available = 0; + } + } + else + { + if (lqt_decode_audio_track(video2->qt, audio_temp_buffer, NULL, samples_available, 0)) + { + samples_available = 0; + } + else + { + for (index = 0; index < samples_available; index++) + { + ((int16_t *) waveHeader[current_header].lpData)[2 * index] = audio_temp_buffer[0][index]; + ((int16_t *) waveHeader[current_header].lpData)[2 * index + 1] = audio_temp_buffer[1][index]; + } + } + } + + if (samples_available == 0) + { + audio_eof = 1; + } + else + { + waveHeader[current_header].dwBufferLength = samples_available * video2->audio_format_size * video2->audio_channels; + waveHeader[current_header].dwFlags &= ~WHDR_DONE; + waveOutWrite(hWaveOut, &(waveHeader[current_header]), sizeof(WAVEHDR)); + current_header = (current_header + 1) & 15; + } + } + } + + if (video2->play_video) + { + diff_time = GetTickCount() - next_frame; + if (diff_time >= 0) + { + hDC = GetDC((blit_mode == 2)?NULL:video2->hWnd); + if (blit_mode) + { + old_blt_mode = SetStretchBltMode(hDC, COLORONCOLOR); + StretchBlt(hDC, 0, 0, (blit_mode == 2)?AVI_desktopWidth:width, (blit_mode == 2)?AVI_desktopHeight:height, + hAviDC, 0, 0, video2->video_width, video2->video_height, + SRCCOPY); + SetStretchBltMode(hDC, old_blt_mode); + } + else + { + BitBlt(hDC, 0, 0, video2->video_width, video2->video_height, hAviDC, 0, 0, SRCCOPY); + } + ReleaseDC(video2->hWnd, hDC); + + frame_num++; + + if (frame_num < video2->video_frames) + { + if (video2->read_compressed_video) + { + buffer_length = lqt_read_video_frame(video2->qt, &buffer, &buffer_alloc, frame_num, &next_frame_time, 0); + if (0 == buffer_length) + { + AVI_playbackFinished = 1; + } + else + { + next_frame = first_frame + (int)((((double)next_frame_time) / video2->video_time_scale) * 1000); + decode_rle8(buffer, buffer_length, video2->video_width, video2->video_height, rows); + } + } + else + { + next_frame_time = lqt_frame_time(video2->qt, 0); + next_frame = first_frame + (int)((((double)next_frame_time) / video2->video_time_scale) * 1000); + + if (lqt_decode_video(video2->qt, rows, 0)) + { + AVI_playbackFinished = 1; + } + } + } + else + { + frame_num = video2->video_frames; + next_frame = last_frame; + } + } + } + + if (flags & 2) + { + Sleep(1); + } + else + { + SYSTEM_SystemTask_c(); + + if (BLEV_GetEvent_c(&event)) + { + switch (event.type) + { + case BBBLEV_TYPE_KEYUP: + if (event.key != BBBLEV_KEY_ESCAPE) + { + break; + } + // @fallthrough@ + case BBBLEV_TYPE_MOUSELEFTUP: + case BBBLEV_TYPE_MOUSERIGHTUP: + AVI_playbackFinished = 1; + returnValue = 2; + break; + default: + break; + } + } + + if (AVI_stopPlayback) + { + AVI_playbackFinished = 1; + returnValue = 1; + } + + if (AVI_cancelPlayback) + { + AVI_playbackFinished = 1; + returnValue = 2; + } + + if ((!SYSTEM_IsApplicationActive_c()) || AVI_playbackFinished) + { + ShowWindow(video2->hWnd, SW_HIDE); + MoveWindow(video2->hWnd, AVI_desktopWidth, AVI_desktopHeight, 100, 100, FALSE); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + AVI_playbackFinished = 1; + if (!SYSTEM_IsApplicationActive_c()) + { + returnValue = 2; + } + } + } + } + + if (hWaveOut != NULL) + { + waveOutReset(hWaveOut); + for (index = 15; index >= 0; index--) + { + waveOutUnprepareHeader(hWaveOut, &(waveHeader[index]), sizeof(WAVEHDR)); + } + waveOutClose(hWaveOut); + } + if (audio_temp_buffer[0] != NULL) + { + HeapFree(GetProcessHeap(), 0, audio_temp_buffer[0]); + } + if (audio_buffer != NULL) + { + HeapFree(GetProcessHeap(), 0, audio_buffer); + } + + if (buffer != NULL) + { + free(buffer); + } + if (hAviFrame != NULL) + { + SelectObject(hAviDC, hAviFrame); + DeleteObject(hAviFrame); + DeleteDC(hAviDC); + HeapFree(GetProcessHeap(), 0, rows); + } +#else + if (flags & 2) + { + mcierr = mciSendCommandA(video2->wDeviceID, MCI_PLAY, mciPlayFlags | MCI_WAIT, (uintptr_t)&mciPlayParams); + if (mcierr) + { + mciGetErrorStringA(mcierr, tempText, 1024); + MessageBoxA(DSAWIN_GetMainWindowHandle_c(), tempText, "MCI-Error PLAY", MB_OK); + ShowWindow(video2->hWnd, SW_HIDE); + FX_ReserveDevices_c(1); + DSA_ReuseStaticColors_c(1); + DSA_SetPal_c(0, &(video2->palette1), 0, 256, 0); + DSA_ActivatePal_c(); + DSA_TotalRepaint_c(); + MoveWindow(video2->hWnd, AVI_desktopWidth, AVI_desktopHeight, 100, 100, FALSE); + return 0; + } + } + else + { + mcierr = mciSendCommandA(video2->wDeviceID, MCI_PLAY, mciPlayFlags | MCI_NOTIFY, (uintptr_t)&mciPlayParams); + if (mcierr) + { + mciGetErrorStringA(mcierr, tempText, 1024); + MessageBoxA(DSAWIN_GetMainWindowHandle_c(), tempText, "MCI-Error PLAY", MB_OK); + ShowWindow(video2->hWnd, SW_HIDE); + FX_ReserveDevices_c(1); + DSA_ReuseStaticColors_c(1); + DSA_SetPal_c(0, &(video2->palette1), 0, 256, 0); + DSA_ActivatePal_c(); + DSA_TotalRepaint_c(); + MoveWindow(video2->hWnd, AVI_desktopWidth, AVI_desktopHeight, 100, 100, FALSE); + return 0; + } + + while ( 1 ) + { + if (AVI_playbackFinished) + { + break; + } + + SYSTEM_SystemTask_c(); + + if (BLEV_GetEvent_c(&event)) + { + switch (event.type) + { + case BBBLEV_TYPE_KEYUP: + if (event.key != BBBLEV_KEY_ESCAPE) + { + break; + } + // @fallthrough@ + case BBBLEV_TYPE_MOUSELEFTUP: + case BBBLEV_TYPE_MOUSERIGHTUP: + AVI_playbackFinished = 1; + returnValue = 2; + break; + default: + break; + } + } + + if (AVI_stopPlayback) + { + AVI_playbackFinished = 1; + returnValue = 1; + } + + if (AVI_cancelPlayback) + { + AVI_playbackFinished = 1; + returnValue = 2; + } + + if ((!SYSTEM_IsApplicationActive_c()) || AVI_playbackFinished) + { + mciStopParams.dwCallback = 0; + ShowWindow(video2->hWnd, SW_HIDE); + MoveWindow(video2->hWnd, AVI_desktopWidth, AVI_desktopHeight, 100, 100, FALSE); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + mcierr = mciSendCommandA(video2->wDeviceID, MCI_STOP, MCI_WAIT, (uintptr_t)&mciStopParams); + AVI_playbackFinished = 1; + if (!SYSTEM_IsApplicationActive_c()) + { + returnValue = 2; + } + } + } + } +#endif + + ShowWindow(video2->hWnd, SW_HIDE); + if ((AVI_numVideos == 1) && (AVI_destortionLevel >= 1)) + { + DSA_ReuseStaticColors_c(0xFFFFFFFF); + } + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + if ((!(flags & 0x80000000)) || (returnValue == 2)) + { + DSA_SetPal_c(0, &(video2->palette1), 0, 256, 0); + DSA_ActivatePal_c(); + DSA_TotalRepaint_c(); + } + FX_ReserveDevices_c(1); + return returnValue; +} + diff --git a/games/Battle Isle 3/SR-BI3/BBAVI.h b/games/Battle Isle 3/SR-BI3/BBAVI.h new file mode 100644 index 0000000..5d5a928 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBAVI.h @@ -0,0 +1,46 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_BBAVI_H_INCLUDED_) +#define _BBAVI_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int AVI_Init_c(void); +void AVI_Exit_c(void); +void AVI_SetDestortionLevel_c(int destortionLevel); +void AVI_SystemTask_c(void); +void *AVI_OpenVideo_c(const char *path, const uint8_t *param2); +void AVI_CloseVideo_c(void *video); +int AVI_PlayVideo_c(void *video, int x, int y, int param4, int param5, int volume, unsigned int flags); + +#ifdef __cplusplus +} +#endif + +#endif /* _BBAVI_H_INCLUDED_ */ diff --git a/games/Battle Isle 3/SR-BI3/BBBLEV.c b/games/Battle Isle 3/SR-BI3/BBBLEV.c new file mode 100644 index 0000000..861786f --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBBLEV.c @@ -0,0 +1,132 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "BBBLEV.h" +#include "BBSYSTEM.h" +#include + + +static int BLEV_initialized = 0; +static BLEV_Event BLEV_events[32]; +static int BLEV_readIndex; +static int BLEV_state; +static int BLEV_writeIndex; + + +int BLEV_Init_c(void) +{ + if ( BLEV_initialized ) + { + return 1; + } + + BLEV_state = 0; + BLEV_readIndex = 0; + BLEV_writeIndex = 0; + + BLEV_initialized = 1; + + return 1; +} + +void BLEV_Exit_c(void) +{ + if (BLEV_initialized) + { + BLEV_initialized = 0; + } +} + +void BLEV_ClearAllEvents_c(void) +{ + int index; + + for (index = 0; index < 100; index++) + { + SYSTEM_SystemTask_c(); + BLEV_state = 0; + BLEV_readIndex = 0; + BLEV_writeIndex = 0; + } +} + +int BLEV_PutEvent_c(const BLEV_Event *event) +{ + if (BLEV_state == 2) + { + return 0; + } + + BLEV_events[BLEV_writeIndex] = *event; + + BLEV_writeIndex++; + if (BLEV_writeIndex == 32) + { + BLEV_writeIndex = 0; + } + + if (BLEV_writeIndex == BLEV_readIndex) + { + BLEV_state = 2; + } + else + { + BLEV_state = 1; + } + + return 1; +} + +int BLEV_GetEvent_c(BLEV_Event *event) +{ + if (BLEV_state == 0) + { + return 0; + } + + *event = BLEV_events[BLEV_readIndex]; + + BLEV_readIndex++; + if (BLEV_readIndex == 32) + { + BLEV_readIndex = 0; + } + + BLEV_state = (BLEV_writeIndex != BLEV_readIndex)?1:0; + + return 1; +} + +int BLEV_PeekEvent_c(BLEV_Event *event) +{ + if (BLEV_state == 0) + { + return 0; + } + + *event = BLEV_events[BLEV_readIndex]; + + return 1; +} + diff --git a/games/Battle Isle 3/SR-BI3/BBBLEV.h b/games/Battle Isle 3/SR-BI3/BBBLEV.h new file mode 100644 index 0000000..29bfd2c --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBBLEV.h @@ -0,0 +1,103 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_BBBLEV_H_INCLUDED_) +#define _BBBLEV_H_INCLUDED_ + +#include + +#define BBBLEV_TYPE_KEYDOWN 1 +#define BBBLEV_TYPE_KEYUP 2 +#define BBBLEV_TYPE_MOUSELEFTDOWN 4 +#define BBBLEV_TYPE_MOUSELEFTUP 8 +#define BBBLEV_TYPE_MOUSELEFTDOUBLECLICK 16 +#define BBBLEV_TYPE_MOUSERIGHTDOWN 32 +#define BBBLEV_TYPE_MOUSERIGHTUP 64 +#define BBBLEV_TYPE_MOUSERIGHTDOUBLECLICK 128 +#define BBBLEV_TYPE_MOUSEMOVE 256 + +#define BBBLEV_BUTTON_MOUSELEFT 1 +#define BBBLEV_BUTTON_MOUSERIGHT 2 +#define BBBLEV_BUTTON_SHIFT 8 +#define BBBLEV_BUTTON_CONTROL 0x10 +#define BBBLEV_BUTTON_ALT 0x20 + +#define BBBLEV_KEY_ESCAPE 0x100 +#define BBBLEV_KEY_F1 0x101 +#define BBBLEV_KEY_F2 0x102 +#define BBBLEV_KEY_F3 0x103 +#define BBBLEV_KEY_F4 0x104 +#define BBBLEV_KEY_F5 0x105 +#define BBBLEV_KEY_F6 0x106 +#define BBBLEV_KEY_F7 0x107 +#define BBBLEV_KEY_F8 0x108 +#define BBBLEV_KEY_F9 0x109 +#define BBBLEV_KEY_F10 0x10A +#define BBBLEV_KEY_F11 0x10B +#define BBBLEV_KEY_F12 0x10C +#define BBBLEV_KEY_TAB 0x10D +#define BBBLEV_KEY_INSERT 0x10E +#define BBBLEV_KEY_DELETE 0x10F +#define BBBLEV_KEY_BACKSPACE 0x110 +#define BBBLEV_KEY_HOME 0x111 +#define BBBLEV_KEY_END 0x112 +#define BBBLEV_KEY_PAGEUP 0x113 +#define BBBLEV_KEY_PAGEDOWN 0x114 +#define BBBLEV_KEY_LEFT 0x115 +#define BBBLEV_KEY_UP 0x116 +#define BBBLEV_KEY_RIGHT 0x117 +#define BBBLEV_KEY_DOWN 0x118 +#define BBBLEV_KEY_ENTER 0x119 + + +#pragma pack(1) + +typedef struct __attribute__ ((__packed__)) _BLEV_Event { + uint32_t type; + void *screen; + uint32_t buttonState; + int32_t key; + uint32_t x; + uint32_t y; +} BLEV_Event; + +#pragma pack() + + +#ifdef __cplusplus +extern "C" { +#endif + +int BLEV_Init_c(void); +void BLEV_Exit_c(void); +void BLEV_ClearAllEvents_c(void); +int BLEV_PutEvent_c(const BLEV_Event *event); +int BLEV_GetEvent_c(BLEV_Event *event); +int BLEV_PeekEvent_c(BLEV_Event *event); + +#ifdef __cplusplus +} +#endif + +#endif /* _BBBLEV_H_INCLUDED_ */ diff --git a/games/Battle Isle 3/SR-BI3/BBDBG.c b/games/Battle Isle 3/SR-BI3/BBDBG.c new file mode 100644 index 0000000..95ada93 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBDBG.c @@ -0,0 +1,426 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "BBDBG.h" +#include "BBDSA.h" +#include "BBMEM.h" +#include +#define WIN32_LEAN_AND_MEAN +#include + + +typedef struct { + const char *module_name; + const char *function_name; + uint8_t quiet_function; +} DBG_struct; + + +static int DBG_initialized = 0; +static int DBG_stackPos1 = -1; +static HANDLE DBG_hLogFile = INVALID_HANDLE_VALUE; +static int DBG_stackPos2 = -1; +static int DBG_newLine = 0; +static int DBG_level = 0; +static int DBG_writeToLogFile = 1; +static char DBG_printBuffer[300]; +static unsigned int DBG_logBufferPosition; +static char DBG_moduleName[104]; +static char DBG_logBuffer[104]; +static DBG_struct DBG_stack[128]; + + +static void DBG_Action(unsigned int type, const char *module_name, const char *function_name, int line, const char *msg); + +static int DBG_OpenLogFile_c(void) +{ + DBG_hLogFile = CreateFileA("LOGFILE.TXT", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (DBG_hLogFile != INVALID_HANDLE_VALUE) return 1; + + MessageBoxA((HWND)DSAWIN_GetMainWindowHandle_c(), "COULD NOT CREATE DEBUG-OUTPUTFILE ( 1 ). This is no severe Error and you may proceed normally.", "INFORMATION", MB_OK | MB_ICONINFORMATION); + return 0; +} + +static void DBG_WriteToLogFile_c(const char *str) +{ + unsigned int index; + DWORD NumberOfBytesWritten; + + if (DBG_level > 0) return; + + for (index = 0; str[index] != 0; index++) + { + DBG_logBuffer[DBG_logBufferPosition] = str[index]; + if ((DBG_logBufferPosition != 100) && (str[index] != '\n')) + { + DBG_logBufferPosition++; + } + else + { + if (DBG_hLogFile != INVALID_HANDLE_VALUE) + { + if ((DBG_logBuffer[DBG_logBufferPosition] == '\n') || (DBG_logBuffer[DBG_logBufferPosition] == '\r')) + { + DBG_logBuffer[DBG_logBufferPosition] = '\r'; + DBG_logBufferPosition++; + DBG_logBuffer[DBG_logBufferPosition] = '\n'; + } + DBG_logBuffer[DBG_logBufferPosition + 1] = 0; + WriteFile(DBG_hLogFile, DBG_logBuffer, DBG_logBufferPosition + 1, &NumberOfBytesWritten, NULL); + FlushFileBuffers(DBG_hLogFile); + } + + DBG_logBufferPosition = 0; + } + } +} + +static void DBG_CloseOutputFile_c(void) +{ + if (DBG_hLogFile != INVALID_HANDLE_VALUE) + { + CloseHandle(DBG_hLogFile); + DBG_hLogFile = INVALID_HANDLE_VALUE; + } +} + +void DBG_Panic_c(const char *module, int line) +{ + int closeLogFile; + + closeLogFile = 0; + sprintf(DBG_printBuffer, "A severe error has occured!\nPlease refere to your manual for further information.\nPlease write down the following information:\nMODULE: %s\nLINE:%d\n", module, line); + MessageBoxA((HWND)DSAWIN_GetMainWindowHandle_c(), DBG_printBuffer, "MAJOR ERROR", MB_OK); + + if (!DBG_writeToLogFile) + { + return; + } + + DBG_writeToLogFile = 0; + if (DBG_hLogFile == INVALID_HANDLE_VALUE) + { + if (!DBG_OpenLogFile_c()) + { + return; + } + closeLogFile = 1; + } + + MEM_Dump_c(DBG_hLogFile); + + if (DBG_hLogFile != INVALID_HANDLE_VALUE) + { + if (closeLogFile) + { + CloseHandle(DBG_hLogFile); + DBG_hLogFile = INVALID_HANDLE_VALUE; + } + } +} + +int DBG_Init_c(void) +{ + if (!DBG_initialized) + { + DBG_stackPos1 = -1; + DBG_stackPos2 = -1; + DBG_newLine = 0; + DBG_logBufferPosition = 0; + DBG_logBuffer[101] = 0; + DBG_level = 0; + } + DBG_initialized++; + DBG_Action(2, "BBSYSTEM", "MAIN", 0, "SYSTEMENTRY\n"); + return 1; +} + +void DBG_Exit_c(void) +{ + DBG_initialized--; + if (DBG_initialized == 0) + { + DBG_CloseOutputFile_c(); + } +} + +static void DBG_PrintString_c(unsigned int type, const char *msg, int line) +{ + if (type == 0x100) + { + DBG_WriteToLogFile_c("\n"); + DBG_newLine = 1; + return; + } + + DBG_moduleName[0] = 0; + + if ( DBG_stackPos2 != DBG_stackPos1 ) + { + if (DBG_stackPos1 >= 0) + { + if ((DBG_stackPos2 == -1) || 0 != strcmp(DBG_stack[DBG_stackPos2].module_name, DBG_stack[DBG_stackPos1].module_name)) + { + sprintf(DBG_moduleName, " %s ", DBG_stack[DBG_stackPos1].module_name); + } + } + + switch (type) + { + case 2: + if (DBG_moduleName[0] != 0) + { + sprintf( + DBG_printBuffer, + " >>> DOWN TO FUNCTION : %s IN MODULE : %s -----\n", + DBG_stack[DBG_stackPos1].function_name, + DBG_moduleName + ); + } + else + { + sprintf( + DBG_printBuffer, + " >>> DOWN TO FUNCTION : %s -----\n", + DBG_stack[DBG_stackPos1].function_name + ); + } + break; + + case 4: + if (DBG_moduleName[0] != 0) + { + sprintf( + DBG_printBuffer, + " <<< RETURN TO FUNCTION: %s IN MODULE : %s\n --- FROM LINE: %ld IN FUNCTION: %s -----\n", + DBG_stack[DBG_stackPos1].function_name, + DBG_moduleName, + (long int)line, + DBG_stack[DBG_stackPos1 + 1].function_name + ); + } + else + { + sprintf( + DBG_printBuffer, + " <<< RETURN TO FUNCTION: %s FROM LINE: %ld IN FUNCTION: %s -----\n", + DBG_stack[DBG_stackPos1].function_name, + (long int)line, + DBG_stack[DBG_stackPos1 + 1].function_name + ); + } + break; + + case 8: + sprintf( + DBG_printBuffer, + " ### ERROR !! ### RETURN TO FUNCTION: %s FROM LINE: %ld IN FUNCTION: %s -----\n", + DBG_stack[DBG_stackPos1].function_name, + (long int)line, + DBG_stack[DBG_stackPos1 + 1].function_name + ); + break; + + case 0x10: + sprintf(DBG_printBuffer, " --- LOOP - ENTRY \n"); + break; + + case 0x20: + sprintf(DBG_printBuffer, " --- LOOP - EXIT \n"); + break; + + case 0x40: + sprintf(DBG_printBuffer, " --- LOOP - BREAK \n"); + break; + + case 0x80: + sprintf(DBG_printBuffer, " --- BRANCH SWITCH\n"); + break; + + default: + DBG_printBuffer[0] = 0; + break; + } + + DBG_WriteToLogFile_c(DBG_printBuffer); + DBG_stackPos2 = DBG_stackPos1; + } + + if (DBG_newLine) + { + if (msg != NULL) + { + if ((DBG_stackPos1 != -1) && DBG_stack[DBG_stackPos1].quiet_function) + { + sprintf(DBG_printBuffer, " LINE : %06ld -- QUIETFUNCTION: %s -- MSG : ", (long int)line, DBG_stack[DBG_stackPos1].function_name); + } + else + { + sprintf(DBG_printBuffer, " LINE : %06ld -- MSG : ", (long int)line); + } + + DBG_WriteToLogFile_c(DBG_printBuffer); + sprintf(DBG_printBuffer, "%s", msg); + } + else + { + DBG_printBuffer[0] = 0; + } + } + else if (msg != NULL) + { + sprintf(DBG_printBuffer, "%s", msg); + } + else + { + DBG_printBuffer[0] = 0; + } + + DBG_WriteToLogFile_c(DBG_printBuffer); + DBG_newLine = (strrchr(DBG_printBuffer, '\n') != NULL)?1:0; + + switch (type) + { + case 2: + case 4: + case 8: + case 0x10: + case 0x20: + case 0x40: + case 0x80: + if (!DBG_newLine) + { + sprintf(DBG_printBuffer, "\n"); + DBG_newLine = 1; + DBG_WriteToLogFile_c(DBG_printBuffer); + } + break; + + default: + break; + } + + DBG_stackPos2 = DBG_stackPos1; +} + +static void DBG_Action(unsigned int type, const char *module_name, const char *function_name, int line, const char *msg) +{ + uint8_t panic; + uint8_t quiet_function; + + quiet_function = 0; + panic = 0; + + if (type & 0x80000000) + { + type &= 0x7FFFFFFF; + quiet_function = 1; + } + + if (type & 0x40000000) + { + type &= 0xBFFFFFFF; + panic = 1; + } + + switch (type) + { + case 2u: + if (DBG_stackPos1 >= 0x7f) + { + DBG_PrintString_c(type, "ERROR : DEBUG-STACK OVERFLOW!!!\n", line); + } + else + { + DBG_stackPos1++; + DBG_stack[DBG_stackPos1].module_name = module_name; + DBG_stack[DBG_stackPos1].function_name = function_name; + DBG_stack[DBG_stackPos1].quiet_function = quiet_function; + + if ((DBG_stackPos1 != 0) && (!DBG_stack[DBG_stackPos1].quiet_function)) + { + if (!DBG_newLine) + { + DBG_PrintString_c(0x100, NULL, 0); + } + + DBG_PrintString_c(type, msg, line); + + if (!DBG_newLine) + { + DBG_PrintString_c(0x100, NULL, line); + } + } + } + + DBG_writeToLogFile = 1; + break; + + case 4u: + case 8u: + if ( DBG_stackPos1 < 0 ) + { + DBG_PrintString_c(type, "ERROR : DEBUG-STACK UNDERFLOW!!!\n", line); + } + else + { + DBG_stackPos1--; + + if ((DBG_stackPos1 != -1) && (!DBG_stack[DBG_stackPos1 + 1].quiet_function)) + { + if (!DBG_newLine) + { + DBG_PrintString_c(0x100, NULL, 0); + } + + DBG_PrintString_c(type, msg, line); + + if (!DBG_newLine) + { + DBG_PrintString_c(0x100, NULL, line); + } + } + } + + if (panic) + { + DBG_Panic_c(module_name, line); + } + break; + + case 0x10u: + case 0x20u: + case 0x40u: + case 0x80u: + DBG_PrintString_c(type, msg, line); + // @fallthrough@ + case 0: + DBG_PrintString_c(0x100, NULL, line); + break; + + default: + break; + } +} + diff --git a/games/Battle Isle 3/SR-BI3/BBDBG.h b/games/Battle Isle 3/SR-BI3/BBDBG.h new file mode 100644 index 0000000..d8a3d1a --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBDBG.h @@ -0,0 +1,42 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_BBDBG_H_INCLUDED_) +#define _BBDBG_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void DBG_Panic_c(const char *module, int line); +int DBG_Init_c(void); +void DBG_Exit_c(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _BBDBG_H_INCLUDED_ */ diff --git a/games/Battle Isle 3/SR-BI3/BBDEPACK.c b/games/Battle Isle 3/SR-BI3/BBDEPACK.c new file mode 100644 index 0000000..e6c5566 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBDEPACK.c @@ -0,0 +1,111 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "BBDEPACK.h" + + +unsigned int DEPACK_c(const uint8_t *src, uint8_t *dst) +{ + unsigned int multivalue; + unsigned int dstcounter; + unsigned int mask; + unsigned int copyvalue; + int copyoffset; + int copycounter; + uint8_t *copyptr; + uint8_t *endptr; + uint8_t backup[2]; + unsigned int srccounter; + unsigned int length; + + if (!((src[0] == 'T') && (src[1] == 'P') && (src[2] == 'W') && (src[3] == 'M'))) + { + return 0; + } + + length = src[4] | (src[5] << 8) | (src[6] << 16) | (src[7] << 24); + + src += 8; + srccounter = length; + endptr = &dst[length]; + backup[0] = endptr[0]; + backup[1] = endptr[1]; + dstcounter = length + 1; + + while (1) + { + multivalue = *src++; + + for (mask = 0x80; mask != 0; mask >>= 1) + { + if (multivalue & mask) + { + copyvalue = *src++; + copyoffset = ((copyvalue & 0xf0) << 4) | (*src++); + copycounter = (copyvalue & 0x0f) + 3; + copyptr = &dst[-copyoffset]; + + for (; copycounter != 0; copycounter--) + { + *dst++ = *copyptr++; + + dstcounter--; + if (dstcounter == 0) + { + endptr[0] = backup[0]; + endptr[1] = backup[1]; + + return length; + } + + srccounter--; + if (srccounter == 0) + { + return length; + } + } + } + else + { + *dst++ = *src++; + + dstcounter--; + if (dstcounter == 0) + { + endptr[0] = backup[0]; + endptr[1] = backup[1]; + + return length; + } + + srccounter--; + if (srccounter == 0) + { + return length; + } + } + } + } +} + diff --git a/games/Battle Isle 3/SR-BI3/BBDEPACK.h b/games/Battle Isle 3/SR-BI3/BBDEPACK.h new file mode 100644 index 0000000..cf67196 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBDEPACK.h @@ -0,0 +1,40 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_BBDEPACK_H_INCLUDED_) +#define _BBDEPACK_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +unsigned int DEPACK_c(const uint8_t *src, uint8_t *dst); + +#ifdef __cplusplus +} +#endif + +#endif /* _BBDEPACK_H_INCLUDED_ */ diff --git a/games/Battle Isle 3/SR-BI3/BBDOS.c b/games/Battle Isle 3/SR-BI3/BBDOS.c new file mode 100644 index 0000000..8c78cab --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBDOS.c @@ -0,0 +1,321 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "BBDOS.h" +#include "BBMEM.h" +#define WIN32_LEAN_AND_MEAN +#include + + +typedef struct { + unsigned int flags; + HFILE handle; +} DOS_struct; + + +static int DOS_initialized = 0; +static DOS_struct DOS_handles[256]; + + +int DOS_Init_c(void) +{ + int count, index; + + if (DOS_initialized) + { + return 1; + } + + count = SetHandleCount(255); + for (index = 0; index < count; index++) + { + DOS_handles[index].flags = 0; + } + for (index = count; index < 256; index++) + { + DOS_handles[index].flags = 1; + } + + DOS_initialized = 1; + return 1; +} + +void DOS_Exit_c(void) +{ + int index; + + if (DOS_initialized) + { + DOS_initialized = 0; + + for (index = 0; index < 256; index++) + { + if (DOS_handles[index].flags & 1) + { + DOS_Close_c(index); + } + } + } +} + +int DOS_Open_c(const char *path, unsigned int mode) +{ + int iReadWrite, append, index; + + iReadWrite = OF_READ; + append = 0; + if ((mode & DOS_OPEN_MODE_READ) && (mode & DOS_OPEN_MODE_WRITE)) + { + iReadWrite = OF_READWRITE; + } + else if (mode & DOS_OPEN_MODE_WRITE) + { + iReadWrite = OF_WRITE; + } + else if (mode & DOS_OPEN_MODE_APPEND) + { + iReadWrite = OF_WRITE; + append = 1; + } + + for (index = 0; index < 256; index++) + { + if (DOS_handles[index].flags == 0) break; + } + if (index == 256) + { + return -1; + } + + if ((!append) && (iReadWrite != OF_READ)) + { + DOS_handles[index].handle = _lcreat(path, 0); // 0 = Normal. Can be read from or written to without restriction. + if (DOS_handles[index].handle == HFILE_ERROR) + { + return -1; + } + } + else + { + DOS_handles[index].handle = _lopen(path, iReadWrite); + if (DOS_handles[index].handle == HFILE_ERROR) + { + if (iReadWrite == OF_READ) + { + return -1; + } + + DOS_handles[index].handle = _lcreat(path, 0); // 0 = Normal. Can be read from or written to without restriction. + if (DOS_handles[index].handle == HFILE_ERROR) + { + return -1; + } + } + else if (append) + { + _llseek(DOS_handles[index].handle, 0, 2); // 2 = Moves the pointer from the end of the file. + } + } + + DOS_handles[index].flags = mode | 1; + return index; +} + +int DOS_Close_c(int file_handle) +{ + file_handle = (int16_t)file_handle; + + if (!(DOS_handles[file_handle].flags & 1)) + { + return 0; + } + + _lclose(DOS_handles[file_handle].handle); + DOS_handles[file_handle].flags = 0; + return 1; +} + +int DOS_Read_c(int file_handle, void *buffer, unsigned int length) +{ + file_handle = (int16_t)file_handle; + + if (!(DOS_handles[file_handle].flags & 1)) + { + return -1; + } + + return _lread(DOS_handles[file_handle].handle, buffer, length); +} + +int DOS_Write_c(int file_handle, const void *buffer, unsigned int length) +{ + unsigned int total_length, to_write, written; + + file_handle = (int16_t)file_handle; + + if (!(DOS_handles[file_handle].flags & 1)) + { + return -1; + } + + total_length = length; + while (length != 0) + { + to_write = length; + if (to_write >= 65535) + { + to_write = 65535; + } + written = _lwrite(DOS_handles[file_handle].handle, buffer, to_write); + if (written != to_write) + { + return -1; + } + buffer = (const void *)(written + (uintptr_t)buffer); + length -= written; + }; + + return total_length; +} + +int DOS_Seek_c(int file_handle, int origin, int offset) +{ + LONG res; + + file_handle = (int16_t)file_handle; + + if (!(DOS_handles[file_handle].flags & 1)) + { + return 0; + } + + origin = (int16_t)origin; + + if (origin == DOS_SEEK_CUR) + { + res = _llseek(DOS_handles[file_handle].handle, offset, 1); // 1 = Moves the file from its current location. + } + else if (origin == DOS_SEEK_SET) + { + res = _llseek(DOS_handles[file_handle].handle, offset, 0); // 0 = Moves the pointer from the beginning of the file. + } + else if (origin == DOS_SEEK_END) + { + res = _llseek(DOS_handles[file_handle].handle, offset, 2); // 2 = Moves the pointer from the end of the file. + } + else + { + res = _llseek(DOS_handles[file_handle].handle, offset, 0); // 0 = Moves the pointer from the beginning of the file. + } + + return (res != HFILE_ERROR)?1:0; +} + +void *DOS_ReadFile_c(const char *path, void *buffer) +{ + int length, memalloc, file_handle; + + length = DOS_GetFileLength_c(path); + if (length < 0) + { + return NULL; + } + + memalloc = 0; + if (buffer == NULL) + { + buffer = MEM_malloc_c(length, NULL, NULL, 0, 0); + if (buffer == NULL) + { + return NULL; + } + memalloc = 1; + } + + file_handle = DOS_Open_c(path, DOS_OPEN_MODE_READ); + if (file_handle < 0) + { + if (memalloc & 1) + { + MEM_free_c(buffer); + } + return NULL; + } + + if (DOS_Read_c(file_handle, buffer, length) < 0) + { + DOS_Close_c(file_handle); + if (memalloc & 1) + { + MEM_free_c(buffer); + } + return NULL; + } + + DOS_Close_c(file_handle); + return buffer; +} + +int DOS_WriteFile_c(const char *path, const void *buffer, unsigned int length) +{ + int file_handle; + + file_handle = DOS_Open_c(path, DOS_OPEN_MODE_WRITE); + if (file_handle < 0) + { + return 0; + } + + if (DOS_Write_c(file_handle, buffer, length) < 0) + { + DOS_Close_c(file_handle); + return 0; + } + + DOS_Close_c(file_handle); + return 1; +} + +int DOS_GetFileLength_c(const char *path) +{ + LONG res; + int file_handle; + + file_handle = DOS_Open_c(path, DOS_OPEN_MODE_READ); + if (file_handle < 0) + { + return -1; + } + + res = _llseek(DOS_handles[file_handle].handle, 0, 2); // 2 = Moves the pointer from the end of the file. + if (res == HFILE_ERROR) + { + DOS_Close_c(file_handle); + return -1; + } + + DOS_Close_c(file_handle); + return res; +} + diff --git a/games/Battle Isle 3/SR-BI3/BBDOS.h b/games/Battle Isle 3/SR-BI3/BBDOS.h new file mode 100644 index 0000000..6d23b3e --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBDOS.h @@ -0,0 +1,57 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_BBDOS_H_INCLUDED_) +#define _BBDOS_H_INCLUDED_ + +#include + +#define DOS_OPEN_MODE_READ 2 +#define DOS_OPEN_MODE_WRITE 4 +#define DOS_OPEN_MODE_APPEND 8 + +#define DOS_SEEK_CUR 0 +#define DOS_SEEK_SET 1 +#define DOS_SEEK_END 2 + +#ifdef __cplusplus +extern "C" { +#endif + +int DOS_Init_c(void); +void DOS_Exit_c(void); +int DOS_Open_c(const char *path, unsigned int mode); +int DOS_Close_c(int file_handle); +int DOS_Read_c(int file_handle, void *buffer, unsigned int length); +int DOS_Write_c(int file_handle, const void *buffer, unsigned int length); +int DOS_Seek_c(int file_handle, int origin, int offset); +void *DOS_ReadFile_c(const char *path, void *buffer); +int DOS_WriteFile_c(const char *path, const void *buffer, unsigned int length); +int DOS_GetFileLength_c(const char *path); + +#ifdef __cplusplus +} +#endif + +#endif /* _BBDOS_H_INCLUDED_ */ diff --git a/games/Battle Isle 3/SR-BI3/BBDSA.c b/games/Battle Isle 3/SR-BI3/BBDSA.c new file mode 100644 index 0000000..b2f12b3 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBDSA.c @@ -0,0 +1,2256 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "BBDSA.h" +#include "BBDBG.h" +#include "BBSYSTEM.h" +#include "BBLBL.h" +#include "BBMEM.h" +#include "BBLL.h" +#include "BBBLEV.h" +#include "BBFX.h" +#include "SDIresource.h" +#include +#include "WinApi-wing32.h" +#define WIN32_LEAN_AND_MEAN +#include + + +// exported variables +#ifdef __cplusplus +extern "C" { +#endif +extern DSA_Screen *p_last_touched_screen; +extern int32_t sl_screenwidth; +extern int32_t sl_screenheight; +extern DSA_Screen *p_mouse_gui; +extern DSA_Screen *h_mouse_win; +extern int32_t b_mouse_capture_on; +extern int32_t b_application_active; +#ifdef __cplusplus +} +#endif + + +#define BBDSA_UNKNOWN1 1 +#define BBDSA_VISIBLE 2 + +#define BBDSA_EXTRA_SCREEN 0 +#define BBDSA_EXTRA_BUTTON_STATE 4 +#define BBDSA_EXTRA_RESIZING_MODE 8 +#define BBDSA_EXTRA_PALETTE_REMAPPING 12 +#define BBDSA_EXTRA_SIZE 16 + +#define IDC_ICON1 101 + + +typedef struct { + int used; + DSA_Screen *screen; +} DSA_Screen2; + +typedef union { + LOGPALETTE pal; + struct { + WORD palVersion2; + WORD palNumEntries2; + PALETTEENTRY palPalEntry2[256]; + } pal2; +} myLOGPALETTE; + + +static int DSA_deactivate = 0; +static const INT DSA_elements[19] = { COLOR_ACTIVEBORDER, COLOR_ACTIVECAPTION, COLOR_APPWORKSPACE, COLOR_BACKGROUND, COLOR_3DDKSHADOW, COLOR_3DSHADOW, COLOR_BTNTEXT, COLOR_CAPTIONTEXT, COLOR_GRAYTEXT, COLOR_HIGHLIGHT, COLOR_HIGHLIGHTTEXT, COLOR_INACTIVEBORDER, COLOR_INACTIVECAPTION, COLOR_MENU, COLOR_MENUTEXT, COLOR_SCROLLBAR, COLOR_WINDOW, COLOR_WINDOWFRAME, COLOR_WINDOWTEXT }; +static const COLORREF DSA_elementColors[19] = { RGB(0, 0, 0), RGB(255, 255, 255), RGB(255, 255, 255), RGB(255, 255, 255), RGB(255, 255, 255), RGB(0, 0, 0), RGB(0, 0, 0), RGB(0, 0, 0), RGB(0, 0, 0), RGB(0, 0, 0), RGB(255, 255, 255), RGB(255, 255, 255), RGB(255, 255, 255), RGB(255, 255, 255), RGB(0, 0, 0), RGB(255, 255, 255), RGB(255, 255, 255), RGB(0, 0, 0), RGB(0, 0, 0) }; +static int DSA_isBitmapDirty = 0; +static const char DSA_mainClass[] = "BBMAINWINDOW"; +static const char DSA_windowClasses[5][5] = { "0000", "0001", "XXXX", "0003", "XXXX" }; +static const DWORD DSA_windowStyles[5] = { WS_POPUP, WS_POPUP | WS_CAPTION, 0xFFFFFFFF, WS_POPUP | WS_CAPTION, 0xFFFFFFFF }; +static HINSTANCE DSA_hInstance = NULL; +static int DSA_initialized = 0; +static DSA_Screen *DSA_activeScreen = NULL; +static int DSA_isBGFixed = 0; +static int DSA_isBGBlack = 0; +static HDC DSA_BG_hDC = NULL; +static HGDIOBJ DSA_BG_hBitmap = NULL; +static uint8_t *DSA_BG_buffer = NULL; +static int DSA_isBGInRAM = 1; +static int DSA_BG_offsetX = -1; +static int DSA_BG_offsetY = -1; +static int DSA_wasVisible = 0; +unsigned int DSA_pixelMapList = 0; +static DSA_Palette DSA_palette = { 256, 1, { { 0 } } }; +static int DSA_bitsPerPixel = 0; +static DSA_Screen *DSA_nextActiveScreen; +static COLORREF DSA_systemColors[19]; +static LOGPALETTE *DSA_systemPalette; +static BYTE DSA_keyState[256]; +char DSA_IconID[100]; +char DSA_WindowName[100]; +HPALETTE DSA_hPalette; +static PALETTEENTRY DSA_paletteEntries[256]; +static int DSA_activated; +OPM_struct DSA_pixelMapBG; +static DSA_Screen2 DSA_screens[64]; +RGBQUAD DSA_colorTable[256]; + + +static int DSA_GetMyIndex_c(void *hWnd); +static void DSA_ActivateApp_c(int isActive); +static void DSA_SetColorTable_c(void); +static LRESULT WINAPI DSA_Mainwindow_Callback_c(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); +static LRESULT WINAPI DSA_0000_Callback_c(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); +static LRESULT WINAPI DSA_0003_Callback_c(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + + +static HPALETTE DSA_CreatePalette_c(void) +{ + HPALETTE hPal; + int index; + myLOGPALETTE palette; + + palette.pal.palVersion = 0x300; + palette.pal.palNumEntries = 256; + memset(palette.pal.palPalEntry, 0, 256 * sizeof(PALETTEENTRY)); + + for (index = 0; index < 256; index++) + { + palette.pal2.palPalEntry2[index].peRed = DSA_palette.palPalEntry[index].peRed; + palette.pal2.palPalEntry2[index].peGreen = DSA_palette.palPalEntry[index].peGreen; + palette.pal2.palPalEntry2[index].peBlue = DSA_palette.palPalEntry[index].peBlue; + palette.pal2.palPalEntry2[index].peFlags = PC_NOCOLLAPSE; + } + + palette.pal2.palPalEntry2[0].peFlags = 0; + palette.pal2.palPalEntry2[255].peFlags = 0; + + hPal = CreatePalette(&(palette.pal)); + if (hPal == NULL) + { + DBG_Panic_c("C:\\DATA\\BBLIB\\SRC\\BASE\\bbdsa.c", 611); + return 0; + } + + return hPal; +} + +static void DSA_MapPalette_c(LOGPALETTE *palette) +{ + HPALETTE hPrevPal; + HDC hDC; + HPALETTE hPal; + int index; + myLOGPALETTE pal2; + + pal2.pal.palVersion = 0x300; + pal2.pal.palNumEntries = 256; + memset(pal2.pal.palPalEntry, 0, 256 * sizeof(PALETTEENTRY)); + + if (palette != NULL) + { + memmove(pal2.pal.palPalEntry, palette->palPalEntry, 256 * sizeof(PALETTEENTRY)); + for (index = 0; index < 256; index++) + { + pal2.pal2.palPalEntry2[index].peFlags = PC_NOCOLLAPSE; + } + } + else + { + for (index = 0; index < 256; index++) + { + pal2.pal2.palPalEntry2[index].peRed = 0; + pal2.pal2.palPalEntry2[index].peGreen = 0; + pal2.pal2.palPalEntry2[index].peBlue = 0; + pal2.pal2.palPalEntry2[index].peFlags = PC_NOCOLLAPSE; + } + } + + pal2.pal2.palPalEntry2[255].peRed = 255; + pal2.pal2.palPalEntry2[255].peGreen = 255; + pal2.pal2.palPalEntry2[255].peBlue = 255; + pal2.pal2.palPalEntry2[0].peFlags = 0; + pal2.pal2.palPalEntry2[255].peFlags = 0; + + hDC = GetDC(NULL); + hPal = CreatePalette(&(pal2.pal)); + if (hPal != NULL) + { + UnrealizeObject(hPal); + hPrevPal = SelectPalette(hDC, hPal, FALSE); + RealizePalette(hDC); + DeleteObject(SelectPalette(hDC, hPrevPal, FALSE)); + } + + ReleaseDC(NULL, hDC); +} + +void DSA_ReuseStaticColors_c(unsigned int osVersions) +{ + HDC hDC; + + if (!(SYSTEM_GetOS_c() & osVersions)) + { + return; + } + + hDC = GetDC(NULL); + if (DSA_bitsPerPixel == 8) + { + SetSystemPaletteUse(hDC, SYSPAL_NOSTATIC); + } + ReleaseDC(NULL, hDC); + + DSA_MapPalette_c(NULL); + DSA_ActivatePal_c(); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); +} + +void DSA_FreeStaticColors_c(unsigned int osVersions) +{ + HDC hDC; + + if (!(SYSTEM_GetOS_c() & osVersions)) + { + return; + } + + hDC = GetDC(NULL); + if (DSA_bitsPerPixel == 8) + { + SetSystemPaletteUse(hDC, SYSPAL_STATIC); + } + ReleaseDC(0, hDC); + + DSA_MapPalette_c(NULL); + DSA_ActivatePal_c(); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); +} + +void DSAWIN_PrepareInit_c(void *hInstance) +{ + DSA_hInstance = (HINSTANCE)hInstance; +} + +void *DSAWIN_GetMainWindowHandle_c(void) +{ + return (DSA_screens[0].used)?DSA_screens[0].screen->hWnd:NULL; +} + +void *DSAWIN_GetInstance_c(void) +{ + return DSA_hInstance; +} + +int DSA_Init_c(void) +{ + int index; + HDC hDC; + WNDCLASSA WndClass; + + if (DSA_initialized) + { + return 1; + } + + memset(&WndClass, 0, sizeof(WNDCLASSA)); + hDC = GetDC(NULL); + if (hDC == NULL) + { + DBG_Panic_c("C:\\DATA\\BBLIB\\SRC\\BASE\\bbdsa.c", 1185); + return 0; + } + + DSA_bitsPerPixel = GetDeviceCaps(hDC, BITSPIXEL); + ReleaseDC(NULL, hDC); + + if (DSA_bitsPerPixel < 8) + { + MessageBoxA(NULL, "This program needs at least 256 colors! Please switch to an appropriate color resolution", "SETTINGS ERROR", MB_OK | MB_ICONERROR); + return 0; + } + + DSA_systemPalette = (LOGPALETTE *)MEM_malloc_c(sizeof(LOGPALETTE) + 255 * sizeof(PALETTEENTRY), NULL, NULL, 0, 0); + if (DSA_systemPalette == NULL) + { + return 0; + } + + DSA_systemPalette->palNumEntries = 256; + DSA_systemPalette->palVersion = 0x300; + hDC = GetDC(NULL); + GetSystemPaletteEntries(hDC, 0, 256, DSA_systemPalette->palPalEntry); + ReleaseDC(NULL, hDC); + + DSA_MapPalette_c(NULL); + DSA_BG_hDC = NULL; + DSA_BG_hBitmap = NULL; + DSA_BG_buffer = NULL; + DSA_pixelMapBG.flags = 0; + DSA_activeScreen = NULL; + + sl_screenwidth = GetSystemMetrics(SM_CXSCREEN); + sl_screenheight = GetSystemMetrics(SM_CYSCREEN); + b_mouse_capture_on = 0; + p_last_touched_screen = NULL; + + for (index = 1; index < 64; index++) + { + DSA_screens[index].used = 0; + } + + DSA_screens[0].used = 1; + DSA_screens[0].screen = (DSA_Screen *)MEM_malloc_c(sizeof(DSA_Screen), NULL, NULL, 0, 0); + if (DSA_screens[0].screen == NULL) + { + MEM_free_c(DSA_systemPalette); + return 0; + } + + DSA_screens[0].screen->hDC = NULL; + DSA_screens[0].screen->hBitmap = NULL; + DSA_screens[0].screen->opm = NULL; + DSA_screens[0].screen->unknown_08 = 0; + DSA_screens[0].screen->unknown_00 = 0; + + WndClass.style = CS_BYTEALIGNWINDOW | CS_NOCLOSE | CS_DBLCLKS; + WndClass.lpfnWndProc = (WNDPROC)DSA_Mainwindow_Callback_c; + WndClass.cbClsExtra = 0; + WndClass.cbWndExtra = BBDSA_EXTRA_SIZE; + WndClass.hInstance = DSA_hInstance; + // change: don't load app icon from executable resources + //WndClass.hIcon = LoadIconA(DSA_hInstance, (LPCSTR)MAKEINTRESOURCE(IDC_ICON1)); + WndClass.hIcon = (HICON)resource_LoadAppIcon(); + WndClass.hCursor = NULL; + WndClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); + WndClass.lpszMenuName = NULL; + WndClass.lpszClassName = DSA_mainClass; + if (!RegisterClassA(&WndClass)) + { + MEM_free_c(DSA_systemPalette); + return 0; + } + + WndClass.style = CS_BYTEALIGNWINDOW | CS_NOCLOSE | CS_DBLCLKS; + WndClass.lpfnWndProc = (WNDPROC)DSA_0000_Callback_c; + WndClass.cbClsExtra = 0; + WndClass.cbWndExtra = BBDSA_EXTRA_SIZE; + WndClass.hInstance = DSA_hInstance; + WndClass.hIcon = LoadIconA(NULL, (LPCSTR)IDI_APPLICATION); + WndClass.hCursor = NULL; + WndClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); + WndClass.lpszMenuName = NULL; + WndClass.lpszClassName = DSA_windowClasses[0]; + if (!RegisterClassA(&WndClass)) + { + UnregisterClassA(DSA_mainClass, DSA_hInstance); + MEM_free_c(DSA_systemPalette); + return 0; + } + + WndClass.style = CS_BYTEALIGNWINDOW | CS_NOCLOSE | CS_DBLCLKS; + WndClass.lpfnWndProc = (WNDPROC)DSA_0003_Callback_c; + WndClass.cbClsExtra = 0; + WndClass.cbWndExtra = BBDSA_EXTRA_SIZE; + WndClass.hInstance = DSA_hInstance; + WndClass.hIcon = LoadIconA(NULL, (LPCSTR)IDI_APPLICATION); + WndClass.hCursor = NULL; + WndClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); + WndClass.lpszMenuName = NULL; + WndClass.lpszClassName = DSA_windowClasses[1]; + if (!RegisterClassA(&WndClass)) + { + UnregisterClassA(DSA_mainClass, DSA_hInstance); + UnregisterClassA(DSA_windowClasses[0], DSA_hInstance); + MEM_free_c(DSA_systemPalette); + return 0; + } + + WndClass.style = CS_BYTEALIGNWINDOW | CS_NOCLOSE | CS_DBLCLKS; + WndClass.lpfnWndProc = (WNDPROC)DSA_0003_Callback_c; + WndClass.cbClsExtra = 0; + WndClass.cbWndExtra = BBDSA_EXTRA_SIZE; + WndClass.hInstance = DSA_hInstance; + WndClass.hIcon = LoadIconA(NULL, (LPCSTR)IDI_APPLICATION); + WndClass.hCursor = NULL; + WndClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); + WndClass.lpszMenuName = NULL; + WndClass.lpszClassName = DSA_windowClasses[3]; + if (!RegisterClassA(&WndClass)) + { + UnregisterClassA(DSA_mainClass, DSA_hInstance); + UnregisterClassA(DSA_windowClasses[0], DSA_hInstance); + UnregisterClassA(DSA_windowClasses[1], DSA_hInstance); + MEM_free_c(DSA_systemPalette); + return 0; + } + + DSA_screens[0].screen->hWnd = CreateWindowExA( + 0, + DSA_mainClass, + DSA_WindowName, + WS_POPUP, + -GetSystemMetrics(SM_CXBORDER), + -GetSystemMetrics(SM_CYBORDER), + GetSystemMetrics(SM_CXSCREEN) + GetSystemMetrics(SM_CXBORDER), + GetSystemMetrics(SM_CYSCREEN) + GetSystemMetrics(SM_CYBORDER), + NULL, + NULL, + DSA_hInstance, + 0 + ); + if (DSA_screens[0].screen->hWnd == NULL) + { + UnregisterClassA(DSA_mainClass, DSA_hInstance); + UnregisterClassA(DSA_windowClasses[0], DSA_hInstance); + UnregisterClassA(DSA_windowClasses[1], DSA_hInstance); + UnregisterClassA(DSA_windowClasses[3], DSA_hInstance); + MEM_free_c(DSA_systemPalette); + return 0; + } + + SetTimer(DSA_screens[0].screen->hWnd, 0, 100, NULL); + ShowWindow(DSA_screens[0].screen->hWnd, SW_SHOW); + + DSA_hPalette = DSA_CreatePalette_c(); + if (DSA_hPalette == NULL) + { + SendMessageA(DSA_screens[0].screen->hWnd, WM_QUIT, 0, 0); + UnregisterClassA(DSA_mainClass, DSA_hInstance); + UnregisterClassA(DSA_windowClasses[0], DSA_hInstance); + UnregisterClassA(DSA_windowClasses[1], DSA_hInstance); + UnregisterClassA(DSA_windowClasses[3], DSA_hInstance); + MEM_free_c(DSA_systemPalette); + return 0; + } + + DSA_pixelMapList = LL_NewList_c(); + if (DSA_pixelMapList == 0) + { + SendMessageA(DSA_screens[0].screen->hWnd, WM_QUIT, 0, 0); + UnregisterClassA(DSA_mainClass, DSA_hInstance); + UnregisterClassA(DSA_windowClasses[0], DSA_hInstance); + UnregisterClassA(DSA_windowClasses[1], DSA_hInstance); + UnregisterClassA(DSA_windowClasses[3], DSA_hInstance); + DeleteObject(DSA_hPalette); + MEM_free_c(DSA_systemPalette); + return 0; + } + + DSA_initialized = 1; + return 1; +} + +void DSA_Exit_c(void) +{ + int index; + + if (DSA_initialized) + { + KillTimer((HWND)DSA_screens[0].screen->hWnd, 0); + + for (index = 1; index < 64; index++) + { + if (DSA_screens[index].used) + { + DSA_CloseScreen_c(DSA_screens[index].screen); + } + } + + if (IsWindow((HWND)DSA_screens[0].screen->hWnd)) + { + SendMessageA((HWND)DSA_screens[0].screen->hWnd, WM_CLOSE, 0, 0); + DSA_screens[0].screen->hWnd = NULL; + } + + if (DSA_BG_hDC != NULL) + { + OPM_Del_c(&DSA_pixelMapBG); + } + + MEM_free_c(DSA_screens[0].screen); + MEM_free_c(DSA_systemPalette); + UnregisterClassA(DSA_mainClass, DSA_hInstance); + UnregisterClassA(DSA_windowClasses[0], DSA_hInstance); + UnregisterClassA(DSA_windowClasses[1], DSA_hInstance); + UnregisterClassA(DSA_windowClasses[3], DSA_hInstance); + DeleteObject(DSA_hPalette); + } + + LL_DestroyList_c(DSA_pixelMapList); + DSA_initialized = 0; +} + +int DSA_OpenScreen_c(DSA_Screen *screen, OPM_struct *opm, int param3, const char *windowName, int x, int y, int type) +{ + int index, width, height; + HWND hWnd; + + x = (int16_t)x; + y = (int16_t)y; + + screen->unknown_00 = 0; + + for (index = 0; index < 64; index++) + { + if (!DSA_screens[index].used) break; + } + + if (index >= 64) + { + return 0; + } + + DSA_screens[index].screen = screen; + + if (x == -1) + { + x = (sl_screenwidth / 2) - (opm->width >> 1); + } + + if (y == -1) + { + y = (sl_screenheight / 2) - (opm->height >> 1); + } + + if (DSA_windowStyles[type & 3] & WS_CAPTION) + { + width = opm->width + 2 * GetSystemMetrics(SM_CXBORDER); + height = opm->height + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYBORDER); + hWnd = CreateWindowExA( + 0, + DSA_windowClasses[type & 3], + windowName, + DSA_windowStyles[type & 3], + x, + y, + width, + height, + DSA_screens[0].screen->hWnd, + NULL, + DSA_hInstance, + NULL + ); + } + else + { + hWnd = CreateWindowExA( + 0, + DSA_windowClasses[type & 3], + windowName, + DSA_windowStyles[type & 3], + x, + y, + opm->width, + opm->height, + DSA_screens[0].screen->hWnd, + NULL, + DSA_hInstance, + NULL + ); + } + + screen->hWnd = hWnd; + if (screen->hWnd == NULL) + { + return 0; + } + + screen->hDC = opm->hDC; + screen->hBitmap = opm->hBitmap; + screen->opm = opm; + screen->type = type; + screen->size = opm->height * opm->width; + screen->flags = 0; + SetWindowLongA(screen->hWnd, BBDSA_EXTRA_SCREEN, (LONG)screen); + DSA_screens[index].used = 1; + DSA_activeScreen = screen; + SendMessageA(screen->hWnd, WM_QUERYNEWPALETTE, 0, 0); + + return 1; +} + +void DSA_CloseScreen_c(DSA_Screen *screen) +{ + int index; + + index = DSA_GetMyIndex_c(screen->hWnd); + if (index == -1) + { + return; + } + + if (!DSA_screens[index].used) + { + return; + } + + if (IsWindow((HWND)screen->hWnd)) + { + SendMessageA((HWND)screen->hWnd, WM_CLOSE, 0, 0); + + DSA_screens[index].screen->hWnd = NULL; + + if (p_last_touched_screen == screen) + { + p_last_touched_screen = NULL; + } + + if (DSA_activeScreen == screen) + { + DSA_activeScreen = NULL; + } + + if (screen == p_mouse_gui) + { + p_mouse_gui = NULL; + } + + if (screen == h_mouse_win) + { + h_mouse_win = NULL; + } + + //if (screen == h_mouse_win) + //{ + // h_mouse_win = NULL; + //} + + if (screen == DSA_nextActiveScreen) + { + DSA_nextActiveScreen = NULL; + } + } + + screen->unknown_00 = 0; + DSA_screens[index].used = 0; +} + +void DSA_CopyMainOPMToScreen_c(DSA_Screen *screen, int onlyModified) +{ + OPM_struct *opm; + + opm = screen->opm; + if (onlyModified & 0xffff) + { + if (!(opm->flags & BBOPM_MODIFIED)) + { + return; + } + } + + opm->flags &= ~BBOPM_MODIFIED; + if (!IsIconic((HWND)DSA_screens[0].screen->hWnd)) + { + InvalidateRect((HWND)screen->hWnd, NULL, TRUE); + UpdateWindow((HWND)screen->hWnd); + } +} + +void DSA_StretchOPMToScreen_c(DSA_Screen *screen, int xDst, int yDst, int widthDst, int heightDst, OPM_struct *opm, int xSrc, int ySrc, int widthSrc, int heightSrc) +{ + HDC hDC; + HWND hWnd; + HPALETTE hPrevPal; + + hWnd = (screen != NULL)?(HWND)screen->hWnd:NULL; + hDC = GetDC(hWnd); + if (hDC == NULL) + { + return; + } + + hPrevPal = SelectPalette(hDC, DSA_hPalette, FALSE); + if (hPrevPal != NULL) + { + WinGStretchBlt_c(hDC, (int16_t)xDst, (int16_t)yDst, (int16_t)widthDst, (int16_t)heightDst, (HDC)opm->hDC, (int16_t)xSrc, (int16_t)ySrc, (int16_t)widthSrc, (int16_t)heightSrc); + SelectPalette(hDC, hPrevPal, FALSE); + } + ReleaseDC(hWnd, hDC); +} + +void DSA_CopyOPMToScreenEx_c(DSA_Screen *screen, int xDst, int yDst, int width, int height, OPM_struct *opm, int xSrc, int ySrc) +{ + HDC hDC; + HWND hWnd; + HPALETTE hPrevPal; + int screenWidth; + int screenHeight; + + if (screen != NULL) + { + hWnd = (HWND)screen->hWnd; + screenWidth = screen->opm->width; + screenHeight = screen->opm->height; + } + else + { + hWnd = NULL; + screenWidth = sl_screenwidth; + screenHeight = sl_screenheight; + } + + xDst = (int16_t)xDst; + yDst = (int16_t)yDst; + width = (int16_t)width; + height = (int16_t)height; + xSrc = (int16_t)xSrc; + ySrc = (int16_t)ySrc; + + if (xDst + width > screenWidth) + { + width = screenWidth - xDst; + } + + if (yDst + height > screenHeight) + { + height = screenHeight - yDst; + } + + hDC = GetDC(hWnd); + if (hDC == NULL) + { + return; + } + + hPrevPal = SelectPalette(hDC, DSA_hPalette, FALSE); + if (hPrevPal != NULL) + { + WinGBitBlt_c(hDC, xDst, yDst, width, height, (HDC)opm->hDC, xSrc, ySrc); + SelectPalette(hDC, hPrevPal, FALSE); + } + ReleaseDC(hWnd, hDC); +} + +static int DSA_GetMyIndex_c(void *hWnd) +{ + int index; + + for (index = 0; index < 64; index++) + { + if ((DSA_screens[index].used) && (DSA_screens[index].screen->hWnd == hWnd)) + { + return index; + } + } + + return -1; +} + +void DSA_TotalRepaint_c(void) +{ + int index; + + if (!DSA_initialized) + { + return; + } + + for (index = 0; index < 64; index++) + { + if (DSA_screens[index].used) + { + InvalidateRect((HWND)DSA_screens[index].screen->hWnd, NULL, (index == 0)?TRUE:FALSE); + UpdateWindow((HWND)DSA_screens[index].screen->hWnd); + } + } +} + +void DSA_MoveScreen_c(DSA_Screen *screen, int changeX, int changeY) +{ + int index; + RECT rect; + + GetWindowRect((HWND)screen->hWnd, &rect); + SetWindowPos((HWND)screen->hWnd, HWND_TOP, changeX + rect.left, changeY + rect.top, 0, 0, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE); + + for (index = 0; index < 64; index++) + { + if (DSA_screens[index].used) + { + UpdateWindow((HWND)DSA_screens[index].screen->hWnd); + } + } +} + +int DSA_ResizeScreen_c(DSA_Screen *screen, OPM_struct *opm, int redraw) +{ + int width, height, index; + + screen->size = opm->height * opm->width; + screen->opm = opm; + screen->hDC = opm->hDC; + screen->hBitmap = opm->hBitmap; + + if (DSA_windowStyles[screen->type & 3] & WS_CAPTION) + { + width = opm->width + 2 * GetSystemMetrics(SM_CXBORDER); + height = opm->height + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYBORDER); + } + else + { + width = opm->width; + height = opm->height; + } + + memset(opm->buffer, 0, opm->height * opm->width); + SetWindowPos((HWND)screen->hWnd, HWND_TOP, 0, 0, width, height, SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOZORDER | SWP_NOMOVE); + WinGSetDIBColorTable_c((HDC)opm->hDC, 0, 256, DSA_colorTable); + + if (redraw & 0xff) + { + InvalidateRect((HWND)screen->hWnd, NULL, TRUE); + UpdateWindow((HWND)screen->hWnd); + } + + for (index = 0; index < 64; index++) + { + if (DSA_screens[index].used) + { + if (DSA_screens[index].screen != screen) + { + InvalidateRect((HWND)DSA_screens[index].screen->hWnd, NULL, TRUE); + UpdateWindow((HWND)DSA_screens[index].screen->hWnd); + } + } + } + + return 1; +} + +int DSA_DrawSizingScreen_c(DSA_Screen *screen, int16_t *rect) +{ + int index; + + if (DSA_windowStyles[screen->type & 3] & WS_CAPTION) + { + rect[2] += 2 * GetSystemMetrics(SM_CXBORDER); + rect[3] += GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYBORDER); + } + + SetWindowPos((HWND)screen->hWnd, HWND_TOP, 0, 0, rect[2], rect[3], SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); + InvalidateRect((HWND)screen->hWnd, NULL, TRUE); + UpdateWindow((HWND)screen->hWnd); + + for (index = 0; index < 64; index++) + { + if (DSA_screens[index].used) + { + if (DSA_screens[index].screen != screen) + { + UpdateWindow((HWND)DSA_screens[index].screen->hWnd); + } + } + } + + return 1; +} + +void DSA_EnterResizingMode_c(DSA_Screen *screen) +{ + SendMessageA((HWND)screen->hWnd, WM_USER, 1, 0); +} + +void DSA_LeaveResizingMode_c(DSA_Screen *screen) +{ + SendMessageA((HWND)screen->hWnd, WM_USER, 0, 0); +} + +void DSA_GetDSAMetrics_c(DSA_Screen *screen, int32_t *x, int32_t *y, int32_t *width, int32_t *height, uint8_t *isVisible) +{ + RECT rect; + + if (screen != NULL) + { + GetWindowRect((HWND)screen->hWnd, &rect); + } + else + { + GetWindowRect((HWND)DSAWIN_GetMainWindowHandle_c(), &rect); + } + + if (x != NULL) + { + *x = rect.left; + } + + if (y != NULL) + { + *y = rect.top; + } + + if (width != NULL) + { + *width = rect.right - rect.left; + } + + if (height != NULL) + { + *height = rect.bottom - rect.top; + } + + if (isVisible != NULL) + { + if (screen != NULL) + { + *isVisible = IsWindowVisible((HWND)screen->hWnd); + } + else + { + *isVisible = 1; + } + } +} + +void DSA_SetDSAPos_c(DSA_Screen *screen, int x, int y, int repaint) +{ + RECT rect; + + if (x == -1) + { + x = (sl_screenwidth / 2) - (screen->opm->width >> 1); + } + else if (x == -2) + { + GetWindowRect((HWND)screen->hWnd, &rect); + x = rect.left; + } + + if (y == -1) + { + y = (sl_screenheight / 2) - (screen->opm->height >> 1); + } + else if (y == -2) + { + GetWindowRect((HWND)screen->hWnd, &rect); + y = rect.top; + } + + SetWindowPos((HWND)screen->hWnd, HWND_TOP, x, y, 0, 0, SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOZORDER | SWP_NOSIZE); + + if (repaint & 0xff) + { + DSA_TotalRepaint_c(); + } +} + +static LRESULT DSA_MouseEvent_c(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, DSA_Screen *screen, LONG buttonState) +{ + BLEV_Event event; + + uMsg = uMsg & 0xffff; + + switch (uMsg) + { + case WM_LBUTTONDOWN: + event.type = BBBLEV_TYPE_MOUSELEFTDOWN; + buttonState |= BBBLEV_BUTTON_MOUSELEFT; + break; + + case WM_LBUTTONUP: + event.type = BBBLEV_TYPE_MOUSELEFTUP; + buttonState &= ~BBBLEV_BUTTON_MOUSELEFT; + break; + + case WM_LBUTTONDBLCLK: + event.type = BBBLEV_TYPE_MOUSELEFTDOUBLECLICK; + buttonState &= ~BBBLEV_BUTTON_MOUSELEFT; + break; + + case WM_RBUTTONDOWN: + event.type = BBBLEV_TYPE_MOUSERIGHTDOWN; + buttonState |= BBBLEV_BUTTON_MOUSERIGHT; + break; + + case WM_RBUTTONUP: + event.type = BBBLEV_TYPE_MOUSERIGHTUP; + buttonState &= ~BBBLEV_BUTTON_MOUSERIGHT; + break; + + case WM_RBUTTONDBLCLK: + event.type = BBBLEV_TYPE_MOUSERIGHTDOUBLECLICK; + buttonState &= ~BBBLEV_BUTTON_MOUSERIGHT; + break; + + default: + break; + } + + event.screen = screen; + event.key = -1; + event.x = lParam & 0xffff; + event.y = lParam >> 16; + event.buttonState = buttonState; + SetWindowLongA(hWnd, BBDSA_EXTRA_BUTTON_STATE, buttonState); + BLEV_PutEvent_c(&event); + + return 0; +} + +static LRESULT DSA_KeyEvent_c(HWND hWnd, UINT uMsg, UINT wParam, LPARAM lParam, DSA_Screen *screen, LONG buttonState) +{ + WORD chars[2]; + BLEV_Event event; + + uMsg = uMsg & 0xffff; + + event.type = (uMsg == WM_KEYUP)?BBBLEV_TYPE_KEYUP:BBBLEV_TYPE_KEYDOWN; + + switch (wParam) + { + case VK_SHIFT: + if (uMsg == WM_KEYUP) + { + SetWindowLongA(hWnd, BBDSA_EXTRA_BUTTON_STATE, buttonState & ~BBBLEV_BUTTON_SHIFT); + } + else + { + SetWindowLongA(hWnd, BBDSA_EXTRA_BUTTON_STATE, buttonState | BBBLEV_BUTTON_SHIFT); + } + return 0; + + case VK_CONTROL: + if (uMsg == WM_KEYUP) + { + SetWindowLongA(hWnd, BBDSA_EXTRA_BUTTON_STATE, buttonState & ~BBBLEV_BUTTON_CONTROL); + } + else + { + SetWindowLongA(hWnd, BBDSA_EXTRA_BUTTON_STATE, buttonState | BBBLEV_BUTTON_CONTROL); + } + return 0; + + case VK_MENU: + if (uMsg == WM_KEYUP) + { + SetWindowLongA(hWnd, BBDSA_EXTRA_BUTTON_STATE, buttonState & ~BBBLEV_BUTTON_ALT); + } + else + { + SetWindowLongA(hWnd, BBDSA_EXTRA_BUTTON_STATE, buttonState | BBBLEV_BUTTON_ALT); + } + return 0; + + default: + break; + } + + switch (wParam) + { + case VK_TAB: + event.key = BBBLEV_KEY_TAB; + break; + + case VK_BACK: + event.key = BBBLEV_KEY_BACKSPACE; + break; + + case VK_RETURN: + event.key = BBBLEV_KEY_ENTER; + break; + + case VK_PRIOR: + event.key = BBBLEV_KEY_PAGEUP; + break; + + case VK_NEXT: + event.key = BBBLEV_KEY_PAGEDOWN; + break; + + case VK_ESCAPE: + event.key = BBBLEV_KEY_ESCAPE; + break; + + case VK_END: + event.key = BBBLEV_KEY_END; + break; + + case VK_HOME: + event.key = BBBLEV_KEY_HOME; + break; + + case VK_LEFT: + event.key = BBBLEV_KEY_LEFT; + break; + + case VK_UP: + event.key = BBBLEV_KEY_UP; + break; + + case VK_RIGHT: + event.key = BBBLEV_KEY_RIGHT; + break; + + case VK_DOWN: + event.key = BBBLEV_KEY_DOWN; + break; + + case VK_DELETE: + event.key = BBBLEV_KEY_DELETE; + break; + + case VK_INSERT: + event.key = BBBLEV_KEY_INSERT; + break; + + default: + if ((wParam >= VK_F1) && (wParam <= VK_F12)) + { + event.key = wParam + (BBBLEV_KEY_F1 - VK_F1); + } + else + { + GetKeyboardState(DSA_keyState); + if (ToAscii(wParam, (lParam >> 16) & 0xff, DSA_keyState, chars, 0) == 1) + { + event.key = chars[0] & 0xff; + } + else + { + return DefWindowProcA(hWnd, uMsg, wParam, lParam); + } + } + break; + } + + event.buttonState = buttonState; + event.screen = screen; + event.x = -1; + event.y = -1; + BLEV_PutEvent_c(&event); + + return 0; +} + +static LRESULT WINAPI DSA_Mainwindow_Callback_c(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + HPALETTE hPrevPal; + HDC hDC; + UINT mappedPaletteEntries; + LONG buttonState; + PAINTSTRUCT paint; + + uMsg = uMsg & 0xffff; + + buttonState = GetWindowLongA(hWnd, BBDSA_EXTRA_BUTTON_STATE); + + switch (uMsg) + { + case WM_COMMAND: + // wParam + break; + + case WM_LBUTTONDOWN: + case WM_LBUTTONUP: + case WM_LBUTTONDBLCLK: + case WM_RBUTTONDOWN: + case WM_RBUTTONUP: + case WM_RBUTTONDBLCLK: + return DSA_MouseEvent_c(hWnd, uMsg, wParam, lParam, NULL, buttonState); + + case WM_KEYDOWN: + case WM_KEYUP: + return DSA_KeyEvent_c(hWnd, uMsg, wParam, lParam, NULL, buttonState); + + case WM_ACTIVATE: + if ((wParam == WA_ACTIVE) || (wParam == WA_CLICKACTIVE)) + { + DSA_activeScreen = NULL; + } + + if (((wParam & 0xffff) != WA_ACTIVE) || DSA_deactivate) + { + return 0; + } + + DSA_deactivate = 1; + DSA_ActivateApp_c(1); + DSA_ActivatePal_c(); + break; + + case WM_ACTIVATEAPP: +#if defined(__WINE__) + // change: workaround + return 0; +#endif + DSA_activated = wParam & 0xff; + if (DSA_deactivate) + { + if (!DSA_activated) + { + DSA_ActivateApp_c(DSA_activated); + } + + if (DSA_hPalette != NULL) + { + UnrealizeObject(DSA_hPalette); + hDC = GetDC(hWnd); + if (hDC != NULL) + { + hPrevPal = SelectPalette(hDC, DSA_hPalette, FALSE); + RealizePalette(hDC); + SelectPalette(hDC, hPrevPal, FALSE); + ReleaseDC(hWnd, hDC); + } + } + } + break; + + case WM_PALETTECHANGED: + if (((HWND)wParam == hWnd) || (!DSA_deactivate)) + { + break; + } + // @fallthrough@ + case WM_QUERYNEWPALETTE: + mappedPaletteEntries = 0; + if (DSA_deactivate) + { + if ( DSA_hPalette ) + { + hDC = GetDC(hWnd); + if (hDC != NULL) + { + hPrevPal = SelectPalette(hDC, DSA_hPalette, FALSE); + if (hPrevPal != NULL) + { + DSA_SetColorTable_c(); + mappedPaletteEntries = RealizePalette(hDC); + SelectPalette(hDC, hPrevPal, FALSE); + ReleaseDC(hWnd, hDC); + } + } + } + return mappedPaletteEntries; + } + break; + + case WM_CREATE: + SetWindowLongA(hWnd, BBDSA_EXTRA_BUTTON_STATE, 0); + SetWindowLongA(hWnd, BBDSA_EXTRA_RESIZING_MODE, 0); + SetWindowLongA(hWnd, BBDSA_EXTRA_PALETTE_REMAPPING, 0); + // change: remove unused + //DSA_hDesktopWnd = GetDesktopWindow(); + //dword_10016680 = (int)GetSystemMenu(hWnd, 0); + break; + + case WM_MOVE: + case WM_SIZE: + break; + + case WM_ERASEBKGND: + if ((DSA_BG_hDC != NULL) && (!IsIconic(hWnd)) && (!DSA_isBGBlack)) + { + return 1; + } + break; + + case WM_PAINT: + hDC = BeginPaint(hWnd, &paint); + if ((!DSA_isBGFixed) && (DSA_BG_hDC != NULL) && (!IsIconic(hWnd)) && (!DSA_isBGBlack)) + { + hPrevPal = SelectPalette(hDC, DSA_hPalette, FALSE); + if (hPrevPal != NULL) + { + WinGBitBlt_c( + hDC, + paint.rcPaint.left, + paint.rcPaint.top, + paint.rcPaint.right - paint.rcPaint.left, + paint.rcPaint.bottom - paint.rcPaint.top, + DSA_BG_hDC, + paint.rcPaint.left, + paint.rcPaint.top + ); + SelectPalette(hDC, hPrevPal, FALSE); + } + } + EndPaint(hWnd, &paint); + break; + + case WM_CLOSE: + DestroyWindow(hWnd); + PostQuitMessage(0); + // change: remove unused + //SYSTEM_QuitProgramFlag = 1; + //byte_1001910C = 0; + break; + + case WM_DESTROY: + PostQuitMessage(0); + break; + + case WM_MOUSEMOVE: + // change: remove unused + //BLEV_keyState = 0; + //if (wParam & MK_CONTROL) + //{ + // BLEV_keyState |= BBBLEV_BUTTON_CONTROL; + //} + //if (wParam & MK_LBUTTON) + //{ + // BLEV_keyState |= BBBLEV_BUTTON_MOUSELEFT; + //} + //if (wParam & MK_RBUTTON) + //{ + // BLEV_keyState |= BBBLEV_BUTTON_MOUSERIGHT; + //} + //if (wParam & MK_SHIFT) + //{ + // BLEV_keyState |= BBBLEV_BUTTON_SHIFT; + //} + + p_last_touched_screen = NULL; + break; + + default: + break; + } + + return DefWindowProcA(hWnd, uMsg, wParam, lParam); +} + +static LRESULT WINAPI DSA_0000_Callback_c(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + BLEV_Event event; + RECT rect; + HDC hDC; + LONG mappedPaletteEntries; + HPALETTE hPrevPal; + DSA_Screen *screen; + LONG buttonState; + LONG resizingMode; + PAINTSTRUCT paint; + + uMsg = uMsg & 0xffff; + + screen = (DSA_Screen *)GetWindowLongA(hWnd, BBDSA_EXTRA_SCREEN); + buttonState = GetWindowLongA(hWnd, BBDSA_EXTRA_BUTTON_STATE); + resizingMode = GetWindowLongA(hWnd, BBDSA_EXTRA_RESIZING_MODE); + + switch (uMsg) + { + case WM_SYSCOMMAND: + // change: remove unused + //if (!dword_100190AC) + //{ + // return 0; + //} + break; + + case WM_COMMAND: + // wParam + break; + + case WM_LBUTTONDOWN: + case WM_LBUTTONUP: + case WM_LBUTTONDBLCLK: + case WM_RBUTTONDOWN: + case WM_RBUTTONUP: + case WM_RBUTTONDBLCLK: + return DSA_MouseEvent_c(hWnd, uMsg, wParam, lParam, screen, buttonState); + + case WM_KEYDOWN: + case WM_KEYUP: + return DSA_KeyEvent_c(hWnd, uMsg, wParam, lParam, screen, buttonState); + + case WM_USER: + SetWindowLongA(hWnd, BBDSA_EXTRA_RESIZING_MODE, wParam); + return 0; + + case WM_ACTIVATE: + switch (wParam) + { + case WA_INACTIVE: + DSA_activeScreen = NULL; + SetWindowLongA(hWnd, BBDSA_EXTRA_PALETTE_REMAPPING, 0); + break; + + case WA_ACTIVE: + DSA_activeScreen = screen; + SetWindowLongA(hWnd, BBDSA_EXTRA_PALETTE_REMAPPING, 1); + break; + + case WA_CLICKACTIVE: + DSA_activeScreen = screen; + SetWindowLongA(hWnd, BBDSA_EXTRA_PALETTE_REMAPPING, 0); + break; + } + return 0; + + case WM_PALETTECHANGED: + if (((HWND)wParam == hWnd) || IsIconic(DSA_screens[0].screen->hWnd)) + { + return 0; + } + // @fallthrough@ + case WM_QUERYNEWPALETTE: + mappedPaletteEntries = 0; + hPrevPal = NULL; + if (!IsIconic(DSA_screens[0].screen->hWnd)) + { + mappedPaletteEntries = GetWindowLongA(hWnd, BBDSA_EXTRA_PALETTE_REMAPPING); + if (mappedPaletteEntries <= 0) + { + if (DSA_hPalette != NULL) + { + hDC = GetDC(hWnd); + if (hDC != NULL) + { + hPrevPal = SelectPalette(hDC, DSA_hPalette, FALSE); + if (hPrevPal != NULL) + { + mappedPaletteEntries = RealizePalette(hDC); + SelectPalette(hDC, hPrevPal, FALSE); + ReleaseDC(hWnd, hDC); + if (screen->hDC != NULL) + { + mappedPaletteEntries = WinGSetDIBColorTable_c(screen->hDC, 0, 256, DSA_colorTable); + } + } + } + } + return mappedPaletteEntries; + } + } + SetWindowLongA(hWnd, BBDSA_EXTRA_PALETTE_REMAPPING, mappedPaletteEntries - 1); + return 0; + + case WM_CREATE: + SetWindowLongA(hWnd, BBDSA_EXTRA_BUTTON_STATE, 0); + SetWindowLongA(hWnd, BBDSA_EXTRA_RESIZING_MODE, 0); + SetWindowLongA(hWnd, BBDSA_EXTRA_PALETTE_REMAPPING, 0); + return 0; + + case WM_MOVE: + case WM_SIZE: + return 0; + + case WM_ERASEBKGND: + if (!resizingMode) + { + return 1; + } + break; + + case WM_PAINT: + hDC = BeginPaint(hWnd, &paint); + if ((paint.rcPaint.right == paint.rcPaint.left) || + (paint.rcPaint.bottom == paint.rcPaint.top) || + resizingMode || + IsIconic(hWnd) + ) + { + if (resizingMode == 1) + { + GetClientRect(hWnd, &rect); + SaveDC(hDC); + + SelectObject(hDC, GetStockObject(WHITE_PEN)); + + MoveToEx(hDC, 0, rect.bottom - 1, 0); + LineTo(hDC, 0, 0); + LineTo(hDC, rect.right - 1, 0); + + MoveToEx(hDC, 1, rect.bottom - 2, 0); + LineTo(hDC, 1, 1); + LineTo(hDC, rect.right - 2, 1); + + MoveToEx(hDC, 0, rect.bottom - 1, 0); + LineTo(hDC, rect.right - 1, rect.bottom - 1); + LineTo(hDC, rect.right - 1, 0); + + MoveToEx(hDC, 1, rect.bottom - 2, 0); + LineTo(hDC, rect.right - 2, rect.bottom - 2); + LineTo(hDC, rect.right - 2, 1); + + RestoreDC(hDC, -1); + } + } + else + { + hPrevPal = SelectPalette(hDC, DSA_hPalette, FALSE); + if (hPrevPal != NULL) + { + WinGBitBlt_c( + hDC, + paint.rcPaint.left, + paint.rcPaint.top, + paint.rcPaint.right - paint.rcPaint.left, + paint.rcPaint.bottom - paint.rcPaint.top, + screen->hDC, + paint.rcPaint.left, + paint.rcPaint.top + ); + SelectPalette(hDC, hPrevPal, FALSE); + } + } + EndPaint(hWnd, &paint); + return 0; + + case WM_CLOSE: + DestroyWindow(hWnd); + return 0; + + case WM_DESTROY: + return 0; + + case WM_MOUSEMOVE: + // change: remove unused + //BLEV_keyState = 0; + //if (wParam & MK_CONTROL) + //{ + // BLEV_keyState |= BBBLEV_BUTTON_CONTROL; + //} + //if (wParam & MK_LBUTTON) + //{ + // BLEV_keyState |= BBBLEV_BUTTON_MOUSELEFT; + //} + //if (wParam & MK_RBUTTON) + //{ + // BLEV_keyState |= BBBLEV_BUTTON_MOUSERIGHT; + //} + //if (wParam & MK_SHIFT) + //{ + // BLEV_keyState |= BBBLEV_BUTTON_SHIFT; + //} + + p_last_touched_screen = screen; + if (screen->flags & BBDSA_UNKNOWN1) + { + event.type = BBBLEV_TYPE_MOUSEMOVE; + event.screen = screen; + event.buttonState = 0; + event.key = 0; + event.x = lParam & 0xffff; + event.y = lParam >> 16; + BLEV_PutEvent_c(&event); + } + return 0; + + default: + break; + } + + return DefWindowProcA(hWnd, uMsg, wParam, lParam); +} + +static LRESULT WINAPI DSA_0003_Callback_c(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + BLEV_Event event; + RECT rect; + HDC hDC; + LONG mappedPaletteEntries; + HPALETTE hPrevPal; + DSA_Screen *screen; + LONG buttonState; + LONG resizingMode; + PAINTSTRUCT paint; + + uMsg = uMsg & 0xffff; + + screen = (DSA_Screen *)GetWindowLongA(hWnd, BBDSA_EXTRA_SCREEN); + buttonState = GetWindowLongA(hWnd, BBDSA_EXTRA_BUTTON_STATE); + resizingMode = GetWindowLongA(hWnd, BBDSA_EXTRA_RESIZING_MODE); + + switch (uMsg) + { + case WM_SYSCOMMAND: + // change: remove unused + //if (!dword_100190AC) + //{ + // return 0; + //} + break; + + case WM_COMMAND: + // wParam + break; + + case WM_LBUTTONDOWN: + case WM_LBUTTONUP: + case WM_LBUTTONDBLCLK: + case WM_RBUTTONDOWN: + case WM_RBUTTONUP: + case WM_RBUTTONDBLCLK: + return DSA_MouseEvent_c(hWnd, uMsg, wParam, lParam, screen, buttonState); + + case WM_KEYDOWN: + case WM_KEYUP: + return DSA_KeyEvent_c(hWnd, uMsg, wParam, lParam, screen, buttonState); + + case WM_USER: + SetWindowLongA(hWnd, BBDSA_EXTRA_RESIZING_MODE, wParam); + return 0; + + case WM_ACTIVATE: + switch (wParam) + { + case WA_INACTIVE: + DSA_activeScreen = NULL; + SetWindowLongA(hWnd, BBDSA_EXTRA_PALETTE_REMAPPING, 0); + break; + + case WA_ACTIVE: + DSA_activeScreen = screen; + SetWindowLongA(hWnd, BBDSA_EXTRA_PALETTE_REMAPPING, 1); + break; + + case WA_CLICKACTIVE: + DSA_activeScreen = screen; + SetWindowLongA(hWnd, BBDSA_EXTRA_PALETTE_REMAPPING, 0); + break; + } + return 0; + + case WM_PALETTECHANGED: + if (((HWND)wParam == hWnd) || IsIconic(DSA_screens[0].screen->hWnd)) + { + return 0; + } + // @fallthrough@ + case WM_QUERYNEWPALETTE: + mappedPaletteEntries = 0; + hPrevPal = NULL; + if (!IsIconic(DSA_screens[0].screen->hWnd)) + { + mappedPaletteEntries = GetWindowLongA(hWnd, BBDSA_EXTRA_PALETTE_REMAPPING); + if (mappedPaletteEntries <= 0) + { + if (DSA_hPalette != NULL) + { + hDC = GetDC(hWnd); + if (hDC != NULL) + { + hPrevPal = SelectPalette(hDC, DSA_hPalette, FALSE); + if (hPrevPal != NULL) + { + mappedPaletteEntries = RealizePalette(hDC); + SelectPalette(hDC, hPrevPal, FALSE); + ReleaseDC(hWnd, hDC); + if (screen->hDC != NULL) + { + mappedPaletteEntries = WinGSetDIBColorTable_c(screen->hDC, 0, 256, DSA_colorTable); + } + } + } + } + return mappedPaletteEntries; + } + } + SetWindowLongA(hWnd, BBDSA_EXTRA_PALETTE_REMAPPING, mappedPaletteEntries - 1); + return 0; + + case WM_CREATE: + SetWindowLongA(hWnd, BBDSA_EXTRA_BUTTON_STATE, 0); + SetWindowLongA(hWnd, BBDSA_EXTRA_RESIZING_MODE, 0); + SetWindowLongA(hWnd, BBDSA_EXTRA_PALETTE_REMAPPING, 0); + return 0; + + case WM_MOVE: + case WM_SIZE: + return 0; + + case WM_ERASEBKGND: + if (!resizingMode) + { + return 1; + } + break; + + case WM_PAINT: + hDC = BeginPaint(hWnd, &paint); + if ((paint.rcPaint.right == paint.rcPaint.left) || + (paint.rcPaint.bottom == paint.rcPaint.top) || + resizingMode || + IsIconic(hWnd) + ) + { + if (resizingMode == 1) + { + GetClientRect(hWnd, &rect); + SaveDC(hDC); + + SelectObject(hDC, GetStockObject(WHITE_PEN)); + + MoveToEx(hDC, 0, rect.bottom - 1, 0); + LineTo(hDC, 0, 0); + LineTo(hDC, rect.right - 1, 0); + + MoveToEx(hDC, 1, rect.bottom - 2, 0); + LineTo(hDC, 1, 1); + LineTo(hDC, rect.right - 2, 1); + + MoveToEx(hDC, 0, rect.bottom - 1, 0); + LineTo(hDC, rect.right - 1, rect.bottom - 1); + LineTo(hDC, rect.right - 1, 0); + + MoveToEx(hDC, 1, rect.bottom - 2, 0); + LineTo(hDC, rect.right - 2, rect.bottom - 2); + LineTo(hDC, rect.right - 2, 1); + + RestoreDC(hDC, -1); + } + } + else + { + hPrevPal = SelectPalette(hDC, DSA_hPalette, FALSE); + if (hPrevPal != NULL) + { + WinGBitBlt_c( + hDC, + paint.rcPaint.left, + paint.rcPaint.top, + paint.rcPaint.right - paint.rcPaint.left, + paint.rcPaint.bottom - paint.rcPaint.top, + screen->hDC, + paint.rcPaint.left, + paint.rcPaint.top + ); + SelectPalette(hDC, hPrevPal, FALSE); + } + } + EndPaint(hWnd, &paint); + return 0; + + case WM_CLOSE: + DestroyWindow(hWnd); + return 0; + + case WM_DESTROY: + return 0; + + case WM_MOUSEMOVE: + // change: remove unused + //BLEV_keyState = 0; + //if (wParam & MK_CONTROL) + //{ + // BLEV_keyState |= BBBLEV_BUTTON_CONTROL; + //} + //if (wParam & MK_LBUTTON) + //{ + // BLEV_keyState |= BBBLEV_BUTTON_MOUSELEFT; + //} + //if (wParam & MK_RBUTTON) + //{ + // BLEV_keyState |= BBBLEV_BUTTON_MOUSERIGHT; + //} + //if (wParam & MK_SHIFT) + //{ + // BLEV_keyState |= BBBLEV_BUTTON_SHIFT; + //} + + p_last_touched_screen = screen; + if (screen->flags & BBDSA_UNKNOWN1) + { + event.type = BBBLEV_TYPE_MOUSEMOVE; + event.screen = screen; + event.buttonState = 0; + event.key = 0; + event.x = lParam & 0xffff; + event.y = lParam >> 16; + BLEV_PutEvent_c(&event); + } + return 0; + + default: + break; + } + + return DefWindowProcA(hWnd, uMsg, wParam, lParam); +} + +void DSA_GetScreenExtends_c(int32_t *width, int32_t *height) +{ + *width = GetSystemMetrics(SM_CXSCREEN); + *height = GetSystemMetrics(SM_CYSCREEN); +} + +void *DSA_GetActiveScreen_c(void) +{ + return DSA_activeScreen; +} + +void DSA_SetActiveScreen_c(DSA_Screen *screen) +{ + LONG oldValue; + + if (screen == NULL) + { + screen = DSA_screens[0].screen; + } + + oldValue = GetWindowLongA((HWND)screen->hWnd, BBDSA_EXTRA_PALETTE_REMAPPING); + SetWindowLongA((HWND)screen->hWnd, BBDSA_EXTRA_PALETTE_REMAPPING, oldValue + 1); + + if (IsIconic((HWND)DSA_screens[0].screen->hWnd)) + { + DSA_nextActiveScreen = screen; + } + else + { + DSA_activeScreen = screen; + SetActiveWindow((HWND)screen->hWnd); + DSA_nextActiveScreen = NULL; + } +} + +void *DSA_GetLastTouchedScreen_c(void) +{ + return p_last_touched_screen; +} + +void DSA_CopyPartOPMToScreen_c(DSA_Screen *screen, int x, int y, int width, int height) +{ + RECT rect; + + if (IsIconic((HWND)DSA_screens[0].screen->hWnd)) + { + return; + } + + rect.left = x; + rect.top = y; + rect.right = x + width; + rect.bottom = y + height; + + InvalidateRect((HWND)screen->hWnd, &rect, FALSE); + UpdateWindow((HWND)screen->hWnd); +} + +int DSA_ScreenVisibility_c(DSA_Screen *screen, int show) +{ + BOOL res; + + res = FALSE; + if (show & 0xff) + { + screen->flags |= BBDSA_VISIBLE; + if (!IsIconic((HWND)DSA_screens[0].screen->hWnd)) + { + res = ShowWindow((HWND)screen->hWnd, SW_SHOWNORMAL); + } + } + else + { + screen->flags &= ~BBDSA_VISIBLE; + res = ShowWindow((HWND)screen->hWnd, SW_HIDE); + } + + return (res)?1:0; +} + +int DSA_LoadBackground_c(const char *path) +{ + unsigned int bgWidth, bgHeight; + void *lib; + GFX_struct *gfx; + + lib = LBL_OpenLib_c(path, 1); + if (lib == NULL) + { + return 0; + } + + gfx = (GFX_struct *)LBL_ReadEntry_c(lib, NULL, 0, 1, NULL); + if (gfx == NULL) + { + LBL_CloseLib_c(lib); + // change: added return + return 0; + } + + LBL_CloseLib_c(lib); + + bgHeight = GetSystemMetrics(SM_CYBORDER) + sl_screenheight + 8; + // change: fix bug + //bgWidth = ((GetSystemMetrics(SM_CXBORDER) / 4) * 4) + sl_screenwidth + 4; + bgWidth = ((GetSystemMetrics(SM_CXBORDER) / 4) * 4) + ((sl_screenwidth + 3) & ~3) + 4; + if (!OPM_New_c(bgWidth, bgHeight, 1, &DSA_pixelMapBG, NULL)) + { + MEM_free_c(gfx); + return 0; + } + + DSA_BG_hDC = (HDC)DSA_pixelMapBG.hDC; + DSA_BG_hBitmap = (HGDIOBJ)DSA_pixelMapBG.hBitmap; + DSA_BG_buffer = DSA_pixelMapBG.buffer; + + if (gfx->width <= sl_screenwidth) + { + memset(DSA_pixelMapBG.buffer, 0, DSA_pixelMapBG.height * DSA_pixelMapBG.width); + OPM_CopyGFXOPM_c(&DSA_pixelMapBG, gfx, (sl_screenwidth / 2) - (gfx->width >> 1), sl_screenheight - gfx->height, 0); + DSA_BG_offsetX = (sl_screenwidth / 2) - (gfx->width >> 1); + DSA_BG_offsetY = sl_screenheight - gfx->height; + } + else + { + OPM_CopyGFXOPM_c(&DSA_pixelMapBG, gfx, -((gfx->width - sl_screenwidth) / 2), 1 - (gfx->height - sl_screenheight), 0); + DSA_BG_offsetX = -((gfx->width - sl_screenwidth) / 2); + DSA_BG_offsetY = 1 - (gfx->height - sl_screenheight); + } + + MEM_free_c(gfx); + + DSA_screens[0].screen->hDC = DSA_BG_hDC; + DSA_screens[0].screen->opm = &DSA_pixelMapBG; + // change: fix error + //DSA_screens[0].screen->hBitmap = DSA_pixelMapBG.buffer; + DSA_screens[0].screen->hBitmap = DSA_pixelMapBG.hBitmap; + DSA_screens[0].screen->size = DSA_pixelMapBG.size; + + InvalidateRect((HWND)DSA_screens[0].screen->hWnd, NULL, FALSE); + UpdateWindow((HWND)DSA_screens[0].screen->hWnd); + + return 1; +} + +void DSA_GetPalette_c(DSA_Palette *palette) +{ + memmove(palette, &DSA_palette, sizeof(DSA_Palette)); +} + +void DSA_FixBackground_c(int isFixed) +{ + isFixed = isFixed & 0xff; + + DSA_isBGFixed = isFixed; + if (!isFixed) + { + InvalidateRect((HWND)DSA_screens[0].screen->hWnd, NULL, FALSE); + SYSTEM_SystemTask_c(); + } +} + +void DSA_SetCapture_c(DSA_Screen *screen) +{ + if (screen != NULL) + { + SetCapture((HWND)screen->hWnd); + } + else + { + ReleaseCapture(); + } +} + +void DSA_SystemTask_c(void) +{ + int isVisible, index; + + isVisible = (IsIconic((HWND)DSA_screens[0].screen->hWnd) == 0)?1:0; + + if (!isVisible && DSA_wasVisible) + { + InvalidateRect(NULL, NULL, TRUE); + } + else + { + if (isVisible || DSA_wasVisible) + { + if (isVisible && !DSA_wasVisible) + { + DSA_ActivatePal_c(); + + for (index = 1; index < 64; index++) + { + if (DSA_screens[index].screen != NULL) + { + if (DSA_screens[index].screen->flags & BBDSA_VISIBLE) + { + ShowWindow((HWND)DSA_screens[index].screen->hWnd, SW_SHOWNORMAL); + } + else + { + ShowWindow((HWND)DSA_screens[index].screen->hWnd, SW_HIDE); + } + } + } + + DSA_ActivatePal_c(); + + if (DSA_nextActiveScreen != NULL) + { + DSA_SetActiveScreen_c(DSA_nextActiveScreen); + DSA_nextActiveScreen = NULL; + } + + DSA_TotalRepaint_c(); + } + else + { + if ((DSA_BG_hDC != NULL) && DSA_isBGInRAM) + { + OPM_AccessBitmap_c(&DSA_pixelMapBG); + } + } + } + } + + DSA_wasVisible = isVisible; +} + +int DSA_SetBackgroundInRAM_c(int value) +{ + int oldvalue; + + oldvalue = DSA_isBGInRAM; + DSA_isBGInRAM = value & 0xff; + return oldvalue; +} + +void DSA_SetPal_c(int unused, DSA_Palette *palette, unsigned int src_start_entry, unsigned int num_entries, unsigned int dst_start_entry) +{ + unsigned int src_index, dst_index, counter; + + src_index = src_start_entry & 0xffff; + dst_index = dst_start_entry & 0xffff; + num_entries = num_entries & 0xffff; + + for (counter = 0; counter < num_entries && src_index < palette->palNumEntries && dst_index < 256; counter++) + { + if (palette->palPalEntry[src_index].peRed == 0) + { + palette->palPalEntry[src_index].peRed = 1; + } + if (palette->palPalEntry[src_index].peRed == 255) + { + palette->palPalEntry[src_index].peRed = 254; + } + if (palette->palPalEntry[src_index].peGreen == 0) + { + palette->palPalEntry[src_index].peGreen = 1; + } + if (palette->palPalEntry[src_index].peGreen == 255) + { + palette->palPalEntry[src_index].peGreen = 254; + } + if (palette->palPalEntry[src_index].peBlue == 0) + { + palette->palPalEntry[src_index].peBlue = 1; + } + if (palette->palPalEntry[src_index].peBlue == 255) + { + palette->palPalEntry[src_index].peBlue = 254; + } + + DSA_palette.palPalEntry[dst_index].peRed = palette->palPalEntry[src_index].peRed; + DSA_palette.palPalEntry[dst_index].peGreen = palette->palPalEntry[src_index].peGreen; + DSA_palette.palPalEntry[dst_index].peBlue = palette->palPalEntry[src_index].peBlue; + + DSA_paletteEntries[dst_index].peRed = palette->palPalEntry[src_index].peRed; + DSA_paletteEntries[dst_index].peGreen = palette->palPalEntry[src_index].peGreen; + DSA_paletteEntries[dst_index].peBlue = palette->palPalEntry[src_index].peBlue; + + DSA_colorTable[dst_index].rgbRed = palette->palPalEntry[src_index].peRed; + DSA_colorTable[dst_index].rgbGreen = palette->palPalEntry[src_index].peGreen; + DSA_colorTable[dst_index].rgbBlue = palette->palPalEntry[src_index].peBlue; + + src_index++; + dst_index++; + } + + DSA_palette.palPalEntry[255].peRed = 255; + DSA_palette.palPalEntry[255].peGreen = 255; + DSA_palette.palPalEntry[255].peBlue = 255; + DSA_palette.palPalEntry[0].peRed = 0; + DSA_palette.palPalEntry[0].peGreen = 0; + DSA_palette.palPalEntry[0].peBlue = 0; + + DSA_paletteEntries[255].peRed = 255; + DSA_paletteEntries[255].peGreen = 255; + DSA_paletteEntries[255].peBlue = 255; + DSA_paletteEntries[0].peRed = 0; + DSA_paletteEntries[0].peGreen = 0; + DSA_paletteEntries[0].peBlue = 0; + + DSA_colorTable[255].rgbRed = 255; + DSA_colorTable[255].rgbGreen = 255; + DSA_colorTable[255].rgbBlue = 255; + DSA_colorTable[0].rgbRed = 0; + DSA_colorTable[0].rgbGreen = 0; + DSA_colorTable[0].rgbBlue = 0; +} + +void DSA_ActivatePal_c(void) +{ + int index; + + if (DSA_hPalette == NULL) + { + return; + } + + for (index = 0; index < 256; index++) + { + DSA_paletteEntries[index].peFlags = PC_NOCOLLAPSE; + DSA_colorTable[index].rgbReserved = 0; + } + + DSA_paletteEntries[0].peFlags = 0; + DSA_paletteEntries[255].peFlags = 0; + + SetPaletteEntries(DSA_hPalette, 0, 256, DSA_paletteEntries); + + if (SYSTEM_IsApplicationActive_c()) + { + for (index = 0; index < 64; index++) + { + if (DSA_screens[index].used) + { + SendMessageA((HWND)DSA_screens[index].screen->hWnd, WM_QUERYNEWPALETTE, 0, 0); + } + } + } +} + +static void DSA_ActivateApp_c(int isActive) +{ + int index; + HDC hDC; + + hDC = GetDC(NULL); + + if (isActive && (GetSystemPaletteUse(hDC) == SYSPAL_STATIC)) + { + for (index = 0; index < 19; index++) + { + DSA_systemColors[index] = GetSysColor(DSA_elements[index]); + } + + ClipCursor(NULL); + + if (DSA_bitsPerPixel == 8) + { + SetSystemPaletteUse(hDC, SYSPAL_NOSTATIC); + SetSysColors(19, DSA_elements, DSA_elementColors); + } + + DSA_MapPalette_c(NULL); + FX_ReserveDevices_c(1); + b_application_active = 1; + } + else if (!isActive) + { + DSA_MapPalette_c(DSA_systemPalette); + + if (DSA_bitsPerPixel == 8) + { + SetSystemPaletteUse(hDC, SYSPAL_STATIC); + SetSysColors(19, DSA_elements, DSA_systemColors); + } + + ClipCursor(NULL); + FX_ReserveDevices_c(0); + ShowWindow(DSAWIN_GetMainWindowHandle_c(), SW_MINIMIZE); + SetCursor(LoadCursorA(NULL, (LPCSTR)IDC_ARROW)); + DSA_deactivate = 0; + b_application_active = 0; + InvalidateRect(NULL, NULL, TRUE); + } + + ReleaseDC(NULL, hDC); +} + +static void DSA_SetColorTable_c(void) +{ + OPM_struct *opm; + + LL_Reset_c(DSA_pixelMapList); + while (1) + { + opm = (OPM_struct *)LL_GetData_c(DSA_pixelMapList); + if (opm == NULL) + { + break; + } + + if (opm->hDC != NULL) + { + WinGSetDIBColorTable_c(opm->hDC, 0, 256, DSA_colorTable); + } + + LL_GotoNext_c(DSA_pixelMapList); + } +} + +void DSA_PreventPaletteRemapping_c(int valueAdd) +{ + int index; + LONG oldValue; + + if (valueAdd < 0) + { + return; + } + + for (index = 0; index < 64; index++) + { + if (DSA_screens[index].used) + { + oldValue = GetWindowLongA((HWND)DSA_screens[index].screen->hWnd, BBDSA_EXTRA_PALETTE_REMAPPING); + SetWindowLongA((HWND)DSA_screens[index].screen->hWnd, BBDSA_EXTRA_PALETTE_REMAPPING, oldValue + valueAdd); + } + } +} + +int DSA_GetBackgroundOffset_c(int32_t *offsetX, int32_t *offsetY) +{ + if (DSA_BG_hDC == NULL) + { + return 0; + } + + *offsetX = DSA_BG_offsetX; + *offsetY = DSA_BG_offsetY; + return 1; +} + +void DSA_SetBackground2Black_c(int isBlack) +{ + DSA_isBGBlack = isBlack & 0xff; + InvalidateRect((HWND)DSA_screens[0].screen->hWnd, NULL, TRUE); + UpdateWindow((HWND)DSA_screens[0].screen->hWnd); +} + +int DSA_MarkBitmapAsDirty_c(int param1, int param2) +{ + if (param2) + { + return DSA_isBitmapDirty; + } + else + { + DSA_isBitmapDirty = 1; + return 0xAD03; + } +} + diff --git a/games/Battle Isle 3/SR-BI3/BBDSA.h b/games/Battle Isle 3/SR-BI3/BBDSA.h new file mode 100644 index 0000000..5324fb2 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBDSA.h @@ -0,0 +1,107 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_BBDSA_H_INCLUDED_) +#define _BBDSA_H_INCLUDED_ + +#include +#include "BBOPM.h" + + +#pragma pack(1) + +typedef struct __attribute__ ((__packed__)) _DSA_Screen { + uint32_t unknown_00; + OPM_struct *opm; + uint32_t unknown_08; + uint32_t type; + void *hWnd; + uint32_t flags; + void *hDC; + void *hBitmap; + uint32_t size; +} DSA_Screen; + +typedef struct __attribute__ ((__packed__)) _DSA_Palette { + uint16_t palNumEntries; + uint16_t palVersion; + struct { + uint8_t peRed; + uint8_t peGreen; + uint8_t peBlue; + uint8_t peFlags; + } palPalEntry[256]; +} DSA_Palette; + +#pragma pack() + + +#ifdef __cplusplus +extern "C" { +#endif + +void DSA_ReuseStaticColors_c(unsigned int osVersions); +void DSA_FreeStaticColors_c(unsigned int osVersions); +void DSAWIN_PrepareInit_c(void *hInstance); +void *DSAWIN_GetMainWindowHandle_c(void); +void *DSAWIN_GetInstance_c(void); +int DSA_Init_c(void); +void DSA_Exit_c(void); +int DSA_OpenScreen_c(DSA_Screen *screen, OPM_struct *opm, int param3, const char *windowName, int x, int y, int type); +void DSA_CloseScreen_c(DSA_Screen *screen); +void DSA_CopyMainOPMToScreen_c(DSA_Screen *screen, int onlyModified); +void DSA_StretchOPMToScreen_c(DSA_Screen *screen, int xDst, int yDst, int widthDst, int heightDst, OPM_struct *opm, int xSrc, int ySrc, int widthSrc, int heightSrc); +void DSA_CopyOPMToScreenEx_c(DSA_Screen *screen, int xDst, int yDst, int width, int height, OPM_struct *opm, int xSrc, int ySrc); +void DSA_TotalRepaint_c(void); +void DSA_MoveScreen_c(DSA_Screen *screen, int changeX, int changeY); +int DSA_ResizeScreen_c(DSA_Screen *screen, OPM_struct *opm, int redraw); +int DSA_DrawSizingScreen_c(DSA_Screen *screen, int16_t *rect); +void DSA_EnterResizingMode_c(DSA_Screen *screen); +void DSA_LeaveResizingMode_c(DSA_Screen *screen); +void DSA_GetDSAMetrics_c(DSA_Screen *screen, int32_t *x, int32_t *y, int32_t *width, int32_t *height, uint8_t *isVisible); +void DSA_SetDSAPos_c(DSA_Screen *screen, int x, int y, int repaint); +void DSA_GetScreenExtends_c(int32_t *width, int32_t *height); +void *DSA_GetActiveScreen_c(void); +void DSA_SetActiveScreen_c(DSA_Screen *screen); +void *DSA_GetLastTouchedScreen_c(void); +void DSA_CopyPartOPMToScreen_c(DSA_Screen *screen, int x, int y, int width, int height); +int DSA_ScreenVisibility_c(DSA_Screen *screen, int show); +int DSA_LoadBackground_c(const char *path); +void DSA_GetPalette_c(DSA_Palette *palette); +void DSA_FixBackground_c(int isFixed); +void DSA_SetCapture_c(DSA_Screen *screen); +void DSA_SystemTask_c(void); +int DSA_SetBackgroundInRAM_c(int value); +void DSA_SetPal_c(int unused, DSA_Palette *palette, unsigned int src_start_entry, unsigned int num_entries, unsigned int dst_start_entry); +void DSA_ActivatePal_c(void); +void DSA_PreventPaletteRemapping_c(int valueAdd); +int DSA_GetBackgroundOffset_c(int32_t *offsetX, int32_t *offsetY); +void DSA_SetBackground2Black_c(int isBlack); +int DSA_MarkBitmapAsDirty_c(int param1, int param2); + +#ifdef __cplusplus +} +#endif + +#endif /* _BBDSA_H_INCLUDED_ */ diff --git a/games/Battle Isle 3/SR-BI3/BBFX.c b/games/Battle Isle 3/SR-BI3/BBFX.c new file mode 100644 index 0000000..1ee7cb9 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBFX.c @@ -0,0 +1,505 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "BBFX.h" +#include "BBDOS.h" +#include "BBMEM.h" +#include + + +#define GETLE32(_buf,_index) ( ((uint32_t)_buf[_index]) | (((uint32_t)_buf[(_index) + 1]) << 8) | (((uint32_t)_buf[(_index) + 2]) << 16) | (((uint32_t)_buf[(_index) + 3]) << 24) ) +#define GETLE16(_buf,_index) ( ((uint32_t)_buf[_index]) | (((uint32_t)_buf[(_index) + 1]) << 8) ) + + +typedef struct _FX_struct { + uint8_t *total_ptr; + int total_size; + int priority; + int ID; + int remaining_loops; + uint8_t *remaining_ptr; + int remaining_size; +} FX_struct; + + +static int FX_initialized = 0; +static int FX_reserved = 0; +static int FX_counter = 0; +static int FX_waveOpened = 0; +static HWAVEOUT FX_hWaveOut = NULL; +static UINT_PTR FX_timerID = 0; +static WAVEHDR FX_waveHeaders[2] = {{0, 0, 0, 0, 0, 0, NULL, 0}, {0, 0, 0, 0, 0, 0, NULL, 0}}; +static unsigned int FX_volume = 65535; +static int FX_inTimer = 0; +static int FX_outputEnabled = 1; +static DWORD FX_originalVolume = 0; +static int FX_deviceReserved = 0; +static const WAVEFORMATEX FX_waveFormat = {WAVE_FORMAT_PCM, 1, 11025, 11025, 1, 8, 0}; +static int FX_sampleID[4]; +static uint8_t FX_waveBuffers[2][2756]; +static FX_struct FX_playingSamples[4]; +static void *FX_libraries[128]; + + +static void FX_StopPlaying_c(void) +{ + int index; + + if (!FX_deviceReserved) + { + return; + } + + waveOutReset(FX_hWaveOut); + + if (FX_timerID != 0) + { + KillTimer(0, FX_timerID); + FX_timerID = 0; + } + + for (index = 0; index < 4; index++) + { + FX_playingSamples[index].total_size = 0; + FX_playingSamples[index].remaining_size = 0; + } +} + +int FX_Init_c(void) +{ + int index; + + if (!FX_initialized) + { + for (index = 0; index < 128; index++) + { + FX_libraries[index] = NULL; + } + + for (index = 0; index < 2756; index++) + { + FX_waveBuffers[0][index] = FX_waveBuffers[1][index] = 0x80; + } + + FX_deviceReserved = (FX_ReserveDevices_c(1))?1:0; + } + + FX_initialized++; + return 1; +} + +void FX_Exit_c(void) +{ + int index; + + FX_initialized--; + if (FX_initialized > 0) + { + return; + } + + FX_ReserveDevices_c(0); + + for (index = 0; index < 128; index++) + { + if (FX_libraries[index] != NULL) + { + MEM_free_c(FX_libraries[index]); + FX_libraries[index] = NULL; + } + } + + FX_deviceReserved = 0; +} + +int FX_ReserveDevices_c(int reserve) +{ + WAVEOUTCAPS caps; + int index; + + if ((!FX_deviceReserved) && (FX_initialized > 0)) + { + return 0; + } + + if (reserve & 0xff) + { + if (FX_reserved) + { + return 1; + } + + + if (MMSYSERR_NOERROR != waveOutOpen(&FX_hWaveOut, WAVE_MAPPER, &FX_waveFormat, 0, 0, WAVE_ALLOWSYNC)) + { + FX_waveOpened = 0; + FX_hWaveOut = NULL; + return 0; + } + + FX_waveOpened = 1; + FX_reserved = 1; + + waveOutGetDevCapsA(WAVE_MAPPER, &caps, sizeof(WAVEOUTCAPS)); + waveOutGetVolume(FX_hWaveOut, &FX_originalVolume); + waveOutSetVolume(FX_hWaveOut, (FX_volume & 0xffff) | ((FX_volume & 0xffff) << 16)); + + for (index = 0; index < 2; index++) + { + FX_waveHeaders[index].lpData = (LPSTR) &(FX_waveBuffers[index]); + FX_waveHeaders[index].dwBufferLength = 2756; + FX_waveHeaders[index].dwFlags = 0; + FX_waveHeaders[index].dwLoops = 0; + + if (MMSYSERR_NOERROR != waveOutPrepareHeader(FX_hWaveOut, &(FX_waveHeaders[index]), sizeof(WAVEHDR))) + { + for (index--; index >= 0; index--) + { + waveOutUnprepareHeader(FX_hWaveOut, &(FX_waveHeaders[index]), sizeof(WAVEHDR)); + } + + waveOutClose(FX_hWaveOut); + FX_waveOpened = 0; + FX_hWaveOut = NULL; + return 0; + } + } + + for (index = 0; index < 4; index++) + { + FX_playingSamples[index].total_ptr = NULL; + FX_playingSamples[index].total_size = 0; + FX_playingSamples[index].priority = 0; + } + + return 1; + } + else + { + if (FX_hWaveOut == NULL) + { + return 1; + } + + if (!FX_reserved) + { + return 1; + } + + FX_StopPlaying_c(); + + for (index = 0; index < 2; index++) + { + waveOutUnprepareHeader(FX_hWaveOut, &(FX_waveHeaders[index]), sizeof(WAVEHDR)); + } + + waveOutSetVolume(FX_hWaveOut, (FX_originalVolume & 0xffff) | ((FX_originalVolume & 0xffff) << 16)); + waveOutClose(FX_hWaveOut); + FX_hWaveOut = NULL; + FX_waveOpened = 0; + FX_reserved = 0; + + return 1; + } +} + +int FX_ReadLib_c(const char *path) +{ + int index; + + for (index = 0; index < 128; index++) + { + if (FX_libraries[index] == NULL) break; + } + + if (index >= 128) + { + return -1; + } + + FX_libraries[index] = DOS_ReadFile_c(path, NULL); + if (FX_libraries[index] == NULL) + { + return -1; + } + + return index; +} + +void FX_FreeLib_c(int lib_handle) +{ + if ((lib_handle >= 0) && (lib_handle < 128)) + { + if (FX_libraries[lib_handle] != NULL) + { + MEM_free_c(FX_libraries[lib_handle]); + FX_libraries[lib_handle] = NULL; + } + } +} + +void FX_StopAllSamples_c(void) +{ + if (FX_waveOpened) + { + FX_StopPlaying_c(); + } +} + +static VOID CALLBACK FX_TimerFunc(HWND a1, UINT a2, UINT_PTR a3, DWORD a4) +{ + uint8_t *buffer; + unsigned int accum; + uint8_t *samples_ptr[4]; + int header; + int num_samples; + int index; + int samples_size[4]; + int buf_index; + + header = -1; + num_samples = 0; + + if (FX_inTimer) + { + return; + } + + FX_inTimer = 1; + + if (FX_waveHeaders[0].dwFlags & WHDR_DONE) + { + header = 0; + } + else if (FX_waveHeaders[1].dwFlags & WHDR_DONE) + { + header = 1; + } + + if (header != -1) + { + for (index = 0; index < 4; index++) + { + if (FX_playingSamples[index].remaining_size <= 0) + { + samples_ptr[index] = NULL; + FX_sampleID[index] = -1; + } + else + { + samples_ptr[index] = FX_playingSamples[index].remaining_ptr; + samples_size[index] = FX_playingSamples[index].remaining_size; + if (samples_size[index] >= 2756) + { + samples_size[index] = 2756; + } + FX_playingSamples[index].remaining_ptr += samples_size[index]; + FX_playingSamples[index].remaining_size -= samples_size[index]; + FX_sampleID[index] = FX_playingSamples[index].ID; + + if (FX_playingSamples[index].remaining_size == 0) + { + if (FX_playingSamples[index].remaining_loops <= 0) + { + FX_playingSamples[index].total_size = 0; + } + else + { + FX_playingSamples[index].remaining_ptr = FX_playingSamples[index].total_ptr; + FX_playingSamples[index].remaining_size = FX_playingSamples[index].total_size; + FX_playingSamples[index].remaining_loops--; + } + } + num_samples++; + } + } + + FX_waveHeaders[header].dwFlags &= ~WHDR_DONE; + buffer = (uint8_t *)FX_waveHeaders[header].lpData; + for (buf_index = 0; buf_index < 2756; buf_index++) + { + accum = 0; + for (index = 0; index < 4; index++) + { + if (samples_ptr[index] != NULL) + { + accum += samples_ptr[index][0]; + samples_ptr[index]++; + samples_size[index]--; + if (samples_size[index] == 0) + { + samples_ptr[index] = NULL; + } + } + else + { + accum += 0x80; + } + } + + buffer[buf_index] = accum >> 2; + } + + waveOutWrite(FX_hWaveOut, &(FX_waveHeaders[header]), sizeof(WAVEHDR)); + } + + FX_inTimer = 0; +} + +int FX_PlaySample_c(int lib_handle, int sample_number, int priority, int volume, int times_play) +{ + uint8_t *library, *entries; + unsigned int num_samples, size, sample_offset; + int index, free_sample, min_priority; + + free_sample = -1; + min_priority = 100; + + if (!FX_deviceReserved) + { + return 0; + } + + if (!FX_outputEnabled) + { + return 1; + } + + if (!FX_waveOpened) + { + return -1; + } + + if ((lib_handle < 0) || (sample_number < 0)) + { + return -1; + } + + if (lib_handle >= 128) + { + return -1; + } + + library = (uint8_t *)(FX_libraries[lib_handle]); + if (library == NULL) + { + return -1; + } + + num_samples = GETLE16(library, 8); + // change: fix condition + //if (sample_number > num_samples) + if (sample_number >= num_samples) + { + return -1; + } + + if (priority > 99) priority = 99; + if (priority < 0) priority = 0; + if (volume > 65535) volume = 65535; + if (volume < 0) volume = 0; + + entries = &(library[GETLE32(library, 0)]); + sample_offset = GETLE32(entries, 12 * sample_number + 8); + if (sample_number == (num_samples - 1)) + { + size = GETLE32(library, 0) - sample_offset; + } + else + { + size = GETLE32(entries, 12 * (sample_number + 1) + 8) - sample_offset; + } + + if (size <= 200) + { + return -1; + } + + for (index = 0; index < 4; index++) + { + if (FX_playingSamples[index].total_size == 0) + { + free_sample = index; + break; + } + + if ((priority >= FX_playingSamples[index].priority) && (min_priority >= FX_playingSamples[index].priority)) + { + free_sample = index; + min_priority = FX_playingSamples[index].priority; + } + } + + if (free_sample == -1) + { + return -1; + } + + *((volatile int *) &FX_playingSamples[free_sample].remaining_size) = 0; + *((volatile int *) &FX_playingSamples[free_sample].total_size) = 0; + + FX_playingSamples[free_sample].total_ptr = &(library[sample_offset + 50]); + FX_playingSamples[free_sample].remaining_ptr = &(library[sample_offset + 50]); + FX_playingSamples[free_sample].priority = priority; + FX_playingSamples[free_sample].remaining_loops = times_play - 1; + FX_playingSamples[free_sample].ID = FX_counter; + FX_counter++; + FX_playingSamples[free_sample].total_size = size - 200; + FX_playingSamples[free_sample].remaining_size = size - 200; + + if (FX_timerID == 0) + { + for (index = 0; index < 2; index++) + { + FX_waveHeaders[index].dwFlags |= WHDR_DONE; + } + + FX_timerID = SetTimer(0, 0, 10, FX_TimerFunc); + if (FX_timerID == 0) + { + FX_playingSamples[free_sample].priority = 0; + return -1; + } + } + + return FX_playingSamples[free_sample].ID; +} + +void FX_SetVolume_c(unsigned int volume) +{ + if (!FX_deviceReserved) + { + return; + } + + waveOutSetVolume(FX_hWaveOut, (volume & 0xffff) | ((volume & 0xffff) << 16)); + FX_volume = volume; + FX_outputEnabled = (volume != 0)?1:0; +} + +int FM_IsError_c(void) +{ + return 0; +} + diff --git a/games/Battle Isle 3/SR-BI3/BBFX.h b/games/Battle Isle 3/SR-BI3/BBFX.h new file mode 100644 index 0000000..cbfc3cb --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBFX.h @@ -0,0 +1,48 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_BBFX_H_INCLUDED_) +#define _BBFX_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int FX_Init_c(void); +void FX_Exit_c(void); +int FX_ReserveDevices_c(int reserve); +int FX_ReadLib_c(const char *path); +void FX_FreeLib_c(int lib_handle); +void FX_StopAllSamples_c(void); +int FX_PlaySample_c(int lib_handle, int sample_number, int priority, int volume, int times_play); +void FX_SetVolume_c(unsigned int volume); +int FM_IsError_c(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _BBFX_H_INCLUDED_ */ diff --git a/games/Battle Isle 3/SR-BI3/BBLBL.c b/games/Battle Isle 3/SR-BI3/BBLBL.c new file mode 100644 index 0000000..bce88c4 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBLBL.c @@ -0,0 +1,389 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "BBLBL.h" +#include "BBMEM.h" +#include "BBDOS.h" +#include "BBDEPACK.h" +#include +#include +#define WIN32_LEAN_AND_MEAN +#include + + +#define GETLE32(_buf,_index) ( ((uint32_t)_buf[_index]) | (((uint32_t)_buf[(_index) + 1]) << 8) | (((uint32_t)_buf[(_index) + 2]) << 16) | (((uint32_t)_buf[(_index) + 3]) << 24) ) +#define GETLE16(_buf,_index) ( ((uint32_t)_buf[_index]) | (((uint32_t)_buf[(_index) + 1]) << 8) ) + + +typedef struct _LBL_Entry { + unsigned int offset; + unsigned int size; + unsigned int uncompressed_size; + uint8_t name[8]; +} LBL_Entry; + +typedef struct _LBL_Library { + unsigned int entries_offset; + //unsigned int field_4; + unsigned int num_entries; + //unsigned int field_A; + LBL_Entry *entries; + int file_handle; + int current_entry; + char path[MAX_PATH]; // change: increase path length +} LBL_Library; + + +static int LBL_initialized = 0; + + +int LBL_Init_c(void) +{ + LBL_initialized++; + return 1; +} + +void LBL_Exit_c(void) +{ + if (LBL_initialized > 0) + { + LBL_initialized--; + } +} + +void *LBL_OpenLib_c(const char *path, int param2) +{ + LBL_Library *library; + uint8_t buffer12[12]; + unsigned int index; + + if (!LBL_initialized) + { + return NULL; + } + + library = (LBL_Library *)MEM_malloc_c(sizeof(LBL_Library), NULL, NULL, 0, 0); + if (library == NULL) + { + return NULL; + } + + library->file_handle = DOS_Open_c(path, DOS_OPEN_MODE_READ); + if (library->file_handle == -1) + { + MEM_free_c(library); + return NULL; + } + + if (DOS_Read_c(library->file_handle, buffer12, 12) != 12) + { + DOS_Close_c(library->file_handle); + MEM_free_c(library); + return NULL; + } + + library->entries_offset = GETLE32(buffer12, 0); + //library->field_4 = GETLE32(buffer12, 4); + library->num_entries = GETLE16(buffer12, 8); + //library->field_A = GETLE16(buffer12, 10); + + library->entries = (LBL_Entry *)MEM_malloc_c(sizeof(LBL_Entry) * (library->num_entries + 1), NULL, NULL, 0, 0); + if (library->entries == NULL) + { + DOS_Close_c(library->file_handle); + MEM_free_c(library); + return NULL; + } + + // change: replace nonsense condition + //if ((DOS_Seek_c(library->file_handle, DOS_SEEK_SET, library->entries_offset) & 0xff) == -1) + if (!DOS_Seek_c(library->file_handle, DOS_SEEK_SET, library->entries_offset)) + { + DOS_Close_c(library->file_handle); + MEM_free_c(library->entries); + MEM_free_c(library); + return NULL; + } + + for (index = 0; index < library->num_entries; index++) + { + if (DOS_Read_c(library->file_handle, buffer12, 12) != 12) + { + DOS_Close_c(library->file_handle); + MEM_free_c(library->entries); + MEM_free_c(library); + return NULL; + } + + library->entries[index].offset = GETLE32(buffer12, 8); + library->entries[index].size = 0; + library->entries[index].uncompressed_size = 0; + memmove(library->entries[index].name, buffer12, 8); + } + + for (index = 0; index < library->num_entries; index++) + { + if (index >= (library->num_entries - 1)) + { + library->entries[index].size = library->entries_offset - library->entries[index].offset; + } + else + { + library->entries[index].size = library->entries[index + 1].offset - library->entries[index].offset; + } + + if (param2 & 0xff) + { + // change: replace nonsense condition + //if ((DOS_Seek_c(library->file_handle, DOS_SEEK_SET, library->entries[index].offset) & 0xff) == -1) + if (!DOS_Seek_c(library->file_handle, DOS_SEEK_SET, library->entries[index].offset)) + { + DOS_Close_c(library->file_handle); + MEM_free_c(library->entries); + MEM_free_c(library); + return NULL; + } + + if (DOS_Read_c(library->file_handle, buffer12, 8) != 8) + { + DOS_Close_c(library->file_handle); + MEM_free_c(library->entries); + MEM_free_c(library); + return NULL; + } + + if (0 == memcmp(buffer12, "TPWM", 4)) + { + library->entries[index].uncompressed_size = GETLE32(buffer12, 4); + } + } + } + + strncpy(library->path, path, MAX_PATH); // change: increase path length + library->current_entry = -1; + + DOS_Close_c(library->file_handle); + library->file_handle = -1; + + return library; +} + +void *LBL_ReadEntry_c(void *lib, void *entry_data, unsigned int entry_number, int close_file, void *entry_name) +{ + LBL_Library *library; + void *compressed_data; + unsigned int size; + void *data; + + if (!LBL_initialized) + { + return NULL; + } + + library = (LBL_Library *)lib; + + if (entry_number >= library->num_entries) + { + return NULL; + } + + if (entry_name != NULL) + { + memmove(entry_name, library->entries[entry_number].name, 8); + } + + if (library->entries[entry_number].uncompressed_size != 0) + { + size = library->entries[entry_number].uncompressed_size; + } + else + { + size = library->entries[entry_number].size; + } + + if (library->file_handle == -1) + { + library->file_handle = DOS_Open_c(library->path, DOS_OPEN_MODE_READ); + if (library->file_handle == -1) + { + return NULL; + } + } + + if (library->current_entry != entry_number) + { + // change: replace nonsense condition + //if((DOS_Seek_c(library->file_handle, DOS_SEEK_SET, library->entries[entry_number].offset) & 0xff) == -1) + if(!DOS_Seek_c(library->file_handle, DOS_SEEK_SET, library->entries[entry_number].offset)) + { + DOS_Close_c(library->file_handle); + library->file_handle = -1; + return NULL; + } + } + + library->current_entry = entry_number + 1; + + if (entry_data != NULL) + { + data = entry_data; + } + else + { + data = MEM_malloc_c(size, NULL, NULL, 0, 0); + if (data == NULL) + { + DOS_Close_c(library->file_handle); + library->file_handle = -1; + return NULL; + } + } + + if (library->entries[entry_number].uncompressed_size != 0) + { + compressed_data = MEM_malloc_c(library->entries[entry_number].size, NULL, NULL, 0, 0); + if (compressed_data == NULL) + { + DOS_Close_c(library->file_handle); + library->file_handle = -1; + if (data != entry_data) + { + MEM_free_c(data); + } + return NULL; + } + + if (DOS_Read_c(library->file_handle, compressed_data, library->entries[entry_number].size) != library->entries[entry_number].size) + { + DOS_Close_c(library->file_handle); + library->file_handle = -1; + if (data != entry_data) + { + MEM_free_c(data); + } + return NULL; + } + + DEPACK_c((const uint8_t *)compressed_data, (uint8_t *)data); + MEM_free_c(compressed_data); + } + else + { + if (DOS_Read_c(library->file_handle, data, library->entries[entry_number].size) != library->entries[entry_number].size) + { + DOS_Close_c(library->file_handle); + library->file_handle = -1; + if (data != entry_data) + { + MEM_free_c(data); + } + return NULL; + } + } + + if (close_file & 0xff) + { + DOS_Close_c(library->file_handle); + library->file_handle = -1; + library->current_entry = -1; + } + + return data; +} + +void LBL_CloseLib_c(void *lib) +{ + LBL_Library *library; + + if (!LBL_initialized) + { + return; + } + + library = (LBL_Library *)lib; + + if (library->file_handle != -1) + { + DOS_Close_c(library->file_handle); + } + MEM_free_c(library->entries); + MEM_free_c(library); +} + +int LBL_GetEntrySize_c(void *lib, unsigned int entry_number) +{ + LBL_Library *library; + + if (!LBL_initialized) + { + return -1; + } + + library = (LBL_Library *)lib; + + if (entry_number >= library->num_entries) + { + return -1; + } + + if (library->entries[entry_number].uncompressed_size != 0) + { + return library->entries[entry_number].uncompressed_size; + } + else + { + return library->entries[entry_number].size; + } +} + +void LBL_CloseFile_c(void *lib) +{ + LBL_Library *library; + + if (!LBL_initialized) + { + return; + } + + library = (LBL_Library *)lib; + + if (library->file_handle == -1) + { + return; + } + + DOS_Close_c(library->file_handle); + library->file_handle = -1; + library->current_entry = -1; +} + +int LBL_GetNOFEntries_c(void *lib) +{ + LBL_Library *library; + + library = (LBL_Library *)lib; + + return library->num_entries; +} + diff --git a/games/Battle Isle 3/SR-BI3/BBLBL.h b/games/Battle Isle 3/SR-BI3/BBLBL.h new file mode 100644 index 0000000..f650071 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBLBL.h @@ -0,0 +1,47 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_BBLBL_H_INCLUDED_) +#define _BBLBL_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int LBL_Init_c(void); +void LBL_Exit_c(void); +void *LBL_OpenLib_c(const char *path, int param2); +void LBL_CloseLib_c(void *lib); +void *LBL_ReadEntry_c(void *lib, void *entry_data, unsigned int entry_number, int close_file, void *entry_metadata); +int LBL_GetEntrySize_c(void *lib, unsigned int entry_number); +void LBL_CloseFile_c(void *lib); +int LBL_GetNOFEntries_c(void *lib); + +#ifdef __cplusplus +} +#endif + +#endif /* _BBLBL_H_INCLUDED_ */ diff --git a/games/Battle Isle 3/SR-BI3/BBLBM.c b/games/Battle Isle 3/SR-BI3/BBLBM.c new file mode 100644 index 0000000..68e1349 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBLBM.c @@ -0,0 +1,466 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "BBLBM.h" +#include "BBMEM.h" +#include "BBDSA.h" +#include "BBOPM.h" +#include "BBDOS.h" +#include +#include + + +typedef struct { + const uint8_t *buffer; + int length; + const uint8_t *bmhd_chunk; + const uint8_t *body_chunk; + const uint8_t *cmap_chunk; +} LBM_struct; + + +static int LBM_serieNumber = 0; +static char LBM_autoSaveName[13]; +static char LBM_serieName[13]; + + +static const uint8_t *LBM_FindChunk_c(LBM_struct *lbmdata, const char *chunk_id) +{ + int bufferindex, idindex, matchlength; + + for (bufferindex = 0; bufferindex < lbmdata->length; bufferindex++) + { + matchlength = 0; + for (idindex = 0; idindex < 4; idindex++) + { + if (lbmdata->buffer[bufferindex + idindex] == chunk_id[idindex]) + { + matchlength++; + } + } + + if (matchlength == 4) + { + return &(lbmdata->buffer[bufferindex]); + } + } + + return NULL; +} + +static void LBM_GetPal_c(LBM_struct *lbmdata, DSA_Palette *palette) +{ + const uint8_t *cmap_ptr; + int index; + + cmap_ptr = lbmdata->cmap_chunk + 8; + for (index = 0; index < 256; index++) + { + palette->palPalEntry[index].peRed = cmap_ptr[0]; + palette->palPalEntry[index].peGreen = cmap_ptr[1]; + palette->palPalEntry[index].peBlue = cmap_ptr[2]; + cmap_ptr += 3; + } +} + +static void LBM_DisplayLBMinOPM_c(LBM_struct *lbmdata, OPM_struct *pixel_map) +{ + const uint8_t *bmhd_ptr, *body_ptr; + int width, height, x, y, copy_length, index; + uint8_t value; + + bmhd_ptr = lbmdata->bmhd_chunk + 8; + // change: removed pointless abs + //width = abs(bmhd_ptr[1] + (bmhd_ptr[0] << 8)); + width = bmhd_ptr[1] + (bmhd_ptr[0] << 8); + // change: removed pointless abs + //height = abs(bmhd_ptr[3] + (bmhd_ptr[2] << 8)); + height = bmhd_ptr[3] + (bmhd_ptr[2] << 8); + + body_ptr = lbmdata->body_chunk + 8; + + if (bmhd_ptr[10]) + { + // compressed data + + x = 0; + y = 0; + do + { + copy_length = (int8_t)*body_ptr; + body_ptr++; + + if (copy_length < 0) + { + if (copy_length > -128) + { + value = *body_ptr; + body_ptr++; + copy_length = -copy_length; + for (index = 0; index <= copy_length; index++) + { + OPM_SetPixel_c(pixel_map, x, y, value); + x++; + } + } + } + else + { + for (index = 0; index <= copy_length; index++) + { + OPM_SetPixel_c(pixel_map, x, y, *body_ptr); + x++; + body_ptr++; + } + } + + if (x == width) + { + x = 0; + y++; + } + } + while (y < height); + } + else + { + // uncompressed data + + for (y = 0; y < height; y++) + { + for (x = 0; x < width; x++) + { + OPM_SetPixel_c(pixel_map, x, y, *body_ptr); + body_ptr++; + } + } + } +} + +int LBM_DisplayLBM_c(const char *path, void *pixel_map, uint8_t *palette, unsigned int flags) +{ + LBM_struct lbmdata; + const uint8_t *bmhd_ptr; + int width, height; + + if (flags & 0x10000) + { + lbmdata.length = 100000000; + lbmdata.buffer = (uint8_t *)path; + } + else + { + lbmdata.length = DOS_GetFileLength_c(path); + if (lbmdata.length < 0) + { + return 0; + } + + lbmdata.buffer = (uint8_t *)DOS_ReadFile_c(path, NULL); + if (lbmdata.buffer == NULL) + { + return 0; + } + } + + lbmdata.bmhd_chunk = LBM_FindChunk_c(&lbmdata, "BMHD"); + if (lbmdata.bmhd_chunk == NULL) + { + return 0; + } + + lbmdata.body_chunk = LBM_FindChunk_c(&lbmdata, "BODY"); + if (lbmdata.body_chunk == NULL) + { + return 0; + } + + lbmdata.cmap_chunk = LBM_FindChunk_c(&lbmdata, "CMAP"); + if (lbmdata.cmap_chunk == NULL) + { + return 0; + } + + if (palette != NULL) + { + LBM_GetPal_c(&lbmdata, (DSA_Palette *)palette); + } + + bmhd_ptr = lbmdata.bmhd_chunk + 8; + // change: removed pointless abs + //width = abs(bmhd_ptr[1] + (bmhd_ptr[0] << 8)); + width = bmhd_ptr[1] + (bmhd_ptr[0] << 8); + // change: removed pointless abs + //height = abs(bmhd_ptr[3] + (bmhd_ptr[2] << 8)); + height = bmhd_ptr[3] + (bmhd_ptr[2] << 8); + + if (flags & 1) + { + if (!OPM_New_c(width, height, 1, (OPM_struct *)pixel_map, NULL)) + { + return 0; + } + } + else if (flags & 2) + { + ((OPM_struct *)pixel_map)->width = width; + ((OPM_struct *)pixel_map)->height = height; + ((OPM_struct *)pixel_map)->stride = width; + ((OPM_struct *)pixel_map)->size = width * height; + ((OPM_struct *)pixel_map)->clip_x = 0; + ((OPM_struct *)pixel_map)->clip_y = 0; + ((OPM_struct *)pixel_map)->clip_width = width; + ((OPM_struct *)pixel_map)->clip_height = height; + } + + LBM_DisplayLBMinOPM_c(&lbmdata, (OPM_struct *)pixel_map); + + if (!(flags & 0x10000)) + { + MEM_free_c((void *)lbmdata.buffer); + } + + return 1; +} + +static uint8_t *LBM_WriteBE16_c(uint8_t *buffer, uint16_t value) +{ + buffer[0] = value >> 8; + buffer[1] = value & 0xff; + + return buffer + 2; +} + +static uint8_t *LBM_WriteBE32_c(uint8_t *buffer, uint32_t value) +{ + buffer[0] = value >> 24; + buffer[2] = (value >> 16) & 0xff; + buffer[3] = (value >> 8) & 0xff; + buffer[4] = value & 0xff; + + return buffer + 4; +} + +static uint8_t *LBM_WriteChunkID_c(uint8_t *buffer, const char *chunkname) +{ + int index; + + for (index = 0; index < 4; index++) + { + *buffer = chunkname[index]; + buffer++; + } + + return buffer; +} + +static void LBM_SaveLBM_c(const char *path, OPM_struct *pixel_map) +{ + uint8_t *buffer, *cur_ptr, *chunk_size_ptr[2]; + int index; + OPM_struct pm2; + DSA_Palette palette; + + buffer = (uint8_t *)MEM_malloc_c(pixel_map->height * pixel_map->width + 2000, NULL, NULL, 0, 0); + + DSA_GetPalette_c(&palette); + + // write "FORM" chunk id + chunk_size_ptr[0] = LBM_WriteChunkID_c(buffer, "FORM"); + + // write "PBM " id + cur_ptr = LBM_WriteChunkID_c(chunk_size_ptr[0] + 4, "PBM "); + + // write "BMHD" chunk id + chunk_size_ptr[1] = LBM_WriteChunkID_c(cur_ptr, "BMHD"); + + // write image width (16-bit Big Endian) + cur_ptr = LBM_WriteBE16_c(chunk_size_ptr[1] + 4, pixel_map->width); + + // write image height (16-bit Big Endian) + cur_ptr = LBM_WriteBE16_c(cur_ptr, pixel_map->height); + + // write xOrigin (16-bit Big Endian) + cur_ptr = LBM_WriteBE16_c(cur_ptr, 0); + + // write yOrigin (16-bit Big Endian) + cur_ptr = LBM_WriteBE16_c(cur_ptr, 0); + + // write numPlanes (image bpp) (8-bit) + cur_ptr[0] = 0; + + // write mask (8-bit) + cur_ptr[1] = 0; + + // write compression (8-bit) + cur_ptr[2] = 0; + + // write padding (8-bit) + cur_ptr[3] = 0; + + // write Transparent colour (16-bit Big Endian) + cur_ptr = LBM_WriteBE16_c(cur_ptr + 4, 0); + + // write xAspect (8-bit) + cur_ptr[0] = 10; + + // write yAspect (8-bit) + cur_ptr[1] = 11; + + // write pageWidth (16-bit Big Endian) + cur_ptr = LBM_WriteBE16_c(cur_ptr + 2, pixel_map->width); + + // write pageHeight (16-bit Big Endian) + cur_ptr = LBM_WriteBE16_c(cur_ptr, pixel_map->height); + + // write "BMHD" chunk size (32-bit Big Endian) + LBM_WriteBE32_c(chunk_size_ptr[1], (cur_ptr - chunk_size_ptr[1]) - 4); + + // write "CMAP" chunk id + chunk_size_ptr[1] = LBM_WriteChunkID_c(cur_ptr, "CMAP"); + + // space for "CMAP" chunk size + cur_ptr = chunk_size_ptr[1] + 4; + + // fill "CMAP" chunk + for (index = 0; index < 256; index++) + { + cur_ptr[0] = palette.palPalEntry[index].peRed; + cur_ptr[1] = palette.palPalEntry[index].peGreen; + cur_ptr[2] = palette.palPalEntry[index].peBlue; + cur_ptr += 3; + } + + // write "CMAP" chunk size (32-bit Big Endian) + LBM_WriteBE32_c(chunk_size_ptr[1], (cur_ptr - chunk_size_ptr[1]) - 4); + + // write "BODY" chunk id + chunk_size_ptr[1] = LBM_WriteChunkID_c(cur_ptr, "BODY"); + + // space for "BODY" chunk size + cur_ptr = chunk_size_ptr[1] + 4; + + OPM_New_c(pixel_map->width, pixel_map->height, 1, &pm2, cur_ptr); + + // fill "BODY" chunk + memmove(pm2.buffer, pixel_map->buffer, pixel_map->height * pixel_map->width); + cur_ptr += pixel_map->height * pixel_map->width; + + // write "BODY" chunk size (32-bit Big Endian) + LBM_WriteBE32_c(chunk_size_ptr[1], (cur_ptr - chunk_size_ptr[1]) - 4); + + // write "FORM" chunk size (32-bit Big Endian) + LBM_WriteBE32_c(chunk_size_ptr[0], (cur_ptr - chunk_size_ptr[0]) - 4); + + DOS_WriteFile_c(path, buffer, cur_ptr - buffer); + + OPM_Del_c(&pm2); + + MEM_free_c(buffer); +} + +void LBM_StartSerie_c(int number) +{ + if ((number < 0) || (number > 999)) + { + return; + } + + memmove(LBM_serieName, "Dxxx_yyy.LBM", 13); + + if (number < 100) + { + LBM_serieName[1] = '0'; + } + else + { + LBM_serieName[1] = (number / 100) + '0'; + number %= 100; + } + + if (number < 10) + { + LBM_serieName[2] = '0'; + } + else + { + LBM_serieName[2] = (number / 10) + '0'; + number %= 10; + } + + if (number < 1) + { + LBM_serieName[3] = '0'; + } + else + { + LBM_serieName[3] = number + '0'; + } + + LBM_serieNumber = 0; +} + +void LBM_AutoSave_c(void *pixel_map) +{ + if ((LBM_serieNumber < 0) || (LBM_serieNumber > 999)) + { + return; + } + + memmove(LBM_autoSaveName, LBM_serieName, 13); + + if (LBM_serieNumber < 100) + { + LBM_autoSaveName[5] = '0'; + } + else + { + LBM_autoSaveName[5] = (LBM_serieNumber / 100) + '0'; + LBM_serieNumber %= 100; + } + + if (LBM_serieNumber < 10) + { + LBM_autoSaveName[6] = '0'; + } + else + { + LBM_autoSaveName[6] = (LBM_serieNumber / 10) + '0'; + LBM_serieNumber %= 10; + } + + if (LBM_serieNumber < 1) + { + LBM_autoSaveName[7] = '0'; + } + else + { + LBM_autoSaveName[7] = LBM_serieNumber + '0'; + } + + LBM_serieNumber++; + + LBM_SaveLBM_c(LBM_autoSaveName, (OPM_struct *)pixel_map); +} + diff --git a/games/Battle Isle 3/SR-BI3/BBLBM.h b/games/Battle Isle 3/SR-BI3/BBLBM.h new file mode 100644 index 0000000..3ed7a2f --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBLBM.h @@ -0,0 +1,42 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_BBLBM_H_INCLUDED_) +#define _BBLBM_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int LBM_DisplayLBM_c(const char *path, void *pixel_map, uint8_t *palette, unsigned int flags); +void LBM_StartSerie_c(int number); +void LBM_AutoSave_c(void *pixel_map); + +#ifdef __cplusplus +} +#endif + +#endif /* _BBLBM_H_INCLUDED_ */ diff --git a/games/Battle Isle 3/SR-BI3/BBLL.c b/games/Battle Isle 3/SR-BI3/BBLL.c new file mode 100644 index 0000000..7ef065d --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBLL.c @@ -0,0 +1,323 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "BBLL.h" +#include "BBMEM.h" +#include + + +typedef struct _LL_Element { + struct _LL_Element *prev; + struct _LL_Element *next; + void *data; +} LL_Element; + +typedef struct _LL_List { + int used; + LL_Element *before_first; + LL_Element *after_last; + LL_Element *current; + unsigned int num_elements; +} LL_List; + + +static int LL_initialized = 0; +static unsigned int LL_numLists = 0; +static LL_List *LL_lists; + + +int LL_Init_c(void) +{ + if (LL_initialized) + { + return 1; + } + + LL_lists = (LL_List *)MEM_malloc_c(sizeof(LL_List), NULL, NULL, 0, 0); + if (LL_lists == NULL) + { + return 0; + } + + LL_lists->used = 0; + LL_numLists = 1; + LL_initialized = 1; + + return 1; +} + +void LL_Exit_c(void) +{ + unsigned int index; + + if (!LL_initialized) + { + return; + } + + for (index = 0; index < LL_numLists; index++) + { + if (LL_lists[index].used) + { + LL_DestroyList_c(index + 1); + } + } + + MEM_free_c(LL_lists); + LL_initialized = 0; +} + +unsigned int LL_NewList_c(void) +{ + LL_Element *before_first, *after_last; + unsigned int index; + LL_List *new_lists; + + before_first = (LL_Element *)MEM_malloc_c(sizeof(LL_Element), NULL, NULL, 0, 0); + if (before_first == NULL) + { + return 0; + } + + after_last = (LL_Element *)MEM_malloc_c(sizeof(LL_Element), NULL, NULL, 0, 0); + if (after_last == NULL) + { + MEM_free_c(before_first); + return 0; + } + + for (index = 0; index < LL_numLists; index++) + { + if (!LL_lists[index].used) break; + } + + if (index == LL_numLists) + { + new_lists = (LL_List *)MEM_malloc_c(sizeof(LL_List) * (LL_numLists + 1), NULL, NULL, 0, 0); + if (new_lists == NULL) + { + MEM_free_c(before_first); + MEM_free_c(after_last); + return 0; + } + + memmove(new_lists, LL_lists, sizeof(LL_List) * LL_numLists); + MEM_free_c(LL_lists); + LL_numLists++; + LL_lists = new_lists; + } + + LL_lists[index].before_first = before_first; + LL_lists[index].after_last = after_last; + LL_lists[index].current = NULL; + LL_lists[index].num_elements = 0; + LL_lists[index].used = 1; + + before_first->prev = NULL; + before_first->next = after_last; + after_last->prev = before_first; + after_last->next = NULL; + before_first->data = NULL; + after_last->data = NULL; + + return index + 1; +} + +int LL_AppendElement_c(unsigned int list_handle, void *data) +{ + unsigned int index; + LL_Element *prev, *new; + + if ((list_handle == 0) || ((list_handle - 1) >= LL_numLists)) + { + return 0; + } + + index = list_handle - 1; + + if (!LL_lists[index].used) + { + return 0; + } + + prev = LL_lists[index].after_last->prev; + new = (LL_Element *)MEM_malloc_c(sizeof(LL_Element), NULL, NULL, 0, 0); + if (new == NULL) + { + return 0; + } + + new->prev = prev; + new->next = prev->next; + prev->next->prev = new; + prev->next = new; + new->data = data; + LL_lists[index].num_elements++; + + return 1; +} + +void LL_Reset_c(unsigned int list_handle) +{ + unsigned int index; + + if ((list_handle == 0) || ((list_handle - 1) >= LL_numLists)) + { + return; + } + + index = list_handle - 1; + + if (!LL_lists[index].used) + { + return; + } + + if (LL_lists[index].num_elements != 0) + { + LL_lists[index].current = LL_lists[index].before_first->next; + } + else + { + LL_lists[index].current = NULL; + } +} + +void *LL_GetData_c(unsigned int list_handle) +{ + unsigned int index; + + if ((list_handle == 0) || ((list_handle - 1) >= LL_numLists)) + { + return NULL; + } + + index = list_handle - 1; + + if (!LL_lists[index].used) + { + return NULL; + } + + if (LL_lists[index].current == NULL) + { + return NULL; + } + + return LL_lists[index].current->data; +} + +int LL_GotoNext_c(unsigned int list_handle) +{ + unsigned int index; + + if ((list_handle == 0) || ((list_handle - 1) >= LL_numLists)) + { + return 0; + } + + index = list_handle - 1; + + if (!LL_lists[index].used) + { + return 0; + } + + if (LL_lists[index].current != NULL) + { + LL_lists[index].current = LL_lists[index].current->next; + if (LL_lists[index].current == LL_lists[index].after_last) + { + LL_lists[index].current = NULL; + } + } + + return (LL_lists[index].current != NULL)?1:0; +} + +int LL_DeleteElement_c(unsigned int list_handle) +{ + unsigned int index; + LL_Element *current, *next; + + if ((list_handle == 0) || ((list_handle - 1) >= LL_numLists)) + { + return 0; + } + + index = list_handle - 1; + + if (!LL_lists[index].used) + { + return 0; + } + + current = LL_lists[index].current; + if (current == NULL) + { + return 0; + } + + next = current->next; + current->prev->next = current->next; + current->next->prev = current->prev; + MEM_free_c(current); + LL_lists[index].current = next; + if (next == LL_lists[index].after_last) + { + LL_lists[index].current = NULL; + } + LL_lists[index].num_elements--; + + return 1; +} + +void LL_DestroyList_c(unsigned int list_handle) +{ + unsigned int index; + LL_Element *element, *next; + + if ((list_handle == 0) || ((list_handle - 1) >= LL_numLists)) + { + return; + } + + index = list_handle - 1; + + if (!LL_lists[index].used) + { + return; + } + + element = LL_lists[index].before_first; + while (element != NULL) + { + next = element->next; + MEM_free_c(element); + element = next; + } + + LL_lists[index].used = 0; +} + diff --git a/games/Battle Isle 3/SR-BI3/BBLL.h b/games/Battle Isle 3/SR-BI3/BBLL.h new file mode 100644 index 0000000..aaa7028 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBLL.h @@ -0,0 +1,48 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_BBLL_H_INCLUDED_) +#define _BBLL_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int LL_Init_c(void); +void LL_Exit_c(void); +unsigned int LL_NewList_c(void); +int LL_AppendElement_c(unsigned int list_handle, void *data); +void LL_Reset_c(unsigned int list_handle); +void *LL_GetData_c(unsigned int list_handle); +int LL_GotoNext_c(unsigned int list_handle); +int LL_DeleteElement_c(unsigned int list_handle); +void LL_DestroyList_c(unsigned int list_handle); + +#ifdef __cplusplus +} +#endif + +#endif /* _BBLL_H_INCLUDED_ */ diff --git a/games/Battle Isle 3/SR-BI3/BBMEM.c b/games/Battle Isle 3/SR-BI3/BBMEM.c new file mode 100644 index 0000000..527f457 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBMEM.c @@ -0,0 +1,273 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "BBMEM.h" +#include "BBDSA.h" +#include "BBDBG.h" +#include +#include +#include "WinApi-wing32.h" +#define WIN32_LEAN_AND_MEAN +#include + + +#undef ORIGINAL_MEM_ALLOC + + +#ifdef ORIGINAL_MEM_ALLOC +typedef struct _MEM_struct { + unsigned int size; + struct _MEM_struct *ptr; + unsigned int type; +} MEM_struct; +#endif + + +static int BBMEM_initialized = 0; +static void *BBMEM_PoolPointer = NULL; +#if 0 +static HDC BBMEM_hWinGDC[20]; +#endif + + +static void BBMEM_DumpLine_c(void *hFile, const char *str) +{ + // do nothing +} + +int MEM_Init_c(void) +{ +#if 0 + int index, index2; +#endif + + if (!BBMEM_initialized) + { + BBMEM_PoolPointer = malloc(0x100000); + if (BBMEM_PoolPointer == NULL) + { + DBG_Panic_c("C:\\DATA\\BBLIB\\SRC\\BASE\\BBMem.c", 568); + return 0; + } + +#if 0 + for (index = 0; index < 20; index++) + { + BBMEM_hWinGDC[index] = (HDC)WinGCreateDC_c(); + if (BBMEM_hWinGDC[i] == NULL) + { + for (index2 = index - 1; index2 >= 0; index2--) + { + DeleteDC(BBMEM_hWinGDC[index2]); + } + + free(BBMEM_PoolPointer); + DBG_Panic_c("C:\\DATA\\BBLIB\\SRC\\BASE\\BBMem.c", 588); + return 0; + } + } +#endif + } + + BBMEM_initialized++; + return 1; +} + +void MEM_Exit_c(void) +{ + BBMEM_initialized--; + if (BBMEM_initialized <= 0) + { + BBMEM_FreeMemory_c(0); + } +} + +void *MEM_malloc_c(unsigned int size, const char *module_name, const char *object_type, unsigned int line, int type) +{ +#ifdef ORIGINAL_MEM_ALLOC + MEM_struct *mem; +#else + void *mem; +#endif + + if (size == 0) + { + return NULL; + } + +#ifdef ORIGINAL_MEM_ALLOC + mem = (MEM_struct *)malloc(size + sizeof(MEM_struct)); +#else + mem = malloc(size); +#endif + if (mem == NULL) + { + BBMEM_FreeMemory_c(1); +#ifdef ORIGINAL_MEM_ALLOC + mem = (MEM_struct *)malloc(size + sizeof(MEM_struct)); +#else + mem = malloc(size); +#endif + } + + if (mem == NULL) + { + MessageBoxA((HWND)DSAWIN_GetMainWindowHandle_c(), "WINDOWS meldet zuwenig freien Speicher.Beenden Sie einige Anwendungen und starten Sie Battle Isle 3 erneut. Ihr momentaner Spielstand ist in Slot 9 oder 10 gesichert.", "MEMORY HANDLER", MB_OK | MB_ICONERROR); + DBG_Panic_c("C:\\DATA\\BBLIB\\SRC\\BASE\\BBMem.c", 908); + return NULL; + } + +#ifdef ORIGINAL_MEM_ALLOC + mem->size = size; + mem->type = 0; + mem->ptr = mem; + + return (void *)(sizeof(MEM_struct) + (uintptr_t)mem); +#else + return mem; +#endif +} + +void MEM_free_c(void *mem_ptr) +{ +#ifdef ORIGINAL_MEM_ALLOC + MEM_struct *mem; +#endif + + if (mem_ptr == NULL) + { + return; + } + +#ifdef ORIGINAL_MEM_ALLOC + mem = (MEM_struct *)(((uintptr_t)mem_ptr) - sizeof(MEM_struct)); + free(mem); +#else + free(mem_ptr); +#endif +} + +void MEM_Take_Snapshot_c(const char *name) +{ + // do nothing +} + +void MEM_Check_Snapshot_c(void) +{ + // do nothing +} + +void MEM_Dump_c(void *hFile) +{ + DWORD ticks; + + BBMEM_DumpLine_c(hFile, "---------------- LAST MEMORY DUMP BEGIN --------------------"); + BBMEM_DumpLine_c(hFile, NULL); + + ticks = GetTickCount(); + BBMEM_DumpLine_c(hFile, "Current Time in ms: "); + BBMEM_DumpLine_c(hFile, (const char *)(ticks | 0x80000000)); + BBMEM_DumpLine_c(hFile, NULL); + + + ticks = GetTickCount(); + BBMEM_DumpLine_c(hFile, NULL); + BBMEM_DumpLine_c(hFile, "Current Time in ms: "); + BBMEM_DumpLine_c(hFile, (const char *)(ticks | 0x80000000)); + BBMEM_DumpLine_c(hFile, NULL); + + BBMEM_DumpLine_c(hFile, "---------------- LAST MEMORY DUMP END --------------------"); + BBMEM_DumpLine_c(hFile, NULL); + + if (hFile != NULL) + { + FlushFileBuffers(hFile); + } +} + +void MEM_SwitchSecurity_c(unsigned int security) +{ + // do nothing +} + +void *BASEMEM_Alloc_c(unsigned int size) +{ + return MEM_malloc_c(size, "BASEMEM", NULL, 0, 1); +} + +int BASEMEM_Free_c(void *mem_ptr) +{ + MEM_free_c(mem_ptr); + return 1; +} + +void BASEMEM_CopyMem_c(const void *src, void *dst, unsigned int length) +{ + memmove(dst, src, length); +} + +void BASEMEM_FillMemByte_c(void *dst, unsigned int length, int c) +{ + memset(dst, c, length); +} + +void BBMEM_FreeMemory_c(int type) +{ +#if 0 + int index; +#endif + + if (BBMEM_PoolPointer != NULL) + { + free(BBMEM_PoolPointer); + } + BBMEM_PoolPointer = NULL; + +#if 0 + for (index = 0; index < 20; index++) + { + if (BBMEM_hWinGDC[index] != NULL) + { + DeleteDC(BBMEM_hWinGDC[index]); + } + BBMEM_hWinGDC[index] = NULL; + } +#endif + + if (type == 1) + { + MessageBoxA((HWND)DSAWIN_GetMainWindowHandle_c(), "Your system is low on memory. Save your work and quit the applicatijon at once!", "MEMORY OBSERVER", MB_OK | MB_ICONERROR); + } + + if (type == 2) + { + MessageBoxA((HWND)DSAWIN_GetMainWindowHandle_c(), "Your system is low on WinG - DCs. Save your work and quit the applicatijon at once!", "MEMORY OBSERVER", MB_OK | MB_ICONERROR); + } +} + +void *BBMEM_GetPoolPointer_c(void) +{ + return BBMEM_PoolPointer; +} + diff --git a/games/Battle Isle 3/SR-BI3/BBMEM.h b/games/Battle Isle 3/SR-BI3/BBMEM.h new file mode 100644 index 0000000..8d7e0d3 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBMEM.h @@ -0,0 +1,53 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_BBMEM_H_INCLUDED_) +#define _BBMEM_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int MEM_Init_c(void); +void MEM_Exit_c(void); +void *MEM_malloc_c(unsigned int size, const char *module_name, const char *object_type, unsigned int line, int type); +void MEM_free_c(void *mem_ptr); +void MEM_Take_Snapshot_c(const char *name); +void MEM_Check_Snapshot_c(void); +void MEM_Dump_c(void *hFile); +void MEM_SwitchSecurity_c(unsigned int security); +void *BASEMEM_Alloc_c(unsigned int size); +int BASEMEM_Free_c(void *mem_ptr); +void BASEMEM_CopyMem_c(const void *src, void *dst, unsigned int length); +void BASEMEM_FillMemByte_c(void *dst, unsigned int length, int c); +void BBMEM_FreeMemory_c(int type); +void *BBMEM_GetPoolPointer_c(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _BBMEM_H_INCLUDED_ */ diff --git a/games/Battle Isle 3/SR-BI3/BBOPM.c b/games/Battle Isle 3/SR-BI3/BBOPM.c new file mode 100644 index 0000000..7442d25 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBOPM.c @@ -0,0 +1,708 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "BBOPM.h" +#include "BBLL.h" +#include "BBMEM.h" +#include "BBDSA.h" +#include "WinApi-wing32.h" +#define WIN32_LEAN_AND_MEAN +#include + + +extern unsigned int DSA_pixelMapList; +extern OPM_struct DSA_pixelMapBG; +extern RGBQUAD DSA_colorTable[256]; + + +typedef union { + BITMAPINFO bmi; + struct { + BITMAPINFOHEADER header2; + RGBQUAD colors2[256]; + } bmi2; +} myBITMAPINFO; + + +static int OPM_initialized = 0; +static myBITMAPINFO OPM_bitmapInfo; + + +int OPM_Init_c(void) +{ + if (OPM_initialized) + { + return 1; + } + + OPM_initialized = 1; + return 1; +} + +void OPM_Exit_c(void) +{ + OPM_struct *pixel_map; + + if (!OPM_initialized) + { + return; + } + + LL_Reset_c(DSA_pixelMapList); + while (1) + { + pixel_map = (OPM_struct *)LL_GetData_c(DSA_pixelMapList); + if (pixel_map == NULL) + { + break; + } + + if ((!(pixel_map->flags & BBOPM_VIRTUAL)) && (pixel_map->flags & BBOPM_OWNED_BUFFER)) + { + if (pixel_map->flags & BBOPM_SECONDARY) + { + MEM_free_c(pixel_map->buffer); + } + else + { + SelectObject((HDC)pixel_map->hDC, (HGDIOBJ)pixel_map->hSelected); + DeleteObject((HGDIOBJ)pixel_map->hBitmap); + DeleteDC((HDC)pixel_map->hDC); + } + } + + LL_GotoNext_c(DSA_pixelMapList); + } + + OPM_initialized = 0; +} + +int OPM_New_c(unsigned int width, unsigned int height, unsigned int bytes_per_pixel, OPM_struct *pixel_map, uint8_t *buffer) +{ + RGBQUAD *colors; + int index; + char msg[128]; + + width = (uint16_t)width; + height = (uint16_t)height; + bytes_per_pixel = (uint16_t)bytes_per_pixel; + + + pixel_map->flags = 0; + + colors = &(OPM_bitmapInfo.bmi.bmiColors[0]); + // change: 255 replaced with 256 + //for (index = 0; index < 255; index++) + for (index = 0; index < 256; index++) + { + colors[index].rgbRed = index; + colors[index].rgbGreen = index; + colors[index].rgbBlue = index; + colors[index].rgbReserved = 0; + } + + OPM_bitmapInfo.bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + OPM_bitmapInfo.bmi.bmiHeader.biWidth = 1; + OPM_bitmapInfo.bmi.bmiHeader.biHeight = 1; + OPM_bitmapInfo.bmi.bmiHeader.biPlanes = 1; + OPM_bitmapInfo.bmi.bmiHeader.biBitCount = 8; + + if ( buffer != NULL) + { + pixel_map->buffer = buffer; + pixel_map->hDC = NULL; + pixel_map->hBitmap = NULL; + pixel_map->hSelected = NULL; + } + else + { + pixel_map->hDC = WinGCreateDC_c(); + if (pixel_map->hDC == NULL) + { + BBMEM_FreeMemory_c(2); + pixel_map->hDC = WinGCreateDC_c(); + } + if (pixel_map->hDC == NULL) + { + // change: bytes_per_pixel replaced with height + //wsprintfA(msg, "WinGCreateDC: Widht: %d Height: %d", width, bytes_per_pixel); + wsprintfA(msg, "WinGCreateDC: Widht: %d Height: %d", width, height); + MessageBoxA((HWND)DSAWIN_GetMainWindowHandle_c(), msg, "WING ERROR", MB_OK | MB_ICONERROR); + MessageBoxA((HWND)DSAWIN_GetMainWindowHandle_c(), "WINDOWS meldet zuwenig freien Speicher.Beenden Sie einige Anwendungen und starten Sie Battle Isle 3 erneut. Ihr momentaner Spielstand ist in Slot 9 oder 10 gesichert.", "BITMAP 1 HANDLER", MB_OK | MB_ICONERROR); + return 0; + } + + OPM_bitmapInfo.bmi.bmiHeader.biWidth = width; + OPM_bitmapInfo.bmi.bmiHeader.biHeight = -(int)height; + + pixel_map->hBitmap = WinGCreateBitmap_c((HDC)pixel_map->hDC, &(OPM_bitmapInfo.bmi), (void **)&(pixel_map->buffer)); + if (pixel_map->hBitmap == NULL) + { + BBMEM_FreeMemory_c(1); + pixel_map->hBitmap = WinGCreateBitmap_c((HDC)pixel_map->hDC, &(OPM_bitmapInfo.bmi), (void **)&(pixel_map->buffer)); + } + if (pixel_map->hBitmap == NULL) + { + // change: bytes_per_pixel replaced with height + //wsprintfA(msg, "WinGCreateBitmap: Widht: %d Height: %d", width, bytes_per_pixel); + wsprintfA(msg, "WinGCreateBitmap: Widht: %d Height: %d", width, height); + MessageBoxA((HWND)DSAWIN_GetMainWindowHandle_c(), msg, "WING ERROR", MB_OK | MB_ICONERROR); + MessageBoxA((HWND)DSAWIN_GetMainWindowHandle_c(), "WINDOWS meldet zuwenig freien Speicher.Beenden Sie einige Anwendungen und starten Sie Battle Isle 3 erneut. Ihr momentaner Spielstand ist in Slot 9 oder 10 gesichert.", "BITMAP 2 HANDLER", MB_OK | MB_ICONERROR); + DeleteDC((HDC)pixel_map->hDC); + pixel_map->hDC = NULL; + return 0; + } + + pixel_map->hSelected = SelectObject((HDC)pixel_map->hDC, (HGDIOBJ)pixel_map->hBitmap); + if (pixel_map->hSelected == NULL) + { + // change: bytes_per_pixel replaced with height + //wsprintfA(msg, "SelectObject: Widht: %d Height: %d", width, bytes_per_pixel); + wsprintfA(msg, "SelectObject: Widht: %d Height: %d", width, height); + MessageBoxA((HWND)DSAWIN_GetMainWindowHandle_c(), msg, "WING ERROR", MB_OK | MB_ICONERROR); + MessageBoxA((HWND)DSAWIN_GetMainWindowHandle_c(), "WINDOWS meldet zuwenig freien Speicher.Beenden Sie einige Anwendungen und starten Sie Battle Isle 3 erneut. Ihr momentaner Spielstand ist in Slot 9 oder 10 gesichert.", "BITMAP 3 HANDLER", MB_OK | MB_ICONERROR); + DeleteObject((HGDIOBJ)pixel_map->hBitmap); + DeleteDC((HDC)pixel_map->hDC); + pixel_map->hDC = NULL; + return 0; + } + + LL_AppendElement_c(DSA_pixelMapList, pixel_map); + WinGSetDIBColorTable_c((HDC)pixel_map->hDC, 0, 256, DSA_colorTable); + pixel_map->flags |= BBOPM_OWNED_BUFFER; + } + + pixel_map->width = width; + pixel_map->height = height; + pixel_map->size = width * height; + pixel_map->bytes_per_pixel = bytes_per_pixel; + pixel_map->clip_x = 0; + pixel_map->clip_y = 0; + pixel_map->clip_width = width; + pixel_map->clip_height = height; + pixel_map->origin_x = 0; + pixel_map->origin_y = 0; + pixel_map->bytes_per_pixel2 = bytes_per_pixel; + pixel_map->stride = width * bytes_per_pixel; + pixel_map->flags |= BBOPM_CREATED | BBOPM_MODIFIED; + pixel_map->access_offset = 0; + + return 1; +} + +void OPM_Del_c(OPM_struct *pixel_map) +{ + OPM_struct *pm2; + + if ((!(pixel_map->flags & BBOPM_VIRTUAL)) && (pixel_map->flags & BBOPM_OWNED_BUFFER)) + { + if (pixel_map->flags & BBOPM_SECONDARY) + { + MEM_free_c(pixel_map->buffer); + } + else + { + LL_Reset_c(DSA_pixelMapList); + while (1) + { + pm2 = (OPM_struct *)LL_GetData_c(DSA_pixelMapList); + if (pm2 == NULL) + { + break; + } + + if (pm2 == pixel_map) + { + LL_DeleteElement_c(DSA_pixelMapList); + break; + } + + LL_GotoNext_c(DSA_pixelMapList); + } + + SelectObject((HDC)pixel_map->hDC, (HGDIOBJ)pixel_map->hSelected); + DeleteObject((HGDIOBJ)pixel_map->hBitmap); + DeleteDC((HDC)pixel_map->hDC); + } + } + + pixel_map->flags = 0; +} + +void OPM_CreateVirtualOPM_c(OPM_struct *base_pixel_map, OPM_struct *virtual_pixel_map, int virtual_x, int virtual_y, int virtual_width, int virtual_height) +{ + virtual_x = (uint16_t)virtual_x; + virtual_y = (uint16_t)virtual_y; + virtual_width = (uint16_t)virtual_width; + virtual_height = (uint16_t)virtual_height; + + virtual_pixel_map->flags = BBOPM_VIRTUAL | BBOPM_CREATED | BBOPM_MODIFIED; + virtual_pixel_map->virtual_x = virtual_x; + virtual_pixel_map->virtual_y = virtual_y; + virtual_pixel_map->base_pixel_map = base_pixel_map; + virtual_pixel_map->width = virtual_width; + virtual_pixel_map->height = virtual_height; + virtual_pixel_map->bytes_per_pixel = base_pixel_map->bytes_per_pixel; + virtual_pixel_map->size = base_pixel_map->size; + virtual_pixel_map->clip_x = 0; + virtual_pixel_map->clip_y = 0; + virtual_pixel_map->clip_width = virtual_width; + virtual_pixel_map->clip_height = virtual_height; + virtual_pixel_map->origin_x = 0; + virtual_pixel_map->origin_y = 0; + virtual_pixel_map->bytes_per_pixel2 = base_pixel_map->bytes_per_pixel; + virtual_pixel_map->stride = base_pixel_map->stride; + virtual_pixel_map->buffer = &(base_pixel_map->buffer[virtual_y * virtual_pixel_map->stride + virtual_x]); + virtual_pixel_map->hDC = base_pixel_map->hDC; + virtual_pixel_map->hBitmap = base_pixel_map->hBitmap; + virtual_pixel_map->hSelected = base_pixel_map->hSelected; + virtual_pixel_map->access_offset = 0; +} + +int OPM_CreateSecondaryOPM_c(int width, int height, int bytes_per_pixel, OPM_struct *pixel_map, uint8_t *buffer) +{ + width = (uint16_t)width; + height = (uint16_t)height; + bytes_per_pixel = (uint16_t)bytes_per_pixel; + + pixel_map->flags = 0; + if (buffer != NULL) + { + pixel_map->buffer = buffer; + pixel_map->hDC = NULL; + pixel_map->hBitmap = NULL; + pixel_map->hSelected = NULL; + } + else + { + pixel_map->hDC = NULL; + pixel_map->hBitmap = NULL; + pixel_map->hSelected = NULL; + pixel_map->buffer = (uint8_t *)MEM_malloc_c(height * width * bytes_per_pixel, NULL, NULL, 0, 0); + if (pixel_map->buffer == NULL) + { + return 0; + } + + pixel_map->flags |= BBOPM_OWNED_BUFFER; + } + pixel_map->flags |= BBOPM_SECONDARY; + pixel_map->width = width; + pixel_map->height = height; + pixel_map->size = height * width; + pixel_map->bytes_per_pixel = bytes_per_pixel; + pixel_map->clip_x = 0; + pixel_map->clip_y = 0; + pixel_map->clip_width = width; + pixel_map->clip_height = height; + pixel_map->origin_x = 0; + pixel_map->origin_y = 0; + pixel_map->bytes_per_pixel2 = bytes_per_pixel; + pixel_map->stride = width * bytes_per_pixel; + pixel_map->access_offset = 0; + pixel_map->flags |= BBOPM_CREATED | BBOPM_MODIFIED; + + return 1; +} + +void OPM_SetPixel_c(OPM_struct *pixel_map, int x, int y, uint8_t color) +{ + x = (int16_t)(x + pixel_map->origin_x); + y = (int16_t)(y + pixel_map->origin_y); + + if ((x >= pixel_map->clip_x) && + (x < pixel_map->clip_x + pixel_map->clip_width) && + (y >= pixel_map->clip_y) && + (y < pixel_map->clip_y + pixel_map->clip_height) + ) + { + pixel_map->flags |= BBOPM_MODIFIED; + pixel_map->buffer[y * pixel_map->stride + x] = color; + } +} + +void OPM_HorLine_c(OPM_struct *pixel_map, int x, int y, unsigned int length, uint8_t color) +{ + int length2, index; + + x = (int16_t)(x + pixel_map->origin_x); + y = (int16_t)(y + pixel_map->origin_y); + length = (uint16_t)length; + + if ((y < pixel_map->clip_y) || (y >= pixel_map->clip_y + pixel_map->clip_height) || (x < pixel_map->clip_x)) + { + return; + } + + length2 = pixel_map->clip_x + pixel_map->clip_width - x; + if (length2 >= length) + { + length2 = length; + } + + if (length2 > 0) + { + for (index = 0; index < length2; index++) + { + pixel_map->buffer[y * pixel_map->stride + (x + index)] = color; + } + + pixel_map->flags |= BBOPM_MODIFIED; + } +} + +void OPM_VerLine_c(OPM_struct *pixel_map, int x, int y, unsigned int length, uint8_t color) +{ + int length2, index; + + x = (int16_t)(x + pixel_map->origin_x); + y = (int16_t)(y + pixel_map->origin_y); + length = (uint16_t)length; + + if ((x < pixel_map->clip_x) || (x >= pixel_map->clip_x + pixel_map->clip_width) || (y < pixel_map->clip_y)) + { + return; + } + + length2 = pixel_map->clip_y + pixel_map->clip_height - y; + if (length2 >= length) + { + length2 = length; + } + + if (length2 > 0) + { + for (index = 0; index < length2; index++) + { + pixel_map->buffer[(y + index) * pixel_map->stride + x] = color; + } + + pixel_map->flags |= BBOPM_MODIFIED; + } +} + +void OPM_FillBox_c(OPM_struct *pixel_map, int x, int y, unsigned int width, unsigned int height, uint8_t color) +{ + int index; + + height = (uint16_t)height; + + if (pixel_map == NULL) + { + if (!(DSA_pixelMapBG.flags & BBOPM_CREATED)) + { + return; + } + + pixel_map = &DSA_pixelMapBG; + } + + for (index = 0; index < height; index++) + { + OPM_HorLine_c(pixel_map, x, y + index, width, color); + } +} + +void OPM_CopyGFXOPM_c(OPM_struct *pixel_map, GFX_struct *gfx, int pos_x, int pos_y, uint8_t value_add) +{ + int clip_x, clip_y, clip_endx, clip_endy; + int dst_x, dst_y, dst_width, dst_height; + int gfx_width, dst_stride, dst_diff, src_diff; + int counter_x, counter_y; + uint8_t *src_ptr, *dst_ptr, transparent_color, src_value; + + pos_x = (int16_t)pos_x; + pos_y = (int16_t)pos_y; + + + if (pixel_map == NULL) + { + if (!(DSA_pixelMapBG.flags & BBOPM_CREATED)) + { + return; + } + pixel_map = &DSA_pixelMapBG; + } + + transparent_color = gfx->transparent_color; + dst_width = gfx->width; + dst_height = gfx->height; + gfx_width = dst_width; + src_ptr = &(gfx->data[0]); + + dst_stride = pixel_map->stride; + dst_x = pos_x + gfx->pos_x; + dst_y = pos_y + gfx->pos_y; + + clip_x = pixel_map->clip_x; + clip_y = pixel_map->clip_y; + clip_endx = clip_x + pixel_map->clip_width; + clip_endy = clip_y + pixel_map->clip_height; + + if (dst_x < clip_x) + { + if (clip_x - dst_x > dst_width) + { + return; + } + dst_width -= clip_x - dst_x; + src_ptr += clip_x - dst_x; + dst_x = pixel_map->clip_x; + } + + if (dst_y < clip_y) + { + if (clip_y - dst_y > dst_height) + { + return; + } + dst_height -= clip_y - dst_y; + src_ptr += gfx_width * (clip_y - dst_y); + dst_y = pixel_map->clip_y; + } + + if (dst_x + dst_width > clip_endx) + { + if (dst_x > clip_endx) + { + return; + } + dst_width -= (dst_x + dst_width) - clip_endx; + } + + if (dst_y + dst_height > clip_endy) + { + if (dst_y > clip_endy) + { + return; + } + dst_height -= (dst_y + dst_height) - clip_endy; + } + + if ((dst_width < 1) || (dst_height < 1)) return; + + + dst_diff = dst_stride - dst_width; + src_diff = gfx_width - dst_width; + dst_ptr = &(pixel_map->buffer[dst_y * dst_stride + dst_x]); + + for (counter_y = dst_height; counter_y != 0; counter_y--) + { + for (counter_x = dst_width; counter_x != 0; counter_x--) + { + src_value = *src_ptr; + src_ptr++; + if (src_value != transparent_color) + { + *dst_ptr = value_add + src_value; + } + dst_ptr++; + } + + dst_ptr += dst_diff; + src_ptr += src_diff; + } + + pixel_map->flags |= BBOPM_MODIFIED; +} + +void OPM_CopyOPMOPM_c(OPM_struct *src_pixel_map, OPM_struct *dst_pixel_map, int src_x, int src_y, int copy_width, int copy_height, int dst_x, int dst_y) +{ + int clip_x, clip_y, clip_endx, clip_endy; + int src_add_x, src_add_y, src_width, src_height; + int dst_add_x, dst_add_y, dst_width, dst_height; + int max_add_x, max_add_y, min_width, min_height; + int counter, dst_stride, src_stride; + uint8_t *dst_ptr, *src_ptr; + + src_x = (int16_t)src_x; + src_y = (int16_t)src_y; + copy_width = (int16_t)copy_width; + copy_height = (int16_t)copy_height; + dst_x = (int16_t)dst_x; + dst_y = (int16_t)dst_y; + + + if (src_pixel_map == NULL) + { + if (!(DSA_pixelMapBG.flags & BBOPM_CREATED)) + { + return; + } + src_pixel_map = &DSA_pixelMapBG; + } + + if (dst_pixel_map == NULL) + { + if (!(DSA_pixelMapBG.flags & BBOPM_CREATED)) + { + return; + } + dst_pixel_map = &DSA_pixelMapBG; + } + + src_width = copy_width; + src_height = copy_height; + src_add_x = 0; + src_add_y = 0; + dst_width = copy_width; + dst_height = copy_height; + dst_add_x = 0; + dst_add_y = 0; + + clip_x = src_pixel_map->clip_x; + clip_y = src_pixel_map->clip_y; + clip_endx = clip_x + src_pixel_map->clip_width; + clip_endy = clip_y + src_pixel_map->clip_height; + + if (src_x < clip_x) + { + if (clip_x - src_x > copy_width) + { + return; + } + src_width = copy_width - (clip_x - src_x); + src_add_x = clip_x - src_x; + src_x = src_pixel_map->clip_x; + } + + if (src_y < clip_y) + { + if (clip_y - src_y > copy_height) + { + return; + } + src_height = copy_height - (clip_y - src_y); + src_add_y = clip_y - src_y; + src_y = src_pixel_map->clip_y; + } + + if (src_x + src_width > clip_endx) + { + if (src_x > clip_endx) + { + return; + } + src_width -= (src_x + src_width) - clip_endx; + } + + if (src_y + src_height > clip_endy) + { + if (src_y > clip_endy) + { + return; + } + src_height -= (src_y + src_height) - clip_endy; + } + + if ((src_width < 1) || (src_height < 1)) return; + + + clip_x = dst_pixel_map->clip_x; + clip_y = dst_pixel_map->clip_y; + clip_endx = clip_x + dst_pixel_map->clip_width; + clip_endy = clip_y + dst_pixel_map->clip_height; + + if (dst_x < clip_x) + { + if (clip_x - dst_x > copy_width) + { + return; + } + dst_width = copy_width - (clip_x - dst_x); + dst_add_x = clip_x - dst_x; + dst_x = dst_pixel_map->clip_x; + } + + if (dst_y < clip_y) + { + if (clip_y - dst_y > copy_height) + { + return; + } + dst_height = copy_height - (clip_y - dst_y); + dst_add_y = clip_y - dst_y; + dst_y = dst_pixel_map->clip_y; + } + + if (dst_x + dst_width > clip_endx) + { + if (dst_x > clip_endx) + { + return; + } + dst_width -= (dst_x + dst_width) - clip_endx; + } + + if (dst_y + dst_height > clip_endy) + { + if (dst_y > clip_endy) + { + return; + } + dst_height -= (dst_y + dst_height) - clip_endy; + } + + if ((dst_width < 1) || (dst_height < 1)) return; + + max_add_x = (dst_add_x >= src_add_x)?dst_add_x:src_add_x; + max_add_y = (dst_add_y >= src_add_y)?dst_add_y:src_add_y; + min_width = (dst_width <= src_width)?dst_width:src_width; + min_height = (dst_height <= src_height)?dst_height:src_height; + + if ((copy_width <= max_add_x) || (copy_height <= max_add_y)) return; + + + dst_stride = dst_pixel_map->stride; + src_stride = src_pixel_map->stride; + dst_ptr = &(dst_pixel_map->buffer[(src_add_y + dst_y) * dst_pixel_map->stride + (src_add_x + dst_x)]); + src_ptr = &(src_pixel_map->buffer[(dst_add_y + src_y) * src_pixel_map->stride + (dst_add_x + src_x)]); + + for (counter = min_height; counter != 0; counter--) + { + memcpy(dst_ptr, src_ptr, min_width); + dst_ptr += dst_stride; + src_ptr += src_stride; + } + + dst_pixel_map->flags |= BBOPM_MODIFIED; +} + +void OPM_AccessBitmap_c(OPM_struct *pixel_map) +{ + uint8_t *ptr; + uint8_t value; + + ptr = &pixel_map->buffer[pixel_map->access_offset]; + value = *ptr; + *ptr = 0xAA; + *ptr = value; + + pixel_map->access_offset += 2048; + if (pixel_map->access_offset >= pixel_map->size) + { + pixel_map->access_offset = 0; + } +} + diff --git a/games/Battle Isle 3/SR-BI3/BBOPM.h b/games/Battle Isle 3/SR-BI3/BBOPM.h new file mode 100644 index 0000000..b1acf5b --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBOPM.h @@ -0,0 +1,102 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_BBOPM_H_INCLUDED_) +#define _BBOPM_H_INCLUDED_ + +#include + +#define BBOPM_OWNED_BUFFER 1 +#define BBOPM_MODIFIED 2 +#define BBOPM_CREATED 4 +#define BBOPM_VIRTUAL 8 +#define BBOPM_SECONDARY 0x10 + + +#pragma pack(1) + +typedef struct __attribute__ ((__packed__)) _OPM_struct { + uint32_t flags; + int16_t width; + int16_t height; + int16_t bytes_per_pixel; + uint8_t *buffer; + uint32_t size; + uint16_t bytes_per_pixel2; + int16_t stride; + int16_t origin_x; + int16_t origin_y; + int16_t clip_x; + int16_t clip_y; + int16_t clip_width; + int16_t clip_height; + int16_t virtual_x; + int16_t virtual_y; + struct _OPM_struct *base_pixel_map; + void *hDC; + void *hBitmap; + void *hSelected; + uint32_t access_offset; +} OPM_struct; + +typedef struct __attribute__ ((__packed__)) _GFX_struct { + uint32_t unknown_00; + uint32_t unknown_04; + uint32_t unknown_08; + uint8_t transparent_color; + uint8_t unknown_0D; + int16_t pos_x; + int16_t pos_y; + uint16_t width; + uint16_t height; + uint32_t unknown_16; + uint8_t data[1]; +} GFX_struct; + +#pragma pack() + + +#ifdef __cplusplus +extern "C" { +#endif + +int OPM_Init_c(void); +void OPM_Exit_c(void); +int OPM_New_c(unsigned int width, unsigned int height, unsigned int bytes_per_pixel, OPM_struct *pixel_map, uint8_t *buffer); +void OPM_Del_c(OPM_struct *pixel_map); +void OPM_CreateVirtualOPM_c(OPM_struct *base_pixel_map, OPM_struct *virtual_pixel_map, int virtual_x, int virtual_y, int virtual_width, int virtual_height); +int OPM_CreateSecondaryOPM_c(int width, int height, int bytes_per_pixel, OPM_struct *pixel_map, uint8_t *buffer); +void OPM_SetPixel_c(OPM_struct *pixel_map, int x, int y, uint8_t color); +void OPM_HorLine_c(OPM_struct *pixel_map, int x, int y, unsigned int length, uint8_t color); +void OPM_VerLine_c(OPM_struct *pixel_map, int x, int y, unsigned int length, uint8_t color); +void OPM_FillBox_c(OPM_struct *pixel_map, int x, int y, unsigned int width, unsigned int height, uint8_t color); +void OPM_CopyGFXOPM_c(OPM_struct *pixel_map, GFX_struct *gfx, int pos_x, int pos_y, uint8_t value_add); +void OPM_CopyOPMOPM_c(OPM_struct *src_pixel_map, OPM_struct *dst_pixel_map, int src_x, int src_y, int copy_width, int copy_height, int dst_x, int dst_y); +void OPM_AccessBitmap_c(OPM_struct *pixel_map); + +#ifdef __cplusplus +} +#endif + +#endif /* _BBOPM_H_INCLUDED_ */ diff --git a/games/Battle Isle 3/SR-BI3/BBRNG.c b/games/Battle Isle 3/SR-BI3/BBRNG.c new file mode 100644 index 0000000..f5497d2 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBRNG.c @@ -0,0 +1,218 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "BBRNG.h" +#include "BBMEM.h" +#include +#include + + +typedef struct _RNG_struct { + void *elements; + int num_elements; + int element_size; + int read_index; + int write_index; +} RNG_struct; + + +static int RNG_initialized = 0; + + +int RNG_Init_c(void) +{ + RNG_initialized++; + return 1; +} + +void RNG_Exit_c(void) +{ + RNG_initialized--; +} + +void *RNG_NewBuffer_c(int element_size, int num_elements) +{ + RNG_struct *ring; + + ring = (RNG_struct *)MEM_malloc_c(sizeof(RNG_struct), NULL, NULL, 0, 0); + if (ring == NULL) + { + return NULL; + } + + ring->elements = MEM_malloc_c(element_size * num_elements, NULL, NULL, 0, 0); + if (ring->elements == NULL) + { + MEM_free_c(ring); + return NULL; + } + + ring->num_elements = num_elements; + ring->element_size = element_size; + ring->read_index = -1; + ring->write_index = -1; + + return ring; +} + +void RNG_DelBuffer_c(void *buffer) +{ + RNG_struct *ring; + + ring = (RNG_struct *)buffer; + + MEM_free_c(ring->elements); + MEM_free_c(ring); +} + +int RNG_In_c(void *buffer, const void *element) +{ + RNG_struct *ring; + + ring = (RNG_struct *)buffer; + + if (ring->read_index == ring->write_index) + { + if (ring->read_index != -1) + { + return 0; + } + + ring->read_index = 0; + ring->write_index = 1; + + memmove(ring->elements, element, ring->element_size); + } + else + { + memmove((void *)(((uintptr_t)ring->elements) + (ring->write_index * ring->element_size)), element, ring->element_size); + + ring->write_index++; + if (ring->write_index >= ring->num_elements) + { + ring->write_index = 0; + } + } + + return 1; +} + +int RNG_Out_c(void *buffer, void *element) +{ + RNG_struct *ring; + + ring = (RNG_struct *)buffer; + + if (ring->read_index == -1) + { + return 0; + } + + if (element != NULL) + { + memmove(element, (void *)(((uintptr_t)ring->elements) + (ring->read_index * ring->element_size)), ring->element_size); + } + + ring->read_index++; + if (ring->read_index >= ring->num_elements) + { + ring->read_index = 0; + } + if (ring->read_index == ring->write_index) + { + ring->read_index = -1; + ring->write_index = -1; + } + + return 1; +} + +int RNG_Peek_c(void *buffer, void *element) +{ + RNG_struct *ring; + + ring = (RNG_struct *)buffer; + + if (ring->read_index == -1) + { + return 0; + } + + if (element != NULL) + { + memmove(element, (void *)(((uintptr_t)ring->elements) + (ring->read_index * ring->element_size)), ring->element_size); + } + + return 1; +} + +void RNG_Replace_c(void *buffer, const void *element) +{ + RNG_struct *ring; + + ring = (RNG_struct *)buffer; + + if (ring->read_index == -1) + { + RNG_In_c(ring, element); + } + else + { + memmove((void *)(((uintptr_t)ring->elements) + (ring->read_index * ring->element_size)), element, ring->element_size); + } +} + +void RNG_PutFirst_c(void *buffer, const void *element) +{ + RNG_struct *ring; + int full; + + ring = (RNG_struct *)buffer; + + if (ring->read_index == -1) + { + RNG_In_c(ring, element); + } + else + { + full = (ring->read_index == ring->write_index)?1:0; + + if (ring->read_index <= 0) + { + ring->read_index = ring->num_elements - 1; + } + else + { + ring->read_index--; + } + + if (full) + { + ring->write_index = ring->read_index; + } + + memmove((void *)(((uintptr_t)ring->elements) + (ring->read_index * ring->element_size)), element, ring->element_size); + } +} + diff --git a/games/Battle Isle 3/SR-BI3/BBRNG.h b/games/Battle Isle 3/SR-BI3/BBRNG.h new file mode 100644 index 0000000..13e93f9 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBRNG.h @@ -0,0 +1,48 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_BBRNG_H_INCLUDED_) +#define _BBRNG_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int RNG_Init_c(void); +void RNG_Exit_c(void); +void *RNG_NewBuffer_c(int element_size, int num_elements); +void RNG_DelBuffer_c(void *buffer); +int RNG_In_c(void *buffer, const void *element); +int RNG_Out_c(void *buffer, void *element); +int RNG_Peek_c(void *buffer, void *element); +void RNG_Replace_c(void *buffer, const void *element); +void RNG_PutFirst_c(void *buffer, const void *element); + +#ifdef __cplusplus +} +#endif + +#endif /* _BBRNG_H_INCLUDED_ */ diff --git a/games/Battle Isle 3/SR-BI3/BBSYSTEM.c b/games/Battle Isle 3/SR-BI3/BBSYSTEM.c new file mode 100644 index 0000000..9ce0fb7 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBSYSTEM.c @@ -0,0 +1,205 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "BBSYSTEM.h" +#include "BBDSA.h" +#include "BBAVI.h" +#define WIN32_LEAN_AND_MEAN +#include + + +extern char DSA_IconID[100]; +extern char DSA_WindowName[100]; + + +static unsigned int SYSTEM_OS = 0; +static int SYSTEM_initialized = 0; +static unsigned int SYSTEM_tickBase; + + +void SYSTEM_SetInitValues_c(int type, const char *value) +{ + if (type == 0) + { + strncpy(DSA_WindowName, value, 100); + DSA_WindowName[99] = 0; + } + else if (type == 1) + { + strncpy(DSA_IconID, value, 100); + DSA_IconID[99] = 0; + } +} + +void SYSTEM_SystemTask_c(void) +{ + MSG msg; + + if (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) + { + TranslateMessage(&msg); + DispatchMessageA(&msg); + } + + DSA_SystemTask_c(); + AVI_SystemTask_c(); +} + +int SYSTEM_Init_c(void) +{ + unsigned int platform; + DWORD version; + + if (SYSTEM_initialized) + { + return 1; + } + + SYSTEM_tickBase = GetTickCount(); + + version = GetVersion(); + platform = (version >> 16) & 0x8000; + if (platform == 0) + { + SYSTEM_OS = 1; // Windows NT + } + else if (platform == 0x8000) + { + if ((version & 0xff) < 4) + { + SYSTEM_OS = 2; // Win32s with Windows 3.1 + } + else + { + SYSTEM_OS = 4; // Windows 95 + } + } + + SYSTEM_initialized = 1; + return 1; +} + +void SYSTEM_Exit_c(void) +{ + if (SYSTEM_initialized) + { + SYSTEM_initialized = 0; + } +} + +unsigned int SYSTEM_GetTicks_c(void) +{ + return (GetTickCount() - SYSTEM_tickBase) / 17; +} + +int SYSTEM_IsApplicationActive_c(void) +{ + return (IsIconic((HWND)DSAWIN_GetMainWindowHandle_c()) == 0)?1:0; +} + +void SYSTEM_WaitTicks_c(unsigned int ticks) +{ + unsigned int start_ticks; + int finish; + UINT_PTR timerID; + MSG msg; + + finish = 0; + timerID = SetTimer((HWND)DSAWIN_GetMainWindowHandle_c(), 0xAA, (1000 * ticks) / 60, NULL); + if (timerID != 0) + { + while (!finish) + { + if (GetMessageA(&msg, NULL, 0, 0)) + { + if ((msg.hwnd == DSAWIN_GetMainWindowHandle_c()) && + (msg.message == WM_TIMER) && + (msg.wParam == timerID ) + ) + { + finish = 1; + } + + TranslateMessage(&msg); + DispatchMessageA(&msg); + } + + DSA_SystemTask_c(); + } + + KillTimer((HWND)DSAWIN_GetMainWindowHandle_c(), timerID); + } + else + { + // change: insert delays into active waiting + //start_ticks = SYSTEM_GetTicks_c(); + //while (SYSTEM_GetTicks_c() < ticks + start_ticks) + //{ + // SYSTEM_SystemTask_c(); + //} + start_ticks = GetTickCount(); + finish = (1000 * ticks) / 60; + while (1) + { + ticks = GetTickCount(); + if (((int)(ticks - start_ticks)) >= finish) break; + + SYSTEM_SystemTask_c(); + + if (GetTickCount() == ticks) + { + if (!PeekMessageA(&msg, NULL, 0, 0, PM_NOREMOVE | PM_NOYIELD)) + { + Sleep(0); + if (GetTickCount() == ticks) + { + if (!PeekMessageA(&msg, NULL, 0, 0, PM_NOREMOVE | PM_NOYIELD)) + { + Sleep(1); + } + } + } + } + } + } +} + +void SYSTEM_EnterCriticalSection_c(void) +{ +} + +void SYSTEM_LeaveCriticalSection_c(void) +{ +} + +int SYSTEM_InCriticalSection_c(void) +{ + return 0; +} + +unsigned int SYSTEM_GetOS_c(void) +{ + return SYSTEM_OS; +} + diff --git a/games/Battle Isle 3/SR-BI3/BBSYSTEM.h b/games/Battle Isle 3/SR-BI3/BBSYSTEM.h new file mode 100644 index 0000000..d22fafa --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBSYSTEM.h @@ -0,0 +1,50 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_BBSYSTEM_H_INCLUDED_) +#define _BBSYSTEM_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void SYSTEM_SetInitValues_c(int type, const char *value); +void SYSTEM_SystemTask_c(void); +int SYSTEM_Init_c(void); +void SYSTEM_Exit_c(void); +unsigned int SYSTEM_GetTicks_c(void); +int SYSTEM_IsApplicationActive_c(void); +void SYSTEM_WaitTicks_c(unsigned int ticks); +void SYSTEM_EnterCriticalSection_c(void); +void SYSTEM_LeaveCriticalSection_c(void); +int SYSTEM_InCriticalSection_c(void); +unsigned int SYSTEM_GetOS_c(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _BBSYSTEM_H_INCLUDED_ */ diff --git a/games/Battle Isle 3/SR-BI3/BBTOOL.c b/games/Battle Isle 3/SR-BI3/BBTOOL.c new file mode 100644 index 0000000..52f2d24 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBTOOL.c @@ -0,0 +1,45 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "BBTOOL.h" + + +unsigned int TOOL_Chiffre_c(uint8_t *buffer, unsigned int length, const uint8_t *key, unsigned int keylength) +{ + unsigned int index, keyindex; + + keyindex = 0; + for (index = 0; index < length; index++) + { + buffer[index] ^= key[keyindex]; + keyindex++; + if (keyindex == keylength) + { + keyindex = 0; + } + } + + return index; +} + diff --git a/games/Battle Isle 3/SR-BI3/BBTOOL.h b/games/Battle Isle 3/SR-BI3/BBTOOL.h new file mode 100644 index 0000000..a6ca98c --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBTOOL.h @@ -0,0 +1,40 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_BBTOOL_H_INCLUDED_) +#define _BBTOOL_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +unsigned int TOOL_Chiffre_c(uint8_t *buffer, unsigned int length, const uint8_t *key, unsigned int keylength); + +#ifdef __cplusplus +} +#endif + +#endif /* _BBTOOL_H_INCLUDED_ */ diff --git a/games/Battle Isle 3/SR-BI3/BBTXT.c b/games/Battle Isle 3/SR-BI3/BBTXT.c new file mode 100644 index 0000000..a05232e --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBTXT.c @@ -0,0 +1,268 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "BBTXT.h" +#include "BBOPM.h" +#include "BBLBL.h" +#include "BBMEM.h" +#include + + +typedef struct { + unsigned int unknown_00; + GFX_struct *char_gfx[256]; +} TXT_struct; + + +static int TXT_initialized = 0; +static TXT_struct *TXT_fonts[32]; + + +int TXT_Init_c(void) +{ + int index; + + if (!TXT_initialized) + { + for (index = 0; index < 32; index++) + { + TXT_fonts[index] = NULL; + } + } + + TXT_initialized++; + return 1; +} + +void TXT_Exit_c(void) +{ + //int index; + + TXT_initialized--; + if (TXT_initialized > 0) + { + return; + } + + TXT_UnloadAllFonts_c(); + /*for (index = 0; index < 32; index++) + { + if (TXT_fonts[index] != NULL) + { + TXT_UnloadFont_c(index); + } + }*/ +} + +int TXT_LoadFont_c(const char *path) +{ + int error, font_handle, index, num_entries; + void *lib; + TXT_struct *font; + GFX_struct *gfx; + uint8_t metadata[8]; + + error = 0; + for (font_handle = 0; font_handle < 32; font_handle++) + { + if (TXT_fonts[font_handle] == NULL) break; + } + + if (font_handle >= 32) + { + return -1; + } + + lib = LBL_OpenLib_c(path, 0); + if (lib == NULL) + { + return -1; + } + + font = (TXT_struct *)MEM_malloc_c(sizeof(TXT_struct), NULL, NULL, 0, 0); + if (font == NULL) + { + LBL_CloseLib_c(lib); + return -1; + } + + for (index = 0; index < 256; index++) + { + font->char_gfx[index] = NULL; + } + + num_entries = LBL_GetNOFEntries_c(lib); + + for (index = 0; index < num_entries; index++) + { + gfx = (GFX_struct *)LBL_ReadEntry_c(lib, NULL, index, 0, metadata); + if (gfx == NULL) + { + error = 1; + break; + } + + font->char_gfx[metadata[0]] = gfx; + font->unknown_00 = metadata[1]; + + gfx->transparent_color = 0xff; + } + + if (error || (font->char_gfx[32] == NULL)) + { + for (index = 0; index < 256; index++) + { + if (font->char_gfx[index] != NULL) + { + MEM_free_c(font->char_gfx[index]); + } + } + + MEM_free_c(font); + LBL_CloseLib_c(lib); + return -1; + } + + + for (index = 0; index < 256; index++) + { + if (font->char_gfx[index] == NULL) + { + font->char_gfx[index] = font->char_gfx[32]; + } + } + + TXT_fonts[font_handle] = font; + LBL_CloseLib_c(lib); + + return font_handle; +} + +static void TXT_UnloadFont_c(int font_handle) +{ + TXT_struct *font; + int index; + + if ((font_handle < 0) || (font_handle >= 32)) + { + return; + } + + font = TXT_fonts[font_handle]; + if (font == NULL) + { + return; + } + + for (index = 0; index < 256; index++) + { + if ((index != 32) && (font->char_gfx[index] == font->char_gfx[32])) + { + font->char_gfx[index] = NULL; + } + } + + for (index = 0; index < 256; index++) + { + if (font->char_gfx[index] != NULL) + { + MEM_free_c(font->char_gfx[index]); + } + } + + MEM_free_c(font); + TXT_fonts[font_handle] = NULL; +} + +void TXT_WriteString_c(const char *text, int font_handle, void *dst_pixel_map, int x, int y, int width, int height, uint8_t color_add) +{ + TXT_struct *font; + OPM_struct *pixel_map; + int16_t orig_clip_x, orig_clip_y, orig_clip_width, orig_clip_height; + int index; + GFX_struct *gfx; + + if ((font_handle < 0) || (font_handle >= 32)) + { + return; + } + + font = (TXT_struct *)TXT_fonts[font_handle]; + if (font == NULL) + { + return; + } + + if ((text == NULL) || (dst_pixel_map == NULL)) + { + return; + } + + pixel_map = (OPM_struct *)dst_pixel_map; + + orig_clip_x = pixel_map->clip_x; + orig_clip_y = pixel_map->clip_y; + orig_clip_width = pixel_map->clip_width; + orig_clip_height = pixel_map->clip_height; + + pixel_map->clip_x = x; + pixel_map->clip_y = y; + pixel_map->clip_width = width; + pixel_map->clip_height = height; + + if (pixel_map->clip_x < 0) pixel_map->clip_x = 0; + if (pixel_map->clip_y < 0) pixel_map->clip_y = 0; + if (pixel_map->clip_x > pixel_map->width) pixel_map->clip_x = pixel_map->width; + if (pixel_map->clip_y > pixel_map->height) pixel_map->clip_y = pixel_map->height; + if (pixel_map->clip_width < 0) pixel_map->clip_width = 0; + if (pixel_map->clip_height < 0) pixel_map->clip_height = 0; + if (pixel_map->clip_width > pixel_map->width) pixel_map->clip_width = pixel_map->width; + if (pixel_map->clip_height > pixel_map->height) pixel_map->clip_height = pixel_map->height; + + for (index = 0; text[index] != 0; index++) + { + gfx = font->char_gfx[(uint8_t)text[index]]; + OPM_CopyGFXOPM_c(pixel_map, gfx, x, y, color_add); + x += gfx->width; + } + + pixel_map->clip_x = orig_clip_x; + pixel_map->clip_y = orig_clip_y; + pixel_map->clip_width = orig_clip_width; + pixel_map->clip_height = orig_clip_height; +} + +void TXT_UnloadAllFonts_c(void) +{ + int index; + + for (index = 0; index < 32; index++) + { + if (TXT_fonts[index] != NULL) + { + TXT_UnloadFont_c(index); + } + } +} + diff --git a/games/Battle Isle 3/SR-BI3/BBTXT.h b/games/Battle Isle 3/SR-BI3/BBTXT.h new file mode 100644 index 0000000..eef7d2e --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/BBTXT.h @@ -0,0 +1,44 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_BBTXT_H_INCLUDED_) +#define _BBTXT_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int TXT_Init_c(void); +void TXT_Exit_c(void); +int TXT_LoadFont_c(const char *path); +void TXT_WriteString_c(const char *text, int font_handle, void *dst_pixel_map, int x, int y, int width, int height, uint8_t color_add); +void TXT_UnloadAllFonts_c(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _BBTXT_H_INCLUDED_ */ diff --git a/games/Battle Isle 3/SR-BI3/CLIB.c b/games/Battle Isle 3/SR-BI3/CLIB.c new file mode 100644 index 0000000..5f610f3 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/CLIB.c @@ -0,0 +1,299 @@ +/** + * + * Copyright (C) 2019-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#define _FILE_OFFSET_BITS 64 +#include +#include +#include "CLIB.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if (defined(__WIN32__) || (__WINDOWS__)) && !defined(_WIN32) +#define _WIN32 +#endif + +#if defined(_WIN32) +#define WIN32_LEAN_AND_MEAN +#include +#endif + + +#define eprintf(...) fprintf(stderr,__VA_ARGS__) + + +static int32_t ms_randseed; + + +int32_t memcmp_c(const void *s1, const void *s2, uint32_t n) +{ +#ifdef DEBUG_CLIB + eprintf("memcmp: 0x%x, 0x%x, %i\n", (uintptr_t) s1, (uintptr_t) s2, n); +#endif + + return memcmp(s1, s2, n); +} + +void *memcpy_c(void *dest, const void *src, uint32_t n) +{ +#ifdef DEBUG_CLIB + eprintf("memcpy: 0x%x, 0x%x, %i\n", (uintptr_t) dest, (uintptr_t) src, n); +#endif + + return memcpy(dest, src, n); +} + +void *memset_c(void *s, int32_t c, uint32_t n) +{ +#ifdef DEBUG_CLIB + eprintf("memset: 0x%x, 0x%x, %i\n", (uintptr_t) s, c, n); +#endif + + return memset(s, c, n); +} + + +char *strcat_c(char *dest, const char *src) +{ +#ifdef DEBUG_CLIB + eprintf("strcat: 0x%x (%s), 0x%x (%s)\n", (uintptr_t) dest, dest, (uintptr_t) src, src); +#endif + + return strcat(dest, src); +} + +int32_t strcmp_c(const char *s1, const char *s2) +{ +#ifdef DEBUG_CLIB + eprintf("strcmp: 0x%x (%s), 0x%x (%s)\n", (uintptr_t) s1, s1, (uintptr_t) s2, s2); +#endif + + return strcmp(s1, s2); +} + +char *strcpy_c(char *dest, const char *src) +{ +#ifdef DEBUG_CLIB + eprintf("strcpy: 0x%x (%s), 0x%x (%s)\n", (uintptr_t) dest, dest, (uintptr_t) src, src); +#endif + + return strcpy(dest, src); +} + +uint32_t strlen_c(const char *s) +{ +#ifdef DEBUG_CLIB + eprintf("strlen: 0x%x (%s)\n", (uintptr_t) s, s); +#endif + + return strlen(s); +} + +char *strncpy_c(char *dest, const char *src, uint32_t n) +{ +#ifdef DEBUG_CLIB + eprintf("strncpy: 0x%x, 0x%x (%s), %i\n", (uintptr_t) dest, (uintptr_t) src, src, n); +#endif + + return strncpy(dest, src, n); +} + +int32_t _strnicmp_c(const char *s1, const char *s2, uint32_t n) +{ +#ifdef DEBUG_CLIB + eprintf("_strnicmp: 0x%x (%s), 0x%x (%s), %i\n", (uintptr_t) s1, s1, (uintptr_t) s2, s2, n); +#endif + + return strncasecmp(s1, s2, n); +} + +char *strstr_c(const char *haystack, const char *needle) +{ +#ifdef DEBUG_CLIB + eprintf("strstr: 0x%x (%s), 0x%x (%s)\n", (uintptr_t) haystack, haystack, (uintptr_t) needle, needle); +#endif + + return strstr(haystack, needle); +} + + +void ms_srand_c(uint32_t seed) +{ +#ifdef DEBUG_CLIB + eprintf("srand (MS): 0x%x\n", seed); +#endif + + ms_randseed = seed; +} + +int32_t ms_rand_c(void) +{ + int32_t newvalue; + +#ifdef DEBUG_CLIB + eprintf("rand (MS)\n"); +#endif + + newvalue = (ms_randseed * 0x343FD) + 0x269EC3; + ms_randseed = newvalue; + return (newvalue & 0x7FFF0000) >> 16; +} + +int32_t wc_rand_c(void) +{ +#ifdef DEBUG_CLIB + eprintf("rand (Watcom)\n"); +#endif + + // Watcom implementation returns values in range 0-0x7fff + return rand() & 0x7fff; +} + + +int32_t atoi_c(const char *nptr) +{ +#ifdef DEBUG_CLIB + eprintf("atoi: 0x%x (%s)\n", (uintptr_t) nptr, nptr); +#endif + + return atoi(nptr); +} + +int32_t atol_c(const char *nptr) +{ +#ifdef DEBUG_CLIB + eprintf("atol: 0x%x (%s)\n", (uintptr_t) nptr, nptr); +#endif + + return atol(nptr); +} + +static void xtoa(uint32_t value, char *buffer, int32_t radix, int negative) +{ + char ch; + char *pos1, *pos2; + unsigned int rem; + + if (negative) + { + *buffer = '-'; + buffer++; + value = -(int32_t)value; + } + + pos1 = buffer; + do + { + rem = value % radix; + value /= radix; + + if (rem <= 9) + { + *buffer++ = rem + '0'; + } + else + { + *buffer++ = rem + 'a' - 10; + } + } + while (value != 0); + *buffer = 0; + + pos2 = buffer - 1; + do + { + ch = *pos2; + *pos2 = *pos1; + *pos1 = ch; + + pos2--; + pos1++; + } + while (pos1 < pos2); +} + +char *_ltoa_c(int32_t value, char *buffer, int32_t radix) +{ +#ifdef DEBUG_CLIB + eprintf("_ltoa: %i, 0x%x, %i\n", value, (uintptr_t) buffer, radix); +#endif + + if ((radix == 10) && (value < 0)) + { + xtoa(value, buffer, 10, 1); + } + else + { + xtoa(value, buffer, radix, 0); + } + + return buffer; +} + + +int32_t isalnum_c(int32_t c) +{ +#ifdef DEBUG_CLIB + eprintf("isalnum: %i\n", c); +#endif + + return isalnum(c); +} + + +int32_t _except_handler3_c(void *exception_record, void *registration, void *context, void *dispatcher) +{ +#if defined(_WIN32) + fprintf(stderr, "exception handler 3: %i\n", (int) ((PEXCEPTION_RECORD)exception_record)->ExceptionCode); +#else + fprintf(stderr, "exception handler 3: %i\n", *((uint32_t *)exception_record)); +#endif +#if defined(__WINE__) + TerminateProcess(GetCurrentProcess(), 0); + return 0; +#else + exit(0); +#endif +} + + +void sync_c(void) +{ +#ifdef DEBUG_CLIB + eprintf("sync\n"); +#endif + +#if defined(__WINE__) || !defined(_WIN32) + sync(); +#endif +} + diff --git a/games/Battle Isle 3/SR-BI3/CLIB.h b/games/Battle Isle 3/SR-BI3/CLIB.h new file mode 100644 index 0000000..19daabc --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/CLIB.h @@ -0,0 +1,66 @@ +/** + * + * Copyright (C) 2019-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_CLIB_H_INCLUDED_) +#define _CLIB_H_INCLUDED_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int32_t memcmp_c(const void *s1, const void *s2, uint32_t n); +void *memcpy_c(void *dest, const void *src, uint32_t n); +void *memset_c(void *s, int32_t c, uint32_t n); + +char *strcat_c(char *dest, const char *src); +int32_t strcmp_c(const char *s1, const char *s2); +char *strcpy_c(char *dest, const char *src); +uint32_t strlen_c(const char *s); +char *strncpy_c(char *dest, const char *src, uint32_t n); +int32_t _strnicmp_c(const char *s1, const char *s2, uint32_t n); +char *strstr_c(const char *haystack, const char *needle); + +void ms_srand_c(uint32_t seed); +int32_t ms_rand_c(void); +int32_t wc_rand_c(void); + +int32_t atoi_c(const char *nptr); +int32_t atol_c(const char *nptr); +char *_ltoa_c(int32_t value, char *buffer, int32_t radix); + +int32_t isalnum_c(int32_t c); + +int32_t _except_handler3_c(void *exception_record, void *registration, void *context, void *dispatcher); + +void sync_c(void); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/games/Battle Isle 3/SR-BI3/FGT.c b/games/Battle Isle 3/SR-BI3/FGT.c new file mode 100644 index 0000000..362fbc2 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/FGT.c @@ -0,0 +1,73 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "FGT.h" +#define WIN32_LEAN_AND_MEAN +#include + + +static DWORD LastTicks[3]; +static int TicksDelay[3]; + +void FGT_SystemTask_End(int flushGdi) +{ + MSG msg; + + if (flushGdi) + { + GdiFlush(); + } + + if (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) + { + TranslateMessage(&msg); + DispatchMessageA(&msg); + } +} + +void FGT_CheckTicksDelay(int index) +{ + DWORD Ticks; + + Ticks = GetTickCount(); + if (Ticks == LastTicks[index]) + { + if (TicksDelay[index] == 0) + { + TicksDelay[index] = 1; + Sleep(0); + } + else + { + LastTicks[index] = 0; + Sleep(1); + } + } + else + { + LastTicks[index] = Ticks; + TicksDelay[index] = 0; + } +} + diff --git a/games/Battle Isle 3/SR-BI3/FGT.h b/games/Battle Isle 3/SR-BI3/FGT.h new file mode 100644 index 0000000..7976760 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/FGT.h @@ -0,0 +1,41 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_FGT_H_INCLUDED_) +#define _FGT_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void FGT_SystemTask_End(int flushGdi); +void FGT_CheckTicksDelay(int index); + +#ifdef __cplusplus +} +#endif + +#endif /* _FGT_H_INCLUDED_ */ diff --git a/games/Battle Isle 3/SR-BI3/Game-Config.c b/games/Battle Isle 3/SR-BI3/Game-Config.c new file mode 100644 index 0000000..3894c11 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/Game-Config.c @@ -0,0 +1,222 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#define GAME_CONFIG_DEFINE_VARIABLES +#include "Game-Config.h" +#include +#include +#include + + +#define CONFIG_FILE "BI3.cfg" + + +static char *trim_string(char *buf) +{ + int len; + + while (*buf == ' ') buf++; + + len = strlen(buf); + + while (len != 0 && buf[len - 1] == ' ') + { + len--; + buf[len] = 0; + } + + return buf; +} + + +void ReadConfiguration(void) __attribute__((noinline)); +void ReadConfiguration(void) +{ + FILE *f; + char buf[8192]; + char *str, *param; + int items, num_int; + + Intro_Play = 1; + Outro_Play = 1; + +#if defined(__WINE__) + Audio_MidiSubsystem = 3; +#else + Audio_MidiSubsystem = 11; +#endif + Audio_MidiVolume = 100; + Audio_SoundFontPath = NULL; + Audio_MidiDevice = NULL; + Audio_OPL3BankNumber = 59; + + f = fopen(CONFIG_FILE, "rt"); + if (f == NULL) return; + + + while (!feof(f)) + { + // skip empty lines + items = fscanf(f, "%8192[\n\r]", buf); + + // read line + buf[0] = 0; + items = fscanf(f, "%8192[^\n^\r]", buf); + if (items <= 0) continue; + + // trim line + str = trim_string(buf); + + if (str[0] == 0) continue; + if (str[0] == '#') continue; + + // find parameter (after '=') + param = strchr(str, '='); + + if (param == NULL) continue; + + // split string into two strings + *param = 0; + param++; + + // trim them + str = trim_string(str); + param = trim_string(param); + + if ( strncasecmp(str, "Intro_", 6) == 0 ) // str begins with "Intro_" + { + // intro settings + + str += 6; + + if ( strcasecmp(str, "Play") == 0 ) // str equals "Play" + { + if ( strcasecmp(param, "yes") == 0 ) // param equals "yes" + { + Intro_Play = 1; + } + else if ( strcasecmp(param, "no") == 0 ) // param equals "no" + { + Intro_Play = 0; + } + } + + } + else if ( strncasecmp(str, "Outro_", 6) == 0 ) // str begins with "Outro_" + { + // intro settings + + str += 6; + + if ( strcasecmp(str, "Play") == 0 ) // str equals "Play" + { + if ( strcasecmp(param, "yes") == 0 ) // param equals "yes" + { + Outro_Play = 1; + } + else if ( strcasecmp(param, "no") == 0 ) // param equals "no" + { + Outro_Play = 0; + } + } + + } + else if ( strncasecmp(str, "Audio_", 6) == 0 ) // str begins with "Audio_" + { + // audio settings + + str += 6; + + if ( strcasecmp(str, "MidiSubsystem") == 0 ) // str equals "MidiSubsystem" + { + // MIDI subsystem + + if ( strcasecmp(param, "wildmidi") == 0 ) // param equals "wildmidi" + { + Audio_MidiSubsystem = 1; + } + else if ( strcasecmp(param, "bassmidi") == 0 ) // param equals "bassmidi" + { + Audio_MidiSubsystem = 2; + } + else if ( strcasecmp(param, "adlmidi") == 0 ) // param equals "adlmidi" + { + Audio_MidiSubsystem = 3; + } + else if ( strcasecmp(param, "nativewindows") == 0 ) // param equals "nativewindows" + { + Audio_MidiSubsystem = 11; + } + else if ( strcasecmp(param, "alsa") == 0 ) // param equals "alsa" + { + Audio_MidiSubsystem = 12; + } + else if ( strcasecmp(param, "original") == 0 ) // param equals "original" + { + Audio_MidiSubsystem = 0; + } + } + else if ( strcasecmp(str, "MidiVolume") == 0 ) // str equals "MidiVolume" + { + num_int = 0; + sscanf(param, "%i", &num_int); + if (num_int > 0) + { + Audio_MidiVolume = num_int; + } + } + else if ( strcasecmp(str, "SoundFont_Path") == 0 ) // str equals "SoundFont_Path" + { + // path to SoundFont file + + if (*param != 0) + { + Audio_SoundFontPath = strdup(param); + } + } + else if ( strcasecmp(str, "MidiDevice") == 0 ) // str equals "MidiDevice" + { + // MIDI Device name + + if (*param != 0) + { + Audio_MidiDevice = strdup(param); + } + } + else if ( strcasecmp(str, "OPL3BankNumber") == 0 ) // str equals "OPL3BankNumber" + { + num_int = 0; + sscanf(param, "%i", &num_int); + if (num_int >= 0) + { + Audio_OPL3BankNumber = num_int; + } + } + + } + + } + + fclose(f); +} diff --git a/games/Battle Isle 3/SR-BI3/Game-Config.h b/games/Battle Isle 3/SR-BI3/Game-Config.h new file mode 100644 index 0000000..0f72409 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/Game-Config.h @@ -0,0 +1,52 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_GAME_CONFIG_H_INCLUDED_) +#define _GAME_CONFIG_H_INCLUDED_ + +#ifdef GAME_CONFIG_DEFINE_VARIABLES +#define GAME_CONFIG_STORAGE +#else +#define GAME_CONFIG_STORAGE extern +#endif + +GAME_CONFIG_STORAGE int Intro_Play; /* play intro movies ? */ +GAME_CONFIG_STORAGE int Outro_Play; /* play outro movies ? */ + +GAME_CONFIG_STORAGE int Audio_MidiSubsystem; /* MIDI subsystem + 0: original + 1: WildMidi + 2: BASSMIDI + 3: ADLMIDI + 11: native Windows + 12: ALSA */ +GAME_CONFIG_STORAGE int Audio_MidiVolume; /* MIDI volume (0-127) */ +GAME_CONFIG_STORAGE const char *Audio_SoundFontPath; /* Path to SoundFont file */ +GAME_CONFIG_STORAGE const char *Audio_MidiDevice; /* MIDI device */ +GAME_CONFIG_STORAGE int Audio_OPL3BankNumber; /* OPL3 bank number (0-72) */ + +void ReadConfiguration(void); + +#endif + diff --git a/games/Battle Isle 3/SR-BI3/SConstruct b/games/Battle Isle 3/SR-BI3/SConstruct new file mode 100644 index 0000000..aa3a5ef --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/SConstruct @@ -0,0 +1,146 @@ +# +# Copyright (C) 2019-2021 Roman Pauer +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +import os +import subprocess + +# set help text +vars = Variables('custom.py') +vars.Add(EnumVariable('debug', 'Set debug level (0 = release version)', '0', + allowed_values=('0', '1', '2'), + ignorecase=2)) +vars.Add(EnumVariable('device', 'Set target device', 'none', + allowed_values=('none', 'pc-windows', 'pc-windows-oldvideo', 'pc-linux', 'arm-linux-llasm', 'pc-linux-llasm'), + ignorecase=2)) +env = Environment(variables = vars) + +debug = int(env['debug']) +device = env['device'] +clean = env.GetOption('clean') + +if device == 'none': + device = 'pc-linux' + if env['PLATFORM'] == 'posix': + if os.uname()[4].startswith('arm'): + device = 'arm-linux-llasm' + env['device'] = device + print("\nYou didn't set any target device (parameter 'device').") + print("'" + device + "' will be used for compiling.\n") + +Help(vars.GenerateHelpText(env)) + +llasm_version = False +llasm_params = "" +llvm_params = "" + +if device.endswith("-llasm"): + llasm_version = True + device = device[0:-6] + +if device == 'pc-linux': + # default settings + env = Environment(CC = 'winegcc', + CCFLAGS = '-m32 -O2 -Wall', + LINK = 'winegcc', + LINKFLAGS = '-m32 -Wl,-z,noexecstack -mwindows', + LIBS = ['dl', 'quicktime', 'kernel32', 'winmm', 'user32', 'gdi32'] + ) + if llasm_version: + llasm_params = '-pic' + llvm_params = '-mtriple=i686-unknown-linux-gnu -relocation-model=pic' + env.Append(CCFLAGS = ' -fpic') + env.Append(LINKFLAGS = ' -pic') + env.Append(ENV = {'PATH' : os.environ['PATH']}) +elif device == 'arm-linux': + env = Environment(CC = 'winegcc', + CCFLAGS = '-O2 -Wall -fpic', + LINK = 'winegcc', + LINKFLAGS = '-Wl,-z,noexecstack -mwindows -pic', + LIBS = ['dl', 'quicktime', 'kernel32', 'winmm', 'user32', 'gdi32'], + ENV = {'PATH' : os.environ['PATH']} + ) + llasm_params = '-pic' + llvm_params = '-relocation-model=pic' +elif device == 'pc-windows': + env = Environment(CCFLAGS = '-m32 -O2 -Wall', + LINKFLAGS = '-m32 -mwindows', + LIBS = ['quicktime', 'kernel32', 'winmm', 'user32', 'gdi32'] + ) +elif device == 'pc-windows-oldvideo': + env = Environment(CCFLAGS = '-m32 -O2 -Wall -DOLDVIDEO', + LINKFLAGS = '-m32 -mwindows', + LIBS = ['kernel32', 'winmm', 'user32', 'gdi32'] + ) + +def get_compiler_version(compiler_path, env_path): + process = subprocess.Popen([compiler_path, '-dumpversion'], stdout=subprocess.PIPE, env={"PATH": env_path}) + (stdout, stderr) = process.communicate() + if not stdout or stdout.isspace(): + return None + version = stdout.strip().split(b'.') + return version + +def is_version_ge(version, comparand): + if version is None or comparand is None: + return False + + for i in range(len(comparand)): + if i >= len(version): + component = 0 + else: + component = int(version[i]) + if int(comparand[i]) > component: + return False + if int(comparand[i]) < component: + return True + return True + +if not llasm_version and not clean: + compiler_version = get_compiler_version(env['CC'], env['ENV']['PATH']) + if is_version_ge(compiler_version, [3, 4]): + env.Append(CCFLAGS = ' -fno-PIE') + if is_version_ge(compiler_version, [6]): + env.Append(LINKFLAGS = ' -no-pie') + +# debug settings +if debug <= 0: + env.Append(LINKFLAGS = ' -s') +elif debug == 1: + env.Append(CCFLAGS = ' -g') +else: + env.Append(CCFLAGS = ' -g -D__DEBUG__') + +if llasm_version: + bld = Builder(action = 'llasm $SOURCE -O -I .. ' + llasm_params + ' | opt -O3 | llc -O=3 -filetype=obj ' + llvm_params + ' > $TARGET', + suffix = "$OBJSUFFIX", + src_suffix = '.llasm' + ) + env.Append(BUILDERS = {'llasm' : bld}) + + arch_objs = SConscript('llasm/SConscript', exports='device env') +else: + arch_objs = SConscript('x86/SConscript', exports='device env') + +env.Program('SR-BI3', Glob('*.c') + arch_objs) + +if clean: + Execute(Delete(["SR-BI3.exe", "SR-BI3.exe.so"])) diff --git a/games/Battle Isle 3/SR-BI3/SDI.c b/games/Battle Isle 3/SR-BI3/SDI.c new file mode 100644 index 0000000..1efcfa0 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/SDI.c @@ -0,0 +1,591 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if defined(__WINE__) || !defined(OLDVIDEO) +#define USE_QUICKTIMELIB +#else +#undef USE_QUICKTIMELIB +#endif + +#include "SDI.h" +#define WIN32_LEAN_AND_MEAN +#include +#if defined(USE_QUICKTIMELIB) && !defined(__WINE__) +#include +#endif + + +static const char * const SDI_INI_name = "SDI.INI"; +const char *SDI_INI_path; +const char *SDI_install_path; +const char *SDI_CD_path; + +static struct { + DWORD Last; + int Delay; +} TicksArray[13]; + + +void SDI_CheckTicksDelay(int index) +{ + DWORD Ticks; + + Ticks = GetTickCount(); + if (Ticks == TicksArray[index].Last) + { + if (TicksArray[index].Delay == 0) + { + TicksArray[index].Delay = 1; + Sleep(0); + } + else + { + TicksArray[index].Last = 0; + Sleep(1); + } + } + else + { + TicksArray[index].Last = Ticks; + TicksArray[index].Delay = 0; + } +} + + +static int get_ansi_path(LPCWSTR lpPath, const char **result) +{ + DWORD dwAnsiLength, dwShortLength; + HANDLE hHeap; + char *lpAnsiBuffer; + LPWSTR lpShortBuffer; + BOOL bUsedDefaultChar; + + lpShortBuffer = NULL; + + // get length of ansi string + dwAnsiLength = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, lpPath, -1, NULL, 0, NULL, NULL); + hHeap = GetProcessHeap(); + if (dwAnsiLength < MAX_PATH) + { + // allocate buffer for ansi string + lpAnsiBuffer = (char *) HeapAlloc(hHeap, 0, dwAnsiLength); + if (lpAnsiBuffer == NULL) goto error; + + // convert unicode path to ansi string + dwAnsiLength = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, lpPath, -1, lpAnsiBuffer, dwAnsiLength, NULL, &bUsedDefaultChar); + if (dwAnsiLength == 0) goto error; + + if (!bUsedDefaultChar && dwAnsiLength < MAX_PATH) + { + // success, if ansi string is short enough and all characters could be represented + *result = lpAnsiBuffer; + return 1; + } + + HeapFree(hHeap, 0, lpAnsiBuffer); + } + + lpAnsiBuffer = NULL; + + // get length of short path + dwShortLength = GetShortPathNameW(lpPath, NULL, 0); + if (dwShortLength == 0) goto error; + + // allocate buffer for short path + lpShortBuffer = (LPWSTR) HeapAlloc(hHeap, 0, dwShortLength * sizeof(WCHAR)); + if (lpShortBuffer == NULL) goto error; + + // get short path from unicode path + dwShortLength = GetShortPathNameW(lpPath, lpShortBuffer, dwShortLength); + if (dwShortLength == 0) goto error; + + // get length of ansi string + dwAnsiLength = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, lpShortBuffer, -1, NULL, 0, NULL, NULL); + if (dwAnsiLength >= MAX_PATH) goto error; + + // allocate buffer for ansi string + lpAnsiBuffer = (char *) HeapAlloc(hHeap, 0, dwAnsiLength); + if (lpAnsiBuffer == NULL) goto error; + + // convert short path to ansi string + dwAnsiLength = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, lpShortBuffer, -1, lpAnsiBuffer, dwAnsiLength, NULL, &bUsedDefaultChar); + if (dwAnsiLength == 0) goto error; + + HeapFree(hHeap, 0, lpShortBuffer); + lpShortBuffer = NULL; + + if (!bUsedDefaultChar && dwAnsiLength < MAX_PATH) + { + // success, if ansi string is short enough and all characters could be represented + *result = lpAnsiBuffer; + return 1; + } + +error: + if (lpShortBuffer != NULL) + { + HeapFree(hHeap, 0, lpShortBuffer); + } + if (lpAnsiBuffer != NULL) + { + HeapFree(hHeap, 0, lpAnsiBuffer); + } + *result = NULL; + return 0; +} + +static int get_environment_path(LPCWSTR lpName, const char **result) +{ + DWORD dwLength; + LPWSTR lpBuffer, lpPath; + HANDLE hHeap; +#if defined(__WINE__) + DWORD dwUnixLength; + char *lpUnixBUffer; +#endif + + // get length of environment variable + dwLength = GetEnvironmentVariableW(lpName, NULL, 0); + if (dwLength <= 1) + { + // environment variable doesn't exist + *result = NULL; + return 1; + } + + // allocate buffer for environment variable + hHeap = GetProcessHeap(); + lpBuffer = (LPWSTR) HeapAlloc(hHeap, 0, (dwLength + 1) * sizeof(WCHAR)); + if (lpBuffer == NULL) goto error; + + // get environment variable + dwLength = GetEnvironmentVariableW(lpName, lpBuffer, dwLength); + if (dwLength == 0) goto error; + + // strip trailing slashes/backslashes + while ((dwLength != 0) && ((lpBuffer[dwLength - 1] == L'\\') || (lpBuffer[dwLength - 1] == L'/'))) + { + lpBuffer[dwLength - 1] = 0; + dwLength--; + } + + if ((dwLength == 2) && (lpBuffer[1] == L':')) + { + lpBuffer[2] = L'\\'; + lpBuffer[3] = 0; + dwLength++; + } + + if (dwLength == 0) + { + HeapFree(hHeap, 0, lpBuffer); + *result = NULL; + return 1; + } + +#if defined(__WINE__) + // get length of unix path + dwUnixLength = WideCharToMultiByte(CP_UNIXCP, 0, lpBuffer, -1, NULL, 0, NULL, NULL); + + // allocate buffer for unix path + lpUnixBUffer = (char *) HeapAlloc(hHeap, 0, dwUnixLength); + if (lpUnixBUffer == NULL) goto error; + + // convert environment variable to unix path + dwUnixLength = WideCharToMultiByte(CP_UNIXCP, 0, lpBuffer, -1, lpUnixBUffer, dwUnixLength, NULL, NULL); + if (dwUnixLength == 0) + { + HeapFree(hHeap, 0, lpUnixBUffer); + goto error; + } + + HeapFree(hHeap, 0, lpBuffer); + lpBuffer = NULL; + + // get windows path from unix path + lpPath = wine_get_dos_file_name(lpUnixBUffer); + HeapFree(hHeap, 0, lpUnixBUffer); + + if (lpPath == NULL) goto error; +#else + lpPath = lpBuffer; +#endif + + // get ansi path from unicode path + if (!get_ansi_path(lpPath, result)) goto error; + + if (lpBuffer != NULL) + { + HeapFree(hHeap, 0, lpBuffer); + } + return 1; + +error: + if (lpBuffer != NULL) + { + HeapFree(hHeap, 0, lpBuffer); + } + *result = NULL; + return 0; +} + +static int get_executable_path(LPCWSTR lpFileName, int include_filename, const char **result) +{ + WCHAR executable[MAX_PATH]; + DWORD dwAttrib, dwLength; + HANDLE hHeap; + LPWSTR lpBuffer, lpFilePart; + + // get path to executable + dwLength = GetModuleFileNameW(NULL, executable, MAX_PATH); + if ((dwLength == 0) || (dwLength >= MAX_PATH)) return 0; + + // get length of full path + dwLength = GetFullPathNameW(executable, 0, NULL, NULL); + if (dwLength == 0) return 0; + + // allocate buffer for full path + hHeap = GetProcessHeap(); + lpBuffer = (LPWSTR) HeapAlloc(hHeap, 0, (dwLength + ((lpFileName != NULL)?lstrlenW(lpFileName):0)) * sizeof(WCHAR)); + if (lpBuffer == NULL) goto error; + + // locate the filename in path + dwLength = GetFullPathNameW(executable, dwLength, lpBuffer, &lpFilePart); + if (dwLength == 0) goto error; + + if (lpFileName != NULL) + { + // replace filename in path with input filename + lstrcpyW(lpFilePart, lpFileName); + + // check if input filename exists in executable's directory + dwAttrib = GetFileAttributesW(lpBuffer); + if ((dwAttrib == INVALID_FILE_ATTRIBUTES) || (dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) goto error; + } + + // if it does, then use the full path to it + if (!include_filename) + { + lpFilePart[-1] = 0; + + if ((lpBuffer[1] == L':') && (lpBuffer[2] == 0)) + { + lpBuffer[2] = L'\\'; + lpBuffer[3] = 0; + } + } + + // get ansi path from unicode path + if (!get_ansi_path(lpBuffer, result)) goto error; + + HeapFree(hHeap, 0, lpBuffer); + return 1; + +error: + if (lpBuffer != NULL) + { + HeapFree(hHeap, 0, lpBuffer); + } + *result = NULL; + return 0; +} + +static int get_full_path(LPCWSTR lpFileName, const char **result) +{ + DWORD dwLength; + HANDLE hHeap; + LPWSTR lpBuffer; + + // get length of full path + dwLength = GetFullPathNameW(lpFileName, 0, NULL, NULL); + if (dwLength == 0) return 0; + + // allocate buffer for full path + hHeap = GetProcessHeap(); + lpBuffer = (LPWSTR) HeapAlloc(hHeap, 0, dwLength * sizeof(WCHAR)); + if (lpBuffer == NULL) goto error; + + // get full path + dwLength = GetFullPathNameW(lpFileName, dwLength, lpBuffer, NULL); + if (dwLength == 0) goto error; + + // get ansi path from unicode path + if (!get_ansi_path(lpBuffer, result)) goto error; + + HeapFree(hHeap, 0, lpBuffer); + return 1; + +error: + if (lpBuffer != NULL) + { + HeapFree(hHeap, 0, lpBuffer); + } + *result = NULL; + return 0; +} + +static int get_current_path(const char **result) +{ + DWORD dwLength; + HANDLE hHeap; + LPWSTR lpBuffer; + + // get length of current path + dwLength = GetCurrentDirectoryW(0, NULL); + if (dwLength == 0) return 0; + + // allocate buffer for current path + hHeap = GetProcessHeap(); + lpBuffer = (LPWSTR) HeapAlloc(hHeap, 0, dwLength * sizeof(WCHAR)); + if (lpBuffer == NULL) goto error; + + // get current path + dwLength = GetCurrentDirectoryW(dwLength, lpBuffer); + if (dwLength == 0) goto error; + + // get ansi path from unicode path + if (!get_ansi_path(lpBuffer, result)) goto error; + + HeapFree(hHeap, 0, lpBuffer); + return 1; + +error: + if (lpBuffer != NULL) + { + HeapFree(hHeap, 0, lpBuffer); + } + *result = NULL; + return 0; +} + +static int duplicate_ansi_string(char *lpPath, DWORD dwLength, const char **result) +{ + char *lpAnsiBuffer; + + if ((dwLength == 0) || (dwLength >= MAX_PATH)) return 0; + + lpAnsiBuffer = (char *) HeapAlloc(GetProcessHeap(), 0, dwLength + 1); + if (lpAnsiBuffer == NULL) return 0; + + lstrcpyA(lpAnsiBuffer, lpPath); + *result = lpAnsiBuffer; + return 1; +} + +static int set_current_path(void) +{ + WCHAR executable[MAX_PATH]; + DWORD dwLength; + HANDLE hHeap; + LPWSTR lpBuffer, lpFilePart; + + // get path to executable + dwLength = GetModuleFileNameW(NULL, executable, MAX_PATH); + if ((dwLength == 0) || (dwLength >= MAX_PATH)) return 0; + + // get length of full path + dwLength = GetFullPathNameW(executable, 0, NULL, NULL); + if (dwLength == 0) return 0; + + // allocate buffer for full path + hHeap = GetProcessHeap(); + lpBuffer = (LPWSTR) HeapAlloc(hHeap, 0, dwLength * sizeof(WCHAR)); + if (lpBuffer == NULL) goto error; + + // locate the filename in path + dwLength = GetFullPathNameW(executable, dwLength, lpBuffer, &lpFilePart); + if (dwLength == 0) goto error; + + // remove filename in path + lpFilePart[1] = 0; + + // set current directory + if (!SetCurrentDirectoryW(lpBuffer)) goto error; + + HeapFree(hHeap, 0, lpBuffer); + return 1; + +error: + if (lpBuffer != NULL) + { + HeapFree(hHeap, 0, lpBuffer); + } + return 0; +} + +int SDI_LocatePaths(void) __attribute__((noinline)); +int SDI_LocatePaths(void) +{ + DWORD dwAttrib, dwLength; +#if defined(USE_QUICKTIMELIB) && !defined(__WINE__) + char buffer[MAX_PATH + 24]; +#else + char buffer[MAX_PATH + 8]; +#endif + + + // if environment variable SDI_INSTALL_PATH is set then it contains the path to the installed game + if (!get_environment_path(L"SDI_INSTALL_PATH", &SDI_install_path)) return 0; + + + SDI_INI_path = NULL; + if (SDI_install_path != NULL) + { + lstrcpyA(buffer, SDI_install_path); + if (!((buffer[1] == ':') && (buffer[2] == '\\') && (buffer[3] == 0))) + { + lstrcatA(buffer, "\\"); + } + lstrcatA(buffer, SDI_INI_name); + dwLength = lstrlenA(buffer); + + if (dwLength <= MAX_PATH) + { + // check if SDI.INI exists in the game install directory + dwAttrib = GetFileAttributesA(buffer); + if ((dwAttrib != INVALID_FILE_ATTRIBUTES) && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) + { + // if it does, then use the full path to it + if (!duplicate_ansi_string(buffer, dwLength, &SDI_INI_path)) return 0; + } + } + } + + if (SDI_INI_path == NULL) + { + // check if SDI.INI exists in executable's directory + // if it does, then use the full path to it + if (!get_executable_path(L"SDI.INI", 1, &SDI_INI_path)) return 0; + } + + if (SDI_INI_path == NULL) + { + // check if SDI.INI exists in current directory + dwAttrib = GetFileAttributesA(SDI_INI_name); + if ((dwAttrib != INVALID_FILE_ATTRIBUTES) && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) + { + // if it does, then get the full path to it + if (!get_full_path(L"SDI.INI", &SDI_INI_path)) return 0; + } + } + + if (SDI_INI_path == NULL) + { + // if SDI.INI wasn't found, then use SDI.INI in windows directory + SDI_INI_path = SDI_INI_name; + } + + + if (SDI_install_path == NULL) + { + // check if TST.LIB exists in executable's directory + // if it does, then use executable's directory as game install directory + if (!get_executable_path(L"TST.LIB", 0, &SDI_install_path)) return 0; + } + + if (SDI_install_path == NULL) + { + // use current directory as game install directory + if (!get_current_path(&SDI_install_path)) return 0; + } + + + // if environment variable SDI_CD_PATH is set then it contains the path to the game CD + if (!get_environment_path(L"SDI_CD_PATH", &SDI_CD_path)) return 0; + +#if !defined(__WINE__) + if (SDI_CD_path == NULL) + { + dwLength = GetPrivateProfileStringA("FILES", "PATH3", NULL, buffer, MAX_PATH + 1, SDI_INI_name); + + while ((dwLength != 0) && ((buffer[dwLength - 1] == '\\') || (buffer[dwLength - 1] == '/'))) + { + buffer[dwLength - 1] = 0; + dwLength--; + } + + if ((dwLength != 0) && (dwLength < (MAX_PATH - 7))) + { + // add trailing backslash + buffer[dwLength] = '\\'; + dwLength++; + + lstrcatA(buffer, "CD2.ID"); + + // check if CD2.ID exists in path written in SDI.INI in windows directory + dwAttrib = GetFileAttributesA(buffer); + if ((dwAttrib != INVALID_FILE_ATTRIBUTES) && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) + { + // if it does, then use the path as game CD path + if ((dwLength == 3) && (buffer[1] == ':')) + { + buffer[dwLength] = 0; + } + else + { + buffer[dwLength - 1] = 0; + dwLength--; + } + + if (!duplicate_ansi_string(buffer, dwLength, &SDI_CD_path)) return 0; + } + } + } +#endif + + if (SDI_CD_path == NULL) + { + // use DATA firectory in game install path as game CD path + lstrcpyA(buffer, SDI_install_path); + if (!((buffer[1] == ':') && (buffer[2] == '\\') && (buffer[3] == 0))) + { + lstrcatA(buffer, "\\"); + } + lstrcatA(buffer, "DATA"); + + if (!duplicate_ansi_string(buffer, lstrlenA(buffer), &SDI_CD_path)) return 0; + } + +#if defined(USE_QUICKTIMELIB) && !defined(__WINE__) + if (NULL == getenv("LIBQUICKTIME_PLUGIN_DIR")) + { + const char *plugin_path; + if (get_executable_path(NULL, 0, &plugin_path)) + { + lstrcpyA(buffer, "LIBQUICKTIME_PLUGIN_DIR"); + buffer[23] = '='; + buffer[24] = 0; + lstrcatA(buffer, plugin_path); + HeapFree(GetProcessHeap(), 0, (LPVOID)plugin_path); + + putenv(buffer); + } + } +#endif + + set_current_path(); + + return 1; +} + diff --git a/games/Battle Isle 3/SR-BI3/SDI.h b/games/Battle Isle 3/SR-BI3/SDI.h new file mode 100644 index 0000000..5534806 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/SDI.h @@ -0,0 +1,41 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_SDI_H_INCLUDED_) +#define _SDI_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void SDI_CheckTicksDelay(int index); +int SDI_LocatePaths(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _SDI_H_INCLUDED_ */ diff --git a/games/Battle Isle 3/SR-BI3/SDIcmdline.c b/games/Battle Isle 3/SR-BI3/SDIcmdline.c new file mode 100644 index 0000000..a91c1b7 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/SDIcmdline.c @@ -0,0 +1,95 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "SDIcmdline.h" +#define WIN32_LEAN_AND_MEAN +#include + + +int cmdline_ContainsOption(int option) +{ + const char *curptr; + char option_upper; + + curptr = GetCommandLineA(); + if (curptr == NULL) return 0; + + option_upper = (char)option; + if ((option_upper >= 'a') && (option_upper <= 'z')) + { + option_upper -= 0x20; + } + + while (1) + { + while ((*curptr != 0) && (*curptr != '/') && (*curptr != '-')) + { + curptr++; + } + + if (*curptr == 0) + { + return 0; + } + + curptr++; + + if ((*curptr == option_upper) || + ((*curptr >= 'a') && + (*curptr <= 'z') && + ((*curptr - 0x20) == option_upper) + ) + ) + { + return 1; + } + }; +} + +void cmdline_ReadLanguageOption(uint32_t *language) +{ + const char *curptr; + + curptr = GetCommandLineA(); + if (curptr == NULL) return; + + while (*curptr != 0) + { + if ((*curptr == '/') || (*curptr == '-')) + { + curptr++; + + if ((*curptr >= '0') && (*curptr <= '9')) + { + *language = *curptr - '0'; + break; + } + } + else + { + curptr++; + } + }; +} + diff --git a/games/Battle Isle 3/SR-BI3/SDIcmdline.h b/games/Battle Isle 3/SR-BI3/SDIcmdline.h new file mode 100644 index 0000000..67db7d4 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/SDIcmdline.h @@ -0,0 +1,41 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_SDICMDLINE_H_INCLUDED_) +#define _SDICMDLINE_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int cmdline_ContainsOption(int option); +void cmdline_ReadLanguageOption(uint32_t *language); + +#ifdef __cplusplus +} +#endif + +#endif /* _SDICMDLINE_H_INCLUDED_ */ diff --git a/games/Battle Isle 3/SR-BI3/SDImidi.c b/games/Battle Isle 3/SR-BI3/SDImidi.c new file mode 100644 index 0000000..4ad35d4 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/SDImidi.c @@ -0,0 +1,819 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "SDImidi.h" +#include "midi-plugins.h" +#include "midi-plugins2.h" +#include "Game-Config.h" +#include +#include +#include + +#if defined(__WINE__) + #undef MIDI_WINDOWS +#else + #define MIDI_WINDOWS 1 +#endif + +#if !defined(MIDI_WINDOWS) + #include +#endif + + +#define MS_STOPPED 0 +#define MS_OPENED 1 +#define MS_PLAYING 2 + + +#define BUFFER_SIZE 28672 + +#define MP_STOPPED 0 +#define MP_PLAYING 1 +#define MP_PAUSED 2 +#define MP_STARTED 3 + + +typedef struct _MP_midi_ { + uint16_t bytes_left[2], start_index, reserved; + volatile uint8_t read_buffer, write_buffer, status; + uint8_t end_of_midi; + int32_t loop_count; + void *midi; + CRITICAL_SECTION critsec; + WAVEHDR header[2]; + uint8_t buffer[2][BUFFER_SIZE]; +} MP_midi; + + +#if defined(MIDI_WINDOWS) + static HMODULE MP_handle = NULL; + static HMODULE MP2_handle = NULL; +#else + static void *MP_handle = NULL; + static void *MP2_handle = NULL; +#endif + +static midi_plugin_functions MP_functions; +static midi_plugin2_functions MP2_functions; + +static void *midi_buffer; +static int midi_status, midi_size; + +static MP_midi MP_sequence; + +static HWAVEOUT hWaveOut; + +static HANDLE MP_thread; +static volatile int thread_finish; + + +static DWORD WINAPI MP_ProcessData(LPVOID lpParameter) +{ + while (!thread_finish) + { + if (TryEnterCriticalSection(&(MP_sequence.critsec))) + { + if (MP_sequence.midi != NULL) + { + if (MP_sequence.status == MP_PLAYING) + { + if (MP_sequence.header[MP_sequence.read_buffer & 1].dwFlags & WHDR_DONE) + { + MP_sequence.header[MP_sequence.read_buffer & 1].dwFlags &= ~WHDR_DONE; + + MP_sequence.start_index = 0; + MP_sequence.read_buffer = (MP_sequence.read_buffer + 1) & 3; + } + + if (MP_sequence.end_of_midi) + { + if (MP_sequence.read_buffer == MP_sequence.write_buffer) + { + MP_sequence.status = MP_STOPPED; + } + } + else + { + if ((((MP_sequence.read_buffer + 1) & 3) == MP_sequence.write_buffer) || + (MP_sequence.read_buffer == MP_sequence.write_buffer) + ) + { + int write_buffer; + + write_buffer = MP_sequence.write_buffer & 1; + + MP_sequence.bytes_left[write_buffer] = MP_functions.get_data(MP_sequence.midi, (char *) MP_sequence.buffer[write_buffer], BUFFER_SIZE); + if (MP_sequence.bytes_left[write_buffer] != BUFFER_SIZE) + { + MP_functions.rewind_midi(MP_sequence.midi); + + if (MP_sequence.loop_count != 0) + { + MP_sequence.loop_count--; + if (MP_sequence.loop_count == 0) + { + MP_sequence.loop_count = 1; + MP_sequence.end_of_midi = 1; + } + } + + if (!MP_sequence.end_of_midi) + { + int size; + + size = MP_functions.get_data(MP_sequence.midi, (char *) &(MP_sequence.buffer[write_buffer][MP_sequence.bytes_left[write_buffer]]), BUFFER_SIZE - MP_sequence.bytes_left[write_buffer]); + MP_sequence.bytes_left[write_buffer] += size; + } + else + { + memset(&(MP_sequence.buffer[write_buffer][MP_sequence.bytes_left[write_buffer]]), 0, BUFFER_SIZE - MP_sequence.bytes_left[write_buffer]); + } + } + + if (MP_sequence.read_buffer == MP_sequence.write_buffer) + { + MP_sequence.start_index = 0; + } + + waveOutWrite(hWaveOut, &(MP_sequence.header[write_buffer]), sizeof(WAVEHDR)); + + MP_sequence.write_buffer = (MP_sequence.write_buffer + 1) & 3; + } + } + } + else if (MP_sequence.status == MP_STARTED) + { + MP_sequence.end_of_midi = 0; + + if ((((MP_sequence.read_buffer + 1) & 3) == MP_sequence.write_buffer) || + (MP_sequence.read_buffer == MP_sequence.write_buffer) + ) + { + int write_buffer; + + write_buffer = MP_sequence.write_buffer & 1; + + MP_sequence.bytes_left[write_buffer] = MP_functions.get_data(MP_sequence.midi, (char *) MP_sequence.buffer[write_buffer], BUFFER_SIZE); + + if (MP_sequence.read_buffer == MP_sequence.write_buffer) + { + MP_sequence.start_index = 0; + } + + waveOutWrite(hWaveOut, &(MP_sequence.header[write_buffer]), sizeof(WAVEHDR)); + + MP_sequence.write_buffer = (MP_sequence.write_buffer + 1) & 3; + } + + MP_sequence.status = MP_PLAYING; + } + } + + LeaveCriticalSection(&(MP_sequence.critsec)); + } + + Sleep(10); + } + + return 0; +} + +static int MP_Startup(void) +{ + midi_plugin_initialize MP_initialize; + midi_plugin_parameters MP_parameters; + WAVEFORMATEX waveFormat; + + if (MP_handle != NULL) return 0; + +#if defined(MIDI_WINDOWS) + if (Audio_MidiSubsystem == 1) { + MP_handle = LoadLibrary(".\\midi-wildmidi.dll"); + } else if (Audio_MidiSubsystem == 2) { + MP_handle = LoadLibrary(".\\midi-bassmidi.dll"); + } else if (Audio_MidiSubsystem == 3) { + MP_handle = LoadLibrary(".\\midi-adlmidi.dll"); + } else return 1; + + #define free_library FreeLibrary + #define get_proc_address GetProcAddress +#else + if (Audio_MidiSubsystem == 1) { + MP_handle = dlopen("./midi-wildmidi.so", RTLD_LAZY); + } else if (Audio_MidiSubsystem == 2) { + MP_handle = dlopen("./midi-bassmidi.so", RTLD_LAZY); + } else if (Audio_MidiSubsystem == 3) { + MP_handle = dlopen("./midi-adlmidi.so", RTLD_LAZY); + } else return 1; + + #define free_library dlclose + #define get_proc_address dlsym +#endif + if (MP_handle == NULL) return 2; + + MP_initialize = (midi_plugin_initialize) get_proc_address(MP_handle, MIDI_PLUGIN_INITIALIZE); + + if (MP_initialize == NULL) + { + free_library(MP_handle); + MP_handle = NULL; + return 3; + } + + memset(&MP_parameters, 0, sizeof(MP_parameters)); + MP_parameters.soundfont_path = Audio_SoundFontPath; + MP_parameters.opl3_bank_number = Audio_OPL3BankNumber; + + if (MP_initialize(44100, &MP_parameters, &MP_functions)) + { + free_library(MP_handle); + MP_handle = NULL; + return 4; + } + + // initialize buffers + memset(&(MP_sequence), 0, (char *) &(MP_sequence.buffer) - (char *) &(MP_sequence)); + InitializeCriticalSection(&(MP_sequence.critsec)); + + // initialize waveout + waveFormat.wFormatTag = WAVE_FORMAT_PCM; + waveFormat.nChannels = 2; + waveFormat.nSamplesPerSec = 44100; + waveFormat.nAvgBytesPerSec = 4 * 44100; + waveFormat.nBlockAlign = 4; + waveFormat.wBitsPerSample = 16; + waveFormat.cbSize = 0; + + if (MMSYSERR_NOERROR != waveOutOpen(&hWaveOut, WAVE_MAPPER, &waveFormat, 0, 0, WAVE_ALLOWSYNC)) + { + DeleteCriticalSection(&(MP_sequence.critsec)); + MP_functions.shutdown_plugin(); + free_library(MP_handle); + MP_handle = NULL; + return 5; + } + + MP_sequence.header[0].lpData = (LPSTR) &(MP_sequence.buffer[0]); + MP_sequence.header[0].dwBufferLength = BUFFER_SIZE; + MP_sequence.header[1].lpData = (LPSTR) &(MP_sequence.buffer[1]); + MP_sequence.header[1].dwBufferLength = BUFFER_SIZE; + + if (MMSYSERR_NOERROR != waveOutPrepareHeader(hWaveOut, &(MP_sequence.header[0]), sizeof(WAVEHDR))) + { + waveOutClose(hWaveOut); + DeleteCriticalSection(&(MP_sequence.critsec)); + MP_functions.shutdown_plugin(); + free_library(MP_handle); + MP_handle = NULL; + return 5; + } + if (MMSYSERR_NOERROR != waveOutPrepareHeader(hWaveOut, &(MP_sequence.header[1]), sizeof(WAVEHDR))) + { + waveOutUnprepareHeader(hWaveOut, &(MP_sequence.header[0]), sizeof(WAVEHDR)); + waveOutClose(hWaveOut); + DeleteCriticalSection(&(MP_sequence.critsec)); + MP_functions.shutdown_plugin(); + free_library(MP_handle); + MP_handle = NULL; + return 5; + } + + MP_functions.set_master_volume(Audio_MidiVolume); + + // start thread + thread_finish = 0; + + MP_thread = CreateThread(NULL, 0, MP_ProcessData, NULL, 0, NULL); + if (MP_thread == NULL) + { + DeleteCriticalSection(&(MP_sequence.critsec)); + MP_functions.shutdown_plugin(); + free_library(MP_handle); + MP_handle = NULL; + return 6; + } + + midi_status = MS_STOPPED; + + return 0; + +#undef get_proc_address +#undef free_library +} + +static void MP_Shutdown(void) +{ + if (MP_handle == NULL) return; + + // stop thread + thread_finish = 1; + WaitForSingleObjectEx(MP_thread, INFINITE, FALSE); + CloseHandle(MP_thread); + + // close waveout + waveOutReset(hWaveOut); + waveOutUnprepareHeader(hWaveOut, &(MP_sequence.header[1]), sizeof(WAVEHDR)); + waveOutUnprepareHeader(hWaveOut, &(MP_sequence.header[0]), sizeof(WAVEHDR)); + waveOutClose(hWaveOut); + + // close midi files + if (MP_sequence.midi != NULL) + { + MP_functions.close_midi(MP_sequence.midi); + MP_sequence.midi = NULL; + } + DeleteCriticalSection(&(MP_sequence.critsec)); + + MP_functions.shutdown_plugin(); +#if defined(MIDI_WINDOWS) + FreeLibrary(MP_handle); +#else + dlclose(MP_handle); +#endif + MP_handle = NULL; +} + + +static int MP2_Startup(void) +{ + midi_plugin2_initialize MP2_initialize; + midi_plugin2_parameters MP2_parameters; + + if (MP2_handle != NULL) return 0; + +#if defined(MIDI_WINDOWS) + if (Audio_MidiSubsystem == 11) { + MP2_handle = LoadLibraryA(".\\midi2-windows.dll"); + } else return 1; + + #define free_library FreeLibrary + #define get_proc_address GetProcAddress +#else + if (Audio_MidiSubsystem == 12) { + MP2_handle = dlopen("./midi2-alsa.so", RTLD_LAZY); + } else return 1; + + #define free_library dlclose + #define get_proc_address dlsym +#endif + if (MP2_handle == NULL) return 2; + + MP2_initialize = (midi_plugin2_initialize) get_proc_address(MP2_handle, MIDI_PLUGIN2_INITIALIZE); + + if (MP2_initialize == NULL) + { + free_library(MP2_handle); + MP2_handle = NULL; + return 3; + } + + memset(&MP2_parameters, 0, sizeof(MP2_parameters)); + MP2_parameters.midi_device_name = Audio_MidiDevice; + + if (MP2_initialize(&MP2_parameters, &MP2_functions)) + { + free_library(MP2_handle); + MP2_handle = NULL; + return 4; + } + + midi_buffer = NULL; + midi_status = MS_STOPPED; + + MP2_functions.set_volume(Audio_MidiVolume); + + return 0; + +#undef get_proc_address +#undef free_library +} + +static void MP2_Shutdown(void) +{ + if (MP2_handle == NULL) return; + + MP2_functions.halt(); + + MP2_functions.shutdown_plugin(); +#if defined(MIDI_WINDOWS) + FreeLibrary(MP2_handle); +#else + dlclose(MP2_handle); +#endif + MP2_handle = NULL; +} + + +int midi_PluginStartup(void) __attribute__((noinline)); +int midi_PluginStartup(void) +{ + if (Audio_MidiSubsystem == 0) return 0; + + if (Audio_MidiSubsystem <= 10) + { + return MP_Startup(); + } + else + { + return MP2_Startup(); + } +} + +void midi_PluginShutdown(void) +{ + if (Audio_MidiSubsystem == 0) return; + + if (Audio_MidiSubsystem <= 10) + { + MP_Shutdown(); + } + else + { + MP2_Shutdown(); + } +} + + +static void unload_midi(void) +{ + if (midi_buffer != NULL) + { + HeapFree(GetProcessHeap(), 0, midi_buffer); + + midi_buffer = NULL; + } +} + +static int load_midi(const char *filename) +{ + HANDLE hFile; + DWORD dwFileSize, dwFileSizeHigh, dwBytesRead; + BOOL bResult; + + hFile = CreateFileA(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); + if (hFile == INVALID_HANDLE_VALUE) return 0; + + dwFileSize = GetFileSize(hFile, &dwFileSizeHigh); + if ((dwFileSize == INVALID_FILE_SIZE) || (dwFileSizeHigh != 0)) + { + CloseHandle(hFile); + return 0; + } + + midi_buffer = HeapAlloc(GetProcessHeap(), 0, dwFileSize); + if (midi_buffer == NULL) + { + CloseHandle(hFile); + return 0; + } + + bResult = ReadFile(hFile, midi_buffer, dwFileSize, &dwBytesRead, NULL); + if ((!bResult) || (dwBytesRead != dwFileSize)) + { + unload_midi(); + CloseHandle(hFile); + return 0; + } + + CloseHandle(hFile); + + midi_size = dwFileSize; + + return 1; +} + + +int midi_OpenSDIMusic(const char *filename) +{ + // change: + if (Audio_MidiSubsystem == 0) + { + char strCommand[1024]; + char strReturnString[128]; + + sprintf(strCommand, "open sequencer!%s alias sdimusic", filename); + return mciSendStringA(strCommand, strReturnString, 128, NULL); + } + + if (Audio_MidiSubsystem <= 10) + { + if (MP_handle == NULL) + { + midi_status = MS_OPENED; + return 0; + } + + EnterCriticalSection(&(MP_sequence.critsec)); + + waveOutReset(hWaveOut); + MP_sequence.status = MP_STOPPED; + MP_sequence.read_buffer = 0; + MP_sequence.write_buffer = 0; + MP_sequence.end_of_midi = 0; + + if (MP_sequence.midi != NULL) + { + MP_functions.close_midi(MP_sequence.midi); + MP_sequence.midi = NULL; + } + + unload_midi(); + + midi_status = MS_STOPPED; + + if (!load_midi(filename)) + { + LeaveCriticalSection(&(MP_sequence.critsec)); + return 2; + } + + MP_sequence.loop_count = 0; + MP_sequence.midi = MP_functions.open_buffer(midi_buffer, midi_size); + LeaveCriticalSection(&(MP_sequence.critsec)); + + if (MP_sequence.midi == NULL) return 2; + } + else + { + if (MP2_handle == NULL) + { + midi_status = MS_OPENED; + return 0; + } + + MP2_functions.halt(); + unload_midi(); + + midi_status = MS_STOPPED; + + if (!load_midi(filename)) return 2; + } + + midi_status = MS_OPENED; + return 0; +} + +unsigned int midi_GetSDIMusicID(void) +{ + // change: + if (Audio_MidiSubsystem == 0) + { + return mciGetDeviceIDA("sdimusic"); + } + + if (Audio_MidiSubsystem <= 10) + { + if (MP_handle == NULL) return 2; + } + else + { + if (MP2_handle == NULL) return 2; + } + + return (midi_status != MS_STOPPED)?1:0; +} + +int midi_PlaySDIMusic(void) +{ + // change: + if (Audio_MidiSubsystem == 0) + { + char strReturnString[128]; + + return mciSendStringA("play sdimusic from 0", strReturnString, 128, NULL); + } + + if (Audio_MidiSubsystem <= 10) + { + if (MP_handle == NULL) + { + midi_status = MS_PLAYING; + return 0; + } + + if (midi_status == MS_STOPPED) return 3; + + if (midi_status == MS_OPENED) + { + EnterCriticalSection(&(MP_sequence.critsec)); + + MP_sequence.status = MP_STARTED; + + LeaveCriticalSection(&(MP_sequence.critsec)); + + midi_status = MS_PLAYING; + } + } + else + { + if (MP2_handle == NULL) + { + midi_status = MS_PLAYING; + return 0; + } + + if (midi_status == MS_STOPPED) return 3; + + if (midi_status == MS_OPENED) + { + if (MP2_functions.play(midi_buffer, midi_size, -1)) return 4; + + midi_status = MS_PLAYING; + } + } + + return 0; +} + +int midi_CloseSDIMusic(void) +{ + // change: + if (Audio_MidiSubsystem == 0) + { + char strReturnString[128]; + + return mciSendStringA("close sdimusic", strReturnString, 128, NULL); + } + + if (Audio_MidiSubsystem <= 10) + { + if (MP_handle == NULL) + { + midi_status = MS_STOPPED; + return 0; + } + + EnterCriticalSection(&(MP_sequence.critsec)); + + waveOutReset(hWaveOut); + MP_sequence.status = MP_STOPPED; + MP_sequence.read_buffer = 0; + MP_sequence.write_buffer = 0; + + if (MP_sequence.midi != NULL) + { + MP_functions.close_midi(MP_sequence.midi); + MP_sequence.midi = NULL; + } + + LeaveCriticalSection(&(MP_sequence.critsec)); + + unload_midi(); + } + else + { + if (MP2_handle == NULL) + { + midi_status = MS_STOPPED; + return 0; + } + + MP2_functions.halt(); + unload_midi(); + } + + midi_status = MS_STOPPED; + return 0; +} + +int midi_IsPlaying(unsigned int musicID) +{ + // change: + if (Audio_MidiSubsystem == 0) + { + MCI_STATUS_PARMS mciStatusParms; + + mciStatusParms.dwCallback = 0; + mciStatusParms.dwItem = MCI_STATUS_MODE; + + if (0 != mciSendCommandA(musicID, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&mciStatusParms)) + { + return 0; + } + + return ((mciStatusParms.dwReturn == MCI_MODE_PLAY) || (mciStatusParms.dwReturn == MCI_MODE_SEEK))?1:0; + } + + if (Audio_MidiSubsystem <= 10) + { + if (MP_handle == NULL) + { + return (midi_status == MS_PLAYING)?1:0; + } + } + else + { + if (MP2_handle == NULL) + { + return (midi_status == MS_PLAYING)?1:0; + } + } + if (musicID == 0) return 0; + + return (midi_status == MS_PLAYING)?1:0; +} + + +int midi_OpenTestMusic(void) +{ + // change: + if (Audio_MidiSubsystem == 0) + { + char strReturnString[1024]; + + return mciSendStringA("open sequencer!TST.MID alias testmusic", strReturnString, 1024, NULL); + } + + return midi_OpenSDIMusic("TST.MID"); +} + +int midi_PlayTestMusic(void) +{ + // change: + if (Audio_MidiSubsystem == 0) + { + char strReturnString[1024]; + + return mciSendStringA("play testmusic from 0", strReturnString, 1024, NULL); + } + + return midi_PlaySDIMusic(); +} + +int midi_CloseTestMusic(void) +{ + // change: + if (Audio_MidiSubsystem == 0) + { + char strReturnString[128]; + + return mciSendStringA("close testmusic", strReturnString, 128, NULL); + } + + return midi_CloseSDIMusic(); +} + + +int midi_GetErrorString(int error, char *text, unsigned int length) +{ + // change: + if (Audio_MidiSubsystem == 0) + { + return mciGetErrorStringA(error, text, length); + } + + const char *errorText; + + if (text == NULL) return 0; + + switch (error) + { + case 1: + errorText = "MIDI plugin is not loaded"; + break; + case 2: + errorText = "MIDI file could not be loaded"; + break; + case 3: + errorText = "MIDI file is not loaded"; + break; + case 4: + errorText = "MIDI file could not start playing"; + break; + default: + errorText = NULL; + break; + } + + if (errorText == NULL) return 0; + + if (NULL == lstrcpynA(text, "", length)) + { + *text = 0; + return 0; + } + + return 1; +} + diff --git a/games/Battle Isle 3/SR-BI3/SDImidi.h b/games/Battle Isle 3/SR-BI3/SDImidi.h new file mode 100644 index 0000000..d436c1d --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/SDImidi.h @@ -0,0 +1,51 @@ +/** + * + * Copyright (C) 2020-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_SDIMIDI_H_INCLUDED_) +#define _SDIMIDI_H_INCLUDED_ + +int midi_PluginStartup(void); +void midi_PluginShutdown(void); + +#ifdef __cplusplus +extern "C" { +#endif + +int midi_OpenSDIMusic(const char *filename); +unsigned int midi_GetSDIMusicID(void); +int midi_PlaySDIMusic(void); +int midi_CloseSDIMusic(void); +int midi_IsPlaying(unsigned int musicID); + +int midi_OpenTestMusic(void); +int midi_PlayTestMusic(void); +int midi_CloseTestMusic(void); + +int midi_GetErrorString(int error, char *text, unsigned int length); + +#ifdef __cplusplus +} +#endif + +#endif /* _SDIMIDI_H_INCLUDED_ */ diff --git a/games/Battle Isle 3/SR-BI3/SDIresource.c b/games/Battle Isle 3/SR-BI3/SDIresource.c new file mode 100644 index 0000000..7029e1c --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/SDIresource.c @@ -0,0 +1,1988 @@ +/* encoding = UTF-8 */ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "SDIresource.h" +#define WIN32_LEAN_AND_MEAN +#include + + +static const uint8_t bAppIconDIB[744] = { +// DIB header - BITMAPINFOHEADER + 0x28, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +// Color table - RGBA32 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, + 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0x00, + 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, + 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, +// Pixel array - ANDbits + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x88, 0x88, 0x88, 0x88, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x01, 0x11, 0x11, 0x11, 0x11, 0x10, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x08, 0x80, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x80, 0x08, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x08, 0x00, 0x00, 0x80, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x11, 0x11, 0x08, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x33, 0x33, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x01, 0x13, 0x31, 0x10, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x71, 0x00, 0x10, 0x13, 0x31, 0x01, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x30, 0x01, 0x00, 0x01, 0x10, 0x00, 0x10, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x07, 0x00, 0x10, 0x00, 0x01, 0x10, 0x00, 0x01, 0x00, 0x70, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x70, 0x01, 0x00, 0x11, 0x13, 0x31, 0x11, 0x00, 0x10, 0x07, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x30, 0x10, 0x01, 0x33, 0x13, 0x31, 0x33, 0x10, 0x01, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x08, 0x01, 0x01, 0x11, 0x81, 0x33, 0x33, 0x18, 0x11, 0x10, 0x10, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x70, 0x10, 0x33, 0x33, 0x31, 0x33, 0x33, 0x13, 0x33, 0x33, 0x01, 0x07, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x01, 0x1b, 0x33, 0x13, 0x3b, 0xb3, 0x31, 0x33, 0xb1, 0x10, 0x10, 0x00, 0x00, + 0x00, 0x00, 0x10, 0xb7, 0x33, 0x33, 0x33, 0xb3, 0x3b, 0x33, 0x33, 0x33, 0x7b, 0x01, 0x00, 0x00, + 0x00, 0x80, 0x33, 0x33, 0x33, 0xbb, 0xb3, 0x33, 0x33, 0x3b, 0xbb, 0x33, 0x33, 0x33, 0x08, 0x00, + 0x07, 0x03, 0xbb, 0xbb, 0xbb, 0x33, 0x3b, 0x33, 0x33, 0xb3, 0x33, 0xbb, 0xbb, 0xbb, 0x30, 0x70, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xbb, 0xbb, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, + 0x07, 0x88, 0x88, 0x88, 0x88, 0x87, 0x77, 0x77, 0x77, 0x77, 0x78, 0x88, 0x88, 0x88, 0x88, 0x70, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +// Pixel array - XORbits + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xe0, 0x07, 0xff, + 0xff, 0xc0, 0x03, 0xff, + 0xff, 0x80, 0x01, 0xff, + 0xff, 0xc0, 0x03, 0xff, + 0xff, 0xc0, 0x03, 0xff, + 0xff, 0xe0, 0x07, 0xff, + 0xff, 0xe0, 0x07, 0xff, + 0xff, 0xe0, 0x07, 0xff, + 0xff, 0xe0, 0x07, 0xff, + 0xff, 0xc0, 0x03, 0xff, + 0xff, 0x80, 0x01, 0xff, + 0xff, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0xff, + 0xfe, 0x00, 0x00, 0x7f, + 0xfc, 0x00, 0x00, 0x3f, + 0xfc, 0x00, 0x00, 0x3f, + 0xf8, 0x00, 0x00, 0x1f, + 0xf0, 0x00, 0x00, 0x0f, + 0xf0, 0x00, 0x00, 0x0f, + 0xe0, 0x00, 0x00, 0x07, + 0xc0, 0x00, 0x00, 0x03, + 0x80, 0x00, 0x00, 0x01, + 0x80, 0x00, 0x00, 0x01, + 0x80, 0x00, 0x00, 0x01, + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, +}; + +static HICON hAppIcon = NULL; + + +#define NUM_STRING_RESOURCES 11 + +static const WCHAR AppStringData_1[2725] = { +// 0 +// + 0x0000, +// 1 +// Dies ist das erste Mal, daß Sie Battle Isle 3 starten.\n Das Programm führt nun eine Reihe von Tests durch, um Ihren Computer zu überprüfen.\nDieser Test findet nur einmal statt.\n \nBITTE SCHALTEN SIE DAS PROGRAMM NICHT IN DEN HINTERGRUND! + 0x00ec, + 0x0044, 0x0069, 0x0065, 0x0073, 0x0020, 0x0069, 0x0073, 0x0074, 0x0020, 0x0064, 0x0061, 0x0073, 0x0020, 0x0065, 0x0072, 0x0073, + 0x0074, 0x0065, 0x0020, 0x004d, 0x0061, 0x006c, 0x002c, 0x0020, 0x0064, 0x0061, 0x00df, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, + 0x0042, 0x0061, 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x0020, 0x0033, 0x0020, 0x0073, 0x0074, + 0x0061, 0x0072, 0x0074, 0x0065, 0x006e, 0x002e, 0x000a, 0x0020, 0x0044, 0x0061, 0x0073, 0x0020, 0x0050, 0x0072, 0x006f, 0x0067, + 0x0072, 0x0061, 0x006d, 0x006d, 0x0020, 0x0066, 0x00fc, 0x0068, 0x0072, 0x0074, 0x0020, 0x006e, 0x0075, 0x006e, 0x0020, 0x0065, + 0x0069, 0x006e, 0x0065, 0x0020, 0x0052, 0x0065, 0x0069, 0x0068, 0x0065, 0x0020, 0x0076, 0x006f, 0x006e, 0x0020, 0x0054, 0x0065, + 0x0073, 0x0074, 0x0073, 0x0020, 0x0064, 0x0075, 0x0072, 0x0063, 0x0068, 0x002c, 0x0020, 0x0075, 0x006d, 0x0020, 0x0049, 0x0068, + 0x0072, 0x0065, 0x006e, 0x0020, 0x0043, 0x006f, 0x006d, 0x0070, 0x0075, 0x0074, 0x0065, 0x0072, 0x0020, 0x007a, 0x0075, 0x0020, + 0x00fc, 0x0062, 0x0065, 0x0072, 0x0070, 0x0072, 0x00fc, 0x0066, 0x0065, 0x006e, 0x002e, 0x000a, 0x0044, 0x0069, 0x0065, 0x0073, + 0x0065, 0x0072, 0x0020, 0x0054, 0x0065, 0x0073, 0x0074, 0x0020, 0x0066, 0x0069, 0x006e, 0x0064, 0x0065, 0x0074, 0x0020, 0x006e, + 0x0075, 0x0072, 0x0020, 0x0065, 0x0069, 0x006e, 0x006d, 0x0061, 0x006c, 0x0020, 0x0073, 0x0074, 0x0061, 0x0074, 0x0074, 0x002e, + 0x000a, 0x0020, 0x000a, 0x0042, 0x0049, 0x0054, 0x0054, 0x0045, 0x0020, 0x0053, 0x0043, 0x0048, 0x0041, 0x004c, 0x0054, 0x0045, + 0x004e, 0x0020, 0x0053, 0x0049, 0x0045, 0x0020, 0x0044, 0x0041, 0x0053, 0x0020, 0x0050, 0x0052, 0x004f, 0x0047, 0x0052, 0x0041, + 0x004d, 0x004d, 0x0020, 0x004e, 0x0049, 0x0043, 0x0048, 0x0054, 0x0020, 0x0049, 0x004e, 0x0020, 0x0044, 0x0045, 0x004e, 0x0020, + 0x0048, 0x0049, 0x004e, 0x0054, 0x0045, 0x0052, 0x0047, 0x0052, 0x0055, 0x004e, 0x0044, 0x0021, +// 2 +// Es wird jetzt ein AVI Video geladen.\nBei defekten Videotreibern (hauptächlich unter Windows 3.11) kann der Aufruf fehlschlagen. Sie sehen dann eine Fehlermeldung. Eventuell müssen Sie Windows neu starten, wenn Ihr Rechner nicht mehr reagiert. + 0x00f2, + 0x0045, 0x0073, 0x0020, 0x0077, 0x0069, 0x0072, 0x0064, 0x0020, 0x006a, 0x0065, 0x0074, 0x007a, 0x0074, 0x0020, 0x0065, 0x0069, + 0x006e, 0x0020, 0x0041, 0x0056, 0x0049, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0067, 0x0065, 0x006c, 0x0061, + 0x0064, 0x0065, 0x006e, 0x002e, 0x000a, 0x0042, 0x0065, 0x0069, 0x0020, 0x0064, 0x0065, 0x0066, 0x0065, 0x006b, 0x0074, 0x0065, + 0x006e, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0074, 0x0072, 0x0065, 0x0069, 0x0062, 0x0065, 0x0072, 0x006e, 0x0020, + 0x0028, 0x0068, 0x0061, 0x0075, 0x0070, 0x0074, 0x00e4, 0x0063, 0x0068, 0x006c, 0x0069, 0x0063, 0x0068, 0x0020, 0x0075, 0x006e, + 0x0074, 0x0065, 0x0072, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0033, 0x002e, 0x0031, 0x0031, + 0x0029, 0x0020, 0x006b, 0x0061, 0x006e, 0x006e, 0x0020, 0x0064, 0x0065, 0x0072, 0x0020, 0x0041, 0x0075, 0x0066, 0x0072, 0x0075, + 0x0066, 0x0020, 0x0066, 0x0065, 0x0068, 0x006c, 0x0073, 0x0063, 0x0068, 0x006c, 0x0061, 0x0067, 0x0065, 0x006e, 0x002e, 0x0020, + 0x0053, 0x0069, 0x0065, 0x0020, 0x0073, 0x0065, 0x0068, 0x0065, 0x006e, 0x0020, 0x0064, 0x0061, 0x006e, 0x006e, 0x0020, 0x0065, + 0x0069, 0x006e, 0x0065, 0x0020, 0x0046, 0x0065, 0x0068, 0x006c, 0x0065, 0x0072, 0x006d, 0x0065, 0x006c, 0x0064, 0x0075, 0x006e, + 0x0067, 0x002e, 0x0020, 0x0045, 0x0076, 0x0065, 0x006e, 0x0074, 0x0075, 0x0065, 0x006c, 0x006c, 0x0020, 0x006d, 0x00fc, 0x0073, + 0x0073, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, + 0x006e, 0x0065, 0x0075, 0x0020, 0x0073, 0x0074, 0x0061, 0x0072, 0x0074, 0x0065, 0x006e, 0x002c, 0x0020, 0x0077, 0x0065, 0x006e, + 0x006e, 0x0020, 0x0049, 0x0068, 0x0072, 0x0020, 0x0052, 0x0065, 0x0063, 0x0068, 0x006e, 0x0065, 0x0072, 0x0020, 0x006e, 0x0069, + 0x0063, 0x0068, 0x0074, 0x0020, 0x006d, 0x0065, 0x0068, 0x0072, 0x0020, 0x0072, 0x0065, 0x0061, 0x0067, 0x0069, 0x0065, 0x0072, + 0x0074, 0x002e, +// 3 +// Das File TST.AVI wurde nicht im Battle Isle 3 Directory auf Ihrer Festplatte gefunden.\nKopieren Sie das File von Ihrer CD (aus dem BIN Directory) oder installieren Sie Battle Isle 3 erneut. + 0x00bd, + 0x0044, 0x0061, 0x0073, 0x0020, 0x0046, 0x0069, 0x006c, 0x0065, 0x0020, 0x0054, 0x0053, 0x0054, 0x002e, 0x0041, 0x0056, 0x0049, + 0x0020, 0x0077, 0x0075, 0x0072, 0x0064, 0x0065, 0x0020, 0x006e, 0x0069, 0x0063, 0x0068, 0x0074, 0x0020, 0x0069, 0x006d, 0x0020, + 0x0042, 0x0061, 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x0020, 0x0033, 0x0020, 0x0044, 0x0069, + 0x0072, 0x0065, 0x0063, 0x0074, 0x006f, 0x0072, 0x0079, 0x0020, 0x0061, 0x0075, 0x0066, 0x0020, 0x0049, 0x0068, 0x0072, 0x0065, + 0x0072, 0x0020, 0x0046, 0x0065, 0x0073, 0x0074, 0x0070, 0x006c, 0x0061, 0x0074, 0x0074, 0x0065, 0x0020, 0x0067, 0x0065, 0x0066, + 0x0075, 0x006e, 0x0064, 0x0065, 0x006e, 0x002e, 0x000a, 0x004b, 0x006f, 0x0070, 0x0069, 0x0065, 0x0072, 0x0065, 0x006e, 0x0020, + 0x0053, 0x0069, 0x0065, 0x0020, 0x0064, 0x0061, 0x0073, 0x0020, 0x0046, 0x0069, 0x006c, 0x0065, 0x0020, 0x0076, 0x006f, 0x006e, + 0x0020, 0x0049, 0x0068, 0x0072, 0x0065, 0x0072, 0x0020, 0x0043, 0x0044, 0x0020, 0x0028, 0x0061, 0x0075, 0x0073, 0x0020, 0x0064, + 0x0065, 0x006d, 0x0020, 0x0042, 0x0049, 0x004e, 0x0020, 0x0044, 0x0069, 0x0072, 0x0065, 0x0063, 0x0074, 0x006f, 0x0072, 0x0079, + 0x0029, 0x0020, 0x006f, 0x0064, 0x0065, 0x0072, 0x0020, 0x0069, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, 0x006c, 0x0069, 0x0065, + 0x0072, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0042, 0x0061, 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, + 0x0073, 0x006c, 0x0065, 0x0020, 0x0033, 0x0020, 0x0065, 0x0072, 0x006e, 0x0065, 0x0075, 0x0074, 0x002e, +// 4 +// Der folgende Fehler wurde von Windows gemeldet:\n\n%s\n\nEs wird jetzt versucht, das Video noch einmal zu öffnen und dabei den Fehler zu umgehen. + 0x008d, + 0x0044, 0x0065, 0x0072, 0x0020, 0x0066, 0x006f, 0x006c, 0x0067, 0x0065, 0x006e, 0x0064, 0x0065, 0x0020, 0x0046, 0x0065, 0x0068, + 0x006c, 0x0065, 0x0072, 0x0020, 0x0077, 0x0075, 0x0072, 0x0064, 0x0065, 0x0020, 0x0076, 0x006f, 0x006e, 0x0020, 0x0057, 0x0069, + 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0067, 0x0065, 0x006d, 0x0065, 0x006c, 0x0064, 0x0065, 0x0074, 0x003a, 0x000a, + 0x000a, 0x0025, 0x0073, 0x000a, 0x000a, 0x0045, 0x0073, 0x0020, 0x0077, 0x0069, 0x0072, 0x0064, 0x0020, 0x006a, 0x0065, 0x0074, + 0x007a, 0x0074, 0x0020, 0x0076, 0x0065, 0x0072, 0x0073, 0x0075, 0x0063, 0x0068, 0x0074, 0x002c, 0x0020, 0x0064, 0x0061, 0x0073, + 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x006e, 0x006f, 0x0063, 0x0068, 0x0020, 0x0065, 0x0069, 0x006e, 0x006d, + 0x0061, 0x006c, 0x0020, 0x007a, 0x0075, 0x0020, 0x00f6, 0x0066, 0x0066, 0x006e, 0x0065, 0x006e, 0x0020, 0x0075, 0x006e, 0x0064, + 0x0020, 0x0064, 0x0061, 0x0062, 0x0065, 0x0069, 0x0020, 0x0064, 0x0065, 0x006e, 0x0020, 0x0046, 0x0065, 0x0068, 0x006c, 0x0065, + 0x0072, 0x0020, 0x007a, 0x0075, 0x0020, 0x0075, 0x006d, 0x0067, 0x0065, 0x0068, 0x0065, 0x006e, 0x002e, +// 5 +// Das System konnte ein angefordertes Fenster nicht öffnen. Das deutet entweder auf Speichermangel oder einen schweren Fehler innerhalb Windows hin. Beenden Sie eventuell andere Programme und starten Battle Isle 3 neu. + 0x00d8, + 0x0044, 0x0061, 0x0073, 0x0020, 0x0053, 0x0079, 0x0073, 0x0074, 0x0065, 0x006d, 0x0020, 0x006b, 0x006f, 0x006e, 0x006e, 0x0074, + 0x0065, 0x0020, 0x0065, 0x0069, 0x006e, 0x0020, 0x0061, 0x006e, 0x0067, 0x0065, 0x0066, 0x006f, 0x0072, 0x0064, 0x0065, 0x0072, + 0x0074, 0x0065, 0x0073, 0x0020, 0x0046, 0x0065, 0x006e, 0x0073, 0x0074, 0x0065, 0x0072, 0x0020, 0x006e, 0x0069, 0x0063, 0x0068, + 0x0074, 0x0020, 0x00f6, 0x0066, 0x0066, 0x006e, 0x0065, 0x006e, 0x002e, 0x0020, 0x0044, 0x0061, 0x0073, 0x0020, 0x0064, 0x0065, + 0x0075, 0x0074, 0x0065, 0x0074, 0x0020, 0x0065, 0x006e, 0x0074, 0x0077, 0x0065, 0x0064, 0x0065, 0x0072, 0x0020, 0x0061, 0x0075, + 0x0066, 0x0020, 0x0053, 0x0070, 0x0065, 0x0069, 0x0063, 0x0068, 0x0065, 0x0072, 0x006d, 0x0061, 0x006e, 0x0067, 0x0065, 0x006c, + 0x0020, 0x006f, 0x0064, 0x0065, 0x0072, 0x0020, 0x0065, 0x0069, 0x006e, 0x0065, 0x006e, 0x0020, 0x0073, 0x0063, 0x0068, 0x0077, + 0x0065, 0x0072, 0x0065, 0x006e, 0x0020, 0x0046, 0x0065, 0x0068, 0x006c, 0x0065, 0x0072, 0x0020, 0x0069, 0x006e, 0x006e, 0x0065, + 0x0072, 0x0068, 0x0061, 0x006c, 0x0062, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0068, 0x0069, + 0x006e, 0x002e, 0x0020, 0x0042, 0x0065, 0x0065, 0x006e, 0x0064, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0065, + 0x0076, 0x0065, 0x006e, 0x0074, 0x0075, 0x0065, 0x006c, 0x006c, 0x0020, 0x0061, 0x006e, 0x0064, 0x0065, 0x0072, 0x0065, 0x0020, + 0x0050, 0x0072, 0x006f, 0x0067, 0x0072, 0x0061, 0x006d, 0x006d, 0x0065, 0x0020, 0x0075, 0x006e, 0x0064, 0x0020, 0x0073, 0x0074, + 0x0061, 0x0072, 0x0074, 0x0065, 0x006e, 0x0020, 0x0042, 0x0061, 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, + 0x0065, 0x0020, 0x0033, 0x0020, 0x006e, 0x0065, 0x0075, 0x002e, +// 6 +// Das Öffnen des Videos schlug fehl!\nHaben Sie VIDEO FÜR WINDOWS 1.1e installiert?\nWenn nicht,holen Sie dies bitte nach und starten danach BATTLE ISLE 3 SETUP\n.Das Abspielen der Videos ist bis auf weiteres abgeschaltet. + 0x00d9, + 0x0044, 0x0061, 0x0073, 0x0020, 0x00d6, 0x0066, 0x0066, 0x006e, 0x0065, 0x006e, 0x0020, 0x0064, 0x0065, 0x0073, 0x0020, 0x0056, + 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x0020, 0x0073, 0x0063, 0x0068, 0x006c, 0x0075, 0x0067, 0x0020, 0x0066, 0x0065, 0x0068, + 0x006c, 0x0021, 0x000a, 0x0048, 0x0061, 0x0062, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0056, 0x0049, 0x0044, + 0x0045, 0x004f, 0x0020, 0x0046, 0x00dc, 0x0052, 0x0020, 0x0057, 0x0049, 0x004e, 0x0044, 0x004f, 0x0057, 0x0053, 0x0020, 0x0031, + 0x002e, 0x0031, 0x0065, 0x0020, 0x0069, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, 0x006c, 0x0069, 0x0065, 0x0072, 0x0074, 0x003f, + 0x000a, 0x0057, 0x0065, 0x006e, 0x006e, 0x0020, 0x006e, 0x0069, 0x0063, 0x0068, 0x0074, 0x002c, 0x0068, 0x006f, 0x006c, 0x0065, + 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0064, 0x0069, 0x0065, 0x0073, 0x0020, 0x0062, 0x0069, 0x0074, 0x0074, 0x0065, + 0x0020, 0x006e, 0x0061, 0x0063, 0x0068, 0x0020, 0x0075, 0x006e, 0x0064, 0x0020, 0x0073, 0x0074, 0x0061, 0x0072, 0x0074, 0x0065, + 0x006e, 0x0020, 0x0064, 0x0061, 0x006e, 0x0061, 0x0063, 0x0068, 0x0020, 0x0042, 0x0041, 0x0054, 0x0054, 0x004c, 0x0045, 0x0020, + 0x0049, 0x0053, 0x004c, 0x0045, 0x0020, 0x0033, 0x0020, 0x0053, 0x0045, 0x0054, 0x0055, 0x0050, 0x000a, 0x002e, 0x0044, 0x0061, + 0x0073, 0x0020, 0x0041, 0x0062, 0x0073, 0x0070, 0x0069, 0x0065, 0x006c, 0x0065, 0x006e, 0x0020, 0x0064, 0x0065, 0x0072, 0x0020, + 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x0020, 0x0069, 0x0073, 0x0074, 0x0020, 0x0062, 0x0069, 0x0073, 0x0020, 0x0061, + 0x0075, 0x0066, 0x0020, 0x0077, 0x0065, 0x0069, 0x0074, 0x0065, 0x0072, 0x0065, 0x0073, 0x0020, 0x0061, 0x0062, 0x0067, 0x0065, + 0x0073, 0x0063, 0x0068, 0x0061, 0x006c, 0x0074, 0x0065, 0x0074, 0x002e, +// 7 +// + 0x0000, +// 8 +// + 0x0000, +// 9 +// Diese Fehlermeldung bedeutet, daß die Treiber Ihrer Videokarte defekt sind. Bitte starten Sie Battle Isle 3 erneut. Der Test der den Fehler verursachte wird dann übersprungen.\nErkundigen Sie sich beim Hersteller Ihrer Videokarte nach neuen Treibern. + 0x00f9, + 0x0044, 0x0069, 0x0065, 0x0073, 0x0065, 0x0020, 0x0046, 0x0065, 0x0068, 0x006c, 0x0065, 0x0072, 0x006d, 0x0065, 0x006c, 0x0064, + 0x0075, 0x006e, 0x0067, 0x0020, 0x0062, 0x0065, 0x0064, 0x0065, 0x0075, 0x0074, 0x0065, 0x0074, 0x002c, 0x0020, 0x0064, 0x0061, + 0x00df, 0x0020, 0x0064, 0x0069, 0x0065, 0x0020, 0x0054, 0x0072, 0x0065, 0x0069, 0x0062, 0x0065, 0x0072, 0x0020, 0x0049, 0x0068, + 0x0072, 0x0065, 0x0072, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x006b, 0x0061, 0x0072, 0x0074, 0x0065, 0x0020, 0x0064, + 0x0065, 0x0066, 0x0065, 0x006b, 0x0074, 0x0020, 0x0073, 0x0069, 0x006e, 0x0064, 0x002e, 0x0020, 0x0042, 0x0069, 0x0074, 0x0074, + 0x0065, 0x0020, 0x0073, 0x0074, 0x0061, 0x0072, 0x0074, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0042, 0x0061, + 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x0020, 0x0033, 0x0020, 0x0065, 0x0072, 0x006e, 0x0065, + 0x0075, 0x0074, 0x002e, 0x0020, 0x0044, 0x0065, 0x0072, 0x0020, 0x0054, 0x0065, 0x0073, 0x0074, 0x0020, 0x0064, 0x0065, 0x0072, + 0x0020, 0x0064, 0x0065, 0x006e, 0x0020, 0x0046, 0x0065, 0x0068, 0x006c, 0x0065, 0x0072, 0x0020, 0x0076, 0x0065, 0x0072, 0x0075, + 0x0072, 0x0073, 0x0061, 0x0063, 0x0068, 0x0074, 0x0065, 0x0020, 0x0077, 0x0069, 0x0072, 0x0064, 0x0020, 0x0064, 0x0061, 0x006e, + 0x006e, 0x0020, 0x00fc, 0x0062, 0x0065, 0x0072, 0x0073, 0x0070, 0x0072, 0x0075, 0x006e, 0x0067, 0x0065, 0x006e, 0x002e, 0x000a, + 0x0045, 0x0072, 0x006b, 0x0075, 0x006e, 0x0064, 0x0069, 0x0067, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0073, + 0x0069, 0x0063, 0x0068, 0x0020, 0x0062, 0x0065, 0x0069, 0x006d, 0x0020, 0x0048, 0x0065, 0x0072, 0x0073, 0x0074, 0x0065, 0x006c, + 0x006c, 0x0065, 0x0072, 0x0020, 0x0049, 0x0068, 0x0072, 0x0065, 0x0072, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x006b, + 0x0061, 0x0072, 0x0074, 0x0065, 0x0020, 0x006e, 0x0061, 0x0063, 0x0068, 0x0020, 0x006e, 0x0065, 0x0075, 0x0065, 0x006e, 0x0020, + 0x0054, 0x0072, 0x0065, 0x0069, 0x0062, 0x0065, 0x0072, 0x006e, 0x002e, +// 10 +// Ihre Videotreiber sind defekt.\n Battle Isle 3 wird nicht mehr versuchen Videos abzuspielen, so daß Sie das Programm vorerst benutzen können. Setzen Sie sich mit Ihrem Videokartenhersteller in Verbindung, um neue Treiber zu erhalten. + 0x00e8, + 0x0049, 0x0068, 0x0072, 0x0065, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0074, 0x0072, 0x0065, 0x0069, 0x0062, 0x0065, + 0x0072, 0x0020, 0x0073, 0x0069, 0x006e, 0x0064, 0x0020, 0x0064, 0x0065, 0x0066, 0x0065, 0x006b, 0x0074, 0x002e, 0x000a, 0x0020, + 0x0042, 0x0061, 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x0020, 0x0033, 0x0020, 0x0077, 0x0069, + 0x0072, 0x0064, 0x0020, 0x006e, 0x0069, 0x0063, 0x0068, 0x0074, 0x0020, 0x006d, 0x0065, 0x0068, 0x0072, 0x0020, 0x0076, 0x0065, + 0x0072, 0x0073, 0x0075, 0x0063, 0x0068, 0x0065, 0x006e, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x0020, 0x0061, + 0x0062, 0x007a, 0x0075, 0x0073, 0x0070, 0x0069, 0x0065, 0x006c, 0x0065, 0x006e, 0x002c, 0x0020, 0x0073, 0x006f, 0x0020, 0x0064, + 0x0061, 0x00df, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0064, 0x0061, 0x0073, 0x0020, 0x0050, 0x0072, 0x006f, 0x0067, 0x0072, + 0x0061, 0x006d, 0x006d, 0x0020, 0x0076, 0x006f, 0x0072, 0x0065, 0x0072, 0x0073, 0x0074, 0x0020, 0x0062, 0x0065, 0x006e, 0x0075, + 0x0074, 0x007a, 0x0065, 0x006e, 0x0020, 0x006b, 0x00f6, 0x006e, 0x006e, 0x0065, 0x006e, 0x002e, 0x0020, 0x0053, 0x0065, 0x0074, + 0x007a, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0073, 0x0069, 0x0063, 0x0068, 0x0020, 0x006d, 0x0069, 0x0074, + 0x0020, 0x0049, 0x0068, 0x0072, 0x0065, 0x006d, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x006b, 0x0061, 0x0072, 0x0074, + 0x0065, 0x006e, 0x0068, 0x0065, 0x0072, 0x0073, 0x0074, 0x0065, 0x006c, 0x006c, 0x0065, 0x0072, 0x0020, 0x0069, 0x006e, 0x0020, + 0x0056, 0x0065, 0x0072, 0x0062, 0x0069, 0x006e, 0x0064, 0x0075, 0x006e, 0x0067, 0x002c, 0x0020, 0x0075, 0x006d, 0x0020, 0x006e, + 0x0065, 0x0075, 0x0065, 0x0020, 0x0054, 0x0072, 0x0065, 0x0069, 0x0062, 0x0065, 0x0072, 0x0020, 0x007a, 0x0075, 0x0020, 0x0065, + 0x0072, 0x0068, 0x0061, 0x006c, 0x0074, 0x0065, 0x006e, 0x002e, +// 11 +// Beim letzten Starten von Battle Isle 3 konnte das Testvideo nicht geladen werden. Dieser Umstand wird beim nächsten Versuch berücksichtigt. + 0x008b, + 0x0042, 0x0065, 0x0069, 0x006d, 0x0020, 0x006c, 0x0065, 0x0074, 0x007a, 0x0074, 0x0065, 0x006e, 0x0020, 0x0053, 0x0074, 0x0061, + 0x0072, 0x0074, 0x0065, 0x006e, 0x0020, 0x0076, 0x006f, 0x006e, 0x0020, 0x0042, 0x0061, 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, + 0x0049, 0x0073, 0x006c, 0x0065, 0x0020, 0x0033, 0x0020, 0x006b, 0x006f, 0x006e, 0x006e, 0x0074, 0x0065, 0x0020, 0x0064, 0x0061, + 0x0073, 0x0020, 0x0054, 0x0065, 0x0073, 0x0074, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x006e, 0x0069, 0x0063, 0x0068, + 0x0074, 0x0020, 0x0067, 0x0065, 0x006c, 0x0061, 0x0064, 0x0065, 0x006e, 0x0020, 0x0077, 0x0065, 0x0072, 0x0064, 0x0065, 0x006e, + 0x002e, 0x0020, 0x0044, 0x0069, 0x0065, 0x0073, 0x0065, 0x0072, 0x0020, 0x0055, 0x006d, 0x0073, 0x0074, 0x0061, 0x006e, 0x0064, + 0x0020, 0x0077, 0x0069, 0x0072, 0x0064, 0x0020, 0x0062, 0x0065, 0x0069, 0x006d, 0x0020, 0x006e, 0x00e4, 0x0063, 0x0068, 0x0073, + 0x0074, 0x0065, 0x006e, 0x0020, 0x0056, 0x0065, 0x0072, 0x0073, 0x0075, 0x0063, 0x0068, 0x0020, 0x0062, 0x0065, 0x0072, 0x00fc, + 0x0063, 0x006b, 0x0073, 0x0069, 0x0063, 0x0068, 0x0074, 0x0069, 0x0067, 0x0074, 0x002e, +// 12 +// Der folgende Fehler wurde von Windows gemeldet:\n\n%s\n\nHaben Sie VIDEO FÜR WINDOWS 1.1e installiert?\nWenn nicht,holen Sie dies bitte nach und starten danach BATTLE ISLE 3 SETUP.\nDas Abspielen der Videos ist bis auf weiteres abgeschaltet. + 0x00eb, + 0x0044, 0x0065, 0x0072, 0x0020, 0x0066, 0x006f, 0x006c, 0x0067, 0x0065, 0x006e, 0x0064, 0x0065, 0x0020, 0x0046, 0x0065, 0x0068, + 0x006c, 0x0065, 0x0072, 0x0020, 0x0077, 0x0075, 0x0072, 0x0064, 0x0065, 0x0020, 0x0076, 0x006f, 0x006e, 0x0020, 0x0057, 0x0069, + 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0067, 0x0065, 0x006d, 0x0065, 0x006c, 0x0064, 0x0065, 0x0074, 0x003a, 0x000a, + 0x000a, 0x0025, 0x0073, 0x000a, 0x000a, 0x0048, 0x0061, 0x0062, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0056, + 0x0049, 0x0044, 0x0045, 0x004f, 0x0020, 0x0046, 0x00dc, 0x0052, 0x0020, 0x0057, 0x0049, 0x004e, 0x0044, 0x004f, 0x0057, 0x0053, + 0x0020, 0x0031, 0x002e, 0x0031, 0x0065, 0x0020, 0x0069, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, 0x006c, 0x0069, 0x0065, 0x0072, + 0x0074, 0x003f, 0x000a, 0x0057, 0x0065, 0x006e, 0x006e, 0x0020, 0x006e, 0x0069, 0x0063, 0x0068, 0x0074, 0x002c, 0x0068, 0x006f, + 0x006c, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0064, 0x0069, 0x0065, 0x0073, 0x0020, 0x0062, 0x0069, 0x0074, + 0x0074, 0x0065, 0x0020, 0x006e, 0x0061, 0x0063, 0x0068, 0x0020, 0x0075, 0x006e, 0x0064, 0x0020, 0x0073, 0x0074, 0x0061, 0x0072, + 0x0074, 0x0065, 0x006e, 0x0020, 0x0064, 0x0061, 0x006e, 0x0061, 0x0063, 0x0068, 0x0020, 0x0042, 0x0041, 0x0054, 0x0054, 0x004c, + 0x0045, 0x0020, 0x0049, 0x0053, 0x004c, 0x0045, 0x0020, 0x0033, 0x0020, 0x0053, 0x0045, 0x0054, 0x0055, 0x0050, 0x002e, 0x000a, + 0x0044, 0x0061, 0x0073, 0x0020, 0x0041, 0x0062, 0x0073, 0x0070, 0x0069, 0x0065, 0x006c, 0x0065, 0x006e, 0x0020, 0x0064, 0x0065, + 0x0072, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x0020, 0x0069, 0x0073, 0x0074, 0x0020, 0x0062, 0x0069, 0x0073, + 0x0020, 0x0061, 0x0075, 0x0066, 0x0020, 0x0077, 0x0065, 0x0069, 0x0074, 0x0065, 0x0072, 0x0065, 0x0073, 0x0020, 0x0061, 0x0062, + 0x0067, 0x0065, 0x0073, 0x0063, 0x0068, 0x0061, 0x006c, 0x0074, 0x0065, 0x0074, 0x002e, +// 13 +// Der folgende Fehler wurde von Windows gemeldet:\n\n%s\n\nBitte starten Sie Battle Isle 3 erneut. Das Programm wird dann den Aufruf, der den Fehler verursachte umgehen. + 0x00a3, + 0x0044, 0x0065, 0x0072, 0x0020, 0x0066, 0x006f, 0x006c, 0x0067, 0x0065, 0x006e, 0x0064, 0x0065, 0x0020, 0x0046, 0x0065, 0x0068, + 0x006c, 0x0065, 0x0072, 0x0020, 0x0077, 0x0075, 0x0072, 0x0064, 0x0065, 0x0020, 0x0076, 0x006f, 0x006e, 0x0020, 0x0057, 0x0069, + 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0067, 0x0065, 0x006d, 0x0065, 0x006c, 0x0064, 0x0065, 0x0074, 0x003a, 0x000a, + 0x000a, 0x0025, 0x0073, 0x000a, 0x000a, 0x0042, 0x0069, 0x0074, 0x0074, 0x0065, 0x0020, 0x0073, 0x0074, 0x0061, 0x0072, 0x0074, + 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0042, 0x0061, 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, + 0x006c, 0x0065, 0x0020, 0x0033, 0x0020, 0x0065, 0x0072, 0x006e, 0x0065, 0x0075, 0x0074, 0x002e, 0x0020, 0x0044, 0x0061, 0x0073, + 0x0020, 0x0050, 0x0072, 0x006f, 0x0067, 0x0072, 0x0061, 0x006d, 0x006d, 0x0020, 0x0077, 0x0069, 0x0072, 0x0064, 0x0020, 0x0064, + 0x0061, 0x006e, 0x006e, 0x0020, 0x0064, 0x0065, 0x006e, 0x0020, 0x0041, 0x0075, 0x0066, 0x0072, 0x0075, 0x0066, 0x002c, 0x0020, + 0x0064, 0x0065, 0x0072, 0x0020, 0x0064, 0x0065, 0x006e, 0x0020, 0x0046, 0x0065, 0x0068, 0x006c, 0x0065, 0x0072, 0x0020, 0x0076, + 0x0065, 0x0072, 0x0075, 0x0072, 0x0073, 0x0061, 0x0063, 0x0068, 0x0074, 0x0065, 0x0020, 0x0075, 0x006d, 0x0067, 0x0065, 0x0068, + 0x0065, 0x006e, 0x002e, +// 14 +// Es wird jetzt ein AVI Video in verschiedenen Größe gespielt..\nBei defekten Videokartentreibern sehen Sie Fehlermeldungen oder der Rechner reagiert nicht mehr. Starten Sie den Computer dann neu und rufen BATTLE ISLE 3 noch einmal auf. + 0x00e9, + 0x0045, 0x0073, 0x0020, 0x0077, 0x0069, 0x0072, 0x0064, 0x0020, 0x006a, 0x0065, 0x0074, 0x007a, 0x0074, 0x0020, 0x0065, 0x0069, + 0x006e, 0x0020, 0x0041, 0x0056, 0x0049, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0069, 0x006e, 0x0020, 0x0076, + 0x0065, 0x0072, 0x0073, 0x0063, 0x0068, 0x0069, 0x0065, 0x0064, 0x0065, 0x006e, 0x0065, 0x006e, 0x0020, 0x0047, 0x0072, 0x00f6, + 0x00df, 0x0065, 0x0020, 0x0067, 0x0065, 0x0073, 0x0070, 0x0069, 0x0065, 0x006c, 0x0074, 0x002e, 0x002e, 0x000a, 0x0042, 0x0065, + 0x0069, 0x0020, 0x0064, 0x0065, 0x0066, 0x0065, 0x006b, 0x0074, 0x0065, 0x006e, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, + 0x006b, 0x0061, 0x0072, 0x0074, 0x0065, 0x006e, 0x0074, 0x0072, 0x0065, 0x0069, 0x0062, 0x0065, 0x0072, 0x006e, 0x0020, 0x0073, + 0x0065, 0x0068, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0046, 0x0065, 0x0068, 0x006c, 0x0065, 0x0072, 0x006d, + 0x0065, 0x006c, 0x0064, 0x0075, 0x006e, 0x0067, 0x0065, 0x006e, 0x0020, 0x006f, 0x0064, 0x0065, 0x0072, 0x0020, 0x0064, 0x0065, + 0x0072, 0x0020, 0x0052, 0x0065, 0x0063, 0x0068, 0x006e, 0x0065, 0x0072, 0x0020, 0x0072, 0x0065, 0x0061, 0x0067, 0x0069, 0x0065, + 0x0072, 0x0074, 0x0020, 0x006e, 0x0069, 0x0063, 0x0068, 0x0074, 0x0020, 0x006d, 0x0065, 0x0068, 0x0072, 0x002e, 0x0020, 0x0053, + 0x0074, 0x0061, 0x0072, 0x0074, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0064, 0x0065, 0x006e, 0x0020, 0x0043, + 0x006f, 0x006d, 0x0070, 0x0075, 0x0074, 0x0065, 0x0072, 0x0020, 0x0064, 0x0061, 0x006e, 0x006e, 0x0020, 0x006e, 0x0065, 0x0075, + 0x0020, 0x0075, 0x006e, 0x0064, 0x0020, 0x0072, 0x0075, 0x0066, 0x0065, 0x006e, 0x0020, 0x0042, 0x0041, 0x0054, 0x0054, 0x004c, + 0x0045, 0x0020, 0x0049, 0x0053, 0x004c, 0x0045, 0x0020, 0x0033, 0x0020, 0x006e, 0x006f, 0x0063, 0x0068, 0x0020, 0x0065, 0x0069, + 0x006e, 0x006d, 0x0061, 0x006c, 0x0020, 0x0061, 0x0075, 0x0066, 0x002e, +// 15 +// Sie starten Battle Isle 3 erneut nach einem Absturz oder nachdem das Programm terminierte. Der Aufruf, der den Fehler verursachte wird nun umgangen. Bitte lesen im technischen Begleitheft hierzu weitere Informationen. + 0x00d9, + 0x0053, 0x0069, 0x0065, 0x0020, 0x0073, 0x0074, 0x0061, 0x0072, 0x0074, 0x0065, 0x006e, 0x0020, 0x0042, 0x0061, 0x0074, 0x0074, + 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x0020, 0x0033, 0x0020, 0x0065, 0x0072, 0x006e, 0x0065, 0x0075, 0x0074, + 0x0020, 0x006e, 0x0061, 0x0063, 0x0068, 0x0020, 0x0065, 0x0069, 0x006e, 0x0065, 0x006d, 0x0020, 0x0041, 0x0062, 0x0073, 0x0074, + 0x0075, 0x0072, 0x007a, 0x0020, 0x006f, 0x0064, 0x0065, 0x0072, 0x0020, 0x006e, 0x0061, 0x0063, 0x0068, 0x0064, 0x0065, 0x006d, + 0x0020, 0x0064, 0x0061, 0x0073, 0x0020, 0x0050, 0x0072, 0x006f, 0x0067, 0x0072, 0x0061, 0x006d, 0x006d, 0x0020, 0x0074, 0x0065, + 0x0072, 0x006d, 0x0069, 0x006e, 0x0069, 0x0065, 0x0072, 0x0074, 0x0065, 0x002e, 0x0020, 0x0044, 0x0065, 0x0072, 0x0020, 0x0041, + 0x0075, 0x0066, 0x0072, 0x0075, 0x0066, 0x002c, 0x0020, 0x0064, 0x0065, 0x0072, 0x0020, 0x0064, 0x0065, 0x006e, 0x0020, 0x0046, + 0x0065, 0x0068, 0x006c, 0x0065, 0x0072, 0x0020, 0x0076, 0x0065, 0x0072, 0x0075, 0x0072, 0x0073, 0x0061, 0x0063, 0x0068, 0x0074, + 0x0065, 0x0020, 0x0077, 0x0069, 0x0072, 0x0064, 0x0020, 0x006e, 0x0075, 0x006e, 0x0020, 0x0075, 0x006d, 0x0067, 0x0061, 0x006e, + 0x0067, 0x0065, 0x006e, 0x002e, 0x0020, 0x0042, 0x0069, 0x0074, 0x0074, 0x0065, 0x0020, 0x006c, 0x0065, 0x0073, 0x0065, 0x006e, + 0x0020, 0x0069, 0x006d, 0x0020, 0x0074, 0x0065, 0x0063, 0x0068, 0x006e, 0x0069, 0x0073, 0x0063, 0x0068, 0x0065, 0x006e, 0x0020, + 0x0042, 0x0065, 0x0067, 0x006c, 0x0065, 0x0069, 0x0074, 0x0068, 0x0065, 0x0066, 0x0074, 0x0020, 0x0068, 0x0069, 0x0065, 0x0072, + 0x007a, 0x0075, 0x0020, 0x0077, 0x0065, 0x0069, 0x0074, 0x0065, 0x0072, 0x0065, 0x0020, 0x0049, 0x006e, 0x0066, 0x006f, 0x0072, + 0x006d, 0x0061, 0x0074, 0x0069, 0x006f, 0x006e, 0x0065, 0x006e, 0x002e, +}; + +static const WCHAR AppStringData_2[1967] = { +// 16 +// + 0x0000, +// 17 +// Dieses Problem wird erfahrungsgemäß nicht mehr auftreten, wenn Sie Ihr System auf Windows 95 updaten, da der Fehler in den Videotreibern Ihrer Karte für Windows 3.11 liegt. Sie werden dann auch in der Lage sein, Videos zu sehen. + 0x00e4, + 0x0044, 0x0069, 0x0065, 0x0073, 0x0065, 0x0073, 0x0020, 0x0050, 0x0072, 0x006f, 0x0062, 0x006c, 0x0065, 0x006d, 0x0020, 0x0077, + 0x0069, 0x0072, 0x0064, 0x0020, 0x0065, 0x0072, 0x0066, 0x0061, 0x0068, 0x0072, 0x0075, 0x006e, 0x0067, 0x0073, 0x0067, 0x0065, + 0x006d, 0x00e4, 0x00df, 0x0020, 0x006e, 0x0069, 0x0063, 0x0068, 0x0074, 0x0020, 0x006d, 0x0065, 0x0068, 0x0072, 0x0020, 0x0061, + 0x0075, 0x0066, 0x0074, 0x0072, 0x0065, 0x0074, 0x0065, 0x006e, 0x002c, 0x0020, 0x0077, 0x0065, 0x006e, 0x006e, 0x0020, 0x0053, + 0x0069, 0x0065, 0x0020, 0x0049, 0x0068, 0x0072, 0x0020, 0x0053, 0x0079, 0x0073, 0x0074, 0x0065, 0x006d, 0x0020, 0x0061, 0x0075, + 0x0066, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0039, 0x0035, 0x0020, 0x0075, 0x0070, 0x0064, + 0x0061, 0x0074, 0x0065, 0x006e, 0x002c, 0x0020, 0x0064, 0x0061, 0x0020, 0x0064, 0x0065, 0x0072, 0x0020, 0x0046, 0x0065, 0x0068, + 0x006c, 0x0065, 0x0072, 0x0020, 0x0069, 0x006e, 0x0020, 0x0064, 0x0065, 0x006e, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, + 0x0074, 0x0072, 0x0065, 0x0069, 0x0062, 0x0065, 0x0072, 0x006e, 0x0020, 0x0049, 0x0068, 0x0072, 0x0065, 0x0072, 0x0020, 0x004b, + 0x0061, 0x0072, 0x0074, 0x0065, 0x0020, 0x0066, 0x00fc, 0x0072, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, + 0x0020, 0x0033, 0x002e, 0x0031, 0x0031, 0x0020, 0x006c, 0x0069, 0x0065, 0x0067, 0x0074, 0x002e, 0x0020, 0x0053, 0x0069, 0x0065, + 0x0020, 0x0077, 0x0065, 0x0072, 0x0064, 0x0065, 0x006e, 0x0020, 0x0064, 0x0061, 0x006e, 0x006e, 0x0020, 0x0061, 0x0075, 0x0063, + 0x0068, 0x0020, 0x0069, 0x006e, 0x0020, 0x0064, 0x0065, 0x0072, 0x0020, 0x004c, 0x0061, 0x0067, 0x0065, 0x0020, 0x0073, 0x0065, + 0x0069, 0x006e, 0x002c, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x0020, 0x007a, 0x0075, 0x0020, 0x0073, 0x0065, + 0x0068, 0x0065, 0x006e, 0x002e, +// 18 +// + 0x0000, +// 19 +// Der folgende Fehler wurde von Windows gemeldet:\n\n%s\n\nDas Abspielen gezoomter Videos ist bis auf weiteres abgeschaltet, bitte lesen Sie im technischen Begleitheft nach. + 0x00a8, + 0x0044, 0x0065, 0x0072, 0x0020, 0x0066, 0x006f, 0x006c, 0x0067, 0x0065, 0x006e, 0x0064, 0x0065, 0x0020, 0x0046, 0x0065, 0x0068, + 0x006c, 0x0065, 0x0072, 0x0020, 0x0077, 0x0075, 0x0072, 0x0064, 0x0065, 0x0020, 0x0076, 0x006f, 0x006e, 0x0020, 0x0057, 0x0069, + 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0067, 0x0065, 0x006d, 0x0065, 0x006c, 0x0064, 0x0065, 0x0074, 0x003a, 0x000a, + 0x000a, 0x0025, 0x0073, 0x000a, 0x000a, 0x0044, 0x0061, 0x0073, 0x0020, 0x0041, 0x0062, 0x0073, 0x0070, 0x0069, 0x0065, 0x006c, + 0x0065, 0x006e, 0x0020, 0x0067, 0x0065, 0x007a, 0x006f, 0x006f, 0x006d, 0x0074, 0x0065, 0x0072, 0x0020, 0x0056, 0x0069, 0x0064, + 0x0065, 0x006f, 0x0073, 0x0020, 0x0020, 0x0069, 0x0073, 0x0074, 0x0020, 0x0062, 0x0069, 0x0073, 0x0020, 0x0061, 0x0075, 0x0066, + 0x0020, 0x0077, 0x0065, 0x0069, 0x0074, 0x0065, 0x0072, 0x0065, 0x0073, 0x0020, 0x0061, 0x0062, 0x0067, 0x0065, 0x0073, 0x0063, + 0x0068, 0x0061, 0x006c, 0x0074, 0x0065, 0x0074, 0x002c, 0x0020, 0x0062, 0x0069, 0x0074, 0x0074, 0x0065, 0x0020, 0x006c, 0x0065, + 0x0073, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0069, 0x006d, 0x0020, 0x0074, 0x0065, 0x0063, 0x0068, 0x006e, + 0x0069, 0x0073, 0x0063, 0x0068, 0x0065, 0x006e, 0x0020, 0x0042, 0x0065, 0x0067, 0x006c, 0x0065, 0x0069, 0x0074, 0x0068, 0x0065, + 0x0066, 0x0074, 0x0020, 0x006e, 0x0061, 0x0063, 0x0068, 0x002e, +// 20 +// Ihre Windowsinstallation ist in der Lageauf Vollbild gezoomte Videos abzuspielen. + 0x0051, + 0x0049, 0x0068, 0x0072, 0x0065, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0069, 0x006e, 0x0073, 0x0074, + 0x0061, 0x006c, 0x006c, 0x0061, 0x0074, 0x0069, 0x006f, 0x006e, 0x0020, 0x0069, 0x0073, 0x0074, 0x0020, 0x0069, 0x006e, 0x0020, + 0x0064, 0x0065, 0x0072, 0x0020, 0x004c, 0x0061, 0x0067, 0x0065, 0x0061, 0x0075, 0x0066, 0x0020, 0x0056, 0x006f, 0x006c, 0x006c, + 0x0062, 0x0069, 0x006c, 0x0064, 0x0020, 0x0067, 0x0065, 0x007a, 0x006f, 0x006f, 0x006d, 0x0074, 0x0065, 0x0020, 0x0056, 0x0069, + 0x0064, 0x0065, 0x006f, 0x0073, 0x0020, 0x0061, 0x0062, 0x007a, 0x0075, 0x0073, 0x0070, 0x0069, 0x0065, 0x006c, 0x0065, 0x006e, + 0x002e, +// 21 +// + 0x0000, +// 22 +// + 0x0000, +// 23 +// Das Video wird jetzt geschlossen. Auch hier kann es passieren, daß Ihr Rechner nicht mehr reagiert. Starten Sie dann Battle Isle 3 erneut. + 0x008a, + 0x0044, 0x0061, 0x0073, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0077, 0x0069, 0x0072, 0x0064, 0x0020, 0x006a, + 0x0065, 0x0074, 0x007a, 0x0074, 0x0020, 0x0067, 0x0065, 0x0073, 0x0063, 0x0068, 0x006c, 0x006f, 0x0073, 0x0073, 0x0065, 0x006e, + 0x002e, 0x0020, 0x0041, 0x0075, 0x0063, 0x0068, 0x0020, 0x0068, 0x0069, 0x0065, 0x0072, 0x0020, 0x006b, 0x0061, 0x006e, 0x006e, + 0x0020, 0x0065, 0x0073, 0x0020, 0x0070, 0x0061, 0x0073, 0x0073, 0x0069, 0x0065, 0x0072, 0x0065, 0x006e, 0x002c, 0x0020, 0x0064, + 0x0061, 0x00df, 0x0020, 0x0049, 0x0068, 0x0072, 0x0020, 0x0052, 0x0065, 0x0063, 0x0068, 0x006e, 0x0065, 0x0072, 0x0020, 0x006e, + 0x0069, 0x0063, 0x0068, 0x0074, 0x0020, 0x006d, 0x0065, 0x0068, 0x0072, 0x0020, 0x0072, 0x0065, 0x0061, 0x0067, 0x0069, 0x0065, + 0x0072, 0x0074, 0x002e, 0x0020, 0x0053, 0x0074, 0x0061, 0x0072, 0x0074, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, + 0x0064, 0x0061, 0x006e, 0x006e, 0x0020, 0x0042, 0x0061, 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, + 0x0020, 0x0033, 0x0020, 0x0065, 0x0072, 0x006e, 0x0065, 0x0075, 0x0074, 0x002e, +// 24 +// Es wird jetzt ein AVI Video von 640 * 480 Punkten geladen.\nAuch hier besteht wieder die Möglichkeit, daß Windows abstürzt. Starten Sie Battle Isle 3 dann neu. + 0x009e, + 0x0045, 0x0073, 0x0020, 0x0077, 0x0069, 0x0072, 0x0064, 0x0020, 0x006a, 0x0065, 0x0074, 0x007a, 0x0074, 0x0020, 0x0065, 0x0069, + 0x006e, 0x0020, 0x0041, 0x0056, 0x0049, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0076, 0x006f, 0x006e, 0x0020, + 0x0036, 0x0034, 0x0030, 0x0020, 0x002a, 0x0020, 0x0034, 0x0038, 0x0030, 0x0020, 0x0050, 0x0075, 0x006e, 0x006b, 0x0074, 0x0065, + 0x006e, 0x0020, 0x0067, 0x0065, 0x006c, 0x0061, 0x0064, 0x0065, 0x006e, 0x002e, 0x000a, 0x0041, 0x0075, 0x0063, 0x0068, 0x0020, + 0x0068, 0x0069, 0x0065, 0x0072, 0x0020, 0x0062, 0x0065, 0x0073, 0x0074, 0x0065, 0x0068, 0x0074, 0x0020, 0x0077, 0x0069, 0x0065, + 0x0064, 0x0065, 0x0072, 0x0020, 0x0064, 0x0069, 0x0065, 0x0020, 0x004d, 0x00f6, 0x0067, 0x006c, 0x0069, 0x0063, 0x0068, 0x006b, + 0x0065, 0x0069, 0x0074, 0x002c, 0x0020, 0x0064, 0x0061, 0x00df, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, + 0x0020, 0x0061, 0x0062, 0x0073, 0x0074, 0x00fc, 0x0072, 0x007a, 0x0074, 0x002e, 0x0020, 0x0053, 0x0074, 0x0061, 0x0072, 0x0074, + 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0042, 0x0061, 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, + 0x006c, 0x0065, 0x0020, 0x0033, 0x0020, 0x0064, 0x0061, 0x006e, 0x006e, 0x0020, 0x006e, 0x0065, 0x0075, 0x002e, +// 25 +// Das 640*480 Video läßt sich nicht öffnen. Battle Isle 3 wird nicht mehr versuchen, solche Videos zu spielen. Wenden Sie sich wegen eines neuen Treibers an den Hersteller Ihrer Graphikkarte. + 0x00bd, + 0x0044, 0x0061, 0x0073, 0x0020, 0x0036, 0x0034, 0x0030, 0x002a, 0x0034, 0x0038, 0x0030, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, + 0x006f, 0x0020, 0x006c, 0x00e4, 0x00df, 0x0074, 0x0020, 0x0073, 0x0069, 0x0063, 0x0068, 0x0020, 0x006e, 0x0069, 0x0063, 0x0068, + 0x0074, 0x0020, 0x00f6, 0x0066, 0x0066, 0x006e, 0x0065, 0x006e, 0x002e, 0x0020, 0x0042, 0x0061, 0x0074, 0x0074, 0x006c, 0x0065, + 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x0020, 0x0033, 0x0020, 0x0077, 0x0069, 0x0072, 0x0064, 0x0020, 0x006e, 0x0069, 0x0063, + 0x0068, 0x0074, 0x0020, 0x006d, 0x0065, 0x0068, 0x0072, 0x0020, 0x0076, 0x0065, 0x0072, 0x0073, 0x0075, 0x0063, 0x0068, 0x0065, + 0x006e, 0x002c, 0x0020, 0x0073, 0x006f, 0x006c, 0x0063, 0x0068, 0x0065, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, + 0x0020, 0x007a, 0x0075, 0x0020, 0x0073, 0x0070, 0x0069, 0x0065, 0x006c, 0x0065, 0x006e, 0x002e, 0x0020, 0x0057, 0x0065, 0x006e, + 0x0064, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0073, 0x0069, 0x0063, 0x0068, 0x0020, 0x0077, 0x0065, 0x0067, + 0x0065, 0x006e, 0x0020, 0x0065, 0x0069, 0x006e, 0x0065, 0x0073, 0x0020, 0x006e, 0x0065, 0x0075, 0x0065, 0x006e, 0x0020, 0x0054, + 0x0072, 0x0065, 0x0069, 0x0062, 0x0065, 0x0072, 0x0073, 0x0020, 0x0061, 0x006e, 0x0020, 0x0064, 0x0065, 0x006e, 0x0020, 0x0048, + 0x0065, 0x0072, 0x0073, 0x0074, 0x0065, 0x006c, 0x006c, 0x0065, 0x0072, 0x0020, 0x0049, 0x0068, 0x0072, 0x0065, 0x0072, 0x0020, + 0x0047, 0x0072, 0x0061, 0x0070, 0x0068, 0x0069, 0x006b, 0x006b, 0x0061, 0x0072, 0x0074, 0x0065, 0x002e, +// 26 +// Das File BIG.AVI wurde nicht im Battle Isle 3 Directory auf Ihrer Festplatte gefunden.\nKopieren Sie das File von Ihrer CD (aus dem BIN Directory) oder installieren Sie Battle Isle 3 erneut. + 0x00bd, + 0x0044, 0x0061, 0x0073, 0x0020, 0x0046, 0x0069, 0x006c, 0x0065, 0x0020, 0x0042, 0x0049, 0x0047, 0x002e, 0x0041, 0x0056, 0x0049, + 0x0020, 0x0077, 0x0075, 0x0072, 0x0064, 0x0065, 0x0020, 0x006e, 0x0069, 0x0063, 0x0068, 0x0074, 0x0020, 0x0069, 0x006d, 0x0020, + 0x0042, 0x0061, 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x0020, 0x0033, 0x0020, 0x0044, 0x0069, + 0x0072, 0x0065, 0x0063, 0x0074, 0x006f, 0x0072, 0x0079, 0x0020, 0x0061, 0x0075, 0x0066, 0x0020, 0x0049, 0x0068, 0x0072, 0x0065, + 0x0072, 0x0020, 0x0046, 0x0065, 0x0073, 0x0074, 0x0070, 0x006c, 0x0061, 0x0074, 0x0074, 0x0065, 0x0020, 0x0067, 0x0065, 0x0066, + 0x0075, 0x006e, 0x0064, 0x0065, 0x006e, 0x002e, 0x000a, 0x004b, 0x006f, 0x0070, 0x0069, 0x0065, 0x0072, 0x0065, 0x006e, 0x0020, + 0x0053, 0x0069, 0x0065, 0x0020, 0x0064, 0x0061, 0x0073, 0x0020, 0x0046, 0x0069, 0x006c, 0x0065, 0x0020, 0x0076, 0x006f, 0x006e, + 0x0020, 0x0049, 0x0068, 0x0072, 0x0065, 0x0072, 0x0020, 0x0043, 0x0044, 0x0020, 0x0028, 0x0061, 0x0075, 0x0073, 0x0020, 0x0064, + 0x0065, 0x006d, 0x0020, 0x0042, 0x0049, 0x004e, 0x0020, 0x0044, 0x0069, 0x0072, 0x0065, 0x0063, 0x0074, 0x006f, 0x0072, 0x0079, + 0x0029, 0x0020, 0x006f, 0x0064, 0x0065, 0x0072, 0x0020, 0x0069, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, 0x006c, 0x0069, 0x0065, + 0x0072, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0042, 0x0061, 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, + 0x0073, 0x006c, 0x0065, 0x0020, 0x0033, 0x0020, 0x0065, 0x0072, 0x006e, 0x0065, 0x0075, 0x0074, 0x002e, +// 27 +// Ihre Videotreiber sind defekt. Battle Isle 3 wird nicht mehr versuchen 640*480 Videos abzuspielen, so daß Sie das Programm vorerst benutzen können. Setzen Sie sich mit Ihrem Videokartenhersteller in Verbindung, um neue Treiber zu erhalten. + 0x00ef, + 0x0049, 0x0068, 0x0072, 0x0065, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0074, 0x0072, 0x0065, 0x0069, 0x0062, 0x0065, + 0x0072, 0x0020, 0x0073, 0x0069, 0x006e, 0x0064, 0x0020, 0x0064, 0x0065, 0x0066, 0x0065, 0x006b, 0x0074, 0x002e, 0x0020, 0x0042, + 0x0061, 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x0020, 0x0033, 0x0020, 0x0077, 0x0069, 0x0072, + 0x0064, 0x0020, 0x006e, 0x0069, 0x0063, 0x0068, 0x0074, 0x0020, 0x006d, 0x0065, 0x0068, 0x0072, 0x0020, 0x0076, 0x0065, 0x0072, + 0x0073, 0x0075, 0x0063, 0x0068, 0x0065, 0x006e, 0x0020, 0x0036, 0x0034, 0x0030, 0x002a, 0x0034, 0x0038, 0x0030, 0x0020, 0x0056, + 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x0020, 0x0061, 0x0062, 0x007a, 0x0075, 0x0073, 0x0070, 0x0069, 0x0065, 0x006c, 0x0065, + 0x006e, 0x002c, 0x0020, 0x0073, 0x006f, 0x0020, 0x0064, 0x0061, 0x00df, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0064, 0x0061, + 0x0073, 0x0020, 0x0050, 0x0072, 0x006f, 0x0067, 0x0072, 0x0061, 0x006d, 0x006d, 0x0020, 0x0076, 0x006f, 0x0072, 0x0065, 0x0072, + 0x0073, 0x0074, 0x0020, 0x0062, 0x0065, 0x006e, 0x0075, 0x0074, 0x007a, 0x0065, 0x006e, 0x0020, 0x006b, 0x00f6, 0x006e, 0x006e, + 0x0065, 0x006e, 0x002e, 0x0020, 0x0053, 0x0065, 0x0074, 0x007a, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0073, + 0x0069, 0x0063, 0x0068, 0x0020, 0x006d, 0x0069, 0x0074, 0x0020, 0x0049, 0x0068, 0x0072, 0x0065, 0x006d, 0x0020, 0x0056, 0x0069, + 0x0064, 0x0065, 0x006f, 0x006b, 0x0061, 0x0072, 0x0074, 0x0065, 0x006e, 0x0068, 0x0065, 0x0072, 0x0073, 0x0074, 0x0065, 0x006c, + 0x006c, 0x0065, 0x0072, 0x0020, 0x0069, 0x006e, 0x0020, 0x0056, 0x0065, 0x0072, 0x0062, 0x0069, 0x006e, 0x0064, 0x0075, 0x006e, + 0x0067, 0x002c, 0x0020, 0x0075, 0x006d, 0x0020, 0x006e, 0x0065, 0x0075, 0x0065, 0x0020, 0x0054, 0x0072, 0x0065, 0x0069, 0x0062, + 0x0065, 0x0072, 0x0020, 0x007a, 0x0075, 0x0020, 0x0065, 0x0072, 0x0068, 0x0061, 0x006c, 0x0074, 0x0065, 0x006e, 0x002e, +// 28 +// Der folgende Fehler wurde von Windows gemeldet:\n\n%s\n\n.Das Abspielen von 640*480 Videos ist bis auf weiteres abgeschaltet, bitte lesen Sie im technischen Begleitheft nach. + 0x00aa, + 0x0044, 0x0065, 0x0072, 0x0020, 0x0066, 0x006f, 0x006c, 0x0067, 0x0065, 0x006e, 0x0064, 0x0065, 0x0020, 0x0046, 0x0065, 0x0068, + 0x006c, 0x0065, 0x0072, 0x0020, 0x0077, 0x0075, 0x0072, 0x0064, 0x0065, 0x0020, 0x0076, 0x006f, 0x006e, 0x0020, 0x0057, 0x0069, + 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0067, 0x0065, 0x006d, 0x0065, 0x006c, 0x0064, 0x0065, 0x0074, 0x003a, 0x000a, + 0x000a, 0x0025, 0x0073, 0x000a, 0x000a, 0x002e, 0x0044, 0x0061, 0x0073, 0x0020, 0x0041, 0x0062, 0x0073, 0x0070, 0x0069, 0x0065, + 0x006c, 0x0065, 0x006e, 0x0020, 0x0076, 0x006f, 0x006e, 0x0020, 0x0036, 0x0034, 0x0030, 0x002a, 0x0034, 0x0038, 0x0030, 0x0020, + 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x0020, 0x0069, 0x0073, 0x0074, 0x0020, 0x0062, 0x0069, 0x0073, 0x0020, 0x0061, + 0x0075, 0x0066, 0x0020, 0x0077, 0x0065, 0x0069, 0x0074, 0x0065, 0x0072, 0x0065, 0x0073, 0x0020, 0x0061, 0x0062, 0x0067, 0x0065, + 0x0073, 0x0063, 0x0068, 0x0061, 0x006c, 0x0074, 0x0065, 0x0074, 0x002c, 0x0020, 0x0062, 0x0069, 0x0074, 0x0074, 0x0065, 0x0020, + 0x006c, 0x0065, 0x0073, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0069, 0x006d, 0x0020, 0x0074, 0x0065, 0x0063, + 0x0068, 0x006e, 0x0069, 0x0073, 0x0063, 0x0068, 0x0065, 0x006e, 0x0020, 0x0042, 0x0065, 0x0067, 0x006c, 0x0065, 0x0069, 0x0074, + 0x0068, 0x0065, 0x0066, 0x0074, 0x0020, 0x006e, 0x0061, 0x0063, 0x0068, 0x002e, +// 29 +// Es wird jetzt ein AVI Video in 640*480 gespielt..\nBei defekten Videotreibern kann der Aufruf fehlschlagen. Sie sehen dann eine Fehlermeldung. Eventuell müssen Sie Windows neu starten, wenn Ihr Rechner nicht mehr reagiert. + 0x00dd, + 0x0045, 0x0073, 0x0020, 0x0077, 0x0069, 0x0072, 0x0064, 0x0020, 0x006a, 0x0065, 0x0074, 0x007a, 0x0074, 0x0020, 0x0065, 0x0069, + 0x006e, 0x0020, 0x0041, 0x0056, 0x0049, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0069, 0x006e, 0x0020, 0x0036, + 0x0034, 0x0030, 0x002a, 0x0034, 0x0038, 0x0030, 0x0020, 0x0067, 0x0065, 0x0073, 0x0070, 0x0069, 0x0065, 0x006c, 0x0074, 0x002e, + 0x002e, 0x000a, 0x0042, 0x0065, 0x0069, 0x0020, 0x0064, 0x0065, 0x0066, 0x0065, 0x006b, 0x0074, 0x0065, 0x006e, 0x0020, 0x0056, + 0x0069, 0x0064, 0x0065, 0x006f, 0x0074, 0x0072, 0x0065, 0x0069, 0x0062, 0x0065, 0x0072, 0x006e, 0x0020, 0x006b, 0x0061, 0x006e, + 0x006e, 0x0020, 0x0064, 0x0065, 0x0072, 0x0020, 0x0041, 0x0075, 0x0066, 0x0072, 0x0075, 0x0066, 0x0020, 0x0066, 0x0065, 0x0068, + 0x006c, 0x0073, 0x0063, 0x0068, 0x006c, 0x0061, 0x0067, 0x0065, 0x006e, 0x002e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0073, + 0x0065, 0x0068, 0x0065, 0x006e, 0x0020, 0x0064, 0x0061, 0x006e, 0x006e, 0x0020, 0x0065, 0x0069, 0x006e, 0x0065, 0x0020, 0x0046, + 0x0065, 0x0068, 0x006c, 0x0065, 0x0072, 0x006d, 0x0065, 0x006c, 0x0064, 0x0075, 0x006e, 0x0067, 0x002e, 0x0020, 0x0045, 0x0076, + 0x0065, 0x006e, 0x0074, 0x0075, 0x0065, 0x006c, 0x006c, 0x0020, 0x006d, 0x00fc, 0x0073, 0x0073, 0x0065, 0x006e, 0x0020, 0x0053, + 0x0069, 0x0065, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x006e, 0x0065, 0x0075, 0x0020, 0x0073, + 0x0074, 0x0061, 0x0072, 0x0074, 0x0065, 0x006e, 0x002c, 0x0020, 0x0077, 0x0065, 0x006e, 0x006e, 0x0020, 0x0049, 0x0068, 0x0072, + 0x0020, 0x0052, 0x0065, 0x0063, 0x0068, 0x006e, 0x0065, 0x0072, 0x0020, 0x006e, 0x0069, 0x0063, 0x0068, 0x0074, 0x0020, 0x006d, + 0x0065, 0x0068, 0x0072, 0x0020, 0x0072, 0x0065, 0x0061, 0x0067, 0x0069, 0x0065, 0x0072, 0x0074, 0x002e, +// 30 +// Der folgende Fehler wurde von Windows gemeldet:\n\n%s\n\nDas Abspielen von 640*480 Videos ist bis auf weiteres abgeschaltet, bitte lesen Sie im technischen Begleitheft nach. + 0x00aa, + 0x0044, 0x0065, 0x0072, 0x0020, 0x0066, 0x006f, 0x006c, 0x0067, 0x0065, 0x006e, 0x0064, 0x0065, 0x0020, 0x0046, 0x0065, 0x0068, + 0x006c, 0x0065, 0x0072, 0x0020, 0x0077, 0x0075, 0x0072, 0x0064, 0x0065, 0x0020, 0x0076, 0x006f, 0x006e, 0x0020, 0x0057, 0x0069, + 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0067, 0x0065, 0x006d, 0x0065, 0x006c, 0x0064, 0x0065, 0x0074, 0x003a, 0x000a, + 0x000a, 0x0025, 0x0073, 0x000a, 0x000a, 0x0044, 0x0061, 0x0073, 0x0020, 0x0041, 0x0062, 0x0073, 0x0070, 0x0069, 0x0065, 0x006c, + 0x0065, 0x006e, 0x0020, 0x0076, 0x006f, 0x006e, 0x0020, 0x0036, 0x0034, 0x0030, 0x002a, 0x0034, 0x0038, 0x0030, 0x0020, 0x0056, + 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x0020, 0x0020, 0x0069, 0x0073, 0x0074, 0x0020, 0x0062, 0x0069, 0x0073, 0x0020, 0x0061, + 0x0075, 0x0066, 0x0020, 0x0077, 0x0065, 0x0069, 0x0074, 0x0065, 0x0072, 0x0065, 0x0073, 0x0020, 0x0061, 0x0062, 0x0067, 0x0065, + 0x0073, 0x0063, 0x0068, 0x0061, 0x006c, 0x0074, 0x0065, 0x0074, 0x002c, 0x0020, 0x0062, 0x0069, 0x0074, 0x0074, 0x0065, 0x0020, + 0x006c, 0x0065, 0x0073, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0069, 0x006d, 0x0020, 0x0074, 0x0065, 0x0063, + 0x0068, 0x006e, 0x0069, 0x0073, 0x0063, 0x0068, 0x0065, 0x006e, 0x0020, 0x0042, 0x0065, 0x0067, 0x006c, 0x0065, 0x0069, 0x0074, + 0x0068, 0x0065, 0x0066, 0x0074, 0x0020, 0x006e, 0x0061, 0x0063, 0x0068, 0x002e, +// 31 +// + 0x0000, +}; + +static const WCHAR AppStringData_3[2908] = { +// 32 +// Die verwendeten Videos sind schwarz, es ist also normal, daß Sie während der Tests keine Bilder sehen. Bitte entnehmen Sie weitere Informationen dem technischen Handbuch. + 0x00aa, + 0x0044, 0x0069, 0x0065, 0x0020, 0x0076, 0x0065, 0x0072, 0x0077, 0x0065, 0x006e, 0x0064, 0x0065, 0x0074, 0x0065, 0x006e, 0x0020, + 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x0020, 0x0073, 0x0069, 0x006e, 0x0064, 0x0020, 0x0073, 0x0063, 0x0068, 0x0077, + 0x0061, 0x0072, 0x007a, 0x002c, 0x0020, 0x0065, 0x0073, 0x0020, 0x0069, 0x0073, 0x0074, 0x0020, 0x0061, 0x006c, 0x0073, 0x006f, + 0x0020, 0x006e, 0x006f, 0x0072, 0x006d, 0x0061, 0x006c, 0x002c, 0x0020, 0x0064, 0x0061, 0x00df, 0x0020, 0x0053, 0x0069, 0x0065, + 0x0020, 0x0077, 0x00e4, 0x0068, 0x0072, 0x0065, 0x006e, 0x0064, 0x0020, 0x0064, 0x0065, 0x0072, 0x0020, 0x0054, 0x0065, 0x0073, + 0x0074, 0x0073, 0x0020, 0x006b, 0x0065, 0x0069, 0x006e, 0x0065, 0x0020, 0x0042, 0x0069, 0x006c, 0x0064, 0x0065, 0x0072, 0x0020, + 0x0073, 0x0065, 0x0068, 0x0065, 0x006e, 0x002e, 0x0020, 0x0042, 0x0069, 0x0074, 0x0074, 0x0065, 0x0020, 0x0065, 0x006e, 0x0074, + 0x006e, 0x0065, 0x0068, 0x006d, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0077, 0x0065, 0x0069, 0x0074, 0x0065, + 0x0072, 0x0065, 0x0020, 0x0049, 0x006e, 0x0066, 0x006f, 0x0072, 0x006d, 0x0061, 0x0074, 0x0069, 0x006f, 0x006e, 0x0065, 0x006e, + 0x0020, 0x0064, 0x0065, 0x006d, 0x0020, 0x0074, 0x0065, 0x0063, 0x0068, 0x006e, 0x0069, 0x0073, 0x0063, 0x0068, 0x0065, 0x006e, + 0x0020, 0x0048, 0x0061, 0x006e, 0x0064, 0x0062, 0x0075, 0x0063, 0x0068, 0x002e, +// 33 +// TESTABSCHLUSS.\nSie können zwar Videos abspielen, müssen aber mit Beeinträchtigungen rechnen. Der Grund ist, daß Ihr Videokartentreiber fehlerhaft ist. Wenden Sie sich wegen eines Updates an den Hersteller Ihrer Videokarte. + 0x00de, + 0x0054, 0x0045, 0x0053, 0x0054, 0x0041, 0x0042, 0x0053, 0x0043, 0x0048, 0x004c, 0x0055, 0x0053, 0x0053, 0x002e, 0x000a, 0x0053, + 0x0069, 0x0065, 0x0020, 0x006b, 0x00f6, 0x006e, 0x006e, 0x0065, 0x006e, 0x0020, 0x007a, 0x0077, 0x0061, 0x0072, 0x0020, 0x0056, + 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x0020, 0x0061, 0x0062, 0x0073, 0x0070, 0x0069, 0x0065, 0x006c, 0x0065, 0x006e, 0x002c, + 0x0020, 0x006d, 0x00fc, 0x0073, 0x0073, 0x0065, 0x006e, 0x0020, 0x0061, 0x0062, 0x0065, 0x0072, 0x0020, 0x006d, 0x0069, 0x0074, + 0x0020, 0x0042, 0x0065, 0x0065, 0x0069, 0x006e, 0x0074, 0x0072, 0x00e4, 0x0063, 0x0068, 0x0074, 0x0069, 0x0067, 0x0075, 0x006e, + 0x0067, 0x0065, 0x006e, 0x0020, 0x0072, 0x0065, 0x0063, 0x0068, 0x006e, 0x0065, 0x006e, 0x002e, 0x0020, 0x0044, 0x0065, 0x0072, + 0x0020, 0x0047, 0x0072, 0x0075, 0x006e, 0x0064, 0x0020, 0x0069, 0x0073, 0x0074, 0x002c, 0x0020, 0x0064, 0x0061, 0x00df, 0x0020, + 0x0049, 0x0068, 0x0072, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x006b, 0x0061, 0x0072, 0x0074, 0x0065, 0x006e, 0x0074, + 0x0072, 0x0065, 0x0069, 0x0062, 0x0065, 0x0072, 0x0020, 0x0066, 0x0065, 0x0068, 0x006c, 0x0065, 0x0072, 0x0068, 0x0061, 0x0066, + 0x0074, 0x0020, 0x0069, 0x0073, 0x0074, 0x002e, 0x0020, 0x0057, 0x0065, 0x006e, 0x0064, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, + 0x0065, 0x0020, 0x0073, 0x0069, 0x0063, 0x0068, 0x0020, 0x0077, 0x0065, 0x0067, 0x0065, 0x006e, 0x0020, 0x0065, 0x0069, 0x006e, + 0x0065, 0x0073, 0x0020, 0x0055, 0x0070, 0x0064, 0x0061, 0x0074, 0x0065, 0x0073, 0x0020, 0x0061, 0x006e, 0x0020, 0x0064, 0x0065, + 0x006e, 0x0020, 0x0048, 0x0065, 0x0072, 0x0073, 0x0074, 0x0065, 0x006c, 0x006c, 0x0065, 0x0072, 0x0020, 0x0049, 0x0068, 0x0072, + 0x0065, 0x0072, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x006b, 0x0061, 0x0072, 0x0074, 0x0065, 0x002e, +// 34 +// TESTABSCHLUSS.\nIhr Videokartentreiber ist fehlerhaft, so daß es nicht möglich ist, Videos abzuspielen. Wenden Sie sich wegen eines Updates an den Hersteller Ihrer Videokarte. + 0x00ae, + 0x0054, 0x0045, 0x0053, 0x0054, 0x0041, 0x0042, 0x0053, 0x0043, 0x0048, 0x004c, 0x0055, 0x0053, 0x0053, 0x002e, 0x000a, 0x0049, + 0x0068, 0x0072, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x006b, 0x0061, 0x0072, 0x0074, 0x0065, 0x006e, 0x0074, 0x0072, + 0x0065, 0x0069, 0x0062, 0x0065, 0x0072, 0x0020, 0x0069, 0x0073, 0x0074, 0x0020, 0x0066, 0x0065, 0x0068, 0x006c, 0x0065, 0x0072, + 0x0068, 0x0061, 0x0066, 0x0074, 0x002c, 0x0020, 0x0073, 0x006f, 0x0020, 0x0064, 0x0061, 0x00df, 0x0020, 0x0065, 0x0073, 0x0020, + 0x006e, 0x0069, 0x0063, 0x0068, 0x0074, 0x0020, 0x006d, 0x00f6, 0x0067, 0x006c, 0x0069, 0x0063, 0x0068, 0x0020, 0x0069, 0x0073, + 0x0074, 0x002c, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x0020, 0x0061, 0x0062, 0x007a, 0x0075, 0x0073, 0x0070, + 0x0069, 0x0065, 0x006c, 0x0065, 0x006e, 0x002e, 0x0020, 0x0057, 0x0065, 0x006e, 0x0064, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, + 0x0065, 0x0020, 0x0073, 0x0069, 0x0063, 0x0068, 0x0020, 0x0077, 0x0065, 0x0067, 0x0065, 0x006e, 0x0020, 0x0065, 0x0069, 0x006e, + 0x0065, 0x0073, 0x0020, 0x0055, 0x0070, 0x0064, 0x0061, 0x0074, 0x0065, 0x0073, 0x0020, 0x0061, 0x006e, 0x0020, 0x0064, 0x0065, + 0x006e, 0x0020, 0x0048, 0x0065, 0x0072, 0x0073, 0x0074, 0x0065, 0x006c, 0x006c, 0x0065, 0x0072, 0x0020, 0x0049, 0x0068, 0x0072, + 0x0065, 0x0072, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x006b, 0x0061, 0x0072, 0x0074, 0x0065, 0x002e, +// 35 +// Die Datei TST.LIB konnte nicht gelesen werden. Wenn Sie nicht im aktuellen Directory ist,kopieren Sie sie aus dem BIN Verzeichnis der CD dorthin, oder installieren BATTLE ISLE 3 erneut. + 0x00b9, + 0x0044, 0x0069, 0x0065, 0x0020, 0x0044, 0x0061, 0x0074, 0x0065, 0x0069, 0x0020, 0x0054, 0x0053, 0x0054, 0x002e, 0x004c, 0x0049, + 0x0042, 0x0020, 0x006b, 0x006f, 0x006e, 0x006e, 0x0074, 0x0065, 0x0020, 0x006e, 0x0069, 0x0063, 0x0068, 0x0074, 0x0020, 0x0067, + 0x0065, 0x006c, 0x0065, 0x0073, 0x0065, 0x006e, 0x0020, 0x0077, 0x0065, 0x0072, 0x0064, 0x0065, 0x006e, 0x002e, 0x0020, 0x0057, + 0x0065, 0x006e, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x006e, 0x0069, 0x0063, 0x0068, 0x0074, 0x0020, 0x0069, 0x006d, + 0x0020, 0x0061, 0x006b, 0x0074, 0x0075, 0x0065, 0x006c, 0x006c, 0x0065, 0x006e, 0x0020, 0x0044, 0x0069, 0x0072, 0x0065, 0x0063, + 0x0074, 0x006f, 0x0072, 0x0079, 0x0020, 0x0069, 0x0073, 0x0074, 0x002c, 0x006b, 0x006f, 0x0070, 0x0069, 0x0065, 0x0072, 0x0065, + 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0073, 0x0069, 0x0065, 0x0020, 0x0061, 0x0075, 0x0073, 0x0020, 0x0064, 0x0065, + 0x006d, 0x0020, 0x0042, 0x0049, 0x004e, 0x0020, 0x0056, 0x0065, 0x0072, 0x007a, 0x0065, 0x0069, 0x0063, 0x0068, 0x006e, 0x0069, + 0x0073, 0x0020, 0x0064, 0x0065, 0x0072, 0x0020, 0x0043, 0x0044, 0x0020, 0x0064, 0x006f, 0x0072, 0x0074, 0x0068, 0x0069, 0x006e, + 0x002c, 0x0020, 0x006f, 0x0064, 0x0065, 0x0072, 0x0020, 0x0069, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, 0x006c, 0x0069, 0x0065, + 0x0072, 0x0065, 0x006e, 0x0020, 0x0042, 0x0041, 0x0054, 0x0054, 0x004c, 0x0045, 0x0020, 0x0049, 0x0053, 0x004c, 0x0045, 0x0020, + 0x0033, 0x0020, 0x0065, 0x0072, 0x006e, 0x0065, 0x0075, 0x0074, 0x002e, +// 36 +// Wahrscheinlich ist Ihre Soundkarte nicht richtig eingestellt. Überprüfen Sie die Einstellungen (IRQ,Adresse,DMA).\nVersuchen Sie auch, ob Sie das Sample "TST.WAV" (im aktuellen Verzeichnis) mit dem Media-Player abspielen können. + 0x00e3, + 0x0057, 0x0061, 0x0068, 0x0072, 0x0073, 0x0063, 0x0068, 0x0065, 0x0069, 0x006e, 0x006c, 0x0069, 0x0063, 0x0068, 0x0020, 0x0069, + 0x0073, 0x0074, 0x0020, 0x0049, 0x0068, 0x0072, 0x0065, 0x0020, 0x0053, 0x006f, 0x0075, 0x006e, 0x0064, 0x006b, 0x0061, 0x0072, + 0x0074, 0x0065, 0x0020, 0x006e, 0x0069, 0x0063, 0x0068, 0x0074, 0x0020, 0x0072, 0x0069, 0x0063, 0x0068, 0x0074, 0x0069, 0x0067, + 0x0020, 0x0065, 0x0069, 0x006e, 0x0067, 0x0065, 0x0073, 0x0074, 0x0065, 0x006c, 0x006c, 0x0074, 0x002e, 0x0020, 0x00dc, 0x0062, + 0x0065, 0x0072, 0x0070, 0x0072, 0x00fc, 0x0066, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0064, 0x0069, 0x0065, + 0x0020, 0x0045, 0x0069, 0x006e, 0x0073, 0x0074, 0x0065, 0x006c, 0x006c, 0x0075, 0x006e, 0x0067, 0x0065, 0x006e, 0x0020, 0x0028, + 0x0049, 0x0052, 0x0051, 0x002c, 0x0041, 0x0064, 0x0072, 0x0065, 0x0073, 0x0073, 0x0065, 0x002c, 0x0044, 0x004d, 0x0041, 0x0029, + 0x002e, 0x000a, 0x0056, 0x0065, 0x0072, 0x0073, 0x0075, 0x0063, 0x0068, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, + 0x0061, 0x0075, 0x0063, 0x0068, 0x002c, 0x0020, 0x006f, 0x0062, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0064, 0x0061, 0x0073, + 0x0020, 0x0053, 0x0061, 0x006d, 0x0070, 0x006c, 0x0065, 0x0020, 0x0022, 0x0054, 0x0053, 0x0054, 0x002e, 0x0057, 0x0041, 0x0056, + 0x0022, 0x0020, 0x0028, 0x0069, 0x006d, 0x0020, 0x0061, 0x006b, 0x0074, 0x0075, 0x0065, 0x006c, 0x006c, 0x0065, 0x006e, 0x0020, + 0x0056, 0x0065, 0x0072, 0x007a, 0x0065, 0x0069, 0x0063, 0x0068, 0x006e, 0x0069, 0x0073, 0x0029, 0x0020, 0x006d, 0x0069, 0x0074, + 0x0020, 0x0064, 0x0065, 0x006d, 0x0020, 0x004d, 0x0065, 0x0064, 0x0069, 0x0061, 0x002d, 0x0050, 0x006c, 0x0061, 0x0079, 0x0065, + 0x0072, 0x0020, 0x0061, 0x0062, 0x0073, 0x0070, 0x0069, 0x0065, 0x006c, 0x0065, 0x006e, 0x0020, 0x006b, 0x00f6, 0x006e, 0x006e, + 0x0065, 0x006e, 0x002e, +// 37 +// Es wird jetzt nach einer Musikkarte gesucht. Dazu wird ein MIDI-File geladen. + 0x004d, + 0x0045, 0x0073, 0x0020, 0x0077, 0x0069, 0x0072, 0x0064, 0x0020, 0x006a, 0x0065, 0x0074, 0x007a, 0x0074, 0x0020, 0x006e, 0x0061, + 0x0063, 0x0068, 0x0020, 0x0065, 0x0069, 0x006e, 0x0065, 0x0072, 0x0020, 0x004d, 0x0075, 0x0073, 0x0069, 0x006b, 0x006b, 0x0061, + 0x0072, 0x0074, 0x0065, 0x0020, 0x0067, 0x0065, 0x0073, 0x0075, 0x0063, 0x0068, 0x0074, 0x002e, 0x0020, 0x0044, 0x0061, 0x007a, + 0x0075, 0x0020, 0x0077, 0x0069, 0x0072, 0x0064, 0x0020, 0x0065, 0x0069, 0x006e, 0x0020, 0x004d, 0x0049, 0x0044, 0x0049, 0x002d, + 0x0046, 0x0069, 0x006c, 0x0065, 0x0020, 0x0067, 0x0065, 0x006c, 0x0061, 0x0064, 0x0065, 0x006e, 0x002e, +// 38 +// Das Musikfile wird jetzt gestartet. Möglicherweise gibt Windows eine Meldung die besagt,daß die Datei nicht korrekt wiedergegeben werden kann.Klicken Sie dann auf OK,nachdem Sie die kleine Checkbox angeklickt haben. + 0x00d7, + 0x0044, 0x0061, 0x0073, 0x0020, 0x004d, 0x0075, 0x0073, 0x0069, 0x006b, 0x0066, 0x0069, 0x006c, 0x0065, 0x0020, 0x0077, 0x0069, + 0x0072, 0x0064, 0x0020, 0x006a, 0x0065, 0x0074, 0x007a, 0x0074, 0x0020, 0x0067, 0x0065, 0x0073, 0x0074, 0x0061, 0x0072, 0x0074, + 0x0065, 0x0074, 0x002e, 0x0020, 0x004d, 0x00f6, 0x0067, 0x006c, 0x0069, 0x0063, 0x0068, 0x0065, 0x0072, 0x0077, 0x0065, 0x0069, + 0x0073, 0x0065, 0x0020, 0x0067, 0x0069, 0x0062, 0x0074, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, + 0x0065, 0x0069, 0x006e, 0x0065, 0x0020, 0x004d, 0x0065, 0x006c, 0x0064, 0x0075, 0x006e, 0x0067, 0x0020, 0x0064, 0x0069, 0x0065, + 0x0020, 0x0062, 0x0065, 0x0073, 0x0061, 0x0067, 0x0074, 0x002c, 0x0064, 0x0061, 0x00df, 0x0020, 0x0064, 0x0069, 0x0065, 0x0020, + 0x0044, 0x0061, 0x0074, 0x0065, 0x0069, 0x0020, 0x006e, 0x0069, 0x0063, 0x0068, 0x0074, 0x0020, 0x006b, 0x006f, 0x0072, 0x0072, + 0x0065, 0x006b, 0x0074, 0x0020, 0x0077, 0x0069, 0x0065, 0x0064, 0x0065, 0x0072, 0x0067, 0x0065, 0x0067, 0x0065, 0x0062, 0x0065, + 0x006e, 0x0020, 0x0077, 0x0065, 0x0072, 0x0064, 0x0065, 0x006e, 0x0020, 0x006b, 0x0061, 0x006e, 0x006e, 0x002e, 0x004b, 0x006c, + 0x0069, 0x0063, 0x006b, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0064, 0x0061, 0x006e, 0x006e, 0x0020, 0x0061, + 0x0075, 0x0066, 0x0020, 0x004f, 0x004b, 0x002c, 0x006e, 0x0061, 0x0063, 0x0068, 0x0064, 0x0065, 0x006d, 0x0020, 0x0053, 0x0069, + 0x0065, 0x0020, 0x0064, 0x0069, 0x0065, 0x0020, 0x006b, 0x006c, 0x0065, 0x0069, 0x006e, 0x0065, 0x0020, 0x0043, 0x0068, 0x0065, + 0x0063, 0x006b, 0x0062, 0x006f, 0x0078, 0x0020, 0x0061, 0x006e, 0x0067, 0x0065, 0x006b, 0x006c, 0x0069, 0x0063, 0x006b, 0x0074, + 0x0020, 0x0068, 0x0061, 0x0062, 0x0065, 0x006e, 0x002e, +// 39 +// Das File TST.MID wurde nicht im aktuellen Directory:\n%s\nauf Ihrer Festplatte gefunden.\nBATTLE ISLE 3 wird trotzdem versuchen,Musik zu spielen.Sollte dabei ein Fehler auftreten,wird die Musikausgabe jedoch abgeschaltet. + 0x00da, + 0x0044, 0x0061, 0x0073, 0x0020, 0x0046, 0x0069, 0x006c, 0x0065, 0x0020, 0x0054, 0x0053, 0x0054, 0x002e, 0x004d, 0x0049, 0x0044, + 0x0020, 0x0077, 0x0075, 0x0072, 0x0064, 0x0065, 0x0020, 0x006e, 0x0069, 0x0063, 0x0068, 0x0074, 0x0020, 0x0069, 0x006d, 0x0020, + 0x0061, 0x006b, 0x0074, 0x0075, 0x0065, 0x006c, 0x006c, 0x0065, 0x006e, 0x0020, 0x0044, 0x0069, 0x0072, 0x0065, 0x0063, 0x0074, + 0x006f, 0x0072, 0x0079, 0x003a, 0x000a, 0x0025, 0x0073, 0x000a, 0x0061, 0x0075, 0x0066, 0x0020, 0x0049, 0x0068, 0x0072, 0x0065, + 0x0072, 0x0020, 0x0046, 0x0065, 0x0073, 0x0074, 0x0070, 0x006c, 0x0061, 0x0074, 0x0074, 0x0065, 0x0020, 0x0067, 0x0065, 0x0066, + 0x0075, 0x006e, 0x0064, 0x0065, 0x006e, 0x002e, 0x000a, 0x0042, 0x0041, 0x0054, 0x0054, 0x004c, 0x0045, 0x0020, 0x0049, 0x0053, + 0x004c, 0x0045, 0x0020, 0x0033, 0x0020, 0x0077, 0x0069, 0x0072, 0x0064, 0x0020, 0x0074, 0x0072, 0x006f, 0x0074, 0x007a, 0x0064, + 0x0065, 0x006d, 0x0020, 0x0076, 0x0065, 0x0072, 0x0073, 0x0075, 0x0063, 0x0068, 0x0065, 0x006e, 0x002c, 0x004d, 0x0075, 0x0073, + 0x0069, 0x006b, 0x0020, 0x007a, 0x0075, 0x0020, 0x0073, 0x0070, 0x0069, 0x0065, 0x006c, 0x0065, 0x006e, 0x002e, 0x0053, 0x006f, + 0x006c, 0x006c, 0x0074, 0x0065, 0x0020, 0x0064, 0x0061, 0x0062, 0x0065, 0x0069, 0x0020, 0x0065, 0x0069, 0x006e, 0x0020, 0x0046, + 0x0065, 0x0068, 0x006c, 0x0065, 0x0072, 0x0020, 0x0061, 0x0075, 0x0066, 0x0074, 0x0072, 0x0065, 0x0074, 0x0065, 0x006e, 0x002c, + 0x0077, 0x0069, 0x0072, 0x0064, 0x0020, 0x0064, 0x0069, 0x0065, 0x0020, 0x004d, 0x0075, 0x0073, 0x0069, 0x006b, 0x0061, 0x0075, + 0x0073, 0x0067, 0x0061, 0x0062, 0x0065, 0x0020, 0x006a, 0x0065, 0x0064, 0x006f, 0x0063, 0x0068, 0x0020, 0x0061, 0x0062, 0x0067, + 0x0065, 0x0073, 0x0063, 0x0068, 0x0061, 0x006c, 0x0074, 0x0065, 0x0074, 0x002e, +// 40 +// Windows konnte keine Musikkarte feststellen. Es wird nicht mehr versucht, Musiken abzuspielen. + 0x005e, + 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x006b, 0x006f, 0x006e, 0x006e, 0x0074, 0x0065, 0x0020, 0x006b, + 0x0065, 0x0069, 0x006e, 0x0065, 0x0020, 0x004d, 0x0075, 0x0073, 0x0069, 0x006b, 0x006b, 0x0061, 0x0072, 0x0074, 0x0065, 0x0020, + 0x0066, 0x0065, 0x0073, 0x0074, 0x0073, 0x0074, 0x0065, 0x006c, 0x006c, 0x0065, 0x006e, 0x002e, 0x0020, 0x0045, 0x0073, 0x0020, + 0x0077, 0x0069, 0x0072, 0x0064, 0x0020, 0x006e, 0x0069, 0x0063, 0x0068, 0x0074, 0x0020, 0x006d, 0x0065, 0x0068, 0x0072, 0x0020, + 0x0076, 0x0065, 0x0072, 0x0073, 0x0075, 0x0063, 0x0068, 0x0074, 0x002c, 0x0020, 0x004d, 0x0075, 0x0073, 0x0069, 0x006b, 0x0065, + 0x006e, 0x0020, 0x0061, 0x0062, 0x007a, 0x0075, 0x0073, 0x0070, 0x0069, 0x0065, 0x006c, 0x0065, 0x006e, 0x002e, +// 41 +// Ein unbekannter Fehler ist aufgetreten. Das Spielen der Musik wird bis auf weiteres abgeschaltet. Versuchen Sie, das File TST.MID im aktuellen Verzeichnis mit dem Media-Player abzuspielen. Überprüfen Sie, ob Ihre Musikkarte richtig eingestellt ist. + 0x00f8, + 0x0045, 0x0069, 0x006e, 0x0020, 0x0075, 0x006e, 0x0062, 0x0065, 0x006b, 0x0061, 0x006e, 0x006e, 0x0074, 0x0065, 0x0072, 0x0020, + 0x0046, 0x0065, 0x0068, 0x006c, 0x0065, 0x0072, 0x0020, 0x0069, 0x0073, 0x0074, 0x0020, 0x0061, 0x0075, 0x0066, 0x0067, 0x0065, + 0x0074, 0x0072, 0x0065, 0x0074, 0x0065, 0x006e, 0x002e, 0x0020, 0x0044, 0x0061, 0x0073, 0x0020, 0x0053, 0x0070, 0x0069, 0x0065, + 0x006c, 0x0065, 0x006e, 0x0020, 0x0064, 0x0065, 0x0072, 0x0020, 0x004d, 0x0075, 0x0073, 0x0069, 0x006b, 0x0020, 0x0077, 0x0069, + 0x0072, 0x0064, 0x0020, 0x0062, 0x0069, 0x0073, 0x0020, 0x0061, 0x0075, 0x0066, 0x0020, 0x0077, 0x0065, 0x0069, 0x0074, 0x0065, + 0x0072, 0x0065, 0x0073, 0x0020, 0x0061, 0x0062, 0x0067, 0x0065, 0x0073, 0x0063, 0x0068, 0x0061, 0x006c, 0x0074, 0x0065, 0x0074, + 0x002e, 0x0020, 0x0056, 0x0065, 0x0072, 0x0073, 0x0075, 0x0063, 0x0068, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x002c, + 0x0020, 0x0064, 0x0061, 0x0073, 0x0020, 0x0046, 0x0069, 0x006c, 0x0065, 0x0020, 0x0054, 0x0053, 0x0054, 0x002e, 0x004d, 0x0049, + 0x0044, 0x0020, 0x0069, 0x006d, 0x0020, 0x0061, 0x006b, 0x0074, 0x0075, 0x0065, 0x006c, 0x006c, 0x0065, 0x006e, 0x0020, 0x0056, + 0x0065, 0x0072, 0x007a, 0x0065, 0x0069, 0x0063, 0x0068, 0x006e, 0x0069, 0x0073, 0x0020, 0x006d, 0x0069, 0x0074, 0x0020, 0x0064, + 0x0065, 0x006d, 0x0020, 0x004d, 0x0065, 0x0064, 0x0069, 0x0061, 0x002d, 0x0050, 0x006c, 0x0061, 0x0079, 0x0065, 0x0072, 0x0020, + 0x0061, 0x0062, 0x007a, 0x0075, 0x0073, 0x0070, 0x0069, 0x0065, 0x006c, 0x0065, 0x006e, 0x002e, 0x0020, 0x00dc, 0x0062, 0x0065, + 0x0072, 0x0070, 0x0072, 0x00fc, 0x0066, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x002c, 0x0020, 0x006f, 0x0062, 0x0020, + 0x0049, 0x0068, 0x0072, 0x0065, 0x0020, 0x004d, 0x0075, 0x0073, 0x0069, 0x006b, 0x006b, 0x0061, 0x0072, 0x0074, 0x0065, 0x0020, + 0x0072, 0x0069, 0x0063, 0x0068, 0x0074, 0x0069, 0x0067, 0x0020, 0x0065, 0x0069, 0x006e, 0x0067, 0x0065, 0x0073, 0x0074, 0x0065, + 0x006c, 0x006c, 0x0074, 0x0020, 0x0069, 0x0073, 0x0074, 0x002e, +// 42 +// Der folgende Fehler wurde von Windows gemeldet:\n\n%s\n\nDas Abspielen der Musik ist bis auf weiteres abgeschaltet, bitte lesen Sie im technischen Begleitheft nach. + 0x00a1, + 0x0044, 0x0065, 0x0072, 0x0020, 0x0066, 0x006f, 0x006c, 0x0067, 0x0065, 0x006e, 0x0064, 0x0065, 0x0020, 0x0046, 0x0065, 0x0068, + 0x006c, 0x0065, 0x0072, 0x0020, 0x0077, 0x0075, 0x0072, 0x0064, 0x0065, 0x0020, 0x0076, 0x006f, 0x006e, 0x0020, 0x0057, 0x0069, + 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0067, 0x0065, 0x006d, 0x0065, 0x006c, 0x0064, 0x0065, 0x0074, 0x003a, 0x000a, + 0x000a, 0x0025, 0x0073, 0x000a, 0x000a, 0x0044, 0x0061, 0x0073, 0x0020, 0x0041, 0x0062, 0x0073, 0x0070, 0x0069, 0x0065, 0x006c, + 0x0065, 0x006e, 0x0020, 0x0064, 0x0065, 0x0072, 0x0020, 0x004d, 0x0075, 0x0073, 0x0069, 0x006b, 0x0020, 0x0020, 0x0069, 0x0073, + 0x0074, 0x0020, 0x0062, 0x0069, 0x0073, 0x0020, 0x0061, 0x0075, 0x0066, 0x0020, 0x0077, 0x0065, 0x0069, 0x0074, 0x0065, 0x0072, + 0x0065, 0x0073, 0x0020, 0x0061, 0x0062, 0x0067, 0x0065, 0x0073, 0x0063, 0x0068, 0x0061, 0x006c, 0x0074, 0x0065, 0x0074, 0x002c, + 0x0020, 0x0062, 0x0069, 0x0074, 0x0074, 0x0065, 0x0020, 0x006c, 0x0065, 0x0073, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, + 0x0020, 0x0069, 0x006d, 0x0020, 0x0074, 0x0065, 0x0063, 0x0068, 0x006e, 0x0069, 0x0073, 0x0063, 0x0068, 0x0065, 0x006e, 0x0020, + 0x0042, 0x0065, 0x0067, 0x006c, 0x0065, 0x0069, 0x0074, 0x0068, 0x0065, 0x0066, 0x0074, 0x0020, 0x006e, 0x0061, 0x0063, 0x0068, + 0x002e, +// 43 +// Das deutet darauf hin, daß Ihre Soundkarte falsch installiert ist. Überprüfen Sie Ihre Windows-Sounddtreiber und die Einstellungen auf der Musikkarte.. Versuchen Sie, danach das File TST.MID im aktuellen Verzeichnis mit dem Media-Player abzuspielen. + 0x00fb, + 0x0044, 0x0061, 0x0073, 0x0020, 0x0064, 0x0065, 0x0075, 0x0074, 0x0065, 0x0074, 0x0020, 0x0064, 0x0061, 0x0072, 0x0061, 0x0075, + 0x0066, 0x0020, 0x0068, 0x0069, 0x006e, 0x002c, 0x0020, 0x0064, 0x0061, 0x00df, 0x0020, 0x0049, 0x0068, 0x0072, 0x0065, 0x0020, + 0x0053, 0x006f, 0x0075, 0x006e, 0x0064, 0x006b, 0x0061, 0x0072, 0x0074, 0x0065, 0x0020, 0x0066, 0x0061, 0x006c, 0x0073, 0x0063, + 0x0068, 0x0020, 0x0069, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, 0x006c, 0x0069, 0x0065, 0x0072, 0x0074, 0x0020, 0x0069, 0x0073, + 0x0074, 0x002e, 0x0020, 0x00dc, 0x0062, 0x0065, 0x0072, 0x0070, 0x0072, 0x00fc, 0x0066, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, + 0x0065, 0x0020, 0x0049, 0x0068, 0x0072, 0x0065, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x002d, 0x0053, + 0x006f, 0x0075, 0x006e, 0x0064, 0x0064, 0x0074, 0x0072, 0x0065, 0x0069, 0x0062, 0x0065, 0x0072, 0x0020, 0x0075, 0x006e, 0x0064, + 0x0020, 0x0064, 0x0069, 0x0065, 0x0020, 0x0045, 0x0069, 0x006e, 0x0073, 0x0074, 0x0065, 0x006c, 0x006c, 0x0075, 0x006e, 0x0067, + 0x0065, 0x006e, 0x0020, 0x0061, 0x0075, 0x0066, 0x0020, 0x0064, 0x0065, 0x0072, 0x0020, 0x004d, 0x0075, 0x0073, 0x0069, 0x006b, + 0x006b, 0x0061, 0x0072, 0x0074, 0x0065, 0x002e, 0x002e, 0x0020, 0x0020, 0x0056, 0x0065, 0x0072, 0x0073, 0x0075, 0x0063, 0x0068, + 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x002c, 0x0020, 0x0064, 0x0061, 0x006e, 0x0061, 0x0063, 0x0068, 0x0020, 0x0064, + 0x0061, 0x0073, 0x0020, 0x0046, 0x0069, 0x006c, 0x0065, 0x0020, 0x0054, 0x0053, 0x0054, 0x002e, 0x004d, 0x0049, 0x0044, 0x0020, + 0x0069, 0x006d, 0x0020, 0x0061, 0x006b, 0x0074, 0x0075, 0x0065, 0x006c, 0x006c, 0x0065, 0x006e, 0x0020, 0x0056, 0x0065, 0x0072, + 0x007a, 0x0065, 0x0069, 0x0063, 0x0068, 0x006e, 0x0069, 0x0073, 0x0020, 0x006d, 0x0069, 0x0074, 0x0020, 0x0064, 0x0065, 0x006d, + 0x0020, 0x004d, 0x0065, 0x0064, 0x0069, 0x0061, 0x002d, 0x0050, 0x006c, 0x0061, 0x0079, 0x0065, 0x0072, 0x0020, 0x0061, 0x0062, + 0x007a, 0x0075, 0x0073, 0x0070, 0x0069, 0x0065, 0x006c, 0x0065, 0x006e, 0x002e, 0x0020, +// 44 +// Unter Windows 311 ist die häufigste Ursache ein falsch eingestellter MIDI-Mapper. Ziehen Sie das technische Begleitheft zu rate.\nSie sollten ein Update auf Windows 95 erwägen, da es Multimedia-Geräte wesentlich besser unterstützt als Windows 311. + 0x00f6, + 0x0055, 0x006e, 0x0074, 0x0065, 0x0072, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0033, 0x0031, + 0x0031, 0x0020, 0x0069, 0x0073, 0x0074, 0x0020, 0x0064, 0x0069, 0x0065, 0x0020, 0x0068, 0x00e4, 0x0075, 0x0066, 0x0069, 0x0067, + 0x0073, 0x0074, 0x0065, 0x0020, 0x0055, 0x0072, 0x0073, 0x0061, 0x0063, 0x0068, 0x0065, 0x0020, 0x0065, 0x0069, 0x006e, 0x0020, + 0x0066, 0x0061, 0x006c, 0x0073, 0x0063, 0x0068, 0x0020, 0x0065, 0x0069, 0x006e, 0x0067, 0x0065, 0x0073, 0x0074, 0x0065, 0x006c, + 0x006c, 0x0074, 0x0065, 0x0072, 0x0020, 0x004d, 0x0049, 0x0044, 0x0049, 0x002d, 0x004d, 0x0061, 0x0070, 0x0070, 0x0065, 0x0072, + 0x002e, 0x0020, 0x005a, 0x0069, 0x0065, 0x0068, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0064, 0x0061, 0x0073, + 0x0020, 0x0074, 0x0065, 0x0063, 0x0068, 0x006e, 0x0069, 0x0073, 0x0063, 0x0068, 0x0065, 0x0020, 0x0042, 0x0065, 0x0067, 0x006c, + 0x0065, 0x0069, 0x0074, 0x0068, 0x0065, 0x0066, 0x0074, 0x0020, 0x007a, 0x0075, 0x0020, 0x0072, 0x0061, 0x0074, 0x0065, 0x002e, + 0x000a, 0x0053, 0x0069, 0x0065, 0x0020, 0x0073, 0x006f, 0x006c, 0x006c, 0x0074, 0x0065, 0x006e, 0x0020, 0x0065, 0x0069, 0x006e, + 0x0020, 0x0055, 0x0070, 0x0064, 0x0061, 0x0074, 0x0065, 0x0020, 0x0061, 0x0075, 0x0066, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, + 0x006f, 0x0077, 0x0073, 0x0020, 0x0039, 0x0035, 0x0020, 0x0065, 0x0072, 0x0077, 0x00e4, 0x0067, 0x0065, 0x006e, 0x002c, 0x0020, + 0x0064, 0x0061, 0x0020, 0x0065, 0x0073, 0x0020, 0x004d, 0x0075, 0x006c, 0x0074, 0x0069, 0x006d, 0x0065, 0x0064, 0x0069, 0x0061, + 0x002d, 0x0047, 0x0065, 0x0072, 0x00e4, 0x0074, 0x0065, 0x0020, 0x0077, 0x0065, 0x0073, 0x0065, 0x006e, 0x0074, 0x006c, 0x0069, + 0x0063, 0x0068, 0x0020, 0x0062, 0x0065, 0x0073, 0x0073, 0x0065, 0x0072, 0x0020, 0x0075, 0x006e, 0x0074, 0x0065, 0x0072, 0x0073, + 0x0074, 0x00fc, 0x0074, 0x007a, 0x0074, 0x0020, 0x0061, 0x006c, 0x0073, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, + 0x0073, 0x0020, 0x0033, 0x0031, 0x0031, 0x002e, +// 45 +// Dieses Problem wird erfahrungsgemäß nicht mehr auftreten, wenn Sie Ihr System auf Windows 95 updaten, da es Multimedia Geräte wesentlich besser unterstützt als Windows 311. + 0x00ac, + 0x0044, 0x0069, 0x0065, 0x0073, 0x0065, 0x0073, 0x0020, 0x0050, 0x0072, 0x006f, 0x0062, 0x006c, 0x0065, 0x006d, 0x0020, 0x0077, + 0x0069, 0x0072, 0x0064, 0x0020, 0x0065, 0x0072, 0x0066, 0x0061, 0x0068, 0x0072, 0x0075, 0x006e, 0x0067, 0x0073, 0x0067, 0x0065, + 0x006d, 0x00e4, 0x00df, 0x0020, 0x006e, 0x0069, 0x0063, 0x0068, 0x0074, 0x0020, 0x006d, 0x0065, 0x0068, 0x0072, 0x0020, 0x0061, + 0x0075, 0x0066, 0x0074, 0x0072, 0x0065, 0x0074, 0x0065, 0x006e, 0x002c, 0x0020, 0x0077, 0x0065, 0x006e, 0x006e, 0x0020, 0x0053, + 0x0069, 0x0065, 0x0020, 0x0049, 0x0068, 0x0072, 0x0020, 0x0053, 0x0079, 0x0073, 0x0074, 0x0065, 0x006d, 0x0020, 0x0061, 0x0075, + 0x0066, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0039, 0x0035, 0x0020, 0x0075, 0x0070, 0x0064, + 0x0061, 0x0074, 0x0065, 0x006e, 0x002c, 0x0020, 0x0064, 0x0061, 0x0020, 0x0065, 0x0073, 0x0020, 0x004d, 0x0075, 0x006c, 0x0074, + 0x0069, 0x006d, 0x0065, 0x0064, 0x0069, 0x0061, 0x0020, 0x0047, 0x0065, 0x0072, 0x00e4, 0x0074, 0x0065, 0x0020, 0x0077, 0x0065, + 0x0073, 0x0065, 0x006e, 0x0074, 0x006c, 0x0069, 0x0063, 0x0068, 0x0020, 0x0062, 0x0065, 0x0073, 0x0073, 0x0065, 0x0072, 0x0020, + 0x0075, 0x006e, 0x0074, 0x0065, 0x0072, 0x0073, 0x0074, 0x00fc, 0x0074, 0x007a, 0x0074, 0x0020, 0x0061, 0x006c, 0x0073, 0x0020, + 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0033, 0x0031, 0x0031, 0x002e, +// 46 +// Das Starten des VIDEO FÜR WINDOWS Setupprogrammes war nicht möglich. Bitte starten Sie das Setup wie im technischen Begleitheft angegeben von Hand. + 0x0093, + 0x0044, 0x0061, 0x0073, 0x0020, 0x0053, 0x0074, 0x0061, 0x0072, 0x0074, 0x0065, 0x006e, 0x0020, 0x0064, 0x0065, 0x0073, 0x0020, + 0x0056, 0x0049, 0x0044, 0x0045, 0x004f, 0x0020, 0x0046, 0x00dc, 0x0052, 0x0020, 0x0057, 0x0049, 0x004e, 0x0044, 0x004f, 0x0057, + 0x0053, 0x0020, 0x0053, 0x0065, 0x0074, 0x0075, 0x0070, 0x0070, 0x0072, 0x006f, 0x0067, 0x0072, 0x0061, 0x006d, 0x006d, 0x0065, + 0x0073, 0x0020, 0x0077, 0x0061, 0x0072, 0x0020, 0x006e, 0x0069, 0x0063, 0x0068, 0x0074, 0x0020, 0x006d, 0x00f6, 0x0067, 0x006c, + 0x0069, 0x0063, 0x0068, 0x002e, 0x0020, 0x0042, 0x0069, 0x0074, 0x0074, 0x0065, 0x0020, 0x0073, 0x0074, 0x0061, 0x0072, 0x0074, + 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0064, 0x0061, 0x0073, 0x0020, 0x0053, 0x0065, 0x0074, 0x0075, 0x0070, + 0x0020, 0x0077, 0x0069, 0x0065, 0x0020, 0x0069, 0x006d, 0x0020, 0x0074, 0x0065, 0x0063, 0x0068, 0x006e, 0x0069, 0x0073, 0x0063, + 0x0068, 0x0065, 0x006e, 0x0020, 0x0042, 0x0065, 0x0067, 0x006c, 0x0065, 0x0069, 0x0074, 0x0068, 0x0065, 0x0066, 0x0074, 0x0020, + 0x0061, 0x006e, 0x0067, 0x0065, 0x0067, 0x0065, 0x0062, 0x0065, 0x006e, 0x0020, 0x0076, 0x006f, 0x006e, 0x0020, 0x0048, 0x0061, + 0x006e, 0x0064, 0x002e, +// 47 +// Die Überprüfung Ihres Rechners ist abgeschlossen. BATTLE ISLE 3 wird jetzt gestartet. + 0x0055, + 0x0044, 0x0069, 0x0065, 0x0020, 0x00dc, 0x0062, 0x0065, 0x0072, 0x0070, 0x0072, 0x00fc, 0x0066, 0x0075, 0x006e, 0x0067, 0x0020, + 0x0049, 0x0068, 0x0072, 0x0065, 0x0073, 0x0020, 0x0052, 0x0065, 0x0063, 0x0068, 0x006e, 0x0065, 0x0072, 0x0073, 0x0020, 0x0069, + 0x0073, 0x0074, 0x0020, 0x0061, 0x0062, 0x0067, 0x0065, 0x0073, 0x0063, 0x0068, 0x006c, 0x006f, 0x0073, 0x0073, 0x0065, 0x006e, + 0x002e, 0x0020, 0x0042, 0x0041, 0x0054, 0x0054, 0x004c, 0x0045, 0x0020, 0x0049, 0x0053, 0x004c, 0x0045, 0x0020, 0x0033, 0x0020, + 0x0077, 0x0069, 0x0072, 0x0064, 0x0020, 0x006a, 0x0065, 0x0074, 0x007a, 0x0074, 0x0020, 0x0067, 0x0065, 0x0073, 0x0074, 0x0061, + 0x0072, 0x0074, 0x0065, 0x0074, 0x002e, +}; + +static const WCHAR AppStringData_4[2398] = { +// 48 +// Es konnte keine Soundkarte festgestellt werden. Alle Geräuscheffekte sind ausgeschaltet. Sollten Sie dennoch eine Karte eingebaut haben, überprüfen Sie, ob die nötigen Treiber korrekt eingestellt sind und ob die Karte korrekt eingestellt ist. + 0x00f2, + 0x0045, 0x0073, 0x0020, 0x006b, 0x006f, 0x006e, 0x006e, 0x0074, 0x0065, 0x0020, 0x006b, 0x0065, 0x0069, 0x006e, 0x0065, 0x0020, + 0x0053, 0x006f, 0x0075, 0x006e, 0x0064, 0x006b, 0x0061, 0x0072, 0x0074, 0x0065, 0x0020, 0x0066, 0x0065, 0x0073, 0x0074, 0x0067, + 0x0065, 0x0073, 0x0074, 0x0065, 0x006c, 0x006c, 0x0074, 0x0020, 0x0077, 0x0065, 0x0072, 0x0064, 0x0065, 0x006e, 0x002e, 0x0020, + 0x0041, 0x006c, 0x006c, 0x0065, 0x0020, 0x0047, 0x0065, 0x0072, 0x00e4, 0x0075, 0x0073, 0x0063, 0x0068, 0x0065, 0x0066, 0x0066, + 0x0065, 0x006b, 0x0074, 0x0065, 0x0020, 0x0073, 0x0069, 0x006e, 0x0064, 0x0020, 0x0061, 0x0075, 0x0073, 0x0067, 0x0065, 0x0073, + 0x0063, 0x0068, 0x0061, 0x006c, 0x0074, 0x0065, 0x0074, 0x002e, 0x0020, 0x0053, 0x006f, 0x006c, 0x006c, 0x0074, 0x0065, 0x006e, + 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0064, 0x0065, 0x006e, 0x006e, 0x006f, 0x0063, 0x0068, 0x0020, 0x0065, 0x0069, 0x006e, + 0x0065, 0x0020, 0x004b, 0x0061, 0x0072, 0x0074, 0x0065, 0x0020, 0x0065, 0x0069, 0x006e, 0x0067, 0x0065, 0x0062, 0x0061, 0x0075, + 0x0074, 0x0020, 0x0068, 0x0061, 0x0062, 0x0065, 0x006e, 0x002c, 0x0020, 0x00fc, 0x0062, 0x0065, 0x0072, 0x0070, 0x0072, 0x00fc, + 0x0066, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x002c, 0x0020, 0x006f, 0x0062, 0x0020, 0x0064, 0x0069, 0x0065, 0x0020, + 0x006e, 0x00f6, 0x0074, 0x0069, 0x0067, 0x0065, 0x006e, 0x0020, 0x0054, 0x0072, 0x0065, 0x0069, 0x0062, 0x0065, 0x0072, 0x0020, + 0x006b, 0x006f, 0x0072, 0x0072, 0x0065, 0x006b, 0x0074, 0x0020, 0x0065, 0x0069, 0x006e, 0x0067, 0x0065, 0x0073, 0x0074, 0x0065, + 0x006c, 0x006c, 0x0074, 0x0020, 0x0073, 0x0069, 0x006e, 0x0064, 0x0020, 0x0075, 0x006e, 0x0064, 0x0020, 0x006f, 0x0062, 0x0020, + 0x0064, 0x0069, 0x0065, 0x0020, 0x004b, 0x0061, 0x0072, 0x0074, 0x0065, 0x0020, 0x006b, 0x006f, 0x0072, 0x0072, 0x0065, 0x006b, + 0x0074, 0x0020, 0x0065, 0x0069, 0x006e, 0x0067, 0x0065, 0x0073, 0x0074, 0x0065, 0x006c, 0x006c, 0x0074, 0x0020, 0x0069, 0x0073, + 0x0074, 0x002e, +// 49 +// Eine Soundkarte zur Ausgabe von Geräuschen wurde gefunden. Es wird jetzt ein Sample abgespielt. + 0x005f, + 0x0045, 0x0069, 0x006e, 0x0065, 0x0020, 0x0053, 0x006f, 0x0075, 0x006e, 0x0064, 0x006b, 0x0061, 0x0072, 0x0074, 0x0065, 0x0020, + 0x007a, 0x0075, 0x0072, 0x0020, 0x0041, 0x0075, 0x0073, 0x0067, 0x0061, 0x0062, 0x0065, 0x0020, 0x0076, 0x006f, 0x006e, 0x0020, + 0x0047, 0x0065, 0x0072, 0x00e4, 0x0075, 0x0073, 0x0063, 0x0068, 0x0065, 0x006e, 0x0020, 0x0077, 0x0075, 0x0072, 0x0064, 0x0065, + 0x0020, 0x0067, 0x0065, 0x0066, 0x0075, 0x006e, 0x0064, 0x0065, 0x006e, 0x002e, 0x0020, 0x0045, 0x0073, 0x0020, 0x0077, 0x0069, + 0x0072, 0x0064, 0x0020, 0x006a, 0x0065, 0x0074, 0x007a, 0x0074, 0x0020, 0x0065, 0x0069, 0x006e, 0x0020, 0x0053, 0x0061, 0x006d, + 0x0070, 0x006c, 0x0065, 0x0020, 0x0061, 0x0062, 0x0067, 0x0065, 0x0073, 0x0070, 0x0069, 0x0065, 0x006c, 0x0074, 0x002e, +// 50 +// Der Eintrag SDIPATH im File SDI.INI ist nicht korrekt gesetzt. Dieser Eintrag muß auf das Verzeichnis zeigen, in dem BATTLE ISLE 3 installiert ist. Installieren Sie BATTLE ISLE 3 neu! + 0x00b7, + 0x0044, 0x0065, 0x0072, 0x0020, 0x0045, 0x0069, 0x006e, 0x0074, 0x0072, 0x0061, 0x0067, 0x0020, 0x0053, 0x0044, 0x0049, 0x0050, + 0x0041, 0x0054, 0x0048, 0x0020, 0x0069, 0x006d, 0x0020, 0x0046, 0x0069, 0x006c, 0x0065, 0x0020, 0x0053, 0x0044, 0x0049, 0x002e, + 0x0049, 0x004e, 0x0049, 0x0020, 0x0069, 0x0073, 0x0074, 0x0020, 0x006e, 0x0069, 0x0063, 0x0068, 0x0074, 0x0020, 0x006b, 0x006f, + 0x0072, 0x0072, 0x0065, 0x006b, 0x0074, 0x0020, 0x0067, 0x0065, 0x0073, 0x0065, 0x0074, 0x007a, 0x0074, 0x002e, 0x0020, 0x0044, + 0x0069, 0x0065, 0x0073, 0x0065, 0x0072, 0x0020, 0x0045, 0x0069, 0x006e, 0x0074, 0x0072, 0x0061, 0x0067, 0x0020, 0x006d, 0x0075, + 0x00df, 0x0020, 0x0061, 0x0075, 0x0066, 0x0020, 0x0064, 0x0061, 0x0073, 0x0020, 0x0056, 0x0065, 0x0072, 0x007a, 0x0065, 0x0069, + 0x0063, 0x0068, 0x006e, 0x0069, 0x0073, 0x0020, 0x007a, 0x0065, 0x0069, 0x0067, 0x0065, 0x006e, 0x002c, 0x0020, 0x0069, 0x006e, + 0x0020, 0x0064, 0x0065, 0x006d, 0x0020, 0x0042, 0x0041, 0x0054, 0x0054, 0x004c, 0x0045, 0x0020, 0x0049, 0x0053, 0x004c, 0x0045, + 0x0020, 0x0033, 0x0020, 0x0069, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, 0x006c, 0x0069, 0x0065, 0x0072, 0x0074, 0x0020, 0x0069, + 0x0073, 0x0074, 0x002e, 0x0020, 0x0049, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, 0x006c, 0x0069, 0x0065, 0x0072, 0x0065, 0x006e, + 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0042, 0x0041, 0x0054, 0x0054, 0x004c, 0x0045, 0x0020, 0x0049, 0x0053, 0x004c, 0x0045, + 0x0020, 0x0033, 0x0020, 0x006e, 0x0065, 0x0075, 0x0021, +// 51 +// Das Directory, das im Eintrag SDIPATH im File SDI.INI eingetragen ist, konnte nicht zum aktuellen Directory gemacht werden. Der Eintrag muß das Directory enthalten, in dem BATTLE ISLE 3 installiert ist. Installieren Sie das Programm neu. + 0x00ed, + 0x0044, 0x0061, 0x0073, 0x0020, 0x0044, 0x0069, 0x0072, 0x0065, 0x0063, 0x0074, 0x006f, 0x0072, 0x0079, 0x002c, 0x0020, 0x0064, + 0x0061, 0x0073, 0x0020, 0x0069, 0x006d, 0x0020, 0x0045, 0x0069, 0x006e, 0x0074, 0x0072, 0x0061, 0x0067, 0x0020, 0x0053, 0x0044, + 0x0049, 0x0050, 0x0041, 0x0054, 0x0048, 0x0020, 0x0069, 0x006d, 0x0020, 0x0046, 0x0069, 0x006c, 0x0065, 0x0020, 0x0053, 0x0044, + 0x0049, 0x002e, 0x0049, 0x004e, 0x0049, 0x0020, 0x0065, 0x0069, 0x006e, 0x0067, 0x0065, 0x0074, 0x0072, 0x0061, 0x0067, 0x0065, + 0x006e, 0x0020, 0x0069, 0x0073, 0x0074, 0x002c, 0x0020, 0x006b, 0x006f, 0x006e, 0x006e, 0x0074, 0x0065, 0x0020, 0x006e, 0x0069, + 0x0063, 0x0068, 0x0074, 0x0020, 0x007a, 0x0075, 0x006d, 0x0020, 0x0061, 0x006b, 0x0074, 0x0075, 0x0065, 0x006c, 0x006c, 0x0065, + 0x006e, 0x0020, 0x0044, 0x0069, 0x0072, 0x0065, 0x0063, 0x0074, 0x006f, 0x0072, 0x0079, 0x0020, 0x0067, 0x0065, 0x006d, 0x0061, + 0x0063, 0x0068, 0x0074, 0x0020, 0x0077, 0x0065, 0x0072, 0x0064, 0x0065, 0x006e, 0x002e, 0x0020, 0x0044, 0x0065, 0x0072, 0x0020, + 0x0045, 0x0069, 0x006e, 0x0074, 0x0072, 0x0061, 0x0067, 0x0020, 0x006d, 0x0075, 0x00df, 0x0020, 0x0064, 0x0061, 0x0073, 0x0020, + 0x0044, 0x0069, 0x0072, 0x0065, 0x0063, 0x0074, 0x006f, 0x0072, 0x0079, 0x0020, 0x0065, 0x006e, 0x0074, 0x0068, 0x0061, 0x006c, + 0x0074, 0x0065, 0x006e, 0x002c, 0x0020, 0x0069, 0x006e, 0x0020, 0x0064, 0x0065, 0x006d, 0x0020, 0x0042, 0x0041, 0x0054, 0x0054, + 0x004c, 0x0045, 0x0020, 0x0049, 0x0053, 0x004c, 0x0045, 0x0020, 0x0033, 0x0020, 0x0069, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, + 0x006c, 0x0069, 0x0065, 0x0072, 0x0074, 0x0020, 0x0069, 0x0073, 0x0074, 0x002e, 0x0020, 0x0049, 0x006e, 0x0073, 0x0074, 0x0061, + 0x006c, 0x006c, 0x0069, 0x0065, 0x0072, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0064, 0x0061, 0x0073, 0x0020, + 0x0050, 0x0072, 0x006f, 0x0067, 0x0072, 0x0061, 0x006d, 0x006d, 0x0020, 0x006e, 0x0065, 0x0075, 0x002e, +// 52 +// Ihr Videotreiber meldet folgende Bildeinstellungen:\nBildbreite:%d\nBildhöhe:%d\nAnzahl Farben:%d\nSollten diese Werte nicht korrekt sein, versuchen Sie beim Hersteller Ihrer Graphikkarte einen neueren Treiber zu bekommen. + 0x00da, + 0x0049, 0x0068, 0x0072, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0074, 0x0072, 0x0065, 0x0069, 0x0062, 0x0065, 0x0072, + 0x0020, 0x006d, 0x0065, 0x006c, 0x0064, 0x0065, 0x0074, 0x0020, 0x0066, 0x006f, 0x006c, 0x0067, 0x0065, 0x006e, 0x0064, 0x0065, + 0x0020, 0x0042, 0x0069, 0x006c, 0x0064, 0x0065, 0x0069, 0x006e, 0x0073, 0x0074, 0x0065, 0x006c, 0x006c, 0x0075, 0x006e, 0x0067, + 0x0065, 0x006e, 0x003a, 0x000a, 0x0042, 0x0069, 0x006c, 0x0064, 0x0062, 0x0072, 0x0065, 0x0069, 0x0074, 0x0065, 0x003a, 0x0025, + 0x0064, 0x000a, 0x0042, 0x0069, 0x006c, 0x0064, 0x0068, 0x00f6, 0x0068, 0x0065, 0x003a, 0x0025, 0x0064, 0x000a, 0x0041, 0x006e, + 0x007a, 0x0061, 0x0068, 0x006c, 0x0020, 0x0046, 0x0061, 0x0072, 0x0062, 0x0065, 0x006e, 0x003a, 0x0025, 0x0064, 0x000a, 0x0053, + 0x006f, 0x006c, 0x006c, 0x0074, 0x0065, 0x006e, 0x0020, 0x0064, 0x0069, 0x0065, 0x0073, 0x0065, 0x0020, 0x0057, 0x0065, 0x0072, + 0x0074, 0x0065, 0x0020, 0x006e, 0x0069, 0x0063, 0x0068, 0x0074, 0x0020, 0x006b, 0x006f, 0x0072, 0x0072, 0x0065, 0x006b, 0x0074, + 0x0020, 0x0073, 0x0065, 0x0069, 0x006e, 0x002c, 0x0020, 0x0076, 0x0065, 0x0072, 0x0073, 0x0075, 0x0063, 0x0068, 0x0065, 0x006e, + 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0062, 0x0065, 0x0069, 0x006d, 0x0020, 0x0048, 0x0065, 0x0072, 0x0073, 0x0074, 0x0065, + 0x006c, 0x006c, 0x0065, 0x0072, 0x0020, 0x0049, 0x0068, 0x0072, 0x0065, 0x0072, 0x0020, 0x0047, 0x0072, 0x0061, 0x0070, 0x0068, + 0x0069, 0x006b, 0x006b, 0x0061, 0x0072, 0x0074, 0x0065, 0x0020, 0x0065, 0x0069, 0x006e, 0x0065, 0x006e, 0x0020, 0x006e, 0x0065, + 0x0075, 0x0065, 0x0072, 0x0065, 0x006e, 0x0020, 0x0054, 0x0072, 0x0065, 0x0069, 0x0062, 0x0065, 0x0072, 0x0020, 0x007a, 0x0075, + 0x0020, 0x0062, 0x0065, 0x006b, 0x006f, 0x006d, 0x006d, 0x0065, 0x006e, 0x002e, +// 53 +// Sie benutzen immer noch Windows 3.11 . Es wäre besser, wenn Sie Ihr System auf Windows 95 oder Windows NT updaten, da diese System mehr Leistung bieten und generell stabiler und problemloser laufen. + 0x00c6, + 0x0053, 0x0069, 0x0065, 0x0020, 0x0062, 0x0065, 0x006e, 0x0075, 0x0074, 0x007a, 0x0065, 0x006e, 0x0020, 0x0069, 0x006d, 0x006d, + 0x0065, 0x0072, 0x0020, 0x006e, 0x006f, 0x0063, 0x0068, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, + 0x0033, 0x002e, 0x0031, 0x0031, 0x0020, 0x002e, 0x0020, 0x0045, 0x0073, 0x0020, 0x0077, 0x00e4, 0x0072, 0x0065, 0x0020, 0x0062, + 0x0065, 0x0073, 0x0073, 0x0065, 0x0072, 0x002c, 0x0020, 0x0077, 0x0065, 0x006e, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, + 0x0049, 0x0068, 0x0072, 0x0020, 0x0053, 0x0079, 0x0073, 0x0074, 0x0065, 0x006d, 0x0020, 0x0061, 0x0075, 0x0066, 0x0020, 0x0057, + 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0039, 0x0035, 0x0020, 0x006f, 0x0064, 0x0065, 0x0072, 0x0020, 0x0057, + 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x004e, 0x0054, 0x0020, 0x0075, 0x0070, 0x0064, 0x0061, 0x0074, 0x0065, + 0x006e, 0x002c, 0x0020, 0x0064, 0x0061, 0x0020, 0x0064, 0x0069, 0x0065, 0x0073, 0x0065, 0x0020, 0x0053, 0x0079, 0x0073, 0x0074, + 0x0065, 0x006d, 0x0020, 0x006d, 0x0065, 0x0068, 0x0072, 0x0020, 0x004c, 0x0065, 0x0069, 0x0073, 0x0074, 0x0075, 0x006e, 0x0067, + 0x0020, 0x0062, 0x0069, 0x0065, 0x0074, 0x0065, 0x006e, 0x0020, 0x0075, 0x006e, 0x0064, 0x0020, 0x0067, 0x0065, 0x006e, 0x0065, + 0x0072, 0x0065, 0x006c, 0x006c, 0x0020, 0x0073, 0x0074, 0x0061, 0x0062, 0x0069, 0x006c, 0x0065, 0x0072, 0x0020, 0x0075, 0x006e, + 0x0064, 0x0020, 0x0070, 0x0072, 0x006f, 0x0062, 0x006c, 0x0065, 0x006d, 0x006c, 0x006f, 0x0073, 0x0065, 0x0072, 0x0020, 0x006c, + 0x0061, 0x0075, 0x0066, 0x0065, 0x006e, 0x002e, +// 54 +// Verlief der Test soeben ohne Fehlermeldung? + 0x002b, + 0x0056, 0x0065, 0x0072, 0x006c, 0x0069, 0x0065, 0x0066, 0x0020, 0x0064, 0x0065, 0x0072, 0x0020, 0x0054, 0x0065, 0x0073, 0x0074, + 0x0020, 0x0073, 0x006f, 0x0065, 0x0062, 0x0065, 0x006e, 0x0020, 0x006f, 0x0068, 0x006e, 0x0065, 0x0020, 0x0046, 0x0065, 0x0068, + 0x006c, 0x0065, 0x0072, 0x006d, 0x0065, 0x006c, 0x0064, 0x0075, 0x006e, 0x0067, 0x003f, +// 55 +// Konnten Sie das Sample hören? + 0x001d, + 0x004b, 0x006f, 0x006e, 0x006e, 0x0074, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0064, 0x0061, 0x0073, 0x0020, + 0x0053, 0x0061, 0x006d, 0x0070, 0x006c, 0x0065, 0x0020, 0x0068, 0x00f6, 0x0072, 0x0065, 0x006e, 0x003f, +// 56 +// Können Sie die Musik hören? + 0x001b, + 0x004b, 0x00f6, 0x006e, 0x006e, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0064, 0x0069, 0x0065, 0x0020, 0x004d, + 0x0075, 0x0073, 0x0069, 0x006b, 0x0020, 0x0068, 0x00f6, 0x0072, 0x0065, 0x006e, 0x003f, +// 57 +// Battle Isle 3 kann jetzt VIDEO FÜR WINDOWS 1.1e installieren.\n\nLESEN SIE VORHER UNBEDINGT DAS TECHNISCHE BEGLEITHEFT !!!!!!\n\nWollen Sie VFW 1.1e tatsächlich installieren? + 0x00aa, + 0x0042, 0x0061, 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x0020, 0x0033, 0x0020, 0x006b, 0x0061, + 0x006e, 0x006e, 0x0020, 0x006a, 0x0065, 0x0074, 0x007a, 0x0074, 0x0020, 0x0056, 0x0049, 0x0044, 0x0045, 0x004f, 0x0020, 0x0046, + 0x00dc, 0x0052, 0x0020, 0x0057, 0x0049, 0x004e, 0x0044, 0x004f, 0x0057, 0x0053, 0x0020, 0x0031, 0x002e, 0x0031, 0x0065, 0x0020, + 0x0069, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, 0x006c, 0x0069, 0x0065, 0x0072, 0x0065, 0x006e, 0x002e, 0x000a, 0x000a, 0x004c, + 0x0045, 0x0053, 0x0045, 0x004e, 0x0020, 0x0053, 0x0049, 0x0045, 0x0020, 0x0056, 0x004f, 0x0052, 0x0048, 0x0045, 0x0052, 0x0020, + 0x0055, 0x004e, 0x0042, 0x0045, 0x0044, 0x0049, 0x004e, 0x0047, 0x0054, 0x0020, 0x0044, 0x0041, 0x0053, 0x0020, 0x0054, 0x0045, + 0x0043, 0x0048, 0x004e, 0x0049, 0x0053, 0x0043, 0x0048, 0x0045, 0x0020, 0x0042, 0x0045, 0x0047, 0x004c, 0x0045, 0x0049, 0x0054, + 0x0048, 0x0045, 0x0046, 0x0054, 0x0020, 0x0021, 0x0021, 0x0021, 0x0021, 0x0021, 0x0021, 0x000a, 0x000a, 0x0057, 0x006f, 0x006c, + 0x006c, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, 0x0056, 0x0046, 0x0057, 0x0020, 0x0031, 0x002e, 0x0031, 0x0065, + 0x0020, 0x0074, 0x0061, 0x0074, 0x0073, 0x00e4, 0x0063, 0x0068, 0x006c, 0x0069, 0x0063, 0x0068, 0x0020, 0x0069, 0x006e, 0x0073, + 0x0074, 0x0061, 0x006c, 0x006c, 0x0069, 0x0065, 0x0072, 0x0065, 0x006e, 0x003f, +// 58 +// Während des Spieles trat ein Absturz in einer Videosequenz auf. Offensichtlich enthalten Ihre Videotreiber doch Fehler. Die Funktion, die den Fehler verursachte wird ab jetzt vermieden, allerdings leidet darunter die Qualität der Videos. + 0x00ed, + 0x0057, 0x00e4, 0x0068, 0x0072, 0x0065, 0x006e, 0x0064, 0x0020, 0x0064, 0x0065, 0x0073, 0x0020, 0x0053, 0x0070, 0x0069, 0x0065, + 0x006c, 0x0065, 0x0073, 0x0020, 0x0074, 0x0072, 0x0061, 0x0074, 0x0020, 0x0065, 0x0069, 0x006e, 0x0020, 0x0041, 0x0062, 0x0073, + 0x0074, 0x0075, 0x0072, 0x007a, 0x0020, 0x0069, 0x006e, 0x0020, 0x0065, 0x0069, 0x006e, 0x0065, 0x0072, 0x0020, 0x0056, 0x0069, + 0x0064, 0x0065, 0x006f, 0x0073, 0x0065, 0x0071, 0x0075, 0x0065, 0x006e, 0x007a, 0x0020, 0x0061, 0x0075, 0x0066, 0x002e, 0x0020, + 0x004f, 0x0066, 0x0066, 0x0065, 0x006e, 0x0073, 0x0069, 0x0063, 0x0068, 0x0074, 0x006c, 0x0069, 0x0063, 0x0068, 0x0020, 0x0065, + 0x006e, 0x0074, 0x0068, 0x0061, 0x006c, 0x0074, 0x0065, 0x006e, 0x0020, 0x0049, 0x0068, 0x0072, 0x0065, 0x0020, 0x0056, 0x0069, + 0x0064, 0x0065, 0x006f, 0x0074, 0x0072, 0x0065, 0x0069, 0x0062, 0x0065, 0x0072, 0x0020, 0x0064, 0x006f, 0x0063, 0x0068, 0x0020, + 0x0046, 0x0065, 0x0068, 0x006c, 0x0065, 0x0072, 0x002e, 0x0020, 0x0044, 0x0069, 0x0065, 0x0020, 0x0046, 0x0075, 0x006e, 0x006b, + 0x0074, 0x0069, 0x006f, 0x006e, 0x002c, 0x0020, 0x0064, 0x0069, 0x0065, 0x0020, 0x0064, 0x0065, 0x006e, 0x0020, 0x0046, 0x0065, + 0x0068, 0x006c, 0x0065, 0x0072, 0x0020, 0x0076, 0x0065, 0x0072, 0x0075, 0x0072, 0x0073, 0x0061, 0x0063, 0x0068, 0x0074, 0x0065, + 0x0020, 0x0077, 0x0069, 0x0072, 0x0064, 0x0020, 0x0061, 0x0062, 0x0020, 0x006a, 0x0065, 0x0074, 0x007a, 0x0074, 0x0020, 0x0076, + 0x0065, 0x0072, 0x006d, 0x0069, 0x0065, 0x0064, 0x0065, 0x006e, 0x002c, 0x0020, 0x0061, 0x006c, 0x006c, 0x0065, 0x0072, 0x0064, + 0x0069, 0x006e, 0x0067, 0x0073, 0x0020, 0x006c, 0x0065, 0x0069, 0x0064, 0x0065, 0x0074, 0x0020, 0x0064, 0x0061, 0x0072, 0x0075, + 0x006e, 0x0074, 0x0065, 0x0072, 0x0020, 0x0064, 0x0069, 0x0065, 0x0020, 0x0051, 0x0075, 0x0061, 0x006c, 0x0069, 0x0074, 0x00e4, + 0x0074, 0x0020, 0x0064, 0x0065, 0x0072, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x002e, +// 59 +// Während des Spieles trat ein Absturz in einer Videosequenz auf. In Zukunft wird nicht mehr versucht,Videos abzuspielen.Wenden Sie sich wegen neuer Treiber an den Hersteller Ihrer Videokarte. + 0x00bf, + 0x0057, 0x00e4, 0x0068, 0x0072, 0x0065, 0x006e, 0x0064, 0x0020, 0x0064, 0x0065, 0x0073, 0x0020, 0x0053, 0x0070, 0x0069, 0x0065, + 0x006c, 0x0065, 0x0073, 0x0020, 0x0074, 0x0072, 0x0061, 0x0074, 0x0020, 0x0065, 0x0069, 0x006e, 0x0020, 0x0041, 0x0062, 0x0073, + 0x0074, 0x0075, 0x0072, 0x007a, 0x0020, 0x0069, 0x006e, 0x0020, 0x0065, 0x0069, 0x006e, 0x0065, 0x0072, 0x0020, 0x0056, 0x0069, + 0x0064, 0x0065, 0x006f, 0x0073, 0x0065, 0x0071, 0x0075, 0x0065, 0x006e, 0x007a, 0x0020, 0x0061, 0x0075, 0x0066, 0x002e, 0x0020, + 0x0049, 0x006e, 0x0020, 0x005a, 0x0075, 0x006b, 0x0075, 0x006e, 0x0066, 0x0074, 0x0020, 0x0077, 0x0069, 0x0072, 0x0064, 0x0020, + 0x006e, 0x0069, 0x0063, 0x0068, 0x0074, 0x0020, 0x006d, 0x0065, 0x0068, 0x0072, 0x0020, 0x0076, 0x0065, 0x0072, 0x0073, 0x0075, + 0x0063, 0x0068, 0x0074, 0x002c, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x0020, 0x0061, 0x0062, 0x007a, 0x0075, 0x0073, + 0x0070, 0x0069, 0x0065, 0x006c, 0x0065, 0x006e, 0x002e, 0x0057, 0x0065, 0x006e, 0x0064, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, + 0x0065, 0x0020, 0x0073, 0x0069, 0x0063, 0x0068, 0x0020, 0x0077, 0x0065, 0x0067, 0x0065, 0x006e, 0x0020, 0x006e, 0x0065, 0x0075, + 0x0065, 0x0072, 0x0020, 0x0054, 0x0072, 0x0065, 0x0069, 0x0062, 0x0065, 0x0072, 0x0020, 0x0061, 0x006e, 0x0020, 0x0064, 0x0065, + 0x006e, 0x0020, 0x0048, 0x0065, 0x0072, 0x0073, 0x0074, 0x0065, 0x006c, 0x006c, 0x0065, 0x0072, 0x0020, 0x0049, 0x0068, 0x0072, + 0x0065, 0x0072, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x006b, 0x0061, 0x0072, 0x0074, 0x0065, 0x002e, 0x0020, +// 60 +// Bitte legen Sie die erste BATTLE ISLE 3 CD in Ihr CD-ROM Laufwerk ! + 0x0043, + 0x0042, 0x0069, 0x0074, 0x0074, 0x0065, 0x0020, 0x006c, 0x0065, 0x0067, 0x0065, 0x006e, 0x0020, 0x0053, 0x0069, 0x0065, 0x0020, + 0x0064, 0x0069, 0x0065, 0x0020, 0x0065, 0x0072, 0x0073, 0x0074, 0x0065, 0x0020, 0x0042, 0x0041, 0x0054, 0x0054, 0x004c, 0x0045, + 0x0020, 0x0049, 0x0053, 0x004c, 0x0045, 0x0020, 0x0033, 0x0020, 0x0043, 0x0044, 0x0020, 0x0069, 0x006e, 0x0020, 0x0049, 0x0068, + 0x0072, 0x0020, 0x0043, 0x0044, 0x002d, 0x0052, 0x004f, 0x004d, 0x0020, 0x004c, 0x0061, 0x0075, 0x0066, 0x0077, 0x0065, 0x0072, + 0x006b, 0x0020, 0x0021, +// 61 +// Während des letzten Videoabspielens trat ein Fehler auf.Offenbar ist Ihr Videotreiber defekt. Soll das Abspielen von Videos abgeschaltet werden, um weitere Abstürze zu vermeiden? + 0x00b2, + 0x0057, 0x00e4, 0x0068, 0x0072, 0x0065, 0x006e, 0x0064, 0x0020, 0x0064, 0x0065, 0x0073, 0x0020, 0x006c, 0x0065, 0x0074, 0x007a, + 0x0074, 0x0065, 0x006e, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0061, 0x0062, 0x0073, 0x0070, 0x0069, 0x0065, 0x006c, + 0x0065, 0x006e, 0x0073, 0x0020, 0x0074, 0x0072, 0x0061, 0x0074, 0x0020, 0x0065, 0x0069, 0x006e, 0x0020, 0x0046, 0x0065, 0x0068, + 0x006c, 0x0065, 0x0072, 0x0020, 0x0061, 0x0075, 0x0066, 0x002e, 0x004f, 0x0066, 0x0066, 0x0065, 0x006e, 0x0062, 0x0061, 0x0072, + 0x0020, 0x0069, 0x0073, 0x0074, 0x0020, 0x0049, 0x0068, 0x0072, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0074, 0x0072, + 0x0065, 0x0069, 0x0062, 0x0065, 0x0072, 0x0020, 0x0064, 0x0065, 0x0066, 0x0065, 0x006b, 0x0074, 0x002e, 0x0020, 0x0053, 0x006f, + 0x006c, 0x006c, 0x0020, 0x0064, 0x0061, 0x0073, 0x0020, 0x0041, 0x0062, 0x0073, 0x0070, 0x0069, 0x0065, 0x006c, 0x0065, 0x006e, + 0x0020, 0x0076, 0x006f, 0x006e, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x0020, 0x0061, 0x0062, 0x0067, 0x0065, + 0x0073, 0x0063, 0x0068, 0x0061, 0x006c, 0x0074, 0x0065, 0x0074, 0x0020, 0x0077, 0x0065, 0x0072, 0x0064, 0x0065, 0x006e, 0x002c, + 0x0020, 0x0075, 0x006d, 0x0020, 0x0077, 0x0065, 0x0069, 0x0074, 0x0065, 0x0072, 0x0065, 0x0020, 0x0041, 0x0062, 0x0073, 0x0074, + 0x00fc, 0x0072, 0x007a, 0x0065, 0x0020, 0x007a, 0x0075, 0x0020, 0x0076, 0x0065, 0x0072, 0x006d, 0x0065, 0x0069, 0x0064, 0x0065, + 0x006e, 0x003f, +// 62 +// BATTLE ISLE 3 ist bereit und erwartet Ihre Befehle! + 0x0033, + 0x0042, 0x0041, 0x0054, 0x0054, 0x004c, 0x0045, 0x0020, 0x0049, 0x0053, 0x004c, 0x0045, 0x0020, 0x0033, 0x0020, 0x0069, 0x0073, + 0x0074, 0x0020, 0x0062, 0x0065, 0x0072, 0x0065, 0x0069, 0x0074, 0x0020, 0x0075, 0x006e, 0x0064, 0x0020, 0x0065, 0x0072, 0x0077, + 0x0061, 0x0072, 0x0074, 0x0065, 0x0074, 0x0020, 0x0049, 0x0068, 0x0072, 0x0065, 0x0020, 0x0042, 0x0065, 0x0066, 0x0065, 0x0068, + 0x006c, 0x0065, 0x0021, +// 63 +// Diese Demo enthält keinerlei Videosequenzen oder Animationen! Sie können keinen Spielstand laden oder speichern.\n\nDie Vollversion wird auf 2 CDs mit insgesamt ca. 1 Gigabyte Videosequenzen und 40 Karten ausgeliefert. + 0x00d8, + 0x0044, 0x0069, 0x0065, 0x0073, 0x0065, 0x0020, 0x0044, 0x0065, 0x006d, 0x006f, 0x0020, 0x0065, 0x006e, 0x0074, 0x0068, 0x00e4, + 0x006c, 0x0074, 0x0020, 0x006b, 0x0065, 0x0069, 0x006e, 0x0065, 0x0072, 0x006c, 0x0065, 0x0069, 0x0020, 0x0056, 0x0069, 0x0064, + 0x0065, 0x006f, 0x0073, 0x0065, 0x0071, 0x0075, 0x0065, 0x006e, 0x007a, 0x0065, 0x006e, 0x0020, 0x006f, 0x0064, 0x0065, 0x0072, + 0x0020, 0x0041, 0x006e, 0x0069, 0x006d, 0x0061, 0x0074, 0x0069, 0x006f, 0x006e, 0x0065, 0x006e, 0x0021, 0x0020, 0x0053, 0x0069, + 0x0065, 0x0020, 0x006b, 0x00f6, 0x006e, 0x006e, 0x0065, 0x006e, 0x0020, 0x006b, 0x0065, 0x0069, 0x006e, 0x0065, 0x006e, 0x0020, + 0x0053, 0x0070, 0x0069, 0x0065, 0x006c, 0x0073, 0x0074, 0x0061, 0x006e, 0x0064, 0x0020, 0x006c, 0x0061, 0x0064, 0x0065, 0x006e, + 0x0020, 0x006f, 0x0064, 0x0065, 0x0072, 0x0020, 0x0073, 0x0070, 0x0065, 0x0069, 0x0063, 0x0068, 0x0065, 0x0072, 0x006e, 0x002e, + 0x000a, 0x000a, 0x0044, 0x0069, 0x0065, 0x0020, 0x0056, 0x006f, 0x006c, 0x006c, 0x0076, 0x0065, 0x0072, 0x0073, 0x0069, 0x006f, + 0x006e, 0x0020, 0x0077, 0x0069, 0x0072, 0x0064, 0x0020, 0x0061, 0x0075, 0x0066, 0x0020, 0x0032, 0x0020, 0x0043, 0x0044, 0x0073, + 0x0020, 0x006d, 0x0069, 0x0074, 0x0020, 0x0069, 0x006e, 0x0073, 0x0067, 0x0065, 0x0073, 0x0061, 0x006d, 0x0074, 0x0020, 0x0063, + 0x0061, 0x002e, 0x0020, 0x0031, 0x0020, 0x0047, 0x0069, 0x0067, 0x0061, 0x0062, 0x0079, 0x0074, 0x0065, 0x0020, 0x0056, 0x0069, + 0x0064, 0x0065, 0x006f, 0x0073, 0x0065, 0x0071, 0x0075, 0x0065, 0x006e, 0x007a, 0x0065, 0x006e, 0x0020, 0x0075, 0x006e, 0x0064, + 0x0020, 0x0034, 0x0030, 0x0020, 0x004b, 0x0061, 0x0072, 0x0074, 0x0065, 0x006e, 0x0020, 0x0061, 0x0075, 0x0073, 0x0067, 0x0065, + 0x006c, 0x0069, 0x0065, 0x0066, 0x0065, 0x0072, 0x0074, 0x002e, +}; + +static const WCHAR AppStringData_5[32] = { +// 64 +// a + 0x0001, + 0x0061, +// 65 +// a + 0x0001, + 0x0061, +// 66 +// a + 0x0001, + 0x0061, +// 67 +// a + 0x0001, + 0x0061, +// 68 +// a + 0x0001, + 0x0061, +// 69 +// a + 0x0001, + 0x0061, +// 70 +// a + 0x0001, + 0x0061, +// 71 +// a + 0x0001, + 0x0061, +// 72 +// a + 0x0001, + 0x0061, +// 73 +// a + 0x0001, + 0x0061, +// 74 +// a + 0x0001, + 0x0061, +// 75 +// a + 0x0001, + 0x0061, +// 76 +// a + 0x0001, + 0x0061, +// 77 +// a + 0x0001, + 0x0061, +// 78 +// a + 0x0001, + 0x0061, +// 79 +// a + 0x0001, + 0x0061, +}; + +static const WCHAR AppStringData_6[32] = { +// 80 +// a + 0x0001, + 0x0061, +// 81 +// a + 0x0001, + 0x0061, +// 82 +// a + 0x0001, + 0x0061, +// 83 +// a + 0x0001, + 0x0061, +// 84 +// a + 0x0001, + 0x0061, +// 85 +// a + 0x0001, + 0x0061, +// 86 +// a + 0x0001, + 0x0061, +// 87 +// a + 0x0001, + 0x0061, +// 88 +// a + 0x0001, + 0x0061, +// 89 +// a + 0x0001, + 0x0061, +// 90 +// a + 0x0001, + 0x0061, +// 91 +// a + 0x0001, + 0x0061, +// 92 +// a + 0x0001, + 0x0061, +// 93 +// a + 0x0001, + 0x0061, +// 94 +// a + 0x0001, + 0x0061, +// 95 +// a + 0x0001, + 0x0061, +}; + +static const WCHAR AppStringData_7[1582] = { +// 96 +// a + 0x0001, + 0x0061, +// 97 +// a + 0x0001, + 0x0061, +// 98 +// a + 0x0001, + 0x0061, +// 99 +// a + 0x0001, + 0x0061, +// 100 +// a + 0x0001, + 0x0061, +// 101 +// This is the first time you have started Battle Isle.\n The program will now carry out a series of checks on your computer.\nThis check will only be done once.\n \nPLEASE DO NOT SWITCH THE PROGRAM TO THE BACKGROUND! + 0x00d2, + 0x0054, 0x0068, 0x0069, 0x0073, 0x0020, 0x0069, 0x0073, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0066, 0x0069, 0x0072, 0x0073, + 0x0074, 0x0020, 0x0074, 0x0069, 0x006d, 0x0065, 0x0020, 0x0079, 0x006f, 0x0075, 0x0020, 0x0068, 0x0061, 0x0076, 0x0065, 0x0020, + 0x0073, 0x0074, 0x0061, 0x0072, 0x0074, 0x0065, 0x0064, 0x0020, 0x0042, 0x0061, 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, + 0x0073, 0x006c, 0x0065, 0x002e, 0x000a, 0x0020, 0x0054, 0x0068, 0x0065, 0x0020, 0x0070, 0x0072, 0x006f, 0x0067, 0x0072, 0x0061, + 0x006d, 0x0020, 0x0077, 0x0069, 0x006c, 0x006c, 0x0020, 0x006e, 0x006f, 0x0077, 0x0020, 0x0063, 0x0061, 0x0072, 0x0072, 0x0079, + 0x0020, 0x006f, 0x0075, 0x0074, 0x0020, 0x0061, 0x0020, 0x0073, 0x0065, 0x0072, 0x0069, 0x0065, 0x0073, 0x0020, 0x006f, 0x0066, + 0x0020, 0x0063, 0x0068, 0x0065, 0x0063, 0x006b, 0x0073, 0x0020, 0x006f, 0x006e, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, + 0x0063, 0x006f, 0x006d, 0x0070, 0x0075, 0x0074, 0x0065, 0x0072, 0x002e, 0x000a, 0x0054, 0x0068, 0x0069, 0x0073, 0x0020, 0x0063, + 0x0068, 0x0065, 0x0063, 0x006b, 0x0020, 0x0077, 0x0069, 0x006c, 0x006c, 0x0020, 0x006f, 0x006e, 0x006c, 0x0079, 0x0020, 0x0062, + 0x0065, 0x0020, 0x0064, 0x006f, 0x006e, 0x0065, 0x0020, 0x006f, 0x006e, 0x0063, 0x0065, 0x002e, 0x000a, 0x0020, 0x000a, 0x0050, + 0x004c, 0x0045, 0x0041, 0x0053, 0x0045, 0x0020, 0x0044, 0x004f, 0x0020, 0x004e, 0x004f, 0x0054, 0x0020, 0x0053, 0x0057, 0x0049, + 0x0054, 0x0043, 0x0048, 0x0020, 0x0054, 0x0048, 0x0045, 0x0020, 0x0050, 0x0052, 0x004f, 0x0047, 0x0052, 0x0041, 0x004d, 0x0020, + 0x0054, 0x004f, 0x0020, 0x0054, 0x0048, 0x0045, 0x0020, 0x0042, 0x0041, 0x0043, 0x004b, 0x0047, 0x0052, 0x004f, 0x0055, 0x004e, + 0x0044, 0x0021, +// 102 +// An AVI Video is now being loaded.\nIt may not be possible to access if the video driver is defective (mainly in Windows 3.11), in which case you will see an error message. You may have to start Windows again if your computer does not respond. + 0x00f1, + 0x0041, 0x006e, 0x0020, 0x0041, 0x0056, 0x0049, 0x0020, 0x0056, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0069, 0x0073, 0x0020, + 0x006e, 0x006f, 0x0077, 0x0020, 0x0062, 0x0065, 0x0069, 0x006e, 0x0067, 0x0020, 0x006c, 0x006f, 0x0061, 0x0064, 0x0065, 0x0064, + 0x002e, 0x000a, 0x0049, 0x0074, 0x0020, 0x006d, 0x0061, 0x0079, 0x0020, 0x006e, 0x006f, 0x0074, 0x0020, 0x0062, 0x0065, 0x0020, + 0x0070, 0x006f, 0x0073, 0x0073, 0x0069, 0x0062, 0x006c, 0x0065, 0x0020, 0x0074, 0x006f, 0x0020, 0x0061, 0x0063, 0x0063, 0x0065, + 0x0073, 0x0073, 0x0020, 0x0069, 0x0066, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, + 0x0064, 0x0072, 0x0069, 0x0076, 0x0065, 0x0072, 0x0020, 0x0069, 0x0073, 0x0020, 0x0064, 0x0065, 0x0066, 0x0065, 0x0063, 0x0074, + 0x0069, 0x0076, 0x0065, 0x0020, 0x0028, 0x006d, 0x0061, 0x0069, 0x006e, 0x006c, 0x0079, 0x0020, 0x0069, 0x006e, 0x0020, 0x0057, + 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0033, 0x002e, 0x0031, 0x0031, 0x0029, 0x002c, 0x0020, 0x0069, 0x006e, + 0x0020, 0x0077, 0x0068, 0x0069, 0x0063, 0x0068, 0x0020, 0x0063, 0x0061, 0x0073, 0x0065, 0x0020, 0x0079, 0x006f, 0x0075, 0x0020, + 0x0077, 0x0069, 0x006c, 0x006c, 0x0020, 0x0073, 0x0065, 0x0065, 0x0020, 0x0061, 0x006e, 0x0020, 0x0065, 0x0072, 0x0072, 0x006f, + 0x0072, 0x0020, 0x006d, 0x0065, 0x0073, 0x0073, 0x0061, 0x0067, 0x0065, 0x002e, 0x0020, 0x0059, 0x006f, 0x0075, 0x0020, 0x006d, + 0x0061, 0x0079, 0x0020, 0x0068, 0x0061, 0x0076, 0x0065, 0x0020, 0x0074, 0x006f, 0x0020, 0x0073, 0x0074, 0x0061, 0x0072, 0x0074, + 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0061, 0x0067, 0x0061, 0x0069, 0x006e, 0x0020, 0x0069, + 0x0066, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x0063, 0x006f, 0x006d, 0x0070, 0x0075, 0x0074, 0x0065, 0x0072, 0x0020, + 0x0064, 0x006f, 0x0065, 0x0073, 0x0020, 0x006e, 0x006f, 0x0074, 0x0020, 0x0072, 0x0065, 0x0073, 0x0070, 0x006f, 0x006e, 0x0064, + 0x002e, +// 103 +// File TST.AVI was not found in the Battle Isle Directory on your hard disk.\nCopy the file from your CD (from the BIN Directory) or re-install Battle Isle. + 0x0099, + 0x0046, 0x0069, 0x006c, 0x0065, 0x0020, 0x0054, 0x0053, 0x0054, 0x002e, 0x0041, 0x0056, 0x0049, 0x0020, 0x0077, 0x0061, 0x0073, + 0x0020, 0x006e, 0x006f, 0x0074, 0x0020, 0x0066, 0x006f, 0x0075, 0x006e, 0x0064, 0x0020, 0x0069, 0x006e, 0x0020, 0x0074, 0x0068, + 0x0065, 0x0020, 0x0042, 0x0061, 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x0020, 0x0044, 0x0069, + 0x0072, 0x0065, 0x0063, 0x0074, 0x006f, 0x0072, 0x0079, 0x0020, 0x006f, 0x006e, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, + 0x0068, 0x0061, 0x0072, 0x0064, 0x0020, 0x0064, 0x0069, 0x0073, 0x006b, 0x002e, 0x000a, 0x0043, 0x006f, 0x0070, 0x0079, 0x0020, + 0x0074, 0x0068, 0x0065, 0x0020, 0x0066, 0x0069, 0x006c, 0x0065, 0x0020, 0x0066, 0x0072, 0x006f, 0x006d, 0x0020, 0x0079, 0x006f, + 0x0075, 0x0072, 0x0020, 0x0043, 0x0044, 0x0020, 0x0028, 0x0066, 0x0072, 0x006f, 0x006d, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, + 0x0042, 0x0049, 0x004e, 0x0020, 0x0044, 0x0069, 0x0072, 0x0065, 0x0063, 0x0074, 0x006f, 0x0072, 0x0079, 0x0029, 0x0020, 0x006f, + 0x0072, 0x0020, 0x0072, 0x0065, 0x002d, 0x0069, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, 0x006c, 0x0020, 0x0042, 0x0061, 0x0074, + 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x002e, +// 104 +// Windows has reported the following error:\n\n%s\n\now trying to open the video again and avoid the error. + 0x0065, + 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0068, 0x0061, 0x0073, 0x0020, 0x0072, 0x0065, 0x0070, 0x006f, + 0x0072, 0x0074, 0x0065, 0x0064, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0066, 0x006f, 0x006c, 0x006c, 0x006f, 0x0077, 0x0069, + 0x006e, 0x0067, 0x0020, 0x0065, 0x0072, 0x0072, 0x006f, 0x0072, 0x003a, 0x000a, 0x000a, 0x0025, 0x0073, 0x000a, 0x000a, 0x006f, + 0x0077, 0x0020, 0x0074, 0x0072, 0x0079, 0x0069, 0x006e, 0x0067, 0x0020, 0x0074, 0x006f, 0x0020, 0x006f, 0x0070, 0x0065, 0x006e, + 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0061, 0x0067, 0x0061, 0x0069, 0x006e, + 0x0020, 0x0061, 0x006e, 0x0064, 0x0020, 0x0061, 0x0076, 0x006f, 0x0069, 0x0064, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0065, + 0x0072, 0x0072, 0x006f, 0x0072, 0x002e, +// 105 +// The system could not open the desired window. This indicates insufficient memory or a serious defect in Windows. If necessary, end other programs and start Battle Isle again. + 0x00ae, + 0x0054, 0x0068, 0x0065, 0x0020, 0x0073, 0x0079, 0x0073, 0x0074, 0x0065, 0x006d, 0x0020, 0x0063, 0x006f, 0x0075, 0x006c, 0x0064, + 0x0020, 0x006e, 0x006f, 0x0074, 0x0020, 0x006f, 0x0070, 0x0065, 0x006e, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0064, 0x0065, + 0x0073, 0x0069, 0x0072, 0x0065, 0x0064, 0x0020, 0x0077, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x002e, 0x0020, 0x0054, 0x0068, + 0x0069, 0x0073, 0x0020, 0x0069, 0x006e, 0x0064, 0x0069, 0x0063, 0x0061, 0x0074, 0x0065, 0x0073, 0x0020, 0x0069, 0x006e, 0x0073, + 0x0075, 0x0066, 0x0066, 0x0069, 0x0063, 0x0069, 0x0065, 0x006e, 0x0074, 0x0020, 0x006d, 0x0065, 0x006d, 0x006f, 0x0072, 0x0079, + 0x0020, 0x006f, 0x0072, 0x0020, 0x0061, 0x0020, 0x0073, 0x0065, 0x0072, 0x0069, 0x006f, 0x0075, 0x0073, 0x0020, 0x0064, 0x0065, + 0x0066, 0x0065, 0x0063, 0x0074, 0x0020, 0x0069, 0x006e, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x002e, + 0x0020, 0x0049, 0x0066, 0x0020, 0x006e, 0x0065, 0x0063, 0x0065, 0x0073, 0x0073, 0x0061, 0x0072, 0x0079, 0x002c, 0x0020, 0x0065, + 0x006e, 0x0064, 0x0020, 0x006f, 0x0074, 0x0068, 0x0065, 0x0072, 0x0020, 0x0070, 0x0072, 0x006f, 0x0067, 0x0072, 0x0061, 0x006d, + 0x0073, 0x0020, 0x0061, 0x006e, 0x0064, 0x0020, 0x0073, 0x0074, 0x0061, 0x0072, 0x0074, 0x0020, 0x0042, 0x0061, 0x0074, 0x0074, + 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x0020, 0x0061, 0x0067, 0x0061, 0x0069, 0x006e, 0x002e, +// 106 +// Was not able to open video!\nHave you installed VIDEO FOR WINDOWS 1.1e?\nIf not, please do so, then start BATTLE ISLE SETUP\n.The video has temporarily been turned off. + 0x00a6, + 0x0057, 0x0061, 0x0073, 0x0020, 0x006e, 0x006f, 0x0074, 0x0020, 0x0061, 0x0062, 0x006c, 0x0065, 0x0020, 0x0074, 0x006f, 0x0020, + 0x006f, 0x0070, 0x0065, 0x006e, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0021, 0x000a, 0x0048, 0x0061, 0x0076, 0x0065, + 0x0020, 0x0079, 0x006f, 0x0075, 0x0020, 0x0069, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, 0x006c, 0x0065, 0x0064, 0x0020, 0x0056, + 0x0049, 0x0044, 0x0045, 0x004f, 0x0020, 0x0046, 0x004f, 0x0052, 0x0020, 0x0057, 0x0049, 0x004e, 0x0044, 0x004f, 0x0057, 0x0053, + 0x0020, 0x0031, 0x002e, 0x0031, 0x0065, 0x003f, 0x000a, 0x0049, 0x0066, 0x0020, 0x006e, 0x006f, 0x0074, 0x002c, 0x0020, 0x0070, + 0x006c, 0x0065, 0x0061, 0x0073, 0x0065, 0x0020, 0x0064, 0x006f, 0x0020, 0x0073, 0x006f, 0x002c, 0x0020, 0x0074, 0x0068, 0x0065, + 0x006e, 0x0020, 0x0073, 0x0074, 0x0061, 0x0072, 0x0074, 0x0020, 0x0042, 0x0041, 0x0054, 0x0054, 0x004c, 0x0045, 0x0020, 0x0049, + 0x0053, 0x004c, 0x0045, 0x0020, 0x0020, 0x0053, 0x0045, 0x0054, 0x0055, 0x0050, 0x000a, 0x002e, 0x0054, 0x0068, 0x0065, 0x0020, + 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0068, 0x0061, 0x0073, 0x0020, 0x0074, 0x0065, 0x006d, 0x0070, 0x006f, 0x0072, + 0x0061, 0x0072, 0x0069, 0x006c, 0x0079, 0x0020, 0x0062, 0x0065, 0x0065, 0x006e, 0x0020, 0x0074, 0x0075, 0x0072, 0x006e, 0x0065, + 0x0064, 0x0020, 0x006f, 0x0066, 0x0066, 0x002e, +// 107 +// + 0x0000, +// 108 +// + 0x0000, +// 109 +// This message means that your video card's drivers are defective. Please start Battle Isle again. The test which revealed the error will be omitted.\nPlease obtain new drivers from the manufacturer of your video card. + 0x00d7, + 0x0054, 0x0068, 0x0069, 0x0073, 0x0020, 0x006d, 0x0065, 0x0073, 0x0073, 0x0061, 0x0067, 0x0065, 0x0020, 0x006d, 0x0065, 0x0061, + 0x006e, 0x0073, 0x0020, 0x0074, 0x0068, 0x0061, 0x0074, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x0076, 0x0069, 0x0064, + 0x0065, 0x006f, 0x0020, 0x0063, 0x0061, 0x0072, 0x0064, 0x0027, 0x0073, 0x0020, 0x0064, 0x0072, 0x0069, 0x0076, 0x0065, 0x0072, + 0x0073, 0x0020, 0x0061, 0x0072, 0x0065, 0x0020, 0x0064, 0x0065, 0x0066, 0x0065, 0x0063, 0x0074, 0x0069, 0x0076, 0x0065, 0x002e, + 0x0020, 0x0050, 0x006c, 0x0065, 0x0061, 0x0073, 0x0065, 0x0020, 0x0073, 0x0074, 0x0061, 0x0072, 0x0074, 0x0020, 0x0042, 0x0061, + 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x0020, 0x0061, 0x0067, 0x0061, 0x0069, 0x006e, 0x002e, + 0x0020, 0x0054, 0x0068, 0x0065, 0x0020, 0x0074, 0x0065, 0x0073, 0x0074, 0x0020, 0x0077, 0x0068, 0x0069, 0x0063, 0x0068, 0x0020, + 0x0072, 0x0065, 0x0076, 0x0065, 0x0061, 0x006c, 0x0065, 0x0064, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0065, 0x0072, 0x0072, + 0x006f, 0x0072, 0x0020, 0x0077, 0x0069, 0x006c, 0x006c, 0x0020, 0x0062, 0x0065, 0x0020, 0x006f, 0x006d, 0x0069, 0x0074, 0x0074, + 0x0065, 0x0064, 0x002e, 0x000a, 0x0050, 0x006c, 0x0065, 0x0061, 0x0073, 0x0065, 0x0020, 0x006f, 0x0062, 0x0074, 0x0061, 0x0069, + 0x006e, 0x0020, 0x006e, 0x0065, 0x0077, 0x0020, 0x0064, 0x0072, 0x0069, 0x0076, 0x0065, 0x0072, 0x0073, 0x0020, 0x0066, 0x0072, + 0x006f, 0x006d, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x006d, 0x0061, 0x006e, 0x0075, 0x0066, 0x0061, 0x0063, 0x0074, 0x0075, + 0x0072, 0x0065, 0x0072, 0x0020, 0x006f, 0x0066, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, + 0x006f, 0x0020, 0x0063, 0x0061, 0x0072, 0x0064, 0x002e, +// 110 +// Your video drivers are defective.\n Battle Isle will not try to play videos, so that you can use the program. Please obtain new drivers from the manufacturer of your video cards. + 0x00b1, + 0x0059, 0x006f, 0x0075, 0x0072, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0064, 0x0072, 0x0069, 0x0076, 0x0065, + 0x0072, 0x0073, 0x0020, 0x0061, 0x0072, 0x0065, 0x0020, 0x0064, 0x0065, 0x0066, 0x0065, 0x0063, 0x0074, 0x0069, 0x0076, 0x0065, + 0x002e, 0x000a, 0x0020, 0x0042, 0x0061, 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x0020, 0x0077, + 0x0069, 0x006c, 0x006c, 0x0020, 0x006e, 0x006f, 0x0074, 0x0020, 0x0074, 0x0072, 0x0079, 0x0020, 0x0074, 0x006f, 0x0020, 0x0070, + 0x006c, 0x0061, 0x0079, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x002c, 0x0020, 0x0073, 0x006f, 0x0020, 0x0074, + 0x0068, 0x0061, 0x0074, 0x0020, 0x0079, 0x006f, 0x0075, 0x0020, 0x0063, 0x0061, 0x006e, 0x0020, 0x0075, 0x0073, 0x0065, 0x0020, + 0x0074, 0x0068, 0x0065, 0x0020, 0x0070, 0x0072, 0x006f, 0x0067, 0x0072, 0x0061, 0x006d, 0x002e, 0x0020, 0x0050, 0x006c, 0x0065, + 0x0061, 0x0073, 0x0065, 0x0020, 0x006f, 0x0062, 0x0074, 0x0061, 0x0069, 0x006e, 0x0020, 0x006e, 0x0065, 0x0077, 0x0020, 0x0064, + 0x0072, 0x0069, 0x0076, 0x0065, 0x0072, 0x0073, 0x0020, 0x0066, 0x0072, 0x006f, 0x006d, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, + 0x006d, 0x0061, 0x006e, 0x0075, 0x0066, 0x0061, 0x0063, 0x0074, 0x0075, 0x0072, 0x0065, 0x0072, 0x0020, 0x006f, 0x0066, 0x0020, + 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0063, 0x0061, 0x0072, 0x0064, 0x0073, + 0x002e, +// 111 +// The last time Battle Isle was started, the test video could not be loaded. This will be allowed for during the next attempt. + 0x007c, + 0x0054, 0x0068, 0x0065, 0x0020, 0x006c, 0x0061, 0x0073, 0x0074, 0x0020, 0x0074, 0x0069, 0x006d, 0x0065, 0x0020, 0x0042, 0x0061, + 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x0020, 0x0077, 0x0061, 0x0073, 0x0020, 0x0073, 0x0074, + 0x0061, 0x0072, 0x0074, 0x0065, 0x0064, 0x002c, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0074, 0x0065, 0x0073, 0x0074, 0x0020, + 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0063, 0x006f, 0x0075, 0x006c, 0x0064, 0x0020, 0x006e, 0x006f, 0x0074, 0x0020, + 0x0062, 0x0065, 0x0020, 0x006c, 0x006f, 0x0061, 0x0064, 0x0065, 0x0064, 0x002e, 0x0020, 0x0054, 0x0068, 0x0069, 0x0073, 0x0020, + 0x0077, 0x0069, 0x006c, 0x006c, 0x0020, 0x0062, 0x0065, 0x0020, 0x0061, 0x006c, 0x006c, 0x006f, 0x0077, 0x0065, 0x0064, 0x0020, + 0x0066, 0x006f, 0x0072, 0x0020, 0x0064, 0x0075, 0x0072, 0x0069, 0x006e, 0x0067, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x006e, + 0x0065, 0x0078, 0x0074, 0x0020, 0x0061, 0x0074, 0x0074, 0x0065, 0x006d, 0x0070, 0x0074, 0x002e, +}; + +static const WCHAR AppStringData_8[1863] = { +// 112 +// Windows has reported the following error:\n\n%s\n\nHave you installed VIDEO FOR WINDOWS 1.1e?\nIf not, please do so, then start BATTLE ISLE SETUP\n.The video has temporarily been turned off. + 0x00b8, + 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0068, 0x0061, 0x0073, 0x0020, 0x0072, 0x0065, 0x0070, 0x006f, + 0x0072, 0x0074, 0x0065, 0x0064, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0066, 0x006f, 0x006c, 0x006c, 0x006f, 0x0077, 0x0069, + 0x006e, 0x0067, 0x0020, 0x0065, 0x0072, 0x0072, 0x006f, 0x0072, 0x003a, 0x000a, 0x000a, 0x0025, 0x0073, 0x000a, 0x000a, 0x0048, + 0x0061, 0x0076, 0x0065, 0x0020, 0x0079, 0x006f, 0x0075, 0x0020, 0x0069, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, 0x006c, 0x0065, + 0x0064, 0x0020, 0x0056, 0x0049, 0x0044, 0x0045, 0x004f, 0x0020, 0x0046, 0x004f, 0x0052, 0x0020, 0x0057, 0x0049, 0x004e, 0x0044, + 0x004f, 0x0057, 0x0053, 0x0020, 0x0031, 0x002e, 0x0031, 0x0065, 0x003f, 0x000a, 0x0049, 0x0066, 0x0020, 0x006e, 0x006f, 0x0074, + 0x002c, 0x0020, 0x0070, 0x006c, 0x0065, 0x0061, 0x0073, 0x0065, 0x0020, 0x0064, 0x006f, 0x0020, 0x0073, 0x006f, 0x002c, 0x0020, + 0x0074, 0x0068, 0x0065, 0x006e, 0x0020, 0x0073, 0x0074, 0x0061, 0x0072, 0x0074, 0x0020, 0x0042, 0x0041, 0x0054, 0x0054, 0x004c, + 0x0045, 0x0020, 0x0049, 0x0053, 0x004c, 0x0045, 0x0020, 0x0053, 0x0045, 0x0054, 0x0055, 0x0050, 0x000a, 0x002e, 0x0054, 0x0068, + 0x0065, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0068, 0x0061, 0x0073, 0x0020, 0x0074, 0x0065, 0x006d, 0x0070, + 0x006f, 0x0072, 0x0061, 0x0072, 0x0069, 0x006c, 0x0079, 0x0020, 0x0062, 0x0065, 0x0065, 0x006e, 0x0020, 0x0074, 0x0075, 0x0072, + 0x006e, 0x0065, 0x0064, 0x0020, 0x006f, 0x0066, 0x0066, 0x002e, +// 113 +// Windows has reported the following error:\n\n%s\n\nPlease start Battle Isle again. The program will then omit the instruction which caused the error. + 0x0091, + 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0068, 0x0061, 0x0073, 0x0020, 0x0072, 0x0065, 0x0070, 0x006f, + 0x0072, 0x0074, 0x0065, 0x0064, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0066, 0x006f, 0x006c, 0x006c, 0x006f, 0x0077, 0x0069, + 0x006e, 0x0067, 0x0020, 0x0065, 0x0072, 0x0072, 0x006f, 0x0072, 0x003a, 0x000a, 0x000a, 0x0025, 0x0073, 0x000a, 0x000a, 0x0050, + 0x006c, 0x0065, 0x0061, 0x0073, 0x0065, 0x0020, 0x0073, 0x0074, 0x0061, 0x0072, 0x0074, 0x0020, 0x0042, 0x0061, 0x0074, 0x0074, + 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x0020, 0x0061, 0x0067, 0x0061, 0x0069, 0x006e, 0x002e, 0x0020, 0x0054, + 0x0068, 0x0065, 0x0020, 0x0070, 0x0072, 0x006f, 0x0067, 0x0072, 0x0061, 0x006d, 0x0020, 0x0077, 0x0069, 0x006c, 0x006c, 0x0020, + 0x0074, 0x0068, 0x0065, 0x006e, 0x0020, 0x006f, 0x006d, 0x0069, 0x0074, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0069, 0x006e, + 0x0073, 0x0074, 0x0072, 0x0075, 0x0063, 0x0074, 0x0069, 0x006f, 0x006e, 0x0020, 0x0077, 0x0068, 0x0069, 0x0063, 0x0068, 0x0020, + 0x0063, 0x0061, 0x0075, 0x0073, 0x0065, 0x0064, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0065, 0x0072, 0x0072, 0x006f, 0x0072, + 0x002e, +// 114 +// An AVI video will now be played in various sizes.\nIf the video card drivers are defective, you will see an error message, or your computer will not respond. If this happens, re-start your computer and call up BATTLE ISLE again. + 0x00e3, + 0x0041, 0x006e, 0x0020, 0x0041, 0x0056, 0x0049, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0077, 0x0069, 0x006c, + 0x006c, 0x0020, 0x006e, 0x006f, 0x0077, 0x0020, 0x0062, 0x0065, 0x0020, 0x0070, 0x006c, 0x0061, 0x0079, 0x0065, 0x0064, 0x0020, + 0x0069, 0x006e, 0x0020, 0x0076, 0x0061, 0x0072, 0x0069, 0x006f, 0x0075, 0x0073, 0x0020, 0x0073, 0x0069, 0x007a, 0x0065, 0x0073, + 0x002e, 0x000a, 0x0049, 0x0066, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0063, + 0x0061, 0x0072, 0x0064, 0x0020, 0x0064, 0x0072, 0x0069, 0x0076, 0x0065, 0x0072, 0x0073, 0x0020, 0x0061, 0x0072, 0x0065, 0x0020, + 0x0064, 0x0065, 0x0066, 0x0065, 0x0063, 0x0074, 0x0069, 0x0076, 0x0065, 0x002c, 0x0020, 0x0079, 0x006f, 0x0075, 0x0020, 0x0077, + 0x0069, 0x006c, 0x006c, 0x0020, 0x0073, 0x0065, 0x0065, 0x0020, 0x0061, 0x006e, 0x0020, 0x0065, 0x0072, 0x0072, 0x006f, 0x0072, + 0x0020, 0x006d, 0x0065, 0x0073, 0x0073, 0x0061, 0x0067, 0x0065, 0x002c, 0x0020, 0x006f, 0x0072, 0x0020, 0x0079, 0x006f, 0x0075, + 0x0072, 0x0020, 0x0063, 0x006f, 0x006d, 0x0070, 0x0075, 0x0074, 0x0065, 0x0072, 0x0020, 0x0077, 0x0069, 0x006c, 0x006c, 0x0020, + 0x006e, 0x006f, 0x0074, 0x0020, 0x0072, 0x0065, 0x0073, 0x0070, 0x006f, 0x006e, 0x0064, 0x002e, 0x0020, 0x0049, 0x0066, 0x0020, + 0x0074, 0x0068, 0x0069, 0x0073, 0x0020, 0x0068, 0x0061, 0x0070, 0x0070, 0x0065, 0x006e, 0x0073, 0x002c, 0x0020, 0x0072, 0x0065, + 0x002d, 0x0073, 0x0074, 0x0061, 0x0072, 0x0074, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x0063, 0x006f, 0x006d, 0x0070, + 0x0075, 0x0074, 0x0065, 0x0072, 0x0020, 0x0061, 0x006e, 0x0064, 0x0020, 0x0063, 0x0061, 0x006c, 0x006c, 0x0020, 0x0075, 0x0070, + 0x0020, 0x0042, 0x0041, 0x0054, 0x0054, 0x004c, 0x0045, 0x0020, 0x0049, 0x0053, 0x004c, 0x0045, 0x0020, 0x0061, 0x0067, 0x0061, + 0x0069, 0x006e, 0x002e, +// 115 +// You are re-starting Battle Isle after a crash or after the program terminated. The instruction which caused the error will now be avoided. For further information, please see your manual. + 0x00bb, + 0x0059, 0x006f, 0x0075, 0x0020, 0x0061, 0x0072, 0x0065, 0x0020, 0x0072, 0x0065, 0x002d, 0x0073, 0x0074, 0x0061, 0x0072, 0x0074, + 0x0069, 0x006e, 0x0067, 0x0020, 0x0042, 0x0061, 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x0020, + 0x0061, 0x0066, 0x0074, 0x0065, 0x0072, 0x0020, 0x0061, 0x0020, 0x0063, 0x0072, 0x0061, 0x0073, 0x0068, 0x0020, 0x006f, 0x0072, + 0x0020, 0x0061, 0x0066, 0x0074, 0x0065, 0x0072, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0070, 0x0072, 0x006f, 0x0067, 0x0072, + 0x0061, 0x006d, 0x0020, 0x0074, 0x0065, 0x0072, 0x006d, 0x0069, 0x006e, 0x0061, 0x0074, 0x0065, 0x0064, 0x002e, 0x0020, 0x0054, + 0x0068, 0x0065, 0x0020, 0x0069, 0x006e, 0x0073, 0x0074, 0x0072, 0x0075, 0x0063, 0x0074, 0x0069, 0x006f, 0x006e, 0x0020, 0x0077, + 0x0068, 0x0069, 0x0063, 0x0068, 0x0020, 0x0063, 0x0061, 0x0075, 0x0073, 0x0065, 0x0064, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, + 0x0065, 0x0072, 0x0072, 0x006f, 0x0072, 0x0020, 0x0077, 0x0069, 0x006c, 0x006c, 0x0020, 0x006e, 0x006f, 0x0077, 0x0020, 0x0062, + 0x0065, 0x0020, 0x0061, 0x0076, 0x006f, 0x0069, 0x0064, 0x0065, 0x0064, 0x002e, 0x0020, 0x0046, 0x006f, 0x0072, 0x0020, 0x0066, + 0x0075, 0x0072, 0x0074, 0x0068, 0x0065, 0x0072, 0x0020, 0x0069, 0x006e, 0x0066, 0x006f, 0x0072, 0x006d, 0x0061, 0x0074, 0x0069, + 0x006f, 0x006e, 0x002c, 0x0020, 0x0070, 0x006c, 0x0065, 0x0061, 0x0073, 0x0065, 0x0020, 0x0073, 0x0065, 0x0065, 0x0020, 0x0079, + 0x006f, 0x0075, 0x0072, 0x0020, 0x006d, 0x0061, 0x006e, 0x0075, 0x0061, 0x006c, 0x002e, +// 116 +// + 0x0000, +// 117 +// This problem will not recur if you update your system to Windows 95, as the defect is in the video drivers for your Windows 3.11 card. You will then also be able to watch the videos. + 0x00b6, + 0x0054, 0x0068, 0x0069, 0x0073, 0x0020, 0x0070, 0x0072, 0x006f, 0x0062, 0x006c, 0x0065, 0x006d, 0x0020, 0x0077, 0x0069, 0x006c, + 0x006c, 0x0020, 0x006e, 0x006f, 0x0074, 0x0020, 0x0072, 0x0065, 0x0063, 0x0075, 0x0072, 0x0020, 0x0069, 0x0066, 0x0020, 0x0079, + 0x006f, 0x0075, 0x0020, 0x0075, 0x0070, 0x0064, 0x0061, 0x0074, 0x0065, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x0073, + 0x0079, 0x0073, 0x0074, 0x0065, 0x006d, 0x0020, 0x0074, 0x006f, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, + 0x0020, 0x0039, 0x0035, 0x002c, 0x0020, 0x0061, 0x0073, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0064, 0x0065, 0x0066, 0x0065, + 0x0063, 0x0074, 0x0020, 0x0069, 0x0073, 0x0020, 0x0069, 0x006e, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0076, 0x0069, 0x0064, + 0x0065, 0x006f, 0x0020, 0x0064, 0x0072, 0x0069, 0x0076, 0x0065, 0x0072, 0x0073, 0x0020, 0x0066, 0x006f, 0x0072, 0x0020, 0x0079, + 0x006f, 0x0075, 0x0072, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0033, 0x002e, 0x0031, 0x0031, + 0x0020, 0x0063, 0x0061, 0x0072, 0x0064, 0x002e, 0x0020, 0x0059, 0x006f, 0x0075, 0x0020, 0x0077, 0x0069, 0x006c, 0x006c, 0x0020, + 0x0074, 0x0068, 0x0065, 0x006e, 0x0020, 0x0061, 0x006c, 0x0073, 0x006f, 0x0020, 0x0062, 0x0065, 0x0020, 0x0061, 0x0062, 0x006c, + 0x0065, 0x0020, 0x0074, 0x006f, 0x0020, 0x0077, 0x0061, 0x0074, 0x0063, 0x0068, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0076, + 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x002e, +// 118 +// + 0x0000, +// 119 +// Windows has reported the following error\n\n%s\n\nThe zoomed videos have been turned off. Please consult your manual. + 0x0071, + 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0068, 0x0061, 0x0073, 0x0020, 0x0072, 0x0065, 0x0070, 0x006f, + 0x0072, 0x0074, 0x0065, 0x0064, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0066, 0x006f, 0x006c, 0x006c, 0x006f, 0x0077, 0x0069, + 0x006e, 0x0067, 0x0020, 0x0065, 0x0072, 0x0072, 0x006f, 0x0072, 0x000a, 0x000a, 0x0025, 0x0073, 0x000a, 0x000a, 0x0054, 0x0068, + 0x0065, 0x0020, 0x007a, 0x006f, 0x006f, 0x006d, 0x0065, 0x0064, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x0020, + 0x0068, 0x0061, 0x0076, 0x0065, 0x0020, 0x0062, 0x0065, 0x0065, 0x006e, 0x0020, 0x0074, 0x0075, 0x0072, 0x006e, 0x0065, 0x0064, + 0x0020, 0x006f, 0x0066, 0x0066, 0x002e, 0x0020, 0x0050, 0x006c, 0x0065, 0x0061, 0x0073, 0x0065, 0x0020, 0x0063, 0x006f, 0x006e, + 0x0073, 0x0075, 0x006c, 0x0074, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x006d, 0x0061, 0x006e, 0x0075, 0x0061, 0x006c, + 0x002e, +// 120 +// Your Windows installation is capable of playing full screen zoomed videos. + 0x004a, + 0x0059, 0x006f, 0x0075, 0x0072, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0069, 0x006e, 0x0073, + 0x0074, 0x0061, 0x006c, 0x006c, 0x0061, 0x0074, 0x0069, 0x006f, 0x006e, 0x0020, 0x0069, 0x0073, 0x0020, 0x0063, 0x0061, 0x0070, + 0x0061, 0x0062, 0x006c, 0x0065, 0x0020, 0x006f, 0x0066, 0x0020, 0x0070, 0x006c, 0x0061, 0x0079, 0x0069, 0x006e, 0x0067, 0x0020, + 0x0066, 0x0075, 0x006c, 0x006c, 0x0020, 0x0073, 0x0063, 0x0072, 0x0065, 0x0065, 0x006e, 0x0020, 0x007a, 0x006f, 0x006f, 0x006d, + 0x0065, 0x0064, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x002e, +// 121 +// + 0x0000, +// 122 +// + 0x0000, +// 123 +// The video will now be closed. Your computer may fail to respond; if this happens, re-start Battle Isle. + 0x0067, + 0x0054, 0x0068, 0x0065, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0077, 0x0069, 0x006c, 0x006c, 0x0020, 0x006e, + 0x006f, 0x0077, 0x0020, 0x0062, 0x0065, 0x0020, 0x0063, 0x006c, 0x006f, 0x0073, 0x0065, 0x0064, 0x002e, 0x0020, 0x0059, 0x006f, + 0x0075, 0x0072, 0x0020, 0x0063, 0x006f, 0x006d, 0x0070, 0x0075, 0x0074, 0x0065, 0x0072, 0x0020, 0x006d, 0x0061, 0x0079, 0x0020, + 0x0066, 0x0061, 0x0069, 0x006c, 0x0020, 0x0074, 0x006f, 0x0020, 0x0072, 0x0065, 0x0073, 0x0070, 0x006f, 0x006e, 0x0064, 0x003b, + 0x0020, 0x0069, 0x0066, 0x0020, 0x0074, 0x0068, 0x0069, 0x0073, 0x0020, 0x0068, 0x0061, 0x0070, 0x0070, 0x0065, 0x006e, 0x0073, + 0x002c, 0x0020, 0x0072, 0x0065, 0x002d, 0x0073, 0x0074, 0x0061, 0x0072, 0x0074, 0x0020, 0x0042, 0x0061, 0x0074, 0x0074, 0x006c, + 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x002e, +// 124 +// A 640 * 480 point AVI video will now be loaded.\nOnce again, Windows may crash; if this happens, re-start Battle Isle. + 0x0075, + 0x0041, 0x0020, 0x0036, 0x0034, 0x0030, 0x0020, 0x002a, 0x0020, 0x0034, 0x0038, 0x0030, 0x0020, 0x0070, 0x006f, 0x0069, 0x006e, + 0x0074, 0x0020, 0x0041, 0x0056, 0x0049, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0077, 0x0069, 0x006c, 0x006c, + 0x0020, 0x006e, 0x006f, 0x0077, 0x0020, 0x0062, 0x0065, 0x0020, 0x006c, 0x006f, 0x0061, 0x0064, 0x0065, 0x0064, 0x002e, 0x000a, + 0x004f, 0x006e, 0x0063, 0x0065, 0x0020, 0x0061, 0x0067, 0x0061, 0x0069, 0x006e, 0x002c, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, + 0x006f, 0x0077, 0x0073, 0x0020, 0x006d, 0x0061, 0x0079, 0x0020, 0x0063, 0x0072, 0x0061, 0x0073, 0x0068, 0x003b, 0x0020, 0x0069, + 0x0066, 0x0020, 0x0074, 0x0068, 0x0069, 0x0073, 0x0020, 0x0068, 0x0061, 0x0070, 0x0070, 0x0065, 0x006e, 0x0073, 0x002c, 0x0020, + 0x0072, 0x0065, 0x002d, 0x0073, 0x0074, 0x0061, 0x0072, 0x0074, 0x0020, 0x0042, 0x0061, 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, + 0x0049, 0x0073, 0x006c, 0x0065, 0x002e, +// 125 +// It is not possible to open the 640*480 video. Battle Isle will not attempt to play these videos again. Please obtain a new driver from the manufacturer of your graphics card. + 0x00ae, + 0x0049, 0x0074, 0x0020, 0x0069, 0x0073, 0x0020, 0x006e, 0x006f, 0x0074, 0x0020, 0x0070, 0x006f, 0x0073, 0x0073, 0x0069, 0x0062, + 0x006c, 0x0065, 0x0020, 0x0074, 0x006f, 0x0020, 0x006f, 0x0070, 0x0065, 0x006e, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0036, + 0x0034, 0x0030, 0x002a, 0x0034, 0x0038, 0x0030, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x002e, 0x0020, 0x0042, 0x0061, + 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x0020, 0x0077, 0x0069, 0x006c, 0x006c, 0x0020, 0x006e, + 0x006f, 0x0074, 0x0020, 0x0061, 0x0074, 0x0074, 0x0065, 0x006d, 0x0070, 0x0074, 0x0020, 0x0074, 0x006f, 0x0020, 0x0070, 0x006c, + 0x0061, 0x0079, 0x0020, 0x0074, 0x0068, 0x0065, 0x0073, 0x0065, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x0020, + 0x0061, 0x0067, 0x0061, 0x0069, 0x006e, 0x002e, 0x0020, 0x0050, 0x006c, 0x0065, 0x0061, 0x0073, 0x0065, 0x0020, 0x006f, 0x0062, + 0x0074, 0x0061, 0x0069, 0x006e, 0x0020, 0x0061, 0x0020, 0x006e, 0x0065, 0x0077, 0x0020, 0x0064, 0x0072, 0x0069, 0x0076, 0x0065, + 0x0072, 0x0020, 0x0066, 0x0072, 0x006f, 0x006d, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x006d, 0x0061, 0x006e, 0x0075, 0x0066, + 0x0061, 0x0063, 0x0074, 0x0075, 0x0072, 0x0065, 0x0072, 0x0020, 0x006f, 0x0066, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, + 0x0067, 0x0072, 0x0061, 0x0070, 0x0068, 0x0069, 0x0063, 0x0073, 0x0020, 0x0063, 0x0061, 0x0072, 0x0064, 0x002e, +// 126 +// File BIG.AVI was not found in the Battle Isle Directory on your hard disk.\nCopy the file from your CD (from the BIN Directory) or re-install Battle Isle. + 0x0099, + 0x0046, 0x0069, 0x006c, 0x0065, 0x0020, 0x0042, 0x0049, 0x0047, 0x002e, 0x0041, 0x0056, 0x0049, 0x0020, 0x0077, 0x0061, 0x0073, + 0x0020, 0x006e, 0x006f, 0x0074, 0x0020, 0x0066, 0x006f, 0x0075, 0x006e, 0x0064, 0x0020, 0x0069, 0x006e, 0x0020, 0x0074, 0x0068, + 0x0065, 0x0020, 0x0042, 0x0061, 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x0020, 0x0044, 0x0069, + 0x0072, 0x0065, 0x0063, 0x0074, 0x006f, 0x0072, 0x0079, 0x0020, 0x006f, 0x006e, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, + 0x0068, 0x0061, 0x0072, 0x0064, 0x0020, 0x0064, 0x0069, 0x0073, 0x006b, 0x002e, 0x000a, 0x0043, 0x006f, 0x0070, 0x0079, 0x0020, + 0x0074, 0x0068, 0x0065, 0x0020, 0x0066, 0x0069, 0x006c, 0x0065, 0x0020, 0x0066, 0x0072, 0x006f, 0x006d, 0x0020, 0x0079, 0x006f, + 0x0075, 0x0072, 0x0020, 0x0043, 0x0044, 0x0020, 0x0028, 0x0066, 0x0072, 0x006f, 0x006d, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, + 0x0042, 0x0049, 0x004e, 0x0020, 0x0044, 0x0069, 0x0072, 0x0065, 0x0063, 0x0074, 0x006f, 0x0072, 0x0079, 0x0029, 0x0020, 0x006f, + 0x0072, 0x0020, 0x0072, 0x0065, 0x002d, 0x0069, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, 0x006c, 0x0020, 0x0042, 0x0061, 0x0074, + 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x002e, +// 127 +// Your video drivers are defective. Battle Isle will not attempt to play 640*480 videos, so that you can use the program. Please obtain new drivers from the manufacturer of your video cards. + 0x00bc, + 0x0059, 0x006f, 0x0075, 0x0072, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0064, 0x0072, 0x0069, 0x0076, 0x0065, + 0x0072, 0x0073, 0x0020, 0x0061, 0x0072, 0x0065, 0x0020, 0x0064, 0x0065, 0x0066, 0x0065, 0x0063, 0x0074, 0x0069, 0x0076, 0x0065, + 0x002e, 0x0020, 0x0042, 0x0061, 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x0020, 0x0077, 0x0069, + 0x006c, 0x006c, 0x0020, 0x006e, 0x006f, 0x0074, 0x0020, 0x0061, 0x0074, 0x0074, 0x0065, 0x006d, 0x0070, 0x0074, 0x0020, 0x0074, + 0x006f, 0x0020, 0x0070, 0x006c, 0x0061, 0x0079, 0x0020, 0x0036, 0x0034, 0x0030, 0x002a, 0x0034, 0x0038, 0x0030, 0x0020, 0x0076, + 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x002c, 0x0020, 0x0073, 0x006f, 0x0020, 0x0074, 0x0068, 0x0061, 0x0074, 0x0020, 0x0079, + 0x006f, 0x0075, 0x0020, 0x0063, 0x0061, 0x006e, 0x0020, 0x0075, 0x0073, 0x0065, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0070, + 0x0072, 0x006f, 0x0067, 0x0072, 0x0061, 0x006d, 0x002e, 0x0020, 0x0050, 0x006c, 0x0065, 0x0061, 0x0073, 0x0065, 0x0020, 0x006f, + 0x0062, 0x0074, 0x0061, 0x0069, 0x006e, 0x0020, 0x006e, 0x0065, 0x0077, 0x0020, 0x0064, 0x0072, 0x0069, 0x0076, 0x0065, 0x0072, + 0x0073, 0x0020, 0x0066, 0x0072, 0x006f, 0x006d, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x006d, 0x0061, 0x006e, 0x0075, 0x0066, + 0x0061, 0x0063, 0x0074, 0x0075, 0x0072, 0x0065, 0x0072, 0x0020, 0x006f, 0x0066, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, + 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0063, 0x0061, 0x0072, 0x0064, 0x0073, 0x002e, +}; + +static const WCHAR AppStringData_9[2274] = { +// 128 +// Windows has reported the following error:\n\n%s\n\n. 640*480 videos have been turned off. Please consult your manual. + 0x0071, + 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0068, 0x0061, 0x0073, 0x0020, 0x0072, 0x0065, 0x0070, 0x006f, + 0x0072, 0x0074, 0x0065, 0x0064, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0066, 0x006f, 0x006c, 0x006c, 0x006f, 0x0077, 0x0069, + 0x006e, 0x0067, 0x0020, 0x0065, 0x0072, 0x0072, 0x006f, 0x0072, 0x003a, 0x000a, 0x000a, 0x0025, 0x0073, 0x000a, 0x000a, 0x002e, + 0x0020, 0x0036, 0x0034, 0x0030, 0x002a, 0x0034, 0x0038, 0x0030, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x0020, + 0x0068, 0x0061, 0x0076, 0x0065, 0x0020, 0x0062, 0x0065, 0x0065, 0x006e, 0x0020, 0x0074, 0x0075, 0x0072, 0x006e, 0x0065, 0x0064, + 0x0020, 0x006f, 0x0066, 0x0066, 0x002e, 0x0020, 0x0050, 0x006c, 0x0065, 0x0061, 0x0073, 0x0065, 0x0020, 0x0063, 0x006f, 0x006e, + 0x0073, 0x0075, 0x006c, 0x0074, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x006d, 0x0061, 0x006e, 0x0075, 0x0061, 0x006c, + 0x002e, +// 129 +// A 640*480 AVI video will now be played.\nIt may not be possible to access if your video drivers are defective, in which case you will see an error message. You may have to re-start Windows if your computer does not react. + 0x00dc, + 0x0041, 0x0020, 0x0036, 0x0034, 0x0030, 0x002a, 0x0034, 0x0038, 0x0030, 0x0020, 0x0041, 0x0056, 0x0049, 0x0020, 0x0076, 0x0069, + 0x0064, 0x0065, 0x006f, 0x0020, 0x0077, 0x0069, 0x006c, 0x006c, 0x0020, 0x006e, 0x006f, 0x0077, 0x0020, 0x0062, 0x0065, 0x0020, + 0x0070, 0x006c, 0x0061, 0x0079, 0x0065, 0x0064, 0x002e, 0x000a, 0x0049, 0x0074, 0x0020, 0x006d, 0x0061, 0x0079, 0x0020, 0x006e, + 0x006f, 0x0074, 0x0020, 0x0062, 0x0065, 0x0020, 0x0070, 0x006f, 0x0073, 0x0073, 0x0069, 0x0062, 0x006c, 0x0065, 0x0020, 0x0074, + 0x006f, 0x0020, 0x0061, 0x0063, 0x0063, 0x0065, 0x0073, 0x0073, 0x0020, 0x0069, 0x0066, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, + 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0064, 0x0072, 0x0069, 0x0076, 0x0065, 0x0072, 0x0073, 0x0020, 0x0061, + 0x0072, 0x0065, 0x0020, 0x0064, 0x0065, 0x0066, 0x0065, 0x0063, 0x0074, 0x0069, 0x0076, 0x0065, 0x002c, 0x0020, 0x0069, 0x006e, + 0x0020, 0x0077, 0x0068, 0x0069, 0x0063, 0x0068, 0x0020, 0x0063, 0x0061, 0x0073, 0x0065, 0x0020, 0x0079, 0x006f, 0x0075, 0x0020, + 0x0077, 0x0069, 0x006c, 0x006c, 0x0020, 0x0073, 0x0065, 0x0065, 0x0020, 0x0061, 0x006e, 0x0020, 0x0065, 0x0072, 0x0072, 0x006f, + 0x0072, 0x0020, 0x006d, 0x0065, 0x0073, 0x0073, 0x0061, 0x0067, 0x0065, 0x002e, 0x0020, 0x0059, 0x006f, 0x0075, 0x0020, 0x006d, + 0x0061, 0x0079, 0x0020, 0x0068, 0x0061, 0x0076, 0x0065, 0x0020, 0x0074, 0x006f, 0x0020, 0x0072, 0x0065, 0x002d, 0x0073, 0x0074, + 0x0061, 0x0072, 0x0074, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0069, 0x0066, 0x0020, 0x0079, + 0x006f, 0x0075, 0x0072, 0x0020, 0x0063, 0x006f, 0x006d, 0x0070, 0x0075, 0x0074, 0x0065, 0x0072, 0x0020, 0x0064, 0x006f, 0x0065, + 0x0073, 0x0020, 0x006e, 0x006f, 0x0074, 0x0020, 0x0072, 0x0065, 0x0061, 0x0063, 0x0074, 0x002e, +// 130 +// Windows has reported the following error:\n\n%s\n\n 640*480 videos have been turned off. Please consult your manual. + 0x0070, + 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0068, 0x0061, 0x0073, 0x0020, 0x0072, 0x0065, 0x0070, 0x006f, + 0x0072, 0x0074, 0x0065, 0x0064, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0066, 0x006f, 0x006c, 0x006c, 0x006f, 0x0077, 0x0069, + 0x006e, 0x0067, 0x0020, 0x0065, 0x0072, 0x0072, 0x006f, 0x0072, 0x003a, 0x000a, 0x000a, 0x0025, 0x0073, 0x000a, 0x000a, 0x0020, + 0x0036, 0x0034, 0x0030, 0x002a, 0x0034, 0x0038, 0x0030, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x0020, 0x0068, + 0x0061, 0x0076, 0x0065, 0x0020, 0x0062, 0x0065, 0x0065, 0x006e, 0x0020, 0x0074, 0x0075, 0x0072, 0x006e, 0x0065, 0x0064, 0x0020, + 0x006f, 0x0066, 0x0066, 0x002e, 0x0020, 0x0050, 0x006c, 0x0065, 0x0061, 0x0073, 0x0065, 0x0020, 0x0063, 0x006f, 0x006e, 0x0073, + 0x0075, 0x006c, 0x0074, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x006d, 0x0061, 0x006e, 0x0075, 0x0061, 0x006c, 0x002e, +// 131 +// + 0x0000, +// 132 +// The videos being used are blank, so you will not be able to see any pictures during the tests. Please consult your manual for further details. + 0x008e, + 0x0054, 0x0068, 0x0065, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x0020, 0x0062, 0x0065, 0x0069, 0x006e, 0x0067, + 0x0020, 0x0075, 0x0073, 0x0065, 0x0064, 0x0020, 0x0061, 0x0072, 0x0065, 0x0020, 0x0062, 0x006c, 0x0061, 0x006e, 0x006b, 0x002c, + 0x0020, 0x0073, 0x006f, 0x0020, 0x0079, 0x006f, 0x0075, 0x0020, 0x0077, 0x0069, 0x006c, 0x006c, 0x0020, 0x006e, 0x006f, 0x0074, + 0x0020, 0x0062, 0x0065, 0x0020, 0x0061, 0x0062, 0x006c, 0x0065, 0x0020, 0x0074, 0x006f, 0x0020, 0x0073, 0x0065, 0x0065, 0x0020, + 0x0061, 0x006e, 0x0079, 0x0020, 0x0070, 0x0069, 0x0063, 0x0074, 0x0075, 0x0072, 0x0065, 0x0073, 0x0020, 0x0064, 0x0075, 0x0072, + 0x0069, 0x006e, 0x0067, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0074, 0x0065, 0x0073, 0x0074, 0x0073, 0x002e, 0x0020, 0x0050, + 0x006c, 0x0065, 0x0061, 0x0073, 0x0065, 0x0020, 0x0063, 0x006f, 0x006e, 0x0073, 0x0075, 0x006c, 0x0074, 0x0020, 0x0079, 0x006f, + 0x0075, 0x0072, 0x0020, 0x006d, 0x0061, 0x006e, 0x0075, 0x0061, 0x006c, 0x0020, 0x0066, 0x006f, 0x0072, 0x0020, 0x0066, 0x0075, + 0x0072, 0x0074, 0x0068, 0x0065, 0x0072, 0x0020, 0x0064, 0x0065, 0x0074, 0x0061, 0x0069, 0x006c, 0x0073, 0x002e, +// 133 +// TESTS COMPLETED.\nYou can play videos, but the quality may be impaired, as your videeo card driver is defective. Please ask the manufacturer of your video card for an update. + 0x00ad, + 0x0054, 0x0045, 0x0053, 0x0054, 0x0053, 0x0020, 0x0043, 0x004f, 0x004d, 0x0050, 0x004c, 0x0045, 0x0054, 0x0045, 0x0044, 0x002e, + 0x000a, 0x0059, 0x006f, 0x0075, 0x0020, 0x0063, 0x0061, 0x006e, 0x0020, 0x0070, 0x006c, 0x0061, 0x0079, 0x0020, 0x0076, 0x0069, + 0x0064, 0x0065, 0x006f, 0x0073, 0x002c, 0x0020, 0x0062, 0x0075, 0x0074, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0071, 0x0075, + 0x0061, 0x006c, 0x0069, 0x0074, 0x0079, 0x0020, 0x006d, 0x0061, 0x0079, 0x0020, 0x0062, 0x0065, 0x0020, 0x0069, 0x006d, 0x0070, + 0x0061, 0x0069, 0x0072, 0x0065, 0x0064, 0x002c, 0x0020, 0x0061, 0x0073, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x0076, + 0x0069, 0x0064, 0x0065, 0x0065, 0x006f, 0x0020, 0x0063, 0x0061, 0x0072, 0x0064, 0x0020, 0x0064, 0x0072, 0x0069, 0x0076, 0x0065, + 0x0072, 0x0020, 0x0069, 0x0073, 0x0020, 0x0064, 0x0065, 0x0066, 0x0065, 0x0063, 0x0074, 0x0069, 0x0076, 0x0065, 0x002e, 0x0020, + 0x0050, 0x006c, 0x0065, 0x0061, 0x0073, 0x0065, 0x0020, 0x0061, 0x0073, 0x006b, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x006d, + 0x0061, 0x006e, 0x0075, 0x0066, 0x0061, 0x0063, 0x0074, 0x0075, 0x0072, 0x0065, 0x0072, 0x0020, 0x006f, 0x0066, 0x0020, 0x0079, + 0x006f, 0x0075, 0x0072, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0063, 0x0061, 0x0072, 0x0064, 0x0020, 0x0066, + 0x006f, 0x0072, 0x0020, 0x0061, 0x006e, 0x0020, 0x0075, 0x0070, 0x0064, 0x0061, 0x0074, 0x0065, 0x002e, +// 134 +// TESTS COMPLETED.\nIt is not possible to play videos as your video card driver is defective. Please ask the manufacturer of your video card for an update. + 0x0098, + 0x0054, 0x0045, 0x0053, 0x0054, 0x0053, 0x0020, 0x0043, 0x004f, 0x004d, 0x0050, 0x004c, 0x0045, 0x0054, 0x0045, 0x0044, 0x002e, + 0x000a, 0x0049, 0x0074, 0x0020, 0x0069, 0x0073, 0x0020, 0x006e, 0x006f, 0x0074, 0x0020, 0x0070, 0x006f, 0x0073, 0x0073, 0x0069, + 0x0062, 0x006c, 0x0065, 0x0020, 0x0074, 0x006f, 0x0020, 0x0070, 0x006c, 0x0061, 0x0079, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, + 0x006f, 0x0073, 0x0020, 0x0061, 0x0073, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, + 0x0020, 0x0063, 0x0061, 0x0072, 0x0064, 0x0020, 0x0064, 0x0072, 0x0069, 0x0076, 0x0065, 0x0072, 0x0020, 0x0069, 0x0073, 0x0020, + 0x0064, 0x0065, 0x0066, 0x0065, 0x0063, 0x0074, 0x0069, 0x0076, 0x0065, 0x002e, 0x0020, 0x0050, 0x006c, 0x0065, 0x0061, 0x0073, + 0x0065, 0x0020, 0x0061, 0x0073, 0x006b, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x006d, 0x0061, 0x006e, 0x0075, 0x0066, 0x0061, + 0x0063, 0x0074, 0x0075, 0x0072, 0x0065, 0x0072, 0x0020, 0x006f, 0x0066, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x0076, + 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0063, 0x0061, 0x0072, 0x0064, 0x0020, 0x0066, 0x006f, 0x0072, 0x0020, 0x0061, 0x006e, + 0x0020, 0x0075, 0x0070, 0x0064, 0x0061, 0x0074, 0x0065, 0x002e, +// 135 +// It was not possible to read file TST.LIB. If it is not in the current directory, please copy it from the CD's BIN directory, or re-install BATTLE ISLE. + 0x0097, + 0x0049, 0x0074, 0x0020, 0x0077, 0x0061, 0x0073, 0x0020, 0x006e, 0x006f, 0x0074, 0x0020, 0x0070, 0x006f, 0x0073, 0x0073, 0x0069, + 0x0062, 0x006c, 0x0065, 0x0020, 0x0074, 0x006f, 0x0020, 0x0072, 0x0065, 0x0061, 0x0064, 0x0020, 0x0066, 0x0069, 0x006c, 0x0065, + 0x0020, 0x0054, 0x0053, 0x0054, 0x002e, 0x004c, 0x0049, 0x0042, 0x002e, 0x0020, 0x0049, 0x0066, 0x0020, 0x0069, 0x0074, 0x0020, + 0x0069, 0x0073, 0x0020, 0x006e, 0x006f, 0x0074, 0x0020, 0x0069, 0x006e, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0063, 0x0075, + 0x0072, 0x0072, 0x0065, 0x006e, 0x0074, 0x0020, 0x0064, 0x0069, 0x0072, 0x0065, 0x0063, 0x0074, 0x006f, 0x0072, 0x0079, 0x002c, + 0x0020, 0x0070, 0x006c, 0x0065, 0x0061, 0x0073, 0x0065, 0x0020, 0x0063, 0x006f, 0x0070, 0x0079, 0x0020, 0x0069, 0x0074, 0x0020, + 0x0066, 0x0072, 0x006f, 0x006d, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0043, 0x0044, 0x0027, 0x0073, 0x0020, 0x0042, 0x0049, + 0x004e, 0x0020, 0x0064, 0x0069, 0x0072, 0x0065, 0x0063, 0x0074, 0x006f, 0x0072, 0x0079, 0x002c, 0x0020, 0x006f, 0x0072, 0x0020, + 0x0072, 0x0065, 0x002d, 0x0069, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, 0x006c, 0x0020, 0x0042, 0x0041, 0x0054, 0x0054, 0x004c, + 0x0045, 0x0020, 0x0049, 0x0053, 0x004c, 0x0045, 0x002e, +// 136 +// Your sound card appears to be set incorrectly. Please check the settings (IRQ,Address,DMA).\nAlso check that you can play the sample "TST.WAV" (in the currect directory) with the media player. + 0x00bf, + 0x0059, 0x006f, 0x0075, 0x0072, 0x0020, 0x0073, 0x006f, 0x0075, 0x006e, 0x0064, 0x0020, 0x0063, 0x0061, 0x0072, 0x0064, 0x0020, + 0x0061, 0x0070, 0x0070, 0x0065, 0x0061, 0x0072, 0x0073, 0x0020, 0x0074, 0x006f, 0x0020, 0x0062, 0x0065, 0x0020, 0x0073, 0x0065, + 0x0074, 0x0020, 0x0069, 0x006e, 0x0063, 0x006f, 0x0072, 0x0072, 0x0065, 0x0063, 0x0074, 0x006c, 0x0079, 0x002e, 0x0020, 0x0050, + 0x006c, 0x0065, 0x0061, 0x0073, 0x0065, 0x0020, 0x0063, 0x0068, 0x0065, 0x0063, 0x006b, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, + 0x0073, 0x0065, 0x0074, 0x0074, 0x0069, 0x006e, 0x0067, 0x0073, 0x0020, 0x0028, 0x0049, 0x0052, 0x0051, 0x002c, 0x0041, 0x0064, + 0x0064, 0x0072, 0x0065, 0x0073, 0x0073, 0x002c, 0x0044, 0x004d, 0x0041, 0x0029, 0x002e, 0x000a, 0x0041, 0x006c, 0x0073, 0x006f, + 0x0020, 0x0063, 0x0068, 0x0065, 0x0063, 0x006b, 0x0020, 0x0074, 0x0068, 0x0061, 0x0074, 0x0020, 0x0079, 0x006f, 0x0075, 0x0020, + 0x0063, 0x0061, 0x006e, 0x0020, 0x0070, 0x006c, 0x0061, 0x0079, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0073, 0x0061, 0x006d, + 0x0070, 0x006c, 0x0065, 0x0020, 0x0022, 0x0054, 0x0053, 0x0054, 0x002e, 0x0057, 0x0041, 0x0056, 0x0022, 0x0020, 0x0028, 0x0069, + 0x006e, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0063, 0x0075, 0x0072, 0x0072, 0x0065, 0x0063, 0x0074, 0x0020, 0x0064, 0x0069, + 0x0072, 0x0065, 0x0063, 0x0074, 0x006f, 0x0072, 0x0079, 0x0029, 0x0020, 0x0077, 0x0069, 0x0074, 0x0068, 0x0020, 0x0074, 0x0068, + 0x0065, 0x0020, 0x006d, 0x0065, 0x0064, 0x0069, 0x0061, 0x0020, 0x0070, 0x006c, 0x0061, 0x0079, 0x0065, 0x0072, 0x002e, +// 137 +// Looking for a music card. A MIDI file will also be loaded. + 0x003a, + 0x004c, 0x006f, 0x006f, 0x006b, 0x0069, 0x006e, 0x0067, 0x0020, 0x0066, 0x006f, 0x0072, 0x0020, 0x0061, 0x0020, 0x006d, 0x0075, + 0x0073, 0x0069, 0x0063, 0x0020, 0x0063, 0x0061, 0x0072, 0x0064, 0x002e, 0x0020, 0x0041, 0x0020, 0x004d, 0x0049, 0x0044, 0x0049, + 0x0020, 0x0066, 0x0069, 0x006c, 0x0065, 0x0020, 0x0077, 0x0069, 0x006c, 0x006c, 0x0020, 0x0061, 0x006c, 0x0073, 0x006f, 0x0020, + 0x0062, 0x0065, 0x0020, 0x006c, 0x006f, 0x0061, 0x0064, 0x0065, 0x0064, 0x002e, +// 138 +// Starting the music file. Windows may report that the file can not be played properly; if this happens, click on the small check box and then on OK. + 0x0093, + 0x0053, 0x0074, 0x0061, 0x0072, 0x0074, 0x0069, 0x006e, 0x0067, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x006d, 0x0075, 0x0073, + 0x0069, 0x0063, 0x0020, 0x0066, 0x0069, 0x006c, 0x0065, 0x002e, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, + 0x0020, 0x006d, 0x0061, 0x0079, 0x0020, 0x0072, 0x0065, 0x0070, 0x006f, 0x0072, 0x0074, 0x0020, 0x0074, 0x0068, 0x0061, 0x0074, + 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0066, 0x0069, 0x006c, 0x0065, 0x0020, 0x0063, 0x0061, 0x006e, 0x0020, 0x006e, 0x006f, + 0x0074, 0x0020, 0x0062, 0x0065, 0x0020, 0x0070, 0x006c, 0x0061, 0x0079, 0x0065, 0x0064, 0x0020, 0x0070, 0x0072, 0x006f, 0x0070, + 0x0065, 0x0072, 0x006c, 0x0079, 0x003b, 0x0020, 0x0069, 0x0066, 0x0020, 0x0074, 0x0068, 0x0069, 0x0073, 0x0020, 0x0068, 0x0061, + 0x0070, 0x0070, 0x0065, 0x006e, 0x0073, 0x002c, 0x0020, 0x0063, 0x006c, 0x0069, 0x0063, 0x006b, 0x0020, 0x006f, 0x006e, 0x0020, + 0x0074, 0x0068, 0x0065, 0x0020, 0x0073, 0x006d, 0x0061, 0x006c, 0x006c, 0x0020, 0x0063, 0x0068, 0x0065, 0x0063, 0x006b, 0x0020, + 0x0062, 0x006f, 0x0078, 0x0020, 0x0061, 0x006e, 0x0064, 0x0020, 0x0074, 0x0068, 0x0065, 0x006e, 0x0020, 0x006f, 0x006e, 0x0020, + 0x004f, 0x004b, 0x002e, +// 139 +// File TST.MID was not found in the current directory:\n%s\non your hard disk.\nBATTLE ISLE will attempt to play music; if an error becomes apparent, the music will be turned off. + 0x00ae, + 0x0046, 0x0069, 0x006c, 0x0065, 0x0020, 0x0054, 0x0053, 0x0054, 0x002e, 0x004d, 0x0049, 0x0044, 0x0020, 0x0077, 0x0061, 0x0073, + 0x0020, 0x006e, 0x006f, 0x0074, 0x0020, 0x0066, 0x006f, 0x0075, 0x006e, 0x0064, 0x0020, 0x0069, 0x006e, 0x0020, 0x0074, 0x0068, + 0x0065, 0x0020, 0x0063, 0x0075, 0x0072, 0x0072, 0x0065, 0x006e, 0x0074, 0x0020, 0x0064, 0x0069, 0x0072, 0x0065, 0x0063, 0x0074, + 0x006f, 0x0072, 0x0079, 0x003a, 0x000a, 0x0025, 0x0073, 0x000a, 0x006f, 0x006e, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, + 0x0068, 0x0061, 0x0072, 0x0064, 0x0020, 0x0064, 0x0069, 0x0073, 0x006b, 0x002e, 0x000a, 0x0042, 0x0041, 0x0054, 0x0054, 0x004c, + 0x0045, 0x0020, 0x0049, 0x0053, 0x004c, 0x0045, 0x0020, 0x0077, 0x0069, 0x006c, 0x006c, 0x0020, 0x0061, 0x0074, 0x0074, 0x0065, + 0x006d, 0x0070, 0x0074, 0x0020, 0x0074, 0x006f, 0x0020, 0x0070, 0x006c, 0x0061, 0x0079, 0x0020, 0x006d, 0x0075, 0x0073, 0x0069, + 0x0063, 0x003b, 0x0020, 0x0069, 0x0066, 0x0020, 0x0061, 0x006e, 0x0020, 0x0065, 0x0072, 0x0072, 0x006f, 0x0072, 0x0020, 0x0062, + 0x0065, 0x0063, 0x006f, 0x006d, 0x0065, 0x0073, 0x0020, 0x0061, 0x0070, 0x0070, 0x0061, 0x0072, 0x0065, 0x006e, 0x0074, 0x002c, + 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x006d, 0x0075, 0x0073, 0x0069, 0x0063, 0x0020, 0x0077, 0x0069, 0x006c, 0x006c, 0x0020, + 0x0062, 0x0065, 0x0020, 0x0074, 0x0075, 0x0072, 0x006e, 0x0065, 0x0064, 0x0020, 0x006f, 0x0066, 0x0066, 0x002e, +// 140 +// Windows could not identify a music card. It will not attempt to play any further music. + 0x0057, + 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0063, 0x006f, 0x0075, 0x006c, 0x0064, 0x0020, 0x006e, 0x006f, + 0x0074, 0x0020, 0x0069, 0x0064, 0x0065, 0x006e, 0x0074, 0x0069, 0x0066, 0x0079, 0x0020, 0x0061, 0x0020, 0x006d, 0x0075, 0x0073, + 0x0069, 0x0063, 0x0020, 0x0063, 0x0061, 0x0072, 0x0064, 0x002e, 0x0020, 0x0049, 0x0074, 0x0020, 0x0077, 0x0069, 0x006c, 0x006c, + 0x0020, 0x006e, 0x006f, 0x0074, 0x0020, 0x0061, 0x0074, 0x0074, 0x0065, 0x006d, 0x0070, 0x0074, 0x0020, 0x0074, 0x006f, 0x0020, + 0x0070, 0x006c, 0x0061, 0x0079, 0x0020, 0x0061, 0x006e, 0x0079, 0x0020, 0x0066, 0x0075, 0x0072, 0x0074, 0x0068, 0x0065, 0x0072, + 0x0020, 0x006d, 0x0075, 0x0073, 0x0069, 0x0063, 0x002e, +// 141 +// An unidentified error has arisen. The music has been turned off. Try to play file TST.MID in the cuerrent directory with your media player, and check that your music card has been correctly set. + 0x00c2, + 0x0041, 0x006e, 0x0020, 0x0075, 0x006e, 0x0069, 0x0064, 0x0065, 0x006e, 0x0074, 0x0069, 0x0066, 0x0069, 0x0065, 0x0064, 0x0020, + 0x0065, 0x0072, 0x0072, 0x006f, 0x0072, 0x0020, 0x0068, 0x0061, 0x0073, 0x0020, 0x0061, 0x0072, 0x0069, 0x0073, 0x0065, 0x006e, + 0x002e, 0x0020, 0x0054, 0x0068, 0x0065, 0x0020, 0x006d, 0x0075, 0x0073, 0x0069, 0x0063, 0x0020, 0x0068, 0x0061, 0x0073, 0x0020, + 0x0062, 0x0065, 0x0065, 0x006e, 0x0020, 0x0074, 0x0075, 0x0072, 0x006e, 0x0065, 0x0064, 0x0020, 0x006f, 0x0066, 0x0066, 0x002e, + 0x0020, 0x0054, 0x0072, 0x0079, 0x0020, 0x0074, 0x006f, 0x0020, 0x0070, 0x006c, 0x0061, 0x0079, 0x0020, 0x0066, 0x0069, 0x006c, + 0x0065, 0x0020, 0x0054, 0x0053, 0x0054, 0x002e, 0x004d, 0x0049, 0x0044, 0x0020, 0x0069, 0x006e, 0x0020, 0x0074, 0x0068, 0x0065, + 0x0020, 0x0063, 0x0075, 0x0065, 0x0072, 0x0072, 0x0065, 0x006e, 0x0074, 0x0020, 0x0064, 0x0069, 0x0072, 0x0065, 0x0063, 0x0074, + 0x006f, 0x0072, 0x0079, 0x0020, 0x0077, 0x0069, 0x0074, 0x0068, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x006d, 0x0065, + 0x0064, 0x0069, 0x0061, 0x0020, 0x0070, 0x006c, 0x0061, 0x0079, 0x0065, 0x0072, 0x002c, 0x0020, 0x0061, 0x006e, 0x0064, 0x0020, + 0x0063, 0x0068, 0x0065, 0x0063, 0x006b, 0x0020, 0x0074, 0x0068, 0x0061, 0x0074, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, + 0x006d, 0x0075, 0x0073, 0x0069, 0x0063, 0x0020, 0x0063, 0x0061, 0x0072, 0x0064, 0x0020, 0x0068, 0x0061, 0x0073, 0x0020, 0x0062, + 0x0065, 0x0065, 0x006e, 0x0020, 0x0063, 0x006f, 0x0072, 0x0072, 0x0065, 0x0063, 0x0074, 0x006c, 0x0079, 0x0020, 0x0073, 0x0065, + 0x0074, 0x002e, +// 142 +// Windows has reported the following error:\n\n%s\n\nThe music has been turned off; please consult your manual for further details. + 0x007d, + 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0068, 0x0061, 0x0073, 0x0020, 0x0072, 0x0065, 0x0070, 0x006f, + 0x0072, 0x0074, 0x0065, 0x0064, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0066, 0x006f, 0x006c, 0x006c, 0x006f, 0x0077, 0x0069, + 0x006e, 0x0067, 0x0020, 0x0065, 0x0072, 0x0072, 0x006f, 0x0072, 0x003a, 0x000a, 0x000a, 0x0025, 0x0073, 0x000a, 0x000a, 0x0054, + 0x0068, 0x0065, 0x0020, 0x006d, 0x0075, 0x0073, 0x0069, 0x0063, 0x0020, 0x0068, 0x0061, 0x0073, 0x0020, 0x0062, 0x0065, 0x0065, + 0x006e, 0x0020, 0x0074, 0x0075, 0x0072, 0x006e, 0x0065, 0x0064, 0x0020, 0x006f, 0x0066, 0x0066, 0x003b, 0x0020, 0x0070, 0x006c, + 0x0065, 0x0061, 0x0073, 0x0065, 0x0020, 0x0063, 0x006f, 0x006e, 0x0073, 0x0075, 0x006c, 0x0074, 0x0020, 0x0079, 0x006f, 0x0075, + 0x0072, 0x0020, 0x006d, 0x0061, 0x006e, 0x0075, 0x0061, 0x006c, 0x0020, 0x0066, 0x006f, 0x0072, 0x0020, 0x0066, 0x0075, 0x0072, + 0x0074, 0x0068, 0x0065, 0x0072, 0x0020, 0x0064, 0x0065, 0x0074, 0x0061, 0x0069, 0x006c, 0x0073, 0x002e, +// 143 +// This indicates that your sound card has been incorrectly installed. Please check your Windows sound driver and the settings on the music card, and try to play file TST.MID in the current directory on your media player. + 0x00db, + 0x0054, 0x0068, 0x0069, 0x0073, 0x0020, 0x0069, 0x006e, 0x0064, 0x0069, 0x0063, 0x0061, 0x0074, 0x0065, 0x0073, 0x0020, 0x0074, + 0x0068, 0x0061, 0x0074, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x0073, 0x006f, 0x0075, 0x006e, 0x0064, 0x0020, 0x0063, + 0x0061, 0x0072, 0x0064, 0x0020, 0x0068, 0x0061, 0x0073, 0x0020, 0x0062, 0x0065, 0x0065, 0x006e, 0x0020, 0x0069, 0x006e, 0x0063, + 0x006f, 0x0072, 0x0072, 0x0065, 0x0063, 0x0074, 0x006c, 0x0079, 0x0020, 0x0069, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, 0x006c, + 0x0065, 0x0064, 0x002e, 0x0020, 0x0050, 0x006c, 0x0065, 0x0061, 0x0073, 0x0065, 0x0020, 0x0063, 0x0068, 0x0065, 0x0063, 0x006b, + 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0073, 0x006f, + 0x0075, 0x006e, 0x0064, 0x0020, 0x0064, 0x0072, 0x0069, 0x0076, 0x0065, 0x0072, 0x0020, 0x0061, 0x006e, 0x0064, 0x0020, 0x0074, + 0x0068, 0x0065, 0x0020, 0x0073, 0x0065, 0x0074, 0x0074, 0x0069, 0x006e, 0x0067, 0x0073, 0x0020, 0x006f, 0x006e, 0x0020, 0x0074, + 0x0068, 0x0065, 0x0020, 0x006d, 0x0075, 0x0073, 0x0069, 0x0063, 0x0020, 0x0063, 0x0061, 0x0072, 0x0064, 0x002c, 0x0020, 0x0061, + 0x006e, 0x0064, 0x0020, 0x0074, 0x0072, 0x0079, 0x0020, 0x0074, 0x006f, 0x0020, 0x0070, 0x006c, 0x0061, 0x0079, 0x0020, 0x0066, + 0x0069, 0x006c, 0x0065, 0x0020, 0x0054, 0x0053, 0x0054, 0x002e, 0x004d, 0x0049, 0x0044, 0x0020, 0x0069, 0x006e, 0x0020, 0x0074, + 0x0068, 0x0065, 0x0020, 0x0063, 0x0075, 0x0072, 0x0072, 0x0065, 0x006e, 0x0074, 0x0020, 0x0064, 0x0069, 0x0072, 0x0065, 0x0063, + 0x0074, 0x006f, 0x0072, 0x0079, 0x0020, 0x006f, 0x006e, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x006d, 0x0065, 0x0064, + 0x0069, 0x0061, 0x0020, 0x0070, 0x006c, 0x0061, 0x0079, 0x0065, 0x0072, 0x002e, 0x0020, +}; + +static const WCHAR AppStringData_10[2147] = { +// 144 +// The most common cause in Windows 311 is an incorrectly set MIDI-Mapper. Please consult your manual.\nYou would be advised to upgrade to Windows 95, as this supports muti-media equipment much better than Windows 311. + 0x00d6, + 0x0054, 0x0068, 0x0065, 0x0020, 0x006d, 0x006f, 0x0073, 0x0074, 0x0020, 0x0063, 0x006f, 0x006d, 0x006d, 0x006f, 0x006e, 0x0020, + 0x0063, 0x0061, 0x0075, 0x0073, 0x0065, 0x0020, 0x0069, 0x006e, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, + 0x0020, 0x0033, 0x0031, 0x0031, 0x0020, 0x0069, 0x0073, 0x0020, 0x0061, 0x006e, 0x0020, 0x0069, 0x006e, 0x0063, 0x006f, 0x0072, + 0x0072, 0x0065, 0x0063, 0x0074, 0x006c, 0x0079, 0x0020, 0x0073, 0x0065, 0x0074, 0x0020, 0x004d, 0x0049, 0x0044, 0x0049, 0x002d, + 0x004d, 0x0061, 0x0070, 0x0070, 0x0065, 0x0072, 0x002e, 0x0020, 0x0050, 0x006c, 0x0065, 0x0061, 0x0073, 0x0065, 0x0020, 0x0063, + 0x006f, 0x006e, 0x0073, 0x0075, 0x006c, 0x0074, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x006d, 0x0061, 0x006e, 0x0075, + 0x0061, 0x006c, 0x002e, 0x000a, 0x0059, 0x006f, 0x0075, 0x0020, 0x0077, 0x006f, 0x0075, 0x006c, 0x0064, 0x0020, 0x0062, 0x0065, + 0x0020, 0x0061, 0x0064, 0x0076, 0x0069, 0x0073, 0x0065, 0x0064, 0x0020, 0x0074, 0x006f, 0x0020, 0x0075, 0x0070, 0x0067, 0x0072, + 0x0061, 0x0064, 0x0065, 0x0020, 0x0074, 0x006f, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0039, + 0x0035, 0x002c, 0x0020, 0x0061, 0x0073, 0x0020, 0x0074, 0x0068, 0x0069, 0x0073, 0x0020, 0x0073, 0x0075, 0x0070, 0x0070, 0x006f, + 0x0072, 0x0074, 0x0073, 0x0020, 0x006d, 0x0075, 0x0074, 0x0069, 0x002d, 0x006d, 0x0065, 0x0064, 0x0069, 0x0061, 0x0020, 0x0065, + 0x0071, 0x0075, 0x0069, 0x0070, 0x006d, 0x0065, 0x006e, 0x0074, 0x0020, 0x006d, 0x0075, 0x0063, 0x0068, 0x0020, 0x0062, 0x0065, + 0x0074, 0x0074, 0x0065, 0x0072, 0x0020, 0x0074, 0x0068, 0x0061, 0x006e, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, + 0x0073, 0x0020, 0x0033, 0x0031, 0x0031, 0x002e, +// 145 +// This error will not recurr if you update your system to Windows 95, as this supports multi-media equipment much better than Windows 311. + 0x0088, + 0x0054, 0x0068, 0x0069, 0x0073, 0x0020, 0x0065, 0x0072, 0x0072, 0x006f, 0x0072, 0x0020, 0x0077, 0x0069, 0x006c, 0x006c, 0x0020, + 0x006e, 0x006f, 0x0074, 0x0020, 0x0072, 0x0065, 0x0063, 0x0075, 0x0072, 0x0072, 0x0020, 0x0069, 0x0066, 0x0020, 0x0079, 0x006f, + 0x0075, 0x0020, 0x0075, 0x0070, 0x0064, 0x0061, 0x0074, 0x0065, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x0073, 0x0079, + 0x0073, 0x0074, 0x0065, 0x006d, 0x0020, 0x0074, 0x006f, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, + 0x0039, 0x0035, 0x002c, 0x0020, 0x0061, 0x0073, 0x0020, 0x0074, 0x0068, 0x0069, 0x0073, 0x0020, 0x0073, 0x0075, 0x0070, 0x0070, + 0x006f, 0x0072, 0x0074, 0x0073, 0x0020, 0x006d, 0x0075, 0x006c, 0x0074, 0x0069, 0x002d, 0x006d, 0x0065, 0x0064, 0x0069, 0x0061, + 0x0020, 0x0065, 0x0071, 0x0075, 0x0069, 0x0070, 0x006d, 0x0065, 0x006e, 0x0074, 0x0020, 0x006d, 0x0075, 0x0063, 0x0068, 0x0020, + 0x0062, 0x0065, 0x0074, 0x0074, 0x0065, 0x0072, 0x0020, 0x0074, 0x0068, 0x0061, 0x006e, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, + 0x006f, 0x0077, 0x0073, 0x0020, 0x0033, 0x0031, 0x0031, 0x002e, +// 146 +// It was not possible to start the VIDEO FOR WINDOWS Set-up program. Please start the set-up manually, as explained in your manual. + 0x0081, + 0x0049, 0x0074, 0x0020, 0x0077, 0x0061, 0x0073, 0x0020, 0x006e, 0x006f, 0x0074, 0x0020, 0x0070, 0x006f, 0x0073, 0x0073, 0x0069, + 0x0062, 0x006c, 0x0065, 0x0020, 0x0074, 0x006f, 0x0020, 0x0073, 0x0074, 0x0061, 0x0072, 0x0074, 0x0020, 0x0074, 0x0068, 0x0065, + 0x0020, 0x0056, 0x0049, 0x0044, 0x0045, 0x004f, 0x0020, 0x0046, 0x004f, 0x0052, 0x0020, 0x0057, 0x0049, 0x004e, 0x0044, 0x004f, + 0x0057, 0x0053, 0x0020, 0x0053, 0x0065, 0x0074, 0x002d, 0x0075, 0x0070, 0x0020, 0x0070, 0x0072, 0x006f, 0x0067, 0x0072, 0x0061, + 0x006d, 0x002e, 0x0020, 0x0050, 0x006c, 0x0065, 0x0061, 0x0073, 0x0065, 0x0020, 0x0073, 0x0074, 0x0061, 0x0072, 0x0074, 0x0020, + 0x0074, 0x0068, 0x0065, 0x0020, 0x0073, 0x0065, 0x0074, 0x002d, 0x0075, 0x0070, 0x0020, 0x006d, 0x0061, 0x006e, 0x0075, 0x0061, + 0x006c, 0x006c, 0x0079, 0x002c, 0x0020, 0x0061, 0x0073, 0x0020, 0x0065, 0x0078, 0x0070, 0x006c, 0x0061, 0x0069, 0x006e, 0x0065, + 0x0064, 0x0020, 0x0069, 0x006e, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x006d, 0x0061, 0x006e, 0x0075, 0x0061, 0x006c, + 0x002e, +// 147 +// Your computer check is now complete. Now starting BATTLE ISLE. + 0x003e, + 0x0059, 0x006f, 0x0075, 0x0072, 0x0020, 0x0063, 0x006f, 0x006d, 0x0070, 0x0075, 0x0074, 0x0065, 0x0072, 0x0020, 0x0063, 0x0068, + 0x0065, 0x0063, 0x006b, 0x0020, 0x0069, 0x0073, 0x0020, 0x006e, 0x006f, 0x0077, 0x0020, 0x0063, 0x006f, 0x006d, 0x0070, 0x006c, + 0x0065, 0x0074, 0x0065, 0x002e, 0x0020, 0x004e, 0x006f, 0x0077, 0x0020, 0x0073, 0x0074, 0x0061, 0x0072, 0x0074, 0x0069, 0x006e, + 0x0067, 0x0020, 0x0042, 0x0041, 0x0054, 0x0054, 0x004c, 0x0045, 0x0020, 0x0049, 0x0053, 0x004c, 0x0045, 0x002e, +// 148 +// No sound card was identified. All sound effects have been turned off. If you have installed a sound card, please check that the card and the necessary drivers are set correctly. + 0x00b1, + 0x004e, 0x006f, 0x0020, 0x0073, 0x006f, 0x0075, 0x006e, 0x0064, 0x0020, 0x0063, 0x0061, 0x0072, 0x0064, 0x0020, 0x0077, 0x0061, + 0x0073, 0x0020, 0x0069, 0x0064, 0x0065, 0x006e, 0x0074, 0x0069, 0x0066, 0x0069, 0x0065, 0x0064, 0x002e, 0x0020, 0x0041, 0x006c, + 0x006c, 0x0020, 0x0073, 0x006f, 0x0075, 0x006e, 0x0064, 0x0020, 0x0065, 0x0066, 0x0066, 0x0065, 0x0063, 0x0074, 0x0073, 0x0020, + 0x0068, 0x0061, 0x0076, 0x0065, 0x0020, 0x0062, 0x0065, 0x0065, 0x006e, 0x0020, 0x0074, 0x0075, 0x0072, 0x006e, 0x0065, 0x0064, + 0x0020, 0x006f, 0x0066, 0x0066, 0x002e, 0x0020, 0x0049, 0x0066, 0x0020, 0x0079, 0x006f, 0x0075, 0x0020, 0x0068, 0x0061, 0x0076, + 0x0065, 0x0020, 0x0069, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, 0x006c, 0x0065, 0x0064, 0x0020, 0x0061, 0x0020, 0x0073, 0x006f, + 0x0075, 0x006e, 0x0064, 0x0020, 0x0063, 0x0061, 0x0072, 0x0064, 0x002c, 0x0020, 0x0070, 0x006c, 0x0065, 0x0061, 0x0073, 0x0065, + 0x0020, 0x0063, 0x0068, 0x0065, 0x0063, 0x006b, 0x0020, 0x0074, 0x0068, 0x0061, 0x0074, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, + 0x0063, 0x0061, 0x0072, 0x0064, 0x0020, 0x0061, 0x006e, 0x0064, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x006e, 0x0065, 0x0063, + 0x0065, 0x0073, 0x0073, 0x0061, 0x0072, 0x0079, 0x0020, 0x0064, 0x0072, 0x0069, 0x0076, 0x0065, 0x0072, 0x0073, 0x0020, 0x0061, + 0x0072, 0x0065, 0x0020, 0x0073, 0x0065, 0x0074, 0x0020, 0x0063, 0x006f, 0x0072, 0x0072, 0x0065, 0x0063, 0x0074, 0x006c, 0x0079, + 0x002e, +// 149 +// A sound card for sound effects has been found. A sample will now be played. + 0x004b, + 0x0041, 0x0020, 0x0073, 0x006f, 0x0075, 0x006e, 0x0064, 0x0020, 0x0063, 0x0061, 0x0072, 0x0064, 0x0020, 0x0066, 0x006f, 0x0072, + 0x0020, 0x0073, 0x006f, 0x0075, 0x006e, 0x0064, 0x0020, 0x0065, 0x0066, 0x0066, 0x0065, 0x0063, 0x0074, 0x0073, 0x0020, 0x0068, + 0x0061, 0x0073, 0x0020, 0x0062, 0x0065, 0x0065, 0x006e, 0x0020, 0x0066, 0x006f, 0x0075, 0x006e, 0x0064, 0x002e, 0x0020, 0x0041, + 0x0020, 0x0073, 0x0061, 0x006d, 0x0070, 0x006c, 0x0065, 0x0020, 0x0077, 0x0069, 0x006c, 0x006c, 0x0020, 0x006e, 0x006f, 0x0077, + 0x0020, 0x0062, 0x0065, 0x0020, 0x0070, 0x006c, 0x0061, 0x0079, 0x0065, 0x0064, 0x002e, +// 150 +// Entry SDIPATH in file SDI.INI is not set correctly; this entry must indicate the directory in which BATTLE ISLE is installed. Please re-install BATTLE ISLE! + 0x009c, + 0x0045, 0x006e, 0x0074, 0x0072, 0x0079, 0x0020, 0x0053, 0x0044, 0x0049, 0x0050, 0x0041, 0x0054, 0x0048, 0x0020, 0x0069, 0x006e, + 0x0020, 0x0066, 0x0069, 0x006c, 0x0065, 0x0020, 0x0053, 0x0044, 0x0049, 0x002e, 0x0049, 0x004e, 0x0049, 0x0020, 0x0069, 0x0073, + 0x0020, 0x006e, 0x006f, 0x0074, 0x0020, 0x0073, 0x0065, 0x0074, 0x0020, 0x0063, 0x006f, 0x0072, 0x0072, 0x0065, 0x0063, 0x0074, + 0x006c, 0x0079, 0x003b, 0x0020, 0x0074, 0x0068, 0x0069, 0x0073, 0x0020, 0x0065, 0x006e, 0x0074, 0x0072, 0x0079, 0x0020, 0x006d, + 0x0075, 0x0073, 0x0074, 0x0020, 0x0069, 0x006e, 0x0064, 0x0069, 0x0063, 0x0061, 0x0074, 0x0065, 0x0020, 0x0074, 0x0068, 0x0065, + 0x0020, 0x0064, 0x0069, 0x0072, 0x0065, 0x0063, 0x0074, 0x006f, 0x0072, 0x0079, 0x0020, 0x0069, 0x006e, 0x0020, 0x0077, 0x0068, + 0x0069, 0x0063, 0x0068, 0x0020, 0x0042, 0x0041, 0x0054, 0x0054, 0x004c, 0x0045, 0x0020, 0x0049, 0x0053, 0x004c, 0x0045, 0x0020, + 0x0069, 0x0073, 0x0020, 0x0069, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, 0x006c, 0x0065, 0x0064, 0x002e, 0x0020, 0x0050, 0x006c, + 0x0065, 0x0061, 0x0073, 0x0065, 0x0020, 0x0072, 0x0065, 0x002d, 0x0069, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, 0x006c, 0x0020, + 0x0042, 0x0041, 0x0054, 0x0054, 0x004c, 0x0045, 0x0020, 0x0049, 0x0053, 0x004c, 0x0045, 0x0021, +// 151 +// It was not possible to make the directory listed as SDIPATH in file SDI.INI into a current directory. The entry must contain the directory in which BATTLE ISLE is installed. Please re-install the program. + 0x00cc, + 0x0049, 0x0074, 0x0020, 0x0077, 0x0061, 0x0073, 0x0020, 0x006e, 0x006f, 0x0074, 0x0020, 0x0070, 0x006f, 0x0073, 0x0073, 0x0069, + 0x0062, 0x006c, 0x0065, 0x0020, 0x0074, 0x006f, 0x0020, 0x006d, 0x0061, 0x006b, 0x0065, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, + 0x0064, 0x0069, 0x0072, 0x0065, 0x0063, 0x0074, 0x006f, 0x0072, 0x0079, 0x0020, 0x006c, 0x0069, 0x0073, 0x0074, 0x0065, 0x0064, + 0x0020, 0x0061, 0x0073, 0x0020, 0x0053, 0x0044, 0x0049, 0x0050, 0x0041, 0x0054, 0x0048, 0x0020, 0x0069, 0x006e, 0x0020, 0x0066, + 0x0069, 0x006c, 0x0065, 0x0020, 0x0053, 0x0044, 0x0049, 0x002e, 0x0049, 0x004e, 0x0049, 0x0020, 0x0069, 0x006e, 0x0074, 0x006f, + 0x0020, 0x0061, 0x0020, 0x0063, 0x0075, 0x0072, 0x0072, 0x0065, 0x006e, 0x0074, 0x0020, 0x0064, 0x0069, 0x0072, 0x0065, 0x0063, + 0x0074, 0x006f, 0x0072, 0x0079, 0x002e, 0x0020, 0x0054, 0x0068, 0x0065, 0x0020, 0x0065, 0x006e, 0x0074, 0x0072, 0x0079, 0x0020, + 0x006d, 0x0075, 0x0073, 0x0074, 0x0020, 0x0063, 0x006f, 0x006e, 0x0074, 0x0061, 0x0069, 0x006e, 0x0020, 0x0074, 0x0068, 0x0065, + 0x0020, 0x0064, 0x0069, 0x0072, 0x0065, 0x0063, 0x0074, 0x006f, 0x0072, 0x0079, 0x0020, 0x0069, 0x006e, 0x0020, 0x0077, 0x0068, + 0x0069, 0x0063, 0x0068, 0x0020, 0x0042, 0x0041, 0x0054, 0x0054, 0x004c, 0x0045, 0x0020, 0x0049, 0x0053, 0x004c, 0x0045, 0x0020, + 0x0069, 0x0073, 0x0020, 0x0069, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, 0x006c, 0x0065, 0x0064, 0x002e, 0x0020, 0x0050, 0x006c, + 0x0065, 0x0061, 0x0073, 0x0065, 0x0020, 0x0072, 0x0065, 0x002d, 0x0069, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, 0x006c, 0x0020, + 0x0074, 0x0068, 0x0065, 0x0020, 0x0070, 0x0072, 0x006f, 0x0067, 0x0072, 0x0061, 0x006d, 0x002e, +// 152 +// Your video driver has reported the following picture settings:\nPicture width:%d\nPicture height:%d\nNumber of colours:%d\nIf these values are incorrect, try to obtain a new driver from the manufacturer of your graphics card. + 0x00dd, + 0x0059, 0x006f, 0x0075, 0x0072, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0064, 0x0072, 0x0069, 0x0076, 0x0065, + 0x0072, 0x0020, 0x0068, 0x0061, 0x0073, 0x0020, 0x0072, 0x0065, 0x0070, 0x006f, 0x0072, 0x0074, 0x0065, 0x0064, 0x0020, 0x0074, + 0x0068, 0x0065, 0x0020, 0x0066, 0x006f, 0x006c, 0x006c, 0x006f, 0x0077, 0x0069, 0x006e, 0x0067, 0x0020, 0x0070, 0x0069, 0x0063, + 0x0074, 0x0075, 0x0072, 0x0065, 0x0020, 0x0073, 0x0065, 0x0074, 0x0074, 0x0069, 0x006e, 0x0067, 0x0073, 0x003a, 0x000a, 0x0050, + 0x0069, 0x0063, 0x0074, 0x0075, 0x0072, 0x0065, 0x0020, 0x0077, 0x0069, 0x0064, 0x0074, 0x0068, 0x003a, 0x0025, 0x0064, 0x000a, + 0x0050, 0x0069, 0x0063, 0x0074, 0x0075, 0x0072, 0x0065, 0x0020, 0x0068, 0x0065, 0x0069, 0x0067, 0x0068, 0x0074, 0x003a, 0x0025, + 0x0064, 0x000a, 0x004e, 0x0075, 0x006d, 0x0062, 0x0065, 0x0072, 0x0020, 0x006f, 0x0066, 0x0020, 0x0063, 0x006f, 0x006c, 0x006f, + 0x0075, 0x0072, 0x0073, 0x003a, 0x0025, 0x0064, 0x000a, 0x0049, 0x0066, 0x0020, 0x0074, 0x0068, 0x0065, 0x0073, 0x0065, 0x0020, + 0x0076, 0x0061, 0x006c, 0x0075, 0x0065, 0x0073, 0x0020, 0x0061, 0x0072, 0x0065, 0x0020, 0x0069, 0x006e, 0x0063, 0x006f, 0x0072, + 0x0072, 0x0065, 0x0063, 0x0074, 0x002c, 0x0020, 0x0074, 0x0072, 0x0079, 0x0020, 0x0074, 0x006f, 0x0020, 0x006f, 0x0062, 0x0074, + 0x0061, 0x0069, 0x006e, 0x0020, 0x0061, 0x0020, 0x006e, 0x0065, 0x0077, 0x0020, 0x0064, 0x0072, 0x0069, 0x0076, 0x0065, 0x0072, + 0x0020, 0x0066, 0x0072, 0x006f, 0x006d, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x006d, 0x0061, 0x006e, 0x0075, 0x0066, 0x0061, + 0x0063, 0x0074, 0x0075, 0x0072, 0x0065, 0x0072, 0x0020, 0x006f, 0x0066, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x0067, + 0x0072, 0x0061, 0x0070, 0x0068, 0x0069, 0x0063, 0x0073, 0x0020, 0x0063, 0x0061, 0x0072, 0x0064, 0x002e, +// 153 +// You are still using Windows 3.11. You would be advised to update your system to Windows 95 or Windows NT, as these offer better performance and have fewer problems. + 0x00a4, + 0x0059, 0x006f, 0x0075, 0x0020, 0x0061, 0x0072, 0x0065, 0x0020, 0x0073, 0x0074, 0x0069, 0x006c, 0x006c, 0x0020, 0x0075, 0x0073, + 0x0069, 0x006e, 0x0067, 0x0020, 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0033, 0x002e, 0x0031, 0x0031, + 0x002e, 0x0020, 0x0059, 0x006f, 0x0075, 0x0020, 0x0077, 0x006f, 0x0075, 0x006c, 0x0064, 0x0020, 0x0062, 0x0065, 0x0020, 0x0061, + 0x0064, 0x0076, 0x0069, 0x0073, 0x0065, 0x0064, 0x0020, 0x0074, 0x006f, 0x0020, 0x0075, 0x0070, 0x0064, 0x0061, 0x0074, 0x0065, + 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x0073, 0x0079, 0x0073, 0x0074, 0x0065, 0x006d, 0x0020, 0x0074, 0x006f, 0x0020, + 0x0057, 0x0069, 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x0039, 0x0035, 0x0020, 0x006f, 0x0072, 0x0020, 0x0057, 0x0069, + 0x006e, 0x0064, 0x006f, 0x0077, 0x0073, 0x0020, 0x004e, 0x0054, 0x002c, 0x0020, 0x0061, 0x0073, 0x0020, 0x0074, 0x0068, 0x0065, + 0x0073, 0x0065, 0x0020, 0x006f, 0x0066, 0x0066, 0x0065, 0x0072, 0x0020, 0x0062, 0x0065, 0x0074, 0x0074, 0x0065, 0x0072, 0x0020, + 0x0070, 0x0065, 0x0072, 0x0066, 0x006f, 0x0072, 0x006d, 0x0061, 0x006e, 0x0063, 0x0065, 0x0020, 0x0061, 0x006e, 0x0064, 0x0020, + 0x0068, 0x0061, 0x0076, 0x0065, 0x0020, 0x0066, 0x0065, 0x0077, 0x0065, 0x0072, 0x0020, 0x0070, 0x0072, 0x006f, 0x0062, 0x006c, + 0x0065, 0x006d, 0x0073, 0x002e, +// 154 +// Did the test run without any error reports? + 0x002b, + 0x0044, 0x0069, 0x0064, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0074, 0x0065, 0x0073, 0x0074, 0x0020, 0x0072, 0x0075, 0x006e, + 0x0020, 0x0077, 0x0069, 0x0074, 0x0068, 0x006f, 0x0075, 0x0074, 0x0020, 0x0061, 0x006e, 0x0079, 0x0020, 0x0065, 0x0072, 0x0072, + 0x006f, 0x0072, 0x0020, 0x0072, 0x0065, 0x0070, 0x006f, 0x0072, 0x0074, 0x0073, 0x003f, +// 155 +// Could you hear the sample? + 0x001a, + 0x0043, 0x006f, 0x0075, 0x006c, 0x0064, 0x0020, 0x0079, 0x006f, 0x0075, 0x0020, 0x0068, 0x0065, 0x0061, 0x0072, 0x0020, 0x0074, + 0x0068, 0x0065, 0x0020, 0x0073, 0x0061, 0x006d, 0x0070, 0x006c, 0x0065, 0x003f, +// 156 +// Can you hear the music? + 0x0017, + 0x0043, 0x0061, 0x006e, 0x0020, 0x0079, 0x006f, 0x0075, 0x0020, 0x0068, 0x0065, 0x0061, 0x0072, 0x0020, 0x0074, 0x0068, 0x0065, + 0x0020, 0x006d, 0x0075, 0x0073, 0x0069, 0x0063, 0x003f, +// 157 +// Battle Isle can now install VIDEO FOR WINDOWS 1.1e.\n\nPLEASE BE SURE TO READ YOUR MANUAL FIRST!!!!!!\n\nDo you want to install VFW 1.1e? + 0x0085, + 0x0042, 0x0061, 0x0074, 0x0074, 0x006c, 0x0065, 0x0020, 0x0049, 0x0073, 0x006c, 0x0065, 0x0020, 0x0063, 0x0061, 0x006e, 0x0020, + 0x006e, 0x006f, 0x0077, 0x0020, 0x0069, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, 0x006c, 0x0020, 0x0056, 0x0049, 0x0044, 0x0045, + 0x004f, 0x0020, 0x0046, 0x004f, 0x0052, 0x0020, 0x0057, 0x0049, 0x004e, 0x0044, 0x004f, 0x0057, 0x0053, 0x0020, 0x0031, 0x002e, + 0x0031, 0x0065, 0x002e, 0x000a, 0x000a, 0x0050, 0x004c, 0x0045, 0x0041, 0x0053, 0x0045, 0x0020, 0x0042, 0x0045, 0x0020, 0x0053, + 0x0055, 0x0052, 0x0045, 0x0020, 0x0054, 0x004f, 0x0020, 0x0052, 0x0045, 0x0041, 0x0044, 0x0020, 0x0059, 0x004f, 0x0055, 0x0052, + 0x0020, 0x004d, 0x0041, 0x004e, 0x0055, 0x0041, 0x004c, 0x0020, 0x0046, 0x0049, 0x0052, 0x0053, 0x0054, 0x0021, 0x0021, 0x0021, + 0x0021, 0x0021, 0x0021, 0x000a, 0x000a, 0x0044, 0x006f, 0x0020, 0x0079, 0x006f, 0x0075, 0x0020, 0x0077, 0x0061, 0x006e, 0x0074, + 0x0020, 0x0074, 0x006f, 0x0020, 0x0069, 0x006e, 0x0073, 0x0074, 0x0061, 0x006c, 0x006c, 0x0020, 0x0056, 0x0046, 0x0057, 0x0020, + 0x0031, 0x002e, 0x0031, 0x0065, 0x003f, +// 158 +// One of the video sequences crashed during the game. Your video drivers appear to be defective. The function which caused the problem will be avoided from now on, and the video quality may suffer as a result. + 0x00cf, + 0x004f, 0x006e, 0x0065, 0x0020, 0x006f, 0x0066, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, + 0x0020, 0x0073, 0x0065, 0x0071, 0x0075, 0x0065, 0x006e, 0x0063, 0x0065, 0x0073, 0x0020, 0x0063, 0x0072, 0x0061, 0x0073, 0x0068, + 0x0065, 0x0064, 0x0020, 0x0064, 0x0075, 0x0072, 0x0069, 0x006e, 0x0067, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0067, 0x0061, + 0x006d, 0x0065, 0x002e, 0x0020, 0x0059, 0x006f, 0x0075, 0x0072, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0064, + 0x0072, 0x0069, 0x0076, 0x0065, 0x0072, 0x0073, 0x0020, 0x0061, 0x0070, 0x0070, 0x0065, 0x0061, 0x0072, 0x0020, 0x0074, 0x006f, + 0x0020, 0x0062, 0x0065, 0x0020, 0x0064, 0x0065, 0x0066, 0x0065, 0x0063, 0x0074, 0x0069, 0x0076, 0x0065, 0x002e, 0x0020, 0x0054, + 0x0068, 0x0065, 0x0020, 0x0066, 0x0075, 0x006e, 0x0063, 0x0074, 0x0069, 0x006f, 0x006e, 0x0020, 0x0077, 0x0068, 0x0069, 0x0063, + 0x0068, 0x0020, 0x0063, 0x0061, 0x0075, 0x0073, 0x0065, 0x0064, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0070, 0x0072, 0x006f, + 0x0062, 0x006c, 0x0065, 0x006d, 0x0020, 0x0077, 0x0069, 0x006c, 0x006c, 0x0020, 0x0062, 0x0065, 0x0020, 0x0061, 0x0076, 0x006f, + 0x0069, 0x0064, 0x0065, 0x0064, 0x0020, 0x0066, 0x0072, 0x006f, 0x006d, 0x0020, 0x006e, 0x006f, 0x0077, 0x0020, 0x006f, 0x006e, + 0x002c, 0x0020, 0x0061, 0x006e, 0x0064, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, + 0x0071, 0x0075, 0x0061, 0x006c, 0x0069, 0x0074, 0x0079, 0x0020, 0x006d, 0x0061, 0x0079, 0x0020, 0x0073, 0x0075, 0x0066, 0x0066, + 0x0065, 0x0072, 0x0020, 0x0061, 0x0073, 0x0020, 0x0061, 0x0020, 0x0072, 0x0065, 0x0073, 0x0075, 0x006c, 0x0074, 0x002e, +// 159 +// One of the video sequences crashed during the game. In future, no more videos will be plyed. Please obtain new drivers from the manufacturer of your video card. + 0x00a1, + 0x004f, 0x006e, 0x0065, 0x0020, 0x006f, 0x0066, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, + 0x0020, 0x0073, 0x0065, 0x0071, 0x0075, 0x0065, 0x006e, 0x0063, 0x0065, 0x0073, 0x0020, 0x0063, 0x0072, 0x0061, 0x0073, 0x0068, + 0x0065, 0x0064, 0x0020, 0x0064, 0x0075, 0x0072, 0x0069, 0x006e, 0x0067, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x0067, 0x0061, + 0x006d, 0x0065, 0x002e, 0x0020, 0x0049, 0x006e, 0x0020, 0x0066, 0x0075, 0x0074, 0x0075, 0x0072, 0x0065, 0x002c, 0x0020, 0x006e, + 0x006f, 0x0020, 0x006d, 0x006f, 0x0072, 0x0065, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0073, 0x0020, 0x0077, 0x0069, + 0x006c, 0x006c, 0x0020, 0x0062, 0x0065, 0x0020, 0x0070, 0x006c, 0x0079, 0x0065, 0x0064, 0x002e, 0x0020, 0x0050, 0x006c, 0x0065, + 0x0061, 0x0073, 0x0065, 0x0020, 0x006f, 0x0062, 0x0074, 0x0061, 0x0069, 0x006e, 0x0020, 0x006e, 0x0065, 0x0077, 0x0020, 0x0064, + 0x0072, 0x0069, 0x0076, 0x0065, 0x0072, 0x0073, 0x0020, 0x0066, 0x0072, 0x006f, 0x006d, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, + 0x006d, 0x0061, 0x006e, 0x0075, 0x0066, 0x0061, 0x0063, 0x0074, 0x0075, 0x0072, 0x0065, 0x0072, 0x0020, 0x006f, 0x0066, 0x0020, + 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0063, 0x0061, 0x0072, 0x0064, 0x002e, + 0x0020, +}; + +static const WCHAR AppStringData_11[500] = { +// 160 +// Please insert the first BATTLE ISLE CD in your CD-ROM drive ! + 0x003d, + 0x0050, 0x006c, 0x0065, 0x0061, 0x0073, 0x0065, 0x0020, 0x0069, 0x006e, 0x0073, 0x0065, 0x0072, 0x0074, 0x0020, 0x0074, 0x0068, + 0x0065, 0x0020, 0x0066, 0x0069, 0x0072, 0x0073, 0x0074, 0x0020, 0x0042, 0x0041, 0x0054, 0x0054, 0x004c, 0x0045, 0x0020, 0x0049, + 0x0053, 0x004c, 0x0045, 0x0020, 0x0043, 0x0044, 0x0020, 0x0069, 0x006e, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x0043, + 0x0044, 0x002d, 0x0052, 0x004f, 0x004d, 0x0020, 0x0064, 0x0072, 0x0069, 0x0076, 0x0065, 0x0020, 0x0021, +// 161 +// An error arose while the last video was being played, indicating that your video driver is defective. Do you want video playing to be turned off to avoid a further crash? + 0x00aa, + 0x0041, 0x006e, 0x0020, 0x0065, 0x0072, 0x0072, 0x006f, 0x0072, 0x0020, 0x0061, 0x0072, 0x006f, 0x0073, 0x0065, 0x0020, 0x0077, + 0x0068, 0x0069, 0x006c, 0x0065, 0x0020, 0x0074, 0x0068, 0x0065, 0x0020, 0x006c, 0x0061, 0x0073, 0x0074, 0x0020, 0x0076, 0x0069, + 0x0064, 0x0065, 0x006f, 0x0020, 0x0077, 0x0061, 0x0073, 0x0020, 0x0062, 0x0065, 0x0069, 0x006e, 0x0067, 0x0020, 0x0070, 0x006c, + 0x0061, 0x0079, 0x0065, 0x0064, 0x002c, 0x0020, 0x0069, 0x006e, 0x0064, 0x0069, 0x0063, 0x0061, 0x0074, 0x0069, 0x006e, 0x0067, + 0x0020, 0x0074, 0x0068, 0x0061, 0x0074, 0x0020, 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, + 0x0020, 0x0064, 0x0072, 0x0069, 0x0076, 0x0065, 0x0072, 0x0020, 0x0069, 0x0073, 0x0020, 0x0064, 0x0065, 0x0066, 0x0065, 0x0063, + 0x0074, 0x0069, 0x0076, 0x0065, 0x002e, 0x0020, 0x0044, 0x006f, 0x0020, 0x0079, 0x006f, 0x0075, 0x0020, 0x0077, 0x0061, 0x006e, + 0x0074, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x0070, 0x006c, 0x0061, 0x0079, 0x0069, 0x006e, 0x0067, 0x0020, + 0x0074, 0x006f, 0x0020, 0x0062, 0x0065, 0x0020, 0x0074, 0x0075, 0x0072, 0x006e, 0x0065, 0x0064, 0x0020, 0x006f, 0x0066, 0x0066, + 0x0020, 0x0074, 0x006f, 0x0020, 0x0061, 0x0076, 0x006f, 0x0069, 0x0064, 0x0020, 0x0061, 0x0020, 0x0066, 0x0075, 0x0072, 0x0074, + 0x0068, 0x0065, 0x0072, 0x0020, 0x0063, 0x0072, 0x0061, 0x0073, 0x0068, 0x003f, +// 162 +// BATTLE ISLE is ready and awaits your orders! + 0x002c, + 0x0042, 0x0041, 0x0054, 0x0054, 0x004c, 0x0045, 0x0020, 0x0049, 0x0053, 0x004c, 0x0045, 0x0020, 0x0069, 0x0073, 0x0020, 0x0072, + 0x0065, 0x0061, 0x0064, 0x0079, 0x0020, 0x0061, 0x006e, 0x0064, 0x0020, 0x0061, 0x0077, 0x0061, 0x0069, 0x0074, 0x0073, 0x0020, + 0x0079, 0x006f, 0x0075, 0x0072, 0x0020, 0x006f, 0x0072, 0x0064, 0x0065, 0x0072, 0x0073, 0x0021, +// 163 +// This demo - version does not contain any video - sequences nor animations! You will not be able to save or load a game\n\nThe full - version contains more than 1 gigabyte of videosequences and 40 different maps. + 0x00d1, + 0x0054, 0x0068, 0x0069, 0x0073, 0x0020, 0x0064, 0x0065, 0x006d, 0x006f, 0x0020, 0x002d, 0x0020, 0x0076, 0x0065, 0x0072, 0x0073, + 0x0069, 0x006f, 0x006e, 0x0020, 0x0064, 0x006f, 0x0065, 0x0073, 0x0020, 0x006e, 0x006f, 0x0074, 0x0020, 0x0063, 0x006f, 0x006e, + 0x0074, 0x0061, 0x0069, 0x006e, 0x0020, 0x0061, 0x006e, 0x0079, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, 0x006f, 0x0020, 0x002d, + 0x0020, 0x0073, 0x0065, 0x0071, 0x0075, 0x0065, 0x006e, 0x0063, 0x0065, 0x0073, 0x0020, 0x006e, 0x006f, 0x0072, 0x0020, 0x0061, + 0x006e, 0x0069, 0x006d, 0x0061, 0x0074, 0x0069, 0x006f, 0x006e, 0x0073, 0x0021, 0x0020, 0x0059, 0x006f, 0x0075, 0x0020, 0x0077, + 0x0069, 0x006c, 0x006c, 0x0020, 0x006e, 0x006f, 0x0074, 0x0020, 0x0062, 0x0065, 0x0020, 0x0061, 0x0062, 0x006c, 0x0065, 0x0020, + 0x0074, 0x006f, 0x0020, 0x0073, 0x0061, 0x0076, 0x0065, 0x0020, 0x006f, 0x0072, 0x0020, 0x006c, 0x006f, 0x0061, 0x0064, 0x0020, + 0x0061, 0x0020, 0x0067, 0x0061, 0x006d, 0x0065, 0x000a, 0x000a, 0x0054, 0x0068, 0x0065, 0x0020, 0x0066, 0x0075, 0x006c, 0x006c, + 0x0020, 0x002d, 0x0020, 0x0076, 0x0065, 0x0072, 0x0073, 0x0069, 0x006f, 0x006e, 0x0020, 0x0063, 0x006f, 0x006e, 0x0074, 0x0061, + 0x0069, 0x006e, 0x0073, 0x0020, 0x006d, 0x006f, 0x0072, 0x0065, 0x0020, 0x0074, 0x0068, 0x0061, 0x006e, 0x0020, 0x0031, 0x0020, + 0x0067, 0x0069, 0x0067, 0x0061, 0x0062, 0x0079, 0x0074, 0x0065, 0x0020, 0x006f, 0x0066, 0x0020, 0x0076, 0x0069, 0x0064, 0x0065, + 0x006f, 0x0073, 0x0065, 0x0071, 0x0075, 0x0065, 0x006e, 0x0063, 0x0065, 0x0073, 0x0020, 0x0061, 0x006e, 0x0064, 0x0020, 0x0034, + 0x0030, 0x0020, 0x0064, 0x0069, 0x0066, 0x0066, 0x0065, 0x0072, 0x0065, 0x006e, 0x0074, 0x0020, 0x006d, 0x0061, 0x0070, 0x0073, + 0x002e, +// 164 +// + 0x0000, +// 165 +// + 0x0000, +// 166 +// + 0x0000, +// 167 +// + 0x0000, +// 168 +// + 0x0000, +// 169 +// + 0x0000, +// 170 +// + 0x0000, +// 171 +// + 0x0000, +// 172 +// + 0x0000, +// 173 +// + 0x0000, +// 174 +// + 0x0000, +// 175 +// + 0x0000, +}; + +static const WCHAR * const AppStrings[NUM_STRING_RESOURCES] = { + AppStringData_1, + AppStringData_2, + AppStringData_3, + AppStringData_4, + AppStringData_5, + AppStringData_6, + AppStringData_7, + AppStringData_8, + AppStringData_9, + AppStringData_10, + AppStringData_11, +}; + +static char **AppAnsiStrings = NULL; + + +void *resource_LoadAppIcon(void) +{ + if (hAppIcon == NULL) + { + hAppIcon = CreateIconFromResource((PBYTE)bAppIconDIB, 744, TRUE, 0x00030000); + } + + return hAppIcon; +} + +int resource_LoadStringA(unsigned int uID, char *lpBuffer, int cchBufferMax) +{ + int foundStrLen, convertLen, counter; + const WCHAR *foundStr; + + if (lpBuffer == NULL) return 0; + + if (uID >= 16 * NUM_STRING_RESOURCES) return 0; + + foundStr = AppStrings[uID >> 4]; + foundStrLen = *foundStr; + foundStr++; + + for (counter = uID & 15; counter != 0; counter--) + { + foundStr += foundStrLen; + foundStrLen = *foundStr; + foundStr++; + } + + if (foundStrLen == 0) return 0; + + if (cchBufferMax == 0) + { + if (AppAnsiStrings == NULL) + { + AppAnsiStrings = (char **)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 16 * NUM_STRING_RESOURCES * sizeof(char *)); + if (AppAnsiStrings == NULL) return 0; + } + + if (AppAnsiStrings[uID] == NULL) + { + AppAnsiStrings[uID] = (char *)HeapAlloc(GetProcessHeap(), 0, foundStrLen); + if (AppAnsiStrings[uID] == NULL) return 0; + + WideCharToMultiByte(CP_ACP, 0, foundStr, foundStrLen, AppAnsiStrings[uID], foundStrLen, NULL, NULL); + } + + *(void **)lpBuffer = AppAnsiStrings[uID]; + return foundStrLen; + } + else + { + convertLen = (foundStrLen <= (cchBufferMax - 1)) ? foundStrLen : (cchBufferMax - 1); + + if ((AppAnsiStrings != NULL) && (AppAnsiStrings[uID] != NULL)) + { + CopyMemory(lpBuffer, AppAnsiStrings[uID], convertLen); + } + else + { + WideCharToMultiByte(CP_ACP, 0, foundStr, convertLen, lpBuffer, cchBufferMax, NULL, NULL); + } + + lpBuffer[convertLen] = 0; + + return convertLen; + } +} + diff --git a/games/Battle Isle 3/SR-BI3/SDIresource.h b/games/Battle Isle 3/SR-BI3/SDIresource.h new file mode 100644 index 0000000..deae3ef --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/SDIresource.h @@ -0,0 +1,41 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_SDIRESOURCE_H_INCLUDED_) +#define _SDIRESOURCE_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void *resource_LoadAppIcon(void); +int resource_LoadStringA(unsigned int uID, char *lpBuffer, int cchBufferMax); + +#ifdef __cplusplus +} +#endif + +#endif /* _SDIRESOURCE_H_INCLUDED_ */ diff --git a/games/Battle Isle 3/SR-BI3/SDIvideo.c b/games/Battle Isle 3/SR-BI3/SDIvideo.c new file mode 100644 index 0000000..87f370b --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/SDIvideo.c @@ -0,0 +1,1065 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if defined(__WINE__) || !defined(OLDVIDEO) +#define USE_QUICKTIMELIB +#else +#undef USE_QUICKTIMELIB +#endif + +#include "SDIvideo.h" +#include "BBDSA.h" +#if defined(USE_QUICKTIMELIB) +#include "BBSYSTEM.h" +#include +#include +#include +#endif +#include + + +typedef struct { + int32_t field00; + int32_t field04; + int32_t field08; + int32_t field0c; +} video_struct; + +typedef struct { + HWND hWnd; + uint32_t reserved[9]; +#if defined(USE_QUICKTIMELIB) + quicktime_t *qt; + + long frame_number; + long video_frames; + int video_width; + int video_height; + int64_t video_duration; + int video_time_scale; + int colormodel; + + int play_audio; + int audio_channels; + long audio_sample_rate; + int audio_format_size; + int decode_raw_audio; + int64_t audio_length; + + int32_t screen_width; + int32_t screen_height; + + int blit_mode; + int stretch_width; + int stretch_height; + HDC hAviDC; + HBITMAP hAviFrame; + uint8_t** rows; + + unsigned int last_frame; + unsigned int next_frame; + unsigned int first_frame; + + uint8_t *audio_buffer; + int16_t *audio_temp_buffer[2]; + HWAVEOUT hWaveOut; + WAVEHDR waveHeader[16]; + + int audio_temp_buffer_samples; + int audio_eof; + int current_header; +#endif +} AVI_struct; + + +static const char PRE_windowClass[] = "PREFIXCALLBACK"; +static const char POST_windowClass[] = "POSTFIXCALLBACK"; +static const char SS_windowClass[] = "SSCALLBACK"; + + +extern AVI_struct video_PRE_avi; +extern MCIDEVICEID video_PRE_mciId; +extern int32_t video_PRE_dword_4CF328; +extern int32_t video_PRE_dword_4CF32C; +extern video_struct video_PRE_stru_4CF330[33]; +extern volatile int32_t video_PRE_dword_4CF540; +extern volatile uint8_t video_PRE_byte_4CF544; +extern volatile uint8_t video_PRE_byte_4CF548; +extern volatile int32_t video_PRE_dword_4CF54C; +extern uint8_t video_PRE_byte_4CF550; + +extern AVI_struct video_POST_avi; +extern MCIDEVICEID video_POST_mciId; +extern video_struct video_POST_stru_4CFA40[3]; +extern volatile int32_t video_POST_dword_4CFA70; +extern volatile uint8_t video_POST_byte_4CFA74; +extern volatile uint8_t video_POST_byte_4CFA78; +extern volatile int32_t video_POST_dword_4CFA7C; +extern uint8_t video_POST_byte_4CFA80; + + +#if defined(USE_QUICKTIMELIB) + +static int close_video(AVI_struct *video) +{ + if (video->qt != NULL) + { + quicktime_close(video->qt); + video->qt = NULL; + } + + return 0; +} + +static int open_video(const char *path, AVI_struct *video) +{ +#if defined(__WINE__) + WCHAR pathW[MAX_PATH]; + char *pathUnix; +#endif + int color_models[3]; + lqt_sample_format_t format; + + video->hAviFrame = NULL; + video->rows = NULL; + video->frame_number = -1; + + video->audio_buffer = NULL; + video->audio_temp_buffer[0] = NULL; + video->hWaveOut = NULL; + +#if defined(__WINE__) + MultiByteToWideChar(CP_ACP, 0, path, -1, pathW, MAX_PATH); + pathUnix = wine_get_unix_file_name(pathW); + + video->qt = lqt_open_read(pathUnix); +#else + video->qt = lqt_open_read(path); +#endif + if (video->qt == NULL) return 0; + + if ((quicktime_video_tracks(video->qt) <= 0) || !quicktime_supported_video(video->qt, 0)) + { + close_video(video); + return 0; + } + + video->video_frames = quicktime_video_length(video->qt, 0); + + video->video_time_scale = lqt_video_time_scale(video->qt, 0); + video->video_duration = lqt_video_duration(video->qt, 0); + + video->video_width = quicktime_video_width(video->qt, 0); + video->video_height = quicktime_video_height(video->qt, 0); + + color_models[0] = BC_BGR888; + color_models[1] = BC_BGR8888; + color_models[2] = LQT_COLORMODEL_NONE; + video->colormodel = lqt_get_best_colormodel(video->qt, 0, color_models); + + lqt_set_cmodel(video->qt, 0, video->colormodel); + + + video->play_audio = 0; + if (quicktime_audio_tracks(video->qt) > 0) + { + if (quicktime_supported_audio(video->qt, 0)) + { + video->audio_channels = quicktime_track_channels(video->qt, 0); + video->audio_sample_rate = quicktime_sample_rate(video->qt, 0); + + if (((video->audio_channels == 1) || + (video->audio_channels == 2) + ) && + (video->audio_sample_rate > 0) && + (video->audio_sample_rate <= 48000) + ) + { + video->play_audio = 1; + } + } + } + + if (video->play_audio) + { + format = lqt_get_sample_format(video->qt, 0); + if ((format == LQT_SAMPLE_UINT8) || (format == LQT_SAMPLE_INT16)) + { + video->audio_format_size = (format == LQT_SAMPLE_UINT8)?1:2; + video->decode_raw_audio = 1; + } + else + { + video->audio_format_size = 2; + video->decode_raw_audio = 0; + } + + video->audio_length = quicktime_audio_length(video->qt, 0); + } + + return 1; +} + +static int play_video_prepare(uint32_t zoomed, AVI_struct *video) +{ + int x, y, width, height; + RECT rect; + struct { + BITMAPINFOHEADER bmiHeader; + RGBQUAD bmiColors[256]; + } bmi; + HGDIOBJ hAviSelected; + void *pAviData; + int rowspan, index; + int audio_buffer_size; + WAVEFORMATEX waveFormat; + + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + + DSA_GetScreenExtends_c(&(video->screen_width), &(video->screen_height)); + + + bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bmi.bmiHeader.biWidth = video->video_width; + bmi.bmiHeader.biHeight = -video->video_height; + bmi.bmiHeader.biPlanes = 1; + bmi.bmiHeader.biBitCount = (video->colormodel == BC_BGR888)?24:32; + bmi.bmiHeader.biCompression = BI_RGB; + bmi.bmiHeader.biSizeImage = 0; + bmi.bmiHeader.biXPelsPerMeter = 0; + bmi.bmiHeader.biYPelsPerMeter = 0; + bmi.bmiHeader.biClrUsed = 0; + bmi.bmiHeader.biClrImportant = 0; + + pAviData = NULL; + video->rows = (uint8_t **) HeapAlloc(GetProcessHeap(), 0, video->video_height * sizeof(uint8_t*)); + if (video->rows == NULL) + { + return 0; + } + + video->hAviDC = CreateCompatibleDC(NULL); + if (video->hAviDC != NULL) + { + video->hAviFrame = CreateDIBSection(video->hAviDC, (const BITMAPINFO *)&bmi, DIB_RGB_COLORS, &pAviData, NULL, 0); + if (video->hAviFrame != NULL) + { + hAviSelected = SelectObject(video->hAviDC, video->hAviFrame); + if (hAviSelected == NULL) + { + DeleteObject(video->hAviFrame); + DeleteDC(video->hAviDC); + pAviData = NULL; + } + } + else + { + DeleteDC(video->hAviDC); + pAviData = NULL; + } + } + + if (pAviData == NULL) + { + HeapFree(GetProcessHeap(), 0, video->rows); + video->rows = NULL; + return 0; + } + + rowspan = ((video->video_width * bmi.bmiHeader.biBitCount + 31) & ~31) >> 3; + + video->rows[0] = (uint8_t *)pAviData; + for (index = 1; index < video->video_height; index++) + { + video->rows[index] = video->rows[0] + index * rowspan; + } + + lqt_set_row_span(video->qt, 0, rowspan); + + + if (video->play_audio) + { + video->audio_temp_buffer_samples = (video->audio_sample_rate < 8000)?1024:(1024 * (video->audio_sample_rate / 11025)); + audio_buffer_size = 16 * video->audio_temp_buffer_samples * video->audio_format_size * video->audio_channels; + + video->audio_buffer = (uint8_t *) HeapAlloc(GetProcessHeap(), 0, audio_buffer_size); + if (video->audio_buffer != NULL) + { + if ((video->audio_channels > 1) && !video->decode_raw_audio) + { + video->audio_temp_buffer[0] = (int16_t *) HeapAlloc(GetProcessHeap(), 0, video->audio_channels * video->audio_temp_buffer_samples * sizeof(int16_t)); + if (video->audio_temp_buffer[0] == NULL) + { + HeapFree(GetProcessHeap(), 0, video->audio_buffer); + video->audio_buffer = NULL; + + } + else + { + video->audio_temp_buffer[1] = video->audio_temp_buffer[0] + video->audio_temp_buffer_samples; + } + } + } + + if (video->audio_buffer != NULL) + { + // initialize waveout + waveFormat.wFormatTag = WAVE_FORMAT_PCM; + waveFormat.nChannels = video->audio_channels; + waveFormat.nSamplesPerSec = video->audio_sample_rate; + waveFormat.nAvgBytesPerSec = video->audio_channels * video->audio_format_size * video->audio_sample_rate; + waveFormat.nBlockAlign = video->audio_channels * video->audio_format_size; + waveFormat.wBitsPerSample = video->audio_format_size * 8; + waveFormat.cbSize = 0; + + if (MMSYSERR_NOERROR != waveOutOpen(&(video->hWaveOut), WAVE_MAPPER, &waveFormat, 0, 0, WAVE_ALLOWSYNC)) + { + video->hWaveOut = NULL; + } + else + { + for (index = 0; index < 16; index++) + { + video->waveHeader[index].dwBufferLength = video->audio_temp_buffer_samples * video->audio_format_size * video->audio_channels; + video->waveHeader[index].lpData = (LPSTR)(video->audio_buffer + index * video->waveHeader[index].dwBufferLength); + video->waveHeader[index].dwFlags = 0; + + if (MMSYSERR_NOERROR != waveOutPrepareHeader(video->hWaveOut, &(video->waveHeader[index]), sizeof(WAVEHDR))) + { + for (index--; index >= 0; index--) + { + waveOutUnprepareHeader(video->hWaveOut, &(video->waveHeader[index]), sizeof(WAVEHDR)); + } + + waveOutClose(video->hWaveOut); + video->hWaveOut = NULL; + break; + } + + video->waveHeader[index].dwFlags |= WHDR_DONE; + } + } + } + } + + + if (zoomed & 0xff) + { + width = (video->screen_width <= 1024)?video->screen_width:1024; + height = (video->screen_height <= 768)?video->screen_height:768; + + x = (video->screen_width - width) >> 1; + y = video->screen_height - height; + + video->blit_mode = 1; + video->stretch_width = width; + video->stretch_height = height; + } + else + { + width = video->video_width; + height = video->video_height; + + x = (video->screen_width - width) >> 1; + y = (video->screen_height - height) >> 1; + + video->blit_mode = 0; + } + + MoveWindow(video->hWnd, x, y, width, height, FALSE); + ShowWindow(video->hWnd, TRUE); + + SetRect( + &rect, + (video->screen_width >> 1) - 158, + (video->screen_height >> 1) - 98, + (video->screen_width >> 1) + 158, + (video->screen_height >> 1) + 98 + ); + + if (SYSTEM_GetOS_c() != 2) + { + SetCursorPos(video->screen_width >> 1, video->screen_height >> 1); + ShowCursor(FALSE); + } + + ClipCursor(&rect); + + return 1; +} + +static int play_video_start(int start_frame, AVI_struct *video) +{ + int64_t start_time; + unsigned int start_ticks, start_samples; + + if (start_frame == 0) + { + start_ticks = 0; + + lqt_seek_video(video->qt, 0, 0); + + if (video->hWaveOut != NULL) + { + quicktime_set_audio_position(video->qt, 0, 0); + } + } + else if (start_frame < video->video_frames) + { + start_time = lqt_get_frame_time(video->qt, 0, start_frame); + start_ticks = (int) ((((double)start_time) / video->video_time_scale) * 1000); + + lqt_seek_video(video->qt, 0, start_time); + + if (video->hWaveOut != NULL) + { + start_samples = (int) ((((double)start_time) / video->video_time_scale) * video->audio_sample_rate); + quicktime_set_audio_position(video->qt, start_samples, 0); + } + } + else + { + return 0; + } + + video->frame_number = start_frame; + + // decode first frame + if (lqt_decode_video(video->qt, video->rows, 0)) + { + return 0; + } + + video->audio_eof = (video->hWaveOut != NULL)?0:1; + video->current_header = 0; + + video->next_frame = GetTickCount(); + video->first_frame = video->next_frame - start_ticks; + video->last_frame = video->first_frame + (int)((((double)video->video_duration) / video->video_time_scale) * 1000); + + return 1; +} + +static int play_video_process(AVI_struct *video) +{ + int diff_time, old_blt_mode; + HDC hDC; + int64_t next_frame_time, last_position; + int samples_available, index; + int16_t *output_i; + + diff_time = GetTickCount() - video->last_frame; + if (diff_time >= 0) + { + return 0; + } + + if (!video->audio_eof) + { + if (video->waveHeader[video->current_header].dwFlags & WHDR_DONE) + { + samples_available = video->audio_temp_buffer_samples; + + last_position = lqt_last_audio_position(video->qt, 0); + + if (samples_available >= video->audio_length - last_position) + { + samples_available = video->audio_length - last_position; + video->audio_eof = 1; + } + + if (video->decode_raw_audio) + { + samples_available = lqt_decode_audio_raw(video->qt, video->waveHeader[video->current_header].lpData, samples_available, 0); + } + else if (video->audio_channels == 1) + { + output_i = (int16_t *) video->waveHeader[video->current_header].lpData; + if (lqt_decode_audio_track(video->qt, &output_i, NULL, samples_available, 0)) + { + samples_available = 0; + } + } + else + { + if (lqt_decode_audio_track(video->qt, video->audio_temp_buffer, NULL, samples_available, 0)) + { + samples_available = 0; + } + else + { + for (index = 0; index < samples_available; index++) + { + ((int16_t *) video->waveHeader[video->current_header].lpData)[2 * index] = video->audio_temp_buffer[0][index]; + ((int16_t *) video->waveHeader[video->current_header].lpData)[2 * index + 1] = video->audio_temp_buffer[1][index]; + } + } + } + + if (samples_available == 0) + { + video->audio_eof = 1; + } + else + { + video->waveHeader[video->current_header].dwBufferLength = samples_available * video->audio_format_size * video->audio_channels; + video->waveHeader[video->current_header].dwFlags &= ~WHDR_DONE; + waveOutWrite(video->hWaveOut, &(video->waveHeader[video->current_header]), sizeof(WAVEHDR)); + video->current_header = (video->current_header + 1) & 15; + } + } + } + + diff_time = GetTickCount() - video->next_frame; + if (diff_time >= 0) + { + hDC = GetDC(video->hWnd); + if (video->blit_mode) + { + old_blt_mode = SetStretchBltMode(hDC, COLORONCOLOR); + StretchBlt(hDC, 0, 0, video->stretch_width, video->stretch_height, + video->hAviDC, 0, 0, video->video_width, video->video_height, + SRCCOPY); + SetStretchBltMode(hDC, old_blt_mode); + } + else + { + BitBlt(hDC, 0, 0, video->video_width, video->video_height, video->hAviDC, 0, 0, SRCCOPY); + } + ReleaseDC(video->hWnd, hDC); + + video->frame_number++; + + if (video->frame_number < video->video_frames) + { + next_frame_time = lqt_frame_time(video->qt, 0); + video->next_frame = video->first_frame + (int)((((double)next_frame_time) / video->video_time_scale) * 1000); + + if (lqt_decode_video(video->qt, video->rows, 0)) + { + return 0; + } + } + else + { + video->frame_number = video->video_frames; + video->next_frame = video->last_frame; + } + } + + return 1; +} + +static void play_video_stop(AVI_struct *video) +{ + if (video->hWaveOut != NULL) + { + waveOutReset(video->hWaveOut); + } +} + +static void play_video_unprepare(AVI_struct *video) +{ + int index; + + ShowCursor(TRUE); + ClipCursor(FALSE); + + ShowWindow(video->hWnd, FALSE); + MoveWindow(video->hWnd, video->screen_width, video->screen_height, 100, 100, FALSE); + + if (video->hWaveOut != NULL) + { + waveOutReset(video->hWaveOut); + for (index = 15; index >= 0; index--) + { + waveOutUnprepareHeader(video->hWaveOut, &(video->waveHeader[index]), sizeof(WAVEHDR)); + } + waveOutClose(video->hWaveOut); + video->hWaveOut = NULL; + } + if (video->audio_temp_buffer[0] != NULL) + { + HeapFree(GetProcessHeap(), 0, video->audio_temp_buffer[0]); + video->audio_temp_buffer[0] = NULL; + } + if (video->audio_buffer != NULL) + { + HeapFree(GetProcessHeap(), 0, video->audio_buffer); + video->audio_buffer = NULL; + } + + if (video->hAviFrame != NULL) + { + SelectObject(video->hAviDC, video->hAviFrame); + DeleteObject(video->hAviFrame); + video->hAviFrame = NULL; + DeleteDC(video->hAviDC); + video->hAviDC = NULL; + HeapFree(GetProcessHeap(), 0, video->rows); + video->rows = NULL; + } + + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); + SYSTEM_SystemTask_c(); +} + +#endif + + +static LRESULT WINAPI PRE_VideoCallback_c(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + int index, frame_number; +#if !defined(USE_QUICKTIMELIB) + MCI_STATUS_PARMS mciStatusParams; +#endif + PAINTSTRUCT paint; + + uMsg = uMsg & 0xffff; + + switch (uMsg) + { + case WM_ERASEBKGND: + return 0; + + case WM_PAINT: + BeginPaint(hWnd, &paint); + EndPaint(hWnd, &paint); + return 0; + + case WM_CHAR: +#if defined(USE_QUICKTIMELIB) + frame_number = video_PRE_avi.frame_number; +#else + mciStatusParams.dwCallback = 0; + mciStatusParams.dwItem = MCI_STATUS_POSITION; + mciStatusParams.dwTrack = 1; + + if (0 == mciSendCommandA(video_PRE_mciId, MCI_STATUS, MCI_STATUS_ITEM, (uintptr_t)&mciStatusParams)) + { + frame_number = (int32_t)mciStatusParams.dwReturn; + } + else frame_number = -1; +#endif + + if (frame_number >= 0) + { + for (index = 0; index < video_PRE_dword_4CF32C; index++) + { + if ((video_PRE_stru_4CF330[11 * video_PRE_dword_4CF328 + index].field00 <= frame_number) && + (video_PRE_stru_4CF330[11 * video_PRE_dword_4CF328 + index].field04 > frame_number) + ) + { + if (wParam == VK_SPACE) + { + video_PRE_dword_4CF540 = video_PRE_stru_4CF330[11 * video_PRE_dword_4CF328 + index].field0c; + return 0; + } + + if (wParam == VK_ESCAPE) + { + video_PRE_dword_4CF540 = video_PRE_stru_4CF330[11 * video_PRE_dword_4CF328 + index].field08; + if (index > 0) + { + video_PRE_byte_4CF548 = 1; + video_PRE_dword_4CF54C = index; + } + return 0; + } + } + } + } + + return DefWindowProcA(hWnd, uMsg, wParam, lParam); + +#if !defined(USE_QUICKTIMELIB) + case MM_MCINOTIFY: + if (!video_PRE_byte_4CF544) + { + video_PRE_dword_4CF540 = -1; + } + video_PRE_byte_4CF544 = 0; + return 0; +#endif + + default: + return DefWindowProcA(hWnd, uMsg, wParam, lParam); + } +} + +uint32_t video_RegisterClass_PRE_Video(void) +{ + WNDCLASSA wndClass; + + wndClass.style = CS_NOCLOSE | CS_DBLCLKS; + wndClass.lpfnWndProc = (WNDPROC)PRE_VideoCallback_c; + wndClass.cbClsExtra = 0; + wndClass.cbWndExtra = 0; + wndClass.hInstance = DSAWIN_GetInstance_c(); + wndClass.hIcon = NULL; + wndClass.hCursor = NULL; + wndClass.hbrBackground = NULL; + wndClass.lpszMenuName = NULL; + wndClass.lpszClassName = PRE_windowClass; + + return RegisterClassA(&wndClass); +} + +int video_Open_PRE_Video(const char *path) +{ +#if defined(USE_QUICKTIMELIB) + return open_video(path, &video_PRE_avi); +#else + return -1; +#endif +} + +int video_Close_PRE_Video(void) +{ +#if defined(USE_QUICKTIMELIB) + return close_video(&video_PRE_avi); +#else + return -1; +#endif +} + +int video_Play_PRE_Video(uint32_t zoomed) +{ +#if defined(USE_QUICKTIMELIB) + int start_frame; + + if (!play_video_prepare(zoomed, &video_PRE_avi)) + { + return 0; + } + + start_frame = 0; + video_PRE_dword_4CF540 = -2; + + while (video_PRE_dword_4CF540 != -1) + { + if (!play_video_start(start_frame, &video_PRE_avi)) + { + break; + } + + while (video_PRE_dword_4CF540 == -2) + { + if (!play_video_process(&video_PRE_avi)) + { + if (!video_PRE_byte_4CF544) + { + video_PRE_dword_4CF540 = -1; + } + video_PRE_byte_4CF544 = 0; + break; + } + + SYSTEM_SystemTask_c(); + + if (video_PRE_byte_4CF548) + { + if (video_PRE_stru_4CF330[11 * video_PRE_dword_4CF328 + video_PRE_dword_4CF54C].field04 <= video_PRE_avi.frame_number) + { + video_PRE_dword_4CF540 = -1; + } + } + + if (!SYSTEM_IsApplicationActive_c() && video_PRE_byte_4CF550) + { + // change: don't pause playback + //video_PRE_byte_4CF550 = 0; + //play_video_pause(&video_PRE_avi); + } + + if (SYSTEM_IsApplicationActive_c() && !video_PRE_byte_4CF550 ) + { + // change: don't resume playback + //video_PRE_byte_4CF550 = 1; + //play_video_resume(&video_PRE_avi); + } + } + + if ((video_PRE_dword_4CF540 == -1) || video_PRE_byte_4CF548) + { + break; + } + + video_PRE_byte_4CF544 = 1; + play_video_stop(&video_PRE_avi); + + start_frame = video_PRE_stru_4CF330[11 * video_PRE_dword_4CF328 + video_PRE_dword_4CF540].field00; + video_PRE_dword_4CF540 = -2; + } + + play_video_unprepare(&video_PRE_avi); + + return 0; +#else + return -1; +#endif +} + + +static LRESULT WINAPI POST_VideoCallback_c(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + int index, frame_number; +#if !defined(USE_QUICKTIMELIB) + MCI_STATUS_PARMS mciStatusParams; +#endif + PAINTSTRUCT paint; + + uMsg = uMsg & 0xffff; + + switch (uMsg) + { + case WM_ERASEBKGND: + return 0; + + case WM_PAINT: + BeginPaint(hWnd, &paint); + EndPaint(hWnd, &paint); + return 0; + + case WM_CHAR: +#if defined(USE_QUICKTIMELIB) + frame_number = video_POST_avi.frame_number; +#else + mciStatusParams.dwCallback = 0; + mciStatusParams.dwItem = MCI_STATUS_POSITION; + mciStatusParams.dwTrack = 1; + + if (0 == mciSendCommandA(video_POST_mciId, MCI_STATUS, MCI_STATUS_ITEM, (uintptr_t)&mciStatusParams)) + { + frame_number = (int32_t)mciStatusParams.dwReturn; + } + else frame_number = -1; +#endif + + if (frame_number >= 0) + { + for (index = 0; index < 3; index++) + { + if ((video_POST_stru_4CFA40[index].field00 <= frame_number) && + (video_POST_stru_4CFA40[index].field04 > frame_number) + ) + { + if (wParam == VK_SPACE) + { + video_POST_dword_4CFA70 = video_POST_stru_4CFA40[index].field0c; + return 0; + } + + if (wParam == VK_ESCAPE) + { + video_POST_dword_4CFA70 = video_POST_stru_4CFA40[index].field08; + if (index > 0) + { + video_POST_byte_4CFA78 = 1; + video_POST_dword_4CFA7C = index; + } + return 0; + } + } + } + } + + return DefWindowProcA(hWnd, uMsg, wParam, lParam); + +#if !defined(USE_QUICKTIMELIB) + case MM_MCINOTIFY: + if (!video_POST_byte_4CFA74) + { + video_POST_dword_4CFA70 = -1; + } + video_POST_byte_4CFA74 = 0; + return 0; +#endif + + default: + return DefWindowProcA(hWnd, uMsg, wParam, lParam); + } +} + +uint32_t video_RegisterClass_POST_Video(void) +{ + WNDCLASSA wndClass; + + wndClass.style = CS_NOCLOSE | CS_DBLCLKS; + wndClass.lpfnWndProc = (WNDPROC)POST_VideoCallback_c; + wndClass.cbClsExtra = 0; + wndClass.cbWndExtra = 0; + wndClass.hInstance = DSAWIN_GetInstance_c(); + wndClass.hIcon = NULL; + wndClass.hCursor = NULL; + wndClass.hbrBackground = NULL; + wndClass.lpszMenuName = NULL; + wndClass.lpszClassName = POST_windowClass; + + return RegisterClassA(&wndClass); +} + +int video_Open_POST_Video(const char *path) +{ +#if defined(USE_QUICKTIMELIB) + return open_video(path, &video_POST_avi); +#else + return -1; +#endif +} + +int video_Close_POST_Video(void) +{ +#if defined(USE_QUICKTIMELIB) + return close_video(&video_POST_avi); +#else + return -1; +#endif +} + +int video_Play_POST_Video(uint32_t zoomed) +{ +#if defined(USE_QUICKTIMELIB) + int start_frame; + + if (!play_video_prepare(zoomed, &video_POST_avi)) + { + return 0; + } + + start_frame = 0; + video_POST_dword_4CFA70 = -2; + + while (video_POST_dword_4CFA70 != -1) + { + if (!play_video_start(start_frame, &video_POST_avi)) + { + break; + } + + while (video_POST_dword_4CFA70 == -2) + { + if (!play_video_process(&video_POST_avi)) + { + if (!video_POST_byte_4CFA74) + { + video_POST_dword_4CFA70 = -1; + } + video_POST_byte_4CFA74 = 0; + break; + } + + SYSTEM_SystemTask_c(); + + if (video_POST_byte_4CFA78) + { + if (video_POST_stru_4CFA40[video_POST_dword_4CFA7C].field04 <= video_POST_avi.frame_number) + { + video_POST_dword_4CFA70 = -1; + } + } + + if (!SYSTEM_IsApplicationActive_c() && video_POST_byte_4CFA80) + { + // change: don't pause playback + //video_POST_byte_4CFA80 = 0; + //play_video_pause(&video_POST_avi); + } + + if (SYSTEM_IsApplicationActive_c() && !video_POST_byte_4CFA80) + { + // change: don't resume playback + //video_POST_byte_4CFA80 = 1; + //play_video_resume(&video_POST_avi); + } + } + + if ((video_POST_dword_4CFA70 == -1) || video_POST_byte_4CFA78) + { + break; + } + + video_POST_byte_4CFA74 = 1; + play_video_stop(&video_POST_avi); + + start_frame = video_POST_stru_4CFA40[video_POST_dword_4CFA70].field00; + video_POST_dword_4CFA70 = -2; + } + + play_video_unprepare(&video_POST_avi); + + return 0; +#else + return -1; +#endif +} + + +static LRESULT WINAPI SS_VideoCallback_c(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + PAINTSTRUCT paint; + + uMsg = uMsg & 0xffff; + + switch (uMsg) + { + case WM_PAINT: + BeginPaint(hWnd, &paint); + EndPaint(hWnd, &paint); + return 0; + + case WM_ERASEBKGND: + return 0; + + case MM_MCINOTIFY: + return 0; + + default: + return DefWindowProcA(hWnd, uMsg, wParam, lParam); + } +} + +uint32_t video_RegisterClass_SS_Video(void) +{ + WNDCLASSA wndClass; + + wndClass.style = CS_NOCLOSE | CS_DBLCLKS; + wndClass.lpfnWndProc = (WNDPROC)SS_VideoCallback_c; + wndClass.cbClsExtra = 0; + wndClass.cbWndExtra = 0; + wndClass.hInstance = DSAWIN_GetInstance_c(); + wndClass.hIcon = NULL; + wndClass.hCursor = NULL; + wndClass.hbrBackground = NULL; + wndClass.lpszMenuName = NULL; + wndClass.lpszClassName = SS_windowClass; + + return RegisterClassA(&wndClass); +} + diff --git a/games/Battle Isle 3/SR-BI3/SDIvideo.h b/games/Battle Isle 3/SR-BI3/SDIvideo.h new file mode 100644 index 0000000..06d3051 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/SDIvideo.h @@ -0,0 +1,50 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_SDIVIDEO_H_INCLUDED_) +#define _SDIVIDEO_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +uint32_t video_RegisterClass_PRE_Video(void); +int video_Open_PRE_Video(const char *path); +int video_Close_PRE_Video(void); +int video_Play_PRE_Video(uint32_t zoomed); + +uint32_t video_RegisterClass_POST_Video(void); +int video_Open_POST_Video(const char *path); +int video_Close_POST_Video(void); +int video_Play_POST_Video(uint32_t zoomed); + +uint32_t video_RegisterClass_SS_Video(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _SDIVIDEO_H_INCLUDED_ */ diff --git a/games/Battle Isle 3/SR-BI3/WinApi-gdi32.c b/games/Battle Isle 3/SR-BI3/WinApi-gdi32.c new file mode 100644 index 0000000..dbaf78f --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/WinApi-gdi32.c @@ -0,0 +1,68 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "WinApi-gdi32.h" +#define WIN32_LEAN_AND_MEAN +#include + +void * CreateFontIndirectA_c(const void * lplf) +{ + return CreateFontIndirectA((CONST LOGFONTA *)lplf); +} + +uint32_t DeleteObject_c(void * ho) +{ + return DeleteObject((HGDIOBJ)ho); +} + +uint32_t GdiFlush_c(void) +{ + return GdiFlush(); +} + +int32_t GetDeviceCaps_c(void * hdc, int32_t index) +{ + return GetDeviceCaps((HDC)hdc, index); +} + +uint32_t GetTextExtentPointA_c(void * hdc, const char * lpString, int32_t c, void * lpsz) +{ + return GetTextExtentPointA((HDC)hdc, lpString, c, (LPSIZE)lpsz); +} + +void * SelectObject_c(void * hdc, void * h) +{ + return SelectObject((HDC)hdc, (HGDIOBJ)h); +} + +int32_t SetBkMode_c(void * hdc, int32_t mode) +{ + return SetBkMode((HDC)hdc, mode); +} + +uint32_t TextOutA_c(void * hdc, int32_t x, int32_t y, const char * lpString, int32_t c) +{ + return TextOutA((HDC)hdc, x, y, lpString, c); +} + diff --git a/games/Battle Isle 3/SR-BI3/WinApi-gdi32.h b/games/Battle Isle 3/SR-BI3/WinApi-gdi32.h new file mode 100644 index 0000000..0697bc8 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/WinApi-gdi32.h @@ -0,0 +1,48 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_WINAPI_GDI32_H_INCLUDED_) +#define _WINAPI_GDI32_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void * CreateFontIndirectA_c(const void * lplf); +uint32_t DeleteObject_c(void * ho); +uint32_t GdiFlush_c(void); +int32_t GetDeviceCaps_c(void * hdc, int32_t index); +uint32_t GetTextExtentPointA_c(void * hdc, const char * lpString, int32_t c, void * lpsz); +void * SelectObject_c(void * hdc, void * h); +int32_t SetBkMode_c(void * hdc, int32_t mode); +uint32_t TextOutA_c(void * hdc, int32_t x, int32_t y, const char * lpString, int32_t c); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/games/Battle Isle 3/SR-BI3/WinApi-kernel32.c b/games/Battle Isle 3/SR-BI3/WinApi-kernel32.c new file mode 100644 index 0000000..cb78d1d --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/WinApi-kernel32.c @@ -0,0 +1,182 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "WinApi-kernel32.h" +#define WIN32_LEAN_AND_MEAN +#include + + +extern const char *SDI_INI_path; +extern const char *SDI_install_path; +extern const char *SDI_CD_path; + + +uint32_t CloseHandle_c(void * hObject) +{ + return CloseHandle((HANDLE)hObject); +} + +void * CreateFileA_c(const char * lpFileName, uint32_t dwDesiredAccess, uint32_t dwShareMode, void * lpSecurityAttributes, uint32_t dwCreationDisposition, uint32_t dwFlagsAndAttributes, void * hTemplateFile) +{ + return CreateFileA(lpFileName, dwDesiredAccess, dwShareMode, (LPSECURITY_ATTRIBUTES)lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, (HANDLE)hTemplateFile); +} + +uint32_t FindClose_c(void * hFindFile) +{ + return FindClose((HANDLE)hFindFile); +} + +void * FindFirstFileA_c(const char * lpFileName, void * lpFindFileData) +{ + return FindFirstFileA(lpFileName, (LPWIN32_FIND_DATAA)lpFindFileData); +} + +uint32_t FindNextFileA_c(void * hFindFile, void * lpFindFileData) +{ + return FindNextFileA((HANDLE)hFindFile, (LPWIN32_FIND_DATAA)lpFindFileData); +} + +uint32_t GetCurrentDirectoryA_c(uint32_t nBufferLength, char * lpBuffer) +{ + return GetCurrentDirectoryA(nBufferLength, lpBuffer); +} + +uint32_t GetPrivateProfileIntA_c(const char * lpAppName, const char * lpKeyName, int32_t nDefault, const char * lpFileName) +{ + // change: use full path to SDI.INI + //return GetPrivateProfileIntA(lpAppName, lpKeyName, nDefault, lpFileName); + return GetPrivateProfileIntA(lpAppName, lpKeyName, nDefault, SDI_INI_path); +} + +uint32_t GetPrivateProfileStringA_c(const char * lpAppName, const char * lpKeyName, const char * lpDefault, char * lpReturnedString, uint32_t nSize, const char * lpFileName) +{ + // change: don't get paths from SDI.INI + if (0 == lstrcmpiA(lpAppName, "FILES")) + { + const char *path; + int len; + + if ((0 == lstrcmpiA(lpKeyName, "SDIPATH")) || (0 == lstrcmpiA(lpKeyName, "PATH2"))) + { + path = SDI_install_path; + } + else if (0 == lstrcmpiA(lpKeyName, "PATH3")) + { + path = SDI_CD_path; + } + else + { + if (lpReturnedString != NULL) + { + *lpReturnedString = 0; + } + return 0; + } + + if (lpReturnedString == NULL) + { + return 0; + } + + len = lstrlenA(path); + if (len < nSize) + { + lstrcpyA(lpReturnedString, path); + return len; + } + else + { + lstrcpynA(lpReturnedString, path, nSize - 1); + return nSize - 1; + } + } + + // change: use full path to SDI.INI + //return GetPrivateProfileStringA(lpAppName, lpKeyName, lpDefault, lpReturnedString, nSize, lpFileName); + return GetPrivateProfileStringA(lpAppName, lpKeyName, lpDefault, lpReturnedString, nSize, SDI_INI_path); +} + +uint32_t GetTickCount_c(void) +{ + return GetTickCount(); +} + +void GlobalMemoryStatus_c(void * lpBuffer) +{ + // change: return saturated values + //return GlobalMemoryStatus((LPMEMORYSTATUS)lpBuffer); + MEMORYSTATUSEX status; + + ((LPMEMORYSTATUS)lpBuffer)->dwLength = sizeof(MEMORYSTATUS); + status.dwLength = sizeof(MEMORYSTATUSEX); + + if (GlobalMemoryStatusEx(&status)) + { + ((LPMEMORYSTATUS)lpBuffer)->dwMemoryLoad = status.dwMemoryLoad; + ((LPMEMORYSTATUS)lpBuffer)->dwTotalPhys = (status.ullTotalPhys <= MAXLONG ) ? status.ullTotalPhys : MAXLONG; + ((LPMEMORYSTATUS)lpBuffer)->dwAvailPhys = (status.ullAvailPhys <= 1000000000) ? status.ullAvailPhys : 1000000000; + ((LPMEMORYSTATUS)lpBuffer)->dwTotalPageFile = (status.ullTotalPageFile <= MAXLONG ) ? status.ullTotalPageFile : MAXLONG; + ((LPMEMORYSTATUS)lpBuffer)->dwAvailPageFile = (status.ullAvailPageFile <= 1000000000) ? status.ullAvailPageFile : 1000000000; + ((LPMEMORYSTATUS)lpBuffer)->dwTotalVirtual = (status.ullTotalVirtual <= MAXLONG ) ? status.ullTotalVirtual : MAXLONG; + ((LPMEMORYSTATUS)lpBuffer)->dwAvailVirtual = (status.ullAvailVirtual <= 1000000000) ? status.ullAvailVirtual : 1000000000; + } + else + { + ((LPMEMORYSTATUS)lpBuffer)->dwMemoryLoad = 100; + ((LPMEMORYSTATUS)lpBuffer)->dwTotalPhys = MAXLONG; + ((LPMEMORYSTATUS)lpBuffer)->dwAvailPhys = 0; + ((LPMEMORYSTATUS)lpBuffer)->dwTotalPageFile = MAXLONG; + ((LPMEMORYSTATUS)lpBuffer)->dwAvailPageFile = 0; + ((LPMEMORYSTATUS)lpBuffer)->dwTotalVirtual = MAXLONG; + ((LPMEMORYSTATUS)lpBuffer)->dwAvailVirtual = 0; + } +} + +uint32_t ReadFile_c(void * hFile, void * lpBuffer, uint32_t nNumberOfBytesToRead, uint32_t * lpNumberOfBytesRead, void * lpOverlapped) +{ + return ReadFile((HANDLE)hFile, lpBuffer, nNumberOfBytesToRead, (LPDWORD)lpNumberOfBytesRead, (LPOVERLAPPED)lpOverlapped); +} + +uint32_t SetCurrentDirectoryA_c(const char * lpPathName) +{ + return SetCurrentDirectoryA(lpPathName); +} + +uint32_t SetFilePointer_c(void * hFile, int32_t lDistanceToMove, int32_t * lpDistanceToMoveHigh, uint32_t dwMoveMethod) +{ + return SetFilePointer((HANDLE)hFile, lDistanceToMove, (PLONG)lpDistanceToMoveHigh, dwMoveMethod); +} + +uint32_t WriteFile_c(void * hFile, const void * lpBuffer, uint32_t nNumberOfBytesToWrite, uint32_t * lpNumberOfBytesWritten, void * lpOverlapped) +{ + return WriteFile((HANDLE)hFile, lpBuffer, nNumberOfBytesToWrite, (LPDWORD)lpNumberOfBytesWritten, (LPOVERLAPPED)lpOverlapped); +} + +uint32_t WritePrivateProfileStringA_c(const char * lpAppName, const char * lpKeyName, const char * lpString, const char * lpFileName) +{ + // change: use full path to SDI.INI + //return WritePrivateProfileStringA(lpAppName, lpKeyName, lpString, lpFileName); + return WritePrivateProfileStringA(lpAppName, lpKeyName, lpString, SDI_INI_path); +} + diff --git a/games/Battle Isle 3/SR-BI3/WinApi-kernel32.h b/games/Battle Isle 3/SR-BI3/WinApi-kernel32.h new file mode 100644 index 0000000..47080b0 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/WinApi-kernel32.h @@ -0,0 +1,55 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_WINAPI_KERNEL32_H_INCLUDED_) +#define _WINAPI_KERNEL32_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +uint32_t CloseHandle_c(void * hObject); +void * CreateFileA_c(const char * lpFileName, uint32_t dwDesiredAccess, uint32_t dwShareMode, void * lpSecurityAttributes, uint32_t dwCreationDisposition, uint32_t dwFlagsAndAttributes, void * hTemplateFile); +uint32_t FindClose_c(void * hFindFile); +void * FindFirstFileA_c(const char * lpFileName, void * lpFindFileData); +uint32_t FindNextFileA_c(void * hFindFile, void * lpFindFileData); +uint32_t GetCurrentDirectoryA_c(uint32_t nBufferLength, char * lpBuffer); +uint32_t GetPrivateProfileIntA_c(const char * lpAppName, const char * lpKeyName, int32_t nDefault, const char * lpFileName); +uint32_t GetPrivateProfileStringA_c(const char * lpAppName, const char * lpKeyName, const char * lpDefault, char * lpReturnedString, uint32_t nSize, const char * lpFileName); +uint32_t GetTickCount_c(void); +void GlobalMemoryStatus_c(void * lpBuffer); +uint32_t ReadFile_c(void * hFile, void * lpBuffer, uint32_t nNumberOfBytesToRead, uint32_t * lpNumberOfBytesRead, void * lpOverlapped); +uint32_t SetCurrentDirectoryA_c(const char * lpPathName); +uint32_t SetFilePointer_c(void * hFile, int32_t lDistanceToMove, int32_t * lpDistanceToMoveHigh, uint32_t dwMoveMethod); +uint32_t WriteFile_c(void * hFile, const void * lpBuffer, uint32_t nNumberOfBytesToWrite, uint32_t * lpNumberOfBytesWritten, void * lpOverlapped); +uint32_t WritePrivateProfileStringA_c(const char * lpAppName, const char * lpKeyName, const char * lpString, const char * lpFileName); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/games/Battle Isle 3/SR-BI3/WinApi-user32.c b/games/Battle Isle 3/SR-BI3/WinApi-user32.c new file mode 100644 index 0000000..dad1fa3 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/WinApi-user32.c @@ -0,0 +1,161 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "WinApi-user32.h" +#include "SDIresource.h" +#define WIN32_LEAN_AND_MEAN +#include + +uint32_t ClientToScreen_c(void * hWnd, void * lpPoint) +{ + return ClientToScreen((HWND)hWnd, (LPPOINT)lpPoint); +} + +uint32_t ClipCursor_c(const void * lpRect) +{ + return ClipCursor((CONST RECT *)lpRect); +} + +void * CreateWindowExA_c(uint32_t dwExStyle, const char * lpClassName, const char * lpWindowName, uint32_t dwStyle, int32_t X, int32_t Y, int32_t nWidth, int32_t nHeight, void * hWndParent, void * hMenu, void * hInstance, void * lpParam) +{ + return CreateWindowExA(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, (HWND)hWndParent, (HMENU)hMenu, (HINSTANCE)hInstance, lpParam); +} + +void * GetActiveWindow_c(void) +{ + return GetActiveWindow(); +} + +uint32_t GetCursorPos_c(void * lpPoint) +{ + return GetCursorPos((LPPOINT)lpPoint); +} + +void * GetDC_c(void * hWnd) +{ + return GetDC((HWND)hWnd); +} + +uint32_t GetWindowRect_c(void * hWnd, void * lpRect) +{ + return GetWindowRect((HWND)hWnd, (LPRECT)lpRect); +} + +uint32_t IsIconic_c(void * hWnd) +{ + return IsIconic((HWND)hWnd); +} + +uint32_t IsWindowVisible_c(void * hWnd) +{ + return IsWindowVisible((HWND)hWnd); +} + +void * LoadCursorA_c(void * hInstance, const char * lpCursorName) +{ + return LoadCursorA((HINSTANCE)hInstance, lpCursorName); +} + +int32_t LoadStringA_c(void * hInstance, uint32_t uID, char * lpBuffer, int32_t cchBufferMax) +{ + // change: don't load string from executable resources + //return LoadStringA((HINSTANCE)hInstance, uID, lpBuffer, cchBufferMax); + return resource_LoadStringA(uID, lpBuffer, cchBufferMax); +} + +int32_t MessageBoxA_c(void * hWnd, const char * lpText, const char * lpCaption, uint32_t uType) +{ + return MessageBoxA((HWND)hWnd, lpText, lpCaption, uType); +} + +uint32_t MoveWindow_c(void * hWnd, int32_t X, int32_t Y, int32_t nWidth, int32_t nHeight, uint32_t bRepaint) +{ + return MoveWindow((HWND)hWnd, X, Y, nWidth, nHeight, bRepaint); +} + +uint32_t ReleaseCapture_c(void) +{ + return ReleaseCapture(); +} + +int32_t ReleaseDC_c(void * hWnd, void * hDC) +{ + return ReleaseDC((HWND)hWnd, (HDC)hDC); +} + +uint32_t ScreenToClient_c(void * hWnd, void * lpPoint) +{ + return ScreenToClient((HWND)hWnd, (LPPOINT)lpPoint); +} + +int32_t SendMessageA_c(void * hWnd, uint32_t Msg, uint32_t wParam, uint32_t lParam) +{ + return SendMessageA((HWND)hWnd, Msg, wParam, lParam); +} + +void * SetActiveWindow_c(void * hWnd) +{ + return SetActiveWindow((HWND)hWnd); +} + +void * SetCursor_c(void * hCursor) +{ + return SetCursor((HCURSOR)hCursor); +} + +uint32_t SetCursorPos_c(int32_t X, int32_t Y) +{ + return SetCursorPos(X, Y); +} + +uint32_t SetRect_c(void * lprc, int32_t xLeft, int32_t yTop, int32_t xRight, int32_t yBottom) +{ + return SetRect((LPRECT)lprc, xLeft, yTop, xRight, yBottom); +} + +uint32_t SetRectEmpty_c(void * lprc) +{ + return SetRectEmpty((LPRECT)lprc); +} + +uint32_t SetWindowPos_c(void * hWnd, void * hWndInsertAfter, int32_t X, int32_t Y, int32_t cx, int32_t cy, uint32_t uFlags) +{ + return SetWindowPos((HWND)hWnd, (HWND)hWndInsertAfter, X, Y, cx, cy, uFlags); +} + +int32_t ShowCursor_c(uint32_t bShow) +{ + return ShowCursor(bShow); +} + +uint32_t ShowWindow_c(void * hWnd, int32_t nCmdShow) +{ + return ShowWindow((HWND)hWnd, nCmdShow); +} + +uint32_t UnregisterClassA_c(const char * lpClassName, void * hInstance) +{ + return UnregisterClassA(lpClassName, (HINSTANCE)hInstance); +} + diff --git a/games/Battle Isle 3/SR-BI3/WinApi-user32.h b/games/Battle Isle 3/SR-BI3/WinApi-user32.h new file mode 100644 index 0000000..78ff255 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/WinApi-user32.h @@ -0,0 +1,66 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_WINAPI_USER32_H_INCLUDED_) +#define _WINAPI_USER32_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +uint32_t ClientToScreen_c(void * hWnd, void * lpPoint); +uint32_t ClipCursor_c(const void * lpRect); +void * CreateWindowExA_c(uint32_t dwExStyle, const char * lpClassName, const char * lpWindowName, uint32_t dwStyle, int32_t X, int32_t Y, int32_t nWidth, int32_t nHeight, void * hWndParent, void * hMenu, void * hInstance, void * lpParam); +void * GetActiveWindow_c(void); +uint32_t GetCursorPos_c(void * lpPoint); +void * GetDC_c(void * hWnd); +uint32_t GetWindowRect_c(void * hWnd, void * lpRect); +uint32_t IsIconic_c(void * hWnd); +uint32_t IsWindowVisible_c(void * hWnd); +void * LoadCursorA_c(void * hInstance, const char * lpCursorName); +int32_t LoadStringA_c(void * hInstance, uint32_t uID, char * lpBuffer, int32_t cchBufferMax); +int32_t MessageBoxA_c(void * hWnd, const char * lpText, const char * lpCaption, uint32_t uType); +uint32_t MoveWindow_c(void * hWnd, int32_t X, int32_t Y, int32_t nWidth, int32_t nHeight, uint32_t bRepaint); +uint32_t ReleaseCapture_c(void); +int32_t ReleaseDC_c(void * hWnd, void * hDC); +uint32_t ScreenToClient_c(void * hWnd, void * lpPoint); +int32_t SendMessageA_c(void * hWnd, uint32_t Msg, uint32_t wParam, uint32_t lParam); +void * SetActiveWindow_c(void * hWnd); +void * SetCursor_c(void * hCursor); +uint32_t SetCursorPos_c(int32_t X, int32_t Y); +uint32_t SetRect_c(void * lprc, int32_t xLeft, int32_t yTop, int32_t xRight, int32_t yBottom); +uint32_t SetRectEmpty_c(void * lprc); +uint32_t SetWindowPos_c(void * hWnd, void * hWndInsertAfter, int32_t X, int32_t Y, int32_t cx, int32_t cy, uint32_t uFlags); +int32_t ShowCursor_c(uint32_t bShow); +uint32_t ShowWindow_c(void * hWnd, int32_t nCmdShow); +uint32_t UnregisterClassA_c(const char * lpClassName, void * hInstance); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/games/Battle Isle 3/SR-BI3/WinApi-wing32.c b/games/Battle Isle 3/SR-BI3/WinApi-wing32.c new file mode 100644 index 0000000..4a13f33 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/WinApi-wing32.c @@ -0,0 +1,60 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "WinApi-wing32.h" +#define WIN32_LEAN_AND_MEAN +#include + +uint32_t WinGBitBlt_c( void * hdcDst, int32_t xDst, int32_t yDst, int32_t width, int32_t height, void * hdcSrc, int32_t xSrc, int32_t ySrc ) +{ + return BitBlt( (HDC)hdcDst, xDst, yDst, width, height, (HDC)hdcSrc, xSrc, ySrc, SRCCOPY ); +} + +void * WinGCreateBitmap_c( void * hdc, void *bmi, void **bits ) +{ + return CreateDIBSection( (HDC)hdc, (BITMAPINFO *)bmi, DIB_RGB_COLORS, bits, NULL, 0 ); +} + +void * WinGCreateDC_c( void ) +{ + return CreateCompatibleDC( NULL ); +} + +uint32_t WinGSetDIBColorTable_c( void * hdc, uint32_t start, uint32_t end, void *colors ) +{ + return SetDIBColorTable( (HDC)hdc, start, end, (RGBQUAD *)colors ); +} + +uint32_t WinGStretchBlt_c( void * hdcDst, int32_t xDst, int32_t yDst, int32_t widthDst, int32_t heightDst, void * hdcSrc, int32_t xSrc, int32_t ySrc, int32_t widthSrc, int32_t heightSrc ) +{ + INT prev_mode; + BOOL retval; + + prev_mode = SetStretchBltMode( (HDC)hdcDst, COLORONCOLOR ); + retval = StretchBlt( (HDC)hdcDst, xDst, yDst, widthDst, heightDst, (HDC)hdcSrc, xSrc, ySrc, widthSrc, heightSrc, SRCCOPY ); + SetStretchBltMode( (HDC)hdcDst, prev_mode ); + + return retval; +} + diff --git a/games/Battle Isle 3/SR-BI3/WinApi-wing32.h b/games/Battle Isle 3/SR-BI3/WinApi-wing32.h new file mode 100644 index 0000000..ce58857 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/WinApi-wing32.h @@ -0,0 +1,45 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_WINAPI_WING32_H_INCLUDED_) +#define _WINAPI_WING32_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +uint32_t WinGBitBlt_c( void * hdcDst, int32_t xDst, int32_t yDst, int32_t width, int32_t height, void * hdcSrc, int32_t xSrc, int32_t ySrc ); +void * WinGCreateBitmap_c( void * hdc, void *bmi, void **bits ); +void * WinGCreateDC_c( void ); +uint32_t WinGSetDIBColorTable_c( void * hdc, uint32_t start, uint32_t end, void *colors ); +uint32_t WinGStretchBlt_c( void * hdcDst, int32_t xDst, int32_t yDst, int32_t widthDst, int32_t heightDst, void * hdcSrc, int32_t xSrc, int32_t ySrc, int32_t widthSrc, int32_t heightSrc ); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/games/Battle Isle 3/SR-BI3/WinApi-winmm.c b/games/Battle Isle 3/SR-BI3/WinApi-winmm.c new file mode 100644 index 0000000..3cfd06f --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/WinApi-winmm.c @@ -0,0 +1,42 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "WinApi-winmm.h" +#include + +uint32_t mciGetErrorStringA_c(uint32_t mcierr, char * pszText, uint32_t cchText) +{ + return mciGetErrorStringA(mcierr, pszText, cchText); +} + +uint32_t mciSendCommandA_c(uint32_t mciId, uint32_t uMsg, uint32_t * dwParam1, uint32_t * dwParam2) +{ +#if defined(__WINE__) + // when using wine, this is called only by the detection, so it's ok to return 0 (= OK) + return 0; +#else + return mciSendCommandA(mciId, uMsg, (DWORD_PTR)dwParam1, (DWORD_PTR)dwParam2); +#endif +} + diff --git a/games/Battle Isle 3/SR-BI3/WinApi-winmm.h b/games/Battle Isle 3/SR-BI3/WinApi-winmm.h new file mode 100644 index 0000000..5d65256 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/WinApi-winmm.h @@ -0,0 +1,42 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_WINAPI_WINMM_H_INCLUDED_) +#define _WINAPI_WINMM_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +uint32_t mciGetErrorStringA_c(uint32_t mcierr, char * pszText, uint32_t cchText); +uint32_t mciSendCommandA_c(uint32_t mciId, uint32_t uMsg, uint32_t * dwParam1, uint32_t * dwParam2); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/games/Battle Isle 3/SR-BI3/llasm/BASELIBR.llasm b/games/Battle Isle 3/SR-BI3/llasm/BASELIBR.llasm new file mode 100644 index 0000000..ae42c3b --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/BASELIBR.llasm @@ -0,0 +1,71 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +datasegment .bss uninitialized + +dlabel sl_left_capture global +dlabel _sl_left_capture global +dskip 4 +dlabel sl_top_capture global +dlabel _sl_top_capture global +dskip 4 +dlabel sl_bottom_capture global +dlabel _sl_bottom_capture global +dskip 4 +dlabel sl_right_capture global +dlabel _sl_right_capture global +dskip 4 + +endd + +datasegment .data + +dlabel p_last_touched_screen global +dlabel _p_last_touched_screen global +db 0 dup 4 +dlabel sl_screenwidth global +dlabel _sl_screenwidth global +db 0 dup 4 +dlabel sl_screenheight global +dlabel _sl_screenheight global +db 0 dup 4 +dlabel p_mouse_gui global +dlabel _p_mouse_gui global +db 0 dup 4 +dlabel h_mouse_win global +dlabel _h_mouse_win global +db 0 dup 4 +dlabel b_mouse_capture_on global +dlabel _b_mouse_capture_on global +db 0 dup 4 +dlabel b_application_active global +dlabel _b_application_active global +db 0 dup 4 +dlabel w_avi_device_id global +dlabel _w_avi_device_id global +db 0xff +db 0xff +db 0 +db 0 + +endd + diff --git a/games/Battle Isle 3/SR-BI3/llasm/BBAVI-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/BBAVI-asm.llasm new file mode 100644 index 0000000..bd6cd0d --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/BBAVI-asm.llasm @@ -0,0 +1,109 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +func AVI_Init_c +funcv AVI_Exit_c +funcv AVI_SetDestortionLevel_c destortionLevel +func AVI_OpenVideo_c *path, *param2 +funcv AVI_CloseVideo_c *video +func AVI_PlayVideo_c *video, x, y, param4, param5, volume, flags + +proc AVI_Init public + +; [esp ] = return address + + Call_Asm_Stack0 AVI_Init_c + + Call_Asm_Return 0 + +endp ; end procedure AVI_Init + + +proc AVI_Exit public + +; [esp ] = return address + + Call_Asm_Stack0_void AVI_Exit_c + + Call_Asm_Return 0 + +endp ; end procedure AVI_Exit + + +proc AVI_SetDestortionLevel public + +; [esp + 4] = int destortionLevel +; [esp ] = return address + + Call_Asm_Stack1_void AVI_SetDestortionLevel_c + + Call_Asm_Return 0 + +endp ; end procedure AVI_SetDestortionLevel + + +proc AVI_OpenVideo public + +; [esp + 2*4] = const uint8_t * param2 +; [esp + 4] = const char * path +; [esp ] = return address + + Call_Asm_Stack2 AVI_OpenVideo_c + + Call_Asm_Return 0 + +endp ; end procedure AVI_OpenVideo + + +proc AVI_CloseVideo public + +; [esp + 4] = void * video +; [esp ] = return address + + Call_Asm_Stack1_void AVI_CloseVideo_c + + Call_Asm_Return 0 + +endp ; end procedure AVI_CloseVideo + + +proc AVI_PlayVideo public + +; [esp + 7*4] = unsigned int flags +; [esp + 6*4] = int volume +; [esp + 5*4] = int param5 +; [esp + 4*4] = int param4 +; [esp + 3*4] = int y +; [esp + 2*4] = int x +; [esp + 4] = void * video +; [esp ] = return address + + Call_Asm_Stack7 AVI_PlayVideo_c + + Call_Asm_Return 0 + +endp ; end procedure AVI_PlayVideo + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/BBBLEV-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/BBBLEV-asm.llasm new file mode 100644 index 0000000..84720f4 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/BBBLEV-asm.llasm @@ -0,0 +1,101 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +func BLEV_Init_c +funcv BLEV_Exit_c +funcv BLEV_ClearAllEvents_c +func BLEV_PutEvent_c *event +func BLEV_GetEvent_c *event +func BLEV_PeekEvent_c *event + +proc BLEV_Init public + +; [esp ] = return address + + Call_Asm_Stack0 BLEV_Init_c + + Call_Asm_Return 0 + +endp ; end procedure BLEV_Init + + +proc BLEV_Exit public + +; [esp ] = return address + + Call_Asm_Stack0_void BLEV_Exit_c + + Call_Asm_Return 0 + +endp ; end procedure BLEV_Exit + + +proc BLEV_ClearAllEvents public + +; [esp ] = return address + + Call_Asm_Stack0_void BLEV_ClearAllEvents_c + + Call_Asm_Return 0 + +endp ; end procedure BLEV_ClearAllEvents + + +proc BLEV_PutEvent public + +; [esp + 4] = const BLEV_Event * event +; [esp ] = return address + + Call_Asm_Stack1 BLEV_PutEvent_c + + Call_Asm_Return 0 + +endp ; end procedure BLEV_PutEvent + + +proc BLEV_GetEvent public + +; [esp + 4] = BLEV_Event * event +; [esp ] = return address + + Call_Asm_Stack1 BLEV_GetEvent_c + + Call_Asm_Return 0 + +endp ; end procedure BLEV_GetEvent + + +proc BLEV_PeekEvent public + +; [esp + 4] = BLEV_Event * event +; [esp ] = return address + + Call_Asm_Stack1 BLEV_PeekEvent_c + + Call_Asm_Return 0 + +endp ; end procedure BLEV_PeekEvent + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/BBDBG-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/BBDBG-asm.llasm new file mode 100644 index 0000000..ea9e2d3 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/BBDBG-asm.llasm @@ -0,0 +1,64 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +funcv DBG_Panic_c *module, line +func DBG_Init_c +funcv DBG_Exit_c + +proc DBG_Panic public + +; [esp + 2*4] = int line +; [esp + 4] = const char * module +; [esp ] = return address + + Call_Asm_Stack2_void DBG_Panic_c + + Call_Asm_Return 0 + +endp ; end procedure DBG_Panic + + +proc DBG_Init public + +; [esp ] = return address + + Call_Asm_Stack0 DBG_Init_c + + Call_Asm_Return 0 + +endp ; end procedure DBG_Init + + +proc DBG_Exit public + +; [esp ] = return address + + Call_Asm_Stack0_void DBG_Exit_c + + Call_Asm_Return 0 + +endp ; end procedure DBG_Exit + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/BBDEPACK-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/BBDEPACK-asm.llasm new file mode 100644 index 0000000..73af380 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/BBDEPACK-asm.llasm @@ -0,0 +1,40 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +func DEPACK_c *src, *dst + +proc DEPACK public + +; [esp + 2*4] = uint8_t * dst +; [esp + 4] = const uint8_t * src +; [esp ] = return address + + Call_Asm_Stack2 DEPACK_c + + Call_Asm_Return 0 + +endp ; end procedure DEPACK + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/BBDOS-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/BBDOS-asm.llasm new file mode 100644 index 0000000..b58e0c8 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/BBDOS-asm.llasm @@ -0,0 +1,149 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +func DOS_Init_c +funcv DOS_Exit_c +func DOS_Open_c *path, mode +func DOS_Close_c file_handle +func DOS_Read_c file_handle, *buffer, length +func DOS_Write_c file_handle, *buffer, length +func DOS_Seek_c file_handle, origin, offset +func DOS_ReadFile_c *path, *buffer +func DOS_GetFileLength_c *path + +proc DOS_Init public + +; [esp ] = return address + + Call_Asm_Stack0 DOS_Init_c + + Call_Asm_Return 0 + +endp ; end procedure DOS_Init + + +proc DOS_Exit public + +; [esp ] = return address + + Call_Asm_Stack0_void DOS_Exit_c + + Call_Asm_Return 0 + +endp ; end procedure DOS_Exit + + +proc DOS_Open public + +; [esp + 2*4] = unsigned int mode +; [esp + 4] = const char * path +; [esp ] = return address + + Call_Asm_Stack2 DOS_Open_c + + Call_Asm_Return 0 + +endp ; end procedure DOS_Open + + +proc DOS_Close public + +; [esp + 4] = int file_handle +; [esp ] = return address + + Call_Asm_Stack1 DOS_Close_c + + Call_Asm_Return 0 + +endp ; end procedure DOS_Close + + +proc DOS_Read public + +; [esp + 3*4] = unsigned int length +; [esp + 2*4] = void * buffer +; [esp + 4] = int file_handle +; [esp ] = return address + + Call_Asm_Stack3 DOS_Read_c + + Call_Asm_Return 0 + +endp ; end procedure DOS_Read + + +proc DOS_Write public + +; [esp + 3*4] = unsigned int length +; [esp + 2*4] = const void * buffer +; [esp + 4] = int file_handle +; [esp ] = return address + + Call_Asm_Stack3 DOS_Write_c + + Call_Asm_Return 0 + +endp ; end procedure DOS_Write + + +proc DOS_Seek public + +; [esp + 3*4] = int offset +; [esp + 2*4] = int origin +; [esp + 4] = int file_handle +; [esp ] = return address + + Call_Asm_Stack3 DOS_Seek_c + + Call_Asm_Return 0 + +endp ; end procedure DOS_Seek + + +proc DOS_ReadFile public + +; [esp + 2*4] = void * buffer +; [esp + 4] = const char * path +; [esp ] = return address + + Call_Asm_Stack2 DOS_ReadFile_c + + Call_Asm_Return 0 + +endp ; end procedure DOS_ReadFile + + +proc DOS_GetFileLength public + +; [esp + 4] = const char * path +; [esp ] = return address + + Call_Asm_Stack1 DOS_GetFileLength_c + + Call_Asm_Return 0 + +endp ; end procedure DOS_GetFileLength + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/BBDSA-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/BBDSA-asm.llasm new file mode 100644 index 0000000..290a065 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/BBDSA-asm.llasm @@ -0,0 +1,534 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +funcv DSA_ReuseStaticColors_c osVersions +funcv DSA_FreeStaticColors_c osVersions +funcv DSAWIN_PrepareInit_c *hInstance +func DSAWIN_GetMainWindowHandle_c +func DSAWIN_GetInstance_c +func DSA_Init_c +funcv DSA_Exit_c +func DSA_OpenScreen_c *screen, *opm, param3, *windowName, x, y, type +funcv DSA_CloseScreen_c *screen +funcv DSA_CopyMainOPMToScreen_c *screen, onlyModified +funcv DSA_StretchOPMToScreen_c *screen, xDst, yDst, widthDst, heightDst, *opm, xSrc, ySrc, widthSrc, heightSrc +funcv DSA_CopyOPMToScreenEx_c *screen, xDst, yDst, width, height, *opm, xSrc, ySrc +funcv DSA_TotalRepaint_c +funcv DSA_MoveScreen_c *screen, changeX, changeY +func DSA_ResizeScreen_c *screen, *opm, redraw +func DSA_DrawSizingScreen_c *screen, *rect +funcv DSA_EnterResizingMode_c *screen +funcv DSA_LeaveResizingMode_c *screen +funcv DSA_GetDSAMetrics_c *screen, *x, *y, *width, *height, *isVisible +funcv DSA_SetDSAPos_c *screen, x, y, repaint +funcv DSA_GetScreenExtends_c *width, *height +func DSA_GetActiveScreen_c +funcv DSA_SetActiveScreen_c *screen +func DSA_GetLastTouchedScreen_c +funcv DSA_CopyPartOPMToScreen_c *screen, x, y, width, height +func DSA_ScreenVisibility_c *screen, show +func DSA_LoadBackground_c *path +funcv DSA_FixBackground_c isFixed +funcv DSA_SetCapture_c *screen +func DSA_SetBackgroundInRAM_c value +funcv DSA_SetPal_c unused, *palette, src_start_entry, num_entries, dst_start_entry +funcv DSA_ActivatePal_c +funcv DSA_PreventPaletteRemapping_c valueAdd +func DSA_GetBackgroundOffset_c *offsetX, *offsetY +funcv DSA_SetBackground2Black_c isBlack +func DSA_MarkBitmapAsDirty_c param1, param2 + +proc DSA_ReuseStaticColors public + +; [esp + 4] = unsigned int osVersions +; [esp ] = return address + + Call_Asm_Stack1_void DSA_ReuseStaticColors_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_ReuseStaticColors + + +proc DSA_FreeStaticColors public + +; [esp + 4] = unsigned int osVersions +; [esp ] = return address + + Call_Asm_Stack1_void DSA_FreeStaticColors_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_FreeStaticColors + + +proc DSAWIN_PrepareInit public + +; [esp + 4] = void * hInstance +; [esp ] = return address + + Call_Asm_Stack1_void DSAWIN_PrepareInit_c + + Call_Asm_Return 0 + +endp ; end procedure DSAWIN_PrepareInit + + +proc DSAWIN_GetMainWindowHandle public + +; [esp ] = return address + + Call_Asm_Stack0 DSAWIN_GetMainWindowHandle_c + + Call_Asm_Return 0 + +endp ; end procedure DSAWIN_GetMainWindowHandle + + +proc DSAWIN_GetInstance public + +; [esp ] = return address + + Call_Asm_Stack0 DSAWIN_GetInstance_c + + Call_Asm_Return 0 + +endp ; end procedure DSAWIN_GetInstance + + +proc DSA_Init public + +; [esp ] = return address + + Call_Asm_Stack0 DSA_Init_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_Init + + +proc DSA_Exit public + +; [esp ] = return address + + Call_Asm_Stack0_void DSA_Exit_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_Exit + + +proc DSA_OpenScreen public + +; [esp + 7*4] = int type +; [esp + 6*4] = int y +; [esp + 5*4] = int x +; [esp + 4*4] = const char * windowName +; [esp + 3*4] = int param3 +; [esp + 2*4] = OPM_struct * opm +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack7 DSA_OpenScreen_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_OpenScreen + + +proc DSA_CloseScreen public + +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack1_void DSA_CloseScreen_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_CloseScreen + + +proc DSA_CopyMainOPMToScreen public + +; [esp + 2*4] = int onlyModified +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack2_void DSA_CopyMainOPMToScreen_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_CopyMainOPMToScreen + + +proc DSA_StretchOPMToScreen public + +; [esp + 10*4] = int heightSrc +; [esp + 9*4] = int widthSrc +; [esp + 8*4] = int ySrc +; [esp + 7*4] = int xSrc +; [esp + 6*4] = OPM_struct * opm +; [esp + 5*4] = int heightDst +; [esp + 4*4] = int widthDst +; [esp + 3*4] = int yDst +; [esp + 2*4] = int xDst +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack10_void DSA_StretchOPMToScreen_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_StretchOPMToScreen + + +proc DSA_CopyOPMToScreenEx public + +; [esp + 8*4] = int ySrc +; [esp + 7*4] = int xSrc +; [esp + 6*4] = OPM_struct * opm +; [esp + 5*4] = int height +; [esp + 4*4] = int width +; [esp + 3*4] = int yDst +; [esp + 2*4] = int xDst +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack8_void DSA_CopyOPMToScreenEx_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_CopyOPMToScreenEx + + +proc DSA_TotalRepaint public + +; [esp ] = return address + + Call_Asm_Stack0_void DSA_TotalRepaint_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_TotalRepaint + + +proc DSA_MoveScreen public + +; [esp + 3*4] = int changeY +; [esp + 2*4] = int changeX +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack3_void DSA_MoveScreen_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_MoveScreen + + +proc DSA_ResizeScreen public + +; [esp + 3*4] = int redraw +; [esp + 2*4] = OPM_struct * opm +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack3 DSA_ResizeScreen_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_ResizeScreen + + +proc DSA_DrawSizingScreen public + +; [esp + 2*4] = int16_t * rect +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack2 DSA_DrawSizingScreen_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_DrawSizingScreen + + +proc DSA_EnterResizingMode public + +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack1_void DSA_EnterResizingMode_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_EnterResizingMode + + +proc DSA_LeaveResizingMode public + +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack1_void DSA_LeaveResizingMode_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_LeaveResizingMode + + +proc DSA_GetDSAMetrics public + +; [esp + 6*4] = uint8_t * isVisible +; [esp + 5*4] = int32_t * height +; [esp + 4*4] = int32_t * width +; [esp + 3*4] = int32_t * y +; [esp + 2*4] = int32_t * x +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack6_void DSA_GetDSAMetrics_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_GetDSAMetrics + + +proc DSA_SetDSAPos public + +; [esp + 4*4] = int repaint +; [esp + 3*4] = int y +; [esp + 2*4] = int x +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack4_void DSA_SetDSAPos_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_SetDSAPos + + +proc DSA_GetScreenExtends public + +; [esp + 2*4] = int32_t * height +; [esp + 4] = int32_t * width +; [esp ] = return address + + Call_Asm_Stack2_void DSA_GetScreenExtends_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_GetScreenExtends + + +proc DSA_GetActiveScreen public + +; [esp ] = return address + + Call_Asm_Stack0 DSA_GetActiveScreen_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_GetActiveScreen + + +proc DSA_SetActiveScreen public + +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack1_void DSA_SetActiveScreen_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_SetActiveScreen + + +proc DSA_GetLastTouchedScreen public + +; [esp ] = return address + + Call_Asm_Stack0 DSA_GetLastTouchedScreen_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_GetLastTouchedScreen + + +proc DSA_CopyPartOPMToScreen public + +; [esp + 5*4] = int height +; [esp + 4*4] = int width +; [esp + 3*4] = int y +; [esp + 2*4] = int x +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack5_void DSA_CopyPartOPMToScreen_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_CopyPartOPMToScreen + + +proc DSA_ScreenVisibility public + +; [esp + 2*4] = int show +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack2 DSA_ScreenVisibility_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_ScreenVisibility + + +proc DSA_LoadBackground public + +; [esp + 4] = const char * path +; [esp ] = return address + + Call_Asm_Stack1 DSA_LoadBackground_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_LoadBackground + + +proc DSA_FixBackground public + +; [esp + 4] = int isFixed +; [esp ] = return address + + Call_Asm_Stack1_void DSA_FixBackground_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_FixBackground + + +proc DSA_SetCapture public + +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack1_void DSA_SetCapture_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_SetCapture + + +proc DSA_SetBackgroundInRAM public + +; [esp + 4] = int value +; [esp ] = return address + + Call_Asm_Stack1 DSA_SetBackgroundInRAM_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_SetBackgroundInRAM + + +proc DSA_SetPal public + +; [esp + 5*4] = unsigned int dst_start_entry +; [esp + 4*4] = unsigned int num_entries +; [esp + 3*4] = unsigned int src_start_entry +; [esp + 2*4] = DSA_Palette * palette +; [esp + 4] = int unused +; [esp ] = return address + + Call_Asm_Stack5_void DSA_SetPal_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_SetPal + + +proc DSA_ActivatePal public + +; [esp ] = return address + + Call_Asm_Stack0_void DSA_ActivatePal_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_ActivatePal + + +proc DSA_PreventPaletteRemapping public + +; [esp + 4] = int valueAdd +; [esp ] = return address + + Call_Asm_Stack1_void DSA_PreventPaletteRemapping_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_PreventPaletteRemapping + + +proc DSA_GetBackgroundOffset public + +; [esp + 2*4] = int32_t * offsetY +; [esp + 4] = int32_t * offsetX +; [esp ] = return address + + Call_Asm_Stack2 DSA_GetBackgroundOffset_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_GetBackgroundOffset + + +proc DSA_SetBackground2Black public + +; [esp + 4] = int isBlack +; [esp ] = return address + + Call_Asm_Stack1_void DSA_SetBackground2Black_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_SetBackground2Black + + +proc DSA_MarkBitmapAsDirty public + +; [esp + 2*4] = int param2 +; [esp + 4] = int param1 +; [esp ] = return address + + Call_Asm_Stack2 DSA_MarkBitmapAsDirty_c + + Call_Asm_Return 0 + +endp ; end procedure DSA_MarkBitmapAsDirty + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/BBFX-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/BBFX-asm.llasm new file mode 100644 index 0000000..8a482d4 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/BBFX-asm.llasm @@ -0,0 +1,143 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +func FX_Init_c +funcv FX_Exit_c +func FX_ReserveDevices_c reserve +func FX_ReadLib_c *path +funcv FX_FreeLib_c lib_handle +funcv FX_StopAllSamples_c +func FX_PlaySample_c lib_handle, sample_number, priority, volume, times_play +funcv FX_SetVolume_c volume +func FM_IsError_c + +proc FX_Init public + +; [esp ] = return address + + Call_Asm_Stack0 FX_Init_c + + Call_Asm_Return 0 + +endp ; end procedure FX_Init + + +proc FX_Exit public + +; [esp ] = return address + + Call_Asm_Stack0_void FX_Exit_c + + Call_Asm_Return 0 + +endp ; end procedure FX_Exit + + +proc FX_ReserveDevices public + +; [esp + 4] = int reserve +; [esp ] = return address + + Call_Asm_Stack1 FX_ReserveDevices_c + + Call_Asm_Return 0 + +endp ; end procedure FX_ReserveDevices + + +proc FX_ReadLib public + +; [esp + 4] = const char * path +; [esp ] = return address + + Call_Asm_Stack1 FX_ReadLib_c + + Call_Asm_Return 0 + +endp ; end procedure FX_ReadLib + + +proc FX_FreeLib public + +; [esp + 4] = int lib_handle +; [esp ] = return address + + Call_Asm_Stack1_void FX_FreeLib_c + + Call_Asm_Return 0 + +endp ; end procedure FX_FreeLib + + +proc FX_StopAllSamples public + +; [esp ] = return address + + Call_Asm_Stack0_void FX_StopAllSamples_c + + Call_Asm_Return 0 + +endp ; end procedure FX_StopAllSamples + + +proc FX_PlaySample public + +; [esp + 5*4] = int times_play +; [esp + 4*4] = int volume +; [esp + 3*4] = int priority +; [esp + 2*4] = int sample_number +; [esp + 4] = int lib_handle +; [esp ] = return address + + Call_Asm_Stack5 FX_PlaySample_c + + Call_Asm_Return 0 + +endp ; end procedure FX_PlaySample + + +proc FX_SetVolume public + +; [esp + 4] = unsigned int volume +; [esp ] = return address + + Call_Asm_Stack1_void FX_SetVolume_c + + Call_Asm_Return 0 + +endp ; end procedure FX_SetVolume + + +proc FM_IsError public + +; [esp ] = return address + + Call_Asm_Stack0 FM_IsError_c + + Call_Asm_Return 0 + +endp ; end procedure FM_IsError + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/BBLBL-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/BBLBL-asm.llasm new file mode 100644 index 0000000..6c65f6e --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/BBLBL-asm.llasm @@ -0,0 +1,134 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +func LBL_Init_c +funcv LBL_Exit_c +func LBL_OpenLib_c *path, param2 +funcv LBL_CloseLib_c *lib +func LBL_ReadEntry_c *lib, *entry_data, entry_number, close_file, *entry_metadata +func LBL_GetEntrySize_c *lib, entry_number +funcv LBL_CloseFile_c *lib +func LBL_GetNOFEntries_c *lib + +proc LBL_Init public + +; [esp ] = return address + + Call_Asm_Stack0 LBL_Init_c + + Call_Asm_Return 0 + +endp ; end procedure LBL_Init + + +proc LBL_Exit public + +; [esp ] = return address + + Call_Asm_Stack0_void LBL_Exit_c + + Call_Asm_Return 0 + +endp ; end procedure LBL_Exit + + +proc LBL_OpenLib public + +; [esp + 2*4] = int param2 +; [esp + 4] = const char * path +; [esp ] = return address + + Call_Asm_Stack2 LBL_OpenLib_c + + Call_Asm_Return 0 + +endp ; end procedure LBL_OpenLib + + +proc LBL_CloseLib public + +; [esp + 4] = void * lib +; [esp ] = return address + + Call_Asm_Stack1_void LBL_CloseLib_c + + Call_Asm_Return 0 + +endp ; end procedure LBL_CloseLib + + +proc LBL_ReadEntry public + +; [esp + 5*4] = void * entry_metadata +; [esp + 4*4] = int close_file +; [esp + 3*4] = unsigned int entry_number +; [esp + 2*4] = void * entry_data +; [esp + 4] = void * lib +; [esp ] = return address + + Call_Asm_Stack5 LBL_ReadEntry_c + + Call_Asm_Return 0 + +endp ; end procedure LBL_ReadEntry + + +proc LBL_GetEntrySize public + +; [esp + 2*4] = unsigned int entry_number +; [esp + 4] = void * lib +; [esp ] = return address + + Call_Asm_Stack2 LBL_GetEntrySize_c + + Call_Asm_Return 0 + +endp ; end procedure LBL_GetEntrySize + + +proc LBL_CloseFile public + +; [esp + 4] = void * lib +; [esp ] = return address + + Call_Asm_Stack1_void LBL_CloseFile_c + + Call_Asm_Return 0 + +endp ; end procedure LBL_CloseFile + + +proc LBL_GetNOFEntries public + +; [esp + 4] = void * lib +; [esp ] = return address + + Call_Asm_Stack1 LBL_GetNOFEntries_c + + Call_Asm_Return 0 + +endp ; end procedure LBL_GetNOFEntries + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/BBLBM-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/BBLBM-asm.llasm new file mode 100644 index 0000000..74054b1 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/BBLBM-asm.llasm @@ -0,0 +1,68 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +func LBM_DisplayLBM_c *path, *pixel_map, *palette, flags +funcv LBM_StartSerie_c number +funcv LBM_AutoSave_c *pixel_map + +proc LBM_DisplayLBM public + +; [esp + 4*4] = unsigned int flags +; [esp + 3*4] = uint8_t * palette +; [esp + 2*4] = void * pixel_map +; [esp + 4] = const char * path +; [esp ] = return address + + Call_Asm_Stack4 LBM_DisplayLBM_c + + Call_Asm_Return 0 + +endp ; end procedure LBM_DisplayLBM + + +proc LBM_StartSerie public + +; [esp + 4] = int number +; [esp ] = return address + + Call_Asm_Stack1_void LBM_StartSerie_c + + Call_Asm_Return 0 + +endp ; end procedure LBM_StartSerie + + +proc LBM_AutoSave public + +; [esp + 4] = void * pixel_map +; [esp ] = return address + + Call_Asm_Stack1_void LBM_AutoSave_c + + Call_Asm_Return 0 + +endp ; end procedure LBM_AutoSave + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/BBLL-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/BBLL-asm.llasm new file mode 100644 index 0000000..fa90c03 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/BBLL-asm.llasm @@ -0,0 +1,50 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +func LL_Init_c +funcv LL_Exit_c + +proc LL_Init public + +; [esp ] = return address + + Call_Asm_Stack0 LL_Init_c + + Call_Asm_Return 0 + +endp ; end procedure LL_Init + + +proc LL_Exit public + +; [esp ] = return address + + Call_Asm_Stack0_void LL_Exit_c + + Call_Asm_Return 0 + +endp ; end procedure LL_Exit + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/BBMEM-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/BBMEM-asm.llasm new file mode 100644 index 0000000..a0dbda9 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/BBMEM-asm.llasm @@ -0,0 +1,186 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +func MEM_Init_c +funcv MEM_Exit_c +func MEM_malloc_c size, *module_name, *object_type, line, type +funcv MEM_free_c *mem_ptr +funcv MEM_Take_Snapshot_c *name +funcv MEM_Check_Snapshot_c +funcv MEM_SwitchSecurity_c security +func BASEMEM_Alloc_c size +func BASEMEM_Free_c *mem_ptr +funcv BASEMEM_CopyMem_c *src, *dst, length +funcv BASEMEM_FillMemByte_c *dst, length, c +func BBMEM_GetPoolPointer_c + +proc MEM_Init public + +; [esp ] = return address + + Call_Asm_Stack0 MEM_Init_c + + Call_Asm_Return 0 + +endp ; end procedure MEM_Init + + +proc MEM_Exit public + +; [esp ] = return address + + Call_Asm_Stack0_void MEM_Exit_c + + Call_Asm_Return 0 + +endp ; end procedure MEM_Exit + + +proc MEM_malloc public + +; [esp + 5*4] = int type +; [esp + 4*4] = unsigned int line +; [esp + 3*4] = const char * object_type +; [esp + 2*4] = const char * module_name +; [esp + 4] = unsigned int size +; [esp ] = return address + + Call_Asm_Stack5 MEM_malloc_c + + Call_Asm_Return 0 + +endp ; end procedure MEM_malloc + + +proc MEM_free public + +; [esp + 4] = void * mem_ptr +; [esp ] = return address + + Call_Asm_Stack1_void MEM_free_c + + Call_Asm_Return 0 + +endp ; end procedure MEM_free + + +proc MEM_Take_Snapshot public + +; [esp + 4] = const char * name +; [esp ] = return address + + Call_Asm_Stack1_void MEM_Take_Snapshot_c + + Call_Asm_Return 0 + +endp ; end procedure MEM_Take_Snapshot + + +proc MEM_Check_Snapshot public + +; [esp ] = return address + + Call_Asm_Stack0_void MEM_Check_Snapshot_c + + Call_Asm_Return 0 + +endp ; end procedure MEM_Check_Snapshot + + +proc MEM_SwitchSecurity public + +; [esp + 4] = unsigned int security +; [esp ] = return address + + Call_Asm_Stack1_void MEM_SwitchSecurity_c + + Call_Asm_Return 0 + +endp ; end procedure MEM_SwitchSecurity + + +proc BASEMEM_Alloc public + +; [esp + 4] = unsigned int size +; [esp ] = return address + + Call_Asm_Stack1 BASEMEM_Alloc_c + + Call_Asm_Return 0 + +endp ; end procedure BASEMEM_Alloc + + +proc BASEMEM_Free public + +; [esp + 4] = void * mem_ptr +; [esp ] = return address + + Call_Asm_Stack1 BASEMEM_Free_c + + Call_Asm_Return 0 + +endp ; end procedure BASEMEM_Free + + +proc BASEMEM_CopyMem public + +; [esp + 3*4] = unsigned int length +; [esp + 2*4] = void * dst +; [esp + 4] = const void * src +; [esp ] = return address + + Call_Asm_Stack3_void BASEMEM_CopyMem_c + + Call_Asm_Return 0 + +endp ; end procedure BASEMEM_CopyMem + + +proc BASEMEM_FillMemByte public + +; [esp + 3*4] = int c +; [esp + 2*4] = unsigned int length +; [esp + 4] = void * dst +; [esp ] = return address + + Call_Asm_Stack3_void BASEMEM_FillMemByte_c + + Call_Asm_Return 0 + +endp ; end procedure BASEMEM_FillMemByte + + +proc BBMEM_GetPoolPointer public + +; [esp ] = return address + + Call_Asm_Stack0 BBMEM_GetPoolPointer_c + + Call_Asm_Return 0 + +endp ; end procedure BBMEM_GetPoolPointer + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/BBOPM-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/BBOPM-asm.llasm new file mode 100644 index 0000000..4f0c07e --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/BBOPM-asm.llasm @@ -0,0 +1,233 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +func OPM_Init_c +funcv OPM_Exit_c +func OPM_New_c width, height, bytes_per_pixel, *pixel_map, *buffer +funcv OPM_Del_c *pixel_map +funcv OPM_CreateVirtualOPM_c *base_pixel_map, *virtual_pixel_map, virtual_x, virtual_y, virtual_width, virtual_height +func OPM_CreateSecondaryOPM_c width, height, bytes_per_pixel, *pixel_map, *buffer +funcv OPM_SetPixel_c *pixel_map, x, y, color +funcv OPM_HorLine_c *pixel_map, x, y, length, color +funcv OPM_VerLine_c *pixel_map, x, y, length, color +funcv OPM_FillBox_c *pixel_map, x, y, width, height, color +funcv OPM_CopyGFXOPM_c *pixel_map, *gfx, pos_x, pos_y, value_add +funcv OPM_CopyOPMOPM_c *src_pixel_map, *dst_pixel_map, src_x, src_y, copy_width, copy_height, dst_x, dst_y +funcv OPM_AccessBitmap_c *pixel_map + +proc OPM_Init public + +; [esp ] = return address + + Call_Asm_Stack0 OPM_Init_c + + Call_Asm_Return 0 + +endp ; end procedure OPM_Init + + +proc OPM_Exit public + +; [esp ] = return address + + Call_Asm_Stack0_void OPM_Exit_c + + Call_Asm_Return 0 + +endp ; end procedure OPM_Exit + + +proc OPM_New public + +; [esp + 5*4] = uint8_t * buffer +; [esp + 4*4] = OPM_struct * pixel_map +; [esp + 3*4] = unsigned int bytes_per_pixel +; [esp + 2*4] = unsigned int height +; [esp + 4] = unsigned int width +; [esp ] = return address + + Call_Asm_Stack5 OPM_New_c + + Call_Asm_Return 0 + +endp ; end procedure OPM_New + + +proc OPM_Del public + +; [esp + 4] = OPM_struct * pixel_map +; [esp ] = return address + + Call_Asm_Stack1_void OPM_Del_c + + Call_Asm_Return 0 + +endp ; end procedure OPM_Del + + +proc OPM_CreateVirtualOPM public + +; [esp + 6*4] = int virtual_height +; [esp + 5*4] = int virtual_width +; [esp + 4*4] = int virtual_y +; [esp + 3*4] = int virtual_x +; [esp + 2*4] = OPM_struct * virtual_pixel_map +; [esp + 4] = OPM_struct * base_pixel_map +; [esp ] = return address + + Call_Asm_Stack6_void OPM_CreateVirtualOPM_c + + Call_Asm_Return 0 + +endp ; end procedure OPM_CreateVirtualOPM + + +proc OPM_CreateSecondaryOPM public + +; [esp + 5*4] = uint8_t * buffer +; [esp + 4*4] = OPM_struct * pixel_map +; [esp + 3*4] = int bytes_per_pixel +; [esp + 2*4] = int height +; [esp + 4] = int width +; [esp ] = return address + + Call_Asm_Stack5 OPM_CreateSecondaryOPM_c + + Call_Asm_Return 0 + +endp ; end procedure OPM_CreateSecondaryOPM + + +proc OPM_SetPixel public + +; [esp + 4*4] = uint8_t color +; [esp + 3*4] = int y +; [esp + 2*4] = int x +; [esp + 4] = OPM_struct * pixel_map +; [esp ] = return address + + Call_Asm_Stack4_void OPM_SetPixel_c + + Call_Asm_Return 0 + +endp ; end procedure OPM_SetPixel + + +proc OPM_HorLine public + +; [esp + 5*4] = uint8_t color +; [esp + 4*4] = unsigned int length +; [esp + 3*4] = int y +; [esp + 2*4] = int x +; [esp + 4] = OPM_struct * pixel_map +; [esp ] = return address + + Call_Asm_Stack5_void OPM_HorLine_c + + Call_Asm_Return 0 + +endp ; end procedure OPM_HorLine + + +proc OPM_VerLine public + +; [esp + 5*4] = uint8_t color +; [esp + 4*4] = unsigned int length +; [esp + 3*4] = int y +; [esp + 2*4] = int x +; [esp + 4] = OPM_struct * pixel_map +; [esp ] = return address + + Call_Asm_Stack5_void OPM_VerLine_c + + Call_Asm_Return 0 + +endp ; end procedure OPM_VerLine + + +proc OPM_FillBox public + +; [esp + 6*4] = uint8_t color +; [esp + 5*4] = unsigned int height +; [esp + 4*4] = unsigned int width +; [esp + 3*4] = int y +; [esp + 2*4] = int x +; [esp + 4] = OPM_struct * pixel_map +; [esp ] = return address + + Call_Asm_Stack6_void OPM_FillBox_c + + Call_Asm_Return 0 + +endp ; end procedure OPM_FillBox + + +proc OPM_CopyGFXOPM public + +; [esp + 5*4] = uint8_t value_add +; [esp + 4*4] = int pos_y +; [esp + 3*4] = int pos_x +; [esp + 2*4] = GFX_struct * gfx +; [esp + 4] = OPM_struct * pixel_map +; [esp ] = return address + + Call_Asm_Stack5_void OPM_CopyGFXOPM_c + + Call_Asm_Return 0 + +endp ; end procedure OPM_CopyGFXOPM + + +proc OPM_CopyOPMOPM public + +; [esp + 8*4] = int dst_y +; [esp + 7*4] = int dst_x +; [esp + 6*4] = int copy_height +; [esp + 5*4] = int copy_width +; [esp + 4*4] = int src_y +; [esp + 3*4] = int src_x +; [esp + 2*4] = OPM_struct * dst_pixel_map +; [esp + 4] = OPM_struct * src_pixel_map +; [esp ] = return address + + Call_Asm_Stack8_void OPM_CopyOPMOPM_c + + Call_Asm_Return 0 + +endp ; end procedure OPM_CopyOPMOPM + + +proc OPM_AccessBitmap public + +; [esp + 4] = OPM_struct * pixel_map +; [esp ] = return address + + Call_Asm_Stack1_void OPM_AccessBitmap_c + + Call_Asm_Return 0 + +endp ; end procedure OPM_AccessBitmap + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/BBRNG-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/BBRNG-asm.llasm new file mode 100644 index 0000000..6e88aad --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/BBRNG-asm.llasm @@ -0,0 +1,147 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +func RNG_Init_c +funcv RNG_Exit_c +func RNG_NewBuffer_c element_size, num_elements +funcv RNG_DelBuffer_c *buffer +func RNG_In_c *buffer, *element +func RNG_Out_c *buffer, *element +func RNG_Peek_c *buffer, *element +funcv RNG_Replace_c *buffer, *element +funcv RNG_PutFirst_c *buffer, *element + +proc RNG_Init public + +; [esp ] = return address + + Call_Asm_Stack0 RNG_Init_c + + Call_Asm_Return 0 + +endp ; end procedure RNG_Init + + +proc RNG_Exit public + +; [esp ] = return address + + Call_Asm_Stack0_void RNG_Exit_c + + Call_Asm_Return 0 + +endp ; end procedure RNG_Exit + + +proc RNG_NewBuffer public + +; [esp + 2*4] = int num_elements +; [esp + 4] = int element_size +; [esp ] = return address + + Call_Asm_Stack2 RNG_NewBuffer_c + + Call_Asm_Return 0 + +endp ; end procedure RNG_NewBuffer + + +proc RNG_DelBuffer public + +; [esp + 4] = void * buffer +; [esp ] = return address + + Call_Asm_Stack1_void RNG_DelBuffer_c + + Call_Asm_Return 0 + +endp ; end procedure RNG_DelBuffer + + +proc RNG_In public + +; [esp + 2*4] = const void * element +; [esp + 4] = void * buffer +; [esp ] = return address + + Call_Asm_Stack2 RNG_In_c + + Call_Asm_Return 0 + +endp ; end procedure RNG_In + + +proc RNG_Out public + +; [esp + 2*4] = void * element +; [esp + 4] = void * buffer +; [esp ] = return address + + Call_Asm_Stack2 RNG_Out_c + + Call_Asm_Return 0 + +endp ; end procedure RNG_Out + + +proc RNG_Peek public + +; [esp + 2*4] = void * element +; [esp + 4] = void * buffer +; [esp ] = return address + + Call_Asm_Stack2 RNG_Peek_c + + Call_Asm_Return 0 + +endp ; end procedure RNG_Peek + + +proc RNG_Replace public + +; [esp + 2*4] = const void * element +; [esp + 4] = void * buffer +; [esp ] = return address + + Call_Asm_Stack2_void RNG_Replace_c + + Call_Asm_Return 0 + +endp ; end procedure RNG_Replace + + +proc RNG_PutFirst public + +; [esp + 2*4] = const void * element +; [esp + 4] = void * buffer +; [esp ] = return address + + Call_Asm_Stack2_void RNG_PutFirst_c + + Call_Asm_Return 0 + +endp ; end procedure RNG_PutFirst + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/BBSYSTEM-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/BBSYSTEM-asm.llasm new file mode 100644 index 0000000..8682013 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/BBSYSTEM-asm.llasm @@ -0,0 +1,161 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +funcv SYSTEM_SetInitValues_c type, *value +funcv SYSTEM_SystemTask_c +func SYSTEM_Init_c +funcv SYSTEM_Exit_c +func SYSTEM_GetTicks_c +func SYSTEM_IsApplicationActive_c +funcv SYSTEM_WaitTicks_c ticks +funcv SYSTEM_EnterCriticalSection_c +funcv SYSTEM_LeaveCriticalSection_c +func SYSTEM_InCriticalSection_c +func SYSTEM_GetOS_c + +proc SYSTEM_SetInitValues public + +; [esp + 2*4] = const char * value +; [esp + 4] = int type +; [esp ] = return address + + Call_Asm_Stack2_void SYSTEM_SetInitValues_c + + Call_Asm_Return 0 + +endp ; end procedure SYSTEM_SetInitValues + + +proc SYSTEM_SystemTask public + +; [esp ] = return address + + Call_Asm_Stack0_void SYSTEM_SystemTask_c + + Call_Asm_Return 0 + +endp ; end procedure SYSTEM_SystemTask + + +proc SYSTEM_Init public + +; [esp ] = return address + + Call_Asm_Stack0 SYSTEM_Init_c + + Call_Asm_Return 0 + +endp ; end procedure SYSTEM_Init + + +proc SYSTEM_Exit public + +; [esp ] = return address + + Call_Asm_Stack0_void SYSTEM_Exit_c + + Call_Asm_Return 0 + +endp ; end procedure SYSTEM_Exit + + +proc SYSTEM_GetTicks public + +; [esp ] = return address + + Call_Asm_Stack0 SYSTEM_GetTicks_c + + Call_Asm_Return 0 + +endp ; end procedure SYSTEM_GetTicks + + +proc SYSTEM_IsApplicationActive public + +; [esp ] = return address + + Call_Asm_Stack0 SYSTEM_IsApplicationActive_c + + Call_Asm_Return 0 + +endp ; end procedure SYSTEM_IsApplicationActive + + +proc SYSTEM_WaitTicks public + +; [esp + 4] = unsigned int ticks +; [esp ] = return address + + Call_Asm_Stack1_void SYSTEM_WaitTicks_c + + Call_Asm_Return 0 + +endp ; end procedure SYSTEM_WaitTicks + + +proc SYSTEM_EnterCriticalSection public + +; [esp ] = return address + + Call_Asm_Stack0_void SYSTEM_EnterCriticalSection_c + + Call_Asm_Return 0 + +endp ; end procedure SYSTEM_EnterCriticalSection + + +proc SYSTEM_LeaveCriticalSection public + +; [esp ] = return address + + Call_Asm_Stack0_void SYSTEM_LeaveCriticalSection_c + + Call_Asm_Return 0 + +endp ; end procedure SYSTEM_LeaveCriticalSection + + +proc SYSTEM_InCriticalSection public + +; [esp ] = return address + + Call_Asm_Stack0 SYSTEM_InCriticalSection_c + + Call_Asm_Return 0 + +endp ; end procedure SYSTEM_InCriticalSection + + +proc SYSTEM_GetOS public + +; [esp ] = return address + + Call_Asm_Stack0 SYSTEM_GetOS_c + + Call_Asm_Return 0 + +endp ; end procedure SYSTEM_GetOS + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/BBTOOL-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/BBTOOL-asm.llasm new file mode 100644 index 0000000..6e2a922 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/BBTOOL-asm.llasm @@ -0,0 +1,42 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +func TOOL_Chiffre_c *buffer, length, *key, keylength + +proc TOOL_Chiffre public + +; [esp + 4*4] = unsigned int keylength +; [esp + 3*4] = const uint8_t * key +; [esp + 2*4] = unsigned int length +; [esp + 4] = uint8_t * buffer +; [esp ] = return address + + Call_Asm_Stack4 TOOL_Chiffre_c + + Call_Asm_Return 0 + +endp ; end procedure TOOL_Chiffre + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/BBTXT-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/BBTXT-asm.llasm new file mode 100644 index 0000000..b717744 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/BBTXT-asm.llasm @@ -0,0 +1,95 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +func TXT_Init_c +funcv TXT_Exit_c +func TXT_LoadFont_c *path +funcv TXT_WriteString_c *text, font_handle, *dst_pixel_map, x, y, width, height, color_add +funcv TXT_UnloadAllFonts_c + +proc TXT_Init public + +; [esp ] = return address + + Call_Asm_Stack0 TXT_Init_c + + Call_Asm_Return 0 + +endp ; end procedure TXT_Init + + +proc TXT_Exit public + +; [esp ] = return address + + Call_Asm_Stack0_void TXT_Exit_c + + Call_Asm_Return 0 + +endp ; end procedure TXT_Exit + + +proc TXT_LoadFont public + +; [esp + 4] = const char * path +; [esp ] = return address + + Call_Asm_Stack1 TXT_LoadFont_c + + Call_Asm_Return 0 + +endp ; end procedure TXT_LoadFont + + +proc TXT_WriteString public + +; [esp + 8*4] = uint8_t color_add +; [esp + 7*4] = int height +; [esp + 6*4] = int width +; [esp + 5*4] = int y +; [esp + 4*4] = int x +; [esp + 3*4] = void * dst_pixel_map +; [esp + 2*4] = int font_handle +; [esp + 4] = const char * text +; [esp ] = return address + + Call_Asm_Stack8_void TXT_WriteString_c + + Call_Asm_Return 0 + +endp ; end procedure TXT_WriteString + + +proc TXT_UnloadAllFonts public + +; [esp ] = return address + + Call_Asm_Stack0_void TXT_UnloadAllFonts_c + + Call_Asm_Return 0 + +endp ; end procedure TXT_UnloadAllFonts + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/CLIB-asm-llasm.c b/games/Battle Isle 3/SR-BI3/llasm/CLIB-asm-llasm.c new file mode 100644 index 0000000..3f30d03 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/CLIB-asm-llasm.c @@ -0,0 +1,67 @@ +/** + * + * Copyright (C) 2019-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "CLIB-asm-llasm.h" +#include +#include "printf_x86.h" + + +#define eprintf(...) fprintf(stderr,__VA_ARGS__) + + +int32_t printf2_c(const char *format, uint32_t *ap) +{ + int res; + +#ifdef DEBUG_CLIB + eprintf("printf: 0x%x (%s) - ", (uintptr_t) format, format); +#endif + + res = vfctprintf_x86((void (*)(char, void*))fputc, stdout, format, ap); + +#ifdef DEBUG_CLIB + eprintf("%i\n", res); +#endif + + return res; +} + + +int32_t sprintf2_c(char *str, const char *format, uint32_t *ap) +{ + int res; + +#ifdef DEBUG_CLIB + eprintf("sprintf: 0x%x, 0x%x (%s) - ", (uintptr_t) str, (uintptr_t) format, format); +#endif + + res = vsprintf_x86(str, format, ap); + +#ifdef DEBUG_CLIB + eprintf("%i (%s)\n", res, str); +#endif + + return res; +} + diff --git a/games/Battle Isle 3/SR-BI3/llasm/CLIB-asm-llasm.h b/games/Battle Isle 3/SR-BI3/llasm/CLIB-asm-llasm.h new file mode 100644 index 0000000..793d750 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/CLIB-asm-llasm.h @@ -0,0 +1,42 @@ +/** + * + * Copyright (C) 2019-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_CLIB_ASM_LLASM_H_INCLUDED_) +#define _CLIB_ASM_LLASM_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int32_t printf2_c(const char *format, uint32_t *ap); +int32_t sprintf2_c(char *str, const char *format, uint32_t *ap); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/games/Battle Isle 3/SR-BI3/llasm/CLIB-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/CLIB-asm.llasm new file mode 100644 index 0000000..f87f503 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/CLIB-asm.llasm @@ -0,0 +1,422 @@ +;; +;; Copyright (C) 2019-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +func memcmp_c *s1, *s2, n +func memcpy_c *dest, *src, n +func memset_c *s, c, n + +func strcat_c *dest, *src +func strcmp_c *s1, *s2 +func strcpy_c *dest, *src +func strlen_c *s +func strncpy_c *dest, *src, n +func _strnicmp_c *s1, *s2, n +func strstr_c *haystack, *needle + +func printf2_c *format, *ap +func sprintf2_c *str, *format, *ap + +funcv ms_srand_c seed +func ms_rand_c +func wc_rand_c + +func atoi_c *nptr +func atol_c *nptr +func _ltoa_c value, *buffer, radix + +func isalnum_c c + +func _except_handler3_c *exception_record, *registration, *context, *dispatcher + +funcv sync_c + + +proc ms_memcmp_asm2c public + +; [esp + 3*4] = uint32_t n +; [esp + 2*4] = const void *s2 +; [esp + 4] = const void *s1 +; [esp ] = return address + + Call_Asm_Stack3 memcmp_c + + Call_Asm_Return 0 + +endp ; end procedure ms_memcmp_asm2c + + +proc ms_memcpy_asm2c public + +; [esp + 3*4] = uint32_t n +; [esp + 2*4] = const void *src +; [esp + 4] = void *dest +; [esp ] = return address + + Call_Asm_Stack3 memcpy_c + + Call_Asm_Return 0 + +endp ; end procedure ms_memcpy_asm2c + + +proc wc_memset_asm2c public + tcall ms_memset_asm2c +endp +proc ms_memset_asm2c public + +; [esp + 3*4] = uint32_t n +; [esp + 2*4] = int32_t c +; [esp + 4] = void *s +; [esp ] = return address + + Call_Asm_Stack3 memset_c + + Call_Asm_Return 0 + +endp ; end procedure ms_memset_asm2c + + +proc ms_strcat_asm2c public + +; [esp + 2*4] = const char *src +; [esp + 4] = char *dest +; [esp ] = return address + + Call_Asm_Stack2 strcat_c + + Call_Asm_Return 0 + +endp ; end procedure ms_strcat_asm2c + + +proc wc_strcmp_asm2c public + tcall ms_strcmp_asm2c +endp +proc ms_strcmp_asm2c public + +; [esp + 2*4] = const char *s2 +; [esp + 4] = const char *s1 +; [esp ] = return address + + Call_Asm_Stack2 strcmp_c + + Call_Asm_Return 0 + +endp ; end procedure ms_strcmp_asm2c + + +proc wc_strcpy_asm2c public + tcall ms_strcpy_asm2c +endp +proc ms_strcpy_asm2c public + +; [esp + 2*4] = const char *src +; [esp + 4] = char *dest +; [esp ] = return address + + Call_Asm_Stack2 strcpy_c + + Call_Asm_Return 0 + +endp ; end procedure ms_strcpy_asm2c + + +proc ms_strlen_asm2c public + +; [esp + 4] = const char *s +; [esp ] = return address + + Call_Asm_Stack1 strlen_c + + Call_Asm_Return 0 + +endp ; end procedure ms_strlen_asm2c + + +proc ms_strncpy_asm2c public + +; [esp + 3*4] = uint32_t n +; [esp + 2*4] = const char *src +; [esp + 4] = char *dest +; [esp ] = return address + + Call_Asm_Stack3 strncpy_c + + Call_Asm_Return 0 + +endp ; end procedure ms_strncpy_asm2c + + +proc ms__strnicmp_asm2c public + +; [esp + 3*4] = uint32_t n +; [esp + 2*4] = const char *s2 +; [esp + 4] = const char *s1 +; [esp ] = return address + + Call_Asm_Stack3 _strnicmp_c + + Call_Asm_Return 0 + +endp ; end procedure ms__strnicmp_asm2c + + +proc ms_strstr_asm2c public + +; [esp + 2*4] = const char *needle +; [esp + 4] = const char *haystack +; [esp ] = return address + + Call_Asm_Stack2 strstr_c + + Call_Asm_Return 0 + +endp ; end procedure ms_strstr_asm2c + + +proc ms__alloca_probe_asm2c public + +; eax = uint32_t size +; [esp] = return address + + ; push ecx + sub esp, esp, 4 + store ecx, esp, 4 + + ; lea ecx, [esp+4] + add ecx, esp, 4 + + ; sub ecx, eax + ; sbb eax, eax + ; not eax + ; and ecx, eax + sub tmp1, ecx, eax + cmovult ecx, eax, ecx, 0, tmp1 + + ; mov eax, esp + ; and eax, 0FFFFF000h + and eax, esp, 0xfffff000 + + tcall ms__alloca_probe_cs10 + +endp ; end procedure ms__alloca_probe_asm2c + +proc ms__alloca_probe_cs10 + + ; cmp ecx, eax + ; jb short cs20 + cmovult ecx, eax, tmp1, 1, 0 + ctcallnz tmp1, ms__alloca_probe_cs20 + + tcall ms__alloca_probe_cs15 + +endp ; end procedure ms__alloca_probe_cs10 + +proc ms__alloca_probe_cs15 + ; mov eax, ecx + mov tmpadr, ecx + + ; pop ecx + load ecx, esp, 4 + add esp, esp, 4 + + ; xchg eax, esp + ; mov eax, [eax] + ; mov [esp+0], eax + ; retn + load tmp1, esp, 4 + add esp, tmpadr, 4 + tcall tmp1 + +endp ; end procedure ms__alloca_probe_cs15 + +proc ms__alloca_probe_cs20 + + ; sub eax, 1000h + sub eax, eax, 0x1000 + + ; test [eax], eax + mov tmp1, 0 + store tmp1, eax, 4 + + ; jmp short cs10 + tcall ms__alloca_probe_cs10 + +endp ; end procedure ms__alloca_probe_cs20 + + +proc ms_printf_asm2c public + +; [esp + 2*4] = ... +; [esp + 4] = const char *format +; [esp ] = return address + + Call_Asm_VariableStack1 printf2_c + + Call_Asm_Return 0 + +endp ; end procedure ms_printf_asm2c + + +proc wc_sprintf_asm2c public + +; [esp + 3*4] = ... +; [esp + 2*4] = const char *format +; [esp + 4] = char *str +; [esp ] = return address + + Call_Asm_VariableStack2 sprintf2_c + + Call_Asm_Return 0 + +endp ; end procedure wc_sprintf_asm2c + + +proc ms__ftol_asm2c public + +; st0 = num +; [esp] = return address + + FTOL_INT64 + + load eax, tmp0, 4 + add tmpadr, tmp0, 4 + load edx, tmpadr, 4 + + Call_Asm_Return 0 + +endp ; end procedure ms__ftol_asm2c + + +proc ms_srand_asm2c public + +; [esp + 4] = uint32_t seed +; [esp ] = return address + + Call_Asm_Stack1_void ms_srand_c + + Call_Asm_Return 0 + +endp ; end procedure ms_srand_asm2c + + +proc ms_rand_asm2c public + +; [esp] = return address + + Call_Asm_Stack0 ms_rand_c + + Call_Asm_Return 0 + +endp ; end procedure ms_rand_asm2c + + +proc wc_rand_asm2c public + +; [esp] = return address + + Call_Asm_Stack0 wc_rand_c + + Call_Asm_Return 0 + +endp ; end procedure wc_rand_asm2c + + +proc ms_atoi_asm2c public + +; [esp + 4] = const char *nptr +; [esp ] = return address + + Call_Asm_Stack1 atoi_c + + Call_Asm_Return 0 + +endp ; end procedure ms_atoi_asm2c + + +proc ms_atol_asm2c public + +; [esp + 4] = const char *nptr +; [esp ] = return address + + Call_Asm_Stack1 atol_c + + Call_Asm_Return 0 + +endp ; end procedure ms_atol_asm2c + + +proc ms__ltoa_asm2c public + +; [esp + 3*4] = int radix +; [esp + 2*4] = char *buffer +; [esp + 4] = long value +; [esp ] = return address + + Call_Asm_Stack3 _ltoa_c + + Call_Asm_Return 0 + +endp ; end procedure ms__ltoa_asm2c + + +proc ms_isalnum_asm2c public + +; [esp + 4] = int c +; [esp ] = return address + + Call_Asm_Stack1 isalnum_c + + Call_Asm_Return 0 + +endp ; end procedure ms_isalnum_asm2c + + +proc ms__except_handler3_asm2c public + +; [esp + 4*4] = PEXCEPTION_REGISTRATION dispatcher +; [esp + 3*4] = PCONTEXT context +; [esp + 2*4] = PEXCEPTION_REGISTRATION registration +; [esp + 4] = PEXCEPTION_RECORD exception_record +; [esp ] = return address + + Call_Asm_Stack4 _except_handler3_c + + Call_Asm_Return 0 + +endp ; end procedure ms__except_handler3_asm2c + + +proc sync_asm2c public + +; [esp] = return address + + Call_Asm_Stack0_void sync_c + + Call_Asm_Return 0 + +endp ; end procedure sync_asm2c + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/FGT-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/FGT-asm.llasm new file mode 100644 index 0000000..fb65761 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/FGT-asm.llasm @@ -0,0 +1,51 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +funcv FGT_SystemTask_End flushGdi +funcv FGT_CheckTicksDelay index + +proc FGT_SystemTask_End_asm2c public + +; [esp + 4] = int flushGdi +; [esp ] = return address + + Call_Asm_Stack1_void FGT_SystemTask_End + + Call_Asm_Return 1 + +endp ; end procedure FGT_SystemTask_End_asm2c + + +proc FGT_CheckTicksDelay_asm2c public + +; [esp + 4] = int index +; [esp ] = return address + + Call_Asm_Stack1_void FGT_CheckTicksDelay + + Call_Asm_Return 1 + +endp ; end procedure FGT_CheckTicksDelay_asm2c + diff --git a/games/Battle Isle 3/SR-BI3/llasm/SConscript b/games/Battle Isle 3/SR-BI3/llasm/SConscript new file mode 100644 index 0000000..ed47e2e --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/SConscript @@ -0,0 +1,57 @@ +# +# Copyright (C) 2019-2021 Roman Pauer +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +import re + +llasm_include_re = re.compile(r'^include\s+(\S+)\r?$', re.M) + +def llasmfile_scan(node, env, path): + contents = node.get_text_contents() + includes = llasm_include_re.findall(contents) + includes2 = [] + for include in includes: + if not node.File(include).exists() and node.File("../" + include).exists(): + includes2.append("../" + include) + else: + includes2.append(include) + return includes2 + +llasmscan = Scanner(function = llasmfile_scan, + skeys = ['.llasm'], + recursive = True) + +SourceFileScanner.add_scanner('.llasm', llasmscan) + + +Import('env') + +obj = env.Object(Glob('*.c')) + +for llasm_file in Glob('*.llasm', strings = True): + obj += env.llasm(llasm_file) + +obj += env.llasm('ms_figtr/MS_FIGTR.llasm') +obj += env.llasm('sdi_1r/SDI_1R.llasm') +obj += env.llasm('wc_figtr/WC_FIGTR.llasm') + +Return('obj') + diff --git a/games/Battle Isle 3/SR-BI3/llasm/SDI-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/SDI-asm.llasm new file mode 100644 index 0000000..39c5387 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/SDI-asm.llasm @@ -0,0 +1,38 @@ +;; +;; Copyright (C) 2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +funcv SDI_CheckTicksDelay index + +proc SDI_CheckTicksDelay_asm2c public + +; [esp + 4] = int index +; [esp ] = return address + + Call_Asm_Stack1_void SDI_CheckTicksDelay + + Call_Asm_Return 1 + +endp ; end procedure SDI_CheckTicksDelay_asm2c + diff --git a/games/Battle Isle 3/SR-BI3/llasm/SDIcmdline-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/SDIcmdline-asm.llasm new file mode 100644 index 0000000..62e3271 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/SDIcmdline-asm.llasm @@ -0,0 +1,52 @@ +;; +;; Copyright (C) 2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +func cmdline_ContainsOption option +funcv cmdline_ReadLanguageOption *language + +proc cmdline_ContainsOption_asm2c public + +; [esp + 4] = int option +; [esp ] = return address + + Call_Asm_Stack1 cmdline_ContainsOption + + Call_Asm_Return 0 + +endp ; end procedure cmdline_ContainsOption_asm2c + + +proc cmdline_ReadLanguageOption_asm2c public + +; [esp + 4] = uint32_t *language +; [esp ] = return address + + Call_Asm_Stack1_void cmdline_ReadLanguageOption + + Call_Asm_Return 1 + +endp ; end procedure cmdline_ReadLanguageOption_asm2c + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/SDImidi-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/SDImidi-asm.llasm new file mode 100644 index 0000000..1b13669 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/SDImidi-asm.llasm @@ -0,0 +1,139 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +func midi_OpenSDIMusic *filename +func midi_GetSDIMusicID +func midi_PlaySDIMusic +func midi_CloseSDIMusic +func midi_IsPlaying musicID +func midi_OpenTestMusic +func midi_PlayTestMusic +func midi_CloseTestMusic +func midi_GetErrorString error, *text, length + +proc midi_OpenSDIMusic_asm2c public + +; [esp + 4] = const char *filename +; [esp ] = return address + + Call_Asm_Stack1 midi_OpenSDIMusic + + Call_Asm_Return 1 + +endp ; end procedure midi_OpenSDIMusic_asm2c + + +proc midi_GetSDIMusicID_asm2c public + +; [esp ] = return address + + Call_Asm_Stack0 midi_GetSDIMusicID + + Call_Asm_Return 0 + +endp ; end procedure midi_GetSDIMusicID_asm2c + + +proc midi_PlaySDIMusic_asm2c public + +; [esp ] = return address + + Call_Asm_Stack0 midi_PlaySDIMusic + + Call_Asm_Return 0 + +endp ; end procedure midi_PlaySDIMusic_asm2c + + +proc midi_CloseSDIMusic_asm2c public + +; [esp ] = return address + + Call_Asm_Stack0 midi_CloseSDIMusic + + Call_Asm_Return 0 + +endp ; end procedure midi_CloseSDIMusic_asm2c + + +proc midi_IsPlaying_asm2c public + +; [esp + 4] = unsigned int musicID +; [esp ] = return address + + Call_Asm_Stack1 midi_IsPlaying + + Call_Asm_Return 1 + +endp ; end procedure midi_IsPlaying_asm2c + + +proc midi_OpenTestMusic_asm2c public + +; [esp ] = return address + + Call_Asm_Stack0 midi_OpenTestMusic + + Call_Asm_Return 0 + +endp ; end procedure midi_OpenTestMusic_asm2c + + +proc midi_PlayTestMusic_asm2c public + +; [esp ] = return address + + Call_Asm_Stack0 midi_PlayTestMusic + + Call_Asm_Return 0 + +endp ; end procedure midi_PlayTestMusic_asm2c + + +proc midi_CloseTestMusic_asm2c public + +; [esp ] = return address + + Call_Asm_Stack0 midi_CloseTestMusic + + Call_Asm_Return 0 + +endp ; end procedure midi_CloseTestMusic_asm2c + + +proc midi_GetErrorString_asm2c public + +; [esp + 3*4] = unsigned int length +; [esp + 2*4] = char *text +; [esp + 4] = int error +; [esp ] = return address + + Call_Asm_Stack3 midi_GetErrorString + + Call_Asm_Return 3 + +endp ; end procedure midi_GetErrorString_asm2c + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/SDIvideo-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/SDIvideo-asm.llasm new file mode 100644 index 0000000..3e6c71f --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/SDIvideo-asm.llasm @@ -0,0 +1,138 @@ +;; +;; Copyright (C) 2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +func video_RegisterClass_PRE_Video +func video_Open_PRE_Video *path +func video_Close_PRE_Video +func video_Play_PRE_Video zoomed +func video_RegisterClass_POST_Video +func video_Open_POST_Video *path +func video_Close_POST_Video +func video_Play_POST_Video zoomed +func video_RegisterClass_SS_Video + +proc video_RegisterClass_PRE_Video_asm2c public + +; [esp ] = return address + + Call_Asm_Stack0 video_RegisterClass_PRE_Video + + Call_Asm_Return 0 + +endp ; end procedure video_RegisterClass_PRE_Video_asm2c + + +proc video_Open_PRE_Video_asm2c public + +; [esp + 4] = const char *path +; [esp ] = return address + + Call_Asm_Stack1 video_Open_PRE_Video + + Call_Asm_Return 1 + +endp ; end procedure video_Open_PRE_Video_asm2c + + +proc video_Close_PRE_Video_asm2c public + +; [esp ] = return address + + Call_Asm_Stack0 video_Close_PRE_Video + + Call_Asm_Return 0 + +endp ; end procedure video_Close_PRE_Video_asm2c + + +proc video_Play_PRE_Video_asm2c public + +; [esp + 4] = uint32_t zoomed +; [esp ] = return address + + Call_Asm_Stack1 video_Play_PRE_Video + + Call_Asm_Return 1 + +endp ; end procedure video_Play_PRE_Video_asm2c + + +proc video_RegisterClass_POST_Video_asm2c public + +; [esp ] = return address + + Call_Asm_Stack0 video_RegisterClass_POST_Video + + Call_Asm_Return 0 + +endp ; end procedure video_RegisterClass_POST_Video_asm2c + + +proc video_Open_POST_Video_asm2c public + +; [esp + 4] = const char *path +; [esp ] = return address + + Call_Asm_Stack1 video_Open_POST_Video + + Call_Asm_Return 1 + +endp ; end procedure video_Open_POST_Video_asm2c + + +proc video_Close_POST_Video_asm2c public + +; [esp ] = return address + + Call_Asm_Stack0 video_Close_POST_Video + + Call_Asm_Return 0 + +endp ; end procedure video_Close_POST_Video_asm2c + + +proc video_Play_POST_Video_asm2c public + +; [esp + 4] = uint32_t zoomed +; [esp ] = return address + + Call_Asm_Stack1 video_Play_POST_Video + + Call_Asm_Return 1 + +endp ; end procedure video_Play_POST_Video_asm2c + + +proc video_RegisterClass_SS_Video_asm2c public + +; [esp ] = return address + + Call_Asm_Stack0 video_RegisterClass_SS_Video + + Call_Asm_Return 0 + +endp ; end procedure video_RegisterClass_SS_Video_asm2c + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/WinApi-gdi32-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/WinApi-gdi32-asm.llasm new file mode 100644 index 0000000..e740c69 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/WinApi-gdi32-asm.llasm @@ -0,0 +1,139 @@ +;; +;; Copyright (C) 2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +func CreateFontIndirectA_c *lplf +func DeleteObject_c *ho +func GdiFlush_c +func GetDeviceCaps_c *hdc, index +func GetTextExtentPointA_c *hdc, *lpString, c, *lpsz +func SelectObject_c *hdc, *h +func SetBkMode_c *hdc, mode +func TextOutA_c *hdc, x, y, *lpString, c + +proc CreateFontIndirectA_asm2c public + +; [esp + 4] = CONST LOGFONTA * lplf +; [esp ] = return address + + Call_Asm_Stack1 CreateFontIndirectA_c + + Call_Asm_Return 1 + +endp ; end procedure CreateFontIndirectA_asm2c + + +proc DeleteObject_asm2c public + +; [esp + 4] = HGDIOBJ ho +; [esp ] = return address + + Call_Asm_Stack1 DeleteObject_c + + Call_Asm_Return 1 + +endp ; end procedure DeleteObject_asm2c + + +proc GdiFlush_asm2c public + +; [esp ] = return address + + Call_Asm_Stack0 GdiFlush_c + + Call_Asm_Return 0 + +endp ; end procedure GdiFlush_asm2c + + +proc GetDeviceCaps_asm2c public + +; [esp + 2*4] = int index +; [esp + 4] = HDC hdc +; [esp ] = return address + + Call_Asm_Stack2 GetDeviceCaps_c + + Call_Asm_Return 2 + +endp ; end procedure GetDeviceCaps_asm2c + + +proc GetTextExtentPointA_asm2c public + +; [esp + 4*4] = LPSIZE lpsz +; [esp + 3*4] = int c +; [esp + 2*4] = LPCSTR lpString +; [esp + 4] = HDC hdc +; [esp ] = return address + + Call_Asm_Stack4 GetTextExtentPointA_c + + Call_Asm_Return 4 + +endp ; end procedure GetTextExtentPointA_asm2c + + +proc SelectObject_asm2c public + +; [esp + 2*4] = HGDIOBJ h +; [esp + 4] = HDC hdc +; [esp ] = return address + + Call_Asm_Stack2 SelectObject_c + + Call_Asm_Return 2 + +endp ; end procedure SelectObject_asm2c + + +proc SetBkMode_asm2c public + +; [esp + 2*4] = int mode +; [esp + 4] = HDC hdc +; [esp ] = return address + + Call_Asm_Stack2 SetBkMode_c + + Call_Asm_Return 2 + +endp ; end procedure SetBkMode_asm2c + + +proc TextOutA_asm2c public + +; [esp + 5*4] = int c +; [esp + 4*4] = LPCSTR lpString +; [esp + 3*4] = int y +; [esp + 2*4] = int x +; [esp + 4] = HDC hdc +; [esp ] = return address + + Call_Asm_Stack5 TextOutA_c + + Call_Asm_Return 5 + +endp ; end procedure TextOutA_asm2c + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/WinApi-kernel32-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/WinApi-kernel32-asm.llasm new file mode 100644 index 0000000..c6c4b0b --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/WinApi-kernel32-asm.llasm @@ -0,0 +1,251 @@ +;; +;; Copyright (C) 2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +func CloseHandle_c *hObject +func CreateFileA_c *lpFileName, dwDesiredAccess, dwShareMode, *lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, *hTemplateFile +func FindClose_c *hFindFile +func FindFirstFileA_c *lpFileName, *lpFindFileData +func FindNextFileA_c *hFindFile, *lpFindFileData +func GetCurrentDirectoryA_c nBufferLength, *lpBuffer +func GetPrivateProfileIntA_c *lpAppName, *lpKeyName, nDefault, *lpFileName +func GetPrivateProfileStringA_c *lpAppName, *lpKeyName, *lpDefault, *lpReturnedString, nSize, *lpFileName +func GetTickCount_c +funcv GlobalMemoryStatus_c *lpBuffer +func ReadFile_c *hFile, *lpBuffer, nNumberOfBytesToRead, *lpNumberOfBytesRead, *lpOverlapped +func SetCurrentDirectoryA_c *lpPathName +func SetFilePointer_c *hFile, lDistanceToMove, *lpDistanceToMoveHigh, dwMoveMethod +func WriteFile_c *hFile, *lpBuffer, nNumberOfBytesToWrite, *lpNumberOfBytesWritten, *lpOverlapped +func WritePrivateProfileStringA_c *lpAppName, *lpKeyName, *lpString, *lpFileName + +proc CloseHandle_asm2c public + +; [esp + 4] = HANDLE hObject +; [esp ] = return address + + Call_Asm_Stack1 CloseHandle_c + + Call_Asm_Return 1 + +endp ; end procedure CloseHandle_asm2c + + +proc CreateFileA_asm2c public + +; [esp + 7*4] = HANDLE hTemplateFile +; [esp + 6*4] = DWORD dwFlagsAndAttributes +; [esp + 5*4] = DWORD dwCreationDisposition +; [esp + 4*4] = LPSECURITY_ATTRIBUTES lpSecurityAttributes +; [esp + 3*4] = DWORD dwShareMode +; [esp + 2*4] = DWORD dwDesiredAccess +; [esp + 4] = LPCSTR lpFileName +; [esp ] = return address + + Call_Asm_Stack7 CreateFileA_c + + Call_Asm_Return 7 + +endp ; end procedure CreateFileA_asm2c + + +proc FindClose_asm2c public + +; [esp + 4] = HANDLE hFindFile +; [esp ] = return address + + Call_Asm_Stack1 FindClose_c + + Call_Asm_Return 1 + +endp ; end procedure FindClose_asm2c + + +proc FindFirstFileA_asm2c public + +; [esp + 2*4] = LPWIN32_FIND_DATAA lpFindFileData +; [esp + 4] = LPCSTR lpFileName +; [esp ] = return address + + Call_Asm_Stack2 FindFirstFileA_c + + Call_Asm_Return 2 + +endp ; end procedure FindFirstFileA_asm2c + + +proc FindNextFileA_asm2c public + +; [esp + 2*4] = LPWIN32_FIND_DATAA lpFindFileData +; [esp + 4] = HANDLE hFindFile +; [esp ] = return address + + Call_Asm_Stack2 FindNextFileA_c + + Call_Asm_Return 2 + +endp ; end procedure FindNextFileA_asm2c + + +proc GetCurrentDirectoryA_asm2c public + +; [esp + 2*4] = LPSTR lpBuffer +; [esp + 4] = DWORD nBufferLength +; [esp ] = return address + + Call_Asm_Stack2 GetCurrentDirectoryA_c + + Call_Asm_Return 2 + +endp ; end procedure GetCurrentDirectoryA_asm2c + + +proc GetPrivateProfileIntA_asm2c public + +; [esp + 4*4] = LPCSTR lpFileName +; [esp + 3*4] = INT nDefault +; [esp + 2*4] = LPCSTR lpKeyName +; [esp + 4] = LPCSTR lpAppName +; [esp ] = return address + + Call_Asm_Stack4 GetPrivateProfileIntA_c + + Call_Asm_Return 4 + +endp ; end procedure GetPrivateProfileIntA_asm2c + + +proc GetPrivateProfileStringA_asm2c public + +; [esp + 6*4] = LPCSTR lpFileName +; [esp + 5*4] = DWORD nSize +; [esp + 4*4] = LPSTR lpReturnedString +; [esp + 3*4] = LPCSTR lpDefault +; [esp + 2*4] = LPCSTR lpKeyName +; [esp + 4] = LPCSTR lpAppName +; [esp ] = return address + + Call_Asm_Stack6 GetPrivateProfileStringA_c + + Call_Asm_Return 6 + +endp ; end procedure GetPrivateProfileStringA_asm2c + + +proc GetTickCount_asm2c public + +; [esp ] = return address + + Call_Asm_Stack0 GetTickCount_c + + Call_Asm_Return 0 + +endp ; end procedure GetTickCount_asm2c + + +proc GlobalMemoryStatus_asm2c public + +; [esp + 4] = LPMEMORYSTATUS lpBuffer +; [esp ] = return address + + Call_Asm_Stack1_void GlobalMemoryStatus_c + + Call_Asm_Return 1 + +endp ; end procedure GlobalMemoryStatus_asm2c + + +proc ReadFile_asm2c public + +; [esp + 5*4] = LPOVERLAPPED lpOverlapped +; [esp + 4*4] = LPDWORD lpNumberOfBytesRead +; [esp + 3*4] = DWORD nNumberOfBytesToRead +; [esp + 2*4] = LPVOID lpBuffer +; [esp + 4] = HANDLE hFile +; [esp ] = return address + + Call_Asm_Stack5 ReadFile_c + + Call_Asm_Return 5 + +endp ; end procedure ReadFile_asm2c + + +proc SetCurrentDirectoryA_asm2c public + +; [esp + 4] = LPCSTR lpPathName +; [esp ] = return address + + Call_Asm_Stack1 SetCurrentDirectoryA_c + + Call_Asm_Return 1 + +endp ; end procedure SetCurrentDirectoryA_asm2c + + +proc SetFilePointer_asm2c public + +; [esp + 4*4] = DWORD dwMoveMethod +; [esp + 3*4] = PLONG lpDistanceToMoveHigh +; [esp + 2*4] = LONG lDistanceToMove +; [esp + 4] = HANDLE hFile +; [esp ] = return address + + Call_Asm_Stack4 SetFilePointer_c + + Call_Asm_Return 4 + +endp ; end procedure SetFilePointer_asm2c + + +proc WriteFile_asm2c public + +; [esp + 5*4] = LPOVERLAPPED lpOverlapped +; [esp + 4*4] = LPDWORD lpNumberOfBytesWritten +; [esp + 3*4] = DWORD nNumberOfBytesToWrite +; [esp + 2*4] = LPCVOID lpBuffer +; [esp + 4] = HANDLE hFile +; [esp ] = return address + + Call_Asm_Stack5 WriteFile_c + + Call_Asm_Return 5 + +endp ; end procedure WriteFile_asm2c + + +proc WritePrivateProfileStringA_asm2c public + +; [esp + 4*4] = LPCSTR lpFileName +; [esp + 3*4] = LPCSTR lpString +; [esp + 2*4] = LPCSTR lpKeyName +; [esp + 4] = LPCSTR lpAppName +; [esp ] = return address + + Call_Asm_Stack4 WritePrivateProfileStringA_c + + Call_Asm_Return 4 + +endp ; end procedure WritePrivateProfileStringA_asm2c + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/WinApi-user32-asm-llasm.c b/games/Battle Isle 3/SR-BI3/llasm/WinApi-user32-asm-llasm.c new file mode 100644 index 0000000..e5559a1 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/WinApi-user32-asm-llasm.c @@ -0,0 +1,33 @@ +/** + * + * Copyright (C) 2019-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "WinApi-user32-asm-llasm.h" +#include "printf_x86.h" + + +int32_t wsprintfA2_c(char * param1, const char * param2, uint32_t *ap) +{ + return vsprintf_x86(param1, param2, ap); +} + diff --git a/games/Battle Isle 3/SR-BI3/llasm/WinApi-user32-asm-llasm.h b/games/Battle Isle 3/SR-BI3/llasm/WinApi-user32-asm-llasm.h new file mode 100644 index 0000000..1a94ad3 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/WinApi-user32-asm-llasm.h @@ -0,0 +1,41 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_WINAPI_USER32_ASM_LLASM_H_INCLUDED_) +#define _WINAPI_USER32_ASM_LLASM_H_INCLUDED_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int32_t wsprintfA2_c(char * param1, const char * param2, uint32_t *ap); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/games/Battle Isle 3/SR-BI3/llasm/WinApi-user32-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/WinApi-user32-asm.llasm new file mode 100644 index 0000000..17dd577 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/WinApi-user32-asm.llasm @@ -0,0 +1,420 @@ +;; +;; Copyright (C) 2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +func ClientToScreen_c *hWnd, *lpPoint +func ClipCursor_c *lpRect +func CreateWindowExA_c dwExStyle, *lpClassName, *lpWindowName, dwStyle, X, Y, nWidth, nHeight, *hWndParent, *hMenu, *hInstance, *lpParam +func GetActiveWindow_c +func GetCursorPos_c *lpPoint +func GetDC_c *hWnd +func GetWindowRect_c *hWnd, *lpRect +func IsIconic_c *hWnd +func IsWindowVisible_c *hWnd +func LoadCursorA_c *hInstance, *lpCursorName +func LoadStringA_c *hInstance, uID, *lpBuffer, cchBufferMax +func MessageBoxA_c *hWnd, *lpText, *lpCaption, uType +func MoveWindow_c *hWnd, X, Y, nWidth, nHeight, bRepaint +func ReleaseCapture_c +func ReleaseDC_c *hWnd, *hDC +func ScreenToClient_c *hWnd, *lpPoint +func SendMessageA_c *hWnd, Msg, wParam, lParam +func SetActiveWindow_c *hWnd +func SetCursor_c *hCursor +func SetCursorPos_c X, Y +func SetRect_c *lprc, xLeft, yTop, xRight, yBottom +func SetRectEmpty_c *lprc +func SetWindowPos_c *hWnd, *hWndInsertAfter, X, Y, cx, cy, uFlags +func ShowCursor_c bShow +func ShowWindow_c *hWnd, nCmdShow +func UnregisterClassA_c *lpClassName, *hInstance +func wsprintfA2_c *param1, *param2, *ap + +proc ClientToScreen_asm2c public + +; [esp + 2*4] = LPPOINT lpPoint +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack2 ClientToScreen_c + + Call_Asm_Return 2 + +endp ; end procedure ClientToScreen_asm2c + + +proc ClipCursor_asm2c public + +; [esp + 4] = CONST RECT * lpRect +; [esp ] = return address + + Call_Asm_Stack1 ClipCursor_c + + Call_Asm_Return 1 + +endp ; end procedure ClipCursor_asm2c + + +proc CreateWindowExA_asm2c public + +; [esp + 12*4] = LPVOID lpParam +; [esp + 11*4] = HINSTANCE hInstance +; [esp + 10*4] = HMENU hMenu +; [esp + 9*4] = HWND hWndParent +; [esp + 8*4] = int nHeight +; [esp + 7*4] = int nWidth +; [esp + 6*4] = int Y +; [esp + 5*4] = int X +; [esp + 4*4] = DWORD dwStyle +; [esp + 3*4] = LPCSTR lpWindowName +; [esp + 2*4] = LPCSTR lpClassName +; [esp + 4] = DWORD dwExStyle +; [esp ] = return address + + Call_Asm_Stack12 CreateWindowExA_c + + Call_Asm_Return 12 + +endp ; end procedure CreateWindowExA_asm2c + + +proc GetActiveWindow_asm2c public + +; [esp ] = return address + + Call_Asm_Stack0 GetActiveWindow_c + + Call_Asm_Return 0 + +endp ; end procedure GetActiveWindow_asm2c + + +proc GetCursorPos_asm2c public + +; [esp + 4] = LPPOINT lpPoint +; [esp ] = return address + + Call_Asm_Stack1 GetCursorPos_c + + Call_Asm_Return 1 + +endp ; end procedure GetCursorPos_asm2c + + +proc GetDC_asm2c public + +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack1 GetDC_c + + Call_Asm_Return 1 + +endp ; end procedure GetDC_asm2c + + +proc GetWindowRect_asm2c public + +; [esp + 2*4] = LPRECT lpRect +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack2 GetWindowRect_c + + Call_Asm_Return 2 + +endp ; end procedure GetWindowRect_asm2c + + +proc IsIconic_asm2c public + +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack1 IsIconic_c + + Call_Asm_Return 1 + +endp ; end procedure IsIconic_asm2c + + +proc IsWindowVisible_asm2c public + +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack1 IsWindowVisible_c + + Call_Asm_Return 1 + +endp ; end procedure IsWindowVisible_asm2c + + +proc LoadCursorA_asm2c public + +; [esp + 2*4] = LPCSTR lpCursorName +; [esp + 4] = HINSTANCE hInstance +; [esp ] = return address + + Call_Asm_Stack2 LoadCursorA_c + + Call_Asm_Return 2 + +endp ; end procedure LoadCursorA_asm2c + + +proc LoadStringA_asm2c public + +; [esp + 4*4] = int cchBufferMax +; [esp + 3*4] = LPSTR lpBuffer +; [esp + 2*4] = UINT uID +; [esp + 4] = HINSTANCE hInstance +; [esp ] = return address + + Call_Asm_Stack4 LoadStringA_c + + Call_Asm_Return 4 + +endp ; end procedure LoadStringA_asm2c + + +proc MessageBoxA_asm2c public + +; [esp + 4*4] = UINT uType +; [esp + 3*4] = LPCSTR lpCaption +; [esp + 2*4] = LPCSTR lpText +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack4 MessageBoxA_c + + Call_Asm_Return 4 + +endp ; end procedure MessageBoxA_asm2c + + +proc MoveWindow_asm2c public + +; [esp + 6*4] = WINBOOL bRepaint +; [esp + 5*4] = int nHeight +; [esp + 4*4] = int nWidth +; [esp + 3*4] = int Y +; [esp + 2*4] = int X +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack6 MoveWindow_c + + Call_Asm_Return 6 + +endp ; end procedure MoveWindow_asm2c + + +proc ReleaseCapture_asm2c public + +; [esp ] = return address + + Call_Asm_Stack0 ReleaseCapture_c + + Call_Asm_Return 0 + +endp ; end procedure ReleaseCapture_asm2c + + +proc ReleaseDC_asm2c public + +; [esp + 2*4] = HDC hDC +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack2 ReleaseDC_c + + Call_Asm_Return 2 + +endp ; end procedure ReleaseDC_asm2c + + +proc ScreenToClient_asm2c public + +; [esp + 2*4] = LPPOINT lpPoint +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack2 ScreenToClient_c + + Call_Asm_Return 2 + +endp ; end procedure ScreenToClient_asm2c + + +proc SendMessageA_asm2c public + +; [esp + 4*4] = LPARAM lParam +; [esp + 3*4] = WPARAM wParam +; [esp + 2*4] = UINT Msg +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack4 SendMessageA_c + + Call_Asm_Return 4 + +endp ; end procedure SendMessageA_asm2c + + +proc SetActiveWindow_asm2c public + +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack1 SetActiveWindow_c + + Call_Asm_Return 1 + +endp ; end procedure SetActiveWindow_asm2c + + +proc SetCursor_asm2c public + +; [esp + 4] = HCURSOR hCursor +; [esp ] = return address + + Call_Asm_Stack1 SetCursor_c + + Call_Asm_Return 1 + +endp ; end procedure SetCursor_asm2c + + +proc SetCursorPos_asm2c public + +; [esp + 2*4] = int Y +; [esp + 4] = int X +; [esp ] = return address + + Call_Asm_Stack2 SetCursorPos_c + + Call_Asm_Return 2 + +endp ; end procedure SetCursorPos_asm2c + + +proc SetRect_asm2c public + +; [esp + 5*4] = int yBottom +; [esp + 4*4] = int xRight +; [esp + 3*4] = int yTop +; [esp + 2*4] = int xLeft +; [esp + 4] = LPRECT lprc +; [esp ] = return address + + Call_Asm_Stack5 SetRect_c + + Call_Asm_Return 5 + +endp ; end procedure SetRect_asm2c + + +proc SetRectEmpty_asm2c public + +; [esp + 4] = LPRECT lprc +; [esp ] = return address + + Call_Asm_Stack1 SetRectEmpty_c + + Call_Asm_Return 1 + +endp ; end procedure SetRectEmpty_asm2c + + +proc SetWindowPos_asm2c public + +; [esp + 7*4] = UINT uFlags +; [esp + 6*4] = int cy +; [esp + 5*4] = int cx +; [esp + 4*4] = int Y +; [esp + 3*4] = int X +; [esp + 2*4] = HWND hWndInsertAfter +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack7 SetWindowPos_c + + Call_Asm_Return 7 + +endp ; end procedure SetWindowPos_asm2c + + +proc ShowCursor_asm2c public + +; [esp + 4] = WINBOOL bShow +; [esp ] = return address + + Call_Asm_Stack1 ShowCursor_c + + Call_Asm_Return 1 + +endp ; end procedure ShowCursor_asm2c + + +proc ShowWindow_asm2c public + +; [esp + 2*4] = int nCmdShow +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack2 ShowWindow_c + + Call_Asm_Return 2 + +endp ; end procedure ShowWindow_asm2c + + +proc UnregisterClassA_asm2c public + +; [esp + 2*4] = HINSTANCE hInstance +; [esp + 4] = LPCSTR lpClassName +; [esp ] = return address + + Call_Asm_Stack2 UnregisterClassA_c + + Call_Asm_Return 2 + +endp ; end procedure UnregisterClassA_asm2c + + +proc wsprintfA_asm2c public + +; [esp + 3*4] = ... +; [esp + 2*4] = LPCSTR param2 +; [esp + 4] = LPSTR param1 +; [esp ] = return address + + Call_Asm_VariableStack2 wsprintfA2_c + + Call_Asm_Return 0 + +endp ; end procedure wsprintfA_asm2c + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/WinApi-winmm-asm.llasm b/games/Battle Isle 3/SR-BI3/llasm/WinApi-winmm-asm.llasm new file mode 100644 index 0000000..3ef65b5 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/WinApi-winmm-asm.llasm @@ -0,0 +1,57 @@ +;; +;; Copyright (C) 2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +include llasm.llinc +include asm-calls.llinc + +func mciGetErrorStringA_c mcierr, *pszText, cchText +func mciSendCommandA_c mciId, uMsg, *dwParam1, *dwParam2 + +proc mciGetErrorStringA_asm2c public + +; [esp + 3*4] = UINT cchText +; [esp + 2*4] = LPSTR pszText +; [esp + 4] = MCIERROR mcierr +; [esp ] = return address + + Call_Asm_Stack3 mciGetErrorStringA_c + + Call_Asm_Return 3 + +endp ; end procedure mciGetErrorStringA_asm2c + + +proc mciSendCommandA_asm2c public + +; [esp + 4*4] = DWORD_PTR dwParam2 +; [esp + 3*4] = DWORD_PTR dwParam1 +; [esp + 2*4] = UINT uMsg +; [esp + 4] = MCIDEVICEID mciId +; [esp ] = return address + + Call_Asm_Stack4 mciSendCommandA_c + + Call_Asm_Return 4 + +endp ; end procedure mciSendCommandA_asm2c + + diff --git a/games/Battle Isle 3/SR-BI3/llasm/X86_FS_mem.c b/games/Battle Isle 3/SR-BI3/llasm/X86_FS_mem.c new file mode 100644 index 0000000..d261e5f --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/X86_FS_mem.c @@ -0,0 +1,107 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include +#include +#define WIN32_LEAN_AND_MEAN +#include + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +// C11 +static _Thread_local uint32_t current_SEH_frame = 0; +#elif defined(__cplusplus) && __cplusplus >= 201103L +// C++11 +static thread_local uint32_t current_SEH_frame = 0; +#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) || defined(__IBMC__) || defined(__IBMCPP__) || defined(__ibmxl__) || defined(__GNUC__) || defined(__llvm__) || (defined(__INTEL_COMPILER) && defined(__linux__)) +static __thread uint32_t current_SEH_frame = 0; +#elif defined(_MSC_VER) || (defined(__INTEL_COMPILER) && defined(_WIN32)) || defined(__BORLANDC__) || defined(__DMC__) +static __declspec(thread) uint32_t current_SEH_frame = 0; +#else +#error thread local variables are not supported +#endif + + +static void *vectored_exception_handle = NULL; + + +static LONG CALLBACK exception_handler(PEXCEPTION_POINTERS ExceptionInfo) +{ + if (current_SEH_frame == 0) + { + return EXCEPTION_CONTINUE_SEARCH; + } + + fprintf(stderr, "vectored exception handler: 0x%x\n", ExceptionInfo->ExceptionRecord->ExceptionCode); + TerminateProcess(GetCurrentProcess(), 0); + return 0; +} + + +void X86_InitializeExceptions(void) __attribute__((noinline)); +void X86_InitializeExceptions(void) +{ + vectored_exception_handle = AddVectoredExceptionHandler(1, exception_handler); +} + + +uint32_t X86_ReadFsDword(uint32_t addr) +{ + uint32_t *address; + + if (addr == 0) + { + if (current_SEH_frame != 0) + { + return current_SEH_frame; + } + } + + address = (uint32_t *) (addr + (uintptr_t)NtCurrentTeb()); + + return *address; +} + +void X86_WriteFsDword(uint32_t addr, uint32_t value) +{ + uint32_t *address; + + address = (uint32_t *) (addr + (uintptr_t)NtCurrentTeb()); + + if (addr == 0) + { + if (value == *address) + { + current_SEH_frame = 0; + } + else + { + current_SEH_frame = value; + } + } + else + { + *address = value; + } +} + diff --git a/games/Battle Isle 3/SR-BI3/llasm/asm-calls.llinc b/games/Battle Isle 3/SR-BI3/llasm/asm-calls.llinc new file mode 100644 index 0000000..5906257 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/asm-calls.llinc @@ -0,0 +1,329 @@ +;; +;; Copyright (C) 2019-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +macro Call_Asm_Return _numpop + load tmp0, esp, 4 + add esp, esp, 4 + (\_numpop * 4) + tcall tmp0 +endm + +macro Call_Asm_VariableStack1 proc_name + add tmp0, esp, 4 + load tmp0, tmp0, 4 + add tmp1, esp, 2*4 + call \proc_name tmp0, tmp1 + mov eax, tmp0 +endm + +macro Call_Asm_VariableStack2 proc_name + add tmp0, esp, 4 + load tmp0, tmp0, 4 + add tmp1, esp, 2*4 + load tmp1, tmp1, 4 + add tmp2, esp, 3*4 + call \proc_name tmp0, tmp1, tmp2 + mov eax, tmp0 +endm + +macro Call_Asm_Stack0 proc_name + call \proc_name + mov eax, tmp0 +endm + +macro Call_Asm_Stack0_void proc_name + call \proc_name +endm + +macro Call_Asm_Stack1 proc_name + add tmp0, esp, 4 + load tmp0, tmp0, 4 + call \proc_name tmp0 + mov eax, tmp0 +endm + +macro Call_Asm_Stack1_void proc_name + add tmp0, esp, 4 + load tmp0, tmp0, 4 + call \proc_name tmp0 +endm + +macro Call_Asm_Stack2 proc_name + add tmp0, esp, 4 + load tmp0, tmp0, 4 + add tmp1, esp, 2*4 + load tmp1, tmp1, 4 + call \proc_name tmp0, tmp1 + mov eax, tmp0 +endm + +macro Call_Asm_Stack2_void proc_name + add tmp0, esp, 4 + load tmp0, tmp0, 4 + add tmp1, esp, 2*4 + load tmp1, tmp1, 4 + call \proc_name tmp0, tmp1 +endm + +macro Call_Asm_Stack3 proc_name + add tmp0, esp, 4 + load tmp0, tmp0, 4 + add tmp1, esp, 2*4 + load tmp1, tmp1, 4 + add tmp2, esp, 3*4 + load tmp2, tmp2, 4 + call \proc_name tmp0, tmp1, tmp2 + mov eax, tmp0 +endm + +macro Call_Asm_Stack3_void proc_name + add tmp0, esp, 4 + load tmp0, tmp0, 4 + add tmp1, esp, 2*4 + load tmp1, tmp1, 4 + add tmp2, esp, 3*4 + load tmp2, tmp2, 4 + call \proc_name tmp0, tmp1, tmp2 +endm + +macro Call_Asm_Stack4 proc_name + add tmp0, esp, 4 + load tmp0, tmp0, 4 + add tmp1, esp, 2*4 + load tmp1, tmp1, 4 + add tmp2, esp, 3*4 + load tmp2, tmp2, 4 + add tmp3, esp, 4*4 + load tmp3, tmp3, 4 + call \proc_name tmp0, tmp1, tmp2, tmp3 + mov eax, tmp0 +endm + +macro Call_Asm_Stack4_void proc_name + add tmp0, esp, 4 + load tmp0, tmp0, 4 + add tmp1, esp, 2*4 + load tmp1, tmp1, 4 + add tmp2, esp, 3*4 + load tmp2, tmp2, 4 + add tmp3, esp, 4*4 + load tmp3, tmp3, 4 + call \proc_name tmp0, tmp1, tmp2, tmp3 +endm + +macro Call_Asm_Stack5 proc_name + add tmp0, esp, 4 + load tmp0, tmp0, 4 + add tmp1, esp, 2*4 + load tmp1, tmp1, 4 + add tmp2, esp, 3*4 + load tmp2, tmp2, 4 + add tmp3, esp, 4*4 + load tmp3, tmp3, 4 + add tmp4, esp, 5*4 + load tmp4, tmp4, 4 + call \proc_name tmp0, tmp1, tmp2, tmp3, tmp4 + mov eax, tmp0 +endm + +macro Call_Asm_Stack5_void proc_name + add tmp0, esp, 4 + load tmp0, tmp0, 4 + add tmp1, esp, 2*4 + load tmp1, tmp1, 4 + add tmp2, esp, 3*4 + load tmp2, tmp2, 4 + add tmp3, esp, 4*4 + load tmp3, tmp3, 4 + add tmp4, esp, 5*4 + load tmp4, tmp4, 4 + call \proc_name tmp0, tmp1, tmp2, tmp3, tmp4 +endm + +macro Call_Asm_Stack6 proc_name + add tmp0, esp, 4 + load tmp0, tmp0, 4 + add tmp1, esp, 2*4 + load tmp1, tmp1, 4 + add tmp2, esp, 3*4 + load tmp2, tmp2, 4 + add tmp3, esp, 4*4 + load tmp3, tmp3, 4 + add tmp4, esp, 5*4 + load tmp4, tmp4, 4 + add tmp5, esp, 6*4 + load tmp5, tmp5, 4 + call \proc_name tmp0, tmp1, tmp2, tmp3, tmp4, tmp5 + mov eax, tmp0 +endm + +macro Call_Asm_Stack6_void proc_name + add tmp0, esp, 4 + load tmp0, tmp0, 4 + add tmp1, esp, 2*4 + load tmp1, tmp1, 4 + add tmp2, esp, 3*4 + load tmp2, tmp2, 4 + add tmp3, esp, 4*4 + load tmp3, tmp3, 4 + add tmp4, esp, 5*4 + load tmp4, tmp4, 4 + add tmp5, esp, 6*4 + load tmp5, tmp5, 4 + call \proc_name tmp0, tmp1, tmp2, tmp3, tmp4, tmp5 +endm + +macro Call_Asm_Stack7 proc_name + add tmp0, esp, 4 + load tmp0, tmp0, 4 + add tmp1, esp, 2*4 + load tmp1, tmp1, 4 + add tmp2, esp, 3*4 + load tmp2, tmp2, 4 + add tmp3, esp, 4*4 + load tmp3, tmp3, 4 + add tmp4, esp, 5*4 + load tmp4, tmp4, 4 + add tmp5, esp, 6*4 + load tmp5, tmp5, 4 + add tmp6, esp, 7*4 + load tmp6, tmp6, 4 + call \proc_name tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6 + mov eax, tmp0 +endm + +macro Call_Asm_Stack8 proc_name + add tmp0, esp, 4 + load tmp0, tmp0, 4 + add tmp1, esp, 2*4 + load tmp1, tmp1, 4 + add tmp2, esp, 3*4 + load tmp2, tmp2, 4 + add tmp3, esp, 4*4 + load tmp3, tmp3, 4 + add tmp4, esp, 5*4 + load tmp4, tmp4, 4 + add tmp5, esp, 6*4 + load tmp5, tmp5, 4 + add tmp6, esp, 7*4 + load tmp6, tmp6, 4 + add tmp7, esp, 8*4 + load tmp7, tmp7, 4 + call \proc_name tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7 + mov eax, tmp0 +endm + +macro Call_Asm_Stack8_void proc_name + add tmp0, esp, 4 + load tmp0, tmp0, 4 + add tmp1, esp, 2*4 + load tmp1, tmp1, 4 + add tmp2, esp, 3*4 + load tmp2, tmp2, 4 + add tmp3, esp, 4*4 + load tmp3, tmp3, 4 + add tmp4, esp, 5*4 + load tmp4, tmp4, 4 + add tmp5, esp, 6*4 + load tmp5, tmp5, 4 + add tmp6, esp, 7*4 + load tmp6, tmp6, 4 + add tmp7, esp, 8*4 + load tmp7, tmp7, 4 + call \proc_name tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7 +endm + +macro Call_Asm_Stack9 proc_name + add tmp0, esp, 4 + load tmp0, tmp0, 4 + add tmp1, esp, 2*4 + load tmp1, tmp1, 4 + add tmp2, esp, 3*4 + load tmp2, tmp2, 4 + add tmp3, esp, 4*4 + load tmp3, tmp3, 4 + add tmp4, esp, 5*4 + load tmp4, tmp4, 4 + add tmp5, esp, 6*4 + load tmp5, tmp5, 4 + add tmp6, esp, 7*4 + load tmp6, tmp6, 4 + add tmp7, esp, 8*4 + load tmp7, tmp7, 4 + add tmp8, esp, 9*4 + load tmp8, tmp8, 4 + call \proc_name tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8 + mov eax, tmp0 +endm + +macro Call_Asm_Stack10_void proc_name + add tmp0, esp, 4 + load tmp0, tmp0, 4 + add tmp1, esp, 2*4 + load tmp1, tmp1, 4 + add tmp2, esp, 3*4 + load tmp2, tmp2, 4 + add tmp3, esp, 4*4 + load tmp3, tmp3, 4 + add tmp4, esp, 5*4 + load tmp4, tmp4, 4 + add tmp5, esp, 6*4 + load tmp5, tmp5, 4 + add tmp6, esp, 7*4 + load tmp6, tmp6, 4 + add tmp7, esp, 8*4 + load tmp7, tmp7, 4 + add tmp8, esp, 9*4 + load tmp8, tmp8, 4 + add tmp9, esp, 10*4 + load tmp9, tmp9, 4 + call \proc_name tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8, tmp9 +endm + +macro Call_Asm_Stack12 proc_name + add tmp0, esp, 4 + load tmp0, tmp0, 4 + add tmp1, esp, 2*4 + load tmp1, tmp1, 4 + add tmp2, esp, 3*4 + load tmp2, tmp2, 4 + add tmp3, esp, 4*4 + load tmp3, tmp3, 4 + add tmp4, esp, 5*4 + load tmp4, tmp4, 4 + add tmp5, esp, 6*4 + load tmp5, tmp5, 4 + add tmp6, esp, 7*4 + load tmp6, tmp6, 4 + add tmp7, esp, 8*4 + load tmp7, tmp7, 4 + add tmp8, esp, 9*4 + load tmp8, tmp8, 4 + add tmp9, esp, 10*4 + load tmp9, tmp9, 4 + add tmp10, esp, 11*4 + load tmp10, tmp10, 4 + add tmp11, esp, 12*4 + load tmp11, tmp11, 4 + call \proc_name tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8, tmp9, tmp10, tmp11 + mov eax, tmp0 +endm + diff --git a/games/Battle Isle 3/SR-BI3/llasm/asm-cpu.c b/games/Battle Isle 3/SR-BI3/llasm/asm-cpu.c new file mode 100644 index 0000000..c82a1e7 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/asm-cpu.c @@ -0,0 +1,87 @@ +/** + * + * Copyright (C) 2019 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "llasm_cpu.h" +#include + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +// C11 +static _Thread_local _cpu *thread_cpu = NULL; +#elif defined(__cplusplus) && __cplusplus >= 201103L +// C++11 +static thread_local _cpu *thread_cpu = NULL; +#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) || defined(__IBMC__) || defined(__IBMCPP__) || defined(__ibmxl__) || defined(__GNUC__) || defined(__llvm__) || (defined(__INTEL_COMPILER) && defined(__linux__)) +static __thread _cpu *thread_cpu = NULL; +#elif defined(_MSC_VER) || (defined(__INTEL_COMPILER) && defined(_WIN32)) || defined(__BORLANDC__) || defined(__DMC__) +static __declspec(thread) _cpu *thread_cpu = NULL; +#else +#error thread local variables are not supported +#endif + +uint32_t X86_InterruptFlag; + +EXTERNC _cpu *x86_initialize_cpu(void) +{ + _cpu *cpu; + + cpu = thread_cpu; + if (cpu != NULL) return cpu; + + cpu = (_cpu *)malloc(sizeof(_cpu)); + if (cpu == NULL) exit(1); + + cpu->stack_bottom = malloc(1024 * 1024); + if (cpu->stack_bottom == NULL) exit(2); + + cpu->stack_top = (void *)(1024 * 1024 + (uintptr_t)cpu->stack_bottom); + + cpu->_st_top = 0; + cpu->_st_sw_cond = 0; + cpu->_st_cw = 0x037f; + + esp = (uint32_t)(uintptr_t)cpu->stack_top; + eflags = 0x3202; + X86_InterruptFlag = 1; + + thread_cpu = cpu; + return cpu; +} + +EXTERNC void x86_deinitialize_cpu(void) +{ + _cpu *cpu; + + cpu = thread_cpu; + if (cpu == NULL) return; + + if (cpu->stack_bottom != NULL) + { + free(cpu->stack_bottom); + cpu->stack_bottom = NULL; + } + + free(cpu); + thread_cpu = NULL; +} + diff --git a/games/Battle Isle 3/SR-BI3/llasm/llasm.llinc b/games/Battle Isle 3/SR-BI3/llasm/llasm.llinc new file mode 100644 index 0000000..c65d0d5 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/llasm.llinc @@ -0,0 +1,58 @@ +;part of static recompiler -- do not edit + +;; +;; Copyright (C) 2019-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +macro NOP +endm + +define CF_SHIFT 0 +define PF_SHIFT 2 +define AF_SHIFT 4 +define ZF_SHIFT 6 +define SF_SHIFT 7 +define OF_SHIFT 11 + +define IF_SHIFT 9 +define DF_SHIFT 10 + +define CF 0x01 +define PF 0x04 +define AF 0x10 +define ZF 0x40 +define SF 0x80 +define OF 0x0800 + +define IF 0x0200 +define DF 0x0400 + +include llasm_divide.llinc +include llasm_float.llinc +include llasm_fs_mem.llinc +;include llasm_inout.llinc +;include llasm_int.llinc +;include llasm_movmem.llinc +include llasm_movs.llinc +include llasm_pushx.llinc +;include llasm_scas.llinc +include llasm_stos.llinc +;include llasm_xti.llinc diff --git a/games/Battle Isle 3/SR-BI3/llasm/llasm_cpu.h b/games/Battle Isle 3/SR-BI3/llasm/llasm_cpu.h new file mode 100644 index 0000000..77acf78 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/llasm_cpu.h @@ -0,0 +1,118 @@ +//part of static recompiler -- do not edit + +/** + * + * Copyright (C) 2019 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include + +typedef struct { + uint32_t _eax, _ecx, _edx, _ebx, _esp, _ebp, _esi, _edi, _eflags; + uint32_t _st_top, _st_sw_cond, _st_cw; + double _st[8]; + int64_t _st_result; + void *stack_bottom, *stack_top; +} _cpu; + +#define CPU _cpu *cpu + +#define eax cpu->_eax +#define ebx cpu->_ebx +#define ecx cpu->_ecx +#define edx cpu->_edx +#define esi cpu->_esi +#define edi cpu->_edi +#define ebp cpu->_ebp +#define esp cpu->_esp +#define eflags cpu->_eflags + +#define CF_SHIFT 0 +#define PF_SHIFT 2 +#define AF_SHIFT 4 +#define ZF_SHIFT 6 +#define SF_SHIFT 7 +#define OF_SHIFT 11 + +#define IF_SHIFT 9 +#define DF_SHIFT 10 + +#define CF 0x01 +#define PF 0x04 +#define AF 0x10 +#define ZF 0x40 +#define SF 0x80 +#define OF 0x0800 + +#define IF 0x0200 +#define DF 0x0400 + +#define REG2PTR(x) ((void *)(uintptr_t)(x)) + +#ifdef __cplusplus +#define EXTERNC extern "C" +#else +#define EXTERNC +#endif + +// ********************************************************************* + +typedef struct { + uint32_t u; +} __attribute__((packed)) _unaligned32; + +static inline uint32_t unaligned_read_32(void *adr) +{ + _unaligned32 *uptr = (_unaligned32 *)adr; + return uptr->u; +} + +static inline void unaligned_write_32(void *adr, uint32_t val) +{ + _unaligned32 *uptr = (_unaligned32 *)adr; + uptr->u = val; +} + +#define UNALIGNED_READ_32(adr) (unaligned_read_32(REG2PTR(adr))) +#define UNALIGNED_WRITE_32(adr, val) unaligned_write_32(REG2PTR(adr), (val)); + +// ********************************************************************* + +typedef struct { + uint16_t u; +} __attribute__((packed)) _unaligned16; + +static inline uint16_t unaligned_read_16(void *adr) +{ + _unaligned16 *uptr = (_unaligned16 *)adr; + return uptr->u; +} + +static inline void unaligned_write_16(void *adr, uint16_t val) +{ + _unaligned16 *uptr = (_unaligned16 *)adr; + uptr->u = val; +} + +#define UNALIGNED_READ_16(adr) (unaligned_read_16(REG2PTR(adr))) +#define UNALIGNED_WRITE_16(adr, val) unaligned_write_16(REG2PTR(adr), (val)); + diff --git a/games/Battle Isle 3/SR-BI3/llasm/llasm_divide.c b/games/Battle Isle 3/SR-BI3/llasm/llasm_divide.c new file mode 100644 index 0000000..9055ec6 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/llasm_divide.c @@ -0,0 +1,148 @@ +//part of static recompiler -- do not edit + +/** + * + * Copyright (C) 2019 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "llasm_cpu.h" + + +EXTERNC void x86_div_64_64(CPU, uint32_t *div) +{ + uint64_t dividend, divisor, result; + + dividend = div[0] | (((uint64_t)div[1]) << 32); + divisor = div[2] | (((uint64_t)div[3]) << 32); + + result = dividend / divisor; + + eax = (uint32_t) result; + edx = (uint32_t) (result >> 32); +} + +EXTERNC void x86_div_64(CPU, uint32_t divisor) +{ + if (edx != 0) + { + uint64_t dividend; + + dividend = (((uint64_t)edx) << 32) | eax; + + eax = (uint32_t) (dividend / divisor); + edx = (uint32_t) (dividend % divisor); + } + else + { + edx = (uint32_t) (eax % divisor); + eax = (uint32_t) (eax / divisor); + } +} + + +EXTERNC void x86_div_32(CPU, uint32_t divisor) +{ + uint32_t dividend, quotient, remainder; + + dividend = (edx << 16) | (eax & 0xffff); + + quotient = (uint32_t) (dividend / divisor); + remainder = (uint32_t) (dividend % divisor); + + eax = (eax & 0xffff0000) | (quotient & 0xffff); + edx = (edx & 0xffff0000) | (remainder & 0xffff); +} + + +EXTERNC void x86_div_16(CPU, uint32_t divisor) +{ + uint16_t dividend; + uint32_t quotient, remainder; + + dividend = (uint16_t)(eax & 0xffff); + + quotient = (uint32_t) (dividend / divisor); + remainder = (uint32_t) (dividend % divisor); + + eax = (eax & 0xffff0000) | (quotient & 0xff) | ((remainder & 0xff) << 8); +} + + +EXTERNC void x86_idiv_64_64(CPU, uint32_t *div) +{ + int64_t dividend, divisor, result; + + dividend = div[0] | (((uint64_t)div[1]) << 32); + divisor = div[2] | (((uint64_t)div[3]) << 32); + + result = dividend / divisor; + + eax = (uint32_t) result; + edx = (uint32_t) (result >> 32); +} + +EXTERNC void x86_idiv_64(CPU, int32_t divisor) +{ + if ((int32_t)edx != (((int32_t)eax) >> 31)) + { + int64_t dividend; + + dividend = (((uint64_t)edx) << 32) | eax; + + eax = (int32_t) (dividend / divisor); + edx = (int32_t) (dividend % divisor); + } + else + { + edx = (int32_t) (((int32_t)eax) % divisor); + eax = (int32_t) (((int32_t)eax) / divisor); + } +} + + +EXTERNC void x86_idiv_32(CPU, int32_t divisor) +{ + int32_t dividend, quotient, remainder; + + dividend = (edx << 16) | (eax & 0xffff); + + quotient = (int32_t) (dividend / divisor); + remainder = (int32_t) (dividend % divisor); + + eax = (eax & 0xffff0000) | (quotient & 0xffff); + edx = (edx & 0xffff0000) | (remainder & 0xffff); +} + + +EXTERNC void x86_idiv_16(CPU, int32_t divisor) +{ + int16_t dividend; + int32_t quotient, remainder; + + dividend = (int16_t)(eax & 0xffff); + + quotient = (int32_t) (dividend / divisor); + remainder = (int32_t) (dividend % divisor); + + eax = (eax & 0xffff0000) | (quotient & 0xff) | ((remainder & 0xff) << 8); +} + diff --git a/games/Battle Isle 3/SR-BI3/llasm/llasm_divide.llinc b/games/Battle Isle 3/SR-BI3/llasm/llasm_divide.llinc new file mode 100644 index 0000000..f76a491 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/llasm_divide.llinc @@ -0,0 +1,65 @@ +;part of static recompiler -- do not edit + +;; +;; Copyright (C) 2019 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +funcv x86_div_64_64 $, *div +funcv x86_div_64 $, divisor +funcv x86_div_32 $, divisor +funcv x86_div_16 $, divisor +funcv x86_idiv_64_64 $, *div +funcv x86_idiv_64 $, divisor +funcv x86_idiv_32 $, divisor +funcv x86_idiv_16 $, divisor + +macro DIV_64_64 div + call x86_div_64_64 $, \div +endm + +macro DIV_64 divisor + call x86_div_64 $, \divisor +endm + +macro DIV_32 divisor + call x86_div_32 $, \divisor +endm + +macro DIV_16 divisor + call x86_div_16 $, \divisor +endm + +macro IDIV_64_64 div + call x86_idiv_64_64 $, \div +endm + +macro IDIV_64 divisor + call x86_idiv_64 $, \divisor +endm + +macro IDIV_32 divisor + call x86_idiv_32 $, \divisor +endm + +macro IDIV_16 divisor + call x86_idiv_16 $, \divisor +endm + diff --git a/games/Battle Isle 3/SR-BI3/llasm/llasm_float.c b/games/Battle Isle 3/SR-BI3/llasm/llasm_float.c new file mode 100644 index 0000000..342fcce --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/llasm_float.c @@ -0,0 +1,932 @@ +// part of static recompiler -- do not edit + +/** + * + * Copyright (C) 2019 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "llasm_cpu.h" +#if !defined(__USE_ISOC99) + #define __USE_ISOC99 +#endif +#include + +#ifdef __FLOAT_WORD_ORDER__ + +#if (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__) +#define BIG_ENDIAN_FLOAT_WORD_ORDER +#else +#undef BIG_ENDIAN_FLOAT_WORD_ORDER +#endif + +#if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) +#define BIG_ENDIAN_BYTE_ORDER +#else +#undef BIG_ENDIAN_BYTE_ORDER +#endif + +#else + +#include +#if (__FLOAT_WORD_ORDER == __BIG_ENDIAN) +#define BIG_ENDIAN_FLOAT_WORD_ORDER +#else +#undef BIG_ENDIAN_FLOAT_WORD_ORDER +#endif + +#if (__BYTE_ORDER == __BIG_ENDIAN) +#define BIG_ENDIAN_BYTE_ORDER +#else +#undef BIG_ENDIAN_BYTE_ORDER +#endif + +#endif + +typedef union { + float f; + int32_t i; +} float_int; + +typedef union { + double d; + struct { +#ifdef BIG_ENDIAN_FLOAT_WORD_ORDER + uint32_t high; + uint32_t low; +#else + uint32_t low; + uint32_t high; +#endif + }; +} double_int; + +typedef union { + int64_t i; + struct { +#ifdef BIG_ENDIAN_BYTE_ORDER + uint32_t high; + uint32_t low; +#else + uint32_t low; + uint32_t high; +#endif + }; +} int_int; + +typedef struct { + uint32_t low; + uint32_t high; +} le_int; + + +const static double const_0_0 = 0.0; +const static double const_1_0 = 1.0; +const static double const_lg2 = 0.30102999566398119521; // log10l(2.0l) +const static double const_ln2 = M_LN2; + +#define st cpu->_st +#define st_result cpu->_st_result + +#define st_top cpu->_st_top +#define st_sw_cond cpu->_st_sw_cond +#define st_cw cpu->_st_cw + +#define X87_CF 0x0100 +#define X87_ZF 0x4000 + +#define X87_C0 0x0100 +#define X87_C1 0x0200 +#define X87_C2 0x0400 +#define X87_C3 0x4000 + +#define X87_CX 0x4700 + +#define X87_RC_SHIFT 10 + +#define CLEAR_X87_FLAG(x) { st_sw_cond &= (~(x)) & X87_CX; } + +#define CLEAR_X87_FLAGS { st_sw_cond = 0; } + +#define X87_CMP(x, y) { \ + if ( (x) < (y) ) { \ + st_sw_cond = X87_CF; \ + } else if ( (x) == (y) ) { \ + st_sw_cond = X87_ZF; \ + } else { \ + st_sw_cond = 0; \ + } \ +} + +#define ST(i) st[(st_top+i) & 7] +#define ST0 st[st_top] +#define ST1 ST(1) + + +#define PUSH_REGS { { CLEAR_X87_FLAG(X87_C1); st_top = (st_top - 1) & 7; } } +#define POP_REGS { st_top = (st_top + 1) & 7; CLEAR_X87_FLAG(X87_C1); } +#define POP2_REGS { st_top = (st_top + 2) & 7; CLEAR_X87_FLAG(X87_C1); } + + +// fpu instructions + +EXTERNC void x87_fabs_void(CPU) +{ + ST0 = fabs(ST0); + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fadd_float(CPU, float_int num) +{ + ST0 += num.f; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fadd_double(CPU, uint32_t num_low, uint32_t num_high) +{ + register double_int num; + + num.low = num_low; + num.high = num_high; + ST0 += num.d; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fadd_st(CPU, int num) +{ + ST0 += ST(num); + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fadd_to_st(CPU, int num) +{ + ST(num) += ST0; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_faddp_st(CPU, int num) +{ + ST(num) += ST0; + POP_REGS; +} + +EXTERNC void x87_fchs_void(CPU) +{ + ST0 = -ST0; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fcom_float(CPU, float_int num) +{ + X87_CMP(ST0, num.f) +} + +EXTERNC void x87_fcom_double(CPU, uint32_t num_low, uint32_t num_high) +{ + register double_int num; + + num.low = num_low; + num.high = num_high; + X87_CMP(ST0, num.d) +} + +EXTERNC void x87_fcomp_float(CPU, float_int num) +{ + X87_CMP(ST0, num.f) + POP_REGS; +} + +EXTERNC void x87_fcomp_double(CPU, uint32_t num_low, uint32_t num_high) +{ + register double_int num; + + num.low = num_low; + num.high = num_high; + X87_CMP(ST0, num.d) + POP_REGS; +} + +EXTERNC void x87_fcos_void(CPU) +{ + ST0 = cos(ST0); + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fdiv_float(CPU, float_int num) +{ + ST0 /= num.f; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fdiv_double(CPU, uint32_t num_low, uint32_t num_high) +{ + register double_int num; + + num.low = num_low; + num.high = num_high; + ST0 /= num.d; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fdiv_st(CPU, int num) +{ + ST0 /= ST(num); + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fdiv_to_st(CPU, int num) +{ + ST(num) /= ST0; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fdivp_st(CPU, int num) +{ + ST(num) /= ST0; + POP_REGS; +} + +EXTERNC void x87_fdivr_float(CPU, float_int num) +{ + ST0 = num.f / ST0; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fdivr_double(CPU, uint32_t num_low, uint32_t num_high) +{ + register double_int num; + + num.low = num_low; + num.high = num_high; + ST0 = num.d / ST0; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fdivr_st(CPU, int num) +{ + ST0 = ST(num) / ST0; +} + +EXTERNC void x87_fdivrp_st(CPU, int num) +{ + ST(num) = ST0 / ST(num); + POP_REGS; +} + +EXTERNC void x87_fiadd_int32(CPU, int32_t num) +{ + ST0 += num; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fidiv_int32(CPU, int32_t num) +{ + ST0 /= num; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fidivr_int32(CPU, int32_t num) +{ + ST0 = num / ST0; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fimul_int32(CPU, int32_t num) +{ + ST0 *= num; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fild_int32(CPU, int32_t num) +{ + PUSH_REGS; + ST0 = num; +} + +EXTERNC void x87_fild_int64(CPU, uint32_t num_low, uint32_t num_high) +{ + register int_int num; + + num.low = num_low; + num.high = num_high; + PUSH_REGS; + ST0 = num.i; +} + +EXTERNC void x87_fninit_void(CPU) +{ + st_top = 0; + st_sw_cond = 0; + st_cw = 0x037f; +} + +EXTERNC int32_t x87_fistp_int32(CPU) +{ + register double dval, orig; + register int32_t ival; + + switch ((st_cw >> X87_RC_SHIFT) & 3) + { + case 0: // Round to nearest (even) + orig = ST0; + dval = floor(orig); + if (orig - dval > 0.5) + { + dval += 1.0; + } + else if (!(orig - dval < 0.5)) + { + POP_REGS; + if ((dval < 2147483648.0) && (dval > -2147483648.0)) + { + ival = (int32_t) dval; + ival += ival & 1; + } + else + { + ival = 0x80000000; + } + return ival; + } + break; + case 1: // Round down (toward -infinity) + dval = floor(ST0); + break; + case 2: // Round up (toward +infinity) + dval = ceil(ST0); + break; + case 3: // Round toward zero (Truncate) + dval = trunc(ST0); + break; + } + POP_REGS; + return ((dval < 2147483648.0) && (dval > -2147483648.0))?((int32_t) dval):0x80000000; +} + +EXTERNC uint32_t x87_fistp_int64(CPU) +{ + register double orig, dval; +#ifdef BIG_ENDIAN_BYTE_ORDER + register int_int uval; + register le_int *presult; + #define ival uval.i +#else + register int64_t ival; +#endif + + orig = ST0; + POP_REGS; + + if ((orig >= 9223372036854775808.0) || (orig <= -9223372036854775808.0)) + { +#ifdef BIG_ENDIAN_BYTE_ORDER + uval.i = __INT64_C(0x8000000000000000); + + presult = (le_int *)&(st_result); + + presult->low = uval.low; + presult->high = uval.high; + + return (uint32_t)(uintptr_t)presult; +#else + st_result = __INT64_C(0x8000000000000000); + return (uint32_t)(uintptr_t)&(st_result); +#endif + } + + switch ((st_cw >> X87_RC_SHIFT) & 3) + { + case 0: // Round to nearest (even) + dval = floor(orig); + ival = (int64_t) dval; + if (orig - dval > 0.5) + { + ival++; + } + else if (!(orig - dval < 0.5)) + { + ival += ival & 1; + } + break; + case 1: // Round down (toward -infinity) + ival = (int64_t) floor(orig); + break; + case 2: // Round up (toward +infinity) + ival = (int64_t) ceil(orig); + break; + case 3: // Round toward zero (Truncate) + ival = (int64_t) trunc(orig); + break; + } + +#ifdef BIG_ENDIAN_BYTE_ORDER + #undef ival + + presult = (le_int *)&(st_result); + + presult->low = uval.low; + presult->high = uval.high; + + return (uint32_t)(uintptr_t)presult; +#else + st_result = ival; + return (uint32_t)(uintptr_t)&(st_result); +#endif +} + +EXTERNC void x87_fisub_int32(CPU, int32_t num) +{ + ST0 -= num; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fisubr_int32(CPU, int32_t num) +{ + ST0 = num - ST0; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fld_float(CPU, float_int num) +{ + PUSH_REGS; + ST0 = num.f; +} + +EXTERNC void x87_fld_double(CPU, uint32_t num_low, uint32_t num_high) +{ + register double_int *pst0; + + PUSH_REGS; + pst0 = (double_int *) &(ST0); + pst0->low = num_low; + pst0->high = num_high; +} + +EXTERNC void x87_fld_st(CPU, int num) +{ + register double newval; + + newval = ST(num); + PUSH_REGS; + ST0 = newval; +} + +EXTERNC void x87_fld1_void(CPU) +{ + PUSH_REGS; + ST0 = const_1_0; +} + +EXTERNC void x87_fldlg2_void(CPU) +{ + PUSH_REGS; + ST0 = const_lg2; +} + +EXTERNC void x87_fldln2_void(CPU) +{ + PUSH_REGS; + ST0 = const_ln2; +} + +EXTERNC void x87_fldz_void(CPU) +{ + PUSH_REGS; + ST0 = const_0_0; +} + +EXTERNC void x87_fldcw_uint16(CPU, uint32_t new_cw) +{ + st_cw = new_cw & 0xffff; +} + +EXTERNC void x87_fmul_float(CPU, float_int num) +{ + ST0 *= num.f; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fmul_double(CPU, uint32_t num_low, uint32_t num_high) +{ + register double_int num; + + num.low = num_low; + num.high = num_high; + ST0 *= num.d; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fmul_st(CPU, int num) +{ + ST0 *= ST(num); + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fmul_to_st(CPU, int num) +{ + ST(num) *= ST0; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fmulp_st(CPU, int num) +{ + ST(num) *= ST0; + POP_REGS; +} + +EXTERNC void x87_fsin_void(CPU) +{ + ST0 = sin(ST0); + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fsqrt_void(CPU) +{ + ST0 = sqrt(ST0); +} + +EXTERNC int32_t x87_fst_float(CPU) +{ + register float_int ret; + + CLEAR_X87_FLAGS; + ret.f = ST0; + + return ret.i; +} + +EXTERNC uint32_t x87_fst_double(CPU) +{ +#ifdef BIG_ENDIAN_FLOAT_WORD_ORDER + register double_int *pst0; + register le_int *presult; + + CLEAR_X87_FLAGS; + pst0 = (double_int *)&(ST0); + presult = (le_int *)&(st_result); + + presult->low = pst0->low; + presult->high = pst0->high; + + return (uint32_t)(uintptr_t)presult; +#else + register void *presult; + + CLEAR_X87_FLAGS; + presult = &(ST0); + + return (uint32_t)(uintptr_t)presult; +#endif +} + +EXTERNC void x87_fst_st(CPU, int num) +{ + CLEAR_X87_FLAGS; + ST(num) = ST0; +} + +EXTERNC int32_t x87_fstp_float(CPU) +{ + register float_int ret; + + ret.f = ST0; + POP_REGS; + return ret.i; +} + +EXTERNC uint32_t x87_fstp_double(CPU) +{ +#ifdef BIG_ENDIAN_FLOAT_WORD_ORDER + register double_int *pst0; + register le_int *presult; + + pst0 = (double_int *)&(ST0); + presult = (le_int *)&(st_result); + + presult->low = pst0->low; + presult->high = pst0->high; + + POP_REGS; + return (uint32_t)(uintptr_t)presult; +#else + register void *presult; + + presult = &(ST0); + POP_REGS; + return (uint32_t)(uintptr_t)presult; +#endif +} + +EXTERNC void x87_fstp_st(CPU, int num) +{ + ST(num) = ST0; + POP_REGS; +} + +EXTERNC uint32_t x87_fnstcw_void(CPU) +{ + return st_cw; +} + +EXTERNC uint32_t x87_fnstsw_void(CPU) +{ + return st_sw_cond | (st_top << 11); +} + +EXTERNC void x87_fsub_float(CPU, float_int num) +{ + ST0 -= num.f; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fsub_double(CPU, uint32_t num_low, uint32_t num_high) +{ + register double_int num; + + num.low = num_low; + num.high = num_high; + ST0 -= num.d; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fsub_st(CPU, int num) +{ + ST0 -= ST(num); + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fsub_to_st(CPU, int num) +{ + ST(num) -= ST0; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fsubp_st(CPU, int num) +{ + ST(num) -= ST0; + POP_REGS; +} + +EXTERNC void x87_fsubr_float(CPU, float_int num) +{ + ST0 = num.f - ST0; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fsubr_double(CPU, uint32_t num_low, uint32_t num_high) +{ + register double_int num; + + num.low = num_low; + num.high = num_high; + ST0 = num.d - ST0; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fsubr_st(CPU, int num) +{ + ST0 = ST(num) - ST0; +} + +EXTERNC void x87_fsubrp_st(CPU, int num) +{ + ST(num) = ST0 - ST(num); + POP_REGS; +} + +EXTERNC void x87_fucom_st(CPU, int num) +{ + X87_CMP(ST0, ST(num)) +} + +EXTERNC void x87_fucomp_st(CPU, int num) +{ + X87_CMP(ST0, ST(num)) + POP_REGS; +} + +EXTERNC void x87_fucompp_void(CPU) +{ + X87_CMP(ST0, ST1) + POP2_REGS; +} + +EXTERNC void x87_fxch_st(CPU, int num) +{ + register double tmpst; + + tmpst = ST0; + ST0 = ST(num); + ST(num) = tmpst; + CLEAR_X87_FLAGS; +} + +EXTERNC void x87_fyl2x_void(CPU) +{ + ST1 *= log2(ST0); + POP_REGS; +} + + +// math functions + +// double acos(double x); +// x = ST0 +// return value = ST0 +EXTERNC void x87_facos_void(CPU) +{ + ST0 = acos(ST0); +} + +// double asin(double x); +// x = ST0 +// return value = ST0 +EXTERNC void x87_fasin_void(CPU) +{ + ST0 = asin(ST0); +} + +// double atan2(double y, double x); +// - arc tangent of y/x +// y = ST0 +// x = ST1 +// return value = ST0 +EXTERNC void x87_fatan2_void(CPU) +{ + ST1 = atan2(ST0, ST1); + POP_REGS; +} + +// double atan2(double y, double x); +// - arc tangent of y/x +// y = ST1 +// x = ST0 +// return value = ST0 +EXTERNC void x87_fatan2r_void(CPU) +{ + ST1 = atan2(ST1, ST0); + POP_REGS; +} + +// double log(double x); +// x = ST0 +// return value = ST0 +EXTERNC void x87_flog_void(CPU) +{ + ST0 = log(ST0); +} + +// double log10(double x); +// x = ST0 +// return value = ST0 +EXTERNC void x87_flog10_void(CPU) +{ + ST0 = log10(ST0); +} + +// double fmod(double x, double y); +// - the floating-point remainder of dividing x by y +// x = ST0 +// y = ST1 +// return value = ST0 +EXTERNC void x87_fmod_void(CPU) +{ + ST1 = fmod(ST0, ST1); + POP_REGS; +} + +// double fmod(double x, double y); +// - the floating-point remainder of dividing x by y +// x = ST1 +// y = ST0 +// return value = ST0 +EXTERNC void x87_fmodr_void(CPU) +{ + ST1 = fmod(ST1, ST0); + POP_REGS; +} + +// double pow(double x, double y); +// - the value of x raised to the power of y +// x = ST0 +// y = ST1 +// return value = ST0 +EXTERNC void x87_fpow_void(CPU) +{ + ST1 = pow(ST0, ST1); + POP_REGS; +} + +// double pow(double x, double y); +// - the value of x raised to the power of y +// x = ST1 +// y = ST0 +// return value = ST0 +EXTERNC void x87_fpowr_void(CPU) +{ + ST1 = pow(ST1, ST0); + POP_REGS; +} + +// double round(double x); +// x = ST0 +// return value = ST0 +EXTERNC void x87_fround_void(CPU) +{ + ST0 = round(ST0); +} + +// double tan(double x); +// x = ST0 +// return value = ST0 +EXTERNC void x87_ftan_void(CPU) +{ + ST0 = tan(ST0); +} + +// truncate toward zero +EXTERNC int32_t x87_ftol_int32(CPU) +{ + const static double doublemagic = 6755399441055744.0; // 2^52 * 1.5 + + double_int result; + double num1, num2; + + num1 = ST0; + POP_REGS; + + if (num1 < 0) + { + if (num1 <= -2147483648.0) return 0x80000000; + + result.d = num1 + doublemagic; // fast conversion to int, + num2 = (double)(int32_t)result.low; // result.low contains the result (rounded up or down) + + if (num2 < num1) // compare result with original value and if the result was rounded toward negative infinity, then increase result (truncate toward 0) + { + result.low++; + } + + return (int32_t)result.low; + } + else + { + if (num1 >= 2147483648.0) return 0x80000000; + + result.d = num1 + doublemagic; // fast conversion to int, + if (0 > (int32_t)result.low) return 0x7fffffff; + num2 = (double)(int32_t)result.low; // result.low contains the result (rounded up or down) + + if (num2 > num1) // compare result with original value and if the result was rounded toward positive infinity, then decrease result (truncate toward 0) + { + result.low--; + } + + return (int32_t)result.low; + } +} + +// truncate toward zero +EXTERNC uint32_t x87_ftol_int64(CPU) +{ + register double orig; + + orig = ST0; + POP_REGS; + +#ifdef BIG_ENDIAN_BYTE_ORDER + register int_int ret; + register le_int *presult; + + ret.i = ((orig < 9223372036854775808.0) && (orig > -9223372036854775808.0))?((int64_t) trunc(orig)):__INT64_C(0x8000000000000000); + + presult = (le_int *)&(st_result); + + presult->low = ret.low; + presult->high = ret.high; + + return (uint32_t)(uintptr_t)presult; +#else + st_result = ((orig < 9223372036854775808.0) && (orig > -9223372036854775808.0))?((int64_t) trunc(orig)):__INT64_C(0x8000000000000000); + return (uint32_t)(uintptr_t)&(st_result); +#endif +} + diff --git a/games/Battle Isle 3/SR-BI3/llasm/llasm_float.llinc b/games/Battle Isle 3/SR-BI3/llasm/llasm_float.llinc new file mode 100644 index 0000000..18b1c68 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/llasm_float.llinc @@ -0,0 +1,499 @@ +;part of static recompiler -- do not edit + +;; +;; Copyright (C) 2019 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +funcv x87_fabs_void $ + +funcv x87_fadd_float $, num +funcv x87_fadd_double $, num_low, num_high +funcv x87_fadd_st $, num +funcv x87_fadd_to_st $, num +funcv x87_faddp_st $, num + +funcv x87_fchs_void $ + +funcv x87_fcom_float $, num +funcv x87_fcom_double $, num_low, num_high +funcv x87_fcomp_float $, num +funcv x87_fcomp_double $, num_low, num_high + +funcv x87_fcos_void $ + +funcv x87_fdiv_float $, num +funcv x87_fdiv_double $, num_low, num_high +funcv x87_fdiv_st $, num +funcv x87_fdiv_to_st $, num +funcv x87_fdivp_st $, num +funcv x87_fdivr_float $, num +funcv x87_fdivr_double $, num_low, num_high +funcv x87_fdivr_st $, num +funcv x87_fdivrp_st $, num + +funcv x87_fiadd_int32 $, num +funcv x87_fidiv_int32 $, num +funcv x87_fidivr_int32 $, num + +funcv x87_fild_int32 $, num +funcv x87_fild_int64 $, num_low, num_high + +funcv x87_fimul_int32 $, num + +funcv x87_fninit_void $ + +func x87_fistp_int32 $ +func x87_fistp_int64 $ + +funcv x87_fisub_int32 $, num +funcv x87_fisubr_int32 $, num + +funcv x87_fld_float $, num +funcv x87_fld_double $, num_low, num_high +funcv x87_fld_st $, num +funcv x87_fld1_void $ +funcv x87_fldlg2_void $ +funcv x87_fldln2_void $ +funcv x87_fldz_void $ + +funcv x87_fldcw_uint16 $, new_cw + +funcv x87_fmul_float $, num +funcv x87_fmul_double $, num_low, num_high +funcv x87_fmul_st $, num +funcv x87_fmul_to_st $, num +funcv x87_fmulp_st $, num + +funcv x87_fsin_void $ + +funcv x87_fsqrt_void $ + +func x87_fst_float $ +func x87_fst_double $ +funcv x87_fst_st $, num +func x87_fstp_float $ +func x87_fstp_double $ +funcv x87_fstp_st $, num + +func x87_fnstcw_void $ +func x87_fnstsw_void $ + +funcv x87_fsub_float $, num +funcv x87_fsub_double $, num_low, num_high +funcv x87_fsub_st $, num +funcv x87_fsub_to_st $, num +funcv x87_fsubp_st $, num +funcv x87_fsubr_float $, num +funcv x87_fsubr_double $, num_low, num_high +funcv x87_fsubr_st $, num +funcv x87_fsubrp_st $, num + +funcv x87_fucom_st $, num +funcv x87_fucomp_st $, num +funcv x87_fucompp_void $ + +funcv x87_fxch_st $, num + +funcv x87_fyl2x_void $ + + +funcv x87_facos_void $ +funcv x87_fasin_void $ +funcv x87_fatan2_void $ +funcv x87_fatan2r_void $ +funcv x87_flog_void $ +funcv x87_flog10_void $ +funcv x87_fmod_void $ +funcv x87_fmodr_void $ +funcv x87_fpow_void $ +funcv x87_fpowr_void $ +funcv x87_fround_void $ +funcv x87_ftan_void $ +func x87_ftol_int32 $ +func x87_ftol_int64 $ + + +macro FABS_VOID + call x87_fabs_void $ +endm + + +macro FADD_FLOAT num + call x87_fadd_float $, \num +endm + +macro FADD_DOUBLE num_low, num_high + call x87_fadd_double $, \num_low, \num_high +endm + +macro FADD_ST num + call x87_fadd_st $, \num +endm + +macro FADD_TO_ST num + call x87_fadd_to_st $, \num +endm + +macro FADDP_ST num + call x87_faddp_st $, \num +endm + + +macro FCHS_VOID + call x87_fchs_void $ +endm + + +macro FCOM_FLOAT num + call x87_fcom_float $, \num +endm + +macro FCOM_DOUBLE num_low, num_high + call x87_fcom_double $, \num_low, \num_high +endm + +macro FCOM_ST num + call x87_fucom_st $, \num +endm + +macro FCOMP_FLOAT num + call x87_fcomp_float $, \num +endm + +macro FCOMP_DOUBLE num_low, num_high + call x87_fcomp_double $, \num_low, \num_high +endm + +macro FCOMP_ST num + call x87_fucomp_st $, \num +endm + +macro FCOMPP_VOID + call x87_fucompp_void $ +endm + + +macro FCOS_VOID + call x87_fcos_void $ +endm + + +macro FDIV_FLOAT num + call x87_fdiv_float $, \num +endm + +macro FDIV_DOUBLE num_low, num_high + call x87_fdiv_double $, \num_low, \num_high +endm + +macro FDIV_ST num + call x87_fdiv_st $, \num +endm + +macro FDIV_TO_ST num + call x87_fdiv_to_st $, \num +endm + +macro FDIVP_ST num + call x87_fdivp_st $, \num +endm + +macro FDIVR_FLOAT num + call x87_fdivr_float $, \num +endm + +macro FDIVR_DOUBLE num_low, num_high + call x87_fdivr_double $, \num_low, \num_high +endm + +macro FDIVR_ST num + call x87_fdivr_st $, \num +endm + +macro FDIVRP_ST num + call x87_fdivrp_st $, \num +endm + + +macro FIADD_INT32 num + call x87_fiadd_int32 $, \num +endm + +macro FIDIV_INT32 num + call x87_fidiv_int32 $, \num +endm + +macro FIDIVR_INT32 num + call x87_fidivr_int32 $, \num +endm + + +macro FILD_INT32 num + call x87_fild_int32 $, \num +endm + +macro FILD_INT64 num_low, num_high + call x87_fild_int64 $, \num_low, \num_high +endm + + +macro FNINIT_VOID + call x87_fninit_void $ +endm + + +macro FIMUL_INT32 num + call x87_fimul_int32 $, \num +endm + + +macro FISTP_INT32 + call x87_fistp_int32 $ +endm + +macro FISTP_INT64 + call x87_fistp_int64 $ +endm + + +macro FISUB_INT32 num + call x87_fisub_int32 $, \num +endm + +macro FISUBR_INT32 num + call x87_fisubr_int32 $, \num +endm + + +macro FLD_FLOAT num + call x87_fld_float $, \num +endm + +macro FLD_DOUBLE num_low, num_high + call x87_fld_double $, \num_low, \num_high +endm + +macro FLD_ST num + call x87_fld_st $, \num +endm + +macro FLD1_VOID + call x87_fld1_void $ +endm + +macro FLDLG2_VOID + call x87_fldlg2_void $ +endm + +macro FLDLN2_VOID + call x87_fldln2_void $ +endm + +macro FLDZ_VOID + call x87_fldz_void $ +endm + + +macro FLDCW_UINT16 new_cw + call x87_fldcw_uint16 $, \new_cw +endm + + +macro FMUL_FLOAT num + call x87_fmul_float $, \num +endm + +macro FMUL_DOUBLE num_low, num_high + call x87_fmul_double $, \num_low, \num_high +endm + +macro FMUL_ST num + call x87_fmul_st $, \num +endm + +macro FMUL_TO_ST num + call x87_fmul_to_st $, \num +endm + +macro FMULP_ST num + call x87_fmulp_st $, \num +endm + + +macro FSIN_VOID + call x87_fsin_void $ +endm + + +macro FSQRT_VOID + call x87_fsqrt_void $ +endm + + +macro FST_FLOAT + call x87_fst_float $ +endm + +macro FST_DOUBLE + call x87_fst_double $ +endm + +macro FST_ST num + call x87_fst_st $, \num +endm + +macro FSTP_FLOAT + call x87_fstp_float $ +endm + +macro FSTP_DOUBLE + call x87_fstp_double $ +endm + +macro FSTP_ST num + call x87_fstp_st $, \num +endm + + +macro FNSTCW_VOID + call x87_fnstcw_void $ +endm + +macro FNSTSW_VOID + call x87_fnstsw_void $ +endm + + +macro FSUB_FLOAT num + call x87_fsub_float $, \num +endm + +macro FSUB_DOUBLE num_low, num_high + call x87_fsub_double $, \num_low, \num_high +endm + +macro FSUB_ST num + call x87_fsub_st $, \num +endm + +macro FSUB_TO_ST num + call x87_fsub_to_st $, \num +endm + +macro FSUBP_ST num + call x87_fsubp_st $, \num +endm + +macro FSUBR_FLOAT num + call x87_fsubr_float $, \num +endm + +macro FSUBR_DOUBLE num_low, num_high + call x87_fsubr_double $, \num_low, \num_high +endm + +macro FSUBR_ST num + call x87_fsubr_st $, \num +endm + +macro FSUBRP_ST num + call x87_fsubrp_st $, \num +endm + + +macro FUCOM_ST num + call x87_fucom_st $, \num +endm + +macro FUCOMP_ST num + call x87_fucomp_st $, \num +endm + +macro FUCOMPP_VOID + call x87_fucompp_void $ +endm + + +macro FXCH_ST num + call x87_fxch_st $, \num +endm + + +macro FYL2X_VOID + call x87_fyl2x_void $ +endm + + +macro FACOS_VOID + call x87_facos_void $ +endm + +macro FASIN_VOID + call x87_fasin_void $ +endm + +macro FATAN2_VOID + call x87_fatan2_void $ +endm + +macro FATAN2R_VOID + call x87_fatan2r_void $ +endm + +macro FLOG_VOID + call x87_flog_void $ +endm + +macro FLOG10_VOID + call x87_flog10_void $ +endm + +macro FMOD_VOID + call x87_fmod_void $ +endm + +macro FMODR_VOID + call x87_fmodr_void $ +endm + +macro FPOW_VOID + call x87_fpow_void $ +endm + +macro FPOWR_VOID + call x87_fpowr_void $ +endm + +macro FROUND_VOID + call x87_fround_void $ +endm + +macro FTAN_VOID + call x87_ftan_void $ +endm + +macro FTOL_INT32 + call x87_ftol_int32 $ +endm + +macro FTOL_INT64 + call x87_ftol_int64 $ +endm diff --git a/games/Battle Isle 3/SR-BI3/llasm/llasm_fs_mem.c b/games/Battle Isle 3/SR-BI3/llasm/llasm_fs_mem.c new file mode 100644 index 0000000..5ac9cc3 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/llasm_fs_mem.c @@ -0,0 +1,50 @@ +//part of static recompiler -- do not edit + +/** + * + * Copyright (C) 2019 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "llasm_cpu.h" + +#ifdef __cplusplus +extern "C" { +#endif + +uint32_t X86_ReadFsDword(uint32_t addr); +void X86_WriteFsDword(uint32_t addr, uint32_t value); + +#ifdef __cplusplus +} +#endif + + +EXTERNC uint32_t x86_read_fs_dword(uint32_t address) +{ + return X86_ReadFsDword(address); +} + +EXTERNC void x86_write_fs_dword(uint32_t address, uint32_t value) +{ + X86_WriteFsDword(address, value); +} + diff --git a/games/Battle Isle 3/SR-BI3/llasm/llasm_fs_mem.llinc b/games/Battle Isle 3/SR-BI3/llasm/llasm_fs_mem.llinc new file mode 100644 index 0000000..9b8d4ec --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/llasm_fs_mem.llinc @@ -0,0 +1,26 @@ +;part of static recompiler -- do not edit + +;; +;; Copyright (C) 2019 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +func x86_read_fs_dword address +funcv x86_write_fs_dword address, value diff --git a/games/Battle Isle 3/SR-BI3/llasm/llasm_movs.c b/games/Battle Isle 3/SR-BI3/llasm/llasm_movs.c new file mode 100644 index 0000000..7112cc0 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/llasm_movs.c @@ -0,0 +1,197 @@ +//part of static recompiler -- do not edit + +/** + * + * Copyright (C) 2019 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "llasm_cpu.h" + +EXTERNC void x86_rep_movsb(CPU) +{ + int32_t dir; + + if (ecx == 0) return; + + dir = (eflags & DF)?-1:1; + + do { + *((uint8_t *)REG2PTR(edi)) = *((uint8_t *)REG2PTR(esi)); + esi += dir; + edi += dir; + + ecx--; + } while (ecx != 0); +} + +EXTERNC void x86_rep_movsd(CPU) +{ + uint32_t srcptr, dstptr, counter; + + counter = ecx; + if (counter == 0) return; + + srcptr = esi; + dstptr = edi; + + if ((eflags & DF) == 0) + { + if (((srcptr | dstptr) & 3) == 0) + { + do { + *((uint32_t *)REG2PTR(dstptr)) = *((uint32_t *)REG2PTR(srcptr)); + srcptr += 4; + dstptr += 4; + + counter--; + } while (counter != 0); + } + else if ((srcptr & 3) == 0) + { + do { + UNALIGNED_WRITE_32(dstptr, *((uint32_t *)REG2PTR(srcptr))) + srcptr += 4; + dstptr += 4; + + counter--; + } while (counter != 0); + } + else if ((dstptr & 3) == 0) + { + do { + *((uint32_t *)REG2PTR(dstptr)) = UNALIGNED_READ_32(srcptr); + srcptr += 4; + dstptr += 4; + + counter--; + } while (counter != 0); + } + else + { + do { + UNALIGNED_WRITE_32(dstptr, UNALIGNED_READ_32(srcptr)) + srcptr += 4; + dstptr += 4; + + counter--; + } while (counter != 0); + } + } + else + { + if (((srcptr | dstptr) & 3) == 0) + { + do { + *((uint32_t *)REG2PTR(dstptr)) = *((uint32_t *)REG2PTR(srcptr)); + srcptr -= 4; + dstptr -= 4; + + counter--; + } while (counter != 0); + } + else if ((srcptr & 3) == 0) + { + do { + UNALIGNED_WRITE_32(dstptr, *((uint32_t *)REG2PTR(srcptr))) + srcptr -= 4; + dstptr -= 4; + + counter--; + } while (counter != 0); + } + else if ((dstptr & 3) == 0) + { + do { + *((uint32_t *)REG2PTR(dstptr)) = UNALIGNED_READ_32(srcptr); + srcptr -= 4; + dstptr -= 4; + + counter--; + } while (counter != 0); + } + else + { + do { + UNALIGNED_WRITE_32(dstptr, UNALIGNED_READ_32(srcptr)) + srcptr -= 4; + dstptr -= 4; + + counter--; + } while (counter != 0); + } + } + + ecx = counter; + esi = srcptr; + edi = dstptr; +} + +EXTERNC void x86_rep_movsw(CPU) +{ + int32_t dir; + + if (ecx == 0) return; + + dir = (eflags & DF)?-2:2; + + if (((esi | edi) & 1) == 0) + { + do { + *((uint16_t *)REG2PTR(edi)) = *((uint16_t *)REG2PTR(esi)); + esi += dir; + edi += dir; + + ecx--; + } while (ecx != 0); + } + else if ((esi & 1) == 0) + { + do { + UNALIGNED_WRITE_16(edi, *((uint16_t *)REG2PTR(esi))) + esi += dir; + edi += dir; + + ecx--; + } while (ecx != 0); + } + else if ((edi & 1) == 0) + { + do { + *((uint16_t *)REG2PTR(edi)) = UNALIGNED_READ_16(esi); + esi += dir; + edi += dir; + + ecx--; + } while (ecx != 0); + } + else + { + do { + UNALIGNED_WRITE_16(edi, UNALIGNED_READ_16(esi)) + esi += dir; + edi += dir; + + ecx--; + } while (ecx != 0); + } +} + diff --git a/games/Battle Isle 3/SR-BI3/llasm/llasm_movs.llinc b/games/Battle Isle 3/SR-BI3/llasm/llasm_movs.llinc new file mode 100644 index 0000000..bc7f052 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/llasm_movs.llinc @@ -0,0 +1,40 @@ +;part of static recompiler -- do not edit + +;; +;; Copyright (C) 2019 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +funcv x86_rep_movsb $ +funcv x86_rep_movsd $ +funcv x86_rep_movsw $ + +macro REP_MOVSB + call x86_rep_movsb $ +endm + +macro REP_MOVSD + call x86_rep_movsd $ +endm + +macro REP_MOVSW + call x86_rep_movsw $ +endm + diff --git a/games/Battle Isle 3/SR-BI3/llasm/llasm_pushx.c b/games/Battle Isle 3/SR-BI3/llasm/llasm_pushx.c new file mode 100644 index 0000000..138cb6f --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/llasm_pushx.c @@ -0,0 +1,115 @@ +//part of static recompiler -- do not edit + +/** + * + * Copyright (C) 2019 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "llasm_cpu.h" + +extern uint32_t X86_InterruptFlag; + + +EXTERNC void x86_pushad(CPU) +{ + uint32_t tmp1, *ptr; + + tmp1 = esp; + esp -= 8*4; + ptr = (uint32_t *)REG2PTR(esp); + + ptr[0] = edi; + ptr[1] = esi; + ptr[2] = ebp; + ptr[3] = tmp1; + ptr[4] = ebx; + ptr[5] = edx; + ptr[6] = ecx; + ptr[7] = eax; +} + +EXTERNC void x86_pushaw(CPU) +{ + uint32_t tmp1, tmp2, tmp3, tmp4, *ptr; + + tmp1 = (edi & 0xffff) | (esi << 16); + tmp2 = (ebp & 0xffff) | (esp << 16); + tmp3 = (ebx & 0xffff) | (edx << 16); + tmp4 = (ecx & 0xffff) | (eax << 16); + + esp -= 8*2; + ptr = (uint32_t *)REG2PTR(esp); + + ptr[0] = tmp1; + ptr[1] = tmp2; + ptr[2] = tmp3; + ptr[3] = tmp4; +} + +EXTERNC void x86_popad(CPU) +{ + uint32_t *ptr; + + ptr = (uint32_t *)REG2PTR(esp); + + edi = ptr[0]; + esi = ptr[1]; + ebp = ptr[2]; + ebx = ptr[4]; + edx = ptr[5]; + ecx = ptr[6]; + eax = ptr[7]; + + esp += 8*4; +} + +EXTERNC void x86_popaw(CPU) +{ + uint32_t tmp1, tmp2, tmp3, tmp4, *ptr; + + ptr = (uint32_t *)REG2PTR(esp); + + tmp1 = ptr[0]; + tmp2 = ptr[1]; + tmp3 = ptr[2]; + tmp4 = ptr[3]; + + esp += 8*2; + + edi = (edi & 0xffff0000) | (tmp1 & 0xffff); + ebp = (ebp & 0xffff0000) | (tmp2 & 0xffff); + ebx = (ebx & 0xffff0000) | (tmp3 & 0xffff); + ecx = (ecx & 0xffff0000) | (tmp4 & 0xffff); + + esi = (edi & 0xffff0000) | (tmp1 >> 16); + edx = (ebx & 0xffff0000) | (tmp3 >> 16); + eax = (ecx & 0xffff0000) | (tmp4 >> 16); +} + +EXTERNC void x86_popfd(CPU) +{ + eflags = *((uint32_t *)REG2PTR(esp)); + esp += 4; + + X86_InterruptFlag = (eflags & IF)?1:0; +} + diff --git a/games/Battle Isle 3/SR-BI3/llasm/llasm_pushx.llinc b/games/Battle Isle 3/SR-BI3/llasm/llasm_pushx.llinc new file mode 100644 index 0000000..5f500d5 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/llasm_pushx.llinc @@ -0,0 +1,66 @@ +;part of static recompiler -- do not edit + +;; +;; Copyright (C) 2019 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +funcv x86_pushad $ +funcv x86_pushaw $ +funcv x86_popad $ +funcv x86_popaw $ +funcv x86_popfd $ + +macro PUSH val + sub esp, esp, 4 + store \val, esp, 4 +endm + +macro PUSHAD + call x86_pushad $ +endm + +macro PUSHAW + call x86_pushaw $ +endm + +macro PUSHFD + sub esp, esp, 4 + store eflags, esp, 4 +endm + + +macro POP reg + load \reg, esp, 4 + add esp, esp, 4 +endm + +macro POPAD + call x86_popad $ +endm + +macro POPAW + call x86_popaw $ +endm + +macro POPFD + call x86_popfd $ +endm + diff --git a/games/Battle Isle 3/SR-BI3/llasm/llasm_stos.c b/games/Battle Isle 3/SR-BI3/llasm/llasm_stos.c new file mode 100644 index 0000000..95d4d92 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/llasm_stos.c @@ -0,0 +1,129 @@ +//part of static recompiler -- do not edit + +/** + * + * Copyright (C) 2019 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "llasm_cpu.h" + +EXTERNC void x86_rep_stosb(CPU) +{ + int32_t dir; + + if (ecx == 0) return; + + dir = (eflags & DF)?-1:1; + + do { + *((uint8_t *)REG2PTR(edi)) = eax; + edi += dir; + + ecx--; + } while (ecx != 0); +} + +EXTERNC void x86_rep_stosd(CPU) +{ + uint32_t dstptr, counter, srcvalue; + + counter = ecx; + if (counter == 0) return; + + dstptr = edi; + srcvalue = eax; + + if ((eflags & DF) == 0) + { + if ((dstptr & 3) == 0) + { + do { + *((uint32_t *)REG2PTR(dstptr)) = srcvalue; + dstptr += 4; + + counter--; + } while (counter != 0); + } + else + { + do { + UNALIGNED_WRITE_32(dstptr, srcvalue) + dstptr += 4; + + counter--; + } while (counter != 0); + } + } + else + { + if ((dstptr & 3) == 0) + { + do { + *((uint32_t *)REG2PTR(dstptr)) = srcvalue; + dstptr -= 4; + + counter--; + } while (counter != 0); + } + else + { + do { + UNALIGNED_WRITE_32(dstptr, srcvalue) + dstptr -= 4; + + counter--; + } while (counter != 0); + } + } + + ecx = counter; + edi = dstptr; +} + +EXTERNC void x86_rep_stosw(CPU) +{ + int32_t dir; + + if (ecx == 0) return; + + dir = (eflags & DF)?-2:2; + + if ((edi & 1) == 0) + { + do { + *((uint16_t *)REG2PTR(edi)) = eax; + edi += dir; + + ecx--; + } while (ecx != 0); + } + else + { + do { + UNALIGNED_WRITE_16(edi, eax) + edi += dir; + + ecx--; + } while (ecx != 0); + } +} + diff --git a/games/Battle Isle 3/SR-BI3/llasm/llasm_stos.llinc b/games/Battle Isle 3/SR-BI3/llasm/llasm_stos.llinc new file mode 100644 index 0000000..f7f6043 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/llasm_stos.llinc @@ -0,0 +1,40 @@ +;part of static recompiler -- do not edit + +;; +;; Copyright (C) 2019 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +funcv x86_rep_stosb $ +funcv x86_rep_stosd $ +funcv x86_rep_stosw $ + +macro REP_STOSB + call x86_rep_stosb $ +endm + +macro REP_STOSD + call x86_rep_stosd $ +endm + +macro REP_STOSW + call x86_rep_stosw $ +endm + diff --git a/games/Battle Isle 3/SR-BI3/llasm/macros.llinc b/games/Battle Isle 3/SR-BI3/llasm/macros.llinc new file mode 100644 index 0000000..9ff6f83 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/macros.llinc @@ -0,0 +1,48 @@ +;; +;; Copyright (C) 2019 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +macro ACTION_UNCONDITIONAL_SHORT_JUMP_BACKWARD +endm + +macro ACTION_UNCONDITIONAL_SHORT_JUMP_FORWARD +endm + +macro ACTION_UNCONDITIONAL_JUMP +endm + +macro ACTION_LOOP_BACKWARD +endm + +macro ACTION_LOOP_FORWARD +endm + +macro ACTION_CONDITIONAL_JUMP_BACKWARD +endm + +macro ACTION_CONDITIONAL_JUMP_FORWARD +endm + +macro ACTION_CALL +endm + +; ------------------------------------------------------------------------------ + diff --git a/games/Battle Isle 3/SR-BI3/llasm/main-asm.c b/games/Battle Isle 3/SR-BI3/llasm/main-asm.c new file mode 100644 index 0000000..4cf66cd --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/main-asm.c @@ -0,0 +1,65 @@ +/** + * + * Copyright (C) 2019-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "llasm_cpu.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern _cpu *x86_initialize_cpu(void); +extern void x86_deinitialize_cpu(void); + +extern void c_WinMain_(CPU); + +#ifdef __cplusplus +} +#endif + +EXTERNC int WinMain_asm(void *hInstance, void *hPrevInstance, char *lpCmdLine, int nCmdShow) +{ + _cpu *cpu; + int retval; + + cpu = x86_initialize_cpu(); + + esp -= 4; + *((uint32_t *)REG2PTR(esp)) = nCmdShow; + esp -= 4; + *((uint32_t *)REG2PTR(esp)) = (uintptr_t)lpCmdLine; + esp -= 4; + *((uint32_t *)REG2PTR(esp)) = (uintptr_t)hPrevInstance; + esp -= 4; + *((uint32_t *)REG2PTR(esp)) = (uintptr_t)hInstance; + + // stdcall (4 parameters) + c_WinMain_(cpu); + + retval = eax; + + x86_deinitialize_cpu(); + + return retval; +} + diff --git a/games/Battle Isle 3/SR-BI3/llasm/ms_figtr/extern.llinc b/games/Battle Isle 3/SR-BI3/llasm/ms_figtr/extern.llinc new file mode 100644 index 0000000..acaa304 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/ms_figtr/extern.llinc @@ -0,0 +1,33 @@ +;; +;; Copyright (C) 2019-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +proc ms_strcpy_asm2c external +proc ms_strlen_asm2c external +proc ms_memcpy_asm2c external +proc ms_memset_asm2c external +proc ms__ftol_asm2c external +proc ms__ltoa_asm2c external + +proc __Fight external + +proc FGT_SystemTask_End_asm2c external +proc FGT_CheckTicksDelay_asm2c external diff --git a/games/Battle Isle 3/SR-BI3/llasm/printf_x86.c b/games/Battle Isle 3/SR-BI3/llasm/printf_x86.c new file mode 100644 index 0000000..83a37dd --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/printf_x86.c @@ -0,0 +1,989 @@ +// modified version of printf 4.0.0 (https://github.com/mpaland/printf) + +/////////////////////////////////////////////////////////////////////////////// +// \author (c) Marco Paland (info@paland.com) +// 2014-2019, PALANDesign Hannover, Germany +// +// \license The MIT License (MIT) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +// \brief Tiny printf, sprintf and (v)snprintf implementation, optimized for speed on +// embedded systems with a very limited resources. These routines are thread +// safe and reentrant! +// Use this instead of the bloated standard/newlib printf cause these use +// malloc for printf (and may not be thread safe). +// +/////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include + +#include "printf_x86.h" + + +// define this globally (e.g. gcc -DPRINTF_INCLUDE_CONFIG_H ...) to include the +// printf_config.h header file +// default: undefined +#ifdef PRINTF_INCLUDE_CONFIG_H +#include "printf_config.h" +#endif + + +// 'ntoa' conversion buffer size, this must be big enough to hold one converted +// numeric number including padded zeros (dynamically created on stack) +// default: 32 byte +#ifndef PRINTF_NTOA_BUFFER_SIZE +#define PRINTF_NTOA_BUFFER_SIZE 32U +#endif + +// 'ftoa' conversion buffer size, this must be big enough to hold one converted +// float number including padded zeros (dynamically created on stack) +// default: 32 byte +#ifndef PRINTF_FTOA_BUFFER_SIZE +#define PRINTF_FTOA_BUFFER_SIZE 32U +#endif + +// support for the floating point type (%f) +// default: activated +#ifndef PRINTF_DISABLE_SUPPORT_FLOAT +#define PRINTF_SUPPORT_FLOAT +#endif + +// support for exponential floating point notation (%e/%g) +// default: activated +#ifndef PRINTF_DISABLE_SUPPORT_EXPONENTIAL +#define PRINTF_SUPPORT_EXPONENTIAL +#endif + +// define the default floating point precision +// default: 6 digits +#ifndef PRINTF_DEFAULT_FLOAT_PRECISION +#define PRINTF_DEFAULT_FLOAT_PRECISION 6U +#endif + +// define the largest float suitable to print with %f +// default: 1e9 +#ifndef PRINTF_MAX_FLOAT +#define PRINTF_MAX_FLOAT 1e9 +#endif + +// support for the long long types (%llu or %p) +// default: activated +#ifndef PRINTF_DISABLE_SUPPORT_LONG_LONG +#define PRINTF_SUPPORT_LONG_LONG +#endif + +// support for the ptrdiff_t type (%t) +// ptrdiff_t is normally defined in as long or long long type +// default: activated +#ifndef PRINTF_DISABLE_SUPPORT_PTRDIFF_T +#define PRINTF_SUPPORT_PTRDIFF_T +#endif + +/////////////////////////////////////////////////////////////////////////////// + +// internal flag definitions +#define FLAGS_ZEROPAD (1U << 0U) +#define FLAGS_LEFT (1U << 1U) +#define FLAGS_PLUS (1U << 2U) +#define FLAGS_SPACE (1U << 3U) +#define FLAGS_HASH (1U << 4U) +#define FLAGS_UPPERCASE (1U << 5U) +#define FLAGS_CHAR (1U << 6U) +#define FLAGS_SHORT (1U << 7U) +#define FLAGS_LONG (1U << 8U) +#define FLAGS_LONG_LONG (1U << 9U) +#define FLAGS_PRECISION (1U << 10U) +#define FLAGS_ADAPT_EXP (1U << 11U) + + +// import float.h for DBL_MAX +#if defined(PRINTF_SUPPORT_FLOAT) +#include +#endif + + +// output function type +typedef void (*out_fct_type)(char character, void* buffer, size_t idx, size_t maxlen); + + +// wrapper (used as buffer) for output function type +typedef struct { + void (*fct)(char character, void* arg); + void* arg; +} out_fct_wrap_type; + + +// internal buffer output +static inline void _out_buffer(char character, void* buffer, size_t idx, size_t maxlen) +{ + if (idx < maxlen) { + ((char*)buffer)[idx] = character; + } +} + + +// internal null output +static inline void _out_null(char character, void* buffer, size_t idx, size_t maxlen) +{ + (void)character; (void)buffer; (void)idx; (void)maxlen; +} + + +// internal output function wrapper +static inline void _out_fct(char character, void* buffer, size_t idx, size_t maxlen) +{ + (void)idx; (void)maxlen; + if (character) { + // buffer is the output fct pointer + ((out_fct_wrap_type*)buffer)->fct(character, ((out_fct_wrap_type*)buffer)->arg); + } +} + + +// internal secure strlen +// \return The length of the string (excluding the terminating 0) limited by 'maxsize' +static inline unsigned int _strnlen_s(const char* str, size_t maxsize) +{ + const char* s; + for (s = str; *s && maxsize--; ++s); + return (unsigned int)(s - str); +} + + +// internal test if char is a digit (0-9) +// \return true if char is a digit +static inline bool _is_digit(char ch) +{ + return (ch >= '0') && (ch <= '9'); +} + + +// internal ASCII string to unsigned int conversion +static unsigned int _atoi(const char** str) +{ + unsigned int i = 0U; + while (_is_digit(**str)) { + i = i * 10U + (unsigned int)(*((*str)++) - '0'); + } + return i; +} + + +// output the specified string in reverse, taking care of any zero-padding +static size_t _out_rev(out_fct_type out, char* buffer, size_t idx, size_t maxlen, const char* buf, size_t len, unsigned int width, unsigned int flags) +{ + const size_t start_idx = idx; + + // pad spaces up to given width + if (!(flags & FLAGS_LEFT) && !(flags & FLAGS_ZEROPAD)) { + for (size_t i = len; i < width; i++) { + out(' ', buffer, idx++, maxlen); + } + } + + // reverse string + while (len) { + out(buf[--len], buffer, idx++, maxlen); + } + + // append pad spaces up to given width + if (flags & FLAGS_LEFT) { + while (idx - start_idx < width) { + out(' ', buffer, idx++, maxlen); + } + } + + return idx; +} + + +// internal itoa format +static size_t _ntoa_format(out_fct_type out, char* buffer, size_t idx, size_t maxlen, char* buf, size_t len, bool negative, unsigned int base, unsigned int prec, unsigned int width, unsigned int flags) +{ + // pad leading zeros + if (!(flags & FLAGS_LEFT)) { + if (width && (flags & FLAGS_ZEROPAD) && (negative || (flags & (FLAGS_PLUS | FLAGS_SPACE)))) { + width--; + } + while ((len < prec) && (len < PRINTF_NTOA_BUFFER_SIZE)) { + buf[len++] = '0'; + } + while ((flags & FLAGS_ZEROPAD) && (len < width) && (len < PRINTF_NTOA_BUFFER_SIZE)) { + buf[len++] = '0'; + } + } + + // handle hash + if (flags & FLAGS_HASH) { + if (!(flags & FLAGS_PRECISION) && len && ((len == prec) || (len == width))) { + len--; + if (len && (base == 16U)) { + len--; + } + } + if ((base == 16U) && !(flags & FLAGS_UPPERCASE) && (len < PRINTF_NTOA_BUFFER_SIZE)) { + buf[len++] = 'x'; + } + else if ((base == 16U) && (flags & FLAGS_UPPERCASE) && (len < PRINTF_NTOA_BUFFER_SIZE)) { + buf[len++] = 'X'; + } + else if ((base == 2U) && (len < PRINTF_NTOA_BUFFER_SIZE)) { + buf[len++] = 'b'; + } + if (len < PRINTF_NTOA_BUFFER_SIZE) { + buf[len++] = '0'; + } + } + + if (len < PRINTF_NTOA_BUFFER_SIZE) { + if (negative) { + buf[len++] = '-'; + } + else if (flags & FLAGS_PLUS) { + buf[len++] = '+'; // ignore the space if the '+' exists + } + else if (flags & FLAGS_SPACE) { + buf[len++] = ' '; + } + } + + return _out_rev(out, buffer, idx, maxlen, buf, len, width, flags); +} + + +// internal itoa for 'long' type +static size_t _ntoa_long(out_fct_type out, char* buffer, size_t idx, size_t maxlen, unsigned long value, bool negative, unsigned long base, unsigned int prec, unsigned int width, unsigned int flags) +{ + char buf[PRINTF_NTOA_BUFFER_SIZE]; + size_t len = 0U; + + // no hash for 0 values + if (!value) { + flags &= ~FLAGS_HASH; + } + + // write if precision != 0 and value is != 0 + if (!(flags & FLAGS_PRECISION) || value) { + do { + const char digit = (char)(value % base); + buf[len++] = digit < 10 ? '0' + digit : (flags & FLAGS_UPPERCASE ? 'A' : 'a') + digit - 10; + value /= base; + } while (value && (len < PRINTF_NTOA_BUFFER_SIZE)); + } + + return _ntoa_format(out, buffer, idx, maxlen, buf, len, negative, (unsigned int)base, prec, width, flags); +} + + +// internal itoa for 'long long' type +#if defined(PRINTF_SUPPORT_LONG_LONG) +static size_t _ntoa_long_long(out_fct_type out, char* buffer, size_t idx, size_t maxlen, unsigned long long value, bool negative, unsigned long long base, unsigned int prec, unsigned int width, unsigned int flags) +{ + char buf[PRINTF_NTOA_BUFFER_SIZE]; + size_t len = 0U; + + // no hash for 0 values + if (!value) { + flags &= ~FLAGS_HASH; + } + + // write if precision != 0 and value is != 0 + if (!(flags & FLAGS_PRECISION) || value) { + do { + const char digit = (char)(value % base); + buf[len++] = digit < 10 ? '0' + digit : (flags & FLAGS_UPPERCASE ? 'A' : 'a') + digit - 10; + value /= base; + } while (value && (len < PRINTF_NTOA_BUFFER_SIZE)); + } + + return _ntoa_format(out, buffer, idx, maxlen, buf, len, negative, (unsigned int)base, prec, width, flags); +} +#endif // PRINTF_SUPPORT_LONG_LONG + + +#if defined(PRINTF_SUPPORT_FLOAT) + +#if defined(PRINTF_SUPPORT_EXPONENTIAL) +// forward declaration so that _ftoa can switch to exp notation for values > PRINTF_MAX_FLOAT +static size_t _etoa(out_fct_type out, char* buffer, size_t idx, size_t maxlen, double value, unsigned int prec, unsigned int width, unsigned int flags); +#endif + + +// internal ftoa for fixed decimal floating point +static size_t _ftoa(out_fct_type out, char* buffer, size_t idx, size_t maxlen, double value, unsigned int prec, unsigned int width, unsigned int flags) +{ + char buf[PRINTF_FTOA_BUFFER_SIZE]; + size_t len = 0U; + double diff = 0.0; + + // powers of 10 + static const double pow10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 }; + + // test for special values + if (value != value) + return _out_rev(out, buffer, idx, maxlen, "nan", 3, width, flags); + if (value < -DBL_MAX) + return _out_rev(out, buffer, idx, maxlen, "fni-", 4, width, flags); + if (value > DBL_MAX) + return _out_rev(out, buffer, idx, maxlen, (flags & FLAGS_PLUS) ? "fni+" : "fni", (flags & FLAGS_PLUS) ? 4U : 3U, width, flags); + + // test for very large values + // standard printf behavior is to print EVERY whole number digit -- which could be 100s of characters overflowing your buffers == bad + if ((value > PRINTF_MAX_FLOAT) || (value < -PRINTF_MAX_FLOAT)) { +#if defined(PRINTF_SUPPORT_EXPONENTIAL) + return _etoa(out, buffer, idx, maxlen, value, prec, width, flags); +#else + return 0U; +#endif + } + + // test for negative + bool negative = false; + if (value < 0) { + negative = true; + value = 0 - value; + } + + // set default precision, if not set explicitly + if (!(flags & FLAGS_PRECISION)) { + prec = PRINTF_DEFAULT_FLOAT_PRECISION; + } + // limit precision to 9, cause a prec >= 10 can lead to overflow errors + while ((len < PRINTF_FTOA_BUFFER_SIZE) && (prec > 9U)) { + buf[len++] = '0'; + prec--; + } + + int whole = (int)value; + double tmp = (value - whole) * pow10[prec]; + unsigned long frac = (unsigned long)tmp; + diff = tmp - frac; + + if (diff > 0.5) { + ++frac; + // handle rollover, e.g. case 0.99 with prec 1 is 1.0 + if (frac >= pow10[prec]) { + frac = 0; + ++whole; + } + } + else if (diff < 0.5) { + } + else if ((frac == 0U) || (frac & 1U)) { + // if halfway, round up if odd OR if last digit is 0 + ++frac; + } + + if (prec == 0U) { + diff = value - (double)whole; + if ((!(diff < 0.5) || (diff > 0.5)) && (whole & 1)) { + // exactly 0.5 and ODD, then round up + // 1.5 -> 2, but 2.5 -> 2 + ++whole; + } + } + else { + unsigned int count = prec; + // now do fractional part, as an unsigned number + while (len < PRINTF_FTOA_BUFFER_SIZE) { + --count; + buf[len++] = (char)(48U + (frac % 10U)); + if (!(frac /= 10U)) { + break; + } + } + // add extra 0s + while ((len < PRINTF_FTOA_BUFFER_SIZE) && (count-- > 0U)) { + buf[len++] = '0'; + } + if (len < PRINTF_FTOA_BUFFER_SIZE) { + // add decimal + buf[len++] = '.'; + } + } + + // do whole part, number is reversed + while (len < PRINTF_FTOA_BUFFER_SIZE) { + buf[len++] = (char)(48 + (whole % 10)); + if (!(whole /= 10)) { + break; + } + } + + // pad leading zeros + if (!(flags & FLAGS_LEFT) && (flags & FLAGS_ZEROPAD)) { + if (width && (negative || (flags & (FLAGS_PLUS | FLAGS_SPACE)))) { + width--; + } + while ((len < width) && (len < PRINTF_FTOA_BUFFER_SIZE)) { + buf[len++] = '0'; + } + } + + if (len < PRINTF_FTOA_BUFFER_SIZE) { + if (negative) { + buf[len++] = '-'; + } + else if (flags & FLAGS_PLUS) { + buf[len++] = '+'; // ignore the space if the '+' exists + } + else if (flags & FLAGS_SPACE) { + buf[len++] = ' '; + } + } + + return _out_rev(out, buffer, idx, maxlen, buf, len, width, flags); +} + + +#if defined(PRINTF_SUPPORT_EXPONENTIAL) +// internal ftoa variant for exponential floating-point type, contributed by Martijn Jasperse +static size_t _etoa(out_fct_type out, char* buffer, size_t idx, size_t maxlen, double value, unsigned int prec, unsigned int width, unsigned int flags) +{ + // check for NaN and special values + if ((value != value) || (value > DBL_MAX) || (value < -DBL_MAX)) { + return _ftoa(out, buffer, idx, maxlen, value, prec, width, flags); + } + + // determine the sign + const bool negative = value < 0; + if (negative) { + value = -value; + } + + // default precision + if (!(flags & FLAGS_PRECISION)) { + prec = PRINTF_DEFAULT_FLOAT_PRECISION; + } + + // determine the decimal exponent + // based on the algorithm by David Gay (https://www.ampl.com/netlib/fp/dtoa.c) + union { + uint64_t U; + double F; + } conv; + + conv.F = value; + int exp2 = (int)((conv.U >> 52U) & 0x07FFU) - 1023; // effectively log2 + conv.U = (conv.U & ((1ULL << 52U) - 1U)) | (1023ULL << 52U); // drop the exponent so conv.F is now in [1,2) + // now approximate log10 from the log2 integer part and an expansion of ln around 1.5 + int expval = (int)(0.1760912590558 + exp2 * 0.301029995663981 + (conv.F - 1.5) * 0.289529654602168); + // now we want to compute 10^expval but we want to be sure it won't overflow + exp2 = (int)(expval * 3.321928094887362 + 0.5); + const double z = expval * 2.302585092994046 - exp2 * 0.6931471805599453; + const double z2 = z * z; + conv.U = (uint64_t)(exp2 + 1023) << 52U; + // compute exp(z) using continued fractions, see https://en.wikipedia.org/wiki/Exponential_function#Continued_fractions_for_ex + conv.F *= 1 + 2 * z / (2 - z + (z2 / (6 + (z2 / (10 + z2 / 14))))); + // correct for rounding errors + if (value < conv.F) { + expval--; + conv.F /= 10; + } + + // the exponent format is "%+03d" and largest value is "307", so set aside 4-5 characters + unsigned int minwidth = ((expval < 100) && (expval > -100)) ? 4U : 5U; + + // in "%g" mode, "prec" is the number of *significant figures* not decimals + if (flags & FLAGS_ADAPT_EXP) { + // do we want to fall-back to "%f" mode? + if ((value >= 1e-4) && (value < 1e6)) { + if ((int)prec > expval) { + prec = (unsigned)((int)prec - expval - 1); + } + else { + prec = 0; + } + flags |= FLAGS_PRECISION; // make sure _ftoa respects precision + // no characters in exponent + minwidth = 0U; + expval = 0; + } + else { + // we use one sigfig for the whole part + if ((prec > 0) && (flags & FLAGS_PRECISION)) { + --prec; + } + } + } + + // will everything fit? + unsigned int fwidth = width; + if (width > minwidth) { + // we didn't fall-back so subtract the characters required for the exponent + fwidth -= minwidth; + } else { + // not enough characters, so go back to default sizing + fwidth = 0U; + } + if ((flags & FLAGS_LEFT) && minwidth) { + // if we're padding on the right, DON'T pad the floating part + fwidth = 0U; + } + + // rescale the float value + if (expval) { + value /= conv.F; + } + + // output the floating part + const size_t start_idx = idx; + idx = _ftoa(out, buffer, idx, maxlen, negative ? -value : value, prec, fwidth, flags & ~FLAGS_ADAPT_EXP); + + // output the exponent part + if (minwidth) { + // output the exponential symbol + out((flags & FLAGS_UPPERCASE) ? 'E' : 'e', buffer, idx++, maxlen); + // output the exponent value + idx = _ntoa_long(out, buffer, idx, maxlen, (expval < 0) ? -expval : expval, expval < 0, 10, 0, minwidth-1, FLAGS_ZEROPAD | FLAGS_PLUS); + // might need to right-pad spaces + if (flags & FLAGS_LEFT) { + while (idx - start_idx < width) out(' ', buffer, idx++, maxlen); + } + } + return idx; +} +#endif // PRINTF_SUPPORT_EXPONENTIAL +#endif // PRINTF_SUPPORT_FLOAT + + +static inline int32_t _va_int(uint32_t **va) +{ + uint32_t value; + + value = **va; + (*va)++; + return (int32_t)value; +} + +static inline uint32_t _va_uint(uint32_t **va) +{ + uint32_t value; + + value = **va; + (*va)++; + return value; +} + +static inline void *_va_ptr(uint32_t **va) +{ + uint32_t value; + + value = **va; + (*va)++; + return (void *)(uintptr_t)value; +} + +#ifdef __FLOAT_WORD_ORDER__ + +#if (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__) +#define BIG_ENDIAN_FLOAT_WORD_ORDER +#else +#undef BIG_ENDIAN_FLOAT_WORD_ORDER +#endif + +#if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) +#define BIG_ENDIAN_BYTE_ORDER +#else +#undef BIG_ENDIAN_BYTE_ORDER +#endif + +#else + +#include +#if (__FLOAT_WORD_ORDER == __BIG_ENDIAN) +#define BIG_ENDIAN_FLOAT_WORD_ORDER +#else +#undef BIG_ENDIAN_FLOAT_WORD_ORDER +#endif + +#if (__BYTE_ORDER == __BIG_ENDIAN) +#define BIG_ENDIAN_BYTE_ORDER +#else +#undef BIG_ENDIAN_BYTE_ORDER +#endif + +#endif + +typedef union { + double d; + struct { +#ifdef BIG_ENDIAN_FLOAT_WORD_ORDER + uint32_t high; + uint32_t low; +#else + uint32_t low; + uint32_t high; +#endif + }; +} double_int; + +typedef union { + uint64_t i; + struct { +#ifdef BIG_ENDIAN_BYTE_ORDER + uint32_t high; + uint32_t low; +#else + uint32_t low; + uint32_t high; +#endif + }; +} int_int; + +static inline double _va_double(uint32_t **va) +{ + double_int value; + + value.low = (*va)[0]; + value.high = (*va)[1]; + (*va)+=2; + return value.d; +} + +static inline int64_t _va_int64(uint32_t **va) +{ + int_int value; + + value.low = (*va)[0]; + value.high = (*va)[1]; + (*va)+=2; + return (int64_t)value.i; +} + +static inline uint64_t _va_uint64(uint32_t **va) +{ + int_int value; + + value.low = (*va)[0]; + value.high = (*va)[1]; + (*va)+=2; + return value.i; +} + +// internal vsnprintf +static int _vsnprintf(out_fct_type out, char* buffer, const size_t maxlen, const char* format, uint32_t *va) +{ + unsigned int flags, width, precision, n; + size_t idx = 0U; + + if (!buffer) { + // use null output function + out = _out_null; + } + + while (*format) + { + // format specifier? %[flags][width][.precision][length] + if (*format != '%') { + // no + out(*format, buffer, idx++, maxlen); + format++; + continue; + } + else { + // yes, evaluate it + format++; + } + + // evaluate flags + flags = 0U; + do { + switch (*format) { + case '0': flags |= FLAGS_ZEROPAD; format++; n = 1U; break; + case '-': flags |= FLAGS_LEFT; format++; n = 1U; break; + case '+': flags |= FLAGS_PLUS; format++; n = 1U; break; + case ' ': flags |= FLAGS_SPACE; format++; n = 1U; break; + case '#': flags |= FLAGS_HASH; format++; n = 1U; break; + default : n = 0U; break; + } + } while (n); + + // evaluate width field + width = 0U; + if (_is_digit(*format)) { + width = _atoi(&format); + } + else if (*format == '*') { + const int w = _va_int(&va); + if (w < 0) { + flags |= FLAGS_LEFT; // reverse padding + width = (unsigned int)-w; + } + else { + width = (unsigned int)w; + } + format++; + } + + // evaluate precision field + precision = 0U; + if (*format == '.') { + flags |= FLAGS_PRECISION; + format++; + if (_is_digit(*format)) { + precision = _atoi(&format); + } + else if (*format == '*') { + const int prec = (int)_va_int(&va); + precision = prec > 0 ? (unsigned int)prec : 0U; + format++; + } + } + + // evaluate length field + switch (*format) { + case 'l' : + flags |= FLAGS_LONG; + format++; + if (*format == 'l') { + flags |= FLAGS_LONG_LONG; + format++; + } + break; + case 'h' : + flags |= FLAGS_SHORT; + format++; + if (*format == 'h') { + flags |= FLAGS_CHAR; + format++; + } + break; +#if defined(PRINTF_SUPPORT_PTRDIFF_T) + case 't' : + //flags |= (sizeof(ptrdiff_t) == sizeof(long) ? FLAGS_LONG : FLAGS_LONG_LONG); + flags |= FLAGS_LONG; + format++; + break; +#endif + case 'j' : + //flags |= (sizeof(intmax_t) == sizeof(long) ? FLAGS_LONG : FLAGS_LONG_LONG); + flags |= FLAGS_LONG; + format++; + break; + case 'z' : + //flags |= (sizeof(size_t) == sizeof(long) ? FLAGS_LONG : FLAGS_LONG_LONG); + flags |= FLAGS_LONG; + format++; + break; + default : + break; + } + + // evaluate specifier + switch (*format) { + case 'd' : + case 'i' : + case 'u' : + case 'x' : + case 'X' : + case 'o' : + case 'b' : { + // set the base + unsigned int base; + if (*format == 'x' || *format == 'X') { + base = 16U; + } + else if (*format == 'o') { + base = 8U; + } + else if (*format == 'b') { + base = 2U; + } + else { + base = 10U; + flags &= ~FLAGS_HASH; // no hash for dec format + } + // uppercase + if (*format == 'X') { + flags |= FLAGS_UPPERCASE; + } + + // no plus or space flag for u, x, X, o, b + if ((*format != 'i') && (*format != 'd')) { + flags &= ~(FLAGS_PLUS | FLAGS_SPACE); + } + + // ignore '0' flag when precision is given + if (flags & FLAGS_PRECISION) { + flags &= ~FLAGS_ZEROPAD; + } + + // convert the integer + if ((*format == 'i') || (*format == 'd')) { + // signed + if (flags & FLAGS_LONG_LONG) { +#if defined(PRINTF_SUPPORT_LONG_LONG) + const long long value = _va_int64(&va); + idx = _ntoa_long_long(out, buffer, idx, maxlen, (unsigned long long)(value > 0 ? value : 0 - value), value < 0, base, precision, width, flags); +#endif + } + else if (flags & FLAGS_LONG) { + const long value = _va_int(&va); + idx = _ntoa_long(out, buffer, idx, maxlen, (unsigned long)(value > 0 ? value : 0 - value), value < 0, base, precision, width, flags); + } + else { + const int value = (flags & FLAGS_CHAR) ? (char)_va_int(&va) : (flags & FLAGS_SHORT) ? (short int)_va_int(&va) : _va_int(&va); + idx = _ntoa_long(out, buffer, idx, maxlen, (unsigned int)(value > 0 ? value : 0 - value), value < 0, base, precision, width, flags); + } + } + else { + // unsigned + if (flags & FLAGS_LONG_LONG) { +#if defined(PRINTF_SUPPORT_LONG_LONG) + idx = _ntoa_long_long(out, buffer, idx, maxlen, _va_uint64(&va), false, base, precision, width, flags); +#endif + } + else if (flags & FLAGS_LONG) { + idx = _ntoa_long(out, buffer, idx, maxlen, _va_uint(&va), false, base, precision, width, flags); + } + else { + const unsigned int value = (flags & FLAGS_CHAR) ? (unsigned char)_va_uint(&va) : (flags & FLAGS_SHORT) ? (unsigned short int)_va_uint(&va) : _va_uint(&va); + idx = _ntoa_long(out, buffer, idx, maxlen, value, false, base, precision, width, flags); + } + } + format++; + break; + } +#if defined(PRINTF_SUPPORT_FLOAT) + case 'f' : + case 'F' : + if (*format == 'F') flags |= FLAGS_UPPERCASE; + idx = _ftoa(out, buffer, idx, maxlen, _va_double(&va), precision, width, flags); + format++; + break; +#if defined(PRINTF_SUPPORT_EXPONENTIAL) + case 'e': + case 'E': + case 'g': + case 'G': + if ((*format == 'g')||(*format == 'G')) flags |= FLAGS_ADAPT_EXP; + if ((*format == 'E')||(*format == 'G')) flags |= FLAGS_UPPERCASE; + idx = _etoa(out, buffer, idx, maxlen, _va_double(&va), precision, width, flags); + format++; + break; +#endif // PRINTF_SUPPORT_EXPONENTIAL +#endif // PRINTF_SUPPORT_FLOAT + case 'c' : { + unsigned int l = 1U; + // pre padding + if (!(flags & FLAGS_LEFT)) { + while (l++ < width) { + out(' ', buffer, idx++, maxlen); + } + } + // char output + out((char)_va_int(&va), buffer, idx++, maxlen); + // post padding + if (flags & FLAGS_LEFT) { + while (l++ < width) { + out(' ', buffer, idx++, maxlen); + } + } + format++; + break; + } + + case 's' : { + const char* p = _va_ptr(&va); + unsigned int l = _strnlen_s(p, precision ? precision : (size_t)-1); + // pre padding + if (flags & FLAGS_PRECISION) { + l = (l < precision ? l : precision); + } + if (!(flags & FLAGS_LEFT)) { + while (l++ < width) { + out(' ', buffer, idx++, maxlen); + } + } + // string output + while ((*p != 0) && (!(flags & FLAGS_PRECISION) || precision--)) { + out(*(p++), buffer, idx++, maxlen); + } + // post padding + if (flags & FLAGS_LEFT) { + while (l++ < width) { + out(' ', buffer, idx++, maxlen); + } + } + format++; + break; + } + + case 'p' : { + width = sizeof(void*) * 2U; + flags |= FLAGS_ZEROPAD | FLAGS_UPPERCASE; +#if defined(PRINTF_SUPPORT_LONG_LONG) + //const bool is_ll = sizeof(uintptr_t) == sizeof(long long); + const bool is_ll = false; + if (is_ll) { + idx = _ntoa_long_long(out, buffer, idx, maxlen, (uintptr_t)_va_ptr(&va), false, 16U, precision, width, flags); + } + else { +#endif + idx = _ntoa_long(out, buffer, idx, maxlen, (unsigned long)((uintptr_t)_va_ptr(&va)), false, 16U, precision, width, flags); +#if defined(PRINTF_SUPPORT_LONG_LONG) + } +#endif + format++; + break; + } + + case '%' : + out('%', buffer, idx++, maxlen); + format++; + break; + + default : + out(*format, buffer, idx++, maxlen); + format++; + break; + } + } + + // termination + out((char)0, buffer, idx < maxlen ? idx : maxlen - 1U, maxlen); + + // return written chars without terminating \0 + return (int)idx; +} + + +/////////////////////////////////////////////////////////////////////////////// + +int vsprintf_x86(char* buffer, const char* format, uint32_t *va) +{ + return _vsnprintf(_out_buffer, buffer, (size_t)(ssize_t)-1, format, va); +} + + +int vsnprintf_x86(char* buffer, size_t count, const char* format, uint32_t *va) +{ + return _vsnprintf(_out_buffer, buffer, count, format, va); +} + + +int vfctprintf_x86(void (*out)(char character, void* arg), void* arg, const char* format, uint32_t *va) +{ + const out_fct_wrap_type out_fct_wrap = { out, arg }; + return _vsnprintf(_out_fct, (char*)(uintptr_t)&out_fct_wrap, (size_t)(ssize_t)-1, format, va); +} diff --git a/games/Battle Isle 3/SR-BI3/llasm/printf_x86.h b/games/Battle Isle 3/SR-BI3/llasm/printf_x86.h new file mode 100644 index 0000000..603c247 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/printf_x86.h @@ -0,0 +1,82 @@ +/////////////////////////////////////////////////////////////////////////////// +// \author (c) Marco Paland (info@paland.com) +// 2014-2019, PALANDesign Hannover, Germany +// +// \license The MIT License (MIT) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +// \brief Tiny printf, sprintf and snprintf implementation, optimized for speed on +// embedded systems with a very limited resources. +// Use this instead of bloated standard/newlib printf. +// These routines are thread safe and reentrant. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _PRINTF_X86_H_ +#define _PRINTF_X86_H_ + +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * Tiny vsprintf implementation + * Due to security reasons (buffer overflow) YOU SHOULD CONSIDER USING VSNPRINTF INSTEAD! + * \param buffer A pointer to the buffer where to store the formatted string. MUST be big enough to store the output! + * \param format A string that specifies the format of the output + * \param va A value identifying a variable arguments list + * \return The number of characters that are WRITTEN into the buffer, not counting the terminating null character + */ +int vsprintf_x86(char* buffer, const char* format, uint32_t *va); + +/** + * Tiny vsnprintf implementation + * \param buffer A pointer to the buffer where to store the formatted string + * \param count The maximum number of characters to store in the buffer, including a terminating null character + * \param format A string that specifies the format of the output + * \param va A value identifying a variable arguments list + * \return The number of characters that are WRITTEN into the buffer, not counting the terminating null character + * If the formatted string is truncated the buffer size (count) is returned + */ +int vsnprintf_x86(char* buffer, size_t count, const char* format, uint32_t *va); + + +/** + * vprintf with output function + * You may use this as dynamic alternative to vprintf() with its fixed _putchar() output + * \param out An output function which takes one character and an argument pointer + * \param arg An argument pointer for user data passed to output function + * \param format A string that specifies the format of the output + * \param va A value identifying a variable arguments list + * \return The number of characters that are sent to the output function, not counting the terminating null character + */ +int vfctprintf_x86(void (*out)(char character, void* arg), void* arg, const char* format, uint32_t *va); + +#ifdef __cplusplus +} +#endif + + +#endif // _PRINTF_X86_H_ diff --git a/games/Battle Isle 3/SR-BI3/llasm/sdi_1r/extern.llinc b/games/Battle Isle 3/SR-BI3/llasm/sdi_1r/extern.llinc new file mode 100644 index 0000000..7c4d7f6 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/sdi_1r/extern.llinc @@ -0,0 +1,135 @@ +;; +;; Copyright (C) 2019-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +proc ms_strlen_asm2c external +proc ms_strcat_asm2c external +proc ms_strcpy_asm2c external +proc ms_atol_asm2c external +proc ms_atoi_asm2c external +proc ms_printf_asm2c external +proc ms_strncpy_asm2c external +proc ms_strcmp_asm2c external +proc ms_memcpy_asm2c external +proc ms__ftol_asm2c external +proc ms_memset_asm2c external +proc ms_memcmp_asm2c external +proc ms_srand_asm2c external +proc ms_rand_asm2c external +proc ms__alloca_probe_asm2c external +proc ms_strstr_asm2c external +proc ms_isalnum_asm2c external +proc ms__strnicmp_asm2c external +proc ms__ltoa_asm2c external + +proc ms__except_handler3_asm2c external + +proc SDI_CheckTicksDelay_asm2c external + +proc midi_OpenSDIMusic_asm2c external +proc midi_GetSDIMusicID_asm2c external +proc midi_PlaySDIMusic_asm2c external +proc midi_CloseSDIMusic_asm2c external +proc midi_IsPlaying_asm2c external +proc midi_OpenTestMusic_asm2c external +proc midi_PlayTestMusic_asm2c external +proc midi_CloseTestMusic_asm2c external +proc midi_GetErrorString_asm2c external + +proc cmdline_ContainsOption_asm2c external +proc cmdline_ReadLanguageOption_asm2c external + +proc video_RegisterClass_PRE_Video_asm2c external +proc video_Open_PRE_Video_asm2c external +proc video_Close_PRE_Video_asm2c external +proc video_Play_PRE_Video_asm2c external +proc video_RegisterClass_POST_Video_asm2c external +proc video_Open_POST_Video_asm2c external +proc video_Close_POST_Video_asm2c external +proc video_Play_POST_Video_asm2c external +proc video_RegisterClass_SS_Video_asm2c external + +proc sync_asm2c external + +extern Intro_Play +extern Outro_Play + + +; gdi32.dll +define CreateFontIndirectA CreateFontIndirectA_asm2c +define DeleteObject DeleteObject_asm2c +define GdiFlush GdiFlush_asm2c +define GetDeviceCaps GetDeviceCaps_asm2c +define GetTextExtentPointA GetTextExtentPointA_asm2c +define SelectObject SelectObject_asm2c +define SetBkMode SetBkMode_asm2c +define TextOutA TextOutA_asm2c + +; kernel32.dll +define CloseHandle CloseHandle_asm2c +define CreateFileA CreateFileA_asm2c +define FindClose FindClose_asm2c +define FindFirstFileA FindFirstFileA_asm2c +define FindNextFileA FindNextFileA_asm2c +define GetCurrentDirectoryA GetCurrentDirectoryA_asm2c +define GetPrivateProfileIntA GetPrivateProfileIntA_asm2c +define GetPrivateProfileStringA GetPrivateProfileStringA_asm2c +define GetTickCount GetTickCount_asm2c +define GlobalMemoryStatus GlobalMemoryStatus_asm2c +define ReadFile ReadFile_asm2c +define SetCurrentDirectoryA SetCurrentDirectoryA_asm2c +define SetFilePointer SetFilePointer_asm2c +define WriteFile WriteFile_asm2c +define WritePrivateProfileStringA WritePrivateProfileStringA_asm2c + +; user32.dll +define ClientToScreen ClientToScreen_asm2c +define ClipCursor ClipCursor_asm2c +define CreateWindowExA CreateWindowExA_asm2c +define GetActiveWindow GetActiveWindow_asm2c +define GetCursorPos GetCursorPos_asm2c +define GetDC GetDC_asm2c +define GetWindowRect GetWindowRect_asm2c +define IsIconic IsIconic_asm2c +define IsWindowVisible IsWindowVisible_asm2c +define LoadCursorA LoadCursorA_asm2c +define LoadStringA LoadStringA_asm2c +define MessageBoxA MessageBoxA_asm2c +define MoveWindow MoveWindow_asm2c +define ReleaseCapture ReleaseCapture_asm2c +define ReleaseDC ReleaseDC_asm2c +define ScreenToClient ScreenToClient_asm2c +define SendMessageA SendMessageA_asm2c +define SetActiveWindow SetActiveWindow_asm2c +define SetCursor SetCursor_asm2c +define SetCursorPos SetCursorPos_asm2c +define SetRect SetRect_asm2c +define SetRectEmpty SetRectEmpty_asm2c +define SetWindowPos SetWindowPos_asm2c +define ShowCursor ShowCursor_asm2c +define ShowWindow ShowWindow_asm2c +define UnregisterClassA UnregisterClassA_asm2c +define wsprintfA wsprintfA_asm2c + +; winmm.dll +define mciGetErrorStringA mciGetErrorStringA_asm2c +define mciSendCommandA mciSendCommandA_asm2c + diff --git a/games/Battle Isle 3/SR-BI3/llasm/wc_figtr/extern.llinc b/games/Battle Isle 3/SR-BI3/llasm/wc_figtr/extern.llinc new file mode 100644 index 0000000..2effc57 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/llasm/wc_figtr/extern.llinc @@ -0,0 +1,29 @@ +;; +;; Copyright (C) 2019-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +proc wc_memset_asm2c external +proc wc_strcmp_asm2c external +proc wc_strcpy_asm2c external +proc wc_sprintf_asm2c external +proc wc_rand_asm2c external + +proc FGT_CheckTicksDelay_asm2c external diff --git a/games/Battle Isle 3/SR-BI3/main.c b/games/Battle Isle 3/SR-BI3/main.c new file mode 100644 index 0000000..b3fc128 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/main.c @@ -0,0 +1,83 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "SDI.h" +#include "SDImidi.h" +#include "Game-Config.h" +#define WIN32_LEAN_AND_MEAN +#include + + +void X86_InitializeExceptions(void); + + +#ifdef __cplusplus +extern "C" { +#endif +#if defined(__WINE__) +extern int WinMain_asm( + void *hInstance, + void *hPrevInstance, + char *lpCmdLine, + int nCmdShow +); +#else +extern int CALLBACK WinMain_( + HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow +); +#endif +#ifdef __cplusplus +} +#endif + + +int CALLBACK WinMain( + HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow +) +{ + if (!SDI_LocatePaths()) + { + MessageBoxA(NULL, "Unable to find game paths", "Error", MB_OK); + return 0; + } + + ReadConfiguration(); + + midi_PluginStartup(); + + X86_InitializeExceptions(); + +#if defined(__WINE__) + return WinMain_asm(hInstance, hPrevInstance, lpCmdLine, nCmdShow); +#else + return WinMain_(hInstance, hPrevInstance, lpCmdLine, nCmdShow); +#endif +} + diff --git a/games/Battle Isle 3/SR-BI3/midi-plugins.h b/games/Battle Isle 3/SR-BI3/midi-plugins.h new file mode 100644 index 0000000..0e38969 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/midi-plugins.h @@ -0,0 +1,51 @@ +/** + * + * Copyright (C) 2016-2018 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_MIDI_PLUGIN_H_INCLUDED_) +#define _MIDI_PLUGIN_H_INCLUDED_ + +typedef struct _midi_plugin_parameters_ { + char const *timidity_cfg_path; + char const *soundfont_path; + char const *drivers_cat_path; + char const *mt32_roms_path; + int opl3_bank_number; +} midi_plugin_parameters; + +typedef struct _midi_plugin_functions_ { + int (*set_master_volume) (unsigned char master_volume); // master_volume = 0 - 127 + void * (*open_file) (char const *midifile); + void * (*open_buffer) (void const *midibuffer, long int size); + long int (*get_data) (void *handle, void *buffer, long int size); + int (*rewind_midi) (void *handle); + int (*close_midi) (void *handle); + void (*shutdown_plugin) (void); +} midi_plugin_functions; + +typedef int (*midi_plugin_initialize)(unsigned short int rate, midi_plugin_parameters const *parameters, midi_plugin_functions *functions); + +#define MIDI_PLUGIN_INITIALIZE "initialize_midi_plugin" + +#endif /* _MIDI_PLUGIN_H_INCLUDED_ */ + diff --git a/games/Battle Isle 3/SR-BI3/midi-plugins2.h b/games/Battle Isle 3/SR-BI3/midi-plugins2.h new file mode 100644 index 0000000..e13cb55 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/midi-plugins2.h @@ -0,0 +1,47 @@ +/** + * + * Copyright (C) 2016 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_MIDI_PLUGINS2_H_INCLUDED_) +#define _MIDI_PLUGINS2_H_INCLUDED_ + +typedef struct _midi_plugin2_parameters_ { + char const *midi_device_name; +} midi_plugin2_parameters; + +typedef struct _midi_plugin2_functions_ { + int (*play) (void const *midibuffer, long int size, int loop_count); + int (*pause) (void); + int (*resume) (void); + int (*halt) (void); + int (*set_volume) (unsigned char volume); // volume = 0 - 127 + int (*set_loop_count) (int loop_count); // -1 = unlimited + void (*shutdown_plugin) (void); +} midi_plugin2_functions; + +typedef int (*midi_plugin2_initialize)(midi_plugin2_parameters const *parameters, midi_plugin2_functions *functions); + +#define MIDI_PLUGIN2_INITIALIZE "initialize_midi_plugin2" + +#endif /* _MIDI_PLUGINS2_H_INCLUDED_ */ + diff --git a/games/Battle Isle 3/SR-BI3/x86/BASELIBR.asm b/games/Battle Isle 3/SR-BI3/x86/BASELIBR.asm new file mode 100644 index 0000000..36e6de5 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/BASELIBR.asm @@ -0,0 +1,103 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +global sl_left_capture +global _sl_left_capture +global sl_top_capture +global _sl_top_capture +global sl_bottom_capture +global _sl_bottom_capture +global sl_right_capture +global _sl_right_capture + +global p_last_touched_screen +global _p_last_touched_screen +global sl_screenwidth +global _sl_screenwidth +global sl_screenheight +global _sl_screenheight +global p_mouse_gui +global _p_mouse_gui +global h_mouse_win +global _h_mouse_win +global b_mouse_capture_on +global _b_mouse_capture_on +global b_application_active +global _b_application_active +global w_avi_device_id +global _w_avi_device_id + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +%endif + +%ifidn __OUTPUT_FORMAT__, elf32 +section .bss nobits alloc noexec write align=4 +%else +section .bss bss align=4 +%endif + +sl_left_capture: +_sl_left_capture: +resb 4 +sl_top_capture: +_sl_top_capture: +resb 4 +sl_bottom_capture: +_sl_bottom_capture: +resb 4 +sl_right_capture: +_sl_right_capture: +resb 4 + + +%ifidn __OUTPUT_FORMAT__, elf32 +section .data progbits alloc noexec write align=4 +%else +section .data data align=4 +%endif + +p_last_touched_screen: +_p_last_touched_screen: +dd 0 +sl_screenwidth: +_sl_screenwidth: +dd 0 +sl_screenheight: +_sl_screenheight: +dd 0 +p_mouse_gui: +_p_mouse_gui: +dd 0 +h_mouse_win: +_h_mouse_win: +dd 0 +b_mouse_capture_on: +_b_mouse_capture_on: +dd 0 +b_application_active: +_b_application_active: +dd 0 +w_avi_device_id: +_w_avi_device_id: +dd 0xffff + diff --git a/games/Battle Isle 3/SR-BI3/x86/BBAVI-asm.asm b/games/Battle Isle 3/SR-BI3/x86/BBAVI-asm.asm new file mode 100644 index 0000000..8da2e07 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/BBAVI-asm.asm @@ -0,0 +1,137 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define AVI_Init_c _AVI_Init_c + %define AVI_Exit_c _AVI_Exit_c + %define AVI_SetDestortionLevel_c _AVI_SetDestortionLevel_c + %define AVI_OpenVideo_c _AVI_OpenVideo_c + %define AVI_CloseVideo_c _AVI_CloseVideo_c + %define AVI_PlayVideo_c _AVI_PlayVideo_c +%endif + +extern AVI_Init_c +extern AVI_Exit_c +extern AVI_SetDestortionLevel_c +extern AVI_OpenVideo_c +extern AVI_CloseVideo_c +extern AVI_PlayVideo_c + +global AVI_Init +global AVI_Exit +global AVI_SetDestortionLevel +global AVI_OpenVideo +global AVI_CloseVideo +global AVI_PlayVideo + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +AVI_Init: + +; [esp ] = return address + + Call_Asm_Stack0 AVI_Init_c + + retn + +; end procedure AVI_Init + + +align 16 +AVI_Exit: + +; [esp ] = return address + + Call_Asm_Stack0 AVI_Exit_c + + retn + +; end procedure AVI_Exit + + +align 16 +AVI_SetDestortionLevel: + +; [esp + 4] = int destortionLevel +; [esp ] = return address + + Call_Asm_Stack1 AVI_SetDestortionLevel_c + + retn + +; end procedure AVI_SetDestortionLevel + + +align 16 +AVI_OpenVideo: + +; [esp + 2*4] = const uint8_t * param2 +; [esp + 4] = const char * path +; [esp ] = return address + + Call_Asm_Stack2 AVI_OpenVideo_c + + retn + +; end procedure AVI_OpenVideo + + +align 16 +AVI_CloseVideo: + +; [esp + 4] = void * video +; [esp ] = return address + + Call_Asm_Stack1 AVI_CloseVideo_c + + retn + +; end procedure AVI_CloseVideo + + +align 16 +AVI_PlayVideo: + +; [esp + 7*4] = unsigned int flags +; [esp + 6*4] = int volume +; [esp + 5*4] = int param5 +; [esp + 4*4] = int param4 +; [esp + 3*4] = int y +; [esp + 2*4] = int x +; [esp + 4] = void * video +; [esp ] = return address + + Call_Asm_Stack7 AVI_PlayVideo_c + + retn + +; end procedure AVI_PlayVideo + + diff --git a/games/Battle Isle 3/SR-BI3/x86/BBBLEV-asm.asm b/games/Battle Isle 3/SR-BI3/x86/BBBLEV-asm.asm new file mode 100644 index 0000000..fa74dc5 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/BBBLEV-asm.asm @@ -0,0 +1,129 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define BLEV_Init_c _BLEV_Init_c + %define BLEV_Exit_c _BLEV_Exit_c + %define BLEV_ClearAllEvents_c _BLEV_ClearAllEvents_c + %define BLEV_PutEvent_c _BLEV_PutEvent_c + %define BLEV_GetEvent_c _BLEV_GetEvent_c + %define BLEV_PeekEvent_c _BLEV_PeekEvent_c +%endif + +extern BLEV_Init_c +extern BLEV_Exit_c +extern BLEV_ClearAllEvents_c +extern BLEV_PutEvent_c +extern BLEV_GetEvent_c +extern BLEV_PeekEvent_c + +global BLEV_Init +global BLEV_Exit +global BLEV_ClearAllEvents +global BLEV_PutEvent +global BLEV_GetEvent +global BLEV_PeekEvent + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +BLEV_Init: + +; [esp ] = return address + + Call_Asm_Stack0 BLEV_Init_c + + retn + +; end procedure BLEV_Init + + +align 16 +BLEV_Exit: + +; [esp ] = return address + + Call_Asm_Stack0 BLEV_Exit_c + + retn + +; end procedure BLEV_Exit + + +align 16 +BLEV_ClearAllEvents: + +; [esp ] = return address + + Call_Asm_Stack0 BLEV_ClearAllEvents_c + + retn + +; end procedure BLEV_ClearAllEvents + + +align 16 +BLEV_PutEvent: + +; [esp + 4] = const BLEV_Event * event +; [esp ] = return address + + Call_Asm_Stack1 BLEV_PutEvent_c + + retn + +; end procedure BLEV_PutEvent + + +align 16 +BLEV_GetEvent: + +; [esp + 4] = BLEV_Event * event +; [esp ] = return address + + Call_Asm_Stack1 BLEV_GetEvent_c + + retn + +; end procedure BLEV_GetEvent + + +align 16 +BLEV_PeekEvent: + +; [esp + 4] = BLEV_Event * event +; [esp ] = return address + + Call_Asm_Stack1 BLEV_PeekEvent_c + + retn + +; end procedure BLEV_PeekEvent + + diff --git a/games/Battle Isle 3/SR-BI3/x86/BBDBG-asm.asm b/games/Battle Isle 3/SR-BI3/x86/BBDBG-asm.asm new file mode 100644 index 0000000..5b39588 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/BBDBG-asm.asm @@ -0,0 +1,83 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define DBG_Panic_c _DBG_Panic_c + %define DBG_Init_c _DBG_Init_c + %define DBG_Exit_c _DBG_Exit_c +%endif + +extern DBG_Panic_c +extern DBG_Init_c +extern DBG_Exit_c + +global DBG_Panic +global DBG_Init +global DBG_Exit + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +DBG_Panic: + +; [esp + 2*4] = int line +; [esp + 4] = const char * module +; [esp ] = return address + + Call_Asm_Stack2 DBG_Panic_c + + retn + +; end procedure DBG_Panic + + +align 16 +DBG_Init: + +; [esp ] = return address + + Call_Asm_Stack0 DBG_Init_c + + retn + +; end procedure DBG_Init + + +align 16 +DBG_Exit: + +; [esp ] = return address + + Call_Asm_Stack0 DBG_Exit_c + + retn + +; end procedure DBG_Exit + + diff --git a/games/Battle Isle 3/SR-BI3/x86/BBDEPACK-asm.asm b/games/Battle Isle 3/SR-BI3/x86/BBDEPACK-asm.asm new file mode 100644 index 0000000..82edd36 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/BBDEPACK-asm.asm @@ -0,0 +1,53 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define DEPACK_c _DEPACK_c +%endif + +extern DEPACK_c + +global DEPACK + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +DEPACK: + +; [esp + 2*4] = uint8_t * dst +; [esp + 4] = const uint8_t * src +; [esp ] = return address + + Call_Asm_Stack2 DEPACK_c + + retn + +; end procedure DEPACK + + diff --git a/games/Battle Isle 3/SR-BI3/x86/BBDOS-asm.asm b/games/Battle Isle 3/SR-BI3/x86/BBDOS-asm.asm new file mode 100644 index 0000000..098966d --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/BBDOS-asm.asm @@ -0,0 +1,186 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define DOS_Init_c _DOS_Init_c + %define DOS_Exit_c _DOS_Exit_c + %define DOS_Open_c _DOS_Open_c + %define DOS_Close_c _DOS_Close_c + %define DOS_Read_c _DOS_Read_c + %define DOS_Write_c _DOS_Write_c + %define DOS_Seek_c _DOS_Seek_c + %define DOS_ReadFile_c _DOS_ReadFile_c + %define DOS_GetFileLength_c _DOS_GetFileLength_c +%endif + +extern DOS_Init_c +extern DOS_Exit_c +extern DOS_Open_c +extern DOS_Close_c +extern DOS_Read_c +extern DOS_Write_c +extern DOS_Seek_c +extern DOS_ReadFile_c +extern DOS_GetFileLength_c + +global DOS_Init +global DOS_Exit +global DOS_Open +global DOS_Close +global DOS_Read +global DOS_Write +global DOS_Seek +global DOS_ReadFile +global DOS_GetFileLength + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +DOS_Init: + +; [esp ] = return address + + Call_Asm_Stack0 DOS_Init_c + + retn + +; end procedure DOS_Init + + +align 16 +DOS_Exit: + +; [esp ] = return address + + Call_Asm_Stack0 DOS_Exit_c + + retn + +; end procedure DOS_Exit + + +align 16 +DOS_Open: + +; [esp + 2*4] = unsigned int mode +; [esp + 4] = const char * path +; [esp ] = return address + + Call_Asm_Stack2 DOS_Open_c + + retn + +; end procedure DOS_Open + + +align 16 +DOS_Close: + +; [esp + 4] = int file_handle +; [esp ] = return address + + Call_Asm_Stack1 DOS_Close_c + + retn + +; end procedure DOS_Close + + +align 16 +DOS_Read: + +; [esp + 3*4] = unsigned int length +; [esp + 2*4] = void * buffer +; [esp + 4] = int file_handle +; [esp ] = return address + + Call_Asm_Stack3 DOS_Read_c + + retn + +; end procedure DOS_Read + + +align 16 +DOS_Write: + +; [esp + 3*4] = unsigned int length +; [esp + 2*4] = const void * buffer +; [esp + 4] = int file_handle +; [esp ] = return address + + Call_Asm_Stack3 DOS_Write_c + + retn + +; end procedure DOS_Write + + +align 16 +DOS_Seek: + +; [esp + 3*4] = int offset +; [esp + 2*4] = int origin +; [esp + 4] = int file_handle +; [esp ] = return address + + Call_Asm_Stack3 DOS_Seek_c + + retn + +; end procedure DOS_Seek + + +align 16 +DOS_ReadFile: + +; [esp + 2*4] = void * buffer +; [esp + 4] = const char * path +; [esp ] = return address + + Call_Asm_Stack2 DOS_ReadFile_c + + retn + +; end procedure DOS_ReadFile + + +align 16 +DOS_GetFileLength: + +; [esp + 4] = const char * path +; [esp ] = return address + + Call_Asm_Stack1 DOS_GetFileLength_c + + retn + +; end procedure DOS_GetFileLength + + diff --git a/games/Battle Isle 3/SR-BI3/x86/BBDSA-asm.asm b/games/Battle Isle 3/SR-BI3/x86/BBDSA-asm.asm new file mode 100644 index 0000000..73991d5 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/BBDSA-asm.asm @@ -0,0 +1,652 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define DSA_ReuseStaticColors_c _DSA_ReuseStaticColors_c + %define DSA_FreeStaticColors_c _DSA_FreeStaticColors_c + %define DSAWIN_PrepareInit_c _DSAWIN_PrepareInit_c + %define DSAWIN_GetMainWindowHandle_c _DSAWIN_GetMainWindowHandle_c + %define DSAWIN_GetInstance_c _DSAWIN_GetInstance_c + %define DSA_Init_c _DSA_Init_c + %define DSA_Exit_c _DSA_Exit_c + %define DSA_OpenScreen_c _DSA_OpenScreen_c + %define DSA_CloseScreen_c _DSA_CloseScreen_c + %define DSA_CopyMainOPMToScreen_c _DSA_CopyMainOPMToScreen_c + %define DSA_StretchOPMToScreen_c _DSA_StretchOPMToScreen_c + %define DSA_CopyOPMToScreenEx_c _DSA_CopyOPMToScreenEx_c + %define DSA_TotalRepaint_c _DSA_TotalRepaint_c + %define DSA_MoveScreen_c _DSA_MoveScreen_c + %define DSA_ResizeScreen_c _DSA_ResizeScreen_c + %define DSA_DrawSizingScreen_c _DSA_DrawSizingScreen_c + %define DSA_EnterResizingMode_c _DSA_EnterResizingMode_c + %define DSA_LeaveResizingMode_c _DSA_LeaveResizingMode_c + %define DSA_GetDSAMetrics_c _DSA_GetDSAMetrics_c + %define DSA_SetDSAPos_c _DSA_SetDSAPos_c + %define DSA_GetScreenExtends_c _DSA_GetScreenExtends_c + %define DSA_GetActiveScreen_c _DSA_GetActiveScreen_c + %define DSA_SetActiveScreen_c _DSA_SetActiveScreen_c + %define DSA_GetLastTouchedScreen_c _DSA_GetLastTouchedScreen_c + %define DSA_CopyPartOPMToScreen_c _DSA_CopyPartOPMToScreen_c + %define DSA_ScreenVisibility_c _DSA_ScreenVisibility_c + %define DSA_LoadBackground_c _DSA_LoadBackground_c + %define DSA_FixBackground_c _DSA_FixBackground_c + %define DSA_SetCapture_c _DSA_SetCapture_c + %define DSA_SetBackgroundInRAM_c _DSA_SetBackgroundInRAM_c + %define DSA_SetPal_c _DSA_SetPal_c + %define DSA_ActivatePal_c _DSA_ActivatePal_c + %define DSA_PreventPaletteRemapping_c _DSA_PreventPaletteRemapping_c + %define DSA_GetBackgroundOffset_c _DSA_GetBackgroundOffset_c + %define DSA_SetBackground2Black_c _DSA_SetBackground2Black_c + %define DSA_MarkBitmapAsDirty_c _DSA_MarkBitmapAsDirty_c +%endif + +extern DSA_ReuseStaticColors_c +extern DSA_FreeStaticColors_c +extern DSAWIN_PrepareInit_c +extern DSAWIN_GetMainWindowHandle_c +extern DSAWIN_GetInstance_c +extern DSA_Init_c +extern DSA_Exit_c +extern DSA_OpenScreen_c +extern DSA_CloseScreen_c +extern DSA_CopyMainOPMToScreen_c +extern DSA_StretchOPMToScreen_c +extern DSA_CopyOPMToScreenEx_c +extern DSA_TotalRepaint_c +extern DSA_MoveScreen_c +extern DSA_ResizeScreen_c +extern DSA_DrawSizingScreen_c +extern DSA_EnterResizingMode_c +extern DSA_LeaveResizingMode_c +extern DSA_GetDSAMetrics_c +extern DSA_SetDSAPos_c +extern DSA_GetScreenExtends_c +extern DSA_GetActiveScreen_c +extern DSA_SetActiveScreen_c +extern DSA_GetLastTouchedScreen_c +extern DSA_CopyPartOPMToScreen_c +extern DSA_ScreenVisibility_c +extern DSA_LoadBackground_c +extern DSA_FixBackground_c +extern DSA_SetCapture_c +extern DSA_SetBackgroundInRAM_c +extern DSA_SetPal_c +extern DSA_ActivatePal_c +extern DSA_PreventPaletteRemapping_c +extern DSA_GetBackgroundOffset_c +extern DSA_SetBackground2Black_c +extern DSA_MarkBitmapAsDirty_c + +global DSA_ReuseStaticColors +global DSA_FreeStaticColors +global DSAWIN_PrepareInit +global DSAWIN_GetMainWindowHandle +global DSAWIN_GetInstance +global DSA_Init +global DSA_Exit +global DSA_OpenScreen +global DSA_CloseScreen +global DSA_CopyMainOPMToScreen +global DSA_StretchOPMToScreen +global DSA_CopyOPMToScreenEx +global DSA_TotalRepaint +global DSA_MoveScreen +global DSA_ResizeScreen +global DSA_DrawSizingScreen +global DSA_EnterResizingMode +global DSA_LeaveResizingMode +global DSA_GetDSAMetrics +global DSA_SetDSAPos +global DSA_GetScreenExtends +global DSA_GetActiveScreen +global DSA_SetActiveScreen +global DSA_GetLastTouchedScreen +global DSA_CopyPartOPMToScreen +global DSA_ScreenVisibility +global DSA_LoadBackground +global DSA_FixBackground +global DSA_SetCapture +global DSA_SetBackgroundInRAM +global DSA_SetPal +global DSA_ActivatePal +global DSA_PreventPaletteRemapping +global DSA_GetBackgroundOffset +global DSA_SetBackground2Black +global DSA_MarkBitmapAsDirty + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +DSA_ReuseStaticColors: + +; [esp + 4] = unsigned int osVersions +; [esp ] = return address + + Call_Asm_Stack1 DSA_ReuseStaticColors_c + + retn + +; end procedure DSA_ReuseStaticColors + + +align 16 +DSA_FreeStaticColors: + +; [esp + 4] = unsigned int osVersions +; [esp ] = return address + + Call_Asm_Stack1 DSA_FreeStaticColors_c + + retn + +; end procedure DSA_FreeStaticColors + + +align 16 +DSAWIN_PrepareInit: + +; [esp + 4] = void * hInstance +; [esp ] = return address + + Call_Asm_Stack1 DSAWIN_PrepareInit_c + + retn + +; end procedure DSAWIN_PrepareInit + + +align 16 +DSAWIN_GetMainWindowHandle: + +; [esp ] = return address + + Call_Asm_Stack0 DSAWIN_GetMainWindowHandle_c + + retn + +; end procedure DSAWIN_GetMainWindowHandle + + +align 16 +DSAWIN_GetInstance: + +; [esp ] = return address + + Call_Asm_Stack0 DSAWIN_GetInstance_c + + retn + +; end procedure DSAWIN_GetInstance + + +align 16 +DSA_Init: + +; [esp ] = return address + + Call_Asm_Stack0 DSA_Init_c + + retn + +; end procedure DSA_Init + + +align 16 +DSA_Exit: + +; [esp ] = return address + + Call_Asm_Stack0 DSA_Exit_c + + retn + +; end procedure DSA_Exit + + +align 16 +DSA_OpenScreen: + +; [esp + 7*4] = int type +; [esp + 6*4] = int y +; [esp + 5*4] = int x +; [esp + 4*4] = const char * windowName +; [esp + 3*4] = int param3 +; [esp + 2*4] = OPM_struct * opm +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack7 DSA_OpenScreen_c + + retn + +; end procedure DSA_OpenScreen + + +align 16 +DSA_CloseScreen: + +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack1 DSA_CloseScreen_c + + retn + +; end procedure DSA_CloseScreen + + +align 16 +DSA_CopyMainOPMToScreen: + +; [esp + 2*4] = int onlyModified +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack2 DSA_CopyMainOPMToScreen_c + + retn + +; end procedure DSA_CopyMainOPMToScreen + + +align 16 +DSA_StretchOPMToScreen: + +; [esp + 10*4] = int heightSrc +; [esp + 9*4] = int widthSrc +; [esp + 8*4] = int ySrc +; [esp + 7*4] = int xSrc +; [esp + 6*4] = OPM_struct * opm +; [esp + 5*4] = int heightDst +; [esp + 4*4] = int widthDst +; [esp + 3*4] = int yDst +; [esp + 2*4] = int xDst +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack10 DSA_StretchOPMToScreen_c + + retn + +; end procedure DSA_StretchOPMToScreen + + +align 16 +DSA_CopyOPMToScreenEx: + +; [esp + 8*4] = int ySrc +; [esp + 7*4] = int xSrc +; [esp + 6*4] = OPM_struct * opm +; [esp + 5*4] = int height +; [esp + 4*4] = int width +; [esp + 3*4] = int yDst +; [esp + 2*4] = int xDst +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack8 DSA_CopyOPMToScreenEx_c + + retn + +; end procedure DSA_CopyOPMToScreenEx + + +align 16 +DSA_TotalRepaint: + +; [esp ] = return address + + Call_Asm_Stack0 DSA_TotalRepaint_c + + retn + +; end procedure DSA_TotalRepaint + + +align 16 +DSA_MoveScreen: + +; [esp + 3*4] = int changeY +; [esp + 2*4] = int changeX +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack3 DSA_MoveScreen_c + + retn + +; end procedure DSA_MoveScreen + + +align 16 +DSA_ResizeScreen: + +; [esp + 3*4] = int redraw +; [esp + 2*4] = OPM_struct * opm +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack3 DSA_ResizeScreen_c + + retn + +; end procedure DSA_ResizeScreen + + +align 16 +DSA_DrawSizingScreen: + +; [esp + 2*4] = int16_t * rect +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack2 DSA_DrawSizingScreen_c + + retn + +; end procedure DSA_DrawSizingScreen + + +align 16 +DSA_EnterResizingMode: + +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack1 DSA_EnterResizingMode_c + + retn + +; end procedure DSA_EnterResizingMode + + +align 16 +DSA_LeaveResizingMode: + +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack1 DSA_LeaveResizingMode_c + + retn + +; end procedure DSA_LeaveResizingMode + + +align 16 +DSA_GetDSAMetrics: + +; [esp + 6*4] = uint8_t * isVisible +; [esp + 5*4] = int32_t * height +; [esp + 4*4] = int32_t * width +; [esp + 3*4] = int32_t * y +; [esp + 2*4] = int32_t * x +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack6 DSA_GetDSAMetrics_c + + retn + +; end procedure DSA_GetDSAMetrics + + +align 16 +DSA_SetDSAPos: + +; [esp + 4*4] = int repaint +; [esp + 3*4] = int y +; [esp + 2*4] = int x +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack4 DSA_SetDSAPos_c + + retn + +; end procedure DSA_SetDSAPos + + +align 16 +DSA_GetScreenExtends: + +; [esp + 2*4] = int32_t * height +; [esp + 4] = int32_t * width +; [esp ] = return address + + Call_Asm_Stack2 DSA_GetScreenExtends_c + + retn + +; end procedure DSA_GetScreenExtends + + +align 16 +DSA_GetActiveScreen: + +; [esp ] = return address + + Call_Asm_Stack0 DSA_GetActiveScreen_c + + retn + +; end procedure DSA_GetActiveScreen + + +align 16 +DSA_SetActiveScreen: + +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack1 DSA_SetActiveScreen_c + + retn + +; end procedure DSA_SetActiveScreen + + +align 16 +DSA_GetLastTouchedScreen: + +; [esp ] = return address + + Call_Asm_Stack0 DSA_GetLastTouchedScreen_c + + retn + +; end procedure DSA_GetLastTouchedScreen + + +align 16 +DSA_CopyPartOPMToScreen: + +; [esp + 5*4] = int height +; [esp + 4*4] = int width +; [esp + 3*4] = int y +; [esp + 2*4] = int x +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack5 DSA_CopyPartOPMToScreen_c + + retn + +; end procedure DSA_CopyPartOPMToScreen + + +align 16 +DSA_ScreenVisibility: + +; [esp + 2*4] = int show +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack2 DSA_ScreenVisibility_c + + retn + +; end procedure DSA_ScreenVisibility + + +align 16 +DSA_LoadBackground: + +; [esp + 4] = const char * path +; [esp ] = return address + + Call_Asm_Stack1 DSA_LoadBackground_c + + retn + +; end procedure DSA_LoadBackground + + +align 16 +DSA_FixBackground: + +; [esp + 4] = int isFixed +; [esp ] = return address + + Call_Asm_Stack1 DSA_FixBackground_c + + retn + +; end procedure DSA_FixBackground + + +align 16 +DSA_SetCapture: + +; [esp + 4] = DSA_Screen * screen +; [esp ] = return address + + Call_Asm_Stack1 DSA_SetCapture_c + + retn + +; end procedure DSA_SetCapture + + +align 16 +DSA_SetBackgroundInRAM: + +; [esp + 4] = int value +; [esp ] = return address + + Call_Asm_Stack1 DSA_SetBackgroundInRAM_c + + retn + +; end procedure DSA_SetBackgroundInRAM + + +align 16 +DSA_SetPal: + +; [esp + 5*4] = unsigned int dst_start_entry +; [esp + 4*4] = unsigned int num_entries +; [esp + 3*4] = unsigned int src_start_entry +; [esp + 2*4] = DSA_Palette * palette +; [esp + 4] = int unused +; [esp ] = return address + + Call_Asm_Stack5 DSA_SetPal_c + + retn + +; end procedure DSA_SetPal + + +align 16 +DSA_ActivatePal: + +; [esp ] = return address + + Call_Asm_Stack0 DSA_ActivatePal_c + + retn + +; end procedure DSA_ActivatePal + + +align 16 +DSA_PreventPaletteRemapping: + +; [esp + 4] = int valueAdd +; [esp ] = return address + + Call_Asm_Stack1 DSA_PreventPaletteRemapping_c + + retn + +; end procedure DSA_PreventPaletteRemapping + + +align 16 +DSA_GetBackgroundOffset: + +; [esp + 2*4] = int32_t * offsetY +; [esp + 4] = int32_t * offsetX +; [esp ] = return address + + Call_Asm_Stack2 DSA_GetBackgroundOffset_c + + retn + +; end procedure DSA_GetBackgroundOffset + + +align 16 +DSA_SetBackground2Black: + +; [esp + 4] = int isBlack +; [esp ] = return address + + Call_Asm_Stack1 DSA_SetBackground2Black_c + + retn + +; end procedure DSA_SetBackground2Black + + +align 16 +DSA_MarkBitmapAsDirty: + +; [esp + 2*4] = int param2 +; [esp + 4] = int param1 +; [esp ] = return address + + Call_Asm_Stack2 DSA_MarkBitmapAsDirty_c + + retn + +; end procedure DSA_MarkBitmapAsDirty + + diff --git a/games/Battle Isle 3/SR-BI3/x86/BBFX-asm.asm b/games/Battle Isle 3/SR-BI3/x86/BBFX-asm.asm new file mode 100644 index 0000000..b16e322 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/BBFX-asm.asm @@ -0,0 +1,180 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define FX_Init_c _FX_Init_c + %define FX_Exit_c _FX_Exit_c + %define FX_ReserveDevices_c _FX_ReserveDevices_c + %define FX_ReadLib_c _FX_ReadLib_c + %define FX_FreeLib_c _FX_FreeLib_c + %define FX_StopAllSamples_c _FX_StopAllSamples_c + %define FX_PlaySample_c _FX_PlaySample_c + %define FX_SetVolume_c _FX_SetVolume_c + %define FM_IsError_c _FM_IsError_c +%endif + +extern FX_Init_c +extern FX_Exit_c +extern FX_ReserveDevices_c +extern FX_ReadLib_c +extern FX_FreeLib_c +extern FX_StopAllSamples_c +extern FX_PlaySample_c +extern FX_SetVolume_c +extern FM_IsError_c + +global FX_Init +global FX_Exit +global FX_ReserveDevices +global FX_ReadLib +global FX_FreeLib +global FX_StopAllSamples +global FX_PlaySample +global FX_SetVolume +global FM_IsError + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +FX_Init: + +; [esp ] = return address + + Call_Asm_Stack0 FX_Init_c + + retn + +; end procedure FX_Init + + +align 16 +FX_Exit: + +; [esp ] = return address + + Call_Asm_Stack0 FX_Exit_c + + retn + +; end procedure FX_Exit + + +align 16 +FX_ReserveDevices: + +; [esp + 4] = int reserve +; [esp ] = return address + + Call_Asm_Stack1 FX_ReserveDevices_c + + retn + +; end procedure FX_ReserveDevices + + +align 16 +FX_ReadLib: + +; [esp + 4] = const char * path +; [esp ] = return address + + Call_Asm_Stack1 FX_ReadLib_c + + retn + +; end procedure FX_ReadLib + + +align 16 +FX_FreeLib: + +; [esp + 4] = int lib_handle +; [esp ] = return address + + Call_Asm_Stack1 FX_FreeLib_c + + retn + +; end procedure FX_FreeLib + + +align 16 +FX_StopAllSamples: + +; [esp ] = return address + + Call_Asm_Stack0 FX_StopAllSamples_c + + retn + +; end procedure FX_StopAllSamples + + +align 16 +FX_PlaySample: + +; [esp + 5*4] = int times_play +; [esp + 4*4] = int volume +; [esp + 3*4] = int priority +; [esp + 2*4] = int sample_number +; [esp + 4] = int lib_handle +; [esp ] = return address + + Call_Asm_Stack5 FX_PlaySample_c + + retn + +; end procedure FX_PlaySample + + +align 16 +FX_SetVolume: + +; [esp + 4] = unsigned int volume +; [esp ] = return address + + Call_Asm_Stack1 FX_SetVolume_c + + retn + +; end procedure FX_SetVolume + + +align 16 +FM_IsError: + +; [esp ] = return address + + Call_Asm_Stack0 FM_IsError_c + + retn + +; end procedure FM_IsError + + diff --git a/games/Battle Isle 3/SR-BI3/x86/BBLBL-asm.asm b/games/Battle Isle 3/SR-BI3/x86/BBLBL-asm.asm new file mode 100644 index 0000000..e7e71e6 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/BBLBL-asm.asm @@ -0,0 +1,168 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define LBL_Init_c _LBL_Init_c + %define LBL_Exit_c _LBL_Exit_c + %define LBL_OpenLib_c _LBL_OpenLib_c + %define LBL_CloseLib_c _LBL_CloseLib_c + %define LBL_ReadEntry_c _LBL_ReadEntry_c + %define LBL_GetEntrySize_c _LBL_GetEntrySize_c + %define LBL_CloseFile_c _LBL_CloseFile_c + %define LBL_GetNOFEntries_c _LBL_GetNOFEntries_c +%endif + +extern LBL_Init_c +extern LBL_Exit_c +extern LBL_OpenLib_c +extern LBL_CloseLib_c +extern LBL_ReadEntry_c +extern LBL_GetEntrySize_c +extern LBL_CloseFile_c +extern LBL_GetNOFEntries_c + +global LBL_Init +global LBL_Exit +global LBL_OpenLib +global LBL_CloseLib +global LBL_ReadEntry +global LBL_GetEntrySize +global LBL_CloseFile +global LBL_GetNOFEntries + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +LBL_Init: + +; [esp ] = return address + + Call_Asm_Stack0 LBL_Init_c + + retn + +; end procedure LBL_Init + + +align 16 +LBL_Exit: + +; [esp ] = return address + + Call_Asm_Stack0 LBL_Exit_c + + retn + +; end procedure LBL_Exit + + +align 16 +LBL_OpenLib: + +; [esp + 2*4] = int param2 +; [esp + 4] = const char * path +; [esp ] = return address + + Call_Asm_Stack2 LBL_OpenLib_c + + retn + +; end procedure LBL_OpenLib + + +align 16 +LBL_CloseLib: + +; [esp + 4] = void * lib +; [esp ] = return address + + Call_Asm_Stack1 LBL_CloseLib_c + + retn + +; end procedure LBL_CloseLib + + +align 16 +LBL_ReadEntry: + +; [esp + 5*4] = void * entry_metadata +; [esp + 4*4] = int close_file +; [esp + 3*4] = unsigned int entry_number +; [esp + 2*4] = void * entry_data +; [esp + 4] = void * lib +; [esp ] = return address + + Call_Asm_Stack5 LBL_ReadEntry_c + + retn + +; end procedure LBL_ReadEntry + + +align 16 +LBL_GetEntrySize: + +; [esp + 2*4] = unsigned int entry_number +; [esp + 4] = void * lib +; [esp ] = return address + + Call_Asm_Stack2 LBL_GetEntrySize_c + + retn + +; end procedure LBL_GetEntrySize + + +align 16 +LBL_CloseFile: + +; [esp + 4] = void * lib +; [esp ] = return address + + Call_Asm_Stack1 LBL_CloseFile_c + + retn + +; end procedure LBL_CloseFile + + +align 16 +LBL_GetNOFEntries: + +; [esp + 4] = void * lib +; [esp ] = return address + + Call_Asm_Stack1 LBL_GetNOFEntries_c + + retn + +; end procedure LBL_GetNOFEntries + + diff --git a/games/Battle Isle 3/SR-BI3/x86/BBLBM-asm.asm b/games/Battle Isle 3/SR-BI3/x86/BBLBM-asm.asm new file mode 100644 index 0000000..9042efa --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/BBLBM-asm.asm @@ -0,0 +1,87 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define LBM_DisplayLBM_c _LBM_DisplayLBM_c + %define LBM_StartSerie_c _LBM_StartSerie_c + %define LBM_AutoSave_c _LBM_AutoSave_c +%endif + +extern LBM_DisplayLBM_c +extern LBM_StartSerie_c +extern LBM_AutoSave_c + +global LBM_DisplayLBM +global LBM_StartSerie +global LBM_AutoSave + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +LBM_DisplayLBM: + +; [esp + 4*4] = unsigned int flags +; [esp + 3*4] = uint8_t * palette +; [esp + 2*4] = void * pixel_map +; [esp + 4] = const char * path +; [esp ] = return address + + Call_Asm_Stack4 LBM_DisplayLBM_c + + retn + +; end procedure LBM_DisplayLBM + + +align 16 +LBM_StartSerie: + +; [esp + 4] = int number +; [esp ] = return address + + Call_Asm_Stack1 LBM_StartSerie_c + + retn + +; end procedure LBM_StartSerie + + +align 16 +LBM_AutoSave: + +; [esp + 4] = void * pixel_map +; [esp ] = return address + + Call_Asm_Stack1 LBM_AutoSave_c + + retn + +; end procedure LBM_AutoSave + + diff --git a/games/Battle Isle 3/SR-BI3/x86/BBLL-asm.asm b/games/Battle Isle 3/SR-BI3/x86/BBLL-asm.asm new file mode 100644 index 0000000..d1a3392 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/BBLL-asm.asm @@ -0,0 +1,66 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define LL_Init_c _LL_Init_c + %define LL_Exit_c _LL_Exit_c +%endif + +extern LL_Init_c +extern LL_Exit_c + +global LL_Init +global LL_Exit + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +LL_Init: + +; [esp ] = return address + + Call_Asm_Stack0 LL_Init_c + + retn + +; end procedure LL_Init + + +align 16 +LL_Exit: + +; [esp ] = return address + + Call_Asm_Stack0 LL_Exit_c + + retn + +; end procedure LL_Exit + + diff --git a/games/Battle Isle 3/SR-BI3/x86/BBMEM-asm.asm b/games/Battle Isle 3/SR-BI3/x86/BBMEM-asm.asm new file mode 100644 index 0000000..6d250f3 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/BBMEM-asm.asm @@ -0,0 +1,232 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define MEM_Init_c _MEM_Init_c + %define MEM_Exit_c _MEM_Exit_c + %define MEM_malloc_c _MEM_malloc_c + %define MEM_free_c _MEM_free_c + %define MEM_Take_Snapshot_c _MEM_Take_Snapshot_c + %define MEM_Check_Snapshot_c _MEM_Check_Snapshot_c + %define MEM_SwitchSecurity_c _MEM_SwitchSecurity_c + %define BASEMEM_Alloc_c _BASEMEM_Alloc_c + %define BASEMEM_Free_c _BASEMEM_Free_c + %define BASEMEM_CopyMem_c _BASEMEM_CopyMem_c + %define BASEMEM_FillMemByte_c _BASEMEM_FillMemByte_c + %define BBMEM_GetPoolPointer_c _BBMEM_GetPoolPointer_c +%endif + +extern MEM_Init_c +extern MEM_Exit_c +extern MEM_malloc_c +extern MEM_free_c +extern MEM_Take_Snapshot_c +extern MEM_Check_Snapshot_c +extern MEM_SwitchSecurity_c +extern BASEMEM_Alloc_c +extern BASEMEM_Free_c +extern BASEMEM_CopyMem_c +extern BASEMEM_FillMemByte_c +extern BBMEM_GetPoolPointer_c + +global MEM_Init +global MEM_Exit +global MEM_malloc +global MEM_free +global MEM_Take_Snapshot +global MEM_Check_Snapshot +global MEM_SwitchSecurity +global BASEMEM_Alloc +global BASEMEM_Free +global BASEMEM_CopyMem +global BASEMEM_FillMemByte +global BBMEM_GetPoolPointer + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +MEM_Init: + +; [esp ] = return address + + Call_Asm_Stack0 MEM_Init_c + + retn + +; end procedure MEM_Init + + +align 16 +MEM_Exit: + +; [esp ] = return address + + Call_Asm_Stack0 MEM_Exit_c + + retn + +; end procedure MEM_Exit + + +align 16 +MEM_malloc: + +; [esp + 5*4] = int type +; [esp + 4*4] = unsigned int line +; [esp + 3*4] = const char * object_type +; [esp + 2*4] = const char * module_name +; [esp + 4] = unsigned int size +; [esp ] = return address + + Call_Asm_Stack5 MEM_malloc_c + + retn + +; end procedure MEM_malloc + + +align 16 +MEM_free: + +; [esp + 4] = void * mem_ptr +; [esp ] = return address + + Call_Asm_Stack1 MEM_free_c + + retn + +; end procedure MEM_free + + +align 16 +MEM_Take_Snapshot: + +; [esp + 4] = const char * name +; [esp ] = return address + + Call_Asm_Stack1 MEM_Take_Snapshot_c + + retn + +; end procedure MEM_Take_Snapshot + + +align 16 +MEM_Check_Snapshot: + +; [esp ] = return address + + Call_Asm_Stack0 MEM_Check_Snapshot_c + + retn + +; end procedure MEM_Check_Snapshot + + +align 16 +MEM_SwitchSecurity: + +; [esp + 4] = unsigned int security +; [esp ] = return address + + Call_Asm_Stack1 MEM_SwitchSecurity_c + + retn + +; end procedure MEM_SwitchSecurity + + +align 16 +BASEMEM_Alloc: + +; [esp + 4] = unsigned int size +; [esp ] = return address + + Call_Asm_Stack1 BASEMEM_Alloc_c + + retn + +; end procedure BASEMEM_Alloc + + +align 16 +BASEMEM_Free: + +; [esp + 4] = void * mem_ptr +; [esp ] = return address + + Call_Asm_Stack1 BASEMEM_Free_c + + retn + +; end procedure BASEMEM_Free + + +align 16 +BASEMEM_CopyMem: + +; [esp + 3*4] = unsigned int length +; [esp + 2*4] = void * dst +; [esp + 4] = const void * src +; [esp ] = return address + + Call_Asm_Stack3 BASEMEM_CopyMem_c + + retn + +; end procedure BASEMEM_CopyMem + + +align 16 +BASEMEM_FillMemByte: + +; [esp + 3*4] = int c +; [esp + 2*4] = unsigned int length +; [esp + 4] = void * dst +; [esp ] = return address + + Call_Asm_Stack3 BASEMEM_FillMemByte_c + + retn + +; end procedure BASEMEM_FillMemByte + + +align 16 +BBMEM_GetPoolPointer: + +; [esp ] = return address + + Call_Asm_Stack0 BBMEM_GetPoolPointer_c + + retn + +; end procedure BBMEM_GetPoolPointer + + diff --git a/games/Battle Isle 3/SR-BI3/x86/BBOPM-asm.asm b/games/Battle Isle 3/SR-BI3/x86/BBOPM-asm.asm new file mode 100644 index 0000000..73d816d --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/BBOPM-asm.asm @@ -0,0 +1,282 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define OPM_Init_c _OPM_Init_c + %define OPM_Exit_c _OPM_Exit_c + %define OPM_New_c _OPM_New_c + %define OPM_Del_c _OPM_Del_c + %define OPM_CreateVirtualOPM_c _OPM_CreateVirtualOPM_c + %define OPM_CreateSecondaryOPM_c _OPM_CreateSecondaryOPM_c + %define OPM_SetPixel_c _OPM_SetPixel_c + %define OPM_HorLine_c _OPM_HorLine_c + %define OPM_VerLine_c _OPM_VerLine_c + %define OPM_FillBox_c _OPM_FillBox_c + %define OPM_CopyGFXOPM_c _OPM_CopyGFXOPM_c + %define OPM_CopyOPMOPM_c _OPM_CopyOPMOPM_c + %define OPM_AccessBitmap_c _OPM_AccessBitmap_c +%endif + +extern OPM_Init_c +extern OPM_Exit_c +extern OPM_New_c +extern OPM_Del_c +extern OPM_CreateVirtualOPM_c +extern OPM_CreateSecondaryOPM_c +extern OPM_SetPixel_c +extern OPM_HorLine_c +extern OPM_VerLine_c +extern OPM_FillBox_c +extern OPM_CopyGFXOPM_c +extern OPM_CopyOPMOPM_c +extern OPM_AccessBitmap_c + +global OPM_Init +global OPM_Exit +global OPM_New +global OPM_Del +global OPM_CreateVirtualOPM +global OPM_CreateSecondaryOPM +global OPM_SetPixel +global OPM_HorLine +global OPM_VerLine +global OPM_FillBox +global OPM_CopyGFXOPM +global OPM_CopyOPMOPM +global OPM_AccessBitmap + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +OPM_Init: + +; [esp ] = return address + + Call_Asm_Stack0 OPM_Init_c + + retn + +; end procedure OPM_Init + + +align 16 +OPM_Exit: + +; [esp ] = return address + + Call_Asm_Stack0 OPM_Exit_c + + retn + +; end procedure OPM_Exit + + +align 16 +OPM_New: + +; [esp + 5*4] = uint8_t * buffer +; [esp + 4*4] = OPM_struct * pixel_map +; [esp + 3*4] = unsigned int bytes_per_pixel +; [esp + 2*4] = unsigned int height +; [esp + 4] = unsigned int width +; [esp ] = return address + + Call_Asm_Stack5 OPM_New_c + + retn + +; end procedure OPM_New + + +align 16 +OPM_Del: + +; [esp + 4] = OPM_struct * pixel_map +; [esp ] = return address + + Call_Asm_Stack1 OPM_Del_c + + retn + +; end procedure OPM_Del + + +align 16 +OPM_CreateVirtualOPM: + +; [esp + 6*4] = int virtual_height +; [esp + 5*4] = int virtual_width +; [esp + 4*4] = int virtual_y +; [esp + 3*4] = int virtual_x +; [esp + 2*4] = OPM_struct * virtual_pixel_map +; [esp + 4] = OPM_struct * base_pixel_map +; [esp ] = return address + + Call_Asm_Stack6 OPM_CreateVirtualOPM_c + + retn + +; end procedure OPM_CreateVirtualOPM + + +align 16 +OPM_CreateSecondaryOPM: + +; [esp + 5*4] = uint8_t * buffer +; [esp + 4*4] = OPM_struct * pixel_map +; [esp + 3*4] = int bytes_per_pixel +; [esp + 2*4] = int height +; [esp + 4] = int width +; [esp ] = return address + + Call_Asm_Stack5 OPM_CreateSecondaryOPM_c + + retn + +; end procedure OPM_CreateSecondaryOPM + + +align 16 +OPM_SetPixel: + +; [esp + 4*4] = uint8_t color +; [esp + 3*4] = int y +; [esp + 2*4] = int x +; [esp + 4] = OPM_struct * pixel_map +; [esp ] = return address + + Call_Asm_Stack4 OPM_SetPixel_c + + retn + +; end procedure OPM_SetPixel + + +align 16 +OPM_HorLine: + +; [esp + 5*4] = uint8_t color +; [esp + 4*4] = unsigned int length +; [esp + 3*4] = int y +; [esp + 2*4] = int x +; [esp + 4] = OPM_struct * pixel_map +; [esp ] = return address + + Call_Asm_Stack5 OPM_HorLine_c + + retn + +; end procedure OPM_HorLine + + +align 16 +OPM_VerLine: + +; [esp + 5*4] = uint8_t color +; [esp + 4*4] = unsigned int length +; [esp + 3*4] = int y +; [esp + 2*4] = int x +; [esp + 4] = OPM_struct * pixel_map +; [esp ] = return address + + Call_Asm_Stack5 OPM_VerLine_c + + retn + +; end procedure OPM_VerLine + + +align 16 +OPM_FillBox: + +; [esp + 6*4] = uint8_t color +; [esp + 5*4] = unsigned int height +; [esp + 4*4] = unsigned int width +; [esp + 3*4] = int y +; [esp + 2*4] = int x +; [esp + 4] = OPM_struct * pixel_map +; [esp ] = return address + + Call_Asm_Stack6 OPM_FillBox_c + + retn + +; end procedure OPM_FillBox + + +align 16 +OPM_CopyGFXOPM: + +; [esp + 5*4] = uint8_t value_add +; [esp + 4*4] = int pos_y +; [esp + 3*4] = int pos_x +; [esp + 2*4] = GFX_struct * gfx +; [esp + 4] = OPM_struct * pixel_map +; [esp ] = return address + + Call_Asm_Stack5 OPM_CopyGFXOPM_c + + retn + +; end procedure OPM_CopyGFXOPM + + +align 16 +OPM_CopyOPMOPM: + +; [esp + 8*4] = int dst_y +; [esp + 7*4] = int dst_x +; [esp + 6*4] = int copy_height +; [esp + 5*4] = int copy_width +; [esp + 4*4] = int src_y +; [esp + 3*4] = int src_x +; [esp + 2*4] = OPM_struct * dst_pixel_map +; [esp + 4] = OPM_struct * src_pixel_map +; [esp ] = return address + + Call_Asm_Stack8 OPM_CopyOPMOPM_c + + retn + +; end procedure OPM_CopyOPMOPM + + +align 16 +OPM_AccessBitmap: + +; [esp + 4] = OPM_struct * pixel_map +; [esp ] = return address + + Call_Asm_Stack1 OPM_AccessBitmap_c + + retn + +; end procedure OPM_AccessBitmap + + diff --git a/games/Battle Isle 3/SR-BI3/x86/BBRNG-asm.asm b/games/Battle Isle 3/SR-BI3/x86/BBRNG-asm.asm new file mode 100644 index 0000000..aadff33 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/BBRNG-asm.asm @@ -0,0 +1,184 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define RNG_Init_c _RNG_Init_c + %define RNG_Exit_c _RNG_Exit_c + %define RNG_NewBuffer_c _RNG_NewBuffer_c + %define RNG_DelBuffer_c _RNG_DelBuffer_c + %define RNG_In_c _RNG_In_c + %define RNG_Out_c _RNG_Out_c + %define RNG_Peek_c _RNG_Peek_c + %define RNG_Replace_c _RNG_Replace_c + %define RNG_PutFirst_c _RNG_PutFirst_c +%endif + +extern RNG_Init_c +extern RNG_Exit_c +extern RNG_NewBuffer_c +extern RNG_DelBuffer_c +extern RNG_In_c +extern RNG_Out_c +extern RNG_Peek_c +extern RNG_Replace_c +extern RNG_PutFirst_c + +global RNG_Init +global RNG_Exit +global RNG_NewBuffer +global RNG_DelBuffer +global RNG_In +global RNG_Out +global RNG_Peek +global RNG_Replace +global RNG_PutFirst + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +RNG_Init: + +; [esp ] = return address + + Call_Asm_Stack0 RNG_Init_c + + retn + +; end procedure RNG_Init + + +align 16 +RNG_Exit: + +; [esp ] = return address + + Call_Asm_Stack0 RNG_Exit_c + + retn + +; end procedure RNG_Exit + + +align 16 +RNG_NewBuffer: + +; [esp + 2*4] = int num_elements +; [esp + 4] = int element_size +; [esp ] = return address + + Call_Asm_Stack2 RNG_NewBuffer_c + + retn + +; end procedure RNG_NewBuffer + + +align 16 +RNG_DelBuffer: + +; [esp + 4] = void * buffer +; [esp ] = return address + + Call_Asm_Stack1 RNG_DelBuffer_c + + retn + +; end procedure RNG_DelBuffer + + +align 16 +RNG_In: + +; [esp + 2*4] = const void * element +; [esp + 4] = void * buffer +; [esp ] = return address + + Call_Asm_Stack2 RNG_In_c + + retn + +; end procedure RNG_In + + +align 16 +RNG_Out: + +; [esp + 2*4] = void * element +; [esp + 4] = void * buffer +; [esp ] = return address + + Call_Asm_Stack2 RNG_Out_c + + retn + +; end procedure RNG_Out + + +align 16 +RNG_Peek: + +; [esp + 2*4] = void * element +; [esp + 4] = void * buffer +; [esp ] = return address + + Call_Asm_Stack2 RNG_Peek_c + + retn + +; end procedure RNG_Peek + + +align 16 +RNG_Replace: + +; [esp + 2*4] = const void * element +; [esp + 4] = void * buffer +; [esp ] = return address + + Call_Asm_Stack2 RNG_Replace_c + + retn + +; end procedure RNG_Replace + + +align 16 +RNG_PutFirst: + +; [esp + 2*4] = const void * element +; [esp + 4] = void * buffer +; [esp ] = return address + + Call_Asm_Stack2 RNG_PutFirst_c + + retn + +; end procedure RNG_PutFirst + + diff --git a/games/Battle Isle 3/SR-BI3/x86/BBSYSTEM-asm.asm b/games/Battle Isle 3/SR-BI3/x86/BBSYSTEM-asm.asm new file mode 100644 index 0000000..acd10bb --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/BBSYSTEM-asm.asm @@ -0,0 +1,204 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define SYSTEM_SetInitValues_c _SYSTEM_SetInitValues_c + %define SYSTEM_SystemTask_c _SYSTEM_SystemTask_c + %define SYSTEM_Init_c _SYSTEM_Init_c + %define SYSTEM_Exit_c _SYSTEM_Exit_c + %define SYSTEM_GetTicks_c _SYSTEM_GetTicks_c + %define SYSTEM_IsApplicationActive_c _SYSTEM_IsApplicationActive_c + %define SYSTEM_WaitTicks_c _SYSTEM_WaitTicks_c + %define SYSTEM_EnterCriticalSection_c _SYSTEM_EnterCriticalSection_c + %define SYSTEM_LeaveCriticalSection_c _SYSTEM_LeaveCriticalSection_c + %define SYSTEM_InCriticalSection_c _SYSTEM_InCriticalSection_c + %define SYSTEM_GetOS_c _SYSTEM_GetOS_c +%endif + +extern SYSTEM_SetInitValues_c +extern SYSTEM_SystemTask_c +extern SYSTEM_Init_c +extern SYSTEM_Exit_c +extern SYSTEM_GetTicks_c +extern SYSTEM_IsApplicationActive_c +extern SYSTEM_WaitTicks_c +extern SYSTEM_EnterCriticalSection_c +extern SYSTEM_LeaveCriticalSection_c +extern SYSTEM_InCriticalSection_c +extern SYSTEM_GetOS_c + +global SYSTEM_SetInitValues +global SYSTEM_SystemTask +global SYSTEM_Init +global SYSTEM_Exit +global SYSTEM_GetTicks +global SYSTEM_IsApplicationActive +global SYSTEM_WaitTicks +global SYSTEM_EnterCriticalSection +global SYSTEM_LeaveCriticalSection +global SYSTEM_InCriticalSection +global SYSTEM_GetOS + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +SYSTEM_SetInitValues: + +; [esp + 2*4] = const char * value +; [esp + 4] = int type +; [esp ] = return address + + Call_Asm_Stack2 SYSTEM_SetInitValues_c + + retn + +; end procedure SYSTEM_SetInitValues + + +align 16 +SYSTEM_SystemTask: + +; [esp ] = return address + + Call_Asm_Stack0 SYSTEM_SystemTask_c + + retn + +; end procedure SYSTEM_SystemTask + + +align 16 +SYSTEM_Init: + +; [esp ] = return address + + Call_Asm_Stack0 SYSTEM_Init_c + + retn + +; end procedure SYSTEM_Init + + +align 16 +SYSTEM_Exit: + +; [esp ] = return address + + Call_Asm_Stack0 SYSTEM_Exit_c + + retn + +; end procedure SYSTEM_Exit + + +align 16 +SYSTEM_GetTicks: + +; [esp ] = return address + + Call_Asm_Stack0 SYSTEM_GetTicks_c + + retn + +; end procedure SYSTEM_GetTicks + + +align 16 +SYSTEM_IsApplicationActive: + +; [esp ] = return address + + Call_Asm_Stack0 SYSTEM_IsApplicationActive_c + + retn + +; end procedure SYSTEM_IsApplicationActive + + +align 16 +SYSTEM_WaitTicks: + +; [esp + 4] = unsigned int ticks +; [esp ] = return address + + Call_Asm_Stack1 SYSTEM_WaitTicks_c + + retn + +; end procedure SYSTEM_WaitTicks + + +align 16 +SYSTEM_EnterCriticalSection: + +; [esp ] = return address + + Call_Asm_Stack0 SYSTEM_EnterCriticalSection_c + + retn + +; end procedure SYSTEM_EnterCriticalSection + + +align 16 +SYSTEM_LeaveCriticalSection: + +; [esp ] = return address + + Call_Asm_Stack0 SYSTEM_LeaveCriticalSection_c + + retn + +; end procedure SYSTEM_LeaveCriticalSection + + +align 16 +SYSTEM_InCriticalSection: + +; [esp ] = return address + + Call_Asm_Stack0 SYSTEM_InCriticalSection_c + + retn + +; end procedure SYSTEM_InCriticalSection + + +align 16 +SYSTEM_GetOS: + +; [esp ] = return address + + Call_Asm_Stack0 SYSTEM_GetOS_c + + retn + +; end procedure SYSTEM_GetOS + + diff --git a/games/Battle Isle 3/SR-BI3/x86/BBTOOL-asm.asm b/games/Battle Isle 3/SR-BI3/x86/BBTOOL-asm.asm new file mode 100644 index 0000000..46d0ba9 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/BBTOOL-asm.asm @@ -0,0 +1,55 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define TOOL_Chiffre_c _TOOL_Chiffre_c +%endif + +extern TOOL_Chiffre_c + +global TOOL_Chiffre + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +TOOL_Chiffre: + +; [esp + 4*4] = unsigned int keylength +; [esp + 3*4] = const uint8_t * key +; [esp + 2*4] = unsigned int length +; [esp + 4] = uint8_t * buffer +; [esp ] = return address + + Call_Asm_Stack4 TOOL_Chiffre_c + + retn + +; end procedure TOOL_Chiffre + + diff --git a/games/Battle Isle 3/SR-BI3/x86/BBTXT-asm.asm b/games/Battle Isle 3/SR-BI3/x86/BBTXT-asm.asm new file mode 100644 index 0000000..cffcb28 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/BBTXT-asm.asm @@ -0,0 +1,120 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define TXT_Init_c _TXT_Init_c + %define TXT_Exit_c _TXT_Exit_c + %define TXT_LoadFont_c _TXT_LoadFont_c + %define TXT_WriteString_c _TXT_WriteString_c + %define TXT_UnloadAllFonts_c _TXT_UnloadAllFonts_c +%endif + +extern TXT_Init_c +extern TXT_Exit_c +extern TXT_LoadFont_c +extern TXT_WriteString_c +extern TXT_UnloadAllFonts_c + +global TXT_Init +global TXT_Exit +global TXT_LoadFont +global TXT_WriteString +global TXT_UnloadAllFonts + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +TXT_Init: + +; [esp ] = return address + + Call_Asm_Stack0 TXT_Init_c + + retn + +; end procedure TXT_Init + + +align 16 +TXT_Exit: + +; [esp ] = return address + + Call_Asm_Stack0 TXT_Exit_c + + retn + +; end procedure TXT_Exit + + +align 16 +TXT_LoadFont: + +; [esp + 4] = const char * path +; [esp ] = return address + + Call_Asm_Stack1 TXT_LoadFont_c + + retn + +; end procedure TXT_LoadFont + + +align 16 +TXT_WriteString: + +; [esp + 8*4] = uint8_t color_add +; [esp + 7*4] = int height +; [esp + 6*4] = int width +; [esp + 5*4] = int y +; [esp + 4*4] = int x +; [esp + 3*4] = void * dst_pixel_map +; [esp + 2*4] = int font_handle +; [esp + 4] = const char * text +; [esp ] = return address + + Call_Asm_Stack8 TXT_WriteString_c + + retn + +; end procedure TXT_WriteString + + +align 16 +TXT_UnloadAllFonts: + +; [esp ] = return address + + Call_Asm_Stack0 TXT_UnloadAllFonts_c + + retn + +; end procedure TXT_UnloadAllFonts + + diff --git a/games/Battle Isle 3/SR-BI3/x86/CLIB-asm-x86.c b/games/Battle Isle 3/SR-BI3/x86/CLIB-asm-x86.c new file mode 100644 index 0000000..33ec38d --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/CLIB-asm-x86.c @@ -0,0 +1,85 @@ +/** + * + * Copyright (C) 2019-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "CLIB-asm-x86.h" +#include +#include +#include +#include + + +#define eprintf(...) fprintf(stderr,__VA_ARGS__) + + +void *_alloca_probe_c(uint32_t size) +{ +#ifdef DEBUG_CLIB + eprintf("_alloca_probe: %i\n", size); +#endif + + // return value will be ignored + return memset(alloca(size), 0, size); +} + + +int32_t printf2_c(const char *format, va_list ap) +{ + int res; + +#ifdef DEBUG_CLIB + eprintf("printf: 0x%x (%s) - ", (uintptr_t) format, format); +#endif + + res = vprintf(format, ap); + +#ifdef DEBUG_CLIB + eprintf("%i\n", res); +#endif + + return res; +} + +int32_t sprintf2_c(char *str, const char *format, va_list ap) +{ + int res; + +#ifdef DEBUG_CLIB + eprintf("sprintf: 0x%x, 0x%x (%s) - ", (uintptr_t) str, (uintptr_t) format, format); +#endif + + res = vsprintf(str, format, ap); + +#ifdef DEBUG_CLIB + eprintf("%i (%s)\n", res, str); +#endif + + return res; +} + + +int64_t _ftol_c(double *num) +{ + return (int64_t) trunc(*num); +} + diff --git a/games/Battle Isle 3/SR-BI3/x86/CLIB-asm-x86.h b/games/Battle Isle 3/SR-BI3/x86/CLIB-asm-x86.h new file mode 100644 index 0000000..3a4ed59 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/CLIB-asm-x86.h @@ -0,0 +1,47 @@ +/** + * + * Copyright (C) 2019-2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_CLIB_ASM_X86_H_INCLUDED_) +#define _CLIB_ASM_X86_H_INCLUDED_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void *_alloca_probe_c(uint32_t size); + +int32_t printf2_c(const char *format, va_list ap); +int32_t sprintf2_c(char *str, const char *format, va_list ap); + +int64_t _ftol_c(double *num); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/games/Battle Isle 3/SR-BI3/x86/CLIB-asm.asm b/games/Battle Isle 3/SR-BI3/x86/CLIB-asm.asm new file mode 100644 index 0000000..f18160c --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/CLIB-asm.asm @@ -0,0 +1,491 @@ +;; +;; Copyright (C) 2019-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define memcmp_c _memcmp_c + %define memcpy_c _memcpy_c + %define memset_c _memset_c + + %define strcat_c _strcat_c + %define strcmp_c _strcmp_c + %define strcpy_c _strcpy_c + %define strlen_c _strlen_c + %define strncpy_c _strncpy_c + %define _strnicmp_c __strnicmp_c + %define strstr_c _strstr_c + + %define _alloca_probe_c __alloca_probe_c + + %define printf2_c _printf2_c + %define sprintf2_c _sprintf2_c + + %define _ftol_c __ftol_c + + %define ms_srand_c _ms_srand_c + %define ms_rand_c _ms_rand_c + %define wc_rand_c _wc_rand_c + + %define atoi_c _atoi_c + %define atol_c _atol_c + %define _ltoa_c __ltoa_c + + %define isalnum_c _isalnum_c + + %define _except_handler3_c __except_handler3_c + + %define sync_c _sync_c +%endif + +extern memcmp_c +extern memcpy_c +extern memset_c + +extern strcat_c +extern strcmp_c +extern strcpy_c +extern strlen_c +extern strncpy_c +extern _strnicmp_c +extern strstr_c + +extern _alloca_probe_c + +extern printf2_c +extern sprintf2_c + +extern _ftol_c + +extern ms_srand_c +extern ms_rand_c +extern wc_rand_c + +extern atoi_c +extern atol_c +extern _ltoa_c + +extern isalnum_c + +extern _except_handler3_c + +extern sync_c + + +global ms_memcmp_asm2c +global ms_memcpy_asm2c +global ms_memset_asm2c +global wc_memset_asm2c + +global ms_strcat_asm2c +global ms_strcmp_asm2c +global ms_strcpy_asm2c +global ms_strlen_asm2c +global ms_strncpy_asm2c +global ms__strnicmp_asm2c +global ms_strstr_asm2c +global wc_strcmp_asm2c +global wc_strcpy_asm2c + +global ms__alloca_probe_asm2c + +global ms_printf_asm2c +global wc_sprintf_asm2c + +global ms__ftol_asm2c + +global ms_srand_asm2c +global ms_rand_asm2c +global wc_rand_asm2c + +global ms_atoi_asm2c +global ms_atol_asm2c +global ms__ltoa_asm2c + +global ms_isalnum_asm2c + +global ms__except_handler3_asm2c + +global sync_asm2c + + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +ms_memcmp_asm2c: + +; [esp + 3*4] = uint32_t n +; [esp + 2*4] = const void *s2 +; [esp + 4] = const void *s1 +; [esp ] = return address + + Call_Asm_Stack3 memcmp_c + + retn + +; end procedure ms_memcmp_asm2c + + +align 16 +ms_memcpy_asm2c: + +; [esp + 3*4] = uint32_t n +; [esp + 2*4] = const void *src +; [esp + 4] = void *dest +; [esp ] = return address + + Call_Asm_Stack3 memcpy_c + + retn + +; end procedure ms_memcpy_asm2c + + +align 16 +ms_memset_asm2c: +wc_memset_asm2c: + +; [esp + 3*4] = uint32_t n +; [esp + 2*4] = int32_t c +; [esp + 4] = void *s +; [esp ] = return address + + Call_Asm_Stack3 memset_c + + retn + +; end procedure ms_memset_asm2c + + +align 16 +ms_strcat_asm2c: + +; [esp + 2*4] = const char *src +; [esp + 4] = char *dest +; [esp ] = return address + + Call_Asm_Stack2 strcat_c + + retn + +; end procedure ms_strcat_asm2c + + +align 16 +ms_strcmp_asm2c: +wc_strcmp_asm2c: + +; [esp + 2*4] = const char *s2 +; [esp + 4] = const char *s1 +; [esp ] = return address + + Call_Asm_Stack2 strcmp_c + + retn + +; end procedure ms_strcmp_asm2c + + +align 16 +ms_strcpy_asm2c: +wc_strcpy_asm2c: + +; [esp + 2*4] = const char *src +; [esp + 4] = char *dest +; [esp ] = return address + + Call_Asm_Stack2 strcpy_c + + retn + +; end procedure ms_strcpy_asm2c + + +align 16 +ms_strlen_asm2c: + +; [esp + 4] = const char *s +; [esp ] = return address + + Call_Asm_Stack1 strlen_c + + retn + +; end procedure ms_strlen_asm2c + + +align 16 +ms_strncpy_asm2c: + +; [esp + 3*4] = uint32_t n +; [esp + 2*4] = const char *src +; [esp + 4] = char *dest +; [esp ] = return address + + Call_Asm_Stack3 strncpy_c + + retn + +; end procedure ms_strncpy_asm2c + + +align 16 +ms__strnicmp_asm2c: + +; [esp + 3*4] = uint32_t n +; [esp + 2*4] = const char *s2 +; [esp + 4] = const char *s1 +; [esp ] = return address + + Call_Asm_Stack3 _strnicmp_c + + retn + +; end procedure ms__strnicmp_asm2c + + +align 16 +ms_strstr_asm2c: + +; [esp + 2*4] = const char *needle +; [esp + 4] = const char *haystack +; [esp ] = return address + + Call_Asm_Stack2 strstr_c + + retn + +; end procedure ms_strstr_asm2c + + +align 16 +ms__alloca_probe_asm2c: + +; eax = uint32_t size +; [esp] = return address + + ; save ecx and edx to stack + push ecx + push edx + + ; remember original esp value + mov ecx, esp + ; align stack to 16 bytes + and esp, 0FFFFFFF0h + sub esp, byte 4*4 + + ; save original esp value on stack + mov [esp + 3*4], ecx + ; put function argument to stack + mov [esp], eax + + call _alloca_probe_c + + ; restore function argument to ecx + mov ecx, [esp] + + ; restore original esp value from stack + mov esp, [esp + 3*4] + + ; restore original edx value from stack + pop edx + + lea eax, [esp+4] + sub eax, ecx + + ; restore original ecx value from stack + pop ecx + + xchg esp, eax + mov eax, [eax] + mov [esp], eax + retn + +; end procedure ms__alloca_probe_asm2c + + +align 16 +ms_printf_asm2c: + +; [esp + 2*4] = ... +; [esp + 4] = const char *format +; [esp ] = return address + + Call_Asm_VariableStack1 printf2_c + + retn + +; end procedure ms_printf_asm2c + + +align 16 +wc_sprintf_asm2c: + +; [esp + 3*4] = ... +; [esp + 2*4] = const char *format +; [esp + 4] = char *str +; [esp ] = return address + + Call_Asm_VariableStack2 sprintf2_c + + retn + +; end procedure wc_sprintf_asm2c + + +align 16 +ms__ftol_asm2c: + +; st0 = num +; [esp] = return address + + Call_Asm_Float1_Int _ftol_c + + retn + +; end procedure ms__ftol_asm2c + + +align 16 +ms_srand_asm2c: + +; [esp + 4] = uint32_t seed +; [esp ] = return address + + Call_Asm_Stack1 ms_srand_c + + retn + +; end procedure ms_srand_asm2c + + +align 16 +ms_rand_asm2c: + +; [esp] = return address + + Call_Asm_Stack0 ms_rand_c + + retn + +; end procedure ms_rand_asm2c + + +align 16 +wc_rand_asm2c: + +; [esp] = return address + + Call_Asm_Stack0 wc_rand_c + + retn + +; end procedure wc_rand_asm2c + + +align 16 +ms_atoi_asm2c: + +; [esp + 4] = const char *nptr +; [esp ] = return address + + Call_Asm_Stack1 atoi_c + + retn + +; end procedure ms_atoi_asm2c + + +align 16 +ms_atol_asm2c: + +; [esp + 4] = const char *nptr +; [esp ] = return address + + Call_Asm_Stack1 atol_c + + retn + +; end procedure ms_atol_asm2c + + +align 16 +ms__ltoa_asm2c: + +; [esp + 3*4] = int radix +; [esp + 2*4] = char *buffer +; [esp + 4] = long value +; [esp ] = return address + + Call_Asm_Stack3 _ltoa_c + + retn + +; end procedure ms__ltoa_asm2c + + +align 16 +ms_isalnum_asm2c: + +; [esp + 4] = int c +; [esp ] = return address + + Call_Asm_Stack1 isalnum_c + + retn + +; end procedure ms_isalnum_asm2c + + +align 16 +ms__except_handler3_asm2c: + +; [esp + 4*4] = PEXCEPTION_REGISTRATION dispatcher +; [esp + 3*4] = PCONTEXT context +; [esp + 2*4] = PEXCEPTION_REGISTRATION registration +; [esp + 4] = PEXCEPTION_RECORD exception_record +; [esp ] = return address + + Call_Asm_Stack4 _except_handler3_c + + retn + +; end procedure ms__except_handler3_asm2c + + +align 16 +sync_asm2c: + +; [esp] = return address + + Call_Asm_Stack0 sync_c + + retn + +; end procedure sync_asm2c + + diff --git a/games/Battle Isle 3/SR-BI3/x86/FGT-asm.asm b/games/Battle Isle 3/SR-BI3/x86/FGT-asm.asm new file mode 100644 index 0000000..392e39d --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/FGT-asm.asm @@ -0,0 +1,67 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define FGT_SystemTask_End _FGT_SystemTask_End + %define FGT_CheckTicksDelay _FGT_CheckTicksDelay +%endif + +extern FGT_SystemTask_End +extern FGT_CheckTicksDelay + +global FGT_SystemTask_End_asm2c +global FGT_CheckTicksDelay_asm2c + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +FGT_SystemTask_End_asm2c: + +; [esp + 4] = int flushGdi +; [esp ] = return address + + Call_Asm_Stack1 FGT_SystemTask_End + + retn 4 + +; end procedure FGT_SystemTask_End_asm2c + + +align 16 +FGT_CheckTicksDelay_asm2c: + +; [esp + 4] = int index +; [esp ] = return address + + Call_Asm_Stack1 FGT_CheckTicksDelay + + retn 4 + +; end procedure FGT_CheckTicksDelay_asm2c + diff --git a/games/Battle Isle 3/SR-BI3/x86/SConscript b/games/Battle Isle 3/SR-BI3/x86/SConscript new file mode 100644 index 0000000..8686d42 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/SConscript @@ -0,0 +1,51 @@ +# +# Copyright (C) 2019-2021 Roman Pauer +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +import re + +Import('device env') + +include_re = re.compile(r'^%include\s+"(\S+)"\r?$', re.M) + +def nasmfile_scan(node, env, path): + contents = node.get_text_contents() + includes = include_re.findall(contents) + return includes + +nasmscan = Scanner(function = nasmfile_scan, + skeys = ['.asm'], + recursive = True) + +SourceFileScanner.add_scanner('.asm', nasmscan) + +if device == 'pc-linux': + env1 = Environment(tools=['nasm'], ASFLAGS = ' -felf32 -Ox -w+orphan-labels -w-number-overflow -ix86/') +else: + env1 = Environment(tools=['nasm'], ASFLAGS = ' -fwin32 -Ox -w+orphan-labels -w-number-overflow -ix86/') + +ms_figtr_objs = SConscript('ms_figtr/SConscript', exports='device') +sdi_1r_objs = SConscript('sdi_1r/SConscript', exports='device') +wc_figtr_objs = SConscript('wc_figtr/SConscript', exports='device') + +obj = env1.Object(Glob('*.asm')) + env.Object(Glob('*.c')) + ms_figtr_objs + sdi_1r_objs + wc_figtr_objs + +Return('obj') diff --git a/games/Battle Isle 3/SR-BI3/x86/SDI-asm.asm b/games/Battle Isle 3/SR-BI3/x86/SDI-asm.asm new file mode 100644 index 0000000..aeac184 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/SDI-asm.asm @@ -0,0 +1,51 @@ +;; +;; Copyright (C) 2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define SDI_CheckTicksDelay _SDI_CheckTicksDelay +%endif + +extern SDI_CheckTicksDelay + +global SDI_CheckTicksDelay_asm2c + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +SDI_CheckTicksDelay_asm2c: + +; [esp + 4] = int index +; [esp ] = return address + + Call_Asm_Stack1 SDI_CheckTicksDelay + + retn 4 + +; end procedure SDI_CheckTicksDelay_asm2c + diff --git a/games/Battle Isle 3/SR-BI3/x86/SDIcmdline-asm.asm b/games/Battle Isle 3/SR-BI3/x86/SDIcmdline-asm.asm new file mode 100644 index 0000000..8a4b280 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/SDIcmdline-asm.asm @@ -0,0 +1,68 @@ +;; +;; Copyright (C) 2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define cmdline_ContainsOption _cmdline_ContainsOption + %define cmdline_ReadLanguageOption _cmdline_ReadLanguageOption +%endif + +extern cmdline_ContainsOption +extern cmdline_ReadLanguageOption + +global cmdline_ContainsOption_asm2c +global cmdline_ReadLanguageOption_asm2c + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +cmdline_ContainsOption_asm2c: + +; [esp + 4] = int option +; [esp ] = return address + + Call_Asm_Stack1 cmdline_ContainsOption + + retn + +; end procedure cmdline_ContainsOption_asm2c + + +align 16 +cmdline_ReadLanguageOption_asm2c: + +; [esp + 4] = uint32_t *language +; [esp ] = return address + + Call_Asm_Stack1 cmdline_ReadLanguageOption + + retn 4 + +; end procedure cmdline_ReadLanguageOption_asm2c + + diff --git a/games/Battle Isle 3/SR-BI3/x86/SDImidi-asm.asm b/games/Battle Isle 3/SR-BI3/x86/SDImidi-asm.asm new file mode 100644 index 0000000..02436ac --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/SDImidi-asm.asm @@ -0,0 +1,175 @@ +;; +;; Copyright (C) 2020-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define midi_OpenSDIMusic _midi_OpenSDIMusic + %define midi_GetSDIMusicID _midi_GetSDIMusicID + %define midi_PlaySDIMusic _midi_PlaySDIMusic + %define midi_CloseSDIMusic _midi_CloseSDIMusic + %define midi_IsPlaying _midi_IsPlaying + %define midi_OpenTestMusic _midi_OpenTestMusic + %define midi_PlayTestMusic _midi_PlayTestMusic + %define midi_CloseTestMusic _midi_CloseTestMusic + %define midi_GetErrorString _midi_GetErrorString +%endif + +extern midi_OpenSDIMusic +extern midi_GetSDIMusicID +extern midi_PlaySDIMusic +extern midi_CloseSDIMusic +extern midi_IsPlaying +extern midi_OpenTestMusic +extern midi_PlayTestMusic +extern midi_CloseTestMusic +extern midi_GetErrorString + +global midi_OpenSDIMusic_asm2c +global midi_GetSDIMusicID_asm2c +global midi_PlaySDIMusic_asm2c +global midi_CloseSDIMusic_asm2c +global midi_IsPlaying_asm2c +global midi_OpenTestMusic_asm2c +global midi_PlayTestMusic_asm2c +global midi_CloseTestMusic_asm2c +global midi_GetErrorString_asm2c + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +midi_OpenSDIMusic_asm2c: + +; [esp + 4] = const char *filename +; [esp ] = return address + + Call_Asm_Stack1 midi_OpenSDIMusic + + retn 4 + +; end procedure midi_OpenSDIMusic_asm2c + + +align 16 +midi_GetSDIMusicID_asm2c: + +; [esp ] = return address + + Call_Asm_Stack0 midi_GetSDIMusicID + + retn + +; end procedure midi_GetSDIMusicID_asm2c + + +align 16 +midi_PlaySDIMusic_asm2c: + +; [esp ] = return address + + Call_Asm_Stack0 midi_PlaySDIMusic + + retn + +; end procedure midi_PlaySDIMusic_asm2c + + +align 16 +midi_CloseSDIMusic_asm2c: + +; [esp ] = return address + + Call_Asm_Stack0 midi_CloseSDIMusic + + retn + +; end procedure midi_CloseSDIMusic_asm2c + + +align 16 +midi_IsPlaying_asm2c: + +; [esp + 4] = unsigned int musicID +; [esp ] = return address + + Call_Asm_Stack1 midi_IsPlaying + + retn 4 + +; end procedure midi_IsPlaying_asm2c + + +align 16 +midi_OpenTestMusic_asm2c: + +; [esp ] = return address + + Call_Asm_Stack0 midi_OpenTestMusic + + retn + +; end procedure midi_OpenTestMusic_asm2c + + +align 16 +midi_PlayTestMusic_asm2c: + +; [esp ] = return address + + Call_Asm_Stack0 midi_PlayTestMusic + + retn + +; end procedure midi_PlayTestMusic_asm2c + + +align 16 +midi_CloseTestMusic_asm2c: + +; [esp ] = return address + + Call_Asm_Stack0 midi_CloseTestMusic + + retn + +; end procedure midi_CloseTestMusic_asm2c + + +align 16 +midi_GetErrorString_asm2c: + +; [esp + 3*4] = unsigned int length +; [esp + 2*4] = char *text +; [esp + 4] = int error +; [esp ] = return address + + Call_Asm_Stack3 midi_GetErrorString + + retn 3*4 + +; end procedure midi_GetErrorString_asm2c + diff --git a/games/Battle Isle 3/SR-BI3/x86/SDIvideo-asm.asm b/games/Battle Isle 3/SR-BI3/x86/SDIvideo-asm.asm new file mode 100644 index 0000000..50d68f4 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/SDIvideo-asm.asm @@ -0,0 +1,174 @@ +;; +;; Copyright (C) 2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define video_RegisterClass_PRE_Video _video_RegisterClass_PRE_Video + %define video_Open_PRE_Video _video_Open_PRE_Video + %define video_Close_PRE_Video _video_Close_PRE_Video + %define video_Play_PRE_Video _video_Play_PRE_Video + %define video_RegisterClass_POST_Video _video_RegisterClass_POST_Video + %define video_Open_POST_Video _video_Open_POST_Video + %define video_Close_POST_Video _video_Close_POST_Video + %define video_Play_POST_Video _video_Play_POST_Video + %define video_RegisterClass_SS_Video _video_RegisterClass_SS_Video +%endif + +extern video_RegisterClass_PRE_Video +extern video_Open_PRE_Video +extern video_Close_PRE_Video +extern video_Play_PRE_Video +extern video_RegisterClass_POST_Video +extern video_Open_POST_Video +extern video_Close_POST_Video +extern video_Play_POST_Video +extern video_RegisterClass_SS_Video + +global video_RegisterClass_PRE_Video_asm2c +global video_Open_PRE_Video_asm2c +global video_Close_PRE_Video_asm2c +global video_Play_PRE_Video_asm2c +global video_RegisterClass_POST_Video_asm2c +global video_Open_POST_Video_asm2c +global video_Close_POST_Video_asm2c +global video_Play_POST_Video_asm2c +global video_RegisterClass_SS_Video_asm2c + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +video_RegisterClass_PRE_Video_asm2c: + +; [esp ] = return address + + Call_Asm_Stack0 video_RegisterClass_PRE_Video + + retn + +; end procedure video_RegisterClass_PRE_Video_asm2c + + +align 16 +video_Open_PRE_Video_asm2c: + +; [esp + 4] = const char *path +; [esp ] = return address + + Call_Asm_Stack1 video_Open_PRE_Video + + retn 4 + +; end procedure video_Open_PRE_Video_asm2c + + +align 16 +video_Close_PRE_Video_asm2c: + +; [esp ] = return address + + Call_Asm_Stack0 video_Close_PRE_Video + + retn + +; end procedure video_Close_PRE_Video_asm2c + + +align 16 +video_Play_PRE_Video_asm2c: + +; [esp + 4] = uint32_t zoomed +; [esp ] = return address + + Call_Asm_Stack1 video_Play_PRE_Video + + retn 4 + +; end procedure video_Play_PRE_Video_asm2c + + +align 16 +video_RegisterClass_POST_Video_asm2c: + +; [esp ] = return address + + Call_Asm_Stack0 video_RegisterClass_POST_Video + + retn + +; end procedure video_RegisterClass_POST_Video_asm2c + + +align 16 +video_Open_POST_Video_asm2c: + +; [esp + 4] = const char *path +; [esp ] = return address + + Call_Asm_Stack1 video_Open_POST_Video + + retn 4 + +; end procedure video_Open_POST_Video_asm2c + + +align 16 +video_Close_POST_Video_asm2c: + +; [esp ] = return address + + Call_Asm_Stack0 video_Close_POST_Video + + retn + +; end procedure video_Close_POST_Video_asm2c + + +align 16 +video_Play_POST_Video_asm2c: + +; [esp + 4] = uint32_t zoomed +; [esp ] = return address + + Call_Asm_Stack1 video_Play_POST_Video + + retn 4 + +; end procedure video_Play_POST_Video_asm2c + + +align 16 +video_RegisterClass_SS_Video_asm2c: + +; [esp ] = return address + + Call_Asm_Stack0 video_RegisterClass_SS_Video + + retn + +; end procedure video_RegisterClass_SS_Video_asm2c + diff --git a/games/Battle Isle 3/SR-BI3/x86/WinApi-gdi32-asm.asm b/games/Battle Isle 3/SR-BI3/x86/WinApi-gdi32-asm.asm new file mode 100644 index 0000000..c9069e9 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/WinApi-gdi32-asm.asm @@ -0,0 +1,173 @@ +;; +;; Copyright (C) 2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define CreateFontIndirectA_c _CreateFontIndirectA_c + %define DeleteObject_c _DeleteObject_c + %define GdiFlush_c _GdiFlush_c + %define GetDeviceCaps_c _GetDeviceCaps_c + %define GetTextExtentPointA_c _GetTextExtentPointA_c + %define SelectObject_c _SelectObject_c + %define SetBkMode_c _SetBkMode_c + %define TextOutA_c _TextOutA_c +%endif + +extern CreateFontIndirectA_c +extern DeleteObject_c +extern GdiFlush_c +extern GetDeviceCaps_c +extern GetTextExtentPointA_c +extern SelectObject_c +extern SetBkMode_c +extern TextOutA_c + +global CreateFontIndirectA_asm2c +global DeleteObject_asm2c +global GdiFlush_asm2c +global GetDeviceCaps_asm2c +global GetTextExtentPointA_asm2c +global SelectObject_asm2c +global SetBkMode_asm2c +global TextOutA_asm2c + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +CreateFontIndirectA_asm2c: + +; [esp + 4] = CONST LOGFONTA * lplf +; [esp ] = return address + + Call_Asm_Stack1 CreateFontIndirectA_c + + retn 1*4 + +; end procedure CreateFontIndirectA_asm2c + + +align 16 +DeleteObject_asm2c: + +; [esp + 4] = HGDIOBJ ho +; [esp ] = return address + + Call_Asm_Stack1 DeleteObject_c + + retn 1*4 + +; end procedure DeleteObject_asm2c + + +align 16 +GdiFlush_asm2c: + +; [esp ] = return address + + Call_Asm_Stack0 GdiFlush_c + + retn + +; end procedure GdiFlush_asm2c + + +align 16 +GetDeviceCaps_asm2c: + +; [esp + 2*4] = int index +; [esp + 4] = HDC hdc +; [esp ] = return address + + Call_Asm_Stack2 GetDeviceCaps_c + + retn 2*4 + +; end procedure GetDeviceCaps_asm2c + + +align 16 +GetTextExtentPointA_asm2c: + +; [esp + 4*4] = LPSIZE lpsz +; [esp + 3*4] = int c +; [esp + 2*4] = LPCSTR lpString +; [esp + 4] = HDC hdc +; [esp ] = return address + + Call_Asm_Stack4 GetTextExtentPointA_c + + retn 4*4 + +; end procedure GetTextExtentPointA_asm2c + + +align 16 +SelectObject_asm2c: + +; [esp + 2*4] = HGDIOBJ h +; [esp + 4] = HDC hdc +; [esp ] = return address + + Call_Asm_Stack2 SelectObject_c + + retn 2*4 + +; end procedure SelectObject_asm2c + + +align 16 +SetBkMode_asm2c: + +; [esp + 2*4] = int mode +; [esp + 4] = HDC hdc +; [esp ] = return address + + Call_Asm_Stack2 SetBkMode_c + + retn 2*4 + +; end procedure SetBkMode_asm2c + + +align 16 +TextOutA_asm2c: + +; [esp + 5*4] = int c +; [esp + 4*4] = LPCSTR lpString +; [esp + 3*4] = int y +; [esp + 2*4] = int x +; [esp + 4] = HDC hdc +; [esp ] = return address + + Call_Asm_Stack5 TextOutA_c + + retn 5*4 + +; end procedure TextOutA_asm2c + + diff --git a/games/Battle Isle 3/SR-BI3/x86/WinApi-kernel32-asm.asm b/games/Battle Isle 3/SR-BI3/x86/WinApi-kernel32-asm.asm new file mode 100644 index 0000000..41d81f3 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/WinApi-kernel32-asm.asm @@ -0,0 +1,306 @@ +;; +;; Copyright (C) 2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define CloseHandle_c _CloseHandle_c + %define CreateFileA_c _CreateFileA_c + %define FindClose_c _FindClose_c + %define FindFirstFileA_c _FindFirstFileA_c + %define FindNextFileA_c _FindNextFileA_c + %define GetCurrentDirectoryA_c _GetCurrentDirectoryA_c + %define GetPrivateProfileIntA_c _GetPrivateProfileIntA_c + %define GetPrivateProfileStringA_c _GetPrivateProfileStringA_c + %define GetTickCount_c _GetTickCount_c + %define GlobalMemoryStatus_c _GlobalMemoryStatus_c + %define ReadFile_c _ReadFile_c + %define SetCurrentDirectoryA_c _SetCurrentDirectoryA_c + %define SetFilePointer_c _SetFilePointer_c + %define WriteFile_c _WriteFile_c + %define WritePrivateProfileStringA_c _WritePrivateProfileStringA_c +%endif + +extern CloseHandle_c +extern CreateFileA_c +extern FindClose_c +extern FindFirstFileA_c +extern FindNextFileA_c +extern GetCurrentDirectoryA_c +extern GetPrivateProfileIntA_c +extern GetPrivateProfileStringA_c +extern GetTickCount_c +extern GlobalMemoryStatus_c +extern ReadFile_c +extern SetCurrentDirectoryA_c +extern SetFilePointer_c +extern WriteFile_c +extern WritePrivateProfileStringA_c + +global CloseHandle_asm2c +global CreateFileA_asm2c +global FindClose_asm2c +global FindFirstFileA_asm2c +global FindNextFileA_asm2c +global GetCurrentDirectoryA_asm2c +global GetPrivateProfileIntA_asm2c +global GetPrivateProfileStringA_asm2c +global GetTickCount_asm2c +global GlobalMemoryStatus_asm2c +global ReadFile_asm2c +global SetCurrentDirectoryA_asm2c +global SetFilePointer_asm2c +global WriteFile_asm2c +global WritePrivateProfileStringA_asm2c + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +CloseHandle_asm2c: + +; [esp + 4] = HANDLE hObject +; [esp ] = return address + + Call_Asm_Stack1 CloseHandle_c + + retn 1*4 + +; end procedure CloseHandle_asm2c + + +align 16 +CreateFileA_asm2c: + +; [esp + 7*4] = HANDLE hTemplateFile +; [esp + 6*4] = DWORD dwFlagsAndAttributes +; [esp + 5*4] = DWORD dwCreationDisposition +; [esp + 4*4] = LPSECURITY_ATTRIBUTES lpSecurityAttributes +; [esp + 3*4] = DWORD dwShareMode +; [esp + 2*4] = DWORD dwDesiredAccess +; [esp + 4] = LPCSTR lpFileName +; [esp ] = return address + + Call_Asm_Stack7 CreateFileA_c + + retn 7*4 + +; end procedure CreateFileA_asm2c + + +align 16 +FindClose_asm2c: + +; [esp + 4] = HANDLE hFindFile +; [esp ] = return address + + Call_Asm_Stack1 FindClose_c + + retn 1*4 + +; end procedure FindClose_asm2c + + +align 16 +FindFirstFileA_asm2c: + +; [esp + 2*4] = LPWIN32_FIND_DATAA lpFindFileData +; [esp + 4] = LPCSTR lpFileName +; [esp ] = return address + + Call_Asm_Stack2 FindFirstFileA_c + + retn 2*4 + +; end procedure FindFirstFileA_asm2c + + +align 16 +FindNextFileA_asm2c: + +; [esp + 2*4] = LPWIN32_FIND_DATAA lpFindFileData +; [esp + 4] = HANDLE hFindFile +; [esp ] = return address + + Call_Asm_Stack2 FindNextFileA_c + + retn 2*4 + +; end procedure FindNextFileA_asm2c + + +align 16 +GetCurrentDirectoryA_asm2c: + +; [esp + 2*4] = LPSTR lpBuffer +; [esp + 4] = DWORD nBufferLength +; [esp ] = return address + + Call_Asm_Stack2 GetCurrentDirectoryA_c + + retn 2*4 + +; end procedure GetCurrentDirectoryA_asm2c + + +align 16 +GetPrivateProfileIntA_asm2c: + +; [esp + 4*4] = LPCSTR lpFileName +; [esp + 3*4] = INT nDefault +; [esp + 2*4] = LPCSTR lpKeyName +; [esp + 4] = LPCSTR lpAppName +; [esp ] = return address + + Call_Asm_Stack4 GetPrivateProfileIntA_c + + retn 4*4 + +; end procedure GetPrivateProfileIntA_asm2c + + +align 16 +GetPrivateProfileStringA_asm2c: + +; [esp + 6*4] = LPCSTR lpFileName +; [esp + 5*4] = DWORD nSize +; [esp + 4*4] = LPSTR lpReturnedString +; [esp + 3*4] = LPCSTR lpDefault +; [esp + 2*4] = LPCSTR lpKeyName +; [esp + 4] = LPCSTR lpAppName +; [esp ] = return address + + Call_Asm_Stack6 GetPrivateProfileStringA_c + + retn 6*4 + +; end procedure GetPrivateProfileStringA_asm2c + + +align 16 +GetTickCount_asm2c: + +; [esp ] = return address + + Call_Asm_Stack0 GetTickCount_c + + retn + +; end procedure GetTickCount_asm2c + + +align 16 +GlobalMemoryStatus_asm2c: + +; [esp + 4] = LPMEMORYSTATUS lpBuffer +; [esp ] = return address + + Call_Asm_Stack1 GlobalMemoryStatus_c + + retn 1*4 + +; end procedure GlobalMemoryStatus_asm2c + + +align 16 +ReadFile_asm2c: + +; [esp + 5*4] = LPOVERLAPPED lpOverlapped +; [esp + 4*4] = LPDWORD lpNumberOfBytesRead +; [esp + 3*4] = DWORD nNumberOfBytesToRead +; [esp + 2*4] = LPVOID lpBuffer +; [esp + 4] = HANDLE hFile +; [esp ] = return address + + Call_Asm_Stack5 ReadFile_c + + retn 5*4 + +; end procedure ReadFile_asm2c + + +align 16 +SetCurrentDirectoryA_asm2c: + +; [esp + 4] = LPCSTR lpPathName +; [esp ] = return address + + Call_Asm_Stack1 SetCurrentDirectoryA_c + + retn 1*4 + +; end procedure SetCurrentDirectoryA_asm2c + + +align 16 +SetFilePointer_asm2c: + +; [esp + 4*4] = DWORD dwMoveMethod +; [esp + 3*4] = PLONG lpDistanceToMoveHigh +; [esp + 2*4] = LONG lDistanceToMove +; [esp + 4] = HANDLE hFile +; [esp ] = return address + + Call_Asm_Stack4 SetFilePointer_c + + retn 4*4 + +; end procedure SetFilePointer_asm2c + + +align 16 +WriteFile_asm2c: + +; [esp + 5*4] = LPOVERLAPPED lpOverlapped +; [esp + 4*4] = LPDWORD lpNumberOfBytesWritten +; [esp + 3*4] = DWORD nNumberOfBytesToWrite +; [esp + 2*4] = LPCVOID lpBuffer +; [esp + 4] = HANDLE hFile +; [esp ] = return address + + Call_Asm_Stack5 WriteFile_c + + retn 5*4 + +; end procedure WriteFile_asm2c + + +align 16 +WritePrivateProfileStringA_asm2c: + +; [esp + 4*4] = LPCSTR lpFileName +; [esp + 3*4] = LPCSTR lpString +; [esp + 2*4] = LPCSTR lpKeyName +; [esp + 4] = LPCSTR lpAppName +; [esp ] = return address + + Call_Asm_Stack4 WritePrivateProfileStringA_c + + retn 4*4 + +; end procedure WritePrivateProfileStringA_asm2c + + diff --git a/games/Battle Isle 3/SR-BI3/x86/WinApi-user32-asm-x86.c b/games/Battle Isle 3/SR-BI3/x86/WinApi-user32-asm-x86.c new file mode 100644 index 0000000..3f08f24 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/WinApi-user32-asm-x86.c @@ -0,0 +1,33 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "WinApi-user32-asm-x86.h" +#define WIN32_LEAN_AND_MEAN +#include + +int32_t wsprintfA2_c(char * param1, const char * param2, va_list ap) +{ + return wvsprintfA(param1, param2, ap); +} + diff --git a/games/Battle Isle 3/SR-BI3/x86/WinApi-user32-asm-x86.h b/games/Battle Isle 3/SR-BI3/x86/WinApi-user32-asm-x86.h new file mode 100644 index 0000000..32e2240 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/WinApi-user32-asm-x86.h @@ -0,0 +1,42 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if !defined(_WINAPI_USER32_ASM_X86_H_INCLUDED_) +#define _WINAPI_USER32_ASM_X86_H_INCLUDED_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int32_t wsprintfA2_c(char * param1, const char * param2, va_list ap); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/games/Battle Isle 3/SR-BI3/x86/WinApi-user32-asm.asm b/games/Battle Isle 3/SR-BI3/x86/WinApi-user32-asm.asm new file mode 100644 index 0000000..90fd164 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/WinApi-user32-asm.asm @@ -0,0 +1,511 @@ +;; +;; Copyright (C) 2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define ClientToScreen_c _ClientToScreen_c + %define ClipCursor_c _ClipCursor_c + %define CreateWindowExA_c _CreateWindowExA_c + %define GetActiveWindow_c _GetActiveWindow_c + %define GetCursorPos_c _GetCursorPos_c + %define GetDC_c _GetDC_c + %define GetWindowRect_c _GetWindowRect_c + %define IsIconic_c _IsIconic_c + %define IsWindowVisible_c _IsWindowVisible_c + %define LoadCursorA_c _LoadCursorA_c + %define LoadStringA_c _LoadStringA_c + %define MessageBoxA_c _MessageBoxA_c + %define MoveWindow_c _MoveWindow_c + %define ReleaseCapture_c _ReleaseCapture_c + %define ReleaseDC_c _ReleaseDC_c + %define ScreenToClient_c _ScreenToClient_c + %define SendMessageA_c _SendMessageA_c + %define SetActiveWindow_c _SetActiveWindow_c + %define SetCursor_c _SetCursor_c + %define SetCursorPos_c _SetCursorPos_c + %define SetRect_c _SetRect_c + %define SetRectEmpty_c _SetRectEmpty_c + %define SetWindowPos_c _SetWindowPos_c + %define ShowCursor_c _ShowCursor_c + %define ShowWindow_c _ShowWindow_c + %define UnregisterClassA_c _UnregisterClassA_c + %define wsprintfA2_c _wsprintfA2_c +%endif + +extern ClientToScreen_c +extern ClipCursor_c +extern CreateWindowExA_c +extern GetActiveWindow_c +extern GetCursorPos_c +extern GetDC_c +extern GetWindowRect_c +extern IsIconic_c +extern IsWindowVisible_c +extern LoadCursorA_c +extern LoadStringA_c +extern MessageBoxA_c +extern MoveWindow_c +extern ReleaseCapture_c +extern ReleaseDC_c +extern ScreenToClient_c +extern SendMessageA_c +extern SetActiveWindow_c +extern SetCursor_c +extern SetCursorPos_c +extern SetRect_c +extern SetRectEmpty_c +extern SetWindowPos_c +extern ShowCursor_c +extern ShowWindow_c +extern UnregisterClassA_c +extern wsprintfA2_c + +global ClientToScreen_asm2c +global ClipCursor_asm2c +global CreateWindowExA_asm2c +global GetActiveWindow_asm2c +global GetCursorPos_asm2c +global GetDC_asm2c +global GetWindowRect_asm2c +global IsIconic_asm2c +global IsWindowVisible_asm2c +global LoadCursorA_asm2c +global LoadStringA_asm2c +global MessageBoxA_asm2c +global MoveWindow_asm2c +global ReleaseCapture_asm2c +global ReleaseDC_asm2c +global ScreenToClient_asm2c +global SendMessageA_asm2c +global SetActiveWindow_asm2c +global SetCursor_asm2c +global SetCursorPos_asm2c +global SetRect_asm2c +global SetRectEmpty_asm2c +global SetWindowPos_asm2c +global ShowCursor_asm2c +global ShowWindow_asm2c +global UnregisterClassA_asm2c +global wsprintfA_asm2c + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +ClientToScreen_asm2c: + +; [esp + 2*4] = LPPOINT lpPoint +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack2 ClientToScreen_c + + retn 2*4 + +; end procedure ClientToScreen_asm2c + + +align 16 +ClipCursor_asm2c: + +; [esp + 4] = CONST RECT * lpRect +; [esp ] = return address + + Call_Asm_Stack1 ClipCursor_c + + retn 1*4 + +; end procedure ClipCursor_asm2c + + +align 16 +CreateWindowExA_asm2c: + +; [esp + 12*4] = LPVOID lpParam +; [esp + 11*4] = HINSTANCE hInstance +; [esp + 10*4] = HMENU hMenu +; [esp + 9*4] = HWND hWndParent +; [esp + 8*4] = int nHeight +; [esp + 7*4] = int nWidth +; [esp + 6*4] = int Y +; [esp + 5*4] = int X +; [esp + 4*4] = DWORD dwStyle +; [esp + 3*4] = LPCSTR lpWindowName +; [esp + 2*4] = LPCSTR lpClassName +; [esp + 4] = DWORD dwExStyle +; [esp ] = return address + + Call_Asm_Stack12 CreateWindowExA_c + + retn 12*4 + +; end procedure CreateWindowExA_asm2c + + +align 16 +GetActiveWindow_asm2c: + +; [esp ] = return address + + Call_Asm_Stack0 GetActiveWindow_c + + retn + +; end procedure GetActiveWindow_asm2c + + +align 16 +GetCursorPos_asm2c: + +; [esp + 4] = LPPOINT lpPoint +; [esp ] = return address + + Call_Asm_Stack1 GetCursorPos_c + + retn 1*4 + +; end procedure GetCursorPos_asm2c + + +align 16 +GetDC_asm2c: + +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack1 GetDC_c + + retn 1*4 + +; end procedure GetDC_asm2c + + +align 16 +GetWindowRect_asm2c: + +; [esp + 2*4] = LPRECT lpRect +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack2 GetWindowRect_c + + retn 2*4 + +; end procedure GetWindowRect_asm2c + + +align 16 +IsIconic_asm2c: + +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack1 IsIconic_c + + retn 1*4 + +; end procedure IsIconic_asm2c + + +align 16 +IsWindowVisible_asm2c: + +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack1 IsWindowVisible_c + + retn 1*4 + +; end procedure IsWindowVisible_asm2c + + +align 16 +LoadCursorA_asm2c: + +; [esp + 2*4] = LPCSTR lpCursorName +; [esp + 4] = HINSTANCE hInstance +; [esp ] = return address + + Call_Asm_Stack2 LoadCursorA_c + + retn 2*4 + +; end procedure LoadCursorA_asm2c + + +align 16 +LoadStringA_asm2c: + +; [esp + 4*4] = int cchBufferMax +; [esp + 3*4] = LPSTR lpBuffer +; [esp + 2*4] = UINT uID +; [esp + 4] = HINSTANCE hInstance +; [esp ] = return address + + Call_Asm_Stack4 LoadStringA_c + + retn 4*4 + +; end procedure LoadStringA_asm2c + + +align 16 +MessageBoxA_asm2c: + +; [esp + 4*4] = UINT uType +; [esp + 3*4] = LPCSTR lpCaption +; [esp + 2*4] = LPCSTR lpText +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack4 MessageBoxA_c + + retn 4*4 + +; end procedure MessageBoxA_asm2c + + +align 16 +MoveWindow_asm2c: + +; [esp + 6*4] = WINBOOL bRepaint +; [esp + 5*4] = int nHeight +; [esp + 4*4] = int nWidth +; [esp + 3*4] = int Y +; [esp + 2*4] = int X +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack6 MoveWindow_c + + retn 6*4 + +; end procedure MoveWindow_asm2c + + +align 16 +ReleaseCapture_asm2c: + +; [esp ] = return address + + Call_Asm_Stack0 ReleaseCapture_c + + retn + +; end procedure ReleaseCapture_asm2c + + +align 16 +ReleaseDC_asm2c: + +; [esp + 2*4] = HDC hDC +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack2 ReleaseDC_c + + retn 2*4 + +; end procedure ReleaseDC_asm2c + + +align 16 +ScreenToClient_asm2c: + +; [esp + 2*4] = LPPOINT lpPoint +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack2 ScreenToClient_c + + retn 2*4 + +; end procedure ScreenToClient_asm2c + + +align 16 +SendMessageA_asm2c: + +; [esp + 4*4] = LPARAM lParam +; [esp + 3*4] = WPARAM wParam +; [esp + 2*4] = UINT Msg +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack4 SendMessageA_c + + retn 4*4 + +; end procedure SendMessageA_asm2c + + +align 16 +SetActiveWindow_asm2c: + +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack1 SetActiveWindow_c + + retn 1*4 + +; end procedure SetActiveWindow_asm2c + + +align 16 +SetCursor_asm2c: + +; [esp + 4] = HCURSOR hCursor +; [esp ] = return address + + Call_Asm_Stack1 SetCursor_c + + retn 1*4 + +; end procedure SetCursor_asm2c + + +align 16 +SetCursorPos_asm2c: + +; [esp + 2*4] = int Y +; [esp + 4] = int X +; [esp ] = return address + + Call_Asm_Stack2 SetCursorPos_c + + retn 2*4 + +; end procedure SetCursorPos_asm2c + + +align 16 +SetRect_asm2c: + +; [esp + 5*4] = int yBottom +; [esp + 4*4] = int xRight +; [esp + 3*4] = int yTop +; [esp + 2*4] = int xLeft +; [esp + 4] = LPRECT lprc +; [esp ] = return address + + Call_Asm_Stack5 SetRect_c + + retn 5*4 + +; end procedure SetRect_asm2c + + +align 16 +SetRectEmpty_asm2c: + +; [esp + 4] = LPRECT lprc +; [esp ] = return address + + Call_Asm_Stack1 SetRectEmpty_c + + retn 1*4 + +; end procedure SetRectEmpty_asm2c + + +align 16 +SetWindowPos_asm2c: + +; [esp + 7*4] = UINT uFlags +; [esp + 6*4] = int cy +; [esp + 5*4] = int cx +; [esp + 4*4] = int Y +; [esp + 3*4] = int X +; [esp + 2*4] = HWND hWndInsertAfter +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack7 SetWindowPos_c + + retn 7*4 + +; end procedure SetWindowPos_asm2c + + +align 16 +ShowCursor_asm2c: + +; [esp + 4] = WINBOOL bShow +; [esp ] = return address + + Call_Asm_Stack1 ShowCursor_c + + retn 1*4 + +; end procedure ShowCursor_asm2c + + +align 16 +ShowWindow_asm2c: + +; [esp + 2*4] = int nCmdShow +; [esp + 4] = HWND hWnd +; [esp ] = return address + + Call_Asm_Stack2 ShowWindow_c + + retn 2*4 + +; end procedure ShowWindow_asm2c + + +align 16 +UnregisterClassA_asm2c: + +; [esp + 2*4] = HINSTANCE hInstance +; [esp + 4] = LPCSTR lpClassName +; [esp ] = return address + + Call_Asm_Stack2 UnregisterClassA_c + + retn 2*4 + +; end procedure UnregisterClassA_asm2c + + +align 16 +wsprintfA_asm2c: + +; [esp + 3*4] = ... +; [esp + 2*4] = LPCSTR param2 +; [esp + 4] = LPSTR param1 +; [esp ] = return address + + Call_Asm_VariableStack2 wsprintfA2_c + + retn + +; end procedure wsprintfA_asm2c + + diff --git a/games/Battle Isle 3/SR-BI3/x86/WinApi-winmm-asm.asm b/games/Battle Isle 3/SR-BI3/x86/WinApi-winmm-asm.asm new file mode 100644 index 0000000..b5a8340 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/WinApi-winmm-asm.asm @@ -0,0 +1,73 @@ +;; +;; Copyright (C) 2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%include "asm-calls.inc" + +%ifidn __OUTPUT_FORMAT__, win32 + %define mciGetErrorStringA_c _mciGetErrorStringA_c + %define mciSendCommandA_c _mciSendCommandA_c +%endif + +extern mciGetErrorStringA_c +extern mciSendCommandA_c + +global mciGetErrorStringA_asm2c +global mciSendCommandA_asm2c + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +mciGetErrorStringA_asm2c: + +; [esp + 3*4] = UINT cchText +; [esp + 2*4] = LPSTR pszText +; [esp + 4] = MCIERROR mcierr +; [esp ] = return address + + Call_Asm_Stack3 mciGetErrorStringA_c + + retn 3*4 + +; end procedure mciGetErrorStringA_asm2c + + +align 16 +mciSendCommandA_asm2c: + +; [esp + 4*4] = DWORD_PTR dwParam2 +; [esp + 3*4] = DWORD_PTR dwParam1 +; [esp + 2*4] = UINT uMsg +; [esp + 4] = MCIDEVICEID mciId +; [esp ] = return address + + Call_Asm_Stack4 mciSendCommandA_c + + retn 4*4 + +; end procedure mciSendCommandA_asm2c + + diff --git a/games/Battle Isle 3/SR-BI3/x86/X86_FS_mem.c b/games/Battle Isle 3/SR-BI3/x86/X86_FS_mem.c new file mode 100644 index 0000000..4e73a63 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/X86_FS_mem.c @@ -0,0 +1,52 @@ +/** + * + * Copyright (C) 2021 Roman Pauer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include +#define WIN32_LEAN_AND_MEAN +#include + +void X86_InitializeExceptions(void) +{ + // do nothing +} + + +uint32_t X86_ReadFsDword(uint32_t addr) +{ + uint32_t *address; + + address = (uint32_t *) (addr + (uintptr_t)NtCurrentTeb()); + + return *address; +} + +void X86_WriteFsDword(uint32_t addr, uint32_t value) +{ + uint32_t *address; + + address = (uint32_t *) (addr + (uintptr_t)NtCurrentTeb()); + + *address = value; +} + diff --git a/games/Battle Isle 3/SR-BI3/x86/asm-calls.inc b/games/Battle Isle 3/SR-BI3/x86/asm-calls.inc new file mode 100644 index 0000000..66663f3 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/asm-calls.inc @@ -0,0 +1,554 @@ +;; +;; Copyright (C) 2019-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%macro Call_Asm_Float1_Int 1 + +; st0 = num +; [esp] = return address + + ; remember original esp value + mov eax, esp + ; reserve 16 bytes on stack + sub esp, byte 16 + ; align stack to 16 bytes + and esp, 0FFFFFFF0h + + mov [esp + 4], eax + lea eax, [esp + 8] + fstp qword [eax] + mov [esp], eax + ; stack is aligned to 16 bytes + + call %1 + + ; restore original esp value from stack + mov esp, [esp + 4] + +%endmacro + +%macro Call_Asm_Float1_Float 1 + +; st0 = num +; [esp] = return address + + ; remember original esp value + mov eax, esp + ; reserve 16 bytes on stack + sub esp, byte 16 + ; align stack to 16 bytes + and esp, 0FFFFFFF0h + + mov [esp + 4], eax + lea eax, [esp + 8] + fstp qword [eax] + mov [esp], eax + ; stack is aligned to 16 bytes + + call %1 + + fld qword [esp+8] + + ; restore original esp value from stack + mov esp, [esp + 4] + +%endmacro + +%macro Call_Asm_Float2_Float 1 + +; st1 = num2 +; st0 = num1 +; [esp] = return address + + ; remember original esp value + mov eax, esp + ; reserve 24 bytes on stack + sub esp, byte 24 + ; align stack to 16 bytes + and esp, 0FFFFFFF0h + + mov [esp + 4], eax + lea eax, [esp + 8] + fstp qword [eax] + fstp qword [eax + 8] + mov [esp], eax + ; stack is aligned to 16 bytes + + call %1 + + fld qword [esp+8] + + ; restore original esp value from stack + mov esp, [esp + 4] + +%endmacro + +%macro Call_Asm_VariableStack1 1 + +; [esp + 2*4] = ... +; [esp + 4] = 1st parameter +; [esp ] = return address + + ; remember original esp value + mov eax, esp + ; reserve 12 bytes on stack + sub esp, byte 12 + ; align stack to 16 bytes + and esp, 0FFFFFFF0h + ; save original esp value on stack + mov [esp + 2*4], eax + ; adjust stack for function arguments, so that stack is aligned to 16 bytes before call + add esp, byte 8 + + ; push function arguments to stack + lea ecx, [eax + 2*4] + push ecx + push dword [eax + 4] + ; stack is aligned to 16 bytes + + call %1 + + ; restore original esp value from stack + mov esp, [esp + 2*4] + +%endmacro + +%macro Call_Asm_VariableStack2 1 + +; [esp + 3*4] = ... +; [esp + 2*4] = 2nd parameter +; [esp + 4] = 1st parameter +; [esp ] = return address + + ; remember original esp value + mov eax, esp + ; align stack to 16 bytes + and esp, 0FFFFFFF0h + ; save original esp value on stack + push eax + + ; push function arguments to stack + lea ecx, [eax + 3*4] + push ecx + push dword [eax + 2*4] + push dword [eax + 4] + ; stack is aligned to 16 bytes + + call %1 + + ; restore original esp value from stack + mov esp, [esp + 3*4] + +%endmacro + +%macro Call_Asm_Stack0 1 + +; [esp ] = return address + + ; remember original esp value + mov eax, esp + ; reserve 4 bytes on stack + sub esp, byte 4 + ; align stack to 16 bytes + and esp, 0FFFFFFF0h + ; save original esp value on stack + mov [esp], eax + + ; stack is aligned to 16 bytes + + call %1 + + ; restore original esp value from stack + mov esp, [esp] + +%endmacro + +%macro Call_Asm_Stack1 1 + +; [esp + 4] = 1st parameter +; [esp ] = return address + + ; remember original esp value + mov eax, esp + ; reserve 8 bytes on stack + sub esp, byte 8 + ; align stack to 16 bytes + and esp, 0FFFFFFF0h + ; save original esp value on stack + mov [esp + 1*4], eax + ; adjust stack for function argument, so that stack is aligned to 16 bytes before call + add esp, byte 4 + + ; push function arguments to stack + push dword [eax + 4] + ; stack is aligned to 16 bytes + + call %1 + + ; restore original esp value from stack + mov esp, [esp + 1*4] + +%endmacro + +%macro Call_Asm_Stack2 1 + +; [esp + 2*4] = 2nd parameter +; [esp + 4] = 1st parameter +; [esp ] = return address + + ; remember original esp value + mov eax, esp + ; reserve 12 bytes on stack + sub esp, byte 12 + ; align stack to 16 bytes + and esp, 0FFFFFFF0h + ; save original esp value on stack + mov [esp + 2*4], eax + ; adjust stack for function arguments, so that stack is aligned to 16 bytes before call + add esp, byte 8 + + ; push function arguments to stack + push dword [eax + 2*4] + push dword [eax + 4] + ; stack is aligned to 16 bytes + + call %1 + + ; restore original esp value from stack + mov esp, [esp + 2*4] + +%endmacro + +%macro Call_Asm_Stack3 1 + +; [esp + 3*4] = 3rd parameter +; ... +; [esp + 4] = 1st parameter +; [esp ] = return address + + ; remember original esp value + mov eax, esp + ; align stack to 16 bytes + and esp, 0FFFFFFF0h + ; save original esp value on stack + push eax + + ; push function arguments to stack + push dword [eax + 3*4] + push dword [eax + 2*4] + push dword [eax + 4] + ; stack is aligned to 16 bytes + + call %1 + + ; restore original esp value from stack + mov esp, [esp + 3*4] + +%endmacro + +%macro Call_Asm_Stack4 1 + +; [esp + 4*4] = 4th parameter +; ... +; [esp + 4] = 1st parameter +; [esp ] = return address + + ; remember original esp value + mov eax, esp + ; reserve 4 bytes on stack + sub esp, byte 4 + ; align stack to 16 bytes + and esp, 0FFFFFFF0h + ; save original esp value on stack + mov [esp], eax + + ; push function arguments to stack + ; stack is aligned to 16 bytes + push dword [eax + 4*4] + push dword [eax + 3*4] + push dword [eax + 2*4] + push dword [eax + 4] + ; stack is aligned to 16 bytes + + call %1 + + ; restore original esp value from stack + mov esp, [esp + 4*4] + +%endmacro + +%macro Call_Asm_Stack5 1 + +; [esp + 5*4] = 5th parameter +; ... +; [esp + 4] = 1st parameter +; [esp ] = return address + + ; remember original esp value + mov eax, esp + ; reserve 8 bytes on stack + sub esp, byte 8 + ; align stack to 16 bytes + and esp, 0FFFFFFF0h + ; save original esp value on stack + mov [esp + 1*4], eax + ; adjust stack for function argument, so that stack is aligned to 16 bytes before call + add esp, byte 4 + + ; push function arguments to stack + push dword [eax + 5*4] + ; stack is aligned to 16 bytes + push dword [eax + 4*4] + push dword [eax + 3*4] + push dword [eax + 2*4] + push dword [eax + 4] + ; stack is aligned to 16 bytes + + call %1 + + ; restore original esp value from stack + mov esp, [esp + 5*4] + +%endmacro + +%macro Call_Asm_Stack6 1 + +; [esp + 6*4] = 6th parameter +; ... +; [esp + 4] = 1st parameter +; [esp ] = return address + + ; remember original esp value + mov eax, esp + ; reserve 12 bytes on stack + sub esp, byte 12 + ; align stack to 16 bytes + and esp, 0FFFFFFF0h + ; save original esp value on stack + mov [esp + 2*4], eax + ; adjust stack for function arguments, so that stack is aligned to 16 bytes before call + add esp, byte 8 + + ; push function arguments to stack + push dword [eax + 6*4] + push dword [eax + 5*4] + ; stack is aligned to 16 bytes + push dword [eax + 4*4] + push dword [eax + 3*4] + push dword [eax + 2*4] + push dword [eax + 4] + ; stack is aligned to 16 bytes + + call %1 + + ; restore original esp value from stack + mov esp, [esp + 6*4] + +%endmacro + +%macro Call_Asm_Stack7 1 + +; [esp + 7*4] = 7th parameter +; ... +; [esp + 4] = 1st parameter +; [esp ] = return address + + ; remember original esp value + mov eax, esp + ; align stack to 16 bytes + and esp, 0FFFFFFF0h + ; save original esp value on stack + push eax + + ; push function arguments to stack + push dword [eax + 7*4] + push dword [eax + 6*4] + push dword [eax + 5*4] + ; stack is aligned to 16 bytes + push dword [eax + 4*4] + push dword [eax + 3*4] + push dword [eax + 2*4] + push dword [eax + 4] + ; stack is aligned to 16 bytes + + call %1 + + ; restore original esp value from stack + mov esp, [esp + 7*4] + +%endmacro + +%macro Call_Asm_Stack8 1 + +; [esp + 8*4] = 8th parameter +; ... +; [esp + 4] = 1st parameter +; [esp ] = return address + + ; remember original esp value + mov eax, esp + ; reserve 4 bytes on stack + sub esp, byte 4 + ; align stack to 16 bytes + and esp, 0FFFFFFF0h + ; save original esp value on stack + mov [esp], eax + + ; push function arguments to stack + ; stack is aligned to 16 bytes + push dword [eax + 8*4] + push dword [eax + 7*4] + push dword [eax + 6*4] + push dword [eax + 5*4] + ; stack is aligned to 16 bytes + push dword [eax + 4*4] + push dword [eax + 3*4] + push dword [eax + 2*4] + push dword [eax + 4] + ; stack is aligned to 16 bytes + + call %1 + + ; restore original esp value from stack + mov esp, [esp + 8*4] + +%endmacro + +%macro Call_Asm_Stack9 1 + +; [esp + 9*4] = 9th parameter +; ... +; [esp + 4] = 1st parameter +; [esp ] = return address + + ; remember original esp value + mov eax, esp + ; reserve 8 bytes on stack + sub esp, byte 8 + ; align stack to 16 bytes + and esp, 0FFFFFFF0h + ; save original esp value on stack + mov [esp + 1*4], eax + ; adjust stack for function argument, so that stack is aligned to 16 bytes before call + add esp, byte 4 + + ; push function arguments to stack + push dword [eax + 9*4] + ; stack is aligned to 16 bytes + push dword [eax + 8*4] + push dword [eax + 7*4] + push dword [eax + 6*4] + push dword [eax + 5*4] + ; stack is aligned to 16 bytes + push dword [eax + 4*4] + push dword [eax + 3*4] + push dword [eax + 2*4] + push dword [eax + 4] + ; stack is aligned to 16 bytes + + call %1 + + ; restore original esp value from stack + mov esp, [esp + 9*4] + +%endmacro + +%macro Call_Asm_Stack10 1 + +; [esp + 10*4] = 10th parameter +; ... +; [esp + 4] = 1st parameter +; [esp ] = return address + + ; remember original esp value + mov eax, esp + ; reserve 12 bytes on stack + sub esp, byte 12 + ; align stack to 16 bytes + and esp, 0FFFFFFF0h + ; save original esp value on stack + mov [esp + 2*4], eax + ; adjust stack for function arguments, so that stack is aligned to 16 bytes before call + add esp, byte 8 + + ; push function arguments to stack + push dword [eax + 10*4] + push dword [eax + 9*4] + ; stack is aligned to 16 bytes + push dword [eax + 8*4] + push dword [eax + 7*4] + push dword [eax + 6*4] + push dword [eax + 5*4] + ; stack is aligned to 16 bytes + push dword [eax + 4*4] + push dword [eax + 3*4] + push dword [eax + 2*4] + push dword [eax + 4] + ; stack is aligned to 16 bytes + + call %1 + + ; restore original esp value from stack + mov esp, [esp + 10*4] + +%endmacro + +%macro Call_Asm_Stack12 1 + +; [esp + 12*4] = 12th parameter +; ... +; [esp + 4] = 1st parameter +; [esp ] = return address + + ; remember original esp value + mov eax, esp + ; reserve 4 bytes on stack + sub esp, byte 4 + ; align stack to 16 bytes + and esp, 0FFFFFFF0h + ; save original esp value on stack + mov [esp], eax + + ; push function arguments to stack + ; stack is aligned to 16 bytes + push dword [eax + 12*4] + push dword [eax + 11*4] + push dword [eax + 10*4] + push dword [eax + 9*4] + ; stack is aligned to 16 bytes + push dword [eax + 8*4] + push dword [eax + 7*4] + push dword [eax + 6*4] + push dword [eax + 5*4] + ; stack is aligned to 16 bytes + push dword [eax + 4*4] + push dword [eax + 3*4] + push dword [eax + 2*4] + push dword [eax + 4] + ; stack is aligned to 16 bytes + + call %1 + + ; restore original esp value from stack + mov esp, [esp + 12*4] + +%endmacro + diff --git a/games/Battle Isle 3/SR-BI3/x86/asm_fs_mem.asm b/games/Battle Isle 3/SR-BI3/x86/asm_fs_mem.asm new file mode 100644 index 0000000..5e46dfc --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/asm_fs_mem.asm @@ -0,0 +1,134 @@ +;part of static recompiler -- do not edit + +;; +;; Copyright (C) 2019 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%ifidn __OUTPUT_FORMAT__, win32 + %define X86_ReadFsDword _X86_ReadFsDword + %define X86_WriteFsDword _X86_WriteFsDword +%endif + +extern X86_ReadFsDword +extern X86_WriteFsDword + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +global x86_read_fs_dword +global x86_write_fs_dword + +align 16 +x86_read_fs_dword: + +; [esp + 4] = uint32_t addr +; [esp ] = return address + + pushfd + push eax + push ecx + push edx + +; [esp + 5*4] = uint32_t addr +; [esp 4*4] = return address + + ; remember original esp value + mov eax, esp + ; align stack to 16 bytes + and esp, 0FFFFFFF0h + ; save original esp value on stack + push eax + ; add dummy values to stack, so that stack is aligned to 16 bytes before call + sub esp, byte 2*4 + + ; push function arguments to stack + push dword [eax + 5*4] + ; stack is aligned to 16 bytes + + call X86_ReadFsDword + + ; restore original esp value from stack + mov esp, [esp + 3*4] + + mov [esp + 5*4], eax + +; [esp + 5*4] = uint32_t value +; [esp 4*4] = return address + + pop edx + pop ecx + pop eax + popfd + + retn + +; end procedure x86_read_fs_dword + + +align 16 +x86_write_fs_dword: + +; [esp + 2*4] = uint32_t value +; [esp + 4] = uint32_t addr +; [esp ] = return address + + pushfd + push eax + push ecx + push edx + +; [esp + 6*4] = uint32_t value +; [esp + 5*4] = uint32_t addr +; [esp + 4*4] = return address + + ; remember original esp value + mov eax, esp + ; align stack to 16 bytes + and esp, 0FFFFFFF0h + ; save original esp value on stack + push eax + ; add dummy values to stack, so that stack is aligned to 16 bytes before call + sub esp, byte 4 + + ; push function arguments to stack + push dword [eax + 6*4] + push dword [eax + 5*4] + ; stack is aligned to 16 bytes + + call X86_WriteFsDword + + ; restore original esp value from stack + mov esp, [esp + 3*4] + + pop edx + pop ecx + pop eax + popfd + + retn 2*4 + +; end procedure x86_write_fs_dword + + diff --git a/games/Battle Isle 3/SR-BI3/x86/main-asm.asm b/games/Battle Isle 3/SR-BI3/x86/main-asm.asm new file mode 100644 index 0000000..842c32c --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/main-asm.asm @@ -0,0 +1,55 @@ +;; +;; Copyright (C) 2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +extern WinMain_ + +global WinMain_asm +global _WinMain_asm + +%ifidn __OUTPUT_FORMAT__, elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +section .text progbits alloc exec nowrite align=16 +%else +section .text code align=16 +%endif + +align 16 +WinMain_asm: +_WinMain_asm: + +; [esp + 4*4] = int nCmdShow +; [esp + 3*4] = char *lpCmdLine +; [esp + 2*4] = void *hPrevInstance +; [esp + 4] = void *hInstance +; [esp ] = return address + + push dword [esp + 4*4] + push dword [esp + 4*4] + push dword [esp + 4*4] + push dword [esp + 4*4] + + call WinMain_ + + retn + +; end procedure WinMain_asm + diff --git a/games/Battle Isle 3/SR-BI3/x86/misc.inc b/games/Battle Isle 3/SR-BI3/x86/misc.inc new file mode 100644 index 0000000..7099e3b --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/misc.inc @@ -0,0 +1,25 @@ +;; +;; Copyright (C) 2016 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%define tbyte tword + +%define NDEBUG diff --git a/games/Battle Isle 3/SR-BI3/x86/ms_figtr/SConscript b/games/Battle Isle 3/SR-BI3/x86/ms_figtr/SConscript new file mode 100644 index 0000000..308690f --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/ms_figtr/SConscript @@ -0,0 +1,53 @@ +# +# Copyright (C) 2019-2021 Roman Pauer +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +import re + +Import('device') + +include_re = re.compile(r'^%include\s+"(\S+)"\r?$', re.M) + +def nasmfile_scan(node, env, path): + contents = node.get_text_contents() + includes = include_re.findall(contents) + includes2 = [] + for include in includes: + if not node.File(include).exists() and node.File("../" + include).exists(): + includes2.append("../" + include) + else: + includes2.append(include) + return includes2 + +nasmscan = Scanner(function = nasmfile_scan, + skeys = ['.asm'], + recursive = True) + +SourceFileScanner.add_scanner('.asm', nasmscan) + +if device == 'pc-linux': + env2 = Environment(tools=['nasm'], ASFLAGS = ' -felf32 -O1 -w+orphan-labels -w-number-overflow -ix86/ms_figtr/ -ix86/') +else: + env2 = Environment(tools=['nasm'], ASFLAGS = ' -fwin32 -O1 -w+orphan-labels -w-number-overflow -ix86/ms_figtr/ -ix86/') + +obj = env2.Object('MS_FIGTR.asm') + +Return('obj') diff --git a/games/Battle Isle 3/SR-BI3/x86/ms_figtr/extern.inc b/games/Battle Isle 3/SR-BI3/x86/ms_figtr/extern.inc new file mode 100644 index 0000000..e6c179e --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/ms_figtr/extern.inc @@ -0,0 +1,33 @@ +;; +;; Copyright (C) 2019-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +extern ms_strcpy_asm2c +extern ms_strlen_asm2c +extern ms_memcpy_asm2c +extern ms_memset_asm2c +extern ms__ftol_asm2c +extern ms__ltoa_asm2c + +extern __Fight + +extern FGT_SystemTask_End_asm2c +extern FGT_CheckTicksDelay_asm2c diff --git a/games/Battle Isle 3/SR-BI3/x86/sdi_1r/SConscript b/games/Battle Isle 3/SR-BI3/x86/sdi_1r/SConscript new file mode 100644 index 0000000..59b97ec --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/sdi_1r/SConscript @@ -0,0 +1,53 @@ +# +# Copyright (C) 2019-2021 Roman Pauer +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +import re + +Import('device') + +include_re = re.compile(r'^%include\s+"(\S+)"\r?$', re.M) + +def nasmfile_scan(node, env, path): + contents = node.get_text_contents() + includes = include_re.findall(contents) + includes2 = [] + for include in includes: + if not node.File(include).exists() and node.File("../" + include).exists(): + includes2.append("../" + include) + else: + includes2.append(include) + return includes2 + +nasmscan = Scanner(function = nasmfile_scan, + skeys = ['.asm'], + recursive = True) + +SourceFileScanner.add_scanner('.asm', nasmscan) + +if device == 'pc-linux': + env2 = Environment(tools=['nasm'], ASFLAGS = ' -felf32 -O1 -w+orphan-labels -w-number-overflow -ix86/sdi_1r/ -ix86/') +else: + env2 = Environment(tools=['nasm'], ASFLAGS = ' -fwin32 -O1 -w+orphan-labels -w-number-overflow -ix86/sdi_1r/ -ix86/') + +obj = env2.Object('SDI_1R.asm') + +Return('obj') diff --git a/games/Battle Isle 3/SR-BI3/x86/sdi_1r/extern.inc b/games/Battle Isle 3/SR-BI3/x86/sdi_1r/extern.inc new file mode 100644 index 0000000..b668abd --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/sdi_1r/extern.inc @@ -0,0 +1,140 @@ +;; +;; Copyright (C) 2019-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +%ifidn __OUTPUT_FORMAT__, win32 + %define Intro_Play _Intro_Play + %define Outro_Play _Outro_Play +%endif + +extern ms_strlen_asm2c +extern ms_strcat_asm2c +extern ms_strcpy_asm2c +extern ms_atol_asm2c +extern ms_atoi_asm2c +extern ms_printf_asm2c +extern ms_strncpy_asm2c +extern ms_strcmp_asm2c +extern ms_memcpy_asm2c +extern ms__ftol_asm2c +extern ms_memset_asm2c +extern ms_memcmp_asm2c +extern ms_srand_asm2c +extern ms_rand_asm2c +extern ms__alloca_probe_asm2c +extern ms_strstr_asm2c +extern ms_isalnum_asm2c +extern ms__strnicmp_asm2c +extern ms__ltoa_asm2c + +extern ms__except_handler3_asm2c + +extern SDI_CheckTicksDelay_asm2c + +extern midi_OpenSDIMusic_asm2c +extern midi_GetSDIMusicID_asm2c +extern midi_PlaySDIMusic_asm2c +extern midi_CloseSDIMusic_asm2c +extern midi_IsPlaying_asm2c +extern midi_OpenTestMusic_asm2c +extern midi_PlayTestMusic_asm2c +extern midi_CloseTestMusic_asm2c +extern midi_GetErrorString_asm2c + +extern cmdline_ContainsOption_asm2c +extern cmdline_ReadLanguageOption_asm2c + +extern video_RegisterClass_PRE_Video_asm2c +extern video_Open_PRE_Video_asm2c +extern video_Close_PRE_Video_asm2c +extern video_Play_PRE_Video_asm2c +extern video_RegisterClass_POST_Video_asm2c +extern video_Open_POST_Video_asm2c +extern video_Close_POST_Video_asm2c +extern video_Play_POST_Video_asm2c +extern video_RegisterClass_SS_Video_asm2c + +extern sync_asm2c + +extern Intro_Play +extern Outro_Play + + +; gdi32.dll +%define CreateFontIndirectA CreateFontIndirectA_asm2c +%define DeleteObject DeleteObject_asm2c +%define GdiFlush GdiFlush_asm2c +%define GetDeviceCaps GetDeviceCaps_asm2c +%define GetTextExtentPointA GetTextExtentPointA_asm2c +%define SelectObject SelectObject_asm2c +%define SetBkMode SetBkMode_asm2c +%define TextOutA TextOutA_asm2c + +; kernel32.dll +%define CloseHandle CloseHandle_asm2c +%define CreateFileA CreateFileA_asm2c +%define FindClose FindClose_asm2c +%define FindFirstFileA FindFirstFileA_asm2c +%define FindNextFileA FindNextFileA_asm2c +%define GetCurrentDirectoryA GetCurrentDirectoryA_asm2c +%define GetPrivateProfileIntA GetPrivateProfileIntA_asm2c +%define GetPrivateProfileStringA GetPrivateProfileStringA_asm2c +%define GetTickCount GetTickCount_asm2c +%define GlobalMemoryStatus GlobalMemoryStatus_asm2c +%define ReadFile ReadFile_asm2c +%define SetCurrentDirectoryA SetCurrentDirectoryA_asm2c +%define SetFilePointer SetFilePointer_asm2c +%define WriteFile WriteFile_asm2c +%define WritePrivateProfileStringA WritePrivateProfileStringA_asm2c + +; user32.dll +%define ClientToScreen ClientToScreen_asm2c +%define ClipCursor ClipCursor_asm2c +%define CreateWindowExA CreateWindowExA_asm2c +%define GetActiveWindow GetActiveWindow_asm2c +%define GetCursorPos GetCursorPos_asm2c +%define GetDC GetDC_asm2c +%define GetWindowRect GetWindowRect_asm2c +%define IsIconic IsIconic_asm2c +%define IsWindowVisible IsWindowVisible_asm2c +%define LoadCursorA LoadCursorA_asm2c +%define LoadStringA LoadStringA_asm2c +%define MessageBoxA MessageBoxA_asm2c +%define MoveWindow MoveWindow_asm2c +%define ReleaseCapture ReleaseCapture_asm2c +%define ReleaseDC ReleaseDC_asm2c +%define ScreenToClient ScreenToClient_asm2c +%define SendMessageA SendMessageA_asm2c +%define SetActiveWindow SetActiveWindow_asm2c +%define SetCursor SetCursor_asm2c +%define SetCursorPos SetCursorPos_asm2c +%define SetRect SetRect_asm2c +%define SetRectEmpty SetRectEmpty_asm2c +%define SetWindowPos SetWindowPos_asm2c +%define ShowCursor ShowCursor_asm2c +%define ShowWindow ShowWindow_asm2c +%define UnregisterClassA UnregisterClassA_asm2c +%define wsprintfA wsprintfA_asm2c + +; winmm.dll +%define mciGetErrorStringA mciGetErrorStringA_asm2c +%define mciSendCommandA mciSendCommandA_asm2c + diff --git a/games/Battle Isle 3/SR-BI3/x86/wc_figtr/SConscript b/games/Battle Isle 3/SR-BI3/x86/wc_figtr/SConscript new file mode 100644 index 0000000..5b01696 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/wc_figtr/SConscript @@ -0,0 +1,53 @@ +# +# Copyright (C) 2019-2021 Roman Pauer +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +import re + +Import('device') + +include_re = re.compile(r'^%include\s+"(\S+)"\r?$', re.M) + +def nasmfile_scan(node, env, path): + contents = node.get_text_contents() + includes = include_re.findall(contents) + includes2 = [] + for include in includes: + if not node.File(include).exists() and node.File("../" + include).exists(): + includes2.append("../" + include) + else: + includes2.append(include) + return includes2 + +nasmscan = Scanner(function = nasmfile_scan, + skeys = ['.asm'], + recursive = True) + +SourceFileScanner.add_scanner('.asm', nasmscan) + +if device == 'pc-linux': + env2 = Environment(tools=['nasm'], ASFLAGS = ' -felf32 -O1 -w+orphan-labels -w-number-overflow -ix86/wc_figtr/ -ix86/') +else: + env2 = Environment(tools=['nasm'], ASFLAGS = ' -fwin32 -O1 -w+orphan-labels -w-number-overflow -ix86/wc_figtr/ -ix86/') + +obj = env2.Object('WC_FIGTR.asm') + +Return('obj') diff --git a/games/Battle Isle 3/SR-BI3/x86/wc_figtr/extern.inc b/games/Battle Isle 3/SR-BI3/x86/wc_figtr/extern.inc new file mode 100644 index 0000000..5d9215b --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/wc_figtr/extern.inc @@ -0,0 +1,29 @@ +;; +;; Copyright (C) 2019-2021 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +extern wc_memset_asm2c +extern wc_strcmp_asm2c +extern wc_strcpy_asm2c +extern wc_sprintf_asm2c +extern wc_rand_asm2c + +extern FGT_CheckTicksDelay_asm2c diff --git a/games/Battle Isle 3/SR-BI3/x86/x86inc.inc b/games/Battle Isle 3/SR-BI3/x86/x86inc.inc new file mode 100644 index 0000000..8768898 --- /dev/null +++ b/games/Battle Isle 3/SR-BI3/x86/x86inc.inc @@ -0,0 +1,26 @@ +;part of static recompiler -- do not edit + +;; +;; Copyright (C) 2019 Roman Pauer +;; +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is furnished to do +;; so, subject to the following conditions: +;; +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. +;; +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. +;; + +extern x86_read_fs_dword +extern x86_write_fs_dword diff --git a/games/Battle Isle 3/release/SDI.INI b/games/Battle Isle 3/release/SDI.INI new file mode 100644 index 0000000..1d7ac46 --- /dev/null +++ b/games/Battle Isle 3/release/SDI.INI @@ -0,0 +1,31 @@ +[FILES] +PATH0= +PATH1= +PATH2= +PATH3= +PATH4= +PATH5= +PATH6= +PATH7= +PATH8= +PATH9= +SDIPATH= +COUNTRY=/1 +[ADVANCED] +REMOTEPATH= +FIRSTTIME=NO +[STARTUP] +VFW_SETUP_PATH=+ +PLAYVIDEO=YES +PLAY_320_200=NO +PLAY_ZOOM=NO +PLAY_BIG=YES +ERROR_311=0 +FIRSTTIME=NO +VIDEOCOMPLETE=YES +USEFX=YES +USEFM=YES +SOUNDCOMPLETE=YES +VIDEOCRASH=No +[WIN32] +WIN32=YES diff --git a/games/Battle Isle 3/release/linux/BI3.cfg b/games/Battle Isle 3/release/linux/BI3.cfg new file mode 100644 index 0000000..d7f2b81 --- /dev/null +++ b/games/Battle Isle 3/release/linux/BI3.cfg @@ -0,0 +1,22 @@ +# Intro/Outro settings +# -------------------- +# +# Intro_Play=yes/no - play intro movies ? - default value is yes +# Outro_Play=yes/no - play outro movies ? - default value is yes + +Intro_Play=yes +Outro_Play=yes + +# Audio settings +# -------------- +# +# Audio_MidiSubsystem=alsa/wildmidi/bassmidi/adlmidi - use ALSA sequencer, WildMIDI, BASSMIDI or ADLMIDI for MIDI playback (ALSA sequencer can use hardware or software synth (like Fluidsynth or TiMidity++). WildMIDI uses GUS patch files for playback. BASSMIDI uses soundfont for playback. ADLMIDI uses OPL3 emulator for playback.) +# Audio_MidiVolume=0-127 - midi volume +# Audio_SoundFont_Path=X - X = path to soundfont file (used by BASSMIDI) +# Audio_MidiDevice=X - X = client name or port (e.g. 128:0) (used by ALSA sequencer) +# Audio_OPL3BankNumber=0-73 - OPL3 bank (uses by ADLMIDI; list of banks: https://github.com/Wohlstand/libADLMIDI/blob/1.3.3/utils/gen_adldata/scrapped.txt) +Audio_MidiSubsystem=adlmidi +Audio_MidiVolume=100 +Audio_SoundFont_Path= +Audio_MidiDevice= +Audio_OPL3BankNumber=59 diff --git a/games/Battle Isle 3/release/linux/BattleIsle3.sh b/games/Battle Isle 3/release/linux/BattleIsle3.sh new file mode 100755 index 0000000..79968f3 --- /dev/null +++ b/games/Battle Isle 3/release/linux/BattleIsle3.sh @@ -0,0 +1,18 @@ +#! /bin/sh +cd "`echo $0 | sed 's/\/[^\/]*$//'`" +export LD_LIBRARY_PATH="`pwd`" +export WINEPREFIX="`pwd`/wine" + +if [ -z "$WINEPREFIX" ] +then + mkdir "$WINEPREFIX" +fi + +# Uncomment and set SDI_INSTALL_PATH to contain path to the directory where the game is installed (in case this file is not inside the directory) +# export SDI_INSTALL_PATH="/path/to/game/install/directory" + +# Uncomment and set SDI_CD_PATH to contain path to the directory where the game CDs are copied (in case it's not in the DATA subdirectory of the directory where the game is installed) +# export SDI_CD_PATH="/path/to/game/cd/directory" + +wine SR-BI3.exe.so +sync diff --git a/games/Battle Isle 3/release/linux/readme-Linux.txt b/games/Battle Isle 3/release/linux/readme-Linux.txt new file mode 100644 index 0000000..ccb2753 --- /dev/null +++ b/games/Battle Isle 3/release/linux/readme-Linux.txt @@ -0,0 +1,64 @@ +Battle Isle 3 for Linux (x86) +Version 1.0.0 + +Original Battle Isle 3 is required for playing. +(version from GOG.com can be used for playing) + +Installation +------------ + +Put files from this archive into the installed game's directory. +The game looks for the CDs in the DATA subdirectory (in installed game's directory). +If you have version from GOG.com, then the CDs are already copied there. +Otherwise you have to create the DATA subdirectory and copy the CDs there. +Alternatively you can copy the CDs elsewhere, but you need to edit the path to them in BattleIsle3.sh. +Run BattleIsle3.sh in the installed game's directory. + + +Music +----- + +The game's MIDI music can be played using one of following libraries: +ALSA sequencer, WildMIDI, BASSMIDI, ADLMIDI + +ADLMIDI is the default library, others can be selected in the configuration file. +ALSA sequencer can use hardware or software synth (like Fluidsynth or TiMidity++). +ADLMIDI requires no additional files for MIDI playback, +WildMIDI requirer GUS patches for MIDI playback, +BASSMIDI requires a soundfont for MIDI playback, +ADLMIDI uses OPL3 emulator for MIDI playback. + +ALSA sequencer can detect usable synth automatically or it can be selected in the configuration file. + +GUS patches can be installed anywhere, but the file timidity.cfg must be +either in the game's directory or in /etc/timidity/timidity.cfg +EawPats is a good sounding set of patches. + +Soundfont (for BASSMIDI) can be either copied to the game's directory +or it can be stored anywhere, but the soundfont location must be written +in the configuration file. + + +Configuration +------------- + +Configuration is stored in the file BI3.cfg. +Paths to games files can be set in the file BattleIsle3.sh. + + +Misc +---- + +The game requires Wine (https://www.winehq.org/) to run. + +The game also requires following 32-bit libraries: quicktime2 +On debian based distributions these libraries are in following packages: libquicktime2:i386 + +Source code is available on GitHub: https://github.com/M-HT/SR + + +Changes +------- + +v1.0.0 (2021-06-27) +first Linux (x86) version diff --git a/games/Battle Isle 3/release/windows/BI3.cfg b/games/Battle Isle 3/release/windows/BI3.cfg new file mode 100644 index 0000000..9be6981 --- /dev/null +++ b/games/Battle Isle 3/release/windows/BI3.cfg @@ -0,0 +1,22 @@ +# Intro/Outro settings +# -------------------- +# +# Intro_Play=yes/no - play intro movies ? - default value is yes +# Outro_Play=yes/no - play outro movies ? - default value is yes + +Intro_Play=yes +Outro_Play=yes + +# Audio settings +# -------------- +# +# Audio_MidiSubsystem=nativewindows/wildmidi/bassmidi/adlmidi/original - use NativeWindows, WildMIDI, BASSMIDI, ADLMIDI or the original (Windows 3.1 compatible) method for MIDI playback (WildMIDI uses GUS patch files for playback. BASSMIDI uses soundfont for playback. ADLMIDI uses OPL3 emulator for playback.) +# Audio_MidiVolume=0-127 - midi volume +# Audio_SoundFont_Path=X - X = path to soundfont file (used by BASSMIDI) +# Audio_MidiDevice=X - X = name of MIDI device (used by NativeWindows) +# Audio_OPL3BankNumber=0-73 - OPL3 bank (uses by ADLMIDI; list of banks: https://github.com/Wohlstand/libADLMIDI/blob/1.3.3/utils/gen_adldata/scrapped.txt) +Audio_MidiSubsystem=nativewindows +Audio_MidiVolume=100 +Audio_SoundFont_Path= +Audio_MidiDevice= +Audio_OPL3BankNumber=59 diff --git a/games/Battle Isle 3/release/windows/BattleIsle3.cmd b/games/Battle Isle 3/release/windows/BattleIsle3.cmd new file mode 100644 index 0000000..d0bb885 --- /dev/null +++ b/games/Battle Isle 3/release/windows/BattleIsle3.cmd @@ -0,0 +1,10 @@ +@echo off +cd /D "%~dp0" + +rem Uncomment and set SDI_INSTALL_PATH to contain path to the directory where the game is installed (in case this file is not inside the directory) +rem set SDI_INSTALL_PATH=?:\path\to\game\install\directory + +rem Uncomment and set SDI_CD_PATH to contain path to the directory where the game CDs are copied (in case it's not in the DATA subdirectory of the directory where the game is installed) +rem set SDI_CD_PATH=?:\path\to\game\cd\directory + +start SR-BI3.exe diff --git a/games/Battle Isle 3/release/windows/readme-Windows.txt b/games/Battle Isle 3/release/windows/readme-Windows.txt new file mode 100644 index 0000000..579ec18 --- /dev/null +++ b/games/Battle Isle 3/release/windows/readme-Windows.txt @@ -0,0 +1,66 @@ +Battle Isle 3 for Windows (x86) +Version 1.0.0 + +Original Battle Isle 3 is required for playing. +(version from GOG.com can be used for playing) + +Installation +------------ + +Install game. +Put files from this archive into the installed game's directory. +The game looks for the CDs in the DATA subdirectory (in installed game's directory). +If you have version from GOG.com, then the CDs are already copied there. +Otherwise you have to create the DATA subdirectory and copy the CDs there. +Alternatively you can copy the CDs elsewhere, but you need to edit the path to them in BattleIsle3.cmd. +Run BattleIsle3.cmd in the installed game's directory. + + +Music +----- + +The game's MIDI music can be played using one of following libraries: +NativeWindows, WildMIDI, BASSMIDI, ADLMIDI, original + +NativeWindows is the default library, others can be selected in the configuration file. +ADLMIDI, NativeWindows and original don't require additional files for MIDI playback, +WildMIDI requires GUS patches for MIDI playback, +BASSMIDI requires a soundfont for MIDI playback, +ADLMIDI uses OPL3 emulator for MIDI playback, +original uses Windows 3.1 compatible method for MIDI playback. + +NativeWindows can use the default synth or it can be selected in the configuration file. + +GUS patches can be installed anywhere, but the file timidity.cfg must be +either in the game's directory or in C:\TIMIDITY\timidity.cfg +EawPats is a good sounding set of patches. + +Soundfont (for BASSMIDI) can be either copied to the game's directory +or it can be stored anywhere, but the soundfont location must be written +in the configuration file. + + +Configuration +------------- + +Configuration is stored in the file BI3.cfg. +Paths to games files can be set in the file BattleIsle3.cmd. + + +Misc +---- + +The game uses following libraries for playing video: +quicktime2 (http://libquicktime.sourceforge.net/) +dlfcn-win32 (https://github.com/dlfcn-win32/dlfcn-win32) +ffmpeg (https://www.ffmpeg.org/) +intl from gettext (https://www.gnu.org/software/gettext/) + +Source code is available on GitHub: https://github.com/M-HT/SR + + +Changes +------- + +v1.0.0 (2021-06-27) +first Windows (x86) version diff --git a/games/README.md b/games/README.md index 40b1790..deae24a 100644 --- a/games/README.md +++ b/games/README.md @@ -8,6 +8,6 @@ The games use [SDL](https://libsdl.org/ "Simple DirectMedia Layer"), [SDL_mixer] The games can be built using [scons](http://scons.org/ "SCons: A software construction tool"). To control which version of the game should be built, use SCons Build Variables. Use `scons -h` to list available variables. -To play (or play better) music (in DOS games), use also midi plugins (and libraries) from *midi-plugins* subproject (and *midi-libs* subproject or external closed source libraries). +To play (or play better) music, use also midi plugins (and libraries) from *midi-plugins* subproject (and *midi-libs* subproject or external closed source libraries). The *release* subdirectories contain startup scripts and example configuration files. diff --git a/llasm/llasm.d b/llasm/llasm.d index de83cfb..e472530 100644 --- a/llasm/llasm.d +++ b/llasm/llasm.d @@ -113,6 +113,7 @@ struct dataseg_struct { enum RegisterState { Empty, Read, Write } string input_filename, output_filename, input_directory, return_procedure, dispatcher_procedure; +string[] include_directories; bool output_preprocessed_file, input_reading_proc, input_reading_dataseg, position_independent_code, old_bitcode, no_tail_calls; uint global_optimization_level, procedure_optimization_level; @@ -142,7 +143,7 @@ int num_output_lines; string[] output_lines; immutable int num_regs = 9; -string[] registers_base_list = ["eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eflags", "tmpadr", "tmp0", "tmp1", "tmp2", "tmp3", "tmp4", "tmp5", "tmp6", "tmp7", "tmp8", "tmp9", "tmp10", "tmp11", "tmp12", "tmp13", "tmp14", "tmp15", "tmp16", "tmp17", "tmp18", "tmp19"]; +string[] registers_base_list = ["eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eflags", "tmpadr", "tmpcnd", "tmp0", "tmp1", "tmp2", "tmp3", "tmp4", "tmp5", "tmp6", "tmp7", "tmp8", "tmp9", "tmp10", "tmp11", "tmp12", "tmp13", "tmp14", "tmp15", "tmp16", "tmp17", "tmp18", "tmp19"]; string[] keywords_base_list = ["proc", "extern", "define", "macro", "func", "funcv", "include", "endp", "endm", "datasegment", "dlabel", "dalign", "db", "daddr", "dskip", "endd"]; string[] instructions_base_list = [ "mov reg, reg/const/procaddr/externaddr", @@ -175,6 +176,7 @@ string[] instructions_base_list = [ "cmovz reg, reg, reg/const, reg/const", "cmoveq reg, reg/const, reg, reg/const, reg/const", "cmovult reg, reg/const, reg, reg/const, reg/const", + "cmovugt reg, reg/const, reg, reg/const, reg/const", "cmovslt reg, reg/const, reg, reg/const, reg/const", "cmovsgt reg, reg/const, reg, reg/const, reg/const", "call funcaddr [$/reg/const]", @@ -443,6 +445,26 @@ bool add_include_to_stack(string include_name) { fullpath = absolutePath(path); } + else + { + for (int i = 0; i < include_directories.length; i++) + { + if (isAbsolute(include_directories[i])) + { + path = buildPath(include_directories[i], include_name); + } + else + { + path = buildPath(input_directory, include_directories[i], include_name); + } + + if (exists(path)) + { + fullpath = absolutePath(path); + break; + } + } + } } if (fullpath == null) @@ -1689,6 +1711,7 @@ bool process_proc_body(string proc_name) break; case "cmoveq": // cmoveq reg, reg/const, reg, reg/const, reg/const case "cmovult": // cmovult reg, reg/const, reg, reg/const, reg/const + case "cmovugt": // cmovugt reg, reg/const, reg, reg/const, reg/const case "cmovslt": // cmovslt reg, reg/const, reg, reg/const, reg/const case "cmovsgt": // cmovsgt reg, reg/const, reg, reg/const, reg/const proc_instr_info[linenum].write_reg[0] = paramvals[2].value; @@ -2170,6 +2193,7 @@ bool process_proc_body(string proc_name) break; case "cmoveq": // cmoveq reg, reg/const, reg, reg/const, reg/const case "cmovult": // cmovult reg, reg/const, reg, reg/const, reg/const + case "cmovugt": // cmovugt reg, reg/const, reg, reg/const, reg/const case "cmovslt": // cmovslt reg, reg/const, reg, reg/const, reg/const case "cmovsgt": // cmovsgt reg, reg/const, reg, reg/const, reg/const { @@ -2395,6 +2419,7 @@ public int main(string[] args) output_filename = ""; return_procedure = ""; dispatcher_procedure = ""; + include_directories.length = 0; output_preprocessed_file = false; global_optimization_level = 0; position_independent_code = false; @@ -2414,6 +2439,17 @@ public int main(string[] args) output_filename = args[i + 1].idup; i++; break; + case "-I": + if (i + 1 == args.length) + { + stderr.writeln("Missing argument: " ~ args[i]); + return 2; + } + + include_directories.length++; + include_directories[include_directories.length - 1] = args[i + 1].idup; + i++; + break; case "-O": case "-O2": global_optimization_level = 2; diff --git a/midi-plugins/README.md b/midi-plugins/README.md index 0e1ea87..4de18d4 100644 --- a/midi-plugins/README.md +++ b/midi-plugins/README.md @@ -1,6 +1,6 @@ # midi-plugins -Plugins used by the DOS games to play MIDI (and other types) music. +Plugins used by the games to play MIDI (and other types) music. To compile the plugins run the *komp-x86.sh* script (or the *komp-arm.sh* script, if compiling on ARM).