First pass of NTSC integration

This commit is contained in:
michaelangel007 2014-12-31 14:13:36 -08:00
parent 7ba8128530
commit e116014742
12 changed files with 191 additions and 106 deletions

View File

@ -265,6 +265,7 @@
<ClCompile Include="source\Debugger\Debugger_Parser.cpp" /> <ClCompile Include="source\Debugger\Debugger_Parser.cpp" />
<ClCompile Include="source\Debugger\Debugger_Range.cpp" /> <ClCompile Include="source\Debugger\Debugger_Range.cpp" />
<ClCompile Include="source\Debugger\Debugger_Symbols.cpp" /> <ClCompile Include="source\Debugger\Debugger_Symbols.cpp" />
<ClCompile Include="source\NTSC.cpp" />
<ClCompile Include="source\StdAfx.cpp"> <ClCompile Include="source\StdAfx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug NoDX|Win32'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug NoDX|Win32'">Create</PrecompiledHeader>
@ -392,6 +393,7 @@
<ClInclude Include="source\Debugger\Debugger_Symbols.h" /> <ClInclude Include="source\Debugger\Debugger_Symbols.h" />
<ClInclude Include="source\Debugger\Debugger_Types.h" /> <ClInclude Include="source\Debugger\Debugger_Types.h" />
<ClInclude Include="source\Debugger\Util_MemoryTextFile.h" /> <ClInclude Include="source\Debugger\Util_MemoryTextFile.h" />
<ClInclude Include="source\NTSC.h" />
<ClInclude Include="source\Tfe\Bittypes.h" /> <ClInclude Include="source\Tfe\Bittypes.h" />
<ClInclude Include="source\Tfe\Bpf.h" /> <ClInclude Include="source\Tfe\Bpf.h" />
<ClInclude Include="source\Tfe\Ip6_misc.h" /> <ClInclude Include="source\Tfe\Ip6_misc.h" />

View File

@ -51,6 +51,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "Speech.h" #include "Speech.h"
#endif #endif
#include "Video.h" #include "Video.h"
#include "NTSC.h"
#include "Configuration\About.h" #include "Configuration\About.h"
#include "Configuration\PropertySheet.h" #include "Configuration\PropertySheet.h"
@ -408,7 +409,7 @@ void LoadConfiguration(void)
case A2TYPE_PRAVETS8M: g_nCharsetType = 3; break; //This charset has a very small difference with the PRAVETS82 one an probably has some misplaced characters. Still the Pravets82 charset is used, because setting charset to 3 results in some problems. case A2TYPE_PRAVETS8M: g_nCharsetType = 3; break; //This charset has a very small difference with the PRAVETS82 one an probably has some misplaced characters. Still the Pravets82 charset is used, because setting charset to 3 results in some problems.
} }
// NTSC_VideoInitAppleType();
if (!REGLOAD(TEXT(REGVALUE_JOYSTICK0_EMU_TYPE), &joytype[JN_JOYSTICK0])) if (!REGLOAD(TEXT(REGVALUE_JOYSTICK0_EMU_TYPE), &joytype[JN_JOYSTICK0]))
LoadConfigOldJoystick(JN_JOYSTICK0); LoadConfigOldJoystick(JN_JOYSTICK0);

View File

