;;; -*- 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 . ;; ShowNumberedMenu: ;; ;; Display a popup menu with a small, fixed set of choices. The menu ;; may contain at most 9 items; the user can select an item by ;; pressing the corresponding number key, or by highlighting an item ;; with the arrow keys and pressing Enter. ;; ;; The menu structure consists of the following: ;; - One byte: number of entries ;; - One byte: width of menu in pixels ;; - For each entry: ;; - One byte: length of compressed label string ;; - Variable: compressed label string ;; ;; Input: ;; - HL = address of menu structure ;; ;; Output: ;; - A = 0 if menu cancelled, or A = 1 to A = 9 if an item was ;; selected ;; - If an item was selected, DE = address of the unpacked menu string ;; ;; Destroys: ;; - F, BC, DE, HL ;; - OP1-OP6 ;; - minPenCol ;; - Contents of LCD and saveSScreen ShowNumberedMenu: xor a call PopupInit ld c,(hl) ; number of items inc hl ld b,(hl) ; width of menu inc hl call DrawPopupBox push hl push bc ld a,(penRow) push af ld b,c ld c,'1' ShowNumberedMenu_DisplayLoop: ld a,c inc c call BufVPutMap ld a,':' call BufVPutMap call BufVPutBlank call DisplayGUIString call VNewLine djnz ShowNumberedMenu_DisplayLoop pop af ld e,a ld d,0 pop bc ShowNumberedMenu_KeyLoop: ;; D = currently selected item # ;; E = currently selected pixel row ;; C = number of items push bc push de call XBufCpy pop de push de ld a,e ld h,a add a,6 ld d,a ld a,(penCol) dec a ld l,a add a,6 ld e,a push hl push de BCALL _InvertRect res appWantAlphaUpDn,(iy + alphaUpDnFlag) call GetKey pop de pop hl push af BCALL _InvertRect pop af pop de pop bc ld b,0 SWITCH_BEGIN SWITCH_CASE kUp, ShowNumberedMenu_Up SWITCH_CASE kDown, ShowNumberedMenu_Down SWITCH_CASE kEnter, ShowNumberedMenu_Accept SWITCH_CASE kClear, ShowNumberedMenu_Cancel SWITCH_CASE kQuit, ShowNumberedMenu_Cancel SWITCH_END sub k1 jr c,ShowNumberedMenu_KeyLoop cp c jr nc,ShowNumberedMenu_KeyLoop ld d,a ShowNumberedMenu_Accept: pop hl ld b,d inc b push bc ShowNumberedMenu_AcceptLoop: call UnpackGUIString ex de,hl djnz ShowNumberedMenu_AcceptLoop pop bc push hl ShowNumberedMenu_Cancel: pop hl ld a,b jq_ PopupExit ShowNumberedMenu_Up: ld a,d or a jr z,ShowNumberedMenu_KeyLoop dec d ld a,e sub 7 ShowNumberedMenu_SetRow: ld e,a jr ShowNumberedMenu_KeyLoop ShowNumberedMenu_Down: ld a,d inc a cp c jr nc,ShowNumberedMenu_KeyLoop ld d,a ld a,e add a,7 jr ShowNumberedMenu_SetRow