Merge branch 'master' of https://github.com/pret/pokeemerald into fr_doc

This commit is contained in:
Kurausukun
2021-03-29 18:36:18 -04:00
70 changed files with 2615 additions and 2356 deletions
+1 -1
View File
@@ -941,7 +941,7 @@
.byte 0xb5 .byte 0xb5
.endm .endm
.macro happinesstodamagecalculation .macro friendshiptodamagecalculation
.byte 0xb6 .byte 0xb6
.endm .endm
+2 -2
View File
@@ -1,4 +1,4 @@
gFonts gFonts
gUnknown_03002F84 gDisableTextPrinters
gUnknown_03002F90 gCurGlyph
gTextFlags gTextFlags
+1 -1
View File
@@ -1678,7 +1678,7 @@ BattleScript_EffectReturn::
BattleScript_EffectFrustration:: BattleScript_EffectFrustration::
attackcanceler attackcanceler
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
happinesstodamagecalculation friendshiptodamagecalculation
goto BattleScript_HitFromAtkString goto BattleScript_HitFromAtkString
BattleScript_EffectPresent:: BattleScript_EffectPresent::
+1 -6
View File
@@ -1329,12 +1329,7 @@ void ApplyAffineAnimFrameRelativeAndUpdateMatrix(u8 matrixNum, struct AffineAnim
s16 ConvertScaleParam(s16 scale) s16 ConvertScaleParam(s16 scale)
{ {
s32 val = 0x10000; s32 val = 0x10000;
// UB: possible division by zero return SAFE_DIV(val, scale);
#ifdef UBFIX
if (scale == 0)
return 0;
#endif //UBFIX
return val / scale;
} }
void GetAffineAnimFrame(u8 matrixNum, struct Sprite *sprite, struct AffineAnimFrameCmd *frameCmd) void GetAffineAnimFrame(u8 matrixNum, struct Sprite *sprite, struct AffineAnimFrameCmd *frameCmd)
+116 -116
View File
@@ -21,8 +21,8 @@ static u16 gLastTextFgColor;
static u16 gLastTextShadowColor; static u16 gLastTextShadowColor;
const struct FontInfo *gFonts; const struct FontInfo *gFonts;
u8 gUnknown_03002F84; u8 gDisableTextPrinters;
struct Struct_03002F90 gUnknown_03002F90; struct TextGlyph gCurGlyph;
TextFlags gTextFlags; TextFlags gTextFlags;
const u8 gFontHalfRowOffsets[] = const u8 gFontHalfRowOffsets[] =
@@ -204,7 +204,7 @@ bool16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u8 speed, voi
CopyWindowToVram(gTempTextPrinter.printerTemplate.windowId, 2); CopyWindowToVram(gTempTextPrinter.printerTemplate.windowId, 2);
gTextPrinters[printerTemplate->windowId].active = 0; gTextPrinters[printerTemplate->windowId].active = 0;
} }
gUnknown_03002F84 = 0; gDisableTextPrinters = 0;
return TRUE; return TRUE;
} }
@@ -212,7 +212,7 @@ void RunTextPrinters(void)
{ {
int i; int i;
if (gUnknown_03002F84 == 0) if (gDisableTextPrinters == 0)
{ {
for (i = 0; i < NUM_TEXT_PRINTERS; ++i) for (i = 0; i < NUM_TEXT_PRINTERS; ++i)
{ {
@@ -461,9 +461,9 @@ u8 GetLastTextColor(u8 colorType)
} }
} }
inline static void GLYPH_COPY(u8 *windowTiles, u32 widthOffset, u32 j, u32 i, u32 *ptr, s32 width, s32 height) inline static void GLYPH_COPY(u8 *windowTiles, u32 widthOffset, u32 j, u32 i, u32 *glyphPixels, s32 width, s32 height)
{ {
u32 xAdd, yAdd, r5, bits, toOrr, dummyX; u32 xAdd, yAdd, pixelData, bits, toOrr, dummyX;
u8 *dst; u8 *dst;
xAdd = j + width; xAdd = j + width;
@@ -471,69 +471,69 @@ inline static void GLYPH_COPY(u8 *windowTiles, u32 widthOffset, u32 j, u32 i, u3
dummyX = j; dummyX = j;
for (; i < yAdd; i++) for (; i < yAdd; i++)
{ {
r5 = *ptr++; pixelData = *glyphPixels++;
for (j = dummyX; j < xAdd; j++) for (j = dummyX; j < xAdd; j++)
{ {
if ((toOrr = r5 & 0xF)) if ((toOrr = pixelData & 0xF))
{ {
dst = windowTiles + ((j / 8) * 32) + ((j % 8) / 2) + ((i / 8) * widthOffset) + ((i % 8) * 4); dst = windowTiles + ((j / 8) * 32) + ((j % 8) / 2) + ((i / 8) * widthOffset) + ((i % 8) * 4);
bits = ((j & 1) * 4); bits = ((j & 1) * 4);
*dst = (toOrr << bits) | (*dst & (0xF0 >> bits)); *dst = (toOrr << bits) | (*dst & (0xF0 >> bits));
} }
r5 >>= 4; pixelData >>= 4;
} }
} }
} }
void CopyGlyphToWindow(struct TextPrinter *textPrinter) void CopyGlyphToWindow(struct TextPrinter *textPrinter)
{ {
struct Window *win; struct Window *window;
struct WindowTemplate *winTempl; struct WindowTemplate *template;
u32 *unkStruct; u32 *glyphPixels;
u32 currX, currY, widthOffset; u32 currX, currY, widthOffset;
s32 r4, r0; s32 glyphWidth, glyphHeight;
u8 *windowTiles; u8 *windowTiles;
win = &gWindows[textPrinter->printerTemplate.windowId]; window = &gWindows[textPrinter->printerTemplate.windowId];
winTempl = &win->window; template = &window->window;
if ((r4 = (winTempl->width * 8) - textPrinter->printerTemplate.currentX) > gUnknown_03002F90.width) if ((glyphWidth = (template->width * 8) - textPrinter->printerTemplate.currentX) > gCurGlyph.width)
r4 = gUnknown_03002F90.width; glyphWidth = gCurGlyph.width;
if ((r0 = (winTempl->height * 8) - textPrinter->printerTemplate.currentY) > gUnknown_03002F90.height) if ((glyphHeight = (template->height * 8) - textPrinter->printerTemplate.currentY) > gCurGlyph.height)
r0 = gUnknown_03002F90.height; glyphHeight = gCurGlyph.height;
currX = textPrinter->printerTemplate.currentX; currX = textPrinter->printerTemplate.currentX;
currY = textPrinter->printerTemplate.currentY; currY = textPrinter->printerTemplate.currentY;
unkStruct = (u32 *)&gUnknown_03002F90.unk0; glyphPixels = gCurGlyph.gfxBufferTop;
windowTiles = win->tileData; windowTiles = window->tileData;
widthOffset = winTempl->width * 32; widthOffset = template->width * 32;
if (r4 < 9) if (glyphWidth < 9)
{ {
if (r0 < 9) if (glyphHeight < 9)
{ {
GLYPH_COPY(windowTiles, widthOffset, currX, currY, unkStruct, r4, r0); GLYPH_COPY(windowTiles, widthOffset, currX, currY, glyphPixels, glyphWidth, glyphHeight);
} }
else else
{ {
GLYPH_COPY(windowTiles, widthOffset, currX, currY, unkStruct, r4, 8); GLYPH_COPY(windowTiles, widthOffset, currX, currY, glyphPixels, glyphWidth, 8);
GLYPH_COPY(windowTiles, widthOffset, currX, currY + 8, unkStruct + 16, r4, r0 - 8); GLYPH_COPY(windowTiles, widthOffset, currX, currY + 8, glyphPixels + 16, glyphWidth, glyphHeight - 8);
} }
} }
else else
{ {
if (r0 < 9) if (glyphHeight < 9)
{ {
GLYPH_COPY(windowTiles, widthOffset, currX, currY, unkStruct, 8, r0); GLYPH_COPY(windowTiles, widthOffset, currX, currY, glyphPixels, 8, glyphHeight);
GLYPH_COPY(windowTiles, widthOffset, currX + 8, currY, unkStruct + 8, r4 - 8, r0); GLYPH_COPY(windowTiles, widthOffset, currX + 8, currY, glyphPixels + 8, glyphWidth - 8, glyphHeight);
} }
else else
{ {
GLYPH_COPY(windowTiles, widthOffset, currX, currY, unkStruct, 8, 8); GLYPH_COPY(windowTiles, widthOffset, currX, currY, glyphPixels, 8, 8);
GLYPH_COPY(windowTiles, widthOffset, currX + 8, currY, unkStruct + 8, r4 - 8, 8); GLYPH_COPY(windowTiles, widthOffset, currX + 8, currY, glyphPixels + 8, glyphWidth - 8, 8);
GLYPH_COPY(windowTiles, widthOffset, currX, currY + 8, unkStruct + 16, 8, r0 - 8); GLYPH_COPY(windowTiles, widthOffset, currX, currY + 8, glyphPixels + 16, 8, glyphHeight - 8);
GLYPH_COPY(windowTiles, widthOffset, currX + 8, currY + 8, unkStruct + 24, r4 - 8, r0 - 8); GLYPH_COPY(windowTiles, widthOffset, currX + 8, currY + 8, glyphPixels + 24, glyphWidth - 8, glyphHeight - 8);
} }
} }
} }
@@ -542,7 +542,7 @@ void ClearTextSpan(struct TextPrinter *textPrinter, u32 width)
{ {
struct Window *window; struct Window *window;
struct Bitmap pixels_data; struct Bitmap pixels_data;
struct Struct_03002F90 *gUnk; struct TextGlyph *glyph;
u8* glyphHeight; u8* glyphHeight;
if (gLastTextBgColor != 0) if (gLastTextBgColor != 0)
@@ -552,8 +552,8 @@ void ClearTextSpan(struct TextPrinter *textPrinter, u32 width)
pixels_data.width = window->window.width << 3; pixels_data.width = window->window.width << 3;
pixels_data.height = window->window.height << 3; pixels_data.height = window->window.height << 3;
gUnk = &gUnknown_03002F90; glyph = &gCurGlyph;
glyphHeight = &gUnk->height; glyphHeight = &glyph->height;
FillBitmapRect4Bit( FillBitmapRect4Bit(
&pixels_data, &pixels_data,
@@ -1015,8 +1015,8 @@ u16 RenderText(struct TextPrinter *textPrinter)
break; break;
case CHAR_KEYPAD_ICON: case CHAR_KEYPAD_ICON:
currChar = *textPrinter->printerTemplate.currentChar++; currChar = *textPrinter->printerTemplate.currentChar++;
gUnknown_03002F90.width = DrawKeypadIcon(textPrinter->printerTemplate.windowId, currChar, textPrinter->printerTemplate.currentX, textPrinter->printerTemplate.currentY); gCurGlyph.width = DrawKeypadIcon(textPrinter->printerTemplate.windowId, currChar, textPrinter->printerTemplate.currentX, textPrinter->printerTemplate.currentY);
textPrinter->printerTemplate.currentX += gUnknown_03002F90.width + textPrinter->printerTemplate.letterSpacing; textPrinter->printerTemplate.currentX += gCurGlyph.width + textPrinter->printerTemplate.letterSpacing;
return 0; return 0;
case EOS: case EOS:
return 1; return 1;
@@ -1050,8 +1050,8 @@ u16 RenderText(struct TextPrinter *textPrinter)
if (textPrinter->minLetterSpacing) if (textPrinter->minLetterSpacing)
{ {
textPrinter->printerTemplate.currentX += gUnknown_03002F90.width; textPrinter->printerTemplate.currentX += gCurGlyph.width;
width = textPrinter->minLetterSpacing - gUnknown_03002F90.width; width = textPrinter->minLetterSpacing - gCurGlyph.width;
if (width > 0) if (width > 0)
{ {
ClearTextSpan(textPrinter, width); ClearTextSpan(textPrinter, width);
@@ -1061,9 +1061,9 @@ u16 RenderText(struct TextPrinter *textPrinter)
else else
{ {
if (textPrinter->japanese) if (textPrinter->japanese)
textPrinter->printerTemplate.currentX += (gUnknown_03002F90.width + textPrinter->printerTemplate.letterSpacing); textPrinter->printerTemplate.currentX += (gCurGlyph.width + textPrinter->printerTemplate.letterSpacing);
else else
textPrinter->printerTemplate.currentX += gUnknown_03002F90.width; textPrinter->printerTemplate.currentX += gCurGlyph.width;
} }
return 0; return 0;
case 1: case 1:
@@ -1498,8 +1498,8 @@ u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str)
DecompressGlyphFont1(temp, 1); DecompressGlyphFont1(temp, 1);
break; break;
} }
CpuCopy32(gUnknown_03002F90.unk0, pixels, 0x20); CpuCopy32(gCurGlyph.gfxBufferTop, pixels, 0x20);
CpuCopy32(gUnknown_03002F90.unk40, pixels + 0x20, 0x20); CpuCopy32(gCurGlyph.gfxBufferBottom, pixels + 0x20, 0x20);
pixels += 0x40; pixels += 0x40;
break; break;
} }
@@ -1591,30 +1591,30 @@ void DecompressGlyphFont0(u16 glyphId, bool32 isJapanese)
if (isJapanese == 1) if (isJapanese == 1)
{ {
glyphs = gFont0JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & 0xF)); glyphs = gFont0JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & 0xF));
DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40); // gUnknown_03002F90 + 0x40 DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom);
gUnknown_03002F90.width = 8; // gGlyphWidth gCurGlyph.width = 8;
gUnknown_03002F90.height = 12; // gGlyphHeight gCurGlyph.height = 12;
} }
else else
{ {
glyphs = gFont0LatinGlyphs + (0x20 * glyphId); glyphs = gFont0LatinGlyphs + (0x20 * glyphId);
gUnknown_03002F90.width = gFont0LatinGlyphWidths[glyphId]; gCurGlyph.width = gFont0LatinGlyphWidths[glyphId];
if (gUnknown_03002F90.width <= 8) if (gCurGlyph.width <= 8)
{ {
DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom);
} }
else else
{ {
DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x8, gUnknown_03002F90.unk20); DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8);
DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom);
DecompressGlyphTile(glyphs + 0x18, gUnknown_03002F90.unk60); DecompressGlyphTile(glyphs + 0x18, gCurGlyph.gfxBufferBottom + 8);
} }
gUnknown_03002F90.height = 13; gCurGlyph.height = 13;
} }
} }
@@ -1634,30 +1634,30 @@ void DecompressGlyphFont7(u16 glyphId, bool32 isJapanese)
{ {
int eff; int eff;
glyphs = gFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & (eff = 0xF))); // shh, no questions, only matching now glyphs = gFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & (eff = 0xF))); // shh, no questions, only matching now
DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40); // gUnknown_03002F90 + 0x40 DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom);
gUnknown_03002F90.width = 8; // gGlyphWidth gCurGlyph.width = 8;
gUnknown_03002F90.height = 15; // gGlyphHeight gCurGlyph.height = 15;
} }
else else
{ {
glyphs = gFont7LatinGlyphs + (0x20 * glyphId); glyphs = gFont7LatinGlyphs + (0x20 * glyphId);
gUnknown_03002F90.width = gFont7LatinGlyphWidths[glyphId]; gCurGlyph.width = gFont7LatinGlyphWidths[glyphId];
if (gUnknown_03002F90.width <= 8) if (gCurGlyph.width <= 8)
{ {
DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom);
} }
else else
{ {
DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x8, gUnknown_03002F90.unk20); DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8);
DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom);
DecompressGlyphTile(glyphs + 0x18, gUnknown_03002F90.unk60); DecompressGlyphTile(glyphs + 0x18, gCurGlyph.gfxBufferBottom + 8);
} }
gUnknown_03002F90.height = 15; gCurGlyph.height = 15;
} }
} }
@@ -1676,30 +1676,30 @@ void DecompressGlyphFont8(u16 glyphId, bool32 isJapanese)
if (isJapanese == TRUE) if (isJapanese == TRUE)
{ {
glyphs = gFont0JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & 0xF)); glyphs = gFont0JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & 0xF));
DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40); // gUnknown_03002F90 + 0x40 DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom);
gUnknown_03002F90.width = 8; // gGlyphWidth gCurGlyph.width = 8;
gUnknown_03002F90.height = 12; // gGlyphHeight gCurGlyph.height = 12;
} }
else else
{ {
glyphs = gFont8LatinGlyphs + (0x20 * glyphId); glyphs = gFont8LatinGlyphs + (0x20 * glyphId);
gUnknown_03002F90.width = gFont8LatinGlyphWidths[glyphId]; gCurGlyph.width = gFont8LatinGlyphWidths[glyphId];
if (gUnknown_03002F90.width <= 8) if (gCurGlyph.width <= 8)
{ {
DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom);
} }
else else
{ {
DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x8, gUnknown_03002F90.unk20); DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8);
DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom);
DecompressGlyphTile(glyphs + 0x18, gUnknown_03002F90.unk60); DecompressGlyphTile(glyphs + 0x18, gCurGlyph.gfxBufferBottom + 8);
} }
gUnknown_03002F90.height = 12; gCurGlyph.height = 12;
} }
} }
@@ -1718,32 +1718,32 @@ void DecompressGlyphFont2(u16 glyphId, bool32 isJapanese)
if (isJapanese == TRUE) if (isJapanese == TRUE)
{ {
glyphs = gFont2JapaneseGlyphs + (0x100 * (glyphId >> 0x3)) + (0x10 * (glyphId & 0x7)); glyphs = gFont2JapaneseGlyphs + (0x100 * (glyphId >> 0x3)) + (0x10 * (glyphId & 0x7));
DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x8, gUnknown_03002F90.unk20); // gUnknown_03002F90 + 0x40 DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8);
DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40); // gUnknown_03002F90 + 0x20 DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); // gCurGlyph + 0x20
DecompressGlyphTile(glyphs + 0x88, gUnknown_03002F90.unk60); // gUnknown_03002F90 + 0x60 DecompressGlyphTile(glyphs + 0x88, gCurGlyph.gfxBufferBottom + 8); // gCurGlyph + 0x60
gUnknown_03002F90.width = gFont2JapaneseGlyphWidths[glyphId]; // gGlyphWidth gCurGlyph.width = gFont2JapaneseGlyphWidths[glyphId];
gUnknown_03002F90.height = 14; // gGlyphHeight gCurGlyph.height = 14;
} }
else else
{ {
glyphs = gFont2LatinGlyphs + (0x20 * glyphId); glyphs = gFont2LatinGlyphs + (0x20 * glyphId);
gUnknown_03002F90.width = gFont2LatinGlyphWidths[glyphId]; gCurGlyph.width = gFont2LatinGlyphWidths[glyphId];
if (gUnknown_03002F90.width <= 8) if (gCurGlyph.width <= 8)
{ {
DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom);
} }
else else
{ {
DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x8, gUnknown_03002F90.unk20); DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8);
DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom);
DecompressGlyphTile(glyphs + 0x18, gUnknown_03002F90.unk60); DecompressGlyphTile(glyphs + 0x18, gCurGlyph.gfxBufferBottom + 8);
} }
gUnknown_03002F90.height = 14; gCurGlyph.height = 14;
} }
} }
@@ -1763,30 +1763,30 @@ void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese)
{ {
int eff; int eff;
glyphs = gFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & (eff = 0xF))); // shh, no questions, only matching now glyphs = gFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & (eff = 0xF))); // shh, no questions, only matching now
DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40); // gUnknown_03002F90 + 0x40 DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom);
gUnknown_03002F90.width = 8; // gGlyphWidth gCurGlyph.width = 8;
gUnknown_03002F90.height = 15; // gGlyphHeight gCurGlyph.height = 15;
} }
else else
{ {
glyphs = gFont1LatinGlyphs + (0x20 * glyphId); glyphs = gFont1LatinGlyphs + (0x20 * glyphId);
gUnknown_03002F90.width = gFont1LatinGlyphWidths[glyphId]; gCurGlyph.width = gFont1LatinGlyphWidths[glyphId];
if (gUnknown_03002F90.width <= 8) if (gCurGlyph.width <= 8)
{ {
DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom);
} }
else else
{ {
DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x8, gUnknown_03002F90.unk20); DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8);
DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom);
DecompressGlyphTile(glyphs + 0x18, gUnknown_03002F90.unk60); DecompressGlyphTile(glyphs + 0x18, gCurGlyph.gfxBufferBottom + 8);
} }
gUnknown_03002F90.height = 15; gCurGlyph.height = 15;
} }
} }
@@ -1803,8 +1803,8 @@ void DecompressGlyphFont9(u16 glyphId)
const u16* glyphs; const u16* glyphs;
glyphs = gFont9JapaneseGlyphs + (0x100 * (glyphId >> 4)) + (0x8 * (glyphId & 0xF)); glyphs = gFont9JapaneseGlyphs + (0x100 * (glyphId >> 4)) + (0x8 * (glyphId & 0xF));
DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40); DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom);
gUnknown_03002F90.width = 8; gCurGlyph.width = 8;
gUnknown_03002F90.height = 12; gCurGlyph.height = 12;
} }
+5 -7
View File
@@ -360,20 +360,18 @@ typedef struct {
bool8 forceMidTextSpeed:1; bool8 forceMidTextSpeed:1;
} TextFlags; } TextFlags;
struct Struct_03002F90 struct TextGlyph
{ {
u32 unk0[8]; u32 gfxBufferTop[16];
u32 unk20[8]; u32 gfxBufferBottom[16];
u32 unk40[8];
u32 unk60[8];
u8 width; u8 width;
u8 height; u8 height;
}; };
extern TextFlags gTextFlags; extern TextFlags gTextFlags;
extern u8 gUnknown_03002F84; extern u8 gDisableTextPrinters;
extern struct Struct_03002F90 gUnknown_03002F90; extern struct TextGlyph gCurGlyph;
void SetFontsPointer(const struct FontInfo *fonts); void SetFontsPointer(const struct FontInfo *fonts);
void DeactivateAllTextPrinters(void); void DeactivateAllTextPrinters(void);

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Before

Width:  |  Height:  |  Size: 626 B

After

Width:  |  Height:  |  Size: 626 B

Before

Width:  |  Height:  |  Size: 642 B

After

Width:  |  Height:  |  Size: 642 B

Before

Width:  |  Height:  |  Size: 329 B

After

Width:  |  Height:  |  Size: 329 B

Before

Width:  |  Height:  |  Size: 282 B

After

Width:  |  Height:  |  Size: 282 B

Before

Width:  |  Height:  |  Size: 815 B

After

Width:  |  Height:  |  Size: 815 B

Before

Width:  |  Height:  |  Size: 778 B

After

Width:  |  Height:  |  Size: 778 B

