Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2014-03-03 18:47:30

walk_away21
Member
Registered: 2014-02-20
Post 13/69

Crystal: Updating Growth Move to Gen V / VI Changes

I am working in the Crystal disassembly and I'm wondering if anyone could help with updating Growth to work like the newer generations where it increases Attack and Special Attack. It also sharply increases both in sunlight but that seems way over my head if anyone wants to help with that. (I have not found anywhere which has this code done so if anyone has it done already that would be awesome)

I think the only move in Crystal which changes multiple stats at once is Curse which is tough to follow the code because it raises two stats, lowers one, and functions differently for Ghost type. Would a new Growth have to be implemented similarly with a large chunk of code most likely in a separate .asm file to keep it clean? Here is the current code for Growth's effect:

Growth:
SpecialAttackUp:
    checkobedience
    usedmovetext
    doturn
    specialattackup
    effect0x0a
    effect0x92
    effect0x0c
    statmessageuser
    statupfailtext
    endmove



It clearly needs to also call :

AttackUp:
    checkobedience
    usedmovetext
    doturn
    attackup
    effect0x0a
    effect0x92
    effect0x0c
    statmessageuser
    statupfailtext
    endmove

but is it as simple as just calling this code also for Growth? I'm not sure about the effect 0xXX lines as to what hex they refer to. And what about implementing the sharply increased boosts for when Sunny Day is in effect? Snythesis uses code:

Synthesis:
    checkobedience
    usedmovetext
    doturn
    healday
    endmove


Moonlight and Morning Sun do the same except they call healnite and healmorn respectively.

Offline

#2 2014-03-03 20:52:15

Crystal_
Member
From: Spain
Registered: 2012-09-16
Post 171/430
Website

Re: Crystal: Updating Growth Move to Gen V / VI Changes

The growth effect you want to implement is basically a simplified version of Curse. Curse uses the following battle commands:

Curse:
checkobedience
usedmovetext
doturn
curse
endmove

the curse effect command is:

BattleCommand54: ; 37588
; curse

ld de, BattleMonType1
ld bc, PlayerStatLevels
ld a, [hBattleTurn]
and a
jr z, .go
ld de, EnemyMonType1
ld bc, EnemyStatLevels

.go

; Curse is different for Ghost-types.

ld a, [de]
cp GHOST
jr z, .ghost
inc de
ld a, [de]
cp GHOST
jr z, .ghost


; If no stats can be increased, don't.

; Attack
ld a, [bc]
cp 13 ; max
jr c, .raise

; Defense
inc bc
ld a, [bc]
cp 13 ; max
jr nc, .cantraise

.raise

; Raise Attack and Defense, and lower Speed.

ld a, $1
ld [$c689], a
call AnimateCurrentMove
ld a, $2
call Function36532
call SwitchTurn
call BattleCommand8d
call ResetMiss
call SwitchTurn
call BattleCommand70
call BattleCommand8c
call ResetMiss
call BattleCommand71
jp BattleCommand8c


.ghost

; Cut HP in half and put a curse on the opponent.

call CheckHiddenOpponent
jr nz, .failed

call CheckSubstituteOpp
jr nz, .failed

ld a, BATTLE_VARS_SUBSTATUS1_OPP
call _GetBattleVar
bit 1, [hl]
jr nz, .failed

set 1, [hl]
call AnimateCurrentMove
ld hl, GetHalfMaxHP
call CallBattleCore
ld hl, Function3cc3f
call CallBattleCore
call UpdateUserInParty
ld hl, PutACurseText
jp StdBattleTextBox

.failed
call AnimateFailedMove
jp PrintButItFailed


.cantraise

; Can't raise either stat.

ld b, $8 ; ABILITY
call GetStatName
call AnimateFailedMove
ld hl, WontRiseAnymoreText
jp StdBattleTextBox
; 37618

I see two options here (as long as you want to base the move in curse). Both involve editing Growth commands to be the same as Curse:

Growth:
checkobedience
usedmovetext
doturn
growth
endmove

and both assume that growth is the only move in the game that raises spc atk up one stage. If you wanted to implement a move that only increases spc atk one stage, you'll have to make a new move effect for growth (or just replace one of the unused ones like speeddown2).

