This took a
lot longer than it should to debug (probably because I'm still getting used to assembly) but I have what I need. Thanks to Kerm for showing me _GetStringInput and to BrandonW for the only documentation I could find on it along with example code (
here).
Any way here is my code:
Code: ld hl, promptString
ld de, ioPrompt
bcall(_strcopy)
ld b, (iy+9)
ld c, (iy+1Ch)
push bc ;back up old flag values
res 6, (iy+1Ch)
set 7, (iy+9)
bcall(_GetStringInput)
pop bc
res OnInterrupt, b ;restore old flag values
ld (iy+9), b
ld (iy+1Ch), c
ld hl, 2Dh
ld (OP1+1), hl
rst rFindSym ;look up temporary equation 04h,2Dh,00h,00h
bcall(_ParseInp)
bcall(_StoAns)
bcall(_JForceCmdNoChar)
promptString:
.db "PROMPT:",0
Input: promptString
Output: Ans
This function can still use some improving. Firstly, I haven't implemented any error handlers and secondly, _GetStringInput has its limits (see quote).
brandonw wrote:
It's just like BASIC's Prompt or Input, and it's a little bit clunky, especially if you use [2nd]+[QUIT] (you'll get a memory leak because the program didn't end properly), so probably the smartest thing to do is jump into saferam and delete yourself, so that if you exit too early, you don't get a memory leak. But this also makes leaving the program a little bizarre, so it's up to you (you could set a keyhook earlier to block [2nd]+[QUIT] and stuff like that).