Golden Sun Hacking Community
January 16, 2018, 09:45:40 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
  Home   Forum   DC Wiki Help Search Calendar Downloads Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Questions about Space Manager  (Read 1290 times)
0 Members and 1 Guest are viewing this topic.
Fox
Fox McCloud, the Hacking Doctor
Mercury Clan

Prodigy
*

Coins: 28
Offline Offline

I am: certainly not a Gallant!
Clan Position: Head Gallant
Posts: 2403

« on: June 20, 2017, 11:39:05 AM »

I went through the space manager code... and I get that it is mostly a simple thing with a lot of code... but a small portion of it confuses me.

For those who don't know, here are details of the space manager functions.
Quote
#pragma once
#import "includes.h"

class spacemanager
{
public:
     static int list_num;
     static int organizeList(int *list);
     static int mapSpace(int *list);
     static int findSpace(int *list, int size);
     static int confirmSpace(int *list, int index, int size);
     static int freeSpace(int *list, int pos, int size);
     static int claimSpace( int *list, int pos, int size);
};
list_num is the total number of entries in Atrius's free space table.
orgaizeList - pretty self-explanatory, but is where my question(s) are.
mapSpace will either load the free space table, or if there isn't one, scan for free space. (Based on MFT pointers that point before MFT address. And after those, will scan from end of ROM.) It scan backwards, though, so once there is a non-zero, the space for that section is known. (32-bit aligned size.)
findSpace is simple, looks for the first entry in the free space list that has enough size that is needed.
confirmSpace checks if the entire section has 00s or not. (Depending on a flag) (It may also check if the freeSpace being used is all in freeSpace, but that's probably pointless with the findSpace function.) - It is obvious that this helps reduce overwritting any hex editor related edits... but otherwise is not required to have.
freeSpace literally adds another entry of freeSpace. (Checks each of the freeSpace entries to see whether that space can be added to it, if not, it will be added as a separate entry.)
claimSpace is similar to freeSpace, except that it removes the freeSpace.



My question is with organizeList.
I get that it sorts the list from least to greatest size... but I don't get the next part:
Quote
         if (pos!=i)
          {
               val=list[pos<<1];
               size=list[(pos<<1)+1];
               list[pos<<1]=list[i<<1];
               list[(pos<<1)+1]=list[(i<<1)+1];
               if (val==list[i<<1])
               { list[i<<1]=val|0x40000000; }
               else
               { list[i<<1]=val; }
               list[(i<<1)+1]=size;
          }
          if (list[i<<1]==list[(i-1)<<1])
          {
               list_num--;
               for (ii=i; ii<list_num; ii++)
               {
                    list[ii<<1]=list[(ii+1)<<1];
                    list[(ii<<1)+1]=list[((ii+1)<<1)+1];
               }
               list[list_num<<1]=0; list[(list_num<<1)+1]=0;
               i--;
          }
The bolded sections.... Do those ever happen? And if so how? Otherwise, is it free to remove without problems?
The top section is for switching entries (For the small to large sizes)
The bottom section looks like it removes an entry for when two addresses next to each other match.

And after this code is basically the stuff that frees the old free space table from the ROM and puts the updated free space table back into the ROM.



When doing this for the C# version, I think I'll try to make it a little simpler if I can... by removing confirmSpace, and also that the freeSpace table shouldn't "claim space" for itself. If table is going to be managed outside the ROM data. Maybe.)
« Last Edit: June 20, 2017, 12:16:36 PM by Fox » Logged

Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Remember kids! Before you go on that interview, remember to wash your hands in teawater! *Coughs on hand* (Excuse me, I just coughed up a little teawater, so they're still clean!) You wouldn't want that hiring manager to be unimpressed.

May the force be with you!
Shoo! Why does it smell in here?
Maybe that's the wrong kind of force. *smirk*
View Profile
Luna_blade
The last member of the Luna clan
Luna Clan

Great Member
*

Coins: 0
Offline Offline

I am: Timeless. As in, i don't have much free time.
Posts: 533

« Reply #1 on: June 20, 2017, 07:03:03 PM »

Oof that is some tangled code.

I am not really sure what I am looking at here.
I would like to help out, but I am really too tired currently.
That first if is very puzzling.
Logged

++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
View Profile
Fox
Fox McCloud, the Hacking Doctor
Mercury Clan

Prodigy
*

Coins: 28
Offline Offline

I am: certainly not a Gallant!
Clan Position: Head Gallant
Posts: 2403

« Reply #2 on: June 20, 2017, 08:26:10 PM »

First if? Don't try to understand it without seeing the rest of it: (From Atrius's Source code... C++ Space Manager code file.)

The code before it is about looking for an entry that is of a lower size. Whether one is found or not, depends on how that "if" statement is true or false.
If one is found... the code inside the if block shown in the first post basically swaps them. I'm not sure why there's an "|0x40000000" though...

Spoiler for Hidden:
#include "spacemanager.h"

int spacemanager::list_num;

int spacemanager::organizeList(int *list)
{
     int i, ii, pos, val, size;
     for (i=0; i<list_num-1; i++)
     {
          val=list[(i<<1)+1]; pos=i;
          for (ii=i+1; ii<list_num; ii++)
          {
               if (list[(ii<<1)+1]<val)
               {
                    pos=ii; val=list[(ii<<1)+1];
               }
          }
          if (pos!=i)
          {
               val=list[pos<<1];
               size=list[(pos<<1)+1];
               list[pos<<1]=list[i<<1];
               list[(pos<<1)+1]=list[(i<<1)+1];
               if (val==list[i<<1])
               { list[i<<1]=val|0x40000000; }
               else
               { list[i<<1]=val; }
               list[(i<<1)+1]=size;
          }
          if (list[i<<1]==list[(i-1)<<1])
          {
               list_num--;
               for (ii=i; ii<list_num; ii++)
               {
                    list[ii<<1]=list[(ii+1)<<1];
                    list[(ii<<1)+1]=list[((ii+1)<<1)+1];
               }
               list[list_num<<1]=0; list[(list_num<<1)+1]=0;
               i--;
          }
     }
     //return list_num;
     if ((LOAD_INT(FileTable())>>24)!=8)
     { return list_num; }
     if ((LOAD_INT(FileTable())&0x1FFFFFF)!=0)
     {
          int tlist[32768]; int tnum, tnum2; tnum=list_num;
          pos=LOAD_INT(FileTable());
          WRITE_INT(FileTable(), pos|0x70000000);
          tnum2=spacemanager::mapSpace(tlist); list_num=tnum;
          spacemanager::freeSpace(list, pos,(tnum2<<3)+4);
     }
     else
     { WRITE_INT(FileTable(), 0x7FFFFFFF); }
     pos=spacemanager::findSpace(list, (list_num<<3)+4);
     if (pos>0)
     {
          spacemanager::claimSpace(list, pos, (list_num<<3)+4);
          i=0;
          for (i=0; i<list_num; i++)
          {
               val=list[i<<1];
               WRITE_INT(pos+(i<<3),list[i<<1]);
               WRITE_INT(pos+(i<<3)+4,list[(i<<1)+1]);
          }
          WRITE_INT(pos+(list_num<<3),0x7FFFFFFF);
          WRITE_INT((FileTable()),pos);
          //WRITE_INT(0,0x12345678);
     }
     else
     {
          WRITE_INT(FileTable(),0x08000000);
     }
     return list_num;
}

int spacemanager::mapSpace(int *list)
{
     int pos, val, size;
     for (list_num=0; list_num<32768; list_num++)
     { list[list_num]=0; }
     list_num=0;
     pos=LOAD_INT(FileTable())&0x09FFFFFF;
     if ((pos&0x1FFFFFF)!=0x0)
     {
          val=LOAD_INT(pos+(list_num<<3));
          while (val!=0x7FFFFFFF)
          {
               list[list_num<<1]=val;
               list[(list_num<<1)+1]=LOAD_INT(pos+4+(list_num<<3)); list_num++;
               val=LOAD_INT(pos+(list_num<<3));
               if (val==0)
               { val=0x7FFFFFFF; }
          }
          list[list_num<<1]=0;
          list[(list_num<<1)+1]=0;
          return list_num;
     }
     val=0;
     do
     {
          if (val==1)
          { val++; continue; }
          pos=LOAD_INT(FileTable()+0x4+(val<<2))&0x1FFFFFF;
          if (pos>(FileTable()&0x1FFFFFF))
          {
               pos=FileSize();
          }
          size=0;
          do
          { size++; }
          while (LOAD_BYTE(pos-size)==0);
          size--;
          size=size&0xFFFFFFFC;
          pos-=size;
          if (pos+size==FileSize())
          {
               size+=(32<<20)-FileSize();
          }
          if (size>0)
          {
               list[list_num<<1]=pos|0x08000000;
               list[(list_num<<1)+1]=size;
               list_num++;
          }
          val++;
     }
     while (pos<=(FileTable()&0x1FFFFFF));
     spacemanager::organizeList(list);
     return list_num;
}

int spacemanager::findSpace(int*list, int size)
{
     //size=(size+3)&0xFFFFFFFC;
     int pos, i;
     do
     {
          pos=0;
          for (i=0; i<list_num; i++)
          {
               if (list[(i<<1)+1]>=size)
               {
                    if (spacemanager::confirmSpace(list,list[i<<1],int(size)))
                    {
                         pos=list[i<<1]; i=list_num;
                    }
                    else
                    {
                         pos=-1; i=list_num;
                    }
               }
          }
     }
     while (pos==-1);
     if (pos==0)
     { return pos; }
     return (pos&0x1FFFFFF)|0x08000000;
}
    
int spacemanager::confirmSpace(int *list, int pos, int size)
{
     //size=(size+3)&0xFFFFFFFC;
     int i, index; index=-1;
     for (i=0; i<list_num; i++)
     {
          if ((list[i<<1]&0x1FFFFFF)<=(pos&0x1FFFFFF))
          {
               if (((list[i<<1]+list[(i<<1)+1])&0x1FFFFFF)>=((pos+size)&0x1FFFFFF))
               {
                    index=i; i=list_num;
               }
          }
     }
     if (index<0)
     { return -list_num; }
     if ((list[index<<1]>>28)==1)
     { return list_num; }
     int length, ppos; ppos=pos;
     pos=list[index<<1];
     for (length=0; length<size+(ppos-list[index<<1]); length++)
     {
          if  (LOAD_BYTE(pos+length)!=0)
          {
               size=list[(index<<1)+1]; length--;
               list[(index<<1)+1]=length;
               pos+=size; length=0;
               do
               {
                    length++;
               }
               while (LOAD_BYTE(pos-length)==0);
               length--;
               pos-=length;
               list[list_num<<1]=pos|0x08000000;
               list[(list_num<<1)+1]=length;
               list_num++;
               spacemanager::organizeList(list);
               return -list_num;
          }
     }
     return list_num;
}

int spacemanager::freeSpace(int *list, int pos, int size)
{
     int i, ii, index, pos2, pos3; index=-1; pos2=pos+size;
     pos|=0x10000000;
     for (i=0; i<list_num; i++)
     {
          if ((list[i<<1]&0x1FFFFFF)>(pos&0x1FFFFFF))
          {
               if ((pos2&0x1FFFFFF)>=(list[i<<1]&0x1FFFFFF))
               {
                    pos=pos&0x09FFFFFF|(list[i<<1]&0xF6000000);
                    pos3=list[i<<1]+list[(i<<1)+1];
                    if ((pos3&0x1FFFFFF)>(pos2&0x1FFFFFF))
                    {
                        pos2=pos3;
                        size=(pos2&0x09FFFFFF)-(pos&0x09FFFFFF);
                    }
                    list_num-=1;
                    for (ii=i; ii<list_num; ii++)
                    {
                        list[ii<<1]=list[(ii+1)<<1];
                        list[(ii<<1)+1]=list[((ii+1)<<1)+1];
                    }
                    list[list_num<<1]=0;
                    list[(list_num<<1)+1]=0;
                    i=-1;
               }
          }
          else
          {
               pos3=list[i<<1]+list[(i<<1)+1];
               if ((pos&0x1FFFFFF)<=(pos3&0x1FFFFFF))
               {
                    pos=list[i<<1];
                    if ((pos3&0x1FFFFFF)>(pos2&0x1FFFFFF))
                    {
                        pos2=pos3;
                    }
                    size=(pos2&0x09FFFFFF)-(pos&0x09FFFFFF);
                    list_num-=1;
                    for (ii=i; ii<list_num; ii++)
                    {
                        list[ii<<1]=list[(ii+1)<<1];
                        list[(ii<<1)+1]=list[((ii+1)<<1)+1];
                    }
                    list[list_num<<1]=0;
                    list[(list_num<<1)+1]=0;
                    i=-1;
               }
          }
     }
    
     list[list_num<<1]=(pos&0x1FFFFFF)|0x08000000;
     if ((pos>>28)==1)
     { list[list_num<<1]|=0x10000000; }
     else
     {
          for (i=0; i<size; i++)
          { WRITE_BYTE(pos+i,0); }
     }
     list[(list_num<<1)+1]=size;
     list_num++;
     spacemanager::organizeList(list);
     return list_num;
}

int spacemanager::claimSpace(int *list, int pos, int size)
{
     //size=(size+3)&0xFFFFFFFC;
     if (pos<=0 || size<=0)
     { return -list_num; }
     if (spacemanager::confirmSpace(list, pos, size)<=0)
     { return -list_num; }
     int i, index; index=-1;
     for (i=0; i<list_num; i++)
     {
          if ((list[i<<1]&0x1FFFFFF)<=(pos&0x1FFFFFF))
          {
               if (((list[i<<1]+list[(i<<1)+1])&0x1FFFFFF)>=((pos+size)&0x1FFFFFF))
               {
                    index=i; i=list_num;
               }
          }
     }
     if (index<0)
     { return -list_num; }
     if ((pos&0x1FFFFFF)==(list[index<<1]&0x1FFFFFF))
     {
          if (size<list[(index<<1)+1])
          {
               list[index<<1]+=size;
               list[(index<<1)+1]-=size;
               spacemanager::organizeList(list);
               return list_num;
          }
          else
          {
               list_num-=1;
               for (i=index; i<list_num; i++)
               {
                    list[i<<1]=list[(i+1)<<1];
                    list[(i<<1)+1]=list[((i+1)<<1)+1];
               }
               list[list_num<<1]=0; list[(list_num<<1)+1]=0;
               spacemanager::organizeList(list);
               return list_num;
          }
     }
     else
     {
          i=list[(index<<1)+1]-((pos&0x1FFFFFF)-(list[index<<1]&0x1FFFFFF))-size;
          if (i>0)
          {
               list[list_num<<1]=((pos+size)&0x1FFFFFF)|0x08000000;
               list[(list_num<<1)+1]=i;
               list_num+=1;
          }
          list[(index<<1)+1]=(pos&0x1FFFFFF)-(list[index<<1]&0x1FFFFFF);
     }
     spacemanager::organizeList(list);
     return list_num;
}
« Last Edit: June 20, 2017, 08:33:21 PM by Fox » Logged

Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Remember kids! Before you go on that interview, remember to wash your hands in teawater! *Coughs on hand* (Excuse me, I just coughed up a little teawater, so they're still clean!) You wouldn't want that hiring manager to be unimpressed.

May the force be with you!
Shoo! Why does it smell in here?
Maybe that's the wrong kind of force. *smirk*
View Profile
Luna_blade
The last member of the Luna clan
Luna Clan

Great Member
*

Coins: 0
Offline Offline

I am: Timeless. As in, i don't have much free time.
Posts: 533

« Reply #3 on: June 21, 2017, 07:17:16 AM »

First if?
Yeah "if (list[i<<1]==list[(i-1)<<1])".
so when i = 0x00005000 for example,
list[0x00012000] == list[0x0005FFE] (correct me if I am wrong, still very tired)
that would make little sense to me. I am sure there is some reason that range between the two indices makes sense, but I simply don't know it.
Quote from: Fox link
Don't try to understand it without seeing the rest of it: (From Atrius's Source code... C++ Space Manager code file.)
Mmhh... aha, so this takes the ROM passed to it by another program/code, then is able to tell you where free space is?
Quote from: Fox link
If one is found... the code inside the if block shown in the first post basically swaps them. I'm not sure why there's an "|0x40000000" though..
I guess the bitwise OR is some kind of marking that methods afterwards can use.
Logged

++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
View Profile
Fox
Fox McCloud, the Hacking Doctor
Mercury Clan

Prodigy
*

Coins: 28
Offline Offline

I am: certainly not a Gallant!
Clan Position: Head Gallant
Posts: 2403

« Reply #4 on: June 21, 2017, 09:43:59 AM »

Quote
Yeah "if (list[i<<1]==list[(i-1)<<1])".
so when i = 0x00005000 for example,
list[0x00012000] == list[0x0005FFE] (correct me if I am wrong, still very tired)
that would make little sense to me. I am sure there is some reason that range between the two indices makes sense, but I simply don't know it.
When i=0x5000
if list[0xA000] == list[0x9FFE]

<<1 is like multiplying by 2.

If you do the calculation for any i, the two address will always be the same distance apart (The entry before and the current one... for when the two addresses match... The problem is I'm not sure how they'd ever match based on the rest of the code used? But I'm sure I could have easily missed something.)

list[0] = The first entry's free space address
list[1] = The first entry's free space size
list[2] = second entry's free space address
list[3] = and size (and so on.)

Also, any i that is 0x4000 or above could be out of bounds. Since he has 0x8000 elements. Although, if it turns out that all the list variable is just a pointer to the data (That's the way I think of * after a type)... (As in, no bounds checking), there may still not be an actual error message....

Only the LOAD_INTs and WRITE_INTs / etc. read/write from the ROM, he puts the contents of interest into a "list" variable instead of messing with it directly from the ROM.

Quote
I guess the bitwise OR is some kind of marking that methods afterwards can use.
I get that he's basically adding the bit 0x40000000 for some reason, just wasn't sure why it was needed in this case. (As again, it requires addresses to match to even get to that part. It makes it feel like it is so that next bolded code doesn't get executed or something. But not sure what the reason for all this is.)

---
My WIP code for C# idea:  (A function that may do similar to Atrius's Repointing system... As for right now, we can't assume that any data in a file table has already been repointed from a hex hacker anyway... that, and patch-friendliness (keeping a smaller patch size than my alternative idea.)....However, I do plan to look into the table resizing idea further, just I was thinking I'll probably want to support both ways. (If possible.) )

int claimSpace(int size)
{
//Find space in a possibly "unorganized" list of the lowest size we can get away with.
//Increased free space address/decreases free space size, if new freeSpace size of entry is 0 , remove entry. (Could be set to the last entry's rather than moving everything over.)
//POSSIBLY after a base is done and if I ever feel like it ... if there's enough free space, but there's not one single section that has enough, then do code to organize some data a bit. - It's possible the function that frees space could have something similar as well. Especially if you can run out of free space entries.  (Not sure how I intend to do that yet, so can be ignored.)
//return that address.
}

Might change it to take an address (and maybe another size value) as well, if I decide it should also be responsible for freeing up the invalidated data... and perhaps even updating the pointer. (e.g. freespace and claimspace function often used together?)
But most of that can probably be done via a separate function... Hmm... freeSpace, claimSpace, reallocate....
« Last Edit: June 21, 2017, 02:49:14 PM by Fox » Logged

Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Remember kids! Before you go on that interview, remember to wash your hands in teawater! *Coughs on hand* (Excuse me, I just coughed up a little teawater, so they're still clean!) You wouldn't want that hiring manager to be unimpressed.

May the force be with you!
Shoo! Why does it smell in here?
Maybe that's the wrong kind of force. *smirk*
View Profile
Luna_blade
The last member of the Luna clan
Luna Clan

Great Member
*

Coins: 0
Offline Offline

I am: Timeless. As in, i don't have much free time.
Posts: 533

« Reply #5 on: June 21, 2017, 03:12:54 PM »

When i=0x5000
if list[0xA000] == list[0x9FFE]
<<1 is like multiplying by 2.
Yeah I know shifts, I just did it wrong... not an expert with Hex.

Quote from: Fox
If you do the calculation for any i, the two address will always be the same distance apart (The entry before and the current one... for when the two addresses match... The problem is I'm not sure how they'd ever match based on the rest of the code used? But I'm sure I could have easily missed something.)

list[0] = The first entry's free space address
list[1] = The first entry's free space size
list[2] = second entry's free space address
list[3] = and size (and so on.)
Pretty interesting.
Logged

++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
View Profile
Fox
Fox McCloud, the Hacking Doctor
Mercury Clan

Prodigy
*

Coins: 28
Offline Offline

I am: certainly not a Gallant!
Clan Position: Head Gallant
Posts: 2403

« Reply #6 on: June 21, 2017, 03:44:05 PM »

@1: Okay. It's always worth making sure, though... Right?
@2: For which? The fact that he did it address, size, address, size, etc. or???
Logged

Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Remember kids! Before you go on that interview, remember to wash your hands in teawater! *Coughs on hand* (Excuse me, I just coughed up a little teawater, so they're still clean!) You wouldn't want that hiring manager to be unimpressed.

May the force be with you!
Shoo! Why does it smell in here?
Maybe that's the wrong kind of force. *smirk*
View Profile
Luna_blade
The last member of the Luna clan
Luna Clan

Great Member
*

Coins: 0
Offline Offline

I am: Timeless. As in, i don't have much free time.
Posts: 533

« Reply #7 on: June 21, 2017, 06:30:50 PM »

@1: Okay. It's always worth making sure, though... Right?
yeah
Quote from: Fox
@2: For which? The fact that he did it address, size, address, size, etc. or???
Well, the whole process of finding free space. I have true trouble grasping this right now (and maybe because some parts are not really written the way I usually write) but still pretty interesting.
Logged

++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
View Profile
Fox
Fox McCloud, the Hacking Doctor
Mercury Clan

Prodigy
*

Coins: 28
Offline Offline

I am: certainly not a Gallant!
Clan Position: Head Gallant
Posts: 2403

« Reply #8 on: June 21, 2017, 06:48:47 PM »

@1: Okay.
@2: Oh.

If no free space table:
 Generate one by going through a number of addresses in MFT. (The ones at the beginning.)
 Using these addresses, work your way backwards.
 For each byte is free space as long as it is a 00. (Once there is a non-zero, go to next MFT address or end of file.... and keep scanning backwards.)
If there is already a table, we can use that to determine free space...
His confirmSpace function will check for 00s, again, though... And if there is a non-zero... Then he'll split the entry into two (The general idea is that the first and last chucks are kept as freespace, anything in the middle isn't)... to ensure that data is only containing zeros.
However, the 00 checks in confirmSpace only applies when (freeSpace address)>>28 does not equal 1. .... Makes sense b/c that could mean things that are repointed (the old data) does not need to be checked for 00s... ... And there may be code that can set an entire section to 00s as well. But I'm thinking/guessing that only applies to what was originally found to be 00. (My guess is that he was aiming to keep the size of patches low.... A lot of that is guessing, though... when I actually look at tha data, I'm like..... Huh? Doesn't look like old/outdated freespace tables are cleared out....


Hmmm.....
« Last Edit: June 21, 2017, 09:04:10 PM by Fox » Logged

Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Remember kids! Before you go on that interview, remember to wash your hands in teawater! *Coughs on hand* (Excuse me, I just coughed up a little teawater, so they're still clean!) You wouldn't want that hiring manager to be unimpressed.

May the force be with you!
Shoo! Why does it smell in here?
Maybe that's the wrong kind of force. *smirk*
View Profile
Atrius
Programmer Extraordinaire
Web Host

Fear my blades

Veteran Member
*

Coins: 1
Offline Offline

Gender: Male
Emblems: Website Founder
Clan Position: Creation God of Sol
Posts: 1757

« Reply #9 on: June 23, 2017, 02:39:17 AM »

Oh wow, this is embarrassing...  I do remember putting code in there to prevent problems that probably wouldn't happen, but I don't even remember a lot of this.  I definitely would have written it very differently if I knew then what I know now...


So...  I'm not entirely sure this was related to it, but there was some trickery going on to solve recursion issues...  The way most of the functions are written they're recursive, so for example findSpace calls confirmSpace which calls organizeList which calls findSpace starting the cycle over.  The 0x40000000 was a bit tag marking the address for some purpose that I can't remember, but it may have been to solve a recursion problem, I doubt it was meant solely for the organizeList function...


Fox has the right idea with the list array.  Even locations in the array (list[i<<1]) are addresses, and odd locations (list[(i<<1)+1]) are sizes.
Logged

I'm shaking my head in general disapproval of everything
View Profile WWW
Pages: [1]   Go Up
  Print  
 
Jump to:  

Cbox
Yesterday at 07:26:16 PM
Fox: (path) 1 text=(address) char=(address) free=(address) ; << Well, closer to this... but yeah... even if I do choose to have defaults in the code, I could still use this method for overrides.
Yesterday at 07:24:28 PM
Fox: So like (path) 0 text=(address) char=(address) len=(number) ; (path) 1 free=(address) ; Or something. But that's just a quick example.
Yesterday at 06:59:14 PM
Fox: Hopefully. I was wanting to make it so you could put in the addresses/etc. as one of the arguments in the path. Hm?
Yesterday at 03:37:07 PM
KyleRunner: Nice! I hope you'll add compatibility with others games (GS1, Mario Golf and Tennis) soon.
January 14, 2018, 11:40:09 PM
Fox: Okay. Posted (in Downloads section) an initial cutdown version for now, for my text compressor. Basically to separate the code from my Editor for anyone who wants to mess with it. It only supports GS2, because I still didn't add the addresses/etc. for the other games.
January 14, 2018, 05:01:00 PM
Fox: Okay! Going to need to think how I want it to work. Initial thoughts is maybe have a number of arguments in the filepath thing. And have a number of shortcuts (files) to be used as examples. Assuming there are no problems.
January 14, 2018, 10:38:24 AM
KyleRunner: Well... I'm used to editing text ina a text editor, so... yes! Thanks in advance!
January 13, 2018, 11:38:43 PM
Fox: (Text editor = Text Document like notepad.)
January 13, 2018, 11:38:21 PM
Fox: Would you prefer during the text editing in a text editor? (Like what gstoolkit lets you do?) I could probably make a separate tool or something to compress it.
January 13, 2018, 10:10:02 PM
KyleRunner: Ok. Once I finish my Lost Age translation, I'll try a Mario Golf one. Thanks. (But I'll need help).
January 13, 2018, 10:03:17 PM
Fox: If you want to make it "permanent" (part of a hack), then you'd edit code in the ROM that writes to this location of the IDs you'd want to change. (You can find these locations by using a breakpoint debugger like SDL-H or no$gba.)
January 13, 2018, 10:00:11 PM
Fox: Reload/switch = Recommended to be done through Debug mode/warp menu, ofcourse... since doors seem to appear as if they were disabled? ; 03001238:01 and B+Start to get to warp menu.
January 13, 2018, 09:55:39 PM
Fox: @Kyle Runner = It might be, but you'd have to use the correct addresses for Mario Golf, rather than for GS2 as I have it right now. ; @raijinken = Yes. 02000454 = ID of leader. (Change this and reload/switch room you are in, enjoy.)
January 13, 2018, 02:23:29 PM
raijinken: Hey guys, is it possible to somehow change the lead character on the map? Was wondering. I remember there was a cheat to use Jenna, but what if I wanted Isaac, or Piers?
January 13, 2018, 02:10:03 PM
KyleRunner: Hey, Fox *
January 13, 2018, 02:09:37 PM
KyleRunner: Hey, is your text editor compatible with Mario Golf (GBA)?
January 11, 2018, 08:33:13 PM
Fox: But if it isn't an oversight, I still can't imagine it being that useful.
January 11, 2018, 08:28:24 PM
Fox: part, ofcourse.
January 11, 2018, 08:28:15 PM
Fox: 0200274C = Hmm... Stuff happens here when you use Cyclone around bushes. (These cause tile replacements, and setting event 0 to those tiles.) - And I guess this kept here so it can be scanned after battle. (To re-update the map.) So here is my fun thought (assuming if it is even possible, or even convenient if so.) ... Are there any events from other maps that could be disabled do to using Cyclone on bushes + Retreat glitch? I'll need to do some testing to make sure this isn't an oversight on my
January 09, 2018, 08:09:26 PM
Fox: And the chance for a Djinni battle is 50%.

Affiliates
Temple of Kraden Golden Sunrise
Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.128 seconds with 22 queries.