Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2020-05-08 13:22:50

CharizardSlayer
New member
From: Canada
Registered: 2020-05-08
Post 1/6

Doubts and more with Pokered

Hi to all of you!, I discovered the amazing pokered disassembly yesterday, I've been messing around with it for a while, you know, basic stuff like editing sprites, trainer teams, and "correcting" some typing problems, but let's get back to the point, if I am honest with you, I'm so dumb with these kind of things lol, that's why I am here looking for help in order to do the following and improve my Gen 1 experience:

It's possible to :

1- Give Lorelei, Bruno and Agatha their proper gym leader theme instead of the trainer theme?
2- Assing any in game music to Rocket Grunts battles? Like playing the Rocket Hideout theme instead of the regular trainer theme.
3- Change Victory Road's cave music to "MUSIC_INDIGO_PLATEAU", I've seen a post here but with Oak's speech instead, however I can't find where the music for Victory road's cave is.
4- Expand the bag capacity to more than 30 items? when i try to expand it to like, 80 items, I get the error "Unable to load fixed WRAMX section into bank $201", when I open the "wram.asm" thing on bank 201 is this wTempoModifier:: ;c0f2, what do I have to do there?
5-I read another post talking about team moves in order to give trainers custom moves, how do I do that?  for example, let's say I want Brock's Onix with the moves Rock Throw, Tackle, Hyper Beam, Rest, his geodude with Dig, Body slam, Strength, tackel, And so on with other trainers teams, so how do I do thet with this "Team Nives" thing.
6-Properly expand the Repels and Safari Zone Steps to more steps?


EDIT: And if it's possible, how can I do it? So yeah, that's all, sorry for being a noob and dumb with these things lol.

Last edited by CharizardSlayer (2020-05-08 14:19:29)


NOOB 4EVER

Offline

#2 2020-05-09 05:38:28

Cutie Sith
Member
Registered: 2020-05-04
Post 3/10

Re: Doubts and more with Pokered

While I am more familiar with Yellow and it seems to be easier on there but the file you want to look i for moves of trainers like the gym leaders is data/trainer_moves.asm Now I am a noob too but for red reading it it says this.

; first byte:  pokemon in the trainer's party that gets the move
; second byte: move
; unterminated
db 1,BIDE
db 1,BUBBLEBEAM
db 2,THUNDERBOLT
db 2,MEGA_DRAIN
db 3,TOXIC
db 3,PSYWAVE
db 3,FIRE_BLAST
db 4,FISSURE

I assume it means this. that db 1,Rock Throw, Tackle, Hyper Beam, Rest

would mean it would give his Onix those moves. If not I hope my own stupidity will bait someone out here to give you help too lel.

Offline

#3 2020-05-10 23:20:20

Danny-E 33
Administrator
Registered: 2012-06-09
Post 1,163/1,190

Re: Doubts and more with Pokered

CharizardSlayer wrote:

1- Give Lorelei, Bruno and Agatha their proper gym leader theme instead of the trainer theme?
2- Assing any in game music to Rocket Grunts battles? Like playing the Rocket Hideout theme instead of the regular trainer theme.

Both of these questions can be answered by modifying the routine called "PlayBattleMusic" from audio.asm.

CharizardSlayer wrote:

3- Change Victory Road's cave music to "MUSIC_INDIGO_PLATEAU", I've seen a post here but with Oak's speech instead, however I can't find where the music for Victory road's cave is.

Map songs can be customized by editing data/map_songs.asm.

CharizardSlayer wrote:

4- Expand the bag capacity to more than 30 items? when i try to expand it to like, 80 items, I get the error "Unable to load fixed WRAMX section into bank $201", when I open the "wram.asm" thing on bank 201 is this wTempoModifier:: ;c0f2, what do I have to do there?

Accomplishing this would be a rather large effort and should be revisited once you have a strong grasp of the Gameboy memory map.

CharizardSlayer wrote:

5-I read another post talking about team moves in order to give trainers custom moves, how do I do that?  for example, let's say I want Brock's Onix with the moves Rock Throw, Tackle, Hyper Beam, Rest, his geodude with Dig, Body slam, Strength, tackel, And so on with other trainers teams, so how do I do thet with this "Team Nives" thing.

Currently, custom trainer moves only apply to gym leaders and each gym leader can only have 1 custom move. If you want to expand either of these limitations, you would need to modify the routine called "ReadTrainer" from engine/battle/read_trainer_party.asm.
I am not sure what you are referring to when you say "Team Nives".

CharizardSlayer wrote:

6-Properly expand the Repels and Safari Zone Steps to more steps?

Editing the value for the repel counters can be done by modifying the routines called "ItemUseRepel", "ItemUseSuperRepel", and "ItemUseMaxRepel" from engine/items/items.asm.
Editing the Safari Zone steps can be done by modifying "SafariZoneEntranceText4" from scripts/SafariZoneGate.asm.

