Skip to content

Commit

Permalink
Commit of release state source
Browse files Browse the repository at this point in the history
  • Loading branch information
tbsp committed Sep 30, 2021
0 parents commit 8eee745
Show file tree
Hide file tree
Showing 125 changed files with 21,331 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/bin/
/obj/
/dep/
/res/
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "src/include/hardware.inc"]
path = src/include/hardware.inc
url = https://github.com/gbdev/hardware.inc.git
[submodule "src/include/rgbds-structs"]
path = src/include/rgbds-structs
url = https://github.com/ISSOtm/rgbds-structs.git
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "emulicious-debugger",
"request": "launch",
"name": "Launch in Emulicious",
"program": "${workspaceFolder}/${command:AskForProgramName}",
"port": 58870,
"stopOnEntry": true
}
]
}
57 changes: 57 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"type": "shell",
"command": "make all",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Rebuild",
"type": "shell",
"command": "make rebuild",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Run Emulicious",
"type": "shell",
"command": "make runEmulicious",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Run BGB",
"type": "shell",
"command": "make runBGB",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Run romusage",
"type": "shell",
"command": "make romusage",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The zlib License
================

Copyright (c) 2021 Dave VanEe

This software is provided 'as-is', without any express or implied warranty. In
no event will the authors be held liable for any damages arising from the use of
this software.

Permission is granted to anyone to use this software for any purpose, including
commercial applications, and to alter it and redistribute it freely, subject to
the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim
that you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
not required.

2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.
212 changes: 212 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@

.SUFFIXES:

################################################
# #
# CONSTANT DEFINITIONS #
# #
################################################

# Directory constants
SRCDIR := src
BINDIR := bin
OBJDIR := obj
DEPDIR := dep
RESDIR := res

# Program constants
ifneq ($(shell which rm),)
# POSIX OSes
RM_RF := rm -rf
MKDIR_P := mkdir -p
PY :=
filesize = echo 'NB_PB$2_BLOCKS equ (' `wc -c $1 | cut -d ' ' -f 1` ' + $2 - 1) / $2'
else
# Windows outside of a POSIX env (Cygwin, MSYS2, etc.)
# We need Powershell to get any sort of decent functionality
$(warning Powershell is required to get basic functionality)
RM_RF := -del /q
MKDIR_P := -mkdir
PY := python
filesize = powershell Write-Output $$('NB_PB$2_BLOCKS equ ' + [string] [int] (([IO.File]::ReadAllBytes('$1').Length + $2 - 1) / $2))
endif

# Shortcut if you want to use a local copy of RGBDS
RGBDS := ../rgbds/
RGBASM := $(RGBDS)rgbasm.exe
RGBLINK := $(RGBDS)rgblink.exe
RGBFIX := $(RGBDS)rgbfix.exe
RGBGFX := $(RGBDS)rgbgfx.exe

EMULATOR_EMULICIOUS = ../../Emulicious/Emulicious.exe
EMULATOR_BGB = ../../bgb64/bgb64.exe

ROMUSAGE := ../../Tools/romusage.exe

ROM = $(BINDIR)/$(ROMNAME).$(ROMEXT)

# Argument constants
INCDIRS = $(SRCDIR)/ $(SRCDIR)/include/
WARNINGS = all extra
ASFLAGS = -p $(PADVALUE) $(addprefix -i,$(INCDIRS)) $(addprefix -W,$(WARNINGS))
LDFLAGS = -p $(PADVALUE)
FIXFLAGS = -p $(PADVALUE) -v -i "$(GAMEID)" -k "$(LICENSEE)" -l $(OLDLIC) -m $(MBC) -n $(VERSION) -r $(SRAMSIZE) -t $(TITLE)

