home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 466.lha / A68kExamples / say.asm < prev    next >
Assembly Source File  |  1991-02-03  |  7KB  |  273 lines

  1. ***************************************
  2. * say - speak a text file             *
  3. *                                     *
  4. * written by E. Lenz                  *
  5. *            Johann-Fichte-Strasse 11 *
  6. *            8 Munich 40              *
  7. *            Germany                  *
  8. *                                     *
  9. ***************************************
  10.  
  11. **** exec ****
  12.  
  13. _AbsExecBase     equ 4
  14. _LVOForbid       equ -$84
  15. _LVOPermit       equ -$8a
  16. _LVOAddPort      equ -$162
  17. _LVORemPort      equ -$168
  18. _LVOGetMsg       equ -$174
  19. _LVOReplyMsg     equ -$17a
  20. _LVOWaitPort     equ -$180
  21. _LVOCloseLibrary equ -$19e
  22. _LVOOpenDevice   equ -$1bc
  23. _LVOCloseDevice  equ -$1c2
  24. _LVODoIo         equ -$1c8
  25. _LVOOpenLibrary  equ -$228
  26.  
  27. **** dos *****
  28.  
  29. _LVOOpen     equ -$1e
  30. _LVOClose    equ -$24
  31. _LVORead     equ -$2a
  32. _LVOWrite    equ -$30
  33.  
  34. ***** translator ****
  35.  
  36. _LVOTranslate equ -$1e
  37.  
  38. TC_SIGRECVD      equ $1a
  39. pr_MsgPort       equ $5c
  40. pr_CLI           equ $ac
  41. ThisTask         equ $114
  42. VBlankFrequency  equ $212
  43. SIGBREAK_ANY     equ $1000
  44.  
  45.         XREF ReadLn,request,_Request
  46.  
  47.         move.l  a0,d7             save instruction from CLI
  48.         move.l  d0,d4
  49.         subq.w  #1,d4
  50.         clr.b   0(a0,d4.w)
  51.  
  52.         movea.l _AbsExecBase,a6   test if WB or CLI
  53.         movea.l ThisTask(a6),a0
  54.         move.l  a0,writerep+$10
  55.         lea     TC_SIGRECVD(a0),a1  get task signal address
  56.         move.l  a1,TaskSigs
  57.  
  58.         moveq   #0,d0
  59.         tst.l   pr_CLI(a0)
  60.         bne.s   isCLI
  61.  
  62.         lea     pr_MsgPort(a0),a0        for WB get WB Message
  63.         jsr     _LVOWaitPort(a6)
  64.         jsr     _LVOGetMsg(a6)
  65.         moveq   #0,d4             make sure there's no instruction
  66.  
  67. isCLI   move.l  d0,-(a7)
  68.  
  69.         cmpi.b  #60,VBlankFrequency(a6) test if PAL or NTSC
  70.         beq.s   isNTSC
  71.         move.l  #'256/',window+12
  72.  
  73. isNTSC  lea     transname(pc),a1     open translator library
  74.         moveq   #0,d0
  75.         jsr     _LVOOpenLibrary(a6)
  76.         movea.l d0,a4
  77.         tst.l   d0           this is one of the few cases
  78.         bne.s   Transok      where this test is vital
  79.         lea     transname(pc),a0   first line
  80.         lea     notfnd(pc),a1     second line
  81.         suba.l  a2,a2             no third line
  82.         lea     hdtxt(pc),a3      header
  83.         lea     OkTxt(pc),a4      gadget text
  84.         suba.l  a5,a5             no 2nd gadget
  85.         moveq   #0,d0
  86.         moveq   #1,d1
  87.         jsr     request
  88.         suba.l  a3,a3
  89.         bra     nocon
  90.  
  91. Transok lea     dosname(pc),a1    open DOS library
  92.         moveq   #0,d0
  93.         jsr     _LVOOpenLibrary(a6)
  94.         movea.l d0,a3
  95.         tst.l   d0
  96.         beq.s   Gerror
  97.  
  98.         movea.l d0,a6             open Console window
  99.         move.l  #window,d1
  100.         move.l  #1005,d2
  101.         jsr     _LVOOpen(a6)
  102.         movea.l d0,a5
  103.         tst.l   d0
  104. Gerror  beq     error
  105.  
  106.         movea.l _AbsExecBase,a6
  107.         lea     writerep(pc),a1
  108.         jsr     _LVOAddPort(a6)
  109.  
  110.         lea     talkio(pc),a1
  111.         moveq   #0,d0
  112.         moveq   #0,d1
  113.         lea     nardevice(pc),a0
  114.         jsr     _LVOOpenDevice(a6)
  115.         tst.l   d0
  116.         bne     exit
  117.  
  118.         movea.l a3,a6
  119.         move.l  d7,d1
  120.         tst.l   d4
  121.         bne.s   file
  122.  
  123.         moveq   #0,d0
  124.         move.l  #160,d1
  125.         moveq   #18,d2
  126.         lea     title(pc),a0
  127.         jsr     _Request
  128.         move.l  d0,d1
  129.         bra.s   file
  130.  
  131.         move.l  #filename,d1      open old file
  132. file    move.l  #1005,d2
  133.         jsr     _LVOOpen(a6)
  134.         move.l  d0,filehandle
  135. Gexit   beq     exit
  136.  
  137.         lea     talkio(pc),a1
  138.         move.l  #writerep,14(a1)
  139.         move.w  #150,48(a1)      rate 40-400
  140.         move.w  #110,50(a1)      pitch 65-320
  141.         move.w  #0,52(a1)        mode  0-1
  142.         move.w  #0,54(a1)        sex   0-1
  143.         move.l  #amaps,56(a1)    masks
  144.         move.w  #4,60(a1)        4 masks
  145.         move.w  #64,62(a1)       volume
  146.         move.w  #22200,64(a1)
  147.  
  148. saylop  bsr     Read
  149.         move.l  d1,d4
  150.         beq.s   Gexit
  151.  
  152.         movea.l TaskSigs,a0      test for ***BREAK***
  153.         move.l  (a0),d0
  154.         andi.l  #SIGBREAK_ANY,d0
  155.         bne.s   Gexit
  156.  
  157.         lea     outtext(pc),a1 clear translated stuff
  158.         moveq   #0,d0
  159.         moveq   #$7f,d1
  160. clear   move.l  d0,(a1)+
  161.         dbra    d1,clear
  162.  
  163.         move.l  a1,a2          write to console
  164.         move.l  a5,d1
  165.         move.l  #Buffer,d2
  166.         move.l  d4,d3
  167.         jsr     _LVOWrite(a6)
  168.  
  169.         cmpi.l   #1,d4
  170.         beq.s    saylop
  171.  
  172.         move.l  d4,d0
  173.         clr.b   -1(a2)
  174.  
  175.         lea     Buffer(pc),a0
  176.         lea     outtext(pc),a1
  177.         move.l  #512,d1
  178.         movea.l a4,a6
  179.         jsr     _LVOTranslate(a6)
  180.  
  181.         lea     talkio(pc),a1
  182.         move.w  #3,28(a1)
  183.         move.l  #512,36(a1)
  184.         move.l  #outtext,40(a1)
  185.         move.l  _AbsExecBase,a6
  186.         jsr     _LVODoIo(a6)
  187.         bra     saylop
  188.  
  189. exit    move.l  _AbsExecBase,a6
  190.         lea     writerep(pc),a1
  191.         jsr     _LVORemPort(a6)
  192.  
  193.         lea     talkio(pc),a1
  194.         jsr     _LVOCloseDevice(a6)
  195.  
  196.         movea.l a4,a1               close translator library
  197.         jsr     _LVOCloseLibrary(a6)
  198.  
  199. error   move.l  a3,a6
  200.  
  201.         move.l  filehandle(pc),d1  close file
  202.         beq.s   nofile
  203.         jsr     _LVOClose(a6)
  204.  
  205. nofile  move.l  a5,d1            close console
  206.         beq.s   nocon
  207.         jsr     _LVOClose(a6)
  208.  
  209. nocon   move.l  _AbsExecBase,a6
  210.         move.l  (a7)+,d0
  211.         beq.s   NoBench
  212.         jsr     _LVOForbid(a6)    reply to WB
  213.         movea.l d0,a1
  214.         jsr     _LVOReplyMsg(a6)
  215.         jsr     _LVOPermit(a6)
  216.  
  217. NoBench move.l  a3,d0
  218.         beq.s   NoDos
  219.         movea.l d0,a1             close dos.lib
  220.         jsr     _LVOCloseLibrary(a6)
  221. NoDos   moveq   #0,d0
  222.         rts
  223.  
  224. Read    movem.l a2-a5,-(a7)
  225.         movea.l a3,a6
  226.         move.l  BufNum(pc),d0
  227.         movea.l BufPnt(pc),a0
  228.         movea.l #Buf2,a1
  229.         movea.l #Buffer,a2
  230.         movea.l filehandle(pc),a3
  231.         jsr     ReadLn
  232.         move.l  d0,BufNum
  233.         move.l  a0,BufPnt
  234.         movem.l (a7)+,a2-a5
  235.         rts
  236.  
  237. TaskSigs   ds.l 1
  238. amaps      dc.b 3,5,10,12
  239.  
  240. transname  dc.b 'translator.library',0
  241. dosname    dc.b 'dos.library',0
  242. nardevice  dc.b 'narrator.device',0
  243.            even
  244.  
  245. ; requester texts
  246.  
  247. notfnd     dc.b ' not found',0
  248. hdtxt      dc.b ' Say Request',0
  249. OkTxt      dc.b ' OK',0
  250.            even
  251.  
  252. title      dc.b 'load file to SAY',0
  253.            even
  254.  
  255. filename   ds.b 80
  256.  
  257. window     dc.b 'CON:0/0/639/199/Say - abort with ^C',0
  258.            even
  259.  
  260.  
  261. filehandle dc.l 0
  262. narread    ds.l 20
  263. talkio     ds.l 20
  264. writerep   ds.l 8
  265. BufNum     dc.l 0
  266. BufPnt     dc.l 0
  267. Buffer     ds.b 200
  268. Buf2       ds.b 200
  269. outtext    ds.l $100
  270.            end
  271.  
  272.  
  273.