Offline

#4 2020-05-11 00:54:35

CharizardSlayer
New member
From: Canada
Registered: 2020-05-08
Post 2/6

Re: Doubts and more with Pokered

Hello!, First of all, Thanks, I've mange to do almost everything I wanted, however I'm having problems with two minor things.
First, changing
ItemUseRepel:
ld b,100
to:
ItemUseRepel:
ld b,400
Gives me this error:

ERROR:  main.asm(121) -> engine/items/items.asm(1537) :
        Expression must be 8-bit

What am I doing wrong?

the other thing is, how especifaclly can I assing the battle music to ROCKETS?

Oh and by "Team Nives" I meant TeamMoves, sorry about that.


NOOB 4EVER

Offline

#5 2020-05-11 01:44:40

Danny-E 33
Administrator
Registered: 2012-06-09
Post 1,169/1,190

Re: Doubts and more with Pokered

On the Gameboy, the general purpose CPU registers are 8-bits.
The 'b' register is one of these 8-bit registers.
8-bit numbers can range from 0 to 255, inclusive.
Therefore, you cannot put a number as large as 400 into the 'b' register.

Regarding the Rocket battle theme, take a look at this excerpt from the routine "PlayBattleMusic":

.notGymLeaderBattle
    ld a, [wCurOpponent]
    cp OPP_ID_OFFSET
    jr c, .wildBattle
    cp OPP_SONY3
    jr z, .finalBattle
    cp OPP_LANCE
    jr nz, .normalTrainerBattle
    ld a, MUSIC_GYM_LEADER_BATTLE ; lance also plays gym leader theme
    jr .playSong
.normalTrainerBattle
    ld a, MUSIC_TRAINER_BATTLE
    jr .playSong
.finalBattle
    ld a, MUSIC_FINAL_BATTLE
    jr .playSong
.wildBattle
    ld a, MUSIC_WILD_BATTLE
.playSong
    jp PlayMusic

Since you are new to assembly, let's go through this step-by-step:


ld a, [wCurOpponent]

This takes an 8-bit value from ram and stores it in the 8-bit register 'a'.
This ram location is named wCurOpponent, for readability. It represents the ID of the Pokemon or trainer class the player is about to battle.



cp OPP_ID_OFFSET
jr c, .wildBattle

The first line compares the value in the 'a' register with the value OPP_ID_OFFSET (a constant equal to 200). This is because all Pokemon IDs are less than 200 and all trainer class IDs are greater than 200.
This 'cp' compare instruction will set the 'c' flag if register 'a' contains a value smaller than OPP_ID_OFFSET (and unsets the 'c' flag otherwise). (This instruction also sets another flag discussed later.)
The 'c' flag is a CPU status flag that gets set (and unset) by certain instructions and can be used by other instructions to make decisions. (Flags can only have the value 1 (set) or 0 (unset))
In this case, the next instruction (jr c) will "jump" (move to a new location in code) only if the 'c' flag is set.
Therefore, these two lines of code will jump to a new location (labelled as '.wildBattle' further down in the routine) if the ID of the current opponent is a Pokemon ID.
Otherwise, the ID is a trainer class ID, so code execution continues to the next line (because the jump was not taken).



cp OPP_SONY3
jr z, .finalBattle

Somewhat similar to the previous few lines of code, this will compare the value in the 'a' register to the trainer class ID, OPP_SONY3 (the final rival battle after the Elite Four).
However this time, the 'jr z' instruction will only jump to the new destination if the 'z' flag is set.
The 'z' flag is another CPU status flag. In this case, the 'cp' instruction will set the 'z' flag if the value in register 'a' is equal to OPP_SONY3 (and unsets the 'z' flag otherwise).
So, these few lines of code jump to '.finalBattle' if the opponent is the final rival.



cp OPP_LANCE
jr nz, .normalTrainerBattle
ld a, MUSIC_GYM_LEADER_BATTLE ; lance also plays gym leader theme
jr .playSong

Again, this is somewhat similar to the previous cases.
The 'a' register is compared to OPP_LANCE, which will set or unset the 'c' and 'z' flags appropriately.
The 'jr nz' instruction will jump to the new destination (.normalTrainerBattle) if the opponent is NOT Lance.
Otherwise, if the opponent is lance, the value of MUSIC_GYM_LEADER_BATTLE is loaded into the 'a' register.
Now this time, the 'jr' instruction is an unconditional jump (because there is no 'c', 'nc', 'z', or 'nz' operand).
If an unconditional jump instruction is executed, then the CPU will always jump to the destination (.playSong in this case).



.normalTrainerBattle
    ld a, MUSIC_TRAINER_BATTLE
    jr .playSong
