through sub_81237B4

This commit is contained in:
PikalaxALT 2017-10-30 08:46:36 -04:00
parent 474df27136
commit f6a55433a2
3 changed files with 29 additions and 80 deletions

View File

@ -5,81 +5,6 @@
.text
thumb_func_start sub_812378C
sub_812378C: @ 812378C
ldr r2, =gRegionMap
ldr r2, [r2]
lsls r0, 16
asrs r0, 8
movs r3, 0xE0
lsls r3, 5
adds r0, r3
str r0, [r2, 0x24]
lsls r1, 16
asrs r1, 8
movs r0, 0x90
lsls r0, 6
adds r1, r0
str r1, [r2, 0x28]
adds r2, 0x7D
movs r0, 0x1
strb r0, [r2]
bx lr
.pool
thumb_func_end sub_812378C
thumb_func_start sub_81237B4
sub_81237B4: @ 81237B4
push {r4,lr}
ldr r4, =gRegionMap
ldr r1, [r4]
adds r0, r1, 0
adds r0, 0x7D
ldrb r0, [r0]
cmp r0, 0
beq _0812381A
ldrh r1, [r1, 0x2C]
movs r0, 0x20
bl SetGpuReg
ldr r0, [r4]
ldrh r1, [r0, 0x34]
movs r0, 0x22
bl SetGpuReg
ldr r0, [r4]
ldrh r1, [r0, 0x30]
movs r0, 0x24
bl SetGpuReg
ldr r0, [r4]
ldrh r1, [r0, 0x38]
movs r0, 0x26
bl SetGpuReg
ldr r0, [r4]
ldrh r1, [r0, 0x24]
movs r0, 0x28
bl SetGpuReg
ldr r0, [r4]
ldrh r1, [r0, 0x26]
movs r0, 0x2A
bl SetGpuReg
ldr r0, [r4]
ldrh r1, [r0, 0x28]
movs r0, 0x2C
bl SetGpuReg
ldr r0, [r4]
ldrh r1, [r0, 0x2A]
movs r0, 0x2E
bl SetGpuReg
ldr r0, [r4]
adds r0, 0x7D
movs r1, 0
strb r1, [r0]
_0812381A:
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_81237B4
thumb_func_start sub_8123824
sub_8123824: @ 8123824
push {r4,r5,lr}

View File

@ -232,8 +232,8 @@ struct RegionMap {
/*0x024*/ s32 bg2x;
/*0x028*/ s32 bg2y;
/*0x02c*/ u32 bg2pa;
/*0x030*/ u32 bg2pb;
/*0x034*/ u32 bg2pc;
/*0x030*/ u32 bg2pb;
/*0x038*/ u32 bg2pd;
/*0x03c*/ s32 unk_03c;
/*0x040*/ s32 unk_040;

View File

@ -3,6 +3,7 @@
#include "global.h"
#include "main.h"
#include "menu.h"
#include "gpu_regs.h"
#include "palette.h"
#include "trig.h"
#include "region_map.h"
@ -454,17 +455,40 @@ void CalcZoomScrollParams(s16 scrollX, s16 scrollY, s16 c, s16 d, u16 e, u16 f,
s32 var4;
gRegionMap->bg2pa = e * gSineTable[rotation + 64] >> 8;
gRegionMap->bg2pb = e * -gSineTable[rotation] >> 8;
gRegionMap->bg2pc = f * gSineTable[rotation] >> 8;
gRegionMap->bg2pc = e * -gSineTable[rotation] >> 8;
gRegionMap->bg2pb = f * gSineTable[rotation] >> 8;
gRegionMap->bg2pd = f * gSineTable[rotation + 64] >> 8;
var1 = (scrollX << 8) + (c << 8);
var2 = d * gRegionMap->bg2pc + gRegionMap->bg2pa * c;
var2 = d * gRegionMap->bg2pb + gRegionMap->bg2pa * c;
gRegionMap->bg2x = var1 - var2;
var3 = (scrollY << 8) + (d << 8);
var4 = gRegionMap->bg2pd * d + gRegionMap->bg2pb * c;
var4 = gRegionMap->bg2pd * d + gRegionMap->bg2pc * c;
gRegionMap->bg2y = var3 - var4;
gRegionMap->needUpdateVideoRegs = TRUE;
}
void sub_812378C(s16 x, s16 y)
{
gRegionMap->bg2x = (x << 8) + 0x1c00;
gRegionMap->bg2y = (y << 8) + 0x2400;
gRegionMap->needUpdateVideoRegs = TRUE;
}
void sub_81237B4(void)
{
if (gRegionMap->needUpdateVideoRegs)
{
SetGpuReg(REG_OFFSET_BG2PA, gRegionMap->bg2pa);
SetGpuReg(REG_OFFSET_BG2PB, gRegionMap->bg2pb);
SetGpuReg(REG_OFFSET_BG2PC, gRegionMap->bg2pc);
SetGpuReg(REG_OFFSET_BG2PD, gRegionMap->bg2pd);
SetGpuReg(REG_OFFSET_BG2X_L, gRegionMap->bg2x);
SetGpuReg(REG_OFFSET_BG2X_H, gRegionMap->bg2x >> 16);
SetGpuReg(REG_OFFSET_BG2Y_L, gRegionMap->bg2y);
SetGpuReg(REG_OFFSET_BG2Y_H, gRegionMap->bg2y >> 16);
gRegionMap->needUpdateVideoRegs = FALSE;
}
}