The first option is to make a new battle command. You can overwrite one of the unused battle commands like 3c:

BattleCommand3c: ; 36c2c
; unused
ret
; 36c2d

The growth effect command (not to be mistaken with the whole Growth move effect), would look something like this:

ld bc, PlayerStatLevels
ld a, [hBattleTurn]
and a
jr z, .go
ld bc, EnemyStatLevels

.go

; this first part sets up the scenario, that is, load one's own stat levels if it's our turn and vice versa.

; If no stats can be increased, don't.

; Attack
ld a, [bc]
cp 13 ; max
jr c, .raise

; Defense
inc bc ; point to defense
        inc bc ; point to speed
        inc bc ; point to spc attack
ld a, [bc]
cp 13 ; max
jr nc, .cantraise

.raise

; Raise Attack and Special Attack.

ld a, $1
ld [$c689], a
call AnimateCurrentMove
ld a, $2
call Function36532
call BattleCommand70
call BattleCommand8c
call ResetMiss
call BattleCommand73 ; spc atk +1 command
jp BattleCommand8c

Another option would be modifying the curse command a bit with asm is order to make it support both Growth and Curse. At first glance it looks like this would invlove checking hbattleturn and based on that check curmove/curenemymove in order to differentiate between the two moves. But I wouldn't go for this unless you really have problems finding free space.

Offline

#3 2014-03-03 21:35:11

comet
Member
Registered: 2012-04-09
Post 383/679

Re: Crystal: Updating Growth Move to Gen V / VI Changes

effect0xa animates the user coming out of substitute if it's up. effect0x92 plays the move animation without hitting the opponent. effect0xc animates putting the substitute back up.

effect0xb plays the move animation and the hit animation.
"hittarget" does a b c all at once.

Crystal_ wrote:

If you wanted to implement a move that only increases spc atk one stage, you'll have to make a new move effect for growth (or just replace one of the unused ones like speeddown2).

???? You can add new effects and commands freely. Just edit Growth in place:

...

 Growth:
+    checkobedience
+    usedmovetext
+    doturn
+    growth
+    endmove
+
 SpecialAttackUp:
     checkobedience
     usedmovetext
     doturn
     specialattackup
     effect0x0a
     effect0x92
     effect0x0c
     statmessageuser
     statupfailtext
     endmove
...

To add a new command, plop your label at the end of battle/effect_command_pointers.asm:

BattleCommandPointers: ; 3fd28
    ...
    dw BattleCommandaf ; 365a7
    dw GrowthCommand

The function should be in battle/effect_commands.asm.

For "growth" to be recognized as a valid command, you can define a macro at the top (or in macros.asm):

growth: MACRO
    db $b0
ENDM

Last edited by comet (2014-03-03 21:38:10)

Offline

#4 2014-03-03 21:50:44

walk_away21
Member
Registered: 2014-02-20
Post 14/69

Re: Crystal: Updating Growth Move to Gen V / VI Changes

Thanks for the reply. Ya I was thinking of basing it similar to Curse and no other move raises Special Attack one stage so that's not an issue. If I'm working in the disassembly free space isn't a concern correct? I'm new so I could be mistaken but I have added a number of Pokemon to existing trainers and the compiled ROM works fine so I can just call a newly created ASM in the Battle/Effects folder called Growth (which would sit in there with ASMs of Curse, Rollout, Endure, etc) just fine right... ?


Would this code work / be a good start?

BattleCommand54: ; 37588
; growth

    ld de, BattleMonType1
    ld bc, PlayerStatLevels
    ld a, [hBattleTurn]
    and a
    jr z, .go
    ld de, EnemyMonType1
    ld bc, EnemyStatLevels

.go

; If no stats can be increased, don't.

; Attack
    ld a, [bc]
    cp 13 ; max
    jr c, .raise

; Special Attack
    inc bc
    ld a, [bc]
    cp 13 ; max
    jr nc, .cantraise

.raise

[color=blue] Going to have to check here for sunlight here as code below
 ups atk and sp atk by 2 each

