;LAndroid - Android Driver/Application ; (C) 2011 by Brandon Wilson. All rights reserved. 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 SEGMENT MAIN Var numOptions,1 ; 1; number of menu options EXTERN DispHexHL,DispHexA,IPutS,IPutC,PutSApp,INewLine,IGetKey,VPutSAppCenter EXTERN DirectUSB_Setup,DirectUSB_Init,DirectUSB_ConfigureDevice,DirectUSB_ConnectDevice EXTERN DirectUSB_SendControlData,DirectUSB_Connect,DirectUSB_GetDescriptor EXTERN DirectUSB_SendControlDataOut,WaitTimerB10ms,DirectUSB_HostInit EXTERN DirectUSB_Start,DirectUSB_SetEventHandler,DirectUSB_Stop,DirectUSB_Teardown EXTERN DispLog,DirectUSB_GetCurrentDevice,DirectUSB_RequestData ;----------------------------------------------------------------------------- Init: set appAutoScroll,(iy+appFlags) DisplayMainMenu: ;Display main menu ld hl,mainMenu DisplayMenu: push hl B_CALL ClrLCDFull B_CALL HomeUp pop hl call PutSApp call INewLine ld a,(hl) ld (numOptions),a ld b,a inc hl $$: call PutSApp call INewLine inc hl inc hl djnz $B $$: call IGetKey cp kQuit jr z,ExitApp cp kClear jr z,ExitApp cp k1 jp m,$B cp k9+1 jp p,$B sub k1-1 ld b,a ld a,(numOptions) cp b jr c,$B ld d,b ld hl,mainMenu ld bc,4000h xor a cpir $$: cpir inc hl inc hl dec d jr nz,$B dec hl ld d,(hl) dec hl ld e,(hl) ex de,hl jp (hl) DoAbout: ;Display the About screen ld a,(iy+plotFlags) push af set plotLoc,(iy+plotFlags) res bufferOnly,(iy+plotFlags) B_CALL ForceFullScreen B_CALL ClrLCDFull ld hl,1 ld (curRow),hl ld hl,sAboutText call PutSApp ld hl,bSplashImage ld de,appBackUpScreen ld bc,bSplashImageEnd-bSplashImage ldir ld hl,appBackUpScreen ld de,42*256+33 B_CALL DisplayImage ld a,57 ld (penRow),a ld hl,sURL call VPutSAppCenter ld a,25 ld (penRow),a ld hl,sVersion call VPutSAppCenter ld a,32 ld (penRow),a ld hl,sBuild call VPutSAppCenter pop af ld (iy+plotFlags),a xor a ld (kbdKey),a ld (kbdScanCode),a B_CALL GetKey jr Init DoDemo: B_CALL ClrLCDFull B_CALL HomeUp ld hl,sDemoInstructions call IPutS ;Start USB driver ld b,00000011b call DirectUSB_Setup ;Set up event handlers ld a,evDeviceConnected ld de,evhDeviceConnected call DirectUSB_SetEventHandler ;Make some magic happen! call DirectUSB_Start ;Wait for ON to be pressed keyLoop: $$: ld a,1 out (5Bh),a ei halt in a,(4) bit 3,a jr nz,$B ;Stop the driver (this kills the current connection) call DirectUSB_Stop ;Shut everything down call DirectUSB_Teardown jr Init DoViewLog: jr DispLog ExitAppError: B_CALL ClrLCDFull B_CALL HomeUp ld hl,sError call IPutS B_CALL GetKey ExitApp: B_CALL ClrLCDFull B_CALL HomeUp B_CALL ClrTxtShd B_JUMP JForceCmdNoChar evhDeviceConnected: ld a,'C' call IPutC ret sAboutText: DB " LAndroid " DB " Brandon Wilson ",0 bSplashImage: DB 13, 30 DB 00000000b,00000000b,01100000b,00000000b DB 00000000b,00000111b,11110000b,00000000b DB 00000000b,00001111b,11110000b,00000000b DB 00000000b,00011100b,01100000b,00000000b DB 00011000b,00111000b,00000000b,00000000b DB 00111100b,01110000b,00000000b,01100000b DB 01111111b,11111111b,11111111b,11110000b DB 01111111b,11111111b,11111111b,11110000b DB 00111100b,00000111b,00000000b,01100000b DB 00011000b,00000011b,10001110b,00000000b DB 00000000b,00000001b,11111111b,00000000b DB 00000000b,00000000b,11111111b,00000000b DB 00000000b,00000000b,00001110b,00000000b bSplashImageEnd: sURL: DB "brandonw.net/landroid",0 sVersion: DB "Version ",VER_STRING,0 sBuild: DB "Build ",BUILD_STRING,0 mainMenu: DB "LAndroid v",VER_STRING,0 DB 4 DB "1) Demo",0 DW DoDemo DB "2) View Log",0 DW DoViewLog DB "3) About",0 DW DoAbout DB "4) Quit",0 DW ExitApp sDemoInstructions: DB "Press ",LlBrack,"ON] to " DB "quit.",0 sPressAnyKey: DB "Press any key",0CEh,0 sError: DB "ERROR!",0