;;; -*- 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 .
processor Z80
nolist
include
list
include "mimas.inc"
include "defs.inc"
include "insts.inc"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Static variables - General
;;;
org appBackUpScreen
;;; General app status
RAMCodeCall: ds 16 ; Used to call RAM code and return to
; the same page
saveLwrCaseFlag: ds 1 ; Original appLwrCaseFlag
;;; Current program information
curProgFileName: ds 9 ; Name of the "current"
; program
curProgStartPage: ds 1 ; Page number of the
; start of the current
; program
curProgHeader: ds PROGHEADER_LENGTH ; Copy of current program
; header
curProgSymbolCount: ds 2 ; Number of entries in
; current program symbol
; table
;;; Current program section information
curSectionOffset: ds 2 ; Program offset to
; current section header
curSectionHeader: ds SECTHEADER_LENGTH ; Copy of current section
; header
;;; Custom error message info
customErrorStr: ds 2 ; Error message (compressed format
; string)
customErrorParam: ds 2 ; Value to be displayed, if needed
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Static variables - Program Editor
;;;
;;; Section editor
sectionMenuStart: ds 2
sectionMenuCurrent: ds 2
newSectionHeader: ds SECTHEADER_LENGTH ; Header info for new
; section
;;; Assembly editor
editStartOffset: ds 2 ; Program offset to start of window
editLineOffset: ds 2 ; Program offset to current row
editLineSize: ds 1 ; Number of bytes of program data
; corresponding to current row
;;; Text line editor
textEditXStart: ds 1 ; X coordinate of start of
; text edit box
textEditXEnd: ds 1 ; X coordinate of end of text
; edit box
;;; Alpha menu
alphaMenuTabStart: ds 2 ; Pointer/offset to start of strings
alphaMenuTabEnd: ds 2 ; Pointer/offset to end of strings
alphaMenuUnpackFunc: ds 2 ; Address of function to unpack a
; string from the table
alphaMenuSearchFunc: ds 2 ; Address of function to synchronize
; and compare with a table entry
guiSavedCursor: ds 2 ; Cursor position (saved while a popup
; is active)
guiSavedShiftFlags: ds 1 ; Shift flags (saved while a popup is
; active)
;;; Program menu
progMenuStart: ds 2 ; VAT address of top of window
progMenuCurrent: ds 2 ; VAT address of currently selected
; program
progMenuFirstGood: ds 2 ; VAT address of first valid program
;;; New Program dialog
newProgramName: ds 10 ; Name for new program (used by New
; Program screen)
newProgramType: ds 1 ; Program type (i.e., template)
;;; Other temporary GUI stuff
curScreenBuffer: ds 2 ; Active screen buffer (used by
; various drawing routines)
minPenCol: ds 1 ; Starting pen column (used by VNewLine)
dialogTitle: ds 2 ; Title of current dialog
formatArgPtr0: ds 2 ; Temp pointers to arg expressions
formatArgPtr1: ds 2 ; (used for parsing and printing)
formatArgPtr2: ds 2
NO_BYTE_CARRY formatArgPtr0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Static Variables - Assembler
;;;
;;; Assembler state
asmOutputFileName: ds 10 ; File to store output
asmPassNumber: ds 1 ; Current pass number (starts at 1)
asmLoadPC: ds 2 ; Current load address
asmExecPC: ds 2 ; Current execution address
asmMinLoadPC: ds 2 ; Minimum load address so far
asmMaxLoadPC: ds 2 ; Maximum load address so far
asmLineOffset: ds 2 ; Program offset to current
; source line
asmLineLoadPC: ds 2 ; Load address at start of
; line ($$)
asmLineExecPC: ds 2 ; Exec address at start of
; line ($)
asmAnonSymbolNumber: ds 2 ; Current anonymous symbol number
asmConditionalCount: ds 1 ; Number of successful
; conditionals
asmConditionalSkipCount: ds 1 ; Number of unsuccessful
; conditionals
asmAllowPCBankC: ds 1 ; = 0 to verify code segment < 8k
;;; Debug file information
debugFileStartPage: ds 1 ; Page number of the start of
; the debug file
debugFileSize: ds 2 ; Current size of the debug file
programInfoEndOffset: ds 2 ; Offset to end of program
; file entries in the debug
; file
anonSymbolStartOffset: ds 2 ; Offset to start of anonymous
; symbols in debug file
curProgInfoOffset: ds 2 ; Offset to current program
; file entry in the debug file
curProgSymbolOffset: ds 2 ; Offset to current program's
; symbol entries in the debug
; file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Temporary buffers
;;;
instrBuf: ds 65 ; Temporary instruction buffer (used
; while editing and assembling)
progTextBufferStart: ds 260 ; Main text edit buffer
progTextBufferEnd: ds 1
cutBuffer: ds 261 ; Buffer of text deleted using CLEAR
; (zero-terminated)
ASSERT ($ <= appBackUpScreen + 768)
tempExprLength equ appData ; Length of parsed expressions plus 1
tempExprBuf equ appData + 1 ; (255) Buffer for parsed expressions
; (used temporarily while parsing)
asmHashBins equ plotSScreen ; (512) Hash table used for linking
; symbols (used temporarily while
; assembling)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; File pointers
;;;
curProgStartPtr equ iMathPtr1 ; Pointer to the start of the
; current program (following
; length word) (used while
; editing and assembling)
debugFileStartPtr equ iMathPtr2 ; Pointer to start of the
; debug file (following length
; word) (used while assembling
; only)
asmOutputFilePtr equ iMathPtr3 ; Address of start of output
; file (used while assembling
; only)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Flags
;;;
;;; asm_Flag1 - temporary assembly flags
symbolsChanged equ 0 ; symbol values have changed
inFinalPass equ 1 ; running final (i.e., output) pass
;;; asm_Flag2 - miscellaneous flags
editableProgsOnly equ 0 ; don't show locked files in prog menu
outputForDebug equ 1 ; generate breakpoints
;;; asm_Flag3 - text editing flags
editVarName equ 0 ; allow only A-Z, theta, 0-9
editAsmShortcuts equ 1 ; use instruction shortcut keys
editTextChanged equ 2 ; user has typed in text editor
editClearPressed equ 3 ; CLEAR was just pressed
editNewLine equ 4 ; editing a newly inserted line
formatTemplate equ 5 ; allow X_ARGVAL expressions
menuAtBottom equ 6 ; showing bottom of menu
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; App header
;;;
org $4000
db $80, $0F, 0, 0, 0, 0
db $80, $12 ; Key ID
db $01, $04
db $80, $21 ; Major version
db 0
db $80, $31 ; Minor version
db 1
db $80, $45 ; Name
db "Mimas"
db $80, $81 ; Number of pages
db 2
db $80, $90 ; Suppress default splash screen
db $80, $A1 ; Hardware compatibility mode
db $FF
db $03, $26 ; Date stamp block
db $09, $04 ; Date stamp
db $04, $6F, $1B, $80
db $02, $0D, $40 ; "Signature" of DSB
db $A1, $6B, $99, $F6, $59, $BC, $67, $F5
db $85, $9C, $09, $6C, $0F, $B4, $03, $9B
db $C9, $03, $32, $2C, $E0, $03, $20, $E3
db $2C, $F4, $2D, $73, $B4, $27, $C4, $A0
db $72, $54, $B9, $EA, $7C, $3B, $AA, $16
db $F6, $77, $83, $7A, $EE, $1A, $D4, $42
db $4C, $6B, $8B, $13, $1F, $BB, $93, $8B
db $FC, $19, $1C, $3C, $EC, $4D, $E5, $75
db $80, $7F, 0, 0, 0, 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; App initialization
;;;
;; set up handler for calling RAM code + page 1 routines
ld hl,RAMCodeStub
ld de,RAMCodeCall
ld bc,16
ldir
in a,(6)
ld (RAMCodeP0Patch),a
dec a
ld (RAMCodeP1Patch),a
ld hl,AppVecs
BCALL _AppInit
ld a,(flags + appLwrCaseFlag)
ld (saveLwrCaseFlag),a
xor a
ld (asmAllowPCBankC),a
ld (cutBuffer),a
jp MainMenuInit
AppPutAway:
;; clean up flags
BCALL _ClrCursorHook
ld a,(saveLwrCaseFlag)
ld (flags + appLwrCaseFlag),a
;; invalidate graph
set grfSChanged,(iy + sGrFlags)
BCALL _SetTblGraphDraw
BCALL _ReloadAppEntryVecs
BJUMP _PutAway
AppVecs:
dw DummyRet, DummyRet, AppPutAway, DummyRet, DummyRet, DummyRet
db 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Assorted data for GUI
;;;
include "data.asm"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Main menu
;;;
MainMenuError:
call ShowErrorPopup
MainMenuInit:
ld hl,MainMenuError
call APP_PUSH_ERRORH
set textEraseBelow,(iy + textFlags)
set plotLoc,(iy + plotFlags)
MainMenu:
call ClearBufferSetGraph
ld hl,0101h
ld (penCol),hl
set fracDrawLFont,(iy + fontFlags)
ld hl,mainScreenText
call DisplayGUIString
res fracDrawLFont,(iy + fontFlags)
ld a,32h
ld (penRow),a
call CenterDisplayGUIString
call VNewLine
call CenterDisplayGUIString
ld de,plotSScreen
ld a,14
MainMenu_LogoLoop:
ex de,hl
ld bc,10
add hl,bc
ex de,hl
ldi
ldi
dec a
jr nz,MainMenu_LogoLoop
call XBufCpy
SWITCH_NUMBERED_MENU mainMenuInfo
SWITCH_CASE 1, NewProgramDlg
SWITCH_CASE 2, OpenProgramDlg
SWITCH_END
QuitToTIOS:
BCALL _JForceCmdNoChar
;; UNREACHABLE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Page 0
;;;
include "openprog.asm"
include "sections.asm"
include "asmedit.asm"
include "compile.asm"
include "imports.asm"
include "gui.asm"
include "edit.asm"
include "dialog.asm"
include "vmenu.asm"
include "nummenu.asm"
include "alphmenu.asm"
include "progmenu.asm"
include "build.asm"
include "hash.asm"
include "output.asm"
include "special.asm"
include "irules.asm"
include "itempl.asm"
include "program.asm"
include "symbols.asm"
include "expprint.asm"
include "expparse.asm"
include "exputil.asm"
include "expeval.asm"
include "insprint.asm"
include "insparse.asm"
include "util.asm"
include "bsearch.asm"
include "display.asm"
include "p1call.asm"
if ($ > $7B00)
error "page overflow"
endif
;;; Instruction tables must be aligned to a 256-byte boundary
org $7B00
include "itables.asm"
if ($ > $8000)
error "page overflow"
endif
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Page 1
;;;
org $14000
rorg $4000
include "pack.asm"
include "builtins.asm"
include "p1disp.asm"
include "p1util.asm"
include "sysdata.asm"
if ($ > $8000 - 96)
error "page overflow"
endif