Below is how Solarbeam checks for sun and skips charge if it is sunny so somehow 
this code can be modified to fit Growth [/color]

BattleCommand9e: ; 37d02
; skipsuncharge
    ld a, [Weather]
    cp WEATHER_SUN
    ret nz
    ld b, $39 ; charge
    jp SkipToBattleCommand
; 37d0d




    ld a, $1
    ld [$c689], a
    call AnimateCurrentMove
    ld a, $2                                       
    call Function36532                     
    call SwitchTurn
    call BattleCommand8d
    call ResetMiss
    call SwitchTurn
    call BattleCommand77  **atkup2
    call BattleCommand8c
    call ResetMiss
    call BattleCommand7a  **spcatkup2 actually programmed in effect_commands.asm            
    jp BattleCommand8c



; Raise Attack and Special Attack

    ld a, $1
    ld [$c689], a
    call AnimateCurrentMove
    ld a, $2                                      * do these ld commands need changed?
    call Function36532                    * not sure what this is doing or if needs changed
    call SwitchTurn
    call BattleCommand8d
    call ResetMiss
    call SwitchTurn
    call BattleCommand70
    call BattleCommand8c
    call ResetMiss
    call BattleCommand73                *changed for Special Attack instead of Defense
    jp BattleCommand8c


.cantraise

; Can't raise either stat.

    ld b, $8 ; ABILITY
    call GetStatName
    call AnimateFailedMove
    ld hl, WontRiseAnymoreText
    jp StdBattleTextBox
; 37618

And then update to include in the effect_commands.asm :

INCLUDE "battle/effects/growth.asm"


Thoughts? Did that even make sense haha it was a lot of jumbled thoughts.




EDIT: Was typing out response as Comet answered. That's what I thought about adding stuff in
disassmbly. Not compiled yet so no worry about free space.
Does my thought process make sense and is it on the right track?


EDIT 2: Wait, can I just change Solarbeam's sun skip code to

BattleCommand9e: ; 37d02
; skipsuncharge
    ld a, [Weather]
    cp WEATHER_SUN
    ret nz
    ld b, $39 ; *somehow skip to .go2 here and make .go2 start above the sharply increase both stat code 
and then have it skip single increase? by changing jp SkipToBattleCommand to  jp BattleCommand8c ?*

    jp SkipToBattleCommand
; 37d0d

Last edited by walk_away21 (2014-03-03 22:00:16)

Offline

#5 2014-03-03 22:41:32

comet
Member
Registered: 2012-04-09
Post 384/679

Re: Crystal: Updating Growth Move to Gen V / VI Changes

A ret here means the end of the command. The basic structure you're looking for is:

...

    ld a, [Weather]
    cp WEATHER_SUN
    jr z, .double

    <stat up>
    ret

.double
    <stat up 2>
    ret

Offline

#6 2014-03-03 22:55:25

Crystal_
Member
From: Spain
Registered: 2012-09-16
Post 172/430
Website

Re: Crystal: Updating Growth Move to Gen V / VI Changes

Crystal_ wrote:
If you wanted to implement a move that only increases spc atk one stage, you'll have to make a new move effect for growth (or just replace one of the unused ones like speeddown2).
???? You can add new effects and commands freely. Just edit Growth in place:

I think I expressed myself wrong there. What I meant is that, in case he wanted to use the specialattackup1 effect for another custom move, he'd have to make another move effect then, because editing Growth would leave him with no move effects that only increase the special attack one stage.

If I'm working in the disassembly free space isn't a concern correct?

It's not a problem until you have no free space in the bank you are working in, because that would force you to move to another bank. This is not easy to deal with if you are making/editing routines that interact a few times with other routines located in the original bank. But as long as you don't go past 37FFF, it's fine.

Offline

#7 2014-03-03 23:13:16

walk_away21
Member
Registered: 2014-02-20
Post 15/69

Re: Crystal: Updating Growth Move to Gen V / VI Changes

Ok so I am confused here. The part under Special Attack was taken from Curse's effect which was labeled Defense. Do I have to change anything there? Only the first line of Attack and first two lines of Defense differ so most likely something there.


.go


; If no stats can be increased, don't.