.finalBattle
    ld a, MUSIC_FINAL_BATTLE
    jr .playSong
.wildBattle
    ld a, MUSIC_WILD_BATTLE
.playSong
    jp PlayMusic

Lastly, these are all the labels referenced above throughout the routine.
Each of these labels loads the appropriate song ID into the 'a' register and then concludes the routine by jumping to the 'PlayMusic' routine. (A core sound engine routine.)



If this was a little hard to follow, you can review the Gameboy instruction set here and here.

Once you are familiar with the CPU registers and instructions, you should be able to come up with an approach for modifying this routine to assign a custom song to other trainer class IDs (like Rockets).

Offline

#6 2020-05-11 18:02:13

CharizardSlayer
New member
From: Canada
Registered: 2020-05-08
Post 3/6

Re: Doubts and more with Pokered

Danny-E 33 wrote:

On the Gameboy, the general purpose CPU registers are 8-bits.
The 'b' register is one of these 8-bit registers.
8-bit numbers can range from 0 to 255, inclusive.
Therefore, you cannot put a number as large as 400 into the 'b' register.

Regarding the Rocket battle theme, take a look at this excerpt from the routine "PlayBattleMusic":

.notGymLeaderBattle
    ld a, [wCurOpponent]
    cp OPP_ID_OFFSET
    jr c, .wildBattle
    cp OPP_SONY3
    jr z, .finalBattle
    cp OPP_LANCE
    jr nz, .normalTrainerBattle
    ld a, MUSIC_GYM_LEADER_BATTLE ; lance also plays gym leader theme
    jr .playSong
.normalTrainerBattle
    ld a, MUSIC_TRAINER_BATTLE
    jr .playSong
.finalBattle
    ld a, MUSIC_FINAL_BATTLE
    jr .playSong
.wildBattle
    ld a, MUSIC_WILD_BATTLE
.playSong
    jp PlayMusic

Since you are new to assembly, let's go through this step-by-step:


ld a, [wCurOpponent]

This takes an 8-bit value from ram and stores it in the 8-bit register 'a'.
This ram location is named wCurOpponent, for readability. It represents the ID of the Pokemon or trainer class the player is about to battle.



cp OPP_ID_OFFSET
jr c, .wildBattle

The first line compares the value in the 'a' register with the value OPP_ID_OFFSET (a constant equal to 200). This is because all Pokemon IDs are less than 200 and all trainer class IDs are greater than 200.
This 'cp' compare instruction will set the 'c' flag if register 'a' contains a value smaller than OPP_ID_OFFSET (and unsets the 'c' flag otherwise). (This instruction also sets another flag discussed later.)
The 'c' flag is a CPU status flag that gets set (and unset) by certain instructions and can be used by other instructions to make decisions. (Flags can only have the value 1 (set) or 0 (unset))
In this case, the next instruction (jr c) will "jump" (move to a new location in code) only if the 'c' flag is set.
Therefore, these two lines of code will jump to a new location (labelled as '.wildBattle' further down in the routine) if the ID of the current opponent is a Pokemon ID.
Otherwise, the ID is a trainer class ID, so code execution continues to the next line (because the jump was not taken).



cp OPP_SONY3
jr z, .finalBattle

Somewhat similar to the previous few lines of code, this will compare the value in the 'a' register to the trainer class ID, OPP_SONY3 (the final rival battle after the Elite Four).
However this time, the 'jr z' instruction will only jump to the new destination if the 'z' flag is set.
The 'z' flag is another CPU status flag. In this case, the 'cp' instruction will set the 'z' flag if the value in register 'a' is equal to OPP_SONY3 (and unsets the 'z' flag otherwise).
So, these few lines of code jump to '.finalBattle' if the opponent is the final rival.



cp OPP_LANCE
jr nz, .normalTrainerBattle
ld a, MUSIC_GYM_LEADER_BATTLE ; lance also plays gym leader theme
jr .playSong

Again, this is somewhat similar to the previous cases.
The 'a' register is compared to OPP_LANCE, which will set or unset the 'c' and 'z' flags appropriately.
The 'jr nz' instruction will jump to the new destination (.normalTrainerBattle) if the opponent is NOT Lance.
Otherwise, if the opponent is lance, the value of MUSIC_GYM_LEADER_BATTLE is loaded into the 'a' register.
Now this time, the 'jr' instruction is an unconditional jump (because there is no 'c', 'nc', 'z', or 'nz' operand).
If an unconditional jump instruction is executed, then the CPU will always jump to the destination (.playSong in this case).



.normalTrainerBattle
    ld a, MUSIC_TRAINER_BATTLE
    jr .playSong
.finalBattle
    ld a, MUSIC_FINAL_BATTLE
    jr .playSong
.wildBattle
    ld a, MUSIC_WILD_BATTLE
