battle 1 is decompiled

This commit is contained in:
DizzyEggg 2017-12-17 20:10:57 +01:00
parent 224fdbf026
commit eb8055eb07
21 changed files with 2307 additions and 3232 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2856,8 +2856,8 @@ sav1_map_get_name: @ 8085C58
.pool
thumb_func_end sav1_map_get_name
thumb_func_start sav1_map_get_battletype
sav1_map_get_battletype: @ 8085C80
thumb_func_start GetCurrentMapBattleScene
GetCurrentMapBattleScene: @ 8085C80
push {lr}
ldr r0, =gSaveBlock1Ptr
ldr r1, [r0]
@ -2875,7 +2875,7 @@ sav1_map_get_battletype: @ 8085C80
pop {r1}
bx r1
.pool
thumb_func_end sav1_map_get_battletype
thumb_func_end GetCurrentMapBattleScene
thumb_func_start overworld_bg_setup
@ void overworld_bg_setup()

View File

@ -391,7 +391,7 @@ _08179F00:
.pool
_08179F20:
bl reset_temp_tile_data_buffers
ldr r1, =gUnknown_08D7C440
ldr r1, =gBattleTerrainTiles_Building
movs r0, 0
str r0, [sp]
movs r0, 0x1
@ -423,7 +423,7 @@ _08179F5E:
b _08179FA0
.pool
_08179F78:
ldr r0, =gUnknown_08D7C9EC
ldr r0, =gBattleTerrainPalette_Frontier
movs r1, 0x20
movs r2, 0x60
bl LoadCompressedPalette

1312
asm/rom_8034C54.s Normal file

File diff suppressed because it is too large Load Diff

View File

@ -7602,7 +7602,7 @@ sub_807B170: @ 807B170
movs r0, 0x3
bl SetBgTilemapBuffer
bl DeactivateAllTextPrinters
ldr r0, =gUnknown_08C00000
ldr r0, =gBattleTextboxTiles
mov r10, r0
movs r0, 0
mov r9, r0
@ -7611,7 +7611,7 @@ sub_807B170: @ 807B170
movs r2, 0
movs r3, 0
bl copy_decompressed_tile_data_to_vram_autofree
ldr r0, =gUnknown_08C00524
ldr r0, =gBattleTextboxTilemap
mov r8, r0
ldr r4, =0x0201c000
adds r1, r4, 0
@ -7621,7 +7621,7 @@ sub_807B170: @ 807B170
adds r2, r5, 0
movs r3, 0
bl CopyToBgTilemapBuffer
ldr r6, =gUnknown_08C004E0
ldr r6, =gBattleTextboxPalette
adds r0, r6, 0
movs r1, 0
movs r2, 0x20

View File

@ -4750,74 +4750,74 @@ gUnknown_0831ABA0:: @ 831ABA0
.align 2
gBattleTerrainTable:: @ 831ABA8
@ tall_grass
.4byte gUnknown_08D77D68
.4byte gUnknown_08D78350
.4byte gUnknown_08D7E280
.4byte gUnknown_08D7E808
.4byte gUnknown_08D78318
.4byte gBattleTerrainTiles_TallGrass
.4byte gBattleTerrainTilemap_TallGrass
.4byte gBattleTerrainAnimTiles_TallGrass
.4byte gBattleTerrainAnimTilemap_TallGrass
.4byte gBattleTerrainPalette_TallGrass
@ long_grass
.4byte gUnknown_08D78600
.4byte gUnknown_08D78CB8
.4byte gUnknown_08D7E9C4
.4byte gUnknown_08D7F0D4
.4byte gUnknown_08D78C78
.4byte gBattleTerrainTiles_LongGrass
.4byte gBattleTerrainTilemap_LongGrass
.4byte gBattleTerrainAnimTiles_LongGrass
.4byte gBattleTerrainAnimTilemap_LongGrass
.4byte gBattleTerrainPalette_LongGrass
@ sand
.4byte gUnknown_08D78F68
.4byte gUnknown_08D795A8
.4byte gUnknown_08D7F30C
.4byte gUnknown_08D7F850
.4byte gUnknown_08D79560
.4byte gBattleTerrainTiles_Sand
.4byte gBattleTerrainTilemap_Sand
.4byte gBattleTerrainAnimTiles_Sand
.4byte gBattleTerrainAnimTilemap_Sand
.4byte gBattleTerrainPalette_Sand
@ underwater
.4byte gUnknown_08D79858
.4byte gUnknown_08D79E58
.4byte gUnknown_08D7F9F8
.4byte gUnknown_08D7FEC4
.4byte gUnknown_08D79E10
.4byte gBattleTerrainTiles_Underwater
.4byte gBattleTerrainTilemap_Underwater
.4byte gBattleTerrainAnimTiles_Underwater
.4byte gBattleTerrainAnimTilemap_Underwater
.4byte gBattleTerrainPalette_Underwater
@ water
.4byte gUnknown_08D7A108
.4byte gUnknown_08D7A720
.4byte gUnknown_08D80054
.4byte gUnknown_08D80660
.4byte gUnknown_08D7A6DC
.4byte gBattleTerrainTiles_Water
.4byte gBattleTerrainTilemap_Water
.4byte gBattleTerrainAnimTiles_Water
.4byte gBattleTerrainAnimTilemap_Water
.4byte gBattleTerrainPalette_Water
@ pond_water
.4byte gUnknown_08D7A9D0
.4byte gUnknown_08D7AFB8
.4byte gUnknown_08D80804
.4byte gUnknown_08D80D50
.4byte gUnknown_08D7AF78
.4byte gBattleTerrainTiles_PondWater
.4byte gBattleTerrainTilemap_PondWater
.4byte gBattleTerrainAnimTiles_PondWater
.4byte gBattleTerrainAnimTilemap_PondWater
.4byte gBattleTerrainPalette_PondWater
@ rock
.4byte gUnknown_08D7B268
.4byte gUnknown_08D7B864
.4byte gUnknown_08D80E9C
.4byte gUnknown_08D8147C
.4byte gUnknown_08D7B828
.4byte gBattleTerrainTiles_Rock
.4byte gBattleTerrainTilemap_Rock
.4byte gBattleTerrainAnimTiles_Rock
.4byte gBattleTerrainAnimTilemap_Rock
.4byte gBattleTerrainPalette_Rock
@ cave
.4byte gUnknown_08D7BB14
.4byte gUnknown_08D7C154
.4byte gUnknown_08D81610
.4byte gUnknown_08D81E2C
.4byte gUnknown_08D7C10C
.4byte gBattleTerrainTiles_Cave
.4byte gBattleTerrainTilemap_Cave
.4byte gBattleTerrainAnimTiles_Cave
.4byte gBattleTerrainAnimTilemap_Cave
.4byte gBattleTerrainPalette_Cave
@ building
.4byte gUnknown_08D7C440
.4byte gUnknown_08D7CA28
.4byte gUnknown_08D820D4
.4byte gUnknown_08D824E4
.4byte gUnknown_08D7DEB4
.4byte gBattleTerrainTiles_Building
.4byte gBattleTerrainTilemap_Building
.4byte gBattleTerrainAnimTiles_Building
.4byte gBattleTerrainAnimTilemap_Building
.4byte gBattleTerrainPalette_Building
@ plain
.4byte gUnknown_08D7C440
.4byte gUnknown_08D7CA28
.4byte gUnknown_08D820D4
.4byte gUnknown_08D824E4
.4byte gUnknown_08D7C404
.4byte gBattleTerrainTiles_Building
.4byte gBattleTerrainTilemap_Building
.4byte gBattleTerrainAnimTiles_Building
.4byte gBattleTerrainAnimTilemap_Building
.4byte gBattleTerrainPalette_Plain
.align 2
gUnknown_0831AC70:: @ 831AC70

