home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / falcon / program / x_debug / drivers / moniterm.c < prev    next >
C/C++ Source or Header  |  1992-11-08  |  3KB  |  107 lines

  1.  
  2. /* a Moniterm screen driver for X-Debug
  3.     aka Atari SM194, aka Viking 2/91
  4.     Note that this driver will think the Reflex card is a Moniterm
  5.     
  6.     This driver understands protocol version 1
  7.     
  8.     No screen must be wider than 1280 or taller than 1024 pixels.
  9. */
  10.  
  11. /*
  12.     Compiled with Lattice C 5.06.02
  13.  
  14.     Important: MUST be compiled with:
  15.         -b0    non base relative data
  16.         -v    disable stack checks
  17.     
  18.     Dont use register arguments.
  19.     Either int size is be OK but I use 16-bit ints for smaller prog size.
  20. */
  21.  
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <linea.h>
  25. #include <osbind.h>
  26. #include "driver.h"
  27.  
  28.  
  29. #define    SCREEN    0x00C00000L
  30.  
  31. extern short check_ram(long addr);
  32. short init_monitor(void);
  33.  
  34.  
  35. int main(int argc, char *argv[])
  36. {
  37. struct driver *driver;
  38. int version;
  39. int mode;
  40.  
  41.     linea0();
  42.  
  43.     if (argc<4)
  44.         goto usage;
  45.     if (sscanf(argv[1],"VER=%x",&version)!=1)
  46.         goto usage;
  47.     if (sscanf(argv[2],"BUF=%lx",&driver)!=1)
  48.         goto usage;
  49.     if (sscanf(argv[3],"MODE=%x",&mode)!=1)
  50.         goto usage;
  51.     
  52.     if (check_ram(SCREEN)==0)
  53.         return 10;                        /* if Moniterm not there */    
  54.  
  55.     /* its there. Init the driver structure */
  56.     driver->address = SCREEN;
  57.     driver->planes = 1;
  58.     driver->bytesperline = 160;
  59.     driver->width = 1280;
  60.     driver->height = 960;
  61.     driver->font = -1;                    /* IMPORTANT */
  62.     driver->init = init_monitor;
  63.     driver->start = SCREEN;
  64.     driver->end = SCREEN+0x40000L;        /* it has 256k of RAM */
  65.     driver->gem=driver->tos=0;
  66.  
  67.  
  68.     /* work out if its being used by the system */
  69.     if ((long)Logbase() == SCREEN)    
  70.         {
  71.         long cursor;
  72.         driver->gem=1;
  73.         cursor=(long)V_CUR_AD;
  74.         if ( (cursor>=SCREEN) && (cursor<(SCREEN+0x40000L)) )
  75.             driver->tos=1;                /* if TOS cursor somewhere in the video RAM */
  76.         }
  77.  
  78.     if (mode&0x100)
  79.         driver->height>>=1;                /* halve the height if required */
  80.     return 0;
  81.  
  82. usage:
  83.     printf("X-Debug screen driver for Moniterm Version 1.0\n\
  84. Copyright © 1991 Andy Pennell. All Rights Reserved\n");
  85.  
  86.     if (getenv("SHELL")==NULL)
  87.         Bconin(2);                        /* for non-CLI users (crazy people) */
  88.     return 10;
  89. }
  90.  
  91.  
  92. /*    this initialisation code is called AFTER this program has terminated, so it must not assume
  93.     any registers (eg baseregs) or make library calls that assume files are open (eg printf) or attempt
  94.     to terminate or allocate GEMDOS memory. You have been warned
  95.  
  96.     This function will be called in Supervisor mode.
  97.  
  98.     If for some reason you cannot install, return a non-zero value. This code can initialise hardware registers,
  99.     for example, as no actual initialisation should be performed in main() as the user may not, after all,
  100.     require the services of this monitor.
  101. */
  102.  
  103. short init_monitor(void)
  104. {
  105.     return 0;                    /* always install */
  106. }
  107.