BTII - Character Details

Any developer realated stuff
Post Reply
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

BTII - Character Details

Post by Darendor »

The game stores characters in memory accordingly:

$B800: Character slot 0
$B880: Character slot 1
$B900: Character slot 2
$B980: Character slot 3
$BA00: Character slot 4
$BA80: Character slot 5
$BB00: Character slot 6

I loaded my character in slot #6 and discovered the following:

Code: Select all

.C:bb00  D4 C8       NOOP $C8,X		Character Name: BB00-BB0F
.C:bb02  C5 A0       CMP $A0
.C:bb04  D6 C9       DEC $C9,X
.C:bb06  D3 C9       DCP ($C9),Y
.C:bb08  CF CE FF    DCP $FFCE
.C:bb0b  FF FF FF    ISB $FFFF,X
.C:bb0e  FF FF
.C:bb10  94    	     ISB $94FF,X	Combined ST and IQ stat
.C:bb11  92          JAM		Combined IQ and Dx stat
.C:bb12  94 				Combined Cn and Lk stat		
.C:bb13  8C          STY $8C,X		Combined Lk and ?? stat (Initiative?)
.C:bb14  00          BRK		EXP: BB14-BB1F
.C:bb15  00          BRK
.C:bb16  00          BRK
.C:bb17  00          BRK
.C:bb18  00          BRK
.C:bb19  01 03       ORA ($03,X)
.C:bb1b  08          PHP
.C:bb1c  05 08       ORA $08
.C:bb1e  01 08       ORA ($08,X)
.C:bb20  00          BRK		GOLD: BB25-BB2F
.C:bb21  07 00       SLO $00	[Level; if not equal to b823 then "drained"][???]
.C:bb23  07 00       SLO $00	[Level; if not equal to b823 then "drained"][???]
.C:bb25  00          BRK
.C:bb26  00          BRK
.C:bb27  00          BRK
.C:bb28  00          BRK
.C:bb29  01 09       ORA ($09,X)
.C:bb2b  06 08       ASL $08
.C:bb2d  07 07       SLO $07
.C:bb2f  09
.C:bb30  01          ORA #$01			DEC01
.C:bb31  1E					DEC30
.C:bb32  01					DEC01
.C:bb33  1E          ASL $1E01,X		DEC30
.C:bb34  01					DEC01
.C:bb35  3B          ORA ($3B,X)		DEC59
.C:bb36  01					DEC01
.C:bb37  0F          ORA ($0F,X)		DEC15
.C:bb38  0A          ASL A			DEC10
.C:bb39  00          BRK			DEC00
.C:bb3a  35
.C:bb3b  08          AND $08,X
.C:bb3c  00          BRK
.C:bb3d  C2
.C:bb3e  00          NOOP #$00
.C:bb3f  0F
.C:bb40  07				Sorcerer spell level
.C:bb41  07          SLO $0707		Conjuror spell level
.C:bb42  07				Magician spell level
.C:bb43  07          SLO $07		Wizard spell level
.C:bb44  00          BRK
.C:bb45  00          BRK
.C:bb46  00          BRK
.C:bb47  00          BRK
.C:bb48  00          BRK
.C:bb49  00          BRK
.C:bb4a  00          BRK
.C:bb4b  00          BRK
.C:bb4c  00          BRK
.C:bb4d  00          BRK
.C:bb4e  00          BRK
.C:bb4f  08          PHP
.C:bb50  01				Status of slot #1	01 = Equipped, 00 = Unequipped, F0 = Unidentified
.C:bb51	 3F          ORA ($3F,X)	Inventory slot #1	Mage Staff
.C:bb52  00          BRK		Status of slot #2	
.C:bb53  7E				Inventory slot #2	The Scepter
.C:bb54  00				Status of slot #3	
.C:bb55  5F   	     ROR $5F00,X	Inventory slot #3	Ring of Power #17
.C:bb56  01				Status of slot #4	
.C:bb57  5A          ORA ($5A,X)	Inventory slot #4	Speedboots
.C:bb58  F0				Status of slot #5	Unidentified
.C:bb59  59          BEQ $BBB3		Inventory slot #5	(Crystal Sword)
.C:bb5a  00          BRK		Status of slot #6	
.C:bb5b  57				Inventory slot #6	Dragonwand #35
.C:bb5c  00          SRE $00,X		Status of slot #7	
.C:bb5d  00          BRK		Inventory slot #7
.C:bb5e  00          BRK		Status of slot #8	
.C:bb5f  00          BRK		Inventory slot #8
.C:bb60  00          BRK
.C:bb61  00          BRK
.C:bb62  00          BRK
.C:bb63  00          BRK
.C:bb64  04 				Archmage spell level
.C:bb65  00          NOOP $00			
.C:bb66  00          BRK
.C:bb67  00          BRK
.C:bb68  FF				#charges on inventory item #1 	FF=Unlimited
.C:bb69  FF				#charges on inventory item #2
.C:bb6a  11   	     ISB $11FF,X	#charges on inventory item #3   11>17D
.C:bb6b  FF				#charges on inventory item #4
.C:bb6c  FF				#charges on inventory item #5
.C:bb6d  23   	     ISB $23FF,X	#charges on inventory item #6	23>35D
.C:bb6e  00          BRK		#charges on inventory item #7	No item
.C:bb6f  00          BRK		#charges on inventory item $8	No item
.C:bb70  82 				
.C:bb71  00          NOOP #$00		
.C:bb72  00          BRK
.C:bb73  09
.C:bb74  00          ORA #$00
.C:bb75  00          BRK
.C:bb76  00          BRK
.C:bb77  00          BRK
.C:bb78  00          BRK
.C:bb79  00          BRK
.C:bb7a  00          BRK
My notes on this so far:
- BB10 to BB13 use a combined value, probably bitfields, to store the character's six stats: The 5 we see on the screen, plus their initiative value. Seting these 4 bytes to FF changes the 5 visible stats to 31, and presumably maxes out the initiative value too.
- The experience and gold fields are stored sequentially.
- B330 to B33F I'm not sure about. I suspect it relates to the character's inventory somehow.
- You can set an item's charges to FF and give it unlimited charges. Dragonwand that never runs out? Hell yes.
- This particular character is a Destiny Nut, but I couldn't figure out which flag indicates that.

