home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / utility / degadesk / desktop3.c < prev   
Encoding:
C/C++ Source or Header  |  1989-10-11  |  9.0 KB  |  176 lines

  1. ; **************************************************************************
  2. ; This is the source of DESKTOP.ACC, a program that changes the normal gray
  3. ; background with a Degas P?3 file. This source is public domain, but I
  4. ; would appreciate it very much if a program that uses (part) of this
  5. ; source respects the name of the author!
  6. ; **************************************************************************
  7. ; This source is written for Megamax C, with the inline assembly.
  8. ; **************************************************************************
  9. ; This program needs DESKTOP.PRG version 1.0.
  10. ; **************************************************************************
  11. ; Noud van Kruysbergen
  12. ; N.I.C.I.
  13. ; P.O. Box 9104
  14. ; 6500 HE Nijmegen
  15. ; The Netherlands
  16. ; email: kruysbergen@hnykun53.bitnet
  17. ; **************************************************************************
  18. #include <gemdefs.h>
  19. #include <stdio.h>
  20. #include <osbind.h>
  21. #include <gembind.h>
  22.  
  23. int handle;
  24. int menu_id,msgbf[8];
  25. int i;
  26.  
  27. int clip[4]={0,0,639,399};
  28.  
  29. int contrl[12],intin[128],ptsin[128],intout[128],ptsout[128];
  30. int work_out[57],work_in[11]={1,1,1,1,1,1,1,1,1,1,2};
  31.  
  32. extern int gl_apid;
  33. extern long addr_out[2];
  34.  
  35. long picture=0L;
  36. long l,picstart,bufcount,piccount;
  37.  
  38. char newdta[44];
  39. char path[50],file[14];
  40. char t[70];
  41.  
  42. main()
  43. {
  44.      appl_init();
  45.      v_opnvwk(work_in,&handle,work_out);
  46.      vs_clip(handle,-1,clip);
  47.      if (*(long *)intout==0x4e5f4450) picture=*(long *)(intout+4);
  48.      strcpy(path,"A:\\*.P?3");
  49.      file[0]=0;
  50.      path[0]=(char)(Dgetdrv()+65);
  51.      menu_id=menu_register(gl_apid,"  Desktop Picture");
  52.      while ()
  53.      {
  54.           evnt_mesag(msgbf);
  55.           if (msgbf[0]==AC_OPEN && msgbf[4]==menu_id)
  56.           {
  57.                if (picture==0L) form_alert(1,"[3][DESKTOP 1.1 not resident][Cancel]");
  58.                else
  59.                {
  60.                     i=form_alert(3,"[2][| Desktop Picture 2.03|(with DESKTOP.PRG 1.1)|= Noud van Kruysbergen|][P?3|Gray|Cancel]");
  61.                     if (i<3)
  62.                     {
  63.                          wind_update(BEG_UPDATE);
  64.                          form_dial(FMD_START,0,0,0,0,0,0,640,400);
  65.                          if (i==1)
  66.                          {
  67.                               fsel_input(path,file,&i);
  68.                               if (i)
  69.                               {
  70.                                    strcpy(t,path);
  71.                                    i=0;
  72.                                    while(t[i++]!='*' && i<70);
  73.                                    if (i<70)
  74.                                    {
  75.                                         path[i]=0;
  76.                                         t[--i]=0;
  77.                                         strcat(path,".P?3");
  78.                                         strcat(t,file);
  79.                                         if ((handle=Fopen(t,0))>=0)
  80.                                         {
  81.                                              Fseek(34L,handle,0);
  82.                                              i=strlen(file);
  83.                                              if (file[i-2]=='C')
  84.                                              {
  85.                                                   l=Fsetdta(newdta);
  86.                                                   Fsfirst(t,0);
  87.                                                   Fsetdta(l);
  88.                                                   l=*(long *)(newdta+26);
  89.                                                   if (piccount=picstart=Malloc(l))
  90.                                                   {
  91.                                                        l=Fread(handle,l,picstart);
  92.                                                        bufcount=picture;
  93.                                                        do
  94.                                                        {
  95.                                                             asm
  96.                                                             {
  97.                                                                            move.l    piccount(A4),A0
  98.                                                                            move.b    (A0),D0
  99.                                                                            ext.w     D0
  100.                                                                            and.w     #0xff,D0
  101.                                                                            move.w    D0,i(A4)
  102.                                                                            addq.l    #1,piccount(A4)
  103.                                                             }
  104.                                                             if (i<128)
  105.                                                             {
  106.                                                                  asm
  107.                                                                  {
  108.                                                                                 move.l    bufcount(A4),A2
  109.                                                                                 move.l    piccount(A4),A1
  110.                                                                                 move.w    i(A4),D0
  111.                                                                       pic1loop: move.b    (A1)+,(A2)+
  112.                                                                                 dbf       D0,pic1loop
  113.                                                                                 move.l    A1,piccount(A4)
  114.                                                                                 move.l    A2,bufcount(A4)
  115.                                                                  }
  116.                                                             }
  117.                                                             else
  118.                                                             {
  119.                                                                  if (i!=128)
  120.                                                                  {
  121.                                                                       i^=255;
  122.                                                                       asm
  123.                                                                       {
  124.                                                                                      move.l    bufcount(A4),A2
  125.                                                                                      move.l    piccount(A4),A1
  126.                                                                                      move.w    i(A4),D0
  127.                                                                                      addq.w    #1,D0
  128.                                                                            pic2loop: move.b    (A1),(A2)+
  129.                                                                                      dbf       D0,pic2loop
  130.                                                                                      addq.l    #1,piccount(A4)
  131.                                                                                      move.l    A2,bufcount(A4)
  132.                                                                       }
  133.                                                                  }
  134.                                                             }
  135.                                                        }
  136.                                                        while((piccount-picstart<l) && (bufcount-picture<32000L));
  137.                                                        Mfree(picstart);
  138.                                                   }
  139.                                                   else form_error(8);
  140.                                              }
  141.                                              else Fread(handle,32000L,picture);
  142.                                              Fclose(handle);
  143.                                         }
  144.                                         else
  145.                                         {
  146.                                              form_error(2);
  147.                                              file[0]=0;
  148.                                         }
  149.                                    }
  150.                               }
  151.                          }
  152.                          else
  153.                          {
  154.                               asm
  155.                               {
  156.                                              move.l    picture(A4),A0
  157.                                              move.l    A0,A1
  158.                                              move.w    #199,D1
  159.                                    loop1:    adda.l    #80,A1
  160.                                              move.w    #79,D0
  161.                                    loop2:    move.b    #0x55,(A0)+
  162.                                              move.b    #0xaa,(A1)+
  163.                                              dbf       D0,loop2
  164.                                              adda.l    #80,A0
  165.                                              dbf       D1,loop1
  166.                               }
  167.                          }
  168.                          form_dial(FMD_FINISH,0,0,0,0,0,0,640,400);
  169.                          wind_update(END_UPDATE);
  170.                     }
  171.                }
  172.           }
  173.      }
  174. }
  175.  
  176.