Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2010-12-05 13:19:23

EvilOttoJr
Member
Registered: 2010-12-05
Post 1/86

Need help - can't repoint type strength/weakness chart

Hello everyone! After a LONG hiatus, I'm getting back into hacking, problem is that now I don't know how to do anything!!!

Currently working in Gold version.
I need to repoint the type strength/weakness chart at 0x34D01. The problem is, I cannot find the pointers to it anywhere, not in Translhextion, not in Gold Finger *rage* The pointer should be 0D:014D, but searches for this show nothing in the ROM anywhere. The worst part is I have done this before in a different hack! I repointed to a new type chart at 0x1C1690 and it worked without issue, so why can't I find the pointers now?

I have tried switching the bytes around too just in case I messed up.

Offline

#2 2010-12-05 14:53:23

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

Re: Need help - can't repoint type strength/weakness chart

It seems that there are 2 pointers at following addresses:
- 0x34891
- 0x34935

Since the routines work inside their own bank (i.e. there isn't a bank-byte indicator), you shouldn't be able to repoint the types' table in another bank, without rewriting part of the routine.
Not that it would be so hard; the first method that comes in my mind is this:
redirect the routine (in this case "the routines") to another bank with enough free space to contain both the routines and your new "types' table". [obviously you should know assembly for this].
The free space at the end of bank 0x0D seems too small to repoint the table in there.

Anyway, since I'm not so practical with GSC maybe someone else will come here and correct me if I'm wrong...

Offline

#3 2010-12-05 18:47:37

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 332/3,455

Re: Need help - can't repoint type strength/weakness chart

Even though I mainly hack GSC, I've never actually repointed it in that version. The only time I've repointed it was in Red, when I made a hack to add Dark and Steel type (which Coolboyman has done as well).

You might be able to repoint it within bank x0D though. Assuming you haven't already inserting things in that bank that would be taking up your space, it looks like it might be enough, assuming I haven't forgotten how large the type table is, which is always a possibility.

Offline

#4 2010-12-06 01:04:55

EvilOttoJr
Member
Registered: 2010-12-05
Post 2/86

Re: Need help - can't repoint type strength/weakness chart

Thanks for the quick replies. People on Pokecommunity keep ignoring me...

Two issues here:
1. There is almost no free space in bank 0x0D, maybe 96 bytes worth at 0x37FA0.
2. Something is seriously wrong with my search in Translhextion. Searches for anything more than 3 bytes bring up no results, and any search results are odd. Searching "00 00 00" brings up "00 30 30" and any search with a byte with a "4" in it will also bring up ones with "6". Could it be related to my OS screwing it up? (Windows 7 x64 screws up everything... I have to use DOSBox and it takes me 5 minutes just to pull up HFD so I can edit evolutions and movesets...)

Additionally, I have gotten this to work before. It was pointed to 0x01C1690... it didn't seem to need ASM... which I don't know...

Offline

#5 2010-12-06 03:49:43

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 333/3,455

Re: Need help - can't repoint type strength/weakness chart

Well, Translhextion behaves oddly with larger files, and is known to do things like you said when searching, it does that for me on 32bit Windows XP. When I looked earlier it appeared as though there were many more than just 96 bytes at the end of bank 0D, although I'm sure its equally likely I scrolled a bit too far and looked at bank 0E.

Offline

#6 2010-12-06 04:48:51

62/700

Re: Need help - can't repoint type strength/weakness chart

The size of the table looks to be 0x14C bytes. This is indeed larger than the free space in that bank, 0x50 bytes.

Sawakita's suggestion is good, but a better one would probably be to repoint the ASM routine at 0x34E4D to the end of the bank and extend the size of the strength/weakness table. Depending on how you repoint the ASM you could definitely extend the length by at least 0x48.

Unfortunately there seems to be no pointer to it, meaning it probably executes from a relative jump… you could probably find said jump with a debugger.

EvilOttoJr wrote:

Additionally, I have gotten this to work before. It was pointed to 0x01C1690... it didn't seem to need ASM... which I don't know...

If you can find the file you did this on, I would love to see how you did it.


Also, if Dosbox is slow, try hitting Ctrl+F12 to overclock it.

#7 2010-12-06 10:43:47

EvilOttoJr
Member
Registered: 2010-12-05
Post 3/86

Re: Need help - can't repoint type strength/weakness chart

I may be remembering incorrectly that I succeeded in the original file, all I know is that the type table worked.

How does one use a debugger?

Here's a question: Not sure if this would work at all, but I have an idea. What if I deleted the type table at 0x34d01 and in its place put an ASM routine telling it to go to where my new data is? How would I go about doing this if it's possible?

Offline

#8 2010-12-08 09:07:21

EvilOttoJr
Member
Registered: 2010-12-05
Post 4/86

Re: Need help - can't repoint type strength/weakness chart

Bump'd.

2 things:
1 (mostly for IIMarckus' eyes). I found out what I did to my previous hack to do the type table, and what I did later that confused me. I put my new type table into the rom at 0x1C1690 but apparently couldn't repoint it, so I made a new type table at the original location and just deleted a bunch of strengths and weaknesses I didn't like so my new ones would fit. The fact that my first type table was still in the old ROM at 0x1C1690 confused me. Sorry about that.
2. I know you can switch banks with ASM. Is it possible I can just put a routine for it at 0x34D01 so I don't have to repoint a bunch of other stuff?


(Not sure if there's a rule here against double posting, some forums have one, some don't (my airsoft forum does not), I couldn't find one when I checked the Global Rules thread, if so, please warn me and I won't do it again. Generally I won't edit a post more than 24 ohurs after I've made it so as to bump the subject.)

Offline

#9 2010-12-08 15:02:47

63/700

Re: Need help - can't repoint type strength/weakness chart

EvilOttoJr wrote:

2. I know you can switch banks with ASM. Is it possible I can just put a routine for it at 0x34D01 so I don't have to repoint a bunch of other stuff?

I would expand this weakness/strength table in one of two ways:

  1. Repoint the ASM routine that's right after the table to the end of the bank, and expand the table in place.

  2. Modify the ASM that points to the table to look in a different bank.

In most circumstances, I suspect the first would be easier because it doesn't require actually changing any ASM, but in this case the routine following the table has no pointer, so you would need to modify lots of ASM anyway. So the second one (which is closer to what you're asking about) is about the same level of difficulty.

Sawakita already gave the pointers to the table. The ASM around these pointers (as well as the contents of the table) will need to be moved to a different bank, and the original location replaced with a bankswitch. In Gold, you can bankswitch to ZZ:XXYY like this (asm ; hex):

ld a,ZZ     ; 3E ZZ
ld hl,$XXYY ; 21 YY XX
rst $08     ; CF
EvilOttoJr wrote:

(Not sure if there's a rule here against double posting, some forums have one, some don't (my airsoft forum does not), I couldn't find one when I checked the Global Rules thread, if so, please warn me and I won't do it again. Generally I won't edit a post more than 24 ohurs after I've made it so as to bump the subject.)

Don't worry about it. I've always thought bumping rules were pointless.

#10 2010-12-08 15:21:28

EvilOttoJr
Member
Registered: 2010-12-05
Post 6/86

Re: Need help - can't repoint type strength/weakness chart

Ah damn, now I gotta go learn ASM :D

I get the gist of what you're saying. Now I just need to know how to figure out exactly what needs moved and to where, and where to put in that little ASM thing. This seems just a tad outside my current skill level :(

On a completely unrelated side note, I must say people here are a lot more helpful than on Pokecommunity. If it's not Gen III or IV, it gets unnoticed there. People see "G/S/C" in my thread titles and seem to dodge it. This saddens me as any Pokemon game after Gen II makes me cringe (how do I do a cringing smiley?). So thanks for having a forum about real Pokemon hacking!

Unrelated side note II - I remember you IIMarckus! It was about 18 months ago, I kept asking for help reactivating the Safari Zone in Gold then wrote a tutorial for it thanking you for your information. :) If you want, I can put that tutorial up here for anyone who might need it, I still have it in my hacking folder.

