;;; -*- 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 . ;; RunVerticalMenuAlpha: ;; ;; Display a vertically scrolling menu. The user may press Up/Down to ;; select an item, or Left/Right or Alpha+Up/Down to scroll by pages. ;; ;; Input: ;; - (SP) = address of vertical menu information structure ;; - HL = currently selected item ;; - DE = top of window ;; ;; Output: ;; - A = keycode ;; - HL = currently selected item ;; - DE = top of window ;; ;; Destroys: ;; - F, BC ;; - (penRow), (penCol), (minPenCol) RunVerticalMenuAlpha: set appWantAlphaUpDn,(iy + alphaUpDnFlag) ;; fall through ;; RunVerticalMenu: ;; ;; Display a vertically scrolling menu. The user may press Up/Down to ;; select an item, or Left/Right to scroll by pages. Alpha+Up/Down ;; will also work if the appWantAlphaUpDn flag is set. ;; ;; The information structure (passed as data following the ;; RunVerticalMenu call) contains the following: ;; - Starting pixel row ;; - Number of rows of data to be displayed ;; - Ending pixel row (must equal top-row + 7 * num-rows) ;; - Starting pixel column ;; - Pixel column to place scroll indicators ;; - Callback function to clear display ;; - Callback function to display item (input (penRow) = position; HL ;; = address of item) ;; - Callback function to find next item (input HL = address of item; ;; output HL = address of next item, or carry set if none) ;; - Callback function to find previous item (input HL = address of ;; item; output HL = address of previous item, or carry set if none) ;; - Callback function to show cursor (input A = (penRow) = position ;; of selected item; HL = address of item) ;; - Callback function to hide cursor (input A = (penRow) = position ;; of item previously selected) ;; ;; Except for the outputs mentioned above, callback functions are free ;; to destroy AF, BC, DE, and HL (but must preserve IX.) ;; ;; Input: ;; - (SP) = address of vertical menu information structure ;; - HL = currently selected item ;; - DE = top of window ;; - appWantAlphaUpDn, (iy + alphaUpDnFlag) = 1 to use Alpha+Up/Down ;; for page scrolling ;; ;; Output: ;; - A = keycode ;; - HL = currently selected item ;; - DE = top of window ;; ;; Destroys: ;; - F, BC ;; - (penRow), (penCol), (minPenCol) RunVerticalMenu: ex (sp),ix ex de,hl RunVerticalMenu_Redisplay: ;; HL = top of window ;; DE = selected item set menuAtBottom,(iy + asm_Flag3) ld c,VMENU_DISPLAY_INIT call VerticalMenuCallback ld a,(ix + VMENU_LEFT_COLUMN) ld (minPenCol),a ld a,(ix + VMENU_TOP_ROW) sub 7 ld (penRow),a push hl ld b,(ix + VMENU_NUM_ROWS) RunVerticalMenu_RedisplayLoop: call VNewLine or a sbc hl,de add hl,de jr nz,RunVerticalMenu_NotSelected ld c,a RunVerticalMenu_NotSelected: push bc ld c,VMENU_DISPLAY_ITEM call VerticalMenuCallback call VerticalMenuGetNext pop bc ld a,c jr c,RunVerticalMenu_RedisplayDone djnz RunVerticalMenu_RedisplayLoop push af ld b,LdownArrow call VerticalMenuPutArrow pop af res menuAtBottom,(iy + asm_Flag3) RunVerticalMenu_RedisplayDone: pop hl push hl push af call VerticalMenuGetPrev call nc,VerticalMenuPutTopArrow pop af ex de,hl RunVerticalMenu_SetRow: ld (penRow),a ld c,VMENU_SHOW_CURSOR call VerticalMenuCallback RunVerticalMenu_SameRow: push hl call XBufCpy call GetKey pop hl ld b,(ix + VMENU_NUM_ROWS) dec b SWITCH_BEGIN SWITCH_CASE kUp, RunVerticalMenu_Up SWITCH_CASE kDown, RunVerticalMenu_Down SWITCH_CASE kLeft, RunVerticalMenu_PageUp SWITCH_CASE kRight, RunVerticalMenu_PageDown SWITCH_CASE kAlphaUp, RunVerticalMenu_PageUp SWITCH_CASE kAlphaDown, RunVerticalMenu_PageDown SWITCH_END pop de RunVerticalMenu_Done: ld bc,VMENU_END add ix,bc ex (sp),ix ret RunVerticalMenu_RedisplayAtTop1: pop bc RunVerticalMenu_RedisplayAtTop: ld d,h ld e,l RunVerticalMenu_Redisplay_: jr RunVerticalMenu_Redisplay RunVerticalMenu_Up: call VerticalMenuGetPrev jr c,RunVerticalMenu_SameRow call VerticalMenuHideCursor cp (ix + VMENU_TOP_ROW) jr z,RunVerticalMenu_RedisplayAtTop1 sub 7 jr RunVerticalMenu_SetRow RunVerticalMenu_Down: call VerticalMenuGetNext jr c,RunVerticalMenu_SameRow call VerticalMenuHideCursor add a,7 cp (ix + VMENU_BOTTOM_ROW) jr c,RunVerticalMenu_SetRow ex (sp),hl call VerticalMenuGetNext pop de jr RunVerticalMenu_Redisplay_ RunVerticalMenu_PageUp: pop hl or a RunVerticalMenu_PageUpLoop: call nc,VerticalMenuGetPrev djnz RunVerticalMenu_PageUpLoop jr RunVerticalMenu_RedisplayAtTop RunVerticalMenu_PageDown: pop hl push hl or a RunVerticalMenu_PageDownLoop: call nc,VerticalMenuGetNext djnz RunVerticalMenu_PageDownLoop bit menuAtBottom,(iy + asm_Flag3) jr z,RunVerticalMenu_RedisplayAtTop1 ex de,hl pop hl jr RunVerticalMenu_Redisplay_ ;; VerticalMenuGetPrev: ;; ;; Get the previous entry in the list, if any. ;; ;; Input: ;; - HL = entry in vmenu list ;; - IX = vmenu structure ;; ;; Output: ;; - Carry flag set if input was the first entry in the list ;; - HL = previous entry (if any), otherwise unchanged ;; ;; Destroys: ;; - AF, C VerticalMenuGetPrev: ld c,VMENU_GET_PREV jr VerticalMenuGetItem ;; VerticalMenuGetNext: ;; ;; Get the next entry in the list, if any. ;; ;; Input: ;; - HL = entry in vmenu list ;; - IX = vmenu structure ;; ;; Output: ;; - Carry flag set if input was the last entry in the list ;; - HL = previous entry (if any), otherwise unchanged ;; ;; Destroys: ;; - AF, C VerticalMenuGetNext: ld c,VMENU_GET_NEXT VerticalMenuGetItem: push de push hl push bc call VerticalMenuCallbackNS pop bc jr c,VerticalMenuGetItem_Failed pop de pop de ret ;; VerticalMenuHideCursor: ;; ;; Hide the menu cursor. ;; ;; Input: ;; - IX = vmenu structure ;; ;; Output: ;; - A = (penRow) ;; ;; Destroys: ;; - A, BC VerticalMenuHideCursor: ld a,(penRow) ld c,VMENU_HIDE_CURSOR ;; fall through ;; VerticalMenuCallback: ;; ;; Call one of the vmenu callback functions. ;; ;; Input: ;; - IX = vmenu structure ;; - C = offset to callback pointer ;; ;; Destroys: ;; - BC VerticalMenuCallback: push de push hl push af ld e,a call VerticalMenuCallbackNS pop af VerticalMenuGetItem_Failed: pop hl pop de ret VerticalMenuCallbackNS: push ix ld b,0 add ix,bc ld c,(ix) ld b,(ix + 1) pop ix push bc ;SETRETURN ret VerticalMenuPutTopArrow: ld a,(ix + VMENU_TOP_ROW) ld (penRow),a ld b,LupArrow VerticalMenuPutArrow: ld a,(ix + VMENU_ARROW_COLUMN) ld (penCol),a ld a,b BufVPutMapSave: push de call BufVPutMap pop de ret