259
#ifdef FEATURE_CPUMEMHISTORY
260
static FILE *pcxdrv_memmap_fd;
261
static char *pcxdrv_memmap_ext_filename;
262
static BYTE *pcxdrv_memmap_pcx_data;
264
static int pcxdrv_close_memmap(BYTE *palette)
266
BYTE pcx_color_prefix[2]="\x0c";
268
fwrite(pcx_color_prefix, 1, 1, pcxdrv_memmap_fd);
270
fwrite(palette, 3*256, 1, pcxdrv_memmap_fd);
272
fclose(pcxdrv_memmap_fd);
273
lib_free(pcxdrv_memmap_pcx_data);
274
lib_free(pcxdrv_memmap_ext_filename);
279
static int pcxdrv_write_memmap(int line, int x_size, BYTE *gfx)
284
color=gfx[(line*x_size)];
286
for (i = 1; i<x_size; i++)
288
if (gfx[(line*x_size)+i]==color)
293
pcxdrv_memmap_pcx_data[j]=0xff;
294
pcxdrv_memmap_pcx_data[j+1]=color;
303
color=gfx[(line*x_size)+i];
310
pcxdrv_memmap_pcx_data[j]=0xc0 | amount;
311
pcxdrv_memmap_pcx_data[j+1]=color;
313
color=gfx[(line*x_size)+i];
320
pcxdrv_memmap_pcx_data[j]=0xc1;
321
pcxdrv_memmap_pcx_data[j+1]=color;
326
pcxdrv_memmap_pcx_data[j]=color;
329
color=gfx[(line*x_size)+i];
339
pcxdrv_memmap_pcx_data[j]=0xc1;
340
pcxdrv_memmap_pcx_data[j+1]=color;
345
pcxdrv_memmap_pcx_data[j]=color;
353
pcxdrv_memmap_pcx_data[j]=0xc0 | amount;
354
pcxdrv_memmap_pcx_data[j+1]=color;
359
if (fwrite(pcxdrv_memmap_pcx_data, j, 1, pcxdrv_memmap_fd)<1)
365
static int pcxdrv_write_file_header_memmap(int x_size, int y_size)
369
memset(header, 0, sizeof(header));
376
util_word_to_le_buf(&header[8], (WORD)(x_size-1));
377
util_word_to_le_buf(&header[10], (WORD)(y_size-1));
379
util_word_to_le_buf(&header[12], (WORD)(0));
380
util_word_to_le_buf(&header[14], (WORD)(0));
383
util_word_to_le_buf(&header[66], (WORD)(x_size));
385
if (fwrite(header, sizeof(header), 1, pcxdrv_memmap_fd)<1)
391
static int pcxdrv_open_memmap(const char *filename, int x_size, int y_size)
393
pcxdrv_memmap_ext_filename=util_add_extension_const(filename, pcx_drv.default_extension);
394
pcxdrv_memmap_fd = fopen(pcxdrv_memmap_ext_filename, "wb");
396
if (pcxdrv_memmap_fd==NULL)
398
lib_free(pcxdrv_memmap_ext_filename);
402
if (pcxdrv_write_file_header_memmap(x_size, y_size)<0)
404
fclose(pcxdrv_memmap_fd);
405
lib_free(pcxdrv_memmap_ext_filename);
409
pcxdrv_memmap_pcx_data = (BYTE *)lib_malloc(x_size*2);
414
static int pcxdrv_save_memmap(const char *filename, int x_size, int y_size, BYTE *gfx, BYTE *palette)
418
if (pcxdrv_open_memmap(filename, x_size, y_size) < 0)
421
for (line = 0; line < y_size; line++)
423
pcxdrv_write_memmap(line, x_size, gfx);
426
if (pcxdrv_close_memmap(palette) < 0)
259
433
static gfxoutputdrv_t pcx_drv =