View File

@ -1,12 +1,12 @@
.section gfx_data, "aw", %progbits
gUnknown_08C00000:: @ 8C00000
gBattleTextboxTiles:: @ 8C00000
.incbin "baserom.gba", 0xc00000, 0x4e0
gUnknown_08C004E0:: @ 8C004E0
gBattleTextboxPalette:: @ 8C004E0
.incbin "baserom.gba", 0xc004e0, 0x44
gUnknown_08C00524:: @ 8C00524
gBattleTextboxTilemap:: @ 8C00524
.incbin "baserom.gba", 0xc00524, 0x22c
@ 8C00750
@ -352,199 +352,199 @@ gUnknown_08D77AE4:: @ 8D77AE4
gUnknown_08D77B0C:: @ 8D77B0C
.incbin "baserom.gba", 0xd77b0c, 0x25c
gUnknown_08D77D68:: @ 8D77D68
gBattleTerrainTiles_TallGrass:: @ 8D77D68
.incbin "baserom.gba", 0xd77d68, 0x5b0
gUnknown_08D78318:: @ 8D78318
gBattleTerrainPalette_TallGrass:: @ 8D78318
.incbin "baserom.gba", 0xd78318, 0x38
gUnknown_08D78350:: @ 8D78350
gBattleTerrainTilemap_TallGrass:: @ 8D78350
.incbin "baserom.gba", 0xd78350, 0x2b0
gUnknown_08D78600:: @ 8D78600
gBattleTerrainTiles_LongGrass:: @ 8D78600
.incbin "baserom.gba", 0xd78600, 0x678
gUnknown_08D78C78:: @ 8D78C78
gBattleTerrainPalette_LongGrass:: @ 8D78C78
.incbin "baserom.gba", 0xd78C78, 0x40
gUnknown_08D78CB8:: @ 8D78CB8
gBattleTerrainTilemap_LongGrass:: @ 8D78CB8
.incbin "baserom.gba", 0xd78CB8, 0x2b0
gUnknown_08D78F68:: @ 8D78F68
gBattleTerrainTiles_Sand:: @ 8D78F68
.incbin "baserom.gba", 0xd78f68, 0x5f8
gUnknown_08D79560:: @ 8D79560
gBattleTerrainPalette_Sand:: @ 8D79560
.incbin "baserom.gba", 0xd79560, 0x48
gUnknown_08D795A8:: @ 8D795A8
gBattleTerrainTilemap_Sand:: @ 8D795A8
.incbin "baserom.gba", 0xd795A8, 0x2b0
gUnknown_08D79858:: @ 8D79858
gBattleTerrainTiles_Underwater:: @ 8D79858
.incbin "baserom.gba", 0xd79858, 0x5b8
gUnknown_08D79E10:: @ 8D79E10
gBattleTerrainPalette_Underwater:: @ 8D79E10
.incbin "baserom.gba", 0xd79E10, 0x48
gUnknown_08D79E58:: @ 8D79E58
gBattleTerrainTilemap_Underwater:: @ 8D79E58
.incbin "baserom.gba", 0xd79e58, 0x2b0
gUnknown_08D7A108:: @ 8D7A108
gBattleTerrainTiles_Water:: @ 8D7A108
.incbin "baserom.gba", 0xd7a108, 0x5d4
gUnknown_08D7A6DC:: @ 8D7A6DC
gBattleTerrainPalette_Water:: @ 8D7A6DC
.incbin "baserom.gba", 0xd7a6DC, 0x44
gUnknown_08D7A720:: @ 8D7A720
gBattleTerrainTilemap_Water:: @ 8D7A720
.incbin "baserom.gba", 0xd7a720, 0x2b0
gUnknown_08D7A9D0:: @ 8D7A9D0
gBattleTerrainTiles_PondWater:: @ 8D7A9D0
.incbin "baserom.gba", 0xd7a9D0, 0x5a8
gUnknown_08D7AF78:: @ 8D7AF78
gBattleTerrainPalette_PondWater:: @ 8D7AF78
.incbin "baserom.gba", 0xd7af78, 0x40
gUnknown_08D7AFB8:: @ 8D7AFB8
gBattleTerrainTilemap_PondWater:: @ 8D7AFB8
.incbin "baserom.gba", 0xd7aFB8, 0x2b0
gUnknown_08D7B268:: @ 8D7B268
gBattleTerrainTiles_Rock:: @ 8D7B268
.incbin "baserom.gba", 0xd7b268, 0x5c0
gUnknown_08D7B828:: @ 8D7B828
gBattleTerrainPalette_Rock:: @ 8D7B828
.incbin "baserom.gba", 0xd7b828, 0x3c
gUnknown_08D7B864:: @ 8D7B864
gBattleTerrainTilemap_Rock:: @ 8D7B864
.incbin "baserom.gba", 0xd7b864, 0x2b0
gUnknown_08D7BB14:: @ 8D7BB14
gBattleTerrainTiles_Cave:: @ 8D7BB14
.incbin "baserom.gba", 0xd7bb14, 0x5f8
gUnknown_08D7C10C:: @ 8D7C10C
gBattleTerrainPalette_Cave:: @ 8D7C10C
.incbin "baserom.gba", 0xd7c10c, 0x48
gUnknown_08D7C154:: @ 8D7C154
gBattleTerrainTilemap_Cave:: @ 8D7C154
.incbin "baserom.gba", 0xd7c154, 0x2b0
gUnknown_08D7C404:: @ 8D7C404
gBattleTerrainPalette_Plain:: @ 8D7C404
.incbin "baserom.gba", 0xd7c404, 0x3c
gUnknown_08D7C440:: @ 8D7C440
gBattleTerrainTiles_Building:: @ 8D7C440
.incbin "baserom.gba", 0xd7c440, 0x5ac
gUnknown_08D7C9EC:: @ 8D7C9EC
gBattleTerrainPalette_Frontier:: @ 8D7C9EC
.incbin "baserom.gba", 0xd7c9ec, 0x3c
gUnknown_08D7CA28:: @ 8D7CA28
gBattleTerrainTilemap_Building:: @ 8D7CA28
.incbin "baserom.gba", 0xd7ca28, 0x2b0
gUnknown_08D7CCD8:: @ 8D7CCD8
gBattleTerrainTiles_Stadium:: @ 8D7CCD8
.incbin "baserom.gba", 0xd7ccd8, 0x608
gUnknown_08D7D2E0:: @ 8D7D2E0
gBattleTerrainTilemap_Stadium:: @ 8D7D2E0
.incbin "baserom.gba", 0xd7d2e0, 0x2b0
gUnknown_08D7D590:: @ 8D7D590
gBattleTerrainTiles_Rayquaza:: @ 8D7D590
.incbin "baserom.gba", 0xd7d590, 0x674
gUnknown_08D7DC04:: @ 8D7DC04
gBattleTerrainTilemap_Rayquaza:: @ 8D7DC04
.incbin "baserom.gba", 0xd7dc04, 0x2b0
gUnknown_08D7DEB4:: @ 8D7DEB4
gBattleTerrainPalette_Building:: @ 8D7DEB4
.incbin "baserom.gba", 0xd7deb4, 0x40
gUnknown_08D7DEF4:: @ 8D7DEF4
gBattleTerrainPalette_Kyogre:: @ 8D7DEF4
.incbin "baserom.gba", 0xd7def4, 0x3c
gUnknown_08D7DF30:: @ 8D7DF30
gBattleTerrainPalette_Groudon:: @ 8D7DF30
.incbin "baserom.gba", 0xd7df30, 0x58
gUnknown_08D7DF88:: @ 8D7DF88
gBattleTerrainPalette_BuildingGym:: @ 8D7DF88
.incbin "baserom.gba", 0xd7df88, 0x3c
gUnknown_08D7DFC4:: @ 8D7DFC4
gBattleTerrainPalette_BuildingLeader:: @ 8D7DFC4
.incbin "baserom.gba", 0xd7dfc4, 0x3c
gUnknown_08D7E000:: @ 8D7E000
gBattleTerrainPalette_StadiumAqua:: @ 8D7E000
.incbin "baserom.gba", 0xd7e000, 0x60
gUnknown_08D7E060:: @ 8D7E060
gBattleTerrainPalette_StadiumMagma:: @ 8D7E060
.incbin "baserom.gba", 0xd7e060, 0x6c
gUnknown_08D7E0CC:: @ 8D7E0CC
gBattleTerrainPalette_StadiumSidney:: @ 8D7E0CC
.incbin "baserom.gba", 0xd7e0cc, 0x50
gUnknown_08D7E11C:: @ 8D7E11C
gBattleTerrainPalette_StadiumPhoebe:: @ 8D7E11C
.incbin "baserom.gba", 0xd7e11c, 0x48
gUnknown_08D7E164:: @ 8D7E164
gBattleTerrainPalette_StadiumGlacia:: @ 8D7E164
.incbin "baserom.gba", 0xd7e164, 0x44
gUnknown_08D7E1A8:: @ 8D7E1A8
gBattleTerrainPalette_StadiumDrake:: @ 8D7E1A8
.incbin "baserom.gba", 0xd7e1a8, 0x50
gUnknown_08D7E1F8:: @ 8D7E1F8
gBattleTerrainPalette_StadiumWallace:: @ 8D7E1F8
.incbin "baserom.gba", 0xd7e1f8, 0x3c
gUnknown_08D7E234:: @ 8D7E234
gBattleTerrainPalette_Rayquaza:: @ 8D7E234
.incbin "baserom.gba", 0xd7e234, 0x4c
gUnknown_08D7E280:: @ 8D7E280
gBattleTerrainAnimTiles_TallGrass:: @ 8D7E280
.incbin "baserom.gba", 0xd7e280, 0x588
gUnknown_08D7E808:: @ 8D7E808
gBattleTerrainAnimTilemap_TallGrass:: @ 8D7E808
.incbin "baserom.gba", 0xd7e808, 0x1bc
gUnknown_08D7E9C4:: @ 8D7E9C4
gBattleTerrainAnimTiles_LongGrass:: @ 8D7E9C4
.incbin "baserom.gba", 0xd7e9C4, 0x710
gUnknown_08D7F0D4:: @ 8D7F0D4
gBattleTerrainAnimTilemap_LongGrass:: @ 8D7F0D4
.incbin "baserom.gba", 0xd7F0D4, 0x238
gUnknown_08D7F30C:: @ 8D7F30C
gBattleTerrainAnimTiles_Sand:: @ 8D7F30C
.incbin "baserom.gba", 0xd7F30c, 0x544
gUnknown_08D7F850:: @ 8D7F850
gBattleTerrainAnimTilemap_Sand:: @ 8D7F850
.incbin "baserom.gba", 0xd7F850, 0x1a8
gUnknown_08D7F9F8:: @ 8D7F9F8
gBattleTerrainAnimTiles_Underwater:: @ 8D7F9F8
.incbin "baserom.gba", 0xd7f9f8, 0x4cc
gUnknown_08D7FEC4:: @ 8D7FEC4
gBattleTerrainAnimTilemap_Underwater:: @ 8D7FEC4
.incbin "baserom.gba", 0xd7fec4, 0x190
gUnknown_08D80054:: @ 8D80054
gBattleTerrainAnimTiles_Water:: @ 8D80054
.incbin "baserom.gba", 0xd80054, 0x60c
gUnknown_08D80660:: @ 8D80660
gBattleTerrainAnimTilemap_Water:: @ 8D80660
.incbin "baserom.gba", 0xd80660, 0x1a4
gUnknown_08D80804:: @ 8D80804
gBattleTerrainAnimTiles_PondWater:: @ 8D80804
.incbin "baserom.gba", 0xd80804, 0x54c
gUnknown_08D80D50:: @ 8D80D50
gBattleTerrainAnimTilemap_PondWater:: @ 8D80D50
.incbin "baserom.gba", 0xd80d50, 0x14C
gUnknown_08D80E9C:: @ 8D80E9C
gBattleTerrainAnimTiles_Rock:: @ 8D80E9C
.incbin "baserom.gba", 0xd80e9c, 0x5e0
gUnknown_08D8147C:: @ 8D8147C
gBattleTerrainAnimTilemap_Rock:: @ 8D8147C
.incbin "baserom.gba", 0xd8147C, 0x194
gUnknown_08D81610:: @ 8D81610
gBattleTerrainAnimTiles_Cave:: @ 8D81610
.incbin "baserom.gba", 0xd81610, 0x81c
gUnknown_08D81E2C:: @ 8D81E2C
gBattleTerrainAnimTilemap_Cave:: @ 8D81E2C
.incbin "baserom.gba", 0xd81e2c, 0x2a8
gUnknown_08D820D4:: @ 8D820D4
gBattleTerrainAnimTiles_Building:: @ 8D820D4
.incbin "baserom.gba", 0xd820d4, 0x410
gUnknown_08D824E4:: @ 8D824E4
gBattleTerrainAnimTilemap_Building:: @ 8D824E4
.incbin "baserom.gba", 0xd824e4, 0x124
gUnknown_08D82608:: @ 8D82608
gBattleTerrainAnimTiles_Rayquaza:: @ 8D82608
.incbin "baserom.gba", 0xd82608, 0x668
gUnknown_08D82C70:: @ 8D82C70
gBattleTerrainAnimTilemap_Rayquaza:: @ 8D82C70
.incbin "baserom.gba", 0xd82c70, 0x2a0
gUnknown_08D82F10:: @ 8D82F10

