This commit is contained in:
Michaelangel007 2014-12-28 10:10:36 -08:00
parent 2ed21521e0
commit eb17b07d70
4 changed files with 339 additions and 14 deletions

6
src/StdAfx.h Normal file
View File

@ -0,0 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h> // uint8_t
#include <string.h> // memset
#include <math.h> // cos sin

215
src/cs.cpp Normal file
View File

@ -0,0 +1,215 @@
/*
AppleWin : An Apple //e emulator for Windows
Copyright (C) 2010-2011, William S Simms
AppleWin is free software; you can redistribute it and/or modify
it 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 option) any later version.
AppleWin is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with AppleWin; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#include "cs.h"
unsigned char csbits[2][256][8];
static const char *csstrs[] = { // CLANG FIX: const
" ### "," # "," #### "," ### "," #### "," ##### "," ##### "," #### ",
" # # "," # # "," # # "," # # "," # # "," # "," # "," # ",
" # # # "," # # "," # # "," # "," # # "," # "," # "," # ",
" # ### "," # # "," #### "," # "," # # "," #### "," #### "," # ",
" # ## "," ##### "," # # "," # "," # # "," # "," # "," # ## ",
" # "," # # "," # # "," # # "," # # "," # "," # "," # # ",
" #### "," # # "," #### "," ### "," #### "," ##### "," # "," #### ",
" "," "," "," "," "," "," "," ",
" # # "," ### "," # "," # # "," # "," # # "," # # "," ### ",
" # # "," # "," # "," # # "," # "," ## ## "," # # "," # # ",
" # # "," # "," # "," # # "," # "," # # # "," ## # "," # # ",
" ##### "," # "," # "," ## "," # "," # # # "," # # # "," # # ",
" # # "," # "," # "," # # "," # "," # # "," # ## "," # # ",
" # # "," # "," # # "," # # "," # "," # # "," # # "," # # ",
" # # "," ### "," ### "," # # "," ##### "," # # "," # # "," ### ",
" "," "," "," "," "," "," "," ",
" #### "," ### "," #### "," ### "," ##### "," # # "," # # "," # # ",
" # # "," # # "," # # "," # # "," # "," # # "," # # "," # # ",
" # # "," # # "," # # "," # "," # "," # # "," # # "," # # ",
" #### "," # # "," #### "," ### "," # "," # # "," # # "," # # # ",
" # "," # # # "," # # "," # "," # "," # # "," # # "," # # # ",
" # "," # # "," # # "," # # "," # "," # # "," # # "," ## ## ",
" # "," ## # "," # # "," ### "," # "," ### "," # "," # # ",
" "," "," "," "," "," "," "," ",
" # # "," # # "," ##### "," ##### "," "," ##### "," "," ",
" # # "," # # "," # "," ## "," # "," ## "," "," ",
" # # "," # # "," # "," ## "," # "," ## "," # "," ",
" # "," # "," # "," ## "," # "," ## "," # # "," ",
" # # "," # "," # "," ## "," # "," ## "," # # "," ",
" # # "," # "," # "," ## "," # "," ## "," "," ",
" # # "," # "," ##### "," ##### "," "," ##### "," "," ",
" "," "," "," "," "," "," "," #######",
" "," # "," # # "," # # "," # "," ## "," # "," # ",
" "," # "," # # "," # # "," #### "," ## # "," # # "," # ",
" "," # "," # # "," ##### "," # # "," # "," # # "," # ",
" "," # "," "," # # "," ### "," # "," # "," ",
" "," # "," "," ##### "," # # "," # "," # # # "," ",
" "," "," "," # # "," #### "," # ## "," # # "," ",
" "," # "," "," # # "," # "," ## "," ## # "," ",
" "," "," "," "," "," "," "," ",
" # "," # "," # "," "," "," "," "," ",
" # "," # "," # # # "," # "," "," "," "," # ",
" # "," # "," ### "," # "," "," "," "," # ",
" # "," # "," # "," ##### "," "," ##### "," "," # ",
" # "," # "," ### "," # "," # "," "," "," # ",
" # "," # "," # # # "," # "," # "," "," "," # ",
" # "," # "," # "," "," # "," "," # "," ",
" "," "," "," "," "," "," "," ",
" ### "," # "," ### "," ##### "," # "," ##### "," ### "," ##### ",
" # # "," ## "," # # "," # "," ## "," # "," # "," # ",
" # ## "," # "," # "," # "," # # "," #### "," # "," # ",
" # # # "," # "," ## "," ## "," # # "," # "," #### "," # ",
" ## # "," # "," # "," # "," ##### "," # "," # # "," # ",
" # # "," # "," # "," # # "," # "," # # "," # # "," # ",
" ### "," ### "," ##### "," ### "," # "," ### "," ### "," # ",
" "," "," "," "," "," "," "," ",
" ### "," ### "," "," "," # "," "," # "," ### ",
" # # "," # # "," "," "," # "," "," # "," # # ",
" # # "," # # "," # "," # "," # "," ##### "," # "," # ",
" ### "," #### "," "," "," # "," "," # "," # ",
" # # "," # "," # "," # "," # "," ##### "," # "," # ",
" # # "," # "," "," # "," # "," "," # "," ",
" ### "," ### "," "," # "," # "," "," # "," # ",
" "," "," "," "," "," "," "," ",
" # "," "," # "," "," # "," "," ## "," ",
" # "," "," # "," "," # "," "," # # "," ",
" # "," ### "," #### "," #### "," #### "," ### "," # "," #### ",
" "," # "," # # "," # "," # # "," # # "," #### "," # # ",
" "," #### "," # # "," # "," # # "," ##### "," # "," # # ",
" "," # # "," # # "," # "," # # "," # "," # "," #### ",
" "," #### "," #### "," #### "," #### "," #### "," # "," # ",
" "," "," "," "," "," "," "," ### ",
" # "," # "," # "," # "," ## "," "," "," ",
" # "," "," "," # "," # "," "," "," ",
" #### "," ## "," ## "," # # "," # "," ## ## "," #### "," ### ",
" # # "," # "," # "," # # "," # "," # # # "," # # "," # # ",
" # # "," # "," # "," ### "," # "," # # # "," # # "," # # ",
" # # "," # "," # "," # # "," # "," # # # "," # # "," # # ",
" # # "," ### "," # # "," # # "," ### "," # # "," # # "," ### ",
" "," "," ## "," "," "," "," "," ",
" "," "," "," "," # "," "," "," ",
" "," "," "," "," # "," "," "," ",
" #### "," #### "," # ### "," #### "," #### "," # # "," # # "," # # ",
" # # "," # # "," ## "," # "," # "," # # "," # # "," # # ",
" # # "," # # "," # "," ### "," # "," # # "," # # "," # # # ",
" #### "," #### "," # "," # "," # # "," # ## "," # # "," # # # ",
" # "," # "," # "," #### "," ## "," ## # "," # "," ## ## ",
" # "," # "," "," "," "," "," "," ",
" "," "," "," ### "," # "," ### "," ## # "," ",
" "," "," "," ## "," # "," ## "," # ## "," # # # ",
" # # "," # # "," ##### "," ## "," # "," ## "," "," # # ",
" # # "," # # "," # "," ## "," # "," ## "," "," # # # ",
" # "," # # "," # "," ## "," # "," ## "," "," # # ",
" # # "," #### "," # "," ## "," # "," ## "," "," # # # ",
" # # "," # "," ##### "," ### "," # "," ### "," "," ",
" "," ### "," "," "," # "," "," "," ",
" # "," # "," "," #######"," "," #######"," ###"," ",
" # "," # "," "," # # "," #"," ###### "," ##"," ## ",
" ## ## "," ## ## "," # "," # # "," # "," ##### #"," ######"," ### ",
" #######"," # #"," ## "," # "," # # "," ## ##"," # ## "," ",
" ###### "," # # "," ### "," # "," # # "," # # ###"," # ####"," ### ",
" ###### "," # # "," #### "," # # "," # "," ## ####"," ## "," ## ",
" ######"," # # #"," ## ## "," # # # "," # "," ## ####"," ###### "," # ",
" ## ## "," ## ## "," # #"," #######"," "," #######"," # "," ###",
" # "," "," # "," # "," #######"," #"," ###### "," ## # ",
" # "," "," # "," ### "," "," #"," ###### "," ## ",
" # "," "," # "," # # # "," "," # #"," ###### "," ### ",
" #######"," "," # "," # # #"," "," ## #"," ###### "," ######",
" # "," "," # # #"," # "," "," #######"," ###### "," ### ",
" # "," "," # # # "," # "," "," ## "," ###### "," ## ",
" # "," "," ### "," # "," "," # "," ###### "," # ",
" "," # # # "," # "," # "," "," "," ###### "," #### ##",
" # ##"," #"," #"," "," # "," # "," # # # "," # # # #",
" ## "," # #"," # #"," "," # "," # "," # # # #"," # # # ",
" ### "," # "," ### "," "," # "," # "," # # # "," # # # #",
" ###### "," #######"," ##### "," #######"," # "," #######"," # # # #"," # # # ",
" ### "," ##### "," #######"," "," # "," # "," # # # "," # # # #",
" ## "," ### "," # "," "," # "," # "," # # # #"," # # # ",
" # "," # #"," # #"," "," # "," # "," # # # "," # # # #",
" ## ####"," #"," #"," "," #######"," "," # # # #"," # # # ",
" "," "," #"," # "," #######"," # # "," #######"," # ",
" ##### "," "," #"," ### "," "," # # "," #"," # ",
" # #","####### "," #"," ##### "," "," ### ###"," #"," # ",
" # "," #"," #"," #######"," "," "," ## #"," # ",
" # "," #"," #"," ##### "," "," ### ###"," ## #"," # ",
" # "," #"," #"," ### "," "," # # "," #"," # ",
" #######","########"," #"," # "," "," # # "," #"," # ",
" "," "," #"," "," #######"," "," #######"," # ",
};
#define STRINGS_PER_CHAR 8
#define CHARS_PER_ROW 8
#define STRINGS_PER_CHAR_ROW (STRINGS_PER_CHAR * CHARS_PER_ROW)
void make_csbits (void) {
int i,j;
int szstrs = sizeof csstrs / sizeof csstrs[0];
int numchars = szstrs / STRINGS_PER_CHAR;
for (i = 0; i < numchars; ++i) {
int si = ((i / STRINGS_PER_CHAR) * STRINGS_PER_CHAR_ROW) + (i % CHARS_PER_ROW);
for (j = 0; j < STRINGS_PER_CHAR; ++j)
{
const char *sp = csstrs[si]; // CLANG FIX: const
unsigned char cb = 0;
si += CHARS_PER_ROW;
while (*sp) {
if (*sp++ != ' ') cb |= 0x80;
cb >>= 1;
}
csbits[0][i][j] = cb;
}
}
/* move mousetext */
for (i = 96; i < 128; ++i)
for (j = 0; j < 8; ++j)
csbits[1][i-32][j] = csbits[0][i][j];
/* move lowercase */
for (i = 64; i < 96; ++i)
for (j = 0; j < 8; ++j)
csbits[1][i+32][j] = csbits[1][i+160][j] =
csbits[0][i+160][j] = csbits[0][i][j];
/* move numbers */
for (i = 32; i < 64; ++i)
for (j = 0; j < 8; ++j)
csbits[1][i][j] = csbits[1][i+128][j] =
csbits[0][i+64][j] = csbits[0][i+128][j] = csbits[0][i][j];
/* move uppercase */
for (i = 0; i < 32; ++i)
for (j = 0; j < 8; ++j)
csbits[1][i][j] = csbits[1][i+128][j] = csbits[1][i+192][j] =
csbits[0][i+64][j] = csbits[0][i+128][j] = csbits[0][i+192][j] = csbits[0][i][j];
/* invert (skip mousetext) */
for (i = 0; i < 128; ++i)
for (j = 0; j < 8; ++j)
{
csbits[0][i][j] ^= 0xFF;
if (i < 64 || i >= 96)
csbits[1][i][j] ^= 0xFF;
}
}

