# Skeetendo

’Cause all games were better on the GBC

You are not logged in.

## #1 2014-08-06 19:23:19

halcyon
Member
Registered: 2013-10-14
Post 7/11

### [Red] Problem with Physical/Special Routine

This morning, I altered the CalculateDamage routine at \$3DDCF so that the attack and defense stats used during the calculation are determined according to the move itself, rather than the move's type.

I changed this:

xor a
ld hl, W_DAMAGE ;damage to eventually inflict, intitialise to zero
ldi [hl], a
ld [hl], a
ld hl, W_PLAYERMOVEPOWER
ld a, [hli]     ;*read attack base power
and a
ld d, a         ;*D = attack base, used later
ret z           ;return if attack is zero
ld a, [hl]      ;*test attacking type
cp a, \$14       ;types >= \$14 are all special
jr nc, .specialAttack

To this:

xor a
ld hl, W_DAMAGE ;damage to eventually inflict, intitialise to zero
ldi [hl], a
ld [hl], a
ld hl, W_PLAYERMOVEPOWER
ld a, [hli]     ;*read attack base power
and a
ld d, a         ;*D = attack base, used later
ret z           ;return if attack is zero
jp \$7c00

0F:7C00

ld a,[\$CFD2]     ;load move number into a
ld hl,\$7f00        ;at \$3FF00 is a table of 0x00s and 0x01s. These 0s and 1s are used to determine whether a move is physical or special                                                respectively, and the value of l corresponds to the move number of a given move.
ld l,a                ;load the move number into l
ld a,[hl]            ;load the value of hl into a
dec a
jp z,\$5E16        :if 0, special
jp \$5DE1

The problem is it doesn't work. If the first move I use in the battle is a physical one, then every move of that type will be physical. I hacked Fire Punch (physical) and Ember (special) into Charmander's starting moves and fought Blue in Prof. Oak's lab. If I used Ember first, Fire Punch would do that damage that I would expect it to if it were special and vice-versa. Can anyone help me fix this?

Offline

## #2 2014-08-07 04:37:49

Danny-E 33
Registered: 2012-06-09
Post 811/1,198

### Re: [Red] Problem with Physical/Special Routine

The code looks good. Did you account for the fact that move id's are not 0 indexed? In other words, the first byte at \$3ff00 should be unused, and Pound's physical/special value should actually be located at \$3ff01?

Offline

## #3 2014-08-07 13:50:40

halcyon
Member
Registered: 2013-10-14
Post 8/11

### Re: [Red] Problem with Physical/Special Routine

Yes, I have accounted for that.

EDIT:

Hi Danny, I think that I've solved the problem on my own. I slightly modified the code so that it does the same thing by different means and, for some reason that I have yet to investigate, it works.

0F:5DCF

xor a,a
ld hl,\$D0D7
ldi [hl],a
ld [hl],a
ld hl,\$CFD4
ldi a,[hl]
and a,a
ld d,a
ret z
call \$7C00        ;Calls discrimination routine
jr z,\$5E16         ;If z than special

0F:7C00

ld a,[\$CFD2]
ld hl,\$7F00
ld l,a
dec a
ret

I replaced Charmander with Abra (because there is a great disparity between Abra's Attack and Special stats), initiated a battle with a Nidoran M (because it has identical Defense and Special stats) and made Ember's base power equal to that of Fire Punch in order to avoid doing damage calculations, thus saving time. This discrepancy in damage can be immediately apparent and explained only by the Attack and Special stats. Because Abra has a much higher Special stat than an Attack one, I expected Ember to do noticeably more damage than Fire Punch, and it did. I think that I've got it.

Last edited by halcyon (2014-08-08 01:04:07)

Offline