Skip to content

Commit 0615402

Browse files
committed
Updated for modern building.
1 parent b4fc674 commit 0615402

21 files changed

Lines changed: 193 additions & 251 deletions

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
node_modules
22
img/*.asm
33
builder/bin
4-
build
4+
build
5+
.DS_Store
6+
obj
7+
bin

.vscode/tasks.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"label": "build",
8+
"type": "shell",
9+
"command": "make",
10+
"group": {
11+
"kind": "build",
12+
"isDefault": true
13+
},
14+
"presentation": {
15+
"panel": "new"
16+
},
17+
"problemMatcher": ["$rgbdserror", "$rgbdslinkerror"]
18+
},
19+
{
20+
"label": "clean",
21+
"type": "shell",
22+
"command": "make",
23+
"args": [
24+
"clean"
25+
],
26+
"group": "build",
27+
"presentation": {
28+
"panel": "new"
29+
}
30+
}
31+
]
32+
}

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ A version of Snake programmed for the Game Boy. Binary download and browser-play
66

77
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.
88

9-
The build pipeline has a dependency on [node.js](http://nodejs.org). You'll need to install it.
9+
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).
1010

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

13-
Also in `builder/`, create a folder called `bin` and copy RGBDS' `asm`, `lib`, `link`, and `rgbfix` executables (with those names) into it.
14-
15-
`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).
13+
`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).

build.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

builder/builder.js

Lines changed: 0 additions & 133 deletions
This file was deleted.

builder/gfx.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,10 @@
33
var fs = require("fs");
44
var path = require("path");
55
var PNG = require("pngjs").PNG;
6+
const program = require("commander").program;
67

78
var images = {};
89

9-
module.exports = function(imageDirectory, done) {
10-
var sourceDirectory = path.resolve(imageDirectory, "src");
11-
var fileNames = fs.readdirSync(sourceDirectory);
12-
for(var i=0; i<fileNames.length; i++) {
13-
var fileName = fileNames[i];
14-
if(path.extname(fileName) == ".json") {
15-
var filePath = path.resolve(sourceDirectory, fileName);
16-
processSet(imageDirectory, filePath);
17-
}
18-
}
19-
done();
20-
}
21-
2210
function getImage(dirPath, imageName) {
2311
if(images[imageName] == null) {
2412
var imagePath = path.resolve(dirPath, imageName);
@@ -132,7 +120,7 @@ function outputAssembly(name, indices, bytes, path) {
132120
output += "\n";
133121
}
134122

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

157145
fs.writeFileSync(path, output);
158146
}
147+
148+
program
149+
.version("1.0.0")
150+
.arguments("<src> <dst>")
151+
.action((src, dst) => {
152+
let jsonFilePath = src.substring(0, src.length - path.extname(src).length) + ".json";
153+
console.log(`convert ${src} to ${dst}, ${jsonFilePath}`);
154+
processSet(path.dirname(dst), jsonFilePath);
155+
});
156+
157+
program.parse(process.argv);

builder/package-lock.json

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

builder/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"name" : "gbbuilder",
2+
"name": "gbbuilder",
33
"version": "1.0.0",
4-
"dependencies" : {
5-
"os-homedir" : "1.0.1",
6-
"pngjs" : "~2.3.1"
4+
"dependencies": {
5+
"pngjs": "~6.0.0",
6+
"commander": "~7.1.0"
77
}
8-
}
8+
}

field.asm

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ INCLUDE "inc/rand.asm"
66
INCLUDE "inc/debug.asm"
77
INCLUDE "inc/save.asm"
88

9-
SECTION "Field Module Variables", BSS
9+
SECTION "Field Module Variables", WRAM0
1010
FIELD_MODULE_SNAKE_SLOT_COUNT EQU 18*14
1111
FIELD_MODULE_SNAKE_TICK_TIME EQU 16
1212
FIELD_MODULE_FOOD_PER_TICK_INCREASE EQU 15
@@ -23,51 +23,51 @@ FIELD_MODULE_FONT_DATA_OFFSET EQU 40
2323
FIELD_MODULE_HEART_SPAWN_COUNT EQU 10
2424
FIELD_MODULE_HEART_DURATION_SECONDS EQU 9
2525

26-
fieldModuleTickTime DS 1
27-
fieldModuleFoodUntilTickTimeIncrease DS 1
26+
fieldModuleTickTime: DS 1
27+
fieldModuleFoodUntilTickTimeIncrease: DS 1
2828

29-
fieldModuleHeartSpawnCountdown DS 1
30-
fieldModuleFoodIsHeart DS 1
29+
fieldModuleHeartSpawnCountdown: DS 1
30+
fieldModuleFoodIsHeart: DS 1
3131

32-
fieldModuleSnakeLength DS 1
33-
fieldModuleSnakeSlots DS FIELD_MODULE_SNAKE_SLOT_COUNT * 2
34-
fieldModuleSnakeSlotHead DS 1
35-
fieldModuleSnakeSlotTail DS 1
36-
fieldModuleSnakeTickTime DS 1
37-
fieldModuleSnakeNextDirection DS 1
38-
fieldModuleSnakePreviousDirection DS 1
39-
fieldModuleOccupiedFlags DS FIELD_MODULE_SNAKE_SLOT_COUNT
32+
fieldModuleSnakeLength: DS 1
33+
fieldModuleSnakeSlots: DS FIELD_MODULE_SNAKE_SLOT_COUNT * 2
34+
fieldModuleSnakeSlotHead: DS 1
35+
fieldModuleSnakeSlotTail: DS 1
36+
fieldModuleSnakeTickTime: DS 1
37+
fieldModuleSnakeNextDirection: DS 1
38+
fieldModuleSnakePreviousDirection: DS 1
39+
fieldModuleOccupiedFlags: DS FIELD_MODULE_SNAKE_SLOT_COUNT
4040

41-
fieldModuleShouldWriteSnakeHead DS 1
42-
fieldModuleShouldWriteSnakeHeadX DS 1
43-
fieldModuleShouldWriteSnakeHeadY DS 1
41+
fieldModuleShouldWriteSnakeHead: DS 1
42+
fieldModuleShouldWriteSnakeHeadX: DS 1
43+
fieldModuleShouldWriteSnakeHeadY: DS 1
4444

45-
fieldModuleShouldWriteSnakeTail DS 1
46-
fieldModuleShouldWriteSnakeTailX DS 1
47-
fieldModuleShouldWriteSnakeTailY DS 1
48-
fieldModuleShouldWriteSnakeTailValue DS 1
45+
fieldModuleShouldWriteSnakeTail: DS 1
46+
fieldModuleShouldWriteSnakeTailX: DS 1
47+
fieldModuleShouldWriteSnakeTailY: DS 1
48+
fieldModuleShouldWriteSnakeTailValue: DS 1
4949

50-
fieldModuleHeadCoordinateBufferX DS 1
51-
fieldModuleHeadCoordinateBufferY DS 1
52-
fieldModuleNextDirectionBuffer DS 1
50+
fieldModuleHeadCoordinateBufferX: DS 1
51+
fieldModuleHeadCoordinateBufferY: DS 1
52+
fieldModuleNextDirectionBuffer: DS 1
5353

54-
fieldModuleHeartAgeSeconds DS 1
55-
fieldModuleHeartAgeTicks DS 1
54+
fieldModuleHeartAgeSeconds: DS 1
55+
fieldModuleHeartAgeTicks: DS 1
5656

57-
fieldModuleFoodX DS 1
58-
fieldModuleFoodY DS 1
59-
fieldModuleDidHideFood DS 1
60-
fieldModuleFoodBufferX DS 1
61-
fieldModuleFoodBufferY DS 1
62-
fieldModuleFoodTile DS 1
63-
fieldModuleShouldWriteFoodOAM DS 1
57+
fieldModuleFoodX: DS 1
58+
fieldModuleFoodY: DS 1
59+
fieldModuleDidHideFood: DS 1
60+
fieldModuleFoodBufferX: DS 1
61+
fieldModuleFoodBufferY: DS 1
62+
fieldModuleFoodTile: DS 1
63+
fieldModuleShouldWriteFoodOAM: DS 1
6464

65-
fieldModuleReleasedPause DS 1
65+
fieldModuleReleasedPause: DS 1
6666

67-
fieldModuleScore DS 2
68-
fieldModuleShouldRenderScore DS 1
67+
fieldModuleScore: DS 2
68+
fieldModuleShouldRenderScore: DS 1
6969

70-
SECTION "Field Module", HOME
70+
SECTION "Field Module", ROM0
7171
fieldModuleScoreText:
7272
db "SCORE",0
7373
fieldModuleHighScoreText:

0 commit comments

Comments
 (0)