Changeset 523
- Timestamp:
- Apr 22, 2011, 4:12:48 AM (11 years ago)
- Location:
- abuse/trunk/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/game.cpp
r518 r523 1268 1268 pal->shift(1); 1269 1269 1270 image *gray = new image( sd.find("gray_pict"), fp);1270 image *gray = new image(fp, sd.find("gray_pict")); 1271 1271 image *smoke[5]; 1272 1272 … … 1275 1275 { 1276 1276 sprintf(nm, "smoke%04d.pcx", i + 1); 1277 smoke[i] = new image( sd.find(nm), fp);1277 smoke[i] = new image(fp, sd.find(nm)); 1278 1278 } 1279 1279 -
abuse/trunk/src/imlib/filter.cpp
r518 r523 16 16 #include "macs.h" 17 17 #include "filter.h" 18 19 extern unsigned char current_background;20 18 21 19 filter::filter(palette *from, palette *to) // creates a conversion filter from one palette to another … … 224 222 i++, source++, dest++) 225 223 { 226 if (!transparent || *source != current_background)224 if (!transparent || *source) 227 225 *dest=fdat[*source]; 228 226 } -
abuse/trunk/src/imlib/image.cpp
r522 r523 26 26 #include "system.h" 27 27 28 extern uint8_t current_background; 29 30 char const *imerr_messages[] = 31 { 32 "No error", 33 "Error occurred while reading", 34 "Incorrect file type", 35 "File is corrupted", 36 "File not found", 37 "Memory allocation trouble", 38 "Operation/file type not supported", 39 "Error occurred while writing, (disk full?)" 40 }; 41 42 43 int16_t imerror=0; 44 int16_t swpfile_num=0; 45 46 int16_t current_error() 47 { return imerror; } 48 49 void clear_errors() 50 { 51 if (imerror) 52 { printf("Program stopped, error : "); 53 if (imerror<=imMAX_ERROR) 54 printf("%s\n", imerr_messages[imerror]); 55 else 56 printf("Unsonsponsered error code, you got trouble\n"); 57 #ifdef __DOS_ONLY 58 sound(300); 59 delay(100); 60 nosound(); 61 #else 62 printf("%c%c\n", 7, 8); 63 #endif 64 exit(1); 65 } 66 } 67 68 void set_error(int16_t x) 69 { imerror=x; } 70 71 int16_t last_error() 72 { 73 int16_t ec; 74 ec=imerror; 75 imerror=0; 76 return ec; 77 } 78 79 linked_list image_list; 80 28 linked_list image_list; // FIXME: only jwindow.cpp needs this 81 29 82 30 image_descriptor::image_descriptor(vec2i size, 83 int keep_dirties, int static_memory)31 int keep_dirties, int static_memory) 84 32 { 85 33 m_clipx1 = 0; m_clipy1 = 0; … … 145 93 { 146 94 m_size = size; 95 m_special = NULL; 147 96 if (create_descriptor || page_buffer) 148 { 149 if (create_descriptor==2) 150 m_special=new image_descriptor(size, 1, (page_buffer!=NULL)); 151 else 152 m_special=new image_descriptor(size, 0, (page_buffer!=NULL)); 153 } 154 else 155 m_special = NULL; 97 m_special = new image_descriptor(size, create_descriptor == 2, 98 (page_buffer != NULL)); 156 99 MakePage(size, page_buffer); 157 100 image_list.add_end(this); … … 159 102 } 160 103 161 image::image(spec_entry *e, bFILE *fp) 162 { 163 fp->seek(e->offset, 0); 104 image::image(bFILE *fp, spec_entry *e /* = NULL */) 105 { 106 if (e) 107 fp->seek(e->offset, 0); 164 108 m_size.x = fp->read_uint16(); 165 109 m_size.y = fp->read_uint16(); … … 172 116 } 173 117 174 image::image(bFILE *fp)175 {176 m_size.x = fp->read_uint16();177 m_size.y = fp->read_uint16();178 m_special = NULL;179 MakePage(m_size, NULL);180 for (int i = 0; i < m_size.y; i++)181 fp->read(scan_line(i), m_size.x);182 image_list.add_end(this);183 m_locked = false;184 }185 186 118 void image::Lock() 187 119 { … … 204 136 void image_uninit() 205 137 { 206 /* FIXME: is this used at all? */ 207 /* image *im; 208 while (image_list.first()) 209 { 210 im=(image *)image_list.first(); 211 image_list.unlink(im); 212 delete im; 213 } */ 214 } 215 216 217 void image_cleanup(int ret, void *arg) 218 { image_uninit(); } 138 while (image_list.first()) 139 { 140 image *im = (image *)image_list.first(); 141 image_list.unlink(im); 142 delete im; 143 } 144 } 145 219 146 220 147 void image_init() 221 148 { 222 uint8_t bt[2]; 223 uint16_t wrd, *up; 224 bt[0]=1; 225 bt[1]=0; 226 up=(uint16_t *)bt; 227 wrd=uint16_to_intel(*up); 228 if (wrd!=0x01) 229 { printf("compiled with wrong endianness, edit system.h and try again\n"); 230 printf("1 (intel) = %d\n", (int)wrd); 231 exit(1); 232 } 233 imerror=0; 234 } 235 236 237 int32_t image::total_pixels(uint8_t background) 238 { 239 int ret = 0; 240 Lock(); 241 for(int i = 0; i < m_size.y; i++) 242 { 243 uint8_t *c = scan_line(i); 244 for (int x = 0; x < m_size.x; x++) 245 if (c[x] != background) 246 ret++; 247 } 248 Unlock(); 249 return ret; 149 ; 250 150 } 251 151 … … 254 154 Lock(); 255 155 if(color == -1) 256 color = current_background;156 color = 0; // transparent 257 157 if(m_special) 258 158 { … … 474 374 i++, source++, dest++) 475 375 { 476 if (*source != current_background)376 if (*source) 477 377 *dest = *source; 478 378 } … … 595 495 { 596 496 for (i=0, source=&pg2[x1], dest=&pg1[x]; i<xlen; i++, source++, dest++) 597 if (*source !=current_background) *dest=*source;497 if (*source) *dest=*source; 598 498 pg1=screen->next_line(y+j, pg1); 599 499 pg2=next_line(y1+j, pg2); … … 668 568 { 669 569 for (i=0, source=&pg2[x1], dest=&pg1[x+xl-1]; i<xl; i++, source++, dest--) 670 if (*source !=current_background) *dest=*source;570 if (*source) *dest=*source; 671 571 } 672 572 else … … 744 644 screen->Unlock(); 745 645 } 746 }747 748 749 750 uint8_t image::brightest_color(palette *pal)751 { uint8_t *p, r, g, b, bri;752 int16_t i, j;753 int32_t brv;754 brv=0; bri=0;755 Lock();756 for (j=0; j<m_size.y; j++)757 {758 p=scan_line(j);759 for (i=0; i<m_size.x; i++)760 { pal->get(p[i], r, g, b);761 if ((int32_t)r*(int32_t)g*(int32_t)b>brv)762 { brv=(int32_t)r*(int32_t)g*(int32_t)b;763 bri=p[i];764 }765 }766 }767 Unlock();768 return bri;769 }770 771 uint8_t image::darkest_color(palette *pal, int16_t noblack)772 { uint8_t *p, r, g, b, bri;773 int16_t i, j;774 int32_t brv, x;775 brv=(int32_t)258*(int32_t)258*(int32_t)258; bri=0;776 Lock();777 for (j=0; j<m_size.y; j++)778 {779 p=scan_line(j);780 for (i=0; i<m_size.x; i++)781 { pal->get(p[i], r, g, b);782 x=(int32_t)r*(int32_t)g*(int32_t)b;783 if (x<brv && (x || !noblack))784 { brv=x;785 bri=p[i];786 }787 }788 }789 Unlock();790 return bri;791 646 } 792 647 -
abuse/trunk/src/imlib/image.h
r521 r523 19 19 #define MAX_DIRTY 200 20 20 21 extern char const *imerr_messages[]; // correspond to imERRORS22 #define imREAD_ERROR 123 #define imINCORRECT_FILETYPE 224 #define imFILE_CORRUPTED 325 #define imFILE_NOT_FOUND 426 #define imMEMORY_ERROR 527 #define imNOT_SUPPORTED 628 #define imWRITE_ERROR 729 #define imMAX_ERROR 730 31 int16_t current_error();32 void clear_errors();33 void set_error(int16_t x);34 int16_t last_error();35 21 void image_init(); 36 22 void image_uninit(); 37 23 extern linked_list image_list; 38 39 typedef struct image_color_t40 {41 uint16_t r;42 uint16_t g;43 uint16_t b;44 } image_color;45 46 class filter;47 48 24 49 25 class dirty_rect : public linked_node … … 117 93 image_descriptor *m_special; 118 94 119 image(spec_entry *e, bFILE *fp); 120 image(bFILE *fp); 95 image(bFILE *fp, spec_entry *e = NULL); 121 96 image(vec2i size, uint8_t *page_buffer = NULL, int create_descriptor = 0); 122 97 ~image(); … … 136 111 return last_scan + m_size.x; 137 112 } 138 int32_t total_pixels(uint8_t background=0);139 113 image *copy(); // makes a copy of an image 140 114 void clear(int16_t color = -1); // -1 is background color 141 void to_24bit(palette &pal);142 115 143 116 vec2i Size() const { return m_size; } … … 197 170 image *create_smooth(int16_t smoothness = 1); // 0 no smoothness 198 171 void unpack_scanline(int16_t line, char bitsperpixel = 1); 199 uint8_t brightest_color(palette *pal);200 172 void flip_x(); 201 173 void flip_y(); 202 uint8_t darkest_color(palette *pal, int16_t noblack = 0);203 174 }; 204 175 -
abuse/trunk/src/imlib/include.cpp
r515 r523 35 35 else fp=fopen(filename,"wb"); 36 36 37 if (!fp) 38 set_error(imWRITE_ERROR); 39 else 37 if (fp) 40 38 { 41 39 fprintf(fp,"/* File produced by Satan Paint (c) 1994 Jonathan Clark */\n\n"); … … 69 67 else fprintf(fp,", "); 70 68 } 69 fclose(fp); 71 70 } 72 fclose(fp);73 71 } 74 72 -
abuse/trunk/src/imlib/pcxread.cpp
r512 r523 51 51 FILE *fp=fopen(filename,"wb"); 52 52 if (!fp) 53 {54 set_error(imWRITE_ERROR);55 53 return ; 56 }57 54 58 55 PCX_header.manufactururer=10; … … 74 71 if (!write_PCX_header(fp)) 75 72 { 76 set_error( imWRITE_ERROR);77 return 73 fclose(fp); 74 return; 78 75 } 79 76 -
abuse/trunk/src/imlib/video.h
r494 r523 24 24 25 25 26 extern unsigned char current_background;27 26 extern int xres,yres; 28 27 extern int xoff,yoff; -
abuse/trunk/src/loader2.cpp
r513 r523 75 75 image *load_image(spec_entry *e, bFILE *fp) 76 76 { 77 image *im = new image( e, fp);77 image *im = new image(fp, e); 78 78 if (scale_mult != 1 || scale_div != 1) 79 79 im->Scale(im->Size() * scale_mult / scale_div); -
abuse/trunk/src/loadgame.cpp
r513 r523 180 180 if (se && se->type==SPEC_IMAGE) 181 181 { 182 thumb_nails[start_num] =new image(se,fp);182 thumb_nails[start_num] = new image(fp, se); 183 183 if (thumb_nails[start_num]->Size().x>max_w) max_w=thumb_nails[start_num]->Size().x; 184 184 if (thumb_nails[start_num]->Size().y>max_h) max_h=thumb_nails[start_num]->Size().y; -
abuse/trunk/src/sdlport/video.cpp
r519 r523 44 44 SDL_Surface *window = NULL, *surface = NULL; 45 45 image *screen = NULL; 46 unsigned char current_background;47 46 int win_xscale, win_yscale, mouse_xscale, mouse_yscale; 48 47 int xres, yres;
Note: See TracChangeset
for help on using the changeset viewer.