home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 92plus / asm / source / textes.asm < prev   
Encoding:
Assembly Source File  |  2001-07-01  |  8.8 KB  |  254 lines

  1.     include    "FLIB.H"
  2.     include    "GRAPHLIB.H"
  3.     include    "HEXLIB.H"
  4.     include    "TIOS.H"
  5.     xdef    _main
  6.     xdef    _comment
  7.  
  8. ;-------------------------------------------------------------
  9. ;             TEXT TESTER V1.0
  10. ; Program made by VIVES Fabien
  11. ; EMail : vives@univ-aix.fr
  12. ; For Further informations see the file README.TXT
  13. ;-------------------------------------------------------------
  14. ; Program made with Fargo Program Editor v2.0
  15. ; Benoit SCHERRER - p.c.scherrer@wanadoo.fr
  16. ;-------------------------------------------------------------
  17. ;************************** MACRO ****************************
  18.  
  19. WriteStr MACRO                ; Syntax : x/y/Color/String
  20.     move.w \3,-(a7)            ;we put the color in the Stack.
  21.     pea \4(pc)            ;we put the String to Display in the Stack.
  22.     move.w \2,-(a7)            ;we put the Y-coordinate in the Stack.    
  23.     move.w \1,-(a7)            ;we put the X-coordinate in the Stack.    
  24.     jsr tios::DrawStrXY        ;we call the subroutine in TIOS.
  25.     lea 10(a7),a7            ;we restore the Stack of 10 = 2+4+2+2
  26.     ENDM
  27.  
  28. ;***************** Start of FARGO II Program ******************
  29.  
  30. _main:
  31.     movem.l d0-d2/a0-a1,-(a7)    ;we save the registers we're going to modify.
  32.     move.w #0,cmptr            ;initialisation of " cmptr ".
  33.     jsr flib::clr_scr        ;we clear the screen.
  34.     move.w #0,-(a7)            ;we put the Font 0 in the Text.( smallest Font ).
  35.     jsr tios::FontSetSys        ;we call the subroutine in TIOS.
  36.     lea 2(a7),a7            ;we take the stack back of 2.
  37.     WriteStr #0,#0,#1,intro        ;we display " intro ".
  38.     lea phrase(pc),a1        ;A1 points at var " phrase ".
  39.     clr.l (a1)            ;we clear the longword which A1 points at.
  40.     add.w #4,a1            ;we add 4 bytes at A1.
  41.     clr.l (a1)            ;we clear the longword which A1 points at. Now we are
  42.                     ;sure that var " phrase " is entirely cleared.
  43.     sub.w #4,a1            ;A1 points at " phrase ".
  44.     move.w #2,-(a7)            ;we put the Font 2 in the Stack.
  45.     jsr tios::FontSetSys
  46.     lea 2(a7),a7            ;we restore the Stack of 2.
  47.  
  48. ;NOW WE'RE GOING TO DISPLAY THE LETTERS AS SOON AS THEY ARE PRESSED, AND WE
  49. ;STORE IT IN THE VAR " PHRASE ".
  50.  
  51. saisie:
  52.     jsr flib::idle_loop        ;this subroutine waits for the user to press a key.
  53.                     ;it returns the ASCII value of the key.
  54.  
  55.     cmp.w #13,d0            ;is it ENTER ?
  56.     beq finsaisie            ;if it is go to " finsaisie ".
  57.     cmp.w #257,d0            ;is it BACKSPACE ?
  58.     beq backspce            ;if it is go to " backspce".
  59.     add.w #1,cmptr            ;we add 1 to the counter. This counter limits the 
  60.                     ;number of letters of the word to 8.
  61.     cmp.w #9,cmptr
  62.     beq retour            ;if the counter equal 9 then go to " retour ".
  63.  
  64.     move.b d0,(a1)+            ;we put the letter where A1 points at i.e. in the
  65.                     ;var " phrase " and we add 1 Byte to A1.
  66.  
  67.     WriteStr #10,#10,#1,phrase    ;we display var " phrase ". I do not take time to erase
  68.                     ;the screen. We write above. I mean, if there was 
  69.                     ;already the word  " tr " displayed, and I press the key
  70.                     ; " y ". Then we display the word " try " above " tr ".
  71.  
  72.     bra saisie            ;we go back to " saisie " to pursue the entering of the
  73.                     ;word.
  74.  
  75. retour:
  76.     sub.w #1,cmptr            ;we substract 1 to " cmptr " because before we added 1.
  77.                     ;we are in " retour " because we have reached the limit
  78.                     ;of 8 letters for the word. While the user doesn't press 
  79.                     ;ENTER to end, or BACKSPACE to erase a letter, we go 
  80.                     ;there. 
  81.  
  82.     bra saisie            ;go back to " saisie ".
  83.  
  84. backspce:
  85.     cmp.w #0,cmptr            ;we check if there is at least one letter to erase.If there
  86.                     ;isn't, " cmptr " at 0.
  87.  
  88.     beq saisie            ; cmptr=0 ? so go back at " saisie ".
  89.     sub.w #1,cmptr            ;we erase a letter, so we have to substract 1 to " cmptr ".
  90.     WriteStr #10,#10,#2,phrase       ;I don't want to clear ALL the screen, so we just erase
  91.                     ;the phrase. For this, we rewrite the var " phrase " with
  92.                     ;the color 2.
  93.     move.b #0,-(a1)            ;we substract 1 Byte to A1, and we put 0 where A1 points
  94.                     ;to.
  95.     WriteStr #10,#10,#1,phrase       ;we display the var " phrase ".
  96.     bra saisie
  97.  
  98. finsaisie:
  99.     move.w #0,ancfont    ;initialisation of the  var " ancfont ".
  100.     move.w #50,Posx        ;------------------------------------- " Posx ".
  101.     move.w #50,Posy        ;------------------------------------- " Posy ".
  102.     move.w #1,color        ;------------------------------------- " color ".
  103.  
  104. boucle1:
  105.     jsr flib::clr_scr                ;we clear the screen.
  106.     WriteStr Posx,Posy,color,phrase            ;we display the var " phrase ".
  107.  
  108. boucle2:
  109.     jsr flib::idle_loop    ;we wait for a letter to be pressed.
  110.     cmp.w #264,d0        ; ESC ?
  111.     beq fini
  112.     cmp.w #268,d0        ; F1 ?
  113.     beq Fct1
  114.     cmp.w #269,d0        ; F2 ?
  115.     beq Fct2
  116.     cmp.w #270,d0        ; F3 ?
  117.     beq Fct3
  118.     cmp.w #271,d0        ; F4 ?
  119.     beq Fct4
  120.     cmp.w #272,d0        ; F5 ?
  121.     beq Fct5
  122.     cmp.w #337,d0        ; CURSOR TO THE LEFT ?
  123.     beq gauche
  124.     cmp.w #338,d0        ; CURSOR TO THE TOP ?
  125.     beq haut
  126.     cmp.w #340,d0        ; CURSOR TO THE RIGHT ?
  127.     beq droite
  128.     cmp.w #344,d0        ; CURSOR TO THE BOTTOM ?
  129.     beq bas
  130.     cmp.w #273,d0        ; F6 ?
  131.     beq Fct6
  132.     cmp.w #13,d0        ; ENTER ?
  133.     beq Enter
  134.     bra boucle2
  135.  
  136. haut:
  137.     cmp.w #0,Posy        ;we check if we are at the top of the screen.
  138.     beq boucle2        ;if yes, we go back to " boucle2 ".
  139.     sub.w #1,Posy    
  140.     bra boucle1
  141. bas:
  142.     cmp.w #127,Posy        ;are we at the bottom of the screen ?
  143.     beq boucle2
  144.     add.w #1,Posy
  145.     bra boucle1
  146. gauche:
  147.     cmp.w #0,Posx        ;are we at the left border of the screen ?
  148.     beq boucle2
  149.     sub.w #1,Posx
  150.     bra boucle1
  151. droite:
  152.     cmp.w #239,Posx        ;are we at the right border of the screen ?
  153.     beq boucle2
  154.     add.w #1,Posx
  155.     bra boucle1
  156. Enter:
  157.     clr.l d0
  158.     move.w #2,-(a7)            ;we put the Font 2 in the Stack.
  159.     jsr tios::FontSetSys        ;We set system's Font. This subroutine returns in D0
  160.                     ;the value of the Font before we change.
  161.     lea 2(a7),a7            ;we restore the Stack of 2.
  162.     move.w d0,ancfont        ;we save the ancient Font in " ancfont ".
  163.     jsr flib::clr_scr        
  164.     WriteStr #40,#50,#1,infos    ;we display the text " infos ".
  165.     move.w Posx,d0            ;we put in D0 the number we want to convert in a 
  166.                     ;decimal String.
  167.     moveq #3,d1            ;we put in D1 the size of the number. Here 3 digits.
  168.     lea strbuf(pc),a0        ;we load in A0 where is the var " strbuf ".
  169.     bsr ConvStr            ;we go to the Convert Routine.
  170.     WriteStr #60,#60,#1,strbuf    ;we display the result.
  171.     move.w Posy,d0            ;Same thing as above for Posy.
  172.     moveq #3,d1
  173.     lea strbuf(pc),a0
  174.     bsr ConvStr
  175.     WriteStr #90,#60,#1,strbuf
  176.     jsr flib::idle_loop        ;we wait for a key to be pressed.
  177.     move.w ancfont,-(a7)        ;we load the Font we had before.
  178.     jsr tios::FontSetSys
  179.     lea 2(a7),a7
  180.     bra boucle1
  181.  
  182. Fct1:
  183.     move.w #0,-(a7)        ;we put the Font 0 in the Stack.
  184.     bra suite
  185. Fct2:
  186.     move.w #1,-(a7)        ;we put the Font 1 in the Stack.
  187.     bra suite
  188. Fct3:
  189.     move.w #2,-(a7)        ;we put the Font 2 in the Stack.
  190.     bra suite
  191. Fct4:
  192.     move.w #0,color        ;we put the color 0 in var " color ".
  193.     bra boucle1
  194. Fct5:
  195.     move.w #1,color        ;we put the color 1 in var " color ".
  196.     bra boucle1
  197. Fct6:
  198.     move.w #2,color        ;we put the color 2 in var " color ".
  199.     bra boucle1
  200.     
  201. suite:
  202.     jsr tios::FontSetSys        ;we go to the subroutine that changes the System Font
  203.     lea 2(a7),a7            ;we restore the Stack of 2.
  204.     bra boucle1
  205. fini:
  206.     movem.l (a7)+,d0-d2/a0-a1    ;we take back the registers we have modified.
  207.     rts
  208. ;******************************************* ROUTINE *********************************************
  209.  
  210.  
  211. ;I got this routine in the prog DUMBADV.
  212. ;This routine converts a number in a Decimal String.
  213. ;a0 points at " strbuf ".
  214. ;d1 how many digits the number will be. Here it will be 3 digits.
  215. ;d0 the number we want to convert.
  216.  
  217. ConvStr:
  218.      adda.l  d1,a0        ;a0 points now at "adresse de strbuff " + 3 bytes.
  219.      clr.b   (a0)
  220.      subq.b  #1,d1        ;d1 is a kind of counter.
  221. RepConv:
  222.      divu     #10,d0        ;we divide by ten, because we want the number in Base Ten.
  223.  
  224.      move.l  d0,d2        ;In D0 : The upper word gets the remainder
  225.                 ;and the result is in the lower word.
  226.      lsr.l     #8,d2
  227.      lsr.l     #8,d2        ;we shift twice to the right in order to have the upper word
  228.                 ;at the place of the lower word. ( The lower word is destroyed).
  229.  
  230.      add.b     #48,d2        ;we add 48 to the remainder because the ASCII code of the  
  231.                 ;key " 1 " for example is  : 49. For  " 2 " it's 50.
  232.  
  233.      move.b  d2,-(a0)    ;we substract 1 Byte to A0 and we put D2 where A0 points to.
  234.  
  235.      and.l     #$FFFF,d0    ;sincerely, I really don't know why there is this line. Because
  236.                 ;it changes nothing in D0. If smne see why, please Email Me.
  237.  
  238.      dbra     d1,RepConv    ;we substract 1 to D1. If D1 equals " -1 ", we leave.
  239.      rts            ;go back to the prog.
  240.  
  241. ;******************** Program Variables ***********************
  242. Posx dc.l 0        ;X-Coordinate of our word..
  243. Posy dc.l 0        ;Y-Coordinate of our word.
  244. strbuf dc.l 0,0        ;this variable is necessary to store the Decimal String Posx or Posy.
  245. phrase dc.l 0,0        ;same as above, but it stores the word we want to display.
  246. cmptr dc.w 0        ;a counter.
  247. color dc.w 0        ;the color of our word.
  248. ancfont dc.w 0        ;in this variable we store the Font.
  249. intro dc.b "Type text to Display. ENTER to end. ( 8 letters max ).",0
  250. infos dc.b "Position X / Y :",0
  251. _comment    dc.b    "Text Tester v1.0",0
  252. ;********************** End of Program ************************
  253.     end
  254.