mirror of
https://github.com/Michaelangel007/hgr2rgbntsc.git
synced 2024-12-21 02:31:58 +00:00
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 <stdlib.h>
|
||||
#include <stdint.h> // uint8_t
|
||||
|
27
src/main.cpp
27
src/main.cpp
@ -1,6 +1,11 @@
|
||||
/*
|
||||
Copyleft {C} 2014 Michael Pohoreski
|
||||
License: GPL2
|
||||
|
||||
MSVC2010 Debug:
|
||||
Configuration Properties, Debugging
|
||||
Command Arguments: hgr/archon.hgr2
|
||||
Working Directory: $(ProjectDir)
|
||||
*/
|
||||
|
||||
// Includes _______________________________________________________________
|
||||
@ -33,6 +38,9 @@
|
||||
TARGA_HEADER_SIZE = 0x12
|
||||
};
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma pack(push,1)
|
||||
#endif // _MSC_VER
|
||||
struct TargaHeader_t
|
||||
{ // Addr Bytes
|
||||
uint8_t nIdBytes ; // 00 01 size of ID field that follows 18 byte header (0 usually)
|
||||
@ -53,6 +61,9 @@
|
||||
// pixel data...
|
||||
uint8_t aPixelData[1] ; // 12 ?? variable length RGB data
|
||||
};
|
||||
#ifdef _MSC_VER
|
||||
#pragma pack(pop)
|
||||
#endif // _MSC_VER
|
||||
|
||||
enum VideoFlag_e
|
||||
{
|
||||
@ -98,6 +109,8 @@ printf( "Dst: '%s'\n", pDstFileName );
|
||||
FILE *pSrcFile = fopen( pSrcFileName, "rb" );
|
||||
FILE *pDstFile = fopen( pDstFileName, "w+b" );
|
||||
|
||||
if( pSrcFile )
|
||||
{
|
||||
size_t nPageHGR = 0x2000;
|
||||
fread( gaMemMain + nPageHGR, _8K, 1, pSrcFile );
|
||||
|
||||
@ -107,6 +120,9 @@ printf( "Dst: '%s'\n", pDstFileName );
|
||||
|
||||
fwrite( (void*)&tga , TARGA_HEADER_SIZE , 1, pDstFile );
|
||||
fwrite( (void*)&gaFrameBuffer, sizeof( gaFrameBuffer ), 1, pDstFile );
|
||||
}
|
||||
else
|
||||
printf( "ERROR: Couldn't open source file: '%s'\n", pSrcFileName );
|
||||
|
||||
fclose( pDstFile );
|
||||
fclose( pSrcFile );
|
||||
@ -190,6 +206,12 @@ printf( "Dst: '%s'\n", pDstFileName );
|
||||
int main( const int nArg, const char *aArg[] )
|
||||
{
|
||||
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
|
||||
wsVideoInit();
|
||||
wsVideoStyle( 1, 1 );
|
||||
@ -197,11 +219,6 @@ printf( "Dst: '%s'\n", pDstFileName );
|
||||
g_bVideoMode = VF_HIRES;
|
||||
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 )
|
||||
{
|
||||
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_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 wsFlashidx = 0;
|
||||
@ -705,6 +705,7 @@ int wsVideoIsVbl ()
|
||||
|
||||
unsigned char wsVideoByte (unsigned long cycle)
|
||||
{
|
||||
(void)cycle; // MSVC2010
|
||||
unsigned char * mem;
|
||||
mem = MemGetMainPtr(g_aHorzClockMemAddress[ g_nVideoClockHorz ]);
|
||||
return mem[0];
|
||||
|
Loading…
Reference in New Issue
Block a user