Geekboy

Untitled

May 2nd, 2012
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "ti83plus.inc"
  2. .org $9D93
  3. .db $BB,$6D
  4. LWIDT = 11
  5.  
  6. ;Overwrite application to jump to $9D9A on getcalcserial
  7. ;Overwrite application to jump to $9D97 for bad write
  8. ;
  9. ProgramStart:
  10.  jr ProgramContinue
  11.  jp NoGo               ;9d97
  12.  jp FakeGetCalcSerial  ;9d9a
  13. ProgramContinue:
  14.  bcall(_ClrLCDFull)
  15.  di
  16. ; ld a,2
  17. ; out ($54),a  ;kills the usb controller (ti84+[SE])
  18.  ld a,1
  19.  out ($20),a  ;set fast mode
  20.  call getresumefile
  21.  ld a,(de)  ;checking to see if the file is empty (will read $00)
  22.  or a
  23.  jr z,DoNotResume
  24.  ex de,hl
  25.  ld de,Ourkey
  26.  ld bc,10
  27.  ldir
  28.  ld de,myappvar
  29.  ld bc,10
  30.  ldir
  31. ContinueResume:
  32.  ld hl,myappvar
  33.  rst 20h
  34.  bcall(_ChkFindSym)
  35.  jr nc,_
  36.  call makeappvar
  37.  jr ContinueResume
  38. _:
  39.  ld a,b
  40.  or a
  41.  jr z,_
  42.  bcall(_Arc_Unarc)
  43.  jr ContinueResume
  44. _:
  45.  ex de,hl
  46.  ld (avartemp),hl  ;starting location of the appvar
  47.  ld e,(hl)
  48.  inc hl
  49.  ld d,(hl)
  50.  inc hl
  51.  add hl,de
  52.  ld (avarpos),hl  ;where the current write pointer ought to be.
  53.  xor a
  54.  inc a
  55. DoNotResume:
  56.  call z,makeappvar  ;if not zero, then do not recreate appvar. Already did it
  57.  ld hl,0000
  58.  ld (currow),hl
  59.  in a,(6)
  60.  ld (itemp1),a
  61.  ld a,$68
  62.  out (6),a
  63. MainLoop:
  64.  ld hl,OurKey
  65.  ld b,10
  66. _:
  67.  inc (hl)
  68.  ld a,(hl)
  69.  cp '9'+1
  70.  jr nz,_   ;did not go over, let's keep iterating.
  71.  ld (hl),'0'
  72.  inc hl
  73.  djnz -_
  74. _:
  75.  ld de,$9A00
  76.  ld hl,OurKey
  77.  ld bc,10
  78.  ldir
  79.  ld hl,(OurKey)
  80.  ld a,h
  81.  or L
  82.  cp '0'
  83.  jr nz,_
  84.  ld hl,(OurKey+2)
  85.  ld a,h
  86.  or L
  87.  cp '0'
  88.  jr nz,_
  89.  bcall(_ClrLCDFull)
  90.  ld hl,0000
  91.  ld (currow),hl
  92.  ld hl,OurKey
  93.  bcall(_PutS)
  94.  bcall(_NewLine)
  95.  ld hl,battstate
  96.  bcall(_PutS)
  97.  in a,(2)
  98.  rrca  ;checking bit 0 for battery state. 0=bad 1=good
  99.  ld a,'0'
  100.  adc a,0
  101.  bcall(_PutC)
  102.  xor a
  103.  out (1),a
  104.  nop
  105.  nop
  106.  in a,(1)
  107.  inc a
  108.  jp nz,QuickExit  ;keep going until a key is pressed while something is found
  109. _:
  110.  call $4440
  111.  bcall(_ClrLCDFull)
  112.  ld hl,0
  113.  ld (currow),hl
  114.  ld hl,KeyOutput
  115.  bcall(_PutS)
  116.  ld hl,myappvar+1
  117.  bcall(_PutS)
  118.  bcall(_NewLine)
  119.  ld hl,KeyDrive
  120.  bcall(_PutS)
  121.  bcall(_PutS)
  122.  call expandfile
  123.  jp MainLoop
  124. QuickExit:
  125.  call updateresumestate
  126.  ld a,(itemp1)
  127.  out (6),a
  128.  ret
  129. NoGo:
  130.  pop hl
  131.  jp MainLoop
  132. FakeGetCalcSerial:
  133.  ld hl,CalcSerial
  134.  ld de,Op1
  135.  ld bc,5
  136.  ldir
  137.  ld b,5
  138.  or a
  139.  ret
  140.  
  141. expandfile:  ;
  142.  bcall(_MemChk)
  143.  ld bc,-100
  144.  add hl,bc
  145.  jr c,_
  146.  ld hl,myappvar
  147.  rst 20h
  148.  bcall(_Arc_Unarc)
  149.  ld b,4
  150.  ld hl,myappvar+8
  151. expandfilerenewname:
  152.  inc (hl)
  153.  ld a,(hl)
  154.  cp '9'+1
  155.  jr nz,expandfilenonewname
  156.  ld (hl),'0'
  157.  dec hl
  158.  jr expandfilerenewname
  159. expandfilenonewname:
  160.  call makeappvar
  161. _:
  162.  ld hl,LWIDT
  163.  ld de,(avarpos)
  164.  push hl
  165.  bcall(_InsertMem)
  166.  pop de
  167.  ld hl,(avartemp)
  168.  push hl
  169.  ld a,(hl)
  170.  inc hl
  171.  ld h,(hl)
  172.  ld L,a
  173.  add hl,de
  174.  ex de,hl
  175.  pop hl
  176.  ld (hl),e
  177.  inc hl
  178.  ld (hl),d
  179.  ld de,(avarpos)
  180.  ld hl,ourkey
  181.  ld bc,10
  182.  ldir
  183.  ld a,$0A
  184.  ld (de),a
  185.  inc de
  186.  ld (avarpos),de
  187.  ret
  188.  
  189. makeappvar:
  190.  ld hl,myappvar
  191.  rst 20h
  192.  bcall(_ChkFindSym)
  193.  jr c,_
  194.  bcall(_DelVarArc)
  195. _:
  196.  ld hl,myappvar
  197.  rst 20h
  198.  ld hl,0
  199.  bcall(_CreateAppvar) ;out: DE=filesize location
  200.  ld (avartemp),de
  201.  inc de
  202.  inc de
  203.  ld (avarpos),de
  204.  ret
  205.  
  206. updateresumestate:
  207.  call getresumefile
  208.  ld hl,Ourkey
  209.  ld bc,10
  210.  ldir
  211.  ld hl,myappvar
  212.  ld bc,10
  213.  ldir
  214.  ret
  215.  
  216. getresumefile:
  217.  ld hl,myappvarresume
  218.  rst 20h
  219.  bcall(_chkfindsym)
  220.  jr nc,_
  221.  ld hl,20
  222.  bcall(_createappvar)
  223.  inc de
  224.  inc de
  225.  xor a
  226.  ld (de),a  ;indicate that the file is empty
  227.  jr getresumefile
  228. _:
  229.  ld a,b
  230.  or a
  231.  jr z,_
  232.  bcall(_Arc_Unarc)
  233.  jr getresumefile
  234. _:
  235.  inc de
  236.  inc de
  237.  ret
  238.  
  239. CalcSerial:
  240. .db $0A,$3D,$A5,$8D,$B0
  241. itemp1:
  242. .dw 0
  243. itemp2:
  244. .dw 0
  245. itemp3:
  246. .dw 0
  247.  
  248. avartemp:
  249. .dw 0
  250. avarpos:
  251. .dw 0
  252.  
  253.  
  254.  
  255. KeyOutput:
  256. ;    1234567890123456
  257. .db "Factor saved to ",0
  258. myappvar:
  259. .db $15,"KDBZ0005",0
  260. KeyDrive:
  261. .db "Factor found was",0
  262.  
  263.  
  264. OurKey:
  265. ;    0123456789
  266. .db "2822211869",0
  267.  
  268. myappvarresume:
  269. .db $15,"KDBRESUM",0
  270.  
  271. battstate:
  272. .db "Battery Level:",0
  273.  
  274. .echo "Utility File Size: ",$-ProgramStart," bytes."
Advertisement
Add Comment
Please, Sign In to add comment