Advertisement
technomonkey76

^^vv<><>BA Version 2

Jun 4th, 2011
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .nolist                 ; Obvious
  2. #include "ti83plus.inc"         ; stuff
  3. #include "dcs7.inc"         ; needed
  4. .list                   ; for
  5. .org $9D93              ; every
  6. .db t2ByteTok,tAsmCmp           ; program
  7.  
  8. ; Hooray for my first useful assembly program!!!
  9.  
  10.  
  11.  
  12. ; |-----------------|
  13. ; | All code within |
  14. ; |  the Off label  | The portion of the code used is not meant to be power-efficient... it's not.
  15. ; | thanks to KermM | It WILL drain the batteries!  It was intended for temporary power-off ONLY.
  16. ; |   of Cemetech   |
  17. ; |-----------------|
  18.  
  19. ; Array-based optimization provided by Tanner of Cemetech
  20.  
  21.  
  22.  
  23. _GetKeyRetOff   .equ    $500B       ; GetKeyRetOff B_CALL not defined in ti83plus.inc
  24.  
  25. Start:
  26.     ld hl,CodeArray         ; Put keys to press in memory
  27.  
  28. KeyLoop:
  29.     ld c,0              ; Ensure error level counter is reset to 0
  30.     push hl             ; Keep array in memory
  31.     bcall(_GetKeyRetOff)        ; Prevent NORMAL off on press of On key (would cause RAM leaks, etc.)
  32.     pop hl              ; Recall array to memory
  33.     cp (hl)             ; See if keypress represents currently needed key
  34.     jr z,Correct            ; If correct, jump to Correct* label to set needed values
  35.     call nz,ErrorLevelUp        ; Set error level (register c) to 1 if not correct
  36.     cp kClear           ; Check if key was Clear
  37.     call z,Off          ; If so, use the special Off function
  38.     call nz,ErrorLevelUp        ; If not, set error level to 2
  39.     cp kOff             ; Verify if user pressed [2nd]-[On]
  40.     call z,Off          ; If so, suspend the calc (special Off)
  41.     call nz,ErrorLevelUp        ; If no appropriate key was pressed, set error level to 3
  42.     ld a,3              ; Set new temp value for register a
  43.     cp c                ; Check if error level was 3
  44.     jr z,ErrorInit          ; If error level WAS 3, wait for 7 keypresses before resume.
  45.     jr KeyLoop          ; Return to beginning of loop
  46.  
  47. ErrorInit:
  48.     ld b,7              ; Reset register b (error countdown) to 7
  49.     push hl             ; Preserve pointer to array
  50. Error:
  51.     bcall(_GetKey)          ; Wait for a keypress
  52.     djnz Error          ; Repeat until b=0, decrementing b each time
  53. ErrorEnd:
  54.     pop hl              ; Restore pointer to array
  55.     jr Start            ; Reset values and enter loop again
  56.  
  57. Correct:
  58.     inc hl              ; Make hl point to next element in array
  59.     ld b,(hl)           ; Make register b equal to next element
  60.     xor a               ; Set a to 0
  61.     cp b                ; If b=0 (b=a)...
  62.     jr z,Done           ; End program
  63.     jr KeyLoop          ; Otherwise, go back to loop
  64.  
  65. Done:
  66.     bcall(_ClrLCDFull)      ; Clear the screen
  67.     bcall(_HomeUp)          ; Prepare homescreen
  68.     xor a               ; Set register a to 0
  69.     ld (curRow),a           ; Set the starting row to the first one
  70.     ld a,1              ; Set register a to 1
  71.     ld (curCol),a           ; Set the starting column to the second one
  72.     ld hl,CorrectMsg        ; Put the text in the proper register
  73.     bcall(_PutS)            ; Display the text
  74.     res 7,(iy+28h)          ; Allow normal off with no tricks
  75.     ret             ; Terminate
  76.  
  77. Off:
  78.     ld a,2
  79.     out ($10),a         ;turn off screen
  80.     res OnInterrupt,(iy+OnFlags)
  81.     call debounceon
  82.     im 1                ;TI-OS default interrupt
  83.     ei              ;enable interrupts
  84.     ld  a,1         ;enable ONLY [ON] key, no linkport wake
  85.     out (3),a
  86.     halt
  87.     di
  88.     res OnInterrupt,(iy+OnFlags)
  89.     ld a,3
  90.     out ($10),a         ;turn on screen
  91. debounceon:
  92.     ld b,16
  93. debounceoninner:
  94.     in a,(4)
  95.     bit 3,a
  96.     jr z,debounceon
  97.     djnz debounceoninner
  98.     ret             ; Exit subroutine
  99.  
  100. ErrorLevelUp:
  101.     inc c               ; Add 1 to register c's value
  102.     ret             ; Exit subroutine
  103.  
  104.  
  105. CorrectMsg:
  106.     .db "Access Granted!",0     ; Message to display before terminated
  107. CodeArray:
  108.     .db kUp, kUp, kDown, kDown, kLeft, kRight, kLeft, kRight, kCapB, kCapA, 0   ; Keys to press, in order, zero-terminated.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement