;;; -*- 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 . ;; ShowProgramMenu: ;; ;; Display a full-screen menu allowing the user to select a program ;; file. ;; ;; Input: ;; - HL = pointer to compressed title string ;; - editableProgsOnly = 1 to allow only "editable" program files ;; ;; Output: ;; - Carry flag set if user cancels ;; - OP1 = file name if user accepts ;; ;; Destroys: ;; - AF, BC, DE, HL ;; - OP1-OP6 ;; - penRow, penCol, minPenCol ;; - Contents of LCD, plotSScreen, and saveSScreen ShowProgramMenu: ld (dialogTitle),hl ld hl,(progPtr) call FindCurrentOrNextGoodProg jr nc,ShowProgramMenu_OK ld hl,emsg_NoProgramsFound call ThrowGeneralError ;; UNREACHABLE ShowProgramMenu_OK: BCALL _CanAlphIns ld d,h ld e,l ShowProgramMenu_Loop: VERTICAL_MENU_ALPHA 10, 6, 8, 92, DialogInit, ProgramMenuShow, FindNextGoodProg, FindPrevGoodProg, Invert7Rows, Invert7Rows SWITCH_BEGIN SWITCH_CASE kEnter, ShowProgramMenu_Finished SWITCH_CASE kClear, ShowProgramMenu_Cancel SWITCH_CASE kQuit, ShowProgramMenu_Cancel SWITCH_CASE kYequ, ShowProgramMenu_Cancel SWITCH_CASE kGraph, ShowProgramMenu_Finished SWITCH_END jr ShowProgramMenu_Loop ShowProgramMenu_Cancel: scf jr CanAlphIns ShowProgramMenu_Finished: ex de,hl BCALL _ZeroOP1 ld a,(de) ld hl,-6 add hl,de ld b,(hl) inc b ld de,OP1 ShowProgramMenu_CopyNameLoop: ld (de),a inc de dec hl ld a,(hl) djnz ShowProgramMenu_CopyNameLoop or a CanAlphIns: BCALL _CanAlphIns ret ProgramMenuShow: ld de,-5 add hl,de ld c,(hl) dec hl ld b,(hl) dec hl ProgramMenuShow_Loop: ld a,(hl) dec hl call BufVPutMap djnz ProgramMenuShow_Loop ld a,c or a ret z ld a,1 BufVPutStarAtColumn: ld (penCol),a ld a,'*' jq_ BufVPutMap ;; FindNextGoodProg: ;; ;; Find the next valid program file. ;; ;; Input: ;; - HL = VAT pointer ;; ;; Output: ;; - Carry flag set if no more valid programs found ;; - HL = next valid program's VAT pointer ;; ;; Destroys: ;; - AF, DE, HL ;; - OP1 FindCurrentOrNextGoodProg: ex de,hl ld hl,(pTemp) or a sbc hl,de ccf ret c ex de,hl call IsGoodProg ret z FindNextGoodProg: call MoveToNextProgSym jr FindCurrentOrNextGoodProg ;; FindPrevGoodProg: ;; ;; Find the previous valid program file. ;; ;; Input: ;; - HL = VAT pointer ;; ;; Output: ;; - Carry flag set if no more valid programs found ;; - HL = previous valid program's VAT pointer ;; ;; Destroys: ;; - AF, DE, HL ;; - OP1 FindPrevGoodProg: ex de,hl inc de ld hl,(progPtr) or a sbc hl,de ret c add hl,de call FindPrevSymAV call IsGoodProg jr nz,FindPrevGoodProg ret ;; MoveToNextProgSym: ;; ;; Move to the next program VAT entry. ;; ;; Input: ;; - HL = VAT pointer (<= (progPtr), > (pTemp)) ;; ;; Output: ;; - HL = next VAT pointer ;; ;; Destroys: ;; - AF, DE MoveToNextProgSym: ld de,-6 add hl,de ld a,d sub (hl) ld e,a add hl,de ret ;; FindPrevSymAV: ;; ;; Search for the previous AppVar VAT pointer (or just return the ;; anchor pointer if there are no previous AppVars.) ;; ;; Input: ;; - DE = VAT pointer + 1 ;; - HL = anchor VAT pointer (e.g., (progPtr)) ;; ;; Output: ;; - HL = previous VAT pointer ;; ;; Destroys: ;; - AF, DE FindPrevSymAV_Loop: ld a,(hl) and 1Fh cp AppVarObj jr nz,FindPrevSymAV_Skip pop af FindPrevSymAV: push hl FindPrevSymAV_Skip: push de call MoveToNextProgSym pop de or a sbc hl,de add hl,de jr nc,FindPrevSymAV_Loop pop hl ret ;; IsGoodProg: ;; ;; Check if a program is a valid source file. ;; ;; Input: ;; - HL = VAT pointer ;; - editableProgsOnly, (iy + asm_Flag2) = 1 to reject programs that ;; have the "locked" flag set ;; ;; Output: ;; - Zero flag set if program is valid ;; ;; Destroys: ;; - AF, DE ;; - OP1 IsGoodProg: ld a,(hl) and 1Fh cp AppVarObj ret nz push hl push bc call GetVarDataStart ld de,OP1 ld bc,9 call FlashToRAM ld hl,sourceFileSignature ld de,OP1+2 ld b,5 call CompStrsN pop bc pop hl ret nz bit editableProgsOnly,(iy + asm_Flag2) ret z ld a,(OP1+8) ; program flags and PROGFLAG_LOCKED ret