attempt more warning cleanup

This commit is contained in:
Dagen Brock 2016-10-23 21:17:22 -05:00
parent 9337414c17
commit d5ef2a2a11
8 changed files with 160 additions and 165 deletions

1
.gitignore vendored
View File

@ -13,5 +13,6 @@ src/size_c.h
gsplus gsplus
gsportx gsportx
gsport gsport
*.exe
*.gsp *.gsp

View File

@ -1,21 +1,21 @@
/* /*
GSPLUS - Advanced Apple IIGS Emulator Environment GSPLUS - Advanced Apple IIGS Emulator Environment
Copyright (C) 2010 - 2011 by GSport contributors Copyright (C) 2010 - 2011 by GSport contributors
Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your Free Software Foundation; either version 2 of the License, or (at your
option) any later version. option) any later version.
This program is distributed in the hope that it will be useful, but This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details. for more details.
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
@ -42,7 +42,7 @@
Extensively rewritten to provide full emulation of the Apple ImageWriter II Extensively rewritten to provide full emulation of the Apple ImageWriter II
and LQ printers. and LQ printers.
Information used to write this emulator was provided by Information used to write this emulator was provided by
Apple's "ImageWriter II Technical Reference Manual" Apple's "ImageWriter II Technical Reference Manual"
ISBN# 0-201-17766-8 ISBN# 0-201-17766-8
and and
@ -56,14 +56,14 @@
//#include "png.h" //#include "png.h"
//#pragma comment( lib, "libpng.lib" ) //#pragma comment( lib, "libpng.lib" )
//#pragma comment (lib, "zdll.lib" ) //#pragma comment (lib, "zdll.lib" )
static Imagewriter* defaultImagewriter = NULL; static Imagewriter* defaultImagewriter = NULL;
static FILE *textPrinterFile = NULL; static FILE *textPrinterFile = NULL;
#ifdef WIN32 #ifdef WIN32
const char* const textPrinterFileName = ".\\printer.txt"; const char* const textPrinterFileName = ".\\printer.txt";
#else #else
const char* const textPrinterFileName = "./printer.txt"; const char* const textPrinterFileName = "./printer.txt";
#endif #endif
@ -129,25 +129,25 @@ Imagewriter::Imagewriter(Bit16u dpi, Bit16u paperSize, Bit16u bannerSize, char*
this->dpi = dpi; this->dpi = dpi;
// Create page // Create page
page = SDL_CreateRGBSurface( page = SDL_CreateRGBSurface(
SDL_SWSURFACE, SDL_SWSURFACE,
(Bitu)(defaultPageWidth*dpi), (Bitu)(defaultPageWidth*dpi),
(Bitu)(defaultPageHeight*dpi), (Bitu)(defaultPageHeight*dpi),
8, 8,
0, 0,
0, 0,
0, 0,
0); 0);
// Set a grey palette // Set a grey palette
SDL_Palette* palette = page->format->palette; SDL_Palette* palette = page->format->palette;
for (Bitu i=0; i<32; i++) for (Bitu i=0; i<32; i++)
{ {
palette->colors[i].r =255; palette->colors[i].r =255;
palette->colors[i].g =255; palette->colors[i].g =255;
palette->colors[i].b =255; palette->colors[i].b =255;
} }
// 0 = all white needed for logic 000 // 0 = all white needed for logic 000
FillPalette( 0, 0, 0, 1, palette); FillPalette( 0, 0, 0, 1, palette);
// 1 = magenta* 001 // 1 = magenta* 001
@ -187,9 +187,9 @@ Imagewriter::Imagewriter(Bit16u dpi, Bit16u paperSize, Bit16u bannerSize, char*
// correct resulting color. // correct resulting color.
// i.e. magenta on blank page yyy=001 // i.e. magenta on blank page yyy=001
// then yellow on magenta 001 | 100 = 101 = red // then yellow on magenta 001 | 100 = 101 = red
color=COLOR_BLACK; color=COLOR_BLACK;
curFont = NULL; curFont = NULL;
charRead = false; charRead = false;
autoFeed = false; autoFeed = false;
@ -204,28 +204,28 @@ Imagewriter::Imagewriter(Bit16u dpi, Bit16u paperSize, Bit16u bannerSize, char*
ShowCursor(1); ShowCursor(1);
PRINTDLG pd; PRINTDLG pd;
pd.lStructSize = sizeof(PRINTDLG); pd.lStructSize = sizeof(PRINTDLG);
pd.hDevMode = (HANDLE) NULL; pd.hDevMode = (HANDLE) NULL;
pd.hDevNames = (HANDLE) NULL; pd.hDevNames = (HANDLE) NULL;
pd.Flags = PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE; pd.Flags = PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE;
pd.hwndOwner = NULL; pd.hwndOwner = NULL;
pd.hDC = (HDC) NULL; pd.hDC = (HDC) NULL;
pd.nFromPage = 0xFFFF; pd.nFromPage = 0xFFFF;
pd.nToPage = 0xFFFF; pd.nToPage = 0xFFFF;
pd.nMinPage = 1; pd.nMinPage = 1;
pd.nMaxPage = 0xFFFF; pd.nMaxPage = 0xFFFF;
pd.nCopies = 1; pd.nCopies = 1;
pd.hInstance = NULL; pd.hInstance = NULL;
pd.lCustData = 0L; pd.lCustData = 0L;
pd.lpfnPrintHook = (LPPRINTHOOKPROC) NULL; pd.lpfnPrintHook = (LPPRINTHOOKPROC) NULL;
pd.lpfnSetupHook = (LPSETUPHOOKPROC) NULL; pd.lpfnSetupHook = (LPSETUPHOOKPROC) NULL;
pd.lpPrintTemplateName = (LPCSTR) NULL; pd.lpPrintTemplateName = (LPCSTR) NULL;
pd.lpSetupTemplateName = (LPCSTR) NULL; pd.lpSetupTemplateName = (LPCSTR) NULL;
pd.hPrintTemplate = (HANDLE) NULL; pd.hPrintTemplate = (HANDLE) NULL;
pd.hSetupTemplate = (HANDLE) NULL; pd.hSetupTemplate = (HANDLE) NULL;
if(!PrintDlg(&pd)) if(!PrintDlg(&pd))
{ {
//If user presses cancel, warn them with a dialog and switch output to bitmap files //If user presses cancel, warn them with a dialog and switch output to bitmap files
this->output = "bmp"; this->output = "bmp";
MessageBox(NULL,"You did not select a printer.\nAll printer output will be saved as bitmap files.\nTo select a printer, press F4 and select 'Reset Virtual ImageWriter'",NULL,MB_ICONEXCLAMATION); MessageBox(NULL,"You did not select a printer.\nAll printer output will be saved as bitmap files.\nTo select a printer, press F4 and select 'Reset Virtual ImageWriter'",NULL,MB_ICONEXCLAMATION);
} }
@ -252,7 +252,7 @@ void Imagewriter::resetPrinterHard()
void Imagewriter::resetPrinter() void Imagewriter::resetPrinter()
{ {
#ifdef HAVE_SDL #ifdef HAVE_SDL
printRes = 0; printRes = 0;
color=COLOR_BLACK; color=COLOR_BLACK;
curX = curY = 0.0; curX = curY = 0.0;
ESCSeen = false; ESCSeen = false;
@ -364,11 +364,11 @@ void Imagewriter::updateFont()
default: default:
fontName = g_imagewriter_fixed_font; fontName = g_imagewriter_fixed_font;
} }
if (FT_New_Face(FTlib, fontName, 0, &curFont)) if (FT_New_Face(FTlib, fontName, 0, &curFont))
{ {
printf("Unable to load font %s\n"); printf("Unable to load font %s\n", fontName);
//LOG_MSG("Unable to load font %s", fontName); //LOG_MSG("Unable to load font %s", fontName);
curFont = NULL; curFont = NULL;
} }
@ -393,7 +393,7 @@ void Imagewriter::updateFont()
actcpi = 20.0; actcpi = 20.0;
horizPoints *= 10.0/20.0; horizPoints *= 10.0/20.0;
vertPoints *= 10.0/12.0; vertPoints *= 10.0/12.0;
} }
} else if (style & STYLE_CONDENSED) horizPoints /= 2.0; } else if (style & STYLE_CONDENSED) horizPoints /= 2.0;
@ -413,7 +413,7 @@ void Imagewriter::updateFont()
} }
FT_Set_Char_Size(curFont, (Bit16u)horizPoints*64, (Bit16u)vertPoints*64, dpi, dpi); FT_Set_Char_Size(curFont, (Bit16u)horizPoints*64, (Bit16u)vertPoints*64, dpi, dpi);
if (style & STYLE_ITALICS || charTables[curCharTable] == 0) if (style & STYLE_ITALICS || charTables[curCharTable] == 0)
{ {
FT_Matrix matrix; FT_Matrix matrix;
@ -532,8 +532,8 @@ bool Imagewriter::processCommandChar(Bit8u ch)
neededParam = 2; neededParam = 2;
break; break;
case 0x4c: // Set left margin at column nnn (ESC L nnn) IW case 0x4c: // Set left margin at column nnn (ESC L nnn) IW
case 0x67: // Print graphics for next nnn * 8 databytes (ESC g nnn) IW case 0x67: // Print graphics for next nnn * 8 databytes (ESC g nnn) IW
case 0x75: // Add one tab stop at nnn (ESC u nnn) IW case 0x75: // Add one tab stop at nnn (ESC u nnn) IW
neededParam = 3; neededParam = 3;
break; break;
case 0x28: // Set horizontal tabs (ESC ( nnn,) IW case 0x28: // Set horizontal tabs (ESC ( nnn,) IW
@ -563,7 +563,7 @@ bool Imagewriter::processCommandChar(Bit8u ch)
default: default:
/*LOG_MSG("PRINTER: Unknown command %c (%02Xh) %c , unable to skip parameters.", /*LOG_MSG("PRINTER: Unknown command %c (%02Xh) %c , unable to skip parameters.",
(ESCCmd & 0x800)?"FS":"ESC",ESCCmd, ESCCmd);*/ (ESCCmd & 0x800)?"FS":"ESC",ESCCmd, ESCCmd);*/
neededParam = 0; neededParam = 0;
ESCCmd = 0; ESCCmd = 0;
return true; return true;
@ -900,7 +900,7 @@ bool Imagewriter::processCommandChar(Bit8u ch)
break; break;
} }
case 0x4b: // Select printing color (ESC K) IW case 0x4b: // Select printing color (ESC K) IW
switch (paramc(0)) switch (paramc(0))
{ {
case 0: break; case 0: break;
@ -912,7 +912,7 @@ bool Imagewriter::processCommandChar(Bit8u ch)
case 6: params[0] = 3; break; case 6: params[0] = 3; break;
} }
if(paramc(0)==0) color = COLOR_BLACK; if(paramc(0)==0) color = COLOR_BLACK;
else color = params[0]<<5; else color = params[0]<<5;
break; break;
case 0x3d: // Internal font ID (ESC = n) IW LQ case 0x3d: // Internal font ID (ESC = n) IW LQ
//Ignore for now //Ignore for now
@ -934,7 +934,7 @@ bool Imagewriter::processCommandChar(Bit8u ch)
x = 0; x = 0;
ESCCmd = 0; ESCCmd = 0;
while (x < PARAM3(0)) while (x < PARAM3(0))
{ {
printChar(params[3]); printChar(params[3]);
x++; x++;
} }
@ -982,7 +982,7 @@ bool Imagewriter::processCommandChar(Bit8u ch)
x = 0; x = 0;
while (x < numHorizTabs) while (x < numHorizTabs)
{ {
if (horiztabs[x] == (Real64)PARAM3(0)*(1/(Real64)cpi)) if (horiztabs[x] == (Real64)PARAM3(0)*(1/(Real64)cpi))
{ printf("Tab Found %d\n",PARAM3(0)); { printf("Tab Found %d\n",PARAM3(0));
horiztabs[x] = 0; horiztabs[x] = 0;
} }
@ -1038,7 +1038,7 @@ bool Imagewriter::processCommandChar(Bit8u ch)
while (x < numHorizTabs) while (x < numHorizTabs)
{ {
if (horiztabs[x] == (Real64)PARAM3(0)*(1/(Real64)cpi)) if (horiztabs[x] == (Real64)PARAM3(0)*(1/(Real64)cpi))
{ {
//printf("We have this tab already! at list entry: %d\n", x); //printf("We have this tab already! at list entry: %d\n", x);
haveStop = true; haveStop = true;
} }
@ -1190,7 +1190,7 @@ void Imagewriter::newPage(bool save, bool resetx)
{ {
//PIC_RemoveEvents(PRINTER_EventHandler); //PIC_RemoveEvents(PRINTER_EventHandler);
if(printer_timout) timeout_dirty=false; if(printer_timout) timeout_dirty=false;
#ifdef HAVE_SDL #ifdef HAVE_SDL
if (save) if (save)
outputPage(); outputPage();
@ -1251,11 +1251,11 @@ void Imagewriter::printChar(Bit8u ch)
// Do not print if no font is available // Do not print if no font is available
if (!curFont) return; if (!curFont) return;
if(ch==0x1) ch=0x20; if(ch==0x1) ch=0x20;
// Find the glyph for the char to render // Find the glyph for the char to render
FT_UInt index = FT_Get_Char_Index(curFont, curMap[ch]); FT_UInt index = FT_Get_Char_Index(curFont, curMap[ch]);
// Load the glyph // Load the glyph
FT_Load_Glyph(curFont, index, FT_LOAD_DEFAULT); FT_Load_Glyph(curFont, index, FT_LOAD_DEFAULT);
@ -1301,7 +1301,7 @@ void Imagewriter::printChar(Bit8u ch)
curX += x_advance; curX += x_advance;
// Draw lines if desired // Draw lines if desired
if ((score != SCORE_NONE) && (style & if ((score != SCORE_NONE) && (style &
(STYLE_UNDERLINE))) (STYLE_UNDERLINE)))
{ {
// Find out where to put the line // Find out where to put the line
@ -1336,7 +1336,7 @@ void Imagewriter::blitGlyph(FT_Bitmap bitmap, Bit16u destx, Bit16u desty, bool a
if (source > 0 && (destx+x < page->w) && (desty+y < page->h) ) { if (source > 0 && (destx+x < page->w) && (desty+y < page->h) ) {
Bit8u* target = (Bit8u*)page->pixels + (x+destx) + (y+desty)*page->pitch; Bit8u* target = (Bit8u*)page->pixels + (x+destx) + (y+desty)*page->pitch;
source>>=3; source>>=3;
if (add) { if (add) {
if (((*target)&0x1f )+ source > 31) *target |= (color|0x1f); if (((*target)&0x1f )+ source > 31) *target |= (color|0x1f);
else { else {
@ -1518,7 +1518,7 @@ void Imagewriter::printBitGraph(Bit8u ch)
SDL_LockSurface(page); SDL_LockSurface(page);
// When page dpi is greater than graphics dpi, the drawn pixels get "bigger" // When page dpi is greater than graphics dpi, the drawn pixels get "bigger"
Bitu pixsizeX=1; Bitu pixsizeX=1;
Bitu pixsizeY=1; Bitu pixsizeY=1;
if(bitGraph.adjacent) { if(bitGraph.adjacent) {
pixsizeX = dpi/bitGraph.horizDens > 0? dpi/bitGraph.horizDens : 1; pixsizeX = dpi/bitGraph.horizDens > 0? dpi/bitGraph.horizDens : 1;
@ -1593,10 +1593,10 @@ static void findNextName(char* front, char* ext, char* fname)
do do
{ {
strcpy(fname, document_path); strcpy(fname, document_path);
printf(fname); printf("%s",fname);
#ifdef WIN32 #ifdef WIN32
const char* const pathstring = ".\\%s%d%s"; const char* const pathstring = ".\\%s%d%s";
#else #else
const char* const pathstring = "./%s%d%s"; const char* const pathstring = "./%s%d%s";
#endif #endif
sprintf(fname+strlen(fname), pathstring, front,i++,ext); sprintf(fname+strlen(fname), pathstring, front,i++,ext);
@ -1607,7 +1607,7 @@ static void findNextName(char* front, char* ext, char* fname)
while (test != NULL ); while (test != NULL );
} }
void Imagewriter::outputPage() void Imagewriter::outputPage()
{/* {/*
SDL_Surface *screen; SDL_Surface *screen;
screen = SDL_SetVideoMode(1024, 768, 16, SDL_DOUBLEBUF | SDL_RESIZABLE); screen = SDL_SetVideoMode(1024, 768, 16, SDL_DOUBLEBUF | SDL_RESIZABLE);
@ -1619,20 +1619,20 @@ SDL_LockSurface(page);
image = SDL_DisplayFormat(page); image = SDL_DisplayFormat(page);
SDL_UnlockSurface(page); SDL_UnlockSurface(page);
SDL_Rect src, dest; SDL_Rect src, dest;
src.x = 0; src.x = 0;
src.y = 0; src.y = 0;
src.w = image->w; src.w = image->w;
src.h = image->h; src.h = image->h;
dest.x = 100; dest.x = 100;
dest.y = 100; dest.y = 100;
dest.w = image->w; dest.w = image->w;
dest.h = image->h; dest.h = image->h;
SDL_BlitSurface(image, &src, screen, &dest); SDL_BlitSurface(image, &src, screen, &dest);
SDL_Flip(screen); SDL_Flip(screen);
SDL_Delay(2000); SDL_Delay(2000);
SDL_FreeSurface(image);*/ SDL_FreeSurface(image);*/
char fname[200]; char fname[200];
@ -1643,30 +1643,30 @@ SDL_FreeSurface(image);*/
{ {
ShowCursor(1); ShowCursor(1);
PRINTDLG pd; PRINTDLG pd;
pd.lStructSize = sizeof(PRINTDLG); pd.lStructSize = sizeof(PRINTDLG);
pd.hDevMode = (HANDLE) NULL; pd.hDevMode = (HANDLE) NULL;
pd.hDevNames = (HANDLE) NULL; pd.hDevNames = (HANDLE) NULL;
pd.Flags = PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE; pd.Flags = PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE;
pd.hwndOwner = NULL; pd.hwndOwner = NULL;
pd.hDC = (HDC) NULL; pd.hDC = (HDC) NULL;
pd.nFromPage = 0xFFFF; pd.nFromPage = 0xFFFF;
pd.nToPage = 0xFFFF; pd.nToPage = 0xFFFF;
pd.nMinPage = 1; pd.nMinPage = 1;
pd.nMaxPage = 0xFFFF; pd.nMaxPage = 0xFFFF;
pd.nCopies = 1; pd.nCopies = 1;
pd.hInstance = NULL; pd.hInstance = NULL;
pd.lCustData = 0L; pd.lCustData = 0L;
pd.lpfnPrintHook = (LPPRINTHOOKPROC) NULL; pd.lpfnPrintHook = (LPPRINTHOOKPROC) NULL;
pd.lpfnSetupHook = (LPSETUPHOOKPROC) NULL; pd.lpfnSetupHook = (LPSETUPHOOKPROC) NULL;
pd.lpPrintTemplateName = (LPCSTR) NULL; pd.lpPrintTemplateName = (LPCSTR) NULL;
pd.lpSetupTemplateName = (LPCSTR) NULL; pd.lpSetupTemplateName = (LPCSTR) NULL;
pd.hPrintTemplate = (HANDLE) NULL; pd.hPrintTemplate = (HANDLE) NULL;
pd.hSetupTemplate = (HANDLE) NULL; pd.hSetupTemplate = (HANDLE) NULL;
if(!PrintDlg(&pd)) if(!PrintDlg(&pd))
{ {
//If user clicks cancel, show warning dialog and force all output to bitmaps as failsafe. //If user clicks cancel, show warning dialog and force all output to bitmaps as failsafe.
MessageBox(NULL,"You did not select a printer.\nAll output from this print job will be saved as bitmap files.",NULL,MB_ICONEXCLAMATION); MessageBox(NULL,"You did not select a printer.\nAll output from this print job will be saved as bitmap files.",NULL,MB_ICONEXCLAMATION);
findNextName("page", ".bmp", &fname[0]); findNextName((char *)"page", (char *)".bmp", &fname[0]);
SDL_SaveBMP(page, fname); //Save first page as bitmap. SDL_SaveBMP(page, fname); //Save first page as bitmap.
outputHandle = printerDC; outputHandle = printerDC;
printerDC = NULL; printerDC = NULL;
@ -1682,7 +1682,7 @@ SDL_FreeSurface(image);*/
} }
if (!printerDC) //Fall thru for subsequent pages if printer dialog was cancelled. if (!printerDC) //Fall thru for subsequent pages if printer dialog was cancelled.
{ {
findNextName("page", ".bmp", &fname[0]); findNextName((char *)"page", (char *)".bmp", &fname[0]);
SDL_SaveBMP(page, fname); //Save remaining pages. SDL_SaveBMP(page, fname); //Save remaining pages.
return; return;
} }
@ -1781,8 +1781,8 @@ SDL_FreeSurface(image);*/
else if (strcasecmp(output, "png") == 0) else if (strcasecmp(output, "png") == 0)
{ {
// Find a page that does not exists // Find a page that does not exists
findNextName("page", ".png", &fname[0]); findNextName((char *)"page", (char *)".png", &fname[0]);
png_structp png_ptr; png_structp png_ptr;
png_infop info_ptr; png_infop info_ptr;
png_bytep * row_pointers; png_bytep * row_pointers;
@ -1791,7 +1791,7 @@ SDL_FreeSurface(image);*/
/* Open the actual file */ /* Open the actual file */
FILE * fp=fopen(fname,"wb"); FILE * fp=fopen(fname,"wb");
if (!fp) if (!fp)
{ {
//LOG(LOG_MISC,LOG_ERROR)("PRINTER: Can't open file %s for printer output", fname); //LOG(LOG_MISC,LOG_ERROR)("PRINTER: Can't open file %s for printer output", fname);
return; return;
@ -1809,7 +1809,7 @@ SDL_FreeSurface(image);*/
/* Finalize the initing of png library */ /* Finalize the initing of png library */
png_init_io(png_ptr, fp); png_init_io(png_ptr, fp);
png_set_compression_level(png_ptr,Z_BEST_COMPRESSION); png_set_compression_level(png_ptr,Z_BEST_COMPRESSION);
/* set other zlib parameters */ /* set other zlib parameters */
png_set_compression_mem_level(png_ptr, 8); png_set_compression_mem_level(png_ptr, 8);
png_set_compression_strategy(png_ptr,Z_DEFAULT_STRATEGY); png_set_compression_strategy(png_ptr,Z_DEFAULT_STRATEGY);
@ -1817,11 +1817,11 @@ SDL_FreeSurface(image);*/
png_set_compression_method(png_ptr, 8); png_set_compression_method(png_ptr, 8);
png_set_compression_buffer_size(png_ptr, 8192); png_set_compression_buffer_size(png_ptr, 8192);
png_set_IHDR(png_ptr, info_ptr, page->w, page->h, png_set_IHDR(png_ptr, info_ptr, page->w, page->h,
8, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, 8, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
for (i=0;i<256;i++) for (i=0;i<256;i++)
{ {
palette[i].red = page->format->palette->colors[i].r; palette[i].red = page->format->palette->colors[i].r;
palette[i].green = page->format->palette->colors[i].g; palette[i].green = page->format->palette->colors[i].g;
@ -1833,12 +1833,12 @@ SDL_FreeSurface(image);*/
// Allocate an array of scanline pointers // Allocate an array of scanline pointers
row_pointers = (png_bytep*)malloc(page->h*sizeof(png_bytep)); row_pointers = (png_bytep*)malloc(page->h*sizeof(png_bytep));
for (i=0; i<page->h; i++) for (i=0; i<page->h; i++)
row_pointers[i] = ((Bit8u*)page->pixels+(i*page->pitch)); row_pointers[i] = ((Bit8u*)page->pixels+(i*page->pitch));
// tell the png library what to encode. // tell the png library what to encode.
png_set_rows(png_ptr, info_ptr, row_pointers); png_set_rows(png_ptr, info_ptr, row_pointers);
// Write image to file // Write image to file
png_write_png(png_ptr, info_ptr, 0, NULL); png_write_png(png_ptr, info_ptr, 0, NULL);
@ -1846,13 +1846,13 @@ SDL_FreeSurface(image);*/
SDL_UnlockSurface(page); SDL_UnlockSurface(page);
/*close file*/ /*close file*/
fclose(fp); fclose(fp);
/*Destroy PNG structs*/ /*Destroy PNG structs*/
png_destroy_write_struct(&png_ptr, &info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr);
/*clean up dynamically allocated RAM.*/ /*clean up dynamically allocated RAM.*/
free(row_pointers); free(row_pointers);
} }
@ -1860,7 +1860,7 @@ SDL_FreeSurface(image);*/
else if (strcasecmp(output, "colorps") == 0) else if (strcasecmp(output, "colorps") == 0)
{ {
FILE* psfile = NULL; FILE* psfile = NULL;
// Continue postscript file? // Continue postscript file?
if (outputHandle != NULL) if (outputHandle != NULL)
psfile = (FILE*)outputHandle; psfile = (FILE*)outputHandle;
@ -1869,12 +1869,12 @@ SDL_FreeSurface(image);*/
if (psfile == NULL) if (psfile == NULL)
{ {
if (!multipageOutput) if (!multipageOutput)
findNextName("page", ".ps", &fname[0]); findNextName((char *)"page", (char *)".ps", &fname[0]);
else else
findNextName("doc", ".ps", &fname[0]); findNextName((char *)"doc", (char *)".ps", &fname[0]);
psfile = fopen(fname, "wb"); psfile = fopen(fname, "wb");
if (!psfile) if (!psfile)
{ {
//LOG(LOG_MISC,LOG_ERROR)("PRINTER: Can't open file %s for printer output", fname); //LOG(LOG_MISC,LOG_ERROR)("PRINTER: Can't open file %s for printer output", fname);
return; return;
@ -1945,7 +1945,7 @@ SDL_FreeSurface(image);*/
{ {
// Find end of heterogenous area // Find end of heterogenous area
Bit8u diffCount = 1; Bit8u diffCount = 1;
while (diffCount < 128 && diffCount+pix < numpix && while (diffCount < 128 && diffCount+pix < numpix &&
( (
(diffCount+pix < numpix-2) (diffCount+pix < numpix-2)
|| (templine[pix+diffCount] != templine[pix+diffCount+1]) || (templine[pix+diffCount] != templine[pix+diffCount+1])
@ -1985,7 +1985,7 @@ SDL_FreeSurface(image);*/
{ {
FILE* psfile = NULL; FILE* psfile = NULL;
printf("%d\n",getPixel(2)); printf("%d\n",getPixel(2));
// Continue postscript file? // Continue postscript file?
if (outputHandle != NULL) if (outputHandle != NULL)
psfile = (FILE*)outputHandle; psfile = (FILE*)outputHandle;
@ -1994,12 +1994,12 @@ SDL_FreeSurface(image);*/
if (psfile == NULL) if (psfile == NULL)
{ {
if (!multipageOutput) if (!multipageOutput)
findNextName("page", ".ps", &fname[0]); findNextName((char *)"page", (char *)".ps", &fname[0]);
else else
findNextName("doc", ".ps", &fname[0]); findNextName((char *)"doc", (char *)".ps", &fname[0]);
psfile = fopen(fname, "wb"); psfile = fopen(fname, "wb");
if (!psfile) if (!psfile)
{ {
//LOG(LOG_MISC,LOG_ERROR)("PRINTER: Can't open file %s for printer output", fname); //LOG(LOG_MISC,LOG_ERROR)("PRINTER: Can't open file %s for printer output", fname);
return; return;
@ -2052,7 +2052,7 @@ SDL_FreeSurface(image);*/
{ {
// Find end of heterogenous area // Find end of heterogenous area
Bit8u diffCount = 1; Bit8u diffCount = 1;
while (diffCount < 128 && diffCount+pix < numpix && while (diffCount < 128 && diffCount+pix < numpix &&
( (
(diffCount+pix < numpix-2) (diffCount+pix < numpix-2)
|| (getPixel(pix+diffCount) != getPixel(pix+diffCount+1)) || (getPixel(pix+diffCount) != getPixel(pix+diffCount+1))
@ -2088,9 +2088,9 @@ SDL_FreeSurface(image);*/
} }
} }
else else
{ {
// Find a page that does not exists // Find a page that does not exists
findNextName("page", ".bmp", &fname[0]); findNextName((char *)"page", (char *)".bmp", &fname[0]);
SDL_SaveBMP(page, fname); SDL_SaveBMP(page, fname);
} }
} }
@ -2129,7 +2129,7 @@ void Imagewriter::fprintASCII85(FILE* f, Bit16u b)
// Make sure a line never starts with a % (which may be mistaken as start of a comment) // Make sure a line never starts with a % (which may be mistaken as start of a comment)
if (ASCII85CurCol == 0 && buffer[0] == '%') if (ASCII85CurCol == 0 && buffer[0] == '%')
fprintf(f, " "); fprintf(f, " ");
for (int i=0; i<((b != 257)?5:ASCII85BufferPos+1); i++) for (int i=0; i<((b != 257)?5:ASCII85BufferPos+1); i++)
{ {
fprintf(f, "%c", buffer[i]); fprintf(f, "%c", buffer[i]);
@ -2231,9 +2231,8 @@ Bit8u Imagewriter::getPixel(Bit32u num) {
} }
#endif // HAVE_SDL #endif // HAVE_SDL
//Interfaces to C code //Interfaces to C code
extern "C" void imagewriter_init(int pdpi, int ppaper, int banner, char* poutput, bool mpage) extern "C" void imagewriter_init(int pdpi, int ppaper, int banner, char* poutput, bool mpage)
{ {
if (defaultImagewriter != NULL) return; //if Imagewriter on this port is initialized, reuse it if (defaultImagewriter != NULL) return; //if Imagewriter on this port is initialized, reuse it

View File

@ -1,23 +1,23 @@
/* /*
GSPLUS - Advanced Apple IIGS Emulator Environment GSPLUS - Advanced Apple IIGS Emulator Environment
Copyright (C) 2010 - 2011 by GSport contributors Copyright (C) 2010 - 2011 by GSport contributors
Copyright (C) 2010 by GSport contributors Copyright (C) 2010 by GSport contributors
Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your Free Software Foundation; either version 2 of the License, or (at your
option) any later version. option) any later version.
This program is distributed in the hope that it will be useful, but This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details. for more details.
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
@ -44,7 +44,7 @@
Extensively rewritten to provide full emulation of the Apple ImageWriter II Extensively rewritten to provide full emulation of the Apple ImageWriter II
printer. printer.
Information used to write this emulator was provided by Information used to write this emulator was provided by
Apple's "ImageWriter II Technical Reference Manual" Apple's "ImageWriter II Technical Reference Manual"
ISBN# 0-201-17766-8 ISBN# 0-201-17766-8
@ -134,7 +134,7 @@ public:
// Hard Reset (like switching printer off and on) // Hard Reset (like switching printer off and on)
void resetPrinterHard(); void resetPrinterHard();
// Set Autofeed value // Set Autofeed value
void setAutofeed(bool feed); void setAutofeed(bool feed);
// Get Autofeed value // Get Autofeed value
@ -143,7 +143,7 @@ public:
// True if printer is unable to process more data right now (do not use printChar) // True if printer is unable to process more data right now (do not use printChar)
bool isBusy(); bool isBusy();
// True if the last sent character was received // True if the last sent character was received
bool ack(); bool ack();
// Manual formfeed // Manual formfeed
@ -165,7 +165,7 @@ private:
// Closes a multipage document // Closes a multipage document
void finishMultipage(); void finishMultipage();
// Output current page // Output current page
void outputPage(); void outputPage();
#ifdef HAVE_SDL #ifdef HAVE_SDL
@ -182,7 +182,7 @@ private:
// Reconfigures printer parameters after changing soft-switches with ESC Z and ESC D // Reconfigures printer parameters after changing soft-switches with ESC Z and ESC D
void updateSwitch(); void updateSwitch();
// Overprints a slash over zero if softswitch B-1 is set // Overprints a slash over zero if softswitch B-1 is set
void slashzero(Bit16u penX, Bit16u penY); void slashzero(Bit16u penX, Bit16u penY);
@ -300,7 +300,7 @@ private:
//Interfaces to C code //Interfaces to C code
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#else #else
#include <stdbool.h> #include <stdbool.h>

View File

@ -1651,7 +1651,7 @@ static void findNextName(char* front, char* ext, char* fname)
do do
{ {
strcpy(fname, document_path); strcpy(fname, document_path);
printf(fname); printf("%s",fname);
#ifdef WIN32 #ifdef WIN32
const char* const pathstring = ".\\%s%d%s"; const char* const pathstring = ".\\%s%d%s";
#else #else
@ -1887,9 +1887,9 @@ SDL_FreeSurface(image);*/
if (psfile == NULL) if (psfile == NULL)
{ {
if (!multipageOutput) if (!multipageOutput)
findNextName("page", ".ps", &fname[0]); findNextName((char *)"page", (char *)".ps", &fname[0]);
else else
findNextName("doc", ".ps", &fname[0]); findNextName((char *)"doc", (char *)".ps", &fname[0]);
psfile = fopen(fname, "wb"); psfile = fopen(fname, "wb");
if (!psfile) if (!psfile)
@ -1983,7 +1983,7 @@ SDL_FreeSurface(image);*/
else else
{ {
// Find a page that does not exists // Find a page that does not exists
findNextName("page", ".bmp", &fname[0]); findNextName((char *)"page", (char *)".bmp", &fname[0]);
SDL_SaveBMP(page, fname); SDL_SaveBMP(page, fname);
} }
} }

View File

@ -1,23 +1,23 @@
/* /*
GSPLUS - Advanced Apple IIGS Emulator Environment GSPLUS - Advanced Apple IIGS Emulator Environment
Copyright (C) 2016 - Dagen Brock Copyright (C) 2016 - Dagen Brock
Copyright (C) 2010 - 2012 by GSport contributors Copyright (C) 2010 - 2012 by GSport contributors
Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your Free Software Foundation; either version 2 of the License, or (at your
option) any later version. option) any later version.
This program is distributed in the hope that it will be useful, but This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details. for more details.
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
@ -225,7 +225,7 @@ scc_socket_open_outgoing(int port, double dcycs)
/* ARO: inspect the ATDT command to see if there is a decimal port number declared & if so, use it */ /* ARO: inspect the ATDT command to see if there is a decimal port number declared & if so, use it */
/* Format: ATDT<host>,<port> */ /* Format: ATDT<host>,<port> */
/* Example ATDT192.168.1.21,4001 */ /* Example ATDT192.168.1.21,4001 */
char *comma_ptr = strchr(&scc_ptr->modem_cmd_str[0], ','); char *comma_ptr = strchr((const char *)&scc_ptr->modem_cmd_str[0], ',');
if (comma_ptr != NULL) { if (comma_ptr != NULL) {
long custom_port = strtol(comma_ptr + 1, NULL, 10); long custom_port = strtol(comma_ptr + 1, NULL, 10);
*comma_ptr = '\0'; /* null terminate the hostname string at the position of the comma */ *comma_ptr = '\0'; /* null terminate the hostname string at the position of the comma */
@ -446,7 +446,7 @@ scc_socket_telnet_reqs(int port, double dcycs)
int i, j; int i, j;
scc_ptr = &(scc_stat[port]); scc_ptr = &(scc_stat[port]);
for(i = 0; i < 64; i++) { for(i = 0; i < 64; i++) {
j = i >> 5; j = i >> 5;
mask = 1 << (i & 31); mask = 1 << (i & 31);
@ -1004,7 +1004,7 @@ scc_socket_do_cmd_str(int port, double dcycs)
} }
pos++; pos++;
} }
} }
scc_ptr->modem_dial_or_acc_mode = 1; scc_ptr->modem_dial_or_acc_mode = 1;
scc_socket_open_outgoing(port, dcycs); scc_socket_open_outgoing(port, dcycs);

View File

@ -1,7 +1,7 @@
/* /*
GSPLUS - Advanced Apple IIGS Emulator Environment GSPLUS - Advanced Apple IIGS Emulator Environment
Copyright (C) 2016 - Dagen Brock Copyright (C) 2016 - Dagen Brock
Copyright (C) 2010 - 2012 by GSport contributors Copyright (C) 2010 - 2012 by GSport contributors
Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey
@ -46,6 +46,7 @@ int g_doc_saved_ctl = 0;
int g_queued_samps = 0; int g_queued_samps = 0;
int g_queued_nonsamps = 0; int g_queued_nonsamps = 0;
int g_num_osc_interrupting = 0; int g_num_osc_interrupting = 0;
int g_sound_play_depth = 0;
/* Workaround - gcc in cygwin wasn't defining _WIN32, substituted WIN_SOUND instead */ /* Workaround - gcc in cygwin wasn't defining _WIN32, substituted WIN_SOUND instead */
#if defined(HPUX) || defined(__linux__) || defined(WIN_SOUND) || defined(MAC) || defined(HAVE_SDL) #if defined(HPUX) || defined(__linux__) || defined(WIN_SOUND) || defined(MAC) || defined(HAVE_SDL)
@ -639,7 +640,6 @@ send_sound(int real_samps, int size)
{ {
// real_samps = 1, size = 1602 // real_samps = 1, size = 1602
word32 tmp; word32 tmp;
int ret;
if(g_audio_enable == 0) { if(g_audio_enable == 0) {
printf("Entered send_sound but audio off!\n"); printf("Entered send_sound but audio off!\n");
@ -657,16 +657,15 @@ send_sound(int real_samps, int size)
(real_samps << 30) + size); (real_samps << 30) + size);
// Workaround - gcc in cygwin wasn't defining _WIN32 // Workaround - gcc in cygwin wasn't defining _WIN32
#if defined(WIN_SOUND) || defined(MAC) && !defined(HAVE_SDL) #if defined(WIN_SOUND) || defined(MAC) && !defined(HAVE_SDL)
ret = 0;
child_sound_playit(tmp); child_sound_playit(tmp);
#elif defined(HAVE_SDL) #elif defined(HAVE_SDL)
sound_write_sdl( real_samps, size); sound_write_sdl( real_samps, size);
//sdl_send_audio(&g_sound_shm_addr[g_sound_shm_pos], size, real_samps);
#elif defined(__OS2__) #elif defined(__OS2__)
#else #else
/* Although this looks like a big/little-endian issue, since the */ /* Although this looks like a big/little-endian issue, since the */
/* child is also reading an int, it just works with no byte swap */ /* child is also reading an int, it just works with no byte swap */
int ret = 0;
ret = write(g_pipe_fd[1], &tmp, 4); ret = write(g_pipe_fd[1], &tmp, 4);
if(ret != 4) { if(ret != 4) {
halt_printf("send_sound, wr ret: %d, errno: %d\n", ret, errno); halt_printf("send_sound, wr ret: %d, errno: %d\n", ret, errno);
@ -674,14 +673,12 @@ send_sound(int real_samps, int size)
#endif #endif
} }
void void show_c030_state()
show_c030_state()
{ {
show_c030_samps(&(g_samp_buf[0]), 100); show_c030_samps(&(g_samp_buf[0]), 100);
} }
void void show_c030_samps(int *outptr, int num)
show_c030_samps(int *outptr, int num)
{ {
int i; int i;
@ -699,10 +696,7 @@ show_c030_samps(int *outptr, int num)
} }
} }
int g_sound_play_depth = 0; void sound_play(double dsamps)
void
sound_play(double dsamps)
{ {
register word32 start_time1, start_time2, start_time3, start_time4; register word32 start_time1, start_time2, start_time3, start_time4;
register word32 end_time1, end_time2, end_time3; register word32 end_time1, end_time2, end_time3;
@ -1191,7 +1185,6 @@ doc_sound_end(int osc, int can_repeat, double eff_dsamps, double dsamps)
Doc_reg *rptr, *orptr; Doc_reg *rptr, *orptr;
int mode, omode; int mode, omode;
int other_osc; int other_osc;
int one_shot_stop;
int ctl; int ctl;
/* handle osc stopping and maybe interrupting */ /* handle osc stopping and maybe interrupting */

View File

@ -61,7 +61,9 @@ void win32snd_shutdown();
void child_sound_init_win32(); void child_sound_init_win32();
int win32_send_audio(byte *ptr, int size); int win32_send_audio(byte *ptr, int size);
/* prototypes for sdl(2)snd_driver.c functions */
void sound_shutdown_sdl(); void sound_shutdown_sdl();
void sdlsnd_init(word32 *shmaddr);
/* Prototypes for macsnd_driver.c functions */ /* Prototypes for macsnd_driver.c functions */

View File

@ -1,7 +1,7 @@
/* /*
GSPLUS - Advanced Apple IIGS Emulator Environment GSPLUS - Advanced Apple IIGS Emulator Environment
Copyright (C) 2016 - Dagen Brock Copyright (C) 2016 - Dagen Brock
Copyright (C) 2010 - 2012 by GSport contributors Copyright (C) 2010 - 2012 by GSport contributors
Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey
@ -78,7 +78,7 @@ void
reliable_buf_write(word32 *shm_addr, int pos, int size) reliable_buf_write(word32 *shm_addr, int pos, int size)
{ {
byte *ptr; byte *ptr;
int ret; int ret = 0;
if(size < 1 || pos < 0 || pos > SOUND_SHM_SAMP_SIZE || if(size < 1 || pos < 0 || pos > SOUND_SHM_SAMP_SIZE ||
size > SOUND_SHM_SAMP_SIZE || size > SOUND_SHM_SAMP_SIZE ||
@ -144,7 +144,7 @@ child_sound_loop(int read_fd, int write_fd, word32 *shm_addr)
#if defined(HAVE_SDL) #if defined(HAVE_SDL)
//child_sound_init_sdl(); //child_sound_init_sdl();
long rate = sound_init_device_sdl(); sound_init_device_sdl(); // ignores long return value of sample rate
return; return;
#elif defined(__linux__) || defined(OSS) #elif defined(__linux__) || defined(OSS)
child_sound_init_linux(); child_sound_init_linux();