• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Other] Beginning Hacking (Gen 1)

  • 171
    Posts
    11
    Years
    You cannot use wram space wildly for script flags. There's a reserved area for that. The script flags buffer is a 320-byte area that ends at address D886. Address D887 isn't unused and it's in fact the byte used to store the wild encounter rate of the current map, a value that is updated everytime you enter a new map. You have to either make use of some unused flag (I bet there are a few, but I personally don't know which ones could be unused), remove an existing one from an existing script that you'll no longer want in your hack, or expand the event flags area in memory. This is one of the many advantages that hacking over the pokered dissasembly offers compared to using conventional tools. You can do it by simply replacing line 3056 with ds 321 in wram.asm so that a space of 321 bytes (an extra byte) is reserved. That will give you room for eight more flags (D887 bits 0-7). It will shift everything following that address by one byte, so for example the grass rate that occupied D887 before will now move to D888 and so on. This means that it will break your save, but it shouldn't break anything else unless there's some fixed address in pokered that slipped under the radar, but at this point I don't think so.
     
  • 56
    Posts
    8
    Years
    • Seen Nov 27, 2016
    So the trick will be figuring out which flags are which so I know which ones I can swap out... Any advice on how to check for that?
     
  • 171
    Posts
    11
    Years
    There's no easy way to quicly figure out which are used and which aren't. I'd just expand the area, probably by 10+ bytes at once. It's going to be better in the long run if you are planning on adding more scripts, more trainers, more items, or whatever thing that requires a flag.
     
  • 56
    Posts
    8
    Years
    • Seen Nov 27, 2016
    You can do it by simply replacing line 3056 with ds 321 in wram.asm so that a space of 321 bytes (an extra byte) is reserved. That will give you room for eight more flags (D887 bits 0-7). It will shift everything following that address by one byte, so for example the grass rate that occupied D887 before will now move to D888 and so on. This means that it will break your save, but it shouldn't break anything else unless there's some fixed address in pokered that slipped under the radar, but at this point I don't think so.

    So I could add more than just one byte to this area by changing line 3056 to some number higher than 321? For example something like "ds 323", and should add 24 flags??

    If it's not too complicated..could you explain how that works? Everything located after that byte simply gets moved down (or up or whatever), and leaves me some more useable space for flags. But if there's a limited amount of memory for everything after to move to, when do I need to stop expanding at?
     
  • 171
    Posts
    11
    Years
    Flags are bits, so every byte you add, you get 8 more flags. So yes, you get 24 additional flags in that case.

    Yes, everything located after the bytes you add simply gets moved down, and all the references do as well. So, for example, if D8A4 got moved down, say, to D8A9, then any reference in the code to address D8A4 would start referring to D8A9. That's possible because stuff is labeled in the disassembly instead of being hardcoded addresses. D8A4 ins't actually "D8A4", but "wEnemyMons".

    WRAM goes from C000 to DFFF. DF00-DFFF is reserved for stack so these cannot be used for anything else. But addresses from DEE2 to DEFF are currently unused in Pokemon/Red blue so you have the possibility of easily expanding the event flags buffer up to 29 bytes (DEFF-DEE2).
     
  • 56
    Posts
    8
    Years
    • Seen Nov 27, 2016
    Alright then, looks like my work is cut out for me!

    Did my earlier defining the event where I shouldn't have the effect of resetting the event every time, or were those things probably separate?
     
  • 171
    Posts
    11
    Years
    Did my earlier defining the event where I shouldn't have the effect of resetting the event every time, or were those things probably separate?
    You event flag resetted because it overlapped with the grass encounter rate address, which is overwritten every time you enter a new map.
     

    Fotomac

    Genwunner and proud of it
  • 909
    Posts
    8
    Years
    • Seen Jan 9, 2023
    I'm trying to write a script that has an Oak Aide give the player character the Starter that didn't get chosen inside of the Cerulean Pokémon Center. Basically, what I'm aiming to do is the following:

    • Upon entering Cerulean City, insert a phone call requesting a meeting with the Oak Aide in the Pokémon Center (that much I've already mastered);
    • Keep the guard standing in front of the door of the burglarized house in Cerulean City until the unchosen Starter is picked up or the player character meets with Bill on Cerulean Cape, whichever comes last;
    • Have the Oak Aide tell the player character about the situation that caused the unchosen Starter to fall into his hands;
    • Have him give the unchosen Starter to the player character promptly if there are five or less Pokémon in the player's party, then give some parting words, walk away, and disappear; and
    • Keep him around with an instruction to the player character to make some room for the unchosen Starter if there are six Pokémon in the player's party.

    As I experiment with hacking Pokémon Red/Green/Blue, I've already mastered several things, including the insertion of the female player character and the aforementioned phone calls, but I still have a lot to learn; I'm also thinking of giving the player the opportunity to acquire all three of the Starters in-game without trading, among other things.
     
  • 56
    Posts
    8
    Years
    • Seen Nov 27, 2016
    Since I am far from the foremost authority on hacking the disassembly, I can't really give much in the way of detailed instructions. However, based on what I've gathered over the course of this thread I can make some suggestions:

    Definitely make it a point to expand your WRAM if you plan to add a lot of scripts and flags. Screwed up the first test save, but as stated above, is very much worth it.

    Consider other scripts that already exist in game that are similar in some aspect to what you're aiming to do. It will give you a "template" of sorts to start from. Once you've experimented with those "templates", you can bring more specific questions here.

    Here's some I would look at specifically:
    The Lapras guy in Silph
    Squirtle girl from Yellow
    The Rival choosing a starter
     

    Fotomac

    Genwunner and proud of it
  • 909
    Posts
    8
    Years
    • Seen Jan 9, 2023
    OK, I couldn't find the script with the Squirtle girl from Yellow (and by the way, she's not just any girl, she's Officer Jenny), but I was suggested a similar script from Celadon involving the Eevee Poke Ball.
     
  • 56
    Posts
    8
    Years
    • Seen Nov 27, 2016
    So being the genius that I am, changed a bunch of things at once and glitched my game out.

    In the interest of fixing this issue, I'll describe it as best I can. The game runs as normal, but upon getting to the intro screen with the revolving Mons, it freezes up after a couple of sprites. It seems like it can't load CERTAIN images correctly. I can correlate this because if I load a save state, it plays as normal, until I enter a battle or view particular Mons in my party or DEX. And it's only certain Mons too.

    I changed a lot of the pokemon PNGs in the PIC folder. I changed them back to their originals, but it didn't have any effect. I switched some moves associated with TMs, but I don't think that had much to do with it either.

    Is there anything else I should be looking for? I was getting pretty close to finishing up...Damn.
     
  • 56
    Posts
    8
    Years
    • Seen Nov 27, 2016
    Still no progress with this. I tried clearing out the home folder, then copy and pasting the master files back into it and recompiling. Same issue.

    What also gets me is that some of the Mons whose PNGs I changed initially did not lag or crash the ROM, but also did not actually change in game. Case in point: I switched Metapod to the Green version PNG, and it still loaded the one from Red version without any lag. Does anyone have any clues as to what's going on?
     

    Fotomac

    Genwunner and proud of it
  • 909
    Posts
    8
    Years
    • Seen Jan 9, 2023
    As I try to make it so my hack allows the player to pick up all three Starters, I came up with this script:

    CeruleanPokecenterText5:
    TX_ASM
    ld a, [wExtraFlags]
    bit 0, a ; got unchosen Starter?
    ld hl, .MeetOakAideText
    call PrintText
    ld a, [wPlayerStarter]
    cp CHARMANDER
    jr z, .charmander
    cp SQUIRTLE
    jr z, .squirtle
    ; else Bulbasaur
    lb bc, SQUIRTLE, 5
    jr nz, .showText
    .charmander
    lb bc, BULBASAUR, 5
    call GivePokemon
    jr nz, .showText
    .squirtle
    lb bc, CHARMANDER, 5
    .showText
    call GivePokemon
    jr nc, .comeBackLater
    ; else
    ld hl, .OakAideFarewellText
    call PrintText
    ld hl, wExtraFlags
    call SetSpriteMovementBytesToFF
    ld a, [wXCoord]
    cp $14
    jr nz, .asm_*****
    ld de, CeruleanPokecenterMovement2
    jr .asm_*****
    .asm_*****
    ld de, CeruleanPokecenterMovement1
    .asm_*****
    ld a, $1
    ld [H_SPRITEINDEX], a
    call MoveSprite
    ld a, $3
    ld [wCeruleanPokecenterCurScript], a
    ret
    .comeBackLater
    ld hl, TooManyPokemon
    call PrintText
    jp TextScriptEnd

    However, I still feel this text is a bit incomplete. What name or number should I give the ASM variables, which signify the Oak Aide's movements?

    ETA: Never mind, I think I got it.
     
    Last edited:
  • 9
    Posts
    9
    Years
    • Seen Dec 9, 2016
    So being the genius that I am, changed a bunch of things at once and glitched my game out.

    In the interest of fixing this issue, I'll describe it as best I can. The game runs as normal, but upon getting to the intro screen with the revolving Mons, it freezes up after a couple of sprites. It seems like it can't load CERTAIN images correctly. I can correlate this because if I load a save state, it plays as normal, until I enter a battle or view particular Mons in my party or DEX. And it's only certain Mons too.

    I changed a lot of the pokemon PNGs in the PIC folder. I changed them back to their originals, but it didn't have any effect. I switched some moves associated with TMs, but I don't think that had much to do with it either.

    Is there anything else I should be looking for? I was getting pretty close to finishing up...Damn.
    Not worth quitting since this is probably something extremely trivial. You're just overlooking it. It obviously has to do with the sprites. Could do a rundown on what exactly it was that you did? What pics did you change, and how?
     
  • 171
    Posts
    11
    Years
    Still no progress with this. I tried clearing out the home folder, then copy and pasting the master files back into it and recompiling. Same issue.

    What also gets me is that some of the Mons whose PNGs I changed initially did not lag or crash the ROM, but also did not actually change in game. Case in point: I switched Metapod to the Green version PNG, and it still loaded the one from Red version without any lag. Does anyone have any clues as to what's going on?

    Is there anywhere that I can look at what you've done and preferably build the ROM to debug it? Hard to tell what's wrong without being able to see it.
     
  • 56
    Posts
    8
    Years
    • Seen Nov 27, 2016
    I'll break down what I did with the images:

    So there are these folders under "pics" called "bmon", "rgmon", etc. The hold the red/blue sprites and japanese 3rd cart sprites respectively. I simply moved many of the rgmon sprite PNGs into the bmon folder, figuring the game would simply read the new PNGs since I removed the ones in bmon initially.

    Checking in the pokemon basestats folder, each file points to a "monname.pic" file, and that file type is only present bmon, meaning there isn't anything else I can replace.

    Is there anywhere that I can look at what you've done and preferably build the ROM to debug it? Hard to tell what's wrong without being able to see it.

    What would you suggest as far as getting you access? I don't know how to make an IPS file, not that it's even what you need, come to think of it. I could always save a copy of the home/""/pokered directory, compress it, and send it in a PM or email, unless its too big?
     
  • 171
    Posts
    11
    Years
    Assuming you have a repo cloned or forked from pokered you can download Github for Windows, add your repository, and then upload it to github publically. It's very straightforward with the graphical interface. Plus if you were using version control you would've been able to get rid of the bug by just reverting back to an older commit in just a couple of clicks.

    Because you said that you've already tried switching the pics back to how they were originally, but the problem still stays?
     
  • 56
    Posts
    8
    Years
    • Seen Nov 27, 2016
    Because you said that you've already tried switching the pics back to how they were originally, but the problem still stays?

    Ya. I also tried to change the order of some Mons in the pokedex, which may also be related (I believe I may have tried flipping 2 Mons in the pokemon_constants.asm, which may have been a mistake). The problem persisted even with the blank slate ROM though.

    Let me work on getting that github thing running.
     

    Fotomac

    Genwunner and proud of it
  • 909
    Posts
    8
    Years
    • Seen Jan 9, 2023
    OK, I know where in core.asm to alter the code to correct the Freeze condition, but I don't know exactly how. I mean, I know what to do, I just don't know how to do it.
     
  • 56
    Posts
    8
    Years
    • Seen Nov 27, 2016
    github is not as easy to use as I expected. Even though I've added my edited pokered folder as a repository, I can't seem to jump the files to my new repository. It (thankfully) won't let me commit changes, because apparently my pokered folder is still tied to the original pokered disassembly repository. I'd hate to screw up everything for everyone else.

    OK, I know where in core.asm to alter the code to correct the Freeze condition, but I don't know exactly how. I mean, I know what to do, I just don't know how to do it.

    I would just try to add the turn counter code from the sleep section in the appropriate place in the freeze section and leave everything else be. Of course, this is coming from someone who doesn't really know what they're doing.
     
    Back
    Top