View File

@ -8,6 +8,7 @@
#include "battle_ai_switch_items.h"
#include "battle_gfx_sfx_util.h"
#include "battle_util2.h"
#include "battle_bg.h"
/*
Banks are a name given to what could be called a 'battlerId' or 'monControllerId'.
@ -298,7 +299,6 @@ struct TrainerMonNoItemDefaultMoves
u16 species;
};
u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg);
u8 GetBankSide(u8 bank);
struct TrainerMonItemDefaultMoves
@ -867,16 +867,6 @@ struct BattleScripting
extern struct BattleScripting gBattleScripting;
// functions
// battle_1
void LoadBattleTextboxAndBackground(void);
void LoadBattleEntryBackground(void);
void ApplyPlayerChosenFrameToBattleMenu(void);
bool8 LoadChosenBattleElement(u8 caseId);
void DrawMainBattleBackground(void);
void task00_0800F6FC(u8 taskId);
enum
{
BACK_PIC_BRENDAN,

13
include/battle_bg.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef GUARD_BATTLE_BG_H
#define GUARD_BATTLE_BG_H
void sub_8035658(void);
void sub_80356D0(void);
void ApplyPlayerChosenFrameToBattleMenu(void);
void DrawMainBattleBackground(void);
void LoadBattleTextboxAndBackground(void);
void sub_8035D74(u8 taskId);
void LoadBattleEntryBackground(void);
bool8 LoadChosenBattleElement(u8 caseId);
#endif // GUARD_BATTLE_BG_H

View File

@ -49,7 +49,7 @@ struct OamData
u32 matrixNum:5; // bits 3/4 are h-flip/v-flip if not in affine mode
u32 size:2;
/*0x04*/ u16 tileNum:10; // 0x33F
/*0x04*/ u16 tileNum:10; // 0x3FF
u16 priority:2; // 0x400, 0x800 -> 0xC00
u16 paletteNum:4;
/*0x06*/ u16 affineParam;