27
src/cs.h Normal file
View File

@ -0,0 +1,27 @@
/*
AppleWin : An Apple //e emulator for Windows
Copyright (C) 2010-2011, William S Simms
AppleWin is free software; you can redistribute it and/or modify
it 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 option) any later version.
AppleWin is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with AppleWin; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef INCLUDED_CS_H
#define INCLUDED_CS_H
extern unsigned char csbits[2][256][8];
void make_csbits (void);
#endif

View File

@ -4,12 +4,16 @@
*/
// Includes _______________________________________________________________
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h> // uint8_t
#include <string.h> // memset
#if 0
#include "StdAfx.h"
// uint8_t csbits[ 1024 ];
// void make_csbits() {};
uint8_t *MemGetMainPtr( uint16_t address );
uint8_t *MemGetAuxPtr ( uint16_t address );
#if 1
#include "wsvideo.cpp"
#include "cs.cpp"
#else
#define FRAMEBUFFER_W 600
#define FRAMEBUFFER_H 420
@ -19,7 +23,8 @@
enum
{
_8K = 8 * 1024
_8K = 8 * 1024,
_64K = 64 * 1024
};
enum TargaImageType_e
@ -49,15 +54,28 @@
uint8_t aPixelData[1] ; // 12 ?? variable length RGB data
};
enum VideoFlag_e
{
VF_80COL = 0x00000001,
VF_DHIRES = 0x00000002,
VF_HIRES = 0x00000004,
VF_MASK2 = 0x00000008,
VF_MIXED = 0x00000010,
VF_PAGE2 = 0x00000020,
VF_TEXT = 0x00000040
};
// Globals (Private ) _____________________________________________________
uint8_t gaMemMain[ _8K ];
uint8_t gaMemAux [ _8K ];
uint8_t gaMemMain[ _64K ];
uint8_t gaMemAux [ _64K ];
uint32_t gaFrameBuffer[ FRAMEBUFFER_H ][ FRAMEBUFFER_W ];
int g_bVideoMode;
// Prototypes _____________________________________________________________
void convert( const char *pSrcFileName );
void init_mem();
void init_videomode();
void hgr2rgb();
void rgb2tga( TargaHeader_t *pTargaHeader );
@ -80,7 +98,8 @@ printf( "Dst: '%s'\n", pDstFileName );
FILE *pSrcFile = fopen( pSrcFileName, "rb" );
FILE *pDstFile = fopen( pDstFileName, "w+b" );
fread( gaMemMain, _8K, 1, pSrcFile );
size_t nPageHGR = 0x2000;
fread( gaMemMain + nPageHGR, _8K, 1, pSrcFile );
TargaHeader_t tga;
hgr2rgb();
@ -93,19 +112,67 @@ printf( "Dst: '%s'\n", pDstFileName );
fclose( pSrcFile );
}
//========================================================================
void hgr2rgb()
{
g_pFuncVideoUpdate( VIDEO_SCANNER_6502_CYCLES );
}
//========================================================================
void init_mem()
{
memset( gaMemMain, 0, sizeof( gaMemMain ) );
memset( gaMemMain, 0, sizeof( gaMemAux ) );
//memset( gaFrameBuffer, 0, sizeof( gaFrameBuffer ) );
memset( gaFrameBuffer, 0, sizeof( gaFrameBuffer ) );
}
//========================================================================
void hgr2rgb()
void init_videomode()
{
//g_pFuncVideoUpdate( VIDEO_SCANNER_6502_CYCLES );
// From Video.cpp VideoSetMode()
wsTextPage = 1;
wsHiresPage = 1;
if (g_bVideoMode & VF_PAGE2) {
if (0 == (g_bVideoMode & VF_MASK2)) {
wsTextPage = 2;
wsHiresPage = 2;
}
}
if (g_bVideoMode & VF_TEXT) {
if (g_bVideoMode & VF_80COL)
g_pFuncVideoUpdate = wsUpdateVideoText80;
else
g_pFuncVideoUpdate = wsUpdateVideoText40;
}
else if (g_bVideoMode & VF_HIRES) {
if (g_bVideoMode & VF_DHIRES)
if (g_bVideoMode & VF_80COL)
g_pFuncVideoUpdate = wsUpdateVideoDblHires;
else
g_pFuncVideoUpdate = wsUpdateVideoHires0;
else
g_pFuncVideoUpdate = wsUpdateVideoHires;
}
else {
if (g_bVideoMode & VF_DHIRES)
if (g_bVideoMode & VF_80COL)
g_pFuncVideoUpdate = wsUpdateVideoDblLores;
else
g_pFuncVideoUpdate = wsUpdateVideo7MLores;
else
g_pFuncVideoUpdate = wsUpdateVideoLores;
}
}
uint8_t *MemGetMainPtr( uint16_t address )
{
return &gaMemMain[ address ];
}
uint8_t *MemGetAuxPtr ( uint16_t address )
{
return &gaMemAux[ address ];
}
//========================================================================
@ -123,7 +190,17 @@ printf( "Dst: '%s'\n", pDstFileName );
int main( const int nArg, const char *aArg[] )
{
init_mem();
//init_wsvideo();
wsVideoInitModel( 1 ); // Apple //e
wsVideoInit();
wsVideoStyle( 1, 1 );
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 )
{