Script Execution #2

Filed under: Bytecode, Crusaders of Khazan, Tunnels & Trolls — denormative @ 18:59

Another two complex opcodes implemented. Again, using the “debug” button to trigger the script.

One of them shows the “event image” such as a shopkeeper’s portrait, or the image of the Blue Beetle temple, or the old woman entertaining kids in the Gull marketplace.

The other prompts the player for a “yes/no” response, yields to wait for the player to respond, then continues the script where it left off branching depending upon what the player chose.

As I’ve yet to implement the x68k event images, I’m still using the English version ones.

New Archer Shop

Original Archer Shop



Script Execution #1

Filed under: Bytecode, Crusaders of Khazan, Tunnels & Trolls — denormative @ 12:51

Inbuilt into the game are a series of event scripts. Every time you move to a new square, the game checks a flag within the map details data (for both inside and outside) to see if the square is set as “triggerable”. If this is the case, it then references the event data for the relevant indoor/outdoor map, checks if there’s any events setup for both that (x,y) position and the current facing of the party, and if so executes the compiled bytecode associated with the script.

Essentially everything in the game is controlled by triggers. Of note:

  • Starting fights (including I believe random combat encounters)
  • Visiting shopkeepers (they’re one of the main users of “facing specific” triggers)
  • Random “talking” encounters (such as the beggars in Gull, or the wandering wizard who identifies your items also in Gull)
  • Large pre-programmed encounters (such as the “Temple of the Blue Beetle” event, or the Orcs in the Abandoned House in the same area as the Blue Beetle temple where you’re moved around and get into a series of combats)
  • Notice Boards (such as the one in the Adventure Guild)

I’ve decoded most of the basic elements of the bytecode, at least enough to wander around Gull and trigger most of the events, (though exactly how it triggers a combat encounter is still unknown, even if the opcodes are known), and have started implementing it.

Though as I still haven’t worked out the rendering of the indoor areas, I’m currently testing it via a “debug” icon shown in the screenshot below. This is triggering the first message you see when you start a new game in Gull.

New Start Game Message

Original Start Game Message


Text encoding

Filed under: Crusaders of Khazan, Tunnels & Trolls — denormative @ 14:25

Text encoding in the game is considerably perplexing. There are three different methods used in different places for no discernible reason.

Normal 7/8-bit ASCII is used primarily within the text stored within the executable, but of note spell names are also used in normal encoding.

High-bit set where the highest bit of a 7-bit ASCII character if flipped to on. City/Map names are encoded this way, as are equipment item names, and the intro text.

Swapped nibbles where for each 8-bit ASCII character, the lowest 4-bits are swapped with the highest 4-bits in each byte. This encoding seems to be used solely for character names.


Function Implementations #1

Filed under: Crusaders of Khazan, Tunnels & Trolls — denormative @ 00:42

Implemented partyShareMoney and partyGatherMoney.

The gather implementation works identically to the original game, but the share in the original game works strangely. My implementation just gathers all the money in the party, divides it by the party members and gives them a share each, with the remainder given to the currently selected person. The original game however seems to just shave off the current party member’s stack of money, giving it to the other characters until a transaction would leave him with less money then the other characters post transaction, in which case the transaction doesn’t occur. This seems unduly fiddly.

Implemented partyShareFood.

Works identical to original.


Rest Prompt

Filed under: Crusaders of Khazan, Tunnels & Trolls — denormative @ 22:14

The “rest for 8 hours?” prompt.

Really need fiddle with the Icon’s widths around the place. They’re not fixed and are auto-generated by the greatest width of either the text or icon size, and some of the icons are way too thin for it to look good when paired with thin text.

The date/time functions will need some testing once I implement saving the game. Minutes, seconds, and years are zero-based, days and months are one-based, and it’s making for confusing code and likely to have broken edge cases.

New Rest Prompt

Original Rest Prompt


Set Movement Mode

Filed under: Crusaders of Khazan, Tunnels & Trolls — denormative @ 23:42

Set movement mode. Nothing particular to say, you can highlight and click the movement style listed, or you can just press the associated number key. Works the same as the original.

New Set Movement Mode

Original Set Movement Mode


Filed under: Crusaders of Khazan, Tunnels & Trolls — denormative @ 21:54

Automap semi–done. At least as far as marking where you (“Y”) are, and where you’ve traversed. It doesn’t mark the vertical/horizontal doors, water, or in outdoors the various types of terrain you’ve traversed. All that is dependant on the map rendering data which I haven’t quite figured out yet. It’s also possible the map-tile=>automap-tile mapping is stored in the .exe somewhere and will thus be quite annoying to locate.

New Automap

Original Automap


Set Party Order

Filed under: Bugs, Crusaders of Khazan, Tunnels & Trolls — denormative @ 20:50

Implemented the partySetOrder along with the relevant screen overlays. Contains the same functionality as the original; including the programmer-quirk of starting the list at 0 rather than traditional 1 for non-programmer types. Considering this was ported through at least four different platforms (PC-88, PC-98, X68k, DOS), it’s rather curious it managed to remain unfixed.

At some point I really need to write the handful of lines of code to save games now I’m changing things.

New Order Party

Original Order Party

Image Upgrade #2

Filed under: Crusaders of Khazan, Tunnels & Trolls, X68k — denormative @ 13:50

X68k paperdoll images are also rendering. They look much nicer then the DOS versions.

New Peperdoll with X68k Images

New Paperdoll

Image Upgrade

Filed under: Crusaders of Khazan, Tunnels & Trolls, X68k — denormative @ 01:35

The images below are a comparison between the original DOS images (as rendered in the new engine)  and the images from the Sharp X68000 (X68k) version of T&T rendered with the DOS version’s data-files.

The DOS version is essentially the X68k’s version at a lower resolution and lower colour depth. The DOS version ran at 640×200 (stretched vertically to essentially to 640×400) and up to 16 visible colours, whereas the X68k’s screen resolution was 768×512 with at least 256 colours. Though the game never really seemed to use the greater palette other than with the bigger images.

The icons in the X68k version are considerably sharper. So it’s much more obvious as to what they’re supposed to represent… though a few of them look uglier as a consequence.

New Intro with X68k Images

New Intro

New Main Menu with X68k Images

Main Menu New

Older Posts »

Create a free website or blog at