Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2012-07-14 20:35:41

Danny-E 33
Administrator
Registered: 2012-06-09
Post 57/1,023

Pokemon Red: Legendary Encounters

Mateo said this about the legendary encounters such as Mewtwo in GSC:

Mateo wrote:

Also, here is an example script for a standing Pokemon, such as Mewtwo.

83-PlayPokemonCry
XX-PokemonNumber
00-Part of cry code
47-LoadFont
4C-LoadText
XXXX-Pointer (2-byte) to text for Pokemon
53-CloseTextbox
49-UnloadFont
67-SetLastPersonTalkedTo
FF-None
1E-SetTypeOfFight
03-SetTypeOfFight
XX-TYpe(See list)
5C-LoadPokemonData
XX-Pokemon
YY-Level
5E-StartBattle
5F-ReloadMap/Return to PC is lost
33-BitTable1Set
XXXX-BitFlag to set
6D-HidePerson
XX-PersonEvent (Goldmap person number + 1)
90-EndOfScript

Is this at all applicable to RBY? Are any of these codes also true for gen 1 or is the structure completely different? Is there any sort of documentation on this kind of script in RBY? Thanks for any advice :)


Red Hack: Pokémon Prototype

Total number of registered users: 7000+
Total number of active users: ~12

Offline

#2 2012-07-14 21:27:06

487/700

Re: Pokemon Red: Legendary Encounters

RBY doesn’t have a scripting engine at all: everything is done with a combination of the text engine (similar to GSC’s text engine) and pure ASM.

There are two relevant parts of the map header here: texts and objects. Relevant documentation is here. For example, the object data for Mewtwo’s floor of the Unknown Dungeon starts at 0x45f36 in Red. Look there and interpret the data, and you’ll find three people events: Mewtwo and two items. Here is the disassembly’s excerpt:

db $3 ; people
db SPRITE_SLOWBRO, $d + 4, $1b + 4, $ff, $d0, $41, MEWTWO, 70 ; trainer
db SPRITE_BALL, $9 + 4, $10 + 4, $ff, $ff, $82, ULTRA_BALL ; item
db SPRITE_BALL, $1 + 4, $12 + 4, $ff, $ff, $83, MAX_REVIVE ; item

The species, coordinates, and overworld sprite are defined here.

The text pointers are at 0x45f09. The first one will be associated with the first person event, so we follow it to 0x45f1c.

UnknownDungeon3Text1: ; 0x45f1c
        db $08 ; asm
        ld hl, UnknownDungeon3TrainerHeader0
        call LoadTrainerHeader
        jp TextScriptEnd

Notice it starts with a $08 byte, which tells the text engine to start executing ASM instead of printing text.

I don’t know where the trainer header is documented, but it’s not difficult to understand. Note that it’s used for both trainers and wild Pokémon.

UnknownDungeon3TrainerHeader0: ; 0x45f0f
        db $1 ; flag's bit
        db ($0 << 4) ; trainer's view range
        dw $d85f ; flag's byte
        dw UnknownDungeon3MewtwoText ; 0x5f26 TextBeforeBattle
        dw UnknownDungeon3MewtwoText ; 0x5f26 TextAfterBattle
        dw UnknownDungeon3MewtwoText ; 0x5f26 TextEndBattle
        dw UnknownDungeon3MewtwoText ; 0x5f26 TextEndBattle

For a wild battle, most of these text labels are irrelevant, so just set them to the same thing.

#3 2012-07-15 08:21:48

Danny-E 33
Administrator
Registered: 2012-06-09
Post 59/1,023

Re: Pokemon Red: Legendary Encounters

IIMarckus wrote:

RBY doesn’t have a scripting engine at all: everything is done with a combination of the text engine (similar to GSC’s text engine) and pure ASM.

There are two relevant parts of the map header here: texts and objects. Relevant documentation is here. For example, the object data for Mewtwo’s floor of the Unknown Dungeon starts at 0x45f36 in Red. Look there and interpret the data, and you’ll find three people events: Mewtwo and two items. Here is the disassembly’s excerpt:

db $3 ; people
db SPRITE_SLOWBRO, $d + 4, $1b + 4, $ff, $d0, $41, MEWTWO, 70 ; trainer
db SPRITE_BALL, $9 + 4, $10 + 4, $ff, $ff, $82, ULTRA_BALL ; item
db SPRITE_BALL, $1 + 4, $12 + 4, $ff, $ff, $83, MAX_REVIVE ; item

The species, coordinates, and overworld sprite are defined here.

Okay, I was able to follow along with that. So 05 is telling it to load the Nidoking looking sprite (apparently it is refered to as the Slowbro sprite, but I always called it Nidoking) and 11 is the y-coordinate plus 4 and 1F is the x-coordinate plus 4?
And after the bytes FF D0 and 41, 83 is the id for Mewtwo and 46 is its level.
Then the next byte, 3D, starts the Ultra Ball code, right?
Is the byte before 05 what you're reffering to by db $3? I understand that 3 means it is reading 3 object entries, but what does db mean?
Is every Pokemon encounter a set 8 bytes long and each item 7 bytes?
What do the bytes FF D0 and 41 mean in this code and how to they compare with the same three bytes of the code for the items? I imagine part of this has to indicate if it is currently reading a Pokemon or an item so it knows to read 8 bytes or 7, right? What else do these bytes indicate?
Sorry for all the questions.

IIMarckus wrote:

The text pointers are at 0x45f09. The first one will be associated with the first person event, so we follow it to 0x45f1c.

UnknownDungeon3Text1: ; 0x45f1c
        db $08 ; asm
        ld hl, UnknownDungeon3TrainerHeader0
        call LoadTrainerHeader
        jp TextScriptEnd

Notice it starts with a $08 byte, which tells the text engine to start executing ASM instead of printing text.

I don’t know where the trainer header is documented, but it’s not difficult to understand. Note that it’s used for both trainers and wild Pokémon.

UnknownDungeon3TrainerHeader0: ; 0x45f0f
        db $1 ; flag's bit
        db ($0 << 4) ; trainer's view range
        dw $d85f ; flag's byte
        dw UnknownDungeon3MewtwoText ; 0x5f26 TextBeforeBattle
        dw UnknownDungeon3MewtwoText ; 0x5f26 TextAfterBattle
        dw UnknownDungeon3MewtwoText ; 0x5f26 TextEndBattle
        dw UnknownDungeon3MewtwoText ; 0x5f26 TextEndBattle

For a wild battle, most of these text labels are irrelevant, so just set them to the same thing.

Hm, I'm having a hard time understanding any of this. I am unsure how you're explaining to associate text with an object.


Red Hack: Pokémon Prototype

Total number of registered users: 7000+
Total number of active users: ~12

Offline

#4 2012-07-15 17:56:50

Sawakita
Administrator
Registered: 2010-10-16
Post 287/364

Re: Pokemon Red: Legendary Encounters

IIMarckus wrote:

I don’t know where the trainer header is documented, but it’s not difficult to understand. Note that it’s used for both trainers and wild Pokémon.

I wrote some notes about it, back in the day. They're hosted in pokered's repository's wiki. Look under SET_BATTLE $31cc.

Offline

Board footer

Powered by FluxBB