Spell Weirdness

Discussions and help for Bard's Tale II: The Destiny Knight
Post Reply
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Spell Weirdness

Post by Darendor »

I was doing some more thinking.

Ever notice how the APAR spell seems to have 2 functions? When you cast it in the Wilderness or a city, it asks you what city to teleport to, but when you cast it in a dungeon it asks how many spaces north and east and how many floors up/down?


Does this mean that magic spells in BTII have different mode flags?


Also SCSI seems to be the only magic spell not affected by antimagic squares in a dungeon. This means either that each spell has a flag that allows it to ignore such squares (SCSI being the only spell with this flag turned on), or that the AM square subroutine is specifically programmed to ignore only that spell.


What do you all think?
drifting
Posts: 152
Joined: Wed Dec 07, 2011 10:21 pm

Re: Spell Weirdness

Post by drifting »

Darendor wrote: Mon Feb 18, 2019 1:48 am I was doing some more thinking.

Ever notice how the APAR spell seems to have 2 functions? When you cast it in the Wilderness or a city, it asks you what city to teleport to, but when you cast it in a dungeon it asks how many spaces north and east and how many floors up/down?


Does this mean that magic spells in BTII have different mode flags?
Not really. The code just executes one code path if you're in a dungeon and another if you're not.
Darendor wrote: Mon Feb 18, 2019 1:48 am Also SCSI seems to be the only magic spell not affected by antimagic squares in a dungeon. This means either that each spell has a flag that allows it to ignore such squares (SCSI being the only spell with this flag turned on), or that the AM square subroutine is specifically programmed to ignore only that spell.

What do you all think?
Can you check other spells on an antimagic square? From looking at the (DOS) code, there isn't anything stopping you from casting spells on antimagic squares. It just cancels the duration (light/levitation/shield/etc) spells.
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: Spell Weirdness

Post by Darendor »

I've confirmed by going to the Grey Crypt and attempting to cast REST.

"Darendor cast a spell but it fizzled!"

Can you explain further by code paths? How does that work exactly?

Thanks.
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: Spell Weirdness

Post by Darendor »

In the game, I slowed the emulator to 10%, then attempted to cast APAR in the Grey Crypt.

As soon as I hit ENTER, I entered the ML monitor and found the game was in the middle of executing this code fragment:

.C:4098 01 01 ORA ($01,X)
.C:409a 8E D1 40 STX $40D1
.C:409d 8C D3 40 STY $40D3
.C:40a0 A2 18 LDX #$18
.C:40a2 BD 00 B6 LDA $B600,X
.C:40a5 18 CLC
.C:40a6 69 80 ADC #$80
.C:40a8 8D B8 40 STA $40B8
.C:40ab BD 00 B7 LDA $B700,X
.C:40ae 69 00 ADC #$00
.C:40b0 8D B9 40 STA $40B9
.C:40b3 A0 00 LDY #$00
.C:40b5 A9 FF LDA #$FF
.C:40b7 99 82 2A STA $2A82,Y
.C:40ba 98 TYA
.C:40bb 18 CLC
.C:40bc 69 08 ADC #$08
.C:40be A8 TAY
.C:40bf C0 B8 CPY #$B8
.C:40c1 90 F2 BCC $40B5
.C:40c3 E8 INX
.C:40c4 E0 78 CPX #$78
.C:40c6 90 DA BCC $40A2
.C:40c8 A9 10 LDA #$10
.C:40ca 85 55 STA $55
.C:40cc A9 03 LDA #$03
.C:40ce 85 54 STA $54
.C:40d0 A2 10 LDX #$10
.C:40d2 A0 36 LDY #$36
.C:40d4 60 RTS

I think somewhere in there it checks for the Antimagic flag. I will have to examine the referenced addresses further I guess.
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: Spell Weirdness

Post by Darendor »

It seems that the spellcasting code (from not in combat at least) references data starting at memory location $B600, which I think is the character data.
drifting
Posts: 152
Joined: Wed Dec 07, 2011 10:21 pm

Re: Spell Weirdness

Post by drifting »

Darendor wrote: Mon Feb 18, 2019 4:11 am I've confirmed by going to the Grey Crypt and attempting to cast REST.

"Darendor cast a spell but it fizzled!"

Can you explain further by code paths? How does that work exactly?

Thanks.
Okay. I found the code that casts SCSI on an antiMagic square. In the DOS version, it is hardcoded that SCSI ignores antiMagic. It looks like LOTR also ignores antiMagic.

Code paths are just different execution paths based on a condition. For example, this is near the beginning of the DOS version of the APAR spell. If the global inDungeon flag is 0, then the program executes the code for the city version of the spell. If inDungeon is not zero, then the program executes the dungeon version.

Code: Select all

cmp     inDungeon, 0
jz      short l_cityTeleport
jmp     l_dungeonTeleport
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: Spell Weirdness

Post by Darendor »

drifting wrote: Mon Feb 18, 2019 5:03 am
Darendor wrote: Mon Feb 18, 2019 4:11 am I've confirmed by going to the Grey Crypt and attempting to cast REST.

"Darendor cast a spell but it fizzled!"

Can you explain further by code paths? How does that work exactly?

