Reverse engineering BT3 C64....

For all discussion on all the previous Bard's Tale games: the classic 1980s games (Bard's Tale, II: Destiny Knight, & III: Thief of Fate) & the humorous Bard's Tale (2004) spin off.

Moderator: Bard Hall Bouncers

Post Reply
User avatar
jamespodesta
Explorer
Posts: 365
Joined: February 20th, 2018, 4:02 pm

Reverse engineering BT3 C64....

Post by jamespodesta » October 30th, 2018, 8:33 pm

Thought I'd start a thread here... I'm probably going to need to dip into the c64 version of BT3 to solve a few questions over the next couple of months.
I don't know if anyone else has any experience with this, but feel free to chime in if you know something :)

Previously I've done all the reverse engineering on the Amiga version because I know the debugger for WinUAE pretty well.
However, the Amiga version of BT3 seems so badly ported that its not even useful for research at all. (The other versions had bugs but were still pretty close).

So... I'll be using CCS64. Alt-M opens up a monitor and lets me breakpoint memory accesses and search for codes, so thats the main thing you need.

First thing to research is going to be what the monster attack data means...
Each monster looks like it still has 4 possible attacks in BT3.

For the serpent, which seems to have a melee attack and a breath attack, the data is.

HEX 80,01,80,21,F0,22,F0,23 ; Monster attacks $16

F0 seems to indicate melee attacks. Not sure what the 22 and 23 mean yet.
80 must mean breath attacks (or a specific low powered breath attack). No idea what the 01 and 21 mean.

to be continued...
Lead Programmer
Krome Studios.

_noblesse_oblige_
Master
Posts: 1193
Joined: July 13th, 2015, 7:18 pm

Re: Reverse engineering BT3 C64....

Post by _noblesse_oblige_ » October 30th, 2018, 8:58 pm

Seems like the top 4 bits are modifiers: F = 1111 and 8 = 1000. Probably the lower 3 nibbles are the actual attack ID.
cmibl<enter>

User avatar
jamespodesta
Explorer
Posts: 365
Joined: February 20th, 2018, 4:02 pm

Re: Reverse engineering BT3 C64....

Post by jamespodesta » October 30th, 2018, 9:07 pm

pretty sure the F0 / 80 is a full 256 table entry. all the attacks in bt1/bt2 worked like that. Anything above F0 tends to be special attacks or NO ATTACK. 80+ is probably breaths and ranged attacks (like bow/arrow). Below 80 will be spells - usually sorted close to the order they appear in the manual, where a 1 is an arc fire...

The real mystery is what the 01, 21, 22, 23 do. That's new to BT3.
Lead Programmer
Krome Studios.

User avatar
ZiN
Adventurer
Posts: 682
Joined: January 27th, 2015, 7:57 am

Re: Reverse engineering BT3 C64....

Post by ZiN » October 31st, 2018, 2:53 am

Referencing the data on these lists might prove useful.

User avatar
jamespodesta
Explorer
Posts: 365
Joined: February 20th, 2018, 4:02 pm

Re: Reverse engineering BT3 C64....

Post by jamespodesta » October 31st, 2018, 5:30 am

ZiN wrote:
October 31st, 2018, 2:53 am
Referencing the data on these lists might prove useful.
Nice. I've never seen that one.

According to that, the serpent does actually have 2 different melee's and 2 different breaths, so the second numbers are actual modifiers of damage.

From dissembling the c64 version, I can see the "22" is split into bottom 5 bits and upper 3 bits.

