Initial commit
authorLukas Krickl <lukas@krickl.dev>
Mon, 30 Sep 2024 15:26:20 +0000 (17:26 +0200)
committerLukas Krickl <lukas@krickl.dev>
Mon, 30 Sep 2024 15:26:20 +0000 (17:26 +0200)
.gitattributes [new file with mode: 0644]
.gitignore [new file with mode: 0644]
LICENSE [new file with mode: 0644]
README.md [new file with mode: 0644]
makefile [new file with mode: 0644]
src/header.inc [new file with mode: 0644]
src/hw.inc [new file with mode: 0644]
src/jmp.inc [new file with mode: 0644]
src/main.s [new file with mode: 0644]

diff --git a/.gitattributes b/.gitattributes
new file mode 100644 (file)
index 0000000..176a458
--- /dev/null
@@ -0,0 +1 @@
+* text=auto
diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..ecb9b78
--- /dev/null
@@ -0,0 +1,67 @@
+# Build directory
+bin/
+obj/
+tags
+
+ Prerequisites
+*.d
+
+# Object files
+*.o
+*.ko
+*.obj
+*.elf
+
+# Linker output
+*.ilk
+*.map
+*.exp
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Libraries
+*.lib
+*.a
+*.la
+*.lo
+
+# Shared objects (inc. Windows DLLs)
+*.dll
+*.so
+*.so.*
+*.dylib
+
+# Executables
+*.exe
+*.out
+*.app
+*.i*86
+*.x86_64
+*.hex
+
+# Debug files
+*.dSYM/
+*.su
+*.idb
+*.pdb
+vgcore.*
+
+# Kernel Module Compile Results
+*.mod*
+*.cmd
+.tmp_versions/
+modules.order
+Module.symvers
+Mkfile.old
+dkms.conf
+
+compile_commands.json
+.cache/
+.clang_complete
+.clangd
+.session
+
+assets/
+*.pyc
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..f0bde43
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,18 @@
+Copyright 2024 Lukas Krickl (lukas@krickl.dev)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy 
+of this software and associated documentation files (the "Software"), 
+to deal in the Software without restriction, 
+including without limitation the rights to 
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 
+and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS",
+WITHOUT WARRANTY OF ANY KIND, 
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..261b548
--- /dev/null
+++ b/README.md
@@ -0,0 +1,26 @@
+# tbgb 
+
+An action rougelike platformer for the gameboy!
+
+## Table of content
+
+- [Installation](#Installation)
+- [Usage](#Usage)
+- [License](#License)
+- [Contributing](#Contributing)
+- [TODO](#TODO)
+
+## Installation
+
+## Usage
+
+### Building assets
+
+To build the assets simply check out the `assets repository` into the `assets` directory and run `make tiles`.
+This is only required if changes to the tileset were made. All 'compiled' tile directories are already included in this repository!
+
+## License
+
+This program is distributed under the terms of the MIT License.
+
+## Contributing
diff --git a/makefile b/makefile
new file mode 100644 (file)
index 0000000..2398ce3
--- /dev/null
+++ b/makefile
@@ -0,0 +1,8 @@
+AS=ulas 
+BIN=rg.gb
+BDIR=bin/
+
+all:
+       mkdir -p $(BDIR)
+       ulas -v -o $(BDIR)/$(BIN) -l bin/rg.lst -s bin/rg.mlb -S mlb -i ./src -i ./tiles src/main.s
+
diff --git a/src/header.inc b/src/header.inc
new file mode 100644 (file)
index 0000000..69696a4
--- /dev/null
@@ -0,0 +1,18 @@
+; header
+    jp entry
+    nop
+logo:
+.db 0xCE, 0xED, 0x66, 0x66, 0xCC, 0x0D, 0x00, 0x0B, 0x03, 0x73, 0x00, 0x83, 0x00, 0x0C, 0x00, 0x0D
+.db 0x00, 0x08, 0x11, 0x1F, 0x88, 0x89, 0x00, 0x0E, 0xDC, 0xCC, 0x6E, 0xE6, 0xDD, 0xDD, 0xD9, 0x99
+.db 0xBB, 0xBB, 0x67, 0x63, 0x6E, 0x0E, 0xEC, 0xCC, 0xDD, 0xDC, 0x99, 0x9F, 0xBB, 0xB9, 0x33, 0x3E
+logo_end:
+
+.str "tb"
+.fill 0, 0x147 - $
+
+; cartride type
+; MBC1+RAM+Battery
+.db 0x02 
+.fill 0, 0x14D - $
+.chksm
+.fill 0, 0x150 - $
diff --git a/src/hw.inc b/src/hw.inc
new file mode 100644 (file)
index 0000000..3942be3
--- /dev/null
@@ -0,0 +1,79 @@
+; register defs
+
+#define SCRNW 159
+#define SCRNH 143
+
+; lcd registers 
+
+; lcd y 
+#define RLY 0xFF44
+#define RLYC 0xFF45
+#define RLCD 0xFF40
+
+#define LCDCF_BGON 0b00000001
+#define LCDCF_ON 0b10000000
+#define LCDCF_OBJON 0b00000010
+#define LCDF_WINDOWON 0b00100000
+
+#define RBGP 0xFF47
+#define ROBP0 0xFF48
+#define ROBP1 0xFF49
+
+; screen scroll y and x
+#define RSCY 0xFF42
+#define RSCX 0xFF43
+
+; window y and x
+#define RWY 0xFF4A
+#define RWX 0xFF4B
+
+; P1: joy pad register
+#define RP1 0xFF00
+#define P1F5 0b00100000 ; get buttons 
+#define P1F4 0b00010000 ; get dpad
+
+; buttons 
+#define BTNDOWN 0x80
+#define BTNUP 0x40
+#define BTNLEFT 0x20
+#define BTNRIGHT 0x10
+#define BTNSTART 0x08
+#define BTNSELECT 0x04
+#define BTNA 0x02
+#define BTNB 0x01
+
+; interrupts
+; interrupt flag 
+#define IF 0xFF0F
+; interrupt enabled
+#define IE 0xFFFF
+#define IVBLANK 0b00000001
+
+; location where code for dma needs to be memcyp'd to
+.def int DMAFN = 0xFF80 
+#define DMA 0xFF46
+
+#define OBJSMAX 40
+
+.def int P1FDPAD = P1F5
+.def int P1FBTN = P1F4
+.def int P1FNONE = P1F5 | P1F4
+
+; memory map 
+.def int VRAM = 0x8000
+.def int VRAM9000 = VRAM+0x1000
+.def int SCRN0 = 0x9800
+.def int SCRN1 = 0x9C00
+.def int OAMRAM = 0xFE00
+.def int OBJSIZE = 4
+.def int OAMRAM_SIZE = OBJSMAX * OBJSIZE
+
+#define OAM_FYFLIP 0b01000000
+#define OAM_FXFLIP 0b00100000
+
+; MBC1 registers
+
+; write 0xA here to enable sram 
+#define SRAM_ENABLE 0x0000
+#define ROM_BANKSEL 0x2000
+#define SRAM_BANKSEL 0x4000
diff --git a/src/jmp.inc b/src/jmp.inc
new file mode 100644 (file)
index 0000000..8197685
--- /dev/null
@@ -0,0 +1,28 @@
+; RST $00
+; panic exception handler 
+rst_panic:
+  di
+@forever:
+  jp @forever
+  
+
+.fill 0, 0x40 - $ 
+
+; interrupt vectors
+
+;=============
+; vblank 0x40
+;=============
+vec_vblank:
+  push af
+  push bc
+  push de
+  push hl
+
+
+  pop hl
+  pop de
+  pop bc
+  pop af
+
+  reti
diff --git a/src/main.s b/src/main.s
new file mode 100644 (file)
index 0000000..2fb530a
--- /dev/null
@@ -0,0 +1,15 @@
+#include "hw.inc"
+
+.org 0x0
+#include "jmp.inc"
+.fill 0, 0x100 - $
+#include "header.inc"
+entry:
+
+main:
+@forever:
+  jp @forever 
+
+; fill bank
+.fill 0, 0x7FFF - $