;;; -*- 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 . ;; ShowErrorPopup: ;; ;; Display a popup window containing an error message, and wait for ;; user to press a key. ;; ;; Input: ;; - A = error code ;; ;; Output: ;; - A = key code ;; ;; Destroys: ;; - F, BC, DE, HL ;; - minPenCol ;; - Contents of LCD and saveSScreen ;; - OP1-OP6 ;; - tempExprBuf ShowErrorPopup: ld b,a and 7Fh cp E_Memory & 7Fh ld hl,emsg_OutOfMemory jr z,ShowErrorPopupMessage cp E_AppErr1 & 7Fh ld hl,(customErrorStr) jr z,ShowErrorPopupMessage ld l,b ld h,0 ld (customErrorParam),hl ld hl,emsg_UnknownError ShowErrorPopupMessage: ld de,errorTitle ;; fall through ;; ShowPopupMessage: ;; ;; Display a popup window containing a message, and wait for user to ;; press a key. ;; ;; Input: ;; - DE = address of compressed title string ;; - HL = address of message structure ;; ;; Output: ;; - A = key code ;; ;; Destroys: ;; - F, BC, DE, HL ;; - minPenCol ;; - Contents of LCD and saveSScreen ;; - OP1-OP6 ;; - tempExprBuf (if using formatting characters) ShowPopupMessage: xor a ShowPopupMessageShift: call PopupInit ld c,(hl) inc hl ld b,(hl) inc hl inc c inc c call DrawPopupBox ld a,(penCol) add a,3 ld (minPenCol),a dec c dec c push bc push hl push de ld hl,(penCol) ld e,h ld a,l dec a ld c,8 call FillRectangle pop hl set textInverse,(iy + textFlags) call CenterDisplayGUIString res textInverse,(iy + textFlags) call VNewLine add a,4 ld (penRow),a pop hl pop bc ld b,c ShowPopupMessage_Loop: push bc call UnpackGUIString push de ShowPopupMessage_StrLoop: ld a,(hl) or a jr z,ShowPopupMessage_StrDone inc hl SWITCH_BEGIN SWITCH_CASE F_FILENAME, ShowPopupMessage_Filename SWITCH_CASE F_HEX, ShowPopupMessage_Hex SWITCH_CASE F_LABEL, ShowPopupMessage_Label SWITCH_END call BufVPutMap jr ShowPopupMessage_StrLoop ShowPopupMessage_StrDone: call VNewLine pop hl pop bc djnz ShowPopupMessage_Loop call XBufCpy call GetKey ;; fall through ;; PopupExit: ;; ;; Clean up after running a popup (restore original cursor and shift ;; flags, and cursor position.) ;; ;; Destroys: ;; - None PopupExit: push hl push af BCALL _RestoreTR ld hl,plotSScreen ld (curScreenBuffer),hl ld hl,(guiSavedCursor) ld (penCol),hl ld a,(guiSavedShiftFlags) ld (flags + shiftFlags),a pop af pop hl ret ShowPopupMessage_Filename: push hl ld hl,(customErrorParam) call BufVPutS8 pop hl jr ShowPopupMessage_StrLoop ShowPopupMessage_Hex: ld bc,(customErrorParam) call BufVPutHex16 ShowPopupMessage_StrLoop_: jr ShowPopupMessage_StrLoop ShowPopupMessage_Label: push hl ld hl,(customErrorParam) call GetProgramSymbolInfo jr c,ShowPopupMessage_LabelInvalid call ProgramOffsetToAddress ld de,OP2 ; WARNING: we're assuming that the ; format string itself is short (which ; it should be, if we expect to be ; able to fit an arbitrary symbol name ; in the popup box!) push de call SymbolStringToRAM pop hl ld de,tempExprBuf push de call UnpackSymbolString pop hl call BufVPutS pop hl jr ShowPopupMessage_StrLoop ShowPopupMessage_LabelInvalid: pop hl ld a,'?' call BufVPutMap jr ShowPopupMessage_StrLoop_ ;; PopupInit: ;; ;; Set up flags for a temporary GUI popup (save current cursor ;; position and shift flags, and set saveSScreen as screen buffer.) ;; ;; Input: ;; - A = initial shift flags ;; ;; Destroys: ;; - A PopupInit: push hl ld h,a BCALL _SaveOScreen ld a,(flags + shiftFlags) ld (guiSavedShiftFlags),a ld (iy + shiftFlags),h ld hl,(penCol) ld (guiSavedCursor),hl ld hl,saveSScreen ld (curScreenBuffer),hl pop hl ret ;; DrawPopupBox: ;; ;; Draw a white box with black border, centered on the screen. ;; ;; Input: ;; - B = width in pixels ;; - C = height in text lines ;; ;; Output ;; - (penRow) = Y coordinate of top of box ;; - (penCol) = (minPenCol) = X coordinate of left edge of box + 1 ;; ;; Destroys: ;; - AF DrawPopupBox: push bc push de push hl push ix ld a,c add a,a add a,a add a,a sub c ld c,a ; C = # of lines * 7 rra ld e,a ; E = C / 2 ld a,SCREEN_HEIGHT / 2 sub e ld (penRow),a ld e,a ld a,SCREEN_WIDTH sub b rra inc a ld (penCol),a ld (minPenCol),a dec a call DrawClearRectangle pop ix Pop_HL_DE_BC_Ret: pop hl pop de pop bc ret ;; VNewLine: ;; ;; Move cursor to the next line. ;; ;; Input: ;; - (penRow) = current row ;; - (minPenCol) = starting column ;; ;; Output: ;; - A = (penRow) = next row ;; - (penCol) = starting column ;; ;; Destroys: ;; - F VNewLine: push hl ld hl,penCol ld a,(minPenCol) ld (hl),a inc hl ld a,(hl) add a,7 ld (hl),a pop hl ret ;; DisplayGUIString: ;; ;; Display a packed menu string on the graph buffer. ;; ;; Input: ;; - HL = address of a packed menu string ;; ;; Output: ;; - HL = address of byte following compressed string ;; ;; Destroys: ;; - AF, DE ;; - OP1-OP6 DisplayGUIString: call UnpackGUIString call BufVPutS ex de,hl ret ;; CenterDisplayGUIString: ;; ;; Display a packed menu string, horizontally centered on the graph ;; buffer. ;; ;; Input: ;; - HL = address of a packed menu string ;; ;; Output: ;; - HL = address of byte following compressed string ;; ;; Destroys: ;; - AF, BC, DE ;; - OP1-OP6 CenterDisplayGUIString: call UnpackGUIString call CenterString call BufVPutS ex de,hl ret ;; UnpackGUIString: ;; ;; Decompress a packed string. The byte at HL gives the number of ;; compressed bytes; following bytes are compressed (in "comment" ;; form.) ;; ;; Input: ;; - HL = address of a packed menu string ;; ;; Output: ;; - HL = address in RAM of decompressed string (zero-terminated) ;; - DE = address of byte following compressed string ;; ;; Destroys: ;; - AF ;; - OP1-OP6 UnpackGUIString: push bc ld de,OP1 ld a,(hl) inc hl or a jr z,UnpackGUIString_Tiny ld c,a ld b,0 push de push bc ldir pop bc ex (sp),hl push de call UnpackCommentString jr Pop_HL_DE_BC_Ret UnpackGUIString_Tiny: ldi ld (de),a dec de ex de,hl pop bc ret ;; DialogInit: ;; ;; Clear screen, set plotSScreen as current, and display a ;; "dialog"-style titlebar and soft keys. Used by program menu and ;; library editor as well as by dialogs. ;; ;; Input: ;; - (dialogTitle) = compressed title string ;; ;; Destroys: ;; - AF, BC, DE, HL ;; - penRow, penCol DialogInit: ld hl,dialogSoftKeys DialogInitCustom: push hl call ClearBufferSetGraph ld hl,(dialogTitle) call CenterDisplayGUIString pop hl ;; fall through ;; DisplaySoftKeysAndTitlebar: ;; ;; Display a soft key menu, and invert top 7 rows of the screen. ;; ;; Input: ;; - HL = address of a soft-key menu structure ;; ;; Destroys: ;; - AF, BC, DE, HL ;; - penRow, penCol DisplaySoftKeysAndTitlebar: push hl xor a call Invert7Rows pop hl ;; fall through ;; DisplaySoftKeys: ;; ;; Display a soft key menu. ;; ;; Input: ;; - HL = address of a soft-key menu structure ;; ;; Destroys: ;; - AF, BC, DE, HL ;; - penRow, penCol DisplaySoftKeys: push hl xor a ld e,SCREEN_HEIGHT - 7 ld bc,SCREEN_WIDTH * 256 + 1 call FillRectangle ld hl,256 * (SCREEN_HEIGHT - 6) ld (penCol),hl pop hl ld d,4 DisplaySoftKeys_LineLoop: ld a,(hl) inc hl push hl ld bc,0107h call FillRectangle pop hl dec d jr nz,DisplaySoftKeys_LineLoop DisplaySoftKeys_Loop: ld a,(hl) or a ret z ld (penCol),a inc hl res textEraseBelow,(iy + textFlags) call DisplayGUIString set textEraseBelow,(iy + textFlags) jr DisplaySoftKeys_Loop