home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol075 / g8m.csm < prev    next >
Text File  |  1984-04-29  |  9KB  |  437 lines

  1.     include    bds.lib
  2.     include    z80.lib
  3.     page    55
  4. ;
  5. ;********************************************************
  6. ;*                            *
  7. ;*        BDS-C Supplementary Library        *
  8. ;*            release 3            *
  9. ;*                            *
  10. ;*        Steve de Plater, May. 1982        *
  11. ;*              66 Priam St.            *
  12. ;*              Chester Hill,            *
  13. ;*              NSW, 2162             *
  14. ;*              Australia             *
  15. ;*        Phone: (02) 644 4009            *
  16. ;*                            *
  17. ;********************************************************
  18. ;
  19. ;  THE (IN)FAMOUS BDS-C SUPPLEMENTARY LIBRARY
  20. ;    FOR THE EXIDY SORCERER COMPUTER SYSTEM
  21. ;
  22. ; int supp();
  23. ;
  24. ;   Returns the release number of the SUPP.CRL file
  25. ;   as a 16 bit number (heaven forbid)!
  26.  
  27.     function    supp
  28.  
  29. release equ    3    ;DATE INSTALLED: 28 May 82
  30.             ;-------------------------
  31.  
  32.     lxi    h,release
  33.     ret
  34.  
  35.     endfunc
  36. ;
  37. ;=============================================================
  38. ;
  39. ; int fillb(a1,a2,c,mode)
  40. ;  char c;
  41. ;  int a1, a2, mode;
  42. ;
  43. ;   if (mode==0)
  44. ;     Fills memory from address a1 to address a2 (inclusive)
  45. ;     with the byte c.
  46. ;   else
  47. ;     Fills memory from address a1 for a2 bytes with byte c.
  48. ;
  49.     function    fillb
  50.  
  51.     call    arghak
  52.     push    b
  53.  
  54.     lda    arg4        ;"from/to" or "from/count"
  55.     ora    a        ;"from/to" - jump
  56.     jz    fillb2
  57.     lhld    arg2        ;"COUNT" value
  58.     push    h        ;move it to
  59.     pop    b        ;BC
  60.     jmp    fillb4        ;and jump
  61.  
  62. fillb2: lhld    arg1        ;"FROM" address
  63.     mov    a,l        ;turn it
  64.     cma            ;round
  65.     mov    e,a        ;into the DE pair
  66.     mov    a,h
  67.     cma
  68.     mov    d,a        ;to form"1's comp"
  69.     inx    d        ;and now"2's comp"
  70.     lhld    arg2        ;and now get"TO" addr
  71.     dad    d        ;ie"TO" - "FROM" = range
  72.     push    h        ;move it to
  73.     pop    b        ;BC (bytes to fill)
  74.     inx    b        ;include the end address too!
  75.  
  76. fillb4: lhld    arg1        ;"FROM" address
  77.     lda    arg3        ;byte to fill with
  78.     mov    e,a        ;just somewhere to put it!
  79.  
  80. fillb6: mov    m,a        ;and fill it in there!
  81.     inx    h        ;point to next fill address
  82.     dcx    b        ;one less to go!
  83.     mov    a,b
  84.     ora    c        ;finished ?
  85.     jz    fillb8        ;yes - jump
  86.     mov    a,e        ;get fill byte again
  87.     jmp    fillb6        ;and fill with it
  88.  
  89. fillb8: pop    b        ;all over
  90.     ret
  91.  
  92.     endfunc
  93. ;
  94. ;=============================================================
  95. ;
  96. ; char *fill(saddr,eaddr,string,opt)
  97. ;   char *string;
  98. ;
  99. ;   If (opt==0)
  100. ;     Fills a contiguous block of RAM starting at saddr and
  101. ;     ending at eaddr with the string pointed to by"string".
  102. ;   else
  103. ;     Fills a contiguous block of RAM starting at saddr of
  104. ;     length eaddr bytes with the string pointed to.
  105. ;
  106. ;   The string is reused until the fill is complete.
  107. ;   Returns the address of the fill string.
  108. ;
  109.     function    fill
  110.  
  111.     call    arghak
  112.     push    b
  113.  
  114.     lda    arg4        ;"from/to" or "from/count"
  115.     ora    a
  116.     jz    fill02        ;"from/to" - jump
  117.     lhld    arg2        ;get"COUNT"
  118.     push    h        ;and move to
  119.     pop    b        ;BC
  120.     jmp    fill04        ;then jump
  121.  
  122. fill02: lhld    arg1        ;"FROM" address
  123.     mov    a,l        ;turn it
  124.     cma            ;round
  125.     mov    e,a        ;into the DE pair
  126.     mov    a,h
  127.     cma
  128.     mov    d,a        ;to form"1's comp"
  129.     inx    d        ;and now"2's comp"
  130.     lhld    arg2        ;and now get"TO" addr
  131.     dad    d        ;ie"TO" - "FROM" = range
  132.     push    h        ;move it to
  133.     pop    b        ;BC (bytes to fill)
  134.     inx    b        ;include the end address too!
  135.  
  136. fill04: lhld    arg1        ;"FROM" address
  137.     xchg            ;to DE
  138.     lhld    arg3        ;pointer to the "fill string"
  139.     mov    a,m        ;get first char to fill with
  140.     ora    a        ;null string ?
  141.     jz    fill08        ;if so then quit
  142.  
  143. fill06: stax    d        ;and fill it in there!
  144.     inx    d        ;point to next fill address
  145.     inx    h        ;and next"fill string" char
  146.     dcx    b        ;one less to go!
  147.     mov    a,b
  148.     ora    c        ;finished ?
  149.     jz    fill08        ;yes - jump
  150.     mov    a,m        ;get the next char to fill with
  151.     ora    a        ;is it a 0 (end of string)
  152.     jnz    fill06        ;no - fill with it then
  153.     lhld    arg3        ;back to the start of string
  154.     mov    a,m        ;get the first char
  155.     jmp    fill06        ;and fill with it
  156.  
  157. fill08: lhld    arg3        ;return addr of the fill str
  158.     pop    b        ;all over
  159.     ret
  160.  
  161.     endfunc
  162. ;
  163. ;==============================================================
  164. ;
  165. ; char *strrot(mode,s)
  166. ;   char *s;
  167. ;
  168. ;    Rotates the string (end around) pointed to by"s".
  169. ;    If mode==0 then rotate LEFT, and
  170. ;    if mode<>0 then rotate RIGHT.
  171. ;    Returns the address of the string.
  172. ;
  173.     function    strrot
  174.  
  175.     call    arghak
  176.     push    b
  177.  
  178.     lhld    arg2        ;point to string
  179.     push    h
  180.     pop    d        ;in DE as well
  181.     inx    d        ;and point ahead one
  182.     mvi    c,0        ;a counter to zero!
  183.     lda    arg1        ;get MODE switch
  184.     ora    a        ;rotate left ?
  185.     jnz    strr06        ;no - jump
  186.  
  187.     mov    a,m        ;get char to rotate
  188.     mov    b,a        ;and save it
  189. strr02: ldax    d        ;get char
  190.     ora    a        ;have we reached end of str
  191.     jz    strr04        ;yes - jump
  192.     mov    m,a        ;rotate the char
  193.     inx    h        ;next please
  194.     inx    d
  195.     jmp    strr02        ;and back for more
  196. strr04: mov    a,b        ;"the first shall be last.."
  197.     mov    m,a
  198.     jmp    strr14
  199.  
  200. strr06: mov    a,m        ;first scan for end
  201.     inx    h
  202.     inr    c        ;chars in string
  203.     ora    a        ;there yet ?
  204.     jnz    strr06        ;no - back we go
  205.     dcx    h        ;point back to the null
  206.     dcx    h        ;and then to last char
  207.     dcr    c        ;we don't count the null
  208.     push    h        ;and copy
  209.     pop    d        ;to DE
  210.     dcx    d        ;back one more
  211.     mov    a,m        ;the end char to save
  212.     mov    b,a        ;in B
  213. strr10: dcr    c        ;have we rotated enough ?
  214.     jz    strr12        ;yes - jump
  215.     ldax    d        ;get char to rotate
  216.     mov    m,a        ;and rotate it!
  217.     dcx    h        ;back one more
  218.     dcx    d
  219.     jmp    strr10        ;next please
  220. strr12: mov    a,b        ;".and the last shall be first"
  221.     mov    m,a
  222. strr14: lhld    arg2        ;return string address
  223.     pop    b
  224.     ret
  225.  
  226.     endfunc
  227. ;
  228. ;
  229. ;=============================================================
  230. ;
  231. ; int hi(i)
  232. ;  int i;
  233. ;
  234. ;   Returns the high byte of i.
  235. ;
  236.     function    hi
  237.  
  238.     call    ma1toh
  239.     mov    l,h
  240.     mvi    h,0
  241.     ret
  242.  
  243.     endfunc
  244. ;
  245. ;=============================================================
  246. ;
  247. ; int lo(i)
  248. ;  int i;
  249. ;
  250. ;   Returns the low byte of i.
  251. ;
  252.     function    lo
  253.  
  254.     call    ma1toh
  255.     mvi    h,0
  256.     ret
  257.  
  258.     endfunc
  259. ;
  260. ;============================================================
  261. ;
  262. ; int cursor(x,y);
  263. ;
  264. ;   moves the cursor to position x (line), y (column) of
  265. ;   the Sorcerer screen. (if possible)!
  266. ;   Returns the offset from the beginning of the screen RAM
  267. ;   of the new cursor position.
  268.  
  269.     function    cursor
  270.  
  271.     call    arghak        ;get the arguements
  272.     push    b        ;we need it!
  273.  
  274. getiy    equ    0e1a2h        ;Exidy Monitor entry points
  275. wcur    equ    0e9cch        ;write cursor
  276. rec    equ    0e9e8h        ;remove the old one
  277. ptrset    equ    0e9d6h        ;find the cursor address
  278.  
  279.     lda    arg2        ;get the column
  280.     ora    a
  281.     jm    curses        ;you can't have a -ve column!
  282.     cpi    64
  283.     jnc    curses        ;or one > 63
  284.     lda    arg1        ;get the line
  285.     ora    a
  286.     jm    curses        ;you can't have a -ve line!
  287.     cpi    30
  288.     jnc    curses        ;or one > 29
  289.  
  290.     lda    arg1+1
  291.     ora    a
  292.     jnz    curses
  293.     lda    arg2+1
  294.     ora    a
  295.     jnz    curses
  296.  
  297.     call    getiy
  298.     call    rec
  299.     lda    arg1
  300.     mov    e,a        ;and multiply it be 64
  301.     mvi    d,0
  302.     mvi    b,6
  303. cur04:    sla    e
  304.     rl    d
  305.     dcr    b
  306.     jnz    cur04
  307.     stiy    e,68h        ;and save it in the MWA
  308.     stiy    d,69h        ;(both bytes)
  309.     lda    arg2        ;now get the column
  310.     stiy    a,6ah        ;and save it too
  311.     stiyi    0,6bh        ;high byte is zero
  312.     call    wcur        ;and put the cursor there!
  313.  
  314. curses: call    ptrset        ;just in case we hadn't
  315.     pop    b        ;told you we'd need it
  316.     ret            ;home we go
  317.  
  318.     endfunc
  319.  
  320. pushix    equ    0e5ddh
  321. pushiy    equ    0e5fdh
  322. inxix    equ    023ddh
  323. scan    equ    0e225h
  324. ;
  325. ;==============================================================
  326. ;
  327. ; int remcur()
  328. ;
  329. ;   Removes the cursor from the screen.
  330. ;   Returns the cursor address.
  331. ;
  332.     function    remcur
  333.  
  334.     push    b
  335.     call    getiy
  336.     call    rec
  337.     pop    b
  338.     ret
  339.  
  340.     endfunc
  341. ;
  342. ;==============================================================
  343. ;
  344. ; int mwa();
  345. ;
  346. ;   Returns the MWA address.
  347. ;
  348.     function    mwa
  349.  
  350.     call    getiy
  351.     dw    pushiy
  352.     pop    h
  353.     ret
  354.  
  355.     endfunc
  356. ;
  357. ;=============================================================
  358. ;
  359. ; int exycall();
  360. ;
  361. ;   Calls the Exidy Standard Monitor
  362. ;   using the monitor command found at MWA.
  363. ;   Returns 0 if illegal command (or no command)
  364. ;     or    1 if command successfully executed.
  365. ;
  366. ;   WARNING: This function may not return AT ALL if you
  367. ;   crash it in the Monitor itself! ;BE WARNED!
  368. ;
  369.     function    exycall
  370.  
  371.     push    b        ;just in case!
  372.     dw    pushiy        ;move IY
  373.     pop    h        ;  to HL
  374.     call    scan        ;get delims
  375.     jz    exyc5         ;NONE!
  376.     db    0ddh,021h,012h,0e3h
  377. exyc1:    push    h
  378.     dw    pushix
  379.     mvi    b,2
  380. exyc2:    db    0ddh,07eh,00h
  381.     cmp    m
  382.     jnz    exyc4
  383.     inx    h
  384.     dw    inxix
  385.     dcr    b
  386.     jnz    exyc2
  387.     pop    d
  388.     pop    d
  389.     lxi    b,exyc6
  390.     push    b
  391. exyc3:    db    0ddh,06eh,00h
  392.     db    0ddh,066h,01h
  393.     pchl
  394. exyc4:    db    0ddh,0e1h
  395.     pop    h
  396.     dw    inxix
  397.     dw    inxix
  398.     dw    inxix
  399.     dw    inxix
  400.     db    0ddh,07eh,00h
  401.     ora    a
  402.     jnz    exyc1
  403. exyc5:    lxi    h,0
  404.     pop    b
  405.     ret
  406. exyc6:    lxi    h,1
  407.     pop    b
  408.     ret
  409.  
  410.     endfunc
  411. ;
  412. ;=============================================================
  413. ;
  414. ; int hidecur(c)
  415. ;   char c;
  416. ;
  417. ;    Hides the character passed under the cursor (so that
  418. ;    when the cursor is moved then"all secrets will be
  419. ;       made known" (or at least displayed on the screen))!
  420. ;
  421. ;    Returns the cursor address.
  422. ;
  423.     function    hidecur
  424.  
  425.     call    arghak
  426.     push    b
  427.  
  428.     call    getiy            ;we may not have it
  429.     lda    arg1            ;the char to hide
  430.     stiy    a,067h            ;and hide it there!
  431.     call    ptrset            ;get cursor address
  432.  
  433.     pop    b
  434.     ret                ;and return
  435.  
  436.     endfunc
  437.