Skip to content
Permalink
Browse files

GBDK compilation

  • Loading branch information...
brovador committed Oct 15, 2016
1 parent 7fa49d9 commit 91c704afc36f031be08b6ffc7421cf55ff457780
Showing with 93 additions and 24 deletions.
  1. +4 −1 .gitignore
  2. +29 −17 Makefile
  3. +6 −6 src/main.c
  4. +27 −0 src/snake-map.h
  5. +27 −0 src/snake-tiles.h
@@ -1,4 +1,7 @@
/obj
/dist
/emulator
/tools
/tools
/export

.vscode
@@ -1,22 +1,34 @@
ROM_NAME=rom.gb
BIN=./bin
OBJ=./obj
DIST=./dist
SRC=./src
EMULATOR=./emulator
# Directories
GBDK_DIR = ../gbdk
SRC_DIR = ./src
DIST_DIR = ./dist
OBJ_DIR = ./obj

# Binaries
CC = ./$(GBDK_DIR)/bin/lcc
EMULATOR = ../tools/bgb/bgb.exe

# Files
ROM_FILE = $(DIST_DIR)/rom.gb
OBJ_FILES = $(OBJ_DIR)/main.o \
$(OBJ_DIR)/snake-tiles.o \
$(OBJ_DIR)/snake-map.o

build:
mkdir -p $(OBJ)
mkdir -p $(DIST)
$(BIN)/gbdk-n-compile.sh $(SRC)/main.c -o $(OBJ)/main.rel
$(BIN)/gbdk-n-link.sh $(OBJ)/main.rel -o $(OBJ)/main.ihx
$(BIN)/gbdk-n-make-rom.sh $(OBJ)/main.ihx $(DIST)/$(ROM_NAME)
all: $(ROM_FILE)

clean:
rm -rf $(OBJ)
rm -f $(DIST)/$(ROM_NAME)
$(ROM_FILE): $(OBJ_FILES)
@mkdir -p $(DIST_DIR)
$(CC) -o $@ $^

$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c
@mkdir -p $(OBJ_DIR)
$(CC) -c -o $@ $<

run:
wine $(EMULATOR)/bgb.exe $(DIST)/$(ROM_NAME)
.PHONY : run
run: $(ROM_FILE)
wine $(EMULATOR) $<

.PHONY : clean
clean:
@rm -rf $(DIST_DIR)
@rm -rf $(OBJ_DIR)
@@ -1,9 +1,9 @@
#include <gb/gb.h>
#include <gb/drawing.h>
#include <gb/rand.h>
#include <rand.h>

#include "snake-tiles.c"
#include "snake-map.c"
#include "snake-tiles.h"
#include "snake-map.h"

#define mapWidth 20
#define mapHeight 18
@@ -216,8 +216,8 @@ void game()
levelParts[0] = (level + 1) / 10;
levelParts[1] = (level + 1) - levelParts[0] * 10;
for (i = 0; i < pillsPerLevel[level]; ++i) {
j = (_rand() & 7) % (levelBoundaries[2] - levelBoundaries[0]);
k = (_rand() & 7) % (levelBoundaries[3] - levelBoundaries[1]);
j = (rand() & 7) % (levelBoundaries[2] - levelBoundaries[0]);
k = (rand() & 7) % (levelBoundaries[3] - levelBoundaries[1]);
pillsPositions[i][0] = levelBoundaries[0] + j;
pillsPositions[i][1] = levelBoundaries[1] + k;
++pillsLive;
@@ -314,4 +314,4 @@ void main()
drawUI();

}
}
}
@@ -0,0 +1,27 @@
/*
SNAKE-MAP.C
Map Source File.
Info:
Section :
Bank : 0
Map size : 20 x 18
Tile set : snake-tiles.gbr
Plane count : 1 plane (8 bits)
Plane order : Tiles are continues
Tile offset : 0
Split data : No
This file was generated by GBMB v1.8
*/

#define mapWidth 20
#define mapHeight 18
#define mapBank 0

extern unsigned char map[];

/* End of SNAKE-MAP.C */
@@ -0,0 +1,27 @@
/*
SNAKE-TILES.C
Tile Source File.
Info:
Form : All tiles as one unit.
Format : Gameboy 4 color.
Compression : None.
Counter : None.
Tile size : 8 x 8
Tiles : 0 to 40
Palette colors : None.
SGB Palette : None.
CGB Palette : None.
Convert to metatiles : No.
This file was generated by GBTD v2.2
*/

extern unsigned char tiles[];

/* End of SNAKE-TILES.C */

0 comments on commit 91c704a

Please sign in to comment.
You can’t perform that action at this time.