home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 141_01 / pmklib.doc < prev    next >
Text File  |  1985-03-10  |  4KB  |  134 lines

  1. /* pmklib.c -- personal library -- contents:    84 apr 16
  2.     floating-point square root (& dump)
  3.     utility fcns - find punct, fill str, 
  4.         convert filename, hexdump
  5.     evaluate & plot functionsa
  6.     read & set date/time - Newclock80
  7.          primitives for graphics peripheral - TMS9918a
  8.     cursor-control for TRS-80 screen w/ Omikron bios
  9. */
  10.  
  11. /* fp square root */
  12. fpdump (x) char *x ; {    /* hex dump */
  13.  
  14. char *fpsqrt (z, x) char *z, *x ; {    /* z = sqrt (x)    */
  15.  
  16. /* some little utility functions */
  17. int punct (p, s) char *p, *s ;    { /* find punct char */
  18.  
  19. fill (s, n, c) char *s, c ; int n ; { /* fill s with n c's */
  20.  
  21. fix_name (t, f) char *t, *f ; { /* delete ' ', insert '.' */
  22.  
  23. spread (t, f) byte *t, *f ;  { /* serarate name.ext */
  24.  
  25. hexdmp (l, n) byte *l ; int n ; { /* debug tool */
  26.  
  27. /* evaluate & plot function(s) */
  28. comp_pts (npts, nfcns, x, y, llim, delta, f0, f1, f2, f3)
  29. int npts, nfcns ;    float *x, *y, *llim, *delta ;
  30. float *(*f0)(), *(*f1)(), *(*f2)(), *(*f3)() ;
  31. { /* compute array of function-values ; fcns is an array of 
  32. pointers to functions returning pointers to float */
  33.     
  34. plot_pts (npts, nfcns, x, y, scx, scy) int npts, nfcns ;
  35. float *x, *y, *scx, *scy ;    { /* plot points */
  36.  
  37. axes (x, y) { /* plot axis lines */
  38.  
  39. /* -- fcns to read & set Newclock80    */
  40. syst_d (d) char *d ; { /* system date/time, "yymddhhmmss" */
  41. /* read Newclock80, ASCII format    */
  42.  
  43. read_clock (d_t) byte *d_t ;    {
  44.  
  45. show_clock (d_t) byte *d_t ;    {
  46.  
  47. set_clock (d_t, n) byte *d_t ; int n ;    { /* n = offset */
  48.  
  49. /*  - primitives for CHROMAtrs/TMS9918A graphics */
  50. vram_out (addr, data)    /* output to vram thru tms9918a */
  51. unsigned addr, data ;    {
  52.  
  53. vram_o_m (addr, data, count) /* out data byte count times */
  54. unsigned addr, data, count ;    {
  55.  
  56. vram_o_2 (addr, data1, data2) /* out 2 data bytes */
  57. unsigned addr, data1, data2 ;    {
  58.  
  59. vram_o_a (addr, pdata, count) /* out count bytes from array */
  60. unsigned addr, count ; char *pdata ;    {
  61.  
  62. int vram_in (addr)    /* input from vram thru tms9918a */
  63. unsigned addr ;    {
  64.  
  65. vram_i_a (addr, pdata, count)    /* input count bytes */
  66. unsigned addr, count ; char *pdata ;    {
  67.  
  68. vreg_out (reg, data)    /* output to vreg in tms9918a */
  69. unsigned reg, data ;    {
  70.  
  71. mode2 ()    /* set up tms9918 graphics mode 2 */    {
  72.  
  73. cls (back_gr, fore_gr)        /* clear screen */
  74. unsigned back_gr, fore_gr ;        {
  75.  
  76. spr_init ()    /* clear sprite pattern table */    {
  77.  
  78. spr_def (pat_num, pat)    /* define sprite pattern */
  79. char pat_num, pat[32];    {    int i ;
  80.  
  81. spr_patc (sp_num, pat_num, col)    /* set sprite pattern, color */
  82. char sp_num, pat_num, col;    {
  83.  
  84. spr_mov (sp_num, x, y)    /* move sprite to x, y */
  85. char sp_num, x, y ;    {
  86.  
  87. ld_font (font)    /* load font.def, define characters */    
  88. short font[0x60][6] ; /* dot-matrix images, 6 bytes/char */ {
  89.  
  90. cbar ()    /* draw colored bars */    {
  91.  
  92. wr_str (font, x, y, foregr, text)    /* write string */
  93. unsigned x, y, foregr ;    char **font, *text ;    {
  94.  
  95. wr_ch(font, x, y, foregr, ch)    /* write char to screen, G2 */
  96. short font[0x60][6] ; unsigned x, y, foregr, ch ;    {
  97.  
  98. follow (sprite, stk, pat, off, col, x, y)
  99. /* track joystick stk with sprite */
  100. unsigned sprite, stk, pat, off, col, x, y ;    {
  101.  
  102. line (x1, y1, x2, y2, color) /* draw line (x1,y1) to (x2,y2) */
  103. short x1, x2, y1, y2 ; int color ; {
  104.  
  105. set (h, v, col)        /* point on */
  106. unsigned h, v, col ;    {
  107.  
  108. reset (h, v)        /* point off */
  109. unsigned h, v ;    {
  110.  
  111. test (h, v)        /* test point */
  112. unsigned h, v ;    {
  113.  
  114. xycalc (h, v, offset, b_m)    /* find byte & bit for (h, v) */
  115. unsigned h, v, *offset, *b_m ;    {
  116.  
  117. #define TEST 0xA5
  118. vram_test ()     /* write vram, read back */    {
  119.  
  120. vram_err (l, r, w)    {
  121.  
  122. /* TRS-80 screen cursor control, etc */
  123. clear ()    {    /* clear screen, home cursor */
  124.  
  125. cursor (l, c) int l, c ;    {
  126. /* position cursor to line l, col c */
  127.  
  128. curpr (l, c, s)    int l, c; char *s ; {
  129. /* position cursor & print string */
  130.  
  131. regr, text)    /* write string */
  132. unsigned x, y, foregr ;    char **font, *text ;    {
  133.  
  134. wr_ch(font, x, y, foregr, ch)    /* writ