@ -96,6 +96,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "Speech.h" #include "Speech.h"
#endif #endif
#include "Video.h" #include "Video.h"
#include "NTSC.h"
#include "z80emu.h" #include "z80emu.h"
#include "Z80VICE\z80.h" #include "Z80VICE\z80.h"
@ -103,25 +104,27 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "Debugger\Debug.h" #include "Debugger\Debug.h"
// 6502 Accumulator Bit Flags
#define AF_SIGN 0x80 #define AF_SIGN 0x80
#define AF_OVERFLOW 0x40 #define AF_OVERFLOW 0x40
#define AF_RESERVED 0x20 #define AF_RESERVED 0x20
#define AF_BREAK 0x10 #define AF_BREAK 0x10
#define AF_DECIMAL 0x08 #define AF_DECIMAL 0x08
#define AF_INTERRUPT 0x04 #define AF_INTERRUPT 0x04
#define AF_ZERO 0x02 #define AF_ZERO 0x02
#define AF_CARRY 0x01 #define AF_CARRY 0x01
#define SHORTOPCODES 22 #define SHORTOPCODES 22
#define BENCHOPCODES 33 #define BENCHOPCODES 33
// What is this 6502 code? // What is this 6502 code? Compressed 6502 code -- see: CpuSetupBenchmark()
static BYTE benchopcode[BENCHOPCODES] = {0x06,0x16,0x24,0x45,0x48,0x65,0x68,0x76, static BYTE benchopcode[BENCHOPCODES] = {
0x84,0x85,0x86,0x91,0x94,0xA4,0xA5,0xA6, 0x06,0x16,0x24,0x45,0x48,0x65,0x68,0x76,
0xB1,0xB4,0xC0,0xC4,0xC5,0xE6, 0x84,0x85,0x86,0x91,0x94,0xA4,0xA5,0xA6,
0x19,0x6D,0x8D,0x99,0x9D,0xAD,0xB9,0xBD, 0xB1,0xB4,0xC0,0xC4,0xC5,0xE6,
0xDD,0xED,0xEE}; 0x19,0x6D,0x8D,0x99,0x9D,0xAD,0xB9,0xBD,
0xDD,0xED,0xEE
};
regsrec regs; regsrec regs;
unsigned __int64 g_nCumulativeCycles = 0; unsigned __int64 g_nCumulativeCycles = 0;

View File

@ -44,6 +44,11 @@ static DWORD Cpu6502 (DWORD uTotalCycles)
UINT uExtraCycles = 0; UINT uExtraCycles = 0;
BYTE iOpcode; BYTE iOpcode;
// NTSC_BEGIN
ULONG uElapsedCycles;
ULONG uPreviousCycles = uExecutedCycles;
// NTSC_END
if (g_ActiveCPU == CPU_Z80) if (g_ActiveCPU == CPU_Z80)
{ {
const UINT uZ80Cycles = z80_mainloop(uTotalCycles, uExecutedCycles); CYC(uZ80Cycles) const UINT uZ80Cycles = z80_mainloop(uTotalCycles, uExecutedCycles); CYC(uZ80Cycles)
@ -315,6 +320,14 @@ static DWORD Cpu6502 (DWORD uTotalCycles)
} }
} }
// NTSC_BEGIN
uElapsedCycles = uExecutedCycles - uPreviousCycles;
if( g_bFullSpeed )
NTSC_VideoUpdateCycles( uElapsedCycles );
else
g_pNTSC_FuncVideoUpdate( uElapsedCycles );
// NTSC_END
CheckInterruptSources(uExecutedCycles); CheckInterruptSources(uExecutedCycles);
NMI(uExecutedCycles, uExtraCycles, flagc, flagn, flagv, flagz); NMI(uExecutedCycles, uExtraCycles, flagc, flagn, flagv, flagz);
IRQ(uExecutedCycles, uExtraCycles, flagc, flagn, flagv, flagz); IRQ(uExecutedCycles, uExtraCycles, flagc, flagn, flagv, flagz);

View File

@ -47,6 +47,11 @@ static DWORD Cpu65C02 (DWORD uTotalCycles)
UINT uExtraCycles = 0; UINT uExtraCycles = 0;
BYTE iOpcode; BYTE iOpcode;
// NTSC_BEGIN
ULONG uElapsedCycles;
ULONG uPreviousCycles = uExecutedCycles;
// NTSC_END
if (g_ActiveCPU == CPU_Z80) if (g_ActiveCPU == CPU_Z80)
{ {
const UINT uZ80Cycles = z80_mainloop(uTotalCycles, uExecutedCycles); CYC(uZ80Cycles) const UINT uZ80Cycles = z80_mainloop(uTotalCycles, uExecutedCycles); CYC(uZ80Cycles)
@ -319,6 +324,14 @@ static DWORD Cpu65C02 (DWORD uTotalCycles)
#undef $ #undef $
} }
// NTSC_BEGIN
uElapsedCycles = uExecutedCycles - uPreviousCycles;
if( g_bFullSpeed )
NTSC_VideoUpdateCycles( uElapsedCycles );
else
g_pNTSC_FuncVideoUpdate( uElapsedCycles );
// NTSC_END
CheckInterruptSources(uExecutedCycles); CheckInterruptSources(uExecutedCycles);
NMI(uExecutedCycles, uExtraCycles, flagc, flagn, flagv, flagz); NMI(uExecutedCycles, uExtraCycles, flagc, flagn, flagv, flagz);
IRQ(uExecutedCycles, uExtraCycles, flagc, flagn, flagv, flagz); IRQ(uExecutedCycles, uExtraCycles, flagc, flagn, flagv, flagz);

