Points of Required Attention™
Please chime in on a proposed restructuring of the ROM hacking sections.
Views: 88,558,386
Main | FAQ | Uploader | IRC chat | Radio | Memberlist | Active users | Latest posts | Calendar | Stats | Online users | Search 05-08-24 01:34 AM
Guest: Register | Login

Main - Posts by caitsith2


caitsith2
Posted on 08-21-09 01:14 AM, in SMA4 level card level compressor Link | Quote | ID: 113910

Newcomer
Level: 8

Posts: 1/8
EXP: 1658
Next: 529

Since: 08-21-09

Last post: 3312 days
Last view: 3024 days
I fixed a bug in the code, that was causing the last byte to not be compressed correctly. Smaller compression doesn't do any good, if it does not decompress correctly. Turns out more than just 1 byte of l, at the end of the range stream was actually required to correctly decompress the last byte.

Also dealt with some input validation while I was at it, and final output, in case of e-reader levels.

#include<stdint.h>
#include <stdio.h>

int range(int size,int*src,int ws,char*dst)
{
unsigned di=0,c[0x1000],t[0x1001],l=0,w=0xFFFFFFFF;
for(int x=0;x<ws;x++)
{
c[x]=1;
t[x]=x;
}
t[ws]=ws;
for(int si=0;si<size;si++)
{
int n=src[si];
l+=t[n]*(w/=t[ws]);w*=c[n]++;
for(int x=n;x<ws;t[++x]++);
if(t[ws]>0xFFFF)
{
t[0]=0;
for(int x=0;x<ws;x++)
t[x+1]=t[x]+(c[x]=c[x]>>1|1);
}
while((l&0xFF000000)==(l+w&0xFF000000))
{
dst[di++]=l>>24;
l<<=8;
w<<=8;
}
while(w<=0xFFFF)
{
w=(0x10000-(l&0xFFFF))<<8;
dst[di++]=l>>24;
l<<=8;
}
}
while((l&0xFF000000)==(l+w&0xFF000000))
{
dst[di++]=l>>24;
l<<=8;
w<<=8;
}
while(l&0xFF000000)
{
dst[di++]=(l>>24);
l<<=8;
}
return di;
}

#define MIN(x,y) ((x)<(y)?(x): (y))

int data[0x10000];
int offset[0x4000];

int compress(uint32_t size,uint8_t*src,uint8_t mode,uint8_t*dst)
{
int di=0,oi=0,ws=mode&0x80?0x1000:0x200,ds,os;
dst[0]='A';
dst[1]='S';
dst[2]='R';
dst[3]='0';

dst[4]=mode;
dst[5]=size>>16;
dst[6]=size>>8&0xFF;
dst[7]=size&0xFF;

for(int si=0;si<size; )
{
int bo,bc=0;
for(int off=1;off<=MIN(si,ws);off++)
{
int c;
for(c=0;c<MIN(size-si,0x102);c++)
if(src[si-off+c]!=src[si+c])
break;
if(c>bc)
{
bo=off;
bc=c;
}
}
if(bc>2)
{
data[di++]=bc+0xFD;
offset[oi++]=bo-1;
si+=bc;
}
else
data[di++]=src[si++];
}
//di+=4;
ds=range(di,data,0x200,(char*)dst+12);
os=range(oi,offset,ws,(char*)dst+ds+12);
dst[8]=ds+12>>24;
dst[9]=ds+12>>16&0xFF;
dst[10]=ds+12>>8&0xFF;
dst[11]=ds+12&0xFF;
return ds+12+os;
}


// [insert the code in the post here]
int main(int argc, char* argv[])
{
if(argc<3)
{
printf("Usage: compress <in_file> <out_file>\n");
return -1; // too few arguments
}
FILE *flin=fopen(argv[1],"rb");
FILE *flout=fopen(argv[2],"wb");
if((flin==NULL)||(flout==NULL))
{
printf("Error opening in/out file\n");
return -1;
}
char buf1[409600],buf2[409600]; //400KB each
int size=fread(buf1,1,409600,flin);
size=compress(size,(uint8_t*)buf1,0,(uint8_t*)buf2);
fwrite(buf2,1,size,flout);
if(size>0x7C6)
printf("This level will not work on an e-reader.\n");
fclose(flin);fclose(flout);
return 0;
}



caitsith2
Posted on 08-21-09 09:42 AM, in SUPER MARIO ADVANCE 4 - Hacking & Editor Efforts Link | Quote | ID: 113924

Newcomer
Level: 8

Posts: 2/8
EXP: 1658
Next: 529

Since: 08-21-09

Last post: 3312 days
Last view: 3024 days
Managed to finally apply the translated names over to the actual e-reader level card data. These are located on http://caitsith2.com/ereader/sma4.htm

It was the lack of a working compressor that had proven to be the initial road block from doing that.

caitsith2
Posted on 08-22-09 04:19 AM, in SUPER MARIO ADVANCE 4 - Hacking & Editor Efforts Link | Quote | ID: 113953

Newcomer
Level: 8

Posts: 3/8
EXP: 1658
Next: 529

Since: 08-21-09

