Glitch City Laboratories Archives

Glitch City Laboratories closed on 1 September 2020 (announcement). This is an archived copy of a thread from Glitch City Laboratories Forums.

You can join Glitch City Research Institute to ask questions or discuss current developments.

You may also download the archive of this forum in .tar.gz, .sql.gz, or .sqlite.gz formats.

Programming/Scripting/Development/Web Design

8F Script Help, Simple Text Box - Page 1

8F Script Help, Simple Text Box

Posted by: Connor
Date: 2018-06-26 23:07:19
Hello all, I've been trying to figure out a script that I can implement using 8F. All I want to do is have a text box appear with whatever text I want in it. I've been using TheZZAZZGlitch's creepy pasta script as a reference, but I'm fairly new to assembly and don't understand all of the syntax he uses. Near the beginning of the script, he has dw _DBA5_Tx_DoNotBe ; Text pointer for text ID $01 ["DO NOT BE AFRAID"]
but then doesn't actually have the values _DBA5_Tx_DoNotBe:
db 00,83,8e,7f,8d,8e,93,4f,81,84,7f,80,85,91,80,88,83,51
db 88,93,7f,96,8e,8d,93,7f,87,84,8b,8f,4f,98,8e,94,7f,80,93,7f,80,8b,8b,57
; DO NOT BE AFRAID :: IT WONT HELP YOU AT ALL
until the end of the script. Also, in the part where he actually calls the text box function ld a,$01
ld ($ff00+8c),a
call $2920          ; Display the text ID #1 (DO NOT BE AFRAID)
I don't really understand what "ld ($ff00+8c),a" does or how it is used in this script.
I suppose my two main questions are: what does he do to define that text as having text id 01, and what does "ld ($ff00+8c),a" do in this script? Any help or information would be appreciated. Sorry for the long-winded post, and thanks in advance.

Re: 8F Script Help, Simple Text Box

Posted by: Couldntthinkofaname
Date: 2018-06-27 07:35:15
Near the beggining of his code, the following is written:

ld hl,$d36c
ld (hl),$03
inc hl
ld (hl),$db      ; Set $D36C to $03DB [Repoint current map's text table to $DB03]


This redirects the Map Text Pointer Table to $DB03. At $DB03, he has two pointers defined: _DBA5_Tx_DoNotBe and DBCF_Tx_ThereIs. The former pointer is defined before the latter, so the the former pointer can be treated as text ID 01, and the latter is to be treated as text ID 02.

As for ld ($ff00+8c),a, $FF8c is responsible for what ID us to be displayed by the text bix when calling $2920.

Re: 8F Script Help, Simple Text Box

Posted by: Connor
Date: 2018-06-27 11:49:34
Hey, thanks for the reply, it explains a lot. I have some follow-up questions to the information you gave me.

Are those two text pointers only 1 byte each? Those two lines are supposedly from DB03 to DB04, but I don't see how he points to both DBA5 and DBCF in only two bytes.

Also, why does he use "ld ($ff00+8c), a" instead of just "ld ($ff8c), a"? Does it do something different? Or does it use less opcodes and he uses it for ease of implementation.

Thanks in advance, again.

Re: 8F Script Help, Simple Text Box

Posted by: Couldntthinkofaname
Date: 2018-06-27 13:35:08

Are those two text pointers only 1 byte each? Those two lines are supposedly from DB03 to DB04, but I don't see how he points to both DBA5 and DBCF in only two bytes.


Nope. All addresses and pointers in the Gameboy's architechture are 2 bytes.

As for ld (ff00+8c),a, it swallows only 2 bytes wheras the former instruction ld (ff8c),a swallows three.

Re: 8F Script Help, Simple Text Box

Posted by: ISSOtm
Date: 2018-06-27 18:39:56
To be correct, the correct instruction would be `ldh [$FF00+$8C], a`, or `ldh [$FF8C], a`.

Also, making text appear using 8F shouldn't be too complicated.
I think you'd just need to load a pointer to the text stream in `hl`, and then `call PrintText`. Maybe also `call EnableAutoTextboxDrawing` prior, although I'm not sure if it's necessary there, since auto-drawing is already enabled.

Re: 8F Script Help, Simple Text Box

Posted by: Connor
Date: 2018-07-28 00:54:48
Hey guys, thanks for the help. I had moderate success with ISSOtm's method, but as soon as the message finishes printing, the textbox disappears. Is there another function I need to call so that the textbox only disappears once I press a button, or is there something else I'm missing?

Re: 8F Script Help, Simple Text Box

Posted by: ISSOtm
Date: 2018-07-30 21:44:19
I think there's a function that waits for a button press before closing the textbox.