Skip to content

Commit

Permalink
Merge pull request #159 from Kelebek1/fragment19
Browse files Browse the repository at this point in the history
fragment19
  • Loading branch information
RevoSucks authored Oct 17, 2024
2 parents 23bb731 + 3b19f10 commit 8fee860
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 13 deletions.
18 changes: 18 additions & 0 deletions src/controller.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
#ifndef _CONTROLLER_H_
#define _CONTROLLER_H_

#define BTN_A 0x8000
#define BTN_B 0x4000
#define BTN_Z 0x2000
#define BTN_START 0x1000
#define BTN_DUP 0x0800
#define BTN_DDOWN 0x0400
#define BTN_DLEFT 0x0200
#define BTN_DRIGHT 0x0100
#define BTN_L 0x0020
#define BTN_R 0x0010
#define BTN_CUP 0x0008
#define BTN_CDOWN 0x0004
#define BTN_CLEFT 0x0002
#define BTN_CRIGHT 0x0001

#define BTN_IS_PRESSED(controller, combo) (((controller)->buttonPressed & (combo)) != 0)
#define BTN_IS_DOWN(controller, combo) (((controller)->buttonDown & (combo)) != 0)

typedef struct Controller {
/* 0x00 */ s16 contId;
/* 0x02 */ s16 rawStickX;
Expand Down
147 changes: 138 additions & 9 deletions src/fragments/19/fragment19.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,146 @@
#include "global.h"
#include "fragment19.h"
#include "src/12D80.h"
#include "src/19840.h"
#include "src/1C720.h"
#include "src/1CF30.h"
#include "src/3FB0.h"
#include "src/6A40.h"
#include "src/6BC0.h"
#include "src/fragments/3/fragment3.h"
#include "src/memory.h"
#include "src/stage_loader.h"
#include "src/geo_layout.h"

#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/19/fragment19/func_86D00020.s")
static u32 D_86D00530[] = {
0x0C00FFFF, 0x05000000, 0x0B00001E, 0x00000000, 0x014000F0, 0x0000000F, 0x00000000, 0x00000000, 0x05000000,
0x0D000000, 0x05000000, 0x0F000002, 0x05000000, 0x1F00FFFF, 0x00000000, 0x00000000, 0x00000000, 0x00640064,
0x00640000, 0x05000000, 0x06000000, 0x06000000, 0x14000000, 0x002B0012, 0xFFFFFF32, 0x16FFFFFF, 0x0F000003,
0x05000000, 0x0A000000, &D_800AC840, 0x06000000, 0x06000000, 0x06000000, 0x06000000, 0x01000000, 0x00000000,
};

#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/19/fragment19/func_86D000A8.s")
void func_86D00020(void) {
D_87906054 = D_87906050->unk_00.unk_0C;

#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/19/fragment19/func_86D000D0.s")
D_87906060 = 0xA00;
D_87906062 = 0;
D_87906064 = 0x17C;
D_87906066 = 0x1E;
D_87906068 = 0x32;
D_8790606A = 0x1900;

#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/19/fragment19/func_86D00134.s")
D_8790606C.x = 0;
D_8790606C.y = 0x1E;
D_8790606C.z = 0;

#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/19/fragment19/func_86D0015C.s")
func_87900B64();
}

#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/19/fragment19/func_86D0032C.s")
void func_86D000A8(void) {
func_87900C5C();
func_87900B64();
}

#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/19/fragment19/func_86D0037C.s")
void func_86D000D0(UNUSED s32 arg0) {
func_800079C4();
func_8000699C(&gDisplayListHead, 1);
func_80015348();
func_80015094(&D_87906050->unk_00);

#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/19/fragment19/func_86D003EC.s")
if (D_87903DB0 != 0) {
func_87900F44();
}

func_80007778();
}

void func_86D00134(void) {
func_80006C6C(0x10);
D_87903DC4 = 3;
}

void func_86D0015C(void) {
s32 var_s1 = 1;

while (var_s1 != 0) {
func_87900528();

if (BTN_IS_PRESSED(gPlayer1Controller, BTN_A)) {
func_879037D0(0.2f, 0.0f, 50.0f, 50.0f, 0x2000, 0, 0x1000);
}

if (BTN_IS_PRESSED(gPlayer1Controller, BTN_B)) {
func_87903838(0.2f, 50.0f, 50.0f, 50.0f, 0, 0, 0);
}

if (BTN_IS_PRESSED(gPlayer1Controller, BTN_CLEFT)) {
func_879038AC(0.2f, -50.0f, 50.0f, 50.0f, -0x6000, 0, 0x2000);
}

if (BTN_IS_PRESSED(gPlayer1Controller, BTN_Z)) {
D_87903DB0 = (D_87903DB0 + 1) & 1;
}

if ((D_87903DB0 == 0) && BTN_IS_PRESSED(gPlayer1Controller, BTN_START)) {
D_87903DA0 = 1;
}

func_8790370C();
func_86D000A8();

if ((D_87903DB0 == 0) && BTN_IS_PRESSED(gPlayer1Controller, BTN_CDOWN)) {
var_s1 = 0;
}

func_86D000D0(1);
}
}

void func_86D0032C(void) {
s32 i;

func_80006CB4(0x1E);

for (i = 0; i < 30; i++) {
func_87900528();
func_86D000D0(2);
}
}

void func_86D0037C(void) {
UNUSED s32 pad[2];
MemoryBlock* sp1C = func_80002D10(main_pool_get_available(), 0);

D_87906050 = process_geo_layout(sp1C, &D_86D00530);
func_80002D60(sp1C);
func_8001BB20();
func_8001987C();
func_87903600();
func_86D00020();
}

s32 func_86D003EC(s32 arg0, s32 arg1) {
unk_func_80007444* sp24;

main_pool_push_state('MINI');

func_80005E40(0x20000, 0);
sp24 = func_80007444(0, 1, 3, 1, 2, 1);
func_8001E94C(6, 0);

ASSET_LOAD(D_1000000, common_menu1_ui, 0);
FRAGMENT_LOAD(fragment31);
func_80004454((((u32)D_8D000000 & 0x0FF00000) >> 0x14) - 0x10, _5C7A70_ROM_START, pokedex_area_model_ROM_START);

func_86D0037C();
func_80007678(sp24);
func_86D00134();
func_86D0015C();
func_86D0032C();
func_800076C0();
func_8001E9CC();
func_80005EAC();

main_pool_pop_state('MINI');

return 0;
}
15 changes: 15 additions & 0 deletions src/fragments/19/fragment19.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef _FRAGMENT19_H_
#define _FRAGMENT19_H_

#include "global.h"

void func_86D00020(void);
void func_86D000A8(void);
void func_86D000D0(UNUSED s32 arg0);
void func_86D00134(void);
void func_86D0015C(void);
void func_86D0032C(void);
void func_86D0037C(void);
s32 func_86D003EC(s32 arg0, s32 arg1);

#endif // _FRAGMENT19_H_
2 changes: 1 addition & 1 deletion src/geo_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,6 @@ void func_800189B8(void); // cmd 35
void func_80018A40(void); // cmd 36
void func_80018A8C(void); // cmd 37
void func_80018AD0(void); // cmd 38
struct GraphNode* process_geo_layout(MemoryBlock*, void*);
GraphNode* process_geo_layout(MemoryBlock*, void*);

#endif // _18480_H_
6 changes: 3 additions & 3 deletions yamls/us/rom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1052,10 +1052,10 @@
subsegments:
- [0x17FB40, textbin, fragments/19/fragment19_header]
- [0x17FB60, c, fragments/19/fragment19]
- [0x180070, data, fragments/19/fragment19_data]
- [0x180100, rodata, fragments/19/fragment19_rodata]
- [0x180070, .data, fragments/19/fragment19]
- [0x180100, .rodata, fragments/19/fragment19]

- {vram: 0x86D005D0, type: bss, name: fragments/19/fragment19_bss}
- {vram: 0x86D005D0, type: .bss, name: fragments/19/fragment19}

- name: fragment19_relocs
type: code
Expand Down

0 comments on commit 8fee860

Please sign in to comment.