; Attack
    ld a, [bc]
    cp 13 ; max
    jr c, .checkSun

; Special Attack
    inc bc
    ld a, [bc]
    cp 13 ; max
    jr nc, .cantraise

As far as the full code goes, how does this look for Growth other than what's above?


BattleCommand54: ; 37588
; growth

    ld de, BattleMonType1
    ld bc, PlayerStatLevels
    ld a, [hBattleTurn]
    and a
    jr z, .go
    ld de, EnemyMonType1
    ld bc, EnemyStatLevels

.go


; If no stats can be increased, don't.

; Attack
    ld a, [bc]
    cp 13 ; max
    jr c, .checkSun

; Special Attack
    inc bc
    ld a, [bc]
    cp 13 ; max
    jr nc, .cantraise


.checkSun

; Check if sunny for sharp increases

    ld a, [Weather]
    cp WEATHER_SUN
    jr z, .double
    
    ld a, $1
    ld [$c689], a
    call AnimateCurrentMove
    ld a, $2
    call Function36532
    call SwitchTurn
    call BattleCommand8d
    call ResetMiss
    call SwitchTurn
    call BattleCommand70
    call BattleCommand8c
    call ResetMiss
    call BattleCommand71
    jp BattleCommand8c


.double

; Raises Attack and Special Attack sharply if sunny

    ld a, $1
    ld [$c689], a
    call AnimateCurrentMove
    ld a, $2
    call Function36532
    call SwitchTurn
    call BattleCommand8d
    call ResetMiss
    call SwitchTurn
    call BattleCommand77
    call BattleCommand8c
    call ResetMiss
    call BattleCommand7a
    jp BattleCommand8c


.cantraise

; Can't raise either stat.

    ld b, $8 ; ABILITY
    call GetStatName
    call AnimateFailedMove
    ld hl, WontRiseAnymoreText
    jp StdBattleTextBox
; 37618

This is in its own .asm file called growth and I included it in effects_commands like this:

INCLUDE "battle/effects/growth.asm"

I changed it in move_effects to this:

Growth:
    checkobedience
    usedmovetext
    doturn
    growth
    endmove

And I changed it in moves to this:

move GROWTH,       EFFECT_GROWTH,              0, NORMAL,   100, 20,   0

Besides fixing up the code in the newly created growth.asm is that everything? I shouldn't have to add a pointer or battle command or anything since the move existed before correct?

Offline

#8 2014-03-04 00:40:50

Crystal_
Member
From: Spain
Registered: 2012-09-16
Post 173/430
Website

Re: Crystal: Updating Growth Move to Gen V / VI Changes

BattleCommand54: ; 37588
; growth

    ld de, BattleMonType1
    ld bc, PlayerStatLevels
    ld a, [hBattleTurn]
    and a
    jr z, .go
    ld de, EnemyMonType1
    ld bc, EnemyStatLevels

.go

Loading the pokemon's type is not necessary now. It was necessary for Curse, because it works differently on ghost pokemon so the type needs to be checked. However, no need to do it in order to handle Growth.




; Attack
    ld a, [bc]
    cp 13 ; max
    jr c, .checkSun

; Special Attack
    inc bc
    ld a, [bc]
    cp 13 ; max
    jr nc, .cantraise

If you only increase register pair bc once, it will point to defense instead of special attack. You have to increase it three times to point to special attack.

ld a, $1
    ld [$c689], a
    call AnimateCurrentMove
    ld a, $2
    call Function36532
    call SwitchTurn
    call BattleCommand8d
    call ResetMiss
    call SwitchTurn
    call BattleCommand70
    call BattleCommand8c
    call ResetMiss
    call BattleCommand71
    jp BattleCommand8c

This piece of code will decrease speed and increase attack and defense if copied directly from curse. Firstly, the part until call BattleCommand70, is how Curse lowers your speed. So that part has to be removed. Secondly, battlecommand71 increases defense, but you want battlecommand73 to increase special attack instead.

Use the code I gave you in the lastest 'quote' of my first post. That handles everything but the sunny day boost. The check for whether sunny day is active or not should be on the last block of the code, which is:

