-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- formatted with clang-format - Fixed up build for gdbk-2020 v4.3.0 - Simplified Makefile to use lcc matching the templates/examples from GDBK
- Loading branch information
Showing
21 changed files
with
639 additions
and
866 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
.vscode/ | ||
gbdk/ | ||
Source/obj | ||
mgb.gb | ||
Source/out | ||
mgb.gb |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,69 @@ | ||
BIN=../gbdk-n/bin | ||
OBJ=./obj | ||
# If you move this project you can change the directory | ||
# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/" | ||
ifndef GBDK_HOME | ||
GBDK_HOME = ../gbdk | ||
endif | ||
|
||
PROJECTNAME = mGB | ||
|
||
LCC = $(GBDK_HOME)/bin/lcc | ||
|
||
build: | ||
mkdir -p $(OBJ) | ||
$(BIN)/gbdk-n-compile.sh mgb_save.c -o $(OBJ)/mgb_save.rel -Wa-l -ba0 | ||
LCCFLAGS += -msm83:gb # GB/GBC | ||
# LCCFLAGS += -v # verbose | ||
# LCCFLAGS += -autobank | ||
|
||
ifdef DEBUG | ||
LCCFLAGS += -debug -v | ||
endif | ||
|
||
ifdef RELEASE | ||
LCCFLAGS += -Wf--max-allocs-per-node50000 # A better speed optimization than --opt-code-speed | ||
else | ||
LCCFLAGS += -Wf--opt-code-speed # Optimize for code speed rather than size | ||
endif | ||
|
||
# sdcc settings (-Wf and -Wp) | ||
# LCCFLAGS += -Wf--legacy-banking # Use legacy method to call banked functions | ||
|
||
# sdasgb (asm) settings (-Wa) | ||
# LCCFLAGS += -Wa-l # generate asm listing | ||
# LCCFLAGS += -Wa-a # All symbols are global | ||
# LCCFLAGS += -Wa-s # Create symbol file/outfile[.sym] | ||
# LCCFLAGS += -Wa-j # Enable NoICE Debug Symbols | ||
# LCCFLAGS += -Wa-y # Enable SDCC Debug Symbols | ||
# LCCFLAGS += -Wa-g # Undefined symbols are global | ||
# LCCFLAGS += -Wa-n # Don't resolve global assigned value symbols | ||
# LCCFLAGS += -Wa-z # Disable case sensitivity for symbols | ||
|
||
$(BIN)/gbdk-n-assemble.sh $(OBJ)/mGBASMFunctions.rel mGBASMFunctions.s | ||
$(BIN)/gbdk-n-assemble.sh $(OBJ)/mGBASMSynthFunctions.rel mGBASMSynthFunctions.s | ||
$(BIN)/gbdk-n-assemble.sh $(OBJ)/mGBASMMidiFunctions.rel mGBASMMidiFunctions.s | ||
# sdldgb (linker) settings (-Wl) | ||
# LCCFLAGS += -Wl-m # Map output generated as (out)file[.map] | ||
# LCCFLAGS += -Wl-j # NoICE Debug output as (out)file[.noi] | ||
# LCCFLAGS += -Wl-w # Wide listing format for map file | ||
|
||
$(BIN)/gbdk-n-compile.sh mgb.c -o $(OBJ)/mgb.rel -I ./ -Wa-l -Wl-m -Wl-j | ||
# makebin settings (-Wm) | ||
# LCCFLAGS += -Wm-yS # Convert .noi file named like input file to .sym | ||
LCCFLAGS += -Wm-yc # GBC compatible | ||
LCCFLAGS += -Wm-yn"$(PROJECTNAME)" # cartridge name | ||
LCCFLAGS += -Wm-yt3 # MBC type = ROM+MBC1+RAM+BATT | ||
LCCFLAGS += -Wm-ya1 # number of ram banks: -ya 1 | ||
|
||
|
||
OBJ=obj | ||
OUT=out | ||
|
||
build: | ||
mkdir -p $(OBJ) | ||
mkdir -p $(OUT) | ||
|
||
# mostly so you can see the .asm | ||
$(LCC) $(LCCFLAGS) -c -o $(OBJ)/mGB.rel mGB.c | ||
|
||
$(BIN)/gbdk-n-link.sh $(OBJ)/mgb.rel $(OBJ)/mgb_save.rel $(OBJ)/mGBASMFunctions.rel $(OBJ)/mGBASMSynthFunctions.rel $(OBJ)/mGBASMMidiFunctions.rel -o $(OBJ)/mgb.ihx | ||
$(LCC) $(LCCFLAGS) -o $(OUT)/$(PROJECTNAME).gb $(OBJ)/mGB.rel *.s | ||
|
||
$(BIN)/gbdk-n-make-rom.sh -ya 1 $(OBJ)/mgb.ihx mgb.gb | ||
compile.bat: Makefile | ||
@echo "REM Automatically generated from Makefile" > compile.bat | ||
@make -sn | sed y/\\//\\\\/ | sed s/mkdir\ \-p/mkdir/ | grep -v make >> compile.bat | ||
|
||
clean: | ||
rm -rf $(OBJ) | ||
rm -f mgb.gb | ||
rm -rf $(OUT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
REM Automatically generated from Makefile | ||
mkdir obj | ||
mkdir out | ||
# -ba 0 probably not needed anymore | ||
..\..\gbdk-4.3.0\bin\lcc -msm83:gb -Wf--opt-code-speed -Wf--legacy-banking -Wm-yc -Wm-yn"mGB" -Wm-yt3 -Wm-ya1 -c -Wb-ba0 -o obj\mgb_save.rel mgb_save.c | ||
# mostly so you can see the .asm | ||
..\..\gbdk-4.3.0\bin\lcc -msm83:gb -Wf--opt-code-speed -Wf--legacy-banking -Wm-yc -Wm-yn"mGB" -Wm-yt3 -Wm-ya1 -c -o obj\mGB.rel mGB.c | ||
..\..\gbdk-4.3.0\bin\lcc -msm83:gb -Wf--opt-code-speed -Wf--legacy-banking -Wm-yc -Wm-yn"mGB" -Wm-yt3 -Wm-ya1 -o out\mGB.gb obj\mGB.rel obj\mgb_save.rel *.s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,123 @@ | ||
#include <gb/gb.h> | ||
#include <mGB.h> | ||
#include "mGB.h" | ||
|
||
void printbyte(UBYTE v1, UBYTE v2, UBYTE v3) | ||
{ | ||
bkg[0] = (v1 >> 4)+1; | ||
bkg[1] = (0x0F & v1)+1; | ||
void printbyte(UBYTE v1, UBYTE v2, UBYTE v3) { | ||
bkg[0] = (v1 >> 4) + 1; | ||
bkg[1] = (0x0F & v1) + 1; | ||
|
||
bkg[2] = 0; | ||
bkg[2] = 0; | ||
|
||
bkg[3] = (v2 >> 4)+1; | ||
bkg[4] = (0x0F & v2)+1; | ||
bkg[3] = (v2 >> 4) + 1; | ||
bkg[4] = (0x0F & v2) + 1; | ||
|
||
bkg[5] = 0; | ||
bkg[5] = 0; | ||
|
||
bkg[6] = (v3 >> 4)+1; | ||
bkg[7] = (0x0F & v3)+1; | ||
bkg[6] = (v3 >> 4) + 1; | ||
bkg[7] = (0x0F & v3) + 1; | ||
|
||
bkg[8] = 0; | ||
set_bkg_tiles(1,16,10,1,bkg); | ||
bkg[8] = 0; | ||
set_bkg_tiles(1, 16, 10, 1, bkg); | ||
} | ||
|
||
#include <mGBSynthPitchFunctions.c> | ||
#include <mGBSynthCommonFunctions.c> | ||
#include <mGBDisplayFunctions.c> | ||
#include <mGBMemoryFunctions.c> | ||
#include <mGBUserFunctions.c> | ||
#include "mGBDisplayFunctions.c" | ||
#include "mGBMemoryFunctions.c" | ||
#include "mGBMidiFunctions.c" | ||
#include "mGBSynthCommonFunctions.c" | ||
#include "mGBSynthPitchFunctions.c" | ||
#include "mGBUserFunctions.c" | ||
#include "serial.c" | ||
|
||
void setSoundDefaults() | ||
{ | ||
NR52_REG = 0x8FU; //Turn sound on | ||
NR50_REG = 0x77U; //Turn on Pulses outs | ||
void setSoundDefaults(void) { | ||
rAUDENA = 0x8FU; // Turn sound on | ||
rAUDVOL = 0x77U; // Turn on Pulses outs | ||
|
||
setOutputPan(0U, 64U); | ||
setOutputPan(1U, 64U); | ||
setOutputPan(2U, 64U); | ||
setOutputPan(3U, 64U); | ||
|
||
asmLoadWav(wavDataOffset); //tRIANGLE | ||
NR32_REG = 0x00U; | ||
asmLoadWav(wavDataOffset); // tRIANGLE | ||
rAUD3LEVEL = 0x00U; | ||
|
||
NR44_REG = 0x80U; | ||
NR41_REG = 0x3FU; //sound length | ||
rAUD4GO = 0x80U; | ||
rAUD4LEN = 0x3FU; // sound length | ||
} | ||
|
||
void testSynths() | ||
{ | ||
addressByte = 0x40; | ||
valueByte = 0x7F; | ||
asmPlayNotePu1(); | ||
void testSynths(void) { | ||
addressByte = 0x40; | ||
valueByte = 0x7F; | ||
asmPlayNotePu1(); | ||
} | ||
|
||
void main(void) { | ||
|
||
void main() | ||
{ | ||
disable_interrupts(); | ||
cpu_fast(); | ||
checkMemory(); | ||
displaySetup(); | ||
setSoundDefaults(); | ||
add_TIM(updateSynths); | ||
|
||
loadDataSet(0x00U); | ||
loadDataSet(0x01U); | ||
loadDataSet(0x02U); | ||
loadDataSet(0x03U); | ||
enable_interrupts(); | ||
CRITICAL { | ||
cpu_fast(); | ||
checkMemory(); | ||
displaySetup(); | ||
setSoundDefaults(); | ||
add_TIM(updateSynths); | ||
|
||
loadDataSet(0x00U); | ||
loadDataSet(0x01U); | ||
loadDataSet(0x02U); | ||
loadDataSet(0x03U); | ||
} | ||
|
||
/* Set TMA to divide clock by 0x100 */ | ||
TMA_REG = 0x00U; | ||
rTMA = 0x00U; | ||
/* Set clock to 262144 Hertz */ | ||
TAC_REG = 0x05U; | ||
rTAC = TACF_START | TACF_262KHZ; | ||
/* Handle VBL and TIM interrupts */ | ||
|
||
set_interrupts(VBL_IFLAG | TIM_IFLAG | SIO_IFLAG); | ||
|
||
SHOW_BKG; | ||
SHOW_SPRITES; | ||
SHOW_BKG; | ||
SHOW_SPRITES; | ||
|
||
showSplashScreen(); | ||
delay(2000); | ||
showSplashScreen(); | ||
delay(2000); | ||
|
||
showMainScreen(); | ||
printversion(); | ||
//testSynths(); | ||
asmMain(); | ||
showMainScreen(); | ||
printversion(); | ||
// testSynths(); | ||
gameMain(); | ||
} | ||
|
||
inline void gameMain(void) { | ||
rSC = SIOF_XFER_START | SIOF_CLOCK_EXT; | ||
while (1) { | ||
systemIdle = 1; | ||
|
||
updateMidiBuffer(); | ||
|
||
if (systemIdle) | ||
getPad(); | ||
|
||
if (systemIdle) | ||
asmUpdatePu1(); | ||
|
||
if (systemIdle) | ||
asmUpdatePu2(); | ||
|
||
if (systemIdle) | ||
asmUpdateWav(); | ||
|
||
if (systemIdle) | ||
asmUpdateNoi(); | ||
|
||
if (systemIdle) | ||
mainScreen(); | ||
} | ||
} | ||
|
||
void mainScreen(void) { | ||
if (currentScreen == 0) { | ||
return; | ||
}; | ||
|
||
updateDisplaySynthCounter = (updateDisplaySynthCounter + 1) & 3U; | ||
|
||
updateDisplaySynth(); | ||
// printbyte(statusByte, addressByte, valueByte); | ||
setPlayMarker(); | ||
} |
Oops, something went wrong.