Skip to content

Commit

Permalink
Fix for python 3 and nasm>=2.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Vogt committed Feb 12, 2021
1 parent efe7685 commit ee9c2e6
Show file tree
Hide file tree
Showing 8 changed files with 258 additions and 119 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -15,5 +15,6 @@ autom4te.cache
aclocal.m4
lastbuild.log
src/dosbox
temp
/visualc_2017/Debug
/visualc_2017/Release
58 changes: 58 additions & 0 deletions src/custom/schick/rewrite_m302de/common.h
@@ -1,5 +1,20 @@
#if !defined(COMMON_H)
#define COMMON_H

#if defined(__BORLANDC__)
typedef unsigned char Bit8u;
typedef signed char Bit8s;
typedef unsigned short Bit16u;
typedef signed short Bit16s;
typedef unsigned long Bit32u;
typedef signed long Bit32s;
typedef Bit8u* RealPt;
typedef Bit8u* PhysPt;
typedef Bit8u huge * HugePt;
#else
#include "mem.h"
#endif

/**
struct nvf_desc - nvf descriptor
@src: pointer to a buffer containing the nvf file
Expand Down Expand Up @@ -833,21 +848,36 @@ enum {
ITEM_BEER = 0x17,
ITEM_LANTERN_OFF = 0x19,
ITEM_FLASK_GLASS = 0x1f,
ITEM_PICKLOCKS = 0x23,
ITEM_CLIMBING_HOOKS = 0x28,
ITEM_OIL = 0x29,
ITEM_FLASK_BRONZE = 0x2a,
ITEM_FOOD_PACKAGES = 0x2d,
ITEM_SHIRT = 0x30,
ITEM_SHOES = 0x32,
ITEM_BOOTS = 0x33,
ITEM_LACEUP_SHOE = 0x34,
ITEM_ARMOR_LEATHER = 0x35,
ITEM_SHURIN_POISON = 0x37,
ITEM_ARAX_POISON = 0x38,
ITEM_ANGST_POISON = 0x39,
ITEM_SLEEP_POISON = 0x3a,
ITEM_GOLDLEIM = 0x3b,
ITEM_EINBEERE = 0x3c, /* two bytes */
ITEM_WHIRLWEED = 0x3d, /* two bytes */
ITEM_KROTENSCHEMEL = 0x3e,
ITEM_GULMOND_LEAF = 0x3f, /* two bytes */
ITEM_TARNELE = 0x40, /* two bytes */
ITEM_TORCH_OFF = 0x41,
ITEM_QUARTERSTAFF = 0x45,
ITEM_BALL_CRYSTAL = 0x46,
ITEM_ROBE_GREEN = 0x4b,
ITEM_PLATTENZEUG = 0x52,
ITEM_KETTENZEUG = 0x53,
ITEM_LEDERZEUG = 0x54,
ITEM_TINDERBOX = 0x55,
ITEM_LICORICE = 0x59,
ITEM_BONBONS = 0x5a,
ITEM_WINE = 0x5b, /* two bytes */
ITEM_BRANDY = 0x5c, /* two bytes */
ITEM_NET = 0x61,
Expand All @@ -857,24 +887,52 @@ enum {
ITEM_BELMART = 0x7b, /* two bytes */
ITEM_DONF_SPRING = 0x7c, /* two bytes */
ITEM_MENCHAL = 0x7d, /* two bytes */
ITEM_ALRAUNE = 0x7e,
ITEM_ILMENBLATT = 0x80,
ITEM_FINAGE_TREE = 0x81, /* two bytes */
ITEM_JORUGA_ROOT = 0x82, /* two bytes */
ITEM_LOTUS = 0x84,
ITEM_MAGIC_WAND = 0x85,
ITEM_LOTUS_POISON = 0x8d,
ITEM_KUKRIS = 0x8e,
ITEM_BANNSTAUB = 0x8f,
ITEM_KROETEN_POISON = 0x90,
ITEM_MU_ELIXIR = 0x93,
ITEM_KL_ELIXIR = 0x94,
ITEM_CH_ELIXIR = 0x95,
ITEM_FF_ELIXIR = 0x96,
ITEM_GE_ELIXIR = 0x97,
ITEM_IN_ELIXIR = 0x98,
ITEM_KK_ELIXIR = 0x99,
ITEM_OLGIN_ROOT = 0x9c, /* two bytes */
ITEM_KAIRANHALM = 0x9d,
ITEM_SICKLE = 0xa1,
ITEM_AMULET_BLUE = 0xa3,
ITEM_RING_RED = 0xa5, /* four bytes */
ITEM_EXPURGICUM = 0xa6,
ITEM_VOMICUM = 0xa8,
ITEM_CORONET_SILVER = 0xab,
ITEM_ANTIVENOM = 0xb4,
ITEM_GRIMRING = 0xb5,
ITEM_BELT_SKULL = 0xb6, /* two bytes */
ITEM_GIRDLE_MIGHT = 0xb7,
ITEM_LOBPREISUNGEN = 0xbd,
ITEM_KUKRIS_DAGGER = 0xc1,
ITEM_HELMET = 0xc4,
ITEM_KUKRIS_MENGBILAR = 0xc8,
ITEM_SILVER_MACE = 0xd6,
ITEM_JEWELRY_SILVER = 0xd7,
ITEM_CORONET_BLUE = 0xd9, /* two bytes */
ITEM_BAG = 0xdd,
ITEM_MU_ELIXIR_BAD = 0xe2,
ITEM_KL_ELIXIR_BAD = 0xe3,
ITEM_CH_ELIXIR_BAD = 0xe4,
ITEM_FF_ELIXIR_BAD = 0xe5,
ITEM_GE_ELIXIR_BAD = 0xe6,
ITEM_IN_ELIXIR_BAD = 0xe7,
ITEM_KK_ELIXIR_BAD = 0xe8,
ITEM_MIASTHMATICUM = 0xee,
ITEM_HYLAILIC_FIRE = 0xef,
ITEM_CORONET_GREEN = 0xf5,
ITEM_LANTERN_ON = 0xf9,
ITEM_200_ARROWS = 0xfb,
Expand Down
101 changes: 93 additions & 8 deletions src/custom/schick/rewrite_m302de/datseg.cpp

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/custom/schick/rewrite_m302de/seg048.cpp
Expand Up @@ -775,12 +775,12 @@ void status_menu(signed short hero_pos)
case 5:{
/* from spells-page */
l_di = GUI_radio((Bit8u*)0, 6,
get_ttx(213),
get_tx2(24),
get_tx2(19),
get_tx2(20),
get_ttx(214),
get_tx2(15));
get_ttx(213), // Zauber sprechen
get_tx2(24), // Grundwerte
get_tx2(19), // AT PA Werte
get_tx2(20), // Talente
get_ttx(214), // Mehr Zauber
get_tx2(15)); // Zurueck

if (l_di != -1) {
switch (l_di) {
Expand Down
3 changes: 1 addition & 2 deletions src/custom/schick/rewrite_m302de/seg068.cpp
Expand Up @@ -548,8 +548,7 @@ void THO_academy(void)

/* find the position of the first cursed (=renegade) hero */
hero = get_hero(0);
cursed_hero_pos = 0;
for (item_pos = 0; item_pos <= 6; item_pos++, hero += SIZEOF_HERO) {
for (item_pos = cursed_hero_pos = 0; item_pos <= 6; item_pos++, hero += SIZEOF_HERO) {

if (host_readbs(hero + HERO_TYPE) != HERO_TYPE_NONE &&
host_readbs(hero + HERO_GROUP_NO) == ds_readbs(CURRENT_GROUP) &&
Expand Down
Empty file modified src/custom/schick/rewrite_m302de/tools/disassemble.sh 100644 → 100755
Empty file.
190 changes: 98 additions & 92 deletions src/custom/schick/rewrite_m302de/tools/nc2fc.py
Expand Up @@ -18,114 +18,120 @@
# Diese Ersetzungen koennen daran erkannt werden, dass die Funktion
# innerhalb des Segments in aufseteigender Adressrichtung liegt.

# Compiler: call absadr
# Linker: nop ; push cs; call word reladr
# Compiler: call absadr
# Linker: nop ; push cs; call word reladr

import sys
import string

# Anderungen in der Ausgabedatei
nc = 0
fc = 0
nc_count = 0
fc_count = 0

name = sys.argv[1]

fname = string.rsplit(name, "/", 1)[1]
fname = name.rsplit("/", 1)[1]

infile = open(name, 'r')
outfile = open(name + ".tmp", 'w')

line = infile.readline()
while line is not None and line != "":

nopline = string.split(line, None, 2)
opcode = int(nopline[1][:2], 16)

# far call
if opcode == 0x9a:
o = nopline[0]
o = o + " "
o = o + "9A00000000"
o = o + " "
o = o + "call word 0x0:0x0\n"
outfile.write(o)
fc = fc + 1

# check for a line with nop instruction
elif opcode == 0x90:
lines1 = line
lines2 = infile.readline()
if lines2 is None:
outfile.write(lines1)
continue

pushline = string.split(lines2, None, 2)
opcode = int(pushline[1][:2], 16)
if opcode == 0x0e:
lines3 = infile.readline()
if lines3 is None:
outfile.write(lines1)
outfile.write(lines2)
continue

callline = string.split(lines3)

instruction = callline[1]
opcode = int(instruction[:2], 16)
if opcode == 0xe8:
#get the old relative address
address_lo = int(instruction[2:4], 16)
address_hi = int(instruction[4:6], 16)
address = address_hi * 256 + address_lo

# forward call
if address < 0x8000:

#calculate the absolute address
new_add = address + int(callline[0], 16) + 3

lo = new_add % 256
hi = new_add / 256

#create one output line

#create offset
o = nopline[0]
o = o + " "

#create opcode
o = o + "9A"
o = o + string.upper(hex(lo)[2:4].zfill(2))
o = o + string.upper(hex(hi)[2:4].zfill(2))
o = o + "0000 "

#create assembly
o = o + "call word 0x0:"
o = o + hex(new_add) + "\n"
outfile.write(o)

nc = nc + 1
else:
outfile.write(lines1)
outfile.write(lines2)
outfile.write(lines3)
else:
outfile.write(lines1)
outfile.write(lines2)
outfile.write(lines3)
else:
outfile.write(lines1)
outfile.write(lines2)
else:
outfile.write(line)

#read next line
line = infile.readline()
nopline = line.split(None, 2)
opcode = int(nopline[1][:2], 16)

# far call
if opcode == 0x9a:
o = nopline[0]
o = o + " "
o = o + "9A00000000"
o = o + " "
call_word = "call word"
if call_word not in line:
call_word = "call"
o = o + call_word + " 0x0:0x0\n"
outfile.write(o)
fc_count = fc_count + 1

# check for a line with nop instruction
elif opcode == 0x90:
lines1 = line
lines2 = infile.readline()
if lines2 is None or lines2 == "":
outfile.write(lines1)
line = lines2
continue

pushline = lines2.split(sep=None, maxsplit=2)
opcode = int(pushline[1][:2], 16)
if opcode == 0x0e:
lines3 = infile.readline()
if lines3 is None:
outfile.write(lines1)
outfile.write(lines2)
continue

callline = lines3.split()

instruction = callline[1]
opcode = int(instruction[:2], 16)
if opcode == 0xe8:
#get the old relative address
address_lo = int(instruction[2:4], 16)
address_hi = int(instruction[4:6], 16)
address = address_hi * 256 + address_lo

# forward call
if address < 0x8000:

#calculate the absolute address
new_add = address + int(callline[0], 16) + 3

lo = new_add % 256
hi = new_add // 256

#create one output line

#create offset
o = nopline[0]
o = o + " "

#create opcode
o = o + "9A"
o = o + hex(lo)[2:4].zfill(2).upper()
o = o + hex(hi)[2:4].zfill(2).upper()
o = o + "0000 "

#create assembly
call_word = "call word"
if call_word not in callline:
call_word = "call"
o = o + call_word + " 0x0:"
o = o + hex(new_add) + "\n"
outfile.write(o)

nc_count = nc_count + 1
else:
outfile.write(lines1)
outfile.write(lines2)
outfile.write(lines3)
else:
outfile.write(lines1)
outfile.write(lines2)
outfile.write(lines3)
else:
outfile.write(lines1)
outfile.write(lines2)
else:
outfile.write(line)

#read next line
line = infile.readline()

infile.close()
outfile.close()

if nc > 0 or fc > 0:
print fname, "near = ", nc, " far =", fc, " changed"
if nc_count > 0 or fc_count > 0:
print(fname, "near = ", nc_count, " far =", fc_count, " changed")
else:
print fname
print(fname)
12 changes: 1 addition & 11 deletions src/custom/schick/rewrite_m302de/v302de.h
Expand Up @@ -947,6 +947,7 @@ static inline char* get_itemname(unsigned short item)

#define DUMMY_WARNING() D1_ERR("Error: %s is not implemented\n", __func__)

// end #if !defined(__BORLANDC__)
#else

#define DUMMY_WARNING()
Expand All @@ -959,17 +960,6 @@ static inline char* get_itemname(unsigned short item)
#define INTCAST void interrupt (*)()
#endif

typedef unsigned char Bit8u;
typedef signed char Bit8s;
typedef unsigned short Bit16u;
typedef signed short Bit16s;
typedef unsigned long Bit32u;
typedef signed long Bit32s;

typedef Bit8u* RealPt;
typedef Bit8u* PhysPt;
typedef Bit8u huge * HugePt;

#include <DOS.H>

#include "common.h"
Expand Down

0 comments on commit ee9c2e6

Please sign in to comment.