new stuff idk
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -2,3 +2,6 @@
|
||||
/obj/
|
||||
/dep/
|
||||
/assets/
|
||||
|
||||
src/*.2bpp
|
||||
src/*.tilemap
|
||||
18
.vscode/launch.json
vendored
Normal file
18
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
// 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": "./bin/binx.gb",
|
||||
"host": "172.19.64.1",
|
||||
"port": 58870,
|
||||
"stopOnEntry": true
|
||||
}
|
||||
]
|
||||
}
|
||||
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -2,6 +2,7 @@
|
||||
"rgbdsz80.includePath": [
|
||||
"src/",
|
||||
"src/constants",
|
||||
"src/macros"
|
||||
"src/macros",
|
||||
"include"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
zlib License
|
||||
|
||||
Copyright (c) 2020-2022 Eldred Habert
|
||||
|
||||
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.
|
||||
1141
include/hardware.inc
1141
include/hardware.inc
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
||||
|
||||
|
||||
# Value that the ROM will be filled with.
|
||||
PADVALUE := 0xFF
|
||||
PADVALUE := 0x00
|
||||
|
||||
## Header constants (passed to RGBFIX).
|
||||
|
||||
@@ -11,10 +11,10 @@ PADVALUE := 0xFF
|
||||
VERSION := 0
|
||||
|
||||
# 4-ASCII letter game ID.
|
||||
GAMEID := BOIL
|
||||
GAMEID := BINX
|
||||
|
||||
# Game title, up to 11 ASCII chars.
|
||||
TITLE := BOILERPLATE
|
||||
TITLE := BINX
|
||||
|
||||
# New licensee, 2 ASCII chars.
|
||||
# Homebrew games FTW!.
|
||||
@@ -36,7 +36,7 @@ MBC := 0x00
|
||||
SRAMSIZE := 0x00
|
||||
|
||||
# ROM name.
|
||||
ROMNAME := boilerplate
|
||||
ROMNAME := binx
|
||||
ROMEXT := gb
|
||||
|
||||
|
||||
|
||||
0
scripts/update_hardware_inc.sh
Normal file → Executable file
0
scripts/update_hardware_inc.sh
Normal file → Executable file
1
src/data.asm
Normal file
1
src/data.asm
Normal file
@@ -0,0 +1 @@
|
||||
if !DEF(DATA_ASM)
|
||||
23
src/game.asm
Normal file
23
src/game.asm
Normal file
@@ -0,0 +1,23 @@
|
||||
if !def(GAME_INC)
|
||||
DEF GAME_INC EQU 1
|
||||
|
||||
INCLUDE "hardware.inc"
|
||||
rev_Check_hardware_inc 5.3.0
|
||||
|
||||
INCLUDE "input.asm"
|
||||
INCLUDE "util.asm"
|
||||
INCLUDE "ram.asm"
|
||||
|
||||
SECTION FRAGMENT "Game", ROM0
|
||||
loop: ; Main Loop
|
||||
call WaitVBlank
|
||||
|
||||
call RUN_DMA
|
||||
|
||||
call HandleDirectionInput
|
||||
|
||||
jr loop
|
||||
done:
|
||||
jr done
|
||||
|
||||
endc ; game_inc
|
||||
@@ -1,24 +1,68 @@
|
||||
|
||||
INCLUDE "hardware.inc"
|
||||
rev_Check_hardware_inc 4.0
|
||||
rev_Check_hardware_inc 5.3.0
|
||||
|
||||
INCLUDE "util.asm"
|
||||
INCLUDE "ram.asm"
|
||||
INCLUDE "data.asm"
|
||||
INCLUDE "game.asm"
|
||||
INCLUDE "input.asm"
|
||||
INCLUDE "screen.asm"
|
||||
|
||||
SECTION "Header", ROM0[$100]
|
||||
|
||||
; This is your ROM's entry point
|
||||
; You have 4 bytes of code to do... something
|
||||
di
|
||||
jp EntryPoint
|
||||
|
||||
; Make sure to allocate some space for the header, so no important
|
||||
; code gets put there and later overwritten by RGBFIX.
|
||||
; RGBFIX is designed to operate over a zero-filled header, so make
|
||||
; sure to put zeros regardless of the padding value. (This feature
|
||||
; was introduced in RGBDS 0.4.0, but the -MG etc flags were also
|
||||
; introduced in that version.)
|
||||
ds $150 - @, 0
|
||||
|
||||
SECTION "Entry point", ROM0
|
||||
|
||||
EntryPoint:
|
||||
; Here is where the fun begins, happy coding :)
|
||||
jr @
|
||||
; turn off audio
|
||||
ld a, $00
|
||||
ld [rNR52], a
|
||||
|
||||
call WaitVBlank
|
||||
|
||||
; turn the LCD off, but wait for VBlank first
|
||||
ld a, $00
|
||||
ld [rLCDC], a
|
||||
|
||||
; Copy the DMA proc to HRAM
|
||||
ld de, RUN_DMA
|
||||
ld hl, DMA_Stub
|
||||
ld bc, DMA_Stub.End - DMA_Stub
|
||||
call CopyData
|
||||
|
||||
; Clear shadow OAM
|
||||
call ResetShadowOAM
|
||||
|
||||
; Load tile data
|
||||
ld de, $9000
|
||||
ld hl, TestLevelTileData
|
||||
ld bc, TestLevelTileData.End - TestLevelTileData
|
||||
call CopyData
|
||||
|
||||
; Load level tilemap
|
||||
ld de, $9800
|
||||
ld hl, TestLevelTileMap
|
||||
ld bc, TestLevelTileMap.End - TestLevelTileMap
|
||||
call CopyData
|
||||
|
||||
; Set the scroll registers
|
||||
ld a, $00
|
||||
ld [rSCY], a
|
||||
ld [rSCX], a
|
||||
|
||||
; Initialize scroll speed counter
|
||||
ld a, $00
|
||||
ld [INPUT_COUNTER_ADDR], a
|
||||
|
||||
; Set the pallets
|
||||
ld a, %11100100
|
||||
ld [rBGP], a
|
||||
|
||||
; Turn on the display
|
||||
ld a, %11000001
|
||||
ld [rLCDC], a
|
||||
|
||||
jp loop
|
||||
121
src/input.asm
Normal file
121
src/input.asm
Normal file
@@ -0,0 +1,121 @@
|
||||
if !def(INPUT_INC)
|
||||
DEF INPUT_INC EQU 1
|
||||
|
||||
INCLUDE "hardware.inc"
|
||||
rev_Check_hardware_inc 5.3.0
|
||||
|
||||
INCLUDE "ram.asm"
|
||||
|
||||
SECTION FRAGMENT "Input", ROM0
|
||||
|
||||
DEF DPAD_BUTTON_MASK EQU %11101111
|
||||
DEF RIGHT_DPAD_MASK EQU %00000001
|
||||
DEF LEFT_DPAD_MASK EQU %00000010
|
||||
DEF UP_DPAD_MASK EQU %00000100
|
||||
DEF DOWN_DPAD_MASK EQU %00001000
|
||||
|
||||
DEF COUNTER_TICKRATE EQU 10
|
||||
|
||||
; register b will contain the direction button data
|
||||
ReadDirectionButtons:
|
||||
ld a, DPAD_BUTTON_MASK
|
||||
ld [rJOYP], a
|
||||
|
||||
ld a, [rJOYP]
|
||||
ld a, [rJOYP]
|
||||
ld a, [rJOYP]
|
||||
ld a, [rJOYP]
|
||||
ld b, a
|
||||
|
||||
ret
|
||||
|
||||
HandleDirectionInput:
|
||||
; load counter and check
|
||||
ld a, [INPUT_COUNTER_ADDR]
|
||||
cp a, COUNTER_TICKRATE
|
||||
jr c, .ret ; return if we haven't hit the tickrate
|
||||
|
||||
call ReadDirectionButtons ; b = input data
|
||||
ld a, b
|
||||
|
||||
ld a, b
|
||||
and a, RIGHT_DPAD_MASK
|
||||
call z, PressRight
|
||||
|
||||
ld a, b
|
||||
and a, LEFT_DPAD_MASK
|
||||
call z, PressLeft
|
||||
|
||||
ld a, b
|
||||
and a, UP_DPAD_MASK
|
||||
call z, PressUp
|
||||
|
||||
ld a, b
|
||||
and a, DOWN_DPAD_MASK
|
||||
call z, PressDown
|
||||
|
||||
; reset the counter
|
||||
ld a, $00
|
||||
ld [INPUT_COUNTER_ADDR], a
|
||||
.ret
|
||||
; increment the counter on every call
|
||||
ld a, [INPUT_COUNTER_ADDR]
|
||||
inc a
|
||||
ld [INPUT_COUNTER_ADDR], a
|
||||
ret
|
||||
|
||||
PressLeft:
|
||||
push af
|
||||
|
||||
ld a, [rSCX]
|
||||
or a, a
|
||||
jr z, .ret
|
||||
|
||||
dec a
|
||||
ld [rSCX], a
|
||||
.ret:
|
||||
pop af
|
||||
ret
|
||||
|
||||
PressRight:
|
||||
push af
|
||||
|
||||
ld a, [rSCX]
|
||||
add a, 159
|
||||
jr c, .ret ; c is set if we go above 255, which means past this tileset
|
||||
|
||||
ld a, [rSCX]
|
||||
inc a
|
||||
ld [rSCX], a
|
||||
.ret:
|
||||
pop af
|
||||
ret
|
||||
|
||||
PressUp:
|
||||
push af
|
||||
|
||||
ld a, [rSCY]
|
||||
or a, a
|
||||
jr z, .ret
|
||||
|
||||
dec a
|
||||
ld [rSCY], a
|
||||
.ret
|
||||
pop af
|
||||
ret
|
||||
|
||||
PressDown:
|
||||
push af
|
||||
|
||||
ld a, [rSCY]
|
||||
add a, 143
|
||||
jr c, .ret ; c is set if we go above 255, which means past this tileset
|
||||
|
||||
inc a
|
||||
ld [rSCY], a
|
||||
.ret:
|
||||
pop af
|
||||
ret
|
||||
|
||||
|
||||
endc ; input_inc
|
||||
10
src/ram.asm
Normal file
10
src/ram.asm
Normal file
@@ -0,0 +1,10 @@
|
||||
if !def(RAM_INC)
|
||||
DEF RAM_INC EQU 1
|
||||
|
||||
DEF WRAM_START EQU $C000
|
||||
DEF SHADOW_OAM_ADDR EQU WRAM_START
|
||||
DEF RUN_DMA EQU $FF80
|
||||
|
||||
DEF INPUT_COUNTER_ADDR EQU $C100
|
||||
|
||||
endc ; ram_inc
|
||||
10
src/screen.asm
Normal file
10
src/screen.asm
Normal file
@@ -0,0 +1,10 @@
|
||||
if !def(SCREEN_INC)
|
||||
DEF SCREEN_INC EQU 1
|
||||
|
||||
INCLUDE "hardware.inc"
|
||||
rev_Check_hardware_inc 5.3.0
|
||||
|
||||
SECTION FRAGMENT "Input", ROM0
|
||||
|
||||
|
||||
endc ; screen_inc
|
||||
58
src/util.asm
Normal file
58
src/util.asm
Normal file
@@ -0,0 +1,58 @@
|
||||
if !def(UTIL_INC)
|
||||
DEF UTIL_INC EQU 1
|
||||
|
||||
INCLUDE "hardware.inc"
|
||||
rev_Check_hardware_inc 5.3.0
|
||||
|
||||
SECTION FRAGMENT "Utilities", ROM0
|
||||
|
||||
WaitVBlank:
|
||||
ldh a, [rLY]
|
||||
cp 144 ;
|
||||
jr c, WaitVBlank
|
||||
ret
|
||||
|
||||
; Params
|
||||
; de: dest
|
||||
; hl: source
|
||||
; bc: size
|
||||
CopyData:
|
||||
ld a, [hli]
|
||||
ld [de], a
|
||||
|
||||
inc de
|
||||
dec bc
|
||||
|
||||
ld a, b
|
||||
or c
|
||||
jr nz, CopyData
|
||||
ret
|
||||
|
||||
; Needs to be copied to HRAM
|
||||
DMA_Stub:
|
||||
ld a, HIGH($C100)
|
||||
ldh [$FF46], a ; start DMA transfer (starts right after instruction)
|
||||
ld a, 40 ; delay for a total of 4×40 = 160 M-cycles
|
||||
.wait
|
||||
dec a ; 1 M-cycle
|
||||
jr nz, .wait ; 3 M-cycles
|
||||
ret
|
||||
.End
|
||||
|
||||
ResetShadowOAM:
|
||||
ld bc, $F9
|
||||
ld de, $C100
|
||||
.copy
|
||||
ld a, 0
|
||||
ld [de], a
|
||||
|
||||
inc de
|
||||
dec bc
|
||||
|
||||
ld a, b
|
||||
or c
|
||||
jr nz, .copy
|
||||
ret
|
||||
|
||||
|
||||
endc ; util_inc
|
||||
Reference in New Issue
Block a user