More battle factory work

This commit is contained in:
DizzyEggg 2018-09-02 19:41:33 +02:00
parent 10eb952db5
commit 0238b1c8ec
6 changed files with 612 additions and 1073 deletions

View File

@ -6,719 +6,6 @@
.text
thumb_func_start sub_819AB40
sub_819AB40: @ 819AB40
push {r4-r6,lr}
movs r4, 0
_0819AB44:
ldr r6, =gUnknown_0300127C
ldr r1, [r6]
movs r0, 0x6C
muls r0, r4
adds r1, r0
ldrh r1, [r1, 0xE]
lsls r0, r1, 4
adds r0, r1
lsls r0, 2
ldr r5, =gSprites
adds r0, r5
bl DestroySprite
adds r0, r4, 0x1
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0x5
bls _0819AB44
ldr r0, [r6]
ldrb r1, [r0, 0x4]
lsls r0, r1, 4
adds r0, r1
lsls r0, 2
adds r0, r5
bl DestroySprite
ldr r0, [r6]
ldrb r1, [r0, 0x1]
lsls r0, r1, 4
adds r0, r1
lsls r0, 2
adds r0, r5
bl DestroySprite
ldr r0, [r6]
ldrb r1, [r0, 0x2]
lsls r0, r1, 4
adds r0, r1
lsls r0, 2
adds r0, r5
bl DestroySprite
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end sub_819AB40
thumb_func_start sub_819ABA8
sub_819ABA8: @ 819ABA8
push {r4,lr}
lsls r0, 24
cmp r0, 0
ble _0819ABC8
ldr r0, =gUnknown_0300127C
ldr r1, [r0]
ldrb r3, [r1, 0x3]
adds r2, r0, 0
cmp r3, 0x5
beq _0819ABC4
adds r0, r3, 0x1
b _0819ABDE
.pool
_0819ABC4:
movs r0, 0
b _0819ABDE
_0819ABC8:
ldr r0, =gUnknown_0300127C
ldr r1, [r0]
ldrb r3, [r1, 0x3]
adds r2, r0, 0
cmp r3, 0
beq _0819ABDC
subs r0, r3, 0x1
b _0819ABDE
.pool
_0819ABDC:
movs r0, 0x5
_0819ABDE:
strb r0, [r1, 0x3]
ldr r2, [r2]
ldrb r3, [r2, 0x3]
ldr r4, =gSprites
ldrb r0, [r2, 0x4]
lsls r1, r0, 4
adds r1, r0
lsls r1, 2
adds r1, r4
movs r0, 0x6C
muls r0, r3
adds r2, r0
ldrh r2, [r2, 0xE]
lsls r0, r2, 4
adds r0, r2
lsls r0, 2
adds r0, r4
ldrh r0, [r0, 0x20]
strh r0, [r1, 0x20]
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_819ABA8
thumb_func_start sub_819AC10
sub_819AC10: @ 819AC10
push {lr}
lsls r0, 24
cmp r0, 0
ble _0819AC30
ldr r0, =gUnknown_0300127C
ldr r1, [r0]
ldrb r3, [r1]
adds r2, r0, 0
cmp r3, 0x2
beq _0819AC2C
adds r0, r3, 0x1
b _0819AC46
.pool
_0819AC2C:
movs r0, 0
b _0819AC46
_0819AC30:
ldr r0, =gUnknown_0300127C
ldr r1, [r0]
ldrb r3, [r1]
adds r2, r0, 0
cmp r3, 0
beq _0819AC44
subs r0, r3, 0x1
b _0819AC46
.pool
_0819AC44:
movs r0, 0x2
_0819AC46:
strb r0, [r1]
ldr r3, =gSprites
ldr r2, [r2]
ldrb r0, [r2, 0x1]
lsls r1, r0, 4
adds r1, r0
lsls r1, 2
adds r1, r3
ldrb r0, [r2]
lsls r0, 4
adds r0, 0x70
strh r0, [r1, 0x22]
ldrb r0, [r2, 0x2]
lsls r1, r0, 4
adds r1, r0
lsls r1, 2
adds r1, r3
ldrb r0, [r2]
lsls r0, 4
adds r0, 0x70
strh r0, [r1, 0x22]
pop {r0}
bx r0
.pool
thumb_func_end sub_819AC10
thumb_func_start sub_819AC78
sub_819AC78: @ 819AC78
push {lr}
lsls r0, 24
cmp r0, 0
ble _0819AC98
ldr r0, =gUnknown_0300127C
ldr r1, [r0]
ldrb r3, [r1, 0x7]
adds r2, r0, 0
cmp r3, 0x1
beq _0819AC94
adds r0, r3, 0x1
b _0819ACAE
.pool
_0819AC94:
movs r0, 0
b _0819ACAE
_0819AC98:
ldr r0, =gUnknown_0300127C
ldr r1, [r0]
ldrb r3, [r1, 0x7]
adds r2, r0, 0
cmp r3, 0
beq _0819ACAC
subs r0, r3, 0x1
b _0819ACAE
.pool
_0819ACAC:
movs r0, 0x1
_0819ACAE:
strb r0, [r1, 0x7]
ldr r3, =gSprites
ldr r2, [r2]
ldrb r0, [r2, 0x1]
lsls r1, r0, 4
adds r1, r0
lsls r1, 2
adds r1, r3
ldrb r0, [r2, 0x7]
lsls r0, 4
adds r0, 0x70
strh r0, [r1, 0x22]
ldrb r0, [r2, 0x2]
lsls r1, r0, 4
adds r1, r0
lsls r1, 2
adds r1, r3
ldrb r0, [r2, 0x7]
lsls r0, 4
adds r0, 0x70
strh r0, [r1, 0x22]
pop {r0}
bx r0
.pool
thumb_func_end sub_819AC78
thumb_func_start sub_819ACE0
sub_819ACE0: @ 819ACE0
push {r4-r6,lr}
ldr r5, =gUnknown_0300127C
ldr r0, [r5]
ldrb r6, [r0, 0x3]
movs r1, 0x6C
adds r4, r6, 0
muls r4, r1
adds r0, r4
ldrb r0, [r0, 0x10]
cmp r0, 0
beq _0819AD60
movs r0, 0x64
bl IndexOfSpritePaletteTag
lsls r0, 24
lsrs r3, r0, 24
ldr r1, [r5]
ldrb r0, [r1, 0x5]
cmp r0, 0x3
bne _0819AD44
adds r0, r1, r4
ldrb r0, [r0, 0x10]
cmp r0, 0x1
bne _0819AD44
movs r2, 0
ldrb r0, [r1, 0x10]
cmp r0, 0x2
beq _0819AD32
movs r4, 0x6C
_0819AD1A:
adds r0, r2, 0x1
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0x5
bhi _0819AD32
ldr r0, [r5]
adds r1, r2, 0
muls r1, r4
adds r0, r1
ldrb r0, [r0, 0x10]
cmp r0, 0x2
bne _0819AD1A
_0819AD32:
cmp r2, 0x6
beq _0819AD9C
ldr r0, =gUnknown_0300127C
ldr r1, [r0]
movs r0, 0x6C
muls r0, r2
adds r1, r0
movs r0, 0x1
strb r0, [r1, 0x10]
_0819AD44:
ldr r2, =gUnknown_0300127C
ldr r1, [r2]
movs r0, 0x6C
muls r0, r6
adds r1, r0
movs r0, 0
strb r0, [r1, 0x10]
ldr r1, [r2]
ldrb r0, [r1, 0x5]
subs r0, 0x1
b _0819AD78
.pool
_0819AD60:
movs r0, 0x65
bl IndexOfSpritePaletteTag
lsls r0, 24
lsrs r3, r0, 24
ldr r0, [r5]
adds r1, r0, r4
ldrb r0, [r0, 0x5]
strb r0, [r1, 0x10]
ldr r1, [r5]
ldrb r0, [r1, 0x5]
adds r0, 0x1
_0819AD78:
strb r0, [r1, 0x5]
ldr r2, =gSprites
ldr r0, =gUnknown_0300127C
ldr r0, [r0]
movs r1, 0x6C
muls r1, r6
adds r0, r1
ldrh r0, [r0, 0xE]
lsls r1, r0, 4
adds r1, r0
lsls r1, 2
adds r1, r2
lsls r3, 4
ldrb r2, [r1, 0x5]
movs r0, 0xF
ands r0, r2
orrs r0, r3
strb r0, [r1, 0x5]
_0819AD9C:
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end sub_819ACE0
thumb_func_start SetBallSpritePaletteNum
SetBallSpritePaletteNum: @ 819ADAC
push {r4,lr}
lsls r0, 24
lsrs r4, r0, 24
ldr r0, =gUnknown_0300127C
ldr r0, [r0]
movs r1, 0x6C
muls r1, r4
adds r0, r1
ldrb r0, [r0, 0x10]
cmp r0, 0
beq _0819ADCC
movs r0, 0x65
b _0819ADCE
.pool
_0819ADCC:
movs r0, 0x64
_0819ADCE:
bl IndexOfSpritePaletteTag
lsls r0, 24
lsrs r3, r0, 24
ldr r2, =gSprites
ldr r0, =gUnknown_0300127C
ldr r0, [r0]
movs r1, 0x6C
muls r1, r4
adds r0, r1
ldrh r0, [r0, 0xE]
lsls r1, r0, 4
adds r1, r0
lsls r1, 2
adds r1, r2
lsls r3, 4
ldrb r2, [r1, 0x5]
movs r0, 0xF
ands r0, r2
orrs r0, r3
strb r0, [r1, 0x5]
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end SetBallSpritePaletteNum
thumb_func_start sub_819AE08
sub_819AE08: @ 819AE08
push {r4-r6,lr}
sub sp, 0x4
lsls r0, 24
lsrs r2, r0, 24
ldr r1, =gTasks
lsls r0, r2, 2
adds r0, r2
lsls r0, 3
adds r6, r0, r1
movs r1, 0x8
ldrsh r0, [r6, r1]
cmp r0, 0x7
beq _0819AE64
cmp r0, 0x7
bgt _0819AE30
cmp r0, 0x6
beq _0819AE36
b _0819AF50
.pool
_0819AE30:
cmp r0, 0x8
beq _0819AEE8
b _0819AF50
_0819AE36:
ldr r1, =gPlttBufferUnfaded
ldr r0, =gPlttBufferFaded
movs r2, 0xE4
lsls r2, 1
adds r0, r2
ldrh r0, [r0]
adds r1, r2
movs r2, 0
strh r0, [r1]
movs r0, 0x1
negs r0, r0
str r2, [sp]
movs r1, 0
movs r3, 0x10
bl BeginNormalPaletteFade
movs r0, 0x7
strh r0, [r6, 0x8]
b _0819AF50
.pool
_0819AE64:
ldr r0, =gPaletteFade
ldrb r1, [r0, 0x7]
movs r0, 0x80
ands r0, r1
lsls r0, 24
lsrs r5, r0, 24
cmp r5, 0
bne _0819AF50
ldr r4, =gUnknown_0300127C
ldr r0, [r4]
ldr r2, =0x000002a1
adds r0, r2
ldrb r0, [r0]
bl DestroyTask
ldr r1, [r4]
movs r3, 0xA6
lsls r3, 2
adds r0, r1, r3
ldr r0, [r0]
movs r2, 0xA8
lsls r2, 2
adds r1, r2
bl sub_819F444
bl sub_819AB40
ldr r4, =gUnknown_0203CE2C
ldr r0, [r4]
bl Free
str r5, [r4]
ldr r4, =gUnknown_0203CE30
ldr r0, [r4]
bl Free
str r5, [r4]
ldr r4, =gUnknown_0203CE34
ldr r0, [r4]
bl Free
str r5, [r4]
ldr r4, =gUnknown_0203CE38
ldr r0, [r4]
bl Free
str r5, [r4]
bl FreeAllWindowBuffers
movs r0, 0x8
strh r0, [r6, 0x8]
b _0819AF50
.pool
_0819AEE8:
ldr r4, =gUnknown_0300127C
ldr r1, [r4]
ldr r0, =gPlttBufferUnfaded
movs r3, 0xE4
lsls r3, 1
adds r0, r3
ldrh r0, [r0]
adds r3, 0xDC
adds r1, r3
strh r0, [r1]
adds r0, r2, 0
bl DestroyTask
ldr r1, [r4]
movs r0, 0x1
strb r0, [r1, 0x6]
ldr r0, [r4]
ldrb r6, [r0, 0x3]
ldr r4, =gUnknown_0203CE3C
movs r0, 0x96
lsls r0, 2
bl AllocZeroed
str r0, [r4]
movs r4, 0
_0819AF1A:
ldr r5, =gUnknown_0203CE3C
ldr r1, [r5]
movs r0, 0x64
muls r0, r4
adds r0, r1
ldr r1, =gUnknown_0300127C
ldr r1, [r1]
movs r2, 0x6C
muls r2, r4
adds r1, r2
adds r1, 0x14
movs r2, 0x64
bl memcpy
adds r0, r4, 0x1
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0x5
bls _0819AF1A
ldr r1, [r5]
ldr r0, =sub_819A514
str r0, [sp]
movs r0, 0x1
adds r2, r6, 0
movs r3, 0x5
bl ShowPokemonSummaryScreen
_0819AF50:
add sp, 0x4
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end sub_819AE08
thumb_func_start bc_exit_to_overworld
bc_exit_to_overworld: @ 819AF68
push {r4-r7,lr}
sub sp, 0x4
lsls r0, 24
lsrs r6, r0, 24
ldr r7, =gUnknown_0300127C
ldr r0, [r7]
movs r1, 0xA8
lsls r1, 2
adds r0, r1
ldrb r0, [r0]
cmp r0, 0x1
beq _0819B00E
ldr r1, =gTasks
lsls r0, r6, 2
adds r0, r6
lsls r0, 3
adds r4, r0, r1
movs r0, 0x8
ldrsh r1, [r4, r0]
cmp r1, 0
beq _0819AFA0
cmp r1, 0x1
beq _0819AFB8
b _0819B00E
.pool
_0819AFA0:
movs r0, 0x1
negs r0, r0
str r1, [sp]
movs r1, 0
movs r2, 0
movs r3, 0x10
bl BeginNormalPaletteFade
ldrh r0, [r4, 0x8]
adds r0, 0x1
strh r0, [r4, 0x8]
b _0819B00E
_0819AFB8:
bl UpdatePaletteFade
lsls r0, 24
lsrs r5, r0, 24
cmp r5, 0
bne _0819B00E
bl sub_819B764
ldr r0, [r7]
ldr r1, =0x000002a1
adds r0, r1
ldrb r0, [r0]
bl DestroyTask
bl sub_819AB40
ldr r4, =gUnknown_0203CE2C
ldr r0, [r4]
bl Free
str r5, [r4]
ldr r4, =gUnknown_0203CE34
ldr r0, [r4]
bl Free
str r5, [r4]
ldr r4, =gUnknown_0203CE38
ldr r0, [r4]
bl Free
str r5, [r4]
ldr r0, [r7]
bl Free
str r5, [r7]
bl FreeAllWindowBuffers
ldr r0, =CB2_ReturnToFieldContinueScript
bl SetMainCallback2
adds r0, r6, 0
bl DestroyTask
_0819B00E:
add sp, 0x4
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end bc_exit_to_overworld
thumb_func_start sub_819B02C
sub_819B02C: @ 819B02C
push {r4-r7,lr}
mov r7, r8
push {r7}
lsls r0, 24
lsrs r2, r0, 24
ldr r7, =gUnknown_0300127C
ldr r0, [r7]
movs r1, 0xA8
lsls r1, 2
adds r0, r1
ldrb r0, [r0]
cmp r0, 0x1
beq _0819B11A
ldr r1, =gTasks
lsls r0, r2, 2
adds r0, r2
lsls r0, 3
adds r5, r0, r1
movs r1, 0x8
ldrsh r0, [r5, r1]
cmp r0, 0x5
beq _0819B084
cmp r0, 0x5
bgt _0819B06C
cmp r0, 0x4
beq _0819B07A
b _0819B11A
.pool
_0819B06C:
cmp r0, 0xA
bne _0819B11A
bl sub_819C4B4
movs r0, 0x4
strh r0, [r5, 0x8]
b _0819B11A
_0819B07A:
bl sub_819B8D4
movs r0, 0x5
strh r0, [r5, 0x8]
b _0819B11A
_0819B084:
ldr r2, =gMain
ldrh r1, [r2, 0x2E]
movs r0, 0x1
mov r8, r0
movs r6, 0x1
adds r0, r6, 0
ands r0, r1
cmp r0, 0
beq _0819B0B8
movs r0, 0x5
bl PlaySE
ldr r0, [r7]
ldrb r4, [r0, 0x7]
cmp r4, 0
bne _0819B0C6
bl sub_819C568
strh r4, [r5, 0x8]
ldr r0, =bc_exit_to_overworld
str r0, [r5]
b _0819B11A
.pool
_0819B0B8:
movs r0, 0x2
ands r0, r1
cmp r0, 0
beq _0819B0EC
movs r0, 0x5
bl PlaySE
_0819B0C6:
movs r0, 0x4
bl sub_819B958
bl sub_819BC9C
ldr r0, [r7]
ldr r1, =0x000002a2
adds r0, r1
mov r1, r8
strb r1, [r0]
strh r6, [r5, 0x8]
ldr r0, =sub_819B378
str r0, [r5]
b _0819B11A
.pool
_0819B0EC:
ldrh r1, [r2, 0x30]
movs r0, 0x40
ands r0, r1
cmp r0, 0
beq _0819B106
movs r0, 0x5
bl PlaySE
movs r0, 0x1
negs r0, r0
bl sub_819AC78
b _0819B11A
_0819B106:
movs r0, 0x80
ands r0, r1
cmp r0, 0
beq _0819B11A
movs r0, 0x5
bl PlaySE
movs r0, 0x1
bl sub_819AC78
_0819B11A:
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end sub_819B02C
thumb_func_start sub_819B124
sub_819B124: @ 819B124
@ -836,7 +123,7 @@ _0819B228:
adds r0, r1
movs r1, 0xA
strh r1, [r0, 0x8]
ldr r1, =sub_819B02C
ldr r1, =Task_HandleSelectionScreenYesNo
str r1, [r0]
b _0819B36E
.pool
@ -860,7 +147,7 @@ _0819B260:
adds r0, r1
movs r1, 0x6
strh r1, [r0, 0x8]
ldr r1, =sub_819AE08
ldr r1, =Task_FromSelectScreenToSummaryScreen
str r1, [r0]
b _0819B36E
.pool
@ -909,7 +196,7 @@ _0819B2D0:
bl PlaySE
movs r0, 0x1
negs r0, r0
bl sub_819AC10
bl UpdateMenuCursorPosition
b _0819B36E
_0819B2EA:
movs r0, 0x80
@ -919,7 +206,7 @@ _0819B2EA:
movs r0, 0x5
bl PlaySE
movs r0, 0x1
bl sub_819AC10
bl UpdateMenuCursorPosition
b _0819B36E
_0819B300:
ldr r0, =gPaletteFade
@ -1065,7 +352,7 @@ _0819B422:
bl PlaySE
movs r0, 0x1
_0819B432:
bl sub_819ABA8
bl UpdateBallCursorPosition
bl sub_819BCF8
bl sub_819B9E8
b _0819B476
@ -2041,7 +1328,7 @@ _0819BC60:
adds r1, r2
movs r2, 0
bl sub_819F3F8
bl sub_819ACE0
bl HandleMonSelectionChange
bl sub_819BA64
movs r0, 0x3
bl sub_819B958
@ -2064,7 +1351,7 @@ _0819BC96:
sub_819BC9C: @ 819BC9C
push {lr}
bl sub_819C568
bl sub_819ACE0
bl HandleMonSelectionChange
bl sub_819BA64
movs r0, 0x3
bl sub_819B958