View File

@ -106,6 +106,11 @@ static DWORD Cpu65D02 (DWORD uTotalCycles)
UINT uExtraCycles = 0; UINT uExtraCycles = 0;
BYTE iOpcode; BYTE iOpcode;
// NTSC_BEGIN
ULONG uElapsedCycles;
ULONG uPreviousCycles = uExecutedCycles;
// NTSC_END
if (g_ActiveCPU == CPU_Z80) if (g_ActiveCPU == CPU_Z80)
{ {
const UINT uZ80Cycles = z80_mainloop(uTotalCycles, uExecutedCycles); CYC(uZ80Cycles) const UINT uZ80Cycles = z80_mainloop(uTotalCycles, uExecutedCycles); CYC(uZ80Cycles)
@ -648,6 +653,14 @@ static DWORD Cpu65D02 (DWORD uTotalCycles)
} }
#undef $ #undef $
// NTSC_BEGIN
uElapsedCycles = uExecutedCycles - uPreviousCycles;
if( g_bFullSpeed )
NTSC_VideoUpdateCycles( uElapsedCycles );
else
g_pNTSC_FuncVideoUpdate( uElapsedCycles );
// NTSC_END
CheckInterruptSources(uExecutedCycles); CheckInterruptSources(uExecutedCycles);
NMI(uExecutedCycles, uExtraCycles, flagc, flagn, flagv, flagz); NMI(uExecutedCycles, uExtraCycles, flagc, flagn, flagv, flagz);
IRQ(uExecutedCycles, uExtraCycles, flagc, flagn, flagv, flagz); IRQ(uExecutedCycles, uExtraCycles, flagc, flagn, flagv, flagz);

View File

@ -114,7 +114,7 @@ BOOL CPageConfig::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM
break; break;
case IDC_MONOCOLOR: case IDC_MONOCOLOR:
VideoChooseColor(); VideoChooseMonochromeColor();
break; break;
case IDC_CHECK_CONFIRM_REBOOT: case IDC_CHECK_CONFIRM_REBOOT:

View File

@ -12,8 +12,15 @@
// 560 = Double Hi-Res // 560 = Double Hi-Res
// 384 = Doule Scan Line // 384 = Doule Scan Line
// NTSC_BEGIN
#if 0
#define FRAMEBUFFER_W 560 #define FRAMEBUFFER_W 560
#define FRAMEBUFFER_H 384 #define FRAMEBUFFER_H 384
#else
#define FRAMEBUFFER_W 600
#define FRAMEBUFFER_H 420
#endif
// NTSC_END
// Direct Draw -- For Full Screen // Direct Draw -- For Full Screen
extern LPDIRECTDRAW g_pDD; extern LPDIRECTDRAW g_pDD;

View File

@ -40,6 +40,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "Speaker.h" #include "Speaker.h"
#include "Video.h" #include "Video.h"
// Prototypes (Public)
// Note: This is here and not in Video.h to prevent header include bloat.
// i.e. so we don't need to incude "Structs.h" for NTSC.cpp
DWORD VideoGetSnapshot(SS_IO_Video* pSS);
DWORD VideoSetSnapshot(SS_IO_Video* pSS);
#define DEFAULT_SNAPSHOT_NAME "SaveState.aws" #define DEFAULT_SNAPSHOT_NAME "SaveState.aws"

View File

@ -25,6 +25,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <stdint.h> // uint8_t
#include <windows.h> #include <windows.h>
#include <winuser.h> // WM_MOUSEWHEEL #include <winuser.h> // WM_MOUSEWHEEL

View File

