Fix segfault
This commit is contained in:
parent
c9aa43be4e
commit
3ce93636d8
|
@ -1,3 +1,8 @@
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
// Shut compiler up about strcpy() fopen() not being safe
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS 1
|
||||||
|
#endif // _MSC_VER
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h> // uint8_t
|
#include <stdint.h> // uint8_t
|
||||||
|
|
41
src/main.cpp
41
src/main.cpp
|
@ -1,6 +1,11 @@
|
||||||
/*
|
/*
|
||||||
Copyleft {C} 2014 Michael Pohoreski
|
Copyleft {C} 2014 Michael Pohoreski
|
||||||
License: GPL2
|
License: GPL2
|
||||||
|
|
||||||
|
MSVC2010 Debug:
|
||||||
|
Configuration Properties, Debugging
|
||||||
|
Command Arguments: hgr/archon.hgr2
|
||||||
|
Working Directory: $(ProjectDir)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Includes _______________________________________________________________
|
// Includes _______________________________________________________________
|
||||||
|
@ -33,6 +38,9 @@
|
||||||
TARGA_HEADER_SIZE = 0x12
|
TARGA_HEADER_SIZE = 0x12
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma pack(push,1)
|
||||||
|
#endif // _MSC_VER
|
||||||
struct TargaHeader_t
|
struct TargaHeader_t
|
||||||
{ // Addr Bytes
|
{ // Addr Bytes
|
||||||
uint8_t nIdBytes ; // 00 01 size of ID field that follows 18 byte header (0 usually)
|
uint8_t nIdBytes ; // 00 01 size of ID field that follows 18 byte header (0 usually)
|
||||||
|
@ -53,6 +61,9 @@
|
||||||
// pixel data...
|
// pixel data...
|
||||||
uint8_t aPixelData[1] ; // 12 ?? variable length RGB data
|
uint8_t aPixelData[1] ; // 12 ?? variable length RGB data
|
||||||
};
|
};
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma pack(pop)
|
||||||
|
#endif // _MSC_VER
|
||||||
|
|
||||||
enum VideoFlag_e
|
enum VideoFlag_e
|
||||||
{
|
{
|
||||||
|
@ -98,15 +109,20 @@ printf( "Dst: '%s'\n", pDstFileName );
|
||||||
FILE *pSrcFile = fopen( pSrcFileName, "rb" );
|
FILE *pSrcFile = fopen( pSrcFileName, "rb" );
|
||||||
FILE *pDstFile = fopen( pDstFileName, "w+b" );
|
FILE *pDstFile = fopen( pDstFileName, "w+b" );
|
||||||
|
|
||||||
size_t nPageHGR = 0x2000;
|
if( pSrcFile )
|
||||||
fread( gaMemMain + nPageHGR, _8K, 1, pSrcFile );
|
{
|
||||||
|
size_t nPageHGR = 0x2000;
|
||||||
|
fread( gaMemMain + nPageHGR, _8K, 1, pSrcFile );
|
||||||
|
|
||||||
TargaHeader_t tga;
|
TargaHeader_t tga;
|
||||||
hgr2rgb();
|
hgr2rgb();
|
||||||
rgb2tga( &tga );
|
rgb2tga( &tga );
|
||||||
|
|
||||||
fwrite( (void*)&tga , TARGA_HEADER_SIZE , 1, pDstFile );
|
fwrite( (void*)&tga , TARGA_HEADER_SIZE , 1, pDstFile );
|
||||||
fwrite( (void*)&gaFrameBuffer, sizeof( gaFrameBuffer ), 1, pDstFile );
|
fwrite( (void*)&gaFrameBuffer, sizeof( gaFrameBuffer ), 1, pDstFile );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf( "ERROR: Couldn't open source file: '%s'\n", pSrcFileName );
|
||||||
|
|
||||||
fclose( pDstFile );
|
fclose( pDstFile );
|
||||||
fclose( pSrcFile );
|
fclose( pSrcFile );
|
||||||
|
@ -190,6 +206,12 @@ printf( "Dst: '%s'\n", pDstFileName );
|
||||||
int main( const int nArg, const char *aArg[] )
|
int main( const int nArg, const char *aArg[] )
|
||||||
{
|
{
|
||||||
init_mem();
|
init_mem();
|
||||||
|
|
||||||
|
// From: Video.cpp wsVideoCreateDIBSection()
|
||||||
|
uint8_t *g_pFramebufferbits = (uint8_t*) &gaFrameBuffer[0][0];
|
||||||
|
for (int y = 0; y < 384; y++)
|
||||||
|
wsLines[y] = g_pFramebufferbits + 4 * FRAMEBUFFER_W * ((FRAMEBUFFER_H - 1) - y - 18) + 80;
|
||||||
|
|
||||||
wsVideoInitModel( 1 ); // Apple //e
|
wsVideoInitModel( 1 ); // Apple //e
|
||||||
wsVideoInit();
|
wsVideoInit();
|
||||||
wsVideoStyle( 1, 1 );
|
wsVideoStyle( 1, 1 );
|
||||||
|
@ -197,11 +219,6 @@ printf( "Dst: '%s'\n", pDstFileName );
|
||||||
g_bVideoMode = VF_HIRES;
|
g_bVideoMode = VF_HIRES;
|
||||||
init_videomode();
|
init_videomode();
|
||||||
|
|
||||||
// From: Video.cpp wsVideoCreateDIBSection()
|
|
||||||
uint8_t *g_pFramebufferbits = (uint8_t*) &gaFrameBuffer[0][0];
|
|
||||||
for (int y = 0; y < 384; y++)
|
|
||||||
wsLines[y] = g_pFramebufferbits + 4 * FRAMEBUFFER_W * ((FRAMEBUFFER_H - 1) - y - 18) + 80;
|
|
||||||
|
|
||||||
if( nArg > 1 )
|
if( nArg > 1 )
|
||||||
{
|
{
|
||||||
convert( aArg[1] );
|
convert( aArg[1] );
|
||||||
|
|
|
@ -77,7 +77,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
static unsigned g_nVideoClockVert = 0; // 9-bit: VC VB VA V5 V4 V3 V2 V1 V0 = 0 .. 262
|
static unsigned g_nVideoClockVert = 0; // 9-bit: VC VB VA V5 V4 V3 V2 V1 V0 = 0 .. 262
|
||||||
static unsigned g_nVideoClockHorz = 0; // 6-bit: H5 H4 H3 H2 H1 H0 = 0 .. 64, 25 >= visible
|
static unsigned g_nVideoClockHorz = 0; // 6-bit: H5 H4 H3 H2 H1 H0 = 0 .. 64, 25 >= visible
|
||||||
|
|
||||||
unsigned g_aHorzClockMemAddress[VIDEO_SCANNER_MAX_HORZ];
|
uint16_t g_aHorzClockMemAddress[VIDEO_SCANNER_MAX_HORZ]; // MSVC2010
|
||||||
unsigned char * wsLines[384];
|
unsigned char * wsLines[384];
|
||||||
|
|
||||||
unsigned wsFlashidx = 0;
|
unsigned wsFlashidx = 0;
|
||||||
|
@ -705,6 +705,7 @@ int wsVideoIsVbl ()
|
||||||
|
|
||||||
unsigned char wsVideoByte (unsigned long cycle)
|
unsigned char wsVideoByte (unsigned long cycle)
|
||||||
{
|
{
|
||||||
|
(void)cycle; // MSVC2010
|
||||||
unsigned char * mem;
|
unsigned char * mem;
|
||||||
mem = MemGetMainPtr(g_aHorzClockMemAddress[ g_nVideoClockHorz ]);
|
mem = MemGetMainPtr(g_aHorzClockMemAddress[ g_nVideoClockHorz ]);
|
||||||
return mem[0];
|
return mem[0];
|
||||||
|
|
Loading…
Reference in New Issue