Skip to content

Commit

Permalink
Updated for modern building.
Browse files Browse the repository at this point in the history
  • Loading branch information
DonaldHays committed Mar 10, 2021
1 parent b4fc674 commit 0615402
Show file tree
Hide file tree
Showing 21 changed files with 193 additions and 251 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
node_modules
img/*.asm
builder/bin
build
build
.DS_Store
obj
bin
32 changes: 32 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
// 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",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"panel": "new"
},
"problemMatcher": ["$rgbdserror", "$rgbdslinkerror"]
},
{
"label": "clean",
"type": "shell",
"command": "make",
"args": [
"clean"
],
"group": "build",
"presentation": {
"panel": "new"
}
}
]
}
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ A version of Snake programmed for the Game Boy. Binary download and browser-play

I built this project on macOS. The instructions should be pretty easy to follow from most UNIX-y operating systems. Windows users may have some troubles with the build scripts.

The build pipeline has a dependency on [node.js](http://nodejs.org). You'll need to install it.
The build pipeline has a dependency on [node.js](http://nodejs.org). You'll need to install it. You'll also need to install [RGBDS](https://rgbds.gbdev.io).

`cd` into `builder/` and run `npm install`.

Also in `builder/`, create a folder called `bin` and copy RGBDS' `asm`, `lib`, `link`, and `rgbfix` executables (with those names) into it.

`cd` back to the project root directory. Run `node build`. The output will be in `build/bin/`. Also note that the build process will generate `asm` files in `img/`. You can look at, but not modify, those files (they're rewritten every time you build).
`cd` back to the project root directory. Run `make`. The output will be in `bin/`. Also note that the build process will generate `asm` files in `img/`. You can look at, but not modify, those files (they're rewritten every time you build).
3 changes: 0 additions & 3 deletions build.js

This file was deleted.

133 changes: 0 additions & 133 deletions builder/builder.js

This file was deleted.

27 changes: 13 additions & 14 deletions builder/gfx.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,10 @@
var fs = require("fs");
var path = require("path");
var PNG = require("pngjs").PNG;
const program = require("commander").program;

var images = {};

module.exports = function(imageDirectory, done) {
var sourceDirectory = path.resolve(imageDirectory, "src");
var fileNames = fs.readdirSync(sourceDirectory);
for(var i=0; i<fileNames.length; i++) {
var fileName = fileNames[i];
if(path.extname(fileName) == ".json") {
var filePath = path.resolve(sourceDirectory, fileName);
processSet(imageDirectory, filePath);
}
}
done();
}

function getImage(dirPath, imageName) {
if(images[imageName] == null) {
var imagePath = path.resolve(dirPath, imageName);
Expand Down Expand Up @@ -132,7 +120,7 @@ function outputAssembly(name, indices, bytes, path) {
output += "\n";
}

output += "SECTION \"" + name + " tiles\", HOME\n";
output += "SECTION \"" + name + " tiles\", ROM0\n";
output += name + "Tiles:\n";
for(var i=0; i<bytes.length; i++) {
if(i % 16 == 0) {
Expand All @@ -156,3 +144,14 @@ function outputAssembly(name, indices, bytes, path) {

fs.writeFileSync(path, output);
}

program
.version("1.0.0")
.arguments("<src> <dst>")
.action((src, dst) => {
let jsonFilePath = src.substring(0, src.length - path.extname(src).length) + ".json";
console.log(`convert ${src} to ${dst}, ${jsonFilePath}`);
processSet(path.dirname(dst), jsonFilePath);
});

program.parse(process.argv);
18 changes: 18 additions & 0 deletions builder/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions builder/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name" : "gbbuilder",
"name": "gbbuilder",
"version": "1.0.0",
"dependencies" : {
"os-homedir" : "1.0.1",
"pngjs" : "~2.3.1"
"dependencies": {
"pngjs": "~6.0.0",
"commander": "~7.1.0"
}
}
}
72 changes: 36 additions & 36 deletions field.asm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ INCLUDE "inc/rand.asm"
INCLUDE "inc/debug.asm"
INCLUDE "inc/save.asm"

SECTION "Field Module Variables", BSS
SECTION "Field Module Variables", WRAM0
FIELD_MODULE_SNAKE_SLOT_COUNT EQU 18*14
FIELD_MODULE_SNAKE_TICK_TIME EQU 16
FIELD_MODULE_FOOD_PER_TICK_INCREASE EQU 15
Expand All @@ -23,51 +23,51 @@ FIELD_MODULE_FONT_DATA_OFFSET EQU 40
FIELD_MODULE_HEART_SPAWN_COUNT EQU 10
FIELD_MODULE_HEART_DURATION_SECONDS EQU 9

fieldModuleTickTime DS 1
fieldModuleFoodUntilTickTimeIncrease DS 1
fieldModuleTickTime: DS 1
fieldModuleFoodUntilTickTimeIncrease: DS 1

fieldModuleHeartSpawnCountdown DS 1
fieldModuleFoodIsHeart DS 1
fieldModuleHeartSpawnCountdown: DS 1
fieldModuleFoodIsHeart: DS 1

fieldModuleSnakeLength DS 1
fieldModuleSnakeSlots DS FIELD_MODULE_SNAKE_SLOT_COUNT * 2
fieldModuleSnakeSlotHead DS 1
fieldModuleSnakeSlotTail DS 1
fieldModuleSnakeTickTime DS 1
fieldModuleSnakeNextDirection DS 1
fieldModuleSnakePreviousDirection DS 1
fieldModuleOccupiedFlags DS FIELD_MODULE_SNAKE_SLOT_COUNT
fieldModuleSnakeLength: DS 1
fieldModuleSnakeSlots: DS FIELD_MODULE_SNAKE_SLOT_COUNT * 2
fieldModuleSnakeSlotHead: DS 1
fieldModuleSnakeSlotTail: DS 1
fieldModuleSnakeTickTime: DS 1
fieldModuleSnakeNextDirection: DS 1
fieldModuleSnakePreviousDirection: DS 1
fieldModuleOccupiedFlags: DS FIELD_MODULE_SNAKE_SLOT_COUNT

fieldModuleShouldWriteSnakeHead DS 1
fieldModuleShouldWriteSnakeHeadX DS 1
fieldModuleShouldWriteSnakeHeadY DS 1
fieldModuleShouldWriteSnakeHead: DS 1
fieldModuleShouldWriteSnakeHeadX: DS 1
fieldModuleShouldWriteSnakeHeadY: DS 1

fieldModuleShouldWriteSnakeTail DS 1
fieldModuleShouldWriteSnakeTailX DS 1
fieldModuleShouldWriteSnakeTailY DS 1
fieldModuleShouldWriteSnakeTailValue DS 1
fieldModuleShouldWriteSnakeTail: DS 1
fieldModuleShouldWriteSnakeTailX: DS 1
fieldModuleShouldWriteSnakeTailY: DS 1
fieldModuleShouldWriteSnakeTailValue: DS 1

fieldModuleHeadCoordinateBufferX DS 1
fieldModuleHeadCoordinateBufferY DS 1
fieldModuleNextDirectionBuffer DS 1
fieldModuleHeadCoordinateBufferX: DS 1
fieldModuleHeadCoordinateBufferY: DS 1
fieldModuleNextDirectionBuffer: DS 1

fieldModuleHeartAgeSeconds DS 1
fieldModuleHeartAgeTicks DS 1
fieldModuleHeartAgeSeconds: DS 1
fieldModuleHeartAgeTicks: DS 1

fieldModuleFoodX DS 1
fieldModuleFoodY DS 1
fieldModuleDidHideFood DS 1
fieldModuleFoodBufferX DS 1
fieldModuleFoodBufferY DS 1
fieldModuleFoodTile DS 1
fieldModuleShouldWriteFoodOAM DS 1
fieldModuleFoodX: DS 1
fieldModuleFoodY: DS 1
fieldModuleDidHideFood: DS 1
fieldModuleFoodBufferX: DS 1
fieldModuleFoodBufferY: DS 1
fieldModuleFoodTile: DS 1
fieldModuleShouldWriteFoodOAM: DS 1

fieldModuleReleasedPause DS 1
fieldModuleReleasedPause: DS 1

fieldModuleScore DS 2
fieldModuleShouldRenderScore DS 1
fieldModuleScore: DS 2
fieldModuleShouldRenderScore: DS 1

SECTION "Field Module", HOME
SECTION "Field Module", ROM0
fieldModuleScoreText:
db "SCORE",0
fieldModuleHighScoreText:
Expand Down
Loading

0 comments on commit 0615402

Please sign in to comment.