remove sgb and start implementing text engine
This commit is contained in:
parent
4cc89982f7
commit
6b24ac5549
|
@ -3,23 +3,11 @@
|
|||
; Modified by:
|
||||
; Copyright (C) 2020 Alex Gentilucci
|
||||
; - added vwf library
|
||||
; - added charmap
|
||||
; - remove sgb stuff
|
||||
;
|
||||
; 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.
|
||||
|
||||
; This file is licensed under the terms of the MIT License.
|
||||
; For more license details, see LICENSE or <https://mit-license.org/>.
|
||||
|
||||
; include the libraries
|
||||
INCLUDE "hardware.inc/hardware.inc"
|
||||
|
@ -52,51 +40,6 @@ lb: MACRO
|
|||
ld \1, ((\2) << 8) | (\3)
|
||||
ENDM
|
||||
|
||||
|
||||
; SGB packet types
|
||||
RSRESET
|
||||
PAL01 rb 1
|
||||
PAL23 rb 1
|
||||
PAL12 rb 1
|
||||
PAL03 rb 1
|
||||
ATTR_BLK rb 1
|
||||
ATTR_LIN rb 1
|
||||
ATTR_DIV rb 1
|
||||
ATTR_CHR rb 1
|
||||
SOUND rb 1 ; $08
|
||||
SOU_TRN rb 1
|
||||
PAL_SET rb 1
|
||||
PAL_TRN rb 1
|
||||
ATRC_EN rb 1
|
||||
TEST_EN rb 1
|
||||
ICON_EN rb 1
|
||||
DATA_SND rb 1
|
||||
DATA_TRN rb 1 ; $10
|
||||
MLT_REQ rb 1
|
||||
JUMP rb 1
|
||||
CHR_TRN rb 1
|
||||
PCT_TRN rb 1
|
||||
ATTR_TRN rb 1
|
||||
ATTR_SET rb 1
|
||||
MASK_EN rb 1
|
||||
OBJ_TRN rb 1 ; $18
|
||||
PAL_PRI rb 1
|
||||
|
||||
SGB_PACKET_SIZE equ 16
|
||||
|
||||
; sgb_packet packet_type, nb_packets, data...
|
||||
sgb_packet: MACRO
|
||||
PACKET_SIZE equ _NARG - 1 ; Size of what's below
|
||||
db (\1 << 3) | (\2)
|
||||
REPT _NARG - 2
|
||||
SHIFT
|
||||
db \2
|
||||
ENDR
|
||||
|
||||
ds SGB_PACKET_SIZE - PACKET_SIZE, 0
|
||||
ENDM
|
||||
|
||||
|
||||
; 64 bytes, should be sufficient for most purposes. If you're really starved on
|
||||
; memory check your stack usage and consider setting this to 32 instead.
|
||||
; 16 is probably not enough.
|
||||
|
@ -119,3 +62,13 @@ error: MACRO
|
|||
ENDC
|
||||
ENDM
|
||||
|
||||
newcharmap primary_font
|
||||
CHARS equs "0123456789ABCDEFGHUJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz .!?:-"
|
||||
CHAR = 0
|
||||
REPT STRLEN("{CHARS}")
|
||||
charmap STRSUB("{CHARS}", CHAR + 1, 1), CHAR
|
||||
CHAR = CHAR + 1
|
||||
ENDR
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
INCLUDE "defines.asm"
|
||||
|
||||
|
||||
SECTION "Game Loop", ROM0
|
||||
EnterMainLoop::
|
||||
di
|
||||
|
|
149
src/sgb.asm
149
src/sgb.asm
|
@ -1,149 +0,0 @@
|
|||
; Copyright (C) 2018-2020 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.
|
||||
|
||||
INCLUDE "defines.asm"
|
||||
|
||||
SECTION "SGB routines", ROM0
|
||||
|
||||
; Sends SGB packets to the SGB, assuming we're running on one.
|
||||
; @param hl Pointer to the packet data to be sent (can send any number of packets btw)
|
||||
; @return hl Points to the end of the packet data
|
||||
; @return de Zero
|
||||
; @return bc Zero
|
||||
; @return a Zero
|
||||
SendPackets::
|
||||
ld a, [hl] ; Length
|
||||
and %111
|
||||
ret z
|
||||
ld c, a
|
||||
|
||||
.sendPacket
|
||||
call SendPacketNoDelay
|
||||
call SGBDelay ; Let the ICD chip rest a bit
|
||||
dec c
|
||||
jr nz, .sendPacket
|
||||
ret
|
||||
|
||||
|
||||
; Sends a SGB packet to the SGB to freeze the screen, assuming we're running on one.
|
||||
; Does not perform any delay after sending the packet.
|
||||
; Use only if you're not going to send another SGB packet in the next few frames.
|
||||
; You're likely to perform some decompression or smth after this
|
||||
; @param hl Pointer to the packet data to be sent.
|
||||
; @return hl Points to the end of the packet data
|
||||
; @return b Zero
|
||||
; @return d Zero
|
||||
; @return a $30
|
||||
; @destroy e
|
||||
FreezeSGBScreen::
|
||||
ld hl, FreezeScreenPacket
|
||||
; Sends a SGB packet to the SGB, assuming it's running on one.
|
||||
; Does not perform any delay after sending the packet.
|
||||
; Unsuitable to send multi-packet packets.
|
||||
; Use only if you're not going to send another SGB packet in the next four frames.
|
||||
; Assumes the joypad won't be polled by interrupts during this time, but since the VBlank handler doesn't poll except when waited for, this is fine.
|
||||
; @param hl Pointer to the packet data to be sent.
|
||||
; @return hl Points to the end of the packet data
|
||||
; @return b Zero
|
||||
; @return d Zero
|
||||
; @return a $30
|
||||
; @destroy e
|
||||
SendPacketNoDelay::
|
||||
; Packet transmission begins by sending $00 then $30
|
||||
xor a
|
||||
ldh [rP1], a
|
||||
ld a, $30
|
||||
ldh [rP1], a
|
||||
|
||||
ld b, SGB_PACKET_SIZE
|
||||
.sendByte
|
||||
ld d, 8 ; 8 bits in a byte
|
||||
ld a, [hli] ; Read byte to send
|
||||
ld e, a
|
||||
|
||||
.sendBit
|
||||
ld a, $10 ; 1 bits are sent with $10
|
||||
rr e ; Rotate d and get its lower bit, two birds in one stone!
|
||||
jr c, .bitSet
|
||||
add a, a ; 0 bits are sent with $20
|
||||
.bitSet
|
||||
ldh [rP1], a
|
||||
ld a, $30 ; Terminate pulse
|
||||
ldh [rP1], a
|
||||
dec d
|
||||
jr nz, .sendBit
|
||||
|
||||
dec b
|
||||
jr nz, .sendByte
|
||||
|
||||
; Packets are terminated by a "STOP" 0 bit
|
||||
ld a, $20
|
||||
ldh [rP1], a
|
||||
ld a, $30
|
||||
ldh [rP1], a
|
||||
ret
|
||||
|
||||
SGBDelay::
|
||||
ld de, 7000 ; Magic value, apparently
|
||||
.loop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
dec de
|
||||
ld a, d
|
||||
or e
|
||||
jr nz, .loop
|
||||
ret
|
||||
|
||||
FreezeScreenPacket:
|
||||
sgb_packet MASK_EN, 1, 1
|
||||
|
||||
|
||||
; Fill the $9C00 tilemap with a pattern suitable for SGB _TRN
|
||||
; Also sets up the rendering parameters for the transfer
|
||||
; Finally, assumes the LCD is **off**
|
||||
; @return hl
|
||||
FillScreenWithSGBMap::
|
||||
xor a
|
||||
ldh [hSCY], a
|
||||
ldh [hSCX], a
|
||||
ld b, a ; ld b, 0
|
||||
ld hl, $9C00
|
||||
.writeRow
|
||||
ld c, SCRN_X_B
|
||||
.writeTile
|
||||
ld a, b
|
||||
ld [hli], a
|
||||
inc b
|
||||
jr z, .done
|
||||
dec c
|
||||
jr nz, .writeTile
|
||||
ld a, l
|
||||
add a, SCRN_VX_B - SCRN_X_B
|
||||
ld l, a
|
||||
jr nc, .writeRow
|
||||
inc h
|
||||
jr .writeRow
|
||||
.done
|
||||
ld a, %11100100
|
||||
ldh [hBGP], a
|
||||
SetupSGBLCDC::
|
||||
ld a, LCDCF_ON | LCDCF_WINOFF | LCDCF_BG8000 | LCDCF_BG9C00 | LCDCF_OBJOFF | LCDCF_BGON
|
||||
ldh [rLCDC], a
|
||||
ldh [hLCDC], a
|
||||
ret
|
Loading…
Reference in New Issue