# The list of "root" ASM files that RGBASM will be invoked on
# Note: The res/music directory is explicitly added because songs use duplicate
# labels which make the "include them in a root file" approach cause collisions
SRCS = $(wildcard $(SRCDIR)/*.asm) $(wildcard $(SRCDIR)/res/music/*.asm)
INCDIRS = $(SRCDIR)/ $(SRCDIR)/include/

## Project-specific configuration
# Use this to override the above
include project.mk

################################################
# #
# TARGETS #
# #
################################################

# `all` (Default target): build the ROM
all: $(ROM)
.PHONY: all

# `clean`: Clean temp and bin files
clean:
$(RM_RF) $(BINDIR)
$(RM_RF) $(OBJDIR)
$(RM_RF) $(DEPDIR)
$(RM_RF) $(RESDIR)
.PHONY: clean

# `rebuild`: Build everything from scratch
# It's important to do these two in order if we're using more than one job
rebuild:
$(MAKE) clean
$(MAKE) all
.PHONY: rebuild

runEmulicious:
$(EMULATOR_EMULICIOUS) $(ROM)
.PHONY: runEmulicious

runBGB:
$(EMULATOR_BGB) $(ROM) -watch
.PHONY: runBGB

romusage:
$(ROMUSAGE) $(BINDIR)/$(ROMNAME).map -g
.PHONY: romusage

################################################
# #
# GIT SUBMODULES #
# #
################################################

# By default, cloning the repo does not init submodules
# If that happens, warn the user
# Note that the real paths aren't used!
# Since RGBASM fails to find the files, it outputs the raw paths, not the actual ones.
hardware.inc/hardware.inc rgbds-structs/structs.asm:
@echo 'hardware.inc is not present; have you initialized submodules?'
@echo 'Run `git submodule update --init`, then `make clean`, then `make` again.'
@echo 'Tip: to avoid this, use `git clone --recursive` next time!'
@exit 1

################################################
# #
# RESOURCE FILES #
# #
################################################

# By default, asset recipes convert files in `res/` into other files in `res/`
# This line causes assets not found in `res/` to be also looked for in `src/res/`
# "Source" assets can thus be safely stored there without `make clean` removing them
VPATH := $(SRCDIR)

$(RESDIR)/%.1bpp: $(RESDIR)/%.png
@$(MKDIR_P) $(@D)
$(RGBGFX) -d 1 -o $@ $<

$(RESDIR)/%_linear.2bpp: $(RESDIR)/%_linear.png
@$(MKDIR_P) $(@D)
$(RGBGFX) -d 2 -o $@ $<

$(RESDIR)/%_map.2bpp $(RESDIR)/%_map.tilemap: $(RESDIR)/%_map.png
@$(MKDIR_P) $(@D)
$(RGBGFX) -u -T -d 2 -o $@ $<

$(RESDIR)/%.2bpp: $(RESDIR)/%.png
@$(MKDIR_P) $(@D)
$(RGBGFX) -h -d 2 -o $@ $<

# Define how to compress files using the PackBits16 codec
# Compressor script requires Python 3
$(RESDIR)/%.pb16: $(RESDIR)/% $(SRCDIR)/tools/pb16.py
@$(MKDIR_P) $(@D)
$(PY) $(SRCDIR)/tools/pb16.py $< $(RESDIR)/$*.pb16

$(RESDIR)/%.pb16.size: $(RESDIR)/%
@$(MKDIR_P) $(@D)
$(call filesize,$<,16) > $(RESDIR)/$*.pb16.size

# Define how to compress files using the PackBits8 codec
# Compressor script requires Python 3
$(RESDIR)/%.pb8: $(RESDIR)/% $(SRCDIR)/tools/pb8.py
@$(MKDIR_P) $(@D)
$(PY) $(SRCDIR)/tools/pb8.py $< $(RESDIR)/$*.pb8

$(RESDIR)/%.pb8.size: $(RESDIR)/%
@$(MKDIR_P) $(@D)
$(call filesize,$<,8) > $(RESDIR)/$*.pb8.size

# Define how to compile VWF fonts
# VWF processing script requires Python 3
$(RESDIR)/fonts/%.vwf: $(RESDIR)/fonts/%.png $(SRCDIR)/tools/make_font.py
@$(MKDIR_P) $(@D)
$(SRCDIR)/tools/make_font.py $< $@

# Define how to compile pearl sequences
$(RESDIR)/pearls/%.pearls: $(RESDIR)/pearls/%.png $(SRCDIR)/tools/make_pearl_sequence.py
@$(MKDIR_P) $(@D)
$(SRCDIR)/tools/make_pearl_sequence.py $< $@

# Define how to generate Python-generated asm files
$(RESDIR)/%_generated.asm: $(SRCDIR)/tools/generate_%.py
$<

###############################################
# #
# COMPILATION #
# #
###############################################

# VWF prerequisite
$(SRCDIR)/charmap.asm: $(SRCDIR)/vwf/vwf_config.asm $(RESDIR)/fonts/minimal.vwf
$(RGBASM) $(ASFLAGS) -o $(OBJDIR)/vwf_config.o $< > $@

# How to build a ROM
$(BINDIR)/%.$(ROMEXT) $(BINDIR)/%.sym $(BINDIR)/%.map: $(patsubst $(SRCDIR)/%.asm,$(OBJDIR)/%.o,$(SRCS))
@$(MKDIR_P) $(@D)
$(RGBASM) $(ASFLAGS) -o $(OBJDIR)/build_date.o $(SRCDIR)/res/build_date.asm
$(RGBLINK) $(LDFLAGS) -m $(BINDIR)/$*.map -n $(BINDIR)/$*.sym -o $(BINDIR)/$*.$(ROMEXT) $^ $(OBJDIR)/build_date.o $(OBJDIR)/vwf_config.o \
&& $(RGBFIX) -v $(FIXFLAGS) $(BINDIR)/$*.$(ROMEXT)

# `.mk` files are auto-generated dependency lists of the "root" ASM files, to save a lot of hassle.
# Also add all obj dependencies to the dep file too, so Make knows to remake it
# Caution: some of these flags were added in RGBDS 0.4.0, using an earlier version WILL NOT WORK
# (and produce weird errors)
$(OBJDIR)/%.o $(DEPDIR)/%.mk: $(SRCDIR)/%.asm
@$(MKDIR_P) $(patsubst %/,%,$(dir $(OBJDIR)/$* $(DEPDIR)/$*))
$(RGBASM) $(ASFLAGS) -M $(DEPDIR)/$*.mk -MG -MP -MQ $(OBJDIR)/$*.o -MQ $(DEPDIR)/$*.mk -o $(OBJDIR)/$*.o $<

ifneq ($(MAKECMDGOALS),clean)
-include $(patsubst $(SRCDIR)/%.asm,$(DEPDIR)/%.mk,$(SRCS))
endif

# Catch non-existent files
# KEEP THIS LAST!!
%:
@false

0 comments on commit 8eee745

Please sign in to comment.