~nytpu/ankano unlisted

434f17fd00b4c0e12cf1fe69fd6c2a7d33cd26f1 — nytpu 5 months ago ef357a0 + 3ca7555
Merge branch 'textengine'
5 files changed, 65 insertions(+), 23 deletions(-)

M include/defines.asm
M src/header.asm
M src/intro.asm
M src/loop.asm
A src/text.asm
M include/defines.asm => include/defines.asm +1 -12
@@ 3,8 3,8 @@
; Modified by:
; Copyright (C) 2020 Alex Gentilucci
; - added vwf library
; - added charmap
; - remove sgb stuff
; - bump hardware.inc to 3.0
;
; This file is licensed under the terms of the MIT License.
; For more license details, see LICENSE or <https://mit-license.org/>.


@@ 61,14 61,3 @@ error: MACRO
		jr \1, @-1
	ENDC
ENDM

	newcharmap primary_font
CHARS equs "0123456789ABCDEFGHUJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz .!?:-"
CHAR = 0
REPT STRLEN("{CHARS}")
	charmap STRSUB("{CHARS}", CHAR + 1, 1), CHAR
CHAR = CHAR + 1
ENDR




M src/header.asm => src/header.asm +1 -2
@@ 1,5 1,5 @@
; Copyright (C) 2020 nytpu
; This file incorporates code from: 
; This file incorporates code from:
; Copyright (C) 2018-2020 Eldred Habert
;
; This file is licensed under the terms of the MIT License.


@@ 146,4 146,3 @@ wShadowOAM::
SECTION "Stack", WRAM0[$E000 - STACK_SIZE]
	ds STACK_SIZE
wStackBottom:


M src/intro.asm => src/intro.asm +1 -1
@@ 6,8 6,8 @@ INCLUDE "defines.asm"

SECTION "Intro", ROMX
; render the intro scene
; @destroy all
Intro::
	; TODO: animate intro logo
	; TODO: create start screen
	jp EnterMainLoop


M src/loop.asm => src/loop.asm +9 -8
@@ 4,8 4,9 @@

INCLUDE "defines.asm"


SECTION "Game Loop", ROM0
; initialize stuff for main game loop
; @destroy all
EnterMainLoop::
	di
	; wait for vblank and turn lcd off


@@ 21,20 22,20 @@ EnterMainLoop::
	ldh [hCurROMBank], a
	ld [rROMB0], a

	ld de, GameTiles.bgTiles
	ld hl, $9000
	ld de, GameTiles.bg
	ld hl, _VRAM9000
INCLUDE "res/game_map.2bpp.pb16.size"
	ld bc, NB_PB16_BLOCKS
	PURGE NB_PB16_BLOCKS
	call pb16_unpack_block

	ld de, GameTiles.bgTileMap
	ld hl, $9800
	ld hl, _SCRN0
	ld bc, GameTiles.bgTileMapEnd - GameTiles.bgTileMap
	call LCDMemcpy

	ld de, GameTiles.spriteTiles
	ld hl, $8000
	ld de, GameTiles.sprites
	ld hl, _VRAM8000
INCLUDE "res/spritemap.2bpp.pb16.size"
	ld b, NB_PB16_BLOCKS
	PURGE NB_PB16_BLOCKS


@@ 64,10 65,10 @@ MainLoop:

SECTION "Gameplay Tiles", ROMX
GameTiles:
.bgTiles
.bg
INCBIN "res/game_map.2bpp.pb16"
.bgTileMap
INCBIN "res/game_map.2bpp.tilemap"
.bgTileMapEnd
.spriteTiles
.sprites
INCBIN "res/spritemap.2bpp.pb16"

A src/text.asm => src/text.asm +53 -0
@@ 0,0 1,53 @@
; Copyright (C) 2020 nytpu
; This file is licensed under the terms of the MIT License.
; For more license details, see LICENSE or <https://mit-license.org/>.

INCLUDE "defines.asm"

	newcharmap primary_font
FONTCHARS equs "0123456789ABCDEFGHUJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz .!?:-"
CURCHAR = 0
REPT STRLEN("{FONTCHARS}")
	charmap STRSUB("{FONTCHARS}", CURCHAR + 1, 1), CURCHAR
CURCHAR = CURCHAR + 1
ENDR

SECTION "Font Tiles", ROMX
FontTiles:
INCBIN "res/font.2bpp.pb16"
.end

SECTION "Text Engine", ROM0
; loads font tiles into vram bank
; @param hl start of vram block to copy to
; @destroy all
InitTextEngine::
	; save current bank then change
	ldh a, [hCurROMBank]
	ldh [hTempByte], a
	ld a, BANK(FontTiles)
	ldh [hCurROMBank], a
	ld [rROMB0], a

	ld de, FontTiles
	ld hl, _VRAM8800
INCLUDE "res/font.2bpp.pb16.size"
	ld bc, NB_PB16_BLOCKS
	PURGE NB_PB16_BLOCKS
	call pb16_unpack_block

	; restore old bank
	ldh a, [hTempByte]
	ldh [hCurROMBank], a
	ld [rROMB0], a
	ret

; display text to screen
; @param hl start of vram to copy to
; @param de pointer to start of text string
DispText::
	ldh a, [hCurROMBank]
	ldh [hTempByte], a
	ldh a, BANK(Strings)
	ldh [hCurROMBank], a
	ld [rROMB0], a