.playSong
    jp PlayMusic

Lastly, these are all the labels referenced above throughout the routine.
Each of these labels loads the appropriate song ID into the 'a' register and then concludes the routine by jumping to the 'PlayMusic' routine. (A core sound engine routine.)



If this was a little hard to follow, you can review the Gameboy instruction set here and here.

Once you are familiar with the CPU registers and instructions, you should be able to come up with an approach for modifying this routine to assign a custom song to other trainer class IDs (like Rockets).

Hey, Thanks! I've manage to succesfully change the music that plays during Rocket battles, however.... If i try to assign a song that it's not any battle theme(final battle, gym leader battle, Wild battle, trainer battle) for example MUSIC_DUNGEON1 or MUSIC_SILPH_CO, the songs won't play (no sound at all) during battles, my best guess is that it's not possible to assign overworld songs to trainer battles. However, I would like to hear your opinion, since you know a lot.

Last edited by CharizardSlayer (2020-05-11 18:11:45)


NOOB 4EVER

Offline

#7 2020-05-11 18:38:29

Danny-E 33
Administrator
Registered: 2012-06-09
Post 1,170/1,190

Re: Doubts and more with Pokered

One of the limitations of Pokemon Red is that the game contains 3 entire identical copies of the sound engine. Each of the copies of the sound engine is grouped with a different set of songs.

The battle engine always uses sound engine #2, which contains the battle themes as well as all the battle attack sound effects.
All the other songs (overworld themes, title screen, credits, etc) are split across sound engine #1 and sound engine #3.

Attempting to play a song while the wrong sound engine is loaded will result in glitchy behavior.

There's no easy way around this limitation, but you can use this hack of pokered instead:
https://github.com/dannye/pokered-crysaudio

This replaces all 3 copies of the sound engine with a single copy of the Pokemon Crystal sound engine.
The Pokemon Crystal sound engine is pretty similar to the Pokemon Red sound engine but has extra features and greater flexibility. For example, you can play a song from any bank at any time.



Your other option is to add a new song to sound engine #2 (take a look at audio.asm)

Offline

#8 2020-05-11 23:09:41

CharizardSlayer
New member
From: Canada
Registered: 2020-05-08
Post 4/6

Re: Doubts and more with Pokered

Yeah, Crysaudio does what I want, however....I was using  pokered-gbc (I believe is the one made by Drenn1 and you) because I like the features it has. If possible, what pokered-gbc files should I put inside crysaudio in order to give it the characteristics of pokered-gbc or what crysaudio files should I put inside pokered-gbc in order to give it the fcharacteristics of crysaudio?

Last edited by CharizardSlayer (2020-05-11 23:15:39)


NOOB 4EVER

Offline

#9 2020-05-11 23:36:22

Mateo
Member
Registered: 2009-11-25
Post 3,639/3,655

Re: Doubts and more with Pokered

Luckily, there is already a branch of pokered-gbc with crysaudio included.

The only thing that branch is missing would be a few commits I added to it later, for polished map support and to adjust the colors on a few things and stuff. Shouldn't be too difficult to merge the handful of new commits from 'master' into 'crysaudio' though.


I am not very active on this forum. I only pop in from time to time.

Offline

#10 2020-05-12 12:06:12

CharizardSlayer
New member
From: Canada
Registered: 2020-05-08
Post 5/6

Re: Doubts and more with Pokered

Mateo wrote:

Luckily, there is already a branch of pokered-gbc with crysaudio included.

The only thing that branch is missing would be a few commits I added to it later, for polished map support and to adjust the colors on a few things and stuff. Shouldn't be too difficult to merge the handful of new commits from 'master' into 'crysaudio' though.

Thanks a lot Mateo, that branch is perfect, the only I would like to know how to do is play the original RBY music instead of the GSC music, because when I compile the game, the music that sounds is always from GSC. How can I change that?


NOOB 4EVER

Offline

#11 2020-05-14 00:37:55

Danny-E 33
Administrator
Registered: 2012-06-09
Post 1,172/1,190

Re: Doubts and more with Pokered

In constants.asm, change the value of GEN_2_MUSIC from 1 to 0

Look at crysaudio/red_pointers.asm to see why this works

Offline

#12 2020-05-14 12:17:59

CharizardSlayer
New member
From: Canada
Registered: 2020-05-08
Post 6/6

Re: Doubts and more with Pokered

Yup, that did it, however now I'm having problems with......nah, I'm just kidding! Everything is working perfectly! Thanks Mateo and special thanks to you Danny-E 33, thanks for being patient with me and thanks for your explanations, I really appreciate your help. Thanks a lot!

Last edited by CharizardSlayer (2020-05-14 12:20:17)


NOOB 4EVER

Offline

Board footer

Powered by FluxBB