Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Sunday, October 25, 2026

Diff for games/_shared/my-graph.c between version 1.4 and 1.5

version 1.4, 2003/07/11 11:41:46 version 1.5, 2003/07/17 21:53:31
Line 11 
Line 11 
  *   *
  */   */
   
 /* $Platon: games/_shared/my-graph.c,v 1.3 2003/06/27 02:18:30 nepto Exp $ */  /* $Platon: games/_shared/my-graph.c,v 1.4 2003/07/11 11:41:46 nepto Exp $ */
   
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
Line 84  void my_graph_close(void) /* {{{ */
Line 84  void my_graph_close(void) /* {{{ */
   
 #if ! PLATON_SYSTEM_MSDOS  #if ! PLATON_SYSTEM_MSDOS
   
   static void *putimage_BGI_cache_pointers[PUTIMAGE_BGI_CACHE_SIZE];
   static void *putimage_BGI_cache_data[PUTIMAGE_BGI_CACHE_SIZE];
   static int putimage_BGI_cache_size = 0;
   
   static void putimage_BGI_cache_free(void)
   {
           register int i;
           for (i = 0; i < putimage_BGI_cache_size; i++) {
                   free(putimage_BGI_cache_data[i]);
                   putimage_BGI_cache_data[i]     = NULL;
                   putimage_BGI_cache_pointers[i] = NULL;
           }
   #if 0
           fprintf(stderr, "putimage_BGI_cache_free(): %d entries freed\n",
                           putimage_BGI_cache_size);
   #endif
   }
   
   void putimage_BGI_cached(const int x, const int y, void *image, const int op) /* {{{ */
   {
           register int i;
           register short width, height;
           for (i = 0; i < putimage_BGI_cache_size; i++) {
                   if (putimage_BGI_cache_pointers[i] == image) {
                           putimage(x, y, putimage_BGI_cache_data[i], op);
                           return;
                   }
           }
           if (putimage_BGI_cache_size == 0) {
                   /* We will free cache at the program exit */
                   atexit(putimage_BGI_cache_free);
           }
           putimage_BGI(x, y, image, op);
           if (putimage_BGI_cache_size == PUTIMAGE_BGI_CACHE_SIZE) {
                   /* Remove first item from buffer */
                   for (i = 1; i < PUTIMAGE_BGI_CACHE_SIZE; i++) {
                           putimage_BGI_cache_data    [i - 1] = putimage_BGI_cache_data    [i];
                           putimage_BGI_cache_pointers[i - 1] = putimage_BGI_cache_pointers[i];
                   }
                   putimage_BGI_cache_size--;
           }
           width     = ((short *) image)[0];
           height    = ((short *) image)[1];
           putimage_BGI_cache_data[putimage_BGI_cache_size] =
                   malloc(imagesize(x, y, x + width, y + height));
           if (putimage_BGI_cache_data[putimage_BGI_cache_size] == NULL) {
                   putimage_BGI_cache_pointers[putimage_BGI_cache_size] = NULL;
           } else {
                   getimage(x, y, x + width, y + height,
                                   putimage_BGI_cache_data[putimage_BGI_cache_size]);
                   putimage_BGI_cache_pointers[putimage_BGI_cache_size] = image;
                   putimage_BGI_cache_size++;
           }
   } /* }}} */
   
 void putimage_BGI(const int x, const int y, void *image, const int op) /* {{{ */  void putimage_BGI(const int x, const int y, void *image, const int op) /* {{{ */
 {  {
         register short width, height;          register short width, height;

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top