View File

@ -39,7 +39,7 @@ enum
MAP_BATTLE_SCENE_PHOEBE, // 5
MAP_BATTLE_SCENE_GLACIA, // 6
MAP_BATTLE_SCENE_DRAKE, // 7
MAP_BATTLE_SCENE_BATTLE_TOWER, // 8
MAP_BATTLE_SCENE_FRONTIER, // 8
};
typedef void (*TilesetCB)(void);

View File

@ -136,4 +136,82 @@ extern const u8 gUnknown_08DDB020[];
extern const u8 gUnknown_08DDB2C4[];
extern const u16 gUnknown_08DDAFE0[];
extern const u8 gBattleTextboxTiles[];
extern const u8 gBattleTextboxTilemap[];
extern const u8 gBattleTextboxPalette[];
extern const u8 gUnknown_08D778F0[];
extern const u8 gUnknown_08D77B0C[];
extern const u8 gUnknown_08D77AE4[];
extern const u8 gUnknown_08D779D8[];
extern const u8 gUnknown_08D857A8[];
extern const u8 gUnknown_08D85A1C[];
extern const u8 gUnknown_08D85600[];
// battle terrains
extern const u8 gBattleTerrainTiles_TallGrass[];
extern const u8 gBattleTerrainTilemap_TallGrass[];
extern const u8 gBattleTerrainAnimTiles_TallGrass[];
extern const u8 gBattleTerrainAnimTilemap_TallGrass[];
extern const u8 gBattleTerrainPalette_TallGrass[];
extern const u8 gBattleTerrainTiles_LongGrass[];
extern const u8 gBattleTerrainTilemap_LongGrass[];
extern const u8 gBattleTerrainAnimTiles_LongGrass[];
extern const u8 gBattleTerrainAnimTilemap_LongGrass[];
extern const u8 gBattleTerrainPalette_LongGrass[];
extern const u8 gBattleTerrainTiles_Sand[];
extern const u8 gBattleTerrainTilemap_Sand[];
extern const u8 gBattleTerrainAnimTiles_Sand[];
extern const u8 gBattleTerrainAnimTilemap_Sand[];
extern const u8 gBattleTerrainPalette_Sand[];
extern const u8 gBattleTerrainTiles_Underwater[];
extern const u8 gBattleTerrainTilemap_Underwater[];
extern const u8 gBattleTerrainAnimTiles_Underwater[];
extern const u8 gBattleTerrainAnimTilemap_Underwater[];
extern const u8 gBattleTerrainPalette_Underwater[];
extern const u8 gBattleTerrainTiles_Water[];
extern const u8 gBattleTerrainTilemap_Water[];
extern const u8 gBattleTerrainAnimTiles_Water[];
extern const u8 gBattleTerrainAnimTilemap_Water[];
extern const u8 gBattleTerrainPalette_Water[];
extern const u8 gBattleTerrainTiles_PondWater[];
extern const u8 gBattleTerrainTilemap_PondWater[];
extern const u8 gBattleTerrainAnimTiles_PondWater[];
extern const u8 gBattleTerrainAnimTilemap_PondWater[];
extern const u8 gBattleTerrainPalette_PondWater[];
extern const u8 gBattleTerrainTiles_Rock[];
extern const u8 gBattleTerrainTilemap_Rock[];
extern const u8 gBattleTerrainAnimTiles_Rock[];
extern const u8 gBattleTerrainAnimTilemap_Rock[];
extern const u8 gBattleTerrainPalette_Rock[];
extern const u8 gBattleTerrainTiles_Cave[];
extern const u8 gBattleTerrainTilemap_Cave[];
extern const u8 gBattleTerrainAnimTiles_Cave[];
extern const u8 gBattleTerrainAnimTilemap_Cave[];
extern const u8 gBattleTerrainPalette_Cave[];
extern const u8 gBattleTerrainTiles_Building[];
extern const u8 gBattleTerrainTilemap_Building[];
extern const u8 gBattleTerrainAnimTiles_Building[];
extern const u8 gBattleTerrainAnimTilemap_Building[];
extern const u8 gBattleTerrainPalette_Building[];
extern const u8 gBattleTerrainPalette_Plain[];
extern const u8 gBattleTerrainPalette_Frontier[];
extern const u8 gBattleTerrainTiles_Stadium[];
extern const u8 gBattleTerrainTilemap_Stadium[];
extern const u8 gBattleTerrainTiles_Rayquaza[];
extern const u8 gBattleTerrainTilemap_Rayquaza[];
extern const u8 gBattleTerrainAnimTiles_Rayquaza[];
extern const u8 gBattleTerrainAnimTilemap_Rayquaza[];
extern const u8 gBattleTerrainPalette_Rayquaza[];
extern const u8 gBattleTerrainPalette_Kyogre[];
extern const u8 gBattleTerrainPalette_Groudon[];
extern const u8 gBattleTerrainPalette_BuildingGym[];
extern const u8 gBattleTerrainPalette_BuildingLeader[];
extern const u8 gBattleTerrainPalette_StadiumAqua[];
extern const u8 gBattleTerrainPalette_StadiumMagma[];
extern const u8 gBattleTerrainPalette_StadiumSidney[];
extern const u8 gBattleTerrainPalette_StadiumPhoebe[];
extern const u8 gBattleTerrainPalette_StadiumGlacia[];
extern const u8 gBattleTerrainPalette_StadiumDrake[];
extern const u8 gBattleTerrainPalette_StadiumWallace[];
#endif //GUARD_GRAPHICS_H

View File

@ -14,5 +14,6 @@ void sub_8197434(u8 a0, u8 a1);
void SetStandardWindowBorderStyle(u8 a0, u8 a1);
void sub_8197930(void);
u8 GetPlayerTextSpeed(void);
void sub_81978B0(u16 arg0);
#endif // GUARD_NEW_MENU_HELPERS_H

View File

@ -84,5 +84,8 @@ extern const u8 gText_RegisteredDataDeleted[];
extern const u8 gUnknown_085EA79D[];
extern const u8 gText_PkmnFainted3[];
extern const u8 gText_Coins[];
extern const u8 gText_Draw[];
extern const u8 gText_Loss[];
extern const u8 gText_Win[];
#endif //GUARD_STRINGS_H

View File