@ -35,6 +35,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "Memory.h" #include "Memory.h"
#include "Registry.h" #include "Registry.h"
#include "Video.h" #include "Video.h"
#include "NTSC.h"
#include "..\resource\resource.h" #include "..\resource\resource.h"
#include "Configuration\PropertySheet.h" #include "Configuration\PropertySheet.h"
@ -195,17 +196,6 @@ const BYTE DoubleHiresPalIndex[16] = {
const int SRCOFFS_DHIRES = (SRCOFFS_HIRES + 512); // 1168 const int SRCOFFS_DHIRES = (SRCOFFS_HIRES + 512); // 1168
const int SRCOFFS_TOTAL = (SRCOFFS_DHIRES + 2560); // 3278 const int SRCOFFS_TOTAL = (SRCOFFS_DHIRES + 2560); // 3278
enum VideoFlag_e
{
VF_80COL = 0x00000001,
VF_DHIRES = 0x00000002,
VF_HIRES = 0x00000004,
VF_80STORE= 0x00000008,
VF_MIXED = 0x00000010,
VF_PAGE2 = 0x00000020,
VF_TEXT = 0x00000040
};
#define SW_80COL (g_uVideoMode & VF_80COL) #define SW_80COL (g_uVideoMode & VF_80COL)
#define SW_DHIRES (g_uVideoMode & VF_DHIRES) #define SW_DHIRES (g_uVideoMode & VF_DHIRES)
#define SW_HIRES (g_uVideoMode & VF_HIRES) #define SW_HIRES (g_uVideoMode & VF_HIRES)
@ -223,6 +213,13 @@ const BYTE DoubleHiresPalIndex[16] = {
#define HGR_MATRIX_YOFFSET 2 // For tv emulation HGR Video Mode #define HGR_MATRIX_YOFFSET 2 // For tv emulation HGR Video Mode
// Globals (Public)
uint8_t *g_pFramebufferbits = NULL; // last drawn frame
int g_nAltCharSetOffset = 0; // alternate character set
// Globals (Private)
// video scanner constants // video scanner constants
int const kHBurstClock = 53; // clock when Color Burst starts int const kHBurstClock = 53; // clock when Color Burst starts
int const kHBurstClocks = 4; // clocks per Color Burst duration int const kHBurstClocks = 4; // clocks per Color Burst duration
@ -246,7 +243,6 @@ static COLORREF customcolors[256]; // MONOCHROME is last custom color
static HBITMAP g_hDeviceBitmap; static HBITMAP g_hDeviceBitmap;
static HDC g_hDeviceDC; static HDC g_hDeviceDC;
LPBYTE g_pFramebufferbits = NULL; // last drawn frame
static LPBITMAPINFO g_pFramebufferinfo = NULL; static LPBITMAPINFO g_pFramebufferinfo = NULL;
static LPBYTE g_aFrameBufferOffset[FRAMEBUFFER_H]; // array of pointers to start of each scanline static LPBYTE g_aFrameBufferOffset[FRAMEBUFFER_H]; // array of pointers to start of each scanline
@ -270,7 +266,6 @@ static BYTE colormixbuffer[6];
static WORD colormixmap[6][6][6]; static WORD colormixmap[6][6][6];
// //
static int g_nAltCharSetOffset = 0; // alternate character set
static /*bool*/ UINT g_VideoForceFullRedraw = 1; static /*bool*/ UINT g_VideoForceFullRedraw = 1;
static bool g_bVideoUpdatedThisFrame = false; static bool g_bVideoUpdatedThisFrame = false;
@ -451,6 +446,9 @@ void CreateFrameOffsetTable (LPBYTE addr, LONG pitch)
//=========================================================================== //===========================================================================
void VideoInitialize () void VideoInitialize ()
{ {
// RESET THE VIDEO MODE SWITCHES AND THE CHARACTER SET OFFSET
VideoResetState();
// CREATE A BUFFER FOR AN IMAGE OF THE LAST DRAWN MEMORY // CREATE A BUFFER FOR AN IMAGE OF THE LAST DRAWN MEMORY
vidlastmem = (LPBYTE)VirtualAlloc(NULL,0x10000,MEM_COMMIT,PAGE_READWRITE); vidlastmem = (LPBYTE)VirtualAlloc(NULL,0x10000,MEM_COMMIT,PAGE_READWRITE);
ZeroMemory(vidlastmem,0x10000); ZeroMemory(vidlastmem,0x10000);
@ -466,47 +464,15 @@ void VideoInitialize ()
PAGE_READWRITE); PAGE_READWRITE);
ZeroMemory(g_pFramebufferinfo,sizeof(BITMAPINFOHEADER)+256*sizeof(RGBQUAD)); ZeroMemory(g_pFramebufferinfo,sizeof(BITMAPINFOHEADER)+256*sizeof(RGBQUAD));
g_pFramebufferinfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); g_pFramebufferinfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
g_pFramebufferinfo->bmiHeader.biWidth = FRAMEBUFFER_W; g_pFramebufferinfo->bmiHeader.biWidth = FRAMEBUFFER_W;
g_pFramebufferinfo->bmiHeader.biHeight = FRAMEBUFFER_H; g_pFramebufferinfo->bmiHeader.biHeight = FRAMEBUFFER_H;
g_pFramebufferinfo->bmiHeader.biPlanes = 1; g_pFramebufferinfo->bmiHeader.biPlanes = 1;
g_pFramebufferinfo->bmiHeader.biBitCount = 8; g_pFramebufferinfo->bmiHeader.biBitCount = 32;
g_pFramebufferinfo->bmiHeader.biClrUsed = 256; g_pFramebufferinfo->bmiHeader.biCompression = BI_RGB;
g_pFramebufferinfo->bmiHeader.biClrUsed = 0;
// CREATE A BITMAPINFO STRUCTURE FOR THE SOURCE IMAGE NTSC_VideoCreateDIBSection();
g_pSourceHeader = (LPBITMAPINFO)VirtualAlloc(
NULL,
sizeof(BITMAPINFOHEADER) + 256*sizeof(RGBQUAD),
MEM_COMMIT,
PAGE_READWRITE);
ZeroMemory(g_pSourceHeader,sizeof(BITMAPINFOHEADER));
g_pSourceHeader->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
g_pSourceHeader->bmiHeader.biWidth = SRCOFFS_TOTAL;
g_pSourceHeader->bmiHeader.biHeight = 512;
g_pSourceHeader->bmiHeader.biPlanes = 1;
g_pSourceHeader->bmiHeader.biBitCount = 8;
g_pSourceHeader->bmiHeader.biClrUsed = 256;
// VideoReinitialize() ... except we set the frame buffer palette....
V_CreateIdentityPalette();
//RGB() -> none
//PALETTERGB() -> PC_EXPLICIT
//??? RGB() -> PC_NOCOLLAPSE
for( int iColor = 0; iColor < NUM_COLOR_PALETTE; iColor++ )
customcolors[ iColor ] = ((DWORD)PC_EXPLICIT << 24) | RGB(
g_pFramebufferinfo->bmiColors[iColor].rgbRed,
g_pFramebufferinfo->bmiColors[iColor].rgbGreen,
g_pFramebufferinfo->bmiColors[iColor].rgbBlue
);
// CREATE THE FRAME BUFFER DIB SECTION AND DEVICE CONTEXT,
// CREATE THE SOURCE IMAGE DIB SECTION AND DRAW INTO THE SOURCE BIT BUFFER
V_CreateDIBSections();
// RESET THE VIDEO MODE SWITCHES AND THE CHARACTER SET OFFSET
VideoResetState();
} }
//=========================================================================== //===========================================================================
@ -2329,8 +2295,9 @@ BYTE VideoCheckVbl (WORD, WORD, BYTE, BYTE, ULONG uExecutedCycles)
return (r & ~0x80) | ((bVblBar) ? 0x80 : 0); return (r & ~0x80) | ((bVblBar) ? 0x80 : 0);
} }
// This is called from PageConfig
//=========================================================================== //===========================================================================
void VideoChooseColor () void VideoChooseMonochromeColor ()
{ {
CHOOSECOLOR cc; CHOOSECOLOR cc;
ZeroMemory(&cc,sizeof(CHOOSECOLOR)); ZeroMemory(&cc,sizeof(CHOOSECOLOR));
@ -2595,6 +2562,20 @@ VideoUpdateFuncPtr_t VideoRefreshScreen ()
DebugRefresh(0); DebugRefresh(0);
#endif #endif
// NTSC_BEGIN: wsVideoRefresh()
LPBYTE pDstFrameBufferBits = 0;
LONG pitch = 0;
HDC hFrameDC = FrameGetVideoDC(&pDstFrameBufferBits,&pitch);
if (hFrameDC)
{
// StretchBlt(hFrameDC,0,0,VIEWPORTCX,VIEWPORTCY,g_hDeviceDC,0,0,FRAMEBUFFER_W,FRAMEBUFFER_H,SRCCOPY);
StretchBlt(hFrameDC,0,0,FRAMEBUFFER_W,FRAMEBUFFER_H,g_hDeviceDC,0,0,FRAMEBUFFER_W,FRAMEBUFFER_H,SRCCOPY);
GdiFlush();
}
return NULL;
// NTSC_END
// CHECK EACH CELL FOR CHANGED BYTES. REDRAW PIXELS FOR THE CHANGED BYTES // CHECK EACH CELL FOR CHANGED BYTES. REDRAW PIXELS FOR THE CHANGED BYTES
// IN THE FRAME BUFFER. MARK CELLS IN WHICH REDRAWING HAS TAKEN PLACE AS // IN THE FRAME BUFFER. MARK CELLS IN WHICH REDRAWING HAS TAKEN PLACE AS
// DIRTY. // DIRTY.
@ -2779,8 +2760,8 @@ void _Video_RedrawScreen( VideoUpdateFuncPtr_t pfUpdate, bool bMixed )
//=========================================================================== //===========================================================================
void VideoReinitialize () void VideoReinitialize ()
{ {
V_CreateIdentityPalette(); NTSC_VideoInitAppleType();
V_CreateDIBSections(); NTSC_SetVideoStyle();
} }
@ -2803,10 +2784,10 @@ BYTE VideoSetMode (WORD, WORD address, BYTE write, BYTE, ULONG uExecutedCycles)
switch (address) switch (address)
{ {
case 0x00: g_uVideoMode &= ~VF_80STORE; break; case 0x00: g_uVideoMode &= ~VF_80STORE; ; break;
case 0x01: g_uVideoMode |= VF_80STORE; break; case 0x01: g_uVideoMode |= VF_80STORE; ; break;
case 0x0C: if (!IS_APPLE2) g_uVideoMode &= ~VF_80COL; break; case 0x0C: if (!IS_APPLE2) g_uVideoMode &= ~VF_80COL; NTSC_SetVideoTextMode(40); break;
case 0x0D: if (!IS_APPLE2) g_uVideoMode |= VF_80COL; break; case 0x0D: if (!IS_APPLE2) g_uVideoMode |= VF_80COL; NTSC_SetVideoTextMode(80); break;
case 0x0E: if (!IS_APPLE2) g_nAltCharSetOffset = 0; break; // Alternate char set off case 0x0E: if (!IS_APPLE2) g_nAltCharSetOffset = 0; break; // Alternate char set off
case 0x0F: if (!IS_APPLE2) g_nAltCharSetOffset = 256; break; // Alternate char set on case 0x0F: if (!IS_APPLE2) g_nAltCharSetOffset = 256; break; // Alternate char set on
case 0x50: g_uVideoMode &= ~VF_TEXT; break; case 0x50: g_uVideoMode &= ~VF_TEXT; break;
@ -2821,6 +2802,10 @@ BYTE VideoSetMode (WORD, WORD address, BYTE write, BYTE, ULONG uExecutedCycles)
case 0x5F: if (!IS_APPLE2) g_uVideoMode &= ~VF_DHIRES; break; case 0x5F: if (!IS_APPLE2) g_uVideoMode &= ~VF_DHIRES; break;
} }
// NTSC_BEGIN
NTSC_SetVideoMode( g_uVideoMode );
// NTSC_END
if (SW_80STORE) if (SW_80STORE)
g_uVideoMode &= ~VF_PAGE2; g_uVideoMode &= ~VF_PAGE2;
@ -3316,7 +3301,7 @@ void Video_MakeScreenShot(FILE *pFile)
// Write Pixel Data // Write Pixel Data
// No need to use GetDibBits() since we already have http://msdn.microsoft.com/en-us/library/ms532334.aspx // No need to use GetDibBits() since we already have http://msdn.microsoft.com/en-us/library/ms532334.aspx
// @reference: "Storing an Image" http://msdn.microsoft.com/en-us/library/ms532340(VS.85).aspx // @reference: "Storing an Image" http://msdn.microsoft.com/en-us/library/ms532340(VS.85).aspx
pSrc = ((u8*)g_pFramebufferbits); pSrc = ((uint8_t*)g_pFramebufferbits);
nLen = g_tBmpHeader.nWidthPixels * g_tBmpHeader.nHeightPixels * g_tBmpHeader.nBitsPerPixel / 8; nLen = g_tBmpHeader.nWidthPixels * g_tBmpHeader.nHeightPixels * g_tBmpHeader.nBitsPerPixel / 8;
if( g_iScreenshotType == SCREENSHOT_280x192 ) if( g_iScreenshotType == SCREENSHOT_280x192 )
@ -3351,10 +3336,10 @@ void Video_MakeScreenShot(FILE *pFile)
TargaHeader_t *pHeader = &g_tTargaHeader; TargaHeader_t *pHeader = &g_tTargaHeader;
memset( (void*)pHeader, 0, sizeof( TargaHeader_t ) ); memset( (void*)pHeader, 0, sizeof( TargaHeader_t ) );
pHeader->iImageType = TARGA_RGB; pHeader->iImageType = TARGA_RGB;
pHeader->nWidthPixels = FRAMEBUFFER_W; pHeader->nWidthPixels = FRAMEBUFFER_W;
pHeader->nHeightPixels = FRAMEBUFFER_H; pHeader->nHeightPixels = FRAMEBUFFER_H;
pHeader->nBitsPerPixel = 24; pHeader->nBitsPerPixel = 24;
#endif // SCREENSHOT_TGA #endif // SCREENSHOT_TGA
} }
@ -3393,3 +3378,36 @@ void Config_Save_Video()
REGSAVE(TEXT(REGVALUE_VIDEO_HALF_SCAN_LINES),g_uHalfScanLines); REGSAVE(TEXT(REGVALUE_VIDEO_HALF_SCAN_LINES),g_uHalfScanLines);
REGSAVE(TEXT(REGVALUE_VIDEO_MONO_COLOR ),monochrome); REGSAVE(TEXT(REGVALUE_VIDEO_MONO_COLOR ),monochrome);
} }
// ____________________________________________________________________
//===========================================================================
void NTSC_VideoCreateDIBSection()
{
// CREATE THE DEVICE CONTEXT
HWND window = GetDesktopWindow();
HDC dc = GetDC(window);
if (g_hDeviceDC)
{
DeleteDC(g_hDeviceDC);
}
g_hDeviceDC = CreateCompatibleDC(dc);
// CREATE THE FRAME BUFFER DIB SECTION
if (g_hDeviceBitmap)
DeleteObject(g_hDeviceBitmap);
g_hDeviceBitmap = CreateDIBSection(
dc,
g_pFramebufferinfo,
DIB_RGB_COLORS,
(LPVOID *)&g_pFramebufferbits,0,0
);
SelectObject(g_hDeviceDC,g_hDeviceBitmap);
// CREATE THE OFFSET TABLE FOR EACH SCAN LINE IN THE FRAME BUFFER
// DRAW THE SOURCE IMAGE INTO THE SOURCE BIT BUFFER
ZeroMemory( g_pFramebufferbits, FRAMEBUFFER_W*FRAMEBUFFER_H*4 );
NTSC_VideoInit( g_pFramebufferbits );
}