(You can find this code by putting a memory breakpoint on the monsters combat data... which runs code that stores the 22 in some memory which we can also put a memory breakpoint on to get to the next code that uses that 22..

Looks like a dice roll. Top bits index into a dice size array at $cd68, bottom 5 bits are the number of rolls...
The dice rolls match the kind of damage we'd expect from the melee attack...

,fa5b 4a LSR
,fa5c 4a LSR
,fa5d 4a LSR
,fa5e 4a LSR
,fa5f 4a LSR // shift right 5 bits (divide by 32)
,fa60 aa TAX // high 3 bits to X == 1
,fa61 68 PLA
,fa62 29 1f AND #$1f
,fa64 a8 TAY
,fa65 c8 INY // low 5 bits + 1 to Y == 2+1 == 3
,fa66 a9 00 LDA #$00
,fa68 85 12 STA $12
,fa6a 85 13 STA $13
,fa6c 20 3e ff JSR $ff3e // random number?
,fa6f 3d 68 cd AND $cd68,X // looks like a mask table - so top bits are index to larger masks
,fa72 38 SEC
,fa73 65 12 ADC $12 // add what we have so far to $12.. accumulating the result..
,fa75 85 12 STA $12
,fa77 90 02 BCC $fa7b
,fa79 e6 13 INC $13 // on overflow, increase the high byte, so $13,$12 is our result of DICE * ROLLS
,fa7b 88 DEY
,fa7c d0 ee BNE $fa6c // loop back for Y times...
,fa7e 60 RTS

so for BT3, each monster can have multiple melee attacks with different attack damage since its built into the individual attacks... which matches the table on the link...
Not sure how this works with spells, but presumably they can mutate a spell damage also...
Lead Programmer
Krome Studios.

User avatar
ZiN
Adventurer
Posts: 682
Joined: January 27th, 2015, 7:57 am

Re: Reverse engineering BT3 C64....

Post by ZiN » October 31st, 2018, 5:51 am

jamespodesta wrote:
October 31st, 2018, 5:30 am
Not sure how this works with spells, but presumably they can mutate a spell damage also...
It might be for the spell-vulnerability of certain monsters. Ice monsters in Gelidia took double from fire and half from freeze. Most machines took double from shock. In certain places drain spells could do double and so on.

Zadkiel
Explorer
Posts: 267
Joined: November 23rd, 2015, 5:53 pm

Re: Reverse engineering BT3 C64....

Post by Zadkiel » October 31st, 2018, 6:46 am

ZiN wrote:
October 31st, 2018, 5:51 am
It might be for the spell-vulnerability of certain monsters. Ice monsters in Gelidia took double from fire and half from freeze. Most machines took double from shock. In certain places drain spells could do double and so on.
Those appear to be handled differently - you would expect things like this to be indicated with the 'flag' monster parameter (from the above link) and indeed all the mechanical creatures have the flag unk4 (unknown 4 - the person who made this list didn't know what the flag did).

However there is no flag on ice monsters, but those only exist in Gelidia and ALL monsters in Gelidia are ice monsters so that was likely handled as a map-based modifier instead of a creature-based modifier.

TimN
Initiate
Posts: 4
Joined: July 14th, 2015, 4:10 am

Re: Reverse engineering BT3 C64....

Post by TimN » November 17th, 2018, 6:44 pm

I've been thinking. In BT3, monsters that inflict status effects via melee attacks don't inflict them on every successful hit like they do in the first two games. What if monsters have multiple melee attacks because one is the version that inflicts the status effect, and one is the version that doesn't? I used to theorize that there was some dice roll on a successful melee hit that determines whether the status effect is inflicted, but maybe the game just randomly selects which version of the melee attack the monster uses, and if it's the one with the effect and it hits, you're withered/poisoned/stoned/whatever.

This could also explain why monsters that can inflict more than one kind of status effect (e.g., the Deathclaws on level 4 of UnterBrae, who can both poison and wither you) only inflict one of them on each successful melee hit.

User avatar
jamespodesta
Explorer
Posts: 365
Joined: February 20th, 2018, 4:02 pm

Re: Reverse engineering BT3 C64....

Post by jamespodesta » November 28th, 2018, 12:31 am

TimN wrote:
November 17th, 2018, 6:44 pm
I've been thinking. In BT3, monsters that inflict status effects via melee attacks don't inflict them on every successful hit like they do in the first two games. What if monsters have multiple melee attacks because one is the version that inflicts the status effect, and one is the version that doesn't? I used to theorize that there was some dice roll on a successful melee hit that determines whether the status effect is inflicted, but maybe the game just randomly selects which version of the melee attack the monster uses, and if it's the one with the effect and it hits, you're withered/poisoned/stoned/whatever.

This could also explain why monsters that can inflict more than one kind of status effect (e.g., the Deathclaws on level 4 of UnterBrae, who can both poison and wither you) only inflict one of them on each successful melee hit.
Sorry, haven't been checking the forums a lot. Deep in bt3.
Your theory is correct. Monsters in BT3 have 4 attacks, like bt1/bt2, but now each attack can have different Damage and Status Effects, so you can have one attack that does poison, and one that does wither. Same with breath attacks - you can have 2 that do different damage. (though Range is still per-monster).
Lead Programmer
Krome Studios.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests