;;; -*- 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 . ;; NewProgramDlg: ;; ;; Show the "New Program" dialog, allowing user to create and edit a ;; new program. This routine does not return. NewProgramDlg: xor a ld (newProgramName + 1),a inc a ld (newProgramType),a NewProgramDlg_Loop: ld hl,newProgramLabel ld de,newProgramDlgInfo call ShowDialogScreen NewProgramDlg_Cancel: jr c,MainMenu ld hl,newProgramName + 1 ;; check that file name is non-empty and begins with an ;; uppercase letter ld a,(hl) call IsFileNameStartChar jr c,NewProgramDlg_Loop dec hl ld (hl),AppVarObj rst rMOV9TOOP1 BCALL _ChkFindSym jr nc,OpenProgram ld hl,emptyProgramSize call CreateVarNoCheckDup ld hl,emptyProgramData ldir BCALL _OP4ToOP1 call LoadProgram call LoadFirstSection ;; add template data ld a,(newProgramType) call InsertProgramTemplate jr OpenProgram ;; OpenProgramDlg: ;; ;; Show the "Open Program" dialog, allowing the user to select an ;; existing program to edit. This routine does not return. OpenProgramDlg: set editableProgsOnly,(iy + asm_Flag2) ld hl,openProgramLabel call ShowProgramMenu jr c,NewProgramDlg_Cancel OpenProgram: jr EditProgramSectionsOP1 ;; InsertProgramTemplate: ;; ;; Insert template program code at the end of the current section. ;; ;; Template code for "Asm" programs: ;; ;; ORG userMem - 2 ;; DB $BB, $6D ;; Start: ;; ;; Template code for Ion programs: ;; ;; ORG userMem - 2 ;; DB $BB, $6D ;; RET ;; JR NC,Start ;; DB "Untitled", 0 ;; Start: ;; ;; Template code for MirageOS programs: ;; ;; ORG userMem - 2 ;; DB $BB, $6D ;; RET ;; DB 1 ;; DB $00, $00, $00, ... ;; DB "Untitled", 0 ;; Start: ;; ;; Template code for DoorsCS programs: ;; ;; ORG userMem - 2 ;; DB $BB, $6D ;; XOR D ;; RET ;; JR Start ;; DW 0 ;; DB 7, 0 ;; DW 0 ;; DW 0 ;; Start: ;; ;; Input: ;; - A = program type (0 = empty, 1 = Asm, 2 = Ion, 3 = MirageOS, 4 = DoorsCS) ;; ;; Destroys: ;; - AF, BC, DE, HL InsertProgramTemplate: ld b,a ;; if empty, then delete the builtin "Start" label or a ld hl,0 jq z,UnrefSymbol rra ; Ion and DoorsCS headers (types 2 and ; 4) include an extra ref for "Start" call nc,RefSymbol ld hl,newProgramTemplates InsertProgramTemplate_Loop: ld a,(hl) or a ret z push bc inc hl ld c,(hl) inc hl ;; A = mask of program types for this template ;; C = size of template InsertProgramTemplate_TestLoop: add a,a djnz InsertProgramTemplate_TestLoop jr nc,InsertProgramTemplate_SkipTemplate ;; insert needed memory (note B = 0 due to the loop above) push hl ld hl,(curSectionHeader + SECTHEADER_DATA_END) call InsDelProgramCodeMem pop hl ;; copy template data into program ldir InsertProgramTemplate_SkipTemplate: ;; skip to next template add hl,bc pop bc jr InsertProgramTemplate_Loop