+4 -4
View File
@@ -28,11 +28,11 @@ void SetBerryTreesSeen(void);
extern const struct Berry gBerries[]; extern const struct Berry gBerries[];
struct UnkStruct_0858AB24 { struct BerryCrushBerryData {
u8 unk0; u8 difficulty; // The number of A presses required to crush it
u16 unk1; u16 powder;
}; };
extern const struct UnkStruct_0858AB24 gUnknown_0858AB24[]; extern const struct BerryCrushBerryData gBerryCrush_BerryData[];
#endif // GUARD_BERRY_H #endif // GUARD_BERRY_H
+1 -1
View File
@@ -3,6 +3,6 @@
#include "main.h" #include "main.h"
void StartBerryCrush(MainCallback callback); void StartBerryCrush(MainCallback exitCallback);
#endif // GUARD_BERRY_CRUSH_H #endif // GUARD_BERRY_CRUSH_H
+2 -2
View File
@@ -42,8 +42,8 @@
#define BATTLE_PIKE_FUNC_SET_IN_WILD_MON_ROOM 6 #define BATTLE_PIKE_FUNC_SET_IN_WILD_MON_ROOM 6
#define BATTLE_PIKE_FUNC_CLEAR_IN_WILD_MON_ROOM 7 #define BATTLE_PIKE_FUNC_CLEAR_IN_WILD_MON_ROOM 7
#define BATTLE_PIKE_FUNC_SAVE 8 #define BATTLE_PIKE_FUNC_SAVE 8
#define BATTLE_PIKE_FUNC_NULL_9 9 #define BATTLE_PIKE_FUNC_DUMMY_1 9
#define BATTLE_PIKE_FUNC_NULL_10 10 #define BATTLE_PIKE_FUNC_DUMMY_2 10
#define BATTLE_PIKE_FUNC_GET_ROOM_STATUS 11 #define BATTLE_PIKE_FUNC_GET_ROOM_STATUS 11
#define BATTLE_PIKE_FUNC_GET_ROOM_STATUS_MON 12 #define BATTLE_PIKE_FUNC_GET_ROOM_STATUS_MON 12
#define BATTLE_PIKE_FUNC_HEAL_ONE_TWO_MONS 13 #define BATTLE_PIKE_FUNC_HEAL_ONE_TWO_MONS 13
+1 -1
View File
@@ -52,7 +52,7 @@
#define GAME_STAT_RODE_CABLE_CAR 48 #define GAME_STAT_RODE_CABLE_CAR 48
#define GAME_STAT_ENTERED_HOT_SPRINGS 49 #define GAME_STAT_ENTERED_HOT_SPRINGS 49
#define GAME_STAT_NUM_UNION_ROOM_BATTLES 50 #define GAME_STAT_NUM_UNION_ROOM_BATTLES 50
#define GAME_STAT_51 51 #define GAME_STAT_PLAYED_BERRY_CRUSH 51
#define NUM_USED_GAME_STATS 52 #define NUM_USED_GAME_STATS 52
#define NUM_GAME_STATS 64 #define NUM_GAME_STATS 64
+1 -1
View File
@@ -28,7 +28,7 @@
#define HOLD_EFFECT_MACHO_BRACE 24 #define HOLD_EFFECT_MACHO_BRACE 24
#define HOLD_EFFECT_EXP_SHARE 25 #define HOLD_EFFECT_EXP_SHARE 25
#define HOLD_EFFECT_QUICK_CLAW 26 #define HOLD_EFFECT_QUICK_CLAW 26
#define HOLD_EFFECT_HAPPINESS_UP 27 #define HOLD_EFFECT_FRIENDSHIP_UP 27
#define HOLD_EFFECT_CURE_ATTRACT 28 #define HOLD_EFFECT_CURE_ATTRACT 28
#define HOLD_EFFECT_CHOICE_BAND 29 #define HOLD_EFFECT_CHOICE_BAND 29
#define HOLD_EFFECT_FLINCH 30 #define HOLD_EFFECT_FLINCH 30
+1 -1
View File
@@ -56,7 +56,7 @@
#define VAR_CYCLING_ROAD_RECORD_COLLISIONS 0x4027 #define VAR_CYCLING_ROAD_RECORD_COLLISIONS 0x4027
#define VAR_CYCLING_ROAD_RECORD_TIME_L 0x4028 #define VAR_CYCLING_ROAD_RECORD_TIME_L 0x4028
#define VAR_CYCLING_ROAD_RECORD_TIME_H 0x4029 #define VAR_CYCLING_ROAD_RECORD_TIME_H 0x4029
#define VAR_HAPPINESS_STEP_COUNTER 0x402A #define VAR_FRIENDSHIP_STEP_COUNTER 0x402A
#define VAR_POISON_STEP_COUNTER 0x402B #define VAR_POISON_STEP_COUNTER 0x402B
#define VAR_RESET_RTC_ENABLE 0x402C #define VAR_RESET_RTC_ENABLE 0x402C
#define VAR_ENIGMA_BERRY_AVAILABLE 0x402D #define VAR_ENIGMA_BERRY_AVAILABLE 0x402D
+9 -1
View File
@@ -74,6 +74,14 @@
#define abs(x) (((x) < 0) ? -(x) : (x)) #define abs(x) (((x) < 0) ? -(x) : (x))
#endif #endif
// Used in cases where division by 0 can occur in the retail version.
// Avoids invalid opcodes on some emulators, and the otherwise UB.
#ifdef UBFIX
#define SAFE_DIV(a, b) ((b) ? (a) / (b) : 0)
#else
#define SAFE_DIV(a, b) ((a) / (b))
#endif
// Extracts the upper 16 bits of a 32-bit number // Extracts the upper 16 bits of a 32-bit number
#define HIHALF(n) (((n) & 0xFFFF0000) >> 16) #define HIHALF(n) (((n) & 0xFFFF0000) >> 16)
@@ -209,7 +217,7 @@ struct PyramidBag
struct BerryCrush struct BerryCrush
{ {
u16 berryCrushResults[4]; u16 pressingSpeeds[4]; // For the record with each possible group size, 2-5 players
u32 berryPowderAmount; u32 berryPowderAmount;
u32 unk; u32 unk;
}; };
+3 -3
View File
@@ -5001,9 +5001,9 @@ extern const u16 gUsePokeblockUpDown_Pal[];
extern const u16 gUsePokeblockCondition_Pal[]; extern const u16 gUsePokeblockCondition_Pal[];
// Berry Crush // Berry Crush
extern const u32 gUnknown_08DE34B8[]; extern const u32 gBerryCrush_Crusher_Gfx[];
extern const u16 gUnknown_08DE3398[]; extern const u16 gBerryCrush_Crusher_Pal[];
extern const u32 gUnknown_08DE3FD4[]; extern const u32 gBerryCrush_Crusher_Tilemap[];
// Pokenav // Pokenav
extern const u32 gPokenavMessageBox_Gfx[]; extern const u32 gPokenavMessageBox_Gfx[];
+15 -14
View File
@@ -56,17 +56,17 @@
#define LINKCMD_BLENDER_SEND_KEYS 0x4444 #define LINKCMD_BLENDER_SEND_KEYS 0x4444
#define LINKCMD_BLENDER_SCORE_BEST 0x4523 #define LINKCMD_BLENDER_SCORE_BEST 0x4523
#define LINKCMD_BLENDER_SCORE_GOOD 0x5432 #define LINKCMD_BLENDER_SCORE_GOOD 0x5432
#define LINKCMD_0x5555 0x5555 #define LINKCMD_DUMMY_1 0x5555
#define LINKCMD_0x5566 0x5566 #define LINKCMD_DUMMY_2 0x5566
#define LINKCMD_READY_CLOSE_LINK 0x5FFF #define LINKCMD_READY_CLOSE_LINK 0x5FFF
#define LINKCMD_0x6666 0x6666 #define LINKCMD_SEND_EMPTY 0x6666
#define LINKCMD_0x7777 0x7777 #define LINKCMD_SEND_0xEE 0x7777
#define LINKCMD_BLENDER_PLAY_AGAIN 0x7779 #define LINKCMD_BLENDER_PLAY_AGAIN 0x7779
#define LINKCMD_COUNTDOWN 0x7FFF #define LINKCMD_COUNTDOWN 0x7FFF
#define LINKCMD_CONT_BLOCK 0x8888 #define LINKCMD_CONT_BLOCK 0x8888
#define LINKCMD_BLENDER_NO_BERRIES 0x9999 #define LINKCMD_BLENDER_NO_BERRIES 0x9999
#define LINKCMD_BLENDER_NO_PBLOCK_SPACE 0xAAAA #define LINKCMD_BLENDER_NO_PBLOCK_SPACE 0xAAAA
#define LINKCMD_0xAAAB 0xAAAB #define LINKCMD_SEND_ITEM 0xAAAB
#define LINKCMD_READY_TO_TRADE 0xAABB #define LINKCMD_READY_TO_TRADE 0xAABB
#define LINKCMD_READY_FINISH_TRADE 0xABCD #define LINKCMD_READY_FINISH_TRADE 0xABCD
#define LINKCMD_INIT_BLOCK 0xBBBB #define LINKCMD_INIT_BLOCK 0xBBBB
@@ -76,17 +76,18 @@
#define LINKCMD_START_TRADE 0xCCDD #define LINKCMD_START_TRADE 0xCCDD
#define LINKCMD_CONFIRM_FINISH_TRADE 0xDCBA #define LINKCMD_CONFIRM_FINISH_TRADE 0xDCBA
#define LINKCMD_SET_MONS_TO_TRADE 0xDDDD #define LINKCMD_SET_MONS_TO_TRADE 0xDDDD
#define LINKCMD_0xDDEE 0xDDEE #define LINKCMD_PLAYER_CANCEL_TRADE 0xDDEE
#define LINKCMD_REQUEST_CANCEL 0xEEAA #define LINKCMD_REQUEST_CANCEL 0xEEAA
#define LINKCMD_CANCEL_TRADE 0xEEBB #define LINKCMD_BOTH_CANCEL_TRADE 0xEEBB
#define LINKCMD_0xEECC 0xEECC #define LINKCMD_PARTNER_CANCEL_TRADE 0xEECC
#define LINKCMD_NONE 0xEFFF
#define LINKTYPE_TRADE 0x1111 #define LINKTYPE_TRADE 0x1111
#define LINKTYPE_TRADE_CONNECTING 0x1122 #define LINKTYPE_TRADE_CONNECTING 0x1122
#define LINKTYPE_TRADE_SETUP 0x1133 #define LINKTYPE_TRADE_SETUP 0x1133
#define LINKTYPE_TRADE_DISCONNECTED 0x1144 #define LINKTYPE_TRADE_DISCONNECTED 0x1144
#define LINKTYPE_BATTLE 0x2211 #define LINKTYPE_BATTLE 0x2211
#define LINKTYPE_0x2222 0x2222 // unused battle? #define LINKTYPE_UNUSED_BATTLE 0x2222 // Unused, inferred from gap
#define LINKTYPE_SINGLE_BATTLE 0x2233 #define LINKTYPE_SINGLE_BATTLE 0x2233
#define LINKTYPE_DOUBLE_BATTLE 0x2244 #define LINKTYPE_DOUBLE_BATTLE 0x2244
#define LINKTYPE_MULTI_BATTLE 0x2255 #define LINKTYPE_MULTI_BATTLE 0x2255
@@ -98,7 +99,7 @@
#define LINKTYPE_BERRY_BLENDER_SETUP 0x4411 #define LINKTYPE_BERRY_BLENDER_SETUP 0x4411
#define LINKTYPE_BERRY_BLENDER 0x4422 #define LINKTYPE_BERRY_BLENDER 0x4422
#define LINKTYPE_MYSTERY_EVENT 0x5501 #define LINKTYPE_MYSTERY_EVENT 0x5501
#define LINKTYPE_0x5502 0x5502 // unused? #define LINKTYPE_UNUSED_EREADER 0x5502 // Unused, inferred from gap
#define LINKTYPE_EREADER 0x5503 #define LINKTYPE_EREADER 0x5503
#define LINKTYPE_CONTEST_GMODE 0x6601 #define LINKTYPE_CONTEST_GMODE 0x6601
#define LINKTYPE_CONTEST_EMODE 0x6602 #define LINKTYPE_CONTEST_EMODE 0x6602
@@ -290,17 +291,17 @@ bool8 HandleLinkConnection(void);
void SetLinkDebugValues(u32 seed, u32 flags); void SetLinkDebugValues(u32 seed, u32 flags);
void SetBerryBlenderLinkCallback(void); void SetBerryBlenderLinkCallback(void);
void SetSuppressLinkErrorMessage(bool8 flag); void SetSuppressLinkErrorMessage(bool8 flag);
void sub_800B524(struct LinkPlayer *linkPlayer); void ConvertLinkPlayerName(struct LinkPlayer *linkPlayer);
u8 GetSioMultiSI(void); u8 GetSioMultiSI(void);
void ClearSavedLinkPlayers(void); void ClearSavedLinkPlayers(void);
void BufferLinkErrorInfo(u32 status, u8 lastSendQueueCount, u8 lastRecvQueueCount, u8 unk_06); void BufferLinkErrorInfo(u32 status, u8 lastSendQueueCount, u8 lastRecvQueueCount, bool8 disconnected);
void sub_800B348(void); void LocalLinkPlayerToBlock(void);
void LinkPlayerFromBlock(u32 who); void LinkPlayerFromBlock(u32 who);
bool32 Link_AnyPartnersPlayingFRLG_JP(void); bool32 Link_AnyPartnersPlayingFRLG_JP(void);
void ResetLinkPlayerCount(void); void ResetLinkPlayerCount(void);
void SaveLinkPlayers(u8 a0); void SaveLinkPlayers(u8 a0);
void SetWirelessCommType0(void); void SetWirelessCommType0(void);
bool32 sub_800B504(void); bool32 IsLinkRecvQueueLengthAtLeast3(void);
extern u16 gLinkPartnersHeldKeys[6]; extern u16 gLinkPartnersHeldKeys[6];
extern u32 gLinkDebugSeed; extern u32 gLinkDebugSeed;
+1 -1
View File
@@ -2904,7 +2904,7 @@ extern const u8 gText_CrushingResults[];
extern const u8 gText_BerryCrush2[]; extern const u8 gText_BerryCrush2[];
extern const u8 gText_PressingSpeedRankings[]; extern const u8 gText_PressingSpeedRankings[];
extern const u8 gText_Var1Players[]; extern const u8 gText_Var1Players[];
extern const u8 gText_ReadyToBerryCrush[]; extern const u8 gText_ReadyPickBerry[];
extern const u8 gText_WaitForAllChooseBerry[]; extern const u8 gText_WaitForAllChooseBerry[];
extern const u8 gText_EndedWithXUnitsPowder[]; extern const u8 gText_EndedWithXUnitsPowder[];
extern const u8 gText_RecordingGameResults[]; extern const u8 gText_RecordingGameResults[];
-1
View File
@@ -66,7 +66,6 @@ void InitTrainerHillBattleStruct(void);
void FreeTrainerHillBattleStruct(void); void FreeTrainerHillBattleStruct(void);
void CopyTrainerHillTrainerText(u8 which, u16 trainerId); void CopyTrainerHillTrainerText(u8 which, u16 trainerId);
bool8 InTrainerHillChallenge(void); bool8 InTrainerHillChallenge(void);
void nullsub_129(void);
void PrintOnTrainerHillRecordsWindow(void); void PrintOnTrainerHillRecordsWindow(void);
void LoadTrainerHillObjectEventTemplates(void); void LoadTrainerHillObjectEventTemplates(void);
bool32 LoadTrainerHillFloorObjectEventScripts(void); bool32 LoadTrainerHillFloorObjectEventScripts(void);
+2 -2
View File
@@ -1815,7 +1815,7 @@ void SetBattlerSpriteYOffsetFromYScale(u8 spriteId)
{ {
int var = 64 - GetBattlerYDeltaFromSpriteId(spriteId) * 2; int var = 64 - GetBattlerYDeltaFromSpriteId(spriteId) * 2;
u16 matrix = gSprites[spriteId].oam.matrixNum; u16 matrix = gSprites[spriteId].oam.matrixNum;
int var2 = (var << 8) / gOamMatrices[matrix].d; int var2 = SAFE_DIV(var << 8, gOamMatrices[matrix].d);
if (var2 > 128) if (var2 > 128)
var2 = 128; var2 = 128;
@@ -1828,7 +1828,7 @@ void SetBattlerSpriteYOffsetFromOtherYScale(u8 spriteId, u8 otherSpriteId)
{ {
int var = 64 - GetBattlerYDeltaFromSpriteId(otherSpriteId) * 2; int var = 64 - GetBattlerYDeltaFromSpriteId(otherSpriteId) * 2;
u16 matrix = gSprites[spriteId].oam.matrixNum; u16 matrix = gSprites[spriteId].oam.matrixNum;
int var2 = (var << 8) / gOamMatrices[matrix].d; int var2 = SAFE_DIV(var << 8, gOamMatrices[matrix].d);
if (var2 > 128) if (var2 > 128)
var2 = 128; var2 = 128;
+2 -1
View File
@@ -774,7 +774,8 @@ void BattleArena_DeductMindPoints(u8 battler, u16 stringId)
} }
} }
void sub_81A586C(u8 battler) // Unused. // Unused
static void UpdateHPAtStart(u8 battler)
{ {
u16 *hpAtStart = gBattleStruct->arenaStartHp; u16 *hpAtStart = gBattleStruct->arenaStartHp;
+12 -12
View File
@@ -529,7 +529,7 @@ static const union AnimCmd * const sAnims_Select_Pokeball[] =
sAnim_Select_Pokeball_Moving, sAnim_Select_Pokeball_Moving,
}; };
static const union AffineAnimCmd gUnknown_0861050C[] = static const union AffineAnimCmd sAffineAnim_Select_MonPicBg_Opening[] =
{ {
AFFINEANIMCMD_FRAME(5, 5, 0, 0), AFFINEANIMCMD_FRAME(5, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1), AFFINEANIMCMD_FRAME(0, 0, 0, 1),
@@ -545,7 +545,7 @@ static const union AffineAnimCmd gUnknown_0861050C[] =
AFFINEANIMCMD_END, AFFINEANIMCMD_END,
}; };
static const union AffineAnimCmd gUnknown_0861056C[] = static const union AffineAnimCmd sAffineAnim_Select_MonPicBg_Closing[] =
{ {
AFFINEANIMCMD_FRAME(128, 5, 0, 0), AFFINEANIMCMD_FRAME(128, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1), AFFINEANIMCMD_FRAME(0, 0, 0, 1),
@@ -559,7 +559,7 @@ static const union AffineAnimCmd gUnknown_0861056C[] =
AFFINEANIMCMD_END, AFFINEANIMCMD_END,
}; };
static const union AffineAnimCmd gUnknown_086105BC[] = static const union AffineAnimCmd sAffineAnim_Select_MonPicBg_Open[] =
{ {
AFFINEANIMCMD_FRAME(256, 256, 0, 0), AFFINEANIMCMD_FRAME(256, 256, 0, 0),
AFFINEANIMCMD_END, AFFINEANIMCMD_END,
@@ -567,9 +567,9 @@ static const union AffineAnimCmd gUnknown_086105BC[] =
static const union AffineAnimCmd * const sAffineAnims_Select_MonPicBgAnim[] = static const union AffineAnimCmd * const sAffineAnims_Select_MonPicBgAnim[] =
{ {
gUnknown_0861050C, sAffineAnim_Select_MonPicBg_Opening,
gUnknown_0861056C, sAffineAnim_Select_MonPicBg_Closing,
gUnknown_086105BC, sAffineAnim_Select_MonPicBg_Open,
}; };
static const struct SpriteTemplate sSpriteTemplate_Select_Pokeball = static const struct SpriteTemplate sSpriteTemplate_Select_Pokeball =
@@ -780,7 +780,7 @@ static const union AnimCmd * const sAnims_Swap_Pokeball[] =
sAnim_Swap_Pokeball_Moving, sAnim_Swap_Pokeball_Moving,
}; };
static const union AffineAnimCmd gUnknown_08610768[] = static const union AffineAnimCmd sAffineAnim_Swap_MonPicBg_Opening[] =
{ {
AFFINEANIMCMD_FRAME(5, 5, 0, 0), AFFINEANIMCMD_FRAME(5, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1), AFFINEANIMCMD_FRAME(0, 0, 0, 1),
@@ -796,7 +796,7 @@ static const union AffineAnimCmd gUnknown_08610768[] =
AFFINEANIMCMD_END, AFFINEANIMCMD_END,
}; };
static const union AffineAnimCmd gUnknown_086107C8[] = static const union AffineAnimCmd sAffineAnim_Swap_MonPicBg_Closing[] =
{ {
AFFINEANIMCMD_FRAME(128, 5, 0, 0), AFFINEANIMCMD_FRAME(128, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1), AFFINEANIMCMD_FRAME(0, 0, 0, 1),
@@ -810,7 +810,7 @@ static const union AffineAnimCmd gUnknown_086107C8[] =
AFFINEANIMCMD_END, AFFINEANIMCMD_END,
}; };
static const union AffineAnimCmd gUnknown_08610818[] = static const union AffineAnimCmd sAffineAnim_Swap_MonPicBg_Open[] =
{ {
AFFINEANIMCMD_FRAME(256, 256, 0, 0), AFFINEANIMCMD_FRAME(256, 256, 0, 0),
AFFINEANIMCMD_END, AFFINEANIMCMD_END,
@@ -818,9 +818,9 @@ static const union AffineAnimCmd gUnknown_08610818[] =
static const union AffineAnimCmd * const sAffineAnims_Swap_MonPicBgAnim[] = static const union AffineAnimCmd * const sAffineAnims_Swap_MonPicBgAnim[] =
{ {
gUnknown_08610768, sAffineAnim_Swap_MonPicBg_Opening,
gUnknown_086107C8, sAffineAnim_Swap_MonPicBg_Closing,
gUnknown_08610818, sAffineAnim_Swap_MonPicBg_Open,
}; };
static const struct SpriteTemplate sSpriteTemplate_Swap_Pokeball = static const struct SpriteTemplate sSpriteTemplate_Swap_Pokeball =
+6 -6
View File
@@ -57,8 +57,8 @@ static void GetRoomType(void);
static void SetInWildMonRoom(void); static void SetInWildMonRoom(void);
static void ClearInWildMonRoom(void); static void ClearInWildMonRoom(void);
static void SavePikeChallenge(void); static void SavePikeChallenge(void);
static void nullsub_76(void); static void PikeDummy1(void);
static void nullsub_124(void); static void PikeDummy2(void);
static void GetRoomInflictedStatus(void); static void GetRoomInflictedStatus(void);
static void GetRoomInflictedStatusMon(void); static void GetRoomInflictedStatusMon(void);
static void HealOneOrTwoMons(void); static void HealOneOrTwoMons(void);
@@ -488,8 +488,8 @@ static void (* const sBattlePikeFunctions[])(void) =
[BATTLE_PIKE_FUNC_SET_IN_WILD_MON_ROOM] = SetInWildMonRoom, [BATTLE_PIKE_FUNC_SET_IN_WILD_MON_ROOM] = SetInWildMonRoom,
[BATTLE_PIKE_FUNC_CLEAR_IN_WILD_MON_ROOM] = ClearInWildMonRoom, [BATTLE_PIKE_FUNC_CLEAR_IN_WILD_MON_ROOM] = ClearInWildMonRoom,
[BATTLE_PIKE_FUNC_SAVE] = SavePikeChallenge, [BATTLE_PIKE_FUNC_SAVE] = SavePikeChallenge,
[BATTLE_PIKE_FUNC_NULL_9] = nullsub_76, [BATTLE_PIKE_FUNC_DUMMY_1] = PikeDummy1,
[BATTLE_PIKE_FUNC_NULL_10] = nullsub_124, [BATTLE_PIKE_FUNC_DUMMY_2] = PikeDummy2,
[BATTLE_PIKE_FUNC_GET_ROOM_STATUS] = GetRoomInflictedStatus, [BATTLE_PIKE_FUNC_GET_ROOM_STATUS] = GetRoomInflictedStatus,
[BATTLE_PIKE_FUNC_GET_ROOM_STATUS_MON] = GetRoomInflictedStatusMon, [BATTLE_PIKE_FUNC_GET_ROOM_STATUS_MON] = GetRoomInflictedStatusMon,
[BATTLE_PIKE_FUNC_HEAL_ONE_TWO_MONS] = HealOneOrTwoMons, [BATTLE_PIKE_FUNC_HEAL_ONE_TWO_MONS] = HealOneOrTwoMons,
@@ -715,12 +715,12 @@ static void SavePikeChallenge(void)
TrySavingData(SAVE_LINK); TrySavingData(SAVE_LINK);
} }
static void nullsub_76(void) static void PikeDummy1(void)
{ {
} }
static void nullsub_124(void) static void PikeDummy2(void)
{ {
} }
+3 -3
View File
@@ -258,7 +258,7 @@ static void Cmd_trysetperishsong(void);
static void Cmd_rolloutdamagecalculation(void); static void Cmd_rolloutdamagecalculation(void);
static void Cmd_jumpifconfusedandstatmaxed(void); static void Cmd_jumpifconfusedandstatmaxed(void);
static void Cmd_furycuttercalc(void); static void Cmd_furycuttercalc(void);
static void Cmd_happinesstodamagecalculation(void); static void Cmd_friendshiptodamagecalculation(void);
static void Cmd_presentdamagecalculation(void); static void Cmd_presentdamagecalculation(void);
static void Cmd_setsafeguard(void); static void Cmd_setsafeguard(void);
static void Cmd_magnitudedamagecalculation(void); static void Cmd_magnitudedamagecalculation(void);
@@ -510,7 +510,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
Cmd_rolloutdamagecalculation, //0xB3 Cmd_rolloutdamagecalculation, //0xB3
Cmd_jumpifconfusedandstatmaxed, //0xB4 Cmd_jumpifconfusedandstatmaxed, //0xB4
Cmd_furycuttercalc, //0xB5 Cmd_furycuttercalc, //0xB5
Cmd_happinesstodamagecalculation, //0xB6 Cmd_friendshiptodamagecalculation, //0xB6
Cmd_presentdamagecalculation, //0xB7 Cmd_presentdamagecalculation, //0xB7
Cmd_setsafeguard, //0xB8 Cmd_setsafeguard, //0xB8
Cmd_magnitudedamagecalculation, //0xB9 Cmd_magnitudedamagecalculation, //0xB9
@@ -8471,7 +8471,7 @@ static void Cmd_furycuttercalc(void)
} }
} }
static void Cmd_happinesstodamagecalculation(void) static void Cmd_friendshiptodamagecalculation(void)
{ {
if (gBattleMoves[gCurrentMove].effect == EFFECT_RETURN) if (gBattleMoves[gCurrentMove].effect == EFFECT_RETURN)
gDynamicBasePower = 10 * (gBattleMons[gBattlerAttacker].friendship) / 25; gDynamicBasePower = 10 * (gBattleMons[gBattlerAttacker].friendship) / 25;
+2 -6
View File
@@ -878,12 +878,8 @@ static const u16 sFrontierTrainerIdRangesHard[][2] =
{FRONTIER_TRAINER_JAXON, FRONTIER_TRAINER_GRETEL}, // 200 - 299 {FRONTIER_TRAINER_JAXON, FRONTIER_TRAINER_GRETEL}, // 200 - 299
}; };
// Trainer IDs? Don't make sense as part of previous array, min/max relationship reversed and never accessed // Unknown, unused data
static const u16 sUnused_085DFA1A[][2] = static const u16 sUnused[] = { 179, 141, 200, 183 };
{
{179, 141}, // FRONTIER_TRAINER_ALISON - FRONTIER_TRAINER_KAYDEN
{200, 183}, // FRONTIER_TRAINER_JAXON - FRONTIER_TRAINER_HUNTER
};
static const u8 sBattleTowerPartySizes[FRONTIER_MODE_COUNT] = static const u8 sBattleTowerPartySizes[FRONTIER_MODE_COUNT] =
{ {
+2 -2
View File
@@ -3949,7 +3949,7 @@ u8 GetMoveTarget(u16 move, u8 setTarget)
return targetBattler; return targetBattler;
} }
static bool32 IsNotEventLegalMewOrDeoxys(u8 battlerId) static bool32 IsMonEventLegal(u8 battlerId)
{ {
if (GetBattlerSide(battlerId) == B_SIDE_OPPONENT) if (GetBattlerSide(battlerId) == B_SIDE_OPPONENT)
return TRUE; return TRUE;
@@ -3970,7 +3970,7 @@ u8 IsMonDisobedient(void)
if (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT) if (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT)
return 0; return 0;
if (IsNotEventLegalMewOrDeoxys(gBattlerAttacker)) // only if species is Mew or Deoxys if (IsMonEventLegal(gBattlerAttacker)) // only false if illegal Mew or Deoxys
{ {
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBattlerPosition(gBattlerAttacker) == 2) if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBattlerPosition(gBattlerAttacker) == 2)
return 0; return 0;
+44 -44
View File
@@ -889,50 +889,50 @@ const struct Berry gBerries[] =
}, },
}; };
const struct UnkStruct_0858AB24 gUnknown_0858AB24[] = { const struct BerryCrushBerryData gBerryCrush_BerryData[] = {
{ 50, 20}, [ITEM_CHERI_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 20},
{ 50, 20}, [ITEM_CHESTO_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 20},
{ 50, 20}, [ITEM_PECHA_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 20},
{ 50, 20}, [ITEM_RAWST_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 20},
{ 50, 20}, [ITEM_ASPEAR_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 20},
{ 50, 30}, [ITEM_LEPPA_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 30},
{ 50, 30}, [ITEM_ORAN_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 30},
{ 50, 30}, [ITEM_PERSIM_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 30},
{ 50, 30}, [ITEM_LUM_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 30},
{ 50, 30}, [ITEM_SITRUS_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 50, .powder = 30},
{ 60, 50}, [ITEM_FIGY_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 60, .powder = 50},
{ 60, 50}, [ITEM_WIKI_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 60, .powder = 50},
{ 60, 50}, [ITEM_MAGO_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 60, .powder = 50},
{ 60, 50}, [ITEM_AGUAV_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 60, .powder = 50},
{ 60, 50}, [ITEM_IAPAPA_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 60, .powder = 50},
{ 80, 70}, [ITEM_RAZZ_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 80, .powder = 70},
{ 80, 70}, [ITEM_BLUK_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 80, .powder = 70},
{ 80, 70}, [ITEM_NANAB_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 80, .powder = 70},
{ 80, 70}, [ITEM_WEPEAR_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 80, .powder = 70},
{ 80, 70}, [ITEM_PINAP_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 80, .powder = 70},
{100, 100}, [ITEM_POMEG_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 100, .powder = 100},
{100, 100}, [ITEM_KELPSY_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 100, .powder = 100},
{100, 100}, [ITEM_QUALOT_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 100, .powder = 100},
{100, 100}, [ITEM_HONDEW_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 100, .powder = 100},
{100, 100}, [ITEM_GREPA_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 100, .powder = 100},
{130, 150}, [ITEM_TAMATO_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 130, .powder = 150},
{130, 150}, [ITEM_CORNN_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 130, .powder = 150},
{130, 150}, [ITEM_MAGOST_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 130, .powder = 150},
{130, 150}, [ITEM_RABUTA_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 130, .powder = 150},
{130, 150}, [ITEM_NOMEL_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 130, .powder = 150},
{160, 250}, [ITEM_SPELON_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 160, .powder = 250},
{160, 250}, [ITEM_PAMTRE_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 160, .powder = 250},
{160, 250}, [ITEM_WATMEL_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 160, .powder = 250},
{160, 250}, [ITEM_DURIN_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 160, .powder = 250},
{160, 250}, [ITEM_BELUE_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 160, .powder = 250},
{180, 500}, [ITEM_LIECHI_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 180, .powder = 500},
{180, 500}, [ITEM_GANLON_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 180, .powder = 500},
{180, 500}, [ITEM_SALAC_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 180, .powder = 500},
{180, 500}, [ITEM_PETAYA_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 180, .powder = 500},
{180, 500}, [ITEM_APICOT_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 180, .powder = 500},
{200, 750}, [ITEM_LANSAT_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 200, .powder = 750},
{200, 750}, [ITEM_STARF_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 200, .powder = 750},
{150, 200} [ITEM_ENIGMA_BERRY - FIRST_BERRY_INDEX] = {.difficulty = 150, .powder = 200}
}; };
const struct BerryTree gBlankBerryTree = {}; const struct BerryTree gBlankBerryTree = {};
+1792 -1492
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -904,7 +904,7 @@ static void Task_StartWirelessCableClubBattle(u8 taskId)
{ {
struct LinkPlayer *player = (struct LinkPlayer *)gBlockRecvBuffer[i]; struct LinkPlayer *player = (struct LinkPlayer *)gBlockRecvBuffer[i];
gLinkPlayers[i] = *player; gLinkPlayers[i] = *player;
sub_800B524(&gLinkPlayers[i]); ConvertLinkPlayerName(&gLinkPlayers[i]);
ResetBlockReceivedFlag(i); ResetBlockReceivedFlag(i);
} }
tState = 4; tState = 4;
+1 -1
View File
@@ -2250,7 +2250,7 @@ const struct Item gItems[] =
.name = _("SOOTHE BELL"), .name = _("SOOTHE BELL"),
.itemId = ITEM_SOOTHE_BELL, .itemId = ITEM_SOOTHE_BELL,
.price = 100, .price = 100,
.holdEffect = HOLD_EFFECT_HAPPINESS_UP, .holdEffect = HOLD_EFFECT_FRIENDSHIP_UP,
.description = sSootheBellDesc, .description = sSootheBellDesc,
.pocket = POCKET_ITEMS, .pocket = POCKET_ITEMS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,
+3 -3
View File
@@ -543,7 +543,7 @@ static const struct WindowTemplate sLevelUpStatsWindowTemplate =
.baseBlock = 0x2E9, .baseBlock = 0x2E9,
}; };
static const struct WindowTemplate sUnusedWindowTemplate_08615978 = static const struct WindowTemplate sUnusedWindowTemplate1 =
{ {
.bg = 2, .bg = 2,
.tilemapLeft = 2, .tilemapLeft = 2,
@@ -554,7 +554,7 @@ static const struct WindowTemplate sUnusedWindowTemplate_08615978 =
.baseBlock = 0x1DF, .baseBlock = 0x1DF,
}; };
static const struct WindowTemplate sUnusedWindowTemplate_08615980 = static const struct WindowTemplate sUnusedWindowTemplate2 =
{ {
.bg = 2, .bg = 2,
.tilemapLeft = 0, .tilemapLeft = 0,
@@ -669,7 +669,7 @@ static const u8 *const sDescriptionStringTable[] =
[PARTYBOX_DESC_DONT_HAVE] = gText_DontHave, [PARTYBOX_DESC_DONT_HAVE] = gText_DontHave,
}; };
static const u16 sUnused_08615B94[] = static const u16 sUnusedData[] =
{ {
0x0108, 0x0151, 0x0160, 0x015b, 0x002e, 0x005c, 0x0102, 0x0153, 0x014b, 0x00ed, 0x00f1, 0x010d, 0x003a, 0x003b, 0x003f, 0x0071, 0x0108, 0x0151, 0x0160, 0x015b, 0x002e, 0x005c, 0x0102, 0x0153, 0x014b, 0x00ed, 0x00f1, 0x010d, 0x003a, 0x003b, 0x003f, 0x0071,
0x00b6, 0x00f0, 0x00ca, 0x00db, 0x00da, 0x004c, 0x00e7, 0x0055, 0x0057, 0x0059, 0x00d8, 0x005b, 0x005e, 0x00f7, 0x0118, 0x0068, 0x00b6, 0x00f0, 0x00ca, 0x00db, 0x00da, 0x004c, 0x00e7, 0x0055, 0x0057, 0x0059, 0x00d8, 0x005b, 0x005e, 0x00f7, 0x0118, 0x0068,
+7 -6
View File
@@ -67,7 +67,7 @@ static bool8 TryStartCoordEventScript(struct MapPosition *);
static bool8 TryStartWarpEventScript(struct MapPosition *, u16); static bool8 TryStartWarpEventScript(struct MapPosition *, u16);
static bool8 TryStartMiscWalkingScripts(u16); static bool8 TryStartMiscWalkingScripts(u16);
static bool8 TryStartStepCountScript(u16); static bool8 TryStartStepCountScript(u16);
static void UpdateHappinessStepCounter(void); static void UpdateFriendshipStepCounter(void);
static bool8 UpdatePoisonStepCounter(void); static bool8 UpdatePoisonStepCounter(void);
void FieldClearPlayerInput(struct FieldInput *input) void FieldClearPlayerInput(struct FieldInput *input)
@@ -542,7 +542,7 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior)
} }
IncrementRematchStepCounter(); IncrementRematchStepCounter();
UpdateHappinessStepCounter(); UpdateFriendshipStepCounter();
UpdateFarawayIslandStepCounter(); UpdateFarawayIslandStepCounter();
if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_FORCED_MOVE) && !MetatileBehavior_IsForcedMovementTile(metatileBehavior)) if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_FORCED_MOVE) && !MetatileBehavior_IsForcedMovementTile(metatileBehavior))
@@ -607,14 +607,15 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior)
return FALSE; return FALSE;
} }
void Unref_ClearHappinessStepCounter(void) // Unused
static void ClearFriendshipStepCounter(void)
{ {
VarSet(VAR_HAPPINESS_STEP_COUNTER, 0); VarSet(VAR_FRIENDSHIP_STEP_COUNTER, 0);
} }
static void UpdateHappinessStepCounter(void) static void UpdateFriendshipStepCounter(void)
{ {
u16 *ptr = GetVarPointer(VAR_HAPPINESS_STEP_COUNTER); u16 *ptr = GetVarPointer(VAR_FRIENDSHIP_STEP_COUNTER);
int i; int i;
(*ptr)++; (*ptr)++;
+30 -28
View File
@@ -357,40 +357,42 @@ static void DrawDoor(const struct DoorGraphics *gfx, const struct DoorAnimFrame
} }
} }
enum #define tFramesHi data[0]
{ #define tFramesLo data[1]
TD_FRAMELIST = 0, #define tGfxHi data[2]
TD_GFX = 2, #define tGfxLo data[3]
TD_FRAME = 4, #define tFrameId data[4]
TD_COUNTER, #define tCounter data[5]
TD_X, #define tX data[6]
TD_Y #define tY data[7]
};
static bool32 sub_808A5F0(struct DoorGraphics *gfx, struct DoorAnimFrame *frames, s16 *taskData) // Draws a single frame of the door animation, or skips drawing to wait between frames.
// Returns FALSE when the final frame has been reached
static bool32 AnimateDoorFrame(struct DoorGraphics *gfx, struct DoorAnimFrame *frames, s16 *data)
{ {
if (taskData[TD_COUNTER] == 0) if (tCounter == 0)
DrawDoor(gfx, &frames[taskData[TD_FRAME]], taskData[TD_X], taskData[TD_Y]); DrawDoor(gfx, &frames[tFrameId], tX, tY);
if (taskData[TD_COUNTER] == frames[taskData[TD_FRAME]].time)
if (tCounter == frames[tFrameId].time)
{ {
taskData[TD_COUNTER] = 0; tCounter = 0;
taskData[TD_FRAME]++; tFrameId++;
if (frames[taskData[TD_FRAME]].time == 0) if (frames[tFrameId].time == 0)
return FALSE; return FALSE;
else else
return TRUE; return TRUE;
} }
taskData[TD_COUNTER]++; tCounter++;
return TRUE; return TRUE;
} }
static void Task_AnimateDoor(u8 taskId) static void Task_AnimateDoor(u8 taskId)
{ {
u16 *taskData = gTasks[taskId].data; u16 *data = gTasks[taskId].data;
struct DoorAnimFrame *frames = (struct DoorAnimFrame *)(taskData[TD_FRAMELIST] << 16 | taskData[TD_FRAMELIST + 1]); struct DoorAnimFrame *frames = (struct DoorAnimFrame *)(tFramesHi << 16 | tFramesLo);
struct DoorGraphics *gfx = (struct DoorGraphics *)(taskData[TD_GFX] << 16 | taskData[TD_GFX + 1]); struct DoorGraphics *gfx = (struct DoorGraphics *)(tGfxHi << 16 | tGfxLo);
if (sub_808A5F0(gfx, frames, taskData) == FALSE) if (AnimateDoorFrame(gfx, frames, data) == FALSE)
DestroyTask(taskId); DestroyTask(taskId);
} }
@@ -419,16 +421,16 @@ static s8 StartDoorAnimationTask(const struct DoorGraphics *gfx, const struct Do
else else
{ {
u8 taskId = CreateTask(Task_AnimateDoor, 0x50); u8 taskId = CreateTask(Task_AnimateDoor, 0x50);
s16 *taskData = gTasks[taskId].data; s16 *data = gTasks[taskId].data;
taskData[TD_X] = x; tX = x;
taskData[TD_Y] = y; tY = y;
taskData[TD_FRAMELIST + 1] = (u32)frames; tFramesLo = (u32)frames;
taskData[TD_FRAMELIST] = (u32)frames >> 16; tFramesHi = (u32)frames >> 16;
taskData[TD_GFX + 1] = (u32)gfx; tGfxLo = (u32)gfx;
taskData[TD_GFX] = (u32)gfx >> 16; tGfxHi = (u32)gfx >> 16;
return taskId; return taskId;
} }
+14 -21
View File
@@ -480,13 +480,13 @@ static const struct Subsprite sSubsprites_HofMonitorBig[] =
static const struct SubspriteTable sSubspriteTable_HofMonitorBig = subsprite_table(sSubsprites_HofMonitorBig); static const struct SubspriteTable sSubspriteTable_HofMonitorBig = subsprite_table(sSubsprites_HofMonitorBig);
const union AnimCmd gSpriteAnim_855C2CC[] = const union AnimCmd sAnim_Static[] =
{ {
ANIMCMD_FRAME(.imageValue = 0, .duration = 1), ANIMCMD_FRAME(.imageValue = 0, .duration = 1),
ANIMCMD_JUMP(0) ANIMCMD_JUMP(0)
}; };
const union AnimCmd gSpriteAnim_855C2D4[] = const union AnimCmd sAnim_Flicker[] =
{ {
ANIMCMD_FRAME(.imageValue = 0, .duration = 16), ANIMCMD_FRAME(.imageValue = 0, .duration = 16),
ANIMCMD_FRAME(.imageValue = 1, .duration = 16), ANIMCMD_FRAME(.imageValue = 1, .duration = 16),
@@ -499,15 +499,16 @@ const union AnimCmd gSpriteAnim_855C2D4[] =
ANIMCMD_END ANIMCMD_END
}; };
const union AnimCmd *const gSpriteAnimTable_855C2F8[] = // Flicker on and off, for the Pokéballs / monitors during the PokéCenter heal effect
const union AnimCmd *const sAnims_Flicker[] =
{ {
gSpriteAnim_855C2CC, sAnim_Static,
gSpriteAnim_855C2D4 sAnim_Flicker
}; };
static const union AnimCmd *const sAnimTable_HofMonitor[] = static const union AnimCmd *const sAnims_HofMonitor[] =
{ {
gSpriteAnim_855C2CC sAnim_Static
}; };
static const struct SpriteTemplate sSpriteTemplate_PokeballGlow = static const struct SpriteTemplate sSpriteTemplate_PokeballGlow =
@@ -515,7 +516,7 @@ static const struct SpriteTemplate sSpriteTemplate_PokeballGlow =
.tileTag = 0xFFFF, .tileTag = 0xFFFF,
.paletteTag = FLDEFF_PAL_TAG_POKEBALL_GLOW, .paletteTag = FLDEFF_PAL_TAG_POKEBALL_GLOW,
.oam = &sOam_8x8, .oam = &sOam_8x8,
.anims = gSpriteAnimTable_855C2F8, .anims = sAnims_Flicker,
.images = sPicTable_PokeballGlow, .images = sPicTable_PokeballGlow,
.affineAnims = gDummySpriteAffineAnimTable, .affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCB_PokeballGlow .callback = SpriteCB_PokeballGlow
@@ -526,7 +527,7 @@ static const struct SpriteTemplate sSpriteTemplate_PokecenterMonitor =
.tileTag = 0xFFFF, .tileTag = 0xFFFF,
.paletteTag = FLDEFF_PAL_TAG_GENERAL_0, .paletteTag = FLDEFF_PAL_TAG_GENERAL_0,
.oam = &sOam_16x16, .oam = &sOam_16x16,
.anims = gSpriteAnimTable_855C2F8, .anims = sAnims_Flicker,
.images = sPicTable_PokecenterMonitor, .images = sPicTable_PokecenterMonitor,
.affineAnims = gDummySpriteAffineAnimTable, .affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCB_PokecenterMonitor .callback = SpriteCB_PokecenterMonitor
@@ -537,7 +538,7 @@ static const struct SpriteTemplate sSpriteTemplate_HofMonitorBig =
.tileTag = 0xFFFF, .tileTag = 0xFFFF,
.paletteTag = FLDEFF_PAL_TAG_HOF_MONITOR, .paletteTag = FLDEFF_PAL_TAG_HOF_MONITOR,
.oam = &sOam_16x16, .oam = &sOam_16x16,
.anims = sAnimTable_HofMonitor, .anims = sAnims_HofMonitor,
.images = sPicTable_HofMonitorBig, .images = sPicTable_HofMonitorBig,
.affineAnims = gDummySpriteAffineAnimTable, .affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCB_HallOfFameMonitor .callback = SpriteCB_HallOfFameMonitor
@@ -548,7 +549,7 @@ static const struct SpriteTemplate sSpriteTemplate_HofMonitorSmall =
.tileTag = 0xFFFF, .tileTag = 0xFFFF,
.paletteTag = FLDEFF_PAL_TAG_HOF_MONITOR, .paletteTag = FLDEFF_PAL_TAG_HOF_MONITOR,
.oam = &sOam_32x16, .oam = &sOam_32x16,
.anims = sAnimTable_HofMonitor, .anims = sAnims_HofMonitor,
.images = sPicTable_HofMonitorSmall, .images = sPicTable_HofMonitorSmall,
.affineAnims = gDummySpriteAffineAnimTable, .affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCB_HallOfFameMonitor .callback = SpriteCB_HallOfFameMonitor
@@ -3853,16 +3854,8 @@ static void Task_MoveDeoxysRock(u8 taskId)
case 0: case 0:
data[4] = sprite->pos1.x << 4; data[4] = sprite->pos1.x << 4;
data[5] = sprite->pos1.y << 4; data[5] = sprite->pos1.y << 4;
data[6] = SAFE_DIV(data[2] * 16 - data[4], data[8]);
// UB: Possible divide by zero data[7] = SAFE_DIV(data[3] * 16 - data[5], data[8]);
#ifdef UBFIX
#define DIVISOR (data[8] ? data[8] : 1);
#else
#define DIVISOR (data[8])
#endif
data[6] = (data[2] * 16 - data[4]) / DIVISOR;
data[7] = (data[3] * 16 - data[5]) / DIVISOR;
data[0]++; data[0]++;
case 1: case 1:
if (data[8] != 0) if (data[8] != 0)
+18 -22
View File
@@ -16,7 +16,6 @@
#include "constants/songs.h" #include "constants/songs.h"
#include "constants/map_types.h" #include "constants/map_types.h"
// structures
struct FlashStruct struct FlashStruct
{ {
u8 fromType; u8 fromType;
@@ -26,7 +25,6 @@ struct FlashStruct
void (*func)(void); void (*func)(void);
}; };
// static functions
static void FieldCallback_Flash(void); static void FieldCallback_Flash(void);
static void FldEff_UseFlash(void); static void FldEff_UseFlash(void);
static bool8 TryDoMapTransition(void); static bool8 TryDoMapTransition(void);
@@ -42,7 +40,6 @@ static void Task_EnterCaveTransition2(u8 taskId);
static void Task_EnterCaveTransition3(u8 taskId); static void Task_EnterCaveTransition3(u8 taskId);
static void Task_EnterCaveTransition4(u8 taskId); static void Task_EnterCaveTransition4(u8 taskId);
// rodata
static const struct FlashStruct sTransitionTypes[] = static const struct FlashStruct sTransitionTypes[] =
{ {
{MAP_TYPE_TOWN, MAP_TYPE_UNDERGROUND, TRUE, FALSE, DoEnterCaveTransition}, {MAP_TYPE_TOWN, MAP_TYPE_UNDERGROUND, TRUE, FALSE, DoEnterCaveTransition},
@@ -64,15 +61,14 @@ static const struct FlashStruct sTransitionTypes[] =
{}, {},
}; };
static const u16 gCaveTransitionPalette_White[] = INCBIN_U16("graphics/misc/cave_transition_white.gbapal"); static const u16 sCaveTransitionPalette_White[] = INCBIN_U16("graphics/misc/cave_transition_white.gbapal");
static const u16 gCaveTransitionPalette_Black[] = INCBIN_U16("graphics/misc/cave_transition_black.gbapal"); static const u16 sCaveTransitionPalette_Black[] = INCBIN_U16("graphics/misc/cave_transition_black.gbapal");
static const u16 gUnknown_085B2890[] = INCBIN_U16("graphics/misc/85B2890.gbapal"); static const u16 sCaveTransitionPalette_Enter[] = INCBIN_U16("graphics/misc/cave_transition_enter.gbapal");
static const u16 gUnknown_085B28A0[] = INCBIN_U16("graphics/misc/85B28A0.gbapal"); static const u16 sCaveTransitionPalette_Exit[] = INCBIN_U16("graphics/misc/cave_transition_exit.gbapal");
static const u32 gCaveTransitionTilemap[] = INCBIN_U32("graphics/misc/cave_transition_map.bin.lz"); static const u32 sCaveTransitionTilemap[] = INCBIN_U32("graphics/misc/cave_transition_map.bin.lz");
static const u32 gCaveTransitionTiles[] = INCBIN_U32("graphics/misc/cave_transition.4bpp.lz"); static const u32 sCaveTransitionTiles[] = INCBIN_U32("graphics/misc/cave_transition.4bpp.lz");
// text
bool8 SetUpFieldMove_Flash(void) bool8 SetUpFieldMove_Flash(void)
{ {
// In Ruby and Sapphire, Registeel's tomb is opened by using Fly. In Emerald, // In Ruby and Sapphire, Registeel's tomb is opened by using Fly. In Emerald,
@@ -220,10 +216,10 @@ static void Task_ExitCaveTransition1(u8 taskId)
static void Task_ExitCaveTransition2(u8 taskId) static void Task_ExitCaveTransition2(u8 taskId)
{ {
SetGpuReg(REG_OFFSET_DISPCNT, 0); SetGpuReg(REG_OFFSET_DISPCNT, 0);
LZ77UnCompVram(gCaveTransitionTiles, (void *)(VRAM + 0xC000)); LZ77UnCompVram(sCaveTransitionTiles, (void *)(VRAM + 0xC000));
LZ77UnCompVram(gCaveTransitionTilemap, (void *)(VRAM + 0xF800)); LZ77UnCompVram(sCaveTransitionTilemap, (void *)(VRAM + 0xF800));
LoadPalette(gCaveTransitionPalette_White, 0xE0, 0x20); LoadPalette(sCaveTransitionPalette_White, 0xE0, 0x20);
LoadPalette(gUnknown_085B28A0, 0xE0, 0x10); LoadPalette(sCaveTransitionPalette_Exit, 0xE0, 0x10);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0
| BLDCNT_EFFECT_BLEND | BLDCNT_EFFECT_BLEND
| BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG1
@@ -274,11 +270,11 @@ static void Task_ExitCaveTransition4(u8 taskId)
if (count < 8) if (count < 8)
{ {
gTasks[taskId].data[2]++; gTasks[taskId].data[2]++;
LoadPalette(&gUnknown_085B28A0[count], 0xE0, 16 - 2 * count); LoadPalette(&sCaveTransitionPalette_Exit[count], 0xE0, 16 - 2 * count);
} }
else else
{ {
LoadPalette(gCaveTransitionPalette_White, 0, 0x20); LoadPalette(sCaveTransitionPalette_White, 0, 0x20);
gTasks[taskId].func = Task_ExitCaveTransition5; gTasks[taskId].func = Task_ExitCaveTransition5;
gTasks[taskId].data[2] = 8; gTasks[taskId].data[2] = 8;
} }
@@ -305,8 +301,8 @@ static void Task_EnterCaveTransition1(u8 taskId)
static void Task_EnterCaveTransition2(u8 taskId) static void Task_EnterCaveTransition2(u8 taskId)
{ {
SetGpuReg(REG_OFFSET_DISPCNT, 0); SetGpuReg(REG_OFFSET_DISPCNT, 0);
LZ77UnCompVram(gCaveTransitionTiles, (void *)(VRAM + 0xC000)); LZ77UnCompVram(sCaveTransitionTiles, (void *)(VRAM + 0xC000));
LZ77UnCompVram(gCaveTransitionTilemap, (void *)(VRAM + 0xF800)); LZ77UnCompVram(sCaveTransitionTilemap, (void *)(VRAM + 0xF800));
SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0); SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 0); SetGpuReg(REG_OFFSET_BLDY, 0);
@@ -319,8 +315,8 @@ static void Task_EnterCaveTransition2(u8 taskId)
| DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_1D_MAP
| DISPCNT_BG0_ON | DISPCNT_BG0_ON
| DISPCNT_OBJ_ON); | DISPCNT_OBJ_ON);
LoadPalette(gCaveTransitionPalette_White, 0xE0, 0x20); LoadPalette(sCaveTransitionPalette_White, 0xE0, 0x20);
LoadPalette(gCaveTransitionPalette_Black, 0, 0x20); LoadPalette(sCaveTransitionPalette_Black, 0, 0x20);
gTasks[taskId].func = Task_EnterCaveTransition3; gTasks[taskId].func = Task_EnterCaveTransition3;
gTasks[taskId].data[0] = 16; gTasks[taskId].data[0] = 16;
gTasks[taskId].data[1] = 0; gTasks[taskId].data[1] = 0;
@@ -335,7 +331,7 @@ static void Task_EnterCaveTransition3(u8 taskId)
{ {
gTasks[taskId].data[2]++; gTasks[taskId].data[2]++;
gTasks[taskId].data[2]++; gTasks[taskId].data[2]++;
LoadPalette(&gUnknown_085B2890[15 - count], 0xE0, 2 * (count + 1)); LoadPalette(&sCaveTransitionPalette_Enter[15 - count], 0xE0, 2 * (count + 1));
} }
else else
{ {
@@ -363,7 +359,7 @@ static void Task_EnterCaveTransition4(u8 taskId)
} }
else else
{ {
LoadPalette(gCaveTransitionPalette_Black, 0, 0x20); LoadPalette(sCaveTransitionPalette_Black, 0, 0x20);
SetMainCallback2(gMain.savedCallback); SetMainCallback2(gMain.savedCallback);
} }
} }
+6 -6
View File
@@ -2383,13 +2383,13 @@ void ClearRankingHallRecords(void)
{ {
s32 i, j, k; s32 i, j, k;
// BUG: Passing 0 as a pointer instead of a pointer holding a value of 0. // UB: Passing 0 as a pointer instead of a pointer holding a value of 0.
#ifdef BUGFIX #ifdef UBFIX
u8 zero = 0; u8 emptyId[TRAINER_ID_LENGTH] = {0};
#define ZERO (&zero) #define ZERO emptyId
#else #else
#define ZERO 0 #define ZERO 0
#endif #endif
for (i = 0; i < HALL_FACILITIES_COUNT; i++) for (i = 0; i < HALL_FACILITIES_COUNT; i++)
{ {
+3 -3
View File
@@ -1543,9 +1543,9 @@ const u16 gUnknown_08DE3350[] = INCBIN_U16("graphics/frontier_pass/tilemap1.bin"
const u16 gUnknown_08DE3374[] = INCBIN_U16("graphics/frontier_pass/tilemap2.bin"); const u16 gUnknown_08DE3374[] = INCBIN_U16("graphics/frontier_pass/tilemap2.bin");
// Berry Crush // Berry Crush
const u16 gUnknown_08DE3398[] = INCBIN_U16("graphics/berry_crusher/tiles.gbapal"); const u16 gBerryCrush_Crusher_Pal[] = INCBIN_U16("graphics/berry_crush/crusher.gbapal");
const u32 gUnknown_08DE34B8[] = INCBIN_U32("graphics/berry_crusher/tiles.4bpp.lz"); const u32 gBerryCrush_Crusher_Gfx[] = INCBIN_U32("graphics/berry_crush/crusher.4bpp.lz");
const u32 gUnknown_08DE3FD4[] = INCBIN_U32("graphics/berry_crusher/tiles.bin.lz"); const u32 gBerryCrush_Crusher_Tilemap[] = INCBIN_U32("graphics/berry_crush/crusher.bin.lz");
// random garbage at the end. // random garbage at the end.
static const u8 sEmpty3[0x54BAC] = {0}; static const u8 sEmpty3[0x54BAC] = {0};
+1 -1
View File
@@ -1576,7 +1576,7 @@ static void Task_IntroSpinAndZoomPokeball(u8 taskId)
gTasks[taskId].func = Task_IntroWaitToSetupPart3LegendsFight; gTasks[taskId].func = Task_IntroWaitToSetupPart3LegendsFight;
} }
PanFadeAndZoomScreen(0x78, 0x50, 0x10000 / gTasks[taskId].data[1], gTasks[taskId].data[0]); PanFadeAndZoomScreen(0x78, 0x50, SAFE_DIV(0x10000, gTasks[taskId].data[1]), gTasks[taskId].data[0]);
if (gIntroFrameCounter == 28) if (gIntroFrameCounter == 28)
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_WHITEALPHA); BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_WHITEALPHA);
+151 -208
View File
@@ -41,8 +41,8 @@ struct LinkTestBGInfo
{ {
u32 screenBaseBlock; u32 screenBaseBlock;
u32 paletteNum; u32 paletteNum;
u32 dummy_8; u32 baseChar;
u32 dummy_C; u32 unused;
}; };
static struct BlockTransfer sBlockSend; static struct BlockTransfer sBlockSend;
@@ -97,28 +97,26 @@ struct Link gLink;
u8 gLastRecvQueueCount; u8 gLastRecvQueueCount;
u16 gLinkSavedIme; u16 gLinkSavedIme;
EWRAM_DATA u8 gLinkTestDebugValuesEnabled = 0; static EWRAM_DATA u8 sLinkTestDebugValuesEnabled = 0;
EWRAM_DATA u8 gUnknown_020223BD = 0; static EWRAM_DATA u8 sDummyFlag = FALSE;
EWRAM_DATA u32 gBerryBlenderKeySendAttempts = 0; EWRAM_DATA u32 gBerryBlenderKeySendAttempts = 0;
EWRAM_DATA u16 gBlockRecvBuffer[MAX_RFU_PLAYERS][BLOCK_BUFFER_SIZE / 2] = {}; EWRAM_DATA u16 gBlockRecvBuffer[MAX_RFU_PLAYERS][BLOCK_BUFFER_SIZE / 2] = {};
EWRAM_DATA u8 gBlockSendBuffer[BLOCK_BUFFER_SIZE] = {}; EWRAM_DATA u8 gBlockSendBuffer[BLOCK_BUFFER_SIZE] = {};
EWRAM_DATA bool8 gLinkOpen = FALSE; static EWRAM_DATA bool8 sLinkOpen = FALSE;
EWRAM_DATA u16 gLinkType = 0; EWRAM_DATA u16 gLinkType = 0;
EWRAM_DATA u16 gLinkTimeOutCounter = 0; static EWRAM_DATA u16 sTimeOutCounter = 0;
EWRAM_DATA struct LinkPlayer gLocalLinkPlayer = {}; EWRAM_DATA struct LinkPlayer gLocalLinkPlayer = {};
EWRAM_DATA struct LinkPlayer gLinkPlayers[MAX_RFU_PLAYERS] = {}; EWRAM_DATA struct LinkPlayer gLinkPlayers[MAX_RFU_PLAYERS] = {};
EWRAM_DATA struct LinkPlayer gSavedLinkPlayers[MAX_RFU_PLAYERS] = {}; static EWRAM_DATA struct LinkPlayer sSavedLinkPlayers[MAX_RFU_PLAYERS] = {};
EWRAM_DATA struct { EWRAM_DATA struct {
u32 status; u32 status;
u8 lastRecvQueueCount; u8 lastRecvQueueCount;
u8 lastSendQueueCount; u8 lastSendQueueCount;
u8 unk_06; bool8 disconnected;
} sLinkErrorBuffer = {}; } sLinkErrorBuffer = {};
static EWRAM_DATA u16 sReadyCloseLinkAttempts = 0; // never read static EWRAM_DATA u16 sReadyCloseLinkAttempts = 0; // never read
static EWRAM_DATA void *sLinkErrorBgTilemapBuffer = NULL; static EWRAM_DATA void *sLinkErrorBgTilemapBuffer = NULL;
// Static ROM declarations
static void InitLocalLinkPlayer(void); static void InitLocalLinkPlayer(void);
static void VBlankCB_LinkError(void); static void VBlankCB_LinkError(void);
static void CB2_LinkTest(void); static void CB2_LinkTest(void);
@@ -131,7 +129,7 @@ static void LinkCB_BlockSend(void);
static void LinkCB_BlockSendEnd(void); static void LinkCB_BlockSendEnd(void);
static void SetBlockReceivedFlag(u8 who); static void SetBlockReceivedFlag(u8 who);
static u16 LinkTestCalcBlockChecksum(const u16 *src, u16 size); static u16 LinkTestCalcBlockChecksum(const u16 *src, u16 size);
static void LinkTest_prnthex(u32 pos, u8 a0, u8 a1, u8 a2); static void LinkTest_PrintHex(u32 pos, u8 a0, u8 a1, u8 a2);
static void LinkCB_RequestPlayerDataExchange(void); static void LinkCB_RequestPlayerDataExchange(void);
static void Task_PrintTestData(u8 taskId); static void Task_PrintTestData(u8 taskId);
@@ -160,8 +158,6 @@ static void DoSend(void);
static void StopTimer(void); static void StopTimer(void);
static void SendRecvDone(void); static void SendRecvDone(void);
// .rodata
static const u16 sWirelessLinkDisplayPal[] = INCBIN_U16("graphics/interface/wireless_link_display.gbapal"); static const u16 sWirelessLinkDisplayPal[] = INCBIN_U16("graphics/interface/wireless_link_display.gbapal");
static const u32 sWirelessLinkDisplayGfx[] = INCBIN_U32("graphics/interface/wireless_link_display.4bpp.lz"); static const u32 sWirelessLinkDisplayGfx[] = INCBIN_U32("graphics/interface/wireless_link_display.4bpp.lz");
static const u32 sWirelessLinkDisplayTilemap[] = INCBIN_U32("graphics/interface/wireless_link_display.bin.lz"); static const u32 sWirelessLinkDisplayTilemap[] = INCBIN_U32("graphics/interface/wireless_link_display.bin.lz");
@@ -226,15 +222,13 @@ static const struct WindowTemplate sLinkErrorWindowTemplates[] = {
}; };
static const u8 sTextColors[] = { TEXT_COLOR_TRANSPARENT, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY }; static const u8 sTextColors[] = { TEXT_COLOR_TRANSPARENT, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY };
static const u8 sUnused_082ED224[] = {0x00, 0xFF, 0xFE, 0xFF, 0x00}; static const u8 sUnusedData[] = {0x00, 0xFF, 0xFE, 0xFF, 0x00};
// .text
bool8 IsWirelessAdapterConnected(void) bool8 IsWirelessAdapterConnected(void)
{ {
SetWirelessCommType1(); SetWirelessCommType1();
InitRFUAPI(); InitRFUAPI();
if (rfu_LMAN_REQBN_softReset_and_checkID() == 0x8001) if (rfu_LMAN_REQBN_softReset_and_checkID() == RFU_ID)
{ {
rfu_REQ_stopMode(); rfu_REQ_stopMode();
rfu_waitREQComplete(); rfu_waitREQComplete();
@@ -251,13 +245,13 @@ void Task_DestroySelf(u8 taskId)
DestroyTask(taskId); DestroyTask(taskId);
} }
static void InitLinkTestBG(u8 paletteNum, u8 bgNum, u8 screenBaseBlock, u8 charBaseBlock, u16 a4) static void InitLinkTestBG(u8 paletteNum, u8 bgNum, u8 screenBaseBlock, u8 charBaseBlock, u16 baseChar)
{ {
LoadPalette(sLinkTestDigitsPal, paletteNum * 16, 0x20); LoadPalette(sLinkTestDigitsPal, paletteNum * 16, 0x20);
DmaCopy16(3, sLinkTestDigitsGfx, (u16 *)BG_CHAR_ADDR(charBaseBlock) + (16 * a4), sizeof sLinkTestDigitsGfx); DmaCopy16(3, sLinkTestDigitsGfx, (u16 *)BG_CHAR_ADDR(charBaseBlock) + (16 * baseChar), sizeof sLinkTestDigitsGfx);
gLinkTestBGInfo.screenBaseBlock = screenBaseBlock; gLinkTestBGInfo.screenBaseBlock = screenBaseBlock;
gLinkTestBGInfo.paletteNum = paletteNum; gLinkTestBGInfo.paletteNum = paletteNum;
gLinkTestBGInfo.dummy_8 = a4; gLinkTestBGInfo.baseChar = baseChar;
switch (bgNum) switch (bgNum)
{ {
case 1: case 1:
@@ -274,17 +268,19 @@ static void InitLinkTestBG(u8 paletteNum, u8 bgNum, u8 screenBaseBlock, u8 charB
SetGpuReg(REG_OFFSET_BG0VOFS + bgNum * 4, 0); SetGpuReg(REG_OFFSET_BG0VOFS + bgNum * 4, 0);
} }
void sub_80094EC(u8 paletteNum, u8 bgNum, u8 screenBaseBlock, u8 charBaseBlock) // Unused
static void LoadLinkTestBgGfx(u8 paletteNum, u8 bgNum, u8 screenBaseBlock, u8 charBaseBlock)
{ {
LoadPalette(sLinkTestDigitsPal, paletteNum * 16, 0x20); LoadPalette(sLinkTestDigitsPal, paletteNum * 16, 0x20);
DmaCopy16(3, sLinkTestDigitsGfx, (u16 *)BG_CHAR_ADDR(charBaseBlock), sizeof sLinkTestDigitsGfx); DmaCopy16(3, sLinkTestDigitsGfx, (u16 *)BG_CHAR_ADDR(charBaseBlock), sizeof sLinkTestDigitsGfx);
gLinkTestBGInfo.screenBaseBlock = screenBaseBlock; gLinkTestBGInfo.screenBaseBlock = screenBaseBlock;
gLinkTestBGInfo.paletteNum = paletteNum; gLinkTestBGInfo.paletteNum = paletteNum;
gLinkTestBGInfo.dummy_8 = 0; gLinkTestBGInfo.baseChar = 0;
SetGpuReg(sBGControlRegs[bgNum], BGCNT_SCREENBASE(screenBaseBlock) | BGCNT_CHARBASE(charBaseBlock)); SetGpuReg(sBGControlRegs[bgNum], BGCNT_SCREENBASE(screenBaseBlock) | BGCNT_CHARBASE(charBaseBlock));
} }
void LinkTestScreen(void) // Unused
static void LinkTestScreen(void)
{ {
int i; int i;
@@ -346,10 +342,9 @@ static void InitLink(void)
int i; int i;
for (i = 0; i < CMD_LENGTH; i++) for (i = 0; i < CMD_LENGTH; i++)
{ gSendCmd[i] = LINKCMD_NONE;
gSendCmd[i] = 0xEfff;
} sLinkOpen = TRUE;
gLinkOpen = TRUE;
EnableSerial(); EnableSerial();
} }
@@ -402,7 +397,7 @@ void CloseLink(void)
{ {
LinkRfu_Shutdown(); LinkRfu_Shutdown();
} }
gLinkOpen = FALSE; sLinkOpen = FALSE;
DisableSerial(); DisableSerial();
} }
@@ -413,14 +408,14 @@ static void TestBlockTransfer(u8 nothing, u8 is, u8 used)
if (sLinkTestLastBlockSendPos != sBlockSend.pos) if (sLinkTestLastBlockSendPos != sBlockSend.pos)
{ {
LinkTest_prnthex(sBlockSend.pos, 2, 3, 2); LinkTest_PrintHex(sBlockSend.pos, 2, 3, 2);
sLinkTestLastBlockSendPos = sBlockSend.pos; sLinkTestLastBlockSendPos = sBlockSend.pos;
} }
for (i = 0; i < MAX_LINK_PLAYERS; i++) for (i = 0; i < MAX_LINK_PLAYERS; i++)
{ {
if (sLinkTestLastBlockRecvPos[i] != sBlockRecv[i].pos) if (sLinkTestLastBlockRecvPos[i] != sBlockRecv[i].pos)
{ {
LinkTest_prnthex(sBlockRecv[i].pos, 2, i + 4, 2); LinkTest_PrintHex(sBlockRecv[i].pos, 2, i + 4, 2);
sLinkTestLastBlockRecvPos[i] = sBlockRecv[i].pos; sLinkTestLastBlockRecvPos[i] = sBlockRecv[i].pos;
} }
} }
@@ -435,8 +430,8 @@ static void TestBlockTransfer(u8 nothing, u8 is, u8 used)
ResetBlockReceivedFlag(i); ResetBlockReceivedFlag(i);
if (gLinkTestBlockChecksums[i] != 0x0342) if (gLinkTestBlockChecksums[i] != 0x0342)
{ {
gLinkTestDebugValuesEnabled = FALSE; sLinkTestDebugValuesEnabled = FALSE;
gUnknown_020223BD = FALSE; sDummyFlag = FALSE;
} }
} }
} }
@@ -469,7 +464,7 @@ static void LinkTestProcessKeyInput(void)
{ {
SetCloseLinkCallback(); SetCloseLinkCallback();
} }
if (gLinkTestDebugValuesEnabled) if (sLinkTestDebugValuesEnabled)
{ {
SetLinkDebugValues(gMain.vblankCounter2, gLinkCallback ? gLinkVSyncDisabled : gLinkVSyncDisabled | 0x10); SetLinkDebugValues(gMain.vblankCounter2, gLinkCallback ? gLinkVSyncDisabled : gLinkVSyncDisabled | 0x10);
} }
@@ -489,7 +484,7 @@ u16 LinkMain2(const u16 *heldKeys)
{ {
u8 i; u8 i;
if (!gLinkOpen) if (!sLinkOpen)
{ {
return 0; return 0;
} }
@@ -555,10 +550,10 @@ static void ProcessRecvCmds(u8 unused)
case LINKCMD_BLENDER_SEND_KEYS: case LINKCMD_BLENDER_SEND_KEYS:
gLinkPartnersHeldKeys[i] = gRecvCmds[i][1]; gLinkPartnersHeldKeys[i] = gRecvCmds[i][1];
break; break;
case LINKCMD_0x5555: case LINKCMD_DUMMY_1:
gLinkDummy2 = TRUE; gLinkDummy2 = TRUE;
break; break;
case LINKCMD_0x5566: case LINKCMD_DUMMY_2:
gLinkDummy2 = TRUE; gLinkDummy2 = TRUE;
break; break;
case LINKCMD_INIT_BLOCK: case LINKCMD_INIT_BLOCK:
@@ -612,7 +607,7 @@ static void ProcessRecvCmds(u8 unused)
linkPlayer->neverRead = 0; linkPlayer->neverRead = 0;
linkPlayer->progressFlags = 0; linkPlayer->progressFlags = 0;
} }
sub_800B524(linkPlayer); ConvertLinkPlayerName(linkPlayer);
if (strcmp(block->magic1, sASCIIGameFreakInc) != 0 if (strcmp(block->magic1, sASCIIGameFreakInc) != 0
|| strcmp(block->magic2, sASCIIGameFreakInc) != 0) || strcmp(block->magic2, sASCIIGameFreakInc) != 0)
{ {
@@ -664,22 +659,19 @@ static void BuildSendCmd(u16 command)
gSendCmd[0] = LINKCMD_BLENDER_SEND_KEYS; gSendCmd[0] = LINKCMD_BLENDER_SEND_KEYS;
gSendCmd[1] = gMain.heldKeys; gSendCmd[1] = gMain.heldKeys;
break; break;
case LINKCMD_0x5555: case LINKCMD_DUMMY_1:
gSendCmd[0] = LINKCMD_0x5555; gSendCmd[0] = LINKCMD_DUMMY_1;
break; break;
case LINKCMD_0x6666: case LINKCMD_SEND_EMPTY:
gSendCmd[0] = LINKCMD_0x6666; gSendCmd[0] = LINKCMD_SEND_EMPTY;
gSendCmd[1] = 0; gSendCmd[1] = 0;
break; break;
case LINKCMD_0x7777: case LINKCMD_SEND_0xEE:
{ {
u8 i; u8 i;
gSendCmd[0] = LINKCMD_SEND_0xEE;
gSendCmd[0] = LINKCMD_0x7777;
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
{
gSendCmd[i + 1] = 0xEE; gSendCmd[i + 1] = 0xEE;
}
break; break;
} }
case LINKCMD_INIT_BLOCK: case LINKCMD_INIT_BLOCK:
@@ -690,8 +682,8 @@ static void BuildSendCmd(u16 command)
case LINKCMD_BLENDER_NO_PBLOCK_SPACE: case LINKCMD_BLENDER_NO_PBLOCK_SPACE:
gSendCmd[0] = LINKCMD_BLENDER_NO_PBLOCK_SPACE; gSendCmd[0] = LINKCMD_BLENDER_NO_PBLOCK_SPACE;
break; break;
case LINKCMD_0xAAAB: case LINKCMD_SEND_ITEM:
gSendCmd[0] = LINKCMD_0xAAAB; gSendCmd[0] = LINKCMD_SEND_ITEM;
gSendCmd[1] = gSpecialVar_ItemId; gSendCmd[1] = gSpecialVar_ItemId;
break; break;
case LINKCMD_SEND_BLOCK_REQ: case LINKCMD_SEND_BLOCK_REQ:
@@ -702,14 +694,13 @@ static void BuildSendCmd(u16 command)
gSendCmd[0] = LINKCMD_READY_CLOSE_LINK; gSendCmd[0] = LINKCMD_READY_CLOSE_LINK;
gSendCmd[1] = gReadyCloseLinkType; gSendCmd[1] = gReadyCloseLinkType;
break; break;
case LINKCMD_0x5566: case LINKCMD_DUMMY_2:
gSendCmd[0] = LINKCMD_0x5566; gSendCmd[0] = LINKCMD_DUMMY_2;
break; break;
case LINKCMD_SEND_HELD_KEYS: case LINKCMD_SEND_HELD_KEYS:
if (gHeldKeyCodeToSend == 0 || gLinkTransferringData) if (gHeldKeyCodeToSend == 0 || gLinkTransferringData)
{
break; break;
}
gSendCmd[0] = LINKCMD_SEND_HELD_KEYS; gSendCmd[0] = LINKCMD_SEND_HELD_KEYS;
gSendCmd[1] = gHeldKeyCodeToSend; gSendCmd[1] = gHeldKeyCodeToSend;
break; break;
@@ -819,7 +810,7 @@ bool32 Link_AnyPartnersPlayingFRLG_JP(void)
void OpenLinkTimed(void) void OpenLinkTimed(void)
{ {
sPlayerDataExchangeStatus = EXCHANGE_NOT_STARTED; sPlayerDataExchangeStatus = EXCHANGE_NOT_STARTED;
gLinkTimeOutCounter = 0; sTimeOutCounter = 0;
OpenLink(); OpenLink();
} }
@@ -892,7 +883,7 @@ u8 GetLinkPlayerDataExchangeStatusTimed(int minPlayers, int maxPlayers)
} }
} }
} }
else if (++gLinkTimeOutCounter > 600) else if (++sTimeOutCounter > 600)
{ {
sPlayerDataExchangeStatus = EXCHANGE_TIMED_OUT; sPlayerDataExchangeStatus = EXCHANGE_TIMED_OUT;
} }
@@ -909,9 +900,7 @@ bool8 IsLinkPlayerDataExchangeComplete(void)
for (i = 0; i < GetLinkPlayerCount(); i++) for (i = 0; i < GetLinkPlayerCount(); i++)
{ {
if (gLinkPlayers[i].linkType == gLinkPlayers[0].linkType) if (gLinkPlayers[i].linkType == gLinkPlayers[0].linkType)
{
count++; count++;
}
} }
if (count == GetLinkPlayerCount()) if (count == GetLinkPlayerCount())
{ {
@@ -936,9 +925,7 @@ void ResetLinkPlayers(void)
int i; int i;
for (i = 0; i <= MAX_LINK_PLAYERS; i++) for (i = 0; i <= MAX_LINK_PLAYERS; i++)
{
gLinkPlayers[i] = (struct LinkPlayer){}; gLinkPlayers[i] = (struct LinkPlayer){};
}
} }
static void ResetBlockSend(void) static void ResetBlockSend(void)
@@ -966,9 +953,8 @@ static bool32 InitBlockSend(const void *src, size_t size)
else else
{ {
if (src != gBlockSendBuffer) if (src != gBlockSendBuffer)
{
memcpy(gBlockSendBuffer, src, size); memcpy(gBlockSendBuffer, src, size);
}
sBlockSend.src = gBlockSendBuffer; sBlockSend.src = gBlockSendBuffer;
} }
BuildSendCmd(LINKCMD_INIT_BLOCK); BuildSendCmd(LINKCMD_INIT_BLOCK);
@@ -980,9 +966,7 @@ static bool32 InitBlockSend(const void *src, size_t size)
static void LinkCB_BlockSendBegin(void) static void LinkCB_BlockSendBegin(void)
{ {
if (++sBlockSendDelayCounter > 2) if (++sBlockSendDelayCounter > 2)
{
gLinkCallback = LinkCB_BlockSend; gLinkCallback = LinkCB_BlockSend;
}
} }
static void LinkCB_BlockSend(void) static void LinkCB_BlockSend(void)
@@ -1020,13 +1004,9 @@ void SetBerryBlenderLinkCallback(void)
{ {
gBerryBlenderKeySendAttempts = 0; gBerryBlenderKeySendAttempts = 0;
if (gWirelessCommType) if (gWirelessCommType)
{
Rfu_SetBerryBlenderLinkCallback(); Rfu_SetBerryBlenderLinkCallback();
}
else else
{
gLinkCallback = LinkCB_BerryBlenderSendHeldKeys; gLinkCallback = LinkCB_BerryBlenderSendHeldKeys;
}
} }
// Unused // Unused
@@ -1044,9 +1024,8 @@ static void SendBerryBlenderNoSpaceForPokeblocks(void)
u8 GetMultiplayerId(void) u8 GetMultiplayerId(void)
{ {
if (gWirelessCommType == TRUE) if (gWirelessCommType == TRUE)
{
return Rfu_GetMultiplayerId(); return Rfu_GetMultiplayerId();
}
return SIO_MULTI_CNT->id; return SIO_MULTI_CNT->id;
} }
@@ -1061,18 +1040,16 @@ u8 bitmask_all_link_players_but_self(void)
bool8 SendBlock(u8 unused, const void *src, u16 size) bool8 SendBlock(u8 unused, const void *src, u16 size)
{ {
if (gWirelessCommType == TRUE) if (gWirelessCommType == TRUE)
{
return Rfu_InitBlockSend(src, size); return Rfu_InitBlockSend(src, size);
}
return InitBlockSend(src, size); return InitBlockSend(src, size);
} }
bool8 SendBlockRequest(u8 blockReqType) bool8 SendBlockRequest(u8 blockReqType)
{ {
if (gWirelessCommType == TRUE) if (gWirelessCommType == TRUE)
{
return Rfu_SendBlockRequest(blockReqType); return Rfu_SendBlockRequest(blockReqType);
}
if (gLinkCallback == NULL) if (gLinkCallback == NULL)
{ {
gBlockRequestType = blockReqType; gBlockRequestType = blockReqType;
@@ -1085,31 +1062,25 @@ bool8 SendBlockRequest(u8 blockReqType)
bool8 IsLinkTaskFinished(void) bool8 IsLinkTaskFinished(void)
{ {
if (gWirelessCommType == TRUE) if (gWirelessCommType == TRUE)
{
return IsLinkRfuTaskFinished(); return IsLinkRfuTaskFinished();
}
return gLinkCallback == NULL; return gLinkCallback == NULL;
} }
u8 GetBlockReceivedStatus(void) u8 GetBlockReceivedStatus(void)
{ {
if (gWirelessCommType == TRUE) if (gWirelessCommType == TRUE)
{
return Rfu_GetBlockReceivedStatus(); return Rfu_GetBlockReceivedStatus();
}
return (gBlockReceivedStatus[3] << 3) | (gBlockReceivedStatus[2] << 2) | (gBlockReceivedStatus[1] << 1) | (gBlockReceivedStatus[0] << 0); return (gBlockReceivedStatus[3] << 3) | (gBlockReceivedStatus[2] << 2) | (gBlockReceivedStatus[1] << 1) | (gBlockReceivedStatus[0] << 0);
} }
static void SetBlockReceivedFlag(u8 who) static void SetBlockReceivedFlag(u8 who)
{ {
if (gWirelessCommType == TRUE) if (gWirelessCommType == TRUE)
{
Rfu_SetBlockReceivedFlag(who); Rfu_SetBlockReceivedFlag(who);
}
else else
{
gBlockReceivedStatus[who] = TRUE; gBlockReceivedStatus[who] = TRUE;
}
} }
void ResetBlockReceivedFlags(void) void ResetBlockReceivedFlags(void)
@@ -1119,16 +1090,12 @@ void ResetBlockReceivedFlags(void)
if (gWirelessCommType == TRUE) if (gWirelessCommType == TRUE)
{ {
for (i = 0; i < MAX_RFU_PLAYERS; i++) for (i = 0; i < MAX_RFU_PLAYERS; i++)
{
Rfu_ResetBlockReceivedFlag(i); Rfu_ResetBlockReceivedFlag(i);
}
} }
else else
{ {
for (i = 0; i < MAX_LINK_PLAYERS; i++) for (i = 0; i < MAX_LINK_PLAYERS; i++)
{
gBlockReceivedStatus[i] = FALSE; gBlockReceivedStatus[i] = FALSE;
}
} }
} }
@@ -1147,9 +1114,7 @@ void ResetBlockReceivedFlag(u8 who)
void CheckShouldAdvanceLinkState(void) void CheckShouldAdvanceLinkState(void)
{ {
if ((gLinkStatus & LINK_STAT_MASTER) && EXTRACT_PLAYER_COUNT(gLinkStatus) > 1) if ((gLinkStatus & LINK_STAT_MASTER) && EXTRACT_PLAYER_COUNT(gLinkStatus) > 1)
{
gShouldAdvanceLinkState = 1; gShouldAdvanceLinkState = 1;
}
} }
static u16 LinkTestCalcBlockChecksum(const u16 *src, u16 size) static u16 LinkTestCalcBlockChecksum(const u16 *src, u16 size)
@@ -1159,92 +1124,90 @@ static u16 LinkTestCalcBlockChecksum(const u16 *src, u16 size)
chksum = 0; chksum = 0;
for (i = 0; i < size / 2; i++) for (i = 0; i < size / 2; i++)
{
chksum += src[i]; chksum += src[i];
}
return chksum; return chksum;
} }
static void LinkTest_prnthexchar(char a0, u8 a1, u8 a2) static void LinkTest_PrintNumChar(char val, u8 x, u8 y)
{ {
u16 *vAddr; u16 *vAddr;
vAddr = (u16 *)BG_SCREEN_ADDR(gLinkTestBGInfo.screenBaseBlock); vAddr = (u16 *)BG_SCREEN_ADDR(gLinkTestBGInfo.screenBaseBlock);
vAddr[a2 * 32 + a1] = (gLinkTestBGInfo.paletteNum << 12) | (a0 + 1 + gLinkTestBGInfo.dummy_8); vAddr[y * 32 + x] = (gLinkTestBGInfo.paletteNum << 12) | (val + 1 + gLinkTestBGInfo.baseChar);
} }
static void LinkTest_prntchar(char a0, u8 a1, u8 a2) static void LinkTest_PrintChar(char val, u8 x, u8 y)
{ {
u16 *vAddr; u16 *vAddr;
vAddr = (u16 *)BG_SCREEN_ADDR(gLinkTestBGInfo.screenBaseBlock); vAddr = (u16 *)BG_SCREEN_ADDR(gLinkTestBGInfo.screenBaseBlock);
vAddr[a2 * 32 + a1] = (gLinkTestBGInfo.paletteNum << 12) | (a0 + gLinkTestBGInfo.dummy_8); vAddr[y * 32 + x] = (gLinkTestBGInfo.paletteNum << 12) | (val + gLinkTestBGInfo.baseChar);
} }
static void LinkTest_prnthex(u32 pos, u8 a0, u8 a1, u8 a2) static void LinkTest_PrintHex(u32 num, u8 x, u8 y, u8 length)
{ {
char sp[32 / 2]; char buff[16];
int i; int i;
for (i = 0; i < a2; i++) for (i = 0; i < length; i++)
{ {
sp[i] = pos & 0xf; buff[i] = num & 0xF;
pos >>= 4; num >>= 4;
} }
for (i = a2 - 1; i >= 0; i--) for (i = length - 1; i >= 0; i--)
{ {
LinkTest_prnthexchar(sp[i], a0, a1); LinkTest_PrintNumChar(buff[i], x, y);
a0++; x++;
} }
} }
static void LinkTest_prntint(int a0, u8 a1, u8 a2, u8 a3) static void LinkTest_PrintInt(int num, u8 x, u8 y, u8 length)
{ {
char sp[32 / 2]; char buff[16];
int sp10; int negX;
int i; int i;
sp10 = -1; negX = -1;
if (a0 < 0) if (num < 0)
{ {
sp10 = a1; negX = x;
a0 = -a0; num = -num;
} }
for (i = 0; i < a3; i++) for (i = 0; i < length; i++)
{ {
sp[i] = a0 % 10; buff[i] = num % 10;
a0 /= 10; num /= 10;
} }
for (i = a3 - 1; i >= 0; i--) for (i = length - 1; i >= 0; i--)
{ {
LinkTest_prnthexchar(sp[i], a1, a2); LinkTest_PrintNumChar(buff[i], x, y);
a1++; x++;
}
if (sp10 != -1)
{
LinkTest_prnthexchar(*"\n", sp10, a2);
} }
if (negX != -1)
LinkTest_PrintNumChar(*"\n", negX, y);
} }
static void LinkTest_prntstr(const char *a0, u8 a1, u8 a2) static void LinkTest_PrintString(const char *str, u8 x, u8 y)
{ {
int r6; int xOffset;
int i; int i;
int r5; int yOffset;
r5 = 0; yOffset = 0;
r6 = 0; xOffset = 0;
for (i = 0; a0[i] != 0; a0++) for (i = 0; str[i] != 0; str++)
{ {
if (a0[i] == *"\n") if (str[i] == *"\n")
{ {
r5++; yOffset++;
r6 = 0; xOffset = 0;
} }
else else
{ {
LinkTest_prntchar(a0[i], a1 + r6, a2 + r5); LinkTest_PrintChar(str[i], x + xOffset, y + yOffset);
r6++; xOffset++;
} }
} }
} }
@@ -1260,29 +1223,28 @@ static void LinkCB_RequestPlayerDataExchange(void)
static void Task_PrintTestData(u8 taskId) static void Task_PrintTestData(u8 taskId)
{ {
char sp[32]; char testTitle[32];
int i; int i;
strcpy(sp, sASCIITestPrint); strcpy(testTitle, sASCIITestPrint);
LinkTest_prntstr(sp, 5, 2); LinkTest_PrintString(testTitle, 5, 2);
LinkTest_prnthex(gShouldAdvanceLinkState, 2, 1, 2); LinkTest_PrintHex(gShouldAdvanceLinkState, 2, 1, 2);
LinkTest_prnthex(gLinkStatus, 15, 1, 8); LinkTest_PrintHex(gLinkStatus, 15, 1, 8);
LinkTest_prnthex(gLink.state, 2, 10, 2); LinkTest_PrintHex(gLink.state, 2, 10, 2);
LinkTest_prnthex(EXTRACT_PLAYER_COUNT(gLinkStatus), 15, 10, 2); LinkTest_PrintHex(EXTRACT_PLAYER_COUNT(gLinkStatus), 15, 10, 2);
LinkTest_prnthex(GetMultiplayerId(), 15, 12, 2); LinkTest_PrintHex(GetMultiplayerId(), 15, 12, 2);
LinkTest_prnthex(gLastSendQueueCount, 25, 1, 2); LinkTest_PrintHex(gLastSendQueueCount, 25, 1, 2);
LinkTest_prnthex(gLastRecvQueueCount, 25, 2, 2); LinkTest_PrintHex(gLastRecvQueueCount, 25, 2, 2);
LinkTest_prnthex(GetBlockReceivedStatus(), 15, 5, 2); LinkTest_PrintHex(GetBlockReceivedStatus(), 15, 5, 2);
LinkTest_prnthex(gLinkDebugSeed, 2, 12, 8); LinkTest_PrintHex(gLinkDebugSeed, 2, 12, 8);
LinkTest_prnthex(gLinkDebugFlags, 2, 13, 8); LinkTest_PrintHex(gLinkDebugFlags, 2, 13, 8);
LinkTest_prnthex(GetSioMultiSI(), 25, 5, 1); LinkTest_PrintHex(GetSioMultiSI(), 25, 5, 1);
LinkTest_prnthex(IsSioMultiMaster(), 25, 6, 1); LinkTest_PrintHex(IsSioMultiMaster(), 25, 6, 1);
LinkTest_prnthex(IsLinkConnectionEstablished(), 25, 7, 1); LinkTest_PrintHex(IsLinkConnectionEstablished(), 25, 7, 1);
LinkTest_prnthex(HasLinkErrorOccurred(), 25, 8, 1); LinkTest_PrintHex(HasLinkErrorOccurred(), 25, 8, 1);
for (i = 0; i < MAX_LINK_PLAYERS; i++) for (i = 0; i < MAX_LINK_PLAYERS; i++)
{ LinkTest_PrintHex(gLinkTestBlockChecksums[i], 10, 4 + i, 4);
LinkTest_prnthex(gLinkTestBlockChecksums[i], 10, 4 + i, 4);
}
} }
void SetLinkDebugValues(u32 seed, u32 flags) void SetLinkDebugValues(u32 seed, u32 flags)
@@ -1298,9 +1260,8 @@ u8 GetSavedLinkPlayerCountAsBitFlags(void)
flags = 0; flags = 0;
for (i = 0; i < gSavedLinkPlayerCount; i++) for (i = 0; i < gSavedLinkPlayerCount; i++)
{
flags |= (1 << i); flags |= (1 << i);
}
return flags; return flags;
} }
@@ -1311,9 +1272,8 @@ u8 GetLinkPlayerCountAsBitFlags(void)
flags = 0; flags = 0;
for (i = 0; i < GetLinkPlayerCount(); i++) for (i = 0; i < GetLinkPlayerCount(); i++)
{
flags |= (1 << i); flags |= (1 << i);
}
return flags; return flags;
} }
@@ -1324,9 +1284,7 @@ void SaveLinkPlayers(u8 playerCount)
gSavedLinkPlayerCount = playerCount; gSavedLinkPlayerCount = playerCount;
gSavedMultiplayerId = GetMultiplayerId(); gSavedMultiplayerId = GetMultiplayerId();
for (i = 0; i < MAX_RFU_PLAYERS; i++) for (i = 0; i < MAX_RFU_PLAYERS; i++)
{ sSavedLinkPlayers[i] = gLinkPlayers[i];
gSavedLinkPlayers[i] = gLinkPlayers[i];
}
} }
// The number of players when trading began. This is frequently compared against the // The number of players when trading began. This is frequently compared against the
@@ -1349,7 +1307,7 @@ bool8 DoesLinkPlayerCountMatchSaved(void)
for (i = 0; i < gSavedLinkPlayerCount; i++) for (i = 0; i < gSavedLinkPlayerCount; i++)
{ {
if (gLinkPlayers[i].trainerId == gSavedLinkPlayers[i].trainerId) if (gLinkPlayers[i].trainerId == sSavedLinkPlayers[i].trainerId)
{ {
if (gLinkType == LINKTYPE_BATTLE_TOWER) if (gLinkType == LINKTYPE_BATTLE_TOWER)
{ {
@@ -1375,12 +1333,15 @@ bool8 DoesLinkPlayerCountMatchSaved(void)
void ClearSavedLinkPlayers(void) void ClearSavedLinkPlayers(void)
{ {
int i; int i;
// The CpuSet loop below is incorrectly writing to NULL
// Clearly not what was meant to be written, but here it is anyway. // instead of sSavedLinkPlayers.
for (i = 0; i < 4; i++) // Additionally it's using the wrong array size.
{ #ifdef UBFIX
CpuSet(&gSavedLinkPlayers[i], NULL, sizeof(struct LinkPlayer)); memset(sSavedLinkPlayers, 0, sizeof(sSavedLinkPlayers));
} #else
for (i = 0; i < MAX_LINK_PLAYERS; i++)
CpuSet(&sSavedLinkPlayers[i], NULL, sizeof(struct LinkPlayer));
#endif
} }
void CheckLinkPlayersMatchSaved(void) void CheckLinkPlayersMatchSaved(void)
@@ -1389,8 +1350,8 @@ void CheckLinkPlayersMatchSaved(void)
for (i = 0; i < gSavedLinkPlayerCount; i++) for (i = 0; i < gSavedLinkPlayerCount; i++)
{ {
if (gSavedLinkPlayers[i].trainerId != gLinkPlayers[i].trainerId if (sSavedLinkPlayers[i].trainerId != gLinkPlayers[i].trainerId
|| StringCompare(gSavedLinkPlayers[i].name, gLinkPlayers[i].name) != 0) || StringCompare(sSavedLinkPlayers[i].name, gLinkPlayers[i].name) != 0)
{ {
gLinkErrorOccurred = TRUE; gLinkErrorOccurred = TRUE;
CloseLink(); CloseLink();
@@ -1413,9 +1374,8 @@ u8 GetLinkPlayerCount_2(void)
bool8 IsLinkMaster(void) bool8 IsLinkMaster(void)
{ {
if (gWirelessCommType) if (gWirelessCommType)
{
return Rfu_IsMaster(); return Rfu_IsMaster();
}
return EXTRACT_MASTER(gLinkStatus); return EXTRACT_MASTER(gLinkStatus);
} }
@@ -1568,9 +1528,8 @@ void SetLinkStandbyCallback(void)
else else
{ {
if (gLinkCallback == NULL) if (gLinkCallback == NULL)
{
gLinkCallback = LinkCB_Standby; gLinkCallback = LinkCB_Standby;
}
gLinkDummy1 = FALSE; gLinkDummy1 = FALSE;
} }
} }
@@ -1606,7 +1565,7 @@ static void LinkCB_StandbyForAll(void)
static void CheckErrorStatus(void) static void CheckErrorStatus(void)
{ {
if (gLinkOpen && EXTRACT_LINK_ERRORS(gLinkStatus)) if (sLinkOpen && EXTRACT_LINK_ERRORS(gLinkStatus))
{ {
if (!gSuppressLinkErrorMessage) if (!gSuppressLinkErrorMessage)
{ {
@@ -1620,12 +1579,12 @@ static void CheckErrorStatus(void)
} }
} }
void BufferLinkErrorInfo(u32 status, u8 lastSendQueueCount, u8 lastRecvQueueCount, bool8 unk_06) void BufferLinkErrorInfo(u32 status, u8 lastSendQueueCount, u8 lastRecvQueueCount, bool8 disconnected)
{ {
sLinkErrorBuffer.status = status; sLinkErrorBuffer.status = status;
sLinkErrorBuffer.lastSendQueueCount = lastSendQueueCount; sLinkErrorBuffer.lastSendQueueCount = lastSendQueueCount;
sLinkErrorBuffer.lastRecvQueueCount = lastRecvQueueCount; sLinkErrorBuffer.lastRecvQueueCount = lastRecvQueueCount;
sLinkErrorBuffer.unk_06 = unk_06; sLinkErrorBuffer.disconnected = disconnected;
} }
void CB2_LinkError(void) void CB2_LinkError(void)
@@ -1645,16 +1604,15 @@ void CB2_LinkError(void)
ScanlineEffect_Stop(); ScanlineEffect_Stop();
if (gWirelessCommType) if (gWirelessCommType)
{ {
if (!sLinkErrorBuffer.unk_06) if (!sLinkErrorBuffer.disconnected)
{
gWirelessCommType = 3; gWirelessCommType = 3;
}
ResetLinkRfuGFLayer(); ResetLinkRfuGFLayer();
} }
SetVBlankCallback(VBlankCB_LinkError); SetVBlankCallback(VBlankCB_LinkError);
ResetBgsAndClearDma3BusyFlags(0); ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, sLinkErrorBgTemplates, ARRAY_COUNT(sLinkErrorBgTemplates)); InitBgsFromTemplates(0, sLinkErrorBgTemplates, ARRAY_COUNT(sLinkErrorBgTemplates));
sLinkErrorBgTilemapBuffer = tilemapBuffer = malloc(0x800); sLinkErrorBgTilemapBuffer = tilemapBuffer = malloc(BG_SCREEN_SIZE);
SetBgTilemapBuffer(1, tilemapBuffer); SetBgTilemapBuffer(1, tilemapBuffer);
if (InitWindows(sLinkErrorWindowTemplates)) if (InitWindows(sLinkErrorWindowTemplates))
{ {
@@ -1714,14 +1672,16 @@ static void CB2_PrintErrorMessage(void)
switch (gMain.state) switch (gMain.state)
{ {
case 00: case 00:
if (sLinkErrorBuffer.unk_06) // Below is only true for the RFU, so the other error
// type is inferred to be from a wired connection
if (sLinkErrorBuffer.disconnected)
ErrorMsg_MoveCloserToPartner(); ErrorMsg_MoveCloserToPartner();
else else
ErrorMsg_CheckConnections(); ErrorMsg_CheckConnections();
break; break;
case 02: case 02:
ShowBg(0); ShowBg(0);
if (sLinkErrorBuffer.unk_06) if (sLinkErrorBuffer.disconnected)
ShowBg(1); ShowBg(1);
break; break;
case 30: case 30:
@@ -1748,7 +1708,7 @@ static void CB2_PrintErrorMessage(void)
{ {
PlaySE(SE_PIN); PlaySE(SE_PIN);
gWirelessCommType = 0; gWirelessCommType = 0;
sLinkErrorBuffer.unk_06 = 0; sLinkErrorBuffer.disconnected = FALSE;
sub_81700F8(); sub_81700F8();
} }
} }
@@ -1762,10 +1722,9 @@ static void CB2_PrintErrorMessage(void)
} }
} }
} }
if (gMain.state != 160) if (gMain.state != 160)
{
gMain.state++; gMain.state++;
}
} }
// TODO: there might be a file boundary here, let's name it // TODO: there might be a file boundary here, let's name it
@@ -1795,7 +1754,7 @@ bool8 HasLinkErrorOccurred(void)
return gLinkErrorOccurred; return gLinkErrorOccurred;
} }
void sub_800B348(void) void LocalLinkPlayerToBlock(void)
{ {
struct LinkPlayerBlock *block; struct LinkPlayerBlock *block;
@@ -1816,11 +1775,11 @@ void LinkPlayerFromBlock(u32 who)
block = (struct LinkPlayerBlock *)gBlockRecvBuffer[who_]; block = (struct LinkPlayerBlock *)gBlockRecvBuffer[who_];
player = &gLinkPlayers[who_]; player = &gLinkPlayers[who_];
*player = block->linkPlayer; *player = block->linkPlayer;
sub_800B524(player); ConvertLinkPlayerName(player);
if (strcmp(block->magic1, sASCIIGameFreakInc) != 0 || strcmp(block->magic2, sASCIIGameFreakInc) != 0)
{ if (strcmp(block->magic1, sASCIIGameFreakInc) != 0
|| strcmp(block->magic2, sASCIIGameFreakInc) != 0)
SetMainCallback2(CB2_LinkError); SetMainCallback2(CB2_LinkError);
}
} }
bool8 HandleLinkConnection(void) bool8 HandleLinkConnection(void)
@@ -1833,9 +1792,7 @@ bool8 HandleLinkConnection(void)
gLinkStatus = LinkMain1(&gShouldAdvanceLinkState, gSendCmd, gRecvCmds); gLinkStatus = LinkMain1(&gShouldAdvanceLinkState, gSendCmd, gRecvCmds);
LinkMain2(&gMain.heldKeys); LinkMain2(&gMain.heldKeys);
if ((gLinkStatus & LINK_STAT_RECEIVED_NOTHING) && IsSendingKeysOverCable() == TRUE) if ((gLinkStatus & LINK_STAT_RECEIVED_NOTHING) && IsSendingKeysOverCable() == TRUE)
{
return TRUE; return TRUE;
}
} }
else else
{ {
@@ -1844,9 +1801,7 @@ bool8 HandleLinkConnection(void)
if (IsSendingKeysOverCable() == TRUE) if (IsSendingKeysOverCable() == TRUE)
{ {
if (r4 == TRUE || IsRfuRecvQueueEmpty() || r5) if (r4 == TRUE || IsRfuRecvQueueEmpty() || r5)
{
return TRUE; return TRUE;
}
} }
} }
return FALSE; return FALSE;
@@ -1855,42 +1810,34 @@ bool8 HandleLinkConnection(void)
void SetWirelessCommType1(void) void SetWirelessCommType1(void)
{ {
if (gReceivedRemoteLinkPlayers == 0) if (gReceivedRemoteLinkPlayers == 0)
{
gWirelessCommType = 1; gWirelessCommType = 1;
}
} }
static void SetWirelessCommType0_Internal(void) static void SetWirelessCommType0_Internal(void)
{ {
if (gReceivedRemoteLinkPlayers == 0) if (gReceivedRemoteLinkPlayers == 0)
{
gWirelessCommType = 0; gWirelessCommType = 0;
}
} }
void SetWirelessCommType0(void) void SetWirelessCommType0(void)
{ {
if (gReceivedRemoteLinkPlayers == 0) if (gReceivedRemoteLinkPlayers == 0)
{
gWirelessCommType = 0; gWirelessCommType = 0;
}
} }
u32 GetLinkRecvQueueLength(void) u32 GetLinkRecvQueueLength(void)
{ {
if (gWirelessCommType != 0) if (gWirelessCommType != 0)
{
return GetRfuRecvQueueLength(); return GetRfuRecvQueueLength();
}
return gLink.recvQueue.count; return gLink.recvQueue.count;
} }
bool32 sub_800B504(void) bool32 IsLinkRecvQueueLengthAtLeast3(void)
{ {
if (GetLinkRecvQueueLength() > 2) if (GetLinkRecvQueueLength() > 2)
{
return TRUE; return TRUE;
}
return FALSE; return FALSE;
} }
@@ -1900,9 +1847,9 @@ u8 GetWirelessCommType(void)
return gWirelessCommType; return gWirelessCommType;
} }
void sub_800B524(struct LinkPlayer *player) void ConvertLinkPlayerName(struct LinkPlayer *player)
{ {
player->progressFlagsCopy = player->progressFlags; player->progressFlagsCopy = player->progressFlags; // ? Perhaps relocating for a longer name field
ConvertInternationalString(player->name, player->language); ConvertInternationalString(player->name, player->language);
} }
@@ -2410,9 +2357,7 @@ void ResetSendBuffer(void)
for (i = 0; i < CMD_LENGTH; i++) for (i = 0; i < CMD_LENGTH; i++)
{ {
for (j = 0; j < QUEUE_CAPACITY; j++) for (j = 0; j < QUEUE_CAPACITY; j++)
{ gLink.sendQueue.data[i][j] = LINKCMD_NONE;
gLink.sendQueue.data[i][j] = 0xEFFF;
}
} }
} }
@@ -2429,9 +2374,7 @@ void ResetRecvBuffer(void)
for (j = 0; j < CMD_LENGTH; j++) for (j = 0; j < CMD_LENGTH; j++)
{ {
for (k = 0; k < QUEUE_CAPACITY; k++) for (k = 0; k < QUEUE_CAPACITY; k++)
{ gLink.recvQueue.data[i][j][k] = LINKCMD_NONE;
gLink.recvQueue.data[i][j][k] = 0xEFFF;
}
} }
} }
} }
+4 -4
View File
@@ -1697,7 +1697,7 @@ static void sub_801084C(u8 taskId)
if (AreNoPlayersReceiving()) if (AreNoPlayersReceiving())
{ {
ResetBlockReceivedFlags(); ResetBlockReceivedFlags();
sub_800B348(); LocalLinkPlayerToBlock();
gTasks[taskId].data[0]++; gTasks[taskId].data[0]++;
} }
break; break;
@@ -1786,7 +1786,7 @@ static void ReceiveRfuLinkPlayers(const struct SioInfo *sioInfo)
for (i = 0; i < MAX_RFU_PLAYERS; i++) for (i = 0; i < MAX_RFU_PLAYERS; i++)
{ {
gLinkPlayers[i] = sioInfo->linkPlayers[i]; gLinkPlayers[i] = sioInfo->linkPlayers[i];
sub_800B524(gLinkPlayers + i); ConvertLinkPlayerName(gLinkPlayers + i);
} }
} }
@@ -1831,7 +1831,7 @@ static void Task_ExchangeLinkPlayers(u8 taskId)
ResetBlockReceivedFlag(r4); ResetBlockReceivedFlag(r4);
r2 = (struct LinkPlayerBlock *)gBlockRecvBuffer[r4]; r2 = (struct LinkPlayerBlock *)gBlockRecvBuffer[r4];
gLinkPlayers[r4] = r2->linkPlayer; gLinkPlayers[r4] = r2->linkPlayer;
sub_800B524(gLinkPlayers + r4); ConvertLinkPlayerName(gLinkPlayers + r4);
gTasks[taskId].data[0]++; gTasks[taskId].data[0]++;
} }
break; break;
@@ -1887,7 +1887,7 @@ static void sub_8010D0C(u8 taskId)
case 0: case 0:
if (Rfu.playerCount) if (Rfu.playerCount)
{ {
sub_800B348(); LocalLinkPlayerToBlock();
SendBlock(0, gBlockSendBuffer, sizeof(struct LinkPlayerBlock)); SendBlock(0, gBlockSendBuffer, sizeof(struct LinkPlayerBlock));
gTasks[taskId].data[0]++; gTasks[taskId].data[0]++;
} }
+8 -11
View File
@@ -1616,6 +1616,9 @@ void ply_xcmd_0C(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *tra
void ply_xcmd_0D(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track) void ply_xcmd_0D(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{ {
u32 unk; u32 unk;
#ifdef UBFIX
unk = 0;
#endif
READ_XCMD_BYTE(unk, 0) // UB: uninitialized variable READ_XCMD_BYTE(unk, 0) // UB: uninitialized variable
READ_XCMD_BYTE(unk, 1) READ_XCMD_BYTE(unk, 1)
@@ -1657,18 +1660,12 @@ start_song:
mplayInfo = &gPokemonCryMusicPlayers[i]; mplayInfo = &gPokemonCryMusicPlayers[i];
mplayInfo->ident++; mplayInfo->ident++;
#define CRY ((s32)&gPokemonCrySongs + i * sizeof(struct PokemonCrySong)) gPokemonCrySongs[i] = gPokemonCrySong;
#define CRY_OFS(field) offsetof(struct PokemonCrySong, field)
memcpy((void *)CRY, &gPokemonCrySong, sizeof(struct PokemonCrySong)); gPokemonCrySongs[i].tone = tone;
gPokemonCrySongs[i].part[0] = &gPokemonCrySongs[i].part0;
*(u32 *)(CRY + CRY_OFS(tone)) = (u32)tone; gPokemonCrySongs[i].part[1] = &gPokemonCrySongs[i].part1;
*(u32 *)(CRY + CRY_OFS(part)) = CRY + CRY_OFS(part0); gPokemonCrySongs[i].gotoTarget = (u32)&gPokemonCrySongs[i].cont;
*(u32 *)(CRY + CRY_OFS(part) + 4) = CRY + CRY_OFS(part1);
*(u32 *)(CRY + CRY_OFS(gotoTarget)) = CRY + CRY_OFS(cont);
#undef CRY_OFS
#undef CRY
mplayInfo->ident = ID_NUMBER; mplayInfo->ident = ID_NUMBER;
+30 -18
View File
@@ -197,8 +197,8 @@ static const u8 * const gBattlePyramid_MapHeaderStrings[] =
gText_Pyramid, gText_Pyramid,
}; };
// text // Unused
bool8 sub_80D47D4(void) static bool8 StartMenu_ShowMapNamePopup(void)
{ {
HideStartMenu(); HideStartMenu();
ShowMapNamePopup(); ShowMapNamePopup();
@@ -333,24 +333,36 @@ static void ShowMapNamePopUpWindow(void)
CopyWindowToVram(GetMapNamePopUpWindowId(), 3); CopyWindowToVram(GetMapNamePopUpWindowId(), 3);
} }
static void sub_80D4A78(u8 bg, u8 x, u8 y, u8 deltaX, u8 deltaY, u8 unused) #define TILE_TOP_EDGE_START 0x21D
#define TILE_TOP_EDGE_END 0x228
#define TILE_LEFT_EDGE_TOP 0x229
#define TILE_RIGHT_EDGE_TOP 0x22A
#define TILE_LEFT_EDGE_MID 0x22B
#define TILE_RIGHT_EDGE_MID 0x22C
#define TILE_LEFT_EDGE_BOT 0x22D
#define TILE_RIGHT_EDGE_BOT 0x22E
#define TILE_BOT_EDGE_START 0x22F
#define TILE_BOT_EDGE_END 0x23A
static void DrawMapNamePopUpFrame(u8 bg, u8 x, u8 y, u8 deltaX, u8 deltaY, u8 unused)
{ {
s32 i; s32 i;
for (i = 0; i < 12; i++) // Draw top edge
{ for (i = 0; i < 1 + TILE_TOP_EDGE_END - TILE_TOP_EDGE_START; i++)
FillBgTilemapBufferRect(bg, 0x21D + i, i - 1 + x, y - 1, 1, 1, 0xE); FillBgTilemapBufferRect(bg, TILE_TOP_EDGE_START + i, i - 1 + x, y - 1, 1, 1, 14);
}
FillBgTilemapBufferRect(bg, 0x229, x - 1, y, 1, 1, 0xE); // Draw sides
FillBgTilemapBufferRect(bg, 0x22A, deltaX + x, y, 1, 1, 0xE); FillBgTilemapBufferRect(bg, TILE_LEFT_EDGE_TOP, x - 1, y, 1, 1, 14);
FillBgTilemapBufferRect(bg, 0x22B, x - 1, y + 1 , 1, 1, 0xE); FillBgTilemapBufferRect(bg, TILE_RIGHT_EDGE_TOP, deltaX + x, y, 1, 1, 14);
FillBgTilemapBufferRect(bg, 0x22C, deltaX + x, y + 1, 1, 1, 0xE); FillBgTilemapBufferRect(bg, TILE_LEFT_EDGE_MID, x - 1, y + 1, 1, 1, 14);
FillBgTilemapBufferRect(bg, 0x22D, x - 1, y + 2, 1, 1, 0xE); FillBgTilemapBufferRect(bg, TILE_RIGHT_EDGE_MID, deltaX + x, y + 1, 1, 1, 14);
FillBgTilemapBufferRect(bg, 0x22E, deltaX + x, y + 2, 1, 1, 0xE); FillBgTilemapBufferRect(bg, TILE_LEFT_EDGE_BOT, x - 1, y + 2, 1, 1, 14);
for (i = 0; i < 12; i++) FillBgTilemapBufferRect(bg, TILE_RIGHT_EDGE_BOT, deltaX + x, y + 2, 1, 1, 14);
{
FillBgTilemapBufferRect(bg, 0x22F + i, i - 1 + x, y + deltaY, 1, 1, 0xE); // Draw bottom edge
} for (i = 0; i < 1 + TILE_BOT_EDGE_END - TILE_BOT_EDGE_START; i++)
FillBgTilemapBufferRect(bg, TILE_BOT_EDGE_START + i, i - 1 + x, y + deltaY, 1, 1, 14);
} }
static void LoadMapNamePopUpWindowBg(void) static void LoadMapNamePopUpWindowBg(void)
@@ -369,7 +381,7 @@ static void LoadMapNamePopUpWindowBg(void)
popUpThemeId = gRegionMapSectionId_To_PopUpThemeIdMapping[regionMapSectionId]; popUpThemeId = gRegionMapSectionId_To_PopUpThemeIdMapping[regionMapSectionId];
LoadBgTiles(GetWindowAttribute(popupWindowId, WINDOW_BG), gMapPopUp_Outline_Table[popUpThemeId], 0x400, 0x21D); LoadBgTiles(GetWindowAttribute(popupWindowId, WINDOW_BG), gMapPopUp_Outline_Table[popUpThemeId], 0x400, 0x21D);
CallWindowFunction(popupWindowId, sub_80D4A78); CallWindowFunction(popupWindowId, DrawMapNamePopUpFrame);
PutWindowTilemap(popupWindowId); PutWindowTilemap(popupWindowId);
if (gMapHeader.weather == WEATHER_UNDERWATER_BUBBLES) if (gMapHeader.weather == WEATHER_UNDERWATER_BUBBLES)
LoadPalette(&gUnknown_0857F444, 0xE0, 0x20); LoadPalette(&gUnknown_0857F444, 0xE0, 0x20);
+9 -9
View File
@@ -425,21 +425,21 @@ static void StartBardSong(bool8 useTemporaryLyrics)
gTasks[taskId].tUseTemporaryLyrics = useTemporaryLyrics; gTasks[taskId].tUseTemporaryLyrics = useTemporaryLyrics;
} }
static void sub_81206F0(void) static void EnableTextPrinters(void)
{ {
gUnknown_03002F84 = FALSE; gDisableTextPrinters = FALSE;
} }
static void BardSong_TextSubPrinter(struct TextPrinterTemplate * printer, u16 a1) static void BardSong_DisableTextPrinters(struct TextPrinterTemplate * printer, u16 a1)
{ {
gUnknown_03002F84 = TRUE; gDisableTextPrinters = TRUE;
} }
static void sub_8120708(const u8 * src) static void sub_8120708(const u8 * src)
{ {
DrawDialogueFrame(0, 0); DrawDialogueFrame(0, 0);
AddTextPrinterParameterized(0, 1, src, 0, 1, 1, BardSong_TextSubPrinter); AddTextPrinterParameterized(0, 1, src, 0, 1, 1, BardSong_DisableTextPrinters);
gUnknown_03002F84 = TRUE; gDisableTextPrinters = TRUE;
CopyWindowToVram(0, 3); CopyWindowToVram(0, 3);
} }
@@ -620,7 +620,7 @@ static void Task_BardSong(u8 taskId)
else if (gStringVar4[task->tCharIndex] == CHAR_SPACE) else if (gStringVar4[task->tCharIndex] == CHAR_SPACE)
{ {
sub_81206F0(); EnableTextPrinters();
task->tCharIndex++; task->tCharIndex++;
task->tState = 2; task->tState = 2;
task->data[2] = 0; task->data[2] = 0;
@@ -640,7 +640,7 @@ static void Task_BardSong(u8 taskId)
else if (gStringVar4[task->tCharIndex] == CHAR_SONG_WORD_SEPARATOR) else if (gStringVar4[task->tCharIndex] == CHAR_SONG_WORD_SEPARATOR)
{ {
gStringVar4[task->tCharIndex] = CHAR_SPACE; // restore it back to a space gStringVar4[task->tCharIndex] = CHAR_SPACE; // restore it back to a space
sub_81206F0(); EnableTextPrinters();
task->tCharIndex++; task->tCharIndex++;
task->data[2] = 0; task->data[2] = 0;
} }
@@ -649,7 +649,7 @@ static void Task_BardSong(u8 taskId)
switch (task->data[1]) switch (task->data[1])
{ {
case 0: case 0:
sub_81206F0(); EnableTextPrinters();
task->data[1]++; task->data[1]++;
break; break;
case 1: case 1:
+1 -1
View File
@@ -319,7 +319,7 @@ bool8 MenuHelpers_CallLinkSomething(void)
{ {
if (sub_81221D0() == TRUE) if (sub_81221D0() == TRUE)
return TRUE; return TRUE;
else if (sub_800B504() != TRUE) else if (IsLinkRecvQueueLengthAtLeast3() != TRUE)
return FALSE; return FALSE;
else else
return TRUE; return TRUE;
+4 -4
View File
@@ -48,8 +48,8 @@ static void Task_StaticCountdown_Free(u8 taskId);
static void Task_StaticCountdown_Start(u8 taskId); static void Task_StaticCountdown_Start(u8 taskId);
static void Task_StaticCountdown_Run(u8 taskId); static void Task_StaticCountdown_Run(u8 taskId);
static const u16 s321Start_Static_Pal[] = INCBIN_U16("graphics/link_games/321start_static.gbapal"); static const u16 s321Start_Static_Pal[] = INCBIN_U16("graphics/minigame_countdown/321start_static.gbapal");
static const u32 s321Start_Static_Gfx[] = INCBIN_U32("graphics/link_games/321start_static.4bpp.lz"); static const u32 s321Start_Static_Gfx[] = INCBIN_U32("graphics/minigame_countdown/321start_static.4bpp.lz");
static const struct CompressedSpriteSheet sSpriteSheet_321Start_Static[] = static const struct CompressedSpriteSheet sSpriteSheet_321Start_Static[] =
{ {
@@ -374,8 +374,8 @@ static void CreateStartSprite(u16 tileTag, u16 palTag, s16 x, s16 y, u8 subprior
static void InitStartGraphic(u8 spriteId1, u8 spriteId2, u8 spriteId3); static void InitStartGraphic(u8 spriteId1, u8 spriteId2, u8 spriteId3);
static void SpriteCB_Start(struct Sprite *sprite); static void SpriteCB_Start(struct Sprite *sprite);
static const u16 s321Start_Pal[] = INCBIN_U16("graphics/link_games/321start.gbapal"); static const u16 s321Start_Pal[] = INCBIN_U16("graphics/minigame_countdown/321start.gbapal");
static const u32 s321Start_Gfx[] = INCBIN_U32("graphics/link_games/321start.4bpp.lz"); static const u32 s321Start_Gfx[] = INCBIN_U32("graphics/minigame_countdown/321start.4bpp.lz");
#define tState data[0] #define tState data[0]
#define tTilesTag data[2] #define tTilesTag data[2]
+32 -20
View File
@@ -75,7 +75,7 @@ static u8 ButtonMode_ProcessInput(u8 selection);
static void ButtonMode_DrawChoices(u8 selection); static void ButtonMode_DrawChoices(u8 selection);
static void DrawTextOption(void); static void DrawTextOption(void);
static void DrawOptionMenuTexts(void); static void DrawOptionMenuTexts(void);
static void sub_80BB154(void); static void DrawBgWindowFrames(void);
EWRAM_DATA static bool8 sArrowPressed = FALSE; EWRAM_DATA static bool8 sArrowPressed = FALSE;
@@ -228,7 +228,7 @@ void CB2_InitOptionMenu(void)
DrawOptionMenuTexts(); DrawOptionMenuTexts();
gMain.state++; gMain.state++;
case 9: case 9:
sub_80BB154(); DrawBgWindowFrames();
gMain.state++; gMain.state++;
break; break;
case 10: case 10:
@@ -642,25 +642,37 @@ static void DrawOptionMenuTexts(void)
CopyWindowToVram(WIN_OPTIONS, 3); CopyWindowToVram(WIN_OPTIONS, 3);
} }
static void sub_80BB154(void) #define TILE_TOP_CORNER_L 0x1A2
#define TILE_TOP_EDGE 0x1A3
#define TILE_TOP_CORNER_R 0x1A4
#define TILE_LEFT_EDGE 0x1A5
#define TILE_RIGHT_EDGE 0x1A7
#define TILE_BOT_CORNER_L 0x1A8
#define TILE_BOT_EDGE 0x1A9
#define TILE_BOT_CORNER_R 0x1AA
static void DrawBgWindowFrames(void)
{ {
// bg, tileNum, x, y, width, height, pal // bg, tile, x, y, width, height, palNum
FillBgTilemapBufferRect(1, 0x1A2, 1, 0, 1, 1, 7); // Draw title window frame
FillBgTilemapBufferRect(1, 0x1A3, 2, 0, 0x1B, 1, 7); FillBgTilemapBufferRect(1, TILE_TOP_CORNER_L, 1, 0, 1, 1, 7);
FillBgTilemapBufferRect(1, 0x1A4, 28, 0, 1, 1, 7); FillBgTilemapBufferRect(1, TILE_TOP_EDGE, 2, 0, 27, 1, 7);
FillBgTilemapBufferRect(1, 0x1A5, 1, 1, 1, 2, 7); FillBgTilemapBufferRect(1, TILE_TOP_CORNER_R, 28, 0, 1, 1, 7);
FillBgTilemapBufferRect(1, 0x1A7, 28, 1, 1, 2, 7); FillBgTilemapBufferRect(1, TILE_LEFT_EDGE, 1, 1, 1, 2, 7);
FillBgTilemapBufferRect(1, 0x1A8, 1, 3, 1, 1, 7); FillBgTilemapBufferRect(1, TILE_RIGHT_EDGE, 28, 1, 1, 2, 7);
FillBgTilemapBufferRect(1, 0x1A9, 2, 3, 0x1B, 1, 7); FillBgTilemapBufferRect(1, TILE_BOT_CORNER_L, 1, 3, 1, 1, 7);
FillBgTilemapBufferRect(1, 0x1AA, 28, 3, 1, 1, 7); FillBgTilemapBufferRect(1, TILE_BOT_EDGE, 2, 3, 27, 1, 7);
FillBgTilemapBufferRect(1, 0x1A2, 1, 4, 1, 1, 7); FillBgTilemapBufferRect(1, TILE_BOT_CORNER_R, 28, 3, 1, 1, 7);
FillBgTilemapBufferRect(1, 0x1A3, 2, 4, 0x1A, 1, 7);
FillBgTilemapBufferRect(1, 0x1A4, 28, 4, 1, 1, 7); // Draw options list window frame
FillBgTilemapBufferRect(1, 0x1A5, 1, 5, 1, 0x12, 7); FillBgTilemapBufferRect(1, TILE_TOP_CORNER_L, 1, 4, 1, 1, 7);
FillBgTilemapBufferRect(1, 0x1A7, 28, 5, 1, 0x12, 7); FillBgTilemapBufferRect(1, TILE_TOP_EDGE, 2, 4, 26, 1, 7);
FillBgTilemapBufferRect(1, 0x1A8, 1, 19, 1, 1, 7); FillBgTilemapBufferRect(1, TILE_TOP_CORNER_R, 28, 4, 1, 1, 7);
FillBgTilemapBufferRect(1, 0x1A9, 2, 19, 0x1A, 1, 7); FillBgTilemapBufferRect(1, TILE_LEFT_EDGE, 1, 5, 1, 18, 7);
FillBgTilemapBufferRect(1, 0x1AA, 28, 19, 1, 1, 7); FillBgTilemapBufferRect(1, TILE_RIGHT_EDGE, 28, 5, 1, 18, 7);
FillBgTilemapBufferRect(1, TILE_BOT_CORNER_L, 1, 19, 1, 1, 7);
FillBgTilemapBufferRect(1, TILE_BOT_EDGE, 2, 19, 26, 1, 7);
FillBgTilemapBufferRect(1, TILE_BOT_CORNER_R, 28, 19, 1, 1, 7);
CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(1);
} }
+1 -10
View File
@@ -3032,17 +3032,8 @@ static void SpriteCB_PokedexListMonSprite(struct Sprite *sprite)
else else
{ {
u32 var; u32 var;
sprite->pos2.y = gSineTable[(u8)sprite->data[5]] * 76 / 256; sprite->pos2.y = gSineTable[(u8)sprite->data[5]] * 76 / 256;
// UB: possible division by zero var = SAFE_DIV(0x10000, gSineTable[sprite->data[5] + 64]);
#ifdef UBFIX
if (gSineTable[sprite->data[5] + 64] != 0)
var = 0x10000 / gSineTable[sprite->data[5] + 64];
else
var = 0;
#else
var = 0x10000 / gSineTable[sprite->data[5] + 64];
#endif //UBFIX
if (var > 0xFFFF) if (var > 0xFFFF)
var = 0xFFFF; var = 0xFFFF;
SetOamMatrix(sprite->data[1] + 1, 0x100, 0, 0, var); SetOamMatrix(sprite->data[1] + 1, 0x100, 0, 0, var);
+2 -2
View File
@@ -4649,7 +4649,7 @@ bool8 ExecuteTableBasedItemEffect(struct Pokemon *mon, u16 item, u8 partyIndex,
{ \ { \
friendshipChange = itemEffect[itemEffectParam]; \ friendshipChange = itemEffect[itemEffectParam]; \
friendship = GetMonData(mon, MON_DATA_FRIENDSHIP, NULL); \ friendship = GetMonData(mon, MON_DATA_FRIENDSHIP, NULL); \
if (friendshipChange > 0 && holdEffect == HOLD_EFFECT_HAPPINESS_UP) \ if (friendshipChange > 0 && holdEffect == HOLD_EFFECT_FRIENDSHIP_UP) \
friendship += 150 * friendshipChange / 100; \ friendship += 150 * friendshipChange / 100; \
else \ else \
friendship += friendshipChange; \ friendship += friendshipChange; \
@@ -5828,7 +5828,7 @@ void AdjustFriendship(struct Pokemon *mon, u8 event)
&& (event != FRIENDSHIP_EVENT_LEAGUE_BATTLE || IS_LEAGUE_BATTLE)) && (event != FRIENDSHIP_EVENT_LEAGUE_BATTLE || IS_LEAGUE_BATTLE))
{ {
s8 mod = sFriendshipEventModifiers[event][friendshipLevel]; s8 mod = sFriendshipEventModifiers[event][friendshipLevel];
if (mod > 0 && holdEffect == HOLD_EFFECT_HAPPINESS_UP) if (mod > 0 && holdEffect == HOLD_EFFECT_FRIENDSHIP_UP)
mod = (150 * mod) / 100; mod = (150 * mod) / 100;
friendship += mod; friendship += mod;
if (mod > 0) if (mod > 0)
+130 -131
View File
@@ -40,11 +40,14 @@
#include "constants/songs.h" #include "constants/songs.h"
#include "constants/tv.h" #include "constants/tv.h"
EWRAM_DATA struct MartInfo gMartInfo = {0}; #define TAG_SCROLL_ARROW 2100
EWRAM_DATA struct ShopData *gShopDataPtr = NULL; #define TAG_ITEM_ICON_BASE 2110
EWRAM_DATA struct ListMenuItem *gUnknown_02039F74 = NULL;
EWRAM_DATA u8 (*gUnknown_02039F78)[16] = {0}; static EWRAM_DATA struct MartInfo sMartInfo = {0};
EWRAM_DATA u8 gMartPurchaseHistoryId = 0; static EWRAM_DATA struct ShopData *sShopData = NULL;
static EWRAM_DATA struct ListMenuItem *sListMenuItems = NULL;
static EWRAM_DATA u8 (*sItemNames)[16] = {0};
static EWRAM_DATA u8 sPurchaseHistoryId = 0;
EWRAM_DATA struct ItemSlot gMartPurchaseHistory[3] = {0}; EWRAM_DATA struct ItemSlot gMartPurchaseHistory[3] = {0};
static void Task_ShopMenu(u8 taskId); static void Task_ShopMenu(u8 taskId);
@@ -276,15 +279,15 @@ static u8 CreateShopMenu(u8 martType)
int numMenuItems; int numMenuItems;
ScriptContext2_Enable(); ScriptContext2_Enable();
gMartInfo.martType = martType; sMartInfo.martType = martType;
if (martType == MART_TYPE_NORMAL) if (martType == MART_TYPE_NORMAL)
{ {
struct WindowTemplate winTemplate; struct WindowTemplate winTemplate;
winTemplate = sShopMenuWindowTemplates[0]; winTemplate = sShopMenuWindowTemplates[0];
winTemplate.width = GetMaxWidthInMenuTable(sShopMenuActions_BuySellQuit, ARRAY_COUNT(sShopMenuActions_BuySellQuit)); winTemplate.width = GetMaxWidthInMenuTable(sShopMenuActions_BuySellQuit, ARRAY_COUNT(sShopMenuActions_BuySellQuit));
gMartInfo.windowId = AddWindow(&winTemplate); sMartInfo.windowId = AddWindow(&winTemplate);
gMartInfo.menuActions = sShopMenuActions_BuySellQuit; sMartInfo.menuActions = sShopMenuActions_BuySellQuit;
numMenuItems = ARRAY_COUNT(sShopMenuActions_BuySellQuit); numMenuItems = ARRAY_COUNT(sShopMenuActions_BuySellQuit);
} }
else else
@@ -292,35 +295,35 @@ static u8 CreateShopMenu(u8 martType)
struct WindowTemplate winTemplate; struct WindowTemplate winTemplate;
winTemplate = sShopMenuWindowTemplates[1]; winTemplate = sShopMenuWindowTemplates[1];
winTemplate.width = GetMaxWidthInMenuTable(sShopMenuActions_BuyQuit, ARRAY_COUNT(sShopMenuActions_BuyQuit)); winTemplate.width = GetMaxWidthInMenuTable(sShopMenuActions_BuyQuit, ARRAY_COUNT(sShopMenuActions_BuyQuit));
gMartInfo.windowId = AddWindow(&winTemplate); sMartInfo.windowId = AddWindow(&winTemplate);
gMartInfo.menuActions = sShopMenuActions_BuyQuit; sMartInfo.menuActions = sShopMenuActions_BuyQuit;
numMenuItems = ARRAY_COUNT(sShopMenuActions_BuyQuit); numMenuItems = ARRAY_COUNT(sShopMenuActions_BuyQuit);
} }
SetStandardWindowBorderStyle(gMartInfo.windowId, 0); SetStandardWindowBorderStyle(sMartInfo.windowId, 0);
PrintMenuTable(gMartInfo.windowId, numMenuItems, gMartInfo.menuActions); PrintMenuTable(sMartInfo.windowId, numMenuItems, sMartInfo.menuActions);
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(gMartInfo.windowId, numMenuItems, 0); InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sMartInfo.windowId, numMenuItems, 0);
PutWindowTilemap(gMartInfo.windowId); PutWindowTilemap(sMartInfo.windowId);
CopyWindowToVram(gMartInfo.windowId, 1); CopyWindowToVram(sMartInfo.windowId, 1);
return CreateTask(Task_ShopMenu, 8); return CreateTask(Task_ShopMenu, 8);
} }
static void SetShopMenuCallback(void (* callback)(void)) static void SetShopMenuCallback(void (* callback)(void))
{ {
gMartInfo.callback = callback; sMartInfo.callback = callback;
} }
static void SetShopItemsForSale(const u16 *items) static void SetShopItemsForSale(const u16 *items)
{ {
u16 i = 0; u16 i = 0;
gMartInfo.itemList = items; sMartInfo.itemList = items;
gMartInfo.itemCount = 0; sMartInfo.itemCount = 0;
while (gMartInfo.itemList[i]) while (sMartInfo.itemList[i])
{ {
gMartInfo.itemCount++; sMartInfo.itemCount++;
i++; i++;
} }
} }
@@ -337,7 +340,7 @@ static void Task_ShopMenu(u8 taskId)
Task_HandleShopMenuQuit(taskId); Task_HandleShopMenuQuit(taskId);
break; break;
default: default:
gMartInfo.menuActions[inputCode].func.void_u8(taskId); sMartInfo.menuActions[inputCode].func.void_u8(taskId);
break; break;
} }
} }
@@ -368,14 +371,14 @@ void CB2_ExitSellMenu(void)
static void Task_HandleShopMenuQuit(u8 taskId) static void Task_HandleShopMenuQuit(u8 taskId)
{ {
ClearStdWindowAndFrameToTransparent(gMartInfo.windowId, 2); ClearStdWindowAndFrameToTransparent(sMartInfo.windowId, 2);
RemoveWindow(gMartInfo.windowId); RemoveWindow(sMartInfo.windowId);
SaveRecordedItemPurchasesForTVShow(); SaveRecordedItemPurchasesForTVShow();
ScriptContext2_Disable(); ScriptContext2_Disable();
DestroyTask(taskId); DestroyTask(taskId);
if (gMartInfo.callback) if (sMartInfo.callback)
gMartInfo.callback(); sMartInfo.callback();
} }
static void Task_GoToBuyOrSellMenu(u8 taskId) static void Task_GoToBuyOrSellMenu(u8 taskId)
@@ -398,7 +401,7 @@ static void Task_ReturnToShopMenu(u8 taskId)
{ {
if (IsWeatherNotFadingIn() == TRUE) if (IsWeatherNotFadingIn() == TRUE)
{ {
if (gMartInfo.martType == MART_TYPE_DECOR2) if (sMartInfo.martType == MART_TYPE_DECOR2)
DisplayItemMessageOnField(taskId, gText_CanIHelpWithAnythingElse, ShowShopMenuAfterExitingBuyOrSellMenu); DisplayItemMessageOnField(taskId, gText_CanIHelpWithAnythingElse, ShowShopMenuAfterExitingBuyOrSellMenu);
else else
DisplayItemMessageOnField(taskId, gText_AnythingElseICanHelp, ShowShopMenuAfterExitingBuyOrSellMenu); DisplayItemMessageOnField(taskId, gText_AnythingElseICanHelp, ShowShopMenuAfterExitingBuyOrSellMenu);
@@ -407,7 +410,7 @@ static void Task_ReturnToShopMenu(u8 taskId)
static void ShowShopMenuAfterExitingBuyOrSellMenu(u8 taskId) static void ShowShopMenuAfterExitingBuyOrSellMenu(u8 taskId)
{ {
CreateShopMenu(gMartInfo.martType); CreateShopMenu(sMartInfo.martType);
DestroyTask(taskId); DestroyTask(taskId);
} }
@@ -447,10 +450,10 @@ static void CB2_InitBuyMenu(void)
ResetSpriteData(); ResetSpriteData();
ResetTasks(); ResetTasks();
ClearScheduledBgCopiesToVram(); ClearScheduledBgCopiesToVram();
gShopDataPtr = AllocZeroed(sizeof(struct ShopData)); sShopData = AllocZeroed(sizeof(struct ShopData));
gShopDataPtr->scrollIndicatorsTaskId = TASK_NONE; sShopData->scrollIndicatorsTaskId = TASK_NONE;
gShopDataPtr->itemSpriteIds[0] = SPRITE_NONE; sShopData->itemSpriteIds[0] = SPRITE_NONE;
gShopDataPtr->itemSpriteIds[1] = SPRITE_NONE; sShopData->itemSpriteIds[1] = SPRITE_NONE;
BuyMenuBuildListMenuTemplate(); BuyMenuBuildListMenuTemplate();
BuyMenuInitBgs(); BuyMenuInitBgs();
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20);
@@ -480,9 +483,9 @@ static void CB2_InitBuyMenu(void)
static void BuyMenuFreeMemory(void) static void BuyMenuFreeMemory(void)
{ {
Free(gShopDataPtr); Free(sShopData);
Free(gUnknown_02039F74); Free(sListMenuItems);
Free(gUnknown_02039F78); Free(sItemNames);
FreeAllWindowBuffers(); FreeAllWindowBuffers();
} }
@@ -490,29 +493,29 @@ static void BuyMenuBuildListMenuTemplate(void)
{ {
u16 i; u16 i;
gUnknown_02039F74 = Alloc((gMartInfo.itemCount + 1) * sizeof(*gUnknown_02039F74)); sListMenuItems = Alloc((sMartInfo.itemCount + 1) * sizeof(*sListMenuItems));
gUnknown_02039F78 = Alloc((gMartInfo.itemCount + 1) * sizeof(*gUnknown_02039F78)); sItemNames = Alloc((sMartInfo.itemCount + 1) * sizeof(*sItemNames));
for (i = 0; i < gMartInfo.itemCount; i++) for (i = 0; i < sMartInfo.itemCount; i++)
BuyMenuSetListEntry(&gUnknown_02039F74[i], gMartInfo.itemList[i], gUnknown_02039F78[i]); BuyMenuSetListEntry(&sListMenuItems[i], sMartInfo.itemList[i], sItemNames[i]);
StringCopy(gUnknown_02039F78[i], gText_Cancel2); StringCopy(sItemNames[i], gText_Cancel2);
gUnknown_02039F74[i].name = gUnknown_02039F78[i]; sListMenuItems[i].name = sItemNames[i];
gUnknown_02039F74[i].id = -2; sListMenuItems[i].id = LIST_CANCEL;
gMultiuseListMenuTemplate = sShopBuyMenuListTemplate; gMultiuseListMenuTemplate = sShopBuyMenuListTemplate;
gMultiuseListMenuTemplate.items = gUnknown_02039F74; gMultiuseListMenuTemplate.items = sListMenuItems;
gMultiuseListMenuTemplate.totalItems = gMartInfo.itemCount + 1; gMultiuseListMenuTemplate.totalItems = sMartInfo.itemCount + 1;
if (gMultiuseListMenuTemplate.totalItems > 8) if (gMultiuseListMenuTemplate.totalItems > 8)
gMultiuseListMenuTemplate.maxShowed = 8; gMultiuseListMenuTemplate.maxShowed = 8;
else else
gMultiuseListMenuTemplate.maxShowed = gMultiuseListMenuTemplate.totalItems; gMultiuseListMenuTemplate.maxShowed = gMultiuseListMenuTemplate.totalItems;
gShopDataPtr->itemsShowed = gMultiuseListMenuTemplate.maxShowed; sShopData->itemsShowed = gMultiuseListMenuTemplate.maxShowed;
} }
static void BuyMenuSetListEntry(struct ListMenuItem *menuItem, u16 item, u8 *name) static void BuyMenuSetListEntry(struct ListMenuItem *menuItem, u16 item, u8 *name)
{ {
if (gMartInfo.martType == MART_TYPE_NORMAL) if (sMartInfo.martType == MART_TYPE_NORMAL)
CopyItemName(item, name); CopyItemName(item, name);
else else
StringCopy(name, gDecorations[item].name); StringCopy(name, gDecorations[item].name);
@@ -527,16 +530,16 @@ static void BuyMenuPrintItemDescriptionAndShowItemIcon(s32 item, bool8 onInit, s
if (onInit != TRUE) if (onInit != TRUE)
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
if (item != -2) if (item != LIST_CANCEL)
BuyMenuAddItemIcon(item, gShopDataPtr->iconSlot); BuyMenuAddItemIcon(item, sShopData->iconSlot);
else else
BuyMenuAddItemIcon(-1, gShopDataPtr->iconSlot); BuyMenuAddItemIcon(-1, sShopData->iconSlot);
BuyMenuRemoveItemIcon(item, gShopDataPtr->iconSlot ^ 1); BuyMenuRemoveItemIcon(item, sShopData->iconSlot ^ 1);
gShopDataPtr->iconSlot ^= 1; sShopData->iconSlot ^= 1;
if (item != -2) if (item != LIST_CANCEL)
{ {
if (gMartInfo.martType == MART_TYPE_NORMAL) if (sMartInfo.martType == MART_TYPE_NORMAL)
description = ItemId_GetDescription(item); description = ItemId_GetDescription(item);
else else
description = gDecorations[item].description; description = gDecorations[item].description;
@@ -554,9 +557,9 @@ static void BuyMenuPrintPriceInList(u8 windowId, s32 item, u8 y)
{ {
u8 x; u8 x;
if (item != -2) if (item != LIST_CANCEL)
{ {
if (gMartInfo.martType == MART_TYPE_NORMAL) if (sMartInfo.martType == MART_TYPE_NORMAL)
{ {
ConvertIntToDecimalStringN( ConvertIntToDecimalStringN(
gStringVar1, gStringVar1,
@@ -581,26 +584,26 @@ static void BuyMenuPrintPriceInList(u8 windowId, s32 item, u8 y)
static void BuyMenuAddScrollIndicatorArrows(void) static void BuyMenuAddScrollIndicatorArrows(void)
{ {
if (gShopDataPtr->scrollIndicatorsTaskId == TASK_NONE && gMartInfo.itemCount + 1 > 8) if (sShopData->scrollIndicatorsTaskId == TASK_NONE && sMartInfo.itemCount + 1 > 8)
{ {
gShopDataPtr->scrollIndicatorsTaskId = AddScrollIndicatorArrowPairParameterized( sShopData->scrollIndicatorsTaskId = AddScrollIndicatorArrowPairParameterized(
SCROLL_ARROW_UP, SCROLL_ARROW_UP,
0xAC, 172,
0xC, 12,
0x94, 148,
gMartInfo.itemCount - 7, sMartInfo.itemCount - 7,
2100, TAG_SCROLL_ARROW,
2100, TAG_SCROLL_ARROW,
&gShopDataPtr->scrollOffset); &sShopData->scrollOffset);
} }
} }
static void BuyMenuRemoveScrollIndicatorArrows(void) static void BuyMenuRemoveScrollIndicatorArrows(void)
{ {
if (gShopDataPtr->scrollIndicatorsTaskId != TASK_NONE) if (sShopData->scrollIndicatorsTaskId != TASK_NONE)
{ {
RemoveScrollIndicatorArrowPair(gShopDataPtr->scrollIndicatorsTaskId); RemoveScrollIndicatorArrowPair(sShopData->scrollIndicatorsTaskId);
gShopDataPtr->scrollIndicatorsTaskId = TASK_NONE; sShopData->scrollIndicatorsTaskId = TASK_NONE;
} }
} }
@@ -613,13 +616,13 @@ static void BuyMenuPrintCursor(u8 scrollIndicatorsTaskId, u8 colorSet)
static void BuyMenuAddItemIcon(u16 item, u8 iconSlot) static void BuyMenuAddItemIcon(u16 item, u8 iconSlot)
{ {
u8 spriteId; u8 spriteId;
u8 *spriteIdPtr = &gShopDataPtr->itemSpriteIds[iconSlot]; u8 *spriteIdPtr = &sShopData->itemSpriteIds[iconSlot];
if (*spriteIdPtr != SPRITE_NONE) if (*spriteIdPtr != SPRITE_NONE)
return; return;
if (gMartInfo.martType == MART_TYPE_NORMAL || item == 0xFFFF) if (sMartInfo.martType == MART_TYPE_NORMAL || item == 0xFFFF)
{ {
spriteId = AddItemIconSprite(iconSlot + 2110, iconSlot + 2110, item); spriteId = AddItemIconSprite(iconSlot + TAG_ITEM_ICON_BASE, iconSlot + TAG_ITEM_ICON_BASE, item);
if (spriteId != MAX_SPRITES) if (spriteId != MAX_SPRITES)
{ {
*spriteIdPtr = spriteId; *spriteIdPtr = spriteId;
@@ -629,7 +632,7 @@ static void BuyMenuAddItemIcon(u16 item, u8 iconSlot)
} }
else else
{ {
spriteId = AddDecorationIconObject(item, 20, 84, 1, iconSlot + 2110, iconSlot + 2110); spriteId = AddDecorationIconObject(item, 20, 84, 1, iconSlot + TAG_ITEM_ICON_BASE, iconSlot + TAG_ITEM_ICON_BASE);
if (spriteId != MAX_SPRITES) if (spriteId != MAX_SPRITES)
*spriteIdPtr = spriteId; *spriteIdPtr = spriteId;
} }
@@ -637,12 +640,12 @@ static void BuyMenuAddItemIcon(u16 item, u8 iconSlot)
static void BuyMenuRemoveItemIcon(u16 item, u8 iconSlot) static void BuyMenuRemoveItemIcon(u16 item, u8 iconSlot)
{ {
u8 *spriteIdPtr = &gShopDataPtr->itemSpriteIds[iconSlot]; u8 *spriteIdPtr = &sShopData->itemSpriteIds[iconSlot];
if (*spriteIdPtr == SPRITE_NONE) if (*spriteIdPtr == SPRITE_NONE)
return; return;
FreeSpriteTilesByTag(iconSlot + 2110); FreeSpriteTilesByTag(iconSlot + TAG_ITEM_ICON_BASE);
FreeSpritePaletteByTag(iconSlot + 2110); FreeSpritePaletteByTag(iconSlot + TAG_ITEM_ICON_BASE);
DestroySprite(&gSprites[*spriteIdPtr]); DestroySprite(&gSprites[*spriteIdPtr]);
*spriteIdPtr = SPRITE_NONE; *spriteIdPtr = SPRITE_NONE;
} }
@@ -651,9 +654,9 @@ static void BuyMenuInitBgs(void)
{ {
ResetBgsAndClearDma3BusyFlags(0); ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, sShopBuyMenuBgTemplates, ARRAY_COUNT(sShopBuyMenuBgTemplates)); InitBgsFromTemplates(0, sShopBuyMenuBgTemplates, ARRAY_COUNT(sShopBuyMenuBgTemplates));
SetBgTilemapBuffer(1, gShopDataPtr->tilemapBuffers[1]); SetBgTilemapBuffer(1, sShopData->tilemapBuffers[1]);
SetBgTilemapBuffer(2, gShopDataPtr->tilemapBuffers[3]); SetBgTilemapBuffer(2, sShopData->tilemapBuffers[3]);
SetBgTilemapBuffer(3, gShopDataPtr->tilemapBuffers[2]); SetBgTilemapBuffer(3, sShopData->tilemapBuffers[2]);
SetGpuReg(REG_OFFSET_BG0HOFS, 0); SetGpuReg(REG_OFFSET_BG0HOFS, 0);
SetGpuReg(REG_OFFSET_BG0VOFS, 0); SetGpuReg(REG_OFFSET_BG0VOFS, 0);
SetGpuReg(REG_OFFSET_BG1HOFS, 0); SetGpuReg(REG_OFFSET_BG1HOFS, 0);
@@ -673,7 +676,7 @@ static void BuyMenuInitBgs(void)
static void BuyMenuDecompressBgGraphics(void) static void BuyMenuDecompressBgGraphics(void)
{ {
DecompressAndCopyTileDataToVram(1, gBuyMenuFrame_Gfx, 0x3A0, 0x3E3, 0); DecompressAndCopyTileDataToVram(1, gBuyMenuFrame_Gfx, 0x3A0, 0x3E3, 0);
LZDecompressWram(gBuyMenuFrame_Tilemap, gShopDataPtr->tilemapBuffers[0]); LZDecompressWram(gBuyMenuFrame_Tilemap, sShopData->tilemapBuffers[0]);
LoadCompressedPalette(gMenuMoneyPal, 0xC0, 0x20); LoadCompressedPalette(gMenuMoneyPal, 0xC0, 0x20);
} }
@@ -763,16 +766,16 @@ static void BuyMenuDrawMapMetatile(s16 x, s16 y, const u16 *src, u8 metatileLaye
switch (metatileLayerType) switch (metatileLayerType)
{ {
case 0: case 0:
BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[3], offset1, offset2, src); BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[3], offset1, offset2, src);
BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[1], offset1, offset2, src + 4); BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[1], offset1, offset2, src + 4);
break; break;
case 1: case 1:
BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[2], offset1, offset2, src); BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[2], offset1, offset2, src);
BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[3], offset1, offset2, src + 4); BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[3], offset1, offset2, src + 4);
break; break;
case 2: case 2:
BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[2], offset1, offset2, src); BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[2], offset1, offset2, src);
BuyMenuDrawMapMetatileLayer(gShopDataPtr->tilemapBuffers[1], offset1, offset2, src + 4); BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[1], offset1, offset2, src + 4);
break; break;
} }
} }
@@ -796,7 +799,7 @@ static void BuyMenuCollectObjectEventData(void)
GetXYCoordsOneStepInFrontOfPlayer(&facingX, &facingY); GetXYCoordsOneStepInFrontOfPlayer(&facingX, &facingY);
for (y = 0; y < OBJECT_EVENTS_COUNT; y++) for (y = 0; y < OBJECT_EVENTS_COUNT; y++)
gShopDataPtr->viewportObjects[y][OBJ_EVENT_ID] = OBJECT_EVENTS_COUNT; sShopData->viewportObjects[y][OBJ_EVENT_ID] = OBJECT_EVENTS_COUNT;
for (y = 0; y < 5; y++) for (y = 0; y < 5; y++)
{ {
for (x = 0; x < 7; x++) for (x = 0; x < 7; x++)
@@ -805,25 +808,25 @@ static void BuyMenuCollectObjectEventData(void)
if (objEventId != OBJECT_EVENTS_COUNT) if (objEventId != OBJECT_EVENTS_COUNT)
{ {
gShopDataPtr->viewportObjects[r8][OBJ_EVENT_ID] = objEventId; sShopData->viewportObjects[r8][OBJ_EVENT_ID] = objEventId;
gShopDataPtr->viewportObjects[r8][X_COORD] = x; sShopData->viewportObjects[r8][X_COORD] = x;
gShopDataPtr->viewportObjects[r8][Y_COORD] = y; sShopData->viewportObjects[r8][Y_COORD] = y;
gShopDataPtr->viewportObjects[r8][LAYER_TYPE] = MapGridGetMetatileLayerTypeAt(facingX - 4 + x, facingY - 2 + y); sShopData->viewportObjects[r8][LAYER_TYPE] = MapGridGetMetatileLayerTypeAt(facingX - 4 + x, facingY - 2 + y);
switch (gObjectEvents[objEventId].facingDirection) switch (gObjectEvents[objEventId].facingDirection)
{ {
case DIR_SOUTH: case DIR_SOUTH:
gShopDataPtr->viewportObjects[r8][ANIM_NUM] = 0; sShopData->viewportObjects[r8][ANIM_NUM] = 0;
break; break;
case DIR_NORTH: case DIR_NORTH:
gShopDataPtr->viewportObjects[r8][ANIM_NUM] = 1; sShopData->viewportObjects[r8][ANIM_NUM] = 1;
break; break;
case DIR_WEST: case DIR_WEST:
gShopDataPtr->viewportObjects[r8][ANIM_NUM] = 2; sShopData->viewportObjects[r8][ANIM_NUM] = 2;
break; break;
case DIR_EAST: case DIR_EAST:
default: default:
gShopDataPtr->viewportObjects[r8][ANIM_NUM] = 3; sShopData->viewportObjects[r8][ANIM_NUM] = 3;
break; break;
} }
r8++; r8++;
@@ -840,25 +843,25 @@ static void BuyMenuDrawObjectEvents(void)
for (i = 0; i < OBJECT_EVENTS_COUNT; i++) for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
{ {
if (gShopDataPtr->viewportObjects[i][OBJ_EVENT_ID] == OBJECT_EVENTS_COUNT) if (sShopData->viewportObjects[i][OBJ_EVENT_ID] == OBJECT_EVENTS_COUNT)
continue; continue;
graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[gShopDataPtr->viewportObjects[i][OBJ_EVENT_ID]].graphicsId); graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[sShopData->viewportObjects[i][OBJ_EVENT_ID]].graphicsId);
spriteId = AddPseudoObjectEvent( spriteId = AddPseudoObjectEvent(
gObjectEvents[gShopDataPtr->viewportObjects[i][OBJ_EVENT_ID]].graphicsId, gObjectEvents[sShopData->viewportObjects[i][OBJ_EVENT_ID]].graphicsId,
SpriteCallbackDummy, SpriteCallbackDummy,
(u16)gShopDataPtr->viewportObjects[i][X_COORD] * 16 + 8, (u16)sShopData->viewportObjects[i][X_COORD] * 16 + 8,
(u16)gShopDataPtr->viewportObjects[i][Y_COORD] * 16 + 48 - graphicsInfo->height / 2, (u16)sShopData->viewportObjects[i][Y_COORD] * 16 + 48 - graphicsInfo->height / 2,
2); 2);
if (BuyMenuCheckIfObjectEventOverlapsMenuBg(gShopDataPtr->viewportObjects[i]) == TRUE) if (BuyMenuCheckIfObjectEventOverlapsMenuBg(sShopData->viewportObjects[i]) == TRUE)
{ {
gSprites[spriteId].subspriteTableNum = 4; gSprites[spriteId].subspriteTableNum = 4;
gSprites[spriteId].subspriteMode = SUBSPRITES_ON; gSprites[spriteId].subspriteMode = SUBSPRITES_ON;
} }
StartSpriteAnim(&gSprites[spriteId], gShopDataPtr->viewportObjects[i][ANIM_NUM]); StartSpriteAnim(&gSprites[spriteId], sShopData->viewportObjects[i][ANIM_NUM]);
} }
} }
@@ -877,8 +880,8 @@ static bool8 BuyMenuCheckIfObjectEventOverlapsMenuBg(s16 *object)
static void BuyMenuCopyMenuBgToBg1TilemapBuffer(void) static void BuyMenuCopyMenuBgToBg1TilemapBuffer(void)
{ {
s16 i; s16 i;
u16 *dest = gShopDataPtr->tilemapBuffers[1]; u16 *dest = sShopData->tilemapBuffers[1];
const u16 *src = gShopDataPtr->tilemapBuffers[0]; const u16 *src = sShopData->tilemapBuffers[0];
for (i = 0; i < 1024; i++) for (i = 0; i < 1024; i++)
{ {
@@ -891,7 +894,7 @@ static void BuyMenuCopyMenuBgToBg1TilemapBuffer(void)
static bool8 BuyMenuCheckForOverlapWithMenuBg(int x, int y) static bool8 BuyMenuCheckForOverlapWithMenuBg(int x, int y)
{ {
const u16 *metatile = gShopDataPtr->tilemapBuffers[0]; const u16 *metatile = sShopData->tilemapBuffers[0];
int offset1 = x * 2; int offset1 = x * 2;
int offset2 = y * 64; int offset2 = y * 64;
@@ -913,7 +916,7 @@ static void Task_BuyMenu(u8 taskId)
if (!gPaletteFade.active) if (!gPaletteFade.active)
{ {
s32 itemId = ListMenu_ProcessInput(tListTaskId); s32 itemId = ListMenu_ProcessInput(tListTaskId);
ListMenuGetScrollAndRow(tListTaskId, &gShopDataPtr->scrollOffset, &gShopDataPtr->selectedRow); ListMenuGetScrollAndRow(tListTaskId, &sShopData->scrollOffset, &sShopData->selectedRow);
switch (itemId) switch (itemId)
{ {
@@ -930,22 +933,22 @@ static void Task_BuyMenu(u8 taskId)
BuyMenuRemoveScrollIndicatorArrows(); BuyMenuRemoveScrollIndicatorArrows();
BuyMenuPrintCursor(tListTaskId, 2); BuyMenuPrintCursor(tListTaskId, 2);
if (gMartInfo.martType == MART_TYPE_NORMAL) if (sMartInfo.martType == MART_TYPE_NORMAL)
{ {
gShopDataPtr->totalCost = (ItemId_GetPrice(itemId) >> GetPriceReduction(POKENEWS_SLATEPORT)); sShopData->totalCost = (ItemId_GetPrice(itemId) >> GetPriceReduction(POKENEWS_SLATEPORT));
} }
else else
{ {
gShopDataPtr->totalCost = gDecorations[itemId].price; sShopData->totalCost = gDecorations[itemId].price;
} }
if (!IsEnoughMoney(&gSaveBlock1Ptr->money, gShopDataPtr->totalCost)) if (!IsEnoughMoney(&gSaveBlock1Ptr->money, sShopData->totalCost))
{ {
BuyMenuDisplayMessage(taskId, gText_YouDontHaveMoney, BuyMenuReturnToItemList); BuyMenuDisplayMessage(taskId, gText_YouDontHaveMoney, BuyMenuReturnToItemList);
} }
else else
{ {
if (gMartInfo.martType == MART_TYPE_NORMAL) if (sMartInfo.martType == MART_TYPE_NORMAL)
{ {
CopyItemName(itemId, gStringVar1); CopyItemName(itemId, gStringVar1);
if (ItemId_GetPocket(itemId) == POCKET_TM_HM) if (ItemId_GetPocket(itemId) == POCKET_TM_HM)
@@ -961,9 +964,9 @@ static void Task_BuyMenu(u8 taskId)
else else
{ {
StringCopy(gStringVar1, gDecorations[itemId].name); StringCopy(gStringVar1, gDecorations[itemId].name);
ConvertIntToDecimalStringN(gStringVar2, gShopDataPtr->totalCost, STR_CONV_MODE_LEFT_ALIGN, 6); ConvertIntToDecimalStringN(gStringVar2, sShopData->totalCost, STR_CONV_MODE_LEFT_ALIGN, 6);
if (gMartInfo.martType == MART_TYPE_DECOR) if (sMartInfo.martType == MART_TYPE_DECOR)
StringExpandPlaceholders(gStringVar4, gText_Var1IsItThatllBeVar2); StringExpandPlaceholders(gStringVar4, gText_Var1IsItThatllBeVar2);
else // MART_TYPE_DECOR2 else // MART_TYPE_DECOR2
StringExpandPlaceholders(gStringVar4, gText_YouWantedVar1ThatllBeVar2); StringExpandPlaceholders(gStringVar4, gText_YouWantedVar1ThatllBeVar2);
@@ -992,15 +995,15 @@ static void Task_BuyHowManyDialogueInit(u8 taskId)
BuyMenuPrintItemQuantityAndPrice(taskId); BuyMenuPrintItemQuantityAndPrice(taskId);
ScheduleBgCopyTilemapToVram(0); ScheduleBgCopyTilemapToVram(0);
maxQuantity = GetMoney(&gSaveBlock1Ptr->money) / gShopDataPtr->totalCost; maxQuantity = GetMoney(&gSaveBlock1Ptr->money) / sShopData->totalCost;
if (maxQuantity > MAX_BAG_ITEM_CAPACITY) if (maxQuantity > MAX_BAG_ITEM_CAPACITY)
{ {
gShopDataPtr->maxQuantity = MAX_BAG_ITEM_CAPACITY; sShopData->maxQuantity = MAX_BAG_ITEM_CAPACITY;
} }
else else
{ {
gShopDataPtr->maxQuantity = maxQuantity; sShopData->maxQuantity = maxQuantity;
} }
gTasks[taskId].func = Task_BuyHowManyDialogueHandleInput; gTasks[taskId].func = Task_BuyHowManyDialogueHandleInput;
@@ -1010,9 +1013,9 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId)
{ {
s16 *data = gTasks[taskId].data; s16 *data = gTasks[taskId].data;
if (AdjustQuantityAccordingToDPadInput(&tItemCount, gShopDataPtr->maxQuantity) == TRUE) if (AdjustQuantityAccordingToDPadInput(&tItemCount, sShopData->maxQuantity) == TRUE)
{ {
gShopDataPtr->totalCost = (ItemId_GetPrice(tItemId) >> GetPriceReduction(POKENEWS_SLATEPORT)) * tItemCount; sShopData->totalCost = (ItemId_GetPrice(tItemId) >> GetPriceReduction(POKENEWS_SLATEPORT)) * tItemCount;
BuyMenuPrintItemQuantityAndPrice(taskId); BuyMenuPrintItemQuantityAndPrice(taskId);
} }
else else
@@ -1027,7 +1030,7 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId)
PutWindowTilemap(1); PutWindowTilemap(1);
CopyItemName(tItemId, gStringVar1); CopyItemName(tItemId, gStringVar1);
ConvertIntToDecimalStringN(gStringVar2, tItemCount, STR_CONV_MODE_LEFT_ALIGN, BAG_ITEM_CAPACITY_DIGITS); ConvertIntToDecimalStringN(gStringVar2, tItemCount, STR_CONV_MODE_LEFT_ALIGN, BAG_ITEM_CAPACITY_DIGITS);
ConvertIntToDecimalStringN(gStringVar3, gShopDataPtr->totalCost, STR_CONV_MODE_LEFT_ALIGN, 6); ConvertIntToDecimalStringN(gStringVar3, sShopData->totalCost, STR_CONV_MODE_LEFT_ALIGN, 6);
BuyMenuDisplayMessage(taskId, gText_Var1AndYouWantedVar2, BuyMenuConfirmPurchase); BuyMenuDisplayMessage(taskId, gText_Var1AndYouWantedVar2, BuyMenuConfirmPurchase);
} }
else if (JOY_NEW(B_BUTTON)) else if (JOY_NEW(B_BUTTON))
@@ -1053,7 +1056,7 @@ static void BuyMenuTryMakePurchase(u8 taskId)
PutWindowTilemap(1); PutWindowTilemap(1);
if (gMartInfo.martType == MART_TYPE_NORMAL) if (sMartInfo.martType == MART_TYPE_NORMAL)
{ {
if (AddBagItem(tItemId, tItemCount) == TRUE) if (AddBagItem(tItemId, tItemCount) == TRUE)
{ {
@@ -1069,7 +1072,7 @@ static void BuyMenuTryMakePurchase(u8 taskId)
{ {
if (DecorationAdd(tItemId)) if (DecorationAdd(tItemId))
{ {
if (gMartInfo.martType == MART_TYPE_DECOR) if (sMartInfo.martType == MART_TYPE_DECOR)
BuyMenuDisplayMessage(taskId, gText_ThankYouIllSendItHome, BuyMenuSubtractMoney); BuyMenuDisplayMessage(taskId, gText_ThankYouIllSendItHome, BuyMenuSubtractMoney);
else // MART_TYPE_DECOR2 else // MART_TYPE_DECOR2
BuyMenuDisplayMessage(taskId, gText_ThanksIllSendItHome, BuyMenuSubtractMoney); BuyMenuDisplayMessage(taskId, gText_ThanksIllSendItHome, BuyMenuSubtractMoney);
@@ -1084,11 +1087,11 @@ static void BuyMenuTryMakePurchase(u8 taskId)
static void BuyMenuSubtractMoney(u8 taskId) static void BuyMenuSubtractMoney(u8 taskId)
{ {
IncrementGameStat(GAME_STAT_SHOPPED); IncrementGameStat(GAME_STAT_SHOPPED);
RemoveMoney(&gSaveBlock1Ptr->money, gShopDataPtr->totalCost); RemoveMoney(&gSaveBlock1Ptr->money, sShopData->totalCost);
PlaySE(SE_SHOP); PlaySE(SE_SHOP);
PrintMoneyAmountInMoneyBox(0, GetMoney(&gSaveBlock1Ptr->money), 0); PrintMoneyAmountInMoneyBox(0, GetMoney(&gSaveBlock1Ptr->money), 0);
if (gMartInfo.martType == MART_TYPE_NORMAL) if (sMartInfo.martType == MART_TYPE_NORMAL)
{ {
gTasks[taskId].func = Task_ReturnToItemListAfterItemPurchase; gTasks[taskId].func = Task_ReturnToItemListAfterItemPurchase;
} }
@@ -1143,7 +1146,7 @@ static void BuyMenuPrintItemQuantityAndPrice(u8 taskId)
s16 *data = gTasks[taskId].data; s16 *data = gTasks[taskId].data;
FillWindowPixelBuffer(4, PIXEL_FILL(1)); FillWindowPixelBuffer(4, PIXEL_FILL(1));
PrintMoneyAmount(4, 38, 1, gShopDataPtr->totalCost, TEXT_SPEED_FF); PrintMoneyAmount(4, 38, 1, sShopData->totalCost, TEXT_SPEED_FF);
ConvertIntToDecimalStringN(gStringVar1, tItemCount, STR_CONV_MODE_LEADING_ZEROS, BAG_ITEM_CAPACITY_DIGITS); ConvertIntToDecimalStringN(gStringVar1, tItemCount, STR_CONV_MODE_LEADING_ZEROS, BAG_ITEM_CAPACITY_DIGITS);
StringExpandPlaceholders(gStringVar4, gText_xVar1); StringExpandPlaceholders(gStringVar4, gText_xVar1);
BuyMenuPrint(4, gStringVar4, 0, 1, 0, 0); BuyMenuPrint(4, gStringVar4, 0, 1, 0, 0);
@@ -1169,7 +1172,7 @@ static void Task_ExitBuyMenu(u8 taskId)
static void ClearItemPurchases(void) static void ClearItemPurchases(void)
{ {
gMartPurchaseHistoryId = 0; sPurchaseHistoryId = 0;
memset(gMartPurchaseHistory, 0, sizeof(gMartPurchaseHistory)); memset(gMartPurchaseHistory, 0, sizeof(gMartPurchaseHistory));
} }
@@ -1179,27 +1182,23 @@ static void RecordItemPurchase(u8 taskId)
u16 i; u16 i;
for (i = 0; i < 3; i++) for (i = 0; i < ARRAY_COUNT(gMartPurchaseHistory); i++)
{ {
if (gMartPurchaseHistory[i].itemId == tItemId && gMartPurchaseHistory[i].quantity != 0) if (gMartPurchaseHistory[i].itemId == tItemId && gMartPurchaseHistory[i].quantity != 0)
{ {
if (gMartPurchaseHistory[i].quantity + tItemCount > 255) if (gMartPurchaseHistory[i].quantity + tItemCount > 255)
{
gMartPurchaseHistory[i].quantity = 255; gMartPurchaseHistory[i].quantity = 255;
}
else else
{
gMartPurchaseHistory[i].quantity += tItemCount; gMartPurchaseHistory[i].quantity += tItemCount;
}
return; return;
} }
} }
if (gMartPurchaseHistoryId < 3) if (sPurchaseHistoryId < ARRAY_COUNT(gMartPurchaseHistory))
{ {
gMartPurchaseHistory[gMartPurchaseHistoryId].itemId = tItemId; gMartPurchaseHistory[sPurchaseHistoryId].itemId = tItemId;
gMartPurchaseHistory[gMartPurchaseHistoryId].quantity = tItemCount; gMartPurchaseHistory[sPurchaseHistoryId].quantity = tItemCount;
gMartPurchaseHistoryId++; sPurchaseHistoryId++;
} }
} }
+31 -15
View File
@@ -170,7 +170,7 @@ static const struct MenuAction sStartMenuItems[] =
{gText_MenuBag, {.u8_void = StartMenuBattlePyramidBagCallback}} {gText_MenuBag, {.u8_void = StartMenuBattlePyramidBagCallback}}
}; };
static const struct BgTemplate sUnknown_085105A8[] = static const struct BgTemplate sBgTemplates_LinkBattleSave[] =
{ {
{ {
.bg = 0, .bg = 0,
@@ -183,13 +183,29 @@ static const struct BgTemplate sUnknown_085105A8[] =
} }
}; };
static const struct WindowTemplate sUnknown_085105AC[] = static const struct WindowTemplate sWindowTemplates_LinkBattleSave[] =
{ {
{0, 2, 0xF, 0x1A, 4, 0xF, 0x194}, {
.bg = 0,
.tilemapLeft = 2,
.tilemapTop = 15,
.width = 26,
.height = 4,
.paletteNum = 15,
.baseBlock = 0x194
},
DUMMY_WIN_TEMPLATE DUMMY_WIN_TEMPLATE
}; };
static const struct WindowTemplate sSaveInfoWindowTemplate = {0, 1, 1, 0xE, 0xA, 0xF, 8}; static const struct WindowTemplate sSaveInfoWindowTemplate = {
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 1,
.width = 14,
.height = 10,
.paletteNum = 15,
.baseBlock = 8
};
// Local functions // Local functions
static void BuildStartMenuActions(void); static void BuildStartMenuActions(void);
@@ -211,13 +227,13 @@ static void CreateStartMenuTask(TaskFunc followupFunc);
static void InitSave(void); static void InitSave(void);
static u8 RunSaveCallback(void); static u8 RunSaveCallback(void);
static void ShowSaveMessage(const u8 *message, u8 (*saveCallback)(void)); static void ShowSaveMessage(const u8 *message, u8 (*saveCallback)(void));
static void sub_80A0014(void); static void HideSaveMessageWindow(void);
static void HideSaveInfoWindow(void); static void HideSaveInfoWindow(void);
static void SaveStartTimer(void); static void SaveStartTimer(void);
static bool8 SaveSuccesTimer(void); static bool8 SaveSuccesTimer(void);
static bool8 SaveErrorTimer(void); static bool8 SaveErrorTimer(void);
static void InitBattlePyramidRetire(void); static void InitBattlePyramidRetire(void);
static void sub_80A03D8(void); static void VBlankCB_LinkBattleSave(void);
static bool32 InitSaveWindowAfterLinkBattle(u8 *par1); static bool32 InitSaveWindowAfterLinkBattle(u8 *par1);
static void CB2_SaveAfterLinkBattle(void); static void CB2_SaveAfterLinkBattle(void);
static void ShowSaveInfoWindow(void); static void ShowSaveInfoWindow(void);
@@ -887,7 +903,7 @@ static void SaveGameTask(u8 taskId)
EnableBothScriptContexts(); EnableBothScriptContexts();
} }
static void sub_80A0014(void) static void HideSaveMessageWindow(void)
{ {
ClearDialogWindowAndFrame(0, TRUE); ClearDialogWindowAndFrame(0, TRUE);
} }
@@ -982,7 +998,7 @@ static u8 SaveConfirmInputCallback(void)
case -1: // B Button case -1: // B Button
case 1: // No case 1: // No
HideSaveInfoWindow(); HideSaveInfoWindow();
sub_80A0014(); HideSaveMessageWindow();
return SAVE_CANCELED; return SAVE_CANCELED;
} }
@@ -1028,7 +1044,7 @@ static u8 SaveOverwriteInputCallback(void)
case -1: // B Button case -1: // B Button
case 1: // No case 1: // No
HideSaveInfoWindow(); HideSaveInfoWindow();
sub_80A0014(); HideSaveMessageWindow();
return SAVE_CANCELED; return SAVE_CANCELED;
} }
@@ -1146,14 +1162,14 @@ static u8 BattlePyramidRetireInputCallback(void)
return SAVE_CANCELED; return SAVE_CANCELED;
case -1: // B Button case -1: // B Button
case 1: // No case 1: // No
sub_80A0014(); HideSaveMessageWindow();
return SAVE_SUCCESS; return SAVE_SUCCESS;
} }
return SAVE_IN_PROGRESS; return SAVE_IN_PROGRESS;
} }
static void sub_80A03D8(void) static void VBlankCB_LinkBattleSave(void)
{ {
TransferPlttBuffer(); TransferPlttBuffer();
} }
@@ -1167,7 +1183,7 @@ static bool32 InitSaveWindowAfterLinkBattle(u8 *state)
SetVBlankCallback(NULL); SetVBlankCallback(NULL);
ScanlineEffect_Stop(); ScanlineEffect_Stop();
DmaClear16(3, PLTT, PLTT_SIZE); DmaClear16(3, PLTT, PLTT_SIZE);
DmaFillLarge16(3, 0, (void *)(VRAM + 0x0), 0x18000, 0x1000); DmaFillLarge16(3, 0, (void *)VRAM, VRAM_SIZE, 0x1000);
break; break;
case 1: case 1:
ResetSpriteData(); ResetSpriteData();
@@ -1177,15 +1193,15 @@ static bool32 InitSaveWindowAfterLinkBattle(u8 *state)
break; break;
case 2: case 2:
ResetBgsAndClearDma3BusyFlags(0); ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, sUnknown_085105A8, ARRAY_COUNT(sUnknown_085105A8)); InitBgsFromTemplates(0, sBgTemplates_LinkBattleSave, ARRAY_COUNT(sBgTemplates_LinkBattleSave));
InitWindows(sUnknown_085105AC); InitWindows(sWindowTemplates_LinkBattleSave);
LoadUserWindowBorderGfx_(0, 8, 224); LoadUserWindowBorderGfx_(0, 8, 224);
Menu_LoadStdPalAt(240); Menu_LoadStdPalAt(240);
break; break;
case 3: case 3:
ShowBg(0); ShowBg(0);
BlendPalettes(-1, 16, 0); BlendPalettes(-1, 16, 0);
SetVBlankCallback(sub_80A03D8); SetVBlankCallback(VBlankCB_LinkBattleSave);
EnableInterrupts(1); EnableInterrupts(1);
break; break;
case 4: case 4:
+1 -1
View File
@@ -1292,7 +1292,7 @@ const u8 gText_MatchCallMay_Intro1[] = _("My POKéMON and I help");
const u8 gText_MatchCallMay_Intro2[] = _("my father's research."); const u8 gText_MatchCallMay_Intro2[] = _("my father's research.");
const u8 gText_HatchedFromEgg[] = _("{STR_VAR_1} hatched from the EGG!"); const u8 gText_HatchedFromEgg[] = _("{STR_VAR_1} hatched from the EGG!");
const u8 gText_NicknameHatchPrompt[] = _("Would you like to nickname the newly\nhatched {STR_VAR_1}?"); const u8 gText_NicknameHatchPrompt[] = _("Would you like to nickname the newly\nhatched {STR_VAR_1}?");
ALIGNED(4) const u8 gText_ReadyToBerryCrush[] = _("Are you ready to BERRY-CRUSH?\nPlease pick a BERRY for use.\p"); ALIGNED(4) const u8 gText_ReadyPickBerry[] = _("Are you ready to BERRY-CRUSH?\nPlease pick a BERRY for use.\p");
ALIGNED(4) const u8 gText_WaitForAllChooseBerry[] = _("Please wait while each member\nchooses a BERRY."); ALIGNED(4) const u8 gText_WaitForAllChooseBerry[] = _("Please wait while each member\nchooses a BERRY.");
ALIGNED(4) const u8 gText_EndedWithXUnitsPowder[] = _("{PAUSE_MUSIC}{PLAY_BGM MUS_LEVEL_UP}You ended up with {STR_VAR_1} units of\nsilky-smooth BERRY POWDER.{RESUME_MUSIC}\pYour total amount of BERRY POWDER\nis {STR_VAR_2}.\p"); ALIGNED(4) const u8 gText_EndedWithXUnitsPowder[] = _("{PAUSE_MUSIC}{PLAY_BGM MUS_LEVEL_UP}You ended up with {STR_VAR_1} units of\nsilky-smooth BERRY POWDER.{RESUME_MUSIC}\pYour total amount of BERRY POWDER\nis {STR_VAR_2}.\p");
ALIGNED(4) const u8 gText_RecordingGameResults[] = _("Recording your game results in the\nsave file.\lPlease wait."); ALIGNED(4) const u8 gText_RecordingGameResults[] = _("Recording your game results in the\nsave file.\lPlease wait.");
+7 -7
View File
@@ -1160,12 +1160,12 @@ static void ReactToLinkTradeData(u8 mpId, u8 status)
{ {
switch (gBlockRecvBuffer[0][0]) switch (gBlockRecvBuffer[0][0])
{ {
case LINKCMD_CANCEL_TRADE: case LINKCMD_BOTH_CANCEL_TRADE:
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK); BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
PrintTradeMessage(TRADE_MSG_WAITING_FOR_FRIEND); PrintTradeMessage(TRADE_MSG_WAITING_FOR_FRIEND);
sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_CANCEL_TRADE_1; sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_CANCEL_TRADE_1;
break; break;
case LINKCMD_0xEECC: case LINKCMD_PARTNER_CANCEL_TRADE:
PrintTradeMessage(TRADE_MSG_FRIEND_WANTS_TO_TRADE); PrintTradeMessage(TRADE_MSG_FRIEND_WANTS_TO_TRADE);
sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU;
break; break;
@@ -1180,7 +1180,7 @@ static void ReactToLinkTradeData(u8 mpId, u8 status)
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK); BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_LINK_TRADE_WAIT_FADE; sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_LINK_TRADE_WAIT_FADE;
break; break;
case LINKCMD_0xDDEE: case LINKCMD_PLAYER_CANCEL_TRADE:
PrintTradeMessage(TRADE_MSG_CANCELED); PrintTradeMessage(TRADE_MSG_CANCELED);
sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU;
} }
@@ -1208,7 +1208,7 @@ static void QueueLinkTradeData(void)
&& sTradeMenuData->partnerLinkFlagChoseAction == WANTS_TO_CANCEL) && sTradeMenuData->partnerLinkFlagChoseAction == WANTS_TO_CANCEL)
{ {
PrintTradeMessage(TRADE_MSG_CANCELED); PrintTradeMessage(TRADE_MSG_CANCELED);
sTradeMenuData->linkData[0] = LINKCMD_0xEECC; sTradeMenuData->linkData[0] = LINKCMD_PARTNER_CANCEL_TRADE;
sTradeMenuData->linkData[1] = 0; sTradeMenuData->linkData[1] = 0;
QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA);
sTradeMenuData->playerLinkFlagStatus = sTradeMenuData->partnerLinkFlagStatus = 0; sTradeMenuData->playerLinkFlagStatus = sTradeMenuData->partnerLinkFlagStatus = 0;
@@ -1219,7 +1219,7 @@ static void QueueLinkTradeData(void)
&& sTradeMenuData->partnerLinkFlagChoseAction == WANTS_TO_TRADE) && sTradeMenuData->partnerLinkFlagChoseAction == WANTS_TO_TRADE)
{ {
PrintTradeMessage(TRADE_MSG_FRIEND_WANTS_TO_TRADE); PrintTradeMessage(TRADE_MSG_FRIEND_WANTS_TO_TRADE);
sTradeMenuData->linkData[0] = LINKCMD_0xDDEE; sTradeMenuData->linkData[0] = LINKCMD_PLAYER_CANCEL_TRADE;
sTradeMenuData->linkData[1] = 0; sTradeMenuData->linkData[1] = 0;
QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA);
sTradeMenuData->playerLinkFlagStatus = sTradeMenuData->partnerLinkFlagStatus = 0; sTradeMenuData->playerLinkFlagStatus = sTradeMenuData->partnerLinkFlagStatus = 0;
@@ -1229,7 +1229,7 @@ static void QueueLinkTradeData(void)
else if (sTradeMenuData->playerLinkFlagChoseAction == WANTS_TO_CANCEL else if (sTradeMenuData->playerLinkFlagChoseAction == WANTS_TO_CANCEL
&& sTradeMenuData->partnerLinkFlagChoseAction == WANTS_TO_CANCEL) && sTradeMenuData->partnerLinkFlagChoseAction == WANTS_TO_CANCEL)
{ {
sTradeMenuData->linkData[0] = LINKCMD_CANCEL_TRADE; sTradeMenuData->linkData[0] = LINKCMD_BOTH_CANCEL_TRADE;
sTradeMenuData->linkData[1] = 0; sTradeMenuData->linkData[1] = 0;
QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA);
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK); BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
@@ -1255,7 +1255,7 @@ static void QueueLinkTradeData(void)
|| sTradeMenuData->partnerLinkFlagStatus == CANCEL_TRADE) || sTradeMenuData->partnerLinkFlagStatus == CANCEL_TRADE)
{ {
PrintTradeMessage(TRADE_MSG_CANCELED); PrintTradeMessage(TRADE_MSG_CANCELED);
sTradeMenuData->linkData[0] = LINKCMD_0xDDEE; sTradeMenuData->linkData[0] = LINKCMD_PLAYER_CANCEL_TRADE;
sTradeMenuData->linkData[1] = 0; sTradeMenuData->linkData[1] = 0;
QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA);
sTradeMenuData->playerLinkFlagStatus = 0; sTradeMenuData->playerLinkFlagStatus = 0;
+73 -74
View File
@@ -80,7 +80,7 @@ struct TrainerCardData
u8 cardTiles[0x2300]; u8 cardTiles[0x2300];
u16 cardTilemapBuffer[0x1000]; u16 cardTilemapBuffer[0x1000];
u16 bgTilemapBuffer[0x1000]; u16 bgTilemapBuffer[0x1000];
u16 var_7CA8; u16 cardTop;
u8 language; u8 language;
}; };
@@ -113,7 +113,7 @@ static void SetPlayerCardData(struct TrainerCard*, u8);
static void TrainerCard_GenerateCardForLinkPlayer(struct TrainerCard*); static void TrainerCard_GenerateCardForLinkPlayer(struct TrainerCard*);
static u8 VersionToCardType(u8); static u8 VersionToCardType(u8);
static void SetDataFromTrainerCard(void); static void SetDataFromTrainerCard(void);
static void HandleGpuRegs(void); static void InitGpuRegs(void);
static void ResetGpuRegs(void); static void ResetGpuRegs(void);
static void InitBgsAndWindows(void); static void InitBgsAndWindows(void);
static void SetTrainerCardCb2(void); static void SetTrainerCardCb2(void);
@@ -158,31 +158,30 @@ static bool8 Task_DrawFlippedCardSide(struct Task* task);
static bool8 Task_SetCardFlipped(struct Task* task); static bool8 Task_SetCardFlipped(struct Task* task);
static bool8 Task_AnimateCardFlipUp(struct Task* task); static bool8 Task_AnimateCardFlipUp(struct Task* task);
static bool8 Task_EndCardFlip(struct Task* task); static bool8 Task_EndCardFlip(struct Task* task);
static void sub_80C32EC(u16); static void UpdateCardFlipRegs(u16);
static void LoadMonIconGfx(void); static void LoadMonIconGfx(void);
// const rom data static const u32 sTrainerCardStickers_Gfx[] = INCBIN_U32("graphics/trainer_card/stickers_fr.4bpp.lz");
static const u32 sTrainerCardStickers_Gfx[] = INCBIN_U32("graphics/trainer_card/stickers_fr.4bpp.lz"); static const u16 sUnused_Pal[] = INCBIN_U16("graphics/trainer_card/unused.gbapal");
static const u16 sUnused_0856F18C[] = INCBIN_U16("graphics/trainer_card/unknown_56F18C.gbapal"); static const u16 sHoennTrainerCard1Star_Pal[] = INCBIN_U16("graphics/trainer_card/one_star.gbapal");
static const u16 sHoennTrainerCard1Star_Pal[] = INCBIN_U16("graphics/trainer_card/one_star.gbapal"); static const u16 sKantoTrainerCard1Star_Pal[] = INCBIN_U16("graphics/trainer_card/one_star_fr.gbapal");
static const u16 sKantoTrainerCard1Star_Pal[] = INCBIN_U16("graphics/trainer_card/one_star_fr.gbapal"); static const u16 sHoennTrainerCard2Star_Pal[] = INCBIN_U16("graphics/trainer_card/two_stars.gbapal");
static const u16 sHoennTrainerCard2Star_Pal[] = INCBIN_U16("graphics/trainer_card/two_stars.gbapal"); static const u16 sKantoTrainerCard2Star_Pal[] = INCBIN_U16("graphics/trainer_card/two_stars_fr.gbapal");
static const u16 sKantoTrainerCard2Star_Pal[] = INCBIN_U16("graphics/trainer_card/two_stars_fr.gbapal"); static const u16 sHoennTrainerCard3Star_Pal[] = INCBIN_U16("graphics/trainer_card/three_stars.gbapal");
static const u16 sHoennTrainerCard3Star_Pal[] = INCBIN_U16("graphics/trainer_card/three_stars.gbapal"); static const u16 sKantoTrainerCard3Star_Pal[] = INCBIN_U16("graphics/trainer_card/three_stars_fr.gbapal");
static const u16 sKantoTrainerCard3Star_Pal[] = INCBIN_U16("graphics/trainer_card/three_stars_fr.gbapal"); static const u16 sHoennTrainerCard4Star_Pal[] = INCBIN_U16("graphics/trainer_card/four_stars.gbapal");
static const u16 sHoennTrainerCard4Star_Pal[] = INCBIN_U16("graphics/trainer_card/four_stars.gbapal"); static const u16 sKantoTrainerCard4Star_Pal[] = INCBIN_U16("graphics/trainer_card/four_stars_fr.gbapal");
static const u16 sKantoTrainerCard4Star_Pal[] = INCBIN_U16("graphics/trainer_card/four_stars_fr.gbapal");
static const u16 sHoennTrainerCardFemaleBg_Pal[] = INCBIN_U16("graphics/trainer_card/female_bg.gbapal"); static const u16 sHoennTrainerCardFemaleBg_Pal[] = INCBIN_U16("graphics/trainer_card/female_bg.gbapal");
static const u16 sKantoTrainerCardFemaleBg_Pal[] = INCBIN_U16("graphics/trainer_card/female_bg_fr.gbapal"); static const u16 sKantoTrainerCardFemaleBg_Pal[] = INCBIN_U16("graphics/trainer_card/female_bg_fr.gbapal");
static const u16 sHoennTrainerCardBadges_Pal[] = INCBIN_U16("graphics/trainer_card/badges.gbapal"); static const u16 sHoennTrainerCardBadges_Pal[] = INCBIN_U16("graphics/trainer_card/badges.gbapal");
static const u16 sKantoTrainerCardBadges_Pal[] = INCBIN_U16("graphics/trainer_card/badges_fr.gbapal"); static const u16 sKantoTrainerCardBadges_Pal[] = INCBIN_U16("graphics/trainer_card/badges_fr.gbapal");
static const u16 sTrainerCardGold_Pal[] = INCBIN_U16("graphics/trainer_card/gold.gbapal"); static const u16 sTrainerCardGold_Pal[] = INCBIN_U16("graphics/trainer_card/gold.gbapal");
static const u16 sTrainerCardSticker1_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr1.gbapal"); static const u16 sTrainerCardSticker1_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr1.gbapal");
static const u16 sTrainerCardSticker2_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr2.gbapal"); static const u16 sTrainerCardSticker2_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr2.gbapal");
static const u16 sTrainerCardSticker3_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr3.gbapal"); static const u16 sTrainerCardSticker3_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr3.gbapal");
static const u16 sTrainerCardSticker4_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr4.gbapal"); static const u16 sTrainerCardSticker4_Pal[] = INCBIN_U16("graphics/trainer_card/stickers_fr4.gbapal");
static const u32 sHoennTrainerCardBadges_Gfx[] = INCBIN_U32("graphics/trainer_card/badges.4bpp.lz"); static const u32 sHoennTrainerCardBadges_Gfx[] = INCBIN_U32("graphics/trainer_card/badges.4bpp.lz");
static const u32 sKantoTrainerCardBadges_Gfx[] = INCBIN_U32("graphics/trainer_card/badges_fr.4bpp.lz"); static const u32 sKantoTrainerCardBadges_Gfx[] = INCBIN_U32("graphics/trainer_card/badges_fr.4bpp.lz");
static const struct BgTemplate sTrainerCardBgTemplates[4] = static const struct BgTemplate sTrainerCardBgTemplates[4] =
{ {
@@ -321,7 +320,6 @@ static bool8 (*const sTrainerCardFlipTasks[])(struct Task *) =
Task_EndCardFlip, Task_EndCardFlip,
}; };
// code
static void VblankCb_TrainerCard(void) static void VblankCb_TrainerCard(void)
{ {
LoadOam(); LoadOam();
@@ -620,7 +618,7 @@ static void CB2_InitTrainerCard(void)
gMain.state++; gMain.state++;
break; break;
case 8: case 8:
HandleGpuRegs(); InitGpuRegs();
gMain.state++; gMain.state++;
break; break;
case 9: case 9:
@@ -841,7 +839,7 @@ static void SetDataFromTrainerCard(void)
} }
} }
static void HandleGpuRegs(void) static void InitGpuRegs(void)
{ {
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
ShowBg(0); ShowBg(0);
@@ -852,24 +850,23 @@ static void HandleGpuRegs(void)
SetGpuReg(REG_OFFSET_BLDY, 0); SetGpuReg(REG_OFFSET_BLDY, 0);
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR); SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR);
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ); SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ);
SetGpuReg(REG_OFFSET_WIN0V, 160); SetGpuReg(REG_OFFSET_WIN0V, DISPLAY_HEIGHT);
SetGpuReg(REG_OFFSET_WIN0H, 240); SetGpuReg(REG_OFFSET_WIN0H, DISPLAY_WIDTH);
if (gReceivedRemoteLinkPlayers) if (gReceivedRemoteLinkPlayers)
EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_HBLANK | INTR_FLAG_VCOUNT | INTR_FLAG_TIMER3 | INTR_FLAG_SERIAL); EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_HBLANK | INTR_FLAG_VCOUNT | INTR_FLAG_TIMER3 | INTR_FLAG_SERIAL);
else else
EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_HBLANK); EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_HBLANK);
} }
// Part of animating card flip static void UpdateCardFlipRegs(u16 cardTop)
static void sub_80C32EC(u16 arg0)
{ {
s8 quotient = (arg0 + 40) / 10; s8 blendY = (cardTop + 40) / 10;
if (quotient <= 4) if (blendY <= 4)
quotient = 0; blendY = 0;
sData->flipBlendY = quotient; sData->flipBlendY = blendY;
SetGpuReg(REG_OFFSET_BLDY, sData->flipBlendY); SetGpuReg(REG_OFFSET_BLDY, sData->flipBlendY);
SetGpuReg(REG_OFFSET_WIN0V, (sData->var_7CA8 * 256) | (160 - sData->var_7CA8)); SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(sData->cardTop, DISPLAY_HEIGHT - sData->cardTop));
} }
static void ResetGpuRegs(void) static void ResetGpuRegs(void)
@@ -1578,6 +1575,7 @@ u8 GetTrainerCardStars(u8 cardId)
} }
#define tFlipState data[0] #define tFlipState data[0]
#define tCardTop data[1]
static void FlipTrainerCard(void) static void FlipTrainerCard(void)
{ {
@@ -1608,41 +1606,43 @@ static bool8 Task_BeginCardFlip(struct Task* task)
HideBg(3); HideBg(3);
ScanlineEffect_Stop(); ScanlineEffect_Stop();
ScanlineEffect_Clear(); ScanlineEffect_Clear();
for (i = 0; i < 160; i++) for (i = 0; i < DISPLAY_HEIGHT; i++)
gScanlineEffectRegBuffers[1][i] = 0; gScanlineEffectRegBuffers[1][i] = 0;
task->tFlipState++; task->tFlipState++;
return FALSE; return FALSE;
} }
// Note: Cannot be DISPLAY_HEIGHT / 2, or cardHeight will be 0
#define CARD_FLIP_Y ((DISPLAY_HEIGHT / 2) - 3)
static bool8 Task_AnimateCardFlipDown(struct Task* task) static bool8 Task_AnimateCardFlipDown(struct Task* task)
{ {
u32 r4, r5, r10, r7, r6, var_24, r9, var; u32 cardHeight, r5, r10, cardTop, r6, var_24, cardBottom, var;
s16 i; s16 i;
sData->allowDMACopy = FALSE; sData->allowDMACopy = FALSE;
if (task->data[1] >= 77) if (task->tCardTop >= CARD_FLIP_Y)
task->data[1] = 77; task->tCardTop = CARD_FLIP_Y;
else else
task->data[1] += 7; task->tCardTop += 7;
sData->var_7CA8 = task->data[1]; sData->cardTop = task->tCardTop;
sub_80C32EC(task->data[1]); UpdateCardFlipRegs(task->tCardTop);
// ??? cardTop = task->tCardTop;
r7 = task->data[1]; cardBottom = DISPLAY_HEIGHT - cardTop;
r9 = 160 - r7; cardHeight = cardBottom - cardTop;
r4 = r9 - r7; r6 = -cardTop << 16;
r6 = -r7 << 16; r5 = (DISPLAY_HEIGHT << 16) / cardHeight;
r5 = 0xA00000 / r4; r5 -= 1 << 16;
r5 += 0xFFFF0000;
var_24 = r6; var_24 = r6;
var_24 += r5 * r4; var_24 += r5 * cardHeight;
r10 = r5 / r4; r10 = r5 / cardHeight;
r5 *= 2; r5 *= 2;
for (i = 0; i < r7; i++) for (i = 0; i < cardTop; i++)
gScanlineEffectRegBuffers[0][i] = -i; gScanlineEffectRegBuffers[0][i] = -i;
for (; i < (s16)(r9); i++) for (; i < (s16)cardBottom; i++)
{ {
var = r6 >> 16; var = r6 >> 16;
r6 += r5; r6 += r5;
@@ -1650,11 +1650,11 @@ static bool8 Task_AnimateCardFlipDown(struct Task* task)
gScanlineEffectRegBuffers[0][i] = var; gScanlineEffectRegBuffers[0][i] = var;
} }
var = var_24 >> 16; var = var_24 >> 16;
for (; i < 160; i++) for (; i < DISPLAY_HEIGHT; i++)
gScanlineEffectRegBuffers[0][i] = var; gScanlineEffectRegBuffers[0][i] = var;
sData->allowDMACopy = TRUE; sData->allowDMACopy = TRUE;
if (task->data[1] >= 77) if (task->tCardTop >= CARD_FLIP_Y)
task->tFlipState++; task->tFlipState++;
return FALSE; return FALSE;
@@ -1736,33 +1736,32 @@ static bool8 Task_SetCardFlipped(struct Task* task)
static bool8 Task_AnimateCardFlipUp(struct Task* task) static bool8 Task_AnimateCardFlipUp(struct Task* task)
{ {
u32 r4, r5, r10, r7, r6, var_24, r9, var; u32 cardHeight, r5, r10, cardTop, r6, var_24, cardBottom, var;
s16 i; s16 i;
sData->allowDMACopy = FALSE; sData->allowDMACopy = FALSE;
if (task->data[1] <= 5) if (task->tCardTop <= 5)
task->data[1] = 0; task->tCardTop = 0;
else else
task->data[1] -= 5; task->tCardTop -= 5;
sData->var_7CA8 = task->data[1]; sData->cardTop = task->tCardTop;
sub_80C32EC(task->data[1]); UpdateCardFlipRegs(task->tCardTop);
// ??? cardTop = task->tCardTop;
r7 = task->data[1]; cardBottom = DISPLAY_HEIGHT - cardTop;
r9 = 160 - r7; cardHeight = cardBottom - cardTop;
r4 = r9 - r7; r6 = -cardTop << 16;
r6 = -r7 << 16; r5 = (DISPLAY_HEIGHT << 16) / cardHeight;
r5 = 0xA00000 / r4; r5 -= 1 << 16;
r5 += 0xFFFF0000;
var_24 = r6; var_24 = r6;
var_24 += r5 * r4; var_24 += r5 * cardHeight;
r10 = r5 / r4; r10 = r5 / cardHeight;
r5 /= 2; r5 /= 2;
for (i = 0; i < r7; i++) for (i = 0; i < cardTop; i++)
gScanlineEffectRegBuffers[0][i] = -i; gScanlineEffectRegBuffers[0][i] = -i;
for (; i < (s16)(r9); i++) for (; i < (s16)cardBottom; i++)
{ {
var = r6 >> 16; var = r6 >> 16;
r6 += r5; r6 += r5;
@@ -1770,11 +1769,11 @@ static bool8 Task_AnimateCardFlipUp(struct Task* task)
gScanlineEffectRegBuffers[0][i] = var; gScanlineEffectRegBuffers[0][i] = var;
} }
var = var_24 >> 16; var = var_24 >> 16;
for (; i < 160; i++) for (; i < DISPLAY_HEIGHT; i++)
gScanlineEffectRegBuffers[0][i] = var; gScanlineEffectRegBuffers[0][i] = var;
sData->allowDMACopy = TRUE; sData->allowDMACopy = TRUE;
if (task->data[1] <= 0) if (task->tCardTop <= 0)
task->tFlipState++; task->tFlipState++;
return FALSE; return FALSE;
+5 -5
View File
@@ -74,7 +74,7 @@ static void GetChallengeWon(void);
static void TrainerHillSetTag(void); static void TrainerHillSetTag(void);
static void SetUpDataStruct(void); static void SetUpDataStruct(void);
static void FreeDataStruct(void); static void FreeDataStruct(void);
static void nullsub_2(void); static void TrainerHillDummy(void);
static void SetTimerValue(u32 *dst, u32 val); static void SetTimerValue(u32 *dst, u32 val);
static u32 GetTimerValue(u32 *src); static u32 GetTimerValue(u32 *src);
static void SetTrainerHillMonLevel(struct Pokemon *mon, u8 level); static void SetTrainerHillMonLevel(struct Pokemon *mon, u8 level);
@@ -358,7 +358,7 @@ static void SetUpDataStruct(void)
sHillData = AllocZeroed(sizeof(*sHillData)); sHillData = AllocZeroed(sizeof(*sHillData));
sHillData->floorId = gMapHeader.mapLayoutId - LAYOUT_TRAINER_HILL_1F; sHillData->floorId = gMapHeader.mapLayoutId - LAYOUT_TRAINER_HILL_1F;
CpuCopy32(sDataPerTag[gSaveBlock1Ptr->trainerHill.tag], &sHillData->tag, sizeof(sHillData->tag) + 4 * sizeof(struct TrHillFloor)); CpuCopy32(sDataPerTag[gSaveBlock1Ptr->trainerHill.tag], &sHillData->tag, sizeof(sHillData->tag) + 4 * sizeof(struct TrHillFloor));
nullsub_2(); TrainerHillDummy();
} }
} }
@@ -397,7 +397,7 @@ void CopyTrainerHillTrainerText(u8 which, u16 trainerId)
static void TrainerHillStartChallenge(void) static void TrainerHillStartChallenge(void)
{ {
nullsub_2(); TrainerHillDummy();
if (!ReadTrainerHillAndValidate()) if (!ReadTrainerHillAndValidate())
gSaveBlock1Ptr->trainerHill.field_3D6E_0f = 1; gSaveBlock1Ptr->trainerHill.field_3D6E_0f = 1;
else else
@@ -573,12 +573,12 @@ static void IsTrainerHillChallengeActive(void)
gSpecialVar_Result = TRUE; gSpecialVar_Result = TRUE;
} }
void nullsub_129(void) static void TrainerHillDummy_Unused(void)
{ {
} }
static void nullsub_2(void) static void TrainerHillDummy(void)
{ {
} }
+11 -11
View File
@@ -5,7 +5,7 @@
#include "sound.h" #include "sound.h"
ALIGNED(4) ALIGNED(4)
static const u8 sUnknown_08616124[] = {1, 2, 4}; static const u8 sScrollDistances[] = {1, 2, 4};
static const u16 sFont6BrailleGlyphs[] = INCBIN_U16("graphics/fonts/font6.fwjpnfont"); static const u16 sFont6BrailleGlyphs[] = INCBIN_U16("graphics/fonts/font6.fwjpnfont");
static void DecompressGlyphFont6(u16); static void DecompressGlyphFont6(u16);
@@ -135,7 +135,7 @@ u16 Font6Func(struct TextPrinter *textPrinter)
} }
DecompressGlyphFont6(char_); DecompressGlyphFont6(char_);
CopyGlyphToWindow(textPrinter); CopyGlyphToWindow(textPrinter);
textPrinter->printerTemplate.currentX += gUnknown_03002F90.width + textPrinter->printerTemplate.letterSpacing; textPrinter->printerTemplate.currentX += gCurGlyph.width + textPrinter->printerTemplate.letterSpacing;
return 0; return 0;
case 1: case 1:
if (TextPrinterWait(textPrinter)) if (TextPrinterWait(textPrinter))
@@ -164,15 +164,15 @@ u16 Font6Func(struct TextPrinter *textPrinter)
case 4: case 4:
if (textPrinter->scrollDistance) if (textPrinter->scrollDistance)
{ {
if (textPrinter->scrollDistance < sUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed]) if (textPrinter->scrollDistance < sScrollDistances[gSaveBlock2Ptr->optionsTextSpeed])
{ {
ScrollWindow(textPrinter->printerTemplate.windowId, 0, textPrinter->scrollDistance, PIXEL_FILL(textPrinter->printerTemplate.bgColor)); ScrollWindow(textPrinter->printerTemplate.windowId, 0, textPrinter->scrollDistance, PIXEL_FILL(textPrinter->printerTemplate.bgColor));
textPrinter->scrollDistance = 0; textPrinter->scrollDistance = 0;
} }
else else
{ {
ScrollWindow(textPrinter->printerTemplate.windowId, 0, sUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed], PIXEL_FILL(textPrinter->printerTemplate.bgColor)); ScrollWindow(textPrinter->printerTemplate.windowId, 0, sScrollDistances[gSaveBlock2Ptr->optionsTextSpeed], PIXEL_FILL(textPrinter->printerTemplate.bgColor));
textPrinter->scrollDistance -= sUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed]; textPrinter->scrollDistance -= sScrollDistances[gSaveBlock2Ptr->optionsTextSpeed];
} }
CopyWindowToVram(textPrinter->printerTemplate.windowId, 2); CopyWindowToVram(textPrinter->printerTemplate.windowId, 2);
} }
@@ -206,12 +206,12 @@ static void DecompressGlyphFont6(u16 glyph)
const u16 *glyphs; const u16 *glyphs;
glyphs = sFont6BrailleGlyphs + 0x100 * (glyph / 8) + 0x10 * (glyph % 8); glyphs = sFont6BrailleGlyphs + 0x100 * (glyph / 8) + 0x10 * (glyph % 8);
DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90.unk20)); DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8);
DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90.unk40)); DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom);
DecompressGlyphTile(glyphs + 0x88, (u16 *)(gUnknown_03002F90.unk60)); DecompressGlyphTile(glyphs + 0x88, gCurGlyph.gfxBufferBottom + 8);
gUnknown_03002F90.width = 0x10; gCurGlyph.width = 0x10;
gUnknown_03002F90.height = 0x10; gCurGlyph.height = 0x10;
} }
u32 GetGlyphWidthFont6(u16 glyphId, bool32 isJapanese) u32 GetGlyphWidthFont6(u16 glyphId, bool32 isJapanese)
+2 -2
View File
@@ -16,10 +16,10 @@ gWindowBgTilemapBuffers:
gFonts: gFonts:
.space 4 .space 4
.align 2 .align 2
gUnknown_03002F84: gDisableTextPrinters:
.space 1 .space 1
.align 4 .align 4
gUnknown_03002F90: gCurGlyph:
.space 132 .space 132
.align 2 .align 2
gTextFlags: gTextFlags: