Sync berry_fix_program
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
gUnknown_3005EF0
|
gMultibootStart
|
||||||
gUnknown_3005EF4
|
gMultibootStatus
|
||||||
gUnknown_3005EF8
|
gMultibootSize
|
||||||
gUnknown_3005F00
|
gMultibootParam
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#ifndef GUARD_BERRY_FIX_PROGRAM_H
|
#ifndef GUARD_BERRY_FIX_PROGRAM_H
|
||||||
#define GUARD_BERRY_FIX_PROGRAM_H
|
#define GUARD_BERRY_FIX_PROGRAM_H
|
||||||
|
|
||||||
void mb_berry_fix_serve(void);
|
void CB2_InitBerryFixProgram(void);
|
||||||
|
|
||||||
#endif //GUARD_BERRY_FIX_PROGRAM_H
|
#endif //GUARD_BERRY_FIX_PROGRAM_H
|
||||||
|
|||||||
+99
-82
@@ -9,51 +9,64 @@
|
|||||||
#include "help_system.h"
|
#include "help_system.h"
|
||||||
#include "m4a.h"
|
#include "m4a.h"
|
||||||
|
|
||||||
// Static type declarations
|
enum {
|
||||||
|
SCENE_ENSURE_CONNECT,
|
||||||
|
SCENE_TURN_OFF_POWER,
|
||||||
|
SCENE_TRANSMITTING,
|
||||||
|
SCENE_FOLLOW_INSTRUCT,
|
||||||
|
SCENE_TRANSMIT_FAILED,
|
||||||
|
SCENE_BEGIN,
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct {
|
enum {
|
||||||
u8 state;
|
STATE_BEGIN,
|
||||||
u8 unk1;
|
STATE_CONNECT,
|
||||||
u16 unk2;
|
STATE_TURN_OFF_POWER,
|
||||||
struct MultiBootParam mb;
|
STATE_UNUSED,
|
||||||
} berryfix_t;
|
STATE_INIT_MULTIBOOT,
|
||||||
|
STATE_MULTIBOOT,
|
||||||
|
STATE_TRANSMIT,
|
||||||
|
STATE_SUCCEEDED,
|
||||||
|
STATE_EXIT,
|
||||||
|
STATE_FAILED,
|
||||||
|
STATE_RETRY,
|
||||||
|
};
|
||||||
|
|
||||||
// Static RAM declarations
|
const void *gMultibootStart;
|
||||||
|
int gMultibootStatus;
|
||||||
|
size_t gMultibootSize;
|
||||||
|
struct MultiBootParam gMultibootParam;
|
||||||
|
|
||||||
const void *gUnknown_3005EF0;
|
static void CB2_BerryFix(void);
|
||||||
int gUnknown_3005EF4;
|
static void Task_BerryFixMain(u8 taskId);
|
||||||
size_t gUnknown_3005EF8;
|
|
||||||
struct MultiBootParam gUnknown_3005F00;
|
|
||||||
|
|
||||||
// Static ROM declarations
|
static const void *const sBerryFixGraphics[][3] = {
|
||||||
|
[SCENE_ENSURE_CONNECT] = {
|
||||||
static void mb_berry_fix_maincb(void);
|
|
||||||
static void mb_berry_fix_task(u8 taskId);
|
|
||||||
|
|
||||||
// .rodata
|
|
||||||
|
|
||||||
static const void *const gUnknown_847A890[][3] = {
|
|
||||||
{
|
|
||||||
gBerryFixGameboy_Gfx,
|
gBerryFixGameboy_Gfx,
|
||||||
gBerryFixGameboy_Tilemap,
|
gBerryFixGameboy_Tilemap,
|
||||||
gBerryFixGameboy_Pal
|
gBerryFixGameboy_Pal
|
||||||
}, {
|
},
|
||||||
|
[SCENE_TURN_OFF_POWER] = {
|
||||||
gBerryFixGameboyLogo_Gfx,
|
gBerryFixGameboyLogo_Gfx,
|
||||||
gBerryFixGameboyLogo_Tilemap,
|
gBerryFixGameboyLogo_Tilemap,
|
||||||
gBerryFixGameboyLogo_Pal
|
gBerryFixGameboyLogo_Pal
|
||||||
}, {
|
},
|
||||||
|
[SCENE_TRANSMITTING] = {
|
||||||
gBerryFixGbaTransfer_Gfx,
|
gBerryFixGbaTransfer_Gfx,
|
||||||
gBerryFixGbaTransfer_Tilemap,
|
gBerryFixGbaTransfer_Tilemap,
|
||||||
gBerryFixGbaTransfer_Pal
|
gBerryFixGbaTransfer_Pal
|
||||||
}, {
|
},
|
||||||
|
[SCENE_FOLLOW_INSTRUCT] = {
|
||||||
gBerryFixGbaTransferHighlight_Gfx,
|
gBerryFixGbaTransferHighlight_Gfx,
|
||||||
gBerryFixGbaTransferHighlight_Tilemap,
|
gBerryFixGbaTransferHighlight_Tilemap,
|
||||||
gBerryFixGbaTransferHighlight_Pal
|
gBerryFixGbaTransferHighlight_Pal
|
||||||
}, {
|
},
|
||||||
|
[SCENE_TRANSMIT_FAILED] = {
|
||||||
gBerryFixGbaTransferError_Gfx,
|
gBerryFixGbaTransferError_Gfx,
|
||||||
gBerryFixGbaTransferError_Tilemap,
|
gBerryFixGbaTransferError_Tilemap,
|
||||||
gBerryFixGbaTransferError_Pal
|
gBerryFixGbaTransferError_Pal
|
||||||
}, {
|
},
|
||||||
|
[SCENE_BEGIN] = {
|
||||||
gBerryFixWindow_Gfx,
|
gBerryFixWindow_Gfx,
|
||||||
gBerryFixWindow_Tilemap,
|
gBerryFixWindow_Tilemap,
|
||||||
gBerryFixWindow_Pal
|
gBerryFixWindow_Pal
|
||||||
@@ -63,22 +76,23 @@ static const void *const gUnknown_847A890[][3] = {
|
|||||||
extern const u8 gMultiBootProgram_BerryGlitchFix_Start[0x3BF4];
|
extern const u8 gMultiBootProgram_BerryGlitchFix_Start[0x3BF4];
|
||||||
extern const u8 gMultiBootProgram_BerryGlitchFix_End[];
|
extern const u8 gMultiBootProgram_BerryGlitchFix_End[];
|
||||||
|
|
||||||
// .text
|
static void SetScene(int scene)
|
||||||
|
|
||||||
static void mb_berry_fix_print(int scene)
|
|
||||||
{
|
{
|
||||||
REG_DISPCNT = 0;
|
REG_DISPCNT = 0;
|
||||||
REG_BG0HOFS = 0;
|
REG_BG0HOFS = 0;
|
||||||
REG_BG0VOFS = 0;
|
REG_BG0VOFS = 0;
|
||||||
REG_BLDCNT = 0;
|
REG_BLDCNT = 0;
|
||||||
LZ77UnCompVram(gUnknown_847A890[scene][0], (void *)BG_CHAR_ADDR(0));
|
LZ77UnCompVram(sBerryFixGraphics[scene][0], (void *)BG_CHAR_ADDR(0));
|
||||||
LZ77UnCompVram(gUnknown_847A890[scene][1], (void *)BG_SCREEN_ADDR(31));
|
LZ77UnCompVram(sBerryFixGraphics[scene][1], (void *)BG_SCREEN_ADDR(31));
|
||||||
CpuCopy16(gUnknown_847A890[scene][2], (void *)BG_PLTT, 0x200);
|
CpuCopy16(sBerryFixGraphics[scene][2], (void *)BG_PLTT, 0x200);
|
||||||
REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(31) | BGCNT_TXT256x256;
|
REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(31) | BGCNT_TXT256x256;
|
||||||
REG_DISPCNT = DISPCNT_BG0_ON;
|
REG_DISPCNT = DISPCNT_BG0_ON;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mb_berry_fix_serve(void) // noreturn
|
#define tState data[0]
|
||||||
|
#define tTimer data[1]
|
||||||
|
|
||||||
|
void CB2_InitBerryFixProgram(void)
|
||||||
{
|
{
|
||||||
u8 taskId;
|
u8 taskId;
|
||||||
DisableInterrupts(0xFFFF);
|
DisableInterrupts(0xFFFF);
|
||||||
@@ -91,96 +105,99 @@ void mb_berry_fix_serve(void) // noreturn
|
|||||||
ResetTasks();
|
ResetTasks();
|
||||||
ScanlineEffect_Stop();
|
ScanlineEffect_Stop();
|
||||||
gHelpSystemEnabled = FALSE;
|
gHelpSystemEnabled = FALSE;
|
||||||
taskId = CreateTask(mb_berry_fix_task, 0);
|
taskId = CreateTask(Task_BerryFixMain, 0);
|
||||||
gTasks[taskId].data[0] = 0;
|
gTasks[taskId].tState = STATE_BEGIN;
|
||||||
SetMainCallback2(mb_berry_fix_maincb);
|
SetMainCallback2(CB2_BerryFix);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mb_berry_fix_maincb(void)
|
static void CB2_BerryFix(void)
|
||||||
{
|
{
|
||||||
RunTasks();
|
RunTasks();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mb_berry_fix_task(u8 taskId)
|
static void Task_BerryFixMain(u8 taskId)
|
||||||
{
|
{
|
||||||
s16 * data = gTasks[taskId].data;
|
s16 * data = gTasks[taskId].data;
|
||||||
|
|
||||||
switch (data[0])
|
switch (tState)
|
||||||
{
|
{
|
||||||
case 0:
|
case STATE_BEGIN:
|
||||||
mb_berry_fix_print(5);
|
SetScene(SCENE_BEGIN);
|
||||||
data[0] = 1;
|
tState = STATE_CONNECT;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case STATE_CONNECT:
|
||||||
if (JOY_NEW(A_BUTTON))
|
if (JOY_NEW(A_BUTTON))
|
||||||
{
|
{
|
||||||
mb_berry_fix_print(0);
|
SetScene(SCENE_ENSURE_CONNECT);
|
||||||
data[0] = 2;
|
tState = STATE_TURN_OFF_POWER;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case STATE_TURN_OFF_POWER:
|
||||||
if (JOY_NEW(A_BUTTON))
|
if (JOY_NEW(A_BUTTON))
|
||||||
{
|
{
|
||||||
mb_berry_fix_print(1);
|
SetScene(SCENE_TURN_OFF_POWER);
|
||||||
data[0] = 4;
|
tState = STATE_INIT_MULTIBOOT;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case STATE_INIT_MULTIBOOT:
|
||||||
gUnknown_3005EF0 = gMultiBootProgram_BerryGlitchFix_Start;
|
gMultibootStart = gMultiBootProgram_BerryGlitchFix_Start;
|
||||||
gUnknown_3005EF8 = gMultiBootProgram_BerryGlitchFix_End - gMultiBootProgram_BerryGlitchFix_Start;
|
gMultibootSize = gMultiBootProgram_BerryGlitchFix_End - gMultiBootProgram_BerryGlitchFix_Start;
|
||||||
gUnknown_3005F00.masterp = (void *)gMultiBootProgram_BerryGlitchFix_Start;
|
gMultibootParam.masterp = (void *)gMultiBootProgram_BerryGlitchFix_Start;
|
||||||
gUnknown_3005F00.server_type = MULTIBOOT_SERVER_TYPE_NORMAL;
|
gMultibootParam.server_type = MULTIBOOT_SERVER_TYPE_NORMAL;
|
||||||
MultiBootInit(&gUnknown_3005F00);
|
MultiBootInit(&gMultibootParam);
|
||||||
data[1] = 0;
|
tTimer = 0;
|
||||||
data[0] = 5;
|
tState = STATE_MULTIBOOT;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case STATE_MULTIBOOT:
|
||||||
if (gUnknown_3005F00.probe_count == 0 && gUnknown_3005F00.response_bit & 0x2 && gUnknown_3005F00.client_bit & 0x2)
|
if (gMultibootParam.probe_count == 0 && gMultibootParam.response_bit & 0x2 && gMultibootParam.client_bit & 0x2)
|
||||||
{
|
{
|
||||||
data[1]++;
|
if (++tTimer > 180)
|
||||||
if (data[1] > 180)
|
|
||||||
{
|
{
|
||||||
mb_berry_fix_print(2);
|
SetScene(SCENE_TRANSMITTING);
|
||||||
MultiBootStartMaster(&gUnknown_3005F00, gUnknown_3005EF0 + MULTIBOOT_HEADER_SIZE, gUnknown_3005EF8 - MULTIBOOT_HEADER_SIZE, 4, 1);
|
MultiBootStartMaster(&gMultibootParam, gMultibootStart + MULTIBOOT_HEADER_SIZE, gMultibootSize - MULTIBOOT_HEADER_SIZE, 4, 1);
|
||||||
data[1] = 0;
|
tTimer = 0;
|
||||||
data[0] = 6;
|
tState = STATE_TRANSMIT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
gUnknown_3005EF4 = MultiBootMain(&gUnknown_3005F00);
|
{
|
||||||
|
gMultibootStatus = MultiBootMain(&gMultibootParam);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data[1] = 0;
|
tTimer = 0;
|
||||||
gUnknown_3005EF4 = MultiBootMain(&gUnknown_3005F00);
|
gMultibootStatus = MultiBootMain(&gMultibootParam);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 6:
|
case STATE_TRANSMIT:
|
||||||
gUnknown_3005EF4 = MultiBootMain(&gUnknown_3005F00);
|
gMultibootStatus = MultiBootMain(&gMultibootParam);
|
||||||
if (MultiBootCheckComplete(&gUnknown_3005F00))
|
if (MultiBootCheckComplete(&gMultibootParam))
|
||||||
{
|
{
|
||||||
mb_berry_fix_print(3);
|
SetScene(SCENE_FOLLOW_INSTRUCT);
|
||||||
data[0] = 7;
|
tState = STATE_SUCCEEDED;
|
||||||
|
}
|
||||||
|
else if (!(gMultibootParam.client_bit & 2))
|
||||||
|
{
|
||||||
|
tState = STATE_FAILED;
|
||||||
}
|
}
|
||||||
else if (!(gUnknown_3005F00.client_bit & 2))
|
|
||||||
data[0] = 9;
|
|
||||||
break;
|
break;
|
||||||
case 7:
|
case STATE_SUCCEEDED:
|
||||||
data[0] = 8;
|
tState = STATE_EXIT;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case STATE_EXIT:
|
||||||
if (JOY_NEW(A_BUTTON))
|
if (JOY_NEW(A_BUTTON))
|
||||||
{
|
{
|
||||||
DestroyTask(taskId);
|
DestroyTask(taskId);
|
||||||
DoSoftReset();
|
DoSoftReset();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 9:
|
case STATE_FAILED:
|
||||||
mb_berry_fix_print(4);
|
SetScene(SCENE_TRANSMIT_FAILED);
|
||||||
data[0] = 10;
|
tState = STATE_RETRY;
|
||||||
break;
|
break;
|
||||||
case 10:
|
case STATE_RETRY:
|
||||||
if (JOY_NEW(A_BUTTON))
|
if (JOY_NEW(A_BUTTON))
|
||||||
data[0] = 0;
|
tState = STATE_BEGIN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -897,7 +897,7 @@ static void CB2_FadeOutTransitionToBerryFix(void)
|
|||||||
if (!UpdatePaletteFade())
|
if (!UpdatePaletteFade())
|
||||||
{
|
{
|
||||||
m4aMPlayAllStop();
|
m4aMPlayAllStop();
|
||||||
SetMainCallback2(mb_berry_fix_serve);
|
SetMainCallback2(CB2_InitBerryFixProgram);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user