Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2014-04-24 22:16:59

zbat
New member
Registered: 2014-04-24
Post 1/3

Pokemon Red Map Text Pointers

Hi there. I've recently been doing some research on maps in the first-generation games. I'm completely new to the hex-editing (hex-reading in my case) thing, but I have been able to understand it so far. I'm not wanting to do ROM hacking, but I am interested in data mining. More specifically, I'm interested in the map data in Red and Blue, for now.

What I want to do is read the map for each area, which is fine--I can do that. The map headers all have pointers to the map, which I can follow. However, I need a way to identify each map in my script, since their order in the ROM doesn't correspond to their ID number. Also, as far as I can tell, I can't get the location ID from the map header. My solution was to try to just read each map's name, since there's a pointer to the map's text pointer in the map header.

This is where I've run into problems. PALLET TOWN (8F 80 8B 8B 84 93 7F 93 8E 96 8D) appears six times in the rom, at $71473, $8cf67, $8d702, $8d729, $95c6c, and $a438f. Pallet Town's pointer to its text pointer is 0x4F88 (88 4F), so I go to $18F88. At that point, I expected to find a pointer to one of the offsets at which PALLET TOWN appears in the ROM, but the value there is 0x4F96 (96 4F). None of the locations of the text even ends with 6.

Can somebody explain to me what I'm missing?

Offline

#2 2014-04-25 00:52:25

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

Re: Pokemon Red Map Text Pointers

The location that you looked at (0x18f88) is the table of text pointers for Pallet Town. You looked at the first pointer (0x4f96) which points to the text for when Prof. Oak appears.

PalletTownTextPointers: ; 18f88 (6:4f88)
    dw PalletTownText1
    dw PalletTownText2
    dw PalletTownText3
    dw PalletTownText4
    dw PalletTownText5
    dw PalletTownText6
    dw PalletTownText7

PalletTownText1: ; 18f96 (6:4f96)
    db 8
    ld a,[$CF0D]
    and a
    jr nz,.next
    ld a,1
    ld [$CC3C],a
    ld hl,OakAppearsText
    jr .done
.next
    ld hl,OakWalksUpText
.done
    call PrintText
    jp TextScriptEnd

As you can see, when text begins with $08, that tells the text engine to start executing asm, instead of trying to read text.

If you're trying to get to the "PALLET TOWN" text string that is used in the Pallet Town sign post, that is pointed to by PalletTownText5 from the text pointer table.

PalletTownText5: ; 0x18fe2 sign by fence
    TX_FAR _PalletTownText5
    db "@"
_PalletTownText5:: ; a438b (29:438b)
    text "PALLET TOWN"
    line "Shades of your"
    cont "journey await!"
    done

If you haven't already, you should check out the disassembly of Pokemon Red.
https://github.com/iimarckus/pokered


Red Hack: Pokémon Prototype

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

Offline

#3 2014-04-25 02:08:05

zbat
New member
Registered: 2014-04-24
Post 2/3

Re: Pokemon Red Map Text Pointers

Thank you for that explanation!

The disassembly project is an impressive feat. It looks like it will be my go-to resource for this game generation and the second generation. I guess I'll be reading a lot of Python source for the disassembly tools to figure out how the map data was read, and then move to writing tools to read map data from the GBA games.

Thanks again for such a detailed response.

Offline

#4 2014-04-25 10:27:34

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

Re: Pokemon Red Map Text Pointers

You mentioned that the problem is that the order of the headers in the rom doesn't match the order of their id's.
You may want to look at MapHeaderPointers and MapHeaderBanks:

; see also MapHeaderBanks
MapHeaderPointers:: ; 01ae (0:01ae)
    dw PalletTown_h
    dw ViridianCity_h
    dw PewterCity_h
    dw CeruleanCity_h
    dw LavenderTown_h
    dw VermilionCity_h
    dw CeladonCity_h
    dw FuchsiaCity_h
    dw CinnabarIsland_h
    dw IndigoPlateau_h
    dw SaffronCity_h
.....
; see also MapHeaderPointers
MapHeaderBanks: ; c23d (3:423d)
    db BANK(PalletTown_h) ;PALLET_TOWN
    db BANK(ViridianCity_h) ; VIRIDIAN_CITY
    db BANK(PewterCity_h) ; PEWTER_CITY
    db BANK(CeruleanCity_h) ; CERULEAN_CITY
    db BANK(LavenderTown_h) ; LAVENDER_TOWN
    db BANK(VermilionCity_h) ; VERMILION_CITY
    db BANK(CeladonCity_h) ; CELADON_CITY
    db BANK(FuchsiaCity_h) ; FUCHSIA_CITY
    db BANK(CinnabarIsland_h) ; CINNABAR_ISLAND
    db BANK(IndigoPlateau_h) ; INDIGO_PLATEAU
    db BANK(SaffronCity_h) ; SAFFRON_CITY
.....

Red Hack: Pokémon Prototype

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

Offline

#5 2014-04-28 17:55:10

zbat
New member
Registered: 2014-04-24
Post 3/3

Re: Pokemon Red Map Text Pointers

I had come across information about those here. Does the "ID" of a map come from its position in the list of map header pointers? This is what I was picking up reading through this script.

I think I just misunderstood how a lot of this worked. This information is definitely specifically what I needed. Thanks again for your response!

Offline

#6 2014-04-28 23:38:12

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

Re: Pokemon Red Map Text Pointers

zbat wrote:

Does the "ID" of a map come from its position in the list of map header pointers?

Yes.

zbat wrote:

Thanks again for your response!

You're welcome.


Red Hack: Pokémon Prototype

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

Offline

Board footer

Powered by FluxBB