Cleanup bg.c

This commit is contained in:
Diegoisawesome 2017-09-09 20:52:33 -05:00
parent 001d1027e3
commit f29fc55796
8 changed files with 273 additions and 272 deletions

1
common_syms/bg.txt Normal file
View File

@ -0,0 +1 @@
gUnneededFireRedVariable

View File

@ -1,7 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
gZeroedBgControlStruct:: @ 82E9580
.4byte 0

70
include/bg.h Normal file
View File

@ -0,0 +1,70 @@
#ifndef GUARD_BG_H
#define GUARD_BG_H
#include "global.h"
enum {
BG_CTRL_ATTR_VISIBLE = 1,
BG_CTRL_ATTR_CHARBASEINDEX = 2,
BG_CTRL_ATTR_MAPBASEINDEX = 3,
BG_CTRL_ATTR_SCREENSIZE = 4,
BG_CTRL_ATTR_PALETTEMODE = 5,
BG_CTRL_ATTR_PRIORITY = 6,
BG_CTRL_ATTR_MOSAIC = 7,
BG_CTRL_ATTR_WRAPAROUND = 8,
};
struct BgControl {
struct BgConfig {
u16 visible:1;
u16 unknown_1:1;
u16 screenSize:2;
u16 priority:2;
u16 mosaic:1;
u16 wraparound:1;
u16 charBaseIndex:2;
u16 mapBaseIndex:5;
u16 paletteMode:1;
u8 unknown_2;
u8 unknown_3;
} configs[4];
u16 bgVisibilityAndMode;
};
struct BgTemplate {
u32 bg:2;
u32 charBaseIndex:2;
u32 mapBaseIndex:5;
u32 screenSize:2;
u32 paletteMode:1;
u32 priority:2;
u32 baseTile:10;
};
struct BgConfig2 {
u32 baseTile:10;
u32 basePalette:4;
u32 unk_3:18;
void* tilemap;
u32 bg_x;
u32 bg_y;
};
bool32 IsInvalidBg32(u8);
void ResetBgControlStructs();
u16 GetBgMetricTextMode(u8, u8);
u32 GetBgMetricAffineMode(u8, u8);
u32 GetBgType(u8);
void SetTextModeAndHideBgs();
bool8 IsInvalidBg(u8);
bool32 IsTileMapOutsideWram(u8);
void CopyRectToBgTilemapBufferRect(u8, void*, u8, u8, u8, u8, u8, u8, u8, u8, u8, u16, u16);
void CopyTileMapEntry(u16*, u16*, s32, u32, u32);
u32 GetTileMapIndexFromCoords(s32, s32, s32, u32, u32);
void WriteSequenceToBgTilemapBuffer(u8, u16, u8, u8, u8, u8, u8, s16);
#endif // GUARD_BG_H

View File

@ -34,8 +34,10 @@
#define BG_VRAM VRAM #define BG_VRAM VRAM
#define BG_VRAM_SIZE 0x10000 #define BG_VRAM_SIZE 0x10000
#define BG_CHAR_ADDR(n) (BG_VRAM + (0x4000 * (n))) #define BG_CHAR_SIZE 0x4000
#define BG_SCREEN_ADDR(n) (BG_VRAM + (0x800 * (n))) #define BG_SCREEN_SIZE 0x800
#define BG_CHAR_ADDR(n) (BG_VRAM + (BG_CHAR_SIZE * (n)))
#define BG_SCREEN_ADDR(n) (BG_VRAM + (BG_SCREEN_SIZE * (n)))
// text-mode BG // text-mode BG
#define OBJ_VRAM0 (VRAM + 0x10000) #define OBJ_VRAM0 (VRAM + 0x10000)

View File

@ -268,7 +268,7 @@ SECTIONS {
ALIGN(4) ALIGN(4)
{ {
src/main.o(.rodata); src/main.o(.rodata);
data/bg.o(.rodata); src/bg.o(.rodata);
src/window.o(.rodata); src/window.o(.rodata);
src/text.o(.rodata); src/text.o(.rodata);
src/sprite.o(.rodata); src/sprite.o(.rodata);

440
src/bg.c

File diff suppressed because it is too large Load Diff

View File

@ -23,20 +23,7 @@ gDma3RequestCursor: @ 3000811
.space 0x7 .space 0x7
.include "src/gpu_regs.o" .include "src/gpu_regs.o"
.include "src/bg.o"
.align 4
gUnknown_030008E0: @ 30008E0
.space 0x18
gUnknown_030008F8: @ 30008F8
.space 0x4
gUnknown_030008FC: @ 30008FC
.space 0x3C
gUnknown_03000938: @ 3000938
.space 0x10
.include "src/text.o" .include "src/text.o"
.include "src/sprite.o" .include "src/sprite.o"

View File

@ -39,9 +39,9 @@ IntrMain_Buffer: @ 3002750
gPcmDmaCounter: @ 3002F50 gPcmDmaCounter: @ 3002F50
.space 0x4 .space 0x4
gUnneededFireRedVariable: @ 3002F54 .include "bg.o"
.space 0xC
.align 4
gUnknown_03002F60: @ 3002F60 gUnknown_03002F60: @ 3002F60
.space 0x10 .space 0x10