Skip to content

Commit 31ac98b

Browse files
committed
Fix bug where menu can't open
1 parent e30bec3 commit 31ac98b

10 files changed

+14
-55
lines changed

Makefile

+2-6
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ HFILES = boot.h game.h controller.h font.h font_ext.h \
6464
src/cpu.h \
6565
src/memory_map.h
6666

67-
CODEFILES = boot.c game.c controller.c dram_stack.c \
67+
CODEFILES = boot.c game.c controller.c dram_stack.c gfxinit.c \
6868
src/assert.c \
6969
src/test/cpu_test.c \
7070
src/test/cpu_tests_0.c \
@@ -117,13 +117,9 @@ CODEOBJECTS = $(patsubst %.c, build/%.o, $(CODEFILES)) build/asm/cpu.o
117117

118118
ASMOBJECTS = $(patsubst %.s, build/%.o, $(S_FILES))
119119

120-
DATAFILES = gfxinit.c
121-
122-
DATAOBJECTS = $(patsubst %.c, build/%.o, $(DATAFILES))
123-
124120
CODESEGMENT = build/codesegment.o
125121

126-
OBJECTS = $(CODESEGMENT) $(DATAOBJECTS) $(ASMOBJECTS) $(BOOT_OBJ) data/cgb_bios_placeholder.bin data/dmg_boot_placeholder.bin bin/rsp/ppu.o
122+
OBJECTS = $(CODESEGMENT) $(ASMOBJECTS) $(BOOT_OBJ) data/cgb_bios_placeholder.bin data/dmg_boot_placeholder.bin bin/rsp/ppu.o
127123

128124
build/asm/data.o build/asm/data_placeholder.o: data/cgb_bios_placeholder.bin data/dmg_boot_placeholder.bin
129125

asm/data.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ glabel _cgb_biosSegmentRomStart
1313
glabel _cgb_biosSegmentRomEnd
1414

1515
glabel _gbromSegmentRomStart
16-
.incbin "data/PokemonBlue.gb"
16+
.incbin "data/PokemonYellow.gb"
1717
.balign 16
1818
glabel _gbromSegmentRomEnd

boot.c

-32
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ extern char _codeSegmentTextStart[];
5151
/*
5252
* Symbols generated by "makerom" (ROM)
5353
*/
54-
extern char _staticSegmentRomStart[],
55-
_staticSegmentRomEnd[];
5654
extern char _gbromSegmentRomStart[];
5755

5856
/*
@@ -96,8 +94,6 @@ OSIoMesg dmaIOMessageBuf; /* * see man page to understand this */
9694
* global variables
9795
*/
9896
int rdp_flag = 0;
99-
char *staticSegment;
100-
char *_gEndSegments;
10197

10298

10399

@@ -193,28 +189,6 @@ static void mainproc(void *arg)
193189
osCreateMesgQueue(&retraceMessageQ, retraceMessageBuf, 20);
194190
osViSetEvent(&retraceMessageQ, NULL, 1);
195191

196-
/*
197-
* Stick the static segment right after the code/data segment
198-
*/
199-
staticSegment = _codeSegmentEnd;
200-
201-
osInvalDCache((void *)staticSegment,
202-
(u32) _staticSegmentRomEnd - (u32) _staticSegmentRomStart);
203-
204-
205-
dmaIOMessageBuf.hdr.pri = OS_MESG_PRI_NORMAL;
206-
dmaIOMessageBuf.hdr.retQueue = &dmaMessageQ;
207-
dmaIOMessageBuf.dramAddr = staticSegment;
208-
dmaIOMessageBuf.devAddr = (u32)_staticSegmentRomStart;
209-
dmaIOMessageBuf.size = (u32)_staticSegmentRomEnd-(u32)_staticSegmentRomStart;
210-
211-
osEPiStartDma(handler, &dmaIOMessageBuf, OS_READ);
212-
213-
/*
214-
* Wait for DMA to finish
215-
*/
216-
(void) osRecvMesg(&dmaMessageQ, NULL, OS_MESG_BLOCK);
217-
218192

