Trap issue with BTII on c64

Any developer realated stuff
drifting
Posts: 153
Joined: Wed Dec 07, 2011 10:21 pm

Post by drifting »

Okay. I believe I've found the problem. The saving throw check code uses the melee ndice attribute of the first monster group the party is facing. That offset from the base of the monster group data is $1D.

This section of code takes the dungeon difficulty level, multiplies by 16, adds 7 and stores it at ($67) + $1D. aka the melee ndice attribute.

Code: Select all

a284:0086:1   a5 42             lda $42      ; This is the current dungeon difficulty level
a286:0088:1   0a                asl a        ; * 16
a287:0089:1   0a                asl a
a288:008a:1   0a                asl a
a289:008b:1   0a                asl a
a28a:008c:1   18                clc
a28b:008d:1   69 07             adc #$07     ; + 7
a28d:008f:1   48                pha
This calculates the saving throw value which is ((16 * level_difficulty) + 7). At this point, $67-68 has the correct address for the first monster group $B700.

Code: Select all

a28e:0090:1   ad 55 a4          lda $a455
a291:0093:1   85 67             sta $67
a293:0095:1   ad 56 a4          lda $a456
a296:0098:1   85 68             sta $68 
Now $67-68 has been overwritten by the incorrect value $B300.

Code: Select all

a298:009a:1   a0 1d             ldy #$1d
a29a:009c:1   68                pla
a29b:009d:1   91 67             sta ($67),y  ; Stored at ($67) + $1D
The trap saving throw data has now been written to the wrong memory location. The melee ndice parameter of the first monster group of the last battle is now used as the saving throw value. To give an idea of the difference, the Zen Master's ndice parameter is 14. The lowest dungeon level (1) has a saving throw value of 23.
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Post by Darendor »

Is this easily fixed?
drifting
Posts: 153
Joined: Wed Dec 07, 2011 10:21 pm

Post by drifting »

I think so. I've found the spot in the Apple disk images that has $B300. It's easy to change it to $B700. I need to create a low level party to test it out.
User avatar
ZeroZero
Posts: 286
Joined: Tue Mar 10, 2009 9:10 pm
Location: Germany

Post by ZeroZero »

Excellent job so far, drifting!
drifting
Posts: 153
Joined: Wed Dec 07, 2011 10:21 pm

Post by drifting »

https://github.com/downloads/ChrisAubuc ... 2-dun1.dsk
https://github.com/downloads/ChrisAubuc ... 2-dun2.dsk

These are replacement Apple disk images. I changed two bytes in the trap code to get them (I believe) to work properly.

The first was to change the data at $a456 to point to the proper address for the monster groups. $B700 instead of $B300. Hmm...I wonder if this bug is specific to the Apple version. The disassembly dumps in this thread are offset $400 than what they are when I load these in AppleWin. I wonder if they discovered this bug when moving to the C64.

The second was to change the "jsr $9403" (on Apple) to "jsr $9412" which is, I believe, the do_damage() routine.

In a few tests in the Dark Domain with a low level party it seems it is now working correctly. A poison gas cloud inflicted damage and the poisoned status as it should. Wiped out the entire party except for the high level Archmage used for APAR.
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Post by Darendor »

Are the corrections easily applied to the C64 disk images as well?
drifting
Posts: 153
Joined: Wed Dec 07, 2011 10:21 pm

Post by drifting »

I don't think it will be too difficult. I don't have a C64 emulator set up so I'll have to get one of those going first.
drifting
Posts: 153
Joined: Wed Dec 07, 2011 10:21 pm

Post by drifting »

https://github.com/downloads/ChrisAubuc ... 2-dun1.d64
https://github.com/downloads/ChrisAubuc ... 2-dun2.d64

Tested dungeon disk 1 with a low level party in the Dark Domain and traps work.
User avatar
ZeroZero
Posts: 286
Joined: Tue Mar 10, 2009 9:10 pm
Location: Germany

Post by ZeroZero »

Excellent job, drifting.

I just wonder how difficult BT2 is now, that it works like originally intented...
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Post by Darendor »

ZeroZero wrote:Excellent job, drifting.

I just wonder how difficult BT2 is now, that it works like originally intented...
Well, if the traps were a threat back in the day, I would have modified my dungeon maps to point them out. :?
User avatar
Saxon1974
Posts: 87
Joined: Thu Mar 27, 2008 3:52 am

Post by Saxon1974 »

Hot Damn it works! Great work Drifting!

Does someone want to post the working dungeon discs to the main website's list of files?

I still have a hard time believe the game was shipped like this and was never fixed, thats a HUGE bug to miss and its not what I remember back in the day playing this game.
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Post by Darendor »

I agree, redistributing the D64 images with the corrected trap subroutines would be awesome.

It'd give people a shock who were used to going, "Oh pfft, a MINDTRAP. Big friggin OH MY GOD WHAT THE F@#$%?!" 8)
User avatar
Saxon1974
Posts: 87
Joined: Thu Mar 27, 2008 3:52 am

Post by Saxon1974 »

Dang, looks like this fix broke the treasure chest traps. Now whenever I get rewarded a chest after battle the traps on these dont work.

I got so excited when I saw this was fixed I started another play though, looks like I might need to wait longer for a working version :cry:
User avatar
Saxon1974
Posts: 87
Joined: Thu Mar 27, 2008 3:52 am

Post by Saxon1974 »

Saxon1974 wrote:Dang, looks like this fix broke the treasure chest traps. Now whenever I get rewarded a chest after battle the traps on these dont work.

I got so excited when I saw this was fixed I started another play though, looks like I might need to wait longer for a working version :cry:
Edit post: I went and tried it again with a brand new character disc and it looks like both chest and regular traps do in fact work! :D

My guess is maybe my using an already used character disc had some saved info on it that had already saved something that hosed the traps? Either way it appears these new dungeon discs work properly with a new game with original boot and character discs.

Thanks again for fixing this issue Drifting. If I run into any other bugs I will post them. :wink:
User avatar
Saxon1974
Posts: 87
Joined: Thu Mar 27, 2008 3:52 am

Post by Saxon1974 »

Darendor wrote:I agree, redistributing the D64 images with the corrected trap subroutines would be awesome.

It'd give people a shock who were used to going, "Oh pfft, a MINDTRAP. Big friggin OH MY GOD WHAT THE F@#$%?!" 8)
Ha yes it would be a big shock eh? :lol:

The game is WAY too easy without the traps working. I know someone on the RPGCodex posted that he has a working C64 and the trap events work fine on the real discs.
Post Reply