View File

@ -1,6 +1,7 @@
#ifndef GUARD_POKEMON_SUMMARY_SCREEN_H
#define GUARD_POKEMON_SUMMARY_SCREEN_H
void ShowPokemonSummaryScreen(u8 mode, void *mons, u8 monIndex, u8 maxMonIndex, void (*callback)(void));
void sub_81C4F98(u8, void(*)(void));
void ShowSelectMovePokemonSummaryScreen(struct Pokemon *, u8, u8, MainCallback, u16);

View File

@ -247,6 +247,7 @@ SECTIONS {
src/battle_frontier_1.o(.text);
asm/battle_frontier_1.o(.text);
src/menu.o(.text);
src/battle_factory.o(.text);
asm/battle_frontier_2.o(.text);
src/item_menu.o(.text);
src/list_menu.o(.text);

602
src/battle_factory.c Normal file
View File

@ -0,0 +1,602 @@
#include "global.h"
#include "sprite.h"
#include "event_data.h"
#include "overworld.h"
#include "random.h"
#include "battle_tower.h"
#include "text.h"
#include "palette.h"
#include "task.h"
#include "main.h"
#include "malloc.h"
#include "bg.h"
#include "gpu_regs.h"
#include "window.h"
#include "decompress.h"
#include "pokemon_summary_screen.h"
#include "sound.h"
#include "constants/battle_frontier.h"
#include "constants/songs.h"
#define MENU_SUMMARY 0
#define MENU_RENT 1
#define MENU_DESELECT 1
#define MENU_OTHERS 2
#define MENU_OPTIONS_COUNT 3
#define SELECTABLE_MONS_COUNT 6
#define TAG_PAL_BALL_GREY 0x64
#define TAG_PAL_BALL_SELECTED 0x65
struct FactorySelecteableMon
{
u16 unk0;
u16 spriteId;
u8 selectetedId; // 0 - not selected, 1 - first pokemon, 2 - second pokemon, 3 - third pokemon
struct Pokemon monData;
};
struct FactorySelectMonsStruct
{
u8 menuCursorPos;
u8 menuCursor1SpriteId;
u8 menuCursor2SpriteId;
u8 cursorPos;
u8 cursorSpriteId;
u8 selectingMonsState;
bool8 fromSummaryScreen;
u8 yesNoCursorPos;
u8 unk8;
u8 unk9;
struct FactorySelecteableMon mons[SELECTABLE_MONS_COUNT];
u32 unk294;
u32 unk298;
u32 unk29C;
u8 unk2A0;
u8 unk2A1;
u8 unk2A2;
u8 unk2A3;
u16 unk2A4;
u16 unk2A6;
u16 unk2A8;
u16 unk2AA;
};
extern struct FactorySelectMonsStruct *gUnknown_0300127C;
extern u8 gUnknown_0203CF20;
// This file's functions.
void sub_819A514(void);
void sub_819C5D0(u16 mWin0H, u16 nWin0H, u16 mWin0V, u16 nWin0V);
void sub_819A9AC(void);
void sub_819AA18(void);
void sub_819BE34(void);
void sub_819BA64(void);
void sub_819BCF8(void);
void sub_819B9E8(void);
void sub_819B9B4(void);
void sub_819B764(void);
void sub_819C4B4(void);
void sub_819B8D4(void);
void sub_819C568(void);
void sub_819BC9C(void);
void sub_819C69C(u8 taskId);
void sub_819B378(u8 taskId);
void sub_819B124(u8 taskId);
void sub_819B484(u8 arg0);
void sub_819B63C(u8 arg0);
void SetBallSpritePaletteNum(u8 id);
void sub_819F444(u32 spriteId, u8 *arg1);
void sub_819B958(u8 arg0);
// Ewram variables
EWRAM_DATA u8 *gUnknown_0203CE2C = NULL;
EWRAM_DATA u8 *gUnknown_0203CE30 = NULL;
EWRAM_DATA u8 *gUnknown_0203CE34 = NULL;
EWRAM_DATA u8 *gUnknown_0203CE38 = NULL;
static EWRAM_DATA struct Pokemon *sFactorySelectMons = NULL;
// Const rom data.
extern const struct BgTemplate gUnknown_08610428[3];
extern const struct WindowTemplate gUnknown_08610434[];
extern const u8 gUnknown_0861033C[];
extern const u8 gUnknown_0861023C[];
extern const u16 gUnknown_0861046C[];
extern const u16 gUnknown_0861039C[];
extern const struct SpritePalette gUnknown_086103F4[];
extern const struct SpriteSheet gUnknown_086103BC[];
extern const struct CompressedSpriteSheet gUnknown_086103E4[];
extern const struct SpriteTemplate gUnknown_086105D8;
// gfx
extern const u8 gFrontierFactorySelectMenu_Gfx[];
extern const u8 gFrontierFactorySelectMenu_Tilemap[];
extern const u16 gFrontierFactorySelectMenu_Pal[];
// code
void sub_819A44C(struct Sprite *sprite)
{
if (sprite->oam.paletteNum == IndexOfSpritePaletteTag(TAG_PAL_BALL_SELECTED))
{
if (sprite->animEnded)
{
if (sprite->data[0] != 0)
{
sprite->data[0]--;
}
else if (Random() % 5 == 0)
{
StartSpriteAnim(sprite, 0);
sprite->data[0] = 32;
}
else
{
StartSpriteAnim(sprite, 1);
}
}
else
{
StartSpriteAnimIfDifferent(sprite, 1);
}
}
else
{
StartSpriteAnimIfDifferent(sprite, 0);
}
}
void sub_819A4C8(void)
{
AnimateSprites();
BuildOamBuffer();
RunTextPrinters();
UpdatePaletteFade();
RunTasks();
}
void sub_819A4E4(void)
{
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
}
void sub_819A4F8(void)
{
gUnknown_0300127C = NULL;
SetMainCallback2(sub_819A514);
}
void sub_819A514(void)
{
u8 taskId;
switch (gMain.state)
{
case 0:
if (sFactorySelectMons != NULL)
FREE_AND_SET_NULL(sFactorySelectMons);
SetHBlankCallback(NULL);
SetVBlankCallback(NULL);
CpuFill32(0, (void *)VRAM, VRAM_SIZE);
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, gUnknown_08610428, ARRAY_COUNT(gUnknown_08610428));
InitWindows(gUnknown_08610434);
DeactivateAllTextPrinters();
gMain.state++;
break;
case 1:
gUnknown_0203CE2C = Alloc(0x440);
gUnknown_0203CE30 = AllocZeroed(0x440);
gUnknown_0203CE34 = Alloc(0x800);
gUnknown_0203CE38 = AllocZeroed(0x800);
ChangeBgX(0, 0, 0);
ChangeBgY(0, 0, 0);
ChangeBgX(1, 0, 0);
ChangeBgY(1, 0, 0);
ChangeBgX(3, 0, 0);
ChangeBgY(3, 0, 0);
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 0);
SetGpuReg(REG_OFFSET_MOSAIC, 0);
SetGpuReg(REG_OFFSET_WIN0H, 0);
SetGpuReg(REG_OFFSET_WIN0V, 0);
SetGpuReg(REG_OFFSET_WIN1H, 0);
SetGpuReg(REG_OFFSET_WIN1V, 0);
SetGpuReg(REG_OFFSET_WININ, 0);
SetGpuReg(REG_OFFSET_WINOUT, 0);
gMain.state++;
break;
case 2:
ResetPaletteFade();
ResetSpriteData();
ResetTasks();
FreeAllSpritePalettes();
CpuCopy16(gFrontierFactorySelectMenu_Gfx, gUnknown_0203CE2C, 0x440);
CpuCopy16(gUnknown_0861033C, gUnknown_0203CE30, 0x60);
LoadBgTiles(1, gUnknown_0203CE2C, 0x440, 0);
LoadBgTiles(3, gUnknown_0203CE30, 0x60, 0);
CpuCopy16(gFrontierFactorySelectMenu_Tilemap, gUnknown_0203CE34, 0x800);
LoadBgTilemap(1, gUnknown_0203CE34, 0x800, 0);
LoadPalette(gFrontierFactorySelectMenu_Pal, 0, 0x40);
LoadPalette(gUnknown_0861046C, 0xF0, 8);
LoadPalette(gUnknown_0861046C, 0xE0, 10);
if (gUnknown_0300127C->fromSummaryScreen == TRUE)
gPlttBufferUnfaded[228] = gUnknown_0300127C->unk2A4;
LoadPalette(gUnknown_0861039C, 0x20, 4);
gMain.state++;
break;
case 3:
SetBgTilemapBuffer(3, gUnknown_0203CE38);
CopyToBgTilemapBufferRect(3, gUnknown_0861023C, 11, 4, 8, 8);
CopyToBgTilemapBufferRect(3, gUnknown_0861023C, 2, 4, 8, 8);
CopyToBgTilemapBufferRect(3, gUnknown_0861023C, 20, 4, 8, 8);
CopyBgTilemapBufferToVram(3);
gMain.state++;
break;
case 4:
LoadSpritePalettes(gUnknown_086103F4);
LoadSpriteSheets(gUnknown_086103BC);
LoadCompressedObjectPic(gUnknown_086103E4);
ShowBg(0);
ShowBg(1);
SetVBlankCallback(sub_819A4E4);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0);
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_OBJ_1D_MAP);
if (gUnknown_0300127C->fromSummaryScreen == TRUE)
{
sub_819C5D0(88, 152, 32, 96);
ShowBg(3);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG3 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_OBJ);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(11, 4));
}
else
{
HideBg(3);
}
gMain.state++;
break;
case 5:
if (gUnknown_0300127C->fromSummaryScreen == TRUE)
gUnknown_0300127C->cursorPos = gUnknown_0203CF20;
sub_819A9AC();
sub_819AA18();
if (gUnknown_0300127C->fromSummaryScreen == TRUE)
sub_819BE34();
gMain.state++;
break;
case 6:
sub_819BA64();
PutWindowTilemap(2);
gMain.state++;
break;
case 7:
sub_819BCF8();
PutWindowTilemap(5);
gMain.state++;
break;
case 8:
sub_819B9E8();
PutWindowTilemap(1);
gMain.state++;
break;
case 9:
sub_819B9B4();
PutWindowTilemap(0);
gMain.state++;
break;
case 10:
gUnknown_0300127C->unk2A1 = CreateTask(sub_819C69C, 0);
if (!gUnknown_0300127C->fromSummaryScreen)
{
gTasks[gUnknown_0300127C->unk2A1].data[0] = 0;
taskId = CreateTask(sub_819B378, 0);
gTasks[taskId].data[0] = 0;
}
else
{
gTasks[gUnknown_0300127C->unk2A1].data[0] = 1;
gUnknown_0300127C->unk2A2 = 0;
taskId = CreateTask(sub_819B124, 0);
gTasks[taskId].data[0] = 13;
}
SetMainCallback2(sub_819A4C8);
break;
}
}
void sub_819A9AC(void)
{
u8 i;
if (gUnknown_0300127C != NULL)
return;
gUnknown_0300127C = AllocZeroed(sizeof(*gUnknown_0300127C));
gUnknown_0300127C->cursorPos = 0;
gUnknown_0300127C->selectingMonsState = 1;
gUnknown_0300127C->fromSummaryScreen = FALSE;
for (i = 0; i < SELECTABLE_MONS_COUNT; i++)
gUnknown_0300127C->mons[i].selectetedId = 0;
if (gSaveBlock2Ptr->frontier.lvlMode != FRONTIER_LVL_TENT)
sub_819B484(0);
else
sub_819B63C(0);
}
extern const struct SpriteTemplate gUnknown_086105F0;
extern const struct SpriteTemplate gUnknown_08610608;
extern const struct SpriteTemplate gUnknown_08610620;
void sub_819AA18(void)
{
u8 i, cursorPos;
s16 x;
for (i = 0; i < SELECTABLE_MONS_COUNT; i++)
{
gUnknown_0300127C->mons[i].spriteId = CreateSprite(&gUnknown_086105D8, (35 * i) + 32, 64, 1);
gSprites[gUnknown_0300127C->mons[i].spriteId].data[0] = 0;
SetBallSpritePaletteNum(i);
}
cursorPos = gUnknown_0300127C->cursorPos;
x = gSprites[gUnknown_0300127C->mons[cursorPos].spriteId].pos1.x;
gUnknown_0300127C->cursorSpriteId = CreateSprite(&gUnknown_086105F0, x, 88, 0);
gUnknown_0300127C->menuCursor1SpriteId = CreateSprite(&gUnknown_08610608, 176, 112, 0);
gUnknown_0300127C->menuCursor2SpriteId = CreateSprite(&gUnknown_08610620, 176, 144, 0);
gSprites[gUnknown_0300127C->menuCursor1SpriteId].invisible = 1;
gSprites[gUnknown_0300127C->menuCursor2SpriteId].invisible = 1;
gSprites[gUnknown_0300127C->menuCursor1SpriteId].centerToCornerVecX = 0;
gSprites[gUnknown_0300127C->menuCursor1SpriteId].centerToCornerVecY = 0;
gSprites[gUnknown_0300127C->menuCursor2SpriteId].centerToCornerVecX = 0;
gSprites[gUnknown_0300127C->menuCursor2SpriteId].centerToCornerVecY = 0;
}
void sub_819AB40(void)
{
u8 i;
for (i = 0; i < SELECTABLE_MONS_COUNT; i++)
DestroySprite(&gSprites[gUnknown_0300127C->mons[i].spriteId]);
DestroySprite(&gSprites[gUnknown_0300127C->cursorSpriteId]);
DestroySprite(&gSprites[gUnknown_0300127C->menuCursor1SpriteId]);
DestroySprite(&gSprites[gUnknown_0300127C->menuCursor2SpriteId]);
}
void UpdateBallCursorPosition(s8 direction)
{
u8 cursorPos;
if (direction > 0) // Move cursor right.
{
if (gUnknown_0300127C->cursorPos != SELECTABLE_MONS_COUNT - 1)
gUnknown_0300127C->cursorPos++;
else
gUnknown_0300127C->cursorPos = 0;
}
else // Move cursor left.
{
if (gUnknown_0300127C->cursorPos != 0)
gUnknown_0300127C->cursorPos--;
else
gUnknown_0300127C->cursorPos = SELECTABLE_MONS_COUNT - 1;
}
cursorPos = gUnknown_0300127C->cursorPos;
gSprites[gUnknown_0300127C->cursorSpriteId].pos1.x = gSprites[gUnknown_0300127C->mons[cursorPos].spriteId].pos1.x;
}
void UpdateMenuCursorPosition(s8 direction)
{
if (direction > 0) // Move cursor down.
{
if (gUnknown_0300127C->menuCursorPos != MENU_OPTIONS_COUNT - 1)
gUnknown_0300127C->menuCursorPos++;
else
gUnknown_0300127C->menuCursorPos = 0;
}
else // Move cursor up.
{
if (gUnknown_0300127C->menuCursorPos != 0)
gUnknown_0300127C->menuCursorPos--;
else
gUnknown_0300127C->menuCursorPos = MENU_OPTIONS_COUNT - 1;
}
gSprites[gUnknown_0300127C->menuCursor1SpriteId].pos1.y = (gUnknown_0300127C->menuCursorPos * 16) + 112;
gSprites[gUnknown_0300127C->menuCursor2SpriteId].pos1.y = (gUnknown_0300127C->menuCursorPos * 16) + 112;
}
void UpdateYesNoCursorPosition(s8 direction)
{
if (direction > 0) // Move cursor down.
{
if (gUnknown_0300127C->yesNoCursorPos != 1)
gUnknown_0300127C->yesNoCursorPos++;
else
gUnknown_0300127C->yesNoCursorPos = 0;
}
else // Move cursor up.
{
if (gUnknown_0300127C->yesNoCursorPos != 0)
gUnknown_0300127C->yesNoCursorPos--;
else
gUnknown_0300127C->yesNoCursorPos = 1;
}
gSprites[gUnknown_0300127C->menuCursor1SpriteId].pos1.y = (gUnknown_0300127C->yesNoCursorPos * 16) + 112;
gSprites[gUnknown_0300127C->menuCursor2SpriteId].pos1.y = (gUnknown_0300127C->yesNoCursorPos * 16) + 112;
}
void HandleMonSelectionChange(void)
{
u8 i, paletteNum;
u8 cursorPos = gUnknown_0300127C->cursorPos;
if (gUnknown_0300127C->mons[cursorPos].selectetedId) // Deselect a mon.
{
paletteNum = IndexOfSpritePaletteTag(TAG_PAL_BALL_GREY);
if (gUnknown_0300127C->selectingMonsState == 3 && gUnknown_0300127C->mons[cursorPos].selectetedId == 1)
{
for (i = 0; i < SELECTABLE_MONS_COUNT; i++)
{
if (gUnknown_0300127C->mons[i].selectetedId == 2)
break;
}
if (i == SELECTABLE_MONS_COUNT)
return;
else
gUnknown_0300127C->mons[i].selectetedId = 1;
}
gUnknown_0300127C->mons[cursorPos].selectetedId = 0;
gUnknown_0300127C->selectingMonsState--;
}
else // Select a mon.
{
paletteNum = IndexOfSpritePaletteTag(TAG_PAL_BALL_SELECTED);
gUnknown_0300127C->mons[cursorPos].selectetedId = gUnknown_0300127C->selectingMonsState;
gUnknown_0300127C->selectingMonsState++;
}
gSprites[gUnknown_0300127C->mons[cursorPos].spriteId].oam.paletteNum = paletteNum;
}
void SetBallSpritePaletteNum(u8 id)
{
u8 palNum;
if (gUnknown_0300127C->mons[id].selectetedId)
palNum = IndexOfSpritePaletteTag(TAG_PAL_BALL_SELECTED);
else
palNum = IndexOfSpritePaletteTag(TAG_PAL_BALL_GREY);
gSprites[gUnknown_0300127C->mons[id].spriteId].oam.paletteNum = palNum;
}
void Task_FromSelectScreenToSummaryScreen(u8 taskId)
{
u8 i;
u8 currMonId;
switch (gTasks[taskId].data[0])
{
case 6:
gPlttBufferUnfaded[228] = gPlttBufferFaded[228];
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0);
gTasks[taskId].data[0] = 7;
break;
case 7:
if (!gPaletteFade.active)
{
DestroyTask(gUnknown_0300127C->unk2A1);
sub_819F444(gUnknown_0300127C->unk298, &gUnknown_0300127C->unk2A0);
sub_819AB40();
FREE_AND_SET_NULL(gUnknown_0203CE2C);
FREE_AND_SET_NULL(gUnknown_0203CE30);
FREE_AND_SET_NULL(gUnknown_0203CE34);
FREE_AND_SET_NULL(gUnknown_0203CE38);
FreeAllWindowBuffers();
gTasks[taskId].data[0] = 8;
}
break;
case 8:
gUnknown_0300127C->unk2A4 = gPlttBufferUnfaded[228];
DestroyTask(taskId);
gUnknown_0300127C->fromSummaryScreen = TRUE;
currMonId = gUnknown_0300127C->cursorPos;
sFactorySelectMons = AllocZeroed(sizeof(struct Pokemon) * SELECTABLE_MONS_COUNT);
for (i = 0; i < SELECTABLE_MONS_COUNT; i++)
sFactorySelectMons[i] = gUnknown_0300127C->mons[i].monData;
ShowPokemonSummaryScreen(1, sFactorySelectMons, currMonId, SELECTABLE_MONS_COUNT - 1, sub_819A514);
break;
}
}
void Task_CloseSelectionScreen(u8 taskId)
{
if (gUnknown_0300127C->unk2A0 != 1)
{
switch (gTasks[taskId].data[0])
{
case 0:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0);
gTasks[taskId].data[0]++;
break;
case 1:
if (!UpdatePaletteFade())
{
sub_819B764();
DestroyTask(gUnknown_0300127C->unk2A1);
sub_819AB40();
FREE_AND_SET_NULL(gUnknown_0203CE2C);
FREE_AND_SET_NULL(gUnknown_0203CE34);
FREE_AND_SET_NULL(gUnknown_0203CE38);
FREE_AND_SET_NULL(gUnknown_0300127C);
FreeAllWindowBuffers();
SetMainCallback2(CB2_ReturnToFieldContinueScript);
DestroyTask(taskId);
}
break;
}
}
}
void Task_HandleSelectionScreenYesNo(u8 taskId)
{
if (gUnknown_0300127C->unk2A0 != 1)
{
switch (gTasks[taskId].data[0])
{
case 10:
sub_819C4B4();
gTasks[taskId].data[0] = 4;
break;
case 4:
sub_819B8D4();
gTasks[taskId].data[0] = 5;
break;
case 5:
if (gMain.newKeys & A_BUTTON)
{
PlaySE(SE_SELECT);
if (gUnknown_0300127C->yesNoCursorPos == 0)
{
sub_819C568();
gTasks[taskId].data[0] = 0;
gTasks[taskId].func = Task_CloseSelectionScreen;
}
else
{
sub_819B958(4);
sub_819BC9C();
gUnknown_0300127C->unk2A2 = 1;
gTasks[taskId].data[0] = 1;
gTasks[taskId].func = sub_819B378;
}
}
else if (gMain.newKeys & B_BUTTON)
{
PlaySE(SE_SELECT);
sub_819B958(4);
sub_819BC9C();
gUnknown_0300127C->unk2A2 = 1;
gTasks[taskId].data[0] = 1;
gTasks[taskId].func = sub_819B378;
}
else if (gMain.newAndRepeatedKeys & DPAD_UP)
{
PlaySE(SE_SELECT);
UpdateYesNoCursorPosition(-1);
}
else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
{
PlaySE(SE_SELECT);
UpdateYesNoCursorPosition(1);
}
break;
}
}
}

