home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / screen / hercules / ring.asm < prev    next >
Assembly Source File  |  1989-10-15  |  8KB  |  229 lines

  1.  
  2.  
  3. COMMENT *
  4.  
  5.   Name    : RING.ASM
  6.   Comment : Program to ring the speaker
  7.   Syntax  : RING [ ON | OFF ]
  8.   Author  : M. Bokhorst
  9.   Date    : January 20th, 1988
  10.   Version : 1.0
  11.                
  12. *
  13.  
  14. ;=============================================================================+
  15. ;                                                                             |
  16. ;   Constants   Constants   Constants   Constants   Constants   Constants     |
  17. ;                                                                             |
  18. ;=============================================================================+
  19.  
  20. version        EQU   10h               ;Version number in octets
  21.  
  22. lf             EQU   10                ;Linefeed character code
  23. cr             EQU   13                ;Carriage return character code
  24.  
  25. false          EQU   0                 ;Boolean value false
  26. true           EQU   1                 ;Boolean value true
  27.  
  28. farjump        EQU   0EAh              ;Opcode far jump
  29.  
  30. clockint       EQU   1Ch               ;Interrupt# clock tick
  31.  
  32. dos            EQU   21h               ;Interrupt# dos services
  33. display        EQU   09h               ;Function# display string
  34. keep           EQU   31h               ;Function# terminate & stay resident
  35. setint         EQU   25h               ;Function# set interrupt vector
  36. getint         EQU   35h               ;Function# get interrupt vector
  37. terminate      EQU   4Ch               ;Function# terminate process
  38.  
  39. intint         EQU   0FEh              ;Pointer to signature
  40.  
  41. modemstatus    EQU   02FEh             ;Modem status register port
  42. RI             EQU   40h               ;Mask Ring Indicator
  43.  
  44. D5             EQU   2036              ;Timer value for note D5
  45. G5             EQU   1526              ;Timer value for note G5
  46.  
  47. timervalue     EQU   42h               ;Timer value register
  48. timerctl       EQU   43h               ;Timer control register
  49. portb          EQU   61h               ;Control port B
  50.  
  51. cmdline        EQU   5Dh               ;Offset to command line in PSP
  52.  
  53. ;=============================================================================+
  54. ;                                                                             |
  55. ;   Code   Code   Code   Code   Code   Code   Code   Code   Code   Code       |
  56. ;                                                                             |
  57. ;=============================================================================+
  58.  
  59. coder          SEGMENT
  60.  
  61.                ASSUME CS:coder
  62.  
  63. signature:     DW    'RI'              ;signature
  64.                DB     version          ;          and version number
  65.  
  66. ringon:        DB    true
  67. ringhigh:      DB    false
  68.  
  69. ;-----------------------------------------------------------------------------+
  70. ;                                                                             |
  71. ;   Clockhandler   Clockhandler   Clockhandler   Clockhandler   Clockhandler  |
  72. ;                                                                             |
  73. ;-----------------------------------------------------------------------------+
  74.  
  75. ticker:        PUSH  AX
  76.                PUSH  DX
  77.  
  78.                CMP   BYTE PTR CS:[ringon], true
  79.                JNE   noring
  80.  
  81.                MOV   DX, modemstatus
  82.                IN    AL, DX
  83.                AND   AL, RI                      ;ring signal from modem?
  84.                JZ    ringoff
  85.  
  86.                MOV   AL, 10110110b
  87.                OUT   timerctl, AL                ;initialize timer
  88.  
  89.                TEST  BYTE PTR CS:[ringhigh], true
  90.                JNZ   soundhigh
  91.  
  92.                MOV   AX, D5
  93.                JMP   SHORT soundlow
  94.  
  95. soundhigh:     MOV   AX, G5
  96.  
  97. soundlow:      OUT   timervalue, AL              ;set timer value low
  98.                MOV   AL, AH
  99.                OUT   timervalue, AL              ;set timer value high
  100.                IN    AL, portb
  101.                OR    AL, 00000011b
  102.                OUT   portb, AL                   ;switch speaker on
  103.  
  104.                XOR   BYTE PTR CS:[ringhigh], true
  105.  
  106.                JMP   SHORT noring
  107.  
  108. ringoff:       IN    AL, portb
  109.                AND   AL, 11111100b               ;switch speaker off
  110.                OUT   portb, AL
  111.                MOV   BYTE PTR CS:[ringhigh], false
  112.  
  113. noring:        POP   DX
  114.                POP   AX
  115.  
  116.                DB    farjump
  117. chainoff:      DW    ?
  118. chainseg:      DW    ?
  119.  
  120. ;-----------------------------------------------------------------------------+
  121. ;                                                                             |
  122. ;   Main   Main   Main   Main   Main   Main   Main   Main   Main   Main       |
  123. ;                                                                             |
  124. ;-----------------------------------------------------------------------------+
  125.  
  126. main:          CMP   BYTE PTR DS:[cmdline], 'O'  ;check command line
  127.                JNE   invcmd
  128.  
  129.                CMP   BYTE PTR DS:[cmdline+2], ' '
  130.                JE    enable
  131.  
  132.                CMP   BYTE PTR DS:[cmdline+1], 'F'
  133.                JNE   invcmd
  134.                CMP   BYTE PTR DS:[cmdline+2], 'F'
  135.                JNE   invcmd
  136.                CMP   BYTE PTR DS:[cmdline+3], ' '
  137.                JNE   invcmd
  138.                MOV   BYTE PTR CS:[ringon], false         ;RING OFF
  139.                JMP   SHORT instring
  140.  
  141. enable:        CMP   BYTE PTR DS:[cmdline+1], 'N'
  142.                JNE   invcmd
  143.                MOV   BYTE PTR CS:[ringon], true          ;RING ON
  144.                JMP   SHORT instring
  145.                
  146. invcmd:        MOV   AH, display
  147.                MOV   DX, OFFSET strinv
  148.                PUSH  CS
  149.                POP   DS
  150.                INT   dos                         ;say what's wrong
  151.  
  152.                MOV   AH, terminate
  153.                MOV   AL, 1                       ;errorlevel 1
  154.                INT   dos 
  155.  
  156. instring:      IN    AL, portb
  157.                AND   AL, 11111100b
  158.                OUT   portb, AL                   ;switch speaker off
  159.  
  160.                MOV   AH, getint
  161.                MOV   AL, intint                  ;check signature
  162.                INT   dos
  163.                CMP   WORD PTR ES:[signature], 'RI'
  164.                JNZ   notinst
  165.                CMP   BYTE PTR ES:[signature+2], version
  166.                JNZ   notinst
  167.  
  168.                MOV   AL, BYTE PTR CS:[ringon]
  169.                MOV   BYTE PTR ES:[ringon], AL    ;already installed: modify
  170.  
  171.                MOV   AH, terminate
  172.                MOV   AL, 0                       ;errorlevel 0
  173.                INT   dos
  174.  
  175. notinst:       MOV   AH, getint
  176.                MOV   AL, clockint
  177.                INT   dos
  178.                MOV   WORD PTR CS:[chainoff], BX
  179.                MOV   WORD PTR CS:[chainseg], ES
  180.  
  181.                MOV   AH, setint
  182.                MOV   AL, clockint
  183.                PUSH  CS
  184.                POP   DS
  185.                MOV   DX, OFFSET ticker
  186.                INT   dos                         ;setup new clock handler
  187.  
  188.                MOV   AH, setint
  189.                MOV   AL, intint
  190.                PUSH  CS
  191.                POP   DS
  192.                MOV   DX, OFFSET ticker
  193.                INT   dos                         ;pointer to signature
  194.  
  195.                MOV   AH, display
  196.                MOV   DX, OFFSET strinst          ;first time install
  197.                PUSH  CS
  198.                POP   DS
  199.                INT   dos
  200.  
  201.                MOV   AH, keep
  202.                MOV   AL, 0                       ;errorlevel 0
  203.                MOV   DX, OFFSET main
  204.                MOV   CL, 4
  205.                SHR   DX, CL
  206.                ADD   DX, 17
  207.                INT   dos                         ;TSR
  208.  
  209. strinst:
  210.  
  211. DB  'Ring Version 1.0 installed', cr, lf, '$'
  212.  
  213. strinv:
  214.  
  215. DB  cr, lf
  216. DB  'Ring Version 1.0   ----   Syntax: RING [ ON | OFF ]', cr, lf
  217. DB  'Written by M. Bokhorst; released January 20th, 1988', cr, lf
  218. DB  'Questions, suggestions and bug reports to 2:512/108', cr, lf, '$'
  219.  
  220. coder          ENDS
  221.                END main
  222.  
  223. ;=============================================================================+
  224. ;                                                                             |
  225. ;   End   End   End   End   End   End   End   End   End   End   End   End     |
  226. ;                                                                             |
  227. ;=============================================================================+
  228.  
  229.