home *** CD-ROM | disk | FTP | other *** search
/ kermit.columbia.edu / kermit.columbia.edu.tar / kermit.columbia.edu / trs80model4 / m4h19s.asm < prev    next >
Assembly Source File  |  1986-10-21  |  10KB  |  395 lines

  1. ;        M4H19S/ASM
  2. *GET        M4H19/EQU
  3. *GET        M4H19/MAC
  4. VS        EQU    15    ;Offset in header for visual cursor
  5. VE        EQU    16    ;Offset in header for line mode cursor
  6. DEF_LEN        EQU    17    ;Default length of audible bell
  7. BELLFLAG    EQU    18    ;Audible or visual bell flag
  8. DEF_FREQ    EQU    19    ;Frequency value for bell tone
  9. OLDLOW        EQU    21    ;Set up address used for removing *HP
  10. OLDHIGH        EQU    23    ;Ditto
  11. BIT_MASK    EQU    29    ;Offset to bit mask
  12. ;
  13. ;    Load in low memory to avoid user programs, and KERMIT in
  14. ;    particular
  15. ;
  16.         ORG    2500H
  17. START:
  18.         LD    DE,ARGBUFF+1    ;Copy the arguments
  19.         LD    BC,255        ;Pick a number suffiently large
  20.         LD    (PARMS),DE    ;Save the dest for later use
  21.         LDIR            ;Move the command line
  22. GETH19:
  23.         LD    DE,H19_NAME    ;Check to see if $HEATH is there
  24.         SSVC    @GTMOD        ;Try to find it
  25.         JP    NZ,NOH19    ;Not there, so go put it in
  26.         PUSH    HL        ;Put the header address into IX
  27.         POP    IX
  28.         LD    DE,PARAM_TABLE    ;Get the parameter table
  29.         LD    HL,(PARMS)    ;Get the command line
  30. ;
  31. ;    We look for a '(' to know whether or not to display the usage
  32. ;    message.  If we do not find one, then we give the user help.
  33. ;
  34. LOOP1:
  35.         LD    A,(HL)        ;See if there is anything there
  36.         CP    13        ;End of command line
  37.         JP    Z,SHOW_VALS    ;If so, then give help
  38.         CP    '('        ;Start of argument list?
  39.         JR    Z,LOOP2        ;Jump if it is
  40.         INC    HL        ;Point to next
  41.         JR    LOOP1        ;Loop on
  42. LOOP2:
  43.         DEC    HL        ;Back up before the '('
  44.         SSVC    @PARAM        ;Parse the parameter list
  45.         JP    NZ,SHOW_VALS    ;On failure, give help
  46.         LD    A,(RESP_VS)    ;Was a BLOCK cursor value given?
  47.         OR    A
  48.         JR    Z,CHK_VE    ;Jump if not
  49.         AND    60H        ;Verify only numeric.
  50.         JP    NZ,BAD_PARAM    ;Jump if not
  51.         LD    HL,(VS_VAL)    ;Get the value given
  52.         LD    A,H        ;Make sure it is only a byte
  53.         OR    A
  54.         JP    NZ,TOO_BIG    ;Print a message if too big
  55.         LD    A,L        ;Get the byte value from L
  56.         LD    (IX+VS),A    ;Save it into the $HEATH header
  57. CHK_VE:
  58.         LD    A,(RESP_VE)    ;Was there a line mode cursor
  59.         OR    A        ;Jump if not
  60.         JR    Z,CHK_REM
  61.         AND    60H        ;Verify it is only numeric
  62.         JP    NZ,BAD_PARAM    ;Jump if bad
  63.         LD    HL,(VE_VAL)    ;Get the value
  64.         LD    A,H        ;Make sure it is a byte value
  65.         OR    A
  66.         JP    NZ,TOO_BIG    ;Jump if too big.
  67.         LD    A,L        ;Get the byte value from L
  68.         LD    (IX+VE),A    ;Store it
  69. CHK_REM:
  70.         LD    A,(RESP_REMOVE)    ;Is this a remove request?
  71.         OR    A
  72.         JR    Z,CHK_FREQ    ;If not go check bell frequency
  73.         AND    0A0H        ;Must be boolean
  74.         JP    NZ,BAD_PARAM
  75.         LD    B,0        ;Get the current HIGH$ value
  76.         LD    HL,0
  77.         SSVC    @HIGH$
  78.         JP    NZ,ERROR
  79.         LD    A,(IX+OLDHIGH)    ;Get the OLD HIGH$ from header
  80.         LD    C,A
  81.         LD    A,(IX+OLDHIGH+1)
  82.         LD    B,A        ;See if they are still the same
  83.         OR    A        ;Reset the carry
  84.         SBC    HL,BC        ;Compute the difference
  85.         JP    NZ,CANT_REMOVE    ;If not equal, then can't remove
  86.         LD    A,(IX+OLDLOW)    ;Get the previous HIGH$ that was
  87.         LD    L,A        ;in effect before $HEATH was
  88.         LD    A,(IX+OLDLOW+1)    ;installed
  89.         LD    H,A
  90.         LD    B,0        ;removing the module
  91.         SSVC    @HIGH$
  92.         JP    NZ,ERROR
  93. ;
  94. ;    The code here make several RASH assumptions about what devices
  95. ;    $HEATH is mated to.  It assumes that the following commands were
  96. ;    used to install the $HEATH module:
  97. ;
  98. ;    set *hp h19
  99. ;    filter *so *hp
  100. ;
  101. ;    With these in mind, it does the following commands
  102. ;
  103. ;    reset *so
  104. ;    reset *hp
  105. ;    remove *hp
  106. ;    route *so *do
  107. ;
  108. ;    This should restore the system to a reasonable state, given the
  109. ;    fact that the filter should be in by itself anyway.
  110. ;
  111. REMOVE_FILTER:
  112.         LD    HL,CMD1        ;Do "reset *so" command
  113.         SSVC    @CMNDR
  114.         LD    HL,CMD2        ;Do "reset *hp" command
  115.         SSVC    @CMNDR
  116.         LD    HL,CMD3        ;Do "remove *hp" command
  117.         SSVC    @CMNDR
  118.         LD    HL,CMD4        ;Do "route *so *do" command
  119.         SSVC    @CMNDR
  120.         JP    SET_EXIT    ;Nothing else is reasonable, quit
  121. CHK_FREQ:
  122.         LD    A,(RESP_FREQ)    ;Check for a frequency given
  123.         OR    A
  124.         JR    Z,CHK_DUR    ;Jump if none there
  125.         AND    60H        ;Verify that it is numeric
  126.         JP    NZ,BAD_PARAM    ;Jump if not just numeric
  127.         LD    HL,(FREQ_VAL)    ;Get the value
  128.         LD    (IX+DEF_FREQ),L    ;Use all 16 bits worth
  129.         LD    (IX+DEF_FREQ+1),H
  130. CHK_DUR:
  131.         LD    A,(RESP_DURA)    ;Is there a duration given?
  132.         OR    A
  133.         JR    Z,CHK_BELL    ;Jump if there is isn't
  134.         AND    60H        ;Verify that it is numeric
  135.         JP    NZ,BAD_PARAM    ;Jump if it is not
  136.         LD    HL,(DUR_VAL)    ;Get the value
  137.         LD    A,H        ;Make sure there is only a byte
  138.         OR    A
  139.         JP    NZ,TOO_BIG    ;Jump if MSB not zero
  140.         LD    A,L        ;Get the byte value from L
  141.         LD    (IX+DEF_LEN),A    ;Save the tone length
  142. CHK_BELL:
  143.         LD    A,(RESP_BELL)    ;Are they setting bell flag?
  144.         OR    A
  145.         JP    Z,CHK_STRIP8    ;Check if strip8 parameter given
  146.         AND    0A0H        ;Is it boolean?
  147.         JP    NZ,BAD_PARAM    ;Jump if not
  148.         LD    A,(BELL_VAL)    ;Get the value
  149.         LD    (IX+BELLFLAG),A    ;Save it
  150. CHK_STRIP8:
  151.         LD    A,(RESP_STRIP8)    ;Get the parameter present flag
  152.         OR    A
  153.         JP    Z,CHK_SHOW    ;Go check show parameter
  154.         AND    0A0H        ;Check if boolean
  155.         JP    NZ,BAD_PARAM
  156.         LD    C,(IX+BIT_MASK)
  157.         LD    B,(IX+BIT_MASK+1)
  158.         PUSH    IX
  159.         POP    HL
  160.         ADD    HL,BC        ;Compute the offset
  161.         LD    C,0FFH        ;Get the off mask
  162.         LD    A,(STRIP8_VAL)
  163.         OR    A
  164.         JR    Z,STRIP8_OFF    ;Option is off so jump
  165.         LD    C,07FH        ;Load on mask
  166. STRIP8_OFF:
  167.         LD    (HL),C        ;Patch AND instruction
  168. CHK_SHOW:
  169.         LD    A,(RESP_SHOW)    ;Check if show given
  170.         OR    A
  171.         JR    Z,CHK_HELP    ;Check for help
  172.         AND    0A0H        ;Is it boolean
  173.         JP    NZ,BAD_PARAM    ;Error if not
  174.         LD    A,(SHOW_VAL)    ;Get the value
  175.         OR    A        ;Make sure not (SHOW=NO)
  176.         CALL    NZ,SHOW_VALS
  177. CHK_HELP:
  178.         LD    A,(RESP_HELP)    ;Check if HELP given
  179.         OR    A
  180.         JR    Z,SET_EXIT
  181.         AND    0A0H        ;Is it boolean?
  182.         JP    NZ,BAD_PARAM
  183.         LD    A,(HELP_VAL)    ;Get the value
  184.         OR    A        ;Make sure not (HELP=NO)
  185.         JP    Z,SET_EXIT
  186.         LD    HL,HELP_STR
  187.         SSVC    @DSPLY
  188. SET_EXIT:
  189.         LD    HL,0        ;Set normal exit code
  190.         RET            ;Return, DON'T @EXIT HERE
  191. ;
  192. ;    Show the values of the currently set options
  193. ;
  194. SHOW_VALS:
  195.         LD    HL,LINE_STR    ;Get the line mode cursor descr
  196.         SSVC    @DSPLY        ;Display it
  197.         LD    L,(IX+VE)    ;Get the value
  198.         LD    H,0        ;Make it only a byte
  199.         CALL    NUMOUT        ;Print it on the screen
  200.         LD    HL,BLK_STR    ;Print the block mode descr
  201.         SSVC    @DSPLY
  202.         LD    L,(IX+VS)    ;Get the value
  203.         LD    H,0        ;Make it a byte
  204.         CALL    NUMOUT        ;Print the number on the display
  205.         LD    C,13        ;Get a new line
  206.         SSVC    @DSP
  207.         LD    HL,BELL_STR    ;Print the BELL descr
  208.         SSVC    @DSPLY
  209.         LD    HL,ON_STR    ;Get the ON string
  210.         LD    A,(IX+BELLFLAG)    ;Get the value
  211.         OR    A        ;Check if it is on
  212.         JR    NZ,SHOW_1    ;Jump if it is
  213.         LD    HL,OFF_STR    ;Get the off string
  214. SHOW_1        SSVC    @DSPLY        ;Display ON or OFF
  215.         LD    HL,DURA_STR    ;Get the duration descr
  216.         SSVC    @DSPLY
  217.         LD    L,(IX+DEF_LEN)    ;Get the duration
  218.         LD    H,0        ;Make it a byte in HL
  219.         CALL    NUMOUT        ;Print the number on the screen
  220.         LD    HL,FREQ_STR    ;Print the frequency descr
  221.         SSVC    @DSPLY
  222.         LD    L,(IX+DEF_FREQ)    ;Get the LSB of FREQ
  223.         LD    H,(IX+DEF_FREQ+1);Get the MSB
  224.         CALL    NUMOUT        ;Print the number out
  225.         LD    HL,STRIP_STR    ;Get the STRIP8 message
  226.         SSVC    @DSPLY
  227.         LD    C,(IX+BIT_MASK)
  228.         LD    B,(IX+BIT_MASK+1)
  229.         PUSH    IX
  230.         POP    HL
  231.         ADD    HL,BC        ;Compute the offset
  232.         LD    A,(HL)
  233.         LD    HL,ONSTR
  234.         CP    0FFH        ;Check for off
  235.         JR    NZ,ISON
  236.         LD    HL,OFFSTR
  237. ISON:
  238.         SSVC    @DSPLY
  239.         RET            ;Return to caller
  240. ;
  241. NUMOUT        LD    DE,STRBUF
  242.         PUSH    DE
  243.         SSVC    @HEXDEC
  244.         EX    DE,HL
  245.         LD    (HL),3
  246.         POP    HL
  247.         LD    A,' '
  248. NUM_1        CP    (HL)
  249.         JR    NZ,NUM_2
  250.         INC    HL
  251.         JR    NUM_1
  252. NUM_2        SSVC    @DSPLY
  253.         RET
  254. ;
  255. CANT_REMOVE:
  256.         LD    HL,NO_REMOVE    ;Print the Can't remove message
  257.         SSVC    @DSPLY
  258.         JP    REMOVE_FILTER    ;Finish unlinking the devices
  259. ;
  260. TOO_BIG:
  261.         LD    HL,TOO_BIG_STR    ;Get the TOO BIG message
  262.         DB    0DDH        ;Hide LD HL instruction
  263. ;
  264. NOH19MESS:
  265.         LD    HL,NOFLT_STR    ;Print error message, No H19/FLT
  266.         DB    0DDH        ;Hide LD HL
  267. ;
  268. BAD_PARAM    LD    HL,BAD_PARAM_STR;Print Bad paramter message
  269. ;
  270. PRINT_EXIT:
  271.         SSVC    @DSPLY        ;Print it
  272. EXIT:
  273.         LD    HL,-1        ;Get error exit code
  274.         RET            ;Return from caller
  275. ;
  276. ERROR:
  277.         OR    0C0H
  278.         LD    C,A
  279.         SSVC    @ERROR
  280.         JR    EXIT
  281. ;
  282. NOH19:
  283.         LD    A,(ONCE)    ;Check if we have been here once
  284.         OR    A
  285.         JR    NZ,NOH19MESS    ;If so, then issue a message
  286.         INC    A        ;Set the flag
  287.         LD    (ONCE),A
  288.         LD    HL,SETH19    ;Do the "set *hp h19" command
  289.         SSVC    @CMNDR
  290.         LD    HL,FILTER    ;Do the "filter *so *hp" command
  291.         SSVC    @CMNDR
  292.         JP    GETH19        ;Try to load it again
  293. ;
  294. H19_NAME    DB    '$HEATH',0
  295. NO_REMOVE    DB    'Can not reclaim used memory!',13
  296. STRIP_STR    DB    10,'Strip 8th bit: ',3
  297. ONSTR        DB    'YES',13
  298. OFFSTR        DB    'NO',13
  299. NOFLT_STR    DB    'Can not find H19 filter',13
  300. BAD_PARAM_STR    DB    'Bad parameter value',13
  301. TOO_BIG_STR    DB    'Value too large',13
  302. LINE_STR    DB    'Normal cursor: ',3
  303. BLK_STR        DB    ', Block cursor: ',3
  304. DURA_STR    DB    ', Duration: ',3
  305. FREQ_STR    DB    ', Frequency: ',3
  306. BELL_STR    DB    'Bell: ',3
  307. ON_STR        DB    'ON',3
  308. OFF_STR        DB    'OFF',3
  309. ;
  310. HELP_STR    DB    'Recognized parameters:',10
  311.         DB    'CURSOR      -   Normal cursor character',10
  312.         DB    'BLOCK       -   Block cursor character',10
  313.         DB    'BELL        -   Turn bell ON or OFF',10
  314.         DB    'FREQUENCY   -   Frequency of bell (inverse of '
  315.         DB    'real freq)',10
  316.         DB    'DURATION    -   Length of tone (255 MAX)',10
  317.         DB    'STRIP8      -   Remove 8th bit from characters '
  318.         DB    '(default=ON)',10
  319.         DB    'REMOVE      -   Remove the filter from memory'
  320.         DB    10,'SHOW        -   Show all values',10
  321.         DB    'HELP        -   This message',10,13
  322. ;
  323. VE_VAL        DW    0
  324. VS_VAL        DW    0
  325. RM_FLAG        DW    0
  326. DUR_VAL        DW    0
  327. FREQ_VAL    DW    0
  328. BELL_VAL    DW    0
  329. SHOW_VAL    DW    0
  330. HELP_VAL    DW    0
  331. STRIP8_VAL    DW    0
  332. ;
  333. CMD1        DB    'reset *so',13
  334. CMD2        DB    'reset *hp',13
  335. CMD3        DB    'remove *hp',13
  336. CMD4        DB    'route *so *do',13
  337. SETH19        DB    'set *hp h19',13
  338. FILTER        DB    'filter *so *hp'
  339. PARMS        DW    0
  340. ONCE        DB    0
  341. ARGBUFF        DB    '    '
  342.         DS    255
  343. STRBUF        DS    20
  344. ;
  345. PARAM_TABLE:
  346.         DB    80H
  347. ;
  348.         DB    80H+5
  349.         DB    'BLOCK'
  350. RESP_VS        DB    0
  351.         DW    VS_VAL
  352. ;
  353.         DB    80H+6
  354.         DB    'CURSOR'
  355. RESP_VE        DB    0
  356.         DW    VE_VAL
  357. ;
  358.         DB    40H+6
  359.         DB    'REMOVE'
  360. RESP_REMOVE    DB    0
  361.         DW    RM_FLAG
  362. ;
  363.         DB    90H+9
  364.         DB    'FREQUENCY'
  365. RESP_FREQ    DB    0
  366.         DW    FREQ_VAL
  367. ;
  368.         DB    90H+8
  369.         DB    'DURATION'
  370. RESP_DURA    DB    0
  371.         DW    DUR_VAL
  372. ;
  373.         DB    40H+4
  374.         DB    'BELL'
  375. RESP_BELL    DB    0
  376.         DW    BELL_VAL
  377. ;
  378.         DB    40H+4
  379.         DB    'SHOW'
  380. RESP_SHOW    DB    0
  381.         DW    SHOW_VAL
  382. ;
  383.         DB    40H+4
  384.         DB    'HELP'
  385. RESP_HELP    DB    0
  386.         DW    HELP_VAL
  387. ;
  388.         DB    46H
  389.         DB    'STRIP8'
  390. RESP_STRIP8    DB    0
  391.         DW    STRIP8_VAL
  392. ;
  393. TABLE_END    DB    0
  394.         END    START
  395.