Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Zal0 committed Jan 22, 2021
2 parents 6a6f802 + d2391ff commit 97064af
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 31 deletions.
2 changes: 1 addition & 1 deletion common/include/BankManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#define BANK_MANAGER_H

#include "Stack.h"
#include <gb/gb.h>

#define N_PUSH_BANKS 10

extern UINT8 _current_bank; //defined in crt0.s Used by banked_call and banked ret
extern UINT8* bank_stack;

void PushBank(UINT8 b);
Expand Down
2 changes: 1 addition & 1 deletion common/include/Banks/SetBankCommon.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define _CONCAT(A,B) A ## B
#define CONCAT(A,B) _CONCAT(A,B)

void empty(void) __nonbanked {}
void empty(void) __nonbanked;
__addressmod empty const CODE;
2 changes: 1 addition & 1 deletion common/src/BankManager.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

DECLARE_STACK(bank_stack, N_PUSH_BANKS);


void empty(void) __nonbanked {}

void PushBank(UINT8 b) {
b;
Expand Down
2 changes: 1 addition & 1 deletion common/src/Keys.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Keys.h"

UBYTE previous_KEYS = 0;
UBYTE previous_keys = 0;
UBYTE keys = 0;
54 changes: 30 additions & 24 deletions common/src/MakefileCommon
Original file line number Diff line number Diff line change
@@ -1,51 +1,56 @@
ZGB_PATH_UNIX := $(subst ',,$(subst \,/,'$(ZGB_PATH)'))
GBDK_HOME := $(ZGB_PATH_UNIX)/../env/gbdk
PATH := $(ZGB_PATH_UNIX)/../env/make-3.81-bin/bin;$(ZGB_PATH_UNIX)/../env/gbdk/bin/SDCC/bin;$(ZGB_PATH_UNIX)/../env/msys/bin;$(PATH)
PATH := $(ZGB_PATH_UNIX)/../env/make-3.81-bin/bin;$(ZGB_PATH_UNIX)/../env/gbdk/bin;$(ZGB_PATH_UNIX)/../env/msys/bin;$(PATH)

#--- Default build will be release. Can be overiden passing BUILD_TYPE = debug as a parameter
BUILD_TYPE = Release
CGB = yes

ifneq (,$(findstring Release,$(BUILD_TYPE)))
BUILD_DEFS += -DNDEBUG
else
PROJECT_NAME := $(PROJECT_NAME)_Debug
endif

OBJDIR = ../$(BUILD_TYPE)
OBJDIR_RES_SRC = ../res/src
OBJDIR_RES = ../$(BUILD_TYPE)/res
OBJDIR_ZGB = ../$(BUILD_TYPE)/zgb
BINDIR = ../bin

LCC = $(GBDK_HOME)/bin/lcc
SDCC = sdcc
SDASGB = sdasgb
SDLDGB = sdldgb
MAKEBIN = makebin
IHXCHECK = ihxcheck

GBR2C = $(ZGB_PATH_UNIX)/../tools/gbr2c/gbr2c
GBM2C = $(ZGB_PATH_UNIX)/../tools/gbm2c/gbm2c
PNGB = $(ZGB_PATH_UNIX)/../env/pngb
MOD2GBT = $(ZGB_PATH_UNIX)/../env/mod2gbt
BGB = $(ZGB_PATH_UNIX)/../env/bgb/bgb
ROMVIEW = $(ZGB_PATH_UNIX)/../env/romview/romview.exe

ifneq ($(strip $(N_BANKS)),)
LFLAGS_NBANKS = -Wl-yt1 -Wl-yo$(N_BANKS)
endif

CFLAGS = -mgbz80 --no-std-crt0 --fsigned-char --use-stdout -Dnonbanked= -I$(GBDK_HOME)/include -I$(GBDK_HOME)/include/asm $(BUILD_DEFS) -I../include -I$(ZGB_PATH_UNIX)/include
CFLAGS += -DFILE_NAME=$(basename $(<F))

#since I am placing my OAM mirror at the end of the ram (0xDF00-0xDFFF) I need to move the stack to 0xDEFF
LNAMES=-g _shadow_OAM=0xC000 -g .STACK=0xDEFF -g .refresh_OAM=0xFF80 -b _DATA=0xc0a0 -b _CODE=0x0200
LFLAGS=-n -m -j -w -i -k $(GBDK_HOME)/lib/small/asxxxx/gbz80/ -l gbz80.lib -k $(GBDK_HOME)/lib/small/asxxxx/gb/ -l gb.lib -k $(OBJDIR_ZGB)/ -l zgb.lib $(LNAMES)

ifneq ($(strip $(N_BANKS)),)
BINFLAGS = -yt 1 -yo $(N_BANKS)
endif

# DMG/Color flags
EXTENSION = gb
ifneq (,$(findstring Color,$(BUILD_TYPE)))
LFLAGS_NBANKS += -Wl-yp0x143=0xC0
BINFLAGS += -yc
CFLAGS += -DCGB
EXTENSION = gbc
endif

LFLAGS = -Wl-m -Wl-j $(LFLAGS_NBANKS)

#since I am placing my OAM mirror at the end of the ram (0xDF00-0xDFFF) I need to move the stack to 0xDEFF
LFLAGS += -Wl-g.STACK=0xDEFF
# Release/Debug flags
ifneq (,$(findstring Debug,$(BUILD_TYPE)))
CFLAGS += --debug
LFLAGS += -y
PROJECT_NAME := $(PROJECT_NAME)_Debug
else
CFLAGS += -DNDEBUG
endif

current_dir = $(shell pwd)

Expand Down Expand Up @@ -127,7 +132,7 @@ $(OBJDIR_ZGB):

$(OBJDIR)/zgb/%.o: $(ZGB_PATH_UNIX)/src/%.s
@echo compiling $<
@$(SDASGB) -plosgff -I"libc" $(filter --constseg CODE_%, $(subst .b,--constseg CODE_,$(suffix $(<:%.s=%)))) -c -o $@ $<
@$(SDASGB) -plosgff -I"libc" -I$(GBDK_HOME)/lib/small/asxxxx $(filter --constseg CODE_%, $(subst .b,--constseg CODE_,$(suffix $(<:%.s=%)))) -c -o $@ $<

$(OBJDIR)/zgb/%.o: $(ZGB_PATH_UNIX)/src/%.c
@echo compiling $<
Expand All @@ -149,11 +154,12 @@ $(OBJDIR)/%.o: %.c

$(BINDIR)/$(PROJECT_NAME).$(EXTENSION): $(OBJDIR_ZGB)/zgb.lib $(OBJDIR) $(OBJDIR_RES) $(OBJDIR_RES_SRC) $(BINDIR) $(OBJS)
@echo Linking
$(LCC) $(LFLAGS) -k$(OBJDIR_ZGB) -lzgb.lib -o $(OBJDIR)/$(PROJECT_NAME).$(EXTENSION) $(OBJS)
mv .map $(OBJDIR)/$(PROJECT_NAME).map
mv .sym $(OBJDIR)/$(PROJECT_NAME).sym
$(ROMVIEW) $(OBJDIR)/$(PROJECT_NAME).$(EXTENSION) 255
mv $(OBJDIR)/$(PROJECT_NAME).$(EXTENSION) $(BINDIR)/$(PROJECT_NAME).$(EXTENSION)
@$(SDLDGB) $(LFLAGS) $(OBJDIR)/$(PROJECT_NAME).ihx $(GBDK_HOME)/lib/small/asxxxx/gb/crt0.o $(OBJS)
@$(IHXCHECK) $(OBJDIR)/$(PROJECT_NAME).ihx -e
@$(MAKEBIN) -Z $(BINFLAGS) $(OBJDIR)/$(PROJECT_NAME).ihx $(OBJDIR)/$(PROJECT_NAME).$(EXTENSION)
@$(ROMVIEW) $(OBJDIR)/$(PROJECT_NAME).$(EXTENSION) 255
@mv $(OBJDIR)/$(PROJECT_NAME).$(EXTENSION) $(BINDIR)/$(PROJECT_NAME).$(EXTENSION)
@rm -f *.adb

build_lib: $(OBJDIR) $(OBJS)

Expand Down
2 changes: 1 addition & 1 deletion common/src/Scroll.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void UPDATE_TILE(INT16 x, INT16 y, UINT8* t, UINT8* c) {
#ifdef CGB
if (_cpu == CGB_TYPE) {
VBK_REG = 1;
if(!scroll_cmap || (0x10 & *c)) { //Bit 4 on, means default palette
if(!scroll_cmap /*|| (0x10 & *c)*/) { //Bit 4 on, means default palette
i = scroll_tile_info[replacement];
c = &i;
}
Expand Down
2 changes: 1 addition & 1 deletion tools/gbm2c/gbm2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ int main(int argc, char* argv[])

fprintf(file, "#pragma bank %d\n", bank);

fprintf(file, "\nvoid empty(void) __nonbanked {}\n");
fprintf(file, "\nvoid empty(void) __nonbanked;\n");
fprintf(file, "__addressmod empty const CODE;\n\n");

fprintf(file, "const unsigned char %s_map[] = {", map_export_settings.label_name);
Expand Down
Binary file modified tools/gbm2c/gbm2c.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion tools/gbr2c/gbr2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ int main(int argc, char* argv[]) {
fprintf(file, "#pragma bank %d\n", bank);
//fprintf(file, "unsigned char bank_%s = %d;\n", tile_export.label_name, bank);

fprintf(file, "\nvoid empty(void) __nonbanked {}\n");
fprintf(file, "\nvoid empty(void) __nonbanked;\n");
fprintf(file, "__addressmod empty const CODE;\n\n");

if(tile_export.include_colors){
Expand Down
Binary file modified tools/gbr2c/gbr2c.exe
Binary file not shown.

0 comments on commit 97064af

Please sign in to comment.