Offline

#11 2011-01-14 18:04:55

EvilOttoJr
Member
Registered: 2010-12-05
Post 72/86

Re: Need help - can't repoint type strength/weakness chart

Okay, I'm back on this subject.

After learning a teensy bit of ASM through other questions I've asked here, I think this might actually be doable for me now. I'm going to do the "modify the ASM to look in a different bank" idea.

I have the offsets of the pointers that Sawakita gave me, at 0x34891 and 0x34935; the problem is is that I can't actually seem to figure out where the ASM routine itself starts and ends. It's not writing like a regular script ending in "90" and I'm not finding any FF bytes anywhere. Can someone help me find where each ASM routine starts, and the length in bytes of each one? I'd like to learn what exactly I'm supposed to be looking for as well, in case I need to do this again in the future.

Offline

#12 2011-01-19 20:56:56

EvilOttoJr
Member
Registered: 2010-12-05
Post 78/86

Re: Need help - can't repoint type strength/weakness chart

Bump again - sorry about this guys, but I need to learn how to do this for my hack to progress any further.

Offline

#13 2011-01-19 21:26:26

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 449/3,455

Re: Need help - can't repoint type strength/weakness chart

if memory serves an asm routine tends to end with C9. If you find the middle of the script, like you seem to have already found, you can just back trace it until you hit another C9 (the end of the script before it) or something similar. It won't always start right after another one, so you can't always count on that way, but It works sometimes.

