home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 097.lha / Ic.Source / invadercraft.c < prev    next >
C/C++ Source or Header  |  1986-11-20  |  16KB  |  565 lines

  1. /*
  2.  
  3. InvaderCraft von J.Hertel
  4. (C) CW-Publikationen
  5.  
  6. Hauptprogramm  "invadercraft.c"
  7.  
  8.  
  9. Kompilieren und Linken mit Aztec C Version 3.20a.
  10.  
  11. Im Include-Directory muessen sich die Header-Files "invadercraft1.h" und
  12. "invadercraft2.h" befinden!
  13.  
  14. Aufruf:  cc invadercraft -a
  15.          as invadercraft
  16.  
  17. Linken:  ln invadercraft.o lader.o menu.o action.o con.o -lc
  18. Wenn Sound-Files vorhanden und Sound eingeschaltet (s.u.):
  19.          ln invadercraft.o lader.o menu.o action.o con.o sound.o -lc
  20. */
  21.  
  22.  
  23. /* Falls digitalisierte Klaenge verfuegbar, Kommentarzeichen um #define-
  24. Statement entfernen! */
  25. /* schon geschehen */
  26.  
  27. #define SOUND_ON
  28.  
  29.  
  30. /* Falls spezieller Zeichensatz ("fonts:ic/8e + fonts:ic.font") verfuegbar,
  31. Kommentarzeichen um #define-Statement entfernen! */
  32. /* schon geschehen */
  33.  
  34. #define DISKFONT_ON
  35.  
  36.  
  37. #include <intuition/intuition.h>
  38. #include <graphics/gfxbase.h>
  39. #include <graphics/gfxmacros.h>
  40. #include <hardware/dmabits.h>
  41. #include <hardware/custom.h>
  42. #include <exec/memory.h>
  43. #include <libraries/dos.h>
  44. #include <devices/audio.h>
  45.  
  46. /* Vor Compiler-Aufruf unbedingt "invadercraft1.h" und "invadercraft2.h"
  47. in include/ - Directory kopieren! */
  48.  
  49. #include <invadercraft1.h>
  50. #include <invadercraft2.h>
  51.  
  52. int _Dorg();
  53.  
  54. extern struct IOAudio *ioa[];
  55. extern struct format sdata[];
  56. extern int demo;
  57. extern struct liste slots[MAXVERSIONS][SLOTS];
  58. extern long Read(),Write();
  59. extern APTR AllocMem(),OpenLibrary();
  60.  
  61. struct IntuitionBase *IntuitionBase;
  62. struct Library *DiskfontBase;
  63. struct GfxBase *GfxBase;
  64. struct RastPort rp,rp2,rphi;
  65. struct BitMap bmhi,bm,bm2,inb,schb,misb,expb,bunb,dummyb,mistreb,
  66. mutb,bunkerbuff[2],ab1,bssb,bsib,iff;
  67. struct View v,*old;
  68. struct ViewPort vp,vphi;
  69. struct RasInfo ri,ri2,rihi;
  70. struct ColorMap *cm,*cmhi,*GetColorMap();
  71. #ifdef DISKFONT_ON
  72. struct TextAttr textattr={(STRPTR)"ic.font",8,FS_NORMAL,FPF_DISKFONT};
  73. #endif !DISKFONT_ON
  74. #ifndef DISKFONT_ON
  75. struct TextAttr textattr={(STRPTR)"topaz.font",10,FS_NORMAL,FPF_ROMFONT};
  76. #endif !DISKFONT_ON
  77. struct TextFont *font,*OpenDiskFont(),*OpenFont();
  78. struct Custom *custom=0xDFF000;
  79. struct CIA *ciaa=0xBFE001;
  80. struct FileHandle *fh,*Open();
  81. struct Screen *screen,*OpenScreen();
  82. struct NewScreen newscreen={0,0,320,0,4};
  83. struct NewWindow newwindow={0,0,320,256,0,0,0,BACKDROP|BORDERLESS};
  84. struct Window *window,*OpenWindow();
  85. struct Lock *lock;
  86. struct FileInfoBlock *fib;
  87.  
  88. long REV[2]={0,33};
  89. long YA[]={187L,243L};
  90. long YA1[]={186L,242};
  91.  
  92. int titelbildtiefe,kick,trainer;
  93.  
  94. UWORD *colorp,color[40],dunkelcolors[32],dummycolors[32],titelcolors[32];
  95.  
  96. UWORD colorhi[HIAC]={ 0x000,0xddd,0xf80,0x08f };
  97.  
  98. UWORD color1 [AC] ={ 0x000,0x579,0x5ae,0x53a,
  99.                      0xcb6,0xddf,0xfff,0x666,
  100.                      0x000,0xfff,0x888,0xa60,
  101.                      0xb00,0x841,0x045,0x080 };
  102.  
  103. UWORD color2 [AC] ={ 0x000,0x579,0x5ae,0x53a,
  104.                      0xcb6,0xddf,0xfff,0x666,
  105.                      0x000,0x883,0x0af,0xa60,
  106.                      0xb00,0x841,0x045,0x080 };
  107.  
  108. UWORD color3 [40] ={ 0x000,0x579,0x5ae,0x53a,
  109.                      0xcb6,0xddf,0xfff,0x666 };
  110.  
  111.  
  112. main(argc,argv)
  113. int argc;
  114. char *argv[];
  115.  
  116. /* Programm-Anfang
  117. CLI-Parameter dekodieren, Libraries eroeffnen, Bilder und Sounds laden,
  118. Speicherplatz reservieren (in Form von Bitmaps), Dual-Playfield-View
  119. einschalten und Sprung ins Hauptmenu */
  120.  
  121. {
  122.    int i;
  123.  
  124.    if(argc==0)
  125.       exit(1L);
  126.    else if(argc==1 || (argc>1 && *argv[1]!='1' && *argv[1]!='2') ||
  127.     (argc>2 && *argv[2]!='t') ) {
  128.       printf("Syntax: %s <version> <trainer>\n",argv[0]);
  129.       printf("<version>: '1' oder '2', fuer Kickstart Version 1.1 oder 1.2\
  130. \n<trainer>: 't', nur angeben, wenn Trainer erwuenscht.\n");
  131.       exit(1L);
  132.    }
  133.    else {
  134.       if(*argv[1]=='2')
  135.          kick=1;
  136.    }
  137.    if(argc>2)
  138.       trainer=1;
  139.    if((IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",
  140.     REV[kick]))==0) {
  141.       printf("Falsche Kickstart-Diskette! Version 1.2 wird benoetigt.\n");
  142.       closeall(0);
  143.    }
  144.    if((GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0L))==0) {
  145.       printf("Eroeffnen von Graphics-Library erfolglos!\n");
  146.       closeall(0);
  147.    }
  148.    /* Window oeffnen und wieder schliessen, um zu testen, ob erweiterte
  149.       vertikale Aufloesung (256 Pixels) wirklich nutzbar ist. Manchmal
  150.       laesst sich unter Kick1.2 kein Window ueber 200 Zeilen ausdehnen. */
  151.    if(kick) {
  152.       newwindow.Type=WBENCHSCREEN;
  153.       if((window=OpenWindow(&newwindow))==0) {
  154.          printf("Fehler im Amiga-Betriebssytem aufgetreten.\n\
  155. Bitte Amiga mit Ctrl-A-A ruecksetzen!\n");
  156.          closeall(0);
  157.       }
  158.       CloseWindow(window);
  159.    }
  160.    titelbildladen();
  161.  
  162. #ifdef SOUND_ON
  163.    salloc();
  164.    titelsladen();
  165. #endif !SOUND_ON
  166.  
  167. #ifdef DISKFONT_ON
  168.    if((DiskfontBase = (struct Library *)OpenLibrary("diskfont.library",0L))
  169.     ==0) {
  170.       printf("libs:diskfont.library fehlt!\n");
  171.       closeall(0);
  172.    }
  173.    if((font=OpenDiskFont(&textattr))==0) {
  174. #endif !DISKFONT_ON
  175.  
  176. #ifndef DISKFONT_ON
  177.    if((font=OpenFont(&textattr))==0) {
  178. #endif !DISKFONT_ON
  179.  
  180.       printf("Kann den Zeichensatz nicht eroeffnen!\n");
  181.       closeall(0);
  182.    }
  183.    allocmem();
  184.    laden();
  185.  
  186. #ifdef SOUND_ON
  187.    for(i=0;i<ANZSOUNDS-1;i++)    /* Titelsound nicht mehr laden */
  188.       soundladen(i);
  189. #endif !SOUND_ON
  190.  
  191.    titelsstop();
  192.  
  193.    allocbitmap(&bm,3L,XA+2*VX,YA[kick]+2*VY);
  194.    allocbitmap(&bm2,3L,XA+2*VX,YA[kick]+2*VY);
  195.    allocbitmap(&bunkerbuff[0],3L,XA,BKO4);
  196.    allocbitmap(&bunkerbuff[1],3L,XA,BKO4);
  197.    allocbitmap(&dummyb,DUMMYT,DUMMYX,DUMMYY);
  198.  
  199.    Forbid();
  200.  
  201.    old=GfxBase->ActiView;
  202.    InitView(&v); InitVPort(&vp); InitVPort(&vphi);
  203.  
  204.    v.ViewPort=&vphi; vphi.Next=&vp;
  205.    v.DyOffset=old->DyOffset; v.DxOffset=old->DxOffset;
  206.    vphi.ColorMap=cmhi; vphi.RasInfo=&rihi; vphi.DWidth=HIXA;
  207.    vphi.DHeight=HIYA;  vphi.Modes=HIRES;
  208.    vp.ColorMap=cm;  vp.RasInfo=&ri; vp.DWidth=XA; vp.DHeight=YA[kick];
  209.    vp.Modes=DUALPF; vp.DyOffset=BLKLINE+HIYA;
  210.    rihi.BitMap=&bmhi;
  211.    ri.BitMap=&bm;   ri2.BitMap=&bm2;
  212.    ri.RyOffset=VY;  ri2.RyOffset=VY;
  213.    ri.RxOffset=VX;  ri2.RxOffset=VX;
  214.    ri.Next=&ri2;
  215.  
  216.    InitRastPort(&rphi);
  217.    rphi.BitMap=&bmhi;
  218.    InitRastPort(&rp); InitRastPort(&rp2);
  219.    SetDrMd(&rp,JAM1); SetDrMd(&rp2,JAM1);
  220.    rp.BitMap=&bm; rp2.BitMap=&bm2;
  221.  
  222.    MakeVPort(&v,&vphi);
  223.    MakeVPort(&v,&vp);
  224.    MrgCop(&v);
  225.  
  226.    SetRast(&rp,0L); SetRast(&rp2,0L); SetRast(&rphi,0L); SetAPen(&rphi,1L);
  227.    SetBPen(&rphi,0L); SetDrMd(&rphi,JAM2); SetFont(&rphi,font);
  228.    SetFont(&rp,font); SetFont(&rp2,font);
  229.    LoadRGB4(&vp,dunkelcolors,(long)AC);
  230.    LoadRGB4(&vphi,dunkelcolors,(long)HIAC);
  231.  
  232.    LoadView(&v);
  233.    sync(); sync();
  234.    ON_DISPLAY
  235.  
  236.    anfang();
  237.  
  238.    Permit();
  239.    LoadView(old);
  240.    WaitTOF();
  241.    ON_SPRITE
  242.    hisave();
  243.    FreeVPortCopLists(&vp); FreeVPortCopLists(&vphi);
  244.    FreeCprList(v.LOFCprList);
  245.    closeall(0);
  246. }
  247.  
  248. titelsstop()
  249.  
  250. /* Titelbild und Titelsound sanft ausblenden, Speicher zurueckgeben,
  251. Screen schliessen  */
  252.  
  253. {
  254.    int i,j;
  255.    UWORD zcol;
  256.  
  257.    for(j=0;j<16;j++) {
  258.       sync();
  259.  
  260. #ifdef SOUND_ON
  261.       soundvol(16,60-j*4,3);
  262.       soundvol(16,60-j*4,4);
  263. #endif !SOUND_ON
  264.  
  265.       sync();
  266.       for(i=0; i < 1<<titelbildtiefe ;i++) {
  267.          zcol=*((UWORD *)screen->ViewPort.ColorMap->ColorTable+i);
  268.          if(zcol&0xf00)
  269.             zcol-=0x100;
  270.          if(zcol&0x0f0)
  271.             zcol-=0x010;
  272.          if(zcol&0x00f)
  273.             zcol-=0x001;
  274.          SetRGB4(&screen->ViewPort,(long)i,(long)zcol/256,(long)(zcol/16)%16,
  275.           (long)zcol%16);
  276.       }
  277.    }
  278.  
  279. #ifdef SOUND_ON
  280.    if(sdata[16].name) {
  281.       ioa[3]->ioa_Request.io_Command=CMD_FLUSH;
  282.       ioa[3]->ioa_Request.io_Flags=IOF_QUICK;
  283.       ioa[4]->ioa_Request.io_Command=CMD_FLUSH;
  284.       ioa[4]->ioa_Request.io_Flags=IOF_QUICK;
  285.       BeginIO(ioa[3]);
  286.       BeginIO(ioa[4]);
  287.       Delay(30L);
  288.       FreeMem(sdata[16].buffer,sdata[16].len);   sdata[16].buffer=0;
  289.    }
  290. #endif !SOUND_ON
  291.  
  292.    CloseScreen(screen);   screen=0;
  293.    OFF_DISPLAY
  294. }
  295.  
  296. soundvol(which,vol,channel)
  297. int which,vol,channel;
  298.  
  299. /* Lautstaerke eines gerade ertoenenden Klangs veraendern
  300.    which   = Soundfilenummer 0...ANZSOUNDS-1
  301.    vol     = Lautstaerke      0...64
  302.    channel = Kanalnummer      1...4  */
  303.  
  304. {
  305. #ifdef SOUND_ON
  306.    if(sdata[which].name) {
  307.       ioa[channel]->ioa_Request.io_Command=ADCMD_PERVOL;
  308.       ioa[channel]->ioa_Request.io_Flags=IOF_QUICK;
  309.       ioa[channel]->ioa_Period=(UWORD)((int)sdata[which].period);
  310.       ioa[channel]->ioa_Volume=vol;
  311.       BeginIO(ioa[channel]);
  312.    }
  313. #endif !SOUND_ON
  314.    ;
  315. }
  316.  
  317. sound(which,deltaf,channel)
  318. int which,deltaf,channel;
  319.  
  320. /* Bestimmten Sound abspielen
  321.    which   = Soundfilenummer  0...ANZSOUNDS-1
  322.    deltaf =  Abweichung von
  323.              vordef. Period
  324.                               je nach Period
  325.    channel = Kanalnummer      1...4         */
  326.  
  327. {
  328. #ifdef SOUND_ON
  329.    if(sdata[which].name && demo==0) {
  330.       ioa[channel]->ioa_Request.io_Command=CMD_FLUSH;
  331.       ioa[channel]->ioa_Request.io_Flags=IOF_QUICK;
  332.       BeginIO(ioa[channel]);
  333.       ioa[channel]->ioa_Request.io_Command=CMD_WRITE;
  334.       ioa[channel]->ioa_Request.io_Flags=ADIOF_PERVOL|IOF_QUICK;
  335.       ioa[channel]->ioa_Data=sdata[which].buffer;
  336.       if((int)sdata[which].period+deltaf<90)
  337.          ioa[channel]->ioa_Period=90;
  338.       else
  339.          ioa[channel]->ioa_Period=(UWORD)((int)sdata[which].period+deltaf);
  340.       ioa[channel]->ioa_Cycles=sdata[which].cycles;
  341.       ioa[channel]->ioa_Length=sdata[which].len;
  342.       ioa[channel]->ioa_Volume=sdata[which].volume;
  343.       BeginIO(ioa[channel]);
  344.    }
  345. #endif !SOUND_ON
  346.    ;
  347. }
  348.  
  349. laden()
  350.  
  351. /* IFF-Bilder (fuer Animation der Invaders,Schuesse...) laden, in
  352. die dafuer vorgesehenen Bitmaps kopieren und Highscore-Tabelle laden
  353. bzw., wenn nicht vorhanden, initialisieren. */
  354.  
  355. {
  356.    int i,j,k;
  357.  
  358.    getiff("ic.data:lo-res/about",&iff,&color3[8]);
  359.    BltBitMap(&iff,0L,0L,&ab1,0L,0L,ABOUTWIDTH,ABOUTHEIGHT,0xc0L,7L);
  360.    freebitmap(&iff);
  361.    getiff("ic.data:lo-res/invader1",&iff,color);
  362.    BltBitMap(&iff,0L,0L,&inb,0L,0L,320L,INY*PHASEN,0xc0L,0x7L);
  363.    freebitmap(&iff);
  364.    getiff("ic.data:lo-res/invader2",&iff,dummycolors);
  365.    BltBitMap(&iff,0L,0L,&inb,320L,0L,320L,INY*PHASEN,0xc0L,0x7L);
  366.    freebitmap(&iff);
  367.    getiff("ic.data:lo-res/invader3",&iff,dummycolors);
  368.    BltBitMap(&iff,0L,0L,&inb,640L,0L,320L,INY*PHASEN,0xc0L,0x7L);
  369.    freebitmap(&iff);
  370.    getiff("ic.data:lo-res/schuss",&iff,&color[8]);
  371.    BltBitMap(&iff,0L,0L,&schb,0L,0L,SCHWIDTH,SCHHEIGHT*SCHPHASEN,0xc0L,0x7L);
  372.    freebitmap(&iff);
  373.    getiff("ic.data:lo-res/missile",&iff,dummycolors);
  374.    BltBitMap(&iff,0L,0L,&misb,0L,0L,MISWIDTH,MISHEIGHT*MISPHASEN,0xc0L,0x7L);
  375.    freebitmap(&iff);
  376.    getiff("ic.data:lo-res/explosion",&iff,dummycolors);
  377.    BltBitMap(&iff,0L,0L,&expb,0L,0L,EXPWIDTH,EXPHEIGHT*EXPPHASEN,0xc0L,0x7L);
  378.    freebitmap(&iff);
  379.    getiff("ic.data:lo-res/bunker",&iff,dummycolors);
  380.    BltBitMap(&iff,0L,0L,&bunb,0L,0L,BWIDTH,BHEIGHT,0xc0L,0x7L);
  381.    freebitmap(&iff);
  382.    getiff("ic.data:lo-res/bunkertreffers",&iff,dummycolors);
  383.    BltBitMap(&iff,0L,0L,&bssb,0L,0L,BSSWIDTH,BSSHEIGHT,0xc0L,0x1L);
  384.    freebitmap(&iff);
  385.    getiff("ic.data:lo-res/bunkertrefferi",&iff,dummycolors);
  386.    BltBitMap(&iff,0L,0L,&bsib,0L,0L,BSIWIDTH,BSIHEIGHT,0xc0L,0x1L);
  387.    freebitmap(&iff);
  388.    getiff("ic.data:lo-res/missiletreffer",&iff,dummycolors);
  389.    BltBitMap(&iff,0L,0L,&mistreb,0L,0L,MTWIDTH,MTHEIGHT,0xc0L,0x7L);
  390.    freebitmap(&iff);
  391.    getiff("ic.data:lo-res/mutterschiff",&iff,dummycolors);
  392.    BltBitMap(&iff,0L,0L,&mutb,0L,0L,MUTWIDTH*MUTANZ,
  393.     MUTHEIGHT*(MUTPHASEN+MUTEXPPHASEN),0xc0L,0x7L);
  394.    freebitmap(&iff);
  395.  
  396.    for(k=0;k<MAXVERSIONS;k++)
  397.       for(i=0;i<SLOTS;i++)
  398.          for(j=0;j<8;j++)
  399.             slots[k][i].who[j]='-';
  400.    if((fh=Open("ic.data:highscores",MODE_OLDFILE))==0) {
  401.       return();
  402.    }
  403.    if(Read(fh,slots,(long)sizeof(slots))!=sizeof(slots)) {
  404.       printf("Lesefehler in Datei ic.data:highscores (kein Problem!).\n");
  405.       for(k=0;k<MAXVERSIONS;k++)
  406.          for(i=0;i<SLOTS;i++) {
  407.             for(j=0;j<8;j++)
  408.                slots[k][i].who[j]='-';
  409.             slots[k][i].score=0;
  410.          }
  411.    }
  412.    Close(fh); fh=0;
  413. }
  414.  
  415. hisave()
  416.  
  417. /* Highscore-Tabelle abspeichern */
  418.  
  419. {
  420.    if((fh=Open("ic.data:highscores",MODE_NEWFILE))==NULL) {
  421.       printf("Highscores wurden nicht abgespeichert.\n");
  422.       return();
  423.    }
  424.    if(Write(fh,slots,(long)sizeof(slots))!=sizeof(slots)) {
  425.       printf("Schreibfehler in Datei ic.data:highscores !\n");
  426.    }
  427.    Close(fh); fh=0;
  428.    return();
  429. }
  430.  
  431. allocmem()
  432.  
  433. /* Bitmaps und Colormaps bereitstellen */
  434.  
  435. {
  436.    allocbitmap(&bssb,1L,BSSWIDTH,BSSHEIGHT);
  437.    allocbitmap(&bsib,1L,BSIWIDTH,BSIHEIGHT);
  438.    allocbitmap(&inb,INT,INX,INY*PHASEN);
  439.    allocbitmap(&schb,SCHT,SCHWIDTH,SCHHEIGHT*SCHPHASEN);
  440.    allocbitmap(&misb,MIST,MISWIDTH,MISHEIGHT*MISPHASEN);
  441.    allocbitmap(&expb,EXPT,EXPWIDTH,EXPHEIGHT*(EXPPHASEN+1));
  442.    allocbitmap(&bunb,BT,BWIDTH,BHEIGHT);
  443.    allocbitmap(&mistreb,MTT,MTWIDTH,MTHEIGHT);
  444.    allocbitmap(&mutb,MUTT,MUTWIDTH*MUTANZ,MUTHEIGHT*(MUTEXPPHASEN+1+
  445.     MUTPHASEN));
  446.    allocbitmap(&bmhi,HIT,HIXA,HIYA);
  447.    allocbitmap(&ab1,3L,320L,38L);
  448.    if((cm=GetColorMap((long)AC))==0) {
  449.       printf("GetColorMap() erfolglos...\n");
  450.       closeall(1);
  451.    }
  452.    if((cmhi=GetColorMap((long)HIAC))==0) {
  453.       printf("GetColorMap() erfolglos...\n");
  454.       closeall(1);
  455.    }
  456. }
  457.  
  458. titelbildladen()
  459.  
  460. /* Titelbild laden; Format: 320x200 oder 320x256 max. 32 Farben */
  461.  
  462. {
  463.    UWORD zcol;
  464.    int j,i;
  465.  
  466.    getiff("ic.data:lo-res/titelbild",&iff,titelcolors);
  467.    titelbildtiefe=iff.Depth;
  468.    if( iff.BytesPerRow!=40 || (iff.Rows!=200 && iff.Rows!=256) ) {
  469.       printf("Titelbild hat falsches Format\n");
  470.       closeall(0);
  471.    }
  472.    if(kick)
  473.       newscreen.Height=256;
  474.    else
  475.       newscreen.Height=200;
  476.    newscreen.Depth=titelbildtiefe;
  477.    if((screen=OpenScreen(&newscreen))==0) {
  478.       printf("OpenScreen() erfolglos!\n");
  479.       closeall(0);
  480.    }
  481.    LoadRGB4(&screen->ViewPort,dunkelcolors,1L<<titelbildtiefe);
  482.    SetRast(&screen->RastPort,0L);
  483.    if(kick){
  484.       if(iff.Rows==256)
  485.          BltBitMap(&iff,0L,0L,&screen->BitMap,0L,0L,320L,256L,
  486.           0xc0L,0xffL);
  487.       else
  488.          BltBitMap(&iff,0L,0L,&screen->BitMap,0L,28L,320L,200L,
  489.           0xc0L,0xffL);
  490.    }
  491.    else {
  492.       if(iff.Rows==256)
  493.          BltBitMap(&iff,0L,28L,&screen->BitMap,0L,0L,320L,200L,
  494.           0xc0L,0xffL);
  495.       else
  496.          BltBitMap(&iff,0L,0L,&screen->BitMap,0L,0L,320L,200L,
  497.           0xc0L,0xffL);
  498.    }
  499.    freebitmap(&iff);
  500.    for(j=0;j<15;j++) {
  501.       sync();
  502.       for(i=0; i < 1<<titelbildtiefe ;i++) {
  503.          zcol=*((UWORD *)screen->ViewPort.ColorMap->ColorTable+i);
  504.          if((zcol&0xf00) < (titelcolors[i]&0xf00))
  505.             zcol+=0x100;
  506.          if((zcol&0x0f0) < (titelcolors[i]&0x0f0))
  507.             zcol+=0x010;
  508.          if((zcol&0x00f) < (titelcolors[i]&0x00f))
  509.             zcol+=0x001;
  510.          SetRGB4(&screen->ViewPort,(long)i,(long)zcol/256,
  511.           (long)(zcol/16)%16,(long)zcol%16);
  512.       }
  513.    }
  514. }
  515.  
  516. closeall(fehler)
  517. int fehler;
  518.  
  519. /* Alle reservierten Speicherstuecke und Bitmaps freigeben, Fonts,
  520. Libraries,usw. schliessen */
  521.  
  522. {
  523.    int i;
  524.  
  525.    ON_DISPLAY
  526. #ifdef SOUND_ON
  527.    frees();
  528.    for(i=0;i<ANZSOUNDS;i++)
  529.       if(sdata[i].buffer)
  530.          FreeMem(sdata[i].buffer,sdata[i].len);
  531.    if(lock)
  532.       UnLock(lock);
  533.    if(fib)
  534.       FreeMem(fib,(long)sizeof(struct FileInfoBlock));
  535. #endif !SOUND_ON
  536.    if(fh)
  537.       Close(fh);
  538.    if(font)
  539.       CloseFont(font);
  540.    if(cmhi)
  541.       FreeColorMap(cmhi);
  542.    if(cm)
  543.       FreeColorMap(cm);
  544.    freebitmap(&iff);           freebitmap(&ab1);     freebitmap(&bmhi);
  545.    freebitmap(&mutb);          freebitmap(&mistreb); freebitmap(&dummyb);
  546.    freebitmap(&bunb);          freebitmap(&expb);    freebitmap(&misb);
  547.    freebitmap(&schb);          freebitmap(&bm);      freebitmap(&bm2);
  548.    freebitmap(&inb);           freebitmap(&bssb);    freebitmap(&bsib);
  549.    freebitmap(&bunkerbuff[1]); freebitmap(&bunkerbuff[0]);
  550.    if(screen)
  551.       CloseScreen(screen);
  552. #ifdef DISKFONT_ON
  553.    if(DiskfontBase)
  554.       CloseLibrary(DiskfontBase);
  555. #endif !DISKFONT_ON
  556.    if(GfxBase)
  557.       CloseLibrary(GfxBase);
  558.    if(IntuitionBase)
  559.       CloseLibrary(IntuitionBase);
  560.    if(fehler)
  561.       printf("Zu wenig Speicherplatz!\n");
  562.    exit(0);
  563. }
  564.  
  565.