View File

@ -8,8 +8,8 @@
{ {
VT_MONO_HALFPIXEL_REAL // uses custom monochrome VT_MONO_HALFPIXEL_REAL // uses custom monochrome
, VT_COLOR_STANDARD , VT_COLOR_STANDARD
, VT_COLOR_TEXT_OPTIMIZED , VT_COLOR_TEXT_OPTIMIZED
, VT_COLOR_TVEMU , VT_COLOR_TVEMU
, VT_MONO_AMBER // now half pixel , VT_MONO_AMBER // now half pixel
, VT_MONO_GREEN // now half pixel , VT_MONO_GREEN // now half pixel
, VT_MONO_WHITE // now half pixel , VT_MONO_WHITE // now half pixel
@ -19,28 +19,39 @@
extern TCHAR g_aVideoChoices[]; extern TCHAR g_aVideoChoices[];
extern char *g_apVideoModeDesc[ NUM_VIDEO_MODES ]; extern char *g_apVideoModeDesc[ NUM_VIDEO_MODES ];
enum AppleFont_e enum VideoFlag_e
{ {
// 40-Column mode is 1x Zoom (default) VF_80COL = 0x00000001,
// 80-Column mode is ~0.75x Zoom (7 x 16) VF_DHIRES = 0x00000002,
// Tiny mode is 0.5 zoom (7x8) for debugger VF_HIRES = 0x00000004,
APPLE_FONT_WIDTH = 14, // in pixels VF_80STORE= 0x00000008, // was called VF_MASK2
APPLE_FONT_HEIGHT = 16, // in pixels VF_MIXED = 0x00000010,
VF_PAGE2 = 0x00000020,
VF_TEXT = 0x00000040
};
// Each cell has a reserved aligned pixel area (grid spacing) enum AppleFont_e
APPLE_FONT_CELL_WIDTH = 16, {
APPLE_FONT_CELL_HEIGHT = 16, // 40-Column mode is 1x Zoom (default)
// 80-Column mode is ~0.75x Zoom (7 x 16)
// Tiny mode is 0.5 zoom (7x8) for debugger
APPLE_FONT_WIDTH = 14, // in pixels
APPLE_FONT_HEIGHT = 16, // in pixels
// The bitmap contains 3 regions // Each cell has a reserved aligned pixel area (grid spacing)
// Each region is 256x256 pixels = 16x16 chars APPLE_FONT_CELL_WIDTH = 16,
APPLE_FONT_X_REGIONSIZE = 256, // in pixelx APPLE_FONT_CELL_HEIGHT = 16,
APPLE_FONT_Y_REGIONSIZE = 256, // in pixels
// Starting Y offsets (pixels) for the regions // The bitmap contains 3 regions
APPLE_FONT_Y_APPLE_2PLUS = 0, // ][+ // Each region is 256x256 pixels = 16x16 chars
APPLE_FONT_Y_APPLE_80COL = 256, // //e (inc. Mouse Text) APPLE_FONT_X_REGIONSIZE = 256, // in pixelx
APPLE_FONT_Y_APPLE_40COL = 512, // ][ APPLE_FONT_Y_REGIONSIZE = 256, // in pixels
};
// Starting Y offsets (pixels) for the regions
APPLE_FONT_Y_APPLE_2PLUS = 0, // ][+
APPLE_FONT_Y_APPLE_80COL = 256, // //e (inc. Mouse Text)
APPLE_FONT_Y_APPLE_40COL = 512, // ][
};
// Globals __________________________________________________________ // Globals __________________________________________________________
@ -49,7 +60,8 @@ extern HBITMAP g_hLogoBitmap;
extern COLORREF monochrome; // saved extern COLORREF monochrome; // saved
extern DWORD g_eVideoType; // saved extern DWORD g_eVideoType; // saved
extern DWORD g_uHalfScanLines; // saved extern DWORD g_uHalfScanLines; // saved
extern LPBYTE g_pFramebufferbits; extern uint8_t *g_pFramebufferbits;
extern int g_nAltCharSetOffset; // alternate character set
typedef bool (*VideoUpdateFuncPtr_t)(int,int,int,int,int); typedef bool (*VideoUpdateFuncPtr_t)(int,int,int,int,int);
@ -59,7 +71,7 @@ void CreateColorMixMap();
BOOL VideoApparentlyDirty (); BOOL VideoApparentlyDirty ();
void VideoBenchmark (); void VideoBenchmark ();
void VideoChooseColor (); void VideoChooseMonochromeColor (); // FIXME: Should be moved to PageConfig and call VideoSetMonochromeColor()
void VideoDestroy (); void VideoDestroy ();
void VideoDrawLogoBitmap(HDC hDstDC, int xoff, int yoff, int srcw, int srch, int scale); void VideoDrawLogoBitmap(HDC hDstDC, int xoff, int yoff, int srcw, int srch, int scale);
void VideoDisplayLogo (); void VideoDisplayLogo ();
@ -85,9 +97,6 @@ bool VideoGetSWAltCharSet(void);
void VideoSetForceFullRedraw(void); void VideoSetForceFullRedraw(void);
DWORD VideoGetSnapshot(SS_IO_Video* pSS);
DWORD VideoSetSnapshot(SS_IO_Video* pSS);
void _Video_Dirty(); void _Video_Dirty();
void _Video_RedrawScreen( VideoUpdateFuncPtr_t update, bool bMixed = false ); void _Video_RedrawScreen( VideoUpdateFuncPtr_t update, bool bMixed = false );
void _Video_SetupBanks( bool bBank2 ); void _Video_SetupBanks( bool bBank2 );