ld a, $1
ld [$c689], a
call AnimateCurrentMove
ld a, $2
call Function36532
;********************;
call BattleCommand70
call BattleCommand8c
call ResetMiss
call BattleCommand73 ; spc atk +1 command
jp BattleCommand8c

The part behind the asterisks makes growth increment attack and special attack by one stage. As comet has already said in his last post, this is the structure you have to use (just qoting him here):

ld a, [Weather]
    cp WEATHER_SUN
    jr z, .double

    <stat up>
    ret

.double
    <stat up 2>
    ret

This:    
<stat up>
    ret

stands for the five lines behind the asterisks in my own quote above.

And that:  
  <stat up 2>
    ret

is the same but with battlecommands 70 and 73 changed to their equivalent 'increase_stat_by_2_stages commands.

EDIT: Now that I see it, if you end with the ret instruction like comet said, jp BattleCommand8c should be call BattleCommand8c instead, unless i'm missing something.

Last edited by Crystal_ (2014-03-04 00:47:20)

Offline

#9 2014-03-04 02:26:25

walk_away21
Member
Registered: 2014-02-20
Post 16/69

Re: Crystal: Updating Growth Move to Gen V / VI Changes

Alright thanks. Whoops I changed the command to raise Special Attack instead of Defense in my quote but not in the asm file lol. I had it correct in the sharply increase part haha.

Ok I see it in your post now. I am new to assembly so I really appreciate the help. I have never worked with Gameboy asm so I was getting very confused with what some commands were. For example the inc bc makes a lot more sense now that I know it's incrementing the pointer to the correct base stat. I found a good pdf of Gameboy commands just now so this should help.

Lastly, how do I know to use jp or call? Both seem to jump to a certain address. Is there a certain distance which changes which one to use? I'll change it to call for now. Here is the (hopefulyl) finished code for growth.asm


BattleCommand54: ; 37588
; growth

    ld bc, PlayerStatLevels
    ld a, [hBattleTurn]
    and a
    jr z, .go
    ld de, EnemyMonType1  *******How much of this do I need to load? Not sure what a move is require to. I'm guessing enemy mon type
    ld bc, EnemyStatLevels ******* doesn't matter because code no longer can be ghost type affecting other mon? How much to keep?

.go


; If no stats can be increased, don't.

; Attack
    ld a, [bc]
    cp 13 ; max
    jr c, .checkSun

; Special Attack
    inc bc
    inc bc
    inc bc
    ld a, [bc]
    cp 13 ; max
    jr nc, .cantraise


.checkSun

; Check if sunny for sharp increases

    ld a, [Weather]
    cp WEATHER_SUN
    jr z, .double
    
    ld a, $1
    ld [$c689], a
    call AnimateCurrentMove
    ld a, $2
    call Function36532
    call BattleCommand70
    call BattleCommand8c
    call ResetMiss
    call BattleCommand73
    jp BattleCommand8c


.double

; Raises Attack and Special Attack sharply if sunny

    ld a, $1
    ld [$c689], a
    call AnimateCurrentMove
    ld a, $2
    call Function36532
    call BattleCommand77
    call BattleCommand8c
    call ResetMiss
    call BattleCommand7a
    jp BattleCommand8c


.cantraise

; Can't raise either stat.

    ld b, $8 ; ABILITY
    call GetStatName
    call AnimateFailedMove
    ld hl, WontRiseAnymoreText
    jp StdBattleTextBox
; 37618

Offline

#10 2014-03-04 02:29:13

walk_away21
Member
Registered: 2014-02-20
Post 17/69

Re: Crystal: Updating Growth Move to Gen V / VI Changes

A cool find I noticed while editing Growth in the disassembly is this under it's own move

FakeOut:
    checkobedience
    usedmovetext
    doturn
    checkhit
    fakeout
    hittarget
    resulttext
    endmove

So Fake Out was meant to appear in Gen II? It calls the effect fakeout but it doesn't exist with the other files in there like Mirror Move, Endure, etc. Pretty cool.

Offline

#11 2014-03-04 04:01:55

comet
Member
Registered: 2012-04-09
Post 385/679

Re: Crystal: Updating Growth Move to Gen V / VI Changes