219193
#ifdef USE_DEBUGGER
220194
OSThread* threads = &mainThread;
@@ -225,12 +199,6 @@ static void mainproc(void *arg)
225199
}
226200
#endif
227201

228-
229-
/*
230-
* Stick the texture segment right after the static segment
231-
*/
232-
_gEndSegments = staticSegment +
233-
(u32) _staticSegmentRomEnd - (u32) _staticSegmentRomStart;
234202

235203
clearDebugOutput();
236204

boot.h

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*
1818
*/
1919

20-
#define STATIC_SEGMENT 1
2120
#define DYNAMIC_SEGMENT 3
2221

2322
#define SCREEN_HT 480

gb64.ld

-7
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,6 @@ SECTIONS
8484
_codeSegmentBssEnd = .;
8585

8686
_heapStart = .;
87-
88-
BEGIN_SEG(static, 0x01000000)
89-
{
90-
build/gfxinit.o(.data);
91-
build/gfxinit.o(.bss);
92-
}
93-
END_SEG(static)
9487

9588
. = 0x80200000;
9689

memory.c

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ void* gHeapEnd;
1010
* Symbol genererated by "makerom" (RAM)
1111
*/
1212
extern char _heapStart[];
13-
extern char *_gEndSegments;
14-
1513

1614
void initBlock(struct HeapSegment* segment, void* end, int type)
1715
{

render.c

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ void renderFrame(int clear)
6262
* Tell RCP where each segment is
6363
*/
6464
gSPSegment(glistp++, 0, 0x0); /* physical segment */
65-
gSPSegment(glistp++, STATIC_SEGMENT, OS_K0_TO_PHYSICAL(staticSegment));
6665

6766
gDPSetColorImage(glistp++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WD, OS_K0_TO_PHYSICAL(getColorBuffer()));
6867

render.h

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ extern OSMesgQueue
1616
* global variables
1717
*/
1818
extern int rdp_flag;
19-
extern char *staticSegment;
2019

2120
/*
2221
* frame buffer symbols

src/faulthandler.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void installFaultHandler(OSThread *targetThread)
2222
* Create main thread
2323
*/
2424
osCreateThread(&faultThread, 4, faultHandlerProc, targetThread,
25-
faultThreadStack + FAULT_STACK_SIZE / sizeof(u64), 10);
25+
faultThreadStack + FAULT_STACK_SIZE / sizeof(u64), 11);
2626

2727
osStartThread(&faultThread);
2828
}
@@ -41,10 +41,19 @@ void dumpThreadInfo(OSThread *targetThread)
4141
static void faultHandlerProc(void* arg)
4242
{
4343
OSThread *targetThread = (OSThread*)arg;
44+
OSMesgQueue timerQueue;
45+
OSMesg timerMessages[10];
46+
OSTimer timer;
47+
48+
osCreateMesgQueue(&timerQueue, timerMessages, 10);
49+
osSetTimer(&timer, 0, HANG_DELAY, &timerQueue, NULL);
4450

4551
faultHandlerHeartbeat();
4652

4753
while (1) {
54+
OSMesg msg;
55+
osRecvMesg(&timerQueue, &msg, OS_MESG_BLOCK);
56+
4857
if (osGetTime() - lastHeartbeatTime >= HANG_DELAY) {
4958
DEBUG_PRINT_F("Main thread frozen:\n");
5059
dumpThreadInfo(targetThread);
@@ -57,8 +66,6 @@ static void faultHandlerProc(void* arg)
5766
DEBUG_PRINT_F("Main thread faulted:\n");
5867
dumpThreadInfo(curr);
5968
break;
60-
} else {
61-
osYieldThread();
6269
}
6370
}
6471

src/sprite.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "sprite.h"
33
#include "assert.h"
44

5-
#define DL_CHUNK_SIZE 16
5+
#define DL_CHUNK_SIZE 64
66
#define SPRITE_GL_LENGTH 2098
77

88
Gfx* gLayerSetup[MAX_LAYER_COUNT];

0 commit comments

Comments
 (0)