@ -56,7 +56,8 @@ SECTIONS {
asm/main_menu.o(.text);
src/battle_controllers.o(.text);
src/decompress.o(.text);
asm/battle_1.o(.text);
asm/rom_8034C54.o(.text);
src/battle_bg.o(.text);
src/battle_2.o(.text);
src/battle_util.o(.text);
src/battle_script_commands.o(.text);

View File

@ -152,7 +152,7 @@ extern u8 gUnknown_020241E9;
extern u16 gChosenMove;
extern const struct BattleMove gBattleMoves[];
extern const u16 gUnknown_08C004E0[]; // battle textbox palette
extern const u16 gBattleTextboxPalette[]; // battle textbox palette
extern const struct BgTemplate gUnknown_0831AA08[];
extern const struct WindowTemplate * const gUnknown_0831ABA0[];
extern const u8 gUnknown_0831ACE0[];
@ -754,7 +754,7 @@ static void CB2_HandleStartBattle(void)
ResetBlockReceivedFlags();
sub_8036EB8(2, playerMultiplayerId);
SetAllPlayersBerryData();
taskId = CreateTask(task00_0800F6FC, 0);
taskId = CreateTask(sub_8035D74, 0);
gTasks[taskId].data[1] = 0x10E;
gTasks[taskId].data[2] = 0x5A;
gTasks[taskId].data[5] = 0;
@ -956,7 +956,7 @@ static void CB2_HandleStartMultiPartnerBattle(void)
ResetBlockReceivedFlags();
sub_8036EB8(2, playerMultiplayerId);
SetAllPlayersBerryData();
taskId = CreateTask(task00_0800F6FC, 0);
taskId = CreateTask(sub_8035D74, 0);
gTasks[taskId].data[1] = 0x10E;
gTasks[taskId].data[2] = 0x5A;
gTasks[taskId].data[5] = 0;
@ -1342,7 +1342,7 @@ static void CB2_HandleStartMultiBattle(void)
sub_8036EB8(4, playerMultiplayerId);
SetAllPlayersBerryData();
sub_8068AA4();
var = CreateTask(task00_0800F6FC, 0);
var = CreateTask(sub_8035D74, 0);
gTasks[var].data[1] = 0x10E;
gTasks[var].data[2] = 0x5A;
gTasks[var].data[5] = 0;
@ -1978,7 +1978,7 @@ void sub_8038D64(void)
gBattle_BG3_Y = 0;
sub_80356D0();
LoadCompressedPalette(gUnknown_08C004E0, 0, 64);
LoadCompressedPalette(gBattleTextboxPalette, 0, 64);
ApplyPlayerChosenFrameToBattleMenu();
ResetSpriteData();
ResetTasks();
@ -1988,7 +1988,7 @@ void sub_8038D64(void)
gReservedSpritePaletteCount = 4;
SetVBlankCallback(VBlankCB_Battle);
taskId = CreateTask(task00_0800F6FC, 0);
taskId = CreateTask(sub_8035D74, 0);
gTasks[taskId].data[1] = 0x10E;
gTasks[taskId].data[2] = 0x5A;
gTasks[taskId].data[5] = 1;

754
src/battle_bg.c Normal file
View File

@ -0,0 +1,754 @@
#include "global.h"
#include "battle.h"
#include "sprite.h"
#include "trainer_classes.h"
#include "graphics.h"
#include "decompress.h"
#include "bg.h"
#include "palette.h"
#include "main.h"
#include "gpu_regs.h"
#include "link.h"
#include "battle_message.h"
#include "task.h"
#include "trig.h"
#include "sound.h"
#include "songs.h"
#include "strings.h"
#include "window.h"
#include "text_window.h"
#include "new_menu_helpers.h"
struct BattleBackground
{
const void *tileset;
const void *tilemap;
const void *entryTileset;
const void *entryTilemap;
const void *palette;
};
extern const struct SpriteTemplate gUnknown_0831A9D0;
extern const struct SpriteTemplate gUnknown_0831A9E8;
extern const struct CompressedSpriteSheet gUnknown_0831AA00;
extern const struct BgTemplate gUnknown_0831AA08[4];
extern const struct WindowTemplate *gUnknown_0831ABA0[];
extern const struct BattleBackground gBattleTerrainTable[];
extern u8 gBattleTerrain;
extern u16 gTrainerBattleOpponent_A;
extern u16 gBattle_BG1_X;
extern u16 gBattle_BG1_Y;
extern u16 gBattle_BG2_X;
extern u16 gBattle_BG2_Y;
extern u16 gPartnerTrainerId;
extern u8 GetCurrentMapBattleScene(void);
void sub_8035658(void)
{
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, gUnknown_0831AA08, ARRAY_COUNT(gUnknown_0831AA08));
if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
{
gBattleScripting.field_24 = 1;
SetBgTilemapBuffer(1, gUnknown_02023060);
SetBgTilemapBuffer(2, gUnknown_02023060);
}
else
{
gBattleScripting.field_24 = 0;
}
InitWindows(gUnknown_0831ABA0[gBattleScripting.field_24]);
DeactivateAllTextPrinters();
}
void sub_80356D0(void)
{
DisableInterrupts(INTR_FLAG_HBLANK);
EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_VCOUNT | INTR_FLAG_TIMER3 | INTR_FLAG_SERIAL);
sub_8035658();
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 0);
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJWIN_ON | DISPCNT_WIN0_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
}
void ApplyPlayerChosenFrameToBattleMenu(void)
{
sub_809882C(2, 0x12, 0x10);
sub_809882C(2, 0x22, 0x10);
LoadCompressedPalette(gUnknown_08D85600, 0x50, 0x20);
if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
{
sub_81978B0(0x70);
copy_textbox_border_tile_patterns_to_vram(0, 0x30, 0x70);
gPlttBufferUnfaded[0x76] = 0;
CpuCopy16(&gPlttBufferUnfaded[0x76], &gPlttBufferFaded[0x76], 2);
}
}
void DrawMainBattleBackground(void)
{
if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_x2000000))
{
LZDecompressVram(gBattleTerrainTiles_Building, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Building, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_Frontier, 0x20, 0x60);
}
else if (gBattleTypeFlags & BATTLE_TYPE_GROUDON)
{
LZDecompressVram(gBattleTerrainTiles_Cave, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Cave, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_Groudon, 0x20, 0x60);
}
else if (gBattleTypeFlags & BATTLE_TYPE_KYORGE)
{
LZDecompressVram(gBattleTerrainTiles_Water, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Water, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_Kyogre, 0x20, 0x60);
}
else if (gBattleTypeFlags & BATTLE_TYPE_RAYQUAZA)
{
LZDecompressVram(gBattleTerrainTiles_Rayquaza, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Rayquaza, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_Rayquaza, 0x20, 0x60);
}
else
{
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
{
u8 trainerClass = gTrainers[gTrainerBattleOpponent_A].trainerClass;
if (trainerClass == CLASS_LEADER)
{
LZDecompressVram(gBattleTerrainTiles_Building, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Building, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_BuildingLeader, 0x20, 0x60);
return;
}
else if (trainerClass == CLASS_CHAMPION)
{
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_StadiumWallace, 0x20, 0x60);
return;
}
}
switch (GetCurrentMapBattleScene())
{
default:
case MAP_BATTLE_SCENE_NORMAL:
LZDecompressVram(gBattleTerrainTable[gBattleTerrain].tileset, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTable[gBattleTerrain].tilemap, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainTable[gBattleTerrain].palette, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_GYM:
LZDecompressVram(gBattleTerrainTiles_Building, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Building, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_BuildingGym, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_MAGMA:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_StadiumMagma, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_AQUA:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_StadiumAqua, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_SIDNEY:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_StadiumSidney, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_PHOEBE:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_StadiumPhoebe, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_GLACIA:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_StadiumGlacia, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_DRAKE:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_StadiumDrake, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_FRONTIER:
LZDecompressVram(gBattleTerrainTiles_Building, (void*)(VRAM + 0x8000));
LZDecompressVram(gBattleTerrainTilemap_Building, (void*)(VRAM + 0xD000));
LoadCompressedPalette(gBattleTerrainPalette_Frontier, 0x20, 0x60);
break;
}
}
}
void LoadBattleTextboxAndBackground(void)
{
LZDecompressVram(gBattleTextboxTiles, (void*)(VRAM));
CopyToBgTilemapBuffer(0, gBattleTextboxTilemap, 0, 0);
CopyBgTilemapBufferToVram(0);
LoadCompressedPalette(gBattleTextboxPalette, 0, 0x40);
ApplyPlayerChosenFrameToBattleMenu();
DrawMainBattleBackground();
}
static void sub_8035AE4(u8 taskId, u8 bank, u8 bgId, u8 destX, u8 destY)
{
s32 i;
u16 var = 0;
u16 src[6];
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
{
if (gTasks[taskId].data[5] != 0)
{
switch (bank)
{
case 0:
var = 0x3F & gTasks[taskId].data[3];
break;
case 1:
var = (0xFC0 & gTasks[taskId].data[4]) >> 6;
break;
case 2:
var = (0xFC0 & gTasks[taskId].data[3]) >> 6;
break;
case 3:
var = 0x3F & gTasks[taskId].data[4];
break;
}
}
else
{
switch (bank)
{
case 0:
var = 0x3F & gTasks[taskId].data[3];
break;
case 1:
var = 0x3F & gTasks[taskId].data[4];
break;
case 2:
var = (0xFC0 & gTasks[taskId].data[3]) >> 6;
break;
case 3:
var = (0xFC0 & gTasks[taskId].data[4]) >> 6;
break;
}
}
for (i = 0; i < 3; i++)
{
src[i] = ((var & (3 << (i * 2))) >> (i * 2)) + 0x6001;
}
CopyToBgTilemapBufferRect_ChangePalette(bgId, src, destX, destY, 3, 1, 0x11);
CopyBgTilemapBufferToVram(bgId);
}
else
{
if (bank == gBattleScripting.multiplayerId)
var = gTasks[taskId].data[3];
else
var = gTasks[taskId].data[4];
for (i = 0; i < 6; i++)
{
src[i] = ((var & (3 << (i * 2))) >> (i * 2)) + 0x6001;
}
CopyToBgTilemapBufferRect_ChangePalette(bgId, src, destX, destY, 6, 1, 0x11);
CopyBgTilemapBufferToVram(bgId);
}
}
static void sub_8035C4C(void)
{
if (gBattleOutcome == BATTLE_DREW)
{
BattleHandleAddTextPrinter(gText_Draw, 0x15);
}
else if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
{
if (gBattleOutcome == BATTLE_WON)
{
switch (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18)
{
case 0:
BattleHandleAddTextPrinter(gText_Win, 0x16);
BattleHandleAddTextPrinter(gText_Loss, 0x17);
break;
case 1:
BattleHandleAddTextPrinter(gText_Win, 0x17);
BattleHandleAddTextPrinter(gText_Loss, 0x16);
break;
case 2:
BattleHandleAddTextPrinter(gText_Win, 0x16);
BattleHandleAddTextPrinter(gText_Loss, 0x17);
break;
case 3:
BattleHandleAddTextPrinter(gText_Win, 0x17);
BattleHandleAddTextPrinter(gText_Loss, 0x16);
break;
}
}
else
{
switch (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18)
{
case 0:
BattleHandleAddTextPrinter(gText_Win, 0x17);
BattleHandleAddTextPrinter(gText_Loss, 0x16);
break;
case 1:
BattleHandleAddTextPrinter(gText_Win, 0x16);
BattleHandleAddTextPrinter(gText_Loss, 0x17);
break;
case 2:
BattleHandleAddTextPrinter(gText_Win, 0x17);
BattleHandleAddTextPrinter(gText_Loss, 0x16);
break;
case 3:
BattleHandleAddTextPrinter(gText_Win, 0x16);
BattleHandleAddTextPrinter(gText_Loss, 0x17);
break;
}
}
}
else if (gBattleOutcome == BATTLE_WON)
{
if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 != 0)
{
BattleHandleAddTextPrinter(gText_Win, 0x17);
BattleHandleAddTextPrinter(gText_Loss, 0x16);
}
else
{
BattleHandleAddTextPrinter(gText_Win, 0x16);
BattleHandleAddTextPrinter(gText_Loss, 0x17);
}
}
else
{
if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 != 0)
{
BattleHandleAddTextPrinter(gText_Win, 0x16);
BattleHandleAddTextPrinter(gText_Loss, 0x17);
}
else
{
BattleHandleAddTextPrinter(gText_Win, 0x17);
BattleHandleAddTextPrinter(gText_Loss, 0x16);
}
}
}
void sub_8035D74(u8 taskId)
{
struct LinkPlayer *linkPlayer;
u8 *name;
s32 i, palId;
switch (gTasks[taskId].data[0])
{
case 0:
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
{
for (i = 0; i < BATTLE_BANKS_COUNT; i++)
{
name = gLinkPlayers[i].name;
linkPlayer = &gLinkPlayers[i];
switch (linkPlayer->lp_field_18)
{
case 0:
BattleHandleAddTextPrinter(name, 0x11);
sub_8035AE4(taskId, linkPlayer->lp_field_18, 1, 2, 4);
break;
case 1:
BattleHandleAddTextPrinter(name, 0x12);
sub_8035AE4(taskId, linkPlayer->lp_field_18, 2, 2, 4);
break;
case 2:
BattleHandleAddTextPrinter(name, 0x13);
sub_8035AE4(taskId, linkPlayer->lp_field_18, 1, 2, 8);
break;
case 3:
BattleHandleAddTextPrinter(name, 0x14);
sub_8035AE4(taskId, linkPlayer->lp_field_18, 2, 2, 8);
break;
}
}
}
else
{
u8 playerId = gBattleScripting.multiplayerId;
u8 opponentId = playerId ^ BIT_SIDE;
u8 opponentId_copy = opponentId;
if (gLinkPlayers[playerId].lp_field_18 != 0)
opponentId = playerId, playerId = opponentId_copy;
name = gLinkPlayers[playerId].name;
BattleHandleAddTextPrinter(name, 0xF);
name = gLinkPlayers[opponentId].name;
BattleHandleAddTextPrinter(name, 0x10);
sub_8035AE4(taskId, playerId, 1, 2, 7);
sub_8035AE4(taskId, opponentId, 2, 2, 7);
}
gTasks[taskId].data[0]++;
break;
case 1:
palId = AllocSpritePalette(0x2710);
gPlttBufferUnfaded[palId * 16 + 0x10F] = gPlttBufferFaded[palId * 16 + 0x10F] = 0x7FFF;
gBattleStruct->field_7D = CreateSprite(&gUnknown_0831A9D0, 111, 80, 0);
gBattleStruct->field_7E = CreateSprite(&gUnknown_0831A9E8, 129, 80, 0);
gSprites[gBattleStruct->field_7D].invisible = 1;
gSprites[gBattleStruct->field_7E].invisible = 1;
gTasks[taskId].data[0]++;
break;
case 2:
if (gTasks[taskId].data[5] != 0)
{
gBattle_BG1_X = -(20) - (Sin2(gTasks[taskId].data[1]) / 32);
gBattle_BG2_X = -(140) - (Sin2(gTasks[taskId].data[2]) / 32);
gBattle_BG1_Y = -36;
gBattle_BG2_Y = -36;
}
else
{
gBattle_BG1_X = -(20) - (Sin2(gTasks[taskId].data[1]) / 32);
gBattle_BG1_Y = (Cos2(gTasks[taskId].data[1]) / 32) - 164;
gBattle_BG2_X = -(140) - (Sin2(gTasks[taskId].data[2]) / 32);
gBattle_BG2_Y = (Cos2(gTasks[taskId].data[2]) / 32) - 164;
}
if (gTasks[taskId].data[2] != 0)
{
gTasks[taskId].data[2] -= 2;
gTasks[taskId].data[1] += 2;
}
else
{
if (gTasks[taskId].data[5] != 0)
sub_8035C4C();
PlaySE(SE_W231);
DestroyTask(taskId);
gSprites[gBattleStruct->field_7D].invisible = 0;
gSprites[gBattleStruct->field_7E].invisible = 0;
gSprites[gBattleStruct->field_7E].oam.tileNum += 0x40;
gSprites[gBattleStruct->field_7D].data[0] = 0;
gSprites[gBattleStruct->field_7E].data[0] = 1;
gSprites[gBattleStruct->field_7D].data[1] = gSprites[gBattleStruct->field_7D].pos1.x;
gSprites[gBattleStruct->field_7E].data[1] = gSprites[gBattleStruct->field_7E].pos1.x;
gSprites[gBattleStruct->field_7D].data[2] = 0;
gSprites[gBattleStruct->field_7E].data[2] = 0;
}
break;
}
}
void LoadBattleEntryBackground(void)
{
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
LZDecompressVram(gUnknown_08D778F0, (void*)(VRAM + 0x4000));
LZDecompressVram(gUnknown_08D77B0C, (void*)(VRAM + 0x10000));
LoadCompressedPalette(gUnknown_08D77AE4, 0x60, 0x20);
SetBgAttribute(1, BG_CTRL_ATTR_MAPBASEINDEX, 1);
SetGpuReg(REG_OFFSET_BG1CNT, 0x5C04);
CopyToBgTilemapBuffer(1, gUnknown_08D779D8, 0, 0);
CopyToBgTilemapBuffer(2, gUnknown_08D779D8, 0, 0);
CopyBgTilemapBufferToVram(1);
CopyBgTilemapBufferToVram(2);
SetGpuReg(REG_OFFSET_WININ, 0x36);
SetGpuReg(REG_OFFSET_WINOUT, 0x36);
gBattle_BG1_Y = 0xFF5C;
gBattle_BG2_Y = 0xFF5C;
LoadCompressedObjectPicUsingHeap(&gUnknown_0831AA00);
}
else if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_EREADER_TRAINER))
{
if (!(gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) || gPartnerTrainerId == STEVEN_PARTNER_ID)
{
LZDecompressVram(gBattleTerrainAnimTiles_Building, (void*)(VRAM + 0x4000));
LZDecompressVram(gBattleTerrainAnimTilemap_Building, (void*)(VRAM + 0xE000));
}
else
{
SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 2);
SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 2);
CopyToBgTilemapBuffer(1, gUnknown_08D857A8, 0, 0);
CopyToBgTilemapBuffer(2, gUnknown_08D85A1C, 0, 0);
CopyBgTilemapBufferToVram(1);
CopyBgTilemapBufferToVram(2);
}
}
else if (gBattleTypeFlags & BATTLE_TYPE_GROUDON)
{
LZDecompressVram(gBattleTerrainAnimTiles_Cave, (void*)(VRAM + 0x4000));
LZDecompressVram(gBattleTerrainAnimTilemap_Cave, (void*)(VRAM + 0xE000));
}
else if (gBattleTypeFlags & BATTLE_TYPE_KYORGE)
{
LZDecompressVram(gBattleTerrainAnimTiles_Underwater, (void*)(VRAM + 0x4000));
LZDecompressVram(gBattleTerrainAnimTilemap_Underwater, (void*)(VRAM + 0xE000));
}
else if (gBattleTypeFlags & BATTLE_TYPE_RAYQUAZA)
{
LZDecompressVram(gBattleTerrainAnimTiles_Rayquaza, (void*)(VRAM + 0x4000));
LZDecompressVram(gBattleTerrainAnimTilemap_Rayquaza, (void*)(VRAM + 0xE000));
}
else
{
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
{
u8 trainerClass = gTrainers[gTrainerBattleOpponent_A].trainerClass;
if (trainerClass == CLASS_LEADER)
{
LZDecompressVram(gBattleTerrainAnimTiles_Building, (void*)(VRAM + 0x4000));
LZDecompressVram(gBattleTerrainAnimTilemap_Building, (void*)(VRAM + 0xE000));
return;
}
else if (trainerClass == CLASS_CHAMPION)
{
LZDecompressVram(gBattleTerrainAnimTiles_Building, (void*)(VRAM + 0x4000));
LZDecompressVram(gBattleTerrainAnimTilemap_Building, (void*)(VRAM + 0xE000));
return;
}
}
if (GetCurrentMapBattleScene() == MAP_BATTLE_SCENE_NORMAL)
{
LZDecompressVram(gBattleTerrainTable[gBattleTerrain].entryTileset, (void*)(VRAM + 0x4000));
LZDecompressVram(gBattleTerrainTable[gBattleTerrain].entryTilemap, (void*)(VRAM + 0xE000));
}
else
{
LZDecompressVram(gBattleTerrainAnimTiles_Building, (void*)(VRAM + 0x4000));
LZDecompressVram(gBattleTerrainAnimTilemap_Building, (void*)(VRAM + 0xE000));
}
}
}
bool8 LoadChosenBattleElement(u8 caseId)
{
bool8 ret = FALSE;
switch (caseId)
{
case 0:
LZDecompressVram(gBattleTextboxTiles, (void*)(VRAM));
break;
case 1:
CopyToBgTilemapBuffer(0, gBattleTextboxTilemap, 0, 0);
CopyBgTilemapBufferToVram(0);
break;
case 2:
LoadCompressedPalette(gBattleTextboxPalette, 0, 0x40);
break;
case 3:
if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_EREADER_TRAINER))
{
LZDecompressVram(gBattleTerrainTiles_Building, (void*)(VRAM + 0x8000));
}
else if (gBattleTypeFlags & BATTLE_TYPE_GROUDON)
{
LZDecompressVram(gBattleTerrainTiles_Cave, (void*)(VRAM + 0x8000));
}
else
{
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
{
u8 trainerClass = gTrainers[gTrainerBattleOpponent_A].trainerClass;
if (trainerClass == CLASS_LEADER)
{
LZDecompressVram(gBattleTerrainTiles_Building, (void*)(VRAM + 0x8000));
break;
}
else if (trainerClass == CLASS_CHAMPION)
{
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
break;
}
}
switch (GetCurrentMapBattleScene())
{
default:
case MAP_BATTLE_SCENE_NORMAL:
LZDecompressVram(gBattleTerrainTable[gBattleTerrain].tileset, (void*)(VRAM + 0x8000));
break;
case MAP_BATTLE_SCENE_GYM:
LZDecompressVram(gBattleTerrainTiles_Building, (void*)(VRAM + 0x8000));
break;
case MAP_BATTLE_SCENE_MAGMA:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
break;
case MAP_BATTLE_SCENE_AQUA:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
break;
case MAP_BATTLE_SCENE_SIDNEY:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
break;
case MAP_BATTLE_SCENE_PHOEBE:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
break;
case MAP_BATTLE_SCENE_GLACIA:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
break;
case MAP_BATTLE_SCENE_DRAKE:
LZDecompressVram(gBattleTerrainTiles_Stadium, (void*)(VRAM + 0x8000));
break;
case MAP_BATTLE_SCENE_FRONTIER:
LZDecompressVram(gBattleTerrainTiles_Building, (void*)(VRAM + 0x8000));
break;
}
}
break;
case 4:
if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_EREADER_TRAINER))
{
LZDecompressVram(gBattleTerrainTilemap_Building, (void*)(VRAM + 0xD000));
}
else if (gBattleTypeFlags & BATTLE_TYPE_KYOGRE_GROUDON)
{
if (gGameVersion == VERSION_RUBY)
LZDecompressVram(gBattleTerrainTilemap_Cave, (void*)(VRAM + 0xD000));
else
LZDecompressVram(gBattleTerrainTilemap_Water, (void*)(VRAM + 0xD000));
}
else
{
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
{
u8 trainerClass = gTrainers[gTrainerBattleOpponent_A].trainerClass;
if (trainerClass == CLASS_LEADER)
{
LZDecompressVram(gBattleTerrainTilemap_Building, (void*)(VRAM + 0xD000));
break;
}
else if (trainerClass == CLASS_CHAMPION)
{
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
break;
}
}
switch (GetCurrentMapBattleScene())
{
default:
case MAP_BATTLE_SCENE_NORMAL:
LZDecompressVram(gBattleTerrainTable[gBattleTerrain].tilemap, (void*)(VRAM + 0xD000));
break;
case MAP_BATTLE_SCENE_GYM:
LZDecompressVram(gBattleTerrainTilemap_Building, (void*)(VRAM + 0xD000));
break;
case MAP_BATTLE_SCENE_MAGMA:
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
break;
case MAP_BATTLE_SCENE_AQUA:
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
break;
case MAP_BATTLE_SCENE_SIDNEY:
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
break;
case MAP_BATTLE_SCENE_PHOEBE:
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
break;
case MAP_BATTLE_SCENE_GLACIA:
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
break;
case MAP_BATTLE_SCENE_DRAKE:
LZDecompressVram(gBattleTerrainTilemap_Stadium, (void*)(VRAM + 0xD000));
break;
case MAP_BATTLE_SCENE_FRONTIER:
LZDecompressVram(gBattleTerrainTilemap_Building, (void*)(VRAM + 0xD000));
break;
}
}
break;
case 5:
if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_EREADER_TRAINER))
{
LoadCompressedPalette(gBattleTerrainPalette_Frontier, 0x20, 0x60);
}
else if (gBattleTypeFlags & BATTLE_TYPE_KYOGRE_GROUDON)
{
if (gGameVersion == VERSION_RUBY)
LoadCompressedPalette(gBattleTerrainPalette_Groudon, 0x20, 0x60);
else
LoadCompressedPalette(gBattleTerrainPalette_Kyogre, 0x20, 0x60);
}
else
{
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
{
u8 trainerClass = gTrainers[gTrainerBattleOpponent_A].trainerClass;
if (trainerClass == CLASS_LEADER)
{
LoadCompressedPalette(gBattleTerrainPalette_BuildingLeader, 0x20, 0x60);
break;
}
else if (trainerClass == CLASS_CHAMPION)
{
LoadCompressedPalette(gBattleTerrainPalette_StadiumWallace, 0x20, 0x60);
break;
}
}
switch (GetCurrentMapBattleScene())
{
default:
case MAP_BATTLE_SCENE_NORMAL:
LoadCompressedPalette(gBattleTerrainTable[gBattleTerrain].palette, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_GYM:
LoadCompressedPalette(gBattleTerrainPalette_BuildingGym, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_MAGMA:
LoadCompressedPalette(gBattleTerrainPalette_StadiumMagma, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_AQUA:
LoadCompressedPalette(gBattleTerrainPalette_StadiumAqua, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_SIDNEY:
LoadCompressedPalette(gBattleTerrainPalette_StadiumSidney, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_PHOEBE:
LoadCompressedPalette(gBattleTerrainPalette_StadiumPhoebe, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_GLACIA:
LoadCompressedPalette(gBattleTerrainPalette_StadiumGlacia, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_DRAKE:
LoadCompressedPalette(gBattleTerrainPalette_StadiumDrake, 0x20, 0x60);
break;
case MAP_BATTLE_SCENE_FRONTIER:
LoadCompressedPalette(gBattleTerrainPalette_Frontier, 0x20, 0x60);
break;
}
}
break;
case 6:
ApplyPlayerChosenFrameToBattleMenu();
break;
default:
ret = TRUE;
break;
}
return ret;
}

View File

@ -48,9 +48,9 @@ extern struct SpriteTemplate gUnknown_0202499C;
extern void (*gFieldCallback)(void);
extern const struct CompressedSpriteSheet gMonFrontPicTable[];
extern const u8 gUnknown_08C00000[];
extern const u8 gUnknown_08C00524[];
extern const u8 gUnknown_08C004E0[];
extern const u8 gBattleTextboxTiles[];
extern const u8 gBattleTextboxTilemap[];
extern const u8 gBattleTextboxPalette[];
extern const u16 gUnknown_08DD7300[]; // palette, gameboy advance
extern const u32 gUnknown_08DD7360[]; // tileset gameboy advance
extern const u32 gUnknown_08331F60[]; // tilemap gameboy circle
@ -522,9 +522,9 @@ static void CB2_EggHatch_0(void)
gMain.state++;
break;
case 2:
copy_decompressed_tile_data_to_vram_autofree(0, gUnknown_08C00000, 0, 0, 0);
CopyToBgTilemapBuffer(0, gUnknown_08C00524, 0, 0);
LoadCompressedPalette(gUnknown_08C004E0, 0, 0x20);
copy_decompressed_tile_data_to_vram_autofree(0, gBattleTextboxTiles, 0, 0, 0);
CopyToBgTilemapBuffer(0, gBattleTextboxTilemap, 0, 0);
LoadCompressedPalette(gBattleTextboxPalette, 0, 0x20);
gMain.state++;
break;
case 3:

View File

@ -35,7 +35,7 @@ extern struct SpriteTemplate gUnknown_0202499C;
extern const union AnimCmd * const * const gMonAnimationsSpriteAnimsPtrTable[];
extern void dp12_8087EA4(void);
extern void trs_config(void);
extern void sub_8035658(void);
extern bool8 IsDoubleBattle(void);
extern u8 GetSubstituteSpriteDefault_Y(u8 bank);
extern u8 GetBankSpriteDefault_Y(u8 bank);
@ -73,7 +73,7 @@ static void CB2_ReshowBattleScreenAfterMenu(void)
{
case 0:
dp12_8087EA4();
trs_config();
sub_8035658();
SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 0);
SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 0);
ShowBg(0);

View File

@ -1,17 +1,5 @@
// Includes
#include "global.h"
// Static type declarations
// Static RAM declarations
IWRAM_DATA u32 gUnknown_03000DD4;
IWRAM_DATA u32 gUnknown_03000DD8;
IWRAM_DATA u32 gUnknown_03000DDC;
// Static ROM declarations
// .rodata
// .text

View File

@ -8,7 +8,7 @@
.include "src/link.o"
.include "src/rtc.o"
.include "src/main_menu.o"
.include "src/battle_1.o"
.include "src/rom_8034C54.o"
.include "src/egg_hatch.o"
.include "src/berry_blender.o"
.include "src/play_time.o"