;NspireEx v0.1 ; (C) 2009 by Brandon Wilson. All rights reserved. ;v0.1 Changelog ;Initial release include "settings.inc" NOLIST include "ti83plus.inc" LIST include "equates.inc" include "header.asm" SEGMENT MAIN GLOBALS ON EXTERN IPutS StartApp: B_CALL ClrLCDFull B_CALL HomeUp ld hl,sMainMenu call IPutS mainKeyLoop: call IGetKey cp kClear jr z,ExitApp cp kQuit jr z,ExitApp sub k7 jr z,ExitApp dec a jr z,DoAbout dec a jr z,DoHelp dec a jr z,disableHook dec a jr z,enableHook dec a jr z,DoUninstall dec a jr nz,mainKeyLoop ;Do install ;Patch sector 70h code (if it exists) ;Redirect BCALLs _ExecuteApp and _ExecutePrgm to routines on page 71h: ; _ExecuteApp: routine will swap in this page (via app name) and jump to RunApp ; _ExecutePrgm: routine will swap in this page (via app name) and call RunPrgm ; RunApp/RunPrgm: ; Write the following bytes to 3FF0h: ; push af ; in a,(6) ; push af ; ld a, ; out (6),a ; jp 4083h ; Change three bytes at 0000h to: ; jp 3FF0h ; Scan the entire page for blocks of "bad" instructions from a table on this page. ; If a potentially-bad instruction is found, scan both ahead and behind for at least ; three (customizable) z80 instructions. ; If a bad instruction is found, log its location and original instruction to page 72h: ; bOriginalPage, wOriginalAddress, bInstructionID ; Depending on the bad instruction, either write rst 00h or rst 00h \ ; Terminate the page 72h table with 0FFh. ; Execute the program or application. ; Write 0FFh to the start of page 72h (clearing table). ; 4083h code: ; Determine from the stack the original address/location of "rst 00h". ; Check the following byte to see if it is a special invalid instruction byte. ; If so: ; Execute the equivalent code for that instruction, increase IP to beyond ; the instruction ID, and return. ; If not: ; Get the original page containing "rst 00h" and scan the page 72h table ; for the original address. ; If found: ; Execute the equivalent code for that instruction, increase IP ; to beyond "rst 00h", and return. ; If not found: ; Jump to 0053h. ;NOTE: For common 2+ byte instructions, the instruction ID will be an invalid instruction byte. jr StartApp ExitApp: B_CALL ClrLCDFull B_CALL HomeUp B_JUMP JForceCmdNoChar DoUninstall: enableHook: disableHook: DoHelp: DoAbout: jr StartApp sMainMenu: DB "NspireEx ",VER_STRING,0 DB " 1) Install " DB " 2) Uninstall " DB " 3) Run Program " DB " 4) Help " DB " 5) About " DB " 6) Quit",0