;iPTools - iPhone/iPod Touch USB Tools ; (C) 2010 by Brandon Wilson. All rights reserved. ;Portions in util.asm, usb8x.inc, equates.inc (C) Dan Englender. include "settings.inc" ;Specific settings for this application NOLIST include "ti83plus.inc" include "usb8x.inc" LIST include "equates.inc" ;Equates and macros to be used include "header.asm" GLOBALS ON SEGMENT MAIN EXTERN DispHexHL,DispHexA,IPutS,PutSApp,INewLine,IGetKey EXTERN curMenu,prevMenu,DisplayMenu EXTERN Initializeusb8x,iPhoneInit,iPhoneSendCommand,iPhoneUploadFile EXTERN iPhoneSendControlExploit ;----------------------------------------------------------------------------- Init: DisplayMainMenu: ;Display main menu ld hl,0 ld (prevMenu),hl ld hl,mainMenu ld (curMenu),hl jr DisplayMenu DoTools: ld hl,DisplayMainMenu ld (prevMenu),hl ld hl,toolsMenu ld (curMenu),hl jr DisplayMenu DoRecoveryConsole: B_CALL ClrLCDFull B_CALL HomeUp ;Initialize usb8x call Initializeusb8x jr c,usb8xNotFoundMainMenu jr ExitApp DoJailbreak: B_CALL ClrLCDFull B_CALL HomeUp ;Initialize usb8x call Initializeusb8x jr c,usb8xNotFoundMainMenu ;Initialize the iPhone/iPod touch ld b,82h ld hl,8600h U_CALL SetupLog ld b,0FEh U_CALL LogCustom call iPhoneInit jr c,ExitAppError ;Try and find the payload Flash application ld a,6 B_CALL PutC call IGetKey ld hl,sMyCommand ld de,appData ld bc,sMyCommandEnd-sMyCommand push de ldir pop hl call iPhoneSendCommand jr c,ExitAppError ld a,7 B_CALL PutC ld hl,sPayload rst 20h call iPhoneSendFile jr c,ExitAppError ld a,5 B_CALL PutC call iPhoneSendControlExploit jr c,ExitAppError ld a,5 B_CALL PutC ld hl,sGeohot rst 20h ld hl,OP1 call iPhoneSendCommand jr c,ExitAppError ld a,5 B_CALL PutC ld hl,sGeohotImage rst 20h call iPhoneSendFile jr c,ExitAppError ld a,5 B_CALL PutC ld hl,sSetPicture ld de,appData ld bc,sSetPictureEnd-sSetPicture push de ldir pop hl call iPhoneSendCommand jr c,ExitApp ld a,5 B_CALL PutC ld hl,sBgColor ld de,appData ld bc,sBgColorEnd-sBgColor push de ldir pop hl call iPhoneSendCommand jr c,ExitApp ld a,5 B_CALL PutC ld hl,sPurple rst 20h call iPhoneSendFile jr c,ExitApp ld a,5 B_CALL PutC ld hl,sGeohot rst 20h ld hl,OP1 call iPhoneSendCommand jr c,ExitApp ld a,5 B_CALL PutC ld hl,sReboot ld de,appData ld bc,sRebootEnd-sReboot push de ldir pop hl call iPhoneSendCommand jr c,ExitApp ld hl,sSuccess call PutSApp call IGetKey jr DisplayMainMenu sReboot: DB "reboot",0Dh,0Ah,0 sRebootEnd: sGeohot: DB "geohot",0D,0Ah,0 sGeohotImage: DB AppObj,"GEOHOT ",0 sSetPicture: DB "setpicture 0",0D,0Ah,0 sSetPictureEnd: sBgColor: DB "bgcolor 1 1 1",0D,0Ah,0 sBgColorEnd: sPurple: DB AppObj,"PURPLE ",0 iPhoneSendFile: B_CALL FindApp ret c push af ;Get the total file size ld hl,4002h ld de,appData ld bc,4 B_CALL FlashToRam ld ix,appData ld d,(ix+0) ld e,(ix+1) ld h,(ix+2) ld l,(ix+3) ld bc,122 call DEHLMinusBC ;DEHL now contains the size of the file pop bc ld ix,8080h jr iPhoneUploadFile DEHLMinusBC: or a sbc hl,bc ret nc dec de ret sPayload: DB AppObj,"PAYLOAD ",0 sSuccess: DB "Success!",0 sMyCommand: DB "setenv auto-boot true",0Dh,0Ah,0 sMyCommandEnd: usb8xNotFoundMainMenu: B_CALL ClrLCDFull B_CALL HomeUp ld hl,susb8xNotFound call PutSApp call IGetKey jr DisplayMainMenu ExitApp: B_CALL ClrLCDFull B_CALL HomeUp B_CALL ClrTxtShd bit usb8xInitted,(iy+flashAppFlags) jr z,$F U_CALL StopLog U_CALL HostKill U_CALL DriverKill $$: B_JUMP JForceCmdNoChar ExitAppError: ld a,'E' B_CALL PutC call IGetKey B_CALL ClrLCDFull B_CALL HomeUp ld a,'E' B_CALL PutC U_CALL GetErrorCode ld h,b ld l,c call DispHexHL B_CALL GetKey B_CALL ClrLCDFull B_CALL HomeUp B_CALL ClrTxtShd U_CALL HostKill U_CALL DriverKill B_JUMP JForceCmdNoChar mainMenu: DB "iPTools v",VER_STRING,0 DB 3 DB "1) Jailbreak",0 DW DoJailbreak DB "2) Tools",0 DW DoTools DB "3) Quit",0 DW ExitApp toolsMenu: DB "Tools",0 DB 2 DB "1) Console",0 DW DoRecoveryConsole DB "2) Back",0 DW DisplayMainMenu susb8xNotFound: DB "usb8x does not " DB "appear to be on " DB "the calculator. " DB "Transfer it and " DB "try again.",0