home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / genie-commodore-file-library / C128CPM / GRC128.ZIP / HEAD.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-15  |  5.4 KB  |  384 lines

  1.  
  2. #include <stdio.h>
  3.  
  4. int rest,count,knum,lnum,num;
  5.  
  6. main(argc,argv)
  7.  
  8. int argc,argv[];
  9.  
  10. { char cmd[4];
  11.   char c;
  12.   int fd;
  13.  
  14.   getarg (1,   cmd,      3,argc,argv);
  15.  
  16.   if (((cmd[0] == '/')&&(cmd[1] == '/'))||(cmd[0] == '?'))
  17.  
  18.     {
  19.       
  20.       if ((fd = fopen ("GRC128.HLP","r")) != NULL)
  21.  
  22.         {   while ((c = fgetc(fd)) != EOF)
  23.  
  24.                      putchar(c);
  25.  
  26.         fclose(fd); }
  27.  
  28.       else
  29.       {  printf(" **  file GRC128.HLP missing ");
  30.          printf("on default drive(s) ! ** \n "); }
  31.  
  32.  
  33.     
  34.     #asm
  35.  
  36.     .z80
  37.     
  38.     push bc
  39.     push de
  40.     push hl
  41.     push af
  42.     push ix
  43.     push iy
  44.     ld hl,(0006d)
  45.     ld bc,10d
  46.     add hl,bc
  47.     inc hl
  48.     inc hl
  49.     inc hl
  50.     ld bc,0005d    ;offset zu remove flag
  51.     sbc hl,bc
  52.     ld a,0ffh
  53.     ld (hl),a  
  54.     pop iy
  55.     pop ix
  56.     pop af
  57.     pop hl
  58.     pop de
  59.     pop bc
  60.     .8080
  61.     #endasm
  62.     printf("\n");
  63.         }
  64.   else
  65.  
  66. if ((cmd[0] == 'O')&&(cmd[1] == 'F')&&(cmd[2] == 'F'))  
  67.  
  68.     {
  69.  
  70.  
  71.       #asm
  72.       .z80
  73.         
  74.     start:    push bc
  75.         push de
  76.         push hl
  77.         push af
  78.         push ix
  79.         push iy
  80.         ld hl,0000h
  81.         ld (num),hl
  82.         ld hl,(0006d)
  83.     loop:    ld bc,10d
  84.         add hl,bc
  85.         ld a,(hl)
  86.         cp "R"
  87.         jp nz,no
  88.         inc hl
  89.         ld a,(hl)
  90.         cp "S"
  91.         jp nz,no
  92.         inc hl
  93.         ld a,(hl)
  94.         cp "X"
  95.         jp nz,no
  96.         inc hl
  97.         ld a,(hl)
  98.         cp "I"
  99.         jp nz,no
  100.         ld de,(num)
  101.         inc de
  102.         ld (num),de
  103.         ld bc,0005d    ;offset zu remove flag
  104.         sbc hl,bc
  105.         ld a,0ffh
  106.         ld (hl),a
  107.         ld bc,04d    ;offset to next:
  108.         sbc hl,bc
  109.         ld c,(hl)
  110.         inc hl
  111.         ld b,(hl)
  112.         ld h,b
  113.         ld l,c
  114.         jp loop
  115.     no:    ld hl,(num)
  116.         ld a,l
  117.         ld hl,(0006d)
  118.         ld bc,5888d
  119.         jp test
  120.     again:    add hl,bc
  121.         dec a
  122.     test:    cp 00h
  123.         jp nz,again
  124.         ld (knum),hl            
  125.         pop iy
  126.         pop ix
  127.         pop af
  128.         pop hl
  129.         pop de
  130.         pop bc
  131.         .8080
  132.  
  133.         #endasm
  134. printf("\n"); 
  135. printf("   ********   REMOVING The Graphic System-Extension   ********  \n");
  136. printf("      *****          (c) Erich Koppensteiner          ***** \n");
  137. printf("            ***               Forstmeisterg. 8            *** \n");
  138. printf("          *             1140,Vienna AUSTRIA           * \n");
  139. printf("\n");
  140.     if (num > 1)
  141.         knum=knum-768;
  142.     #asm
  143.     .z80
  144.     push bc
  145.     push de
  146.     push hl
  147.     push af
  148.     push ix
  149.     push iy
  150.     ld hl,(knum)
  151.     ld bc,255d
  152.     sbc hl,bc
  153.     ld b,h
  154.     ld c,l
  155.     ld a,b
  156.     and 03h
  157.     ld b,a
  158.     ld (rest),bc
  159.     srl h
  160.     rr l
  161.     srl h
  162.     rr l
  163.     srl h
  164.     rr l    
  165.     srl h
  166.     rr l
  167.     srl h
  168.     rr l
  169.     srl h
  170.     rr l    
  171.     srl h
  172.     rr l
  173.     srl h
  174.     rr l
  175.     srl h
  176.     rr l
  177.     srl h
  178.     rr l
  179.     ld (lnum),hl
  180.     pop iy
  181.     pop ix
  182.     pop af
  183.     pop hl
  184.     pop de
  185.     pop bc
  186.     .8080
  187.     #endasm    
  188.     
  189.     rest=rest/10;    
  190. /*    lnum=(knum-255)/1024;  */
  191.     printf("                     [ TPA 0100 -  %x ; %u,%u k  ] \n ",knum,lnum,rest);
  192.                  }            
  193.  
  194.         
  195.   else
  196.     if (((cmd[0] == 'O')&&(cmd[1] == 'N'))||(cmd[0] == NULL))
  197.  
  198.     
  199. {
  200. printf("\n");                    
  201. printf("   ********   LOADING  The Graphic System-Extension   ********  \n");
  202. printf("      *****          (c) Erich Koppensteiner          ***** \n");
  203. printf("            ***               Forstmeisterg. 8            *** \n");
  204. printf("          *             1140,Vienna AUSTRIA           * \n");
  205. printf("\n");                    
  206.       #asm
  207.       .z80
  208.     sstart:    push bc
  209.         push de
  210.         push hl
  211.         push af
  212.         push ix
  213.         push iy
  214.         ld a,00h
  215.         ld (count),a
  216.         ld hl,(0006d)
  217.     sloop:    ld bc,10d
  218.         add hl,bc
  219.         ld a,(hl)
  220.         cp "R"
  221.         jp nz,sno
  222.         inc hl
  223.         ld a,(hl)
  224.         cp "S"
  225.         jp nz,sno
  226.         inc hl
  227.         ld a,(hl)
  228.         cp "X"
  229.         jp nz,sno
  230.         inc hl
  231.         ld a,(hl)
  232.         cp "I"
  233.         jp nz,sno
  234.         ld a,(count)
  235.         inc a
  236.         ld (count),a
  237.         ld bc,0005d    ;offset zu remove flag
  238.         sbc hl,bc
  239.         ld bc,04d    ;offset to next:
  240.         sbc hl,bc
  241.         ld c,(hl)
  242.         inc hl
  243.         ld b,(hl)
  244.         ld h,b
  245.         ld l,c
  246.         jp sloop
  247.     sno:    ld a,(count)
  248.         cp 01h
  249.         jp z,weiter
  250.         push af
  251.         jp hihi
  252. text: db "   ** The Graphic System-Extension has already been loades previously   ** $"
  253. uui:  db "                         ** - not loading twice - ** $"
  254.     hihi:    ld c,09d
  255.         ld de,text
  256.         call 0005d
  257.         ld c,09d
  258.         ld de,uui
  259.         call 0005d
  260.         pop af
  261.         ld hl,(0006d)
  262.         ld bc,10d
  263.         add hl,bc
  264.         inc hl
  265.         inc hl
  266.         inc hl
  267.         ld bc,0005d    ;offset zu remove flag
  268.         sbc hl,bc
  269.         ld a,0ffh
  270.         ld (hl),a
  271.     weiter:    ld hl,(count)
  272.         ld a,l
  273.         ld hl,(0006h)
  274.         cp 01h
  275.         jp z,fur
  276.         ld bc,5120d
  277.         add hl,bc
  278.     fur:    ld (count),hl
  279.         pop iy
  280.         pop ix
  281.         pop af
  282.         pop hl
  283.         pop de
  284.         pop bc
  285.         .8080
  286.  
  287.         #endasm   
  288.  
  289.  /*    lnum=(count-255)/1024;  */
  290.     
  291.     #asm
  292.     .z80
  293.     push bc
  294.     push de
  295.     push hl
  296.     push af
  297.     push ix
  298.     push iy
  299.     ld hl,(count)
  300.     ld bc,255d
  301.     sbc hl,bc
  302.     ld b,h
  303.     ld c,l
  304.     ld a,b
  305.     and 03h
  306.     ld b,a
  307.     ld (rest),bc
  308.     srl h
  309.     rr l
  310.     srl h
  311.     rr l
  312.     srl h
  313.     rr l    
  314.     srl h
  315.     rr l
  316.     srl h
  317.     rr l
  318.     srl h
  319.     rr l    
  320.     srl h
  321.     rr l
  322.     srl h
  323.     rr l
  324.     srl h
  325.     rr l
  326.     srl h
  327.     rr l
  328.     ld (lnum),hl
  329.     pop iy
  330.     pop ix
  331.     pop af
  332.     pop hl
  333.     pop de
  334.     pop bc
  335.     .8080
  336.     #endasm    
  337.     printf("\n");
  338.     rest=rest/10;
  339.     printf("                    [ TPA 0100 -  %x ; %u,%u k ]     \n ",count,lnum,rest);
  340.             }
  341.     else
  342.         { printf("  wrong usage ! ");
  343.           printf("usage is: \"grc128\" ");
  344.                   printf("[\"on\"|\"off\"|\"//\"|\"?\"] \n");
  345.           printf("                         ");
  346.  
  347.           #asm
  348.  
  349.         .z80
  350.  
  351.         push bc
  352.         push de
  353.         push hl
  354.         push af
  355.         push ix
  356.         push iy
  357.         ld hl,(0006d)
  358.         ld bc,10d
  359.         add hl,bc
  360.         inc hl
  361.         inc hl
  362.         inc hl
  363.         ld bc,0005d    ;offset zu remove flag
  364.         sbc hl,bc
  365.         ld a,0ffh
  366.         ld (hl),a
  367.         pop iy
  368.         pop ix
  369.         pop af
  370.         pop hl
  371.         pop de
  372.         pop bc
  373.  
  374.         .8080
  375.  
  376.         #endasm
  377. }
  378.  
  379. }
  380.  
  381.  
  382.  
  383.  
  384.