Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2017-11-13 05:47:12

Freakorama
New member
Registered: 2017-11-13
Post 1/5

[PokeCrystal] Help with map related coding

There are a bunch of things I can't figure out how to do for Pokemon Bronze 2.

They are:
-Changing map music during a rocket raid
-Removing wild Pokemon from a map entirely
-Moving a map from Kanto to Johto and keeping its wild encounters working (And they show up on Johto's town map)
-Removing unused map areas from the town map

I have tried simply commenting out the wild pokemon data, but that just rearranged everything.
Even tried setting the encounter rate to 0. But still that gives the same result.

Removing unused areas from the town map no matter what I tried building it would always give me a "missing whatever" or whatever.

Everything else I have no idea where to even start.

Last edited by Freakorama (2017-11-13 05:48:03)

Offline

#2 2017-11-13 06:41:33

Rangi
Member
Registered: 2016-05-09
Post 827/870

Re: [PokeCrystal] Help with map related coding

Changing map music during an event:

This is already done for Mahogany Mart while Team Rocket runs it. constants/music_constants.asm defines MUSIC_MAHOGANY_MART, and MahoganyMart uses that as its BGM in maps/map_headers.asm. Then home/map.asm:GetMapHeaderMusic checks for it and jumps to a special case for that value, which checks StatusFlags2 to decide whether to play MUSIC_ROCKET_HIDEOUT or MUSIC_CHERRYGROVE_CITY.

(There's a similar case for the Radio Tower during Team Rocket's takeover, but for some reason it uses an overly-complicated method with bit 7 being set.)

(Also the value of MUSIC_MAHOGANY_MART happens to equal MUSIC_SUICUNE_BATTLE, but that would only be an issue if a map needed to actually use MUSIC_SUICUNE_BATTLE as its BGM.)

You probably want to check an event, not a status flag, so your special case would look something like this:

GetMapHeaderMusic:: ; 2cbd
    push hl
    push bc
    ld de, 6 ; music
    call GetMapHeaderMember
    ld a, c
    cp MUSIC_FOR_RAIDED_MAP
    jr z, .raidedmap
    callba Function8b342
    ld e, c
    ld d, 0
.done
    pop bc
    pop hl
    ret

.raidedmap
    ld hl, EventFlags + (EVENT_TEAM_ROCKET_RAID_HAPPENING >> 3)
    bit (EVENT_TEAM_ROCKET_RAID_HAPPENING & $7), [hl]
    jr z, .noraid
    ld de, MUSIC_ROCKET_OVERTURE
    jr .done

.noraid
    ld de, MUSIC_CHERRYGROVE_CITY
    jr .done

Then you just define MUSIC_FOR_RAIDED_MAP and use it for all the relevant maps.

Removing wild Pokemon from a map entirely:

Just remove the map from its particular region file in data/wild/*.asm: the first line with the map declaration, the second with the encounter probabilities, and the three groups of seven for mon/day/nite Pokémon.

Moving a map from Kanto to Johto:

Move its encounter data from data/wild/kanto*.asm to data/wild/johto*.asm.

Changing a map's location on the Town Map:

Rearrange the location in constants/landmark_constants.asm, and change its coordinates in engine/landmarks.asm.

Removing unused map areas from the Town Map:

Same as changing the map's location, just delete the landmark data instead of rearranging it.

----------------------------------------

Two tips for finding the answers to these sort of questions. One, just browse through the pokecrystal files and get familiar with their names and what sort of data or code is inside them. You can ignore the low-level asm-heavy ones (which is most of home/ and some of engine/), but pay attention to ones with important names. Like, engine/npctrade.asm is probably going to have the NPC trade information.

Two, look backwards. If you didn't know that engine/npctrade.asm existed, but you knew that a guy in Violet City trades Onix for Bellsprout, you could look at his script in maps/VioletOnixTradeHouse.asm and try to find how it's done. (It happens to use the "trade $1" command; you can then check macros/event.asm and engine/scripting.asm to find the definition of Script_trade, which calls NPCTrade, which is defined in engine/npctrade.asm.)

Searching through all the assembly code is doable with GitHub's search, or with the "grep" command in Cygwin. For example, to search for "MUSIC_MAHOGANY_MART" in all files, including recursively down subdirectories, showing line numbers too, with automatic color highlighting of search terms:

Rangi@PC /cygdrive/c/Users/Rangi/pokecrystal
$ grep --color=auto -rn 'MUSIC_MAHOGANY_MART' *
constants/music_constants.asm:107:MUSIC_MAHOGANY_MART EQU $64 ; leftover from gold
home/map.asm:2294:      cp MUSIC_MAHOGANY_MART
maps/map_headers.asm:106:       map_header MahoganyMart1F, TILESET_KURT_HOUSE, INDOOR, MAHOGANY_TOWN, MUSIC_MAHOGANY_MART, 1, PALETTE_DAY, FISHGROUP_SHORE

Pokémon Polished Crystal (GitHub) — version 2.2.0 released
Pokémon Red★ and Blue★: Space World Edition (GitHub) — updated August 19!
Polished Map: pokered+pokecrystal map, tileset, and palette editor — version 3.5.1 released!

Offline

#3 2017-11-13 07:28:59

Freakorama
New member
Registered: 2017-11-13
Post 3/5

Re: [PokeCrystal] Help with map related coding

landmark $47, $84, Route26Name    ;ROUTE 20
    landmark $3C, $84, VictoryRoadName
    landmark $3C, $80, Route23Name
    landmark $3C, $7C, IndigoPlateauName
;    landmark  0,  0, SproutTowerName ;Above Here
;    landmark 0,  0, LighthouseName
;    landmark  0,  0, RuinsOfAlphName
;    landmark  0,  0, SlowpokeWellName
;    landmark  0,  0, TinTowerName
;    landmark  0,  0, BurnedTowerName
;    landmark  0,  0, BattleTowerName
;    landmark  0,  0, WhirlIslandsName
;    landmark 0,  0, DragonsDenName
;    landmark 0,  0, DarkCaveName
;    landmark 156,  84, SilverCaveName
    landmark $2C, $44, PalletTownName
    landmark $3C, $44, Route7Name 
    landmark $4C, $44, LavenderTownName

I commented out all the unused areas, but that just caused the town map to start displaying Kanto areas in Johto after I had scrolled through all the Johto ones.

Offline

#4 2017-11-13 07:54:52

Rangi
Member
Registered: 2016-05-09
Post 829/870

Re: [PokeCrystal] Help with map related coding

Freakorama wrote:
landmark $47, $84, Route26Name    ;ROUTE 20
    landmark $3C, $84, VictoryRoadName
    landmark $3C, $80, Route23Name
    landmark $3C, $7C, IndigoPlateauName
;    landmark  0,  0, SproutTowerName ;Above Here
;    landmark 0,  0, LighthouseName
;    landmark  0,  0, RuinsOfAlphName
;    landmark  0,  0, SlowpokeWellName
;    landmark  0,  0, TinTowerName
;    landmark  0,  0, BurnedTowerName
;    landmark  0,  0, BattleTowerName
;    landmark  0,  0, WhirlIslandsName
;    landmark 0,  0, DragonsDenName
;    landmark 0,  0, DarkCaveName
;    landmark 156,  84, SilverCaveName
    landmark $2C, $44, PalletTownName
    landmark $3C, $44, Route7Name 
    landmark $4C, $44, LavenderTownName

I commented out all the unused areas, but that just caused the town map to start displaying Kanto areas in Johto after I had scrolled through all the Johto ones.

The constants/landmark_constants.asm values need to correspond to the landmark entries, line by line.


Pokémon Polished Crystal (GitHub) — version 2.2.0 released
Pokémon Red★ and Blue★: Space World Edition (GitHub) — updated August 19!
Polished Map: pokered+pokecrystal map, tileset, and palette editor — version 3.5.1 released!

Offline

#5 2017-11-13 08:20:24

Freakorama
New member
Registered: 2017-11-13
Post 4/5

Re: [PokeCrystal] Help with map related coding

That just gives me this when building:

C:\cygwin64\Freako\bin\rgblink.exe: Unknown symbol 'SILVER_CAVE'
make: *** [Makefile:59: pokebronze2.gbc] Error 1

Offline

#6 2017-11-17 07:02:45

Freakorama
New member
Registered: 2017-11-13
Post 5/5

Re: [PokeCrystal] Help with map related coding

Rearranging flight locations in pokegear.asm has completely messed up the fly map menu.

74GyTMN.png0oSBRRg.png

It shows Kanto locations in Johto, and in Kanto everything is just corrupted and I don't know how to fix it.

And I'm still unable to remove unused locations from the map.
It will not build the game when I remove them.

Last edited by Freakorama (2017-11-17 07:04:01)

Offline

Board footer

Powered by FluxBB