View File

@ -1,337 +0,0 @@
#include "global.h"
#include "sprite.h"
#include "event_data.h"
#include "overworld.h"
#include "random.h"
#include "battle_tower.h"
#include "text.h"
#include "palette.h"
#include "task.h"
#include "main.h"
#include "malloc.h"
#include "bg.h"
#include "gpu_regs.h"
#include "window.h"
#include "decompress.h"
#include "constants/battle_frontier.h"
#define SELECTABLE_MONS_COUNT 6
#define TAG_PAL_BALL_GREY 0x64
#define TAG_PAL_BALL_SELECTED 0x65
struct FactorySelecteableMon
{
u16 unk0;
u16 spriteId;
bool8 selected;
u8 filler6[0x6A - 6];
u8 unk6A;
};
struct UnkStructTempName
{
u8 menuCursorPos;
u8 unk1;
u8 unk2;
u8 cursorPos;
u8 unk4;
u8 unk5;
bool8 fromSummaryScreen;
u8 unk7;
u8 unk8;
u8 unk9;
struct FactorySelecteableMon mons[SELECTABLE_MONS_COUNT];
u8 filler294[0x2a1 - 0x294];
u8 unk2A1;
u8 unk2A2;
u8 unk2A3;
u16 unk2A4;
u16 unk2A6;
u16 unk2A8;
u16 unk2AA;
};
extern struct UnkStructTempName *gUnknown_0300127C;
extern u8 *gUnknown_0203CE2C;
extern u8 *gUnknown_0203CE30;
extern u8 *gUnknown_0203CE34;
extern u8 *gUnknown_0203CE38;
extern struct Pokemon *gUnknown_0203CE3C;
extern u8 gUnknown_0203CF20;
// This file's functions.
void sub_819A514(void);
void sub_819C5D0(u16 mWin0H, u16 nWin0H, u16 mWin0V, u16 nWin0V);
void sub_819A9AC(void);
void sub_819AA18(void);
void sub_819BE34(void);
void sub_819BA64(void);
void sub_819BCF8(void);
void sub_819B9E8(void);
void sub_819B9B4(void);
void sub_819C69C(u8 taskId);
void sub_819B378(u8 taskId);
void sub_819B124(u8 taskId);
void sub_819B484(u8 arg0);
void sub_819B63C(u8 arg0);
void SetBallSpritePaletteNum(u8 id);
// Const rom data.
extern const struct BgTemplate gUnknown_08610428[3];
extern const struct WindowTemplate gUnknown_08610434[];
extern const u8 gUnknown_0861033C[];
extern const u8 gUnknown_0861023C[];
extern const u16 gUnknown_0861046C[];
extern const u16 gUnknown_0861039C[];
extern const struct SpritePalette gUnknown_086103F4[];
extern const struct SpriteSheet gUnknown_086103BC[];
extern const struct CompressedSpriteSheet gUnknown_086103E4[];
extern const struct SpriteTemplate gUnknown_086105D8;
// gfx
extern const u8 gFrontierFactorySelectMenu_Gfx[];
extern const u8 gFrontierFactorySelectMenu_Tilemap[];
extern const u16 gFrontierFactorySelectMenu_Pal[];
// code
void sub_819A44C(struct Sprite *sprite)
{
if (sprite->oam.paletteNum == IndexOfSpritePaletteTag(TAG_PAL_BALL_SELECTED))
{
if (sprite->animEnded)
{
if (sprite->data[0] != 0)
{
sprite->data[0]--;
}
else if (Random() % 5 == 0)
{
StartSpriteAnim(sprite, 0);
sprite->data[0] = 32;
}
else
{
StartSpriteAnim(sprite, 1);
}
}
else
{
StartSpriteAnimIfDifferent(sprite, 1);
}
}
else
{
StartSpriteAnimIfDifferent(sprite, 0);
}
}
void sub_819A4C8(void)
{
AnimateSprites();
BuildOamBuffer();
RunTextPrinters();
UpdatePaletteFade();
RunTasks();
}
void sub_819A4E4(void)
{
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
}
void sub_819A4F8(void)
{
gUnknown_0300127C = NULL;
SetMainCallback2(sub_819A514);
}
void sub_819A514(void)
{
u8 taskId;
switch (gMain.state)
{
case 0:
if (gUnknown_0203CE3C != NULL)
FREE_AND_SET_NULL(gUnknown_0203CE3C);
SetHBlankCallback(NULL);
SetVBlankCallback(NULL);
CpuFill32(0, (void *)VRAM, VRAM_SIZE);
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, gUnknown_08610428, ARRAY_COUNT(gUnknown_08610428));
InitWindows(gUnknown_08610434);
DeactivateAllTextPrinters();
gMain.state++;
break;
case 1:
gUnknown_0203CE2C = Alloc(0x440);
gUnknown_0203CE30 = AllocZeroed(0x440);
gUnknown_0203CE34 = Alloc(0x800);
gUnknown_0203CE38 = AllocZeroed(0x800);
ChangeBgX(0, 0, 0);
ChangeBgY(0, 0, 0);
ChangeBgX(1, 0, 0);
ChangeBgY(1, 0, 0);
ChangeBgX(3, 0, 0);
ChangeBgY(3, 0, 0);
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 0);
SetGpuReg(REG_OFFSET_MOSAIC, 0);
SetGpuReg(REG_OFFSET_WIN0H, 0);
SetGpuReg(REG_OFFSET_WIN0V, 0);
SetGpuReg(REG_OFFSET_WIN1H, 0);
SetGpuReg(REG_OFFSET_WIN1V, 0);
SetGpuReg(REG_OFFSET_WININ, 0);
SetGpuReg(REG_OFFSET_WINOUT, 0);
gMain.state++;
break;
case 2:
ResetPaletteFade();
ResetSpriteData();
ResetTasks();
FreeAllSpritePalettes();
CpuCopy16(gFrontierFactorySelectMenu_Gfx, gUnknown_0203CE2C, 0x440);
CpuCopy16(gUnknown_0861033C, gUnknown_0203CE30, 0x60);
LoadBgTiles(1, gUnknown_0203CE2C, 0x440, 0);
LoadBgTiles(3, gUnknown_0203CE30, 0x60, 0);
CpuCopy16(gFrontierFactorySelectMenu_Tilemap, gUnknown_0203CE34, 0x800);
LoadBgTilemap(1, gUnknown_0203CE34, 0x800, 0);
LoadPalette(gFrontierFactorySelectMenu_Pal, 0, 0x40);
LoadPalette(gUnknown_0861046C, 0xF0, 8);
LoadPalette(gUnknown_0861046C, 0xE0, 10);
if (gUnknown_0300127C->fromSummaryScreen == TRUE)
gPlttBufferUnfaded[228] = gUnknown_0300127C->unk2A4;
LoadPalette(gUnknown_0861039C, 0x20, 4);
gMain.state++;
break;
case 3:
SetBgTilemapBuffer(3, gUnknown_0203CE38);
CopyToBgTilemapBufferRect(3, gUnknown_0861023C, 11, 4, 8, 8);
CopyToBgTilemapBufferRect(3, gUnknown_0861023C, 2, 4, 8, 8);
CopyToBgTilemapBufferRect(3, gUnknown_0861023C, 20, 4, 8, 8);
CopyBgTilemapBufferToVram(3);
gMain.state++;
break;
case 4:
LoadSpritePalettes(gUnknown_086103F4);
LoadSpriteSheets(gUnknown_086103BC);
LoadCompressedObjectPic(gUnknown_086103E4);
ShowBg(0);
ShowBg(1);
SetVBlankCallback(sub_819A4E4);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0);
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_OBJ_1D_MAP);
if (gUnknown_0300127C->fromSummaryScreen == TRUE)
{
sub_819C5D0(88, 152, 32, 96);
ShowBg(3);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG3 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_OBJ);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(11, 4));
}
else
{
HideBg(3);
}
gMain.state++;
break;
case 5:
if (gUnknown_0300127C->fromSummaryScreen == TRUE)
gUnknown_0300127C->cursorPos = gUnknown_0203CF20;
sub_819A9AC();
sub_819AA18();
if (gUnknown_0300127C->fromSummaryScreen == TRUE)
sub_819BE34();
gMain.state++;
break;
case 6:
sub_819BA64();
PutWindowTilemap(2);
gMain.state++;
break;
case 7:
sub_819BCF8();
PutWindowTilemap(5);
gMain.state++;
break;
case 8:
sub_819B9E8();
PutWindowTilemap(1);
gMain.state++;
break;
case 9:
sub_819B9B4();
PutWindowTilemap(0);
gMain.state++;
break;
case 10:
gUnknown_0300127C->unk2A1 = CreateTask(sub_819C69C, 0);
if (!gUnknown_0300127C->fromSummaryScreen)
{
gTasks[gUnknown_0300127C->unk2A1].data[0] = 0;
taskId = CreateTask(sub_819B378, 0);
gTasks[taskId].data[0] = 0;
}
else
{
gTasks[gUnknown_0300127C->unk2A1].data[0] = 1;
gUnknown_0300127C->unk2A2 = 0;
taskId = CreateTask(sub_819B124, 0);
gTasks[taskId].data[0] = 13;
}
SetMainCallback2(sub_819A4C8);
break;
}
}
void sub_819A9AC(void)
{
u8 i;
if (gUnknown_0300127C != NULL)
return;
gUnknown_0300127C = AllocZeroed(sizeof(*gUnknown_0300127C));
gUnknown_0300127C->cursorPos = 0;
gUnknown_0300127C->unk5 = 1;
gUnknown_0300127C->fromSummaryScreen = FALSE;
for (i = 0; i < SELECTABLE_MONS_COUNT; i++)
gUnknown_0300127C->mons[i].selected = FALSE;
if (gSaveBlock2Ptr->frontier.lvlMode != FRONTIER_LVL_TENT)
sub_819B484(0);
else
sub_819B63C(0);
}
extern const struct SpriteTemplate gUnknown_086105F0;
extern const struct SpriteTemplate gUnknown_08610608;
extern const struct SpriteTemplate gUnknown_08610620;
void sub_819AA18(void)
{
u8 i, cursorPos;
s16 x;
for (i = 0; i < SELECTABLE_MONS_COUNT; i++)
{
gUnknown_0300127C->mons[i].spriteId = CreateSprite(&gUnknown_086105D8, (35 * i) + 32, 64, 1);
gSprites[gUnknown_0300127C->mons[i].spriteId].data[0] = 0;
SetBallSpritePaletteNum(i);
}
cursorPos = gUnknown_0300127C->cursorPos;
x = gSprites[gUnknown_0300127C->mons[cursorPos].spriteId].pos1.x;
gUnknown_0300127C->unk4 = CreateSprite(&gUnknown_086105F0, x, 88, 0);
gUnknown_0300127C->unk1 = CreateSprite(&gUnknown_08610608, 176, 112, 0);
gUnknown_0300127C->unk2 = CreateSprite(&gUnknown_08610620, 176, 144, 0);
gSprites[gUnknown_0300127C->unk1].invisible = 1;
gSprites[gUnknown_0300127C->unk2].invisible = 1;
gSprites[gUnknown_0300127C->unk1].centerToCornerVecX = 0;
gSprites[gUnknown_0300127C->unk1].centerToCornerVecY = 0;
gSprites[gUnknown_0300127C->unk2].centerToCornerVecX = 0;
gSprites[gUnknown_0300127C->unk2].centerToCornerVecY = 0;
}

View File

@ -643,22 +643,7 @@ gUnknown_0203CD88: @ 203CD88
.space 0x4
.include "src/menu.o"
.align 2
gUnknown_0203CE2C: @ 203CE2C
.space 0x4
gUnknown_0203CE30: @ 203CE30
.space 0x4
gUnknown_0203CE34: @ 203CE34
.space 0x4
gUnknown_0203CE38: @ 203CE38
.space 0x4
gUnknown_0203CE3C: @ 203CE3C
.space 0x4
.include "src/battle_factory.o"
gUnknown_0203CE40: @ 203CE40
.space 0x4