News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Help with GBC tilemaps  (Read 363 times)

Luccasdavid

  • Jr. Member
  • **
  • Posts: 10
  • You couldn't handle my undivided attention.
    • View Profile
Help with GBC tilemaps
« on: July 18, 2019, 04:28:31 pm »
Edit: the game is "Total Soccer 2000".

I'm working on a GBC hack and I'm having trouble with the tilemaps.

My usual method (which I used succesfuly with GBA games) is locating a tile using VBA's Map viewer function (image 1), getting the address for that tile and then looking for that address in VBA's Memory viewer function. Usually that brings me to the place where the sequence of the tiles is stored (as well as tile atributes like palette, flip, etc.), and then I can easily edit the sequence to fit my objectives. But with GBC games (or this particular game, I've not tried others) this brings me to a place where only the tile atributes are stored (image 2) , which sucks because I really need the edit the sequence of the tiles, aka the tilemap.

I've tried searching the ROM for the hexadecimal sequence of the tiles but I couldn't find. My guess is they are stored in a different way. Can someone please help me?

Image 1
Spoiler:

Image 2
Spoiler:
« Last Edit: July 18, 2019, 05:44:24 pm by Luccasdavid »
You want the truth? You want the truth?! You can't handle the truth! 'Cause when you reach over and put your hand into a pile of goo that was your best friend's face, you'll know what to do!
Forget it, Marge, it's Chinatown

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 6885
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: Help with GBC tilemaps
« Reply #1 on: July 18, 2019, 04:53:51 pm »
9D02 is the address in the CPU's memory space (which in the GB/GBC's case is VRAM, $8000-9FFF). That is not the ROM address of the tile.
It could be anywhere, even compressed, in the ROM.

You can try looking at the hex editor for VRAM (such as in bgb, which I think is a better GB emulator than vanilla VBA anyways), and look for a match in the ROM.

Also, GBC is architecturally a completely different system than GBA.
You will probably want to read up GBC stuff, but from what I recall the original GB didn't even have BG tile attributes, just a tilemap (could be wrong), and GBC added an attribute table in its expanded VRAM (my guess is that GBC knows when running GBC-mode games to bankswap in for the expanded data when rendering the screen.)
"My watch says 30 chickens" Google, 2018

Luccasdavid

  • Jr. Member
  • **
  • Posts: 10
  • You couldn't handle my undivided attention.
    • View Profile
Re: Help with GBC tilemaps
« Reply #2 on: July 18, 2019, 05:02:47 pm »
9D02 is the address in the CPU's memory space (which in the GB/GBC's case is VRAM, $8000-9FFF). That is not the ROM address of the tile.
It could be anywhere, even compressed, in the ROM.

You can try looking at the hex editor for VRAM (such as in bgb, which I think is a better GB emulator than vanilla VBA anyways), and look for a match in the ROM.

Yeah, I know. I don't think it is compressed though. The graphic is not really that large and there's lots of free space in the ROM.

I would try searching the ROM for the VRAM values, but the thing is I can't find the data I'm looking for in the VRAM. It only shows me the tile atributes, and I'm looking for the tile sequence.


Also, GBC is architecturally a completely different system than GBA.
You will probably want to read up GBC stuff, but from what I recall the original GB didn't even have BG tile attributes, just a tilemap (could be wrong), and GBC added an attribute table in its expanded VRAM (my guess is that GBC knows when running GBC-mode games to bankswap in for the expanded data when rendering the screen.)

Well, the sequence that the tiles are to be shown on the screen must be somewhere in the VRAM. But I can't find it, it must be stored in a way I'm not familiar with. So yeah, I'll have to read GBC documents... I just don't know if there is any that will help me.
You want the truth? You want the truth?! You can't handle the truth! 'Cause when you reach over and put your hand into a pile of goo that was your best friend's face, you'll know what to do!
Forget it, Marge, it's Chinatown

Psyklax

  • Hero Member
  • *****
  • Posts: 1030
    • View Profile
    • Psyklax Translations
Re: Help with GBC tilemaps
« Reply #3 on: July 18, 2019, 05:28:59 pm »
First, I second KingMike's suggestion of using BGB, it's a good debug emulator.