Edit: Corrections regarding level as per drifting.
Last edited by Darendor on Fri Jan 29, 2021 4:42 am, edited 3 times in total.
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: BTII - Character Details

Post by Darendor »

Also wondering why it doesn't display an AC value? Probably calculated externally based on class (i.e. Monk or not), plus Dx and specific items. :?
drifting
Posts: 153
Joined: Wed Dec 07, 2011 10:21 pm

Re: BTII - Character Details

Post by drifting »

$BB20-21 and $BB22-23 look to be the current level and the max level. The review board code modifies those when advancing:

Code: Select all

.C:9b03  20 06 08    JSR $0806          " hath earned a level of..."
.C:9b06  A0 23       LDY #$23
.C:9b08  B1 9B       LDA ($9B),Y        ; A = $23 byte of character
.C:9b0a  18          CLC
.C:9b0b  69 01       ADC #$01           ; A = A + 1
.C:9b0d  91 9B       STA ($9B),Y        ; Store incremented value back at $23 byte
.C:9b0f  48          PHA                ; Push A onto stack
.C:9b10  88          DEY                ; Y= $22
.C:9b11  B1 9B       LDA ($9B),Y        ; A = $22 byte of character
.C:9b13  69 00       ADC #$00           ; A = A + 0 + Carry bit from previous add
.C:9b15  91 9B       STA ($9B),Y        ; Store A at $22 byte
.C:9b17  A0 20       LDY #$20
.C:9b19  91 9B       STA ($9B),Y        ; Also store A at $20 byte
.C:9b1b  C8          INY                ; Y = $21
.C:9b1c  68          PLA                ; Pop A from the stack
.C:9b1d  91 9B       STA ($9B),Y        ; Set $21 byte to incremented value
Interestingly, the DOS version only has one byte for the current level and maximum level where the 8 bit version uses two bytes.

$30 - $31 - current hp or max hp
$32 - $33 - current hp or max hp
$38 - Character class
$34 - $35 - probably max sppt
$36 - $37 - probably current sppt
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: BTII - Character Details

Post by Darendor »

drifting wrote: Mon Jan 18, 2021 11:06 pm $BB20-21 and $BB22-23 look to be the current level and the max level. The review board code modifies those when advancing:

Code: Select all

.C:9b03  20 06 08    JSR $0806          " hath earned a level of..."
.C:9b06  A0 23       LDY #$23
.C:9b08  B1 9B       LDA ($9B),Y        ; A = $23 byte of character
.C:9b0a  18          CLC
.C:9b0b  69 01       ADC #$01           ; A = A + 1
.C:9b0d  91 9B       STA ($9B),Y        ; Store incremented value back at $23 byte
.C:9b0f  48          PHA                ; Push A onto stack
.C:9b10  88          DEY                ; Y= $22
.C:9b11  B1 9B       LDA ($9B),Y        ; A = $22 byte of character
.C:9b13  69 00       ADC #$00           ; A = A + 0 + Carry bit from previous add
.C:9b15  91 9B       STA ($9B),Y        ; Store A at $22 byte
.C:9b17  A0 20       LDY #$20
.C:9b19  91 9B       STA ($9B),Y        ; Also store A at $20 byte
.C:9b1b  C8          INY                ; Y = $21
.C:9b1c  68          PLA                ; Pop A from the stack
.C:9b1d  91 9B       STA ($9B),Y        ; Set $21 byte to incremented value
Interestingly, the DOS version only has one byte for the current level and maximum level where the 8 bit version uses two bytes.

$30 - $31 - current hp or max hp
$32 - $33 - current hp or max hp
$38 - Character class
$34 - $35 - probably max sppt
$36 - $37 - probably current sppt
Goddamnit, I screwed up my notations. I should probably sleep sometime this week.

Thanks for catching that.
Weber G
Posts: 125
Joined: Tue Dec 15, 2020 9:58 am

Re: BTII - Character Details

Post by Weber G »

According the character address table, the characters are stored beginning at B800:

character address table ($0A0B):

Code: Select all

>C:0a00  9d 41 09 ca  10 f8 a9 02  4c dc 1c 00  b8 80 b8 00   .A......L.......
>C:0a10  b9 80 b9 00  ba 80 ba 00  bb a0 a0 c3  e8 e1 f2 e1   ................
And so it is:
slot0: $B800
slot1: $B880
slot2: $B900
slot3: $B980
slot4: $BA00
slot5: $BA80
slot6: $BB00

e.g.: slot0:

Code: Select all

>C:b800  c2 d2 c9 c1  ce a0 d4 c8  c5 a0 c6 c9  d3 d4 ff ff   ................
>C:b810  7a 4e 51 92  00 00 00 00  00 00 00 01  01 04 02 09   zNQ.............
>C:b820  00 05 00 05  00 00 00 00  00 00 00 00  00 00 00 00   ................
>C:b830  00 3b 00 3b  00 00 00 00  07 00 3b 00  00 1a 00 07   .;.;......;.....
>C:b840  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 01   ................
>C:b850  01 0d 01 11  01 13 01 0b  01 07 00 0e  00 00 00 00   ................
>C:b860  00 00 00 00  00 00 00 00  ff ff ff ff  ff ff 00 00   ................
>C:b870  00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 b8   ................
The bytes are 90% the same as at BT1. Only a few differences...
Post Reply