Thanks.
Okay. I found the code that casts SCSI on an antiMagic square. In the DOS version, it is hardcoded that SCSI ignores antiMagic. It looks like LOTR also ignores antiMagic.

Code paths are just different execution paths based on a condition. For example, this is near the beginning of the DOS version of the APAR spell. If the global inDungeon flag is 0, then the program executes the code for the city version of the spell. If inDungeon is not zero, then the program executes the dungeon version.

Code: Select all

cmp     inDungeon, 0
jz      short l_cityTeleport
jmp     l_dungeonTeleport

Okay, I just checked on the C64 and LOTR is affected by antimagic zones. Obviously a porting error.

So the spell is specifically hardcoded huh.

Since the inDungeon flag is used for conditional things such as APAR (clearly there are 2 versions), then I wonder if there is such a flag as "inCombat" for say the Dreamspell (ZZGO). Because obviously that spell behaves differently depending on whether the party is in combat or not...
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: Spell Weirdness

Post by Darendor »

Also thank you drifting for posting on this thread. It's nice to have someone to bounce my ideas off of even if they turn out to be way out in left field. :? :roll: 8)
drifting
Posts: 152
Joined: Wed Dec 07, 2011 10:21 pm

Re: Spell Weirdness

Post by drifting »

Darendor wrote: Mon Feb 18, 2019 9:48 am Okay, I just checked on the C64 and LOTR is affected by antimagic zones. Obviously a porting error.

So the spell is specifically hardcoded huh.

Since the inDungeon flag is used for conditional things such as APAR (clearly there are 2 versions), then I wonder if there is such a flag as "inCombat" for say the Dreamspell (ZZGO). Because obviously that spell behaves differently depending on whether the party is in combat or not...
Either that or they decided not being able to detect traps is a bit unfair and added it to the 16 bit versions.

Exactly right on an inCombat flag. Looks like it's only used for ZZGO.
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: Spell Weirdness

Post by Darendor »

drifting wrote: Mon Feb 18, 2019 4:13 pm
Darendor wrote: Mon Feb 18, 2019 9:48 am Okay, I just checked on the C64 and LOTR is affected by antimagic zones. Obviously a porting error.

So the spell is specifically hardcoded huh.

Since the inDungeon flag is used for conditional things such as APAR (clearly there are 2 versions), then I wonder if there is such a flag as "inCombat" for say the Dreamspell (ZZGO). Because obviously that spell behaves differently depending on whether the party is in combat or not...
Either that or they decided not being able to detect traps is a bit unfair and added it to the 16 bit versions.

Exactly right on an inCombat flag. Looks like it's only used for ZZGO.

So APAR and ZZGO have a testing subroutine at the start of their codes, I guess. Meaning there's 2 APARs and 2 ZZGOs.
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: Spell Weirdness

Post by Darendor »

I've nominally determined the subroutine that occurs when you press "C" to cast a spell (noncombat).

Code: Select all

.C:4098  01 01       ORA ($01,X)
.C:409a  8E D1 40    STX $40D1
.C:409d  8C D3 40    STY $40D3
.C:40a0  A2 18       LDX #$18
.C:40a2  BD 00 B6    LDA $B600,X
.C:40a5  18          CLC
.C:40a6  69 80       ADC #$80
.C:40a8  8D B8 40    STA $40B8
.C:40ab  BD 00 B7    LDA $B700,X
.C:40ae  69 00       ADC #$00
.C:40b0  8D B9 40    STA $40B9
.C:40b3  A0 00       LDY #$00
.C:40b5  A9 FF       LDA #$FF
.C:40b7  99 85 2A    STA $2A85,Y
.C:40ba  98          TYA
.C:40bb  18          CLC
.C:40bc  69 08       ADC #$08
.C:40be  A8          TAY
.C:40bf  C0 B8       CPY #$B8
.C:40c1  90 F2       BCC $40B5
.C:40c3  E8          INX
.C:40c4  E0 78       CPX #$78
.C:40c6  90 DA       BCC $40A2
.C:40c8  A9 10       LDA #$10
.C:40ca  85 55       STA $55
.C:40cc  A9 03       LDA #$03
.C:40ce  85 54       STA $54
.C:40d0  A2 00       LDX #$00
.C:40d2  A0 15       LDY #$15
.C:40d4  60          RTS
What does this mean? Well. I suspect it asks who will cast a spell, because...that's kinda what happens when you press....C...

...


Stay tuned for more or less exciting developments. :?
User avatar
Marco
Posts: 81
Joined: Mon Dec 10, 2007 7:45 pm
Contact:

Re: Spell Weirdness

Post by Marco »

In perhaps a similar vein, ZZGO cannot be cast in the PC version until it has been discovered. So this spell may have another flag with it.

Interestingly, I am almost positive that when I originally played this on the Apple 2e, I was able to cast ZZGO prematurely. This is possibly also true on the Apple 2gs. I don’t remember about the c64 and I have never tried the Amiga version.

Marco.
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: Spell Weirdness

Post by Darendor »

The Dreamspell, on the C64 version at least, is a 7th level Sorcerer spell. You simply need to buy your 7th spell level and you can cast it.

I would imagine that the MS-DOS version is the result of porting error. That said, it makes sense that you have to discover it first. Immersion, and all that. :?
Post Reply