;Nspire8x - Nspire Direct USB Driver and UI ; (C) 2010 by Brandon Wilson. All rights reserved. ;Portions in util.asm, usb8x.inc, equates.inc, logview.asm (C) Dan Englender. include "settings.inc" ;Specific settings for this application NOLIST include "ti83plus.inc" LIST include "equates.inc" ;Equates and macros to be used include "header.asm" GLOBALS ON include "usb8x.inc" ;usb8x equates SEGMENT MAIN EXTERN vputstring,IGetKey,IPutS,DispHexHL,PutSApp EXTERN NavNetInit,ProcessNavNetEvents,NavNetRequestDeviceInfo,NavNetGetScreenshot EXTERN NavNetEchoData,NavNetGetErrors EXTERN CalculateCRC,DispLog,VPutSApp,VPutSAppCenter EXTERN InitializePeriphUSB,USBactivityHook EXTERN receiveAndWriteUSBData,DispHexA,sendUSBData_BCbytesFromHL,IPutC EXTERN DoFileBrowser,GetDeviceInfo,DoPeripheralModeTest,DoNdlessInstall Var USBDriverCall,32 ; 32; RAM calls for U_CALL and callback routine Var USBDriverBuf,128 ;128; Static buffer for USB driver's usage Var numChoices,1 ; 1; Var menuAddr,2 ; 2; Var topItem,2 ; 2; Var selectedItem,2 ; 2; Var bChoice,1 ; 1; Var dFileSize,4 ; 4; Var tempWord,2 ; 2; Var currentPath,256 ;256; ;----------------------------------------------------------------------------- AboutScreen: B_CALL ForceFullScreen B_CALL ClrLCDFull ld hl,1 ld (curRow),hl ld hl,sAboutText call PutSApp ld hl,30*256+29 ld (pencol),hl ld hl,Intro_Version call VPutSApp ld a,37 ld (penRow),a ld hl,Intro_Build call VPutSAppCenter ld hl,7 ld (curRow),hl ld hl,sPressAnyKey call IPutS B_CALL GetKey Init: U_CALL_INIT 0 jr c,USBErrorNoDrv ld hl,USBDriverBuf U_CALL DriverInit jr c,USBError U_CALL StopLog StartApp: B_CALL CanAlphIns ld hl,mainMenu ld (menuAddr),hl DrawMenu: B_CALL ClrLCDFull B_CALL HomeUp ld hl,(menuAddr) call PutSApp ld de,0001h ld b,(hl) ld a,b ld (numChoices),a inc hl $$: push bc ld (curRow),de push de call PutSApp pop de inc e inc hl inc hl pop bc djnz $B B_CALL HomeUp keyLoop: B_CALL GetKey cp kQuit jr z,ExitApp cp kClear jr z,ExitApp cp kCapA jr z,AboutScreen cp k1 jr c,keyLoop sub k1 ld b,a ld a,(numChoices) dec a cp b jp m,keyLoop inc b push bc ld hl,(menuAddr) xor a ld bc,20 cpir inc hl pop de dec hl dec hl $$: inc hl inc hl xor a ld bc,20 cpir dec d jr nz,$B ld e,(hl) inc hl ld d,(hl) ex de,hl jp (hl) StartLogging: di ld a,logPage out (7),a ld hl,8000h ld (hl),0 ld de,8001h ld bc,4000h-1 ldir ld b,a ld a,81h out (7),a ld hl,logAddress U_CALL SetupLog jr StartApp StopLogging: U_CALL StopLog jr StartApp USBErrorNoDrv: B_CALL ClrLCDFull B_CALL HomeUp ld hl,sNoUSBDriver call IPutS B_CALL GetKey jr $F USBError: B_CALL ClrLCDFull B_CALL HomeUp ld hl,sUSBError call IPutS U_CALL GetErrorCode push bc pop hl call DispHexHL ld hl,1 ld (curRow),hl call NavNetGetErrors ld b,8 $$: ld a,(hl) inc hl call DispHexA djnz $B ld hl,3 ld (curRow),hl ld hl,sUSBError2 call IPutS onWait: in a,(4) bit 3,a jr nz,onWait ExitApp: U_CALL StopLog U_CALL HostKill U_CALL DriverKill $$: B_CALL ClrLCDFull B_CALL HomeUp B_JUMP JForceCmdNoChar mainMenu: DB "Nspire8x ",VER_STRING,0 DB 7 DB "1) Get Info",0 DW GetDeviceInfo DB "2) File Browser",0 DW DoFileBrowser DB "3) Ndless",0 DW DoNdlessInstall DB "4) Start Logging",0 DW StartLogging DB "5) Stop Logging",0 DW StopLogging DB "6) Dummy Test",0 DW DoPeripheralModeTest DB "7) View Log",0 DW DispLog sAboutText: DB " Nspire8x " DB " Brandon Wilson ",0 Intro_Web: DB "brandonw.net",0 Intro_Version: DB "Version ",VER_STRING,0 Intro_Build: DB "Build ",BUILD_STRING,0 sPressAnyKey: DB "Press any key",0CEh,0 sNoUSBDriver: DB "ERROR: " DB " " DB "usb8x is " DB "required to run " DB "this Flash " DB "application.",0 sUSBError: DB "ERROR ",0 sUSBError2: DB "A communication " DB "error has " DB "occurred. Try " DB "again.",0