Second, which game?! :( I've lost count of the amount of people who come on this forum asking for help but for some reason DON'T say which game they're working on. How can we help if we don't know the game? If I knew then I could look at it for you, perhaps someone has experience of this game, who knows.

Sorry, I'm just tired of this happening all the time. :D Generally speaking, I don't know about the GBA, but the GB differs from the NES in that the VRAM can be directly modified by the CPU, meaning that often graphics are loaded in from all over the place, rather than being a set bank. This is normal in other consoles and computers, of course, but it means that the graphics may not be so easy to find.

As far as I can remember, there's a tilemap in VRAM somewhere, but I'd need a game to look at first. :)

Luccasdavid

  • Jr. Member
  • **
  • Posts: 10
  • You couldn't handle my undivided attention.
    • View Profile
Re: Help with GBC tilemaps
« Reply #4 on: July 18, 2019, 05:39:09 pm »
Really sorry, I thought the name of the game was in the first image. Well, it is not. I'm working on "Total Soccer 2000".

I've now read some GB documents but they didn't really help me much. They don't get into the detail I'm craving here. All I know is my "Tile pattern" (aka Char Base) is comprised at $8800-97FF and my "Background Tile Map" is comprised at $9C00-9FFF. But I kinda new that already, so...

For all I know the sequence of the tiles should be there, every manual says so.

If you look at the second image of my first post you'll see lots of 06, 0C and 07 bytes. For the 06s and 07s the "0" represents a certain tile atribute (or in this case no atribute at all; if I change it to 4 it will give the tile a vertical flip, for example) and the "6"/"7" represents the palette for the tile. But I can't understand what the 0Cs mean. If I change their values nothing happens. And they're not in the ROM. Not that it would be much help to know what they mean though.
« Last Edit: July 18, 2019, 05:45:03 pm by Luccasdavid »
You want the truth? You want the truth?! You can't handle the truth! 'Cause when you reach over and put your hand into a pile of goo that was your best friend's face, you'll know what to do!
Forget it, Marge, it's Chinatown

Psyklax

  • Hero Member
  • *****
  • Posts: 1030
    • View Profile
    • Psyklax Translations
Re: Help with GBC tilemaps
« Reply #5 on: July 18, 2019, 06:38:35 pm »
I can't understand what the 0Cs mean

From looking at the VRAM viewer in BGB, the 0Cs are outside the viewing area, so don't worry about those.

I can see why you're confused, though: it's not immediately obvious. The thing is that on the GBC, there are TWO VRAM banks: what you're seeing is 1:9C00, which is the attribute table, but 0:9C00 is the tilemap. Of course you can't look at 0:9C00 in the RAM viewer if it's not currently switched to it, but by using the debugger to make a breakpoint, I could.

So I set a breakpoint for writes to 0:9CC4, since that's the first tile I could see being used (the previous ones are all black). This breaks at an instruction: ldi (hl),a - meaning load the address in the HL register with the contents of the A register, then increment it. HL has 9CC4, no surprise, so I look at the previous instruction (where did the value in A come from). Sure enough, it's ld a,(bc) - meaning load the A register with the contents of the address in the BC register, that address being 6B8C.

So I go to address $6B8C, which is the E bank of the ROM. Each bank is $4000, so $4000 x $E = $38000 + ($6B8C - $4000) = $3AB8C. I subtract $4000 from the address because it's the second of two ROM banks currently accessed, therefore it starts at $4000.

So yeah, your tilemap is at $3AB8C, or around there anyway. :) Also, for future reference, even if you think the game name is in your screenshot, you should always write it in your post: people in future might search the forum for this game, and besides, I might not even look at your screenshot. ;)

Luccasdavid

  • Jr. Member
  • **
  • Posts: 10
  • You couldn't handle my undivided attention.
    • View Profile
Re: Help with GBC tilemaps
« Reply #6 on: July 18, 2019, 06:57:08 pm »
Wow, thanks a lot! It's all there.

I had no ideia about the two VRAM banks and I'm not used to the art of using breakpoints, so I was at a dead end heheh.

I also realized that VBA and BGB gave me different tile numbers for the same tile. In VBA I was getting 164 ($A4) for a specific tile; on the other hand BGB read it as $24. I was looking in the ROM for the tilemap sequence as VBA interpreted it for me (A4 A5 A6 A7...) and, as I said, I couldn't find that sequence. If only I searched the ROM for the GBG byte sequence (24 25 26 27...) I would have found the tilemap...

So I came to this absolutely obvious conclusion: a better debugger/emulator really makes your life easier. Thanks again!
You want the truth? You want the truth?! You can't handle the truth! 'Cause when you reach over and put your hand into a pile of goo that was your best friend's face, you'll know what to do!
Forget it, Marge, it's Chinatown