;;; -*- TI-Asm -*- ;;; ;;; Mimas - Assembly language IDE for the TI-83 Plus ;;; ;;; Copyright (C) 2010 Benjamin Moody ;;; ;;; This program is free software: you can redistribute it and/or ;;; modify it under the terms of the GNU General Public License as ;;; published by the Free Software Foundation; either version 3 of the ;;; License, or (at your option) any later version. ;;; ;;; This program is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;; General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with this program. If not, see . ;; ShowAlphaMenu: ;; ;; Display a popup menu allowing the user to select from a sorted list ;; of strings. The menu is designed to look and feel similar to the ;; TIOS catalog. A string typed by the user may be used to determine ;; the initial place in the list (for "completion"-like behavior.) ;; The user may navigate the list by pressing the arrow keys, and may ;; press a letter key to jump to the corresponding location. ;; ;; Two callback functions must be supplied: a seek-and-compare ;; function (as used by BSearchS), and an "unpack" function (which ;; receives a list index in HL, and must convert that into a ;; zero-terminated string, returning HL as a pointer to the unpacked ;; string.) ;; ;; Input: ;; - (alphaMenuTabStart) = lower bound for string indices ;; - (alphaMenuTabEnd) = upper bound for string indices ;; - BC = function to extract a string from the list ;; - DE = seek-and-compare function (see BSearchS) ;; - HL = address of string to use as initial key ;; ;; Output: ;; - Carry flag set if user cancelled menu ;; - HL = addres of chosen string (unpacked and 0-terminated) if user ;; accepted a choice ;; ;; Destroys: ;; - AF, BC, DE, HL, IX ;; - OP1-OP6 ;; - minPenCol ;; - Contents of LCD and saveSScreen ShowAlphaMenu: ld (alphaMenuUnpackFunc),bc ld (alphaMenuSearchFunc),de ld a,50h call PopupInit ShowAlphaMenu_JumpToStringLoc: ex de,hl ld hl,(alphaMenuTabStart) ld bc,(alphaMenuTabEnd) ld ix,(alphaMenuSearchFunc) push bc call BSearchS pop bc or a sbc hl,bc add hl,bc jr c,ShowAlphaMenu_NotLastItem call AlphaMenuPrev jr c,ShowAlphaMenu_Cancel ShowAlphaMenu_NotLastItem: ld d,h ld e,l ShowAlphaMenu_Loop: ;; since we set alpha lock, treat Alpha+Up/Down as normal ;; Up/Down (similar to TIOS catalog) res appWantAlphaUpDn,(iy + alphaUpDnFlag) VERTICAL_MENU_NO_ALPHA 4, 8, 15, 82, AlphaMenuInit, AlphaMenuShow, AlphaMenuNext, AlphaMenuPrev, AlphaMenuShowCursor, AlphaMenuHideCursor ld b,0 SWITCH_BEGIN SWITCH_CASE kEnter, ShowAlphaMenu_Accept SWITCH_CASE kClear, ShowAlphaMenu_Cancel SWITCH_CASE kBOL, ShowAlphaMenu_JumpToChar SWITCH_CASE kEOL, ShowAlphaMenu_JumpToEnd SWITCH_CASE kQuit, ShowAlphaMenu_Cancel SWITCH_END push hl push de call KeyToChar pop de pop hl jr nz,ShowAlphaMenu_Loop ld b,a ShowAlphaMenu_JumpToChar: ld hl,OP1 ld (hl),b inc hl ld (hl),0 dec hl jr ShowAlphaMenu_JumpToStringLoc ShowAlphaMenu_JumpToEnd: ld b,'}' jr ShowAlphaMenu_JumpToChar ShowAlphaMenu_Accept: call PopupExit AlphaMenuGetItemString: ld bc,(alphaMenuUnpackFunc) ld de,OP1 call Call_BC or a ret ShowAlphaMenu_Cancel: scf jq_ PopupExit AlphaMenuInit: ld bc,4E08h jq_ DrawPopupBox AlphaMenuShow: call AlphaMenuGetItemString ld d,87 jq_ BufVPutSLimit AlphaMenuPrev: ld bc,(alphaMenuTabStart) inc bc or a sbc hl,bc add hl,bc ret c dec hl ld de,OP1 xor a ld (de),a AlphaMenuCallSearchFunc: ld bc,(alphaMenuSearchFunc) Call_BC: push bc ; SETRETURN ret AlphaMenuNext: push hl ld de,OP1 ld a,'}' ld (de),a call AlphaMenuCallSearchFunc ld bc,(alphaMenuTabEnd) or a sbc hl,bc add hl,bc pop de ccf ret nc ex de,hl ret AlphaMenuHideCursor: ld a,SFourSpaces jr AlphaMenuShowCursorChar AlphaMenuShowCursor: ld a,Sconvert AlphaMenuShowCursorChar: ld hl,penCol ld (hl),11 jq_ BufVPutMap