summaryrefslogtreecommitdiff
path: root/src/debug_menu.c
blob: 376b267ff7e6a399cf455d8dba3b564a406ef993 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#include "global.h"
#include "debug_menu.h"
#include "input.h"
#include "main_menu.h"
#include "menu.h"
#include "memory.h"

extern struct DebugMenu *gUnknown_203B3EC;

const struct UnkTextStruct2 gUnknown_80E7D40 =
{
    0x00, 0x00, 0x00, 0x00,
    0x03, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00,
    0x00, 0x00,
    0x00, 0x00,
    NULL
};

const struct UnkTextStruct2 gUnknown_80E7D58 = 
{
    0x00, 0x00, 0x00, 0x00,
    0x03, 0x00, 0x00, 0x00,
    0x02, 0x00, 0x02, 0x00,
    0x09, 0x0b,
    0x0b, 0x00,
    NULL
};

const struct MenuItem gDebugMenuItems[8] =
{
    {"Dungeons", MENU_DEBUG_MENU_DUNGEONS},
    {"Field", MENU_DEBUG_MENU_FIELD},
    {"Field Map", MENU_DEBUG_MENU_FIELD_MAP},
    {"Field Script", MENU_DEBUG_MENU_FIELD_SCRIPT},
    {"Debug Menu", MENU_DEBUG_MENU_DEBUG_MENU},
    {"Storage", MENU_DEBUG_MENU_STORAGE},
    {"h-open", MENU_DEBUG_MENU_H_OPEN},
    {NULL, 10},
};

ALIGNED(4) static const char debug_menu_fill0[] = "pksdir0";
ALIGNED(4) static const char debug_menu_fill1[] = "pksdir0";
ALIGNED(4) static const char debug_menu_fill2[] = "pksdir0";
ALIGNED(4) static const char debug_menu_fill3[] = "pksdir0";
ALIGNED(4) static const char debug_menu_fill4[] = "pksdir0";
ALIGNED(4) static const char debug_menu_fill5[] = "pksdir0";
ALIGNED(4) static const char debug_menu_fill6[] = "pksdir0";



extern u8 sub_8012FD8(struct DebugMenu *);
extern void sub_8013114(struct DebugMenu *, s32 *);
extern void sub_80976F8(u8);
extern void sub_803A3BC(void);
extern void sub_803A3A0(void);

extern void SetMenuItems(void *menu, struct UnkTextStruct2 *, u32, const struct UnkTextStruct2 *, const struct MenuItem *entries, u32, u32, u32);
extern void sub_8035CF4(struct DebugMenu *, u32, u32);
extern void sub_8035CC0(struct UnkTextStruct2 *, u32);

void CreateDebugMenu(void)
{
  int iVar2;

  if (gUnknown_203B3EC == NULL) {
    gUnknown_203B3EC = MemoryAlloc(sizeof(struct DebugMenu), 8);
    MemoryFill8((u8 *)gUnknown_203B3EC, 0, sizeof(struct DebugMenu));
  }
  for(iVar2 = 0; iVar2 < 4; iVar2++){
    gUnknown_203B3EC->unk140[iVar2] = gUnknown_80E7D40;
  }
  ResetUnusedInputStruct();
  sub_800641C(gUnknown_203B3EC->unk140, 1, 1);
  SetDebugMenuItems();
}

void DeleteDebugMenu(void)
{
    ResetUnusedInputStruct();
    sub_800641C(NULL, 1, 1);
    if(gUnknown_203B3EC != NULL)
    {
        MemoryFree(gUnknown_203B3EC);
        gUnknown_203B3EC = NULL;
    }
}

u32 UpdateDebugMenu(void)
{
  u32 nextMenu;
  s32 counter;
  s32 debugMenuAction;

  nextMenu = MENU_NO_SCREEN_CHANGE;
  debugMenuAction = 11;

  if (sub_8012FD8(gUnknown_203B3EC) == 0) {
    sub_8013114(gUnknown_203B3EC, &debugMenuAction);
  }

  switch(debugMenuAction) {
      case MENU_DEBUG_MENU_DUNGEONS:
        nextMenu = MENU_DEBUG_DUNGEON;
        break;
      case MENU_DEBUG_MENU_FIELD:
        nextMenu = MENU_DEBUG_FIELD;
        break;
      case MENU_DEBUG_MENU_FIELD_MAP:
        nextMenu = MENU_DEBUG_FIELD_MAP;
        break;
      case MENU_DEBUG_MENU_FIELD_SCRIPT:
        nextMenu = MENU_DEBUG_FIELD_SCRIPT;
        break;
      case MENU_DEBUG_MENU_DEBUG_MENU:
        nextMenu = MENU_DEBUG_DEBUG_MENU;
        break;
      case MENU_DEBUG_MENU_UNKNOWN_1: // No option that correponds to this one
        nextMenu = MENU_DEBUG_UNKNOWN_1;
        break;
      case MENU_DEBUG_MENU_STORAGE:
        sub_803A3BC();
        nextMenu = MENU_MAIN_SCREEN;
        break;
      case MENU_DEBUG_MENU_H_OPEN:
        for(counter = 0; counter < 0x20; counter++){
          sub_80976F8(counter);
        }
        nextMenu = MENU_MAIN_SCREEN;
        break;
      case 10:
        sub_803A3A0();
        nextMenu = MENU_MAIN_SCREEN;
        break;
      case 11:
        nextMenu = MENU_NO_SCREEN_CHANGE;
  }
  return nextMenu;
}

void SetDebugMenuItems(void)
{
  SetMenuItems(gUnknown_203B3EC, gUnknown_203B3EC->unk140, 0, &gUnknown_80E7D58, gDebugMenuItems, 1, 0xd, 0);
  sub_8035CF4(gUnknown_203B3EC,0,1);
}

void sub_803A3A0(void)
{
    sub_8035CC0(gUnknown_203B3EC->unk140, 0);
}