Skip to content

Commit

Permalink
sdl build working?
Browse files Browse the repository at this point in the history
  • Loading branch information
freshollie committed May 23, 2024
1 parent 407c610 commit 69e333c
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ libagbsyscall/*.s

!data/maps/*/*/tilemaps/*/*.bin
*.exe
*.dll

# third party deps
/ext
37 changes: 20 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ TOOLS = $(foreach tool,$(TOOLBASE),tools/$(tool)/$(tool)$(EXE))
CPPFLAGS ?= -iquote include -D $(GAME_REGION)
CC1FLAGS ?= -Wimplicit -Wparentheses -Werror -Wno-parentheses-equality

SDL_MINGW_PKG := $(ROOT_DIR)/ext/sdl-mingw/SDL2-2.30.3/i686-w64-mingw32
SDL_MINGW_PKG := ext/SDL2-2.30.3/i686-w64-mingw32
SDL_MINGW_INCLUDE := $(SDL_MINGW_PKG)/include/SDL2
SDL_MINGW_BIN := $(SDL_MINGW_PKG)/bin
SDL_MINGW_SDL_DLL := $(SDL_MINGW_PKG)/bin/SDL2.dll
SDL_MINGW_LIB := $(SDL_MINGW_PKG)/lib
SDL_MINGW_LINKER_FLAGS := -L$(SDL_MINGW_LIB) -lSDL2main -lSDL2.dll
SDL_MINGW_FLAGS := -I$(SDL_MINGW_INCLUDE) -D_THREAD_SAFE
Expand Down Expand Up @@ -298,20 +300,20 @@ $(C_BUILDDIR)/lib/agb_flash.o: CC1FLAGS := -O1 -mthumb-interwork -Werror
$(C_BUILDDIR)/lib/agb_flash%.o: CC1FLAGS := -O1 -mthumb-interwork -Werror
endif

#### win32 deps ####
MAKEFLAGS += --no-print-directory

ifeq ($(PLATFORM),sdl_win32)
all: compare

# $(SDL_MINGW_LIB):
# @mkdir -p ext
# cd ext && wget -qO- https://github.com/libsdl-org/SDL/releases/download/release-2.30.3/SDL2-devel-2.30.3-mingw.zip | bsdtar -xvf-
endif
#### win32 deps ####

#### Main Targets ####
$(SDL_MINGW_LIB):
@mkdir -p ext
cd ext && wget -qO- https://github.com/libsdl-org/SDL/releases/download/release-2.30.3/SDL2-devel-2.30.3-mingw.zip | bsdtar -xvf-

MAKEFLAGS += --no-print-directory
SDL2.dll: $(SDL_MINGW_LIB)
cp $(SDL_MINGW_SDL_DLL) SDL2.dll

all: compare
#### Main Targets ####

rom: $(ROM)

Expand Down Expand Up @@ -354,6 +356,7 @@ clean-tools:

tidy:
$(RM) -f $(ROM) $(ELF) $(MAP)
$(RM) -f $
$(RM) -f $(BUILD_NAME)_europe.gba $(BUILD_NAME)_europe.elf $(BUILD_NAME)_europe.map
$(RM) -f $(BUILD_NAME)_japan.gba $(BUILD_NAME)_japan.elf $(BUILD_NAME)_japan.map
$(RM) -r build/*
Expand Down Expand Up @@ -407,7 +410,6 @@ PROCESSED_LDSCRIPT := $(OBJ_DIR)/$(LDSCRIPT)
$(PROCESSED_LDSCRIPT): $(LDSCRIPT)
$(CPP) -P $(CPPFLAGS) $(LDSCRIPT) > $(PROCESSED_LDSCRIPT)


$(ELF): $(OBJS) $(PROCESSED_LDSCRIPT) libagbsyscall
ifeq ($(PLATFORM),gba)
@echo "$(LD) -T $(LDSCRIPT) -Map $(MAP) <objects> <lib>"
Expand All @@ -418,7 +420,7 @@ else
ifeq ($(PLATFORM),sdl)
cd $(OBJ_DIR) && $(CC1) $(OBJS_REL) $(shell sdl2-config --cflags --libs) -o $(ROOT_DIR)/$@
else ifeq ($(PLATFORM),sdl_win32)
cd $(OBJ_DIR) && $(CC1) -mwin32 $(OBJS_REL) -lmingw32 -L$(SDL_MINGW_LIB) -lSDL2main -lSDL2.dll -lwinmm -lkernel32 -lxinput -o $(ROOT_DIR)/$@ -Xlinker -Map "$(ROOT_DIR)/$(MAP)"
cd $(OBJ_DIR) && $(CC1) -mwin32 $(OBJS_REL) -lmingw32 -L$(ROOT_DIR)/$(SDL_MINGW_LIB) -lSDL2main -lSDL2.dll -lwinmm -lkernel32 -lxinput -o $(ROOT_DIR)/$@ -Xlinker -Map "$(ROOT_DIR)/$(MAP)"
else
@cd $(OBJ_DIR) && $(CC1) -mwin32 $(OBJS_REL) -L$(ROOT_DIR)/libagbsyscall -lagbsyscall -lkernel32 -o $(ROOT_DIR)/$@ -Xlinker -Map "$(ROOT_DIR)/$(MAP)"
endif
Expand Down Expand Up @@ -446,10 +448,10 @@ endif
$(C_OBJS): $(OBJ_DIR)/%.o: %.c $$(c_dep)
@echo "$(CC1) <flags> -o $@ $<"
@$(shell mkdir -p $(shell dirname '$(OBJ_DIR)/$*.i'))
$(CPP) $(CPPFLAGS) $< -o $(OBJ_DIR)/$*.i
$(PREPROC) $(OBJ_DIR)/$*.i | $(CC1) $(CC1FLAGS) -o $(OBJ_DIR)/$*.s -
printf ".text\n\t.align\t2, 0\n" >> $(OBJ_DIR)/$*.s
$(ASM_PSEUDO_OP_CONV) $(OBJ_DIR)/$*.s | $(AS) $(ASFLAGS) -o $@ -
@$(CPP) $(CPPFLAGS) $< -o $(OBJ_DIR)/$*.i
@$(PREPROC) $(OBJ_DIR)/$*.i | $(CC1) $(CC1FLAGS) -o $(OBJ_DIR)/$*.s -
@printf ".text\n\t.align\t2, 0\n" >> $(OBJ_DIR)/$*.s
@$(ASM_PSEUDO_OP_CONV) $(OBJ_DIR)/$*.s | $(AS) $(ASFLAGS) -o $@ -

# Build arm asm sources
ifeq ($(CPU_ARCH),arm)
Expand Down Expand Up @@ -493,7 +495,8 @@ x86: ; @$(MAKE) PLATFORM=win32 CPU_ARCH=i386

sdl: ; @$(MAKE) PLATFORM=sdl

sdl_win32: ; @$(MAKE) PLATFORM=sdl_win32 CPU_ARCH=i386
sdl_win32: SDL2.dll $(SDL_MINGW_LIB)
@$(MAKE) PLATFORM=sdl_win32 CPU_ARCH=i386

chao_garden/mb_chao_garden.gba:
@$(MAKE) -C chao_garden DEBUG=0
Expand Down
4 changes: 1 addition & 3 deletions libagbsyscall/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ ifneq ($(PLATFORM),gba)
endif
else
ifeq ($(PLATFORM), sdl)
CC1FLAGS += -m32
CPPFLAGS += -m32
CPP := $(CC1) -E
CPP := $(CC1) -E
endif
CPPFLAGS += -D CPU_ARCH_X86=0
endif
Expand Down
12 changes: 6 additions & 6 deletions src/lib/m4a.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,19 +302,19 @@ void SoundInit(struct SoundInfo *soundInfo)
| SOUND_A_FIFO_RESET | SOUND_A_TIMER_0 | SOUND_A_RIGHT_OUTPUT
| SOUND_ALL_MIX_FULL;
REG_SOUNDBIAS_H = (REG_SOUNDBIAS_H & 0x3F) | 0x40;
REG_DMA1SAD = (s32)soundInfo->pcmBuffer;
REG_DMA1DAD = (s32)&REG_FIFO_A;
REG_DMA2SAD = (s32)soundInfo->pcmBuffer + PCM_DMA_BUF_SIZE;
REG_DMA2DAD = (s32)&REG_FIFO_B;
REG_DMA1SAD = (intptr_t)soundInfo->pcmBuffer;
REG_DMA1DAD = (intptr_t)&REG_FIFO_A;
REG_DMA2SAD = (intptr_t)soundInfo->pcmBuffer + PCM_DMA_BUF_SIZE;
REG_DMA2DAD = (intptr_t)&REG_FIFO_B;
SOUND_INFO_PTR = soundInfo;
CpuFill32(0, soundInfo, sizeof(struct SoundInfo));
soundInfo->maxChans = 8;
soundInfo->masterVolume = 15;
soundInfo->plynote = (u32)ply_note;
soundInfo->plynote = (uintptr_t)ply_note;
soundInfo->CgbSound = DummyCallback;
soundInfo->CgbOscOff = (void (*)(u8))DummyCallback;
soundInfo->MidiKeyToCgbFreq = (u32(*)(u8, u8, u8))DummyCallback;
soundInfo->ExtVolPit = (u32)DummyCallback;
soundInfo->ExtVolPit = (uintptr_t)DummyCallback;
MPlayJumpTableCopy(gMPlayJumpTable);
soundInfo->MPlayJumpTable = (uintptr_t)gMPlayJumpTable;
SampleFreqSet(SOUND_MODE_FREQ_13379); // ???
Expand Down
24 changes: 12 additions & 12 deletions src/platform/shared/stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,17 @@ void SoundMainBTM(void) { }
double sqrt(double v) { return 0; }
float atan2f(float a, float b) { return 0; }

#ifdef WIN32
void *memset(void *_dst, int value, unsigned int size)
{
u8 *dst = (u8 *)_dst;
u8 *end = dst + size;
// #ifdef WIN32
// void *memset(void *_dst, int value, unsigned int size)
// {
// u8 *dst = (u8 *)_dst;
// u8 *end = dst + size;

while (dst < end) {
*dst = value;
dst++;
}
// while (dst < end) {
// *dst = value;
// dst++;
// }

return dst;
}
#endif
// return dst;
// }
// #endif

0 comments on commit 69e333c

Please sign in to comment.