home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 86 / asm / source / ascii.asm < prev    next >
Encoding:
Assembly Source File  |  2001-07-01  |  11.4 KB  |  371 lines

  1. ;------------------------------------------
  2. ;ASCII Finder 1.1
  3. ;by Andreas Finne
  4. ;a_finne@hotmail.com
  5. ;Copyright (C) 1998
  6. ;
  7. ;I have tried to comment everything.
  8. ;If you use anything from this source,
  9. ;please give me and anyone else who
  10. ;I credited in this source some credit.
  11. ;If you have any ideas, suggestions, comments
  12. ;or questions please e-mail me.
  13. ;Please don't change anything in this source.
  14. ;------------------------------------------
  15.  
  16. #include "asm86.h"
  17. #include "ti86asm.inc"
  18.  
  19. .org _asm_exec_ram
  20.  
  21. ;------------------AShell / Rascall Description-------------------------
  22.     nop         ;Identifies the table
  23.     jp Start            ;Since it must be jp you can as well
  24. .dw $0000   ;Version # of Table        ;take advantage of it
  25. .dw Title   ;Absolute pointer to program description
  26.  
  27.                     ;These are here so I can use as many
  28.                     ;jr's as possible. (jr's are 1 byte smaller than jp's)
  29.  
  30. IncOne:                    ;Routine to increase to the next ascii number
  31.     ld a,(Nyt)            ;Load current ascii number into a
  32.     cp 236                ;Is it 236 (maximum)?
  33.     jr z,KeyLoop            ;If so, jump to check keys again
  34.     inc a                ;Otherwise, increase a
  35.     ld (Nyt),a            ;Load the new ascii number into variable
  36.     jr DispEveryth            ;Put everything out on the screen
  37.  
  38. DecOne:                    ;Routine to decrease to the previous ascii number
  39.     ld a,(Nyt)            ;Load current ascii number into a
  40.     dec a                ;Decrease it
  41.     or a                ;Did it become zero?
  42.     jr z,KeyLoop            ;If so, jump to check keys again
  43.     ld (Nyt),a            ;Otherwise, load new ascii number into variable
  44.     jr DispEveryth            ;Put everything out on the screen
  45.  
  46. IncTen:                    ;Routine to increase ascii number with ten
  47.     ld a,(Nyt)            ;Load current ascii number into a
  48.     cp 227                ;Compare to 227 (9 from maximum)
  49.     call nc,Max            ;If number >= 227 call routine to make it maximum
  50.     add a,10            ;Add 10 to a
  51.     ld (Nyt),a            ;Load new ascii number into variable
  52.     jr DispEveryth            ;Put everything out on the screen
  53.     
  54. DecTen:                    ;Routine to decrease ascii number with ten
  55.     ld a,(Nyt)            ;Load current ascii number into a
  56.     cp 11                ;Compare to 11 (10 from minimum)
  57.     call c,Min            ;If number < 11 call routine to make it minimum
  58.     sub 10                ;Subtract 10 from a
  59.     ld (Nyt),a            ;Load new ascii number into variable
  60.     jr DispEveryth            ;Put everything out on the screen
  61.  
  62. Start:                        ;This is where it all begins
  63.     call _runindicoff        ;Turn off that little thing
  64.     call _flushallmenus        ;Remove all visible menus
  65.     call EmptyUndel            ;Call routine to empty the undel. mem.
  66.     ld a,1                ;Load 1 into a (minimum value)
  67.     ld (Nyt),a            ;Load a into variable
  68.     call ScreenSetup        ;Call routine to put title and other text
  69.  
  70. KeyLoop:                    ;Routine to wait for a key
  71.     call _getkey            ;Call a ROM routine that waits for a key to be pressed
  72.     cp kRight            ;A key has been pressed. Is it RIGHT?
  73.     jr z,IncOne            ;If so, jump to the routine to increase number by 1
  74.     cp kLeft            ;Is it LEFT?
  75.     jr z,DecOne            ;If so, jump to the routine to decrease number by 1
  76.     cp kUp                ;Is it UP?
  77.     jr z,IncTen            ;If so, jump to the routine to increase number by 10
  78.     cp kDown            ;Is it DOWN?
  79.     jr z,DecTen            ;If so, jump to the routine to decrease number by 10
  80.     cp kExit            ;Is it EXIT?
  81.     jr z,Quit            ;Then jump to exit routine
  82.     cp kNext            ;Is it MORE?
  83.     jp z,View            ;Then display the contents of the undel. mem.
  84.     cp kF1                ;Is it F1?
  85.     jr z,Help             ;Then jump to help
  86.     cp kEnter            ;Is it ENTER?
  87.     jp z,CopyChar            ;Then copy the current character to undel. mem.
  88.     cp kClear            ;Is it CLEAR?
  89.     jp z,Clear            ;Then clear the undel. mem.
  90.     jr KeyLoop            ;None of these keys were pressed, check for keys again
  91.     
  92. DispEveryth:                ;Routine to display current ascii number and char
  93.     ld hl,$0901            ;Loads $09 into h and $01 into l
  94.     ld (_curRow),hl            ;Loads $01 into _curRow and $09 into _curCol
  95.     ld hl,Empty            ;Point hl to the text
  96.     call _puts            ;Put it out
  97.     ld hl,$0803            ;Same thing here
  98.     ld (_curRow),hl            ;This is done to get rid of the old ascii number
  99.     ld hl,Empty            ;
  100.     call _puts            ;
  101.     ld hl,10*256+48            ;This is a little trick
  102.     ld (_penCol),hl            ;Loads 10 into _penRow and 48 into _penCol
  103.     ld a,(Nyt)            ;Ascii number into a
  104.     call DispA            ;Routine to display a @ _penCol,_penRow
  105.     ld hl,$0703            ;
  106.     ld (_curRow),hl            ;Coordinates into _curRow and _curCol
  107.     ld a,(Nyt)            ;Ascii number into a
  108.     call _putmap            ;ROM routine to display the char loaded into a
  109.     cp 32                ;If the number is 32 (Space)
  110.     jr z,Space            ;Then print 'space'
  111.     cp 214                ;Is it 214 (Enter)
  112.     jr nz,KeyLoop            ;If not, check keys again
  113.     ld hl,24*256+50            ;Number was 214
  114.     ld (_penCol),hl            ;24 into _penRow and 50 into _penCol
  115.     ld hl,EnterTxt            ;Point hl to the text
  116.     call _vputs            ;Put it out @ _penCol,_penRow in the small font
  117.     jr KeyLoop            ;Check keys again
  118.  
  119. Space:                    ;Ascii number was 32
  120.     ld hl,24*256+50            ;
  121.     ld (_penCol),hl            ;24 into _penRow and 50 into _penCol
  122.     ld hl,SpaceTxt            ;Point hl to the text
  123.     call _vputs            ;Put it out
  124.     jp KeyLoop            ;Check keys again
  125.  
  126. Quit:                    ;Exit routine
  127.     call _clrScrn            ;If I use _clrLCD, everything isn't cleared
  128.     call _homeup            ;Cursor into top left corner
  129.     ret                ;Return from program
  130.  
  131. Help:                    ;Display the help text
  132.     call CEETAA            ;Clear Everything Except Title And Author :)
  133.     ld hl,17*256+1            ;
  134.     ld (_penCol),hl            ;Display text
  135.     ld hl,ClearTxt            ;
  136.     call _vputs            ;
  137.     ld bc,24*256+1            ;I use bc instead of hl, because hl already points
  138.     ld (_penCol),bc            ;to the next text to print
  139.     ;ld hl,CopyTxt            ;HL already points to text, that's why it's commented out
  140.     call _vputs            ;    
  141.     ld bc,31*256+1            ;
  142.     ld (_penCol),bc            ;
  143.     ;ld hl,ViewTxt            ;HL points here already
  144.     call _vputs            ;
  145.     ld bc,38*256+1            ;
  146.     ld (_penCol),bc            ;
  147.     ;ld hl,QuitTxt            ;
  148.     call _vputs            ;
  149.     call _getkey            ;Wait for a keypress
  150.     call ScreenSetup        ;Reprint everything on the previous screen
  151.     jp KeyLoop            ;Check keys again
  152.  
  153. CopyChar:                ;Routine to copy char to undel. mem.
  154.     ld hl,$C012            ;$C012 contains the length of the undel. buffer
  155.     ld a,(hl)            ;Load a with length
  156.     cp 84                ;Is it 84 (maximum)?
  157.     jp z,KeyLoop            ;If so, don't copy any more, check keys again
  158.     inc a                ;Otherwise, increase a
  159.     ld (hl),a            ;Load new length into $C012
  160.     ld hl,(Current)            ;Load current address into hl
  161.     inc hl                ;Increase it
  162.     ld (Current),hl            ;Load new address into current
  163.     ld a,(Nyt)            ;Load ascii number into a
  164.     ld (hl),a            ;Load it in at the new address
  165.     jp KeyLoop            ;Check keys again
  166.  
  167. View:                    ;Displays the contents of undel. mem.
  168.     call CEETAA             ; :)
  169.     ld hl,$0815            ;
  170.     ld (_penCol),hl            ;Display text
  171.     ld hl,ContentsTxt        ;
  172.     call _vputs            ;
  173.     ld a,($C012)            ;Load length into a
  174.     or a                ;Set flag if zero
  175.     jr z,EmptyMem            ;If zero flag is set then the mem is empty
  176.     ld hl,$0002            ;Begin to print it at 0,2
  177.     ld (_curRow),hl            ;
  178.     ld b,a                ;A was the length of the buffer, now b also contains it
  179.     ld hl,$C013            ;$C013 is the address of the first char of the undel mem
  180. ViewLoop:
  181.     ld a,(hl)            ;Load a with the char hl points to
  182.     call _putc            ;Put it out at _curCol,_curRow and advance cursor
  183.     inc hl                ;Increase hl so it points to the next char
  184.     djnz ViewLoop            ;Decrease b, if not zero, jump to ViewLoop
  185.     call _getkey            ;Wait for a keypress
  186.     call ScreenSetup        ;Reprint everything on the previous screen
  187.     jp KeyLoop            ;Check keys again
  188.  
  189. Clear:                    ;Clear the undel mem
  190.     call CEETAA            ;
  191.     ld hl,$0B01            ;
  192.     ld (_penCol),hl            ;
  193.     ld hl,ClearQTxt            ;Print text
  194.     call _vputs            ;
  195.     ld bc,$0404            ;I use bc because hl points to the next text
  196.     ld (_curRow),bc            ;
  197.     ;ld hl,Yes            ;
  198.     call _puts            ;Put it out
  199.     ld a,$0D            ;
  200.     ld (_curCol),a            ;New X-Coord for text
  201.     ;ld hl,No            ;
  202.     call _puts            ;Put it out
  203. ClearLoop:
  204.     call _getkey            ;Wait for a key to be pressed
  205.     cp kDown            ;Is it DOWN?
  206.     jr z,GoBack            ;If so then don't clear the undel mem
  207.     cp kUp                ;Check if it is UP
  208.     jr nz,ClearLoop            ;If not, jump to ClearLoop
  209.     call EmptyUndel            ;Routine to empty undel mem
  210.     call CEETAA            ;
  211. EmptyMem:
  212.     ld hl,$0804            ;
  213.     ld (_curRow),hl            ;
  214.     ld hl,EmptyTxt            ;Displays the text 'Empty!'
  215.     call _puts            ;
  216.     call _getkey            ;Wait for a keypress
  217. GoBack:
  218.     call ScreenSetup        ;Reprint everything on the previous screen
  219.     jp KeyLoop            ;Check keys
  220.         
  221. Max:                    ;Sets a to max-10
  222.     ld a,226            ;226 into a
  223.     ld (Nyt),a            ;Load a into variable
  224.     ret                ;Return from call
  225. Min:                    ;Sets a to min+10
  226.     ld a,11                ;11 into a
  227.     ld (Nyt),a            ;Load a into variable
  228.     ret                ;Return from call
  229.  
  230. CEETAA:                 ;Clear Everything Except Title And Author :)
  231.     ld hl,$FCA0            ;Address to clear pixel before the ones to be cleared
  232.     ld de,$FCA0+1            ;Next pixel
  233.     ld bc,$025F                ;607 pixels to be cleared
  234.     ldir                ;ld (de),(hl)/inc de/inc hl, bc times
  235.     ret                ;Return from call
  236.  
  237. ScreenSetup:
  238.     call _clrLCD            ;Clear the screen
  239.     set textInverse,(iy+textflags)    ;White text on black
  240.     ld hl,$0000            ;
  241.     ld (_curRow),hl            ;
  242.     ld hl,Empty            ;
  243.     call _puts            ;
  244.     ld a,$10            ;
  245.     ld (_curCol),a            ;
  246.     ld hl,Empty            ;
  247.     call _puts            ;Display text
  248.     ld bc,$0200            ;
  249.     ld (_curRow),bc            ;
  250.     ;ld hl,Title            ;
  251.     call _puts            ;
  252.     ld bc,$0005            ;
  253.     ld (_curRow),bc            ;
  254.     ;ld hl,ChooseTxt        ;
  255.     call _puts            ;    
  256.     res textInverse,(iy+textflags)    ;Back to normal mode (black on white)
  257.     ld bc,10*256+1
  258.     ld (_penCol),bc
  259.     ;ld hl,Text
  260.     call _vputs
  261.     ld bc,24*256+1
  262.     ld (_penCol),bc
  263.     ;ld hl,Chartxt
  264.     call _vputs
  265.     ld bc,32*256+1
  266.     ld (_penCol),bc
  267.     ;ld hl,HelpTxt
  268.     call _vputs            ;More text
  269.     ld bc,51*256+27
  270.     ld (_penCol),bc
  271.     ;ld hl,Author
  272.     call _vputs
  273.     ld bc,57*256+27
  274.     ld (_penCol),bc
  275.     ;ld hl,Email
  276.     call _vputs
  277.     ld hl,$0703
  278.     ld (_curRow),hl
  279.     ld a,(Nyt)            ;Load a with the ascii number
  280.     call _putc            ;Put it out
  281.     ld hl,10*256+48
  282.     ld (_penCol),hl
  283.     ;ld a,(Nyt)
  284.     call DispA            ;Also display the number
  285.     ret
  286.  
  287.  
  288. DispA:                                  ;Routine to Display A [By: Matthew Shepcar]
  289.  ld l,a                                 ;Loads a into l
  290.  ld h,0                                 ;0 into H
  291. DispHL:                                 ;Displays HL [By: Matthew Shepcar]
  292.  xor a                                  ;Loads 0 into A
  293.  ld de,-1                               ;Loads -1 into DE
  294.  ld (_curRow),de                        ;Loads de into CurRow
  295.  call 4A33h                             ;Calls 4A33h
  296.  dec hl                                 ;Decrease it
  297.  jp _vputs                              ;Put on screen and return
  298.  
  299. EmptyUndel:                ;Routine to empty the undel mem
  300.     ld hl,$C012            ;Point hl to $C012 (length of undel buffer)
  301.     ld (Current),hl            ;Load that address into current
  302.     xor a                ;Same as ld a,0
  303.     ld (hl),a            ;Load that into length
  304.     ret                ;Return from call
  305.  
  306. ;****** Start of text ******
  307. ;The texts must be in this order
  308. ;or else hl points to the wrong text
  309.  
  310. Empty:
  311.     .db "     ",0
  312.  
  313. Title:
  314.     .db "ASCII Finder 1.1",0
  315.  
  316. ChooseTxt:
  317.     .db " ",207,5," +/- 1"
  318.     .db "  ",6,7," +/- 10 ",0
  319.  
  320. Text:
  321.     .db "ASCII Number:",0
  322.  
  323. Chartxt:
  324.     .db "Character:",0
  325.  
  326. HelpTxt:
  327.     .db "Press F1 for help!",0
  328.  
  329. Author:
  330.     .db "Made by Andreas Finne",0
  331. Email:
  332.     .db "a_finne@hotmail.com",0
  333.  
  334. SpaceTxt:
  335.     .db "<SPACE>",0
  336.  
  337. EnterTxt:
  338.     .db "<ENTER>",0
  339.  
  340. ContentsTxt:
  341.     .db "Contents of undel. mem:",0
  342.  
  343. ClearTxt:
  344.     .db "Clear: Clear undel. mem",0
  345.  
  346. CopyTxt:
  347.     .db "Enter: Copy character to"
  348.     .db " undel. mem",0
  349. ViewTxt:
  350.     .db "More: View contents of"
  351.     .db " undel. mem",0
  352.  
  353. QuitTxt:
  354.     .db "Exit: Quit",0
  355.  
  356. ClearQTxt:
  357.     .db "Do you want"
  358.     .db " to clear the undel. mem?",0
  359. Yes:    .db 6," Yes",0
  360. No:     .db 7," No",0
  361.  
  362. EmptyTxt:
  363.     .db "Empty!",0
  364.  
  365. Current:            ;Holds the address of current place to copy into
  366.     .dw $0000
  367. Nyt:                ;Contains the ascii number
  368.     .db 0
  369.  
  370. .end
  371.