Publish VCC Plus OSS source distribution for 3.6.2 build 60
This commit is contained in:
commit
c652a5276d
1192 files changed
+272368
No files matched your search
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
Copyright 2015 by Joseph Forgione
|
||||
This file is part of VCC (Virtual Color Computer).
|
||||
|
||||
VCC (Virtual Color Computer) 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
VCC (Virtual Color Computer) 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 VCC (Virtual Color Computer). If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Windows printer file and monitor adapter, extracted from mc6821.cpp.
|
||||
#include <Windows.h>
|
||||
#include "../../src/core/mc6821.h"
|
||||
static unsigned char AddLF = 0;
|
||||
static HANDLE hPrintFile = INVALID_HANDLE_VALUE;
|
||||
static HANDLE hout = nullptr;
|
||||
static bool MonState = false;
|
||||
void WritePrintMon(char*);
|
||||
|
||||
void CaptureBit(unsigned char Sample)
|
||||
{
|
||||
unsigned long BytesMoved=0;
|
||||
static unsigned char BitMask=1,StartWait=1;
|
||||
static char Byte=0;
|
||||
if (hPrintFile==INVALID_HANDLE_VALUE)
|
||||
return;
|
||||
if (StartWait & Sample) //Waiting for start bit
|
||||
return;
|
||||
if (StartWait)
|
||||
{
|
||||
StartWait=0;
|
||||
return;
|
||||
}
|
||||
if (Sample)
|
||||
Byte|=BitMask;
|
||||
BitMask=BitMask<<1;
|
||||
if (!BitMask)
|
||||
{
|
||||
BitMask=1;
|
||||
StartWait=1;
|
||||
WriteFile(hPrintFile,&Byte,1,&BytesMoved,nullptr);
|
||||
if (MonState)
|
||||
WritePrintMon(&Byte);
|
||||
if ((Byte==0x0D) & AddLF)
|
||||
{
|
||||
Byte=0x0A;
|
||||
WriteFile(hPrintFile,&Byte,1,&BytesMoved,nullptr);
|
||||
}
|
||||
Byte=0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int OpenPrintFile(const char *FileName)
|
||||
{
|
||||
hPrintFile=CreateFile( FileName,GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ,nullptr,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,nullptr);
|
||||
if (hPrintFile==INVALID_HANDLE_VALUE)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ClosePrintFile()
|
||||
{
|
||||
CloseHandle(hPrintFile);
|
||||
hPrintFile=INVALID_HANDLE_VALUE;
|
||||
FreeConsole();
|
||||
hout=nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
void SetSerialParams(unsigned char TextMode)
|
||||
{
|
||||
AddLF=TextMode;
|
||||
return;
|
||||
}
|
||||
|
||||
void SetMonState(bool State)
|
||||
{
|
||||
if (MonState & !State)
|
||||
{
|
||||
FreeConsole();
|
||||
hout=nullptr;
|
||||
}
|
||||
MonState=State;
|
||||
return;
|
||||
}
|
||||
void WritePrintMon(char *Data)
|
||||
{
|
||||
unsigned long dummy;
|
||||
if (hout==nullptr)
|
||||
{
|
||||
AllocConsole();
|
||||
hout=GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
SetConsoleTitle("Printer Monitor");
|
||||
}
|
||||
WriteConsole(hout,Data,1,&dummy,nullptr);
|
||||
if (Data[0]==0x0D)
|
||||
{
|
||||
Data[0]=0x0A;
|
||||
WriteConsole(hout,Data,1,&dummy,nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user