Last post: 3312 days
Last view: 3024 days
Yet another thing I have managed to do, deals with the European version of the game. It seems that Nintendo did have plans at one point to release an European e-reader, but pulled the plug on that. Instead of outright removing the code from the European SMA4, they just disabled it, presumably with a button code way of enabling it. (can't prove that yet.)

Of course, even with it enabled, European SMA4 will not communicate with the US e-reader, just like US sma4 won't communicate with Japanese e-reader.

Second, a card loader had been extracted from the game, and turned into a save. Unfortunately, card region checking is done by both the e-reader, locking out ALL but its own region, and by the loader, also locking out all but its own region. This means if you do dump the loader from one e-reader, and put it on an out of region e-reader, That out of region e-reader will pass on the card to the loader, but now the loader is going to reject the card as being out of region.

Next, the game won't communicate with its region loader either. However, that proves to be very trivial to patch. As it turns out, The European version, has 5 different card loaders built in, one for each language the game is playable in. The loader on the e-reader, has to match the language selected. Also trivial, just patch it once, make a save, patch it for the next language, make a save.

End result, is in the same place is the readable translated named cards, is a pack for loading onto an european sma4 and us e-reader. The full thing nintendo locked the europeans out of, has been completely unlocked.

caitsith2
Posted on 08-22-09 06:37 AM, in SUPER MARIO ADVANCE 4 - Hacking & Editor Efforts Link | Quote | ID: 113956

Newcomer
Level: 8

Posts: 4/8
EXP: 1658
Next: 529

Since: 08-21-09

Last post: 3312 days
Last view: 3024 days
Posted by Bond697
just so you know, some of those cards marked as unreleased were definitely released. i own at least half of them. unless you mean something else by unreleased.


What I meant by unreleased, is unreleased officially in the North American region. 100% of the SMA4 cards were officially unreleased in the European region, and 100% of them were officially released in the Japan region, as far as the official cards go.

caitsith2
Posted on 08-22-09 08:14 AM, in SUPER MARIO ADVANCE 4 - Hacking & Editor Efforts Link | Quote | ID: 113960

Newcomer
Level: 8

Posts: 5/8
EXP: 1658
Next: 529

Since: 08-21-09

Last post: 3312 days
Last view: 3024 days
Can you show me pictures of those cards then, as proof of them having been released?

Anyways, I went and did a more detailed character map, used by US/EU version of SMA4, for level names. (Jap version uses shift-jis as far as I know.)

A-Z 		 = 00-19
= 1A-1B undefined
',. = 1C-1E
= 1F undefined
a-z = 20-39
ÄÖÜÂÀÇ = 3A-3F
ÉÈÊËÎÏÔŒ = 40-47
ÙÛÁÍÑÓÚÌ = 48-4F
Òäöüßéâà = 50-57
çèêëîïôœ = 58-5F
ùûáíñóúì = 60-67
ò°[er][re]e¿¡a = 68-6F
”“’‘«» = 70-75
0-9 = 76-7F
… „“‚‘ = 80-85
= 86-C3 undefined
[mushroom] = C4
[flower] = C5
[star] = C6
[Circle] = C7
[Heart] = C8
[Monospaced A-U] = C9-DD
= DE-DF undefined
?!-[space] = E0-E3
[Superscript 0-9]= E4-ED
[Subscript 0-9] = EE-F7
e = F8
[Monospaced V-Z] = F9-FD
[Promotional] = FE
[Null] = FF

caitsith2
Posted on 04-10-15 05:06 PM, in Super mario bros 3 advanced 4 hacking Link | Quote | ID: 159840

Newcomer
Level: 8

Posts: 6/8
EXP: 1658
Next: 529

Since: 08-21-09

Last post: 3312 days
Last view: 3024 days
Update that SMA4 E-Reader stuff with http://acmlm.kafuka.org/uploader/get.php?id=4826

I specifically extracted the rare b-dash level from that dumped save, and turned it into an e-reader format .raw format, that will scan on a US e-reader, with an english name. Also included all of the other converted to english name levels as well.

caitsith2
Posted on 04-13-15 06:44 AM, in SUPER MARIO ADVANCE 4 - Hacking & Editor Efforts Link | Quote | ID: 159884

Newcomer
Level: 8

Posts: 7/8
EXP: 1658
Next: 529

Since: 08-21-09

Last post: 3312 days
Last view: 3024 days
Posted by erpster2
Posted by caitsith2
Managed to finally apply the translated names over to the actual e-reader level card data. These are located on http://caitsith2.com/ereader/sma4.htm

It was the lack of a working compressor that had proven to be the initial road block from doing that.


wonderful caitsith2. one problem; all of the levels with the fully translated english names I've tested work except Bowser's Airship Part 1.

After loading the "mushroom 29 - Bowser's Airship Part 1.raw" file into no$gba emulator and attempting to play Bowsers Airship Part1 level, it would start off messed up like this:



mario or luigi would no longer be on screen and the messed up airship would keep scrolling to the right and I would automatically die. seems like that RAW file has some incorrect level data and needs a do-over. can you fix this?


Okay, bug fixed Bowser's Airship part 1. The update is available in http://acmlm.kafuka.org/uploader/get.php?id=4836

This pack also includes the official B-Dash level that was ripped from the dumped save file.

caitsith2
Posted on 04-13-15 06:46 AM, in Super mario bros 3 advanced 4 hacking Link | Quote | ID: 159885

Newcomer
Level: 8

Posts: 8/8
EXP: 1658
Next: 529

Since: 08-21-09

Last post: 3312 days
Last view: 3024 days
Updated the pack again, this time, with Bowser's Airship Part 1 fixed. http://acmlm.kafuka.org/uploader/get.php?id=4836

Main - Posts by caitsith2

Acmlmboard 2.1+4δ (2023-01-15)
© 2005-2023 Acmlm, blackhole89, Xkeeper et al.

Page rendered in 3.609 seconds. (329KB of memory used)
MySQL - queries: 68, rows: 88/88, time: 3.601 seconds.