Skip to content

Instantly share code, notes, and snippets.

@marijnvdwerf
Last active April 29, 2017 19:02
Show Gist options
  • Save marijnvdwerf/7f1f8ac1dfe72b916bb01ff028be0ae1 to your computer and use it in GitHub Desktop.
Save marijnvdwerf/7f1f8ac1dfe72b916bb01ff028be0ae1 to your computer and use it in GitHub Desktop.
#include "global.h"
#include "asm.h"
#include "sprite.h"
#include "string_util.h"
#include "text.h"
extern void *gUnknown_0820A804[];
extern void *gUnknown_0820A80C[];
extern void *gUnknown_0820A814[];
extern u8 gUnknown_0820A81C[0x1E];
#define WRITE_CHAR(string, charcode) \
{ \
*string = charcode; \
string++; \
}
#ifdef NONMATCHING
void sub_8043FC0(u8 spriteId, u8 r1) {
u8 *string;
u8 owner;
u8 *src;
void **destList;
s32 r4;
u8 data[30];
struct Sprite *sprite;
memcpy(data, gUnknown_0820A81C, sizeof(data));
if (!IsDoubleBattle())
{
owner = battle_side_get_owner(gSprites[spriteId].data6);
destList = gUnknown_0820A80C;
if (owner == 0)
{
destList = gUnknown_0820A804;
}
}
else
{
owner = battle_side_get_owner(gSprites[spriteId].data6);
destList = gUnknown_0820A80C;
if (owner == 0)
{
destList = gUnknown_0820A814;
}
}
string = data + 6;
if (r1 == 100)
{
string = ConvertIntToDecimalStringN(string, 100, STR_CONV_MODE_LEFT_ALIGN, 3);
}
else
{
WRITE_CHAR(string, EXT_CTRL_CODE_BEGIN);
string = data + 7;
WRITE_CHAR(string, 0x11);
WRITE_CHAR(string, 0x01);
WRITE_CHAR(string, EXT_CTRL_CODE_BEGIN);
WRITE_CHAR(string, 0x14);
WRITE_CHAR(string, 0x04);
WRITE_CHAR(string, 0xF0); // :
WRITE_CHAR(string, EXT_CTRL_CODE_BEGIN);
WRITE_CHAR(string, 0x14);
WRITE_CHAR(string, 0x00);
string = ConvertIntToDecimalStringN(string, r1, STR_CONV_MODE_LEFT_ALIGN, 2);
}
WRITE_CHAR(string, EXT_CTRL_CODE_BEGIN);
WRITE_CHAR(string, 0x13);
WRITE_CHAR(string, 0x0F);
*string = EOS;
sub_80034D4((u8 *) 0x2000000, data);
// wrong register
sprite = gSprites;
sprite += spriteId;
src = (u8 *) 0x2000020;
for (r4 = 2; r4 != 0; r4--)
{
s32 index = sprite->oam.tileNum;
CpuSet(src, *destList + index * 32, CPU_SET_32BIT | 8);
destList++;
src += 0x40;
}
}
#endif
#include "global.h"
#include "link.h"
#include "string_util.h"
#include "menu.h"
#include "sprite.h"
#include "main.h"
#include "item.h"
#include "task.h"
struct UnkStruct_Sub {
u8 filler00[16];
};
struct UnkStruct {
/*0x00*/ u8 unk00;
/*0x01*/ u8 filler01[79];
/*0x50*/ u8 unk50[4];
/*0x54*/ u8 filler54[6];
/*0x5A*/ u16 unk5A;
/*0x5C*/ u8 filler5C[36];
/*0x80*/ u16 unk80[4];
/*0x88*/ u8 unk88;
/*0x89*/ u8 filler89[34];
/*0xAB*/ u8 unkAB[129];
/*0x12C*/ u32 unk12C;
/*0x130*/ s32 unk130;
/*0x134*/ u8 filler134[48];
/*0x164*/ u8 unk164[4];
/*0x168*/ u8 filler168[20];
/*0x17C*/ u8 unk17C[2];
/*0x17C*/ u8 unk17E[4][16];
};
extern u8 gUnknown_03004834;
extern struct UnkStruct *gUnknown_03004854;
// data/berry_blender.o
extern u8 *gUnknown_082162B8[];
extern const u8 gUnknown_082165E9[5];
extern const u8 gUnknown_082165EE[5];
// data/strings2.o
extern const u8 gMultiText_BerryBlenderMaxSpeedRecord[];
extern const u8 gMultiText_2P3P4P[];
extern const u8 gOtherText_ResultsOfBlending[];
extern const u8 gOtherText_Berry[];
extern const u8 gOtherText_RequiredTime[];
extern const u8 gOtherText_Min[];
extern const u8 gOtherText_Sec[];
extern const u8 gOtherText_MaxSpeed[];
extern const u8 gOtherText_RPM[];
#define CHAR_PERIOD 0xAD
void sub_8050760(void);
void sub_8052BD0(u8 taskId);
extern u16 gScriptItemId;
void sub_805201C(struct Pokeblock *arg0, u8 *arg1);
void sub_810CA34(struct Pokeblock *arg0);
void sub_8050520(void *arg0, struct Pokeblock *pokeblock, u8 arg2, u8 *arg3, u16 arg4);
#ifdef NONMATCHING
u8 sub_8051C58(void) {
switch (gUnknown_03004854->unk00)
{
case 0:
gUnknown_03004854->unk00 += 1;
gUnknown_03004854->unk130 = 17;
break;
case 1:
gUnknown_03004854->unk130 -= 10;
if (gUnknown_03004854->unk130 < 0)
{
gUnknown_03004854->unk130 = 0;
gUnknown_03004854->unk00 += 1;
}
break;
case 2:
gUnknown_03004854->unk130 += 1;
if (gUnknown_03004854->unk130 > 20)
{
u16 i;
for (i = 0; i < 3; i++)
{
DestroySprite(&gSprites[gUnknown_03004854->unk50[i]]);
}
gUnknown_03004854->unk130 = 0;
gUnknown_03004854->unk00 += 1;
}
break;
case 3:
{
u8 *ptr;
u8 buffer[16];
u8 r9[10];
u16 value, r4, value2, value3, value4, i;
MenuDrawTextWindow(4, 2, 25, 17);
sub_8072BD8((u8 *) gOtherText_ResultsOfBlending, 5, 3, 160);
// TODO: decompile
if (gUnknown_03004854->unk88 > 0)
{
for (i = 0; i < gUnknown_03004854->unk88; i++)
{
u8 *ptr;
u8 byte = gUnknown_03004854->unk164[i];
StringCopy(r9, gUnknown_03004854->unk17E[byte]);
ConvertInternationalString(r9, gLinkPlayers[byte].language);
StringAppend(r9, gOtherText_Berry);
ptr = ConvertIntToDecimalString(gUnknown_03004854->unkAB, i + 1);
ptr[0] = CHAR_SPACE;
ptr[1] = CHAR_PERIOD;
ptr[2] = CHAR_PERIOD;
ptr += 3;
ptr = sub_8072C74(ptr, gLinkPlayers[byte].name, 88, 0);
sub_8072C74(ptr, r9, 157, 0);
MenuPrint(
gUnknown_03004854->unkAB,
5,
gUnknown_082165E9[gUnknown_03004854->unk88] + gUnknown_082165EE[gUnknown_03004854->unk88] * i
);
}
}
value4 = gUnknown_03004854->unk5A % 100;
ConvertIntToDecimalStringN(r9, value4, 2, 2);
ptr = gUnknown_03004854->unkAB;
ptr = StringCopy(ptr, gOtherText_MaxSpeed);
MenuPrint(gUnknown_03004854->unkAB, 5, 13);
value3 = gUnknown_03004854->unk5A / 100;
ptr = sub_8072C14(ptr, value3, 121, 1);
ptr[0] = CHAR_SPACE;
ptr[1] = CHAR_PERIOD;
ptr[2] = CHAR_PERIOD;
ptr += 3;
ptr = sub_8072C74(ptr, r9, 142, 1);
StringCopy(ptr, gOtherText_RPM);
MenuPrint(gUnknown_03004854->unkAB, 5, 13);
r4 = gUnknown_03004854->unk12C / 60;
value = r4 % 60;
value2 = r4 / 60;
ConvertIntToDecimalStringN(r9, value2, 2, 2);
ConvertIntToDecimalStringN(buffer, value, 2, 2);
ptr = gUnknown_03004854->unkAB;
ptr = StringCopy(ptr, gOtherText_RequiredTime);
ptr = sub_8072C74(ptr, r9, 102, 1);
ptr = StringAppend(ptr, gOtherText_Min);
ptr = sub_8072C74(ptr, buffer, 136, 1);
StringCopy(ptr, gOtherText_Sec);
MenuPrint(gUnknown_03004854->unkAB, 5, 15);
gUnknown_03004854->unk130 = 0;
gUnknown_03004854->unk00 += 1;
}
break;
case 4:
if (gMain.newKeys & 1)
{
gUnknown_03004854->unk00 += 1;
}
break;
case 5:
{
struct Pokeblock buffer;
u8 buffer2[16];
u16 results[4];
u16 i;
MenuZeroFillScreen();
MenuDrawTextWindow(0, 14, 29, 19);
for (i = 0; i < 4; i++)
{
if (gUnknown_03004854->unk80[i] != 0)
{
results[i] = gUnknown_03004854->unk80[i] - 133;
}
}
sub_8050760();
sub_8050520(gUnknown_03004854->unk17C, &buffer, gUnknown_03004854->unk88, buffer2, gUnknown_03004854->unk5A);
sub_805201C(&buffer, gUnknown_03004854->unkAB);
CreateTask(sub_8052BD0, 6);
MenuPrintMessage(gUnknown_03004854->unkAB, 1, 15);
RemoveBagItem(gScriptItemId, 1);
sub_810CA34(&buffer);
gUnknown_03004854->unk00 += 1;
}
break;
case 6:
if (MenuUpdateWindowText())
{
return TRUE;
}
break;
}
return FALSE;
}
#endif
#ifdef NONMATCHING
void ShowBerryBlenderRecordWindow(void) {
int i;
u8 buffer[32];
MenuDrawTextWindow(6, 3, 23, 16);
MenuPrint(gMultiText_BerryBlenderMaxSpeedRecord, 8, 4);
MenuPrint(gMultiText_2P3P4P, 8, 9);
for (i = 0; i < 3; i++)
{
u32 record;
u8 *ptr;
record = gSaveBlock1.berryBlenderRecords[i];
ptr = sub_8072C14(buffer, record / 100, 18, 1);
ptr[0] = CHAR_SPACE;
ptr[1] = CHAR_PERIOD;
ptr[2] = CHAR_PERIOD;
ptr += 3;
ptr = ConvertIntToDecimalStringN(ptr, record % 100, STR_CONV_MODE_LEADING_ZEROS, 2);
StringAppend(ptr, gOtherText_RPM);
MenuPrint(buffer, 15, 9 + 2 * i);
}
}
#endif
#include "global.h"
#include "text.h"
#include "item.h"
#include "menu.h"
struct UnkStruct {
/*0x00*/ u8 var00;
/*0x01*/ u8 var01;
/*0x02*/ u8 filler02[2];
};
extern u8 gUnknown_02038558;
extern s8 gUnknown_02038559;
extern struct UnkStruct gUnknown_03005D10[];
extern struct BagPocket *gUnknown_03005D24;
void sub_80A4030();
void sub_80A405C();
void sub_80A40AC();
u8 *sub_80A425C(u8, u8 *, u8);
u8 sub_80A42B0(u8, int);
#ifdef NONMATCHING
void sub_80A444C(u16 arg0, u8 arg1, int arg2, int arg3) {
u8 i;
i = arg1;
while (TRUE)
{
u8 index;
u8 top;
struct Item *item;
u8 *local3;
if (i > arg2)
{
break;
}
if (sub_80A42B0(i, arg3) == TRUE)
{
break;
}
index = gUnknown_03005D10[gUnknown_02038559].var01 + i;
top = 2 + i * 2;
local3 = sub_80A425C(arg0, gStringVar1, i);
item = ItemId_GetItem(gUnknown_03005D24->itemSlots[index].itemId);
sub_8072C74(local3, item->name, 96, 0);
MenuPrint(gStringVar1, 14, top);
if (gUnknown_02038558)
{
if (gUnknown_03005D24->itemSlots[index].itemId == gSaveBlock1.registeredItem)
{
sub_80A4030(i);
}
}
else
{
if (gUnknown_03005D24->itemSlots[index].itemId == gSaveBlock1.registeredItem)
{
sub_80A405C(i);
}
else
{
sub_80A40AC(i);
}
}
i += 1;
}
}
#endif
#include "global.h"
#include "task.h"
#include "palette.h"
#include "main.h"
#include "text.h"
#include "menu.h"
#include "pokedex.h"
#include "sound.h"
#include "strings.h"
#include "event_data.h"
#define CHAR_0 (0xA1)
#define CHAR_PERIOD (0xAD)
#define CHAR_COMMA (0xB8)
#define DECIMAL_SEPERATOR CHAR_PERIOD
u16 NationalPokedexNumToSpecies(u16);
u16 NationalToHoennOrder(u16);
extern IntrCallback gUnknown_03005CEC;
extern u8 gPokedexMenu_Gfx[];
extern u8 gUnknown_08E96BD4[];
struct PokedexEntry {
/*0x00*/ u8 categoryName[12];
/*0x0C*/ u16 height; //in decimeters
/*0x0E*/ u16 weight; //in hectograms
/*0x10*/ u8 *descriptionPage1;
/*0x14*/ u8 *descriptionPage2;
/*0x18*/ u16 unused;
/*0x1A*/ u16 pokemonScale;
/*0x1C*/ u16 pokemonOffset;
/*0x1E*/ u16 trainerScale;
/*0x20*/ u16 trainerOffset;
}; /*size = 0x24*/
extern struct PokedexEntry gPokedexEntries[];
#ifdef NONMATCHING
void unref_sub_80913A4(u16 r0, u8 left, u8 top) {
u8 chars[8];
u8 hundreds, tens;
bool8 outputted;
outputted = FALSE;
hundreds = r0 / 1000;
if (hundreds == 0)
{
chars[0] = CHAR_SPACE;
}
else
{
chars[0] = CHAR_0 + hundreds;
outputted = TRUE;
}
tens = ((r0 % 1000) / 100);
if (tens == 0 && !outputted)
{
chars[1] = CHAR_SPACE;
}
else
{
chars[1] = CHAR_0 + tens;
}
chars[2] = CHAR_0 + (((r0 % 1000) % 100) / 10);
chars[3] = DECIMAL_SEPERATOR;
chars[4] = CHAR_0 + (((r0 % 1000) % 100) % 10);
chars[5] = EOS;
MenuPrint(chars, left, top);
}
#endif
#include "global.h"
#include "menu.h"
#include "string_util.h"
struct StorageAction {
u8 *text;
u8 unk4;
};
extern const struct StorageAction gUnknown_083B6DF4[];
extern const u8 unk_2000000[];
#define gUnk2002694 (u8 *)(&unk_2000000[0x2694])
#define gUnk20011fa (u8 *)(&unk_2000000[0x11fa])
#define gUnk20026e4 (u8 *)(&unk_2000000[0x26e4])
#ifdef NONMATCHING
void sub_8098898(u8 arg0) {
u8 *ptr;
MenuDrawTextWindow(10, 16, 29, 19);
switch (gUnknown_083B6DF4[arg0].unk4)
{
case 2:
ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[arg0].text);
ptr = StringCopy(ptr, gUnk20011fa);
break;
case 5:
ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[arg0].text);
ptr = StringCopy(ptr, gUnk20011fa);
break;
case 1:
// {var} + " is selected."
ptr = StringCopy(gUnk2002694, gUnk20011fa);
ptr = StringCopy(ptr, gUnknown_083B6DF4[arg0].text);
break;
case 4:
// {var} + " was released."
ptr = StringCopy(gUnk2002694, gUnk20026e4);
ptr = StringCopy(ptr, gUnknown_083B6DF4[arg0].text);
break;
case 3:
{
u8 *stringLength;
u8 *text;
text = gUnknown_083B6DF4[arg0].text;
stringLength = &text[StringLength(text)] + 1;
ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[arg0].text);
ptr = StringCopy(ptr, gUnk20011fa);
ptr = StringCopy(ptr, stringLength);
}
break;
case 6:
// "Bye-bye, !".substr(-1) + {var} + "Bye-bye, !".last()
{
u8 *stringLength;
u8 *text;
text = gUnknown_083B6DF4[arg0].text;
stringLength = &text[StringLength(text)] - 1;
ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[arg0].text);
ptr = StringCopy(ptr - 1, gUnk20026e4);
ptr = StringCopy(ptr, stringLength);
}
break;
case 0:
default:
ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[arg0].text);
break;
}
while (ptr != &unk_2000000[0x2694+18])
{
ptr[0] = CHAR_SPACE;
ptr++;
}
ptr[0] = EOS;
MenuPrint(gUnk2002694, 11, 17);
}
#endif
#include "global.h"
#include "sprite.h"
#include "text.h"
#include "menu.h"
struct UnkStructA {
/*0x00*/ u8 filler00[4];
/*0x04*/ struct Window unk04;
/*0x34*/ u8 spriteIds[2][6];
/*0x40*/ u8 filler40[2];
/*0x42*/ u8 unk42[4];
/*0x46*/ u8 filler46[0x34];
/*0x7A*/ u8 unk7A;
/*0x7B*/ u8 filler7B[3];
/*0x7E*/ u16 unk7E;
/*0x80*/ u8 unk80[4];
/*0x84*/ u8 unk84;
/*0x85*/ u8 filler85[67];
/*0xC8*/ u8 unkC8[1];
};
struct UCoords8 {
u8 x;
u8 y;
};
extern struct UnkStructA *gUnknown_03004824;
// data/strings2.o
extern const u8 gOtherText_Terminator2[];
extern const u8 *gUnknown_0820C14C[];
// data/trade.o
extern const u16 gTradeMovesBoxTilemap[];
extern const u16 gTradePartyBoxTilemap[];
extern const struct UCoords8 gTradeMonSpriteCoords[];
extern const u8 gUnknown_0820C330[][2];
extern const u8 gUnknown_0820C334[][2][2];
extern const s8 gUnknown_0820C3D1[][2];
// asm/pokemon_icon.o
void sub_809D62C(struct Sprite *);
// asm/trade.o
s8 sub_804A2B4(u8 *, int, int);
void sub_804A33C(u8 *buffer, u8 var28, u8 local1);
void sub_804A51C(u8 r0, u8 r1, u8 r2, u8 r3, u8 sp, u8 sp4);
void sub_804A80C(void);
void sub_804A96C(void *, u8, u8, u16 *, u8, u8, u16);
void sub_804ACD8(u8 *, void *, u8);
// asm/rom_8077ABC.o
void oamt_set_x3A_32(struct Sprite *sprite, void(*callback)(struct Sprite *));
void sub_8078A34(struct Sprite *);
#ifdef NONMATCHING
void sub_8049ED4(u8 arg0) {
u8 buffer1[40];
u8 buffer[56];
u8 monPos;
u8 player;
u32 spriteId;
player = 1;
if (gUnknown_03004824->unk84 <= 5)
{
player = 0;
}
monPos = gUnknown_03004824->unk84 % 6;
switch (gUnknown_03004824->unk80[arg0])
{
case 1:
asm_comment("Case 1");
if (gUnknown_03004824->unk42[arg0] > 0)
{
u8 i;
for (i = 0; i < gUnknown_03004824->unk42[arg0]; i++)
{
gSprites[gUnknown_03004824->spriteIds[player][i]].invisible = TRUE;
}
}
gSprites[gUnknown_03004824->spriteIds[player][monPos]].invisible = FALSE;
gSprites[gUnknown_03004824->spriteIds[player][monPos]].data0 = 20;
gSprites[gUnknown_03004824->spriteIds[player][monPos]].data2 = ((gTradeMonSpriteCoords[player * 6].x + gTradeMonSpriteCoords[player * 6 + 1].x) / 2 * 8) + 14;
gSprites[gUnknown_03004824->spriteIds[player][monPos]].data4 = gTradeMonSpriteCoords[player*6].x * 8 - 12;
oamt_set_x3A_32(&gSprites[gUnknown_03004824->spriteIds[player][monPos]], sub_809D62C);
gUnknown_03004824->unk80[arg0] += 1;
sub_8078A34(&gSprites[gUnknown_03004824->spriteIds[player][monPos]]);
sub_8072DEC();
// (struct Window *win, u16 tileNum, u8 left, u8 top, u8 right, u8 bottom);
FillWindowRect_DefaultPalette(
&gUnknown_03004824->unk04,
0,
gUnknown_0820C330[player][0],
0,
gUnknown_0820C330[player][1],
19
);
sub_804A96C(
gUnknown_03004824->unkC8,
arg0 * 16 - arg0,
0,
(u16 *) gTradePartyBoxTilemap,
15,
17,
0
);
if (player == 0)
{
sub_804A80C();
}
break;
case 2:
{
struct Sprite *sprites = gSprites;
asm_comment("Case 2");
spriteId = gUnknown_03004824->spriteIds[player][monPos];
if (sprites[spriteId].callback == sub_809D62C)
{
gUnknown_03004824->unk80[arg0] = 3;
}
}
break;
case 3:
{
s8 width;
asm_comment("Case 3");
sub_804A96C(
gUnknown_03004824->unkC8,
player * 15,
0,
gTradeMovesBoxTilemap,
15,
17,
0
);
gSprites[gUnknown_03004824->spriteIds[player][monPos]].pos1.x = ((gTradeMonSpriteCoords[player * 6].x + gTradeMonSpriteCoords[player * 6 + 1].x) / 2 * 8) + 14;
gSprites[gUnknown_03004824->spriteIds[player][monPos]].pos1.y = gTradeMonSpriteCoords[player * 6].y - 12;
gSprites[gUnknown_03004824->spriteIds[player][monPos]].pos2.x = 0;
gSprites[gUnknown_03004824->spriteIds[player][monPos]].pos2.y = 0;
width = sub_804A2B4(&buffer1[6], player, monPos);
buffer1[0] = 0xFC;
buffer1[1] = 0x06;
buffer1[2] = 0x04;
buffer1[3] = 0xFC;
buffer1[4] = 0x11;
buffer1[5] = (64 - width) / 2;
sub_8003460(
&gUnknown_03004824->unk04,
buffer1,
gUnknown_03004824->unk7A + player * 192,
gUnknown_0820C334[player][0][0],
gUnknown_0820C334[player][0][1]
);
sub_804A33C(buffer, player, monPos);
sub_8003460(
&gUnknown_03004824->unk04,
gOtherText_Terminator2,
gUnknown_03004824->unk7A + player * 192 + 32,
gUnknown_0820C334[player][1][0],
gUnknown_0820C334[player][1][1] + 1
);
sub_8003460(
&gUnknown_03004824->unk04,
buffer,
gUnknown_03004824->unk7A + player * 192 + 38,
gUnknown_0820C334[player][1][0],
gUnknown_0820C334[player][1][1] + 1
);
gUnknown_03004824->unk80[arg0] += 1;
}
break;
case 4:
asm_comment("Case 4");
// 'Press B to exit'
sub_804ACD8((u8 *) gUnknown_0820C14C[5], (void *) (VRAM + 0x10000 + gUnknown_03004824->unk7E * 32), 20);
sub_804A51C(
arg0,
monPos,
gUnknown_0820C3D1[arg0][0] + 4,
gUnknown_0820C3D1[arg0][1] + 1,
gUnknown_0820C3D1[arg0][0],
gUnknown_0820C3D1[arg0][1]
);
gUnknown_03004824->unk80[arg0] += 1;
break;
}
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment