2017-10-30 00:33:53 +01:00
|
|
|
|
|
|
|
// Includes
|
|
|
|
#include "global.h"
|
2017-10-30 02:14:53 +01:00
|
|
|
#include "main.h"
|
2017-10-30 01:49:49 +01:00
|
|
|
#include "menu.h"
|
|
|
|
#include "palette.h"
|
2017-10-30 13:39:39 +01:00
|
|
|
#include "trig.h"
|
|
|
|
#include "region_map.h"
|
2017-10-30 00:33:53 +01:00
|
|
|
|
|
|
|
// Static type declarations
|
|
|
|
|
|
|
|
struct UnkStruct_0203A148 {
|
|
|
|
u8 filler_000[0xa74];
|
|
|
|
};
|
|
|
|
|
|
|
|
// Static RAM declarations
|
|
|
|
|
2017-10-30 13:39:39 +01:00
|
|
|
EWRAM_DATA struct RegionMap *gRegionMap = NULL;
|
2017-10-30 00:33:53 +01:00
|
|
|
EWRAM_DATA struct UnkStruct_0203A148 *gUnknown_0203A148 = NULL;
|
|
|
|
|
|
|
|
// Static ROM declarations
|
|
|
|
|
2017-10-30 13:39:39 +01:00
|
|
|
static u8 ProcessRegionMapInput_Full(void);
|
|
|
|
static u8 MoveRegionMapCursor_Full(void);
|
|
|
|
static u8 ProcessRegionMapInput_Zoomed(void);
|
|
|
|
static u8 MoveRegionMapCursor_Zoomed(void);
|
|
|
|
void CalcZoomScrollParams(s16 scrollX, s16 scrollY, s16 c, s16 d, u16 e, u16 f, u8 rotation);
|
2017-10-30 02:14:53 +01:00
|
|
|
void sub_81237B4(void);
|
2017-10-30 01:49:49 +01:00
|
|
|
void sub_81238AC(void);
|
|
|
|
u8 get_flagnr_blue_points(u16 mapSecId);
|
2017-10-30 02:14:53 +01:00
|
|
|
u16 sub_8123EB4(u16 mapSecId);
|
2017-10-30 01:49:49 +01:00
|
|
|
void sub_8123FB0(void);
|
2017-10-30 02:31:38 +01:00
|
|
|
u16 sub_812386C(u16 x, u16 y);
|
2017-10-30 03:05:15 +01:00
|
|
|
void sub_812378C(s16 x, s16 y);
|
2017-10-30 04:08:06 +01:00
|
|
|
void sub_8124238(void);
|
|
|
|
void sub_81243B0(void);
|
2017-10-30 13:39:39 +01:00
|
|
|
void sub_81243DC(void);
|
2017-10-30 00:33:53 +01:00
|
|
|
|
|
|
|
// .rodata
|
|
|
|
|
2017-10-30 01:49:49 +01:00
|
|
|
extern const u8 gUnknown_0859F77C[];
|
|
|
|
extern const u8 gUnknown_085A04E0[];
|
|
|
|
extern const u16 gUnknown_0859F73C[];
|
|
|
|
extern const u8 gUnknown_0859F60C[];
|
|
|
|
extern const u8 gUnknown_0859F650[];
|
|
|
|
|
2017-10-30 00:33:53 +01:00
|
|
|
// .text
|
|
|
|
|
2017-10-30 13:39:39 +01:00
|
|
|
void InitRegionMap(struct RegionMap *regionMap, bool8 zoomed)
|
2017-10-30 00:33:53 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
sub_8122CF8(regionMap, NULL, zoomed);
|
2017-10-30 00:33:53 +01:00
|
|
|
while (sub_8122DB0());
|
|
|
|
}
|
|
|
|
|
2017-10-30 13:39:39 +01:00
|
|
|
void sub_8122CF8(struct RegionMap *regionMap, struct BgTemplate *template, bool8 zoomed)
|
2017-10-30 00:33:53 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap = regionMap;
|
|
|
|
gRegionMap->initStep = 0;
|
|
|
|
gRegionMap->zoomed = zoomed;
|
|
|
|
gRegionMap->inputCallback = zoomed == TRUE ? ProcessRegionMapInput_Zoomed : ProcessRegionMapInput_Full;
|
|
|
|
if (template != NULL)
|
2017-10-30 00:33:53 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->bgNum = template->bg;
|
|
|
|
gRegionMap->charBaseIdx = template->charBaseIndex;
|
|
|
|
gRegionMap->mapBaseIdx = template->mapBaseIndex;
|
|
|
|
gRegionMap->bgManaged = TRUE;
|
2017-10-30 00:33:53 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->bgNum = 2;
|
|
|
|
gRegionMap->charBaseIdx = 2;
|
|
|
|
gRegionMap->mapBaseIdx = 28;
|
|
|
|
gRegionMap->bgManaged = FALSE;
|
2017-10-30 00:33:53 +01:00
|
|
|
}
|
|
|
|
}
|
2017-10-30 01:49:49 +01:00
|
|
|
|
|
|
|
void sub_8122D88(struct RegionMap *regionMap)
|
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap = regionMap;
|
2017-10-30 01:49:49 +01:00
|
|
|
sub_81238AC();
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->unk_074 = gRegionMap->cursorPosX;
|
|
|
|
gRegionMap->unk_076 = gRegionMap->cursorPosY;
|
2017-10-30 01:49:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool8 sub_8122DB0(void)
|
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
switch (gRegionMap->initStep)
|
2017-10-30 01:49:49 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2017-10-30 13:39:39 +01:00
|
|
|
if (gRegionMap->bgManaged)
|
2017-10-30 01:49:49 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
decompress_and_copy_tile_data_to_vram(gRegionMap->bgNum, gUnknown_0859F77C, 0, 0, 0);
|
2017-10-30 01:49:49 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LZ77UnCompVram(gUnknown_0859F77C, (u16 *)BG_SCREEN_ADDR(16));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2017-10-30 13:39:39 +01:00
|
|
|
if (gRegionMap->bgManaged)
|
2017-10-30 01:49:49 +01:00
|
|
|
{
|
|
|
|
if (!free_temp_tile_data_buffers_if_possible())
|
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
decompress_and_copy_tile_data_to_vram(gRegionMap->bgNum, gUnknown_085A04E0, 0, 0, 1);
|
2017-10-30 01:49:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LZ77UnCompVram(gUnknown_085A04E0, (u16 *)BG_SCREEN_ADDR(28));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!free_temp_tile_data_buffers_if_possible())
|
|
|
|
{
|
|
|
|
LoadPalette(gUnknown_0859F73C, 0x70, 0x60);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2017-10-30 13:39:39 +01:00
|
|
|
LZ77UnCompWram(gUnknown_0859F60C, gRegionMap->cursorSmallImage);
|
2017-10-30 01:49:49 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2017-10-30 13:39:39 +01:00
|
|
|
LZ77UnCompWram(gUnknown_0859F650, gRegionMap->cursorLargeImage);
|
2017-10-30 01:49:49 +01:00
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
sub_81238AC();
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->unk_074 = gRegionMap->cursorPosX;
|
|
|
|
gRegionMap->unk_076 = gRegionMap->cursorPosY;
|
|
|
|
gRegionMap->mapSecId = sub_8123EB4(gRegionMap->mapSecId);
|
|
|
|
gRegionMap->unk_002 = get_flagnr_blue_points(gRegionMap->mapSecId);
|
|
|
|
GetMapName(gRegionMap->mapSecName, gRegionMap->mapSecId, 16);
|
2017-10-30 01:49:49 +01:00
|
|
|
break;
|
|
|
|
case 6:
|
2017-10-30 13:39:39 +01:00
|
|
|
if (gRegionMap->zoomed == FALSE)
|
2017-10-30 01:49:49 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
CalcZoomScrollParams(0, 0, 0, 0, 0x100, 0x100, 0);
|
2017-10-30 01:49:49 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->scrollX = gRegionMap->cursorPosX * 8 - 0x34;
|
|
|
|
gRegionMap->scrollY = gRegionMap->cursorPosY * 8 - 0x44;
|
|
|
|
gRegionMap->unk_064 = gRegionMap->cursorPosX;
|
|
|
|
gRegionMap->unk_066 = gRegionMap->cursorPosY;
|
|
|
|
CalcZoomScrollParams(gRegionMap->scrollX, gRegionMap->scrollY, 0x38, 0x48, 0x80, 0x80, 0);
|
2017-10-30 01:49:49 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
sub_8123FB0();
|
|
|
|
sub_81237B4();
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->cursorSprite = NULL;
|
|
|
|
gRegionMap->playerIconSprite = NULL;
|
|
|
|
gRegionMap->cursorMovementFrameCounter = 0;
|
|
|
|
gRegionMap->blinkPlayerIcon = FALSE;
|
|
|
|
if (gRegionMap->bgManaged)
|
2017-10-30 01:49:49 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
SetBgAttribute(gRegionMap->bgNum, BG_CTRL_ATTR_MAPBASEINDEX, 2);
|
|
|
|
SetBgAttribute(gRegionMap->bgNum, BG_CTRL_ATTR_VISIBLE, gRegionMap->charBaseIdx);
|
|
|
|
SetBgAttribute(gRegionMap->bgNum, BG_CTRL_ATTR_CHARBASEINDEX, gRegionMap->mapBaseIdx);
|
|
|
|
SetBgAttribute(gRegionMap->bgNum, BG_CTRL_ATTR_PRIORITY, 1);
|
|
|
|
SetBgAttribute(gRegionMap->bgNum, BG_CTRL_ATTR_SCREENSIZE, 1);
|
2017-10-30 01:49:49 +01:00
|
|
|
}
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->initStep ++;
|
2017-10-30 01:49:49 +01:00
|
|
|
return FALSE;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->initStep ++;
|
2017-10-30 01:49:49 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
2017-10-30 01:58:53 +01:00
|
|
|
|
|
|
|
void sub_8123030(u16 a0, u32 a1)
|
|
|
|
{
|
|
|
|
BlendPalettes(0x380, a1, a0);
|
|
|
|
CpuCopy16(gPlttBufferFaded + 0x70, gPlttBufferUnfaded + 0x70, 0x60);
|
|
|
|
}
|
|
|
|
|
2017-10-30 13:39:39 +01:00
|
|
|
void FreeRegionMapIconResources(void)
|
2017-10-30 01:58:53 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
if (gRegionMap->cursorSprite != NULL)
|
2017-10-30 01:58:53 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
DestroySprite(gRegionMap->cursorSprite);
|
|
|
|
FreeSpriteTilesByTag(gRegionMap->cursorTileTag);
|
|
|
|
FreeSpritePaletteByTag(gRegionMap->cursorPaletteTag);
|
2017-10-30 01:58:53 +01:00
|
|
|
}
|
2017-10-30 13:39:39 +01:00
|
|
|
if (gRegionMap->playerIconSprite != NULL)
|
2017-10-30 01:58:53 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
DestroySprite(gRegionMap->playerIconSprite);
|
|
|
|
FreeSpriteTilesByTag(gRegionMap->playerIconTileTag);
|
|
|
|
FreeSpritePaletteByTag(gRegionMap->playerIconPaletteTag);
|
2017-10-30 01:58:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 sub_81230AC(void)
|
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
return gRegionMap->inputCallback();
|
2017-10-30 01:58:53 +01:00
|
|
|
}
|
2017-10-30 02:14:53 +01:00
|
|
|
|
2017-10-30 13:39:39 +01:00
|
|
|
static u8 ProcessRegionMapInput_Full(void)
|
2017-10-30 02:14:53 +01:00
|
|
|
{
|
|
|
|
u8 input;
|
|
|
|
|
|
|
|
input = INPUT_EVENT_NONE;
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->cursorDeltaX = 0;
|
|
|
|
gRegionMap->cursorDeltaY = 0;
|
|
|
|
if (gMain.heldKeys & DPAD_UP && gRegionMap->cursorPosY > 2)
|
2017-10-30 02:14:53 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->cursorDeltaY = -1;
|
2017-10-30 02:31:38 +01:00
|
|
|
input = INPUT_EVENT_MOVE_START;
|
2017-10-30 02:14:53 +01:00
|
|
|
}
|
2017-10-30 13:39:39 +01:00
|
|
|
if (gMain.heldKeys & DPAD_DOWN && gRegionMap->cursorPosY < 16)
|
2017-10-30 02:14:53 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->cursorDeltaY = +1;
|
2017-10-30 02:31:38 +01:00
|
|
|
input = INPUT_EVENT_MOVE_START;
|
2017-10-30 02:14:53 +01:00
|
|
|
}
|
2017-10-30 13:39:39 +01:00
|
|
|
if (gMain.heldKeys & DPAD_LEFT && gRegionMap->cursorPosX > 1)
|
2017-10-30 02:14:53 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->cursorDeltaX = -1;
|
2017-10-30 02:31:38 +01:00
|
|
|
input = INPUT_EVENT_MOVE_START;
|
2017-10-30 02:14:53 +01:00
|
|
|
}
|
2017-10-30 13:39:39 +01:00
|
|
|
if (gMain.heldKeys & DPAD_RIGHT && gRegionMap->cursorPosX < 28)
|
2017-10-30 02:14:53 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->cursorDeltaX = +1;
|
2017-10-30 02:31:38 +01:00
|
|
|
input = INPUT_EVENT_MOVE_START;
|
2017-10-30 02:14:53 +01:00
|
|
|
}
|
|
|
|
if (gMain.newKeys & A_BUTTON)
|
|
|
|
{
|
|
|
|
input = INPUT_EVENT_A_BUTTON;
|
|
|
|
}
|
|
|
|
else if (gMain.newKeys & B_BUTTON)
|
|
|
|
{
|
|
|
|
input = INPUT_EVENT_B_BUTTON;
|
|
|
|
}
|
2017-10-30 02:31:38 +01:00
|
|
|
if (input == INPUT_EVENT_MOVE_START)
|
2017-10-30 02:14:53 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->cursorMovementFrameCounter = 4;
|
|
|
|
gRegionMap->inputCallback = MoveRegionMapCursor_Full;
|
2017-10-30 02:14:53 +01:00
|
|
|
}
|
|
|
|
return input;
|
|
|
|
}
|
2017-10-30 02:31:38 +01:00
|
|
|
|
2017-10-30 13:39:39 +01:00
|
|
|
static u8 MoveRegionMapCursor_Full(void)
|
2017-10-30 02:31:38 +01:00
|
|
|
{
|
|
|
|
u16 mapSecId;
|
|
|
|
|
2017-10-30 13:39:39 +01:00
|
|
|
if (gRegionMap->cursorMovementFrameCounter != 0)
|
2017-10-30 02:31:38 +01:00
|
|
|
{
|
|
|
|
return INPUT_EVENT_MOVE_CONT;
|
|
|
|
}
|
2017-10-30 13:39:39 +01:00
|
|
|
if (gRegionMap->cursorDeltaX > 0)
|
2017-10-30 02:31:38 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->cursorPosX ++;
|
2017-10-30 02:31:38 +01:00
|
|
|
}
|
2017-10-30 13:39:39 +01:00
|
|
|
if (gRegionMap->cursorDeltaX < 0)
|
2017-10-30 02:31:38 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->cursorPosX --;
|
2017-10-30 02:31:38 +01:00
|
|
|
}
|
2017-10-30 13:39:39 +01:00
|
|
|
if (gRegionMap->cursorDeltaY > 0)
|
2017-10-30 02:31:38 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->cursorPosY ++;
|
2017-10-30 02:31:38 +01:00
|
|
|
}
|
2017-10-30 13:39:39 +01:00
|
|
|
if (gRegionMap->cursorDeltaY < 0)
|
2017-10-30 02:31:38 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->cursorPosY --;
|
2017-10-30 02:31:38 +01:00
|
|
|
}
|
2017-10-30 13:39:39 +01:00
|
|
|
mapSecId = sub_812386C(gRegionMap->cursorPosX, gRegionMap->cursorPosY);
|
|
|
|
gRegionMap->unk_002 = get_flagnr_blue_points(mapSecId);
|
|
|
|
if (mapSecId != gRegionMap->mapSecId)
|
2017-10-30 02:31:38 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->mapSecId = mapSecId;
|
|
|
|
GetMapName(gRegionMap->mapSecName, gRegionMap->mapSecId, 16);
|
2017-10-30 02:31:38 +01:00
|
|
|
}
|
|
|
|
sub_8123FB0();
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->inputCallback = ProcessRegionMapInput_Full;
|
2017-10-30 02:31:38 +01:00
|
|
|
return INPUT_EVENT_MOVE_END;
|
|
|
|
}
|
2017-10-30 02:38:45 +01:00
|
|
|
|
2017-10-30 13:39:39 +01:00
|
|
|
static u8 ProcessRegionMapInput_Zoomed(void)
|
2017-10-30 02:38:45 +01:00
|
|
|
{
|
|
|
|
u8 input;
|
|
|
|
|
|
|
|
input = INPUT_EVENT_NONE;
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->zoomedCursorDeltaX = 0;
|
|
|
|
gRegionMap->zoomedCursorDeltaY = 0;
|
|
|
|
if (gMain.heldKeys & DPAD_UP && gRegionMap->scrollY > -0x34)
|
2017-10-30 02:38:45 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->zoomedCursorDeltaY = -1;
|
2017-10-30 02:38:45 +01:00
|
|
|
input = INPUT_EVENT_MOVE_START;
|
|
|
|
}
|
2017-10-30 13:39:39 +01:00
|
|
|
if (gMain.heldKeys & DPAD_DOWN && gRegionMap->scrollY < 0x3c)
|
2017-10-30 02:38:45 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->zoomedCursorDeltaY = +1;
|
2017-10-30 02:38:45 +01:00
|
|
|
input = INPUT_EVENT_MOVE_START;
|
|
|
|
}
|
2017-10-30 13:39:39 +01:00
|
|
|
if (gMain.heldKeys & DPAD_LEFT && gRegionMap->scrollX > -0x2c)
|
2017-10-30 02:38:45 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->zoomedCursorDeltaX = -1;
|
2017-10-30 02:38:45 +01:00
|
|
|
input = INPUT_EVENT_MOVE_START;
|
|
|
|
}
|
2017-10-30 13:39:39 +01:00
|
|
|
if (gMain.heldKeys & DPAD_RIGHT && gRegionMap->scrollX < 0xac)
|
2017-10-30 02:38:45 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->zoomedCursorDeltaX = +1;
|
2017-10-30 02:38:45 +01:00
|
|
|
input = INPUT_EVENT_MOVE_START;
|
|
|
|
}
|
|
|
|
if (gMain.newKeys & A_BUTTON)
|
|
|
|
{
|
|
|
|
input = INPUT_EVENT_A_BUTTON;
|
|
|
|
}
|
|
|
|
if (gMain.newKeys & B_BUTTON)
|
|
|
|
{
|
|
|
|
input = INPUT_EVENT_B_BUTTON;
|
|
|
|
}
|
|
|
|
if (input == INPUT_EVENT_MOVE_START)
|
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->inputCallback = MoveRegionMapCursor_Zoomed;
|
|
|
|
gRegionMap->zoomedCursorMovementFrameCounter = 0;
|
2017-10-30 02:38:45 +01:00
|
|
|
}
|
|
|
|
return input;
|
|
|
|
}
|
2017-10-30 03:05:15 +01:00
|
|
|
|
2017-10-30 13:39:39 +01:00
|
|
|
static u8 MoveRegionMapCursor_Zoomed(void)
|
2017-10-30 03:05:15 +01:00
|
|
|
{
|
|
|
|
u16 x;
|
|
|
|
u16 y;
|
|
|
|
u16 mapSecId;
|
|
|
|
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->scrollY += gRegionMap->zoomedCursorDeltaY;
|
|
|
|
gRegionMap->scrollX += gRegionMap->zoomedCursorDeltaX;
|
|
|
|
sub_812378C(gRegionMap->scrollX, gRegionMap->scrollY);
|
|
|
|
gRegionMap->zoomedCursorMovementFrameCounter ++;
|
|
|
|
if (gRegionMap->zoomedCursorMovementFrameCounter == 8)
|
2017-10-30 03:05:15 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
x = (gRegionMap->scrollX + 0x2c) / 8 + 1;
|
|
|
|
y = (gRegionMap->scrollY + 0x34) / 8 + 2;
|
|
|
|
if (x != gRegionMap->unk_064 || y != gRegionMap->unk_066)
|
2017-10-30 03:05:15 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->unk_064 = x;
|
|
|
|
gRegionMap->unk_066 = y;
|
2017-10-30 03:05:15 +01:00
|
|
|
mapSecId = sub_812386C(x, y);
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->unk_002 = get_flagnr_blue_points(mapSecId);
|
|
|
|
if (mapSecId != gRegionMap->mapSecId)
|
2017-10-30 03:05:15 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->mapSecId = mapSecId;
|
|
|
|
GetMapName(gRegionMap->mapSecName, gRegionMap->mapSecId, 16);
|
2017-10-30 03:05:15 +01:00
|
|
|
}
|
|
|
|
sub_8123FB0();
|
|
|
|
}
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->zoomedCursorMovementFrameCounter = 0;
|
|
|
|
gRegionMap->inputCallback = ProcessRegionMapInput_Zoomed;
|
2017-10-30 03:05:15 +01:00
|
|
|
return INPUT_EVENT_MOVE_END;
|
|
|
|
}
|
2017-10-30 04:08:06 +01:00
|
|
|
return INPUT_EVENT_MOVE_CONT;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_8123418(void)
|
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
if (gRegionMap->zoomed == FALSE)
|
2017-10-30 04:08:06 +01:00
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->scrollY = 0;
|
|
|
|
gRegionMap->scrollX = 0;
|
|
|
|
gRegionMap->unk_040 = 0;
|
|
|
|
gRegionMap->unk_03c = 0;
|
|
|
|
gRegionMap->unk_060 = gRegionMap->cursorPosX * 8 - 0x34;
|
|
|
|
gRegionMap->unk_062 = gRegionMap->cursorPosY * 8 - 0x44;
|
|
|
|
gRegionMap->unk_044 = (gRegionMap->unk_060 << 8) / 16;
|
|
|
|
gRegionMap->unk_048 = (gRegionMap->unk_062 << 8) / 16;
|
|
|
|
gRegionMap->unk_064 = gRegionMap->cursorPosX;
|
|
|
|
gRegionMap->unk_066 = gRegionMap->cursorPosY;
|
|
|
|
gRegionMap->unk_04c = 0x10000;
|
|
|
|
gRegionMap->unk_050 = -0x800;
|
2017-10-30 04:08:06 +01:00
|
|
|
}
|
2017-10-30 03:05:15 +01:00
|
|
|
else
|
|
|
|
{
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->unk_03c = gRegionMap->scrollX * 256;
|
|
|
|
gRegionMap->unk_040 = gRegionMap->scrollY * 256;
|
|
|
|
gRegionMap->unk_060 = 0;
|
|
|
|
gRegionMap->unk_062 = 0;
|
|
|
|
gRegionMap->unk_044 = -(gRegionMap->unk_03c / 16);
|
|
|
|
gRegionMap->unk_048 = -(gRegionMap->unk_040 / 16);
|
|
|
|
gRegionMap->cursorPosX = gRegionMap->unk_064;
|
|
|
|
gRegionMap->cursorPosY = gRegionMap->unk_066;
|
|
|
|
gRegionMap->unk_04c = 0x8000;
|
|
|
|
gRegionMap->unk_050 = 0x800;
|
2017-10-30 03:05:15 +01:00
|
|
|
}
|
2017-10-30 13:39:39 +01:00
|
|
|
gRegionMap->unk_06e = 0;
|
2017-10-30 04:08:06 +01:00
|
|
|
sub_8124238();
|
|
|
|
sub_81243B0();
|
2017-10-30 03:05:15 +01:00
|
|
|
}
|
2017-10-30 13:39:39 +01:00
|
|
|
|
|
|
|
u8 sub_8123514(void)
|
|
|
|
{
|
|
|
|
u8 r4;
|
|
|
|
|
|
|
|
if (gRegionMap->unk_06e >= 16)
|
|
|
|
return 0;
|
|
|
|
gRegionMap->unk_06e ++;
|
|
|
|
if (gRegionMap->unk_06e == 16)
|
|
|
|
{
|
|
|
|
gRegionMap->unk_044 = 0;
|
|
|
|
gRegionMap->unk_048 = 0;
|
|
|
|
gRegionMap->scrollX = gRegionMap->unk_060;
|
|
|
|
gRegionMap->scrollY = gRegionMap->unk_062;
|
|
|
|
gRegionMap->unk_04c = (gRegionMap->zoomed == FALSE) ? (128 << 8) : (256 << 8);
|
|
|
|
gRegionMap->zoomed = !gRegionMap->zoomed;
|
|
|
|
gRegionMap->inputCallback = (gRegionMap->zoomed == FALSE) ? ProcessRegionMapInput_Full : ProcessRegionMapInput_Zoomed;
|
|
|
|
CreateRegionMapCursor(gRegionMap->cursorTileTag, gRegionMap->cursorPaletteTag);
|
|
|
|
sub_81243DC();
|
|
|
|
r4 = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gRegionMap->unk_03c += gRegionMap->unk_044;
|
|
|
|
gRegionMap->unk_040 += gRegionMap->unk_048;
|
|
|
|
gRegionMap->scrollX = gRegionMap->unk_03c >> 8;
|
|
|
|
gRegionMap->scrollY = gRegionMap->unk_040 >> 8;
|
|
|
|
gRegionMap->unk_04c += gRegionMap->unk_050;
|
|
|
|
if ((gRegionMap->unk_044 < 0 && gRegionMap->scrollX < gRegionMap->unk_060)
|
|
|
|
|| (gRegionMap->unk_044 > 0 && gRegionMap->scrollX > gRegionMap->unk_060))
|
|
|
|
{
|
|
|
|
gRegionMap->scrollX = gRegionMap->unk_060;
|
|
|
|
gRegionMap->unk_044 = 0;
|
|
|
|
}
|
|
|
|
if ((gRegionMap->unk_048 < 0 && gRegionMap->scrollY < gRegionMap->unk_062)
|
|
|
|
|| (gRegionMap->unk_048 > 0 && gRegionMap->scrollY > gRegionMap->unk_062))
|
|
|
|
{
|
|
|
|
gRegionMap->scrollY = gRegionMap->unk_062;
|
|
|
|
gRegionMap->unk_048 = 0;
|
|
|
|
}
|
|
|
|
if (gRegionMap->zoomed == FALSE)
|
|
|
|
{
|
|
|
|
if (gRegionMap->unk_04c < (128 << 8))
|
|
|
|
{
|
|
|
|
gRegionMap->unk_04c = (128 << 8);
|
|
|
|
gRegionMap->unk_050 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gRegionMap->unk_04c > (256 << 8))
|
|
|
|
{
|
|
|
|
gRegionMap->unk_04c = (256 << 8);
|
|
|
|
gRegionMap->unk_050 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
r4 = 1;
|
|
|
|
}
|
|
|
|
CalcZoomScrollParams(gRegionMap->scrollX, gRegionMap->scrollY, 0x38, 0x48, gRegionMap->unk_04c >> 8, gRegionMap->unk_04c >> 8, 0);
|
|
|
|
return r4;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CalcZoomScrollParams(s16 scrollX, s16 scrollY, s16 c, s16 d, u16 e, u16 f, u8 rotation)
|
|
|
|
{
|
|
|
|
s32 var1;
|
|
|
|
s32 var2;
|
|
|
|
s32 var3;
|
|
|
|
s32 var4;
|
|
|
|
|
|
|
|
gRegionMap->bg2pa = e * gSineTable[rotation + 64] >> 8;
|
|
|
|
gRegionMap->bg2pb = e * -gSineTable[rotation] >> 8;
|
|
|
|
gRegionMap->bg2pc = f * gSineTable[rotation] >> 8;
|
|
|
|
gRegionMap->bg2pd = f * gSineTable[rotation + 64] >> 8;
|
|
|
|
|
|
|
|
var1 = (scrollX << 8) + (c << 8);
|
|
|
|
var2 = d * gRegionMap->bg2pc + gRegionMap->bg2pa * c;
|
|
|
|
gRegionMap->bg2x = var1 - var2;
|
|
|
|
|
|
|
|
var3 = (scrollY << 8) + (d << 8);
|
|
|
|
var4 = gRegionMap->bg2pd * d + gRegionMap->bg2pb * c;
|
|
|
|
gRegionMap->bg2y = var3 - var4;
|
|
|
|
|
|
|
|
gRegionMap->needUpdateVideoRegs = TRUE;
|
|
|
|
}
|