C64 BT2: complete item list

Any developer realated stuff
Weber G
Posts: 125
Joined: Tue Dec 15, 2020 9:58 am

Re: C64 BT2: complete item list

Post by Weber G »

You're right! The address is $4000.

This is the code for the damage creation. The value of $8356,x (damage) is in X at the beginning:

Code: Select all

.C:a2ae	8A	  	  	TXA	; X => A
.C:a2af	48	  	  	PHA	
.C:a2b0	A2	05	  	LDX #$05	; 05 => X
.C:a2b2	4A	  	  	LSR A	; move A bitwise right
.C:a2b3	CA	  	  	DEX	; X = X -1
.C:a2b4	D0	FC	  	BNE $A2B2	
.C:a2b6	85	48	  	STA $48	; A => $48
.C:a2b8	68	  	  	PLA	
.C:a2b9	29	1F	  	AND #$1F	; 1F AND A
.C:a2bb	85	49	  	STA $49	; A => $49
.C:a2bd	A9	00	  	LDA #$00	; 00 => A
.C:a2bf	85	45	  	STA $45	; A => $45
.C:a2c1	85	46	  	STA $46	; A => $46
.C:a2c3	A0	4F	  	LDY #$4F	; 4F => Y
.C:a2c5	B1	9B	  	LDA ($9B),Y	; ($9B),Y => A
.C:a2c7	18	  	  	CLC	
.C:a2c8	65	AA	  	ADC $AA	; add $AA to A
.C:a2ca	85	3B	  	STA $3B	; A => $3B
.C:a2cc	A4	49	  	LDY $49	; $49 => Y
.C:a2ce	20	90	08	JSR $0890	; jsr => $0890
.C:a2d1	A6	48	  	LDX $48	; $48 => X
.C:a2d3	A5	5B	  	LDA $5B	; $5B => A
.C:a2d5	3D	32	AB	AND $AB32,X	; $AB32,X AND A
.C:a2d8	18	  	  	CLC	
.C:a2d9	69	01	  	ADC #$01	; add 01 to A
.C:a2db	65	45	  	ADC $45	; add $45 to A
.C:a2dd	90	02	  	BCC $A2E1	
.C:a2df	E6	46	  	INC $46	; $46 = $46 +1
.C:a2e1	85	45	  	STA $45	; A => $45
.C:a2e3	88	  	  	DEY	; Y = Y -1
.C:a2e4	10	E8	  	BPL $A2CE	
.C:a2e6	A5	45	  	LDA $45	; $45 => A
.C:a2e8	18	  	  	CLC	
.C:a2e9	69	00	  	ADC #$00	; add 00 to A
.C:a2eb	90	02	  	BCC $A2EF	
.C:a2ed	E6	46	  	INC $46	; $46 = $46 +1
.C:a2ef	18	  	  	CLC	
.C:a2f0	65	41	  	ADC $41	; add $41 to A
.C:a2f2	85	45	  	STA $45	; A => $45
.C:a2f4	A5	46	  	LDA $46	; $46 => A
.C:a2f6	69	00	  	ADC #$00	; add 00 to A
.C:a2f8	85	46	  	STA $46	; A => $46
.C:a2fa	A6	DC	  	LDX $DC	; $DC => X
.C:a2fc	BD	87	02	LDA $0287,X	; $0287,X => A
.C:a2ff	18	  	  	CLC	
.C:a300	65	45	  	ADC $45	; add $45 to A
.C:a302	85	45	  	STA $45	; A => $45
.C:a304	A5	46	  	LDA $46	; $46 => A
.C:a306	69	00	  	ADC #$00	; add 00 to A
.C:a308	85	46	  	STA $46	; A => $46
.C:a30a	BD	8E	02	LDA $028E,X	; $028E,X => A
.C:a30d	F0	19	  	BEQ $A328	
.C:a30f	A8	  	  	TAY	; A => Y
.C:a310	20	90	08	JSR $0890	; jsr => $0890
.C:a313	A5	5A	  	LDA $5A	; $5A => A
.C:a315	29	07	  	AND #$07	; 07 AND A
.C:a317	18	  	  	CLC	
.C:a318	69	01	  	ADC #$01	; add 01 to A
.C:a31a	18	  	  	CLC	
.C:a31b	65	45	  	ADC $45	; add $45 to A
.C:a31d	85	45	  	STA $45	; A => $45
.C:a31f	A5	46	  	LDA $46	; $46 => A
.C:a321	69	00	  	ADC #$00	; add 00 to A
.C:a323	85	46	  	STA $46	; A => $46
.C:a325	88	  	  	DEY	; Y = Y -1
.C:a326	D0	E8	  	BNE $A310	
.C:a328	A5	45	  	LDA $45	; $45 => A
.C:a32a	38	  	  	SEC	
.C:a32b	E5	DF	  	SBC $DF	; substract $DF from A
.C:a32d	85	45	  	STA $45	; A => $45
.C:a32f	B0	0E	  	BCS $A33F	
.C:a331	A5	46	  	LDA $46	; $46 => A
.C:a333	E9	00	  	SBC #$00	; substract 00 from A
.C:a335	85	46	  	STA $46	; A => $46
.C:a337	B0	06	  	BCS $A33F	
.C:a339	A9	00	  	LDA #$00	; 00 => A
.C:a33b	85	45	  	STA $45	; A => $45
.C:a33d	85	46	  	STA $46	; A => $46
.C:a33f	C6	3B	  	DEC $3B	; $3B = $3B -1
.C:a341	30	03	  	BMI $A346	
.C:a343	4C	CC	A2	JMP $A2CC	; jump => $A2CC
$45/ $46 is the damage
$3B is # of attacks

rest should be clear
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: C64 BT2: complete item list

Post by Darendor »

Weber G wrote: Thu Jan 21, 2021 2:34 pm rest should be clear
Image

Oh yeah, totally clear. Like SCBA-diving along the muddy bottom of the China Sea and kicking up dirty and mud everywhere. No confusion here. What-so-EVAR.
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: C64 BT2: complete item list

Post by Darendor »

Weber G wrote: Thu Jan 21, 2021 2:34 pm

Code: Select all

.C:a341	30	03	  	BMI $A346

What it at $A346? Is it relevant at all?
Weber G
Posts: 125
Joined: Tue Dec 15, 2020 9:58 am

Re: C64 BT2: complete item list

Post by Weber G »

Ok, let's take the bardsword as example. The value of the bardsword in the $8356 table is 21(hex) 00100001(bin).
This value, as mentioned, is in X.

1. X is transferred to A
2. A is transferred to the stack
3. $A2B0 - $A2B4 selects bit 5-7 from A; in this case the one in brackets: (001)00001 => A = 1
4. A is stored in $48
5. transfer stack to A
6. A (in A is the former value of X again) AND 1F => select bit 0-4 from A; in this case the one in brackets: 001(00001) => A = 1
7. A is stored in $49

Clear so far for you?
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: C64 BT2: complete item list

Post by Darendor »

I'll try later when I'm not in excruciating agony.

Pain makes it hard to concentrate, and I dunno if you've noticed but this machine language / hedadecimal stuff does me in.
drifting
Posts: 152
Joined: Wed Dec 07, 2011 10:21 pm

Re: C64 BT2: complete item list

Post by drifting »

Weber G wrote: Thu Jan 21, 2021 3:50 pm Ok, let's take the bardsword as example. The value of the bardsword in the $8356 table is 21(hex) 00100001(bin).
This value, as mentioned, is in X.

1. X is transferred to A
2. A is transferred to the stack
3. $A2B0 - $A2B4 selects bit 5-7 from A; in this case the one in brackets: (001)00001 => A = 1
4. A is stored in $48
5. transfer stack to A
6. A (in A is the former value of X again) AND 1F => select bit 0-4 from A; in this case the one in brackets: 001(00001) => A = 1
7. A is stored in $49

Clear so far for you?
In the DOS version, the $48 value is an index into a dice size table and $49 is the number of times to roll. The dice table mask is:

Code: Select all

3,7,0Fh,1Fh,3Fh,7Fh,0FFh,1
So the Bardsword with $48 = 1 and $49 = 1 would do 1d8 damage.
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: C64 BT2: complete item list

Post by Darendor »

drifting wrote: Fri Jan 22, 2021 2:10 amIn the DOS version, the $48 value is an index into a dice size table and $49 is the number of times to roll. The dice table mask is:

Code: Select all

3,7,0Fh,1Fh,3Fh,7Fh,0FFh,1
So the Bardsword with $48 = 1 and $49 = 1 would do 1d8 damage.
- 3. $A2B0 - $A2B4 selects bit 5-7 from A; in this case the one in brackets: (001)00001 => A = 1
- 4. A is stored in $48
- 5. transfer stack to A
- 6. A (in A is the former value of X again) AND 1F => select bit 0-4 from A; in this case the one in brackets: 001(00001) => A = 1
- 7. A is stored in $49

There's no reference to value 8 Decimal so I'm not sure how it's 1-8 damage. Similarly I'm not sure how other weapons for example are 3-24 and the like.
Weber G
Posts: 125
Joined: Tue Dec 15, 2020 9:58 am

Re: C64 BT2: complete item list

Post by Weber G »

drifting, you're completely right with $48 and $49, but not with the damage of the weapon.

Step 1 - 7 from above just seperate the byte $8356,weapon# in two numbers which are stored in $48 (base damage) and $49 (counter for base damage).

the next steps in the code are:
8. $A2BD - $A2C1 => clear $45 and $46 (MSB and LSB of damage)
9. $A2C3 - $A2C8 => load # of attacks form character address ($9B) and add it to $AA and then store the result in $3B (# of attacks); $AA usually contains 1 (with ZZGO it contains 8, if I'm not wrong).
10. now we have: $3B => # of attacks, $48 => base damage; $49 => counter for base damage; $45/ $46 => damage)

Clear so far?

11. $A2CE - $A2D9: creates a random number (00 - FF) and AND this number with the position of X ($48) in the table $AB32.
table $AB32: 03 07 0F 1F 3F 7F FF
Since we have for the bardsword the value 1 in $48, the random number is ANDed with 07. That means the result in A is 0-7. To this result, 1 is added. This increases the value in A to 1-8.
12. $A2DB - $A2E1: add the content of $45 (in our case 0) to A (1-8) and check if the carry flag = 0 (the carry flag is 1 if the result of the addition is > 255).
If carry = 0 => store A (1-8) in $45, else increase $46 (MSB damage) and store A (1-8) in $45.
13. decrease Y by 1 (Y contains $49 (counter for base damage); if Y >= 0 (BPL means if positive) => jump $A2EF (do the loop again).

Since the bardsword has 1 in $49, the loop is done 2 times (1x for 1 in Y and 1x for 0 in Y). So the damage for the bardsword is 2x 1-8 => 2-16.

That's all.

If you want to calculate the damage of a weapon, you have to seperate the damage byte in bit0-4 and bit5-7 as first step. Then take with the number which results from bit5-7 the number from table $AB32 and add 1. Then add 1 to the number which results from bit0-4. Then multiply both numbers => the result is the max. damage.
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: C64 BT2: complete item list

Post by Darendor »

Darendor wrote: Thu Jan 21, 2021 3:41 pm
Weber G wrote: Thu Jan 21, 2021 2:34 pm

Code: Select all

.C:a341	30	03	  	BMI $A346

What it at $A346? Is it relevant at all?
:?
Weber G
Posts: 125
Joined: Tue Dec 15, 2020 9:58 am

Re: C64 BT2: complete item list

Post by Weber G »

What it at $A346? Is it relevant at all?
Sure, that's relevant. It ends the loop with the # of attacks.

BMI:
https://www.c64-wiki.com/wiki/BMI

At $A346 starts the check if the attacking character is a hunter and if it's a critical hit.
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: C64 BT2: complete item list

Post by Darendor »

And I thought BMI stood for body mass index...
Weber G
Posts: 125
Joined: Tue Dec 15, 2020 9:58 am

Re: C64 BT2: complete item list

Post by Weber G »

And I thought BMI stood for body mass index...
:D
drifting
Posts: 152
Joined: Wed Dec 07, 2011 10:21 pm

Re: C64 BT2: complete item list

Post by drifting »

Weber G wrote: Fri Jan 22, 2021 8:33 am drifting, you're completely right with $48 and $49, but not with the damage of the weapon.
This is interesting. The YdX logic is completely different in DOS BT2 (in BT3 the logic is the same as what you've posted here). The DOS logic is:

Code: Select all

Take the value from $AB32 and add 1                         ; 7 + 1 for the Bardsword
Multiply that by $49 plus 1                                 ; 1 + 1, so mask = 16
Generate a random number between 0 and 127                  ; randomNumber = {0...127}
Divide the random number by the mask and keep the remainder ; value = {0...15}
If the remainder is less than $49, add $49                  ; If value < ($49) then value += $49
I missed the "plus 1" part of the "$49 plus 1" so got 1d8 instead of 2d8.

With that logic, the DOS version has a slight bias for values in the $49 to $49+$49 range since a random value of zero will result in $49 damage too. Looks to be the same in DOS BT1 too. Interesting.
Weber G
Posts: 125
Joined: Tue Dec 15, 2020 9:58 am

Re: C64 BT2: complete item list

Post by Weber G »

Ok, but:

value from $AB32 (bardsword) +1 = 8 (right?)
8 * 2 ($49+1) = 16

then:

random number max. = 127
127 / 16 = 7,9375 => really?

it would make more sense to AND the random number with 16 => 127 (max.) AND 16 = 16

And if the random number is 0 or 1 then it's in this case 2. So the damage is 2-16?

Hope I understood it right!?
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: C64 BT2: complete item list

Post by Darendor »

Would either of you two wizards be able to help me figure out my issue in the Off-Topic forum?
Post Reply