home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 82 / asm / source / os-82 / resist.asm < prev   
Encoding:
Assembly Source File  |  2001-07-01  |  4.0 KB  |  143 lines

  1. ;-----------------------------------------------------------
  2. ;
  3. ;                  RESISTOR COLORS v1.0 (OShell)
  4. ;                       BY RAVON/INFINITY
  5. ;
  6. ; Have you ever tried to make a circuit of something and you
  7. ; just neeeeeed that little resistor, even though you didn't
  8. ; pay any attention on the Electronic lessions? You just don't
  9. ; know what color that is what number on those pesky little things.
  10. ;
  11. ; This is a REALLY simple, yet quite useful, program that gives
  12. ; us that valuable (?) information.
  13. ;
  14. ;
  15. ;                                 ravon@kurir.net
  16. ;                                 http://consolemidis.home.ml.org
  17. ;
  18. ;-----------------------------------------------------------
  19.  
  20.  
  21. #INCLUDE "TI-82.h"
  22. .org 0
  23. .db "Resistor Codes",0
  24.  
  25. init:
  26.         ROM_CALL(CLEARLCD)       ;Clear the LCD display
  27.         ld   DE,(PROGRAM_ADDR)   ;Load our program's start location into DE
  28.         ld   c,0
  29.  
  30.  ;--------------
  31.  ; Display the
  32.  ; title
  33.  ;--------------
  34.         set  3,(IY+05)           ;White text on black background;
  35.         ld   HL,$0000            ;The title will be at X=0 and Y=0
  36.         ld   ($800C),HL
  37.         ld   HL,diz              ;Point HL at the 'diz'-text
  38.         add  HL,DE               ;Add the program's start location
  39.         ROM_CALL(D_ZT_STR)       ;Show it
  40.  
  41.         res  3,(IY+05)           ;Black text...
  42.  
  43.  
  44.  ;-------------------------
  45.  ; I want to save space...
  46.  ; By putting this function
  47.  ; up here I save both a
  48.  ; JP REDRAW and a RET
  49.  ;
  50.  ; This function checks how
  51.  ; many rows you have scrolled 
  52.  ;-------------------------
  53. redraw:
  54.         ld   HL,$0001            ;X=0   Y=1
  55.         ld   ($800C),HL
  56.  
  57.         push DE                  ;Put DE on the stack for later usage
  58.         ld   HL,codes            ;Point HL at all the color codes
  59.         add  HL,DE               
  60.         ld   b,c
  61.         ld   a,c                 ;If c=0 (the "cursor" is on top of
  62.         cp   0                   ;the text) then don't perform a
  63.         jr   z,noadd             ;"scroll" (eh...)
  64.                  
  65.         ld   DE,16               ;We want to skip 16 letters (one row)
  66. addloop:
  67.         add  HL,DE
  68.         djnz addloop             ;Loop while b>0
  69. noadd:
  70.         pop  DE                  ;Get DE from the stack
  71.         ROM_CALL(D_ZT_STR)       ;View the zero terminated string
  72.  
  73.  
  74.  
  75. loop:
  76.  ;------------------------
  77.  ; KEYBOARD ROUTINE
  78.  ; TAKEN FROM PONG 1.3.
  79.  ; BY SCOOBIE
  80.  ;------------------------
  81.         sub   a
  82.         out   (1),A
  83.         in    A,(1)
  84.         xor   255
  85.         or    A
  86.         jr    z,loop
  87.  
  88.         bit   6,A
  89.         jr    nz,end
  90.         bit   3,A
  91.         jr    nz,up
  92.         bit   0,A
  93.         jr    nz,down
  94.  
  95.         jr   loop
  96.  
  97.  
  98. end:
  99.         RET                      ;Return to OShell
  100.  
  101. down:
  102.         ld   a,c                 
  103.         cp   10                  ;Check if we have scrolled 10 lines
  104.         jr   z,loop              ;... if not...
  105.         inc  c                   ;Then add one line to C
  106.         jr   redraw              ;And redraw the text
  107. up:
  108.         ld   a,c                 ;Check if we are at the beginning
  109.         cp   0                   ;of the text
  110.         jr   z,loop              ;... if not...
  111.         dec  c                   ;Decrease one line from C
  112.         jr   redraw              ;Redraw it...
  113.  
  114.  
  115.  ;-------------
  116.  ; THE CODES
  117.  ;-------------
  118. codes .db "Black          0"
  119.       .db "Brown          1"
  120.       .db "Red            2"
  121.       .db "Orange         3"
  122.       .db "Yellow         4"
  123.       .db "Green          5"
  124.       .db "Blue           6"
  125.       .db "Purple         7"
  126.       .db "Grey           8"
  127.       .db "White          9"
  128.       .db "                "
  129.       .db "   Tolerance    "
  130.       .db "                "
  131.       .db "Brown     +-  1%"
  132.       .db "Red       +-  2%"
  133.       .db "Gold      +-  5%"
  134.       .db "Silver    +- 10%",0
  135.  
  136.  ;---------------
  137.  ; TITLE.......
  138.  ;---------------
  139. diz   .db "Color     Number",0
  140.  
  141.  
  142. .END
  143.