walk_away21 wrote:

how do I know to use jp or call? Both seem to jump to a certain address. Is there a certain distance which changes which one to use?

Calls return, jumps don't.

It's common to optimize "call x \ ret" as "jp x" but it's less convenient.

Offline

#12 2014-03-04 04:10:00

walk_away21
Member
Registered: 2014-02-20
Post 18/69

Re: Crystal: Updating Growth Move to Gen V / VI Changes

comet wrote:
walk_away21 wrote:

how do I know to use jp or call? Both seem to jump to a certain address. Is there a certain distance which changes which one to use?

Calls return, jumps don't.

It's common to optimize "call x \ ret" as "jp x" but it's less convenient.

So then I would want jp? Both jp s are at the end of that trail of the function. After applying the boosts for sharply increase or normal increase I don't want to return to growth function right?

Offline

#13 2014-03-04 04:12:43

comet
Member
Registered: 2012-04-09
Post 386/679

Re: Crystal: Updating Growth Move to Gen V / VI Changes

You're returning to a ret. It's down to preference.

Offline

#14 2014-03-04 05:42:12

walk_away21
Member
Registered: 2014-02-20
Post 19/69

Re: Crystal: Updating Growth Move to Gen V / VI Changes

Comet you have been a lifesaver to me haha! But I need you on one last error... this time on compile. I fixed two other errors because I forgot to add the macro and new command, but this one I'm not sure what's up.

ERROR: main.tx(38397) -> battle/effect_commands.tx(10612) :
Section can't contain initialized data or section limit exceeded
make: *** [main.o] Error 5


This is what is at line 10612 in effect_commands:

SkipToBattleCommand: ; 37e8c
; Skip over commands until reaching command b.
    ld a, [BattleScriptBufferLoc + 1]
    ld h, a
    ld a, [BattleScriptBufferLoc]
    ld l, a
******.asm_37e94****** Line 10612
    ld a, [hli]
    cp b
    jr nz, .asm_37e94

    ld a, h
    ld [BattleScriptBufferLoc + 1], a
    ld a, l
    ld [BattleScriptBufferLoc], a
    ret
; 37ea1

It's near the end of the file but not THE end. The only thing I added in this file was the include for growth.asm


Is this what Crystal was referring to about? :

It's not a problem until you have no free space in the bank you are working in, because that would force you to move to another bank. This is not easy to deal with if you are making/editing routines that interact a few times with other routines located in the original bank. But as long as you don't go past 37FFF, it's fine.

Offline

#15 2014-03-04 05:52:51

comet
Member
Registered: 2012-04-09
Post 388/679

Re: Crystal: Updating Growth Move to Gen V / VI Changes

yep

put your code in some other bank. you can call it with:

BattleCommand54:
; growth
    callba _BattleCommand54
    ret

if you don't care where it ends up, define a generic romx section like so:

PUSHS

SECTION "Battle Command 54", ROMX

_BattleCommand54:
    <your code>

POPS

PUSHS/POPS save the section context so the rest of the bank continues as normal. it's only required if you want to put the new section in the middle of the file.

Last edited by comet (2014-03-04 05:54:10)

Offline

#16 2014-03-05 02:27:36

walk_away21
Member
Registered: 2014-02-20
Post 20/69

Re: Crystal: Updating Growth Move to Gen V / VI Changes

Ok I'm not gonna lie I know next to nothing about ROM banks and I'm not sure when you say:

put your code in some other bank. you can call it with:
BattleCommand54:
; growth
    callba _BattleCommand54
    ret

Where I should put this? And would I able to keep everything in it's current spot if I added this?

Offline

#17 2014-03-05 03:24:06

Miksy91
Member
Registered: 2010-10-16
Post 2,070/2,311

Re: Crystal: Updating Growth Move to Gen V / VI Changes

Gameboy works so that all the rom data has to be split in smaller pieces. All of these pieces can fit 0x4000 bytes of data and each 0x4000 byte area is a rom bank.
We can access two rom banks at the same time; rom bank 0 and a variable rom bank. So whenever we need to access other parts of the rom, we have to switch the variable rom bank.

(This was actually a pretty bad introduction to what rom banks are, but you'll get the necessary point I believe.)

Offline

#18 2014-03-05 17:58:07

walk_away21
Member
Registered: 2014-02-20
Post 21/69

Re: Crystal: Updating Growth Move to Gen V / VI Changes

Miksy91 wrote:

Gameboy works so that all the rom data has to be split in smaller pieces. All of these pieces can fit 0x4000 bytes of data and each 0x4000 byte area is a rom bank.
We can access two rom banks at the same time; rom bank 0 and a variable rom bank. So whenever we need to access other parts of the rom, we have to switch the variable rom bank.

(This was actually a pretty bad introduction to what rom banks are, but you'll get the necessary point I believe.)

Ok that makes sense. I'm just not sure how / where Comet's code would go to fix the situation of a full ROM bank.

Offline

#19 2014-03-05 20:48:03

Miksy91
Member
Registered: 2010-10-16
Post 2,071/2,311

Re: Crystal: Updating Growth Move to Gen V / VI Changes

I'd imagine that this thing here

comet wrote:

if you don't care where it ends up, define a generic romx section like so:

PUSHS

SECTION "Battle Command 54", ROMX

_BattleCommand54:
    <your code>

POPS

takes care of everything for you. It pushes all the registers onto the stack, calls the routine you want to access (that is located in another rom bank), pops all the register values, and then you would just continue your asm routine whatever way may that be.

Making lots of code sequences (that call other code sequences that do the same thing) like that one could be dangerous though since the stack would take a lot of ram space, but that's really nothing to worry about. You don't even have to think about that actually.

Last edited by Miksy91 (2014-03-05 20:50:22)

Offline

#20 2014-03-05 20:53:39

walk_away21
Member
Registered: 2014-02-20
Post 22/69

Re: Crystal: Updating Growth Move to Gen V / VI Changes

So I would put that code where this currently is?

INCLUDE "battle/effects/growth.asm"

?

Offline

#21 2014-03-06 06:04:34

walk_away21
Member
Registered: 2014-02-20
Post 23/69

Re: Crystal: Updating Growth Move to Gen V / VI Changes

Ok I added this to effectcommands.asm

PUSHS

SECTION "GrowthCommand", ROMX

_GrowthCommand:
; growth

    ld bc, PlayerStatLevels
    ld a, [hBattleTurn]
    and a
    jr z, .growth
    ld de, EnemyMonType1
    ld bc, EnemyStatLevels

.growth


; If no stats can be increased, don't.

; Attack
    ld a, [bc]
    cp 13 ; max
    jr c, .checkSun

; Special Attack
    inc bc
    inc bc
    inc bc
    ld a, [bc]
    cp 13 ; max
    jr nc, .cantraisestats


.checkSun

; Check if sunny for sharp increases

    ld a, [Weather]
    cp WEATHER_SUN
    jr z, .double
    
    ld a, $1
    ld [$c689], a
    call AnimateCurrentMove
    ld a, $2
    call Function36532
    call BattleCommand70
    call BattleCommand8c
    call ResetMiss
    call BattleCommand73
    jp BattleCommand8c


.double

; Raises Attack and Special Attack sharply if sunny

    ld a, $1
    ld [$c689], a
    call AnimateCurrentMove
    ld a, $2
    call Function36532
    call BattleCommand77
    call BattleCommand8c
    call ResetMiss
    call BattleCommand7a
    jp BattleCommand8c


.cantraisestats

; Can't raise either stat.

    ld b, $8 ; ABILITY
    call GetStatName
    call AnimateFailedMove
    ld hl, WontRiseAnymoreText
    jp StdBattleTextBox
; 37618
POPS

Instead of using INCLUDE "battle/effects/growth.asm" and now I get this error:

Unknown symbol 'GrowthCommand'


I added this to effect_command_pointers.asm so I am not sure what I did wrong

    dw GrowthCommand

Offline

#22 2014-03-06 06:10:02

comet
Member
Registered: 2012-04-09
Post 389/679

Re: Crystal: Updating Growth Move to Gen V / VI Changes

You've defined _GrowthCommand. You still need to call it from GrowthCommand.

comet wrote:
GrowthCommand:
    callba _GrowthCommand
    ret

You can also keep your include:

PUSHS
SECTION "Growth Command", ROMX
INCLUDE "battle/effects/growth.asm"
POPS

Offline

#23 2014-03-06 15:45:26

walk_away21
Member
Registered: 2014-02-20
Post 24/69

Re: Crystal: Updating Growth Move to Gen V / VI Changes

Ok I really am so frustrated right now. Now matter what I try I keep getting:

Unknown symbol 'EFFECT_GROWTH'

Now, I had that originally because moves also put in the battles/effects folders like Curse, Endure, and Rollout had their own .asm file in that folder and in moves.asm are called for example by move CURSE,        EFFECT_CURSE. Now, I tried to mimic Curse and do the same thing with Growth. I have tried various suggestions here and keep getting this error. I am going to post all things I have added related to Growth and in which .asm file they are in. I have to be messing up somewhere despite major help and patience from Comet.

moves.asm:

move GROWTH,       EFFECT_GROWTH,              0, NORMAL,   100, 20,   0

effect_commands.asm:

PUSHS

SECTION "Growth Command", ROMX

_GrowthCommand:
; growth

    ld bc, PlayerStatLevels
    ld a, [hBattleTurn]
    and a
    jr z, .growth
    ld de, EnemyMonType1
    ld bc, EnemyStatLevels

.growth


; If no stats can be increased, don't.

; Attack
    ld a, [bc]
    cp 13 ; max
    jr c, .checkSun

; Special Attack
    inc bc
    inc bc
    inc bc
    ld a, [bc]
    cp 13 ; max
    jr nc, .cantraisestats


.checkSun

; Check if sunny for sharp increases

    ld a, [Weather]
    cp WEATHER_SUN
    jr z, .double
    
    ld a, $1
    ld [$c689], a
    call AnimateCurrentMove
    ld a, $2
    call Function36532
    call BattleCommand70
    call BattleCommand8c
    call ResetMiss
    call BattleCommand73
    jp BattleCommand8c


.double

; Raises Attack and Special Attack sharply if sunny

    ld a, $1
    ld [$c689], a
    call AnimateCurrentMove
    ld a, $2
    call Function36532
    call BattleCommand77
    call BattleCommand8c
    call ResetMiss
    call BattleCommand7a
    jp BattleCommand8c


.cantraisestats

; Can't raise either stat.

    ld b, $8 ; ABILITY
    call GetStatName
    call AnimateFailedMove
    ld hl, WontRiseAnymoreText
    jp StdBattleTextBox
; 37618

INCLUDE "battle/effects/growth.asm"
POPS

growth.asm:

GrowthCommand: ; 37588
; growth
    callba _GrowthCommand
    ret

effect_command_pointers.asm:

dw GrowthCommand

I have moved stuff around in growth.asm and effect_commands.asm with the PUSHS and POPS but nothing seems to get rid of or at least change that error. Is it not recognizing it because I'm pushing it into a different ROM bank, the include is inside a PUSH statement, or is it now defined wrong inside effect_command_pointers? I'm trying to think through this error and I can't seem to put it together. I feel bad and somewhat dumb for all these posts but  I just can't get it to work.

Offline

#24 2014-03-06 16:06:10

stag019
Idea Killer
Registered: 2011-01-05
Post 575/630

Re: Crystal: Updating Growth Move to Gen V / VI Changes

EFFECT_GROWTH is not defined in constants/battle_constants.asm. You'll need to define it.


You can try to hide yourself in this world of pretend; when the paper's crumpled up, it can't be perfect again.

Offline

#25 2014-03-06 16:25:28

walk_away21
Member
Registered: 2014-02-20
Post 25/69

Re: Crystal: Updating Growth Move to Gen V / VI Changes

stag019 wrote:

EFFECT_GROWTH is not defined in constants/battle_constants.asm. You'll need to define it.

Omg you are a lifesaver! Now just to test that it actually works haha.



EDIT: Lol used Growth and it reset the game. At least I have something to work with now.

Last edited by walk_away21 (2014-03-06 16:37:24)

Offline

Board footer

Powered by FluxBB