Offline

#14 2011-01-19 21:38:40

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

Re: Need help - can't repoint type strength/weakness chart

What I usually do is searching the end of the previous routine: as normally a routine ends with a "ret"($C9), as Mateo said, or a long "jp xxyy"($C3), although it's really not guaranteed... Anyway when you have found the nearest "ret" or "jp xxyy" check that there are no relative jumps ("jr xx") before it that jump to a location after the said "ret" (or said "jp xxyy"). Also, after the end of the routine there could be not code, but data (data is usually regular so you should notice where it ends).

Also, to be sure that the offset you finally get is correct, you could search for it (big-endian) to see where the routine is called from.

To find the end of your routine just follow it until it dies with a "ret" (or, again, with a "jp"); take into account that if inside your routine there are "calls"($CD $xxyy) that call an address greater than $3FFF, the "called sub-routine" will be inside the switchable bank and you'll have to edit the call, implementing a bank-switch (if I'm not wrong IIMarckus wrote a doc about GSC bank-switches somewhere...), or you could export the sub-routines to the new bank, too (but unless they're short and don't require to directly read the data-table, I would leave them where they are).

Last edited by Sawakita (2011-01-19 21:41:31)

Offline

#15 2011-01-20 02:13:43

EvilOttoJr
Member
Registered: 2010-12-05
Post 79/86

Re: Need help - can't repoint type strength/weakness chart

Okay, thanks guys! I'll see if it works and let you know.

Offline

#16 2011-01-20 02:58:34

EvilOttoJr
Member
Registered: 2010-12-05
Post 80/86

Re: Need help - can't repoint type strength/weakness chart

Tried it and things aren't working. Quick question, can the asm command CD call a pointer that has C9 in it? I've got two instances of "CD C9 31" in which I thought the C9 was "ret" and stopped copying there.

I'm going to try again with editing the calls to do bankswitches.

EDIT: I've got an error, "unknown opcode DB at C242" if that helps anyone. I tried changing my bankswitch to something else which didn't have the same effect leading me to believe there's something wrong with my ASM routine. I also triend not putting in a bank switch to see what it would do, out of curiosity. There were no type advantages at all.

Last edited by EvilOttoJr (2011-01-20 03:33:54)

Offline

#17 2011-01-20 03:48:24

143/700

Re: Need help - can't repoint type strength/weakness chart

EvilOttoJr wrote:

Tried it and things aren't working. Quick question, can the asm command CD call a pointer that has C9 in it?

Yes.

EvilOttoJr wrote:

EDIT: I've got an error, "unknown opcode DB at C242" if that helps anyone.

Your code has an error. Through a call or a jump or some other method, your code jumps to the C000–DFFF area in RAM and starts trying to execute the data there as ASM. This eventually leads to an unrecoverable error (it tries to execute the byte DB, which crashes on a real Game Boy).

Step through the routine with BGB and find out why your code starts executing in the C000–DFFF area.

#18 2011-01-20 18:24:58

EvilOttoJr
Member
Registered: 2010-12-05
Post 81/86

Re: Need help - can't repoint type strength/weakness chart

I'm in the BGB debugger and haven't the slightest clue what I'm doing...

Offline

#19 2011-01-22 00:59:59

144/700

Re: Need help - can't repoint type strength/weakness chart

Set a breakpoint at the address of your instruction. Run the game until the game hits the breakpoint—then BGB will pause and throw you to the debugger. Then step through the code until the code goes to the wrong place.

#20 2011-01-23 07:43:37

EvilOttoJr
Member
Registered: 2010-12-05
Post 82/86

Re: Need help - can't repoint type strength/weakness chart

Okay. I'll try that but the thing I realized was I may be able to get away with keeping the table where it is since I'm going to be taking away a lot of the current type advantages that make no sense, and adding less than that, so I may not need to repoint the table. Last time I just left it alone except for changing a few bytes.

Offline

Board footer

Powered by FluxBB