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,366 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
//#include <dplay.h>
|
||||
#include <dsound.h>
|
||||
#include <stdio.h>
|
||||
#include "defines.h"
|
||||
#include "Vcc.h"
|
||||
#include "config.h"
|
||||
#include "coco3.h"
|
||||
#include "audio.h"
|
||||
#include <vcc/util/logger.h>
|
||||
#include "../../src/core/BuildConfig.h"
|
||||
#include "Cassette.h"
|
||||
|
||||
#if USE_DEBUG_AUDIOTAPE
|
||||
#include "../../src/core/IDisplayDebug.h"
|
||||
#endif
|
||||
|
||||
using AuxBufferType = VCC::Array<VCC::Array<uint32_t, AUDIO_RATE / 60>, 6>;
|
||||
|
||||
constexpr auto MAXCARDS = 12u;
|
||||
//PlayBack
|
||||
static LPDIRECTSOUND lpds; // directsound interface pointer
|
||||
static DSBUFFERDESC dsbd; // directsound description
|
||||
static DSCAPS dscaps; // directsound caps
|
||||
static DSBCAPS dsbcaps; // directsound buffer caps
|
||||
//Record
|
||||
static LPDIRECTSOUNDCAPTURE8 lpdsin;
|
||||
static DSCBUFFERDESC dsbdin; // directsound description
|
||||
|
||||
HRESULT hr;
|
||||
static LPDIRECTSOUNDBUFFER lpdsbuffer1=nullptr; //the sound buffers
|
||||
static LPDIRECTSOUNDCAPTUREBUFFER lpdsbuffer2=nullptr; //the sound buffers for capture
|
||||
static WAVEFORMATEX pcmwf; //generic waveformat structure
|
||||
static void *SndPointer1 = nullptr,*SndPointer2 = nullptr;
|
||||
static unsigned int BitRate=0;
|
||||
static DWORD SndLenth1= 0,SndLenth2= 0,SndBuffLenth = 0;
|
||||
static unsigned char InitPassed=0;
|
||||
static unsigned int BlockSize=0;
|
||||
static AuxBufferType AuxBuffer;
|
||||
static DWORD WritePointer=0;
|
||||
static DWORD BuffOffset=0;
|
||||
static char AuxBufferPointer=0;
|
||||
static int CardCount=0;
|
||||
static unsigned int CurrentRate=0;
|
||||
static unsigned char AudioPause=0;
|
||||
static bool AudioStall = false;
|
||||
static SndCardList *Cards=nullptr;
|
||||
BOOL CALLBACK DSEnumCallback(LPGUID,LPCSTR,LPCSTR,LPVOID);
|
||||
|
||||
|
||||
#if USE_DEBUG_AUDIOTAPE
|
||||
static void* AudioBaseAddress=0;
|
||||
const int AudioHistorySize = 50;
|
||||
struct AudioBufferHistory
|
||||
{
|
||||
void* aBuf;
|
||||
unsigned int aSize;
|
||||
void* bBuf;
|
||||
unsigned int bSize;
|
||||
unsigned int playPos;
|
||||
unsigned int writePos;
|
||||
unsigned int freeBlocks;
|
||||
};
|
||||
AudioBufferHistory gAudioBufferHistory[AudioHistorySize];
|
||||
#endif
|
||||
|
||||
int SoundInit (HWND main_window_handle,const _GUID * Guid,unsigned int Rate)
|
||||
{
|
||||
Rate=(Rate & 3);
|
||||
if (Rate != 0) //Force 44100 or Mute
|
||||
Rate = 3;
|
||||
CurrentRate=Rate;
|
||||
if (InitPassed)
|
||||
{
|
||||
PauseAudio(true);
|
||||
ResetAudio();
|
||||
SoundDeInit();
|
||||
}
|
||||
SndLenth1= 0;
|
||||
SndLenth2= 0;
|
||||
BuffOffset=0;
|
||||
AuxBufferPointer=0;
|
||||
BitRate=iRateList[Rate];
|
||||
BlockSize=BitRate*4/TARGETFRAMERATE;
|
||||
SndBuffLenth = (BlockSize*AUDIOBUFFERS);
|
||||
if (Rate)
|
||||
{
|
||||
hr=DirectSoundCreate(Guid, &lpds, nullptr); // create a directsound object
|
||||
if (hr!=DS_OK)
|
||||
return 1;
|
||||
|
||||
hr=lpds->SetCooperativeLevel(main_window_handle,DSSCL_NORMAL); // set cooperation level normal DSSCL_EXCLUSIVE
|
||||
if (hr!=DS_OK)
|
||||
return 1;
|
||||
// set up the format data structure
|
||||
memset(&pcmwf, 0, sizeof(WAVEFORMATEX));
|
||||
pcmwf.wFormatTag = WAVE_FORMAT_PCM;
|
||||
pcmwf.nChannels = 2;
|
||||
pcmwf.nSamplesPerSec = BitRate;
|
||||
pcmwf.wBitsPerSample = 16;
|
||||
pcmwf.nBlockAlign = (pcmwf.wBitsPerSample * pcmwf.nChannels) >> 3;
|
||||
pcmwf.nAvgBytesPerSec = pcmwf.nSamplesPerSec * pcmwf.nBlockAlign;
|
||||
pcmwf.cbSize = 0;
|
||||
|
||||
// create the secondary buffer
|
||||
memset(&dsbd,0,sizeof(DSBUFFERDESC));
|
||||
dsbd.dwSize = sizeof(DSBUFFERDESC);
|
||||
dsbd.dwFlags = DSBCAPS_GETCURRENTPOSITION2|DSBCAPS_LOCSOFTWARE|DSBCAPS_STATIC|DSBCAPS_GLOBALFOCUS;
|
||||
dsbd.dwBufferBytes = SndBuffLenth;
|
||||
dsbd.lpwfxFormat = &pcmwf;
|
||||
|
||||
hr=lpds->CreateSoundBuffer(&dsbd,&lpdsbuffer1,nullptr);
|
||||
if (hr!=DS_OK)
|
||||
return 1;
|
||||
|
||||
// Clear out sound buffers
|
||||
hr= lpdsbuffer1->Lock(0,SndBuffLenth,&SndPointer1,&SndLenth1,&SndPointer2,&SndLenth2,DSBLOCK_ENTIREBUFFER );
|
||||
if (hr!=DS_OK)
|
||||
return 1;
|
||||
|
||||
#if USE_DEBUG_AUDIOTAPE
|
||||
AudioBaseAddress = SndPointer1;
|
||||
memset(gAudioBufferHistory, 0, sizeof(gAudioBufferHistory));
|
||||
#endif
|
||||
memset (SndPointer1,0,SndBuffLenth);
|
||||
hr=lpdsbuffer1->Unlock(SndPointer1,SndLenth1,SndPointer2,SndLenth2);
|
||||
if (hr!=DS_OK)
|
||||
return 1;
|
||||
|
||||
|
||||
lpdsbuffer1->SetCurrentPosition(0);
|
||||
hr=lpdsbuffer1->Play(0,0,DSBPLAY_LOOPING ); // play the sound in looping mode
|
||||
if (hr!=DS_OK)
|
||||
return 1;
|
||||
InitPassed=1;
|
||||
AudioPause=0;
|
||||
AudioStall = false;
|
||||
}
|
||||
SetAudioRate(AUDIO_RATE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FlushAudioBuffer(unsigned int *Abuffer,unsigned int Lenth)
|
||||
{
|
||||
const unsigned char *Abuffer2=(unsigned char *)Abuffer;
|
||||
|
||||
if (!InitPassed || AudioPause || !Abuffer)
|
||||
return;
|
||||
|
||||
auto freeBlocks = GetFreeBlockCount();
|
||||
if (freeBlocks<=0) // should only happen when frame skipping or unthrottled
|
||||
return;
|
||||
|
||||
// Levels calculated in config.c if Audio config dialog is running
|
||||
UpdateSoundBar(Abuffer,Lenth);
|
||||
|
||||
#if USE_DEBUG_AUDIOTAPE
|
||||
memcpy(&gAudioBufferHistory[0], &gAudioBufferHistory[1], sizeof(gAudioBufferHistory) - sizeof(*gAudioBufferHistory));
|
||||
unsigned long WriteCursor = 0, PlayCursor = 0;
|
||||
lpdsbuffer1->GetCurrentPosition(&PlayCursor, &WriteCursor);
|
||||
auto& history = gAudioBufferHistory[AudioHistorySize - 1];
|
||||
history.playPos = PlayCursor;
|
||||
history.writePos = WriteCursor;
|
||||
history.freeBlocks = freeBlocks;
|
||||
#endif
|
||||
|
||||
hr=lpdsbuffer1->Lock(BuffOffset,Lenth,&SndPointer1,&SndLenth1,&SndPointer2,&SndLenth2,0);
|
||||
if (hr != DS_OK)
|
||||
return;
|
||||
|
||||
memcpy(SndPointer1, Abuffer2, SndLenth1); // copy first section of circular buffer
|
||||
if (SndPointer2 != nullptr) // copy last section if wrapped
|
||||
memcpy(SndPointer2, Abuffer2 + SndLenth1, SndLenth2);
|
||||
hr=lpdsbuffer1->Unlock(SndPointer1,SndLenth1,SndPointer2,SndLenth2);// unlock the buffer
|
||||
BuffOffset=(BuffOffset + Lenth)% SndBuffLenth; //Where to write next
|
||||
|
||||
#if USE_DEBUG_AUDIOTAPE
|
||||
history.aBuf = SndPointer1;
|
||||
history.aSize = SndLenth1;
|
||||
history.bBuf = SndPointer2;
|
||||
history.bSize = SndLenth2;
|
||||
const int s = 75;
|
||||
const int xp = 1000;
|
||||
for (int i = 0; i < 50;++i)
|
||||
{
|
||||
auto& data = gAudioBufferHistory[i];
|
||||
VCC::Pixel col(VCC::ColorYellow); col.a = 200;
|
||||
int x = (char*)data.aBuf - (char*)AudioBaseAddress;
|
||||
int y = 400 + i * 8;
|
||||
DebugDrawBox(xp + x / s, y, data.aSize / s, 3, col);
|
||||
if (data.bBuf)
|
||||
{
|
||||
VCC::Pixel col(VCC::ColorGreen); col.a = 200;
|
||||
int x1 = (char*)data.bBuf - (char*)AudioBaseAddress;
|
||||
DebugDrawBox(xp + x1 / s, y, data.bSize / s, 3, col);
|
||||
}
|
||||
DebugDrawLine(xp + data.playPos / s, y - 1, xp + data.playPos / s, y + 5, VCC::ColorGreen);
|
||||
DebugDrawLine(xp + data.writePos / s, y - 1, xp + data.writePos / s, y + 5, VCC::ColorRed);
|
||||
DebugDrawBox(xp - 20, y, data.freeBlocks, 3, col);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void OnMonitorRestored()
|
||||
{
|
||||
if (!AudioStall) return;
|
||||
InitSound();
|
||||
AudioStall = false;
|
||||
}
|
||||
|
||||
int GetFreeBlockCount() //return 0 on full buffer
|
||||
{
|
||||
static unsigned long LastPlayCursor = 0;
|
||||
static int LastCount = 0;
|
||||
|
||||
unsigned long WriteCursor=0,PlayCursor=0;
|
||||
long RetVal=0,MaxSize=0;
|
||||
if (!InitPassed || AudioPause)
|
||||
return AUDIOBUFFERS;
|
||||
RetVal=lpdsbuffer1->GetCurrentPosition(&PlayCursor,&WriteCursor);
|
||||
if (PlayCursor == LastPlayCursor)
|
||||
{
|
||||
if (++LastCount > 100)
|
||||
{
|
||||
AudioStall = true;
|
||||
LastCount = 0;
|
||||
LastPlayCursor = 0;
|
||||
return AUDIOBUFFERS;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LastPlayCursor = PlayCursor;
|
||||
LastCount = 0;
|
||||
}
|
||||
if (BuffOffset <=PlayCursor)
|
||||
MaxSize= PlayCursor - BuffOffset;
|
||||
else
|
||||
MaxSize= SndBuffLenth - BuffOffset + PlayCursor;
|
||||
return(MaxSize/BlockSize);
|
||||
|
||||
}
|
||||
|
||||
void PurgeAuxBuffer()
|
||||
{
|
||||
if (!InitPassed || AudioPause)
|
||||
return;
|
||||
return;
|
||||
AuxBufferPointer--; //Normally points to next free block Point to last used block
|
||||
if (AuxBufferPointer>=0) //zero is a valid data block
|
||||
{
|
||||
while (GetFreeBlockCount() <= 0);
|
||||
|
||||
|
||||
hr=lpdsbuffer1->Lock(BuffOffset,BlockSize,&SndPointer1,&SndLenth1,&SndPointer2,&SndLenth2,0);//DSBLOCK_FROMWRITECURSOR);
|
||||
if (hr != DS_OK)
|
||||
return;
|
||||
AuxBuffer[AuxBufferPointer].MemCpyTo(SndPointer1, SndLenth1);
|
||||
if (SndPointer2 != nullptr)
|
||||
AuxBuffer[AuxBufferPointer].MemCpyTo((SndLenth1 >> 2), SndPointer2, SndLenth2);
|
||||
BuffOffset=(BuffOffset + BlockSize)% SndBuffLenth;
|
||||
hr=lpdsbuffer1->Unlock(SndPointer1,SndLenth1,SndPointer2,SndLenth2);
|
||||
AuxBufferPointer--;
|
||||
}
|
||||
AuxBufferPointer=0;
|
||||
return;
|
||||
}
|
||||
|
||||
int GetSoundCardList (SndCardList *List)
|
||||
{
|
||||
CardCount=0;
|
||||
Cards=List;
|
||||
DirectSoundEnumerate(DSEnumCallback, nullptr);
|
||||
return CardCount;
|
||||
}
|
||||
|
||||
BOOL CALLBACK DSEnumCallback(LPGUID lpGuid,LPCSTR lpcstrDescription,LPCSTR /*lpcstrModule*/,LPVOID /*lpContext*/)
|
||||
{
|
||||
strncpy(Cards[CardCount].CardName,lpcstrDescription,63);
|
||||
Cards[CardCount++].Guid=lpGuid;
|
||||
return (CardCount<MAXCARDS);
|
||||
}
|
||||
|
||||
int SoundDeInit()
|
||||
{
|
||||
if (InitPassed)
|
||||
{
|
||||
InitPassed=0;
|
||||
if (lpdsbuffer1 != nullptr)
|
||||
{
|
||||
hr = lpdsbuffer1->Release();
|
||||
lpdsbuffer1 = nullptr;
|
||||
}
|
||||
|
||||
if (lpds != nullptr)
|
||||
{
|
||||
hr = lpds->Release();
|
||||
lpds = nullptr;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SoundInInit (const _GUID * Guid)
|
||||
{
|
||||
hr=DirectSoundCaptureCreate(Guid, &lpdsin, nullptr);
|
||||
if (hr!=DS_OK)
|
||||
return 1;
|
||||
dsbdin.dwSize=sizeof(DSCBUFFERDESC); // Size of the structure
|
||||
dsbdin.dwFlags=0;
|
||||
dsbdin.dwReserved=0;
|
||||
dsbdin.lpwfxFormat=&pcmwf; //fix
|
||||
dsbdin.dwBufferBytes=SndBuffLenth;
|
||||
hr=lpdsin->CreateCaptureBuffer(&dsbdin, &lpdsbuffer2, nullptr);
|
||||
if (hr!=DS_OK)
|
||||
return 1;
|
||||
lpdsbuffer2->Start(hr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int GetSoundStatus()
|
||||
{
|
||||
return CurrentRate;
|
||||
}
|
||||
|
||||
void ResetAudio ()
|
||||
{
|
||||
SetAudioRate(GetTapeRate());
|
||||
if (InitPassed)
|
||||
lpdsbuffer1->SetCurrentPosition(0);
|
||||
BuffOffset=0;
|
||||
AuxBufferPointer=0;
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char PauseAudio(unsigned char Pause)
|
||||
{
|
||||
AudioPause=Pause;
|
||||
if (InitPassed)
|
||||
{
|
||||
if (AudioPause==1)
|
||||
hr=lpdsbuffer1->Stop();
|
||||
else
|
||||
hr=lpdsbuffer1->Play(0,0,DSBPLAY_LOOPING);
|
||||
}
|
||||
return AudioPause;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
@echo off
|
||||
:: Build VCC
|
||||
|
||||
set _CL_=
|
||||
set VCC_CONFIG=Release
|
||||
if exist "%VSINSTALLDIR%\MSBuild\Current\Bin\MSBuild.exe" (
|
||||
msbuild vcc.sln /m /p:Configuration=%VCC_CONFIG% /p:Platform=x86
|
||||
if errorlevel 0 (
|
||||
echo Find VCC binaries in %cd%\__bin\Win32\%VCC_CONFIG%
|
||||
)
|
||||
) else (
|
||||
echo Build must be run from Developer Command Prompt for VS 2022
|
||||
)
|
||||
@@ -0,0 +1,14 @@
|
||||
@echo off
|
||||
:: Build without and with logging
|
||||
|
||||
set VCC_CONFIG=Release
|
||||
if exist "%VSINSTALLDIR%\MSBuild\Current\Bin\MSBuild.exe" (
|
||||
msbuild vcc.sln /t:Clean /p:Configuration=%VCC_CONFIG% /p:Platform=x86
|
||||
set _CL_=
|
||||
call Build.bat
|
||||
msbuild vcc.sln /t:Clean /p:Configuration=%VCC_CONFIG% /p:Platform=x86
|
||||
set _CL_=/DUSE_LOGGING
|
||||
call Build.bat
|
||||
) else (
|
||||
echo Build must be run from Developer Command Prompt for VS 2022
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
@echo off
|
||||
:: Clean Build VCC
|
||||
|
||||
set _CL_=
|
||||
set VCC_CONFIG=Release
|
||||
if exist "%VSINSTALLDIR%\MSBuild\Current\Bin\MSBuild.exe" (
|
||||
msbuild vcc.sln /t:Clean /p:Configuration=%VCC_CONFIG% /p:Platform=x86
|
||||
call Build.bat
|
||||
) else (
|
||||
echo Build must be run from Developer Command Prompt for VS 2022
|
||||
)
|
||||
@@ -0,0 +1,674 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <Windows.h>
|
||||
#include <iostream>
|
||||
#include "resource.h"
|
||||
#include "defines.h"
|
||||
#include "coco3.h"
|
||||
#include "config.h"
|
||||
#include <vcc/util/DialogOps.h>
|
||||
#include <vcc/util/fileutil.h>
|
||||
#include "Cassette.h"
|
||||
#include "stdio.h"
|
||||
#include <vcc/util/logger.h>
|
||||
#include <functional>
|
||||
|
||||
unsigned char MotorState=0,TapeMode=STOP,WriteProtect=0,Quiet=30;
|
||||
static HANDLE TapeHandle=nullptr;
|
||||
static unsigned long TapeOffset=0,TotalSize=0;
|
||||
static char TapeFileName[MAX_PATH]="";
|
||||
static char CassPath[MAX_PATH];
|
||||
static unsigned char TempBuffer[8192];
|
||||
static unsigned char *CasBuffer=nullptr;
|
||||
static char TapeWritten = 0;
|
||||
static char FileType = TAPE_UNKNOWN;
|
||||
extern unsigned char TapeFastLoad;
|
||||
unsigned long BytesMoved=0;
|
||||
static unsigned int TempIndex=0;
|
||||
static unsigned int TapeRate=CAS_TAPEAUDIORATE;
|
||||
static unsigned int TapeSampleSize=0;
|
||||
static unsigned int MotorOffDelay = 0;
|
||||
static unsigned long PrvOffset=0,StalledCtr=0;
|
||||
|
||||
unsigned char One[21]={0xC8,0xE8,0xE8,0xF8,0xF8,0xE8,0xC8,0xA8,0x78,0x50,0x50,0x30,0x10,0x00,0x00,0x10,0x30,0x30,0x50,0x80,0xA8};
|
||||
unsigned char Zero[40]={0xC8,0xD8,0xE8,0xE8,0xF0,0xF8,0xF8,0xF8,0xF0,0xE8,0xD8,0xC8,0xB8,0xA8,0x90,0x78,0x78,0x68,0x50,0x40,0x30,0x20,0x10,0x08,0x00,0x00,0x00,0x08,0x10,0x10,0x20,0x30,0x40,0x50,0x68,0x68,0x80,0x90,0xA8,0xB8};
|
||||
|
||||
namespace VCC
|
||||
{
|
||||
struct WavHeader
|
||||
{
|
||||
char riff[4]; // RIFF
|
||||
uint32_t fileSize;
|
||||
char wave[4]; // WAVE
|
||||
};
|
||||
|
||||
struct WavBlock
|
||||
{
|
||||
char name[4]; // "data"
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
struct WavFmtBlock : WavBlock
|
||||
{
|
||||
uint16_t waveType;
|
||||
uint16_t channels;
|
||||
uint32_t bitRate;
|
||||
uint32_t bytesPerSec;
|
||||
uint16_t blockAlign;
|
||||
uint16_t bitsPerSample;
|
||||
};
|
||||
|
||||
void SampleSignedConversion(int width, uint8_t* outBuffer, const uint8_t* inBuffer, size_t samples)
|
||||
{
|
||||
for (size_t i = 0; i < samples; ++i)
|
||||
{
|
||||
auto p = inBuffer + i * width + width - 1;
|
||||
int sample = *p;
|
||||
outBuffer[i] = (uint8_t)(sample + CAS_SILENCE);
|
||||
}
|
||||
}
|
||||
|
||||
void SampleUnsignedConversion(int width, uint8_t* outBuffer, const uint8_t* inBuffer, size_t samples)
|
||||
{
|
||||
for (size_t i = 0; i < samples; ++i)
|
||||
{
|
||||
auto p = inBuffer + i * width + width - 1;
|
||||
uint8_t sample = *p;
|
||||
outBuffer[i] = sample;
|
||||
}
|
||||
}
|
||||
|
||||
void SampleFloatConversion(int width, uint8_t* outBuffer, const uint8_t* inBuffer, size_t samples)
|
||||
{
|
||||
for (size_t i = 0; i < samples; ++i)
|
||||
{
|
||||
auto p = inBuffer + i * width;
|
||||
float sample = *reinterpret_cast<const float*>(p);
|
||||
outBuffer[i] = (uint8_t)(sample * 128) + 256 / 2;
|
||||
}
|
||||
}
|
||||
|
||||
bool Init()
|
||||
{
|
||||
// reduce peak to peak to 75% for .cas as its more realistic what actual tape uses
|
||||
for (int i = 0; i < sizeof(One); ++i)
|
||||
One[i] = One[i] / 2 + One[i] / 4 + 64 / 2;
|
||||
for (int i = 0; i < sizeof(Zero); ++i)
|
||||
Zero[i] = Zero[i] / 2 + Zero[i] / 4 + 64 / 2;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool gInit = Init();
|
||||
}
|
||||
|
||||
static std::function<void(int, uint8_t*, const uint8_t*, size_t)> Conversion;
|
||||
|
||||
//Write Stuff
|
||||
static int LastTrans=0;
|
||||
static unsigned char Mask=0,Byte=0,LastSample=0;
|
||||
//****************************
|
||||
|
||||
void WavtoCas(const unsigned char *,unsigned int);
|
||||
int MountTape( const char *);
|
||||
void CloseTapeFile();
|
||||
void SyncFileBuffer();
|
||||
void CastoWav(unsigned char *,unsigned int);
|
||||
|
||||
unsigned int GetTapeRate()
|
||||
{
|
||||
return TapeRate;
|
||||
}
|
||||
|
||||
unsigned char GetMotorState()
|
||||
{
|
||||
if (MotorOffDelay > 0)
|
||||
{
|
||||
--MotorOffDelay;
|
||||
return 1;
|
||||
}
|
||||
return MotorState;
|
||||
}
|
||||
|
||||
//
|
||||
// true if tape playback is fast load cas
|
||||
//
|
||||
bool GetTapePlaybackFastLoad()
|
||||
{
|
||||
return !IsTapeWav() && TapeFastLoad && TapeMode == PLAY && TotalSize > 0;
|
||||
}
|
||||
|
||||
void Motor(unsigned char State)
|
||||
{
|
||||
MotorState=State;
|
||||
switch (MotorState)
|
||||
{
|
||||
// MOTOROFF
|
||||
case 0:
|
||||
SetSndOutMode(0);
|
||||
switch (TapeMode)
|
||||
{
|
||||
case STOP:
|
||||
break;
|
||||
|
||||
case PLAY:
|
||||
Quiet = 15;
|
||||
StalledCtr = 0;
|
||||
TempIndex = 0;
|
||||
MotorOffDelay = 10;
|
||||
break;
|
||||
|
||||
case REC:
|
||||
SyncFileBuffer();
|
||||
break;
|
||||
|
||||
case EJECT:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
// MOTORON
|
||||
case 1:
|
||||
switch (TapeMode)
|
||||
{
|
||||
case STOP:
|
||||
SetSndOutMode(0);
|
||||
break;
|
||||
|
||||
case PLAY:
|
||||
SetSndOutMode(2);
|
||||
break;
|
||||
|
||||
case REC:
|
||||
SetSndOutMode(1);
|
||||
break;
|
||||
|
||||
case EJECT:
|
||||
SetSndOutMode(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int GetTapeCounter()
|
||||
{
|
||||
return TapeOffset;
|
||||
}
|
||||
|
||||
bool IsTapeWav()
|
||||
{
|
||||
return TapeHandle && FileType == TAPE_WAV;
|
||||
}
|
||||
|
||||
void SetTapeCounter(unsigned int Count, bool forced)
|
||||
{
|
||||
TapeOffset=Count;
|
||||
if (TapeOffset>TotalSize)
|
||||
TotalSize=TapeOffset;
|
||||
UpdateTapeCounter(TapeOffset,TapeMode,forced);
|
||||
return;
|
||||
}
|
||||
|
||||
void UpdateTapeStatus(char* status, int max)
|
||||
{
|
||||
if (TapeMode == PLAY && TapeOffset >= TotalSize)
|
||||
{
|
||||
++StalledCtr;
|
||||
if (StalledCtr >= 100)
|
||||
{
|
||||
TapeMode = STOP;
|
||||
UpdateTapeCounter(TapeOffset, TapeMode, true);
|
||||
}
|
||||
}
|
||||
if (TotalSize > 0 && StalledCtr < 100)
|
||||
snprintf(status, max, " | Tape:%05lu (%0.0f%%)", TapeOffset, ((float)std::min(TotalSize, (TapeOffset + 50)) * 100.0f / TotalSize));
|
||||
}
|
||||
|
||||
void SetTapeMode(unsigned char Mode) //Handles button pressed from Dialog
|
||||
{
|
||||
TapeMode=Mode;
|
||||
switch (TapeMode)
|
||||
{
|
||||
case STOP:
|
||||
|
||||
break;
|
||||
|
||||
case PLAY:
|
||||
if (TapeHandle == nullptr)
|
||||
{
|
||||
if (!LoadTape())
|
||||
{
|
||||
TapeMode = STOP;
|
||||
}
|
||||
else
|
||||
{
|
||||
TapeMode = Mode;
|
||||
}
|
||||
}
|
||||
|
||||
if (MotorState)
|
||||
{
|
||||
Motor(1);
|
||||
}
|
||||
break;
|
||||
|
||||
case REC:
|
||||
if (TapeHandle == nullptr)
|
||||
{
|
||||
if (!LoadTape())
|
||||
{
|
||||
TapeMode = STOP;
|
||||
}
|
||||
else
|
||||
{
|
||||
TapeMode = Mode;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EJECT:
|
||||
CloseTapeFile();
|
||||
strcpy(TapeFileName,"EMPTY");
|
||||
break;
|
||||
}
|
||||
UpdateTapeCounter(TapeOffset,TapeMode);
|
||||
return;
|
||||
}
|
||||
|
||||
void FlushCassetteBuffer(const unsigned char *Buffer,unsigned int *Len)
|
||||
{
|
||||
if (TapeMode!=REC)
|
||||
return;
|
||||
|
||||
unsigned int Length = *Len;
|
||||
*Len = 0;
|
||||
|
||||
TapeWritten = true;
|
||||
switch(FileType)
|
||||
{
|
||||
case TAPE_WAV:
|
||||
SetFilePointer(TapeHandle,TapeOffset+44,nullptr,FILE_BEGIN);
|
||||
WriteFile(TapeHandle,Buffer,Length,&BytesMoved,nullptr);
|
||||
if (Length!=BytesMoved)
|
||||
return;
|
||||
TapeOffset+=Length;
|
||||
if (TapeOffset>TotalSize)
|
||||
TotalSize=TapeOffset;
|
||||
break;
|
||||
|
||||
case TAPE_CAS:
|
||||
WavtoCas(Buffer, Length);
|
||||
break;
|
||||
}
|
||||
UpdateTapeCounter(TapeOffset,TapeMode);
|
||||
return;
|
||||
}
|
||||
|
||||
void LoadCassetteBuffer(unsigned char *CassBuffer, unsigned int* CassBufferSize)
|
||||
{
|
||||
unsigned long BytesMoved=0;
|
||||
if (TapeMode != PLAY)
|
||||
{
|
||||
*CassBufferSize = TapeRate / 60;
|
||||
memset(&CassBuffer[0], CAS_SILENCE, *CassBufferSize);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int offset = TapeOffset;
|
||||
switch (FileType)
|
||||
{
|
||||
case TAPE_WAV:
|
||||
{
|
||||
if (TapeHandle)
|
||||
{
|
||||
SetFilePointer(TapeHandle, TapeOffset + 44, nullptr, FILE_BEGIN);
|
||||
ReadFile(TapeHandle, TempBuffer, TapeSampleSize * TapeRate / 60, &BytesMoved, nullptr);
|
||||
if (BytesMoved > 0)
|
||||
{
|
||||
unsigned int samples = BytesMoved / TapeSampleSize;
|
||||
Conversion(TapeSampleSize, CassBuffer, TempBuffer, samples);
|
||||
*CassBufferSize = samples;
|
||||
TapeOffset += BytesMoved;
|
||||
}
|
||||
if (TapeOffset > TotalSize)
|
||||
TapeOffset = TotalSize;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case TAPE_CAS:
|
||||
{
|
||||
CastoWav(CassBuffer, CAS_TAPEREADAHEAD);
|
||||
*CassBufferSize = CAS_TAPEREADAHEAD;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (TapeOffset == TotalSize) offset = TapeOffset;
|
||||
UpdateTapeCounter(offset,TapeMode);
|
||||
return;
|
||||
}
|
||||
|
||||
int MountTape( const char *FileName) //Return 1 on sucess 0 on fail
|
||||
{
|
||||
char Extension[4]="";
|
||||
unsigned char Index=0;
|
||||
if (TapeHandle!=nullptr)
|
||||
{
|
||||
TapeMode=STOP;
|
||||
CloseTapeFile();
|
||||
}
|
||||
|
||||
WriteProtect=0;
|
||||
FileType = TAPE_UNKNOWN; //1=wav 2=cas
|
||||
TapeHandle = CreateFile(FileName,GENERIC_READ | GENERIC_WRITE,0,nullptr,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,nullptr); //CREATE_NEW OPEN_ALWAYS
|
||||
if (TapeHandle == INVALID_HANDLE_VALUE) //Can't open read/write. try read only
|
||||
{
|
||||
TapeHandle = CreateFile(FileName,GENERIC_READ,0,nullptr,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,nullptr);
|
||||
WriteProtect=1;
|
||||
}
|
||||
if (TapeHandle==INVALID_HANDLE_VALUE)
|
||||
{
|
||||
MessageBox(nullptr,"Can't Mount","Error",0);
|
||||
return 0; //Give up
|
||||
}
|
||||
TapeWritten = false;
|
||||
TotalSize=SetFilePointer(TapeHandle,0,nullptr,FILE_END);
|
||||
TapeOffset=0;
|
||||
TapeRate = CAS_TAPEAUDIORATE;
|
||||
TapeSampleSize = 1;
|
||||
StalledCtr = 0;
|
||||
SetFilePointer(TapeHandle, 0, nullptr, FILE_BEGIN);
|
||||
strcpy(Extension,&FileName[strlen(FileName)-3]);
|
||||
for (Index=0;Index<strlen(Extension);Index++)
|
||||
Extension[Index]=toupper(Extension[Index]);
|
||||
|
||||
if (CasBuffer != nullptr)
|
||||
{
|
||||
free(CasBuffer);
|
||||
CasBuffer = nullptr;
|
||||
}
|
||||
|
||||
if (strcmp(Extension, "WAV") == 0)
|
||||
{
|
||||
using namespace VCC;
|
||||
using namespace std::placeholders;
|
||||
|
||||
WavHeader header;
|
||||
WavFmtBlock formatBlock;
|
||||
ReadFile(TapeHandle, &header, sizeof(header), &BytesMoved, nullptr);
|
||||
ReadFile(TapeHandle, &formatBlock, sizeof(formatBlock), &BytesMoved, nullptr);
|
||||
Conversion = nullptr;
|
||||
if (formatBlock.waveType == 1)
|
||||
{
|
||||
TapeSampleSize = formatBlock.channels * formatBlock.bitsPerSample / 8;
|
||||
if (formatBlock.bitsPerSample == 8)
|
||||
Conversion = SampleUnsignedConversion;
|
||||
else
|
||||
Conversion = SampleSignedConversion;
|
||||
}
|
||||
else if (formatBlock.waveType == 3)
|
||||
{
|
||||
TapeSampleSize = formatBlock.channels * formatBlock.bitsPerSample / 8;
|
||||
if (formatBlock.bitsPerSample == 32)
|
||||
Conversion = SampleFloatConversion;
|
||||
}
|
||||
if (!Conversion) return 0;
|
||||
CasBuffer = (unsigned char*)malloc(CAS_WRITEBUFFERSIZE);
|
||||
FileType = TAPE_WAV;
|
||||
TapeRate = formatBlock.bitRate;
|
||||
}
|
||||
else if (strcmp(Extension, "CAS") == 0)
|
||||
{
|
||||
FileType= TAPE_CAS;
|
||||
LastTrans=0;
|
||||
Mask=0;
|
||||
Byte=0;
|
||||
LastSample=0;
|
||||
TempIndex=0;
|
||||
|
||||
if (TotalSize > CAS_WRITEBUFFERSIZE)
|
||||
TotalSize = CAS_WRITEBUFFERSIZE;
|
||||
|
||||
CasBuffer=(unsigned char *)malloc(CAS_WRITEBUFFERSIZE);
|
||||
ReadFile(TapeHandle,CasBuffer,TotalSize,&BytesMoved,nullptr); //Read the whole file in for .CAS files
|
||||
if (BytesMoved!=TotalSize)
|
||||
return 0;
|
||||
}
|
||||
|
||||
SetSndOutMode(2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CloseTapeFile()
|
||||
{
|
||||
if (TapeHandle==nullptr)
|
||||
return;
|
||||
SyncFileBuffer();
|
||||
CloseHandle(TapeHandle);
|
||||
TapeHandle=nullptr;
|
||||
TapeRate = CAS_TAPEAUDIORATE;
|
||||
TotalSize=0;
|
||||
}
|
||||
|
||||
unsigned int LoadTape()
|
||||
{
|
||||
FileDialog dlg;
|
||||
Setting().read("DefaultPaths","CassPath","",CassPath,MAX_PATH);
|
||||
dlg.setInitialDir(CassPath);
|
||||
dlg.setFilter("Cassette Files (.cas,.wav)\0*.cas;*.wav\0\0");
|
||||
dlg.setTitle("Insert Tape Image");
|
||||
dlg.setFlags(OFN_NOTESTFILECREATE);
|
||||
if (dlg.show()) {
|
||||
dlg.getpath(TapeFileName,MAX_PATH);
|
||||
if (MountTape(TapeFileName)==0) {
|
||||
MessageBox(nullptr,"Can't open file","Error",0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
dlg.getdir(CassPath);
|
||||
if (strcmp(CassPath, "") != 0) {
|
||||
VCC::Util::FixDirSlashes(CassPath);
|
||||
Setting().write("DefaultPaths","CassPath",CassPath);
|
||||
}
|
||||
TapeWritten = false;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void GetTapeName(char *Name)
|
||||
{
|
||||
strcpy(Name,TapeFileName);
|
||||
return;
|
||||
}
|
||||
|
||||
void SyncFileBuffer ()
|
||||
{
|
||||
if (!TapeWritten) return;
|
||||
char Buffer[64]="";
|
||||
unsigned long BytesMoved=0;
|
||||
unsigned int FileSize=TotalSize+40-8;
|
||||
unsigned short WaveType=1; //WAVE type format
|
||||
unsigned int FormatSize=16; //size of WAVE section chunck
|
||||
unsigned short Channels=1; //mono/stereo
|
||||
unsigned int BitRate=TapeRate; //sample rate
|
||||
unsigned short BitsperSample=8; //Bits/sample
|
||||
unsigned int BytesperSec=BitRate*Channels*(BitsperSample/8); //bytes/sec
|
||||
unsigned short BlockAlign=(BitsperSample * Channels)/8; //Block alignment
|
||||
unsigned int ChunkSize=FileSize;
|
||||
|
||||
SetFilePointer(TapeHandle,0,nullptr,FILE_BEGIN);
|
||||
switch (FileType)
|
||||
{
|
||||
case TAPE_CAS:
|
||||
CasBuffer[TapeOffset]=Byte; //capture the last byte
|
||||
LastTrans=0; //reset all static inter-call variables
|
||||
Mask=0;
|
||||
Byte=0;
|
||||
LastSample=0;
|
||||
TempIndex=0;
|
||||
WriteFile(TapeHandle,CasBuffer,TapeOffset,&BytesMoved,nullptr);
|
||||
break;
|
||||
|
||||
case TAPE_WAV:
|
||||
sprintf(Buffer,"RIFF");
|
||||
WriteFile(TapeHandle,Buffer,4,&BytesMoved,nullptr);
|
||||
WriteFile(TapeHandle,&FileSize,4,&BytesMoved,nullptr);
|
||||
sprintf(Buffer,"WAVE");
|
||||
WriteFile(TapeHandle,Buffer,4,&BytesMoved,nullptr);
|
||||
sprintf(Buffer,"fmt ");
|
||||
WriteFile(TapeHandle,Buffer,4,&BytesMoved,nullptr);
|
||||
WriteFile(TapeHandle,&FormatSize,4,&BytesMoved,nullptr);
|
||||
WriteFile(TapeHandle,&WaveType,2,&BytesMoved,nullptr);
|
||||
WriteFile(TapeHandle,&Channels,2,&BytesMoved,nullptr);
|
||||
WriteFile(TapeHandle,&BitRate,4,&BytesMoved,nullptr);
|
||||
WriteFile(TapeHandle,&BytesperSec,4,&BytesMoved,nullptr);
|
||||
WriteFile(TapeHandle,&BlockAlign,2,&BytesMoved,nullptr);
|
||||
WriteFile(TapeHandle,&BitsperSample,2,&BytesMoved,nullptr);
|
||||
sprintf(Buffer,"data");
|
||||
WriteFile(TapeHandle,Buffer,4,&BytesMoved,nullptr);
|
||||
WriteFile(TapeHandle,&ChunkSize,4,&BytesMoved,nullptr);
|
||||
break;
|
||||
}
|
||||
FlushFileBuffers(TapeHandle);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void CastoWav(unsigned char *Buffer,unsigned int BytestoConvert)
|
||||
{
|
||||
unsigned char Byte=0;
|
||||
char Mask=0;
|
||||
|
||||
assert((BytestoConvert & 1) == 0);
|
||||
|
||||
// copy any left over bytes and fill remaining space with silence
|
||||
auto fillSilence = [&]()
|
||||
{
|
||||
int remaining = TempIndex - BytestoConvert;
|
||||
if (TempIndex)
|
||||
memcpy(Buffer, TempBuffer, TempIndex); //Partial Fill of return buffer;
|
||||
memset(&Buffer[TempIndex], CAS_SILENCE, -remaining); //and silence for the rest
|
||||
TempIndex = 0;
|
||||
};
|
||||
|
||||
if (Quiet>0)
|
||||
{
|
||||
Quiet--;
|
||||
fillSilence();
|
||||
return;
|
||||
}
|
||||
|
||||
if (TapeOffset >= TotalSize || TotalSize == 0) //End of tape return nothing
|
||||
{
|
||||
TapeMode=STOP; //Stop at end of tape
|
||||
fillSilence();
|
||||
return;
|
||||
}
|
||||
|
||||
while (TempIndex < BytestoConvert && TapeOffset < TotalSize)
|
||||
{
|
||||
Byte=CasBuffer[(TapeOffset++)%TotalSize];
|
||||
if (GetTapePlaybackFastLoad())
|
||||
{
|
||||
for (Mask = 0; Mask <= 7; ++Mask, Byte >>= 1)
|
||||
{
|
||||
// color basic expects high/low transitions so this
|
||||
// is the smallest waveform that we can have without
|
||||
// hacking the rom. CA
|
||||
// high/low waveform (b1) + tape bit (b0)
|
||||
TempBuffer[TempIndex++] = 2 + (Byte & 1);
|
||||
TempBuffer[TempIndex++] = 0 + (Byte & 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Mask = 0;Mask <= 7;Mask++)
|
||||
{
|
||||
if ((Byte & (1 << Mask)) == 0)
|
||||
{
|
||||
memcpy(&TempBuffer[TempIndex],Zero,40);
|
||||
TempIndex+=40;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(&TempBuffer[TempIndex],One,21);
|
||||
TempIndex+=21;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int remaining = TempIndex - BytestoConvert;
|
||||
if (remaining >= 0)
|
||||
{
|
||||
memcpy(Buffer,TempBuffer,BytestoConvert); //Fill the return Buffer
|
||||
if (remaining > 0)
|
||||
memcpy(TempBuffer, &TempBuffer[BytestoConvert], remaining); //Slide the overage to the front
|
||||
TempIndex-=BytestoConvert; //Point to the Next free byte in the tempbuffer
|
||||
return;
|
||||
}
|
||||
|
||||
fillSilence();
|
||||
}
|
||||
|
||||
|
||||
void WavtoCas(const unsigned char *WaveBuffer,unsigned int Length)
|
||||
{
|
||||
unsigned char Bit=0,Sample=0;
|
||||
unsigned int Index=0,Width=0;
|
||||
|
||||
for (Index=0;Index<Length;Index++)
|
||||
{
|
||||
Sample=WaveBuffer[Index];
|
||||
if ( (LastSample <= 0x80) & (Sample>0x80)) //Low to High transition
|
||||
{
|
||||
Width=Index-LastTrans;
|
||||
if ((Width <10) | (Width >50)) //Invalid Sample Skip it
|
||||
{
|
||||
LastSample=0;
|
||||
LastTrans=Index;
|
||||
Mask=0;
|
||||
Byte=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Bit=1;
|
||||
if (Width >30)
|
||||
Bit=0;
|
||||
Byte=Byte | (Bit<<Mask);
|
||||
Mask++;
|
||||
Mask&=7;
|
||||
if (Mask==0)
|
||||
{
|
||||
CasBuffer[TapeOffset++]=Byte;
|
||||
Byte=0;
|
||||
if (TapeOffset>= CAS_WRITEBUFFERSIZE) //Don't blow past the end of the buffer
|
||||
TapeMode=STOP;
|
||||
}
|
||||
|
||||
}
|
||||
LastTrans=Index;
|
||||
} //Fi LastSample
|
||||
LastSample=Sample;
|
||||
} //Next Index
|
||||
LastTrans-=Length;
|
||||
if (TapeOffset>TotalSize)
|
||||
TotalSize=TapeOffset;
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
#ifndef __CASSETTE_H__
|
||||
#define __CASSETTE_H__
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
constexpr auto STOP = 0u;
|
||||
constexpr auto PLAY = 1u;
|
||||
constexpr auto REC = 2u;
|
||||
constexpr auto EJECT = 3u;
|
||||
|
||||
constexpr auto TAPE_CAS = 2u;
|
||||
constexpr auto TAPE_WAV = 1u;
|
||||
constexpr auto TAPE_UNKNOWN = 0u;
|
||||
|
||||
constexpr auto CAS_WRITEBUFFERSIZE = 0x40000u;
|
||||
constexpr auto CAS_TAPEREADAHEAD = 1000u; // decoded batch size
|
||||
constexpr auto CAS_SILENCE = 128u;
|
||||
constexpr auto CAS_TAPEAUDIORATE = 44100u;
|
||||
|
||||
unsigned int GetTapeCounter();
|
||||
unsigned int LoadTape();
|
||||
bool IsTapeWav();
|
||||
|
||||
void SetTapeCounter(unsigned int, bool force = false);
|
||||
void SetTapeMode(unsigned char);
|
||||
void Motor(unsigned char);
|
||||
void LoadCassetteBuffer(unsigned char *, unsigned int* CassBufferSize);
|
||||
void FlushCassetteBuffer(const unsigned char *,unsigned int *);
|
||||
void GetTapeName(char *);
|
||||
void UpdateTapeStatus(char* status, int max);
|
||||
uint8_t CassInBitStream();
|
||||
bool GetTapePlaybackFastLoad();
|
||||
|
||||
unsigned int GetTapeRate();
|
||||
unsigned char GetMotorState();
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,298 @@
|
||||
//#define USE_LOGGING
|
||||
//======================================================================
|
||||
// This file is part of VCC (Virtual Color Computer).
|
||||
// Vcc is Copyright 2015 by Joseph Forgione
|
||||
//
|
||||
// VCC (Virtual Color Computer) is free software, you can redistribute
|
||||
// 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/>.
|
||||
//======================================================================
|
||||
//
|
||||
// Command line arguments and options to VCC
|
||||
// E J Jaquay 2020
|
||||
//
|
||||
// Since VCC is a windows application traditional Unix command arguments (argc,argV)
|
||||
// are not availiable. However the third argument to WinMain() does provide the
|
||||
// command string less the program name. Historically this argument is used
|
||||
// to supply the path of a Color Computer image file that is loaded into memory
|
||||
// after VCC starts.
|
||||
//
|
||||
// This program permits the command string to supply other information to VCC when
|
||||
// it starts up. It allows the specification of differing VCC init files.
|
||||
//
|
||||
// When writing this I tried to make as flexible as possible as possible without
|
||||
// adding any new dependancies to VCC. By making simple changes to this file
|
||||
// and to the functions that use them it should be possible to add other things.
|
||||
// It maybe. however, that the ability to specify the vcc config file and
|
||||
// possibly logging options will be sufficent for most.
|
||||
//
|
||||
// Syntax:
|
||||
//
|
||||
// Items on command string are separated by blanks unless within quotes.
|
||||
//
|
||||
// Options are specified by a leading dash "-" followed by a single character
|
||||
// option code. This may be followed by an option value.
|
||||
//
|
||||
// Anything that is not an option is considered to be a positional argument.
|
||||
// It is intended that the legacy image file path name will remain the first
|
||||
// such argument so that existing usage is not affected. If there is no longer
|
||||
// a need to specify an image file on the command line this could change.
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
// Specify the config file fred wants to use:
|
||||
// $ VCC -i C:\users\fred\my-vcc.ini
|
||||
//
|
||||
// Inifile in VCC appdir:
|
||||
// $ VCC -i %APPDIR%/vcc/my-vcc.ini
|
||||
//
|
||||
// In current working directory:
|
||||
// $ VCC -i my-vcc.ini
|
||||
//
|
||||
// Quick load image file:
|
||||
// $ VCC "C:\barney's good image.ima"
|
||||
//
|
||||
// Auto paste text:
|
||||
// $ VCC -p "drive 3: loadm "sigmon6": exec"
|
||||
//
|
||||
// Errors returned:
|
||||
// CL_ERR_UNKOPT Unknown option found
|
||||
// CL_ERR_XTRARG Too many arguments
|
||||
//
|
||||
// Caveauts:
|
||||
//
|
||||
// o Supports short (single char) option codes only.
|
||||
// o Option codes may not be combined. Each must be preceeded by dash: '-'
|
||||
// o Command string cannot be longer than 255 characters.
|
||||
// o Wide character or control character input is not supported.
|
||||
// o No provision to escape double quotes or other special characters.
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "../../src/core/BuildConfig.h"
|
||||
#include "CommandLine.h"
|
||||
#include <vcc/util/logger.h>
|
||||
|
||||
// Define global command line settings
|
||||
struct CmdLineArguments CmdArg;
|
||||
|
||||
constexpr auto SEPMARK = 3u; //To mark spaces as separators
|
||||
|
||||
char *ParseCmdString(const char *, const char *);
|
||||
char *GetNextToken ();
|
||||
static char *NxtTokenPtr;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Parse the VCC command string and set ConfigFile, QuickLoadFile, and
|
||||
// possibly other things. Variables set by this routine are global and
|
||||
// are defined in CommandLine.h
|
||||
//
|
||||
// vcc.exe [-d[level]] [-p text] [-i ConfigFile] [QuickLoadFile]
|
||||
//
|
||||
// CmdString: The third arg to WinMain()
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
int GetCmdLineArgs(const char *CmdString)
|
||||
{
|
||||
const char *token; // token pointer (to item in command string)
|
||||
int argnum = 0; // non-option argument number
|
||||
int len; // len of a chr string
|
||||
|
||||
// Options that require values need to be known by the parser
|
||||
// to allow seperation between option code and value.
|
||||
// -i and -p both require options
|
||||
static const char * ValueRequired = "ip";
|
||||
|
||||
// Initialize the global variables set by this routine
|
||||
memset(&CmdArg,0,sizeof(CmdArg));
|
||||
|
||||
// Get the first token from the command string
|
||||
token = ParseCmdString(CmdString,ValueRequired);
|
||||
while (token) {
|
||||
|
||||
// Option?
|
||||
if (*token == '-') {
|
||||
switch (*(token+1)) {
|
||||
|
||||
// "-i" specfies the Vcc configuration file to use.
|
||||
// The value is required and will be found starting
|
||||
// at the third character of the option string.
|
||||
// Default config file is "vcc.ini"
|
||||
case 'i':
|
||||
strncpy(CmdArg.IniFile,token+2,CL_MAX_PATH-1);
|
||||
len = strlen(CmdArg.IniFile);
|
||||
CmdArg.IniFile[len] = '\0';
|
||||
break;
|
||||
|
||||
#if USE_DEBUG_OPTIONS
|
||||
// "-n" render no output at all for running in batch mode.
|
||||
case 'n':
|
||||
CmdArg.NoOutput = true;
|
||||
break;
|
||||
|
||||
// "-f<n> render <n> frames and then exit.
|
||||
case 'f':
|
||||
CmdArg.MaxFrames = atoi(token + 2);
|
||||
break;
|
||||
|
||||
// "-s<file> dump screen shot prior to exit of -f option.
|
||||
case 's':
|
||||
strncpy(CmdArg.Screenshot, token + 2, sizeof(CmdArg.Screenshot) - 1);
|
||||
CmdArg.Screenshot[sizeof(CmdArg.Screenshot) - 1] = 0;
|
||||
break;
|
||||
#endif
|
||||
|
||||
// "-d[level]" enables logging console and sets log level
|
||||
// level is optional. It defaults to 1 and is forced to be
|
||||
// a positive integer 0 to 3.
|
||||
case 'd':
|
||||
if (*(token+2)) {
|
||||
CmdArg.Logging = atoi(token+2);
|
||||
if (CmdArg.Logging < 1) CmdArg.Logging = 0;
|
||||
if (CmdArg.Logging > 3) CmdArg.Logging = 3;
|
||||
} else {
|
||||
CmdArg.Logging = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
// "-p text" Auto paste text on startup. '\n' is appended
|
||||
case 'p':
|
||||
strncpy(CmdArg.PasteText,token+2,CL_MAX_PASTE-2);
|
||||
len = strlen(CmdArg.PasteText);
|
||||
CmdArg.PasteText[len] = '\n';
|
||||
CmdArg.PasteText[len+1] = 0;
|
||||
break;
|
||||
|
||||
// Unknown option code returns an error
|
||||
default:
|
||||
return CL_ERR_UNKOPT;
|
||||
}
|
||||
|
||||
// else Positional argument
|
||||
// argnum indicates argument position starting at one.
|
||||
} else {
|
||||
switch (++argnum) {
|
||||
|
||||
// First (currently only) positional arg is Quick Load filename.
|
||||
case 1:
|
||||
strncpy(CmdArg.QLoadFile,token,CL_MAX_PATH);
|
||||
CmdArg.QLoadFile[CL_MAX_PATH-1]=0;
|
||||
break;
|
||||
|
||||
// Extra positional argument returns an error
|
||||
default:
|
||||
return CL_ERR_XTRARG;
|
||||
}
|
||||
}
|
||||
|
||||
// Get next token
|
||||
token = ParseCmdString(nullptr,ValueRequired);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Command string parser.
|
||||
//
|
||||
// Input string is tokenized using one or more blanks as a separator, excepting
|
||||
// blanks within quotes. If the input String is not null a pointer to the
|
||||
// first token is returned. Otherwise pointers to subsequent tokens are returned.
|
||||
// When there are no more tokens a null pointer is returned.
|
||||
//
|
||||
// ValueRequired: String containing option codes that require values.
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
char * ParseCmdString(const char *CmdString, const char *ValueRequired)
|
||||
{
|
||||
static char cmdline[512]; // Copy of cmd string
|
||||
static char option[256]; // Used to append value to option
|
||||
int quoted;
|
||||
char *token;
|
||||
const char *value;
|
||||
|
||||
// Initial call sets command string. Subsequent calls expect a NULL
|
||||
if (CmdString) {
|
||||
while (*CmdString == ' ') CmdString++; // Skip leading blanks
|
||||
strncpy(cmdline,CmdString,512); // Make a copy of what is left
|
||||
strcat(cmdline," "); // Make sure args are terminated
|
||||
cmdline[511]='\0'; // Be sure string is terminated
|
||||
NxtTokenPtr = cmdline; // Save it's location
|
||||
|
||||
// Mark unquoted blanks
|
||||
quoted = 0;
|
||||
for( char * p = NxtTokenPtr; *p; p++) {
|
||||
if (*p == '"') {
|
||||
quoted = !quoted;
|
||||
} else if (!quoted) {
|
||||
if (*p == ' ') *p = SEPMARK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (token = GetNextToken()) {
|
||||
// Check if it is an option token. If a option value is
|
||||
// required and value is seperated make a copy and append
|
||||
// next token to it
|
||||
if ((token[0] == '-') && (token[1] != '\0') && (token[2] == '\0')) {
|
||||
if (strchr(ValueRequired,token[1])) {
|
||||
if ((NxtTokenPtr[0] != '\0') && (NxtTokenPtr[0] != '-')) {
|
||||
if (value = GetNextToken()) {
|
||||
strcpy(option,token);
|
||||
strcat(option,value);
|
||||
return option;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return token; // null, positional argument, or option with no value
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Terminate token, find next token, return pointer to current
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
char *GetNextToken ()
|
||||
{
|
||||
// Return NULL if no tokens
|
||||
if (*NxtTokenPtr == '\0') return nullptr;
|
||||
|
||||
// Save token pointer
|
||||
char *token = NxtTokenPtr++;
|
||||
|
||||
// Advance to end of token
|
||||
while (*NxtTokenPtr != SEPMARK) NxtTokenPtr++;
|
||||
|
||||
// If anything remains
|
||||
if (*NxtTokenPtr != '\0') {
|
||||
|
||||
// Terminate current token
|
||||
*NxtTokenPtr++ = '\0';
|
||||
|
||||
// Skip past extra separaters to start of next
|
||||
while (*NxtTokenPtr == SEPMARK) NxtTokenPtr++;
|
||||
}
|
||||
|
||||
//Strip leading and trailing quotes from token
|
||||
if (token[0] == '"') {
|
||||
token++;
|
||||
int n = strlen(token);
|
||||
if ((n > 0) && (token[n-1] == '"')) token[n-1] = '\0';
|
||||
}
|
||||
|
||||
// Return address of current token
|
||||
return token;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
//#define USE_LOGGING
|
||||
//======================================================================
|
||||
// This file is part of VCC (Virtual Color Computer).
|
||||
// Vcc is Copyright 2015 by Joseph Forgione
|
||||
//
|
||||
// VCC (Virtual Color Computer) is free software, you can redistribute
|
||||
// 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/>.
|
||||
//======================================================================
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Command line arguments and options to VCC
|
||||
// E J Jaquay 2020
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
constexpr auto CL_MAX_PATH = 256u;
|
||||
constexpr auto CL_MAX_PASTE = 256u;
|
||||
|
||||
// Variables defined by GetCmdLineArgs
|
||||
struct CmdLineArguments {
|
||||
char QLoadFile[CL_MAX_PATH];
|
||||
char IniFile[CL_MAX_PATH];
|
||||
char PasteText[CL_MAX_PASTE];
|
||||
int Logging;
|
||||
bool NoOutput;
|
||||
char Screenshot[CL_MAX_PATH];
|
||||
unsigned int MaxFrames;
|
||||
};
|
||||
extern struct CmdLineArguments CmdArg;
|
||||
|
||||
// Get Settings from Command line string
|
||||
int GetCmdLineArgs(const char * lpCmdLine);
|
||||
|
||||
// Errors returned
|
||||
// FIXME: These need to be turned into a scoped enum and the signature of functions
|
||||
// that use them updated.
|
||||
#define CL_ERR_UNKOPT 1 // Unknown option found
|
||||
#define CL_ERR_XTRARG 2 // Too many arguments
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
copy .\__obj\Win32\Release\vcc\out\vcc.exe .\vcc
|
||||
copy .\__obj\Win32\Release\becker\out\*.dll .\vcc
|
||||
copy .\__obj\Win32\Release\fd502\out\*.dll .\vcc
|
||||
copy .\__obj\Win32\Release\harddisk\out\*.dll .\vcc
|
||||
copy .\__obj\Win32\Release\mpi\out\*.dll .\vcc
|
||||
copy .\__obj\Win32\Release\orch90\out\*.dll .\vcc
|
||||
copy .\__obj\Win32\Release\superide\out\*.dll .\vcc
|
||||
@@ -0,0 +1,534 @@
|
||||
// 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/>.
|
||||
//
|
||||
// Debugger Interface - Part of the Debugger package for VCC
|
||||
// Author: Chet Simpson
|
||||
#include "Debugger.h"
|
||||
#include "DebuggerUtils.h"
|
||||
#include "../../src/core/MachineDefs.h"
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include "../../src/core/tcc1014mmu.h" // FIXME: May want this decoupled from Debugger for Memory Write
|
||||
#include "audio.h"
|
||||
#include "Disassembler.h"
|
||||
#include <assert.h>
|
||||
|
||||
namespace VCC::Debugger
|
||||
{
|
||||
|
||||
void Debugger::Reset()
|
||||
{
|
||||
VCC::Util::section_locker lock(Section_);
|
||||
|
||||
ExecutionMode_ = ExecutionMode::Run;
|
||||
PendingCommand_ = ExecutionMode::Halt;
|
||||
HasPendingCommand_ = false;
|
||||
ProcessorState_ = CPUState();
|
||||
|
||||
for (const auto& callback : RegisteredClients_)
|
||||
{
|
||||
callback.second->OnReset();
|
||||
}
|
||||
|
||||
Decoder_ = std::make_unique<OpDecoder>();
|
||||
TraceEnabled_ = false;
|
||||
TraceRunning_ = false;
|
||||
TraceMarks_.clear();
|
||||
}
|
||||
|
||||
void Debugger::RegisterClient(HWND window, std::unique_ptr<Client> client)
|
||||
{
|
||||
VCC::Util::section_locker lock(Section_);
|
||||
|
||||
if (!client)
|
||||
{
|
||||
throw std::invalid_argument("client cannot be null");
|
||||
}
|
||||
|
||||
if (RegisteredClients_.find(window) != RegisteredClients_.end())
|
||||
{
|
||||
throw std::invalid_argument("Udpate client is already registered with the debugger");
|
||||
}
|
||||
|
||||
RegisteredClients_[window] = move(client);
|
||||
}
|
||||
|
||||
|
||||
void Debugger::RemoveClient(HWND window)
|
||||
{
|
||||
VCC::Util::section_locker lock(Section_);
|
||||
|
||||
if (RegisteredClients_.find(window) == RegisteredClients_.end())
|
||||
{
|
||||
throw std::invalid_argument("window is not registered with the debugger");
|
||||
}
|
||||
|
||||
RegisteredClients_.erase(window);
|
||||
}
|
||||
|
||||
|
||||
void Debugger::Halt()
|
||||
{
|
||||
ExecutionMode_ = ExecutionMode::Halt;
|
||||
}
|
||||
|
||||
|
||||
bool Debugger::IsHalted() const
|
||||
{
|
||||
return ExecutionMode_ == ExecutionMode::Halt;
|
||||
}
|
||||
|
||||
|
||||
bool Debugger::IsHalted(unsigned short& returnPc) const
|
||||
{
|
||||
if (ExecutionMode_ != ExecutionMode::Halt)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
VCC::Util::section_locker lock(Section_);
|
||||
returnPc = ProcessorState_.PC;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Debugger::IsStepping() const
|
||||
{
|
||||
return ExecutionMode_ == ExecutionMode::Step;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CPUState Debugger::GetProcessorStateCopy() const
|
||||
{
|
||||
VCC::Util::section_locker lock(Section_);
|
||||
|
||||
return ProcessorState_;
|
||||
}
|
||||
|
||||
|
||||
bool Debugger::HasPendingCommandNoLock() const
|
||||
{
|
||||
return HasPendingCommand_;
|
||||
}
|
||||
|
||||
|
||||
Debugger::ExecutionMode Debugger::ConsumePendingCommandNoLock()
|
||||
{
|
||||
if (!HasPendingCommandNoLock())
|
||||
{
|
||||
throw std::runtime_error("No pending command to consume");
|
||||
}
|
||||
|
||||
HasPendingCommand_ = false;
|
||||
return PendingCommand_;
|
||||
}
|
||||
|
||||
|
||||
void Debugger::SetBreakpoints(breakpointsbuffer_type breakpoints)
|
||||
{
|
||||
VCC::Util::section_locker lock(Section_);
|
||||
|
||||
Breakpoints_ = move(breakpoints);
|
||||
BreakpointsChanged_ = true;
|
||||
}
|
||||
|
||||
|
||||
bool Debugger::IsTracingEnabled() const
|
||||
{
|
||||
return TraceEnabled_;
|
||||
}
|
||||
|
||||
bool Debugger::IsTracing() const
|
||||
{
|
||||
return TraceRunning_;
|
||||
}
|
||||
|
||||
void Debugger::TraceCaptureInterruptRequest(unsigned char irq, long cycleTime, const CPUState& state)
|
||||
{
|
||||
Decoder_->CaptureInterrupt(TraceEvent::IRQRequested, Decoder_->ToIRQType(irq), cycleTime, state);
|
||||
CheckStopTrace(state);
|
||||
}
|
||||
|
||||
void Debugger::TraceCaptureInterruptMasked(unsigned char irq, long cycleTime, const CPUState& state)
|
||||
{
|
||||
Decoder_->CaptureInterrupt(TraceEvent::IRQMasked, Decoder_->ToIRQType(irq), cycleTime, state);
|
||||
CheckStopTrace(state);
|
||||
}
|
||||
|
||||
void Debugger::TraceCaptureInterruptServicing(unsigned char irq, long cycleTime, const CPUState& state)
|
||||
{
|
||||
Decoder_->CaptureInterrupt(TraceEvent::IRQServicing, Decoder_->ToIRQType(irq), cycleTime, state);
|
||||
CheckStopTrace(state);
|
||||
}
|
||||
|
||||
void Debugger::TraceCaptureInterruptExecuting(unsigned char irq, long cycleTime, const CPUState& state)
|
||||
{
|
||||
Decoder_->CaptureInterrupt(TraceEvent::IRQExecuting, Decoder_->ToIRQType(irq), cycleTime, state);
|
||||
CheckStopTrace(state);
|
||||
}
|
||||
|
||||
void Debugger::TraceCaptureBefore(long cycles, const CPUState& state)
|
||||
{
|
||||
Decoder_->CaptureBefore(cycles, state);
|
||||
CheckStopTrace(state);
|
||||
}
|
||||
|
||||
void Debugger::TraceCaptureAfter(long cycles, const CPUState& state)
|
||||
{
|
||||
Decoder_->CaptureAfter(cycles, state);
|
||||
CheckStopTrace(state);
|
||||
}
|
||||
|
||||
void Debugger::CheckStopTrace(CPUState state)
|
||||
{
|
||||
if (!TraceRunning_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Max samples reached?
|
||||
if (Decoder_->GetSampleCount() >= TraceMaxSamples_)
|
||||
{
|
||||
TraceRunning_ = false;
|
||||
TraceEnabled_ = false;
|
||||
TraceTriggerChanged_ = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Hit a Stop Address?
|
||||
if (find(TraceStopTriggers_.begin(), TraceStopTriggers_.end(), state.PC) != TraceStopTriggers_.end())
|
||||
{
|
||||
TraceRunning_ = false;
|
||||
TraceEnabled_ = false;
|
||||
TraceTriggerChanged_ = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#if USE_NEWTIMING
|
||||
void Debugger::TraceCaptureScreenEvent(TraceEvent evt, double cycles, unsigned int n)
|
||||
{
|
||||
if (!TraceRunning_ || !TraceScreen_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Decoder_->CaptureScreenEvent(evt, cycles, n);
|
||||
}
|
||||
|
||||
void Debugger::TraceCaptureScreenEvent(TraceEvent evt, double cycles, unsigned int n, const char* s)
|
||||
{
|
||||
if (!TraceRunning_ || !TraceScreen_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Decoder_->CaptureScreenEvent(evt, cycles, n, s);
|
||||
}
|
||||
#else
|
||||
void Debugger::TraceCaptureScreenEvent(TraceEvent evt, double cycles)
|
||||
{
|
||||
if (!TraceRunning_ || !TraceScreen_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Decoder_->CaptureScreenEvent(evt, cycles);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void Debugger::TraceEmulatorCycle(TraceEvent evt, int state, double lineNS, double irqNS, double soundNS, double cycles, double drift)
|
||||
{
|
||||
if (!TraceRunning_ || !TraceEmulation_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Decoder_->CaptureEmulatorCycle(evt, state, lineNS, irqNS, soundNS, cycles, drift);
|
||||
}
|
||||
|
||||
|
||||
void Debugger::LockTrace() const
|
||||
{
|
||||
Section_.lock();
|
||||
}
|
||||
|
||||
void Debugger::UnlockTrace() const
|
||||
{
|
||||
Section_.unlock();
|
||||
}
|
||||
|
||||
|
||||
void Debugger::SetTraceEnable()
|
||||
{
|
||||
TraceEnabled_ = true;
|
||||
}
|
||||
|
||||
void Debugger::SetTraceDisable()
|
||||
{
|
||||
TraceEnabled_ = false;
|
||||
TraceRunning_ = false;
|
||||
}
|
||||
|
||||
void Debugger::TraceStart()
|
||||
{
|
||||
TraceRunning_ = true;
|
||||
}
|
||||
|
||||
void Debugger::TraceStop()
|
||||
{
|
||||
TraceRunning_ = false;
|
||||
TraceEnabled_ = false;
|
||||
}
|
||||
|
||||
void Debugger::ResetTrace()
|
||||
{
|
||||
TraceEnabled_ = false;
|
||||
TraceRunning_ = false;
|
||||
{
|
||||
VCC::Util::section_locker lock(Section_);
|
||||
Decoder_->Reset(TraceMaxSamples_);
|
||||
}
|
||||
}
|
||||
|
||||
void Debugger::SetTraceMaxSamples(long samples)
|
||||
{
|
||||
VCC::Util::section_locker lock(Section_);
|
||||
|
||||
TraceMaxSamples_ = samples;
|
||||
Decoder_->Reset(TraceMaxSamples_);
|
||||
}
|
||||
|
||||
void Debugger::SetTraceStartTriggers(triggerbuffer_type startTriggers)
|
||||
{
|
||||
VCC::Util::section_locker lock(Section_);
|
||||
|
||||
TraceStartTriggers_ = move(startTriggers);
|
||||
TraceTriggerChanged_ = true;
|
||||
}
|
||||
|
||||
void Debugger::SetTraceStopTriggers(triggerbuffer_type stopTriggers)
|
||||
{
|
||||
VCC::Util::section_locker lock(Section_);
|
||||
|
||||
TraceStopTriggers_ = move(stopTriggers);
|
||||
TraceTriggerChanged_ = true;
|
||||
}
|
||||
|
||||
void Debugger::SetTraceOptions(bool screen, bool emulation)
|
||||
{
|
||||
VCC::Util::section_locker lock(Section_);
|
||||
|
||||
TraceScreen_ = screen;
|
||||
TraceEmulation_ = emulation;
|
||||
}
|
||||
|
||||
long Debugger::GetTraceSamples() const
|
||||
{
|
||||
VCC::Util::section_locker lock(Section_);
|
||||
|
||||
return Decoder_->GetSampleCount();
|
||||
}
|
||||
|
||||
const Debugger::Debugger::tracebuffer_type& Debugger::GetTraceResult() const
|
||||
{
|
||||
return Decoder_->GetTrace();
|
||||
}
|
||||
|
||||
void Debugger::SetTraceMark(int mark, long sample)
|
||||
{
|
||||
VCC::Util::section_locker lock(Section_);
|
||||
assert(sample >= 0);
|
||||
TraceMarks_[mark] = sample;
|
||||
}
|
||||
|
||||
|
||||
void Debugger::ClearTraceMarks()
|
||||
{
|
||||
VCC::Util::section_locker lock(Section_);
|
||||
|
||||
TraceMarks_.clear();
|
||||
}
|
||||
|
||||
void Debugger::GetTraceMarkSamples(tracebuffer_type &result) const
|
||||
{
|
||||
VCC::Util::section_locker lock(Section_);
|
||||
|
||||
result.clear();
|
||||
|
||||
auto& trace = Decoder_->GetTrace();
|
||||
|
||||
for (const auto& kv: TraceMarks_)
|
||||
{
|
||||
result.push_back(trace[kv.second]);
|
||||
}
|
||||
}
|
||||
|
||||
void Debugger::QueueRun()
|
||||
{
|
||||
ApplyHaltpoints(true);
|
||||
VCC::Util::section_locker lock(Section_);
|
||||
|
||||
PendingCommand_ = ExecutionMode::Run;
|
||||
HasPendingCommand_ = true;
|
||||
}
|
||||
|
||||
void Debugger::QueueStep()
|
||||
{
|
||||
VCC::Util::section_locker lock(Section_);
|
||||
|
||||
PendingCommand_ = ExecutionMode::Step;
|
||||
HasPendingCommand_ = true;
|
||||
}
|
||||
|
||||
void Debugger::QueueHalt()
|
||||
{
|
||||
ApplyHaltpoints(false);
|
||||
VCC::Util::section_locker lock(Section_);
|
||||
|
||||
PendingCommand_ = ExecutionMode::Halt;
|
||||
HasPendingCommand_ = true;
|
||||
}
|
||||
|
||||
void Debugger::ToggleRun() {
|
||||
if (IsHalted()) {
|
||||
PauseAudio(0);
|
||||
QueueRun();
|
||||
} else {
|
||||
QueueHalt();
|
||||
PauseAudio(1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void Debugger::Update()
|
||||
{
|
||||
{
|
||||
VCC::Util::section_locker lock(Section_);
|
||||
|
||||
ProcessorState_ = CPUGetState();
|
||||
|
||||
if (BreakpointsChanged_)
|
||||
{
|
||||
CPUSetBreakpoints(Breakpoints_);
|
||||
BreakpointsChanged_ = false;
|
||||
}
|
||||
|
||||
if (TraceTriggerChanged_)
|
||||
{
|
||||
CPUSetTraceTriggers(TraceStartTriggers_);
|
||||
TraceTriggerChanged_ = false;
|
||||
}
|
||||
|
||||
if (HasPendingCommandNoLock())
|
||||
{
|
||||
ExecutionMode_ = ProcessNewModeNoLock(ConsumePendingCommandNoLock());
|
||||
}
|
||||
|
||||
if (HasPendingWriteNoLock())
|
||||
{
|
||||
ProcessWrite(ConsumePendingWriteNoLock());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (const auto& callback : RegisteredClients_)
|
||||
{
|
||||
callback.second->OnUpdate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Debugger::ExecutionMode Debugger::ProcessNewModeNoLock(ExecutionMode cpuCmd) const
|
||||
{
|
||||
// Run -> Halt
|
||||
if (ExecutionMode_ == ExecutionMode::Run && cpuCmd == ExecutionMode::Halt)
|
||||
{
|
||||
return ExecutionMode::Halt;
|
||||
}
|
||||
// Halt -> Run
|
||||
if (ExecutionMode_ == ExecutionMode::Halt && cpuCmd == ExecutionMode::Run)
|
||||
{
|
||||
return ExecutionMode::Run;
|
||||
}
|
||||
// Halt -> Step
|
||||
if (ExecutionMode_ == ExecutionMode::Halt && cpuCmd == ExecutionMode::Step)
|
||||
{
|
||||
return ExecutionMode::Step;
|
||||
}
|
||||
|
||||
return ExecutionMode_;
|
||||
}
|
||||
|
||||
|
||||
void Debugger::QueueWrite(unsigned short addr, unsigned char value)
|
||||
{
|
||||
VCC::Util::section_locker lock(Section_);
|
||||
|
||||
PendingWrite_ = PendingWrite(addr, value);
|
||||
HasPendingWrite_ = true;
|
||||
}
|
||||
|
||||
|
||||
bool Debugger::HasPendingWriteNoLock() const
|
||||
{
|
||||
return HasPendingWrite_;
|
||||
}
|
||||
|
||||
Debugger::PendingWrite Debugger::ConsumePendingWriteNoLock()
|
||||
{
|
||||
if (!HasPendingWriteNoLock())
|
||||
{
|
||||
throw std::runtime_error("No pending memory writes to consume");
|
||||
}
|
||||
|
||||
HasPendingWrite_ = false;
|
||||
return PendingWrite_;
|
||||
}
|
||||
|
||||
void Debugger::ProcessWrite(PendingWrite memWrite)
|
||||
{
|
||||
MemWrite8(memWrite.value, memWrite.addr);
|
||||
}
|
||||
|
||||
bool Debugger::Halt_Enabled() const
|
||||
{
|
||||
return Halt_Enabled_TF;
|
||||
}
|
||||
|
||||
void Debugger::Enable_Halt(bool flag)
|
||||
{
|
||||
Halt_Enabled_TF = flag;
|
||||
}
|
||||
|
||||
bool Debugger::Break_Enabled() const
|
||||
{
|
||||
return Break_Enabled_TF;
|
||||
}
|
||||
|
||||
void Debugger::Enable_Break(bool flag)
|
||||
{
|
||||
Break_Enabled_TF = flag;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
// 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/>.
|
||||
//
|
||||
// Debugger Interface - Part of the Debugger package for VCC
|
||||
// Author: Chet Simpson
|
||||
#pragma once
|
||||
#include "DebuggerUtils.h"
|
||||
#include "../../src/core/MachineDefs.h"
|
||||
#include <vcc/util/critical_section.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <atomic>
|
||||
#include <Windows.h>
|
||||
#include "OpDecoder.h"
|
||||
|
||||
|
||||
namespace VCC::Debugger
|
||||
{
|
||||
|
||||
struct Client
|
||||
{
|
||||
virtual ~Client() = default;
|
||||
|
||||
virtual void OnReset() = 0;
|
||||
virtual void OnUpdate() = 0;
|
||||
};
|
||||
|
||||
class Debugger
|
||||
{
|
||||
public:
|
||||
|
||||
using callback_type = std::function<void(HWND)>;
|
||||
using breakpointsbuffer_type = std::vector<unsigned short>;
|
||||
using triggerbuffer_type = std::vector<unsigned short>;
|
||||
using tracebuffer_type = std::vector<CPUTrace>;
|
||||
|
||||
public:
|
||||
|
||||
void Reset();
|
||||
|
||||
void RegisterClient(HWND window, std::unique_ptr<Client> client);
|
||||
void RemoveClient(HWND window);
|
||||
|
||||
void SetBreakpoints(breakpointsbuffer_type breakpoints);
|
||||
|
||||
CPUState GetProcessorStateCopy() const;
|
||||
|
||||
bool IsHalted() const;
|
||||
bool IsHalted(unsigned short& pc) const;
|
||||
bool IsStepping() const;
|
||||
|
||||
void Halt();
|
||||
|
||||
void QueueRun();
|
||||
void QueueStep();
|
||||
void QueueHalt();
|
||||
void ToggleRun();
|
||||
|
||||
void QueueWrite(unsigned short addr, unsigned char value);
|
||||
|
||||
bool IsTracing() const;
|
||||
bool IsTracingEnabled() const;
|
||||
|
||||
void TraceStart();
|
||||
void TraceStop();
|
||||
void TraceCaptureBefore(long cycles, const CPUState& state);
|
||||
void TraceCaptureAfter(long cycles, const CPUState& state);
|
||||
void TraceCaptureInterruptRequest(unsigned char irq, long cycleTime, const CPUState& state);
|
||||
void TraceCaptureInterruptMasked(unsigned char irq, long cycleTime, const CPUState& state);
|
||||
void TraceCaptureInterruptServicing(unsigned char irq, long cycleTime, const CPUState& state);
|
||||
void TraceCaptureInterruptExecuting(unsigned char irq, long cycleTime, const CPUState& state);
|
||||
#if USE_NEWTIMING
|
||||
void TraceCaptureScreenEvent(TraceEvent evt, double cycles, unsigned int n);
|
||||
void TraceCaptureScreenEvent(TraceEvent evt, double cycles, unsigned int n, const char *s);
|
||||
#else
|
||||
void TraceCaptureScreenEvent(TraceEvent evt, double cycles);
|
||||
#endif
|
||||
void TraceEmulatorCycle(TraceEvent evt, int state, double lineNS, double irqNS, double soundNS, double cycles, double drift);
|
||||
|
||||
void SetTraceEnable();
|
||||
void SetTraceDisable();
|
||||
void ResetTrace();
|
||||
void SetTraceMaxSamples(long samples);
|
||||
void SetTraceStartTriggers(triggerbuffer_type startTriggers);
|
||||
void SetTraceStopTriggers(triggerbuffer_type stopTriggers);
|
||||
void SetTraceOptions(bool screen, bool emulation);
|
||||
|
||||
long GetTraceSamples() const;
|
||||
void LockTrace() const;
|
||||
void UnlockTrace() const;
|
||||
const tracebuffer_type& GetTraceResult() const;
|
||||
void SetTraceMark(int mark, long sample);
|
||||
void ClearTraceMarks();
|
||||
void GetTraceMarkSamples(tracebuffer_type& result) const;
|
||||
|
||||
void Update();
|
||||
|
||||
// VCC HALT and BREAK instuctions status and enable. A BREAK instruction
|
||||
// can be assembled into code using the lwasm assembler. The HALT
|
||||
// instruction is used by Vcc as a breakpoint mechanism (called
|
||||
// haltpoints to avoid conflict with the mechanism used by the source
|
||||
// code debugger) BREAK instruction is page two opcodes 0x113E and the
|
||||
// HALT instruction is opcode 0x15.
|
||||
bool Break_Enabled() const;
|
||||
void Enable_Break(bool);
|
||||
bool Halt_Enabled() const;
|
||||
void Enable_Halt(bool);
|
||||
|
||||
protected:
|
||||
|
||||
enum class ExecutionMode
|
||||
{
|
||||
Halt,
|
||||
Run,
|
||||
Step
|
||||
};
|
||||
|
||||
bool HasPendingCommandNoLock() const;
|
||||
ExecutionMode ConsumePendingCommandNoLock();
|
||||
ExecutionMode ProcessNewModeNoLock(ExecutionMode cpuCmd) const;
|
||||
|
||||
struct PendingWrite
|
||||
{
|
||||
unsigned short addr;
|
||||
unsigned char value;
|
||||
PendingWrite(unsigned short addr, unsigned char value) : addr(addr), value(value) {};
|
||||
PendingWrite() : addr(0),value(0) {};
|
||||
};
|
||||
|
||||
bool HasPendingWriteNoLock() const;
|
||||
PendingWrite ConsumePendingWriteNoLock();
|
||||
void ProcessWrite(PendingWrite memWrite);
|
||||
|
||||
void CheckStopTrace(CPUState state);
|
||||
|
||||
private:
|
||||
|
||||
mutable VCC::Util::critical_section Section_;
|
||||
bool HasPendingCommand_ = false;
|
||||
ExecutionMode PendingCommand_ = ExecutionMode::Halt;
|
||||
breakpointsbuffer_type Breakpoints_;
|
||||
bool BreakpointsChanged_ = false;
|
||||
CPUState ProcessorState_;
|
||||
std::map<HWND, std::unique_ptr<Client>> RegisteredClients_;
|
||||
std::atomic<ExecutionMode> ExecutionMode_ = ExecutionMode::Run;
|
||||
//
|
||||
bool HasPendingWrite_ = false;
|
||||
PendingWrite PendingWrite_;
|
||||
//
|
||||
std::unique_ptr<OpDecoder> Decoder_;
|
||||
std::atomic<bool> TraceEnabled_ = false;
|
||||
std::atomic<bool> TraceRunning_ = false;
|
||||
size_t TraceMaxSamples_ = 500000;
|
||||
long TraceSamplesCollected_ = 0;
|
||||
bool TraceEmulation_ = false;
|
||||
bool TraceScreen_ = false;
|
||||
triggerbuffer_type TraceStartTriggers_;
|
||||
triggerbuffer_type TraceStopTriggers_;
|
||||
bool TraceTriggerChanged_ = false;
|
||||
tracebuffer_type TraceCaptured_;
|
||||
std::map<int, long> TraceMarks_;
|
||||
bool Break_Enabled_TF = false;
|
||||
bool Halt_Enabled_TF = false;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
// 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/>.
|
||||
//
|
||||
// Debugger Utilities - Part of the Debugger package for VCC
|
||||
// Author: Chet Simpson
|
||||
#include "Debugger.h"
|
||||
#include "../../src/core/tcc1014mmu.h"
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <stdarg.h>
|
||||
#include <memory>
|
||||
#include "defines.h"
|
||||
|
||||
namespace VCC::Debugger
|
||||
{
|
||||
|
||||
std::string ToHexString(long value, int length, bool leadingZeros)
|
||||
{
|
||||
std::ostringstream fmt;
|
||||
|
||||
fmt << std::hex << std::setw(length) << std::uppercase << std::setfill(leadingZeros ? '0' : ' ') << value;
|
||||
|
||||
return fmt.str();
|
||||
}
|
||||
|
||||
std::string ToDecimalString(long value, int length, bool leadingZeros)
|
||||
{
|
||||
std::ostringstream fmt;
|
||||
|
||||
fmt << std::dec << std::setw(length) << std::setfill(leadingZeros ? '0' : ' ') << value;
|
||||
|
||||
return fmt.str();
|
||||
}
|
||||
|
||||
std::string ToByteString(const std::vector<unsigned char>& bytes)
|
||||
{
|
||||
std::ostringstream fmt;
|
||||
|
||||
for (const auto& b : bytes)
|
||||
{
|
||||
if (fmt.str().size() > 0)
|
||||
{
|
||||
fmt << " ";
|
||||
}
|
||||
fmt << ToHexString(b, 2, true);
|
||||
}
|
||||
|
||||
return fmt.str();
|
||||
}
|
||||
|
||||
bool replace(std::string& str, const std::string& from, const std::string& to)
|
||||
{
|
||||
size_t start_pos = str.find(from);
|
||||
if (start_pos == std::string::npos)
|
||||
return false;
|
||||
str.replace(start_pos, from.length(), to);
|
||||
return true;
|
||||
}
|
||||
|
||||
int roundUp(int numToRound, int multiple)
|
||||
{
|
||||
if (multiple == 0)
|
||||
return numToRound;
|
||||
|
||||
int remainder = numToRound % multiple;
|
||||
if (remainder == 0)
|
||||
return numToRound;
|
||||
|
||||
return numToRound + multiple - remainder;
|
||||
}
|
||||
|
||||
int roundDn(int numToRound, int multiple)
|
||||
{
|
||||
if (multiple == 0)
|
||||
return numToRound;
|
||||
|
||||
int remainder = numToRound % multiple;
|
||||
if (remainder == 0)
|
||||
return numToRound;
|
||||
|
||||
return numToRound - remainder;
|
||||
}
|
||||
|
||||
// Get memory for Decode, CPU address or Physical Block + Address
|
||||
unsigned char DbgRead8(bool phyAddr, unsigned short block, unsigned short PC) {
|
||||
if (phyAddr) {
|
||||
unsigned long addr = PC + block * 0x2000;
|
||||
return (unsigned char) GetMem(addr);
|
||||
} else {
|
||||
return SafeMemRead8(PC);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace VCC::Debugger::UI
|
||||
{
|
||||
void BackBufferInfo::CleanupDC(HWND hWnd)
|
||||
{
|
||||
if (DeviceContext)
|
||||
{
|
||||
ReleaseDC(hWnd, DeviceContext);
|
||||
DeleteDC(DeviceContext);
|
||||
DeviceContext = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void BackBufferInfo::CleanupBitmap()
|
||||
{
|
||||
if (Bitmap)
|
||||
{
|
||||
DeleteObject(Bitmap);
|
||||
Bitmap = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
BackBufferInfo AttachBackBuffer(HWND hWnd, int widthAdjust, int heightAdjust)
|
||||
{
|
||||
BackBufferInfo backBuffer;
|
||||
|
||||
GetClientRect(hWnd, &backBuffer.Rect);
|
||||
|
||||
backBuffer.Rect.right += widthAdjust;
|
||||
backBuffer.Rect.bottom += heightAdjust;
|
||||
|
||||
backBuffer.Width = backBuffer.Rect.right - backBuffer.Rect.left;
|
||||
backBuffer.Height = backBuffer.Rect.bottom - backBuffer.Rect.top;
|
||||
|
||||
HDC hdc = GetDC(hWnd);
|
||||
|
||||
backBuffer.Bitmap = CreateCompatibleBitmap(hdc, backBuffer.Width, backBuffer.Height);
|
||||
if (backBuffer.Bitmap == nullptr)
|
||||
{
|
||||
throw std::runtime_error("failed to create backbuffer bitmap");
|
||||
}
|
||||
|
||||
backBuffer.DeviceContext = CreateCompatibleDC(hdc);
|
||||
if (backBuffer.DeviceContext == nullptr)
|
||||
{
|
||||
throw std::runtime_error("failed to create the backbuffer device context");
|
||||
}
|
||||
|
||||
HBITMAP oldbmp = (HBITMAP)SelectObject(backBuffer.DeviceContext, backBuffer.Bitmap);
|
||||
DeleteObject(oldbmp);
|
||||
ReleaseDC(hWnd, hdc);
|
||||
|
||||
return backBuffer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
// 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/>.
|
||||
//
|
||||
// Debugger Utilities - Part of the Debugger package for VCC
|
||||
// Author: Chet Simpson
|
||||
#pragma once
|
||||
#include <Windows.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
|
||||
|
||||
namespace VCC::Debugger
|
||||
{
|
||||
|
||||
template<class Type_>
|
||||
inline LPCSTR ToLPCSTR(std::basic_string<Type_>& str)
|
||||
{
|
||||
return str.c_str();
|
||||
}
|
||||
|
||||
template<class Type_>
|
||||
inline LPCSTR ToLPCSTR(const std::basic_string<Type_>& str)
|
||||
{
|
||||
return str.c_str();
|
||||
}
|
||||
|
||||
template<class Type_>
|
||||
LPCSTR ToLPCSTR(const std::basic_filebuf<Type_>&& str)
|
||||
{
|
||||
static_assert("RValue not supported for ToLPCSTR");
|
||||
}
|
||||
|
||||
std::string ToHexString(long value, int length, bool leadingZeros = true);
|
||||
std::string ToDecimalString(long value, int length, bool leadingZeros = true);
|
||||
std::string ToByteString(const std::vector<unsigned char>& bytes);
|
||||
bool replace(std::string& str, const std::string& from, const std::string& to);
|
||||
int roundUp(int numToRound, int multiple);
|
||||
int roundDn(int numToRound, int multiple);
|
||||
unsigned char DbgRead8(bool phyAddr, unsigned short block, unsigned short PC);
|
||||
}
|
||||
|
||||
namespace VCC::Debugger::UI
|
||||
{
|
||||
|
||||
struct BackBufferInfo
|
||||
{
|
||||
HDC DeviceContext = nullptr;
|
||||
HBITMAP Bitmap = nullptr;
|
||||
RECT Rect{};
|
||||
int Width = 0;
|
||||
int Height = 0;
|
||||
|
||||
void CleanupDC(HWND hWnd);
|
||||
void CleanupBitmap();
|
||||
};
|
||||
|
||||
BackBufferInfo AttachBackBuffer(HWND hWnd, int widthAdjust, int heightAdjust);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,602 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifdef _LEGACY_VCC
|
||||
#pragma warning( disable : 4800 )
|
||||
#endif
|
||||
|
||||
#define NO_WARN_MBCS_MFC_DEPRECATION
|
||||
#define _WIN32_WINNT 0x05010000 // I want to support XP
|
||||
|
||||
#include "../../src/core/BuildConfig.h"
|
||||
#include <vcc/bus/proxy_msgwin.h>
|
||||
#include <vcc/util/limits.h>
|
||||
#include <vcc/util/logger.h>
|
||||
#include <Windows.h>
|
||||
#include <CommCtrl.h> // Windows common controls
|
||||
#include "defines.h"
|
||||
#include "stdio.h"
|
||||
#include "DirectDrawInterface.h"
|
||||
#include "resource.h"
|
||||
#include "../../src/core/tcc1014graphics.h"
|
||||
#include "throttle.h"
|
||||
#include "config.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "../../src/core/IDisplay.h"
|
||||
#include "Screenshot.h"
|
||||
|
||||
#include "OpenGL.h"
|
||||
#include "OpenGLFontConsola.h"
|
||||
#include "DirectX.h"
|
||||
#include "../../src/core/DisplayNull.h"
|
||||
#include "../../src/core/DisplayNone.h"
|
||||
|
||||
#if USE_DEBUG_AUDIOTAPE
|
||||
#include "../../src/core/IDisplayDebug.h"
|
||||
#endif // USE_DEBUG_AUDIOTAPE
|
||||
|
||||
using namespace VCC; // after all includes
|
||||
|
||||
static IDisplay* g_Display = nullptr;
|
||||
static ISystemState* g_SystemState = nullptr;
|
||||
|
||||
static IDisplayDirectX* g_DirectXDisplay = nullptr;
|
||||
static IDisplayOpenGL* g_OpenGLDisplay = nullptr;
|
||||
static const OpenGLFont* g_DisplayFont = nullptr;
|
||||
|
||||
#if USE_OPENGL
|
||||
using ClassOpenGL = OpenGL;
|
||||
#else
|
||||
using ClassOpenGL = DisplayNull;
|
||||
#endif
|
||||
|
||||
#if USE_DIRECTX
|
||||
using ClassDirectX = DirectX;
|
||||
#else
|
||||
using ClassDirectX = DisplayNull;
|
||||
#endif
|
||||
|
||||
static HWND hwndStatusBar=nullptr;
|
||||
static unsigned int StatusBarHeight=0;
|
||||
static TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
|
||||
static TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
|
||||
static HINSTANCE g_hInstance;
|
||||
static int g_nCmdShow;
|
||||
static WNDCLASSEX wcex;
|
||||
static unsigned char InfoBand=1;
|
||||
static unsigned char Resizeable=1;
|
||||
static unsigned char ForceAspect=1;
|
||||
static char StatusText[255]="";
|
||||
static unsigned int Color=0;
|
||||
static Rect RememberWin = { CW_USEDEFAULT, CW_USEDEFAULT, DefaultWidth, DefaultHeight };
|
||||
static bool UseOpenGL = true;
|
||||
|
||||
//Function Prototypes for this module
|
||||
extern LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); //Callback for the main window
|
||||
|
||||
// load font on demand, otherwise false if not supported
|
||||
bool LoadOpenGLFont()
|
||||
{
|
||||
#if USE_OPENGL
|
||||
return g_OpenGLDisplay && (g_DisplayFont || g_OpenGLDisplay->LoadFont(&g_DisplayFont, IDB_FONT_CONSOLA, OpenGLFontConsola, 32, 127) == OpenGL::OK);
|
||||
#else // !USE_OPENGL
|
||||
return false;
|
||||
#endif // !USE_OPENGL
|
||||
}
|
||||
|
||||
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
{
|
||||
g_hInstance=hInstance;
|
||||
g_nCmdShow=nCmdShow;
|
||||
LoadLibrary("RICHED20.DLL");
|
||||
LoadString(g_hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
||||
LoadString(g_hInstance, IDS_APP_TITLE, szWindowClass, MAX_LOADSTRING);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
template<typename T, typename Interface>
|
||||
bool InitGraphics(Interface** ptr, SystemState* CWState, int w, int h)
|
||||
{
|
||||
if (!g_SystemState) g_SystemState = new SystemStatePtr(CWState);
|
||||
if (!*ptr) *ptr = new T(g_SystemState);
|
||||
if (!g_Display) g_Display = *ptr;
|
||||
if (g_Display && g_Display->Setup(CWState->WindowHandle, w, h, StatusBarHeight, CWState->FullScreen == 1) == IDisplay::OK)
|
||||
return true;
|
||||
g_Display = nullptr;
|
||||
*ptr = nullptr;
|
||||
return false;
|
||||
};
|
||||
|
||||
bool CreateNullWindow(SystemState* CWState)
|
||||
{
|
||||
IDisplayOpenGL* display = nullptr;
|
||||
return InitGraphics<DisplayNone>(&display, CWState, 640, 480);
|
||||
}
|
||||
|
||||
bool CreateDDWindow(SystemState *CWState)
|
||||
{
|
||||
RECT rStatBar;
|
||||
RECT rc = { 0, 0, DefaultWidth, DefaultHeight };
|
||||
|
||||
auto isRememberSize = GetRememberSize();
|
||||
|
||||
if (isRememberSize)
|
||||
{
|
||||
auto& windowRect = GetIniWindowRect();
|
||||
rc = windowRect.GetRect();
|
||||
|
||||
// if x or y undefined keep size but use default position
|
||||
if (windowRect.IsDefaultX() || windowRect.IsDefaultY())
|
||||
isRememberSize = false;
|
||||
}
|
||||
|
||||
int xPos = rc.left;
|
||||
int yPos = rc.top;
|
||||
|
||||
// if not remembering window, use default positioning
|
||||
if (!isRememberSize)
|
||||
{
|
||||
xPos = CW_USEDEFAULT;
|
||||
yPos = 0;
|
||||
}
|
||||
|
||||
HMONITOR hmon;
|
||||
|
||||
if (CWState->WindowHandle != nullptr) //If its go a value it must be a mode switch
|
||||
{
|
||||
hmon = MonitorFromWindow(CWState->WindowHandle, MONITOR_DEFAULTTONEAREST);
|
||||
CloseScreen();
|
||||
DestroyWindow(CWState->WindowHandle);
|
||||
UnregisterClass(wcex.lpszClassName,wcex.hInstance);
|
||||
}
|
||||
wcex.cbSize = sizeof(WNDCLASSEX); //And Rebuilt it from scratch
|
||||
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wcex.lpfnWndProc = (WNDPROC)WndProc;
|
||||
wcex.cbClsExtra = 0;
|
||||
wcex.cbWndExtra = 0;
|
||||
wcex.hInstance = g_hInstance;
|
||||
wcex.hIcon = LoadIcon(g_hInstance, (LPCTSTR)IDI_COCO3);
|
||||
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
||||
wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
||||
wcex.lpszMenuName = (LPCSTR)IDR_MENU;
|
||||
wcex.lpszClassName = szWindowClass;
|
||||
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_COCO3);
|
||||
if (CWState->FullScreen)
|
||||
{
|
||||
wcex.lpszMenuName =nullptr; //Fullscreen has no Menu Bar and no Mouse pointer
|
||||
wcex.hCursor = LoadCursor(g_hInstance, MAKEINTRESOURCE(IDC_NONE));
|
||||
}
|
||||
if (!RegisterClassEx(&wcex))
|
||||
return false;
|
||||
if (CWState->FullScreen == 0)
|
||||
{
|
||||
//Windowed Mode
|
||||
|
||||
// Calculates the required size of the window rectangle, based on the desired client-rectangle size
|
||||
// The window rectangle can then be passed to the CreateWindow function to create a window whose client area is the desired size.
|
||||
::AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, TRUE);
|
||||
|
||||
// We create the Main window
|
||||
CWState->WindowHandle = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, xPos, yPos,
|
||||
rc.right - rc.left, rc.bottom - rc.top,
|
||||
nullptr, nullptr, g_hInstance, nullptr);
|
||||
if (!CWState->WindowHandle) // Can't create window
|
||||
return false;
|
||||
|
||||
// Set up stable proxy window for DLL messages
|
||||
CWState->hMsgProxy = Core::ProxyMsgWin::SetProxy(CWState->WindowHandle);
|
||||
|
||||
// Create the Status Bar Window at the bottom
|
||||
hwndStatusBar = ::CreateStatusWindow(WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | CCS_BOTTOM , "Ready", CWState->WindowHandle, 2);
|
||||
if (!hwndStatusBar) // Can't create Status bar
|
||||
return false;
|
||||
|
||||
// Retrieves the dimensions of the bounding rectangle of the specified window
|
||||
// The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen.
|
||||
::GetWindowRect(hwndStatusBar, &rStatBar); // Get the size of the Status bar
|
||||
StatusBarHeight = rStatBar.bottom - rStatBar.top; // Calculate its height
|
||||
|
||||
// Get the size of main window and add height of status bar then resize Main
|
||||
// re-using rStatBar RECT even though it's the main window
|
||||
::GetWindowRect(CWState->WindowHandle, &rStatBar);
|
||||
::MoveWindow(CWState->WindowHandle, rStatBar.left, rStatBar.top, // using MoveWindow to resize
|
||||
rStatBar.right - rStatBar.left, (rStatBar.bottom + StatusBarHeight) - rStatBar.top,
|
||||
1);
|
||||
::SendMessage(hwndStatusBar, WM_SIZE, 0, 0); // Redraw Status bar in new position
|
||||
}
|
||||
else //Full Screen Mode
|
||||
{
|
||||
CaptureCurrentWindowRect();
|
||||
|
||||
MONITORINFO mi = { sizeof(mi) };
|
||||
if (!GetMonitorInfo(hmon, &mi))
|
||||
return false;
|
||||
|
||||
CWState->WindowHandle = CreateWindow(
|
||||
szWindowClass,
|
||||
nullptr,
|
||||
WS_POPUP | WS_VISIBLE,
|
||||
mi.rcMonitor.left,
|
||||
mi.rcMonitor.top,
|
||||
mi.rcMonitor.right - mi.rcMonitor.left,
|
||||
mi.rcMonitor.bottom - mi.rcMonitor.top,
|
||||
nullptr, nullptr, g_hInstance, 0);
|
||||
}
|
||||
|
||||
ShowWindow(CWState->WindowHandle, g_nCmdShow);
|
||||
UpdateWindow(CWState->WindowHandle);
|
||||
|
||||
HWND windowHandle = CWState->WindowHandle;
|
||||
if (windowHandle)
|
||||
{
|
||||
::GetClientRect(windowHandle, &rStatBar);
|
||||
int w = rStatBar.right - rStatBar.left;
|
||||
int h = rStatBar.bottom - rStatBar.top - StatusBarHeight;
|
||||
|
||||
// attempt to use opengl
|
||||
if (UseOpenGL && !InitGraphics<ClassOpenGL>(&g_OpenGLDisplay, CWState, w, h))
|
||||
UseOpenGL = false;
|
||||
|
||||
// otherwise attempt to use directx
|
||||
if (!UseOpenGL && !InitGraphics<ClassDirectX>(&g_DirectXDisplay, CWState, w, h))
|
||||
return false;
|
||||
|
||||
SetAspect(ForceAspect);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
bool IsMaximized(SystemState* DFState)
|
||||
{
|
||||
WINDOWPLACEMENT wp;
|
||||
memset(&wp, 0, sizeof(wp));
|
||||
wp.length = sizeof(wp);
|
||||
GetWindowPlacement(DFState->WindowHandle, &wp);
|
||||
return wp.showCmd == SW_MAXIMIZE;
|
||||
}
|
||||
|
||||
|
||||
void DisplayFlip(SystemState *DFState) // Double buffering flip
|
||||
{
|
||||
if (g_Display)
|
||||
{
|
||||
g_Display->Render();
|
||||
#if USE_OPENGL
|
||||
if (DFState->FullScreen && InfoBand)
|
||||
{
|
||||
if (LoadOpenGLFont())
|
||||
{
|
||||
OpenGL::Rect renderRect;
|
||||
g_OpenGLDisplay->GetRect(OpenGL::OPT_RECT_RENDER, &renderRect);
|
||||
g_OpenGLDisplay->RenderBox(0, 0, renderRect.w, 25, VCC::ColorBlack, true);
|
||||
g_OpenGLDisplay->RenderText(g_DisplayFont, 10, 18, 20, StatusText);
|
||||
}
|
||||
}
|
||||
|
||||
#if USE_DEBUG_AUDIOTAPE
|
||||
// put these here for now as it needs to be on top
|
||||
DebugPrint(10, 250, 20, "Audio Out", VCC::ColorWhite);
|
||||
DebugPrint(10, 400, 20, "Audio In", VCC::ColorWhite);
|
||||
DebugPrint(10, 515, 20, "Motor", VCC::ColorWhite);
|
||||
DebugPrint(10, 545, 20, "MUX", VCC::ColorWhite);
|
||||
#endif // USE_DEBUG_AUDIOTAPE
|
||||
#endif // USE_OPENGL
|
||||
|
||||
g_Display->Present();
|
||||
}
|
||||
|
||||
static RECT CurWindow;
|
||||
::GetWindowRect(DFState->WindowHandle, &CurWindow);
|
||||
static RECT CurScreen;
|
||||
::GetClientRect(DFState->WindowHandle, &CurScreen);
|
||||
int clientWidth = (int)CurScreen.right;
|
||||
int clientHeight = (int)CurScreen.bottom;
|
||||
|
||||
if (!IsMaximized(DFState) && !DFState->FullScreen && !DFState->Exiting)
|
||||
{
|
||||
#if USE_DEFAULT_POSITIONING
|
||||
// preserve default positioning (like older versions):
|
||||
RememberWin.x = RememberWin.IsDefaultX() ? CW_USEDEFAULT : CurWindow.left;
|
||||
RememberWin.y = RememberWin.IsDefaultY() ? CW_USEDEFAULT : CurWindow.top;
|
||||
#else // !USE_DEFAULT_POSITIONING
|
||||
// remember positioning:
|
||||
RememberWin.x = CurWindow.left;
|
||||
RememberWin.y = CurWindow.top;
|
||||
#endif // !USE_DEFAULT_POSITIONING
|
||||
|
||||
// remember size:
|
||||
RememberWin.w = clientWidth; // Used for saving new window size to the ini file.
|
||||
RememberWin.h = clientHeight - StatusBarHeight;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char LockScreen()
|
||||
{
|
||||
if (!g_Display)
|
||||
return 0;
|
||||
|
||||
if (g_Display->LockSurface() != IDisplay::OK)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void UnlockScreen(SystemState *USState)
|
||||
{
|
||||
if (g_DirectXDisplay && InfoBand)
|
||||
g_DirectXDisplay->RenderStatusLine(StatusText);
|
||||
|
||||
if (g_Display->UnlockSurface() != IDisplay::OK)
|
||||
return;
|
||||
|
||||
DisplayFlip(USState);
|
||||
return;
|
||||
}
|
||||
|
||||
void SetStatusBarText(const char *TextBuffer,const SystemState *STState)
|
||||
{
|
||||
if (!STState->FullScreen)
|
||||
{
|
||||
SendMessage(hwndStatusBar,WM_SETTEXT,0, reinterpret_cast<LPARAM>(TextBuffer));
|
||||
SendMessage(hwndStatusBar,WM_SIZE,0,0);
|
||||
}
|
||||
else
|
||||
strcpy(StatusText,TextBuffer);
|
||||
return;
|
||||
}
|
||||
|
||||
void Cls(unsigned int ClsColor,SystemState *CLState)
|
||||
{
|
||||
CLState->ResetPending=3; //Tell Main loop to hold Emu
|
||||
Color=ClsColor;
|
||||
return;
|
||||
}
|
||||
|
||||
void DoCls(SystemState *CLStatus)
|
||||
{
|
||||
unsigned short x=0,y=0;
|
||||
|
||||
if(LockScreen())
|
||||
return;
|
||||
switch (CLStatus->BitDepth)
|
||||
{
|
||||
case 0:
|
||||
for (y=0;y<480;y++)
|
||||
for (x=0;x<640;x++)
|
||||
CLStatus->PTRsurface8[x + (y*CLStatus->SurfacePitch) ]=Color|128;
|
||||
break;
|
||||
case 1:
|
||||
for (y=0;y<480;y++)
|
||||
for (x=0;x<640;x++)
|
||||
CLStatus->PTRsurface16[x + (y*CLStatus->SurfacePitch) ]=Color;
|
||||
break;
|
||||
case 2:
|
||||
for (y=0;y<480;y++)
|
||||
for (x=0;x<640;x++)
|
||||
{
|
||||
CLStatus->PTRsurface8[(x*3) + (y*CLStatus->SurfacePitch) ]=(Color & 0xFF0000)>>16;
|
||||
CLStatus->PTRsurface8[(x*3)+1 + (y*CLStatus->SurfacePitch) ]=(Color & 0x00FF00)>>8;
|
||||
CLStatus->PTRsurface8[(x*3)+2 + (y*CLStatus->SurfacePitch) ]=(Color & 0xFF);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
for (y=0;y<480;y++)
|
||||
for (x=0;x<640;x++)
|
||||
CLStatus->PTRsurface32[x + (y*CLStatus->SurfacePitch) ]=Color;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
UnlockScreen(CLStatus);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char SetInfoBand( unsigned char Tmp)
|
||||
{
|
||||
if (Tmp!=QUERY)
|
||||
InfoBand=Tmp;
|
||||
return InfoBand;
|
||||
}
|
||||
|
||||
unsigned char SetResize(unsigned char Tmp)
|
||||
{
|
||||
if (Tmp != QUERY)
|
||||
{
|
||||
Resizeable = Tmp;
|
||||
if (g_Display)
|
||||
g_Display->SetOption(IDisplay::OPT_FLAG_RESIZEABLE, Resizeable);
|
||||
}
|
||||
return Resizeable;
|
||||
}
|
||||
|
||||
unsigned char SetAspect (unsigned char Tmp)
|
||||
{
|
||||
if (Tmp != QUERY)
|
||||
{
|
||||
ForceAspect = Tmp;
|
||||
if (g_Display)
|
||||
g_Display->SetOption(IDisplay::OPT_FLAG_ASPECT, ForceAspect);
|
||||
}
|
||||
return ForceAspect;
|
||||
}
|
||||
|
||||
void DisplaySignalLostMessage()
|
||||
{
|
||||
#if USE_OPENGL
|
||||
if (LoadOpenGLFont())
|
||||
{
|
||||
const float fontSize = 20;
|
||||
const char* message = " Signal Lost! Press F9 ";
|
||||
const float messageWidth = strlen(message) * fontSize * g_DisplayFont->glyphs->advance;
|
||||
const float baseLine = fontSize - 4;
|
||||
|
||||
OpenGL::Rect renderRect;
|
||||
g_OpenGLDisplay->GetRect(OpenGL::OPT_RECT_RENDER, &renderRect);
|
||||
float x = (renderRect.w - messageWidth) / 2;
|
||||
float y = (renderRect.h - fontSize) / 2;
|
||||
g_OpenGLDisplay->RenderBox(x, y, messageWidth, fontSize, VCC::ColorBlack, true);
|
||||
g_OpenGLDisplay->RenderText(g_DisplayFont, x, y + baseLine, fontSize, message);
|
||||
}
|
||||
#endif // USE_OPENGL
|
||||
}
|
||||
|
||||
float Static(SystemState *STState)
|
||||
{
|
||||
unsigned short x=0;
|
||||
static unsigned short y=0;
|
||||
unsigned char Temp=0;
|
||||
static unsigned char GreyScales[4] = { 128,135,184,191 };
|
||||
|
||||
if (g_Display == nullptr)
|
||||
return 0;
|
||||
|
||||
if (g_Display->LockSurface() != IDisplay::OK)
|
||||
return 0;
|
||||
|
||||
switch (STState->BitDepth)
|
||||
{
|
||||
case 0:
|
||||
for (y=0;y<480;y+=2)
|
||||
for (x=0;x<160;x++)
|
||||
{
|
||||
Temp=rand() & 3;
|
||||
STState->PTRsurface32[x + (y*STState->SurfacePitch>>2) ]= GreyScales[Temp]|(GreyScales[Temp]<<8)|(GreyScales[Temp]<<16) | (GreyScales[Temp]<<24);
|
||||
STState->PTRsurface32[x + ((y+1)*STState->SurfacePitch>>2) ]= GreyScales[Temp]|(GreyScales[Temp]<<8)|(GreyScales[Temp]<<16) | (GreyScales[Temp]<<24);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
for (y=0;y<480;y+=2)
|
||||
for (x=0;x<320;x++)
|
||||
{
|
||||
Temp=rand() & 31;
|
||||
STState->PTRsurface32[x + (y*STState->SurfacePitch>>1) ]=Temp | (Temp <<6) | (Temp<<11) | (Temp<<16) |(Temp<<22)| (Temp<<27);
|
||||
STState->PTRsurface32[x + ((y+1)*STState->SurfacePitch>>1) ]=Temp | (Temp <<6) | (Temp<<11) | (Temp<<16) |(Temp<<22)| (Temp<<27);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
for (y=0;y<480;y++)
|
||||
for (x=0;x<640;x++)
|
||||
{
|
||||
STState->PTRsurface8[(x*3) + (y*STState->SurfacePitch) ]=Temp;
|
||||
STState->PTRsurface8[(x*3)+1 + (y*STState->SurfacePitch) ]=Temp<<8;
|
||||
STState->PTRsurface8[(x*3)+2 + (y*STState->SurfacePitch) ]=Temp <<16;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
for (y=0;y<480;y++)
|
||||
for (x=0;x<640;x++)
|
||||
{
|
||||
Temp=rand() & 255;
|
||||
STState->PTRsurface32[x + (y*STState->SurfacePitch) ]=Temp | (Temp<<8) | (Temp <<16);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
// need to do during lock
|
||||
if (g_DirectXDisplay)
|
||||
g_DirectXDisplay->RenderSignalLostMessage();
|
||||
|
||||
if (g_Display->UnlockSurface() != IDisplay::OK)
|
||||
return 0;
|
||||
|
||||
g_Display->Render();
|
||||
DisplaySignalLostMessage();
|
||||
g_Display->Present();
|
||||
|
||||
return CalculateFPS(false);
|
||||
}
|
||||
|
||||
const Rect& GetCurWindowSize()
|
||||
{
|
||||
return RememberWin;
|
||||
}
|
||||
|
||||
int GetRenderWindowStatusBarHeight()
|
||||
{
|
||||
return StatusBarHeight;
|
||||
}
|
||||
|
||||
|
||||
POINT GetForcedAspectBorderPadding()
|
||||
{
|
||||
if (g_Display)
|
||||
{
|
||||
IDisplay::Rect area;
|
||||
g_Display->GetRect(IDisplay::OPT_RECT_DISPLAY, &area);
|
||||
return { (long)area.x, (long)area.y };
|
||||
}
|
||||
return { 0,0 };
|
||||
}
|
||||
|
||||
void CloseScreen()
|
||||
{
|
||||
if (g_Display)
|
||||
{
|
||||
g_Display->Cleanup();
|
||||
delete g_Display;
|
||||
delete g_SystemState;
|
||||
g_Display = nullptr;
|
||||
g_SystemState = nullptr;
|
||||
|
||||
// alias
|
||||
g_DirectXDisplay = nullptr;
|
||||
g_OpenGLDisplay = nullptr;
|
||||
g_DisplayFont = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void DebugDrawLine(float x1, float y1, float x2, float y2, Pixel color)
|
||||
{
|
||||
if (g_Display)
|
||||
g_Display->DebugDrawLine(x1, y1, x2, y2, color);
|
||||
}
|
||||
|
||||
void DebugDrawBox(float x, float y, float w, float h, Pixel color, bool filled)
|
||||
{
|
||||
if (g_Display)
|
||||
g_Display->DebugDrawBox(x, y, w, h, color, filled);
|
||||
}
|
||||
|
||||
void DebugPrint(float x, float y, float size, const char* str, Pixel color)
|
||||
{
|
||||
if (g_OpenGLDisplay && LoadOpenGLFont())
|
||||
g_OpenGLDisplay->DebugDrawText(g_DisplayFont, x, y, size, str, color);
|
||||
}
|
||||
|
||||
void DumpScreenshot(const char* fname)
|
||||
{
|
||||
using namespace Screenshot;
|
||||
|
||||
auto result = Snap(g_Display, fname);
|
||||
|
||||
if (result != OK)
|
||||
{
|
||||
char msg[128];
|
||||
sprintf(msg, "Unable to take screenshot! (%d)", result);
|
||||
MessageBox(nullptr, msg, "Error", 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
#ifndef __DIRECTDRAWINTERFACE_H__
|
||||
#define __DIRECTDRAWINTERFACE_H__
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
BOOL InitInstance(HINSTANCE,int);
|
||||
void UnlockScreen(SystemState *);
|
||||
unsigned char LockScreen();
|
||||
void SetStatusBarText(const char *,const SystemState *);
|
||||
int GetRenderWindowStatusBarHeight();
|
||||
bool CreateNullWindow(SystemState*);
|
||||
bool CreateDDWindow(SystemState *);
|
||||
void Cls(unsigned int,SystemState *);
|
||||
void DoCls(SystemState *);
|
||||
unsigned char SetInfoBand( unsigned char);
|
||||
unsigned char SetResize(unsigned char);
|
||||
unsigned char SetAspect (unsigned char);
|
||||
float Static(SystemState *);
|
||||
const VCC::Rect& GetCurWindowSize();
|
||||
void DisplayFlip(SystemState *);
|
||||
POINT GetForcedAspectBorderPadding();
|
||||
void CloseScreen();
|
||||
void DumpScreenshot(const char* fname = nullptr);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,514 @@
|
||||
// Copyright 2015 by Joseph Forgion
|
||||
// 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// 2025/04/10 - Craig Allsop - Add OpenGL rendering.
|
||||
//
|
||||
|
||||
#include "DirectX.h"
|
||||
|
||||
#if USE_DIRECTX
|
||||
|
||||
#include "DirectDrawInterface.h"
|
||||
#include "ddraw.h"
|
||||
|
||||
namespace VCC
|
||||
{
|
||||
//
|
||||
// Private wrapper on result code for logging errors
|
||||
//
|
||||
static int Result(int code)
|
||||
{
|
||||
if (code != IDisplay::OK)
|
||||
{
|
||||
char message[256];
|
||||
snprintf(message, 64, "DirectX error %d\nCheck DirectX support", code);
|
||||
MessageBox(nullptr, message, "Error", 0);
|
||||
// FIXME: This is needed and should not be commented out. Wrap it conditional
|
||||
// either here or in the debug log functions.
|
||||
//PrintLogC("OpenGL Error: %d\n", code);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
namespace Detail
|
||||
{
|
||||
//Global Variables for Direct Draw funcions
|
||||
LPDIRECTDRAW g_pDD; // The DirectDraw object
|
||||
LPDIRECTDRAWCLIPPER g_pClipper; // Clipper for primary surface
|
||||
LPDIRECTDRAWSURFACE g_pDDS; // Primary surface
|
||||
LPDIRECTDRAWSURFACE g_pDDSBack; // Back surface
|
||||
IDirectDrawPalette* ddpal; // Needed for 8bit Palette mode
|
||||
bool isInitialized;
|
||||
bool isFullscreen;
|
||||
bool forceAspect;
|
||||
bool resizeable;
|
||||
int statusBarHeight;
|
||||
RECT WindowDefaultSize;
|
||||
POINT ForcedAspectBorderPadding;
|
||||
|
||||
// surface while locked
|
||||
void* surface;
|
||||
int bitDepth;
|
||||
long surfacePitch;
|
||||
}
|
||||
|
||||
DirectX::DirectX(ISystemState* state) : state(state)
|
||||
{
|
||||
using namespace Detail;
|
||||
isInitialized = false;
|
||||
isFullscreen = false;
|
||||
forceAspect = false;
|
||||
statusBarHeight = 0;
|
||||
resizeable = true;
|
||||
WindowDefaultSize = {};
|
||||
ForcedAspectBorderPadding = {};
|
||||
g_pDDSBack = nullptr;
|
||||
g_pDDS = nullptr;
|
||||
g_pClipper = nullptr;
|
||||
g_pDD = nullptr;
|
||||
ddpal = nullptr;
|
||||
surface = nullptr;
|
||||
bitDepth = 0;
|
||||
surfacePitch = 0;
|
||||
}
|
||||
|
||||
int DirectX::Setup(void* hwnd, int width, int height, int statusHeight, bool fullscreen)
|
||||
{
|
||||
using namespace Detail;
|
||||
|
||||
isFullscreen = fullscreen;
|
||||
statusBarHeight = statusHeight;
|
||||
|
||||
GetWindowRect((HWND)hwnd, &WindowDefaultSize);
|
||||
|
||||
HRESULT hr;
|
||||
PALETTEENTRY pal[256];
|
||||
DDSURFACEDESC ddsd; // A structure to describe the surfaces we want
|
||||
unsigned char ColorValues[4] = { 0,85,170,255 };
|
||||
|
||||
memset(&ddsd, 0, sizeof(ddsd)); // Clear all members of the structure to 0
|
||||
ddsd.dwSize = sizeof(ddsd); // The first parameter of the structure must contain the size of the structure
|
||||
|
||||
// Create an instance of a DirectDraw object
|
||||
hr = ::DirectDrawCreate(nullptr, &g_pDD, nullptr);
|
||||
if (FAILED(hr)) return Result(ERR_UNKNOWN);
|
||||
|
||||
VCC::Rect windowRect = { 0, 0, 640, 480 };
|
||||
|
||||
if (fullscreen)
|
||||
{
|
||||
ddsd.lPitch = 0;
|
||||
ddsd.ddpfPixelFormat.dwRGBBitCount = 0;
|
||||
hr = DirectDrawCreate(nullptr, &g_pDD, nullptr); // Initialize DirectDraw
|
||||
if (FAILED(hr)) return Result(ERR_UNKNOWN);
|
||||
hr = g_pDD->SetCooperativeLevel((HWND)hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_NOWINDOWCHANGES);
|
||||
if (FAILED(hr)) return Result(ERR_UNKNOWN);
|
||||
hr = g_pDD->SetDisplayMode(windowRect.w, windowRect.h, 32); // Set 640x480x32 Bit full-screen mode
|
||||
if (FAILED(hr)) return Result(ERR_UNKNOWN);
|
||||
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
|
||||
ddsd.dwBackBufferCount = 1;
|
||||
hr = g_pDD->CreateSurface(&ddsd, &g_pDDS, nullptr);
|
||||
if (FAILED(hr)) return Result(ERR_UNKNOWN);
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
|
||||
g_pDDS->GetAttachedSurface(&ddsd.ddsCaps, &g_pDDSBack);
|
||||
hr = g_pDD->GetDisplayMode(&ddsd);
|
||||
if (FAILED(hr)) return Result(ERR_UNKNOWN);
|
||||
//***********************************TEST*****************************************
|
||||
for (unsigned short i = 0;i <= 63;i++)
|
||||
{
|
||||
pal[i + 128].peBlue = ColorValues[(i & 8) >> 2 | (i & 1)];
|
||||
pal[i + 128].peGreen = ColorValues[(i & 16) >> 3 | (i & 2) >> 1];
|
||||
pal[i + 128].peRed = ColorValues[(i & 32) >> 4 | (i & 4) >> 2];
|
||||
pal[i + 128].peFlags = PC_RESERVED | PC_NOCOLLAPSE;
|
||||
}
|
||||
g_pDD->CreatePalette(DDPCAPS_8BIT | DDPCAPS_ALLOW256, pal, &ddpal, nullptr);
|
||||
g_pDDS->SetPalette(ddpal); // Set palette for Primary surface
|
||||
//**********************************END TEST***************************************
|
||||
}
|
||||
else
|
||||
{
|
||||
// Initialize the DirectDraw object
|
||||
hr = g_pDD->SetCooperativeLevel((HWND)hwnd, DDSCL_NORMAL); // Set DDSCL_NORMAL to use windowed mode
|
||||
if (FAILED(hr)) return Result(ERR_UNKNOWN);
|
||||
|
||||
ddsd.dwFlags = DDSD_CAPS;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
||||
|
||||
// Create our Primary Surface
|
||||
hr = g_pDD->CreateSurface(&ddsd, &g_pDDS, nullptr);
|
||||
if (FAILED(hr)) return Result(ERR_UNKNOWN);
|
||||
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
|
||||
ddsd.dwWidth = windowRect.w; // Make our off-screen surface
|
||||
ddsd.dwHeight = windowRect.h;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY; // Try to create back buffer in video RAM
|
||||
|
||||
#if USE_DIRECTX_16BIT_SURFACE
|
||||
// Set 16-bit pixel format (5-6-5)
|
||||
ddsd.dwFlags |= DDSD_PIXELFORMAT;
|
||||
ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
|
||||
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
|
||||
ddsd.ddpfPixelFormat.dwRGBBitCount = 16;
|
||||
ddsd.ddpfPixelFormat.dwRBitMask = 0xF800; // 5 bits Red
|
||||
ddsd.ddpfPixelFormat.dwGBitMask = 0x07E0; // 6 bits Green
|
||||
ddsd.ddpfPixelFormat.dwBBitMask = 0x001F; // 5 bits Blue
|
||||
#elif USE_DIRECTX_8BIT_SURFACE
|
||||
ddsd.dwFlags |= DDSD_PIXELFORMAT;
|
||||
ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
|
||||
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED8;
|
||||
ddsd.ddpfPixelFormat.dwRGBBitCount = 8;
|
||||
#endif
|
||||
|
||||
hr = g_pDD->CreateSurface(&ddsd, &g_pDDSBack, nullptr);
|
||||
if (FAILED(hr)) // If not enough Video Ram
|
||||
{
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY; // Try to create back buffer in System RAM
|
||||
hr = g_pDD->CreateSurface(&ddsd, &g_pDDSBack, nullptr);
|
||||
if (FAILED(hr)) return Result(ERR_UNKNOWN); //Giving Up
|
||||
MessageBox(nullptr, "Creating Back Buffer in System Ram\n", "Performance Warning", 0);
|
||||
}
|
||||
|
||||
hr = g_pDD->GetDisplayMode(&ddsd);
|
||||
if (FAILED(hr)) return Result(ERR_UNKNOWN);
|
||||
hr = g_pDD->CreateClipper(0, &g_pClipper, nullptr); // Create the clipper using the DirectDraw object
|
||||
if (FAILED(hr)) return Result(ERR_UNKNOWN);
|
||||
hr = g_pClipper->SetHWnd(0, (HWND)hwnd); // Assign your window's HWND to the clipper
|
||||
if (FAILED(hr)) return Result(ERR_UNKNOWN);
|
||||
hr = g_pDDS->SetClipper(g_pClipper); // Attach the clipper to the primary surface
|
||||
if (FAILED(hr)) return Result(ERR_UNKNOWN);
|
||||
hr = g_pDDSBack->Lock(nullptr, &ddsd, DDLOCK_WAIT, nullptr);
|
||||
if (FAILED(hr)) return Result(ERR_UNKNOWN);
|
||||
hr = g_pDDSBack->Unlock(nullptr); // Unlock surface
|
||||
if (FAILED(hr)) return Result(ERR_UNKNOWN);
|
||||
}
|
||||
|
||||
return Result(OK);
|
||||
}
|
||||
|
||||
int DirectX::Render()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Detail;
|
||||
|
||||
static HRESULT hr;
|
||||
static RECT rcSrc; // source blit rectangle
|
||||
static RECT rcDest; // destination blit rectangle
|
||||
static RECT Temp;
|
||||
static POINT p;
|
||||
|
||||
HWND hwnd;
|
||||
if (state->GetWindowHandle((void**)&hwnd) != OK)
|
||||
return Result(ERR_UNKNOWN);
|
||||
|
||||
VCC::Rect windowRect;
|
||||
if (state->GetRect(1, &windowRect) != OK)
|
||||
return Result(ERR_UNKNOWN);
|
||||
|
||||
ForcedAspectBorderPadding = { 0,0 };
|
||||
|
||||
if (isFullscreen) // if we're windowed do the blit, else just Flip
|
||||
hr = g_pDDS->Flip(nullptr, DDFLIP_NOVSYNC | DDFLIP_DONOTWAIT); //DDFLIP_WAIT
|
||||
else
|
||||
{
|
||||
p.x = 0; p.y = 0;
|
||||
|
||||
// The ClientToScreen function converts the client-area coordinates of a specified point to screen coordinates.
|
||||
// in other word the client rectangle of the main windows 0, 0 (upper-left corner)
|
||||
// in a screen x,y coords which is put back into p
|
||||
::ClientToScreen(hwnd, &p); // find out where on the primary surface our window lives
|
||||
|
||||
// get the actual client rectangle, which is always 0,0 - w,h
|
||||
::GetClientRect(hwnd, &rcDest);
|
||||
|
||||
// The OffsetRect function moves the specified rectangle by the specified offsets
|
||||
// add the delta screen point we got above, which gives us the client rect in screen coordinates.
|
||||
::OffsetRect(&rcDest, p.x, p.y);
|
||||
|
||||
// our destination rectangle is going to be
|
||||
::SetRect(&rcSrc, 0, 0, windowRect.w, windowRect.h);
|
||||
|
||||
if (resizeable)
|
||||
{
|
||||
rcDest.bottom -= statusBarHeight;
|
||||
|
||||
if (forceAspect) // Adjust the Aspect Ratio if window is resized
|
||||
{
|
||||
float srcWidth = (float)windowRect.w;
|
||||
float srcHeight = (float)windowRect.h;
|
||||
float srcRatio = srcWidth / srcHeight;
|
||||
|
||||
// change this to use the existing rcDest and the calc, w = right-left & h = bottom-top,
|
||||
// because rcDest has already been converted to screen cords, right?
|
||||
static RECT rcClient;
|
||||
::GetClientRect(hwnd, &rcClient); // x,y is always 0,0 so right, bottom is w,h
|
||||
rcClient.bottom -= statusBarHeight;
|
||||
|
||||
float clientWidth = (float)rcClient.right;
|
||||
float clientHeight = (float)rcClient.bottom;
|
||||
float clientRatio = clientWidth / clientHeight;
|
||||
|
||||
float dstWidth = 0, dstHeight = 0;
|
||||
|
||||
if (clientRatio > srcRatio)
|
||||
{
|
||||
dstWidth = srcWidth * clientHeight / srcHeight;
|
||||
dstHeight = clientHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
dstWidth = clientWidth;
|
||||
dstHeight = srcHeight * clientWidth / srcWidth;
|
||||
}
|
||||
|
||||
float dstX = (clientWidth - dstWidth) / 2;
|
||||
float dstY = (clientHeight - dstHeight) / 2;
|
||||
|
||||
static POINT pDstLeftTop;
|
||||
pDstLeftTop.x = (long)dstX; pDstLeftTop.y = (long)dstY;
|
||||
ForcedAspectBorderPadding = pDstLeftTop;
|
||||
|
||||
::ClientToScreen(hwnd, &pDstLeftTop);
|
||||
|
||||
static POINT pDstRightBottom;
|
||||
pDstRightBottom.x = (long)(dstX + dstWidth); pDstRightBottom.y = (long)(dstY + dstHeight);
|
||||
::ClientToScreen(hwnd, &pDstRightBottom);
|
||||
|
||||
::SetRect(&rcDest, pDstLeftTop.x, pDstLeftTop.y, pDstRightBottom.x, pDstRightBottom.y);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// this does not seem ideal, it lets you begin to resize and immediately resizes it back ... causing a lot of flicker.
|
||||
rcDest.right = rcDest.left + windowRect.w;
|
||||
rcDest.bottom = rcDest.top + windowRect.h;
|
||||
::GetWindowRect(hwnd, &Temp);
|
||||
::MoveWindow(hwnd, Temp.left, Temp.top, WindowDefaultSize.right - WindowDefaultSize.left, WindowDefaultSize.bottom - WindowDefaultSize.top, 1);
|
||||
}
|
||||
|
||||
if (g_pDDSBack == nullptr)
|
||||
return Result(ERR_UNKNOWN);
|
||||
|
||||
hr = g_pDDS->Blt(&rcDest, g_pDDSBack, &rcSrc, DDBLT_WAIT, nullptr); // DDBLT_WAIT
|
||||
if (hr == DDERR_SURFACELOST)
|
||||
{
|
||||
hr = g_pDDS->Restore();
|
||||
if (hr == DDERR_WRONGMODE) return Result(ERR_WRONGMODE);
|
||||
if (FAILED(hr)) return Result(ERR_UNKNOWN);
|
||||
g_pDDSBack->Restore();
|
||||
hr = g_pDDS->Blt(&rcDest, g_pDDSBack, &rcSrc, DDBLT_WAIT, nullptr); // DDBLT_WAIT
|
||||
if (hr == E_FAIL) return Result(OK);
|
||||
}
|
||||
if (FAILED(hr)) return Result(ERR_UNKNOWN);
|
||||
}
|
||||
|
||||
return Result(OK);
|
||||
}
|
||||
|
||||
int DirectX::Present()
|
||||
{
|
||||
return Result(OK);
|
||||
}
|
||||
|
||||
int DirectX::Cleanup()
|
||||
{
|
||||
using namespace Detail;
|
||||
if (g_pDD != nullptr)
|
||||
g_pDD->Release(); //Destroy the current Window
|
||||
|
||||
return Result(OK);
|
||||
}
|
||||
|
||||
int DirectX::SetOption(int flagOption, bool enabled)
|
||||
{
|
||||
using namespace Detail;
|
||||
//if (!isInitialized) return Result(ERR_NOTINITIALIZED);
|
||||
switch (flagOption)
|
||||
{
|
||||
case OPT_FLAG_ASPECT: forceAspect = enabled; break;
|
||||
case OPT_FLAG_RESIZEABLE: resizeable = enabled; break;
|
||||
default: return Result(ERR_BADOPTION);
|
||||
}
|
||||
return Result(OK);
|
||||
}
|
||||
|
||||
int DirectX::GetSurface(Pixel** pixels)
|
||||
{
|
||||
using namespace Detail;
|
||||
if (!surface) return Result(ERR_UNKNOWN);
|
||||
if (bitDepth == 3)
|
||||
{
|
||||
*pixels = (Pixel*)surface;
|
||||
return Result(OK);
|
||||
}
|
||||
return Result(ERR_UNSUPPORTED);
|
||||
}
|
||||
|
||||
int DirectX::GetRect(int rectOption, Rect* rect)
|
||||
{
|
||||
switch (rectOption)
|
||||
{
|
||||
case OPT_RECT_DISPLAY: GetDisplayArea(rect); break;
|
||||
case OPT_RECT_SURFACE: GetSurfaceArea(rect); break;
|
||||
default: return Result(ERR_BADOPTION);
|
||||
}
|
||||
return Result(OK);
|
||||
}
|
||||
|
||||
int DirectX::LockSurface()
|
||||
{
|
||||
using namespace Detail;
|
||||
|
||||
CheckSurfaces();
|
||||
|
||||
HRESULT hr;
|
||||
DDSURFACEDESC ddsd; // A structure to describe the surfaces we want
|
||||
memset(&ddsd, 0, sizeof(ddsd)); // Clear all members of the structure to 0
|
||||
ddsd.dwSize = sizeof(ddsd); // The first parameter of the structure must contain the size of the structure
|
||||
|
||||
// Lock entire surface, wait if it is busy, return surface memory pointer
|
||||
hr = g_pDDSBack->Lock(nullptr, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR, nullptr);
|
||||
if (hr == E_FAIL) return ERR_CANTLOCK;
|
||||
if (FAILED(hr)) return Result(ERR_UNKNOWN);
|
||||
|
||||
switch (ddsd.ddpfPixelFormat.dwRGBBitCount)
|
||||
{
|
||||
case 8:
|
||||
surfacePitch = ddsd.lPitch;
|
||||
bitDepth = 0;
|
||||
break;
|
||||
case 15:
|
||||
case 16:
|
||||
surfacePitch = ddsd.lPitch / 2;
|
||||
bitDepth = 1;
|
||||
break;
|
||||
case 24:
|
||||
MessageBox(nullptr, "24 Bit color is currently unsupported", "Ok", 0);
|
||||
exit(0);
|
||||
surfacePitch = ddsd.lPitch;
|
||||
bitDepth = 2;
|
||||
break;
|
||||
case 32:
|
||||
surfacePitch = ddsd.lPitch / 4;
|
||||
bitDepth = 3;
|
||||
break;
|
||||
default:
|
||||
MessageBox(nullptr, "Unsupported Color Depth!", "Error", 0);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
if (ddsd.lpSurface == nullptr)
|
||||
MessageBox(nullptr, "Returning NULL!!", "ok", 0);
|
||||
|
||||
surface = ddsd.lpSurface;
|
||||
state->SetSurface(surface, bitDepth, surfacePitch);
|
||||
|
||||
return Result(OK);
|
||||
}
|
||||
|
||||
int DirectX::UnlockSurface()
|
||||
{
|
||||
using namespace Detail;
|
||||
|
||||
HRESULT hr;
|
||||
hr = g_pDDSBack->Unlock(nullptr);
|
||||
surface = nullptr;
|
||||
if (FAILED(hr)) return Result(ERR_UNKNOWN);
|
||||
|
||||
return Result(OK);
|
||||
}
|
||||
|
||||
void DirectX::GetSurfaceArea(Rect* rect) const
|
||||
{
|
||||
rect->x = 0;
|
||||
rect->y = 0;
|
||||
rect->w = 640;
|
||||
rect->h = 480;
|
||||
}
|
||||
|
||||
void DirectX::GetDisplayArea(Rect* rect) const
|
||||
{
|
||||
using namespace Detail;
|
||||
rect->x = (float)ForcedAspectBorderPadding.x;
|
||||
rect->y = (float)ForcedAspectBorderPadding.y;
|
||||
rect->w = 640;
|
||||
rect->h = 480;
|
||||
}
|
||||
|
||||
void DirectX::CheckSurfaces() const
|
||||
{
|
||||
using namespace Detail;
|
||||
|
||||
if (g_pDDS) // Check the primary surface
|
||||
if (g_pDDS->IsLost() == DDERR_SURFACELOST)
|
||||
g_pDDS->Restore();
|
||||
|
||||
if (g_pDDSBack) // Check the back buffer
|
||||
if (g_pDDSBack->IsLost() == DDERR_SURFACELOST)
|
||||
g_pDDSBack->Restore();
|
||||
|
||||
}
|
||||
|
||||
int DirectX::RenderSignalLostMessage()
|
||||
{
|
||||
using namespace Detail;
|
||||
static unsigned short TextX = rand() % 580, TextY = rand() % 470;
|
||||
static unsigned char Counter, Counter1 = 32;
|
||||
static char Phase = 1;
|
||||
static char Message[] = " Signal Missing! Press F9";
|
||||
|
||||
HDC hdc;
|
||||
g_pDDSBack->GetDC(&hdc);
|
||||
SetBkColor(hdc, 0);
|
||||
SetTextColor(hdc, RGB(Counter1 << 2, Counter1 << 2, Counter1 << 2));
|
||||
TextOut(hdc, TextX, TextY, Message, strlen(Message));
|
||||
Counter++;
|
||||
Counter1 += Phase;
|
||||
if (Counter1 == 60 || Counter1 == 20)
|
||||
Phase = -Phase;
|
||||
Counter %= 60; //about 1 seconds
|
||||
if (!Counter)
|
||||
{
|
||||
TextX = rand() % 580;
|
||||
TextY = rand() % 470;
|
||||
}
|
||||
g_pDDSBack->ReleaseDC(hdc);
|
||||
return Result(OK);
|
||||
}
|
||||
|
||||
int DirectX::RenderStatusLine(char * statusText)
|
||||
{
|
||||
using namespace Detail;
|
||||
size_t Index = 0;
|
||||
HDC hdc;
|
||||
//Put StatusText for full screen here
|
||||
if (isFullscreen)
|
||||
{
|
||||
g_pDDSBack->GetDC(&hdc);
|
||||
SetBkColor(hdc, RGB(0, 0, 0));
|
||||
SetTextColor(hdc, RGB(255, 255, 255));
|
||||
Index = strlen(statusText);
|
||||
for (;Index < 132;Index++)
|
||||
statusText[Index] = 32;
|
||||
statusText[Index] = 0;
|
||||
TextOut(hdc, 0, 0, statusText, 132);
|
||||
g_pDDSBack->ReleaseDC(hdc);
|
||||
}
|
||||
return Result(OK);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // USE_DIRECTX
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
// Copyright 2015 by Joseph Forgion
|
||||
// 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// 2025/04/10 - Craig Allsop - Add OpenGL rendering.
|
||||
//
|
||||
|
||||
#include "../../src/core/IDisplay.h"
|
||||
#include "defines.h"
|
||||
|
||||
#if USE_DIRECTX
|
||||
|
||||
namespace VCC
|
||||
{
|
||||
struct DirectX : public IDisplayDirectX
|
||||
{
|
||||
enum
|
||||
{
|
||||
ERR_UNSUPPORTED = 100, // unsupported command
|
||||
ERR_BADOPTION, // invalid option being set
|
||||
ERR_WRONGMODE, // mode has changed
|
||||
ERR_CANTLOCK,
|
||||
ERR_UNKNOWN,
|
||||
};
|
||||
|
||||
explicit DirectX(ISystemState* state);
|
||||
|
||||
int Setup(void* hwnd, int width, int height, int statusHeight, bool fullscreen) override;
|
||||
int Render() override;
|
||||
int Present() override;
|
||||
int Cleanup() override;
|
||||
int SetOption(int flagOption, bool enabled) override;
|
||||
int GetSurface(Pixel** pixels) override;
|
||||
int GetRect(int rectOption, Rect* rect) override;
|
||||
int LockSurface() override;
|
||||
int UnlockSurface() override;
|
||||
void DebugDrawLine(float x1, float y1, float x2, float y2, Pixel color) override {};
|
||||
void DebugDrawBox(float x, float y, float w, float h, Pixel color, bool filled) override {};
|
||||
int RenderSignalLostMessage() override;
|
||||
int RenderStatusLine(char* statusText) override;
|
||||
|
||||
private:
|
||||
|
||||
ISystemState* state;
|
||||
|
||||
void GetDisplayArea(Rect* rect) const;
|
||||
void GetSurfaceArea(Rect* rect) const;
|
||||
void CheckSurfaces() const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // USE_DIRECTX
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,27 @@
|
||||
// Copyright 2015 by Joseph Forgion
|
||||
// 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// Disassembly Display - Part of the Debugger package for VCC
|
||||
// Author: Ed Jaquay
|
||||
|
||||
#pragma once
|
||||
#include <Windows.h>
|
||||
|
||||
namespace VCC {
|
||||
void OpenDisassemblerWindow(HINSTANCE instance, HWND parent);
|
||||
void ApplyHaltpoints(bool flag);
|
||||
void KillHaltpoints();
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,27 @@
|
||||
// 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/>.
|
||||
//
|
||||
// Execution Trace Display - Part of the Debugger package for VCC
|
||||
// Authors: Mike Rojas
|
||||
|
||||
#pragma once
|
||||
#include <Windows.h>
|
||||
|
||||
namespace VCC::Debugger::UI
|
||||
{
|
||||
|
||||
void OpenExecutionTraceWindow(HINSTANCE instance, HWND parent);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,356 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
// 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 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/>.
|
||||
//
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// This code is extracted from the standalone version of becker.dll with gui
|
||||
// deletions, changed external calls, and some variable name changes.
|
||||
//
|
||||
//---------------------------------------------------------------------------------
|
||||
//#define USE_LOGGING
|
||||
#define _WINSOCK_DEPRECATED_NO_WARNINGS
|
||||
|
||||
#include <WinSock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <Windows.h>
|
||||
#include <process.h>
|
||||
#include <stdio.h>
|
||||
#include <vcc/util/logger.h>
|
||||
#include "becker.h"
|
||||
|
||||
#define BUFFER_SIZE 512
|
||||
#define TCP_RETRY_DELAY 500
|
||||
#define STATS_PERIOD_MS 100
|
||||
|
||||
//------------------------------------------------------
|
||||
// Error returns from SOCKET dw_open(...)
|
||||
//------------------------------------------------------
|
||||
constexpr SOCKET SOCKET_RETRY = (SOCKET)-1;
|
||||
constexpr SOCKET SOCKET_FATAL = (SOCKET)-2;
|
||||
|
||||
//------------------------------------------------------
|
||||
// local functions
|
||||
//------------------------------------------------------
|
||||
void dw_open();
|
||||
void dw_close();
|
||||
SOCKET dw_open(const char *, const char *);
|
||||
unsigned char dw_status();
|
||||
unsigned char dw_read();
|
||||
int dw_write(char);
|
||||
unsigned __stdcall dw_thread(void *);
|
||||
|
||||
//------------------------------------------------------
|
||||
// globals
|
||||
//------------------------------------------------------
|
||||
|
||||
static SOCKET dwSocket = 0;
|
||||
static bool dwEnabled = false;
|
||||
static HANDLE hDWTCPThread;
|
||||
|
||||
// are we retrying tcp conn
|
||||
static bool retry = false;
|
||||
|
||||
// circular buffer for socket io
|
||||
static char InBuffer[BUFFER_SIZE];
|
||||
static int InReadPos = 0;
|
||||
static int InWritePos = 0;
|
||||
|
||||
// hostname and port
|
||||
static char dwaddress[MAX_PATH] = {};
|
||||
static char dwsport[16] = "65504";
|
||||
static char curaddress[MAX_PATH] = {};
|
||||
static char curport[16] = "65504";
|
||||
|
||||
// statistics
|
||||
static int BytesWrittenSince = 0;
|
||||
static int BytesReadSince = 0;
|
||||
static DWORD LastStats;
|
||||
static float ReadSpeed = 0;
|
||||
static float WriteSpeed = 0;
|
||||
|
||||
//------------------------------------------------------
|
||||
// Set becker server address and port
|
||||
// Should default to "127.0.0.1" and "65504"
|
||||
//------------------------------------------------------
|
||||
|
||||
int becker_sethost(const char *bufdwaddr, const char *bufdwport)
|
||||
{
|
||||
strcpy(dwaddress,bufdwaddr);
|
||||
strcpy(dwsport,bufdwport);
|
||||
|
||||
if (strcmp(dwsport,curport) !=0 || (strcmp(dwaddress,curaddress) != 0))
|
||||
dw_close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// enable or disable becker port
|
||||
//------------------------------------------------------
|
||||
void becker_enable(bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
if (!dwEnabled) {
|
||||
|
||||
// reset buffer pointers
|
||||
InReadPos = 0;
|
||||
InWritePos = 0;
|
||||
|
||||
// start create thread to handle io
|
||||
HANDLE hEvent;
|
||||
|
||||
unsigned threadID;
|
||||
|
||||
hEvent = CreateEvent( nullptr, FALSE, FALSE, nullptr ) ;
|
||||
|
||||
if (hEvent==nullptr) {
|
||||
DLOG_C("Cannot create DWTCPConnection thread!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// start it up...
|
||||
hDWTCPThread = (HANDLE)_beginthreadex
|
||||
( nullptr, 0, &dw_thread, hEvent, 0, &threadID );
|
||||
|
||||
if (hDWTCPThread==nullptr) {
|
||||
DLOG_C("Cannot start DWTCPConnection thread!\n");
|
||||
return;
|
||||
}
|
||||
dwEnabled = true;
|
||||
DLOG_C("DWTCPConnection thread started with id %d\n",threadID);
|
||||
}
|
||||
} else {
|
||||
dw_close();
|
||||
dwEnabled = false;
|
||||
DLOG_C("DWTCPConnection has been disabled.\n");
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// write becker port
|
||||
//------------------------------------------------------
|
||||
void becker_write(unsigned char data,unsigned short port)
|
||||
{
|
||||
if (port == 0x42)
|
||||
dw_write(data);
|
||||
return;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// read becker port
|
||||
//------------------------------------------------------
|
||||
unsigned char becker_read(unsigned short port)
|
||||
{
|
||||
switch (port) {
|
||||
// read status
|
||||
case 0x41:
|
||||
if (dw_status() != 0)
|
||||
return 2;
|
||||
else
|
||||
return 0;
|
||||
// read data
|
||||
case 0x42:
|
||||
return(dw_read());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// get drivewire status for status line
|
||||
//------------------------------------------------------
|
||||
void becker_status(char *DWStatus)
|
||||
{
|
||||
if (dwEnabled) {
|
||||
// calculate speed
|
||||
DWORD sinceCalc = GetTickCount() - LastStats;
|
||||
if (sinceCalc > STATS_PERIOD_MS) {
|
||||
LastStats += sinceCalc;
|
||||
ReadSpeed = 8.0f * (BytesReadSince / (1000.0f - sinceCalc));
|
||||
WriteSpeed = 8.0f * (BytesWrittenSince / (1000.0f - sinceCalc));
|
||||
BytesReadSince = 0;
|
||||
BytesWrittenSince = 0;
|
||||
}
|
||||
if (retry) {
|
||||
sprintf(DWStatus,"DW %s?", curaddress);
|
||||
} else if (dwSocket == 0) {
|
||||
sprintf(DWStatus,"DW ConError");
|
||||
} else {
|
||||
sprintf(DWStatus,"DW OK R:%04.1f W:%04.1f", ReadSpeed , WriteSpeed);
|
||||
}
|
||||
} else {
|
||||
sprintf(DWStatus,"");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// Internal functions
|
||||
//------------------------------------------------------
|
||||
|
||||
// coco checks for data
|
||||
unsigned char dw_status( void )
|
||||
{
|
||||
// check for input data waiting
|
||||
if (retry | (dwSocket == 0) | (InReadPos == InWritePos))
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
// coco reads a byte
|
||||
unsigned char dw_read( void )
|
||||
{
|
||||
// increment buffer read pos, return next byte
|
||||
unsigned char dwdata = InBuffer[InReadPos];
|
||||
InReadPos++;
|
||||
if (InReadPos == BUFFER_SIZE) InReadPos = 0;
|
||||
BytesReadSince++;
|
||||
return dwdata;
|
||||
}
|
||||
|
||||
// coco writes a byte
|
||||
int dw_write( char dwdata)
|
||||
{
|
||||
// send the byte if we're connected
|
||||
if ((dwSocket != 0) & (!retry)) {
|
||||
int res = send(dwSocket, &dwdata, 1, 0);
|
||||
if (res != 1) {
|
||||
DLOG_C("dw_write socket error %d\n", WSAGetLastError());
|
||||
closesocket(dwSocket);
|
||||
dwSocket = 0;
|
||||
} else {
|
||||
BytesWrittenSince++;
|
||||
}
|
||||
|
||||
} else {
|
||||
DLOG_C("dw_write null socket\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dw_close()
|
||||
{
|
||||
// close socket to cause io thread to die
|
||||
DLOG_C("dw_close\n");
|
||||
if (dwSocket != 0) closesocket(dwSocket);
|
||||
dwSocket = 0;
|
||||
InReadPos = 0;
|
||||
InWritePos = 0;
|
||||
hDWTCPThread = nullptr;
|
||||
}
|
||||
|
||||
// try to connect with DW server
|
||||
void dw_open( void )
|
||||
{
|
||||
DLOG_C("dw_open %s:%d\n",dwaddress,dwsport);
|
||||
dwSocket = dw_open(dwaddress,dwsport);
|
||||
if (dwSocket == SOCKET_RETRY) {
|
||||
retry = true;
|
||||
dwSocket = 0;
|
||||
} else if (dwSocket == SOCKET_FATAL) {
|
||||
retry = false;
|
||||
dwSocket = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Override for dw_open(void) replaces gethostbyname with getaddrinfo
|
||||
SOCKET dw_open(const char * server, const char * port)
|
||||
{
|
||||
struct addrinfo hints;
|
||||
ZeroMemory(&hints, sizeof(hints));
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
|
||||
struct addrinfo *result = nullptr;
|
||||
if (getaddrinfo(server, port, &hints, &result) != 0)
|
||||
return SOCKET_FATAL;
|
||||
|
||||
SOCKET s = SOCKET_RETRY;
|
||||
for (auto p = result; p != nullptr; p = p->ai_next) {
|
||||
s = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
|
||||
if (s == INVALID_SOCKET) {
|
||||
freeaddrinfo(result);
|
||||
return SOCKET_FATAL;
|
||||
}
|
||||
if (connect(s, p->ai_addr, p->ai_addrlen) != 0) {
|
||||
closesocket(s);
|
||||
s = SOCKET_RETRY;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
freeaddrinfo(result);
|
||||
return s;
|
||||
}
|
||||
|
||||
// TCP connection thread
|
||||
unsigned __stdcall dw_thread(void* /*Dummy*/)
|
||||
{
|
||||
DLOG_C("dw_thread %d\n",dwEnabled);
|
||||
WSADATA wsaData;
|
||||
|
||||
int sz;
|
||||
int res;
|
||||
|
||||
if (dwEnabled) {
|
||||
// Request Winsock version 2.2
|
||||
if ((WSAStartup(0x202, &wsaData)) != 0) {
|
||||
DLOG_C("dw_thread winsock startup failed, exiting\n");
|
||||
WSACleanup();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
while(dwEnabled) {
|
||||
// get connected
|
||||
dw_open();
|
||||
|
||||
// keep trying...
|
||||
while ((dwSocket == 0) & dwEnabled) {
|
||||
dw_open();
|
||||
// after 2 tries, sleep between attempts
|
||||
Sleep(TCP_RETRY_DELAY);
|
||||
}
|
||||
|
||||
while ((dwSocket != 0) & dwEnabled) {
|
||||
// we have a connection, read as much as possible.
|
||||
if (InReadPos > InWritePos)
|
||||
sz = InReadPos - InWritePos;
|
||||
else
|
||||
sz = BUFFER_SIZE - InWritePos;
|
||||
|
||||
// read the data
|
||||
res = recv(dwSocket,(char *)InBuffer + InWritePos, sz, 0);
|
||||
|
||||
if (res < 1) {
|
||||
// no good, bail out
|
||||
closesocket(dwSocket);
|
||||
dwSocket = 0;
|
||||
} else {
|
||||
// good recv, inc ptr
|
||||
InWritePos += res;
|
||||
if (InWritePos == BUFFER_SIZE) InWritePos = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Not enabled - close socket if necessary
|
||||
if (dwSocket != 0) closesocket(dwSocket);
|
||||
|
||||
dwSocket = 0;
|
||||
|
||||
_endthreadex(0);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef __BECKER_H__
|
||||
#define __BECKER_H__
|
||||
|
||||
void becker_enable(bool); // enable or disable
|
||||
int becker_sethost(const char *, const char *); // server ip address, port
|
||||
unsigned char becker_read(unsigned short); // coco port
|
||||
void becker_write(unsigned char,unsigned short); // value, coco port
|
||||
void becker_status(char *); // becker status for status line
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef __DEFINES_H__
|
||||
#define __DEFINES_H__
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
// FIXME: These are duplicates from the defines.h file in vcc and should be consolidates.
|
||||
constexpr auto TARGETFRAMERATE = 60u;
|
||||
constexpr auto LINESPERFIELD = 262u;
|
||||
constexpr auto QUERY = 255u;
|
||||
constexpr auto INDEXTIME = LINESPERFIELD * TARGETFRAMERATE / 5;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
#include <Windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "distortc.h"
|
||||
|
||||
/* Table description: Bit3 Bit2 Bit1 Bit0
|
||||
Write to $FF51 read from $FF50
|
||||
0x00 1-second digit register S8 S4 S2 S1
|
||||
0x01 10-second digit register x S40 S20 S10
|
||||
0x02 1-minute digit register Mi8 Mi4 Mi2 Mi1
|
||||
0x03 10-minute digit register x Mi40 Mi20 Mi10
|
||||
0x04 1-hour digit register H8 H4 H2 H1
|
||||
0x05 PM/AM, 10-hour digit register x P/A H20 H10
|
||||
0x06 1-day digit register D8 D4 D2 D1
|
||||
0x07 10-day digit register x x D20 D10
|
||||
0x08 1-month digit register Mo8 Mo4 Mo2 Mo1
|
||||
0x09 10-month digit register Mo80 Mo40 Mo20 Mo10
|
||||
0x0A 1-year digit register Y8 Y4 Y2 Y1
|
||||
0x0B 10-yead digit register Y80 Y40 Y20 Y10
|
||||
0x0C Week register x W4 W2 W1
|
||||
|
||||
30
|
||||
0x0D Control register D Sec IRQ Busy Hold
|
||||
adj Flag
|
||||
ITRP
|
||||
0x0E Control register E T1 T0 /STND Mask
|
||||
|
||||
|
||||
0x0F Control register F Test 24/12 Stop Rest
|
||||
|
||||
|
||||
Note: Digits are BDC. Registers only four bits wide.
|
||||
X denotes 'not used'
|
||||
*/
|
||||
static unsigned char time_register=0;
|
||||
static SYSTEMTIME now;
|
||||
static unsigned char Hour12=0;
|
||||
|
||||
unsigned char read_time(unsigned short port)
|
||||
{
|
||||
unsigned char ret_val=0;
|
||||
if (port == 0x50)
|
||||
{
|
||||
GetLocalTime(&now);
|
||||
switch (time_register)
|
||||
{
|
||||
|
||||
case 0:
|
||||
ret_val= now.wSecond % 10;
|
||||
break;
|
||||
case 1:
|
||||
ret_val= now.wSecond / 10;
|
||||
break;
|
||||
case 2:
|
||||
ret_val = now.wMinute % 10;
|
||||
break;
|
||||
case 3:
|
||||
ret_val = now.wMinute / 10;
|
||||
break;
|
||||
case 4:
|
||||
ret_val = now.wHour % 10;
|
||||
break;
|
||||
case 5:
|
||||
ret_val = now.wHour / 10;
|
||||
|
||||
break;
|
||||
case 6:
|
||||
ret_val = now.wDay % 10;
|
||||
break;
|
||||
case 7:
|
||||
ret_val = now.wDay /10;
|
||||
break;
|
||||
case 8:
|
||||
ret_val = now.wMonth % 10;
|
||||
break;
|
||||
case 9:
|
||||
ret_val = now.wMonth /10 ;
|
||||
break;
|
||||
case 0xA:
|
||||
ret_val = now.wYear%10;
|
||||
break;
|
||||
case 0xB:
|
||||
ret_val = (now.wYear%100)/10;
|
||||
break;
|
||||
case 0xC:
|
||||
ret_val=(unsigned char)now.wDayOfWeek; //May not be right
|
||||
break;
|
||||
case 0xD:
|
||||
|
||||
break;
|
||||
case 0xE:
|
||||
|
||||
break;
|
||||
case 0xF:
|
||||
// Hour12
|
||||
break;
|
||||
default:
|
||||
ret_val=0;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
void write_time(unsigned char data,unsigned char port)
|
||||
{
|
||||
switch (port)
|
||||
{
|
||||
case 0x50:
|
||||
switch (time_register)
|
||||
{
|
||||
case 0x0F:
|
||||
Hour12=!((data & 4)>>2);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x51:
|
||||
time_register=(data & 0xF);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef __DISTORTC_H__
|
||||
#define __DISTORTC_H__
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
unsigned char read_time(unsigned short);
|
||||
void write_time(unsigned char,unsigned char);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,785 @@
|
||||
//#define USE_LOGGING
|
||||
//======================================================================
|
||||
// This file is part of VCC (Virtual Color Computer).
|
||||
// Vcc is Copyright 2015 by Joseph Forgione
|
||||
//
|
||||
// VCC (Virtual Color Computer) is free software, you can redistribute
|
||||
// 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/>.
|
||||
//
|
||||
//======================================================================
|
||||
|
||||
/********************************************************************************************
|
||||
* fd502.cpp : Defines the entry point for the DLL application. *
|
||||
* DLL for use with Vcc 1.0 or higher. DLL interface 1.0 Beta *
|
||||
* This Module will emulate a Tandy Floppy Disk Model FD-502 With 3 DSDD drives attached *
|
||||
* Copyright 2006 (c) by Joseph Forgione *
|
||||
*********************************************************************************************/
|
||||
|
||||
#pragma warning( disable : 4800 ) // For legacy builds
|
||||
|
||||
#include <Windows.h>
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include "resource.h"
|
||||
#include "wd1793.h"
|
||||
#include "distortc.h"
|
||||
#include "fd502.h"
|
||||
#include <vcc/util/limits.h>
|
||||
#include <vcc/util/FileOps.h>
|
||||
#include <vcc/util/DialogOps.h>
|
||||
#include <vcc/util/logger.h>
|
||||
// Three includes added for PakGetMenuItem
|
||||
#include <vcc/bus/cartridge_menu.h>
|
||||
#include <vcc/bus/cartridge_messages.h>
|
||||
#include <vcc/util/fileutil.h>
|
||||
|
||||
//include becker code if COMBINE_BECKER is defined in fd502.h
|
||||
#ifdef COMBINE_BECKER
|
||||
#include "becker.h"
|
||||
#endif
|
||||
|
||||
// Settings module groups used
|
||||
const std::string MS_FD502 = "FD-502";
|
||||
const std::string MS_BECKER = "DW Becker";
|
||||
const std::string MS_PATHS = "DefaultPaths";
|
||||
|
||||
constexpr auto EXTROMSIZE = 16384u;
|
||||
|
||||
using namespace std;
|
||||
|
||||
extern DiskInfo gVirtualDrive[5];
|
||||
static unsigned char ExternalRom[EXTROMSIZE];
|
||||
static unsigned char DiskRom[EXTROMSIZE];
|
||||
static unsigned char RGBDiskRom[EXTROMSIZE];
|
||||
static char FloppyPath[MAX_PATH];
|
||||
static char RomFileName[MAX_PATH]="";
|
||||
static char TempRomFileName[MAX_PATH]="";
|
||||
slot_id_type gSlotId {};
|
||||
PakAssertInteruptHostCallback AssertInt = nullptr;
|
||||
unsigned char PhysicalDriveA=0,PhysicalDriveB=0,OldPhysicalDriveA=0,OldPhysicalDriveB=0;
|
||||
static unsigned char *RomPointer[3]={ExternalRom,DiskRom,RGBDiskRom};
|
||||
static unsigned char SelectRom=0;
|
||||
unsigned char SetChip(unsigned char);
|
||||
static unsigned char NewDiskNumber=0,CreateFlag=0;
|
||||
static unsigned char PersistDisks=0;
|
||||
static unsigned char TempSelectRom=0;
|
||||
static unsigned char ClockEnabled=1;
|
||||
LRESULT CALLBACK Config(HWND, UINT, WPARAM, LPARAM);
|
||||
LRESULT CALLBACK NewDisk(HWND,UINT, WPARAM, LPARAM);
|
||||
void LoadConfig();
|
||||
void SaveConfig();
|
||||
long CreateDiskHeader(const char *,unsigned char,unsigned char,unsigned char);
|
||||
void Unload_Disk(unsigned char);
|
||||
void Load_Disk(unsigned char);
|
||||
|
||||
static HWND g_hConfDlg = nullptr;
|
||||
static HINSTANCE gModuleInstance;
|
||||
static unsigned long RealDisks=0;
|
||||
long CreateDisk (unsigned char);
|
||||
static char gSelectedDiskFile[MAX_PATH]="";
|
||||
unsigned char LoadExtRom( unsigned char, const char *);
|
||||
|
||||
// Added for PakGetMenuItem export
|
||||
bool get_menu_item(menu_item_entry*, size_t index);
|
||||
|
||||
int BeckerEnabled=0;
|
||||
char BeckerAddr[MAX_PATH]="";
|
||||
char BeckerPort[32]="";
|
||||
|
||||
// Added for PakGetMenuItem export
|
||||
static HWND gVccWnd = nullptr;
|
||||
static VCC::Util::settings* gpSettings = nullptr; // Pointer to settings object
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
extern "C"
|
||||
{
|
||||
|
||||
__declspec(dllexport) const char* PakGetName()
|
||||
{
|
||||
static char string_buffer[MAX_LOADSTRING];
|
||||
|
||||
LoadString(gModuleInstance, IDS_MODULE_NAME, string_buffer, MAX_LOADSTRING);
|
||||
|
||||
return string_buffer;
|
||||
}
|
||||
|
||||
__declspec(dllexport) const char* PakGetCatalogId()
|
||||
{
|
||||
static char string_buffer[MAX_LOADSTRING];
|
||||
|
||||
LoadString(gModuleInstance, IDS_CATNUMBER, string_buffer, MAX_LOADSTRING);
|
||||
|
||||
return string_buffer;
|
||||
}
|
||||
|
||||
__declspec(dllexport) const char* PakGetDescription()
|
||||
{
|
||||
static char string_buffer[MAX_LOADSTRING];
|
||||
|
||||
LoadString(gModuleInstance, IDS_DESCRIPTION, string_buffer, MAX_LOADSTRING);
|
||||
|
||||
return string_buffer;
|
||||
}
|
||||
|
||||
__declspec(dllexport) void PakInitialize(
|
||||
slot_id_type SlotId,
|
||||
const char* const configuration_path,
|
||||
HWND hVccWnd,
|
||||
const cpak_callbacks* const callbacks)
|
||||
{
|
||||
DLOG_C("fd502 callbacks write=%p cart=%p read=%p int=%p\n",
|
||||
callbacks->write_memory_byte,
|
||||
callbacks->assert_cartridge_line,
|
||||
callbacks->read_memory_byte,
|
||||
callbacks->assert_interrupt);
|
||||
gSlotId = SlotId;
|
||||
gVccWnd = hVccWnd;
|
||||
AssertInt = callbacks->assert_interrupt;
|
||||
// Must create settings object before LoadConfig
|
||||
gpSettings = new VCC::Util::settings(configuration_path);
|
||||
RealDisks = InitController();
|
||||
LoadConfig();
|
||||
SendMessage(gVccWnd,WM_VCC_UPD_MENU,(WPARAM) 0,(LPARAM) 0);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void PakReset()
|
||||
{
|
||||
LoadExtRom(External,RomFileName);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void PakTerminate()
|
||||
{
|
||||
#ifdef COMBINE_BECKER
|
||||
becker_enable(0);
|
||||
#endif
|
||||
CloseCartDialog(g_hConfDlg);
|
||||
for (unsigned char dnum = 0; dnum <= 3; dnum++)
|
||||
{
|
||||
unmount_disk_image(dnum);
|
||||
}
|
||||
}
|
||||
|
||||
//PakGetMenuItem export
|
||||
__declspec(dllexport) bool PakGetMenuItem(menu_item_entry* item, size_t index)
|
||||
{
|
||||
return get_menu_item(item, index);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void PakMenuItemClicked(unsigned char MenuID)
|
||||
{
|
||||
HWND h_own = GetActiveWindow();
|
||||
switch (MenuID)
|
||||
{
|
||||
case 10:
|
||||
Load_Disk(0);
|
||||
break;
|
||||
case 11:
|
||||
Unload_Disk(0);
|
||||
break;
|
||||
case 12:
|
||||
Load_Disk(1);
|
||||
break;
|
||||
case 13:
|
||||
Unload_Disk(1);
|
||||
break;
|
||||
case 14:
|
||||
Load_Disk(2);
|
||||
break;
|
||||
case 15:
|
||||
Unload_Disk(2);
|
||||
break;
|
||||
case 17:
|
||||
Load_Disk(3);
|
||||
break;
|
||||
case 18:
|
||||
Unload_Disk(3);
|
||||
break;
|
||||
case 16:
|
||||
if (g_hConfDlg == nullptr)
|
||||
g_hConfDlg = CreateDialog(
|
||||
gModuleInstance,(LPCTSTR)IDD_CONFIG,h_own,(DLGPROC)Config);
|
||||
ShowWindow(g_hConfDlg,1);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
__declspec(dllexport) void PakWritePort(unsigned char Port,unsigned char Data)
|
||||
{
|
||||
#ifdef COMBINE_BECKER
|
||||
if (BeckerEnabled && (Port == 0x42)) {
|
||||
becker_write(Data,Port);
|
||||
} else //if ( ((Port == 0x50) | (Port==0x51)) & ClockEnabled) {
|
||||
#endif
|
||||
if ( ((Port == 0x50) | (Port==0x51)) & ClockEnabled) {
|
||||
write_time(Data,Port);
|
||||
} else {
|
||||
disk_io_write(Data,Port);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
__declspec(dllexport) unsigned char PakReadPort(unsigned char Port)
|
||||
{
|
||||
#ifdef COMBINE_BECKER
|
||||
if (BeckerEnabled && ((Port == 0x41) | (Port== 0x42 )))
|
||||
return(becker_read(Port));
|
||||
#endif
|
||||
if ( ((Port == 0x50) | (Port== 0x51 )) & ClockEnabled)
|
||||
return(read_time(Port));
|
||||
return(disk_io_read(Port));
|
||||
}
|
||||
|
||||
__declspec(dllexport) void PakProcessHorizontalSync()
|
||||
{
|
||||
PingFdc();
|
||||
return;
|
||||
}
|
||||
|
||||
__declspec(dllexport) unsigned char PakReadMemoryByte(unsigned short Address)
|
||||
{
|
||||
return(RomPointer[SelectRom][Address & (EXTROMSIZE-1)]);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void PakGetStatus(char* text_buffer, size_t buffer_size)
|
||||
{
|
||||
char diskstat[64];
|
||||
DiskStatus(diskstat, sizeof(diskstat));
|
||||
strcpy(text_buffer,diskstat);
|
||||
#ifdef COMBINE_BECKER
|
||||
char beckerstat[64];
|
||||
if(BeckerEnabled) {
|
||||
becker_status(beckerstat);
|
||||
strcat(text_buffer," | ");
|
||||
strcat(text_buffer,beckerstat);
|
||||
}
|
||||
#endif
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(
|
||||
HINSTANCE hinstDLL, // handle to DLL module
|
||||
DWORD reason, // reason for calling function
|
||||
LPVOID lpReserved ) // reserved
|
||||
{
|
||||
if (reason == DLL_PROCESS_ATTACH) {
|
||||
gModuleInstance = hinstDLL;
|
||||
} else if (reason == DLL_PROCESS_DETACH) {
|
||||
PakTerminate();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK Config(HWND hDlg, UINT message, WPARAM wParam, LPARAM /*lParam*/)
|
||||
{
|
||||
static unsigned char temp=0,temp2=0;
|
||||
long ChipChoice[3]={IDC_EXTROM,IDC_TRSDOS,IDC_RGB};
|
||||
long gVirtualDrive[2]={IDC_DISKA,IDC_DISKB};
|
||||
char VirtualNames[5][16]={"None","Drive 0","Drive 1","Drive 2","Drive 3"};
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_CLOSE:
|
||||
DestroyWindow(hDlg);
|
||||
g_hConfDlg = nullptr;
|
||||
return TRUE;
|
||||
|
||||
case WM_INITDIALOG:
|
||||
CenterDialog(hDlg);
|
||||
TempSelectRom=SelectRom;
|
||||
if (!RealDisks)
|
||||
{
|
||||
EnableWindow(GetDlgItem(hDlg, IDC_DISKA), FALSE);
|
||||
EnableWindow(GetDlgItem(hDlg, IDC_DISKB), FALSE);
|
||||
PhysicalDriveA=0;
|
||||
PhysicalDriveB=0;
|
||||
}
|
||||
SendDlgItemMessage(hDlg,IDC_CLOCK,BM_SETCHECK,ClockEnabled,0);
|
||||
OldPhysicalDriveA=PhysicalDriveA;
|
||||
OldPhysicalDriveB=PhysicalDriveB;
|
||||
strcpy(TempRomFileName,RomFileName);
|
||||
SendDlgItemMessage(hDlg,IDC_TURBO,BM_SETCHECK,SetTurboDisk(QUERY),0);
|
||||
SendDlgItemMessage(hDlg,IDC_PERSIST,BM_SETCHECK,PersistDisks,0);
|
||||
for (temp=0;temp<sizeof(ChipChoice) / sizeof(*ChipChoice);temp++)
|
||||
SendDlgItemMessage(hDlg,ChipChoice[temp],BM_SETCHECK,(temp==TempSelectRom),0);
|
||||
for (temp=0;temp<2;temp++)
|
||||
for (temp2=0;temp2<5;temp2++)
|
||||
SendDlgItemMessage (hDlg,gVirtualDrive[temp], CB_ADDSTRING, 0, (LPARAM) VirtualNames[temp2]);
|
||||
|
||||
SendDlgItemMessage (hDlg, IDC_DISKA,CB_SETCURSEL,(WPARAM)PhysicalDriveA,(LPARAM)0);
|
||||
SendDlgItemMessage (hDlg, IDC_DISKB,CB_SETCURSEL,(WPARAM)PhysicalDriveB,(LPARAM)0);
|
||||
SendDlgItemMessage (hDlg,IDC_ROMPATH,WM_SETTEXT,0,(LPARAM)(LPCSTR)TempRomFileName);
|
||||
|
||||
SendDlgItemMessage (hDlg,IDC_BECKER_ENAB,BM_SETCHECK,BeckerEnabled,0);
|
||||
SendDlgItemMessage (hDlg,IDC_BECKER_HOST,WM_SETTEXT,0,(LPARAM)(LPSTR)BeckerAddr);
|
||||
SendDlgItemMessage (hDlg,IDC_BECKER_PORT,WM_SETTEXT,0,(LPARAM)(LPCSTR)BeckerPort);
|
||||
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
ClockEnabled=(unsigned char)SendDlgItemMessage(hDlg,IDC_CLOCK,BM_GETCHECK,0,0);
|
||||
SetTurboDisk((unsigned char)SendDlgItemMessage(hDlg,IDC_TURBO,BM_GETCHECK,0,0));
|
||||
PersistDisks=(unsigned char) SendDlgItemMessage(hDlg,IDC_PERSIST,BM_GETCHECK,0,0);
|
||||
PhysicalDriveA=(unsigned char)SendDlgItemMessage(hDlg,IDC_DISKA,CB_GETCURSEL,0,0);
|
||||
PhysicalDriveB=(unsigned char)SendDlgItemMessage(hDlg,IDC_DISKB,CB_GETCURSEL,0,0);
|
||||
if (!RealDisks)
|
||||
{
|
||||
PhysicalDriveA=0;
|
||||
PhysicalDriveB=0;
|
||||
// MessageBox(0,"Wrong Version or Driver not installed","FDRAWCMD Driver",0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PhysicalDriveA != OldPhysicalDriveA) //Drive changed
|
||||
{
|
||||
if (OldPhysicalDriveA!=0)
|
||||
unmount_disk_image(OldPhysicalDriveA-1);
|
||||
if (PhysicalDriveA!=0)
|
||||
mount_disk_image("*Floppy A:",PhysicalDriveA-1);
|
||||
}
|
||||
if (PhysicalDriveB != OldPhysicalDriveB) //Drive changed
|
||||
{
|
||||
if (OldPhysicalDriveB!=0)
|
||||
unmount_disk_image(OldPhysicalDriveB-1);
|
||||
if (PhysicalDriveB!=0)
|
||||
mount_disk_image("*Floppy B:",PhysicalDriveB-1);
|
||||
}
|
||||
}
|
||||
SelectRom=TempSelectRom;
|
||||
strcpy(RomFileName,TempRomFileName );
|
||||
CheckPath(RomFileName);
|
||||
LoadExtRom(External,RomFileName); //JF
|
||||
#ifdef COMBINE_BECKER
|
||||
GetDlgItemText(hDlg,IDC_BECKER_HOST,BeckerAddr,MAX_PATH);
|
||||
GetDlgItemText(hDlg,IDC_BECKER_PORT,BeckerPort,32);
|
||||
becker_sethost(BeckerAddr,BeckerPort);
|
||||
BeckerEnabled = SendDlgItemMessage (hDlg,IDC_BECKER_ENAB,BM_GETCHECK,0,0);
|
||||
becker_enable(BeckerEnabled);
|
||||
#endif
|
||||
SaveConfig();
|
||||
DestroyWindow(hDlg);
|
||||
g_hConfDlg = nullptr;
|
||||
return TRUE;
|
||||
|
||||
case IDC_EXTROM:
|
||||
case IDC_TRSDOS:
|
||||
case IDC_RGB:
|
||||
for (temp=0;temp<sizeof(ChipChoice) / sizeof(*ChipChoice);temp++)
|
||||
if (LOWORD(wParam)==ChipChoice[temp])
|
||||
{
|
||||
for (temp2=0;temp2<sizeof(ChipChoice) / sizeof(*ChipChoice);temp2++)
|
||||
SendDlgItemMessage(hDlg,ChipChoice[temp2],BM_SETCHECK,0,0);
|
||||
SendDlgItemMessage(hDlg,ChipChoice[temp],BM_SETCHECK,1,0);
|
||||
TempSelectRom=temp;
|
||||
}
|
||||
break;
|
||||
case IDC_BROWSE:
|
||||
{
|
||||
char dir[MAX_PATH];
|
||||
strncpy(dir,TempRomFileName,MAX_PATH);
|
||||
if (char * p = strrchr(dir,'\\')) *p = '\0';
|
||||
|
||||
FileDialog dlg;
|
||||
dlg.setFilter("Disk Rom Images\0*.rom;\0All files\0*.*\0\0");
|
||||
dlg.setTitle("Select Disk Rom Image");
|
||||
dlg.setInitialDir(dir);
|
||||
if (dlg.show(0,g_hConfDlg)) {
|
||||
dlg.getpath(TempRomFileName,MAX_PATH);
|
||||
SendDlgItemMessage
|
||||
(hDlg,IDC_ROMPATH,WM_SETTEXT,0,(LPARAM)dlg.path());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_CLOCK:
|
||||
case IDC_READONLY:
|
||||
break;
|
||||
|
||||
case IDCANCEL:
|
||||
DestroyWindow(hDlg);
|
||||
g_hConfDlg = nullptr;
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Access the settings object
|
||||
VCC::Util::settings& Setting()
|
||||
{
|
||||
return *gpSettings;
|
||||
}
|
||||
|
||||
void Unload_Disk(unsigned char disk) {
|
||||
unmount_disk_image(disk);
|
||||
SendMessage(gVccWnd,WM_VCC_UPD_MENU,(WPARAM) 0,(LPARAM) 0);
|
||||
SaveConfig();
|
||||
}
|
||||
|
||||
void Load_Disk(unsigned char disk)
|
||||
{
|
||||
HWND h_own = GetActiveWindow();
|
||||
FileDialog dlg;
|
||||
dlg.setInitialDir(FloppyPath);
|
||||
dlg.setFilter("Disk Images\0*.dsk;*.os9\0\0");
|
||||
dlg.setDefExt("dsk");
|
||||
dlg.setTitle("Insert Disk Image");
|
||||
dlg.setFlags(OFN_PATHMUSTEXIST);
|
||||
if (dlg.show(0,h_own)) {
|
||||
CreateFlag = 1;
|
||||
HANDLE hr = nullptr;
|
||||
dlg.getpath(gSelectedDiskFile,MAX_PATH);
|
||||
// Verify file exists
|
||||
hr = CreateFile
|
||||
(gSelectedDiskFile,0,FILE_SHARE_READ,nullptr,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,nullptr);
|
||||
// Create new disk file if it does not
|
||||
if (hr == INVALID_HANDLE_VALUE) {
|
||||
NewDiskNumber = disk;
|
||||
//DialogBox will set CreateFlag = 0 on cancel
|
||||
DialogBox(gModuleInstance, (LPCTSTR)IDD_NEWDISK, h_own, (DLGPROC)NewDisk);
|
||||
} else {
|
||||
CloseHandle(hr);
|
||||
}
|
||||
// Attempt mount if file existed or file create was not canceled
|
||||
if (CreateFlag==1) {
|
||||
if (mount_disk_image(gSelectedDiskFile,disk)==0) {
|
||||
MessageBox(g_hConfDlg,"Can't open file","Error",0);
|
||||
} else {
|
||||
dlg.getdir(FloppyPath);
|
||||
SendMessage(gVccWnd,WM_VCC_UPD_MENU,(WPARAM) 0,(LPARAM) 0);
|
||||
SaveConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char SetChip(unsigned char Tmp)
|
||||
{
|
||||
if (Tmp!=QUERY)
|
||||
SelectRom=Tmp;
|
||||
return SelectRom;
|
||||
}
|
||||
|
||||
// Added for PakGetMenuItem export
|
||||
// Return items for cartridge menu. Called for each item
|
||||
bool get_menu_item(menu_item_entry* item, size_t index)
|
||||
{
|
||||
using VCC::Bus::gDllCartMenu;
|
||||
std::string disk;
|
||||
if (!item) return false;
|
||||
// request zero rebuilds the menu list
|
||||
if (index == 0) {
|
||||
gDllCartMenu.clear();
|
||||
gDllCartMenu.add("", 0, MIT_Seperator);
|
||||
gDllCartMenu.add("FD-502 Drive 0",0,MIT_Head);
|
||||
gDllCartMenu.add("Insert",ControlId(10),MIT_Slave);
|
||||
disk = VCC::Util::GetFileNamePart(gVirtualDrive[0].ImageName);
|
||||
gDllCartMenu.add("Eject: "+disk,ControlId(11),MIT_Slave);
|
||||
gDllCartMenu.add("FD-502 Drive 1",0,MIT_Head);
|
||||
gDllCartMenu.add("Insert",ControlId(12),MIT_Slave);
|
||||
disk = VCC::Util::GetFileNamePart(gVirtualDrive[1].ImageName);
|
||||
gDllCartMenu.add("Eject: "+disk,ControlId(13),MIT_Slave);
|
||||
gDllCartMenu.add("FD-502 Drive 2",0,MIT_Head);
|
||||
gDllCartMenu.add("Insert",ControlId(14),MIT_Slave);
|
||||
disk = VCC::Util::GetFileNamePart(gVirtualDrive[2].ImageName);
|
||||
gDllCartMenu.add("Eject: "+disk,ControlId(15),MIT_Slave);
|
||||
gDllCartMenu.add("FD-502 Drive 3",0,MIT_Head);
|
||||
gDllCartMenu.add("Insert",ControlId(17),MIT_Slave);
|
||||
disk = VCC::Util::GetFileNamePart(gVirtualDrive[3].ImageName);
|
||||
gDllCartMenu.add("Eject: "+disk,ControlId(18),MIT_Slave);
|
||||
gDllCartMenu.add("FD-502 Config",ControlId(16),MIT_StandAlone);
|
||||
}
|
||||
// return requested list item or false
|
||||
return gDllCartMenu.copy_item(*item, index);
|
||||
}
|
||||
|
||||
long CreateDisk (unsigned char Disk)
|
||||
{
|
||||
NewDiskNumber=Disk;
|
||||
HWND h_own = GetActiveWindow();
|
||||
DialogBox(gModuleInstance, (LPCTSTR)IDD_NEWDISK, h_own, (DLGPROC)NewDisk);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK NewDisk(HWND hDlg, UINT message, WPARAM wParam, LPARAM /*lParam*/)
|
||||
{
|
||||
unsigned char temp=0,temp2=0;
|
||||
static unsigned char NewDiskType=JVC,NewDiskTracks=2,DblSided=1;
|
||||
char Dummy[MAX_PATH]="";
|
||||
long DiskType[3]={IDC_JVC,IDC_VDK,IDC_DMK};
|
||||
long DiskTracks[3]={IDC_TR35,IDC_TR40,IDC_TR80};
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_CLOSE:
|
||||
EndDialog(hDlg,LOWORD(wParam)); //Modal dialog
|
||||
return TRUE;
|
||||
|
||||
case WM_INITDIALOG:
|
||||
for (temp=0;temp<=2;temp++)
|
||||
SendDlgItemMessage(hDlg,DiskType[temp],BM_SETCHECK,(temp==NewDiskType),0);
|
||||
for (temp=0;temp<=2;temp++)
|
||||
SendDlgItemMessage(hDlg,DiskTracks[temp],BM_SETCHECK,(temp==NewDiskTracks),0);
|
||||
SendDlgItemMessage(hDlg,IDC_DBLSIDE,BM_SETCHECK,DblSided,0);
|
||||
strcpy(Dummy,gSelectedDiskFile);
|
||||
PathStripPath(Dummy);
|
||||
SendDlgItemMessage(hDlg,IDC_TEXT1,WM_SETTEXT,0,(LPARAM)(LPCSTR)Dummy);
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDC_DMK:
|
||||
case IDC_JVC:
|
||||
case IDC_VDK:
|
||||
for (temp=0;temp<=2;temp++)
|
||||
if (LOWORD(wParam)==DiskType[temp])
|
||||
{
|
||||
for (temp2=0;temp2<=2;temp2++)
|
||||
SendDlgItemMessage(hDlg,DiskType[temp2],BM_SETCHECK,0,0);
|
||||
SendDlgItemMessage(hDlg,DiskType[temp],BM_SETCHECK,1,0);
|
||||
NewDiskType=temp;
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_TR35:
|
||||
case IDC_TR40:
|
||||
case IDC_TR80:
|
||||
for (temp=0;temp<=2;temp++)
|
||||
if (LOWORD(wParam)==DiskTracks[temp])
|
||||
{
|
||||
for (temp2=0;temp2<=2;temp2++)
|
||||
SendDlgItemMessage(hDlg,DiskTracks[temp2],BM_SETCHECK,0,0);
|
||||
SendDlgItemMessage(hDlg,DiskTracks[temp],BM_SETCHECK,1,0);
|
||||
NewDiskTracks=temp;
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_DBLSIDE:
|
||||
DblSided=!DblSided;
|
||||
SendDlgItemMessage(hDlg,IDC_DBLSIDE,BM_SETCHECK,DblSided,0);
|
||||
break;
|
||||
|
||||
case IDOK:
|
||||
{
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
const char *ext = gSelectedDiskFile + strlen(gSelectedDiskFile) - 4;
|
||||
if (ext < gSelectedDiskFile) ext = gSelectedDiskFile;
|
||||
// if it doesn't end with .dsk, append it
|
||||
if (_stricmp(ext, ".dsk") != 0)
|
||||
{
|
||||
PathRemoveExtension(gSelectedDiskFile);
|
||||
strcat(gSelectedDiskFile, ".dsk");
|
||||
}
|
||||
if (CreateDiskHeader(gSelectedDiskFile, NewDiskType, NewDiskTracks, DblSided))
|
||||
{
|
||||
strcpy(gSelectedDiskFile, "");
|
||||
MessageBox(g_hConfDlg, "Can't create File", "Error", 0);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case IDCANCEL:
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
CreateFlag=0;
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
long CreateDiskHeader(const char *FileName,unsigned char Type,unsigned char Tracks,unsigned char DblSided)
|
||||
{
|
||||
HANDLE hr=nullptr;
|
||||
unsigned char Dummy=0;
|
||||
unsigned char HeaderBuffer[16]="";
|
||||
unsigned char TrackTable[3]={35,40,80};
|
||||
unsigned short TrackSize=0x1900;
|
||||
unsigned char IgnoreDensity=0,SingleDensity=0,HeaderSize=0;
|
||||
unsigned long BytesWritten=0,FileSize=0;
|
||||
hr=CreateFile( FileName,GENERIC_READ | GENERIC_WRITE,0,nullptr,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,nullptr);
|
||||
if (hr==INVALID_HANDLE_VALUE)
|
||||
return 1; //Failed to create File
|
||||
|
||||
switch (Type)
|
||||
{
|
||||
case DMK:
|
||||
HeaderBuffer[0]=0;
|
||||
HeaderBuffer[1]=TrackTable[Tracks];
|
||||
HeaderBuffer[2]=(TrackSize & 0xFF);
|
||||
HeaderBuffer[3]=(TrackSize >>8);
|
||||
HeaderBuffer[4]=(IgnoreDensity<<7) | (SingleDensity<<6) | ((!DblSided)<<4);
|
||||
HeaderBuffer[0xC]=0;
|
||||
HeaderBuffer[0xD]=0;
|
||||
HeaderBuffer[0xE]=0;
|
||||
HeaderBuffer[0xF]=0;
|
||||
HeaderSize=0x10;
|
||||
FileSize= HeaderSize + (HeaderBuffer[1] * TrackSize * (DblSided+1) );
|
||||
break;
|
||||
|
||||
case JVC: // has variable header size
|
||||
HeaderSize=0;
|
||||
HeaderBuffer[0]=18; //18 Sectors
|
||||
HeaderBuffer[1]=DblSided+1; // Double or single Sided;
|
||||
FileSize = (HeaderBuffer[0] * 0x100 * TrackTable[Tracks] * (DblSided+1));
|
||||
if (DblSided)
|
||||
{
|
||||
FileSize+=2;
|
||||
HeaderSize=2;
|
||||
}
|
||||
break;
|
||||
|
||||
case VDK:
|
||||
HeaderBuffer[9]=DblSided+1;
|
||||
HeaderSize=12;
|
||||
FileSize = ( 18 * 0x100 * TrackTable[Tracks] * (DblSided+1));
|
||||
FileSize+=HeaderSize;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
HeaderBuffer[0]=0;
|
||||
HeaderBuffer[1]=TrackTable[Tracks];
|
||||
HeaderBuffer[2]=(TrackSize & 0xFF);
|
||||
HeaderBuffer[3]=(TrackSize >>8);
|
||||
HeaderBuffer[4]=((!DblSided)<<4);
|
||||
HeaderBuffer[0xC]=0x12;
|
||||
HeaderBuffer[0xD]=0x34;
|
||||
HeaderBuffer[0xE]=0x56;
|
||||
HeaderBuffer[0xF]=0x78;
|
||||
HeaderSize=0x10;
|
||||
FileSize=1;
|
||||
break;
|
||||
|
||||
}
|
||||
SetFilePointer(hr,0,nullptr,FILE_BEGIN);
|
||||
WriteFile(hr,HeaderBuffer,HeaderSize,&BytesWritten,nullptr);
|
||||
SetFilePointer(hr,FileSize-1,nullptr,FILE_BEGIN);
|
||||
WriteFile(hr,&Dummy,1,&BytesWritten,nullptr);
|
||||
CloseHandle(hr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void LoadConfig() // Called on SetIniPath
|
||||
{
|
||||
unsigned char Index=0;
|
||||
char Temp[16]="";
|
||||
char DiskRomPath[MAX_PATH], RGBRomPath[MAX_PATH];
|
||||
char DiskName[MAX_PATH]="";
|
||||
unsigned int RetVal=0;
|
||||
|
||||
#ifdef COMBINE_BECKER
|
||||
BeckerEnabled=Setting().read(MS_BECKER,"DWEnable", 0);
|
||||
Setting().read(MS_BECKER,"DWServerAddr","127.0.0.1",BeckerAddr,MAX_PATH);
|
||||
Setting().read(MS_BECKER,"DWServerPort","65504",BeckerPort,32);
|
||||
if(*BeckerAddr == '\0') strcpy(BeckerAddr,"127.0.0.1");
|
||||
if(*BeckerPort == '\0') strcpy(BeckerPort,"65504");
|
||||
becker_sethost(BeckerAddr,BeckerPort);
|
||||
becker_enable(BeckerEnabled);
|
||||
#endif
|
||||
|
||||
Setting().read(MS_PATHS, "FloppyPath", "", FloppyPath, MAX_PATH);
|
||||
|
||||
SelectRom = Setting().read(MS_FD502,"DiskRom",1); //0 External 1=TRSDOS 2=RGB Dos
|
||||
Setting().read(MS_FD502,"RomPath","",RomFileName,MAX_PATH);
|
||||
PersistDisks=Setting().read(MS_FD502,"Persist",1);
|
||||
CheckPath(RomFileName);
|
||||
LoadExtRom(External,RomFileName); //JF
|
||||
GetModuleFileName(nullptr, DiskRomPath, MAX_PATH);
|
||||
PathRemoveFileSpec(DiskRomPath);
|
||||
strcpy(RGBRomPath, DiskRomPath);
|
||||
strcat(DiskRomPath, "disk11.rom");
|
||||
strcat(RGBRomPath, "rgbdos.rom");
|
||||
LoadExtRom(TandyDisk, DiskRomPath); // Why load?
|
||||
LoadExtRom(RGBDisk, RGBRomPath); // Why load?
|
||||
if (PersistDisks) // TODO: Fix this, checkbox was removed
|
||||
for (Index=0;Index<4;Index++)
|
||||
{
|
||||
sprintf(Temp,"Disk#%i",Index);
|
||||
Setting().read(MS_FD502,Temp,"",DiskName,MAX_PATH);
|
||||
if (strlen(DiskName))
|
||||
{
|
||||
RetVal=mount_disk_image(DiskName,Index);
|
||||
//MessageBox(0, "Disk load attempt", "OK", 0);
|
||||
if (RetVal)
|
||||
{
|
||||
if (!strcmp(DiskName,"*Floppy A:")) //RealDisks
|
||||
PhysicalDriveA=Index+1;
|
||||
if (!strcmp(DiskName,"*Floppy B:"))
|
||||
PhysicalDriveB=Index+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
ClockEnabled=Setting().read(MS_FD502,"ClkEnable",1);
|
||||
SetTurboDisk(Setting().read(MS_FD502, "TurboDisk", 1));
|
||||
|
||||
SendMessage(gVccWnd,WM_VCC_UPD_MENU,(WPARAM) 0,(LPARAM) 0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void SaveConfig()
|
||||
{
|
||||
unsigned char Index=0;
|
||||
char Temp[16]="";
|
||||
ValidatePath(RomFileName);
|
||||
Setting().write(MS_FD502,"DiskRom",SelectRom );
|
||||
Setting().write(MS_FD502,"RomPath",RomFileName);
|
||||
Setting().write(MS_FD502,"Persist",PersistDisks );
|
||||
if (PersistDisks)
|
||||
for (Index=0;Index<4;Index++)
|
||||
{
|
||||
sprintf(Temp,"Disk#%i",Index);
|
||||
Setting().write(MS_FD502,Temp,gVirtualDrive[Index].ImageName);
|
||||
}
|
||||
Setting().write(MS_FD502,"ClkEnable",ClockEnabled );
|
||||
Setting().write(MS_FD502, "TurboDisk", SetTurboDisk(QUERY));
|
||||
if (strcmp(FloppyPath, "") != 0) {
|
||||
Setting().write(MS_PATHS, "FloppyPath", FloppyPath);
|
||||
}
|
||||
#ifdef COMBINE_BECKER
|
||||
Setting().write(MS_BECKER,"DWEnable", BeckerEnabled);
|
||||
Setting().write(MS_BECKER,"DWServerAddr", BeckerAddr);
|
||||
Setting().write(MS_BECKER,"DWServerPort", BeckerPort);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char LoadExtRom( unsigned char RomType,const char *FilePath) //Returns 1 on if loaded
|
||||
{
|
||||
FILE *rom_handle=nullptr;
|
||||
unsigned short index=0;
|
||||
unsigned char RetVal=0;
|
||||
unsigned char *ThisRom[3]={ExternalRom,DiskRom,RGBDiskRom};
|
||||
|
||||
rom_handle=fopen(FilePath,"rb");
|
||||
if (rom_handle==nullptr)
|
||||
memset(ThisRom[RomType],0xFF,EXTROMSIZE);
|
||||
else
|
||||
{
|
||||
while ((feof(rom_handle)==0) & (index<EXTROMSIZE))
|
||||
ThisRom[RomType][index++]=fgetc(rom_handle);
|
||||
RetVal=1;
|
||||
fclose(rom_handle);
|
||||
}
|
||||
|
||||
DLOG_C("load %s %d %d\n",FilePath,RomType,RetVal);
|
||||
return RetVal;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <vcc/bus/cpak_cartridge_definitions.h>
|
||||
#include <vcc/util/Settings.h>
|
||||
|
||||
extern slot_id_type gSlotId;
|
||||
extern PakAssertInteruptHostCallback AssertInt;
|
||||
|
||||
// Access settings object
|
||||
VCC::Util::settings& Setting();
|
||||
|
||||
// DO NOT REMOVE this or references to ituntil becker.dll is retired.
|
||||
// Then FD502 becker becomes permanant.
|
||||
#define COMBINE_BECKER
|
||||
|
||||
// FIXME: These need to be turned into a scoped enum and the signature of functions
|
||||
// that use them updated.
|
||||
#define External 0
|
||||
#define TandyDisk 1
|
||||
#define RGBDisk 2
|
||||
|
||||
@@ -0,0 +1,226 @@
|
||||
// Protect this file from the resource editor
|
||||
// All edits should be done by hand
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#error Fd502.rc is not editable by Visual C++, edit it by hand.
|
||||
#endif //APSTUDIO_INVOKED
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (United States) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
// DO NOT REMOVE until becker.dll is retired. Then FD502 becker becomes permanant.
|
||||
#define COMBINE_BECKER
|
||||
|
||||
IDD_CONFIG DIALOGEX 0, 0, 268, 185
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Floppy Configuration"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x0
|
||||
BEGIN
|
||||
GROUPBOX "Dos Image",IDC_STATIC,3,3,260,65,BS_CENTER
|
||||
RADIOBUTTON "Disk Basic (disk11.rom file must be present in VCC folder)",IDC_TRSDOS,7,13,195,10,WS_TABSTOP
|
||||
RADIOBUTTON "RGB Dos (rgbdos.rom file must be present in VCC folder)",IDC_RGB,7,25,192,10,WS_TABSTOP
|
||||
RADIOBUTTON "External Rom Image :",IDC_EXTROM,7,37,79,10,WS_TABSTOP
|
||||
EDITTEXT IDC_ROMPATH,9,49,218,14,ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP
|
||||
PUSHBUTTON "Browse",IDC_BROWSE,230,49,29,14
|
||||
CONTROL "OverClock Disk Drive",IDC_TURBO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,75,90,10
|
||||
CONTROL "Persistent Disk Images",IDC_PERSIST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,87,90,10
|
||||
CONTROL "Disto Clock [0xFF50-51]",IDC_CLOCK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,99,90,10
|
||||
|
||||
#ifdef COMBINE_BECKER
|
||||
CONTROL "Becker Drivewire [0xFF41-42]",IDC_BECKER_ENAB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,110,75,130,10
|
||||
LTEXT "Server Address",IDC_STATIC,108,87,50,10
|
||||
LTEXT "Server Port",IDC_STATIC,120,99,40,10
|
||||
EDITTEXT IDC_BECKER_HOST,160,87,103,10,ES_AUTOHSCROLL
|
||||
EDITTEXT IDC_BECKER_PORT,160,100,30,10,ES_NUMBER
|
||||
#endif
|
||||
|
||||
GROUPBOX "Physical Disks",IDC_STATIC,3,118,260,43,BS_CENTER
|
||||
LTEXT "A:",IDC_STATIC,10,128,8,8,
|
||||
LTEXT "B:",IDC_STATIC,10,147,8,8,
|
||||
COMBOBOX IDC_DISKA,19,126,59,49,CBS_DROPDOWN | WS_VSCROLL
|
||||
COMBOBOX IDC_DISKB,19,144,59,51,CBS_DROPDOWN | WS_VSCROLL
|
||||
LTEXT "Windows 2000 or higher and FDRAWREAD driver are required for Physical Disk access",IDC_STATIC,85,133,141,22
|
||||
PUSHBUTTON "Cancel",IDCANCEL,40,166,50,14
|
||||
DEFPUSHBUTTON "OK",IDOK,160,166,50,14
|
||||
END
|
||||
|
||||
IDD_NEWDISK DIALOG 0, 0, 186, 70
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Create Disk Image"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Yes",IDOK,106,52,32,14
|
||||
PUSHBUTTON "No",IDCANCEL,143,52,32,14
|
||||
RADIOBUTTON "JVC",IDC_JVC,8,20,33,10,BS_LEFT | BS_VCENTER
|
||||
GROUPBOX "Image Type",IDC_STATIC,4,10,47,42
|
||||
RADIOBUTTON "DMK",IDC_DMK,8,30,33,10,BS_LEFT | BS_VCENTER
|
||||
RADIOBUTTON "VDK",IDC_VDK,8,40,33,10,BS_LEFT | BS_VCENTER
|
||||
RADIOBUTTON "35",IDC_TR35,62,20,24,10
|
||||
GROUPBOX "Tracks",IDC_STATIC,54,10,41,42,BS_CENTER
|
||||
RADIOBUTTON "40",IDC_TR40,62,30,24,10
|
||||
RADIOBUTTON "80",IDC_TR80,62,40,24,10
|
||||
CONTROL "Double Sided",IDC_DBLSIDE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,3,57,61,10
|
||||
LTEXT "",IDC_TEXT1,105,12,68,8
|
||||
LTEXT "File does not exist.",IDC_STATIC,105,25,70,8
|
||||
LTEXT "Create the file?",IDC_STATIC,105,35,48,8
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO
|
||||
BEGIN
|
||||
IDD_CONFIG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 3
|
||||
RIGHTMARGIN, 286
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 171
|
||||
END
|
||||
|
||||
IDD_NEWDISK, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 3
|
||||
RIGHTMARGIN, 182
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 67
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 2,1,9,2
|
||||
PRODUCTVERSION 2,1,9,2
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x21L
|
||||
#else
|
||||
FILEFLAGS 0x20L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "Comments", "Tandy FD-502 with 4 Floppy Drives & RAW support"
|
||||
VALUE "CompanyName", "Bitrot Software"
|
||||
VALUE "FileDescription", "DiskController"
|
||||
VALUE "FileVersion", "2.1.8.1"
|
||||
VALUE "InternalName", "DiskController"
|
||||
VALUE "LegalCopyright", "Copyright � 2010"
|
||||
VALUE "OriginalFilename", "fd502.dll"
|
||||
VALUE "ProductName", "Vcc Module file"
|
||||
VALUE "ProductVersion", "26-3133"
|
||||
VALUE "SpecialBuild", "Tandy Floppy Disk Controller"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// AFX_DIALOG_LAYOUT
|
||||
//
|
||||
|
||||
IDD_CONFIG AFX_DIALOG_LAYOUT
|
||||
BEGIN
|
||||
0
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_MODULE_NAME "FD-502"
|
||||
IDS_VERSION "3.0.1"
|
||||
IDS_DESCRIPTION "Emulate FD502 floppy controller with four floppy drives. Loads Disk Extended Color Basic (disl11.rom) or user selectable disk rom. Also includes Becker Port for communicating with Drivewire and a Disto Clock for use with OS-9. Uses SCS selectable disk ports. Plugs into the Program Pak port or Multi-Pak Interface."
|
||||
#ifdef COMBINE_BECKER
|
||||
IDS_CATNUMBER "+ Becker"
|
||||
#else
|
||||
IDS_CATNUMBER "26-3133"
|
||||
#endif
|
||||
END
|
||||
|
||||
#endif // English (United States) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Legacy|Win32">
|
||||
<Configuration>Legacy</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<SccProjectName />
|
||||
<SccLocalPath />
|
||||
<ProjectGuid>{F4DC9499-4FF1-4A56-83DD-6499062972AA}</ProjectGuid>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\vcc-base.props" />
|
||||
<Import Project="..\vcc-legacy.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\vcc-base.props" />
|
||||
<Import Project="..\vcc-release.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\vcc-base.props" />
|
||||
<Import Project="..\vcc-debug.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">
|
||||
<LibraryPath>C:\Program Files %28x86%29\Windows Kits\8.1\Lib\winv6.3\um\x86;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;fd502_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ResourceCompile />
|
||||
<Link>
|
||||
<LinkDLL>true</LinkDLL>
|
||||
<AdditionalDependencies>WS2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_USRDLL;fd502_EXPORTS;_LEGACY_VCC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalOptions>/arch:SSE</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<LinkDLL>true</LinkDLL>
|
||||
<AdditionalDependencies>WS2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;fd502_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalOptions>/arch:SSE</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<ResourceCompile />
|
||||
<Link>
|
||||
<LinkDLL>true</LinkDLL>
|
||||
<AdditionalDependencies>WS2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="distortc.cpp" />
|
||||
<ClCompile Include="fd502.cpp" />
|
||||
<ClCompile Include="wd1793.cpp" />
|
||||
<ClCompile Include="becker.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="defines.h" />
|
||||
<ClInclude Include="distortc.h" />
|
||||
<ClInclude Include="fd502.h" />
|
||||
<ClInclude Include="fdrawcmd.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="wd1793.h" />
|
||||
<ClInclude Include="becker.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="fd502.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\libcommon\libcommon.vcxproj">
|
||||
<Project>{e0aa25bd-5527-475f-8d8b-b549a6311b0c}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,291 @@
|
||||
#ifndef __FDRAWCMD_SYS__
|
||||
#define __FDRAWCMD_SYS__
|
||||
// fdrawcmd.sys
|
||||
//
|
||||
// Low-level floppy filter, by Simon Owen
|
||||
//
|
||||
// http://simonowen.com/fdrawcmd/
|
||||
|
||||
#ifndef FDRAWCMD_H
|
||||
#define FDRAWCMD_H
|
||||
|
||||
#ifndef CTL_CODE
|
||||
#include <winioctl.h>
|
||||
#endif
|
||||
|
||||
#define FDRAWCMD_VERSION 0x01000109 // Compile-time version, for structures and definitions below
|
||||
// Must be checked with run-time driver for compatibility
|
||||
|
||||
#define FD_CTL_CODE(i,m) CTL_CODE(FILE_DEVICE_UNKNOWN, i, m, FILE_READ_DATA|FILE_WRITE_DATA)
|
||||
|
||||
// If you're not using C/C++, use the IOCTL values below
|
||||
#define IOCTL_FDRAWCMD_GET_VERSION FD_CTL_CODE(0x888, METHOD_BUFFERED) // 0x0022e220
|
||||
|
||||
#define IOCTL_FDCMD_READ_TRACK FD_CTL_CODE(0x802, METHOD_OUT_DIRECT) // 0x0022e00a
|
||||
#define IOCTL_FDCMD_SPECIFY FD_CTL_CODE(0x803, METHOD_BUFFERED) // 0x0022e00c
|
||||
#define IOCTL_FDCMD_SENSE_DRIVE_STATUS FD_CTL_CODE(0x804, METHOD_BUFFERED) // 0x0022e010
|
||||
#define IOCTL_FDCMD_WRITE_DATA FD_CTL_CODE(0x805, METHOD_IN_DIRECT) // 0x0022e015
|
||||
#define IOCTL_FDCMD_READ_DATA FD_CTL_CODE(0x806, METHOD_OUT_DIRECT) // 0x0022e01a
|
||||
#define IOCTL_FDCMD_RECALIBRATE FD_CTL_CODE(0x807, METHOD_BUFFERED) // 0x0022e01c
|
||||
#define IOCTL_FDCMD_SENSE_INT_STATUS FD_CTL_CODE(0x808, METHOD_BUFFERED) // 0x0022e020 // added in 1.0.0.22
|
||||
#define IOCTL_FDCMD_WRITE_DELETED_DATA FD_CTL_CODE(0x809, METHOD_IN_DIRECT) // 0x0022e025
|
||||
#define IOCTL_FDCMD_READ_ID FD_CTL_CODE(0x80a, METHOD_BUFFERED) // 0x0022e028
|
||||
#define IOCTL_FDCMD_READ_DELETED_DATA FD_CTL_CODE(0x80c, METHOD_OUT_DIRECT) // 0x0022e032
|
||||
#define IOCTL_FDCMD_FORMAT_TRACK FD_CTL_CODE(0x80d, METHOD_BUFFERED) // 0x0022e034
|
||||
#define IOCTL_FDCMD_DUMPREG FD_CTL_CODE(0x80e, METHOD_BUFFERED) // 0x0022e038
|
||||
#define IOCTL_FDCMD_SEEK FD_CTL_CODE(0x80f, METHOD_BUFFERED) // 0x0022e03c
|
||||
#define IOCTL_FDCMD_VERSION FD_CTL_CODE(0x810, METHOD_BUFFERED) // 0x0022e040
|
||||
#define IOCTL_FDCMD_SCAN_EQUAL FD_CTL_CODE(0x811, METHOD_IN_DIRECT) // 0x0022e045 (not implemented yet)
|
||||
#define IOCTL_FDCMD_PERPENDICULAR_MODE FD_CTL_CODE(0x812, METHOD_BUFFERED) // 0x0022e048
|
||||
#define IOCTL_FDCMD_CONFIGURE FD_CTL_CODE(0x813, METHOD_BUFFERED) // 0x0022e04c
|
||||
#define IOCTL_FDCMD_LOCK FD_CTL_CODE(0x814, METHOD_BUFFERED) // 0x0022e050
|
||||
#define IOCTL_FDCMD_VERIFY FD_CTL_CODE(0x816, METHOD_BUFFERED) // 0x0022e058
|
||||
#define IOCTL_FDCMD_POWERDOWN_MODE FD_CTL_CODE(0x817, METHOD_BUFFERED) // 0x0022e05c (not implemented yet)
|
||||
#define IOCTL_FDCMD_PART_ID FD_CTL_CODE(0x818, METHOD_BUFFERED) // 0x0022e060
|
||||
#define IOCTL_FDCMD_SCAN_LOW_OR_EQUAL FD_CTL_CODE(0x819, METHOD_IN_DIRECT) // 0x0022e065 (not implemented yet)
|
||||
#define IOCTL_FDCMD_SCAN_HIGH_OR_EQUAL FD_CTL_CODE(0x81d, METHOD_IN_DIRECT) // 0x0022e075 (not implemented yet)
|
||||
#define IOCTL_FDCMD_SAVE FD_CTL_CODE(0x82e, METHOD_BUFFERED) // 0x0022e0b8 (not implemented yet)
|
||||
#define IOCTL_FDCMD_OPTION FD_CTL_CODE(0x833, METHOD_BUFFERED) // 0x0022e0cc (not implemented yet)
|
||||
#define IOCTL_FDCMD_RESTORE FD_CTL_CODE(0x84e, METHOD_BUFFERED) // 0x0022e138 (not implemented yet)
|
||||
#define IOCTL_FDCMD_DRIVE_SPEC_CMD FD_CTL_CODE(0x88e, METHOD_BUFFERED) // 0x0022e238 (not implemented yet)
|
||||
#define IOCTL_FDCMD_RELATIVE_SEEK FD_CTL_CODE(0x88f, METHOD_BUFFERED) // 0x0022e23c
|
||||
#define IOCTL_FDCMD_FORMAT_AND_WRITE FD_CTL_CODE(0x8ad, METHOD_BUFFERED) // 0x0022e2b4 (not implemented yet)
|
||||
|
||||
#define IOCTL_FD_SCAN_TRACK FD_CTL_CODE(0x900, METHOD_BUFFERED) // 0x0022e400
|
||||
#define IOCTL_FD_GET_RESULT FD_CTL_CODE(0x901, METHOD_BUFFERED) // 0x0022e404
|
||||
#define IOCTL_FD_RESET FD_CTL_CODE(0x902, METHOD_BUFFERED) // 0x0022e408
|
||||
#define IOCTL_FD_SET_MOTOR_TIMEOUT FD_CTL_CODE(0x903, METHOD_BUFFERED) // 0x0022e40c
|
||||
#define IOCTL_FD_SET_DATA_RATE FD_CTL_CODE(0x904, METHOD_BUFFERED) // 0x0022e410
|
||||
#define IOCTL_FD_GET_FDC_INFO FD_CTL_CODE(0x905, METHOD_BUFFERED) // 0x0022e414
|
||||
#define IOCTL_FD_GET_REMAIN_COUNT FD_CTL_CODE(0x906, METHOD_BUFFERED) // 0x0022e418 // added in 1.0.0.22
|
||||
#define IOCTL_FD_SET_DISK_CHECK FD_CTL_CODE(0x908, METHOD_BUFFERED) // 0x0022e420
|
||||
#define IOCTL_FD_SET_SHORT_WRITE FD_CTL_CODE(0x909, METHOD_BUFFERED) // 0x0022e424 // added in 1.0.0.22
|
||||
#define IOCTL_FD_SET_SECTOR_OFFSET FD_CTL_CODE(0x90a, METHOD_BUFFERED) // 0x0022e428 // added in 1.0.0.22
|
||||
#define IOCTL_FD_SET_HEAD_SETTLE_TIME FD_CTL_CODE(0x90b, METHOD_BUFFERED) // 0x0022e42c // added in 1.0.0.22
|
||||
#define IOCTL_FD_LOCK_FDC FD_CTL_CODE(0x910, METHOD_BUFFERED) // 0x0022e440 // obsolete from 1.0.1.0
|
||||
#define IOCTL_FD_UNLOCK_FDC FD_CTL_CODE(0x911, METHOD_BUFFERED) // 0x0022e444 // obsolete from 1.0.1.0
|
||||
#define IOCTL_FD_MOTOR_ON FD_CTL_CODE(0x912, METHOD_BUFFERED) // 0x0022e448
|
||||
#define IOCTL_FD_MOTOR_OFF FD_CTL_CODE(0x913, METHOD_BUFFERED) // 0x0022e44c
|
||||
#define IOCTL_FD_WAIT_INDEX FD_CTL_CODE(0x914, METHOD_BUFFERED) // 0x0022e450 // added in 1.0.0.22
|
||||
#define IOCTL_FD_TIMED_SCAN_TRACK FD_CTL_CODE(0x915, METHOD_BUFFERED) // 0x0022e454 // added in 1.0.0.22
|
||||
#define IOCTL_FD_RAW_READ_TRACK FD_CTL_CODE(0x916, METHOD_OUT_DIRECT) // 0x0022e45a // added in 1.0.1.4
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Command flags: multi-track, MFM, sector skip, relative seek direction, verify enable count
|
||||
#define FD_OPTION_MT 0x80
|
||||
#define FD_OPTION_MFM 0x40
|
||||
#define FD_OPTION_SK 0x20
|
||||
#define FD_OPTION_DIR 0x40
|
||||
#define FD_OPTION_EC 0x01
|
||||
|
||||
// FD_FDC_INFO controller types
|
||||
#define FDC_TYPE_UNKNOWN 0
|
||||
#define FDC_TYPE_UNKNOWN2 1
|
||||
#define FDC_TYPE_NORMAL 2
|
||||
#define FDC_TYPE_ENHANCED 3
|
||||
#define FDC_TYPE_82077 4
|
||||
#define FDC_TYPE_82077AA 5
|
||||
#define FDC_TYPE_82078_44 6
|
||||
#define FDC_TYPE_82078_64 7
|
||||
#define FDC_TYPE_NATIONAL 8
|
||||
|
||||
// FD_FDC_INFO supported drive speeds
|
||||
#define FDC_SPEED_250K 0x01
|
||||
#define FDC_SPEED_300K 0x02
|
||||
#define FDC_SPEED_500K 0x04
|
||||
#define FDC_SPEED_1M 0x08
|
||||
#define FDC_SPEED_2M 0x10
|
||||
|
||||
|
||||
#pragma pack(push,1)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4200) // allow zero-sized arrays
|
||||
|
||||
|
||||
typedef struct tagFD_ID_HEADER
|
||||
{
|
||||
BYTE cyl, head, sector, size;
|
||||
}
|
||||
FD_ID_HEADER, *PFD_ID_HEADER;
|
||||
|
||||
typedef struct tagFD_SEEK_PARAMS
|
||||
{
|
||||
BYTE cyl;
|
||||
BYTE head;
|
||||
}
|
||||
FD_SEEK_PARAMS, *PFD_SEEK_PARAMS;
|
||||
|
||||
typedef struct tagFD_RELATIVE_SEEK_PARAMS
|
||||
{
|
||||
BYTE flags; // DIR
|
||||
BYTE head;
|
||||
BYTE offset;
|
||||
}
|
||||
FD_RELATIVE_SEEK_PARAMS, *PFD_RELATIVE_SEEK_PARAMS;
|
||||
|
||||
typedef struct tagFD_READ_WRITE_PARAMS
|
||||
{
|
||||
BYTE flags; // MT MFM SK
|
||||
BYTE phead;
|
||||
BYTE cyl, head, sector, size;
|
||||
BYTE eot, gap, datalen;
|
||||
}
|
||||
FD_READ_WRITE_PARAMS, *PFD_READ_WRITE_PARAMS;
|
||||
|
||||
typedef struct tagFD_CMD_RESULT
|
||||
{
|
||||
BYTE st0, st1, st2;
|
||||
BYTE cyl, head, sector, size;
|
||||
}
|
||||
FD_CMD_RESULT, *PFD_CMD_RESULT;
|
||||
|
||||
typedef struct tagFD_FORMAT_PARAMS
|
||||
{
|
||||
BYTE flags; // MFM
|
||||
BYTE phead;
|
||||
BYTE size, sectors, gap, fill;
|
||||
|
||||
FD_ID_HEADER Header[];
|
||||
}
|
||||
FD_FORMAT_PARAMS, *PFD_FORMAT_PARAMS;
|
||||
|
||||
typedef struct tagFD_READ_ID_PARAMS
|
||||
{
|
||||
BYTE flags; // MFM
|
||||
BYTE head;
|
||||
}
|
||||
FD_READ_ID_PARAMS, *PFD_READ_ID_PARAMS;
|
||||
|
||||
typedef struct tagFD_CONFIGURE_PARAMS
|
||||
{
|
||||
BYTE eis_efifo_poll_fifothr; // b6 = enable implied seek, b5 = enable fifo, b4 = poll disable, b3-b0 = fifo threshold
|
||||
BYTE pretrk; // precompensation start track
|
||||
}
|
||||
FD_CONFIGURE_PARAMS, *PFD_CONFIGURE_PARAMS;
|
||||
|
||||
typedef struct tagFD_SPECIFY_PARAMS
|
||||
{
|
||||
BYTE srt_hut; // b7-b4 = step rate, b3-b0 = head unload time
|
||||
BYTE hlt_nd; // b7-b1 = head load time, b0 = non-DMA flag (unsupported)
|
||||
}
|
||||
FD_SPECIFY_PARAMS, *PFD_SPECIFY_PARAMS;
|
||||
|
||||
typedef struct tagFD_SENSE_PARAMS
|
||||
{
|
||||
BYTE head;
|
||||
}
|
||||
FD_SENSE_PARAMS, *PFD_SENSE_PARAMS;
|
||||
|
||||
typedef struct tagFD_DRIVE_STATUS
|
||||
{
|
||||
BYTE st3;
|
||||
}
|
||||
FD_DRIVE_STATUS, *PFD_DRIVE_STATUS;
|
||||
|
||||
typedef struct tagFD_INTERRUPT_STATUS
|
||||
{
|
||||
BYTE st0; // status register 0
|
||||
BYTE pcn; // present cylinder number
|
||||
}
|
||||
FD_INTERRUPT_STATUS, *PFD_INTERRUPT_STATUS;
|
||||
|
||||
typedef struct tagFD_PERPENDICULAR_PARAMS
|
||||
{
|
||||
BYTE ow_ds_gap_wgate; // b7 = OW, b6 = 0, b5-b2 = drive select, b1 = gap2, b0 = write gate pre-erase loads
|
||||
}
|
||||
FD_PERPENDICULAR_PARAMS, *PFD_PERPENDICULAR_PARAMS;
|
||||
|
||||
typedef struct tagFD_LOCK_PARAMS
|
||||
{
|
||||
BYTE lock; // b7 = lock
|
||||
}
|
||||
FD_LOCK_PARAMS, *PFD_LOCK_PARAMS;
|
||||
|
||||
typedef struct tagFD_LOCK_RESULT
|
||||
{
|
||||
BYTE lock; // b4 = lock
|
||||
}
|
||||
FD_LOCK_RESULT, *PFD_LOCK_RESULT;
|
||||
|
||||
typedef struct tagFD_DUMPREG_RESULT
|
||||
{
|
||||
BYTE pcn0, pcn1, pcn2, pcn3; // present cylinder numbers
|
||||
BYTE srt_hut; // b7-4 = step rate, b3-0 = head unload time
|
||||
BYTE hlt_nd; // b7-1 = head load time, b0 = non-dma mode
|
||||
BYTE sceot; // sector count / end of track
|
||||
BYTE lock_d0123_gap_wgate; // b7 = setting lock, b5-2 = drive selects, b1 = gap 2 (perpendicular), b0 = write gate
|
||||
BYTE eis_efifo_poll_fifothr; // b6 = implied seeks, b5 = fifo enable, b4 = poll disable, b3-0 = fifo threshold
|
||||
BYTE pretrk; // pre-comp start track
|
||||
}
|
||||
FD_DUMPREG_RESULT, *PFD_DUMPREG_RESULT;
|
||||
|
||||
typedef struct tagFD_SECTOR_OFFSET_PARAMS
|
||||
{
|
||||
BYTE sectors; // number of sectors to skip after index
|
||||
}
|
||||
FD_SECTOR_OFFSET_PARAMS, *PFD_SECTOR_OFFSET_PARAMS;
|
||||
|
||||
typedef struct tagFD_SHORT_WRITE_PARAMS
|
||||
{
|
||||
DWORD length; // length to write before interrupting
|
||||
DWORD finetune; // finetune delay in microseconds
|
||||
}
|
||||
FD_SHORT_WRITE_PARAMS, *PFD_SHORT_WRITE_PARAMS;
|
||||
|
||||
typedef struct tagFD_SCAN_PARAMS
|
||||
{
|
||||
BYTE flags; // MFM
|
||||
BYTE head;
|
||||
}
|
||||
FD_SCAN_PARAMS, *PFD_SCAN_PARAMS;
|
||||
|
||||
typedef struct tagFD_SCAN_RESULT
|
||||
{
|
||||
BYTE count; // count of returned headers
|
||||
FD_ID_HEADER Header[]; // array of 'count' id fields
|
||||
}
|
||||
FD_SCAN_RESULT, *PFD_SCAN_RESULT;
|
||||
|
||||
|
||||
typedef struct tagFD_TIMED_ID_HEADER
|
||||
{
|
||||
DWORD reltime; // time relative to index (in microseconds)
|
||||
BYTE cyl, head, sector, size;
|
||||
}
|
||||
FD_TIMED_ID_HEADER, *PFD_TIMED_ID_HEADER;
|
||||
|
||||
typedef struct tagFD_TIMED_SCAN_RESULT
|
||||
{
|
||||
BYTE count; // count of returned headers
|
||||
BYTE firstseen; // offset of first sector detected
|
||||
DWORD tracktime; // total time for track (in microseconds)
|
||||
FD_TIMED_ID_HEADER Header[]; // array of 'count' id fields
|
||||
}
|
||||
FD_TIMED_SCAN_RESULT, *PFD_TIMED_SCAN_RESULT;
|
||||
|
||||
typedef struct tagFD_FDC_INFO
|
||||
{
|
||||
BYTE ControllerType; // FDC_TYPE_*
|
||||
BYTE SpeedsAvailable; // FDC_SPEED_* values ORed together
|
||||
|
||||
BYTE BusType;
|
||||
DWORD BusNumber;
|
||||
DWORD ControllerNumber;
|
||||
DWORD PeripheralNumber;
|
||||
}
|
||||
FD_FDC_INFO, *PFD_FDC_INFO;
|
||||
|
||||
typedef struct tagFD_RAW_READ_PARAMS
|
||||
{
|
||||
BYTE flags; // MFM
|
||||
BYTE head, size;
|
||||
}
|
||||
FD_RAW_READ_PARAMS, *PFD_RAW_READ_PARAMS;
|
||||
|
||||
#pragma warning(pop)
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,6 @@
|
||||
void WriteLog(char *,unsigned char);
|
||||
void CpuDump(void);
|
||||
|
||||
|
||||
#define TOCONS 0
|
||||
#define TOFILE 1
|
||||
@@ -0,0 +1,59 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by fd502.rc
|
||||
//
|
||||
#define IDS_MODULE_NAME 1
|
||||
#define IDS_VERSION 2
|
||||
#define IDS_CATNUMBER 3
|
||||
#define IDS_DESCRIPTION 4
|
||||
#define IDD_CONFIG 101
|
||||
#define IDD_NEWDISK 102
|
||||
#define IDC_DRIVE0 1000
|
||||
#define IDC_DRIVE1 1001
|
||||
#define IDC_DRIVE2 1002
|
||||
#define IDC_EDIT1 1003
|
||||
#define IDC_EDITDRIVE0 1003
|
||||
#define IDC_PATH 1003
|
||||
#define IDC_ROMPATH 1003
|
||||
#define IDC_EDIT2 1004
|
||||
#define IDC_EDITDRIVE2 1004
|
||||
#define IDC_EDIT3 1005
|
||||
#define IDC_EDITDRIVE1 1005
|
||||
#define IDC_MOUNT 1006
|
||||
#define IDC_UNMOUNT 1007
|
||||
#define IDC_CREATE 1008
|
||||
#define IDC_TURBO 1009
|
||||
//#define IDC_KBLEDS 1010
|
||||
#define IDC_RGB 1011
|
||||
#define IDC_DMK 1012
|
||||
#define IDC_JVC 1013
|
||||
#define IDC_VDK 1014
|
||||
#define IDC_TR35 1015
|
||||
#define IDC_TR40 1016
|
||||
#define IDC_TR80 1017
|
||||
#define IDC_DBLSIDE 1018
|
||||
#define IDC_BROWSE 1019
|
||||
#define IDC_RAW 1019
|
||||
#define IDC_TEXT1 1022
|
||||
#define IDC_EXTROM 1023
|
||||
#define IDC_TRSDOS 1024
|
||||
#define IDC_PERSIST 1028
|
||||
#define IDC_DISKA 1029
|
||||
#define IDC_DISKB 1030
|
||||
#define IDC_CLOCK 1031
|
||||
#define IDC_READONLY 1032
|
||||
#define IDC_BECKER_ENAB 1033
|
||||
#define IDC_BECKER_HOST 1034
|
||||
#define IDC_BECKER_PORT 1035
|
||||
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 105
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1036
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,147 @@
|
||||
#ifndef __WD1793_H__
|
||||
#define __WD1793_H__
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
#include "defines.h"
|
||||
unsigned char disk_io_read(unsigned char port);
|
||||
void disk_io_write(unsigned char data,unsigned char port);
|
||||
int mount_disk_image(const char *,unsigned char );
|
||||
void unmount_disk_image(unsigned char drive);
|
||||
void DiskStatus(char* text_buffer, size_t buffer_size);
|
||||
void PingFdc();
|
||||
unsigned char SetTurboDisk( unsigned char);
|
||||
//unsigned char UseKeyboardLeds(unsigned char);
|
||||
DWORD GetDriverVersion ();
|
||||
unsigned short InitController ();
|
||||
//unsigned long UseRawDisk(unsigned char,unsigned char);
|
||||
// Commands for the wd1793 disk controller $FF48
|
||||
|
||||
struct DiskInfo
|
||||
{
|
||||
HANDLE FileHandle;
|
||||
char ImageName[MAX_PATH];
|
||||
long FileSize;
|
||||
unsigned char HeaderSize;
|
||||
unsigned char Sides; // Number of Sides 1 ot 2
|
||||
unsigned char Sectors; //Sectors Per Track
|
||||
unsigned char SectorSize; //0=128 1=256 2=512 3=1024
|
||||
unsigned char FirstSector; // 0 or 1
|
||||
unsigned char ImageType; //0=JVC 1=VDK 2=DMK 3=OS9
|
||||
unsigned short TrackSize;
|
||||
unsigned char WriteProtect;
|
||||
unsigned char HeadPosition; // The "Physical" Track the head is over
|
||||
unsigned char RawDrive;
|
||||
char ImageTypeName[4];
|
||||
};
|
||||
|
||||
struct SectorInfo
|
||||
{
|
||||
unsigned char Track = 0;
|
||||
unsigned char Side = 0;
|
||||
unsigned char Sector = 0;
|
||||
unsigned short Lenth = 0;
|
||||
unsigned short CRC = 0;
|
||||
long DAM = 0;
|
||||
unsigned char Density = 0;
|
||||
};
|
||||
|
||||
|
||||
#define IDLE 255
|
||||
#define NONE 4
|
||||
#define JVC 0
|
||||
#define VDK 1
|
||||
#define DMK 2
|
||||
#define OS9 3
|
||||
#define RAW 4
|
||||
|
||||
|
||||
//Control register masks
|
||||
#define CTRL_DRIVE0 0x01
|
||||
#define CTRL_DRIVE1 0x02
|
||||
#define CTRL_DRIVE2 0x04
|
||||
#define CTRL_MOTOR_EN 0x08
|
||||
#define CTRL_WRT_PRECMP 0x10
|
||||
#define CTRL_DENSITY 0x20
|
||||
#define CTRL_DRIVE3 0x40
|
||||
#define CTRL_HALT_FLAG 0x80
|
||||
#define SIDESELECT 0x40
|
||||
|
||||
//Status Register return codes
|
||||
#define READY 0
|
||||
#define BUSY 0x01
|
||||
#define DRQ 0x02
|
||||
#define INDEXPULSE 0x02
|
||||
#define TRACK_ZERO 0x04
|
||||
#define LOSTDATA 0x04
|
||||
#define RECNOTFOUND 0x10
|
||||
#define WRITEPROTECT 0x40
|
||||
|
||||
|
||||
#define WAITTIME 5
|
||||
#define STEPTIME 15 // 1 Millisecond = 15.78 Pings
|
||||
#define SETTLETIME 10 // CyclestoSettle
|
||||
|
||||
#define RESTORE 0
|
||||
#define SEEK 1
|
||||
#define STEP 2
|
||||
#define STEPUPD 3
|
||||
#define STEPIN 4
|
||||
#define STEPINUPD 5
|
||||
#define STEPOUT 6
|
||||
#define STEPOUTUPD 7
|
||||
#define READSECTOR 8
|
||||
#define READSECTORM 9
|
||||
#define WRITESECTOR 10
|
||||
#define WRITESECTORM 11
|
||||
#define READADDRESS 12
|
||||
#define FORCEINTERUPT 13
|
||||
#define READTRACK 14
|
||||
#define WRITETRACK 15
|
||||
|
||||
#define HEADERBUFFERSIZE 256
|
||||
|
||||
|
||||
//#define IOCTL_KEYBOARD_SET_INDICATORS CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0002, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
//#define IOCTL_KEYBOARD_QUERY_TYPEMATIC CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0008, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
//#define IOCTL_KEYBOARD_QUERY_INDICATORS CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
//typedef struct _KEYBOARD_INDICATOR_PARAMETERS {
|
||||
// USHORT UnitId; // Unit identifier.
|
||||
// USHORT LedFlags; // LED indicator state.
|
||||
//
|
||||
//} KEYBOARD_INDICATOR_PARAMETERS, *PKEYBOARD_INDICATOR_PARAMETERS;
|
||||
|
||||
//#define KEYBOARD_CAPS_LOCK_ON 4
|
||||
//#define KEYBOARD_NUM_LOCK_ON 2
|
||||
//#define KEYBOARD_SCROLL_LOCK_ON 1
|
||||
|
||||
|
||||
//
|
||||
#define DISK_SIDES 1 // sides per disk
|
||||
#define DISK_TRACKS 35 // tracks per side
|
||||
#define DISK_SECTORS 18 // sectors per track
|
||||
#define DISK_DATARATE 2 // 2 is double-density
|
||||
#define SECTOR_SIZE_CODE 1 // 0=128, 1=256, 2=512, 3=1024, ...
|
||||
#define SECTOR_GAP3 16 // gap3 size between sectors
|
||||
#define SECTOR_FILL 0xFF // fill byte for formatted sectors
|
||||
#define SECTOR_BASE 1 // first sector number on track
|
||||
#define TRACK_SKEW 1 // format skew to the same sector on the next track
|
||||
|
||||
#define TRACK_SIZE ((128<<SECTOR_SIZE_CODE)*DISK_SECTORS)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,116 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2015 by Joseph Forgione
|
||||
// This file is part of VCC (Virtual Color Computer).
|
||||
//
|
||||
// VCC (Virtual Color Computer) is free software: you can redistribute itand/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/>.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include "Cartridge.h"
|
||||
//#include <vcc/util/winapi.h>
|
||||
#include <vcc/util/logger.h>
|
||||
|
||||
namespace detail
|
||||
{
|
||||
void NullAssetCartridgeLine(slot_id_type, bool) {}
|
||||
}
|
||||
|
||||
|
||||
Cartridge* Cartridge::m_Singleton(nullptr);
|
||||
|
||||
|
||||
Cartridge::Cartridge()
|
||||
{
|
||||
if (m_Singleton)
|
||||
{
|
||||
// throw std::runtime_error("Cartridge instance already created.");
|
||||
}
|
||||
|
||||
m_Singleton = this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Cartridge::~Cartridge()
|
||||
{
|
||||
m_Singleton = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void Cartridge::LoadConfiguration(const std::string& /*filename*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//void Cartridge::LoadMenuItems()
|
||||
//{
|
||||
//}
|
||||
|
||||
|
||||
void Cartridge::SetSlotId(slot_id_type SlotId)
|
||||
{
|
||||
m_SlotId = SlotId;
|
||||
}
|
||||
|
||||
|
||||
void Cartridge::SetCartLineAssertCallback(PakAssertCartridgeLineHostCallback callback)
|
||||
{
|
||||
AssetCartridgeLinePtr = callback;
|
||||
}
|
||||
|
||||
|
||||
void Cartridge::SetConfigurationPath(std::string path)
|
||||
{
|
||||
m_ConfigurationPath = move(path);
|
||||
LoadConfiguration(m_ConfigurationPath);
|
||||
// LoadMenuItems();
|
||||
}
|
||||
|
||||
std::string Cartridge::GetStatusMessage() const
|
||||
{
|
||||
return std::string();
|
||||
}
|
||||
|
||||
void Cartridge::OnMenuItemSelected(unsigned char /*menuId*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Cartridge::OnReset()
|
||||
{}
|
||||
|
||||
unsigned short Cartridge::UpdateAudio()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Cartridge::GetMenuItem(menu_item_entry* /*item*/, size_t /*index*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned char Cartridge::OnReadMemory(unsigned short /*address*/) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Cartridge::OnWritePort(unsigned char /*port*/, unsigned char /*data*/)
|
||||
{}
|
||||
|
||||
|
||||
unsigned char Cartridge::OnReadPort(unsigned char /*port*/) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
#pragma once
|
||||
#include "CartridgeTrampolines.h"
|
||||
#include <string>
|
||||
|
||||
namespace detail
|
||||
{
|
||||
void NullAssetCartridgeLine(slot_id_type, bool);
|
||||
}
|
||||
|
||||
class Cartridge
|
||||
{
|
||||
protected:
|
||||
|
||||
Cartridge();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
virtual ~Cartridge();
|
||||
|
||||
|
||||
virtual void SetSlotId(slot_id_type SlotId);
|
||||
virtual void SetCartLineAssertCallback(PakAssertCartridgeLineHostCallback callback);
|
||||
virtual void SetConfigurationPath(std::string path);
|
||||
|
||||
virtual std::string GetStatusMessage() const;
|
||||
virtual void OnMenuItemSelected(unsigned char menuId);
|
||||
|
||||
virtual void OnReset();
|
||||
virtual unsigned short UpdateAudio();
|
||||
virtual unsigned char OnReadMemory(unsigned short address) const;
|
||||
virtual void OnWritePort(unsigned char port, unsigned char data);
|
||||
virtual unsigned char OnReadPort(unsigned char port) const;
|
||||
virtual bool GetMenuItem(menu_item_entry* item, size_t index);
|
||||
|
||||
protected:
|
||||
|
||||
void AssetCartridgeLine(bool state) const
|
||||
{
|
||||
AssetCartridgeLinePtr(m_SlotId, state);
|
||||
}
|
||||
|
||||
virtual void LoadConfiguration(const std::string& filename);
|
||||
// virtual void LoadMenuItems();
|
||||
|
||||
private:
|
||||
|
||||
friend const char* PakGetName();
|
||||
friend const char* PakGetCatalogId();
|
||||
friend void PakInitialize(
|
||||
slot_id_type SlotId,
|
||||
const char* const configuration_path,
|
||||
HWND hVccWnd,
|
||||
const cpak_callbacks* const callbacks);
|
||||
friend void PakGetStatus(char* text_buffer, size_t buffer_size);
|
||||
friend void PakMenuItemClicked(unsigned char menuId);
|
||||
friend void PakReset();
|
||||
friend unsigned char PakReadMemoryByte(unsigned short address);
|
||||
friend void PakWritePort(unsigned char port, unsigned char data);
|
||||
friend unsigned char PakReadPort(unsigned char port);
|
||||
friend unsigned short PakSampleAudio();
|
||||
friend bool PakGetMenuItem(menu_item_entry* item, size_t index);
|
||||
|
||||
private:
|
||||
|
||||
static Cartridge* m_Singleton;
|
||||
|
||||
slot_id_type m_SlotId {};
|
||||
std::string m_Name;
|
||||
std::string m_CatalogId;
|
||||
std::string m_ConfigurationPath;
|
||||
PakAssertCartridgeLineHostCallback AssetCartridgeLinePtr = detail::NullAssetCartridgeLine;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
#include "CartridgeTrampolines.h"
|
||||
#include "Cartridge.h"
|
||||
#include "resource.h"
|
||||
#include <vcc/util/limits.h>
|
||||
#include <vcc/util/logger.h>
|
||||
|
||||
//#define USE_LOGGING
|
||||
|
||||
GMC_EXPORT const char* PakGetName()
|
||||
{
|
||||
static char string_buffer[MAX_LOADSTRING];
|
||||
|
||||
LoadString(gModuleInstance, IDS_MODULE_NAME, string_buffer, MAX_LOADSTRING);
|
||||
|
||||
return string_buffer;
|
||||
}
|
||||
|
||||
GMC_EXPORT const char* PakGetCatalogId()
|
||||
{
|
||||
static char string_buffer[MAX_LOADSTRING];
|
||||
|
||||
LoadString(gModuleInstance, IDS_CATNUMBER, string_buffer, MAX_LOADSTRING);
|
||||
|
||||
return string_buffer;
|
||||
}
|
||||
|
||||
GMC_EXPORT const char* PakGetDescription()
|
||||
{
|
||||
static char string_buffer[MAX_LOADSTRING];
|
||||
|
||||
LoadString(gModuleInstance, IDS_DESCRIPTION, string_buffer, MAX_LOADSTRING);
|
||||
|
||||
return string_buffer;
|
||||
}
|
||||
|
||||
HWND gVccWnd;
|
||||
GMC_EXPORT void PakInitialize(
|
||||
slot_id_type SlotId,
|
||||
const char* const configuration_path,
|
||||
HWND hVccWnd,
|
||||
const cpak_callbacks* const callbacks)
|
||||
{
|
||||
gVccWnd = hVccWnd;
|
||||
|
||||
DLOG_C("GMC %p %p %p %p\n",
|
||||
callbacks->assert_interrupt,
|
||||
callbacks->assert_cartridge_line,
|
||||
callbacks->write_memory_byte,
|
||||
callbacks->read_memory_byte);
|
||||
|
||||
Cartridge::m_Singleton->SetSlotId(SlotId);
|
||||
Cartridge::m_Singleton->SetCartLineAssertCallback(callbacks->assert_cartridge_line);
|
||||
Cartridge::m_Singleton->SetConfigurationPath(configuration_path);
|
||||
}
|
||||
|
||||
|
||||
GMC_EXPORT void PakMenuItemClicked(unsigned char menuId)
|
||||
{
|
||||
Cartridge::m_Singleton->OnMenuItemSelected(menuId);
|
||||
}
|
||||
|
||||
|
||||
GMC_EXPORT void PakReset()
|
||||
{
|
||||
Cartridge::m_Singleton->OnReset();
|
||||
}
|
||||
|
||||
|
||||
GMC_EXPORT void PakGetStatus(char* text_buffer, size_t buffer_size)
|
||||
{
|
||||
auto message(Cartridge::m_Singleton->GetStatusMessage());
|
||||
if (message.size() > 63)
|
||||
{
|
||||
message.resize(63);
|
||||
}
|
||||
|
||||
strcpy(text_buffer, message.c_str());
|
||||
}
|
||||
|
||||
|
||||
GMC_EXPORT unsigned char PakReadMemoryByte(unsigned short address)
|
||||
{
|
||||
return Cartridge::m_Singleton->OnReadMemory(address);
|
||||
}
|
||||
|
||||
GMC_EXPORT void PakWritePort(unsigned char port, unsigned char data)
|
||||
{
|
||||
Cartridge::m_Singleton->OnWritePort(port, data);
|
||||
}
|
||||
|
||||
|
||||
GMC_EXPORT unsigned char PakReadPort(unsigned char port)
|
||||
{
|
||||
return Cartridge::m_Singleton->OnReadPort(port);
|
||||
}
|
||||
|
||||
|
||||
// This gets called at the end of every scan line 262 Lines * 60 Frames = 15780 Hz 15720
|
||||
GMC_EXPORT unsigned short PakSampleAudio()
|
||||
{
|
||||
return Cartridge::m_Singleton->UpdateAudio();
|
||||
}
|
||||
|
||||
// Return menu
|
||||
GMC_EXPORT bool PakGetMenuItem(menu_item_entry* item, size_t index)
|
||||
{
|
||||
return Cartridge::m_Singleton->GetMenuItem(item, index);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
#include "GMC.h"
|
||||
|
||||
GMC_EXPORT const char* PakGetName();
|
||||
GMC_EXPORT const char* PakGetCatalogId();
|
||||
GMC_EXPORT void PakInitialize(
|
||||
slot_id_type SlotId,
|
||||
const char* const configuration_path,
|
||||
HWND hVccWnd,
|
||||
const cpak_callbacks* const callbacks);
|
||||
|
||||
GMC_EXPORT void PakGetStatus(char* text_buffer, size_t buffer_size);
|
||||
GMC_EXPORT void PakMenuItemClicked(unsigned char /*menuId*/);
|
||||
GMC_EXPORT void PakReset();
|
||||
GMC_EXPORT unsigned char PakReadMemoryByte(unsigned short address);
|
||||
GMC_EXPORT void PakWritePort(unsigned char port, unsigned char data);
|
||||
GMC_EXPORT unsigned char PakReadPort(unsigned char port);
|
||||
GMC_EXPORT unsigned short PakSampleAudio();
|
||||
GMC_EXPORT bool PakGetMenuItem(menu_item_entry* item, size_t index);
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "Configuration.h"
|
||||
#include <io.h>
|
||||
#include <Windows.h>
|
||||
#include <vcc/util/settings.h>
|
||||
|
||||
using settings = ::VCC::Util::settings;
|
||||
|
||||
Configuration::Configuration(std::string filename)
|
||||
: m_Filename(move(filename))
|
||||
{
|
||||
m_ActiveROM = settings(m_Filename).read("GMC-SN74689","ROM");
|
||||
|
||||
//Chet had plans for an MRU list. maybe someday...
|
||||
// MRUListType mruROMList;
|
||||
// for (auto i(0U); ; ++i)
|
||||
// {
|
||||
// const auto keyName("ROM" + std::to_string(i));
|
||||
// if (!GetPrivateProfileStringA(moduleName, keyName.c_str(), "",
|
||||
// pathBuffer, MAX_PATH, m_Filename.c_str()))
|
||||
// break;
|
||||
// mruROMList.emplace_back(pathBuffer);
|
||||
// }
|
||||
// m_MRURoms = move(mruROMList);
|
||||
}
|
||||
|
||||
std::string Configuration::GetActiveRom() const
|
||||
{
|
||||
return m_ActiveROM;
|
||||
}
|
||||
|
||||
void Configuration::SetActiveRom(std::string filename)
|
||||
{
|
||||
m_ActiveROM = filename;
|
||||
settings(m_Filename).write("GMC-SN74689","ROM",filename);
|
||||
|
||||
// m_MRURoms.emplace_back(m_ActiveROM);
|
||||
// m_ActiveROM = filename;
|
||||
// static const auto moduleName = "GMC-SN74689";
|
||||
// WritePrivateProfileStringA(moduleName, "ROM", filename.data(), m_Filename.c_str());
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
class Configuration
|
||||
{
|
||||
public:
|
||||
|
||||
Configuration() = default;
|
||||
explicit Configuration(std::string filename);
|
||||
virtual ~Configuration() = default;
|
||||
|
||||
std::string GetActiveRom() const;
|
||||
void SetActiveRom(std::string filename);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
using MRUListType = std::vector<std::string>;
|
||||
|
||||
std::string m_Filename;
|
||||
MRUListType m_MRURoms;
|
||||
std::string m_ActiveROM;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vcc/bus/cpak_cartridge_definitions.h>
|
||||
#include <vcc/bus/cartridge_menuitem.h>
|
||||
|
||||
#ifdef GMC_EXPORTS
|
||||
#define GMC_EXPORT extern "C" __declspec(dllexport)
|
||||
#else
|
||||
#define GMC_EXPORT
|
||||
#endif
|
||||
|
||||
extern HINSTANCE gModuleInstance;
|
||||
std::string SelectROMFile();
|
||||
std::string ExtractFilename(std::string path);
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (United States) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 2,1,8,1
|
||||
PRODUCTVERSION 2,1,8,1
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x21L
|
||||
#else
|
||||
FILEFLAGS 0x20L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "Comments", "Game Master Cartridge (SN76489)"
|
||||
VALUE "FileDescription", "GMC"
|
||||
VALUE "FileVersion", "2.1.8.1"
|
||||
VALUE "InternalName", "orch90"
|
||||
VALUE "LegalCopyright", "Copyright � 2019"
|
||||
VALUE "OriginalFilename", "gmc.dll"
|
||||
VALUE "ProductName", "Game Master Cartridge (SN76489)"
|
||||
VALUE "ProductVersion", "26-XXXX"
|
||||
VALUE "SpecialBuild", "Game Master Cartridge (SN76489)"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_MODULE_NAME "Game Master Catridge"
|
||||
IDS_CATNUMBER "26-XXXX"
|
||||
IDS_DESCRIPTION "Emulates John Linville's Game Master Cart. This cartridge provides a dedicated sound chip (SN76489) and more memory, allowing for enhanced graphics and audio in games. GMC ROMS usually assume that the Game Master Cart is loaded in MMI slot 1"
|
||||
IDS_VERSION "1.0"
|
||||
END
|
||||
|
||||
#endif // English (United States) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
#include "GMCCartridge.h"
|
||||
#include <Windows.h>
|
||||
#include <vcc/util/logger.h>
|
||||
#include <vcc/bus/cartridge_menu.h>
|
||||
#include <vcc/bus/cartridge_messages.h>
|
||||
|
||||
static VCC::Bus::cartridge_menu GMCMenu {};
|
||||
|
||||
void GMCCartridge::LoadConfiguration(const std::string& filename)
|
||||
{
|
||||
Cartridge::LoadConfiguration(filename);
|
||||
m_Configuration = Configuration(filename);
|
||||
}
|
||||
|
||||
bool GMCCartridge::GetMenuItem(menu_item_entry* item, size_t index)
|
||||
{
|
||||
if (!item) return false;
|
||||
// request zero rebuilds the menu list but does it ever change?
|
||||
// leave it incase we want to show the loaded rom in the menu
|
||||
if (index == 0) {
|
||||
GMCMenu.clear();
|
||||
GMCMenu.add("", 0, MIT_Seperator);
|
||||
GMCMenu.add("Select GMC ROM", ControlId(MenuItems::SelectRom), MIT_StandAlone);
|
||||
}
|
||||
// return requested list item or false
|
||||
return GMCMenu.copy_item(*item, index);
|
||||
}
|
||||
|
||||
std::string GMCCartridge::GetStatusMessage() const
|
||||
{
|
||||
std::string message("GMC Active");
|
||||
|
||||
const auto activeRom(ExtractFilename(m_ROMImage.GetFilename()));
|
||||
if (m_ROMImage.HasImage())
|
||||
{
|
||||
message += " (" + activeRom + " Loaded)";
|
||||
}
|
||||
else
|
||||
{
|
||||
message += activeRom.empty() ? " (No ROM Selected)" : "(Unable to load `" + activeRom + "`)";
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
void GMCCartridge::OnMenuItemSelected(unsigned char menuId)
|
||||
{
|
||||
if (menuId == MenuItems::SelectRom)
|
||||
{
|
||||
const auto selectedFile(SelectROMFile());
|
||||
m_Configuration.SetActiveRom(selectedFile);
|
||||
|
||||
extern HWND gVccWnd;
|
||||
SendMessage(gVccWnd, WM_VCC_CPU_RESET, (WPARAM)0, (LPARAM)0);
|
||||
|
||||
AssetCartridgeLine(false);
|
||||
AssetCartridgeLine(true);
|
||||
}
|
||||
}
|
||||
|
||||
void GMCCartridge::OnReset()
|
||||
{
|
||||
m_PSG.device_start();
|
||||
|
||||
if (m_ROMImage.Load(m_Configuration.GetActiveRom()))
|
||||
{
|
||||
AssetCartridgeLine(false);
|
||||
AssetCartridgeLine(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ROMImage.Unload();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned short GMCCartridge::UpdateAudio()
|
||||
{
|
||||
SN76489Device::stream_sample_t lbuffer, rbuffer;
|
||||
|
||||
return m_PSG.sound_stream_update(lbuffer, rbuffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned char GMCCartridge::OnReadMemory(unsigned short address) const
|
||||
{
|
||||
return m_ROMImage.Read(address);
|
||||
}
|
||||
|
||||
|
||||
void GMCCartridge::OnWritePort(unsigned char port, unsigned char data)
|
||||
{
|
||||
if (port < 0x40 && port > 0x5f) return;
|
||||
|
||||
switch (port&1)
|
||||
{
|
||||
case Ports::BankSelect:
|
||||
m_ROMImage.SetBank(data);
|
||||
break;
|
||||
|
||||
case Ports::PSG:
|
||||
m_PSG.write(data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsigned char GMCCartridge::OnReadPort(unsigned char port) const
|
||||
{
|
||||
if (port < 0x40 && port > 0x5f) return 0;
|
||||
|
||||
if ((port&1) == Ports::BankSelect)
|
||||
{
|
||||
return m_ROMImage.GetBank();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
#include "Cartridge.h"
|
||||
#include "ROM.h"
|
||||
#include "sn76496.h"
|
||||
#include "Configuration.h"
|
||||
|
||||
|
||||
class GMCCartridge : public Cartridge
|
||||
{
|
||||
public:
|
||||
|
||||
void LoadConfiguration(const std::string& filename) override;
|
||||
|
||||
std::string GetStatusMessage() const override;
|
||||
void OnMenuItemSelected(unsigned char menuId) override;
|
||||
void OnReset() override;
|
||||
unsigned short UpdateAudio() override;
|
||||
unsigned char OnReadMemory(unsigned short address) const override;
|
||||
void OnWritePort(unsigned char port, unsigned char data) override;
|
||||
unsigned char OnReadPort(unsigned char port) const override;
|
||||
bool GetMenuItem(menu_item_entry* item, size_t index) override;
|
||||
|
||||
private:
|
||||
|
||||
struct MenuItems
|
||||
{
|
||||
static const unsigned int SelectRom = 10;
|
||||
};
|
||||
|
||||
struct Ports
|
||||
{
|
||||
static const unsigned char BankSelect = 0;
|
||||
static const unsigned char PSG = 1;
|
||||
};
|
||||
|
||||
ROM m_ROMImage;
|
||||
SN76489Device m_PSG;
|
||||
Configuration m_Configuration;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
#include "ROM.h"
|
||||
#include <fstream>
|
||||
#include <Windows.h>
|
||||
using namespace std;
|
||||
|
||||
bool ROM::Load(std::string filename)
|
||||
{
|
||||
ifstream input(filename,ios::binary);
|
||||
if (!input.is_open())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::streamoff begin = input.tellg();
|
||||
input.seekg(0,ios::end);
|
||||
std::streamoff end = input.tellg();
|
||||
std::streamoff fileLength = end - begin;
|
||||
input.seekg(0,ios::beg);
|
||||
|
||||
std::vector<unsigned char> fileData(static_cast<size_t>(fileLength));
|
||||
input.read(reinterpret_cast<char*>(&fileData[0]), fileData.size());
|
||||
|
||||
if (fileLength != fileData.size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_Filename = move(filename);
|
||||
m_Data = move(fileData);
|
||||
m_BankOffset = 0;
|
||||
m_Bank = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ROM::Unload()
|
||||
{
|
||||
m_Data.clear();
|
||||
m_BankOffset = 0;
|
||||
m_Bank = 0;
|
||||
}
|
||||
|
||||
|
||||
void ROM::Reset()
|
||||
{
|
||||
SetBank(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ROM::SetBank(unsigned char blockId)
|
||||
{
|
||||
if (!m_Data.empty())
|
||||
{
|
||||
m_Bank = blockId;
|
||||
m_BankOffset = blockId * BankSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsigned char ROM::GetBank() const
|
||||
{
|
||||
return m_Bank;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ROM::value_type ROM::Read(size_type readOffset) const
|
||||
{
|
||||
if (m_Data.empty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return m_Data[(m_BankOffset + readOffset) % m_Data.size()];
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class ROM
|
||||
{
|
||||
public:
|
||||
|
||||
using container_type = std::vector<unsigned char>;
|
||||
using value_type = container_type::value_type;
|
||||
using size_type = container_type::size_type;
|
||||
|
||||
static const unsigned BankSize = 16384; // 8k banks
|
||||
|
||||
virtual ~ROM() = default;
|
||||
|
||||
bool HasImage() const
|
||||
{
|
||||
return !m_Data.empty();
|
||||
}
|
||||
|
||||
std::string GetFilename() const
|
||||
{
|
||||
return m_Filename;
|
||||
}
|
||||
|
||||
virtual bool Load(std::string filename);
|
||||
virtual void Unload();
|
||||
virtual void Reset();
|
||||
|
||||
virtual void SetBank(unsigned char blockId);
|
||||
virtual unsigned char GetBank() const;
|
||||
virtual value_type Read(size_type offset) const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
std::string m_Filename;
|
||||
unsigned char m_Bank = 0;
|
||||
size_type m_BankOffset = 0;
|
||||
container_type m_Data;
|
||||
};
|
||||
@@ -0,0 +1,122 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Legacy|Win32">
|
||||
<Configuration>Legacy</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<SccProjectName />
|
||||
<SccLocalPath />
|
||||
<ProjectGuid>{BD7CA587-71D0-43D6-A730-582126B1C1F4}</ProjectGuid>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\vcc-base.props" />
|
||||
<Import Project="..\vcc-legacy.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\vcc-base.props" />
|
||||
<Import Project="..\vcc-release.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\vcc-base.props" />
|
||||
<Import Project="..\vcc-debug.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">
|
||||
<LibraryPath>C:\Program Files %28x86%29\Windows Kits\8.1\Lib\winv6.3\um\x86;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;GMC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ResourceCompile />
|
||||
<Link>
|
||||
<LinkDLL>true</LinkDLL>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_USRDLL;GMC_EXPORTS;_LEGACY_VCC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalOptions>/arch:SSE</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<LinkDLL>true</LinkDLL>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;GMC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalOptions>/arch:SSE</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<ResourceCompile />
|
||||
<Link>
|
||||
<LinkDLL>true</LinkDLL>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Cartridge.cpp" />
|
||||
<ClCompile Include="CartridgeTrampolines.cpp" />
|
||||
<ClCompile Include="Configuration.cpp" />
|
||||
<ClCompile Include="GMCCartridge.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="ROM.cpp" />
|
||||
<ClCompile Include="sn76496.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="CartridgeTrampolines.h" />
|
||||
<ClInclude Include="Configuration.h" />
|
||||
<ClInclude Include="GMC.h" />
|
||||
<ClInclude Include="Cartridge.h" />
|
||||
<ClInclude Include="GMCCartridge.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="ROM.h" />
|
||||
<ClInclude Include="sn76496.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="GMC.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\libcommon\libcommon.vcxproj">
|
||||
<Project>{e0aa25bd-5527-475f-8d8b-b549a6311b0c}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Cartridge.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CartridgeTrampolines.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Configuration.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GMCCartridge.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ROM.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sn76496.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Cartridge.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CartridgeTrampolines.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Configuration.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GMC.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GMCCartridge.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ROM.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sn76496.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{91041c29-a58e-47d1-be3c-2181e226240f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{1bc76e3c-f021-4d3d-9abc-d398f3daab81}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{c2b09bad-8285-4ea1-9cde-aaaa010a2925}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="GMC.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,68 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2015 by Joseph Forgione
|
||||
// This file is part of VCC (Virtual Color Computer).
|
||||
//
|
||||
// VCC (Virtual Color Computer) is free software: you can redistribute itand/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/>.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <Windows.h>
|
||||
#include "GMCCartridge.h"
|
||||
#include <vcc/util/DialogOps.h>
|
||||
|
||||
HINSTANCE gModuleInstance = nullptr;
|
||||
GMCCartridge theCart;
|
||||
|
||||
std::string ExtractFilename(std::string path)
|
||||
{
|
||||
char filename[MAX_PATH];
|
||||
char ext[MAX_PATH];
|
||||
|
||||
_splitpath(path.c_str(), nullptr, nullptr, filename, ext);
|
||||
path = filename;
|
||||
if (ext[0])
|
||||
{
|
||||
path += ext;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
std::string SelectROMFile()
|
||||
{
|
||||
std::string selectedPath;
|
||||
|
||||
FileDialog dlg;
|
||||
dlg.setFilter("ROM Files\0*.ROM\0\0");
|
||||
dlg.setDefExt("rom");
|
||||
dlg.setTitle("Select GMC Rom file");
|
||||
if (dlg.show()) {
|
||||
selectedPath = dlg.path();
|
||||
} else {
|
||||
selectedPath.clear();
|
||||
}
|
||||
return selectedPath;
|
||||
}
|
||||
|
||||
|
||||
BOOL APIENTRY DllMain(HINSTANCE hinst, DWORD reason, LPVOID foo)
|
||||
{
|
||||
if (reason == DLL_PROCESS_ATTACH) {
|
||||
gModuleInstance = hinst;
|
||||
} else if (reason == DLL_PROCESS_DETACH) {
|
||||
//Clean up here.
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by GMC.rc
|
||||
//
|
||||
#define IDS_MODULE_NAME 1
|
||||
#define IDS_CATNUMBER 2
|
||||
#define IDS_DESCRIPTION 3
|
||||
#define IDS_VERSION 4
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,380 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Nicola Salmoria
|
||||
/***************************************************************************
|
||||
|
||||
sn76496.c
|
||||
by Nicola Salmoria
|
||||
with contributions by others
|
||||
|
||||
Routines to emulate the:
|
||||
Texas Instruments SN76489, SN76489A, SN76494/SN76496
|
||||
( Also known as, or at least compatible with, the TMS9919 and SN94624.)
|
||||
and the Sega 'PSG' used on the Master System, Game Gear, and Megadrive/Genesis
|
||||
This chip is known as the Programmable Sound Generator, or PSG, and is a 4
|
||||
channel sound generator, with three squarewave channels and a noise/arbitrary
|
||||
duty cycle channel.
|
||||
|
||||
Noise emulation for all verified chips should be accurate:
|
||||
|
||||
** SN76489 uses a 15-bit shift register with taps on bits D and E, output on E,
|
||||
XOR function.
|
||||
It uses a 15-bit ring buffer for periodic noise/arbitrary duty cycle.
|
||||
Its output is inverted.
|
||||
** SN94624 is the same as SN76489 but lacks the /8 divider on its clock input.
|
||||
** SN76489A uses a 15-bit shift register with taps on bits D and E, output on F,
|
||||
XOR function.
|
||||
It uses a 15-bit ring buffer for periodic noise/arbitrary duty cycle.
|
||||
Its output is not inverted.
|
||||
** SN76494 is the same as SN76489A but lacks the /8 divider on its clock input.
|
||||
** SN76496 is identical in operation to the SN76489A, but the audio input on pin 9 is
|
||||
documented.
|
||||
All the TI-made PSG chips have an audio input line which is mixed with the 4 channels
|
||||
of output. (It is undocumented and may not function properly on the sn76489, 76489a
|
||||
and 76494; the sn76489a input is mentioned in datasheets for the tms5200)
|
||||
All the TI-made PSG chips act as if the frequency was set to 0x400 if 0 is
|
||||
written to the frequency register.
|
||||
** Sega Master System III/MD/Genesis PSG uses a 16-bit shift register with taps
|
||||
on bits C and F, output on F
|
||||
It uses a 16-bit ring buffer for periodic noise/arbitrary duty cycle.
|
||||
(whether it uses an XOR or XNOR needs to be verified, assumed XOR)
|
||||
(whether output is inverted or not needs to be verified, assumed to be inverted)
|
||||
** Sega Game Gear PSG is identical to the SMS3/MD/Genesis one except it has an
|
||||
extra register for mapping which channels go to which speaker.
|
||||
The register, connected to a z80 port, means:
|
||||
for bits 7 6 5 4 3 2 1 0
|
||||
L3 L2 L1 L0 R3 R2 R1 R0
|
||||
Noise is an XOR function, and audio output is negated before being output.
|
||||
All the Sega-made PSG chips act as if the frequency was set to 0 if 0 is written
|
||||
to the frequency register.
|
||||
** NCR8496 (as used on the Tandy 1000TX) is similar to the SN76489 but with a
|
||||
different noise LFSR pattern: taps on bits A and E, output on E, XNOR function
|
||||
It uses a 15-bit ring buffer for periodic noise/arbitrary duty cycle.
|
||||
Its output is inverted.
|
||||
** PSSJ-3 (as used on the later Tandy 1000 series computers) is the same as the
|
||||
NCR8496 with the exception that its output is not inverted.
|
||||
|
||||
1/1/2019: Chet Simpson
|
||||
Refactored for use with VCC Color Computer 3 Emulator
|
||||
|
||||
28/03/2005 : Sebastien Chevalier
|
||||
Update th SN76496Write func, according to SN76489 doc found on SMSPower.
|
||||
- On write with 0x80 set to 0, when LastRegister is other then TONE,
|
||||
the function is similar than update with 0x80 set to 1
|
||||
|
||||
23/04/2007 : Lord Nightmare
|
||||
Major update, implement all three different noise generation algorithms and a
|
||||
set_variant call to discern among them.
|
||||
|
||||
28/04/2009 : Lord Nightmare
|
||||
Add READY line readback; cleaned up struct a bit. Cleaned up comments.
|
||||
Add more TODOs. Fixed some unsaved savestate related stuff.
|
||||
|
||||
04/11/2009 : Lord Nightmare
|
||||
Changed the way that the invert works (it now selects between XOR and XNOR
|
||||
for the taps), and added R->OldNoise to simulate the extra 0 that is always
|
||||
output before the noise LFSR contents are after an LFSR reset.
|
||||
This fixes SN76489/A to match chips. Added SN94624.
|
||||
|
||||
14/11/2009 : Lord Nightmare
|
||||
Removed STEP mess, vastly simplifying the code. Made output bipolar rather
|
||||
than always above the 0 line, but disabled that code due to pending issues.
|
||||
|
||||
16/11/2009 : Lord Nightmare
|
||||
Fix screeching in regulus: When summing together four equal channels, the
|
||||
size of the max amplitude per channel should be 1/4 of the max range, not
|
||||
1/3. Added NCR8496.
|
||||
|
||||
18/11/2009 : Lord Nightmare
|
||||
Modify Init functions to support negating the audio output. The gamegear
|
||||
psg does this. Change gamegear and sega psgs to use XOR rather than XNOR
|
||||
based on testing. Got rid of R->OldNoise and fixed taps accordingly.
|
||||
Added stereo support for game gear.
|
||||
|
||||
15/01/2010 : Lord Nightmare
|
||||
Fix an issue with SN76489 and SN76489A having the wrong periodic noise periods.
|
||||
Note that properly emulating the noise cycle bit timing accurately may require
|
||||
extensive rewriting.
|
||||
|
||||
24/01/2010: Lord Nightmare
|
||||
Implement periodic noise as forcing one of the XNOR or XOR taps to 1 or 0 respectively.
|
||||
Thanks to PlgDavid for providing samples which helped immensely here.
|
||||
Added true clock divider emulation, so sn94624 and sn76494 run 8x faster than
|
||||
the others, as in real life.
|
||||
|
||||
15/02/2010: Lord Nightmare & Michael Zapf (additional testing by PlgDavid)
|
||||
Fix noise period when set to mirror channel 3 and channel 3 period is set to 0 (tested on hardware for noise, wave needs tests) - MZ
|
||||
Fix phase of noise on sn94624 and sn76489; all chips use a standard XOR, the only inversion is the output itself - LN, Plgdavid
|
||||
Thanks to PlgDavid and Michael Zapf for providing samples which helped immensely here.
|
||||
|
||||
23/02/2011: Lord Nightmare & Enik
|
||||
Made it so the Sega PSG chips have a frequency of 0 if 0 is written to the
|
||||
frequency register, while the others have 0x400 as before. Should fix a bug
|
||||
or two on sega games, particularly Vigilante on Sega Master System. Verified
|
||||
on SMS hardware.
|
||||
|
||||
27/06/2012: Michael Zapf
|
||||
Converted to modern device, legacy devices were gradually removed afterwards.
|
||||
|
||||
16/09/2015: Lord Nightmare
|
||||
Fix PSG chips to have volume reg inited on reset to 0x0 based on tests by
|
||||
ValleyBell. Made Sega PSG chips start up with register 0x3 selected (volume
|
||||
for channel 2) based on hardware tests by Nemesis.
|
||||
|
||||
03/09/2018: Lord Nightmare, Qbix, ValleyBell, NewRisingSun
|
||||
* renamed the NCR8496 to its correct name, based on chip pictures on VGMPF
|
||||
* fixed NCR8496's noise LFSR behavior so it is only reset if the mode bit in
|
||||
register 6 is changed.
|
||||
* NCR8496's LFSR feedback function is an XNOR, which is now supported.
|
||||
* add PSSJ-3 support for the later Tandy 1000 series computers.
|
||||
* NCR8496's output is inverted, PSSJ-3's output is not.
|
||||
|
||||
16/10/2026: Craig Allsop
|
||||
* fix integration with vcc and return the expected format.
|
||||
|
||||
TODO: * Implement the TMS9919 - any difference to sn94624?
|
||||
* Implement the T6W28; has registers in a weird order, needs writes
|
||||
to be 'sanitized' first. Also is stereo, similar to game gear.
|
||||
* Factor out common code so that the SAA1099 can share some code.
|
||||
* verify NCR8496/PSSJ-3 behavior on write to mirrored registers; unlike the
|
||||
other variants, the NCR-derived variants are implied to ignore writes to
|
||||
regs 1,3,5,6,7 if 0x80 is not set. This needs to be verified on real hardware.
|
||||
|
||||
***************************************************************************/
|
||||
#include "sn76496.h"
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
|
||||
// was: #define MAX_OUTPUT 0x7fff
|
||||
// changed to use the full range since output is always positive atm, each
|
||||
// channel is given MAX_OUTPUT/4, this is rounded to integer so there is
|
||||
// already loss. See: https://www.smspower.org/Development/SN76489 actual
|
||||
// output is 0/1 (before filtering). If this is changed to +-0.5 then this
|
||||
// should be updated of course.
|
||||
#define MAX_OUTPUT 0xffff
|
||||
|
||||
|
||||
void SN76489Device::device_start()
|
||||
{
|
||||
for (int i = 0; i < 8; i += 2)
|
||||
{
|
||||
m_register[i] = 0;
|
||||
m_register[i + 1] = 0; // volume = 0x0 (max volume) on reset; this needs testing on chips other than SN76489A and Sega VDP PSG
|
||||
}
|
||||
m_last_register = m_sega_style_psg ? 3 : 0; // Sega VDP PSG defaults to selected period reg for 2nd channel
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
m_period[i] = 0;
|
||||
m_volume[i] = 0;
|
||||
m_count[i] = 0;
|
||||
m_output[i] = 0;
|
||||
}
|
||||
|
||||
m_RNG = m_feedback_mask;
|
||||
m_output[3] = m_RNG & 1;
|
||||
|
||||
m_cycles_to_ready = 1; // assume ready is not active immediately on init. is this correct?
|
||||
m_stereo_mask = 0xFF; // all channels enabled
|
||||
|
||||
|
||||
// build volume table (2dB per step)
|
||||
double out = MAX_OUTPUT / 4; // four channels, each gets 1/4 of the total range
|
||||
for (int i = 0; i < 15; i++)
|
||||
{
|
||||
// limit volume to avoid clipping
|
||||
if (out > MAX_OUTPUT / 4)
|
||||
{
|
||||
m_vol_table[i] = MAX_OUTPUT / 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_vol_table[i] = static_cast<int32_t>(out);
|
||||
}
|
||||
|
||||
out /= 1.258925412; /* = 10 ^ (2/20) = 2dB */
|
||||
}
|
||||
m_vol_table[15] = 0;
|
||||
|
||||
m_ready_state = true;
|
||||
}
|
||||
|
||||
|
||||
void SN76489Device::write(uint8_t data)
|
||||
{
|
||||
int n, r, c;
|
||||
|
||||
// set number of cycles until READY is active; this is always one
|
||||
// 'sample', i.e. it equals the clock divider exactly
|
||||
m_cycles_to_ready = 1;
|
||||
|
||||
if (data & 0x80)
|
||||
{
|
||||
r = (data & 0x70) >> 4;
|
||||
m_last_register = r;
|
||||
if ((m_ncr_style_psg && (r == 6)) && ((data & 0x04) != (m_register[6] & 0x04)))
|
||||
{
|
||||
m_RNG = m_feedback_mask; // NCR-style PSG resets the LFSR only on a mode write which actually changes the state of bit 2 of register 6
|
||||
}
|
||||
m_register[r] = (m_register[r] & 0x3f0) | (data & 0x0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
r = m_last_register;
|
||||
//if ((m_ncr_style_psg) && ((r & 1) || (r == 6))) return; // NCR-style PSG ignores writes to regs 1, 3, 5, 6 and 7 with bit 7 clear; this behavior is not verified on hardware yet, uncomment it once verified.
|
||||
}
|
||||
|
||||
c = r >> 1;
|
||||
switch (r)
|
||||
{
|
||||
case 0: // tone 0: frequency
|
||||
case 2: // tone 1: frequency
|
||||
case 4: // tone 2: frequency
|
||||
if ((data & 0x80) == 0)
|
||||
{
|
||||
m_register[r] = (m_register[r] & 0x0f) | ((data & 0x3f) << 4);
|
||||
}
|
||||
|
||||
if (m_register[r] != 0 || !m_sega_style_psg)
|
||||
{
|
||||
m_period[c] = m_register[r];
|
||||
}
|
||||
else
|
||||
{
|
||||
m_period[c] = 0x400;
|
||||
}
|
||||
|
||||
if (r == 4)
|
||||
{
|
||||
// update noise shift frequency
|
||||
if ((m_register[6] & 0x03) == 0x03)
|
||||
{
|
||||
m_period[3] = m_period[2] << 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 1: // tone 0: volume
|
||||
case 3: // tone 1: volume
|
||||
case 5: // tone 2: volume
|
||||
case 7: // noise: volume
|
||||
m_volume[c] = m_vol_table[data & 0x0f];
|
||||
if ((data & 0x80) == 0)
|
||||
{
|
||||
m_register[r] = (m_register[r] & 0x3f0) | (data & 0x0f);
|
||||
}
|
||||
break;
|
||||
|
||||
case 6: // noise: frequency, mode
|
||||
//if ((data & 0x80) == 0) logerror("SN76489Device: write to reg 6 with bit 7 clear; data was %03x, new write is %02x! report this to LN!\n", m_register[6], data);
|
||||
if ((data & 0x80) == 0)
|
||||
{
|
||||
m_register[r] = (m_register[r] & 0x3f0) | (data & 0x0f);
|
||||
}
|
||||
n = m_register[6];
|
||||
// N/512,N/1024,N/2048,Tone #3 output
|
||||
m_period[3] = ((n & 3) == 3) ? (m_period[2] << 1) : (1 << (5 + (n & 3)));
|
||||
if (!m_ncr_style_psg)
|
||||
{
|
||||
m_RNG = m_feedback_mask;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool SN76489Device::in_noise_mode() const
|
||||
{
|
||||
return ((m_register[6] & 4) != 0);
|
||||
}
|
||||
|
||||
void SN76489Device::countdown_cycles()
|
||||
{
|
||||
if (m_cycles_to_ready > 0)
|
||||
{
|
||||
m_cycles_to_ready--;
|
||||
//if (m_ready_state==true) m_ready_handler(CLEAR_LINE);
|
||||
m_ready_state = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//if (m_ready_state==false) m_ready_handler(ASSERT_LINE);
|
||||
m_ready_state = true;
|
||||
}
|
||||
}
|
||||
|
||||
SN76489Device::stream_sample_t SN76489Device::sound_stream_update(stream_sample_t& lbuffer, stream_sample_t& rbuffer)
|
||||
{
|
||||
// decrement Cycles to READY by one
|
||||
countdown_cycles();
|
||||
|
||||
// handle channels 0,1,2
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
m_count[i]--;
|
||||
if (m_count[i] <= 0)
|
||||
{
|
||||
m_output[i] ^= 1;
|
||||
m_count[i] = static_cast<int32_t>(static_cast<float>(m_period[i]) / m_period_divider);
|
||||
}
|
||||
}
|
||||
|
||||
// handle channel 3
|
||||
m_count[3]--;
|
||||
if (m_count[3] <= 0)
|
||||
{
|
||||
// if noisemode is 1, both taps are enabled
|
||||
// if noisemode is 0, the lower tap, whitenoisetap2, is held at 0
|
||||
// The != was a bit-XOR (^) before
|
||||
if (((m_RNG & m_whitenoise_tap1)!=0) != (((static_cast<int32_t>(m_RNG) & m_whitenoise_tap2)!=(m_ncr_style_psg?m_whitenoise_tap2:0)) && in_noise_mode()))
|
||||
{
|
||||
m_RNG >>= 1;
|
||||
m_RNG |= m_feedback_mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_RNG >>= 1;
|
||||
}
|
||||
m_output[3] = m_RNG & 1;
|
||||
|
||||
m_count[3] = static_cast<int32_t>(static_cast<float>(m_period[3]) / m_period_divider);
|
||||
}
|
||||
|
||||
int out;
|
||||
int out2 = 0;
|
||||
|
||||
if (m_stereo)
|
||||
{
|
||||
out = ((((m_stereo_mask & 0x10)!=0) && (m_output[0]!=0))? m_volume[0] : 0)
|
||||
+ ((((m_stereo_mask & 0x20)!=0) && (m_output[1]!=0))? m_volume[1] : 0)
|
||||
+ ((((m_stereo_mask & 0x40)!=0) && (m_output[2]!=0))? m_volume[2] : 0)
|
||||
+ ((((m_stereo_mask & 0x80)!=0) && (m_output[3]!=0))? m_volume[3] : 0);
|
||||
|
||||
out2= ((((m_stereo_mask & 0x1)!=0) && (m_output[0]!=0))? m_volume[0] : 0)
|
||||
+ ((((m_stereo_mask & 0x2)!=0) && (m_output[1]!=0))? m_volume[1] : 0)
|
||||
+ ((((m_stereo_mask & 0x4)!=0) && (m_output[2]!=0))? m_volume[2] : 0)
|
||||
+ ((((m_stereo_mask & 0x8)!=0) && (m_output[3]!=0))? m_volume[3] : 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
out= ((m_output[0]!=0)? m_volume[0]:0)
|
||||
+((m_output[1]!=0)? m_volume[1]:0)
|
||||
+((m_output[2]!=0)? m_volume[2]:0)
|
||||
+((m_output[3]!=0)? m_volume[3]:0);
|
||||
|
||||
// output mono to both channels
|
||||
out2 = out;
|
||||
}
|
||||
|
||||
lbuffer = static_cast<stream_sample_t>(out);
|
||||
rbuffer = static_cast<stream_sample_t>(out2);
|
||||
|
||||
// assumed positive
|
||||
assert(lbuffer >= 0 && lbuffer <= MAX_OUTPUT);
|
||||
assert(rbuffer >= 0 && lbuffer <= MAX_OUTPUT);
|
||||
|
||||
// vcc expects unsigned short as 0xLLRR, as lrbuffer is
|
||||
// never negative just convert to unsigned byte.
|
||||
uint8_t left = std::clamp(lbuffer >> 8, 0, 255);
|
||||
uint8_t right = std::clamp(rbuffer >> 8, 0, 255);
|
||||
return (left << 8) | right;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Nicola Salmoria
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
class SN76489Device
|
||||
{
|
||||
public:
|
||||
|
||||
using stream_sample_t = unsigned short;
|
||||
|
||||
SN76489Device() = default;
|
||||
virtual ~SN76489Device() = default;
|
||||
|
||||
virtual void device_start();
|
||||
virtual void write(uint8_t data);
|
||||
virtual stream_sample_t sound_stream_update(stream_sample_t &lbuffer, stream_sample_t &rbuffer);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
inline bool in_noise_mode() const;
|
||||
void countdown_cycles();
|
||||
|
||||
|
||||
const int32_t m_feedback_mask = 0x4000; // mask for feedback
|
||||
const int32_t m_whitenoise_tap1 = 0x01; // mask for white noise tap 1 (higher one, usually bit 14)
|
||||
const int32_t m_whitenoise_tap2 = 0x02; // mask for white noise tap 2 (lower one, usually bit 13)
|
||||
const bool m_stereo = false; // whether we're dealing with stereo or not
|
||||
const float m_period_divider = 6.11f; // period divider
|
||||
const bool m_ncr_style_psg = false; // flag to ignore writes to regs 1,3,5,6,7 with bit 7 low
|
||||
const bool m_sega_style_psg = true; // flag to make frequency zero acts as if it is one more than max (0x3ff+1) or if it acts like 0; the initial register is pointing to 0x3 instead of 0x0; the volume reg is preloaded with 0xF instead of 0x0
|
||||
|
||||
int32_t m_vol_table[16] = { 0 }; // volume table (for 4-bit to db conversion)
|
||||
|
||||
bool m_ready_state = false;
|
||||
int32_t m_cycles_to_ready = 0; // number of cycles until the READY line goes active
|
||||
int32_t m_register[8] = { 0 }; // registers
|
||||
int32_t m_last_register = 0; // last register written
|
||||
uint32_t m_RNG = 0; // noise generator LFSR
|
||||
int32_t m_stereo_mask = 0; // the stereo output mask
|
||||
int32_t m_period[4] = { 0 }; // Length of 1/2 of waveform
|
||||
int32_t m_volume[4] = { 0 }; // db volume of voice 0-2 and noise
|
||||
int32_t m_count[4] = { 0 }; // Position within the waveform
|
||||
int32_t m_output[4] = { 0 }; // 1-bit output of each channel, pre-volume
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
========================================================================
|
||||
DYNAMIC LINK LIBRARY : DiskController
|
||||
========================================================================
|
||||
|
||||
|
||||
AppWizard has created this DiskController DLL for you.
|
||||
|
||||
This file contains a summary of what you will find in each of the files that
|
||||
make up your DiskController application.
|
||||
|
||||
DiskController.dsp
|
||||
This file (the project file) contains information at the project level and
|
||||
is used to build a single project or subproject. Other users can share the
|
||||
project (.dsp) file, but they should export the makefiles locally.
|
||||
|
||||
DiskController.cpp
|
||||
This is the main DLL source file.
|
||||
|
||||
When created, this DLL does not export any symbols. As a result, it
|
||||
will not produce a .lib file when it is built. If you wish this project
|
||||
to be a project dependency of some other project, you will either need to
|
||||
add code to export some symbols from the DLL so that an export library
|
||||
will be produced, or you can check the "doesn't produce lib" checkbox in
|
||||
the Linker settings page for this project.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Other standard files:
|
||||
|
||||
StdAfx.h, StdAfx.cpp
|
||||
These files are used to build a precompiled header (PCH) file
|
||||
named DiskController.pch and a precompiled types file named StdAfx.obj.
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Other notes:
|
||||
|
||||
AppWizard uses "TODO:" to indicate parts of the source code you
|
||||
should add to or customize.
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,298 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
// cc3vhd.c
|
||||
|
||||
/****************************************************************************
|
||||
* Technical specs on the Virtual Hard Disk interface
|
||||
*
|
||||
* Address Description
|
||||
* ------- -----------
|
||||
* FF80 Logical record number (high byte)
|
||||
* FF81 Logical record number (middle byte)
|
||||
* FF82 Logical record number (low byte)
|
||||
* FF83 Command/status register
|
||||
* FF84 Buffer address (high byte)
|
||||
* FF85 Buffer address (low byte)
|
||||
* FF86 Drive select (0 or 1)
|
||||
*
|
||||
* Set the other registers, and then issue a command to FF83 as follows:
|
||||
*
|
||||
* 0 = read 256-byte sector at LRN
|
||||
* 1 = write 256-byte sector at LRN
|
||||
* 2 = flush write cache (Closes and then opens the image file)
|
||||
* Note: Vcc just issues a "FlushFileBuffers" command.
|
||||
*
|
||||
* Error values:
|
||||
*
|
||||
* 0 = no error
|
||||
* -1 = power-on state (before the first command is recieved)
|
||||
* -2 = invalid command
|
||||
* 2 = VHD image does not exist
|
||||
* 4 = Unable to open VHD image file
|
||||
* 5 = access denied (may not be able to write to VHD image)
|
||||
*
|
||||
* IMPORTANT: The I/O buffer must NOT cross an 8K MMU bank boundary.
|
||||
* Note: This is not an issue for Vcc.
|
||||
****************************************************************************/
|
||||
|
||||
#include <Windows.h>
|
||||
#include <stdio.h>
|
||||
#include "cc3vhd.h"
|
||||
#include "harddisk.h"
|
||||
#include <vcc/util/FileOps.h>
|
||||
|
||||
typedef union {
|
||||
unsigned int All;
|
||||
struct {
|
||||
unsigned char lswlsb,lswmsb,mswlsb,mswmsb;
|
||||
} Byte;
|
||||
} SECOFF;
|
||||
|
||||
typedef union {
|
||||
unsigned int word;
|
||||
struct {
|
||||
unsigned char lsb,msb;
|
||||
} Byte;
|
||||
} Address;
|
||||
|
||||
static int DriveSelect=0;
|
||||
static HANDLE HardDrive[2]={INVALID_HANDLE_VALUE,INVALID_HANDLE_VALUE};
|
||||
static SECOFF SectorOffset;
|
||||
static Address DMAaddress;
|
||||
static unsigned char SectorBuffer[SECTORSIZE];
|
||||
static unsigned char Mounted[2]={0,0};
|
||||
static unsigned char WpHD[2]={0,0};
|
||||
static unsigned short ScanCount=64;
|
||||
static unsigned long LastSectorNum=0;
|
||||
static char DStatus[128]="";
|
||||
static char Status = HD_PWRUP;
|
||||
unsigned long BytesMoved=0;
|
||||
|
||||
void HDcommand(unsigned char);
|
||||
|
||||
int MountHD(const char* FileName, int drive)
|
||||
{
|
||||
drive = drive&1; // Drive can be 0 or 1
|
||||
|
||||
// Unmount existing
|
||||
if (HardDrive[drive] != INVALID_HANDLE_VALUE) UnmountHD(drive);
|
||||
|
||||
// Assume mount will work for now
|
||||
WpHD[drive]=0;
|
||||
Mounted[drive]=1;
|
||||
Status = HD_OK;
|
||||
SectorOffset.All = 0;
|
||||
DMAaddress.word = 0;
|
||||
HardDrive[drive] = CreateFile( FileName,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
0,nullptr,OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,nullptr);
|
||||
|
||||
// If can't open read/write try read only.
|
||||
if (HardDrive[drive] == INVALID_HANDLE_VALUE) {
|
||||
HardDrive[drive] = CreateFile( FileName,
|
||||
GENERIC_READ,
|
||||
0,nullptr,OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,nullptr);
|
||||
WpHD[drive]=1; // drive is write protected
|
||||
}
|
||||
|
||||
// Give up if can't open either way
|
||||
if (HardDrive[drive] == INVALID_HANDLE_VALUE) {
|
||||
WpHD[drive]=0;
|
||||
Mounted[drive]=0;
|
||||
Status = HD_NODSK;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void UnmountHD(int drive)
|
||||
{
|
||||
drive = drive&1; // Drive can be 0 or 1
|
||||
|
||||
if (HardDrive[drive] != INVALID_HANDLE_VALUE) {
|
||||
CloseHandle(HardDrive[drive]);
|
||||
HardDrive[drive] = INVALID_HANDLE_VALUE;
|
||||
Mounted[drive] = 0;
|
||||
Status = HD_NODSK;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear drive select on reset
|
||||
void VhdReset() {
|
||||
MemWrite(0,0xFF86);
|
||||
}
|
||||
|
||||
void HDcommand(unsigned char Command) {
|
||||
|
||||
unsigned short Temp=0;
|
||||
|
||||
// Verify drive is mounted
|
||||
if (Mounted[DriveSelect] == 0) {
|
||||
Status = HD_NODSK;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (Command) {
|
||||
|
||||
case SECTOR_READ:
|
||||
// Verify desired sector is in range
|
||||
if (SectorOffset.All > MAX_SECTOR) {
|
||||
Status = HD_NODSK;
|
||||
return;
|
||||
}
|
||||
|
||||
// Seek desired sector
|
||||
SetFilePointer(HardDrive[DriveSelect],SectorOffset.All,nullptr,FILE_BEGIN);
|
||||
|
||||
// Read it; zero fill if past end of file
|
||||
ReadFile(HardDrive[DriveSelect],SectorBuffer,SECTORSIZE,&BytesMoved,nullptr);
|
||||
for (Temp=0; Temp < SECTORSIZE;Temp++) {
|
||||
if (Temp > BytesMoved) {
|
||||
MemWrite(0,Temp+DMAaddress.word);
|
||||
} else {
|
||||
MemWrite(SectorBuffer[Temp],Temp+DMAaddress.word);
|
||||
}
|
||||
}
|
||||
Status = HD_OK;
|
||||
|
||||
// Put disk status text
|
||||
sprintf(DStatus,"HD%d: Rd %000000.6X",DriveSelect,SectorOffset.All>>8);
|
||||
|
||||
break;
|
||||
|
||||
case SECTOR_WRITE:
|
||||
// Verify desired sector is in range
|
||||
if (SectorOffset.All > MAX_SECTOR) {
|
||||
Status = HD_NODSK;
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for write protect (file opened read only)
|
||||
if (WpHD[DriveSelect] == 1 ) {
|
||||
Status = HD_WP;
|
||||
return;
|
||||
}
|
||||
|
||||
// Copy block from from CoCo RAM
|
||||
for (Temp=0; Temp <SECTORSIZE;Temp++) {
|
||||
SectorBuffer[Temp]=MemRead(Temp+DMAaddress.word);
|
||||
}
|
||||
|
||||
// Seek desired sector
|
||||
SetFilePointer(HardDrive[DriveSelect],SectorOffset.All,nullptr,FILE_BEGIN);
|
||||
|
||||
// Write it
|
||||
WriteFile(HardDrive[DriveSelect],SectorBuffer,SECTORSIZE,&BytesMoved,nullptr);
|
||||
if (BytesMoved != SECTORSIZE) {
|
||||
Status = HD_NODSK;
|
||||
} else {
|
||||
Status = HD_OK;
|
||||
}
|
||||
|
||||
// Put disk status text
|
||||
sprintf(DStatus,"HD: Wr Sec %000000.6X",SectorOffset.All>>8);
|
||||
|
||||
break;
|
||||
|
||||
case DISK_FLUSH:
|
||||
FlushFileBuffers(HardDrive[DriveSelect]);
|
||||
SectorOffset.All=0;
|
||||
DMAaddress.word=0;
|
||||
Status = HD_OK;
|
||||
break;
|
||||
|
||||
default:
|
||||
Status = HD_INVLD;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void DiskStatus(char* text_buffer, size_t buffer_size)
|
||||
{
|
||||
strcpy(text_buffer,DStatus);
|
||||
ScanCount++;
|
||||
|
||||
if (SectorOffset.All != LastSectorNum) {
|
||||
ScanCount=0;
|
||||
LastSectorNum=SectorOffset.All;
|
||||
}
|
||||
|
||||
if (ScanCount > 63) {
|
||||
ScanCount=0;
|
||||
if (Mounted[DriveSelect]==1) {
|
||||
sprintf(DStatus,"HD%d:IDLE",DriveSelect);
|
||||
} else {
|
||||
sprintf(DStatus,"HD%d:No Image!",DriveSelect);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void IdeWrite(unsigned char data,unsigned char port)
|
||||
{
|
||||
switch (port-0x80) {
|
||||
case 0:
|
||||
SectorOffset.Byte.mswmsb = data;
|
||||
break;
|
||||
case 1:
|
||||
SectorOffset.Byte.mswlsb = data;
|
||||
break;
|
||||
case 2:
|
||||
SectorOffset.Byte.lswmsb = data;
|
||||
break;
|
||||
case 3:
|
||||
HDcommand(data);
|
||||
break;
|
||||
case 4:
|
||||
DMAaddress.Byte.msb=data;
|
||||
break;
|
||||
case 5:
|
||||
DMAaddress.Byte.lsb=data;
|
||||
break;
|
||||
case 6:
|
||||
// Only select drive if data is 0 or 1
|
||||
if (data == (data&1)) DriveSelect = data;
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char IdeRead(unsigned char port)
|
||||
{
|
||||
switch (port-0x80) {
|
||||
case 0:
|
||||
return(SectorOffset.Byte.mswmsb);
|
||||
case 1:
|
||||
return(SectorOffset.Byte.mswlsb);
|
||||
case 2:
|
||||
return(SectorOffset.Byte.lswmsb);
|
||||
case 3:
|
||||
return Status;
|
||||
case 4:
|
||||
return(DMAaddress.Byte.msb);
|
||||
case 5:
|
||||
return(DMAaddress.Byte.lsb);
|
||||
case 6:
|
||||
return DriveSelect;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
|
||||
#ifndef __CC3VHD_H__
|
||||
#define __CC3VHD_H__
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
// cc3vhd.h
|
||||
|
||||
void UnmountHD(int);
|
||||
int MountHD(const char*, int);
|
||||
unsigned char IdeRead(unsigned char);
|
||||
void IdeWrite (unsigned char, unsigned char);
|
||||
void DiskStatus(char* text_buffer, size_t buffer_size);
|
||||
void VhdReset();
|
||||
|
||||
constexpr auto DRIVESIZE = 512u; // Mb
|
||||
constexpr auto MAX_SECTOR = DRIVESIZE * 1024 * 1024;
|
||||
constexpr auto SECTORSIZE = 256u;
|
||||
|
||||
// FIXME: These need should probably be turned into a scoped enum.
|
||||
constexpr auto HD_OK = 0;
|
||||
constexpr auto HD_PWRUP = -1;
|
||||
constexpr auto HD_INVLD = -2;
|
||||
constexpr auto HD_NODSK = 4;
|
||||
constexpr auto HD_WP = 5;
|
||||
|
||||
// FIXME: These need should probably be turned into a scoped enum.
|
||||
constexpr auto SECTOR_READ = 0u;
|
||||
constexpr auto SECTOR_WRITE = 1u;
|
||||
constexpr auto DISK_FLUSH = 2u;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,464 @@
|
||||
//#define USE_LOGGING
|
||||
//======================================================================
|
||||
// This file is part of VCC (Virtual Color Computer).
|
||||
// Vcc is Copyright 2015 by Joseph Forgione
|
||||
//
|
||||
// VCC (Virtual Color Computer) is free software, you can redistribute
|
||||
// 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/>.
|
||||
//
|
||||
//======================================================================
|
||||
|
||||
#include <Windows.h>
|
||||
#include <stdio.h>
|
||||
#include<iostream>
|
||||
#include "resource.h"
|
||||
#include "cc3vhd.h"
|
||||
#include <vcc/devices/cloud9.h>
|
||||
#include <vcc/util/FileOps.h>
|
||||
#include <vcc/util/DialogOps.h>
|
||||
#include "../../../src/core/Interrupts.h"
|
||||
#include <vcc/bus/cpak_cartridge_definitions.h>
|
||||
#include <vcc/bus/cartridge_menu.h>
|
||||
#include <vcc/bus/cartridge_messages.h>
|
||||
#include <vcc/util/fileutil.h>
|
||||
#include <vcc/util/limits.h>
|
||||
#include <vcc/util/settings.h>
|
||||
|
||||
constexpr auto DEF_HD_SIZE = 132480u;
|
||||
|
||||
static char VHDfile0[MAX_PATH] { 0 };
|
||||
static char VHDfile1[MAX_PATH] { 0 };
|
||||
static char *VHDfile; // Selected drive file name
|
||||
static char NewVHDfile[MAX_PATH];
|
||||
static char HardDiskPath[MAX_PATH];
|
||||
static ::VCC::Device::rtc::cloud9 cloud9_rtc;
|
||||
|
||||
static slot_id_type gSlotId {};
|
||||
static PakReadMemoryByteHostCallback MemRead8 = nullptr;
|
||||
static PakWriteMemoryByteHostCallback MemWrite8 = nullptr;
|
||||
static int ClockEnabled = 1;
|
||||
static int ClockReadOnly = 1;
|
||||
LRESULT CALLBACK NewDisk(HWND,UINT, WPARAM, LPARAM);
|
||||
|
||||
///void Load_Disk(unsigned char);
|
||||
void LoadHardDisk(int drive);
|
||||
void LoadConfig();
|
||||
void SaveConfig();
|
||||
int CreateDisk(HWND,int);
|
||||
|
||||
static HINSTANCE gModuleInstance;
|
||||
static HWND hConfDlg = nullptr;
|
||||
LRESULT CALLBACK Config(HWND, UINT, WPARAM, LPARAM );
|
||||
|
||||
// Added for PakGetMenuItem export
|
||||
bool get_menu_item(menu_item_entry* item, size_t index);
|
||||
|
||||
// Added for PakGetMenuItem export
|
||||
static HWND gVccWnd = nullptr;
|
||||
|
||||
// Access the settings object
|
||||
static VCC::Util::settings* gpSettings = nullptr;
|
||||
VCC::Util::settings& Setting() {return *gpSettings;}
|
||||
|
||||
//=================================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
void MemWrite(unsigned char Data, unsigned short Address)
|
||||
{
|
||||
MemWrite8(gSlotId, Data, Address);
|
||||
}
|
||||
|
||||
unsigned char MemRead(unsigned short Address)
|
||||
{
|
||||
return MemRead8(gSlotId, Address);
|
||||
}
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
__declspec(dllexport) const char* PakGetName()
|
||||
{
|
||||
static char string_buffer[MAX_LOADSTRING];
|
||||
|
||||
LoadString(gModuleInstance, IDS_MODULE_NAME, string_buffer, MAX_LOADSTRING);
|
||||
|
||||
return string_buffer;
|
||||
}
|
||||
|
||||
__declspec(dllexport) const char* PakGetCatalogId()
|
||||
{
|
||||
static char string_buffer[MAX_LOADSTRING];
|
||||
|
||||
LoadString(gModuleInstance, IDS_CATNUMBER, string_buffer, MAX_LOADSTRING);
|
||||
|
||||
return string_buffer;
|
||||
}
|
||||
|
||||
__declspec(dllexport) const char* PakGetDescription()
|
||||
{
|
||||
static char string_buffer[MAX_LOADSTRING];
|
||||
|
||||
LoadString(gModuleInstance, IDS_DESCRIPTION, string_buffer, MAX_LOADSTRING);
|
||||
|
||||
return string_buffer;
|
||||
}
|
||||
|
||||
__declspec(dllexport) void PakInitialize(
|
||||
slot_id_type SlotId,
|
||||
const char* const configuration_path,
|
||||
HWND hVccWnd,
|
||||
const cpak_callbacks* const callbacks)
|
||||
{
|
||||
gSlotId = SlotId;
|
||||
gVccWnd = hVccWnd;
|
||||
MemRead8 = callbacks->read_memory_byte;
|
||||
MemWrite8 = callbacks->write_memory_byte;
|
||||
gpSettings = new VCC::Util::settings(configuration_path);
|
||||
|
||||
LoadConfig();
|
||||
cloud9_rtc.set_read_only(ClockReadOnly);
|
||||
VhdReset(); // Selects drive zero
|
||||
// Request menu rebuild
|
||||
SendMessage(gVccWnd,WM_VCC_UPD_MENU,(WPARAM) 0,(LPARAM) 0);
|
||||
}
|
||||
|
||||
__declspec(dllexport) bool PakGetMenuItem(menu_item_entry* item, size_t index)
|
||||
{
|
||||
return get_menu_item(item, index);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void PakTerminate()
|
||||
{
|
||||
CloseCartDialog(hConfDlg);
|
||||
UnmountHD(0);
|
||||
UnmountHD(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Configure the hard drive(s). Called from menu
|
||||
// Mount or dismount a hard drive and save config
|
||||
// MountHD and UnmountHD are defined in cc3vhd
|
||||
extern "C"
|
||||
{
|
||||
__declspec(dllexport) void
|
||||
PakMenuItemClicked(unsigned char MenuID)
|
||||
{
|
||||
switch (MenuID)
|
||||
{
|
||||
case 10:
|
||||
LoadHardDisk(0);
|
||||
break;
|
||||
|
||||
case 11:
|
||||
UnmountHD(0);
|
||||
*VHDfile0 = '\0';
|
||||
break;
|
||||
|
||||
case 12:
|
||||
LoadHardDisk(1);
|
||||
break;
|
||||
|
||||
case 13:
|
||||
UnmountHD(1);
|
||||
*VHDfile1 = '\0';
|
||||
break;
|
||||
|
||||
case 14:
|
||||
if (hConfDlg == nullptr)
|
||||
hConfDlg = CreateDialog(gModuleInstance,(LPCTSTR)IDD_CONFIG,GetActiveWindow(),(DLGPROC)Config);
|
||||
ShowWindow(hConfDlg,1);
|
||||
return;
|
||||
}
|
||||
SaveConfig();
|
||||
// FIXME should only rebuild menus if drive is changed
|
||||
SendMessage(gVccWnd,WM_VCC_UPD_MENU,(WPARAM) 0,(LPARAM) 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CALLBACK Config(HWND hDlg, UINT message, WPARAM wParam, LPARAM /*lParam*/)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_CLOSE:
|
||||
DestroyWindow(hDlg);
|
||||
hConfDlg=nullptr;
|
||||
return TRUE;
|
||||
|
||||
case WM_INITDIALOG:
|
||||
CenterDialog(hDlg);
|
||||
SendDlgItemMessage(hDlg, IDC_CLOCK, BM_SETCHECK, ClockEnabled, 0);
|
||||
SendDlgItemMessage(hDlg, IDC_READONLY, BM_SETCHECK, ClockReadOnly, 0);
|
||||
EnableWindow(GetDlgItem(hDlg, IDC_CLOCK), TRUE);
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
ClockEnabled = SendDlgItemMessage(hDlg, IDC_CLOCK, BM_GETCHECK, 0, 0) != 0;
|
||||
ClockReadOnly = SendDlgItemMessage(hDlg, IDC_READONLY, BM_GETCHECK, 0, 0) != 0;
|
||||
cloud9_rtc.set_read_only(ClockReadOnly);
|
||||
SaveConfig();
|
||||
DestroyWindow(hDlg);
|
||||
hConfDlg=nullptr;
|
||||
break;
|
||||
|
||||
case IDCANCEL:
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
DestroyWindow(hDlg);
|
||||
hConfDlg=nullptr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Export write to HD control port
|
||||
extern "C"
|
||||
{
|
||||
__declspec(dllexport) void
|
||||
PakWritePort(unsigned char Port,unsigned char Data)
|
||||
{
|
||||
IdeWrite(Data,Port);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Export read from HD control port
|
||||
extern "C"
|
||||
{
|
||||
__declspec(dllexport) unsigned char PakReadPort(unsigned char Port)
|
||||
{
|
||||
if (((Port == 0x78) | (Port == 0x79) | (Port == 0x7C)) & ClockEnabled)
|
||||
return cloud9_rtc.read_port(Port);
|
||||
return(IdeRead(Port));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Return disk status. (from cc3vhd)
|
||||
extern "C"
|
||||
{
|
||||
__declspec(dllexport) void
|
||||
PakGetStatus(char* text_buffer, size_t buffer_size)
|
||||
{
|
||||
DiskStatus(text_buffer, buffer_size);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain( HINSTANCE hinstDLL, // handle to DLL module
|
||||
DWORD fdwReason, // reason for calling function
|
||||
LPVOID lpReserved ) // reserved
|
||||
{
|
||||
if (fdwReason == DLL_PROCESS_ATTACH) {
|
||||
gModuleInstance = hinstDLL;
|
||||
} else if (fdwReason == DLL_PROCESS_DETACH) {
|
||||
PakTerminate();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
// Get filename from user and mount harddrive
|
||||
void LoadHardDisk(int drive)
|
||||
{
|
||||
char msg[300];
|
||||
|
||||
// Select VHD FileName buffer as per drive
|
||||
switch (drive) {
|
||||
case 0:
|
||||
VHDfile = VHDfile0;
|
||||
break;
|
||||
case 1:
|
||||
VHDfile = VHDfile1;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
HWND hWnd = GetActiveWindow();
|
||||
FileDialog dlg;
|
||||
dlg.setpath(VHDfile);
|
||||
dlg.setFilter("Hard Disk Images\0*.vhd;*.os9;*.img\0All files\0*.*\0\0");
|
||||
dlg.setDefExt("vhd");
|
||||
dlg.setTitle(TEXT("Load HardDisk Image") );
|
||||
dlg.setInitialDir(HardDiskPath);
|
||||
dlg.setFlags(OFN_PATHMUSTEXIST);
|
||||
if (dlg.show(0,hWnd)) {
|
||||
dlg.getpath(NewVHDfile,MAX_PATH);
|
||||
|
||||
// Present new disk dialog if file does not exist
|
||||
if (GetFileAttributes(NewVHDfile) == INVALID_FILE_ATTRIBUTES) {
|
||||
// Dialog box returns zero if file is not created
|
||||
if (DialogBox(gModuleInstance,(LPCTSTR)IDD_NEWDISK,hWnd,(DLGPROC)NewDisk)==0)
|
||||
return;
|
||||
}
|
||||
|
||||
// Actual file mount is done in cc3vhd
|
||||
if (MountHD(NewVHDfile,drive)==0) {
|
||||
snprintf(msg,300,"Can't mount %s",NewVHDfile);
|
||||
MessageBox(hWnd,msg,"Error",0);
|
||||
*VHDfile = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
strncpy(VHDfile,NewVHDfile,MAX_PATH);
|
||||
|
||||
// Save vhd directory for config file
|
||||
dlg.getdir(HardDiskPath);
|
||||
SaveConfig();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Get configuration items from ini file
|
||||
void LoadConfig()
|
||||
{
|
||||
char ModName[MAX_LOADSTRING]="";
|
||||
HANDLE hr;
|
||||
|
||||
Setting().read("DefaultPaths","HardDiskPath","",HardDiskPath, MAX_PATH);
|
||||
|
||||
// Determine module name for config lookups
|
||||
LoadString(gModuleInstance,IDS_MODULE_NAME, ModName, MAX_LOADSTRING);
|
||||
|
||||
// Verify HD0 image file exists and mount it.
|
||||
Setting().read(ModName,"VHDImage","",VHDfile0,MAX_PATH);
|
||||
CheckPath(VHDfile0);
|
||||
hr = CreateFile (VHDfile0,0,FILE_SHARE_READ,nullptr,
|
||||
OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,nullptr);
|
||||
if (hr==INVALID_HANDLE_VALUE) {
|
||||
strcpy(VHDfile0,"");
|
||||
Setting().write(ModName,"VHDImage","");
|
||||
} else {
|
||||
CloseHandle(hr);
|
||||
MountHD(VHDfile0,0);
|
||||
}
|
||||
|
||||
// Verify HD1 image file exists and mount it.
|
||||
Setting().read(ModName,"VHDImage1","",VHDfile1,MAX_PATH);
|
||||
CheckPath(VHDfile1);
|
||||
hr = CreateFile (VHDfile1,0,FILE_SHARE_READ,nullptr,
|
||||
OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,nullptr);
|
||||
if (hr==INVALID_HANDLE_VALUE) {
|
||||
strcpy(VHDfile1,"");
|
||||
Setting().write(ModName,"VHDImage1","");
|
||||
} else {
|
||||
CloseHandle(hr);
|
||||
MountHD(VHDfile1,1);
|
||||
}
|
||||
|
||||
ClockEnabled = Setting().read(ModName,"ClkEnable",1);
|
||||
ClockReadOnly = Setting().read(ModName,"ClkRdOnly",1);
|
||||
|
||||
// Create config menu
|
||||
SendMessage(gVccWnd,WM_VCC_UPD_MENU,(WPARAM) 0,(LPARAM) 0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Save config saves the hard disk path and vhd file names
|
||||
void SaveConfig()
|
||||
{
|
||||
char ModName[MAX_LOADSTRING]="";
|
||||
LoadString(gModuleInstance,IDS_MODULE_NAME,ModName, MAX_LOADSTRING);
|
||||
|
||||
ValidatePath(VHDfile0);
|
||||
ValidatePath(VHDfile1);
|
||||
if (strcmp(HardDiskPath, "") != 0) {
|
||||
Setting().write("DefaultPaths","HardDiskPath",HardDiskPath);
|
||||
}
|
||||
Setting().write(ModName,"VHDImage",VHDfile0);
|
||||
Setting().write(ModName,"VHDImage1",VHDfile1);
|
||||
Setting().write(ModName,"ClkEnable",ClockEnabled);
|
||||
Setting().write(ModName,"ClkRdOnly",ClockReadOnly);
|
||||
return;
|
||||
}
|
||||
|
||||
// Added for PakGetMenuItem export
|
||||
// Return items for cartridge menu. Called for each item
|
||||
bool get_menu_item(menu_item_entry* item, size_t index)
|
||||
{
|
||||
using VCC::Bus::gDllCartMenu;
|
||||
std::string disk;
|
||||
if (!item) return false;
|
||||
// request zero rebuilds the menu list
|
||||
if (index == 0) {
|
||||
gDllCartMenu.clear();
|
||||
gDllCartMenu.add("", 0, MIT_Seperator);
|
||||
gDllCartMenu.add("HD Drive 0",0,MIT_Head);
|
||||
gDllCartMenu.add("Insert",ControlId(10),MIT_Slave);
|
||||
disk = VCC::Util::GetFileNamePart(VHDfile0);
|
||||
gDllCartMenu.add("Eject: "+disk,ControlId(11),MIT_Slave);
|
||||
gDllCartMenu.add("HD Drive 1",0,MIT_Head);
|
||||
gDllCartMenu.add("Insert",ControlId(12),MIT_Slave);
|
||||
disk = VCC::Util::GetFileNamePart(VHDfile1);
|
||||
gDllCartMenu.add("Eject: "+disk,ControlId(13),MIT_Slave);
|
||||
gDllCartMenu.add("HD Config",ControlId(14),MIT_StandAlone);
|
||||
}
|
||||
// return requested list item or false
|
||||
return gDllCartMenu.copy_item(*item, index);
|
||||
}
|
||||
|
||||
// Dialog for creating a new hard disk
|
||||
LRESULT CALLBACK NewDisk(HWND hDlg, UINT message, WPARAM wParam, LPARAM /*lParam*/)
|
||||
{
|
||||
unsigned int hdsize=DEF_HD_SIZE;
|
||||
switch (message)
|
||||
{
|
||||
case WM_CLOSE:
|
||||
EndDialog(hDlg,LOWORD(wParam)); //Modal dialog
|
||||
return TRUE;
|
||||
|
||||
case WM_INITDIALOG:
|
||||
SetDlgItemInt(hDlg,IDC_HDSIZE,DEF_HD_SIZE,0);
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam)) {
|
||||
case IDOK:
|
||||
hdsize=GetDlgItemInt(hDlg,IDC_HDSIZE,nullptr,0);
|
||||
EndDialog(hDlg,CreateDisk(hDlg,hdsize));
|
||||
break;
|
||||
|
||||
case IDCANCEL:
|
||||
EndDialog(hDlg,0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Create a new disk file, return 1 on success
|
||||
int CreateDisk(HWND hDlg, int hdsize)
|
||||
{
|
||||
HANDLE hr=CreateFile( NewVHDfile, GENERIC_READ | GENERIC_WRITE,
|
||||
0,nullptr,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,nullptr);
|
||||
if (hr==INVALID_HANDLE_VALUE) {
|
||||
*NewVHDfile='\0';
|
||||
MessageBox(hDlg,"Can't create File","Error",0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (hdsize>0) {
|
||||
SetFilePointer(hr, hdsize * 1024, nullptr, FILE_BEGIN);
|
||||
SetEndOfFile(hr);
|
||||
}
|
||||
|
||||
CloseHandle(hr);
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef __HARDDISK_H__
|
||||
#define __HARDDISK_H__
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
void MemWrite(unsigned char,unsigned short );
|
||||
unsigned char MemRead(unsigned short );
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,175 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 2,1,8,3
|
||||
PRODUCTVERSION 2,1,8,3
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x21L
|
||||
#else
|
||||
FILEFLAGS 0x20L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "Comments", "Emulator Hard Disk Controller with 130Mb drive\0"
|
||||
VALUE "CompanyName", "BitRot Software.\0"
|
||||
VALUE "FileDescription", "Hard Disk\0"
|
||||
VALUE "FileVersion", "2.1.8.3\0"
|
||||
VALUE "InternalName", "Hard Disk\0"
|
||||
VALUE "LegalCopyright", "Copyright � 2010\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "OriginalFilename", "harddisk.dll\0"
|
||||
VALUE "PrivateBuild", "\0"
|
||||
VALUE "ProductName", "Vcc Module file\0"
|
||||
VALUE "ProductVersion", "2.1.8.3\0"
|
||||
VALUE "SpecialBuild", "RGB Hard Disk Controller\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // !_MAC
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_CONFIG DIALOG DISCARDABLE 0, 0, 170, 50
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Virtual Hard Disk Config"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,113,7,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,113,24,50,14
|
||||
CONTROL "Clock at 0xFF70",IDC_CLOCK,"Button",BS_AUTOCHECKBOX |
|
||||
WS_TABSTOP,7,7,66,10
|
||||
CONTROL "Clock is Read-Only",IDC_READONLY,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,7,18,81,10
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_CONFIG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 163
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 55
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
IDD_NEWDISK DIALOG 50, 50, 150, 80
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Create Hard Disk Image"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
LTEXT "VHD file does not exist",IDC_STATIC,35,7,90,8
|
||||
DEFPUSHBUTTON "Create New File",IDOK,14,21,70,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,88,21,50,14
|
||||
LTEXT "Initial Disk Size",IDC_STATIC,23,45,55,10
|
||||
LTEXT "Kb",IDC_STATIC,107,45,10,10
|
||||
EDITTEXT IDC_HDSIZE,74,44,32,10,ES_RIGHT
|
||||
LTEXT "Kb = 1024 bytes",IDC_STATIC,70,60,55,10
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_MODULE_NAME "Hard Drive"
|
||||
IDS_VERSION "2.0.2"
|
||||
IDS_CATNUMBER "+ Cloud9 RTC"
|
||||
IDS_DESCRIPTION "Enable virtual hard drive emulation. Uses direct memory acces (DMA) to offload the CPU from data transfer tasks. Two VHD hard disk files can be loaded. Also includes a Cloud9 clock."
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Legacy|Win32">
|
||||
<Configuration>Legacy</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<SccProjectName />
|
||||
<SccLocalPath />
|
||||
<ProjectGuid>{FC5D90DF-A488-4E57-A4B2-7C74AE861F9E}</ProjectGuid>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\vcc-base.props" />
|
||||
<Import Project="..\vcc-legacy.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\vcc-base.props" />
|
||||
<Import Project="..\vcc-release.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\vcc-base.props" />
|
||||
<Import Project="..\vcc-debug.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">
|
||||
<LibraryPath>C:\Program Files %28x86%29\Windows Kits\8.1\Lib\winv6.3\um\x86;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;harddisk_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ResourceCompile />
|
||||
<Link>
|
||||
<LinkDLL>true</LinkDLL>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_USRDLL;harddisk_EXPORTS;_LEGACY_VCC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalOptions>/arch:SSE</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<LinkDLL>true</LinkDLL>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;harddisk_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalOptions>/arch:SSE</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<ResourceCompile />
|
||||
<Link>
|
||||
<LinkDLL>true</LinkDLL>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="cc3vhd.cpp" />
|
||||
<ClCompile Include="harddisk.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="cc3vhd.h" />
|
||||
<ClInclude Include="harddisk.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="harddisk.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\libcommon\libcommon.vcxproj">
|
||||
<Project>{e0aa25bd-5527-475f-8d8b-b549a6311b0c}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,41 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by harddisk.rc
|
||||
//
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
#define IDS_MODULE_NAME 1
|
||||
#define IDS_VERSION 2
|
||||
#define IDS_CATNUMBER 3
|
||||
#define IDS_DESCRIPTION 4
|
||||
#define IDD_CONFIG 101
|
||||
#define IDD_NEWDISK 102
|
||||
#define IDC_CLOCK 1001
|
||||
#define IDC_READONLY 1002
|
||||
#define IDC_HDSIZE 1003
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 103
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1010
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,369 @@
|
||||
// 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/>.
|
||||
//
|
||||
// Processor State Display - Part of the Debugger package for VCC
|
||||
// Authors: Mike Rojas, Chet Simpson
|
||||
#include "MMUMonitor.h"
|
||||
#include "Debugger.h"
|
||||
#include "DebuggerUtils.h"
|
||||
#include "defines.h"
|
||||
#include "../../src/core/tcc1014mmu.h"
|
||||
#include "resource.h"
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include "config.h"
|
||||
|
||||
namespace VCC::Debugger::UI {
|
||||
namespace {
|
||||
|
||||
const std::string cWindowSizeX("WindowSizeX");
|
||||
const std::string cWindowSizeY("WindowSizeY");
|
||||
const std::string cWindowPosX("WindowPosX");
|
||||
const std::string cWindowPosY("WindowPosY");
|
||||
|
||||
// Color constants
|
||||
const COLORREF rgbBlack = RGB( 0, 0, 0);
|
||||
const COLORREF rgbViolet = RGB(100, 0, 170);
|
||||
const COLORREF rgbGray = RGB(120, 120, 120);
|
||||
|
||||
VCC::Util::critical_section Section_;
|
||||
MMUState MMUState_;
|
||||
|
||||
HWND MMUMonitorWindow = nullptr;
|
||||
HWND hWndMMUMonitor;
|
||||
BackBufferInfo BackBuffer_;
|
||||
|
||||
class MMUMonitorDebugClient : public Client
|
||||
{
|
||||
public:
|
||||
void OnReset() override {
|
||||
}
|
||||
void OnUpdate() override {
|
||||
VCC::Util::section_locker lock(Section_);
|
||||
MMUState_ = GetMMUState();
|
||||
}
|
||||
};
|
||||
|
||||
// Convert unsigned int to uppercase hex string
|
||||
std::string HexUpc(long value,unsigned int width)
|
||||
{
|
||||
return ToHexString(value, width, true);
|
||||
}
|
||||
|
||||
// Draw string centered in rectangle width w, height 20
|
||||
// x,y set the top left corner of the centering box
|
||||
void PutText(HDC hdc,int x,int y,int w, const std::string& s)
|
||||
{
|
||||
RECT rc;
|
||||
SetRect( &rc, x, y, x + w, y + 20);
|
||||
DrawText( hdc, s.c_str(), s.size(), &rc,
|
||||
DT_CENTER | DT_VCENTER | DT_SINGLELINE);
|
||||
}
|
||||
|
||||
// Draw a visible box
|
||||
void MakeBox(HDC hdc,HPEN pen,int x,int y,int w,int h)
|
||||
{
|
||||
SelectObject(hdc, pen);
|
||||
MoveToEx(hdc, x, y, nullptr);
|
||||
LineTo(hdc, x + w, y);
|
||||
LineTo(hdc, x + w, y + h);
|
||||
LineTo(hdc, x, y + h);
|
||||
LineTo(hdc, x, y);
|
||||
}
|
||||
|
||||
// Set draw color per task number
|
||||
void SetTaskColor(HDC hdc,int Task,COLORREF Tsk0,COLORREF Tsk1)
|
||||
{
|
||||
if (Task==1) {
|
||||
SetTextColor(hdc, Tsk1);
|
||||
} else {
|
||||
SetTextColor(hdc, Tsk0);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw the Monitor Window
|
||||
void DrawMMUMonitor(HDC hdc, LPCRECT clientRect)
|
||||
{
|
||||
RECT rect = *clientRect;
|
||||
|
||||
// Clear background.
|
||||
HBRUSH brush = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
||||
FillRect(hdc, &rect, brush);
|
||||
|
||||
HPEN pen = CreatePen(PS_SOLID, 1, rgbGray);
|
||||
HPEN thickPen = CreatePen(PS_SOLID, 2, rgbGray);
|
||||
|
||||
HFONT hFont = CreateFont(14, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE,
|
||||
DEFAULT_CHARSET, OUT_OUTLINE_PRECIS,
|
||||
CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY,
|
||||
FIXED_PITCH, TEXT("Consolas"));
|
||||
SelectObject(hdc, hFont);
|
||||
|
||||
// Quick pull out MMU state
|
||||
MMUState regs;
|
||||
{
|
||||
VCC::Util::section_locker lock(Section_);
|
||||
regs = MMUState_;
|
||||
}
|
||||
|
||||
// X,Y position for MMU registers
|
||||
int x = rect.left + 4;
|
||||
int y = rect.top + 4;
|
||||
|
||||
// Header
|
||||
SetTextColor(hdc, rgbBlack);
|
||||
PutText(hdc,x+4, y,80,"Real");
|
||||
PutText(hdc,x+71 ,y,40,"MAP 0");
|
||||
PutText(hdc,x+121,y,80,"CPU Memory");
|
||||
PutText(hdc,x+212,y,40,"MAP 1");
|
||||
PutText(hdc,x+239,y,80,"Real");
|
||||
|
||||
// Rows
|
||||
for (int n = 0; n < 8; n++)
|
||||
{
|
||||
// Y position for row
|
||||
y += 20;
|
||||
|
||||
// Map 0 Real Memory
|
||||
SetTaskColor(hdc,regs.ActiveTask,rgbViolet,rgbGray);
|
||||
PutText(hdc,x+14,y,60,HexUpc(regs.Task0[n]*8192,6));
|
||||
|
||||
// Map 0 Box
|
||||
MakeBox(hdc,pen,x+76,y+1,30,16);
|
||||
SetTaskColor(hdc,regs.ActiveTask,rgbBlack,rgbGray);
|
||||
PutText(hdc,x+76,y,30,HexUpc(regs.Task0[n],2));
|
||||
|
||||
// CPU memory
|
||||
SetTextColor(hdc, rgbViolet);
|
||||
PutText(hdc,x+131,y,60,HexUpc(n * 8192,4));
|
||||
|
||||
// Map 1 Box
|
||||
MakeBox(hdc,pen,x+216,y+1,30,16);
|
||||
SetTaskColor(hdc,regs.ActiveTask,rgbGray,rgbBlack);
|
||||
PutText(hdc,x+216,y,30,HexUpc(regs.Task1[n],2));
|
||||
|
||||
// Map 1 Real Memory
|
||||
SetTaskColor(hdc,regs.ActiveTask,rgbGray,rgbViolet);
|
||||
PutText(hdc,x+248,y,60,HexUpc(regs.Task1[n]*8192,6));
|
||||
|
||||
// Active task indicator arrows
|
||||
SelectObject(hdc, thickPen);
|
||||
int dx = (regs.ActiveTask == 0) ? x : x+66;
|
||||
PutText(hdc,dx+115,y,5,"<");
|
||||
MoveToEx(hdc,dx+120,y+10, nullptr);
|
||||
LineTo(hdc,dx+135,y+10);
|
||||
PutText(hdc,dx+137,y,5,">");
|
||||
}
|
||||
|
||||
// Position for the Control bits
|
||||
x = rect.left + 3;
|
||||
y = rect.top + 190;
|
||||
|
||||
// MMU Enable bit
|
||||
SetTextColor(hdc,rgbViolet);
|
||||
PutText(hdc,x,y,130,"FF90:b6 Enable ");
|
||||
MakeBox(hdc,pen,x+130,y+2,20,16);
|
||||
SetTextColor(hdc,rgbBlack);
|
||||
PutText(hdc,x+130,y,20,std::to_string(regs.Enabled));
|
||||
|
||||
// MMU task bit
|
||||
SetTextColor(hdc,rgbViolet);
|
||||
PutText(hdc,x,y+20,130,"FF91:b0 MMU Task");
|
||||
MakeBox(hdc,pen,x+130,y+22,20,16);
|
||||
SetTextColor(hdc,rgbBlack);
|
||||
PutText(hdc,x+130,y+20,20,std::to_string(regs.ActiveTask));
|
||||
|
||||
// X position for second column control bits
|
||||
x = rect.left + 164;
|
||||
|
||||
// Ram Vectors
|
||||
SetTextColor(hdc,rgbViolet);
|
||||
PutText(hdc,x,y,140, "FF90:b3 RAM Vector");
|
||||
MakeBox(hdc,pen,x+140,y+2,20,16);
|
||||
SetTextColor(hdc,rgbBlack);
|
||||
PutText(hdc,x+140,y,20,std::to_string(regs.RamVectors));
|
||||
|
||||
// Rom Mapping
|
||||
SetTextColor(hdc,rgbViolet);
|
||||
PutText(hdc,x,y+20,140,"FF90:b1-0 ROM Map ");
|
||||
MakeBox(hdc,pen,x+140,y+22,20,16);
|
||||
SetTextColor(hdc,rgbBlack);
|
||||
PutText(hdc,x+140,y+20,20,std::to_string(regs.RomMap));
|
||||
|
||||
// Cleanup.
|
||||
DeleteObject(pen);
|
||||
DeleteObject(thickPen);
|
||||
DeleteObject(hFont);
|
||||
}
|
||||
|
||||
void SaveSettings(HWND hDlg)
|
||||
{
|
||||
constexpr int cHeaderHeight = 20; // header with labels
|
||||
|
||||
RECT CurWindow;
|
||||
::GetWindowRect(hDlg, &CurWindow);
|
||||
RECT CurScreen;
|
||||
::GetClientRect(hDlg, &CurScreen);
|
||||
int clientWidth = (int)CurScreen.right;
|
||||
int clientHeight = (int)CurScreen.bottom;
|
||||
|
||||
{
|
||||
VCC::Rect rect;
|
||||
// remember positioning:
|
||||
rect.x = CurWindow.left;
|
||||
rect.y = CurWindow.top;
|
||||
|
||||
// remember size:
|
||||
rect.w = clientWidth; // Used for saving new window size to the ini file.
|
||||
rect.h = clientHeight - cHeaderHeight;
|
||||
|
||||
auto& s = Setting();
|
||||
std::string section("MMUMonitor");
|
||||
auto write = [&](const std::string& key, int value)
|
||||
{
|
||||
s.write(section, key, value);
|
||||
};
|
||||
write(cWindowSizeX, rect.w);
|
||||
write(cWindowSizeY, rect.h);
|
||||
write(cWindowPosX, rect.x);
|
||||
write(cWindowPosY, rect.y);
|
||||
}
|
||||
}
|
||||
|
||||
void LoadSettings(HWND hDlg)
|
||||
{
|
||||
if (hDlg != nullptr)
|
||||
{
|
||||
Rect rect;
|
||||
|
||||
rect.x = CW_USEDEFAULT;
|
||||
rect.y = CW_USEDEFAULT;
|
||||
rect.w = 336;
|
||||
rect.h = 270;
|
||||
|
||||
if (!GetAsyncKeyState(VK_SHIFT))
|
||||
{
|
||||
auto& s = Setting();
|
||||
std::string section("MMUMonitor");
|
||||
auto read = [&](const std::string& key, int& value)
|
||||
{
|
||||
value = s.read(section, key, value);
|
||||
};
|
||||
|
||||
read(cWindowSizeX, rect.w);
|
||||
read(cWindowSizeY, rect.h);
|
||||
read(cWindowPosX, rect.x);
|
||||
read(cWindowPosY, rect.y);
|
||||
}
|
||||
|
||||
RECT ra = { 0,0,0,0 }; // left,top,right,bottom
|
||||
::AdjustWindowRect(&ra, WS_OVERLAPPEDWINDOW, TRUE);
|
||||
int windowBorderWidth = ra.right - ra.left;
|
||||
int windowBorderHeight = ra.bottom - ra.top;
|
||||
::GetWindowRect(hDlg, &ra);
|
||||
|
||||
int width = rect.w + windowBorderWidth;
|
||||
int height = rect.h + windowBorderHeight + 0; /*GetRenderWindowStatusBarHeight();*/
|
||||
int flags = SWP_NOOWNERZORDER | SWP_NOZORDER;
|
||||
int x = rect.IsDefaultX() ? ra.left : rect.x;
|
||||
int y = rect.IsDefaultY() ? ra.top : rect.y;
|
||||
SetWindowPos(hDlg, nullptr, x, y, width, height, flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
INT_PTR CALLBACK MMUMonitorDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM /*lParam*/)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
hWndMMUMonitor = hDlg;
|
||||
RECT Rect;
|
||||
GetClientRect(hDlg, &Rect);
|
||||
BackBuffer_ = AttachBackBuffer(hDlg, 0, -36);
|
||||
SetTimer(hDlg, IDT_PROC_TIMER, 64, nullptr);
|
||||
EmuState.Debugger.RegisterClient(hDlg, std::make_unique<MMUMonitorDebugClient>());
|
||||
LoadSettings(hDlg);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc = BeginPaint(hDlg, &ps);
|
||||
DrawMMUMonitor(BackBuffer_.DeviceContext, &BackBuffer_.Rect);
|
||||
BitBlt(hdc, 0, 0, BackBuffer_.Width, BackBuffer_.Height, BackBuffer_.DeviceContext, 0, 0, SRCCOPY);
|
||||
EndPaint(hDlg, &ps);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_TIMER:
|
||||
|
||||
switch (wParam)
|
||||
{
|
||||
case IDT_PROC_TIMER:
|
||||
InvalidateRect(hDlg, &BackBuffer_.Rect, FALSE);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_NCDESTROY:
|
||||
if (MMUMonitorWindow)
|
||||
{
|
||||
SaveSettings(hDlg);
|
||||
KillTimer(hDlg, IDT_PROC_TIMER);
|
||||
DeleteDC(BackBuffer_.DeviceContext);
|
||||
EmuState.Debugger.RemoveClient(hDlg);
|
||||
MMUMonitorWindow = nullptr;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_CLOSE:
|
||||
DestroyWindow(hDlg);
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
|
||||
case IDCLOSE:
|
||||
DestroyWindow(hDlg);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
} }
|
||||
|
||||
|
||||
void VCC::Debugger::UI::OpenMMUMonitorWindow(HINSTANCE instance, HWND parent)
|
||||
{
|
||||
if (MMUMonitorWindow == nullptr)
|
||||
{
|
||||
MMUMonitorWindow = CreateDialog(
|
||||
instance,
|
||||
MAKEINTRESOURCE(IDD_MMU_MONITOR),
|
||||
parent,
|
||||
MMUMonitorDlgProc);
|
||||
|
||||
ShowWindow(MMUMonitorWindow, SW_SHOWNORMAL);
|
||||
}
|
||||
|
||||
SetFocus(MMUMonitorWindow);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// 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/>.
|
||||
//
|
||||
// MMU Monitor Display - Part of the Debugger package for VCC
|
||||
// Authors: Mike Rojas, Chet Simpson
|
||||
#pragma once
|
||||
#include <Windows.h>
|
||||
|
||||
|
||||
namespace VCC::Debugger::UI
|
||||
{
|
||||
|
||||
void OpenMMUMonitorWindow(HINSTANCE instance, HWND parent);
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,189 @@
|
||||
//------------------------------------------------------------------
|
||||
// Display VCC memory for debugging
|
||||
//
|
||||
// This file is part of VCC (Virtual Color Computer).
|
||||
// Copyright 2015 by Joseph Forgione
|
||||
//
|
||||
// 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/>.
|
||||
//
|
||||
// Memory Map Display - Part of the Debugger package for VCC
|
||||
// Authors: Mike Rojas, Chet Simpson
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
#include <Windows.h>
|
||||
#include "DebuggerUtils.h"
|
||||
#include "../../src/core/tcc1014graphics.h"
|
||||
|
||||
namespace VCC::Debugger::UI
|
||||
{
|
||||
struct MemoryBackBufferInfo : BackBufferInfo
|
||||
{
|
||||
HPEN pen = nullptr;
|
||||
HFONT font = nullptr;
|
||||
|
||||
HBITMAP fontBitmap = nullptr;
|
||||
HBITMAP fontRedBitmap = nullptr;
|
||||
HBITMAP fontAsciiBitmap = nullptr;
|
||||
HDC fontDC = nullptr;
|
||||
HDC fontRedDC = nullptr;
|
||||
HDC fontAsciiDC = nullptr;
|
||||
|
||||
int dataWidth = 0;
|
||||
int dataHeight = 0;
|
||||
int dataStride = 0;
|
||||
char* data = nullptr;
|
||||
|
||||
void Init(HWND hDlgWnd);
|
||||
void CleanupFonts(HWND hWnd);
|
||||
void CleanupPen();
|
||||
void CleanupFont();
|
||||
void Cleanup(HWND hWnd);
|
||||
};
|
||||
|
||||
struct MemoryWindow
|
||||
{
|
||||
// Enum for memory type being examined
|
||||
enum AddrMode
|
||||
{
|
||||
Cpu,
|
||||
Real,
|
||||
ROM,
|
||||
PAK,
|
||||
NotSet
|
||||
};
|
||||
|
||||
enum ViewMode
|
||||
{
|
||||
VM_ASCII,
|
||||
VM_SG4,
|
||||
VM_PMODE0_S0,
|
||||
VM_PMODE0_S1,
|
||||
VM_PMODE1_S0,
|
||||
VM_PMODE1_S1,
|
||||
VM_PMODE2_S0,
|
||||
VM_PMODE2_S1,
|
||||
VM_PMODE3_S0,
|
||||
VM_PMODE3_S1,
|
||||
VM_PMODE4_RGB_S0,
|
||||
VM_PMODE4_RGB_S1,
|
||||
VM_PMODE4_NTSC,
|
||||
VM_TEXT40,
|
||||
VM_TEXT80,
|
||||
VM_HSCREEN1,
|
||||
VM_HSCREEN2,
|
||||
VM_HSCREEN3,
|
||||
VM_HSCREEN4,
|
||||
VM_MAX
|
||||
};
|
||||
|
||||
HWND hDlgMem;
|
||||
HWND hScrollBar;
|
||||
HWND hHorzScrollBar;
|
||||
HWND hEditAdrBeg;
|
||||
HWND hEditAdrEnd;
|
||||
HWND hEditVal;
|
||||
HWND hStatic;
|
||||
|
||||
GimeGpu memGpu;
|
||||
unsigned char *ramCache = nullptr;
|
||||
unsigned int ramPos = -1;
|
||||
|
||||
AddrMode addrMode = AddrMode::NotSet;
|
||||
ViewMode viewMode = VM_SG4;
|
||||
|
||||
static const std::string cMemoryWindow;
|
||||
static const std::string cMemoryWindow2;
|
||||
static const std::string cWindowSizeX;
|
||||
static const std::string cWindowSizeY;
|
||||
static const std::string cWindowPosX;
|
||||
static const std::string cWindowPosY;
|
||||
static const std::string cAddress;
|
||||
static const std::string cAddressMode;
|
||||
static const std::string cViewMode;
|
||||
static const std::string cHex;
|
||||
static const std::string cWide;
|
||||
static const std::string cDataWidth;
|
||||
static const std::string cDataPosX;
|
||||
|
||||
int winIndex;
|
||||
int memSize;
|
||||
int memOffset;
|
||||
int selectionRangeBeg;
|
||||
int selectionRangeEnd;
|
||||
unsigned char *rom;
|
||||
bool isEditing;
|
||||
int showHex;
|
||||
int showWideView;
|
||||
int editAddress;
|
||||
int dataWidth;
|
||||
int dataPosX;
|
||||
|
||||
// Backing buffer used for painting memory data
|
||||
MemoryBackBufferInfo BackBuf;
|
||||
|
||||
MemoryWindow(int index);
|
||||
|
||||
struct Measurements;
|
||||
|
||||
void SetEditing(bool);
|
||||
void FlashDialogWindow();
|
||||
void WriteMemory(int,unsigned char);
|
||||
void SetBackBuffer(const RECT&);
|
||||
void CreateScrollBar(const RECT&);
|
||||
void DrawForm(HDC,LPCRECT);
|
||||
bool DrawMemory(HDC,LPCRECT);
|
||||
void SetEditPosition(int,int);
|
||||
void LocateMemory();
|
||||
void ExportMemory();
|
||||
void CommitValue();
|
||||
void CommitWidth();
|
||||
void CommitWidth(const char *value);
|
||||
void SelectWidth();
|
||||
void SetMemType();
|
||||
void InitializeDialog(HWND);
|
||||
void DoScroll(WPARAM);
|
||||
void DoHorzScroll(WPARAM);
|
||||
int CStrToHex(const char *);
|
||||
void ResetMemoryCache();
|
||||
void ResizeWindow(int width, int height);
|
||||
void RepaintAll();
|
||||
void UpdateVertScrollBar();
|
||||
void UpdateHorzScrollBar();
|
||||
void UpdateWidthDisplay();
|
||||
void SetViewType();
|
||||
void SaveSettings();
|
||||
void LoadSettings();
|
||||
void SetupDataWidth(int delta);
|
||||
void Shutdown();
|
||||
void OnTimer(HWND hDlg);
|
||||
void Paint(HWND hDlg);
|
||||
void Help(HWND hDlg);
|
||||
void Export();
|
||||
void MemType(HWND hDlg);
|
||||
void LeftButton(int x, int y);
|
||||
void Escape();
|
||||
void SelectAdrEnd();
|
||||
void SelectAdrBeg();
|
||||
void SetWindowRect();
|
||||
void ViewType();
|
||||
bool Init();
|
||||
|
||||
unsigned char ReadMemory(int addr);
|
||||
};
|
||||
|
||||
void OpenMemoryMapWindow(HINSTANCE instance, HWND parent);
|
||||
}
|
||||
@@ -0,0 +1,540 @@
|
||||
// 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/>.
|
||||
//
|
||||
// OpDecoder Interface - Part of the Debugger package for VCC
|
||||
// Author: Mike Rojas
|
||||
#include "../../src/core/OpCodeTables.h"
|
||||
#include <stdexcept>
|
||||
#include "../../src/core/tcc1014mmu.h"
|
||||
#include <bitset>
|
||||
#include "DebuggerUtils.h"
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
namespace VCC::Debugger
|
||||
{
|
||||
bool OpCodeTables::ProcessHeuristics(OpCodeInfo& opcode, const CPUState& state, CPUTrace& trace) const
|
||||
{
|
||||
bool valid = true;
|
||||
trace.decodeCycles = state.IsNative6309 ? opcode.num6309cycles : opcode.num6809cycles;
|
||||
|
||||
switch (opcode.modifer)
|
||||
{
|
||||
case Heuristics::None:
|
||||
case Heuristics::Fixed:
|
||||
valid = ProcessNoAdjust(opcode, state, trace);
|
||||
break;
|
||||
case Heuristics::IndexedModeAdjust:
|
||||
valid = ProcessIndexModeAdjust(opcode, state, trace);
|
||||
break;
|
||||
case Heuristics::InterruptAdjust:
|
||||
valid = ProcessInterruptAdjust(opcode, state, trace);
|
||||
break;
|
||||
case Heuristics::StackAdjust:
|
||||
valid = ProcessStackAdjust(opcode, state, trace);
|
||||
break;
|
||||
case Heuristics::LongBranchAdjust:
|
||||
valid = ProcessLongBranchAdjust(opcode, state, trace);
|
||||
break;
|
||||
case Heuristics::TFMAdjust:
|
||||
valid = ProcessTFMAdjust(opcode, state, trace);
|
||||
break;
|
||||
case Heuristics::DIVAdjust:
|
||||
valid = ProcessDIVAdjust(opcode, state, trace);
|
||||
break;
|
||||
case Heuristics::WaitForSYNCAdjust:
|
||||
valid = ProcessWaitForSYNCAdjust(opcode, state, trace);
|
||||
break;
|
||||
default:
|
||||
valid = false;
|
||||
throw std::runtime_error("Unhandled opcode heuristic");
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
bool OpCodeTables::ProcessNoAdjust(const OpCodeInfo& opcode, const CPUState& state, CPUTrace& trace) const
|
||||
{
|
||||
// Get the current PC.
|
||||
unsigned short PC = state.PC;
|
||||
|
||||
// Skip past opcode bytes
|
||||
PC += opcode.oplen;
|
||||
|
||||
// Number of bytes for the operand.
|
||||
int operandLen = opcode.numbytes - opcode.oplen;
|
||||
for (int n = 0; n < operandLen; n++)
|
||||
{
|
||||
trace.bytes.push_back(DbgRead8(state.phyAddr,state.block,PC++));
|
||||
}
|
||||
|
||||
int operand = 0;
|
||||
|
||||
switch (operandLen)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
operand = trace.bytes[opcode.oplen];
|
||||
break;
|
||||
case 2:
|
||||
operand = (trace.bytes[opcode.oplen] << 8) + trace.bytes[opcode.oplen + 1];
|
||||
break;
|
||||
}
|
||||
|
||||
switch (opcode.mode)
|
||||
{
|
||||
case Inherent:
|
||||
break;
|
||||
case Direct:
|
||||
trace.operand = "<$" + ToHexString(operand, 2);
|
||||
break;
|
||||
case Indexed:
|
||||
break;
|
||||
case Relative:
|
||||
trace.operand = ToRelativeAddressString(operand, operandLen);
|
||||
break;
|
||||
case Extended:
|
||||
trace.operand = "$" + ToHexString(operand, 4);
|
||||
break;
|
||||
case Immediate:
|
||||
{
|
||||
// TFR and EXG - use inter-register operand
|
||||
if (opcode.opcode == 0x1F || opcode.opcode == 0x1E)
|
||||
{
|
||||
// Get source and destination registers
|
||||
unsigned char src = operand >> 4;
|
||||
unsigned char dst = operand & 0b00001111;
|
||||
|
||||
trace.operand = ToInterRegister(src) + "," + ToInterRegister(dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
trace.operand = "#$" + ToHexString(operand, 2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case LongRelative:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpCodeTables::ProcessIndexModeAdjust(OpCodeInfo& opcode, const CPUState& state, CPUTrace& trace) const
|
||||
{
|
||||
// Get the current PC.
|
||||
unsigned short PC = state.PC;
|
||||
|
||||
// Get the post byte.
|
||||
PC += opcode.oplen;
|
||||
unsigned char postbyte = DbgRead8(state.phyAddr,state.block,PC);
|
||||
|
||||
trace.bytes.push_back(postbyte);
|
||||
|
||||
// Determine various indexing modes.
|
||||
IndexModeInfo mode;
|
||||
if (!GetIndexMode(postbyte, mode, trace.operand))
|
||||
{
|
||||
// Index mode is not valid.
|
||||
return false;
|
||||
}
|
||||
|
||||
// One byte offset?
|
||||
if (mode.numbytes == 1)
|
||||
{
|
||||
unsigned char b = DbgRead8(state.phyAddr,state.block,++PC);
|
||||
trace.bytes.push_back(b);
|
||||
std::int32_t offset = b;
|
||||
offset = (offset << 24) >> 24;
|
||||
replace(trace.operand, "n", std::to_string(offset));
|
||||
}
|
||||
|
||||
// Two byte offset?
|
||||
if (mode.numbytes == 2)
|
||||
{
|
||||
unsigned char b1 = DbgRead8(state.phyAddr,state.block,++PC);
|
||||
trace.bytes.push_back(b1);
|
||||
unsigned char b2 = DbgRead8(state.phyAddr,state.block,++PC);
|
||||
trace.bytes.push_back(b2);
|
||||
std::int32_t offset = (b1 << 8) + b2;
|
||||
// Extended Indirect?
|
||||
if (trace.operand == "[n]")
|
||||
{
|
||||
replace(trace.operand, "n", "$" + ToHexString(offset, 4));
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = (offset << 16) >> 16;
|
||||
replace(trace.operand, "n", std::to_string(offset));
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust for number of cycles.
|
||||
int additionalCycles = (state.IsNative6309) ? mode.num6309cycles : mode.num6809cycles;
|
||||
trace.decodeCycles = AdjustCycles(opcode, additionalCycles, mode.numbytes, state.IsNative6309);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpCodeTables::GetIndexMode(unsigned char postbyte, IndexModeInfo& mode, std::string& operand) const
|
||||
{
|
||||
// Convert to key.
|
||||
std::string key = std::bitset<8>(postbyte).to_string();
|
||||
|
||||
// MSB = 0? 5 bit offset.
|
||||
if (key[0] == '0')
|
||||
{
|
||||
mode = IndexingModes.at("0RRnnnnn");
|
||||
operand = mode.form;
|
||||
|
||||
// Determine the register.
|
||||
replace(operand, "R", ToRegister(postbyte));
|
||||
|
||||
// Convert 5 bits to sign extended offset (-16 to +15)
|
||||
std::int32_t offset = std::bitset<5>(key.substr(3, 5)).to_ulong();
|
||||
offset = (offset << 27) >> 27;
|
||||
replace(operand, "n", std::to_string(offset));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Try exact match.
|
||||
if (IndexingModes.find(key) != IndexingModes.end())
|
||||
{
|
||||
mode = IndexingModes.at(key);
|
||||
operand = mode.form;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Try PCR modes.
|
||||
key[1] = 'X';
|
||||
key[2] = 'X';
|
||||
if (IndexingModes.find(key) != IndexingModes.end())
|
||||
{
|
||||
mode = IndexingModes.at(key);
|
||||
operand = mode.form;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Try register modes.
|
||||
key[1] = 'R';
|
||||
key[2] = 'R';
|
||||
if (IndexingModes.find(key) != IndexingModes.end())
|
||||
{
|
||||
mode = IndexingModes.at(key);
|
||||
operand = mode.form;
|
||||
replace(operand, "R", ToRegister(postbyte));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Invalid mode.
|
||||
return false;
|
||||
}
|
||||
|
||||
bool OpCodeTables::ProcessInterruptAdjust(OpCodeInfo& opcode, const CPUState& state, CPUTrace& trace) const
|
||||
{
|
||||
trace.decodeCycles = AdjustCycles(opcode, 0, 0, state.IsNative6309);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpCodeTables::ProcessStackAdjust(OpCodeInfo& opcode, const CPUState& state, CPUTrace& trace) const
|
||||
{
|
||||
// Get the current PC.
|
||||
unsigned short PC = state.PC;
|
||||
|
||||
// Get the post byte.
|
||||
unsigned char postbyte = DbgRead8(state.phyAddr,state.block,++PC);
|
||||
trace.bytes.push_back(postbyte);
|
||||
|
||||
// Count the number of registers set in post byte.
|
||||
int additionalCycles = 0;
|
||||
int regIndex = 0;
|
||||
std::array<std::string, 8> registers = { "CC", "A", "B", "DP", "X", "Y", "U/S", "PC" };
|
||||
std::array<int, 8> registerSize = { 1, 1, 1, 1, 2, 2, 2, 2 };
|
||||
registers[6] = opcode.opcode & 0b00000010 ? "S" : "U";
|
||||
while (postbyte)
|
||||
{
|
||||
int bit = postbyte & 1;
|
||||
if (bit)
|
||||
{
|
||||
if (trace.operand.size() > 0)
|
||||
{
|
||||
trace.operand += ",";
|
||||
}
|
||||
trace.operand += registers[regIndex];
|
||||
// One additional cycle per byte pushed/pulled.
|
||||
additionalCycles += registerSize[regIndex];
|
||||
}
|
||||
postbyte >>= 1;
|
||||
regIndex++;
|
||||
}
|
||||
|
||||
// Adjust the number of cycles.
|
||||
trace.decodeCycles = AdjustCycles(opcode, additionalCycles, 0, state.IsNative6309);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpCodeTables::ProcessLongBranchAdjust(OpCodeInfo& opcode, const CPUState& state, CPUTrace& trace) const
|
||||
{
|
||||
// Get the current PC.
|
||||
unsigned short PC = state.PC;
|
||||
|
||||
// Skip past opcode bytes
|
||||
PC += opcode.oplen;
|
||||
|
||||
// Number of bytes for the operand.
|
||||
int operandLen = opcode.numbytes - opcode.oplen;
|
||||
for (int n = 0; n < operandLen; n++)
|
||||
{
|
||||
trace.bytes.push_back(DbgRead8(state.phyAddr,state.block,PC++));
|
||||
}
|
||||
|
||||
// All long branches are relative.
|
||||
int operand = (trace.bytes[opcode.oplen] << 8) + trace.bytes[opcode.oplen + 1];
|
||||
trace.operand = ToRelativeAddressString(operand, operandLen);
|
||||
|
||||
// No adjustment needed on 6309
|
||||
if (state.IsNative6309)
|
||||
{
|
||||
trace.decodeCycles = AdjustCycles(opcode, 0, 0, state.IsNative6309);
|
||||
return true;
|
||||
}
|
||||
|
||||
// We need to determine if the branch will be taken
|
||||
bool willBranch = false;
|
||||
bool C = (state.CC & 0b00000001) == 1;
|
||||
bool V = (state.CC & 0b00000010) == 1; // FIXME: This will never be true because the result can never be 1
|
||||
bool Z = (state.CC & 0b00000100) == 1; // FIXME: This will never be true because the result can never be 1
|
||||
bool N = (state.CC & 0b00001000) == 1; // FIXME: This will never be true because the result can never be 1
|
||||
|
||||
// Will the branch be taken?
|
||||
switch (opcode.opcode)
|
||||
{
|
||||
case 0x24: // LBCC, LBHS
|
||||
willBranch = !C; // IF CC.C = 0 then PC <- PC + IMM
|
||||
break;
|
||||
case 0x25: // LBCS, LBLO
|
||||
willBranch = C; // IF CC.C = 1 then PC <- PC + IMM
|
||||
break;
|
||||
case 0x28: // LBVC
|
||||
willBranch = !V; // IF CC.V = 0 then PC <- PC + IMM
|
||||
break;
|
||||
case 0x29: // LBVS
|
||||
willBranch = V; // IF CC.V = 1 then PC <- PC + IMM
|
||||
break;
|
||||
case 0x26: // LBNE
|
||||
willBranch = !Z; // IF CC.Z = 0 then PC <- PC + IMM
|
||||
break;
|
||||
case 0x27: // LBEQ
|
||||
willBranch = Z; // IF CC.Z = 1 then PC <- PC + IMM
|
||||
break;
|
||||
case 0x2A: // LBPL
|
||||
willBranch = !N; // IF CC.N = 0 then PC <- PC + IMM
|
||||
break;
|
||||
case 0x2B: // LBMI
|
||||
willBranch = N; // IF CC.N = 1 then PC <- PC + IMM
|
||||
break;
|
||||
case 0x2C: // LBGE
|
||||
willBranch = N == V; // IF CC.N = CC.V then PC <- PC + IMM
|
||||
break;
|
||||
case 0x2F: // LBLE
|
||||
willBranch = (N != V) || Z; // IF (CC.N <> CC.V) OR (CC.Z = 1) then PC <- PC + IMM
|
||||
break;
|
||||
case 0x2E: // LBGT
|
||||
willBranch = (N == V) && !Z; // IF (CC.N = CC.V) AND (CC.Z = 0) then PC <- PC + IMM
|
||||
break;
|
||||
case 0x2D: // LBLT
|
||||
willBranch = N != V; // IF CC.N <> CC.V then PC <- PC + IMM
|
||||
break;
|
||||
case 0x22: // LBHI
|
||||
willBranch = !Z && !C; // IF (CC.Z = 0) AND (CC.C = 0) then PC <- PC + IMM
|
||||
break;
|
||||
case 0x23: // LBLS
|
||||
willBranch = Z || C; // IF (CC.Z = 1) OR (CC.C = 1) then PC <- PC + IMM
|
||||
break;
|
||||
}
|
||||
|
||||
// Additional cycle if branch is taken.
|
||||
trace.decodeCycles = AdjustCycles(opcode, willBranch ? 1 : 0, 0, state.IsNative6309);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpCodeTables::ProcessTFMAdjust(OpCodeInfo& opcode, const CPUState& state, CPUTrace& trace) const
|
||||
{
|
||||
// Get the current PC.
|
||||
unsigned short PC = state.PC;
|
||||
|
||||
// Get the post byte.
|
||||
unsigned char postbyte = DbgRead8(state.phyAddr,state.block,++PC);
|
||||
trace.bytes.push_back(postbyte);
|
||||
|
||||
// Get source and destination registers
|
||||
unsigned char src = postbyte >> 4;
|
||||
unsigned char dst = postbyte & 0b00001111;
|
||||
|
||||
trace.operand = ToInterRegister(src) + "," + ToInterRegister(dst);
|
||||
|
||||
// Assume invalid.
|
||||
int additionalCycles = 0;
|
||||
|
||||
// Only D, X, Y, U, S are valid.
|
||||
if (src < 0b0101 && dst < 0b0101)
|
||||
{
|
||||
// Get number of bytes that will be transferred.
|
||||
unsigned short W = (state.E << 8) + state.F;
|
||||
|
||||
// Calculate total cycles to complete.
|
||||
additionalCycles = 3 * W;
|
||||
}
|
||||
|
||||
// Adjust the number of cycles.
|
||||
trace.decodeCycles = AdjustCycles(opcode, additionalCycles, 0, state.IsNative6309);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpCodeTables::ProcessDIVAdjust(OpCodeInfo& opcode, const CPUState& state, CPUTrace& trace) const
|
||||
{
|
||||
// Two rules:
|
||||
// 1) DIVD executes in l fewer cycle if a two's-complement overflow occurs.
|
||||
// 2) Range error means fewer cycles: (13 fewer for DIVD, 21 fewer for DIVQ)
|
||||
|
||||
// Get the current PC.
|
||||
unsigned short PC = state.PC;
|
||||
|
||||
// Determine width.
|
||||
bool wide = (opcode.opcode == 0x8E);
|
||||
|
||||
// Get the dividend
|
||||
int dividend = (state.A << 8) + state.B;
|
||||
|
||||
// Get the divisor
|
||||
int divisor;
|
||||
if (wide)
|
||||
{
|
||||
unsigned char b1 = DbgRead8(state.phyAddr,state.block,++PC);
|
||||
trace.bytes.push_back(b1);
|
||||
unsigned char b2 = DbgRead8(state.phyAddr,state.block,++PC);
|
||||
trace.bytes.push_back(b2);
|
||||
divisor = (b1 << 8) + b2;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char b1 = DbgRead8(state.phyAddr,state.block,++PC);
|
||||
trace.bytes.push_back(b1);
|
||||
divisor = b1;
|
||||
}
|
||||
|
||||
// Calculate the quotient
|
||||
int quotient = dividend / divisor;
|
||||
|
||||
int additionalCycles = 0;
|
||||
|
||||
// Range Error?
|
||||
if (!wide && ((quotient > 255) || (quotient < -256)) ||
|
||||
(wide && ((quotient > 65535) || (quotient < -65536))))
|
||||
{
|
||||
additionalCycles = wide ? -21: -13;
|
||||
}
|
||||
// 2-complement Overflow?
|
||||
else if (!wide && ((quotient > 127) || (quotient < -128)) ||
|
||||
(wide && ((quotient > 32767) || (quotient < -32768))))
|
||||
{
|
||||
additionalCycles = -1;
|
||||
}
|
||||
|
||||
trace.decodeCycles = AdjustCycles(opcode, additionalCycles, 0, state.IsNative6309);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpCodeTables::ProcessWaitForSYNCAdjust(OpCodeInfo& opcode, const CPUState& state, CPUTrace& trace) const
|
||||
{
|
||||
trace.decodeCycles = AdjustCycles(opcode, 0, 0, state.IsNative6309);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string OpCodeTables::ToInterRegister(unsigned char reg) const
|
||||
{
|
||||
std::vector<std::string> regs = { "D", "X", "Y", "U", "S", "PC", "W", "V", "A", "B", "CC", "DP", "0", "0", "E", "F" };
|
||||
return regs[reg];
|
||||
}
|
||||
|
||||
std::string OpCodeTables::ToRegister(unsigned char postbyte) const
|
||||
{
|
||||
int reg = (postbyte & 0b01100000) >> 5;
|
||||
switch (reg)
|
||||
{
|
||||
case 0b00:
|
||||
return "X";
|
||||
case 0b01:
|
||||
return "Y";
|
||||
case 0b10:
|
||||
return "U";
|
||||
case 0b11:
|
||||
return "S";
|
||||
}
|
||||
return "?";
|
||||
}
|
||||
|
||||
std::string OpCodeTables::ToRelativeAddressString(int value, int operandlen) const
|
||||
{
|
||||
std::ostringstream fmt;
|
||||
|
||||
int length = operandlen * 2;
|
||||
int relativeOffset = length + value;
|
||||
switch (operandlen)
|
||||
{
|
||||
case 0:
|
||||
if (relativeOffset > 15) relativeOffset -= 16;
|
||||
break;
|
||||
case 1:
|
||||
if (relativeOffset > 127) relativeOffset -= 256;
|
||||
break;
|
||||
case 2:
|
||||
if (relativeOffset > 32767) relativeOffset -= 65536;
|
||||
break;
|
||||
}
|
||||
|
||||
fmt << "*";
|
||||
if (relativeOffset < 0)
|
||||
{
|
||||
relativeOffset *= -1;
|
||||
fmt << "-$" << std::hex << std::setw(length) << std::uppercase << std::setfill('0') << relativeOffset;
|
||||
}
|
||||
else if (relativeOffset > 0)
|
||||
{
|
||||
fmt << "+$" << std::hex << std::setw(length) << std::uppercase << std::setfill('0') << relativeOffset;
|
||||
}
|
||||
|
||||
return fmt.str();
|
||||
}
|
||||
|
||||
int OpCodeTables::AdjustCycles(OpCodeInfo& opcode, int cycles, int bytes, bool IsNative6309) const
|
||||
{
|
||||
if (IsNative6309)
|
||||
{
|
||||
opcode.num6309cycles += cycles;
|
||||
cycles = opcode.num6309cycles;
|
||||
}
|
||||
else
|
||||
{
|
||||
opcode.num6809cycles += cycles;
|
||||
cycles = opcode.num6809cycles;
|
||||
}
|
||||
opcode.numbytes += bytes;
|
||||
return cycles;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,386 @@
|
||||
// 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/>.
|
||||
//
|
||||
// OpDecoder Interface - Part of the Debugger package for VCC
|
||||
// Author: Mike Rojas
|
||||
#include "OpDecoder.h"
|
||||
#include "../../src/core/tcc1014mmu.h"
|
||||
#include "DebuggerUtils.h"
|
||||
#include "defines.h"
|
||||
#include "../../src/core/Event.h"
|
||||
#include "../../src/core/tcc1014graphics.h"
|
||||
|
||||
|
||||
namespace VCC::Debugger
|
||||
{
|
||||
|
||||
void OpDecoder::Reset(long maxSamples)
|
||||
{
|
||||
TraceCaptured_.clear();
|
||||
TraceCaptured_.reserve(maxSamples);
|
||||
TotalCycles_ = 0;
|
||||
OpCodeTables_ = std::make_unique<OpCodeTables>();
|
||||
}
|
||||
|
||||
void OpDecoder::CaptureBefore(long cycleTime, const CPUState& state)
|
||||
{
|
||||
BeforeCycles_ = cycleTime;
|
||||
CurrentTrace_.event = TraceEvent::Instruction;
|
||||
CurrentTrace_.startState = state;
|
||||
#if USE_NEWTIMING
|
||||
CurrentTrace_.clock = VCC::gEvents.GetClocks();
|
||||
CurrentTrace_.frameStart = gGimeGpu.GetLineStartClock();
|
||||
#endif
|
||||
CurrentTrace_.pc = state.PC;
|
||||
CurrentTrace_.bytes.clear();
|
||||
CurrentTrace_.instruction.clear();
|
||||
CurrentTrace_.operand.clear();
|
||||
|
||||
DecodeInstruction(state, CurrentTrace_);
|
||||
}
|
||||
|
||||
void OpDecoder::CaptureAfter(long cycleTime, const CPUState& state)
|
||||
{
|
||||
AfterCycles_ = cycleTime;
|
||||
CurrentTrace_.cycleTime = TotalCycles_;
|
||||
CurrentTrace_.endState = state;
|
||||
CurrentTrace_.execCycles = AfterCycles_ - BeforeCycles_;
|
||||
TotalCycles_ += CurrentTrace_.execCycles;
|
||||
TraceCaptured_.push_back(CurrentTrace_);
|
||||
}
|
||||
|
||||
void OpDecoder::CaptureInterrupt(TraceEvent evt, IRQType irq, long cycleTime, const CPUState& state)
|
||||
{
|
||||
CPUTrace interrupt;
|
||||
interrupt.event = evt;
|
||||
interrupt.cycleTime = TotalCycles_;
|
||||
#if USE_NEWTIMING
|
||||
interrupt.clock = VCC::gEvents.GetClocks();
|
||||
interrupt.frameStart = gGimeGpu.GetLineStartClock();
|
||||
#endif
|
||||
CurrentTrace_.pc = state.PC;
|
||||
interrupt.startState = state;
|
||||
interrupt.endState = state;
|
||||
interrupt.decodeCycles = cycleTime;
|
||||
interrupt.execCycles = cycleTime;
|
||||
TotalCycles_ += interrupt.execCycles;
|
||||
DecodeInterrupt(evt, irq, interrupt.instruction);
|
||||
TraceCaptured_.push_back(interrupt);
|
||||
}
|
||||
#if USE_NEWTIMING
|
||||
void OpDecoder::CaptureScreenEvent(TraceEvent evt, double cycles, unsigned int line, const char* s)
|
||||
{
|
||||
int execCycles = (int)floor(cycles);
|
||||
CPUTrace screen;
|
||||
DecodeScreen(evt, screen.instruction, line, s);
|
||||
screen.event = evt;
|
||||
screen.clock = VCC::gEvents.GetClocks();
|
||||
screen.frameStart = gGimeGpu.GetLineStartClock();
|
||||
screen.cycleTime = TotalCycles_;
|
||||
screen.pc = 0;
|
||||
screen.startState = { 0 };
|
||||
screen.endState = { 0 };
|
||||
screen.decodeCycles = execCycles;
|
||||
screen.execCycles = execCycles;
|
||||
screen.frame = CurrentFrame_;
|
||||
screen.line = line;
|
||||
// TotalCycles_ += screen.execCycles;
|
||||
TraceCaptured_.push_back(screen);
|
||||
}
|
||||
void OpDecoder::CaptureScreenEvent(TraceEvent evt, double cycles, unsigned int line)
|
||||
{
|
||||
int execCycles = (int)floor(cycles);
|
||||
CPUTrace screen;
|
||||
DecodeScreen(evt, screen.instruction, line, "");
|
||||
screen.event = evt;
|
||||
screen.clock = VCC::gEvents.GetClocks();
|
||||
screen.frameStart = gGimeGpu.GetLineStartClock();
|
||||
screen.cycleTime = TotalCycles_;
|
||||
screen.pc = 0;
|
||||
screen.startState = { 0 };
|
||||
screen.endState = { 0 };
|
||||
screen.decodeCycles = execCycles;
|
||||
screen.execCycles = execCycles;
|
||||
screen.frame = CurrentFrame_;
|
||||
screen.line = line;
|
||||
// TotalCycles_ += screen.execCycles;
|
||||
TraceCaptured_.push_back(screen);
|
||||
}
|
||||
#else
|
||||
void OpDecoder::CaptureScreenEvent(TraceEvent evt, double cycles)
|
||||
{
|
||||
int execCycles = (int)floor(cycles);
|
||||
CPUTrace screen;
|
||||
DecodeScreen(evt, screen.instruction);
|
||||
screen.event = evt;
|
||||
screen.cycleTime = TotalCycles_;
|
||||
screen.pc = 0;
|
||||
screen.startState = { 0 };
|
||||
screen.endState = { 0 };
|
||||
screen.decodeCycles = execCycles;
|
||||
screen.execCycles = execCycles;
|
||||
screen.frame = CurrentFrame_;
|
||||
screen.line = CurrentLine_;
|
||||
// TotalCycles_ += screen.execCycles;
|
||||
TraceCaptured_.push_back(screen);
|
||||
}
|
||||
#endif
|
||||
void OpDecoder::CaptureEmulatorCycle(TraceEvent evt, int state, double lineNS, double irqNS, double soundNS, double cycles, double drift)
|
||||
{
|
||||
CPUTrace emulator;
|
||||
emulator.event = evt;
|
||||
emulator.cycleTime = 0;
|
||||
#if USE_NEWTIMING
|
||||
emulator.clock = VCC::gEvents.GetClocks();
|
||||
emulator.frameStart = gGimeGpu.GetLineStartClock();
|
||||
#endif
|
||||
emulator.startState = { 0 };
|
||||
emulator.endState = { 0 };
|
||||
emulator.decodeCycles = 0;
|
||||
emulator.execCycles = 0;
|
||||
emulator.frame = 0;
|
||||
emulator.line = 0;
|
||||
emulator.emulationState = state;
|
||||
emulator.emulator.push_back(lineNS);
|
||||
emulator.emulator.push_back(irqNS);
|
||||
emulator.emulator.push_back(soundNS);
|
||||
emulator.emulator.push_back(cycles);
|
||||
emulator.emulator.push_back(drift);
|
||||
emulator.emulator.push_back(cycles + -drift);
|
||||
TraceCaptured_.push_back(emulator);
|
||||
}
|
||||
|
||||
const std::vector<VCC::CPUTrace>& OpDecoder::GetTrace() const
|
||||
{
|
||||
return TraceCaptured_;
|
||||
}
|
||||
|
||||
size_t OpDecoder::GetSampleCount() const
|
||||
{
|
||||
return TraceCaptured_.size();
|
||||
}
|
||||
|
||||
OpDecoder::IRQType OpDecoder::ToIRQType(unsigned char irq) const
|
||||
{
|
||||
switch (irq)
|
||||
{
|
||||
case INT_IRQ:
|
||||
return IRQType::InterruptRequest;
|
||||
case INT_FIRQ:
|
||||
return IRQType::FastInterruptRequest;
|
||||
case INT_NMI:
|
||||
return IRQType::NonMaskableInterrupt;
|
||||
}
|
||||
return IRQType();
|
||||
}
|
||||
|
||||
bool OpDecoder::DecodeInterrupt(TraceEvent evt, IRQType irq, std::string& interrupt) const
|
||||
{
|
||||
switch (irq)
|
||||
{
|
||||
case IRQType::InterruptRequest:
|
||||
interrupt += "[IRQ]";
|
||||
break;
|
||||
case IRQType::FastInterruptRequest:
|
||||
interrupt += "[FIRQ]";
|
||||
break;
|
||||
case IRQType::NonMaskableInterrupt:
|
||||
interrupt += "[NMI]";
|
||||
break;
|
||||
}
|
||||
|
||||
switch (evt)
|
||||
{
|
||||
case TraceEvent::IRQRequested:
|
||||
interrupt += " :: Request";
|
||||
break;
|
||||
case TraceEvent::IRQMasked:
|
||||
interrupt += " :: Ignored";
|
||||
break;
|
||||
case TraceEvent::IRQServicing:
|
||||
interrupt += " :: Service";
|
||||
break;
|
||||
case TraceEvent::IRQExecuting:
|
||||
interrupt += " :: Execute";
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if USE_NEWTIMING
|
||||
bool OpDecoder::DecodeScreen(TraceEvent evt, std::string& screen, unsigned int n, const char *s)
|
||||
{
|
||||
switch (evt)
|
||||
{
|
||||
case TraceEvent::ScreenTopBorder:
|
||||
screen = "[Top Border]";
|
||||
break;
|
||||
case TraceEvent::ScreenRender:
|
||||
screen = "[Render]";
|
||||
break;
|
||||
case TraceEvent::ScreenBottomBorder:
|
||||
screen = "[Bot Border]";
|
||||
break;
|
||||
case TraceEvent::ScreenVSYNCLow:
|
||||
screen = "[VSync Low ";
|
||||
screen += std::to_string(n);
|
||||
screen += "]";
|
||||
CurrentLine_ = 0;
|
||||
TotalCycles_ = 0;
|
||||
break;
|
||||
case TraceEvent::ScreenVSYNCHigh:
|
||||
screen = "[VSync High ";
|
||||
screen += std::to_string(n);
|
||||
screen += "]";
|
||||
break;
|
||||
case TraceEvent::ScreenHSYNCLow:
|
||||
screen = "[HSync Low ";
|
||||
screen += std::to_string(n);
|
||||
screen += "]";
|
||||
break;
|
||||
case TraceEvent::ScreenHSYNCHigh:
|
||||
screen = "[HSync High ";
|
||||
screen += std::to_string(n);
|
||||
screen += "]";
|
||||
break;
|
||||
case TraceEvent::ScreenReg:
|
||||
screen = "[";
|
||||
screen += s;
|
||||
screen += "]";
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
bool OpDecoder::DecodeScreen(TraceEvent evt, std::string& screen)
|
||||
{
|
||||
switch (evt)
|
||||
{
|
||||
case TraceEvent::ScreenTopBorder:
|
||||
screen = "[Top Border]";
|
||||
break;
|
||||
case TraceEvent::ScreenRender:
|
||||
screen = "[Render]";
|
||||
break;
|
||||
case TraceEvent::ScreenBottomBorder:
|
||||
screen = "[Bot Border]";
|
||||
break;
|
||||
case TraceEvent::ScreenVSYNCLow:
|
||||
screen = "[VSync Low ";
|
||||
screen += std::to_string(CurrentFrame_);
|
||||
screen += "]";
|
||||
CurrentLine_ = 0;
|
||||
TotalCycles_ = 0;
|
||||
break;
|
||||
case TraceEvent::ScreenVSYNCHigh:
|
||||
screen = "[VSync High ";
|
||||
screen += std::to_string(CurrentFrame_++);
|
||||
screen += "]";
|
||||
break;
|
||||
case TraceEvent::ScreenHSYNCLow:
|
||||
screen = "[HSync Low ";
|
||||
screen += std::to_string(CurrentLine_);
|
||||
screen += "]";
|
||||
break;
|
||||
case TraceEvent::ScreenHSYNCHigh:
|
||||
screen = "[HSync High ";
|
||||
screen += std::to_string(CurrentLine_++);
|
||||
screen += "]";
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool OpDecoder::DecodeInstruction(const CPUState& state, CPUTrace& trace)
|
||||
{
|
||||
// Get the address of the next Op Code.
|
||||
unsigned short PC = state.PC;
|
||||
|
||||
// Get the Op Code.
|
||||
unsigned char Op1 = DbgRead8(state.phyAddr,state.block,PC);
|
||||
|
||||
// Save it.
|
||||
trace.bytes.push_back(Op1);
|
||||
|
||||
// Decode it.
|
||||
OpCodeTables::OpCodeInfo Opcode = OpCodeTables_->Page1OpCodes[Op1];
|
||||
|
||||
// Page 2 Opcode?
|
||||
if (Opcode.mode == OpCodeTables::AddressingMode::OpPage2)
|
||||
{
|
||||
return DecodePage2Instruction(++PC, state, trace);
|
||||
}
|
||||
|
||||
// Page 3 Opcode?
|
||||
if (Opcode.mode == OpCodeTables::AddressingMode::OpPage3)
|
||||
{
|
||||
return DecodePage3Instruction(++PC, state, trace);
|
||||
}
|
||||
|
||||
// Page 1 Opcode =================
|
||||
trace.instruction = Opcode.name;
|
||||
|
||||
// Calculate cycles based on state.
|
||||
OpCodeTables_->ProcessHeuristics(Opcode, state, trace);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpDecoder::DecodePage2Instruction(unsigned short PC, const CPUState& state, CPUTrace& trace)
|
||||
{
|
||||
// Get the extended Op Code.
|
||||
unsigned char Op2 = DbgRead8(state.phyAddr,state.block,PC);
|
||||
|
||||
// Save it.
|
||||
trace.bytes.push_back(Op2);
|
||||
|
||||
// Decode it.
|
||||
OpCodeTables::OpCodeInfo Opcode = OpCodeTables_->Page2OpCodes[Op2];
|
||||
|
||||
// Page 2 Opcode =================
|
||||
trace.instruction = Opcode.name;
|
||||
|
||||
// Calculate cycles based on state.
|
||||
OpCodeTables_->ProcessHeuristics(Opcode, state, trace);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpDecoder::DecodePage3Instruction(unsigned short PC, const CPUState& state, CPUTrace& trace)
|
||||
{
|
||||
// Get the extended Op Code.
|
||||
unsigned char Op3 = DbgRead8(state.phyAddr,state.block,PC);
|
||||
|
||||
// Save it.
|
||||
trace.bytes.push_back(Op3);
|
||||
|
||||
// Decode it.
|
||||
OpCodeTables::OpCodeInfo Opcode = OpCodeTables_->Page3OpCodes[Op3];
|
||||
|
||||
// Page 3 Opcode =================
|
||||
trace.instruction = Opcode.name;
|
||||
|
||||
// Calculate cycles based on state.
|
||||
OpCodeTables_->ProcessHeuristics(Opcode, state, trace);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
//
|
||||
// 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/>.
|
||||
//
|
||||
// OpDecoder Interface - Part of the Debugger package for VCC
|
||||
// Author: Mike Rojas
|
||||
#pragma once
|
||||
#include "../../src/core/BuildConfig.h"
|
||||
#include "Windows.h"
|
||||
#include <string>
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include "../../src/core/OpCodeTables.h"
|
||||
#include "../../src/core/MachineDefs.h"
|
||||
|
||||
namespace VCC::Debugger
|
||||
{
|
||||
class OpDecoder
|
||||
{
|
||||
public:
|
||||
|
||||
OpDecoder()
|
||||
{
|
||||
Reset(500000);
|
||||
};
|
||||
|
||||
// Interrupt Types on a 6x09 microprocessor
|
||||
enum class IRQType
|
||||
{
|
||||
InterruptRequest,
|
||||
FastInterruptRequest,
|
||||
NonMaskableInterrupt
|
||||
};
|
||||
|
||||
void Reset(long maxSamples);
|
||||
void CaptureBefore(long cycleTime, const CPUState& state);
|
||||
void CaptureAfter(long cycleTime, const CPUState& state);
|
||||
void CaptureInterrupt(TraceEvent evt, IRQType irq, long cycleTime, const CPUState& state);
|
||||
#if USE_NEWTIMING
|
||||
void CaptureScreenEvent(TraceEvent evt, double cycles, unsigned int line);
|
||||
void CaptureScreenEvent(TraceEvent evt, double cycles, unsigned int line, const char *s);
|
||||
#else
|
||||
void CaptureScreenEvent(TraceEvent evt, double cycles);
|
||||
#endif
|
||||
void CaptureEmulatorCycle(TraceEvent evt, int state, double lineNS, double irqNS, double soundNS, double cycles, double drift);
|
||||
|
||||
const std::vector<CPUTrace>& GetTrace() const;
|
||||
|
||||
size_t GetSampleCount() const;
|
||||
|
||||
IRQType ToIRQType(unsigned char irq) const;
|
||||
|
||||
bool DecodeInstruction(const CPUState& state, CPUTrace& trace);
|
||||
|
||||
protected:
|
||||
|
||||
bool DecodeInterrupt(TraceEvent evt, IRQType irq, std::string& interrupt) const;
|
||||
#if USE_NEWTIMING
|
||||
bool DecodeScreen(TraceEvent evt, std::string& screen, unsigned int n, const char *s);
|
||||
#else
|
||||
bool DecodeScreen(TraceEvent evt, std::string& screen);
|
||||
#endif
|
||||
bool DecodePage2Instruction(unsigned short PC, const CPUState& state, CPUTrace& trace);
|
||||
bool DecodePage3Instruction(unsigned short PC, const CPUState& state, CPUTrace& trace);
|
||||
|
||||
private:
|
||||
|
||||
std::unique_ptr<OpCodeTables> OpCodeTables_;
|
||||
std::vector<CPUTrace> TraceCaptured_;
|
||||
CPUTrace CurrentTrace_;
|
||||
long TotalCycles_ = 0;
|
||||
long BeforeCycles_ = 0;
|
||||
long AfterCycles_ = 0;
|
||||
int CurrentFrame_ = 0;
|
||||
int CurrentLine_ = 0;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,896 @@
|
||||
// Copyright 2015 by Joseph Forgion
|
||||
// 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// 2025/04/10 - Craig Allsop - Add OpenGL rendering.
|
||||
//
|
||||
|
||||
#include "OpenGL.h"
|
||||
#include "../../src/core/BuildConfig.h"
|
||||
#include <Windows.h>
|
||||
#include <CommCtrl.h>
|
||||
#include <gl/GL.h>
|
||||
#include "GL/glext.h"
|
||||
#include "GL/wglext.h"
|
||||
#include <vcc/util/logger.h>
|
||||
|
||||
#if USE_OPENGL
|
||||
|
||||
#if USE_DEBUG_LINES
|
||||
#include <vector>
|
||||
#endif
|
||||
|
||||
typedef HGLRC(WINAPI* wglprocCreateContextAttribsARB)(HDC, HGLRC, const int*);
|
||||
typedef BOOL(WINAPI* wglprocChoosePixelFormatARB)(HDC, const int*, const FLOAT*, UINT, int*, UINT*);
|
||||
typedef BOOL(WINAPI* wglprocSwapIntervalEXT)(int interval);
|
||||
|
||||
#pragma comment(lib, "opengl32.lib")
|
||||
#pragma comment(lib, "glu32")
|
||||
|
||||
static const LPCSTR ViewClass = "VCC_ViewWnd";
|
||||
static const LPCSTR OpenGLClass = "VCC_OpenGLWnd";
|
||||
|
||||
namespace VCC
|
||||
{
|
||||
//
|
||||
// Private wrapper on result code for logging errors
|
||||
//
|
||||
static int Result(int code)
|
||||
{
|
||||
if (code != OpenGL::OK)
|
||||
{
|
||||
char message[256];
|
||||
snprintf(message,64,"OpenGL error %d\nCheck OpenGL support",code);
|
||||
MessageBox(nullptr,message,"Error",0);
|
||||
// FIXME: This is needed and should not be commented out. Wrap it conditional
|
||||
// either here or in the debug log functions.
|
||||
//PrintLogC("OpenGL Error: %d\n", code);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
//
|
||||
// Impliementation detail of OpenGL interface.
|
||||
//
|
||||
struct OpenGL::Detail
|
||||
{
|
||||
const int SubClassId = 1;
|
||||
const int GLSubClassId = 2;
|
||||
const int SurfaceWidth = 640; // coco surface size
|
||||
const int SurfaceHeight = 480;
|
||||
const float PalFreq = 60.0f;
|
||||
const float NtscFreq = 50.0f;
|
||||
|
||||
bool isInitialized; // if already initialized
|
||||
|
||||
HWND hWnd; // window handle of OpenGL window
|
||||
HDC hDC; // its context
|
||||
HGLRC hRC;
|
||||
|
||||
int width; // width of OpenGL window
|
||||
int height; // height of OpenGL window
|
||||
int statusHeight; // height of status bar
|
||||
bool aspect; // true if aspect preserved, otherwise fit
|
||||
bool ntsc; // use ntsc 50hz, otherwise 60hz
|
||||
Pixel* pixels; // cpu side surface buffer
|
||||
|
||||
GLuint texId; // OpenGL texture on gpu
|
||||
wglprocSwapIntervalEXT wglSwapIntervalEXT;
|
||||
|
||||
ISystemState* state;
|
||||
|
||||
#if USE_DEBUG_LINES
|
||||
struct Line { float x1; float y1; float x2; float y2; Pixel color; };
|
||||
std::vector<Line> debugLines;
|
||||
struct Box { float x1; float y1; float w; float h; Pixel color; bool filled; };
|
||||
std::vector<Box> debugBoxes;
|
||||
struct Text { const OpenGLFont* font; float x1; float y1; float size; std::string str; Pixel color; };
|
||||
std::vector<Text> debugTexts;
|
||||
#endif // USE_DEBUG_LINES
|
||||
|
||||
OpenGL::Detail(ISystemState *state)
|
||||
: isInitialized(false), hWnd(nullptr), hDC(nullptr), hRC(nullptr)
|
||||
, width(0), height(0), statusHeight(0), aspect(true), ntsc(false)
|
||||
, pixels(nullptr), texId(0), wglSwapIntervalEXT(nullptr), state(state)
|
||||
{
|
||||
}
|
||||
|
||||
// intercepted parent window messages
|
||||
static LRESULT __stdcall SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
|
||||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_ERASEBKGND:
|
||||
return 1;
|
||||
|
||||
case WM_SIZE:
|
||||
{
|
||||
auto detail = reinterpret_cast<OpenGL::Detail*>(dwRefData);
|
||||
detail->Resize(LOWORD(lParam), HIWORD(lParam));
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_NCDESTROY:
|
||||
RemoveWindowSubclass(hWnd, &SubclassProc, uIdSubclass);
|
||||
break;
|
||||
};
|
||||
|
||||
return DefSubclassProc(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
static LRESULT __stdcall GLSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
|
||||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_ERASEBKGND:
|
||||
return 1;
|
||||
|
||||
// prevent child window taking mouse messages
|
||||
case WM_NCHITTEST:
|
||||
return HTTRANSPARENT;
|
||||
|
||||
case WM_NCDESTROY:
|
||||
RemoveWindowSubclass(hWnd, &SubclassProc, uIdSubclass);
|
||||
break;
|
||||
};
|
||||
|
||||
return DefSubclassProc(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
void Resize(int width, int height)
|
||||
{
|
||||
// windows callback with client size, leave space for status bar.
|
||||
height -= statusHeight;
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
if (hWnd) SetWindowPos(hWnd, nullptr, 0, 0, width, height, SWP_NOCOPYBITS);
|
||||
}
|
||||
|
||||
int Setup(void* hwnd, int width, int height, int statusHeight)
|
||||
{
|
||||
if (isInitialized)
|
||||
return Result(ERR_INITIALIZED);
|
||||
|
||||
HWND hTempWnd = nullptr;
|
||||
HDC hTempDC = nullptr;
|
||||
HGLRC hTempRC = nullptr;
|
||||
|
||||
auto hInstance = GetModuleHandle(nullptr);
|
||||
|
||||
auto cleanupTempWindow = [&](int err)
|
||||
{
|
||||
if (hTempRC) { wglMakeCurrent(nullptr, nullptr); wglDeleteContext(hTempRC); }
|
||||
if (hTempDC) ReleaseDC(hTempWnd, hTempDC);
|
||||
if (hTempWnd) DestroyWindow(hTempWnd);
|
||||
UnregisterClass(ViewClass, hInstance);
|
||||
return err;
|
||||
};
|
||||
|
||||
auto cleanupWindow = [&](int err)
|
||||
{
|
||||
Cleanup();
|
||||
return cleanupTempWindow(err);
|
||||
};
|
||||
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
this->statusHeight = statusHeight;
|
||||
|
||||
WNDCLASS wc;
|
||||
memset(&wc, 0, sizeof(wc));
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
||||
wc.lpfnWndProc = DefWindowProc;
|
||||
wc.hInstance = GetModuleHandle(nullptr);
|
||||
wc.lpszClassName = ViewClass;
|
||||
if (!RegisterClass(&wc))
|
||||
return ERR_TMPREGISTERCLASS;
|
||||
|
||||
// Create a temporary context to get address of wgl extensions.
|
||||
hTempWnd = CreateWindowEx(WS_EX_APPWINDOW, ViewClass, "Simple", WS_VISIBLE | WS_POPUP | WS_MAXIMIZE,
|
||||
0, 0, 0, 0, nullptr, nullptr, hInstance, nullptr);
|
||||
|
||||
if (!hTempWnd)
|
||||
return Result(ERR_TMPCREATEWINDOW);
|
||||
|
||||
hTempDC = GetDC(hTempWnd);
|
||||
if (!hTempDC)
|
||||
return Result(cleanupTempWindow(ERR_TMPGETDC));
|
||||
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
memset(&pfd, 0, sizeof(pfd));
|
||||
pfd.nSize = sizeof(pfd);
|
||||
pfd.nVersion = 1;
|
||||
pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW;
|
||||
pfd.cColorBits = 24;
|
||||
pfd.iPixelType = PFD_TYPE_RGBA;
|
||||
pfd.iLayerType = PFD_MAIN_PLANE;
|
||||
|
||||
int iPF;
|
||||
if (!(iPF = ChoosePixelFormat(hTempDC, &pfd)))
|
||||
return Result(cleanupTempWindow(ERR_TMPCHOOSEFORMAT));
|
||||
|
||||
if (!SetPixelFormat(hTempDC, iPF, &pfd))
|
||||
return Result(cleanupTempWindow(ERR_TMPSETPIXELFORMAT));
|
||||
|
||||
if (!(hTempRC = wglCreateContext(hTempDC)))
|
||||
return Result(cleanupTempWindow(ERR_TMPCREATECONTEXT));
|
||||
|
||||
if (!wglMakeCurrent(hTempDC, hTempRC))
|
||||
return Result(cleanupTempWindow(ERR_TMPMAKECONTEXT));
|
||||
|
||||
// Function pointers returned by wglGetProcAddress are tied to the render context they were obtained with.
|
||||
wglprocCreateContextAttribsARB wglCreateContextAttribsARB = (wglprocCreateContextAttribsARB)wglGetProcAddress("wglCreateContextAttribsARB");
|
||||
wglprocChoosePixelFormatARB wglChoosePixelFormatARB = (wglprocChoosePixelFormatARB)wglGetProcAddress("wglChoosePixelFormatARB");
|
||||
wglSwapIntervalEXT = (wglprocSwapIntervalEXT)wglGetProcAddress("wglSwapIntervalEXT");
|
||||
|
||||
if (wglChoosePixelFormatARB && wglCreateContextAttribsARB && wglSwapIntervalEXT)
|
||||
{
|
||||
WNDCLASS wc = { 0 };
|
||||
wc.lpfnWndProc = DefWindowProc;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hbrBackground = nullptr;
|
||||
wc.lpszClassName = OpenGLClass;
|
||||
wc.style = CS_OWNDC;
|
||||
|
||||
if (!RegisterClass(&wc))
|
||||
return Result(cleanupTempWindow(ERR_REGISTERCLASS));
|
||||
|
||||
SetWindowSubclass((HWND)hwnd, &SubclassProc, SubClassId, (DWORD_PTR)this);
|
||||
|
||||
hWnd = CreateWindowEx(0, OpenGLClass, nullptr, WS_VISIBLE | WS_CHILD, 0, 0,
|
||||
width, height, (HWND)hwnd, 0, hInstance, this);
|
||||
|
||||
if (!hWnd)
|
||||
{
|
||||
UnregisterClass(OpenGLClass, hInstance);
|
||||
return Result(cleanupTempWindow(ERR_CREATEWINDOW));
|
||||
}
|
||||
|
||||
SetWindowSubclass((HWND)hWnd, &GLSubclassProc, GLSubClassId, (DWORD_PTR)this);
|
||||
|
||||
hDC = GetDC(hWnd);
|
||||
|
||||
if (!hDC)
|
||||
return Result(cleanupWindow(ERR_GETDC));
|
||||
|
||||
int attribs[] = {
|
||||
WGL_DRAW_TO_WINDOW_ARB, TRUE,
|
||||
WGL_DOUBLE_BUFFER_ARB, TRUE,
|
||||
WGL_SUPPORT_OPENGL_ARB, TRUE,
|
||||
WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
|
||||
WGL_COLOR_BITS_ARB, 24,
|
||||
WGL_RED_BITS_ARB, 8,
|
||||
WGL_GREEN_BITS_ARB, 8,
|
||||
WGL_BLUE_BITS_ARB, 8,
|
||||
WGL_DEPTH_BITS_ARB, 0,
|
||||
WGL_STENCIL_BITS_ARB, 0,
|
||||
0, 0
|
||||
};
|
||||
|
||||
UINT numFormats;
|
||||
BOOL success = wglChoosePixelFormatARB(hDC, attribs, nullptr, 1, &iPF, &numFormats);
|
||||
DescribePixelFormat(hDC, iPF, sizeof(pfd), &pfd);
|
||||
|
||||
if (!(success && numFormats >= 1 && SetPixelFormat(hDC, iPF, &pfd)))
|
||||
return Result(cleanupWindow(ERR_SETPIXELFORMAT));
|
||||
|
||||
// request OpenGl 3.0
|
||||
int contextAttribs[] =
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 0,
|
||||
0, 0
|
||||
};
|
||||
|
||||
hRC = wglCreateContextAttribsARB(hDC, nullptr, contextAttribs);
|
||||
if (!hRC)
|
||||
return Result(cleanupWindow(ERR_GLVERSION));
|
||||
|
||||
// release temporary window
|
||||
cleanupTempWindow(OK);
|
||||
}
|
||||
else return Result(ERR_MISSINGAPIS);
|
||||
|
||||
// the off screen surface
|
||||
pixels = new Pixel[SurfaceWidth * SurfaceHeight];
|
||||
memset(pixels, 0, SurfaceWidth * SurfaceHeight * sizeof(Pixel));
|
||||
|
||||
// create texture for rendering surface
|
||||
wglMakeCurrent(hDC, hRC);
|
||||
glViewport(0, 0, width, height);
|
||||
glGenTextures(1, &texId);
|
||||
glBindTexture(GL_TEXTURE_2D, texId);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SurfaceWidth, SurfaceHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, pixels);
|
||||
wglMakeCurrent(nullptr, nullptr);
|
||||
isInitialized = true;
|
||||
return Result(OK);
|
||||
}
|
||||
|
||||
int Render()
|
||||
{
|
||||
if (!isInitialized) return Result(ERR_NOTINITIALIZED);
|
||||
|
||||
wglMakeCurrent(hDC, hRC);
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(0, (float)width, (float)height, 0, -1, 1);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
// select surface texture
|
||||
glBindTexture(GL_TEXTURE_2D, texId);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
// update it
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, SurfaceWidth, SurfaceHeight, GL_BGRA, GL_UNSIGNED_BYTE, pixels);
|
||||
|
||||
Rect area;
|
||||
GetDisplayArea(&area);
|
||||
|
||||
// aliases - don't panic
|
||||
const auto& x = area.x;
|
||||
const auto& y = area.y;
|
||||
const auto& w = area.w;
|
||||
const auto& h = area.h;
|
||||
|
||||
// draw main surface in the middle
|
||||
glColor3f(1, 1, 1);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0); glVertex3f(x, y, 0);
|
||||
glTexCoord2f(1, 0); glVertex3f(x + w, y, 0);
|
||||
glTexCoord2f(1, 1); glVertex3f(x + w, y + h, 0);
|
||||
glTexCoord2f(0, 1); glVertex3f(x, y + h, 0);
|
||||
glEnd();
|
||||
|
||||
#if USE_BLACKEDGES
|
||||
// Switch to black color for edges
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
#define glTexCoord2f(a,b) glColor3f(0,0,0)
|
||||
#endif // USE_BLACKEDGES
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
if (x > 0)
|
||||
{
|
||||
// fill left/right edge
|
||||
glTexCoord2f(0, 0); glVertex3f(0, 0, 0);
|
||||
glTexCoord2f(0, 0); glVertex3f(x, 0, 0);
|
||||
glTexCoord2f(0, 1); glVertex3f(x, h, 0);
|
||||
glTexCoord2f(0, 1); glVertex3f(0, h, 0);
|
||||
|
||||
glTexCoord2f(1, 0); glVertex3f(x + w, y, 0);
|
||||
glTexCoord2f(1, 0); glVertex3f((float)width, y, 0);
|
||||
glTexCoord2f(1, 1); glVertex3f((float)width, y + h, 0);
|
||||
glTexCoord2f(1, 1); glVertex3f(x + w, y + h, 0);
|
||||
}
|
||||
else if (y > 0)
|
||||
{
|
||||
// fill top/bottom edge
|
||||
glTexCoord2f(0, 0); glVertex3f(0, 0, 0);
|
||||
glTexCoord2f(1, 0); glVertex3f(w, 0, 0);
|
||||
glTexCoord2f(1, 0); glVertex3f(w, y, 0);
|
||||
glTexCoord2f(0, 0); glVertex3f(0, y, 0);
|
||||
|
||||
glTexCoord2f(0, 1); glVertex3f(0, y + h, 0);
|
||||
glTexCoord2f(1, 1); glVertex3f(w, y + h, 0);
|
||||
glTexCoord2f(1, 1); glVertex3f(w, (float)height, 0);
|
||||
glTexCoord2f(0, 1); glVertex3f(0, (float)height, 0);
|
||||
}
|
||||
|
||||
#if USE_BLACKEDGES
|
||||
#undef glTexCoord2f
|
||||
#endif // USE_BLACKEDGES
|
||||
|
||||
glEnd();
|
||||
|
||||
#if USE_DEBUG_LINES
|
||||
if (debugBoxes.size())
|
||||
{
|
||||
Pixel lastColor(debugBoxes[0].color);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glColor4ub(lastColor.r, lastColor.g, lastColor.b, lastColor.a);
|
||||
|
||||
for (size_t i = 0; i < debugBoxes.size(); ++i)
|
||||
{
|
||||
auto x = debugBoxes[i].x1;
|
||||
auto y = debugBoxes[i].y1;
|
||||
auto w = debugBoxes[i].w;
|
||||
auto h = debugBoxes[i].h;
|
||||
|
||||
if (lastColor != debugBoxes[i].color)
|
||||
{
|
||||
lastColor = debugBoxes[i].color;
|
||||
glColor4ub(lastColor.r, lastColor.g, lastColor.b, lastColor.a);
|
||||
}
|
||||
|
||||
if (debugBoxes[i].filled)
|
||||
{
|
||||
glBegin(GL_QUADS);
|
||||
glVertex3f(x, y, 0);
|
||||
glVertex3f(x + w, y, 0);
|
||||
glVertex3f(x + w, y + h, 0);
|
||||
glVertex3f(x, y + h, 0);
|
||||
glEnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
glBegin(GL_LINES);
|
||||
glVertex3f(x, y, 0);
|
||||
glVertex3f(x + w, y, 0);
|
||||
|
||||
glVertex3f(x + w, y, 0);
|
||||
glVertex3f(x + w, y + h, 0);
|
||||
|
||||
glVertex3f(x + w, y + h, 0);
|
||||
glVertex3f(x, y + h, 0);
|
||||
|
||||
glVertex3f(x, y + h, 0);
|
||||
glVertex3f(x, y, 0);
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
debugBoxes.clear();
|
||||
}
|
||||
|
||||
// draw some debug lines
|
||||
if (debugLines.size())
|
||||
{
|
||||
Pixel lastColor(debugLines[0].color);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glBegin(GL_LINES);
|
||||
glColor4ub(lastColor.r, lastColor.g, lastColor.b, lastColor.a);
|
||||
for (size_t i = 0; i < debugLines.size(); ++i)
|
||||
{
|
||||
if (lastColor != debugLines[i].color)
|
||||
{
|
||||
lastColor = debugLines[i].color;
|
||||
glColor4ub(lastColor.r, lastColor.g, lastColor.b, lastColor.a);
|
||||
}
|
||||
glVertex3f(debugLines[i].x1, debugLines[i].y1, 0);
|
||||
glVertex3f(debugLines[i].x2, debugLines[i].y2, 0);
|
||||
}
|
||||
glEnd();
|
||||
glDisable(GL_BLEND);
|
||||
debugLines.clear();
|
||||
}
|
||||
|
||||
if (debugTexts.size())
|
||||
{
|
||||
for (auto &t : debugTexts)
|
||||
{
|
||||
RenderText(t.font, t.x1, t.y1, t.size, t.str.c_str());
|
||||
}
|
||||
debugTexts.clear();
|
||||
}
|
||||
#endif // USE_DEBUG_LINES
|
||||
|
||||
wglMakeCurrent(nullptr, nullptr);
|
||||
return Result(OK);
|
||||
}
|
||||
|
||||
int Cleanup()
|
||||
{
|
||||
if (!isInitialized) return Result(ERR_NOTINITIALIZED);
|
||||
if (pixels) delete[] pixels;
|
||||
if (hDC) ReleaseDC(hWnd, hDC);
|
||||
if (hWnd) DestroyWindow(hWnd);
|
||||
UnregisterClass(OpenGLClass, GetModuleHandle(nullptr));
|
||||
isInitialized = false;
|
||||
return Result(OK);
|
||||
}
|
||||
|
||||
int GetSurface(Pixel** pixels) const
|
||||
{
|
||||
if (!isInitialized) return Result(ERR_NOTINITIALIZED);
|
||||
*pixels = this->pixels;
|
||||
return Result(OK);
|
||||
}
|
||||
|
||||
int SetOption(int option, bool enabled)
|
||||
{
|
||||
if (!isInitialized) return Result(ERR_NOTINITIALIZED);
|
||||
switch (option)
|
||||
{
|
||||
case OPT_FLAG_ASPECT: aspect = enabled; break;
|
||||
case OPT_FLAG_NTSC: ntsc = enabled; break;
|
||||
case OPT_FLAG_RESIZEABLE: break;
|
||||
default: return Result(ERR_BADOPTION);
|
||||
}
|
||||
return Result(OK);
|
||||
}
|
||||
|
||||
int GetRect(int rectOption, Rect* rect)
|
||||
{
|
||||
if (!isInitialized) return Result(ERR_NOTINITIALIZED);
|
||||
switch (rectOption)
|
||||
{
|
||||
case OPT_RECT_DISPLAY: GetDisplayArea(rect); break;
|
||||
case OPT_RECT_RENDER: GetRenderArea(rect); break;
|
||||
case OPT_RECT_SURFACE: GetSurfaceArea(rect); break;
|
||||
default: return Result(ERR_BADOPTION);
|
||||
}
|
||||
return Result(OK);
|
||||
}
|
||||
|
||||
int RenderText(const OpenGLFont* font, float x, float y, float size, const char* text) const
|
||||
{
|
||||
if (!isInitialized) return Result(ERR_NOTINITIALIZED);
|
||||
|
||||
int length = strlen(text);
|
||||
wglMakeCurrent(hDC, hRC);
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(0, (float)width, (float)height, 0, -1, 1);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glBindTexture(GL_TEXTURE_2D, font->texture);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glColor3f(1, 1, 1);
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
auto ch = text[i];
|
||||
if (ch < font->start || ch >= font->end) continue;
|
||||
const auto glyph = font->glyphs + ch - font->start;
|
||||
if (ch != ' ')
|
||||
{
|
||||
const auto &ad = glyph->atlasDimensions;
|
||||
const auto& d = glyph->dimensions;
|
||||
|
||||
float u1 = ad.l / font->textureWidth;
|
||||
float v1 = ad.b / font->textureHeight;
|
||||
float u2 = ad.r / font->textureWidth;
|
||||
float v2 = ad.t / font->textureHeight;
|
||||
|
||||
glTexCoord2f(u1, v1); glVertex3f(x + size * d.l, y + size * d.b, 0);
|
||||
glTexCoord2f(u2, v1); glVertex3f(x + size * d.r, y + size * d.b, 0);
|
||||
glTexCoord2f(u2, v2); glVertex3f(x + size * d.r, y + size * d.t, 0);
|
||||
glTexCoord2f(u1, v2); glVertex3f(x + size * d.l, y + size * d.t, 0);
|
||||
}
|
||||
x += glyph->advance * size;
|
||||
}
|
||||
glEnd();
|
||||
wglMakeCurrent(nullptr, nullptr);
|
||||
|
||||
return Result(OK);
|
||||
}
|
||||
|
||||
int Present() const
|
||||
{
|
||||
if (!isInitialized) return Result(ERR_NOTINITIALIZED);
|
||||
wglMakeCurrent(hDC, hRC);
|
||||
// present
|
||||
glFlush();
|
||||
// don't sync with monitor, if monitor is 30hz we want vcc
|
||||
// running at 60 still, refresh is controlled in throttle.
|
||||
wglSwapIntervalEXT(0);
|
||||
SwapBuffers(hDC);
|
||||
wglMakeCurrent(nullptr, nullptr);
|
||||
return Result(OK);
|
||||
}
|
||||
|
||||
int LoadFont(const OpenGLFont** outFont, int bitmapRes, const OpenGLFontGlyph* glyphs, int start, int end) const
|
||||
{
|
||||
*outFont = nullptr;
|
||||
if (!isInitialized) return Result(ERR_NOTINITIALIZED);
|
||||
|
||||
HBITMAP hBitmap = nullptr;
|
||||
HDC dcBitmap = nullptr;
|
||||
COLORREF* bitmapPixels = nullptr;
|
||||
|
||||
auto cleanup = [&](int code)
|
||||
{
|
||||
if (hBitmap) DeleteObject(hBitmap);
|
||||
if (dcBitmap) ReleaseDC(nullptr, dcBitmap);
|
||||
if (bitmapPixels) delete bitmapPixels;
|
||||
return code;
|
||||
};
|
||||
|
||||
// load bitmap resource
|
||||
auto hInstance = GetModuleHandle(nullptr);
|
||||
hBitmap = LoadBitmap(hInstance, MAKEINTRESOURCE(bitmapRes));
|
||||
if (!hBitmap) return Result(cleanup(ERR_FONTHBITMAP));
|
||||
dcBitmap = CreateCompatibleDC(nullptr);
|
||||
if (!dcBitmap) return Result(cleanup(ERR_FONTDC));
|
||||
SelectObject(dcBitmap, hBitmap);
|
||||
|
||||
BITMAP bm;
|
||||
::GetObject(hBitmap, sizeof(bm), &bm);
|
||||
|
||||
BITMAPINFO bmpInfo;
|
||||
bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bmpInfo.bmiHeader.biWidth = bm.bmWidth;
|
||||
bmpInfo.bmiHeader.biHeight = -bm.bmHeight;
|
||||
bmpInfo.bmiHeader.biPlanes = 1;
|
||||
bmpInfo.bmiHeader.biBitCount = 24;
|
||||
bmpInfo.bmiHeader.biCompression = BI_RGB;
|
||||
bmpInfo.bmiHeader.biSizeImage = 0;
|
||||
|
||||
// get bitmap data
|
||||
bitmapPixels = new COLORREF[bm.bmWidth * bm.bmHeight];
|
||||
if (GetDIBits(dcBitmap, hBitmap, 0, bm.bmHeight, bitmapPixels, &bmpInfo, DIB_RGB_COLORS) == 0)
|
||||
return Result(cleanup(ERR_FONTGETDIBITS));
|
||||
|
||||
// upload texture
|
||||
GLuint textureId = 0;
|
||||
wglMakeCurrent(hDC, hRC);
|
||||
glGenTextures(1, &textureId);
|
||||
glBindTexture(GL_TEXTURE_2D, textureId);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bm.bmWidth, bm.bmHeight, 0, GL_BGR, GL_UNSIGNED_BYTE, bitmapPixels);
|
||||
if (glGetError()) return Result(cleanup(ERR_FONTTEXIMAGE2D));
|
||||
wglMakeCurrent(nullptr, nullptr);
|
||||
|
||||
// allocate font
|
||||
OpenGLFont* font = new OpenGLFont();
|
||||
font->glyphs = glyphs;
|
||||
font->start = start;
|
||||
font->end = end;
|
||||
font->texture = textureId;
|
||||
font->textureWidth = (float)bm.bmWidth;
|
||||
font->textureHeight = (float)bm.bmHeight;
|
||||
|
||||
*outFont = font;
|
||||
return Result(cleanup(OK));
|
||||
}
|
||||
|
||||
#if USE_DEBUG_LINES
|
||||
void DebugDrawLine(float x1, float y1, float x2, float y2, Pixel color)
|
||||
{
|
||||
debugLines.push_back({ x1, y1, x2, y2, color });
|
||||
}
|
||||
|
||||
void DebugDrawText(const OpenGLFont* font, float x, float y, float size, const char* text, Pixel color)
|
||||
{
|
||||
debugTexts.push_back({ font, x, y, size, text, color });
|
||||
}
|
||||
void DebugDrawBox(float x1, float y1, float w, float h, Pixel color, bool filled)
|
||||
{
|
||||
debugBoxes.push_back({ x1, y1, w, h, color, filled });
|
||||
}
|
||||
#endif // USE_DEBUG_LINES
|
||||
|
||||
int RenderBox(float x, float y, float w, float h, Pixel color, bool filled) const
|
||||
{
|
||||
if (!isInitialized) return Result(ERR_NOTINITIALIZED);
|
||||
float x2 = x + w;
|
||||
float y2 = y + h;
|
||||
wglMakeCurrent(hDC, hRC);
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(0, (float)width, (float)height, 0, -1, 1);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glColor3ub(color.r, color.g, color.b);
|
||||
if (filled)
|
||||
{
|
||||
glBegin(GL_QUADS);
|
||||
glVertex3f(x, y, 0);
|
||||
glVertex3f(x + w, y, 0);
|
||||
glVertex3f(x + w, y + h, 0);
|
||||
glVertex3f(x, y + h, 0);
|
||||
glEnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
glBegin(GL_LINES);
|
||||
glVertex3f(x, y, 0);
|
||||
glVertex3f(x + w, y, 0);
|
||||
|
||||
glVertex3f(x + w, y, 0);
|
||||
glVertex3f(x + w, y + h, 0);
|
||||
|
||||
glVertex3f(x + w, y + h, 0);
|
||||
glVertex3f(x, y + h, 0);
|
||||
|
||||
glVertex3f(x, y + h, 0);
|
||||
glVertex3f(x, y, 0);
|
||||
glEnd();
|
||||
}
|
||||
wglMakeCurrent(nullptr, nullptr);
|
||||
return Result(OK);
|
||||
}
|
||||
|
||||
int LockSurface()
|
||||
{
|
||||
if (!isInitialized) return Result(ERR_NOTINITIALIZED);
|
||||
state->SetSurface(pixels, 3, DefaultWidth);
|
||||
return Result(OK);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// returns the box where display should be rendered
|
||||
void GetDisplayArea(Rect* area) const
|
||||
{
|
||||
area->w = (float)width;
|
||||
area->h = (float)height;
|
||||
|
||||
// scale to fit display with aspect kept
|
||||
if (aspect)
|
||||
{
|
||||
// keep aspect ratio, ntsc = 50hz
|
||||
float freqScale = ntsc ? PalFreq / NtscFreq : 1.0f;
|
||||
float dw = (float)SurfaceWidth;
|
||||
float dh = (float)SurfaceHeight * freqScale;
|
||||
float rx = area->w / dw;
|
||||
float ry = area->h / dh;
|
||||
float r = rx > ry ? ry : rx;
|
||||
|
||||
area->w = r * dw;
|
||||
area->h = r * dh;
|
||||
}
|
||||
|
||||
// center on display
|
||||
area->x = (width - area->w) / 2.0f;
|
||||
area->y = (height - area->h) / 2.0f;
|
||||
}
|
||||
|
||||
void GetRenderArea(Rect* area) const
|
||||
{
|
||||
area->x = area->y = 0;
|
||||
area->w = (float)width;
|
||||
area->h = (float)height;
|
||||
}
|
||||
|
||||
void GetSurfaceArea(Rect* area) const
|
||||
{
|
||||
area->x = area->y = 0;
|
||||
area->w = (float)SurfaceWidth;
|
||||
area->h = (float)SurfaceHeight;
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Forwarding functions to implementation.
|
||||
//
|
||||
|
||||
int OpenGL::GetSurface(Pixel** pixels)
|
||||
{
|
||||
if (detail)
|
||||
return detail->GetSurface(pixels);
|
||||
return Result(ERR_NOTINITIALIZED);
|
||||
}
|
||||
|
||||
int OpenGL::Setup(void* hwnd, int width, int height, int statusHeight, bool fullscreen)
|
||||
{
|
||||
detail = new Detail(state);
|
||||
return detail->Setup(hwnd, width, height, statusHeight);
|
||||
}
|
||||
|
||||
int OpenGL::Render()
|
||||
{
|
||||
if (detail)
|
||||
return detail->Render();
|
||||
return Result(ERR_NOTINITIALIZED);
|
||||
}
|
||||
|
||||
int OpenGL::Cleanup()
|
||||
{
|
||||
if (detail)
|
||||
{
|
||||
int result = detail->Cleanup();
|
||||
delete detail;
|
||||
detail = nullptr;
|
||||
return result;
|
||||
}
|
||||
return Result(ERR_NOTINITIALIZED);
|
||||
}
|
||||
|
||||
int OpenGL::Present()
|
||||
{
|
||||
if (detail)
|
||||
return detail->Present();
|
||||
return Result(ERR_NOTINITIALIZED);
|
||||
}
|
||||
|
||||
int OpenGL::SetOption(int option, bool enabled)
|
||||
{
|
||||
if (detail)
|
||||
return detail->SetOption(option, enabled);
|
||||
return Result(ERR_NOTINITIALIZED);
|
||||
}
|
||||
|
||||
int OpenGL::RenderBox(float x, float y, float w, float h, Pixel color, bool filled)
|
||||
{
|
||||
if (detail)
|
||||
return detail->RenderBox(x,y,w,h,color,filled);
|
||||
return Result(ERR_NOTINITIALIZED);
|
||||
}
|
||||
|
||||
int OpenGL::GetRect(int rectOption, Rect* area)
|
||||
{
|
||||
if (detail)
|
||||
return detail->GetRect(rectOption, area);
|
||||
return Result(ERR_NOTINITIALIZED);
|
||||
}
|
||||
|
||||
int OpenGL::RenderText(const OpenGLFont* font, float x, float y, float size, const char* text)
|
||||
{
|
||||
if (detail)
|
||||
return detail->RenderText(font, x, y, size, text);
|
||||
return Result(ERR_NOTINITIALIZED);
|
||||
}
|
||||
|
||||
int OpenGL::LoadFont(const OpenGLFont** outFont, int bitmapRes, const OpenGLFontGlyph* glyphs, int start, int end)
|
||||
{
|
||||
if (detail)
|
||||
return detail->LoadFont(outFont, bitmapRes, glyphs, start, end);
|
||||
return Result(ERR_NOTINITIALIZED);
|
||||
}
|
||||
|
||||
int OpenGL::LockSurface()
|
||||
{
|
||||
if (detail)
|
||||
return detail->LockSurface();
|
||||
return Result(ERR_NOTINITIALIZED);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void OpenGL::DebugDrawText(const OpenGLFont* font, float x, float y, float size, const char* text, Pixel color)
|
||||
{
|
||||
#if USE_DEBUG_LINES
|
||||
if (detail)
|
||||
detail->DebugDrawText(font, x, y, size, text, color);
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenGL::DebugDrawLine(float x1, float y1, float x2, float y2, Pixel color)
|
||||
{
|
||||
#if USE_DEBUG_LINES
|
||||
if (detail)
|
||||
detail->DebugDrawLine(x1, y1, x2, y2, color);
|
||||
#endif // USE_DEBUG_LINES
|
||||
}
|
||||
void OpenGL::DebugDrawBox(float x, float y, float w, float h, Pixel color, bool filled)
|
||||
{
|
||||
#if USE_DEBUG_LINES
|
||||
if (detail)
|
||||
detail->DebugDrawBox(x, y, w, h, color, filled);
|
||||
/*
|
||||
{
|
||||
float x2 = x + w;
|
||||
float y2 = y + h;
|
||||
detail->RenderBox(x, y, x2 - x, y2 - y, color, filled);
|
||||
//detail->DebugDrawLine(x, y, x2, y, color);
|
||||
//detail->DebugDrawLine(x2, y, x2, y2, color);
|
||||
//detail->DebugDrawLine(x2, y2, x, y2, color);
|
||||
//detail->DebugDrawLine(x, y2, x, y, color);
|
||||
}
|
||||
*/
|
||||
#endif // USE_DEBUG_LINES
|
||||
}
|
||||
}
|
||||
|
||||
#endif // USE_OPENGL
|
||||
@@ -0,0 +1,83 @@
|
||||
#pragma once
|
||||
|
||||
// Copyright 2015 by Joseph Forgion
|
||||
// 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// 2025/04/10 - Craig Allsop - Add OpenGL rendering.
|
||||
//
|
||||
|
||||
#include "../../src/core/IDisplay.h"
|
||||
|
||||
#if USE_OPENGL
|
||||
|
||||
#include "defines.h"
|
||||
#include "OpenGLFont.h"
|
||||
|
||||
namespace VCC
|
||||
{
|
||||
struct OpenGL : public IDisplayOpenGL
|
||||
{
|
||||
enum // result codes - NOTE: don't reorder this pls, only append.
|
||||
{
|
||||
ERR_INITIALIZED = 100, // already initialized
|
||||
ERR_NOTINITIALIZED, // not initialized
|
||||
ERR_TMPREGISTERCLASS, // unable to register temporary class
|
||||
ERR_TMPCREATEWINDOW, // unable to create temporary window
|
||||
ERR_TMPGETDC, // unable to get temporary window device context
|
||||
ERR_REGISTERCLASS, // unable to register gl class
|
||||
ERR_CREATEWINDOW, // unable to create gl window
|
||||
ERR_GETDC, // unable to get gl window device context
|
||||
ERR_TMPCREATECONTEXT, // unable to create open gl context
|
||||
ERR_SETPIXELFORMAT, // unable to configure pixel format
|
||||
ERR_MISSINGAPIS, // unable to get open gl apis
|
||||
ERR_GLVERSION, // unable to get open gl version
|
||||
ERR_BADOPTION, // invalid option being set
|
||||
ERR_FONTHBITMAP, // unable to load font bitmap
|
||||
ERR_FONTDC, // unable to create device context for font
|
||||
ERR_FONTGETDIBITS, // unable to get font bitmap bits
|
||||
ERR_FONTTEXIMAGE2D, // unable to upload font to texture
|
||||
ERR_TMPCHOOSEFORMAT, // unable to choose pixel format
|
||||
ERR_TMPSETPIXELFORMAT, // unable to set pixel format
|
||||
ERR_TMPMAKECONTEXT, // unable to set context
|
||||
};
|
||||
|
||||
explicit OpenGL(ISystemState* state) : detail(nullptr), state(state) {}
|
||||
|
||||
int Setup(void* hwnd, int width, int height, int statusHeight, bool fullscreen) override;
|
||||
int Render() override;
|
||||
int RenderBox(float x, float y, float w, float h, Pixel color, bool filled) override;
|
||||
int RenderText(const OpenGLFont* font, float x, float y, float size, const char* text) override;
|
||||
int Present() override;
|
||||
int Cleanup() override;
|
||||
|
||||
int SetOption(int flagOption, bool enabled) override;
|
||||
int GetSurface(Pixel** pixels) override;
|
||||
int GetRect(int rectOption, Rect* area) override;
|
||||
int LoadFont(const OpenGLFont** outFont, int bitmapRes, const OpenGLFontGlyph* glyphs, int start, int end) override;
|
||||
int LockSurface() override;
|
||||
|
||||
void DebugDrawText(const OpenGLFont* font, float x, float y, float size, const char* text, Pixel color);
|
||||
void DebugDrawLine(float x1, float y1, float x2, float y2, Pixel color) override;
|
||||
void DebugDrawBox(float x, float y, float w, float h, Pixel color, bool filled) override;
|
||||
|
||||
private:
|
||||
struct Detail;
|
||||
Detail* detail;
|
||||
ISystemState* state;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // USE_OPENGL
|
||||
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
// Copyright 2015 by Joseph Forgion
|
||||
// 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// 2025/04/10 - Craig Allsop - Add OpenGL rendering.
|
||||
//
|
||||
|
||||
#include "../../src/core/BuildConfig.h"
|
||||
|
||||
#if USE_OPENGL
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace VCC
|
||||
{
|
||||
struct OpenGLFontBox
|
||||
{
|
||||
float l, t, r, b;
|
||||
};
|
||||
|
||||
struct OpenGLFontGlyph
|
||||
{
|
||||
float advance; // amount to advance (em)
|
||||
OpenGLFontBox dimensions; // box to draw relative to baseline (em)
|
||||
OpenGLFontBox atlasDimensions; // atlas box (pixels)
|
||||
};
|
||||
|
||||
// handle for fonts
|
||||
struct OpenGLFont
|
||||
{
|
||||
int start; // first character (incl) e.g. 32
|
||||
int end; // last character (excl) e.g. 128
|
||||
uint32_t texture; // open gl texture handle
|
||||
float textureWidth; // texture width
|
||||
float textureHeight; // texture height
|
||||
const OpenGLFontGlyph* glyphs; // array of glyphs
|
||||
};
|
||||
}
|
||||
|
||||
#endif // USE_OPENGL
|
||||
@@ -0,0 +1,134 @@
|
||||
// Copyright 2015 by Joseph Forgion
|
||||
// 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// 2025/04/10 - Craig Allsop - Add OpenGL rendering.
|
||||
//
|
||||
|
||||
#include "OpenGLFontConsola.h"
|
||||
|
||||
#if USE_OPENGL
|
||||
|
||||
//
|
||||
// This file is generated using following options:
|
||||
//
|
||||
// msdf-atlas-gen.exe -font consola.ttf -charset set.txt -type softmask -size 24 -outerpxpadding 2 -format bmp -imageout consola.bmp -yorigin top -csv consola.csv
|
||||
//
|
||||
|
||||
#pragma warning(disable : 4305) // ignore truncation of double to float, its ok.
|
||||
|
||||
namespace VCC
|
||||
{
|
||||
OpenGLFontGlyph OpenGLFontConsola[] =
|
||||
{
|
||||
0.5498046875,0,-0,0,-0,0,184,0,184,
|
||||
0.5498046875,0.16927083333333331,-0.72916666666666663,0.37760416666666663,0.0625,2.5,32.5,7.5,51.5,
|
||||
0.5498046875,0.087402343749999972,-0.72916666666666663,0.46240234374999994,-0.4375,96.5,159.5,105.5,166.5,
|
||||
0.5498046875,-0.016764322916666657,-0.6875,0.56656901041666674,0.020833333333333343,81.5,77.5,95.5,94.5,
|
||||
0.5498046875,0.022216796875,-0.77083333333333326,0.522216796875,0.14583333333333334,115.5,2.5,127.5,24.5,
|
||||
0.5498046875,-0.016764322916666671,-0.72916666666666663,0.56656901041666663,0.0625,11.5,32.5,25.5,51.5,
|
||||
0.5498046875,-0.0028483072916666713,-0.72916666666666663,0.58048502604166663,0.0625,29.5,32.5,43.5,51.5,
|
||||
0.5498046875,0.19181315104166666,-0.72916666666666663,0.35847981770833331,-0.4375,109.5,159.5,113.5,166.5,
|
||||
0.5498046875,0.11800130208333331,-0.77083333333333326,0.45133463541666669,0.22916666666666666,9.5,2.5,17.5,26.5,
|
||||
0.5498046875,0.098470052083333301,-0.77083333333333326,0.43180338541666663,0.22916666666666666,21.5,2.5,29.5,26.5,
|
||||
0.5498046875,0.045979817708333294,-0.72916666666666663,0.50431315104166663,-0.22916666666666666,49.5,159.5,60.5,171.5,
|
||||
0.5498046875,0.0040690104166666574,-0.5625,0.54573567708333326,0.020833333333333343,44.5,141.5,57.5,155.5,
|
||||
0.5498046875,0.08829752604166663,-0.18749999999999994,0.37996419270833326,0.22916666666666666,174.5,55.5,181.5,65.5,
|
||||
0.5498046875,0.087402343749999972,-0.35416666666666663,0.46240234374999994,-0.1875,2.5,176.5,11.5,180.5,
|
||||
0.5498046875,0.16682942708333331,-0.18749999999999997,0.37516276041666663,0.0625,117.5,159.5,122.5,165.5,
|
||||
0.5498046875,0.034993489583333301,-0.72916666666666663,0.49332682291666663,0.14583333333333334,149.5,2.5,160.5,23.5,
|
||||
0.5498046875,0.0040690104166666574,-0.6875,0.54573567708333326,0.0625,19.5,55.5,32.5,73.5,
|
||||
0.5498046875,0.0263671875,-0.6875,0.5263671875,0.020833333333333343,19.5,120.5,31.5,137.5,
|
||||
0.5498046875,0.031982421875,-0.6875,0.531982421875,0.020833333333333343,69.5,120.5,81.5,137.5,
|
||||
0.5498046875,0.050862630208333329,-0.6875,0.50919596354166663,0.0625,51.5,55.5,62.5,73.5,
|
||||
0.5498046875,-0.019205729166666657,-0.6875,0.56412760416666674,0.020833333333333343,85.5,120.5,99.5,137.5,
|
||||
0.5498046875,0.052327473958333294,-0.6875,0.51066080729166663,0.0625,66.5,55.5,77.5,73.5,
|
||||
0.5498046875,0.030029296875,-0.6875,0.530029296875,0.0625,81.5,55.5,93.5,73.5,
|
||||
0.5498046875,0.02294921875,-0.6875,0.52294921875,0.020833333333333343,103.5,120.5,115.5,137.5,
|
||||
0.5498046875,0.025146484375,-0.6875,0.525146484375,0.0625,97.5,55.5,109.5,73.5,
|
||||
0.5498046875,0.018798828125,-0.6875,0.518798828125,0.020833333333333343,119.5,120.5,131.5,137.5,
|
||||
0.5498046875,0.17097981770833331,-0.52083333333333337,0.37931315104166663,0.0625,2.5,141.5,7.5,155.5,
|
||||
0.5498046875,0.09415690104166663,-0.52083333333333326,0.38582356770833326,0.22916666666666666,113.5,55.5,120.5,73.5,
|
||||
0.5498046875,0.028401692708333287,-0.5625,0.48673502604166663,0.0625,150.5,120.5,161.5,135.5,
|
||||
0.5498046875,0.02490234375,-0.4375,0.52490234375,-0.10416666666666666,80.5,159.5,92.5,167.5,
|
||||
0.5498046875,0.063313802083333343,-0.5625,0.52164713541666663,0.0625,135.5,120.5,146.5,135.5,
|
||||
0.5498046875,0.11157226562499994,-0.72916666666666663,0.48657226562499994,0.0625,47.5,32.5,56.5,51.5,
|
||||
0.5498046875,-0.017751982717803011,-0.72916666666666674,0.56558135061553028,0.22916666666666666,61.5,2.5,75.5,25.5,
|
||||
0.5498046875,-0.016764322916666671,-0.6875,0.56656901041666663,0.020833333333333343,51.5,120.5,65.5,137.5,
|
||||
0.5498046875,0.03662109375,-0.6875,0.53662109375,0.020833333333333343,35.5,120.5,47.5,137.5,
|
||||
0.5498046875,0.015380859375,-0.6875,0.515380859375,0.0625,141.5,55.5,153.5,73.5,
|
||||
0.5498046875,0.012858072916666657,-0.6875,0.55452473958333326,0.020833333333333343,2.5,120.5,15.5,137.5,
|
||||
0.5498046875,0.07120768229166663,-0.6875,0.48787434895833326,0.020833333333333343,164.5,99.5,174.5,116.5,
|
||||
0.5498046875,0.07169596354166663,-0.6875,0.48836263020833326,0.020833333333333343,150.5,99.5,160.5,116.5,
|
||||
0.5498046875,-0.0076497395833333426,-0.6875,0.53401692708333326,0.0625,157.5,55.5,170.5,73.5,
|
||||
0.5498046875,0.025146484375,-0.6875,0.525146484375,0.020833333333333343,118.5,99.5,130.5,116.5,
|
||||
0.5498046875,0.045735677083333294,-0.6875,0.50406901041666663,0.020833333333333343,103.5,99.5,114.5,116.5,
|
||||
0.5498046875,0.05021158854166663,-0.6875,0.46687825520833326,0.0625,2.5,77.5,12.5,95.5,
|
||||
0.5498046875,0.043701171875,-0.6875,0.543701171875,0.020833333333333343,68.5,99.5,80.5,116.5,
|
||||
0.5498046875,0.089029947916666671,-0.6875,0.50569661458333326,0.020833333333333343,54.5,99.5,64.5,116.5,
|
||||
0.5498046875,-0.016764322916666657,-0.6875,0.56656901041666674,0.020833333333333343,36.5,99.5,50.5,116.5,
|
||||
0.5498046875,0.025146484375,-0.6875,0.525146484375,0.020833333333333343,20.5,99.5,32.5,116.5,
|
||||
0.5498046875,0.0045572916666666713,-0.6875,0.54622395833333326,0.0625,16.5,77.5,29.5,95.5,
|
||||
0.5498046875,0.03662109375,-0.6875,0.53662109375,0.020833333333333343,169.5,77.5,181.5,94.5,
|
||||
0.5498046875,-0.0028483072916666713,-0.6875,0.58048502604166663,0.22916666666666666,131.5,2.5,145.5,24.5,
|
||||
0.5498046875,0.048095703125,-0.6875,0.548095703125,0.020833333333333343,135.5,77.5,147.5,94.5,
|
||||
0.5498046875,0.0205078125,-0.6875,0.5205078125,0.0625,49.5,77.5,61.5,95.5,
|
||||
0.5498046875,0.0040690104166666574,-0.6875,0.54573567708333326,0.020833333333333343,99.5,77.5,112.5,94.5,
|
||||
0.5498046875,0.025146484375,-0.6875,0.525146484375,0.0625,65.5,77.5,77.5,95.5,
|
||||
0.5498046875,-0.03759765625,-0.6875,0.58740234375,0.020833333333333343,116.5,77.5,131.5,94.5,
|
||||
0.5498046875,-0.016764322916666657,-0.6875,0.56656901041666674,0.020833333333333343,151.5,77.5,165.5,94.5,
|
||||
0.5498046875,-0.018229166666666671,-0.6875,0.56510416666666663,0.020833333333333343,2.5,99.5,16.5,116.5,
|
||||
0.5498046875,-0.03759765625,-0.6875,0.58740234375,0.020833333333333343,84.5,99.5,99.5,116.5,
|
||||
0.5498046875,0.024658203125,-0.6875,0.524658203125,0.020833333333333343,134.5,99.5,146.5,116.5,
|
||||
0.5498046875,0.14298502604166666,-0.72916666666666674,0.43465169270833331,0.22916666666666666,79.5,2.5,86.5,25.5,
|
||||
0.5498046875,0.056966145833333329,-0.72916666666666663,0.51529947916666663,0.14583333333333334,164.5,2.5,175.5,23.5,
|
||||
0.5498046875,0.11515299479166663,-0.72916666666666674,0.40681966145833326,0.22916666666666666,90.5,2.5,97.5,25.5,
|
||||
0.5498046875,0.027099609375,-0.68749999999999989,0.527099609375,-0.27083333333333331,64.5,159.5,76.5,169.5,
|
||||
0.5498046875,-0.03759765625,0.10416666666666666,0.58740234375,0.22916666666666666,15.5,176.5,30.5,179.5,
|
||||
0.5498046875,0.05973307291666663,-0.72916666666666674,0.35139973958333326,-0.52083333333333337,173.5,141.5,180.5,146.5,
|
||||
0.5498046875,0.037923177083333301,-0.52083333333333337,0.49625651041666663,0.0625,61.5,141.5,72.5,155.5,
|
||||
0.5498046875,0.03759765625,-0.72916666666666663,0.53759765625,0.0625,60.5,32.5,72.5,51.5,
|
||||
0.5498046875,0.038899739583333287,-0.52083333333333337,0.49723307291666663,0.0625,91.5,141.5,102.5,155.5,
|
||||
0.5498046875,0.032063802083333301,-0.72916666666666663,0.49039713541666663,0.0625,76.5,32.5,87.5,51.5,
|
||||
0.5498046875,0.024658203125,-0.52083333333333337,0.524658203125,0.0625,11.5,141.5,23.5,155.5,
|
||||
0.5498046875,0.0052897135416666574,-0.72916666666666663,0.54695638020833326,0.020833333333333343,2.5,55.5,15.5,73.5,
|
||||
0.5498046875,0.0069986979166666574,-0.52083333333333326,0.54866536458333326,0.22916666666666666,168.5,32.5,181.5,50.5,
|
||||
0.5498046875,0.045979817708333294,-0.72916666666666663,0.50431315104166663,0.020833333333333343,153.5,32.5,164.5,50.5,
|
||||
0.5498046875,0.051350911458333294,-0.72916666666666663,0.50968424479166663,0.020833333333333343,138.5,32.5,149.5,50.5,
|
||||
0.5498046875,0.03653971354166663,-0.72916666666666674,0.45320638020833326,0.22916666666666666,101.5,2.5,111.5,25.5,
|
||||
0.5498046875,0.053955078125,-0.72916666666666663,0.553955078125,0.020833333333333343,106.5,32.5,118.5,50.5,
|
||||
0.5498046875,0.051350911458333294,-0.72916666666666663,0.50968424479166663,0.020833333333333343,36.5,55.5,47.5,73.5,
|
||||
0.5498046875,0.0040690104166666574,-0.52083333333333326,0.54573567708333326,0.020833333333333343,156.5,141.5,169.5,154.5,
|
||||
0.5498046875,0.045979817708333294,-0.52083333333333326,0.50431315104166663,0.020833333333333343,141.5,141.5,152.5,154.5,
|
||||
0.5498046875,0.0040690104166666574,-0.52083333333333337,0.54573567708333326,0.0625,27.5,141.5,40.5,155.5,
|
||||
0.5498046875,0.03759765625,-0.52083333333333326,0.53759765625,0.22916666666666666,122.5,32.5,134.5,50.5,
|
||||
0.5498046875,0.032063802083333301,-0.52083333333333326,0.49039713541666663,0.22916666666666666,91.5,32.5,102.5,50.5,
|
||||
0.5498046875,0.070494903915229876,-0.52083333333333326,0.5288282372485632,0.020833333333333343,19.5,159.5,30.5,172.5,
|
||||
0.5498046875,0.048421223958333294,-0.52083333333333337,0.50675455729166663,0.0625,76.5,141.5,87.5,155.5,
|
||||
0.5498046875,0.0019531249999999584,-0.6875,0.50195312499999989,0.0625,33.5,77.5,45.5,95.5,
|
||||
0.5498046875,0.045979817708333294,-0.52083333333333337,0.50431315104166663,0.0625,165.5,120.5,176.5,134.5,
|
||||
0.5498046875,0.0023600260416666713,-0.52083333333333326,0.54402669270833326,0.020833333333333343,106.5,141.5,119.5,154.5,
|
||||
0.5498046875,-0.016520182291666657,-0.52083333333333326,0.56681315104166674,0.020833333333333343,123.5,141.5,137.5,154.5,
|
||||
0.5498046875,0.0062662760416666713,-0.52083333333333326,0.54793294270833326,0.020833333333333343,2.5,159.5,15.5,172.5,
|
||||
0.5498046875,0.00065104166666667129,-0.52083333333333326,0.54231770833333326,0.22916666666666666,124.5,55.5,137.5,73.5,
|
||||
0.5498046875,0.048421223958333294,-0.52083333333333326,0.50675455729166663,0.020833333333333343,34.5,159.5,45.5,172.5,
|
||||
0.5498046875,0.05021158854166663,-0.72916666666666674,0.46687825520833326,0.22916666666666666,47.5,2.5,57.5,25.5,
|
||||
0.5498046875,0.21240234374999997,-0.85416666666666674,0.33740234375,0.22916666666666666,2.5,2.5,5.5,28.5,
|
||||
0.5498046875,0.08317057291666663,-0.72916666666666674,0.49983723958333326,0.22916666666666666,33.5,2.5,43.5,25.5,
|
||||
0.5498046875,0.0042753163834065161,-0.39583333333333331,0.54594198305007313,-0.14583333333333331,126.5,159.5,139.5,165.5,
|
||||
};
|
||||
}
|
||||
|
||||
#endif // USE_OPENGL
|
||||
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
// Copyright 2015 by Joseph Forgion
|
||||
// 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// 2025/04/10 - Craig Allsop - Add OpenGL rendering.
|
||||
//
|
||||
|
||||
#include "OpenGLFont.h"
|
||||
|
||||
#if USE_OPENGL
|
||||
|
||||
namespace VCC
|
||||
{
|
||||
OpenGLFontGlyph OpenGLFontConsola[];
|
||||
}
|
||||
|
||||
#endif // USE_OPENGL
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,369 @@
|
||||
// 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/>.
|
||||
//
|
||||
// Processor State Display - Part of the Debugger package for VCC
|
||||
// Authors: Mike Rojas, Chet Simpson
|
||||
#include "ProcessorState.h"
|
||||
#include "Debugger.h"
|
||||
#include "DebuggerUtils.h"
|
||||
#include "defines.h"
|
||||
#include "resource.h"
|
||||
#include <stdexcept>
|
||||
#include "config.h"
|
||||
|
||||
// Generate hex char string from int value
|
||||
// FIXME: This obfuscates that the callsite is using an rvalue.
|
||||
#define HEXCHAR(v,l) (char *) ToHexString(v,l).c_str()
|
||||
|
||||
extern SystemState EmuState;
|
||||
|
||||
namespace VCC::Debugger::UI {
|
||||
namespace {
|
||||
const std::string cWindowSizeX("WindowSizeX");
|
||||
const std::string cWindowSizeY("WindowSizeY");
|
||||
const std::string cWindowPosX("WindowPosX");
|
||||
const std::string cWindowPosY("WindowPosY");
|
||||
|
||||
HWND ProcessorStateWindow = nullptr;
|
||||
BackBufferInfo BackBuf;
|
||||
std::unique_ptr<OpDecoder> Decoder;
|
||||
|
||||
void DrawCntrTxt(HDC hdc, const RECT& r, const char * str, int x, int y, int l, int h)
|
||||
{
|
||||
RECT rc;
|
||||
SetRect(&rc, r.left + x, r.top + y, r.left + x + l, r.top + y + h);
|
||||
DrawText(hdc, str, -1, &rc, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
|
||||
}
|
||||
|
||||
void DrawTextBox(HDC hdc, const RECT& r, int x, int y, int l, int h)
|
||||
{
|
||||
int rx = r.left + x;
|
||||
int ry = r.top + y;
|
||||
MoveToEx(hdc, rx, ry, nullptr);
|
||||
LineTo(hdc, rx + l, ry);
|
||||
LineTo(hdc, rx + l, ry + h);
|
||||
LineTo(hdc, rx, ry + h);
|
||||
LineTo(hdc, rx, ry);
|
||||
}
|
||||
|
||||
void DrawVrtLine(HDC hdc, const RECT& r, int x, int y, int h)
|
||||
{
|
||||
int rx = r.left + x;
|
||||
int ry = r.top + y;
|
||||
MoveToEx(hdc, rx, ry, nullptr);
|
||||
LineTo(hdc, rx, ry + h);
|
||||
}
|
||||
|
||||
void DrawProcessorState(HDC hdc, LPCRECT clientRect)
|
||||
{
|
||||
RECT rect = *clientRect;
|
||||
Decoder = std::make_unique<OpDecoder>();
|
||||
|
||||
// Clear our background.
|
||||
HBRUSH brush = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
||||
FillRect(hdc, &rect, brush);
|
||||
|
||||
HPEN pen = CreatePen(PS_SOLID, 1, RGB(192, 192, 192));
|
||||
SelectObject(hdc, pen);
|
||||
|
||||
// Draw the border.
|
||||
MoveToEx(hdc, rect.left, rect.top, nullptr);
|
||||
LineTo(hdc, rect.right - 1, rect.top);
|
||||
LineTo(hdc, rect.right - 1, rect.bottom - 1);
|
||||
LineTo(hdc, rect.left, rect.bottom - 1);
|
||||
LineTo(hdc, rect.left, rect.top);
|
||||
|
||||
HFONT hFont = CreateFont(14, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE,
|
||||
DEFAULT_CHARSET, OUT_OUTLINE_PRECIS,CLIP_DEFAULT_PRECIS,
|
||||
CLEARTYPE_QUALITY, FIXED_PITCH, TEXT("Consolas"));
|
||||
|
||||
// Draw register boxes and lables
|
||||
SelectObject(hdc, hFont);
|
||||
SetTextColor(hdc, RGB(138, 27, 255));
|
||||
// args HDC RECT X Y L H
|
||||
DrawTextBox(hdc,rect, 8, 18, 72, 18); //D
|
||||
DrawTextBox(hdc,rect, 88, 18, 72, 18); //W
|
||||
DrawTextBox(hdc,rect,168, 18, 72, 18); //X
|
||||
DrawTextBox(hdc,rect,248, 18, 72, 18); //Y
|
||||
DrawTextBox(hdc,rect,328, 18, 72, 18); //S
|
||||
DrawTextBox(hdc,rect,408, 18, 72, 18); //U
|
||||
DrawTextBox(hdc,rect,295, 60, 40, 18); //DP
|
||||
DrawTextBox(hdc,rect,350, 60, 40, 18); //MD
|
||||
DrawTextBox(hdc,rect,408, 60, 72, 18); //V
|
||||
DrawTextBox(hdc,rect, 35,102, 72, 18); //PC
|
||||
DrawVrtLine(hdc,rect, 45, 18, 18); //A|B
|
||||
DrawVrtLine(hdc,rect,125, 18, 18); //E|F
|
||||
|
||||
DrawCntrTxt(hdc,rect,"D", 8, 0, 72, 18); //D
|
||||
DrawCntrTxt(hdc,rect,"W", 90, 0, 72, 18); //W
|
||||
DrawCntrTxt(hdc,rect,"X", 168, 0, 72, 18); //X
|
||||
DrawCntrTxt(hdc,rect,"Y", 248, 0, 72, 18); //Y
|
||||
DrawCntrTxt(hdc,rect,"S", 328, 0, 72, 18); //S
|
||||
DrawCntrTxt(hdc,rect,"U", 408, 0, 72, 18); //U
|
||||
DrawCntrTxt(hdc,rect,"A", 8, 36, 36, 18); //A
|
||||
DrawCntrTxt(hdc,rect,"B", 44, 36, 36, 18); //B
|
||||
DrawCntrTxt(hdc,rect,"E", 90, 36, 36, 18); //E
|
||||
DrawCntrTxt(hdc,rect,"F", 126, 36, 36, 18); //F
|
||||
DrawCntrTxt(hdc,rect,"DP",295, 43, 45, 18); //DP
|
||||
DrawCntrTxt(hdc,rect,"MD",350, 43, 45, 18); //MD
|
||||
DrawCntrTxt(hdc,rect,"V", 408, 43, 72, 18); //V
|
||||
DrawCntrTxt(hdc,rect,"PC", 8,102, 25, 18); //PC
|
||||
|
||||
// Draw CC Box with bit seperators and lables
|
||||
DrawTextBox(hdc,rect,35,60,200,18);
|
||||
for (int x = 60; x < 235 ; x+=25) DrawVrtLine(hdc,rect,x,60,18);
|
||||
DrawCntrTxt(hdc,rect,"CC", 8,60,25,18);
|
||||
DrawCntrTxt(hdc,rect,"E", 35,78,25,18);
|
||||
DrawCntrTxt(hdc,rect,"F", 60,78,25,18);
|
||||
DrawCntrTxt(hdc,rect,"H", 85,78,25,18);
|
||||
DrawCntrTxt(hdc,rect,"I", 110,78,25,18);
|
||||
DrawCntrTxt(hdc,rect,"N", 135,78,25,18);
|
||||
DrawCntrTxt(hdc,rect,"Z", 160,78,25,18);
|
||||
DrawCntrTxt(hdc,rect,"V", 185,78,25,18);
|
||||
DrawCntrTxt(hdc,rect,"C", 210,78,25,18);
|
||||
|
||||
// Instruction box
|
||||
DrawTextBox(hdc,rect,120,102,120,18);
|
||||
|
||||
// A message
|
||||
DrawCntrTxt(hdc,rect,"W, MD, V are 6309 CPU only",260,108,250,18);
|
||||
|
||||
// Pull out processor state. Do it quickly to keep the emulator frame rate high.
|
||||
const auto& regs(EmuState.Debugger.GetProcessorStateCopy());
|
||||
|
||||
SetTextColor(hdc, RGB(0, 0, 0));
|
||||
|
||||
// Dump the registers.
|
||||
DrawCntrTxt(hdc,rect,HEXCHAR(regs.A,2), 10, 18,36,18); //A
|
||||
DrawCntrTxt(hdc,rect,HEXCHAR(regs.B,2), 44, 18,36,18); //B
|
||||
DrawCntrTxt(hdc,rect,HEXCHAR(regs.X,4), 168, 18,72,18); //X
|
||||
DrawCntrTxt(hdc,rect,HEXCHAR(regs.Y,4), 248, 18,72,18); //Y
|
||||
DrawCntrTxt(hdc,rect,HEXCHAR(regs.S,4), 328, 18,72,18); //S
|
||||
DrawCntrTxt(hdc,rect,HEXCHAR(regs.U,4), 408, 18,72,18); //U
|
||||
DrawCntrTxt(hdc,rect,HEXCHAR(regs.PC,4), 35,102,72,18); //PC
|
||||
DrawCntrTxt(hdc,rect,HEXCHAR(regs.DP,2),295, 60,40,18); //DP
|
||||
if (EmuState.CpuType == 1) {
|
||||
DrawCntrTxt(hdc,rect,HEXCHAR(regs.E,2), 90,18,36,18); //E
|
||||
DrawCntrTxt(hdc,rect,HEXCHAR(regs.F,2), 126,18,36,18); //F
|
||||
DrawCntrTxt(hdc,rect,HEXCHAR(regs.MD,2),350,60,40,18); //MD
|
||||
DrawCntrTxt(hdc,rect,HEXCHAR(regs.V,4), 408,60,72,18); //V
|
||||
}
|
||||
// Condition Code bits
|
||||
int x = 35;
|
||||
for (int n = 7; n >= 0; n--) {
|
||||
if (regs.CC & 1 << n) {
|
||||
DrawCntrTxt(hdc, rect, "1", x, 60, 25, 18);
|
||||
} else {
|
||||
DrawCntrTxt(hdc, rect, "-", x, 60, 25, 18);
|
||||
}
|
||||
x += 25;
|
||||
}
|
||||
// Instruction
|
||||
VCC::CPUTrace trace = {};
|
||||
Decoder->DecodeInstruction(regs,trace);
|
||||
trace.instruction.append(6 - trace.instruction.length(),' ');
|
||||
std::string ins = trace.instruction + trace.operand;
|
||||
RECT rc;
|
||||
SetRect(&rc,rect.left+130,rect.top+102,rect.left+250,rect.top+120);
|
||||
DrawText(hdc, ins.c_str(), -1, &rc, DT_VCENTER | DT_SINGLELINE);
|
||||
// Cleanup.
|
||||
DeleteObject(pen);
|
||||
DeleteObject(hFont);
|
||||
}
|
||||
|
||||
void SaveSettings(HWND hDlg)
|
||||
{
|
||||
constexpr int cHeaderHeight = 20; // header with labels
|
||||
|
||||
RECT CurWindow;
|
||||
::GetWindowRect(hDlg, &CurWindow);
|
||||
RECT CurScreen;
|
||||
::GetClientRect(hDlg, &CurScreen);
|
||||
int clientWidth = (int)CurScreen.right;
|
||||
int clientHeight = (int)CurScreen.bottom;
|
||||
|
||||
{
|
||||
VCC::Rect rect;
|
||||
// remember positioning:
|
||||
rect.x = CurWindow.left;
|
||||
rect.y = CurWindow.top;
|
||||
|
||||
// remember size:
|
||||
rect.w = clientWidth; // Used for saving new window size to the ini file.
|
||||
rect.h = clientHeight - cHeaderHeight;
|
||||
|
||||
auto& s = Setting();
|
||||
std::string section("ProcessorState");
|
||||
auto write = [&](const std::string& key, int value)
|
||||
{
|
||||
s.write(section, key, value);
|
||||
};
|
||||
write(cWindowSizeX, rect.w);
|
||||
write(cWindowSizeY, rect.h);
|
||||
write(cWindowPosX, rect.x);
|
||||
write(cWindowPosY, rect.y);
|
||||
}
|
||||
}
|
||||
|
||||
void LoadSettings(HWND hDlg)
|
||||
{
|
||||
if (hDlg != nullptr)
|
||||
{
|
||||
Rect rect;
|
||||
|
||||
rect.x = CW_USEDEFAULT;
|
||||
rect.y = CW_USEDEFAULT;
|
||||
rect.w = 488;
|
||||
rect.h = 143;
|
||||
|
||||
if (!GetAsyncKeyState(VK_SHIFT))
|
||||
{
|
||||
auto& s = Setting();
|
||||
std::string section("ProcessorState");
|
||||
auto read = [&](const std::string& key, int& value)
|
||||
{
|
||||
value = s.read(section, key, value);
|
||||
};
|
||||
|
||||
read(cWindowSizeX, rect.w);
|
||||
read(cWindowSizeY, rect.h);
|
||||
read(cWindowPosX, rect.x);
|
||||
read(cWindowPosY, rect.y);
|
||||
}
|
||||
|
||||
RECT ra = { 0,0,0,0 }; // left,top,right,bottom
|
||||
::AdjustWindowRect(&ra, WS_OVERLAPPEDWINDOW, TRUE);
|
||||
int windowBorderWidth = ra.right - ra.left;
|
||||
int windowBorderHeight = ra.bottom - ra.top;
|
||||
::GetWindowRect(hDlg, &ra);
|
||||
|
||||
int width = rect.w + windowBorderWidth;
|
||||
int height = rect.h + windowBorderHeight + 0; /*GetRenderWindowStatusBarHeight();*/
|
||||
int flags = SWP_NOOWNERZORDER | SWP_NOZORDER;
|
||||
int x = rect.IsDefaultX() ? ra.left : rect.x;
|
||||
int y = rect.IsDefaultY() ? ra.top : rect.y;
|
||||
SetWindowPos(hDlg, nullptr, x, y, width, height, flags);
|
||||
}
|
||||
}
|
||||
|
||||
INT_PTR CALLBACK ProcessorStateDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM /*lParam*/)
|
||||
{
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
RECT Rect;
|
||||
GetClientRect(hDlg, &Rect);
|
||||
BackBuf = AttachBackBuffer(hDlg, 0, -35);
|
||||
SetTimer(hDlg, IDT_PROC_TIMER, 64, nullptr);
|
||||
LoadSettings(hDlg);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_PAINT:
|
||||
{
|
||||
if (EmuState.Debugger.IsHalted()) {
|
||||
SetWindowTextA(hDlg,"Processor State (Halted)");
|
||||
SendMessageA(GetDlgItem(hDlg,IDC_BTN_CPU_HALT),WM_SETTEXT,0, (LPARAM) "Run");
|
||||
EnableWindow(GetDlgItem(hDlg,IDC_BTN_CPU_STEP),true);
|
||||
EnableWindow(GetDlgItem(hDlg,IDC_BTN_SET_PC),true);
|
||||
} else {
|
||||
SetWindowTextA(hDlg,"Processor State");
|
||||
SendMessageA(GetDlgItem(hDlg,IDC_BTN_CPU_HALT),WM_SETTEXT,0, (LPARAM) "Halt");
|
||||
EnableWindow(GetDlgItem(hDlg,IDC_BTN_CPU_STEP),false);
|
||||
EnableWindow(GetDlgItem(hDlg,IDC_BTN_SET_PC),false);
|
||||
}
|
||||
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc = BeginPaint(hDlg, &ps);
|
||||
|
||||
DrawProcessorState(BackBuf.DeviceContext, &BackBuf.Rect);
|
||||
BitBlt(hdc, 0, 0, BackBuf.Width, BackBuf.Height, BackBuf.DeviceContext, 0, 0, SRCCOPY);
|
||||
|
||||
EndPaint(hDlg, &ps);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_TIMER:
|
||||
switch (wParam)
|
||||
{
|
||||
case IDT_PROC_TIMER:
|
||||
InvalidateRect(hDlg, &BackBuf.Rect, FALSE);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_NCDESTROY:
|
||||
SaveSettings(hDlg);
|
||||
KillTimer(hDlg, IDT_PROC_TIMER);
|
||||
DeleteDC(BackBuf.DeviceContext);
|
||||
ProcessorStateWindow = nullptr;
|
||||
break;
|
||||
|
||||
case WM_CLOSE:
|
||||
DestroyWindow(hDlg);
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDC_BTN_CPU_HALT:
|
||||
EmuState.Debugger.ToggleRun();
|
||||
break;
|
||||
case IDC_BTN_SET_PC:
|
||||
{
|
||||
char buf[16];
|
||||
char *eptr;
|
||||
long val;
|
||||
GetWindowText(GetDlgItem(hDlg, IDC_EDIT_PC_ADDR), buf, 8);
|
||||
val = strtol(buf,&eptr,16);
|
||||
if (*buf == '\0' || *eptr != '\0' || val < 0 || val > 65535)
|
||||
{
|
||||
MessageBox(hDlg,"Invalid hex address","Error",IDOK);
|
||||
} else {
|
||||
CPUForcePC(val & 0xFFFF);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IDC_BTN_CPU_STEP:
|
||||
EmuState.Debugger.QueueStep();
|
||||
break;
|
||||
|
||||
case IDCLOSE:
|
||||
DestroyWindow(hDlg);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
} }
|
||||
|
||||
|
||||
void VCC::Debugger::UI::OpenProcessorStateWindow(HINSTANCE instance, HWND parent)
|
||||
{
|
||||
if (ProcessorStateWindow == nullptr)
|
||||
{
|
||||
ProcessorStateWindow = CreateDialog(
|
||||
instance,
|
||||
MAKEINTRESOURCE(IDD_PROCESSOR_STATE),
|
||||
parent,
|
||||
ProcessorStateDlgProc);
|
||||
ShowWindow(ProcessorStateWindow, SW_SHOWNORMAL);
|
||||
}
|
||||
SetFocus(ProcessorStateWindow);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// 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/>.
|
||||
//
|
||||
// Processor State Display - Part of the Debugger package for VCC
|
||||
// Authors: Mike Rojas, Chet Simpson
|
||||
#pragma once
|
||||
#include <Windows.h>
|
||||
|
||||
|
||||
namespace VCC::Debugger::UI
|
||||
{
|
||||
|
||||
void OpenProcessorStateWindow(HINSTANCE instance, HWND parent);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
#include "../../../src/devices/Ramdisk/memboard.h"
|
||||
#include "defines.h"
|
||||
#include "resource.h"
|
||||
#include <vcc/bus/cpak_cartridge_definitions.h>
|
||||
#include <Windows.h>
|
||||
|
||||
static HINSTANCE gModuleInstance;
|
||||
|
||||
|
||||
BOOL WINAPI DllMain(
|
||||
HINSTANCE hinstDLL, // handle to DLL module
|
||||
DWORD fdwReason, // reason for calling function
|
||||
LPVOID lpReserved ) // reserved
|
||||
{
|
||||
if (fdwReason == DLL_PROCESS_ATTACH) //Clean Up
|
||||
{
|
||||
gModuleInstance = hinstDLL;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
__declspec(dllexport) const char* PakGetName()
|
||||
{
|
||||
static char string_buffer[MAX_LOADSTRING];
|
||||
|
||||
LoadString(gModuleInstance, IDS_MODULE_NAME, string_buffer, MAX_LOADSTRING);
|
||||
|
||||
return string_buffer;
|
||||
}
|
||||
|
||||
__declspec(dllexport) const char* PakGetCatalogId()
|
||||
{
|
||||
static char string_buffer[MAX_LOADSTRING];
|
||||
|
||||
LoadString(gModuleInstance, IDS_CATNUMBER, string_buffer, MAX_LOADSTRING);
|
||||
|
||||
return string_buffer;
|
||||
}
|
||||
|
||||
__declspec(dllexport) const char* PakGetDescription()
|
||||
{
|
||||
static char string_buffer[MAX_LOADSTRING];
|
||||
|
||||
LoadString(gModuleInstance, IDS_DESCRIPTION, string_buffer, MAX_LOADSTRING);
|
||||
|
||||
return string_buffer;
|
||||
}
|
||||
|
||||
__declspec(dllexport) void PakInitialize(
|
||||
void* const /*callback_context*/,
|
||||
const char* const /*configuration_path*/,
|
||||
HWND hVccWnd,
|
||||
const cpak_callbacks* const /*context*/)
|
||||
{
|
||||
InitMemBoard();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
__declspec(dllexport) void PakWritePort(unsigned char Port,unsigned char Data)
|
||||
{
|
||||
switch (Port)
|
||||
{
|
||||
// Address of RAM disk to read/write
|
||||
case 0x40:
|
||||
case 0x41:
|
||||
case 0x42:
|
||||
WritePort(Port,Data);
|
||||
return;
|
||||
// Write to RAM disk
|
||||
case 0x43:
|
||||
WriteArray(Data);
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
} //End port switch
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
__declspec(dllexport) unsigned char PakReadPort(unsigned char Port)
|
||||
{
|
||||
switch (Port)
|
||||
{
|
||||
// Read from RAM disk
|
||||
case 0x43:
|
||||
return(ReadArray());
|
||||
|
||||
default:
|
||||
return 0;
|
||||
} //End port switch
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,1
|
||||
PRODUCTVERSION 1,0,0,1
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "Comments", "\0"
|
||||
VALUE "CompanyName", "None\0"
|
||||
VALUE "FileDescription", "Ramdisk\0"
|
||||
VALUE "FileVersion", "1, 0, 0, 1\0"
|
||||
VALUE "InternalName", "Ramdisk\0"
|
||||
VALUE "LegalCopyright", "Copyright � 2007\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "OriginalFilename", "Ramdisk.dll\0"
|
||||
VALUE "PrivateBuild", "\0"
|
||||
VALUE "ProductName", "None Ramdisk\0"
|
||||
VALUE "ProductVersion", "1, 0, 0, 1\0"
|
||||
VALUE "SpecialBuild", "\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // !_MAC
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_MODULE_NAME "RamDisk"
|
||||
IDS_CATNUMBER "00-0000"
|
||||
IDS_DESCRIPTION "Emulation of a 512k ram card simular to those made by Disto. Uses SCS selectable disk ports. Data written is lost when VCC is restarted."
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Legacy|Win32">
|
||||
<Configuration>Legacy</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<SccProjectName />
|
||||
<SccLocalPath />
|
||||
<ProjectGuid>{23D3931C-364B-45E2-B58C-9B3FBC584C0F}</ProjectGuid>
|
||||
<ProjectName>ramdisk</ProjectName>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\vcc-base.props" />
|
||||
<Import Project="..\vcc-debug.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\vcc-base.props" />
|
||||
<Import Project="..\vcc-legacy.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\vcc-base.props" />
|
||||
<Import Project="..\vcc-release.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">
|
||||
<LibraryPath>C:\Program Files %28x86%29\Windows Kits\8.1\Lib\winv6.3\um\x86;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_USRDLL;RAMDISK_EXPORTS;_LEGACY_VCC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalOptions>/arch:SSE</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<LinkDLL>true</LinkDLL>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;RAMDISK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalOptions>/arch:SSE</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<ResourceCompile />
|
||||
<Link>
|
||||
<LinkDLL>true</LinkDLL>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;RAMDISK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ResourceCompile />
|
||||
<Link>
|
||||
<LinkDLL>true</LinkDLL>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\src\devices\Ramdisk\memboard.cpp" />
|
||||
<ClCompile Include="Ramdisk.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\src\devices\Ramdisk\memboard.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Ramdisk.rc" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
//Speed throttling
|
||||
#define FRAMEINTERVAL 120 //Number of frames to sum the framecounter over
|
||||
#define TARGETFRAMERATE 60 //Number of throttled Frames per second to render
|
||||
|
||||
// Audio handling
|
||||
#define BITRATE (LINESPERFIELD*TARGETFRAMERATE)
|
||||
#define BLOCK_SIZE LINESPERFIELD*2
|
||||
#define BLOCK_COUNT 6
|
||||
|
||||
//CPU
|
||||
#define _894KHZ 57
|
||||
#define JIFFIESPERLINE (_894KHZ*4)
|
||||
#define LINESPERFIELD 262
|
||||
|
||||
//Misc
|
||||
#define MAX_LOADSTRING 100
|
||||
#define QUERY 255
|
||||
#define INDEXTIME ((LINESPERFIELD * TARGETFRAMERATE)/5)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by Ramdisk.rc
|
||||
//
|
||||
#define IDS_MODULE_NAME 1
|
||||
#define IDS_CATNUMBER 2
|
||||
#define IDS_DESCRIPTION 3
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,99 @@
|
||||
// Copyright 2015 by Joseph Forgion
|
||||
// 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
#include "Screenshot.h"
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <cstdint>
|
||||
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "../../third_party/legacy_graphics/stb/stb_image_write.h"
|
||||
|
||||
using namespace VCC;
|
||||
|
||||
namespace Screenshot
|
||||
{
|
||||
typedef std::uint8_t uint8_t;
|
||||
|
||||
int Snap(IDisplay* display, const char* fname)
|
||||
{
|
||||
char path[_MAX_PATH];
|
||||
|
||||
if (!fname)
|
||||
{
|
||||
// get user directory
|
||||
const char* userProfile = getenv("USERPROFILE");
|
||||
if (!userProfile) return ERR_NOUSERPROFILE;
|
||||
|
||||
// create filename
|
||||
time_t now = time(nullptr);
|
||||
auto tm = *localtime(&now);
|
||||
auto len = snprintf(path, _MAX_PATH, "%s\\Pictures\\vcc-%04d%02d%02d-%02d%02d%02d-0.png", userProfile, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||
if (len < 0 || len >= _MAX_PATH) return ERR_PATHTOOLONG;
|
||||
|
||||
// check filename clash
|
||||
char* next = path + len - 5; // '0'
|
||||
struct stat st;
|
||||
while (stat(path, &st) == 0)
|
||||
{
|
||||
if (*next == '9') return ERR_FILECLASH;
|
||||
++(*next);
|
||||
}
|
||||
fname = path;
|
||||
}
|
||||
|
||||
if (display->LockSurface() != IDisplay::OK) return ERR_NOLOCK;
|
||||
|
||||
auto cleanup = [&](int code) -> int
|
||||
{
|
||||
if (display->UnlockSurface() != IDisplay::OK) return ERR_NOUNLOCK;
|
||||
return code;
|
||||
};
|
||||
|
||||
// get surface
|
||||
Pixel* pixels;
|
||||
if (display->GetSurface(&pixels) != IDisplay::OK) return cleanup(ERR_NOSURFACE);
|
||||
|
||||
// get dimensions of display surface
|
||||
IDisplay::Rect rect;
|
||||
if (display->GetRect(IDisplay::OPT_RECT_SURFACE, &rect) != IDisplay::OK) return cleanup(ERR_NOAREA);
|
||||
|
||||
auto w = (int)rect.w;
|
||||
auto h = (int)rect.h;
|
||||
|
||||
// convert argb to rgb
|
||||
uint8_t* rgb = new uint8_t[w * h * 3];
|
||||
if (!rgb) return cleanup(1);
|
||||
|
||||
auto cleanupMem = [&](int code) { delete[] rgb; return cleanup(code); };
|
||||
|
||||
uint8_t* p = rgb;
|
||||
for (int i = 0; i < w * h; ++i, ++pixels)
|
||||
{
|
||||
*(p++) = pixels->r;
|
||||
*(p++) = pixels->g;
|
||||
*(p++) = pixels->b;
|
||||
}
|
||||
|
||||
// write the png
|
||||
if (stbi_write_png(fname, w, h, 3, rgb, w * 3) == 0)
|
||||
return cleanupMem(ERR_WRITEPNG);
|
||||
|
||||
// cleanup
|
||||
return cleanupMem(OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
// Copyright 2015 by Joseph Forgion
|
||||
// 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
#include "../../src/core/IDisplay.h"
|
||||
|
||||
namespace Screenshot
|
||||
{
|
||||
enum
|
||||
{
|
||||
OK,
|
||||
ERR_NOUSERPROFILE,
|
||||
ERR_PATHTOOLONG,
|
||||
ERR_FILECLASH,
|
||||
ERR_NOLOCK,
|
||||
ERR_NOUNLOCK,
|
||||
ERR_NOSURFACE,
|
||||
ERR_NOAREA,
|
||||
ERR_WRITEPNG,
|
||||
};
|
||||
|
||||
int Snap(VCC::IDisplay* display, const char* fname);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,626 @@
|
||||
// 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/>.
|
||||
//
|
||||
// Breakpoint Display - Part of the Debugger package for VCC
|
||||
// Authors: Mike Rojas, Chet Simpson
|
||||
|
||||
#define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING // FIXME: Temporary until codecvt deprecation can be addressed
|
||||
|
||||
#include "SourceDebug.h"
|
||||
#include "Debugger.h"
|
||||
#include "DebuggerUtils.h"
|
||||
#include "defines.h"
|
||||
#include "resource.h"
|
||||
#include <vcc/util/DialogOps.h>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <regex>
|
||||
#include <codecvt>
|
||||
#include <locale>
|
||||
#include <commdlg.h>
|
||||
#include <Richedit.h>
|
||||
|
||||
|
||||
namespace VCC::Debugger::UI {
|
||||
namespace {
|
||||
HWND SourceDebugWindow = nullptr;
|
||||
HWND hWndSourceDebug;
|
||||
WNDPROC oldEditProc;
|
||||
|
||||
unsigned short PriorCPUHaltAddress = 0;
|
||||
|
||||
struct Breakpoint
|
||||
{
|
||||
unsigned int id;
|
||||
unsigned int addr;
|
||||
unsigned int line;
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
std::map<int, Breakpoint> mapBreakpoints;
|
||||
std::map<int, int> mapLineAddr;
|
||||
std::map<int, int> mapAddrLine;
|
||||
|
||||
std::vector<std::string> split(const std::string& input, const std::string& rgx)
|
||||
{
|
||||
// passing -1 as the submatch index parameter performs splitting
|
||||
std::regex re(rgx);
|
||||
std::sregex_token_iterator
|
||||
first{ input.begin(), input.end(), re, -1 },
|
||||
last;
|
||||
return { first, last };
|
||||
}
|
||||
|
||||
void ResizeWindow(int width, int height)
|
||||
{
|
||||
HWND hCtl = GetDlgItem(hWndSourceDebug, IDC_SOURCE_LISTING);
|
||||
MoveWindow(hCtl, 14, 255, width - 30, height - 298, TRUE);
|
||||
|
||||
hCtl = GetDlgItem(hWndSourceDebug, IDCLOSE);
|
||||
SetWindowPos(hCtl, nullptr, 10, height - 34, 0, 0, SWP_NOSIZE);
|
||||
hCtl = GetDlgItem(hWndSourceDebug, IDC_BTN_FIND_SOURCE);
|
||||
SetWindowPos(hCtl, nullptr, width - 65, height - 34, 0, 0, SWP_NOSIZE);
|
||||
hCtl = GetDlgItem(hWndSourceDebug, IDC_EDIT_FIND_SOURCE);
|
||||
SetWindowPos(hCtl, nullptr, width - 172, height - 34, 0, 0, SWP_NOSIZE);
|
||||
}
|
||||
|
||||
bool LoadSource(const char* source)
|
||||
{
|
||||
SendDlgItemMessage(hWndSourceDebug, IDC_EDIT_SOURCE, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(source));
|
||||
|
||||
int nLines = 0;
|
||||
std::string loaded(std::to_string(nLines) + " lines loaded");
|
||||
SendDlgItemMessage(hWndSourceDebug, IDC_LINES_LOADED, WM_SETTEXT, 0, (LPARAM)ToLPCSTR(loaded));
|
||||
|
||||
std::ifstream file(source);
|
||||
if (!file.is_open())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string lines;
|
||||
|
||||
for (std::string line; getline(file, line); )
|
||||
{
|
||||
const auto& addr = line.length() >= 4 ? line.substr(0, 4): std::string(4, ' ');
|
||||
const auto& opcodes = line.length() >= 20 ? line.substr(5, 16) : std::string(16, ' ');
|
||||
const auto& code = line.length() >= 60 ? line.substr(56) : "";
|
||||
|
||||
if (addr != std::string(4, ' '))
|
||||
{
|
||||
unsigned int addrInt;
|
||||
std::stringstream ss;
|
||||
ss << addr;
|
||||
ss >> std::hex >> addrInt;
|
||||
mapLineAddr[nLines] = addrInt; // Map address to listing line number.
|
||||
mapAddrLine[addrInt] = nLines; // Map listing line number to address.
|
||||
}
|
||||
lines += " | ";
|
||||
lines += addr.c_str();
|
||||
lines += " | ";
|
||||
lines += opcodes.c_str();
|
||||
lines += " | ";
|
||||
lines += code.c_str();
|
||||
lines += "\n";
|
||||
nLines++;
|
||||
}
|
||||
|
||||
loaded = std::to_string(nLines) + " lines loaded";
|
||||
SendDlgItemMessage(hWndSourceDebug, IDC_SOURCE_LISTING, EM_SETSEL, WPARAM(0), LPARAM(-1));
|
||||
SendDlgItemMessage(hWndSourceDebug, IDC_SOURCE_LISTING, EM_REPLACESEL, WPARAM(TRUE), (LPARAM)ToLPCSTR(lines));
|
||||
SendDlgItemMessage(hWndSourceDebug, IDC_SOURCE_LISTING, EM_LINESCROLL, 0, (LPARAM)-nLines);
|
||||
SendDlgItemMessage(hWndSourceDebug, IDC_LINES_LOADED, WM_SETTEXT, 0, (LPARAM)ToLPCSTR(loaded));
|
||||
return true;
|
||||
}
|
||||
|
||||
void SelectSourceListing(HWND parentWindow)
|
||||
{
|
||||
FileDialog dlg;
|
||||
dlg.setFilter("LWASM listing file (*.lst)\0*.lst\0Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0\0");
|
||||
dlg.setFlags(OFN_FILEMUSTEXIST);
|
||||
dlg.setTitle("Load LWASM Source Listing");
|
||||
if ( dlg.show(0,parentWindow) ) {
|
||||
if (!LoadSource(dlg.path()))
|
||||
MessageBox(parentWindow,"Can't open source listing","Error",0);
|
||||
}
|
||||
}
|
||||
|
||||
void SetupListingControl()
|
||||
{
|
||||
CHARFORMAT fmt;
|
||||
fmt.cbSize = sizeof(CHARFORMAT);
|
||||
LRESULT lResult = SendDlgItemMessage(hWndSourceDebug, IDC_SOURCE_LISTING, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM)&fmt);
|
||||
strcpy(fmt.szFaceName, "Courier New");
|
||||
fmt.yHeight = 10 * 20;
|
||||
fmt.dwEffects = CFE_BOLD;
|
||||
fmt.dwMask = CFM_BOLD | CFM_FACE | CFM_SIZE | CFM_COLOR;
|
||||
fmt.crTextColor = RGB(255, 255, 255);
|
||||
lResult = SendDlgItemMessage(hWndSourceDebug, IDC_SOURCE_LISTING, EM_SETCHARFORMAT, SCF_ASSOCIATEFONT, (LPARAM)&fmt);
|
||||
|
||||
HWND hCtl = GetDlgItem(hWndSourceDebug, IDC_SOURCE_LISTING);
|
||||
|
||||
DWORD msk = ENM_KEYEVENTS | ENM_MOUSEEVENTS; // | ENM_SCROLL | ENM_SCROLLEVENTS;
|
||||
SendMessage(hCtl, EM_SETEVENTMASK, WPARAM(0), (LPARAM)msk);
|
||||
SendMessage(hCtl, EM_SETBKGNDCOLOR, WPARAM(0), RGB(0, 0, 0));
|
||||
|
||||
EnableWindow(GetDlgItem(hWndSourceDebug, IDC_BTN_DEL_BREAKPOINT), false);
|
||||
EnableWindow(GetDlgItem(hWndSourceDebug, IDC_BTN_BREAKPOINT_ON), false);
|
||||
EnableWindow(GetDlgItem(hWndSourceDebug, IDC_BTN_BREAKPOINT_OFF), false);
|
||||
}
|
||||
|
||||
int CurrentSourceLine()
|
||||
{
|
||||
HWND hCtl = GetDlgItem(hWndSourceDebug, IDC_SOURCE_LISTING);
|
||||
int currentCharStart = SendMessage(hCtl, EM_LINEINDEX, WPARAM(-1), 0);
|
||||
return SendMessage(hCtl, EM_LINEFROMCHAR, currentCharStart, 0);
|
||||
}
|
||||
|
||||
void SelectSourceText(int line, int count, int pos = 0)
|
||||
{
|
||||
HWND hCtl = GetDlgItem(hWndSourceDebug, IDC_SOURCE_LISTING);
|
||||
int currentCharStart = SendMessage(hCtl, EM_LINEINDEX, line, 0L);
|
||||
int currentCharEnd = currentCharStart + count;
|
||||
if (count == -1)
|
||||
{
|
||||
currentCharEnd = SendMessage(hCtl, EM_LINEINDEX, line + 1, 0L);
|
||||
}
|
||||
SendMessage(hCtl, EM_SETSEL, currentCharStart + pos, currentCharEnd);
|
||||
}
|
||||
|
||||
std::string GetSelectedSourceText()
|
||||
{
|
||||
WCHAR buf[1000];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
SendDlgItemMessage(hWndSourceDebug, IDC_SOURCE_LISTING, EM_GETSELTEXT, 0, (LPARAM)&buf);
|
||||
|
||||
//setup converter
|
||||
using convert_type = std::codecvt_utf8<wchar_t>;
|
||||
return std::wstring_convert<convert_type, wchar_t>().to_bytes( buf );
|
||||
}
|
||||
|
||||
void SetLineColor(int line, int rgb)
|
||||
{
|
||||
SelectSourceText(line, -1);
|
||||
CHARFORMAT fmt;
|
||||
fmt.cbSize = sizeof(CHARFORMAT);
|
||||
SendDlgItemMessage(hWndSourceDebug, IDC_SOURCE_LISTING, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt);
|
||||
fmt.dwMask = CFM_COLOR;
|
||||
fmt.crTextColor = rgb;
|
||||
SendDlgItemMessage(hWndSourceDebug, IDC_SOURCE_LISTING, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt);
|
||||
}
|
||||
|
||||
void UpdateBreakpointUI(const Breakpoint& bp)
|
||||
{
|
||||
HWND hListCtl = GetDlgItem(hWndSourceDebug, IDC_LIST_BREAKPOINTS);
|
||||
const std::string enabled = bp.enabled ? "On" : "Off";
|
||||
std::string s = "Breakpoint #" + std::to_string(bp.id) + "\t" + enabled + "\taddr = " + ToHexString(bp.addr, 0, false);
|
||||
int pos = SendMessage(hListCtl, LB_ADDSTRING, 0, (LPARAM)ToLPCSTR(s));
|
||||
SendMessage(hListCtl, LB_SETITEMDATA, pos, (LPARAM)bp.id);
|
||||
SendMessage(hListCtl, LB_SETCURSEL, pos, 0);
|
||||
|
||||
EnableWindow(GetDlgItem(hWndSourceDebug, IDC_BTN_DEL_BREAKPOINT), true);
|
||||
EnableWindow(GetDlgItem(hWndSourceDebug, IDC_BTN_BREAKPOINT_ON), true);
|
||||
EnableWindow(GetDlgItem(hWndSourceDebug, IDC_BTN_BREAKPOINT_OFF), true);
|
||||
|
||||
SelectSourceText(bp.line, 4);
|
||||
s = (bp.enabled ? "BK" : "--") + ToDecimalString(bp.id, 2, false);
|
||||
SendDlgItemMessage(hWndSourceDebug, IDC_SOURCE_LISTING, EM_REPLACESEL, WPARAM(FALSE), (LPARAM)ToLPCSTR(s));
|
||||
SetLineColor(bp.line, RGB(255, 100, 100));
|
||||
}
|
||||
|
||||
void UpdateCPUState()
|
||||
{
|
||||
Debugger::breakpointsbuffer_type breakpoints;
|
||||
|
||||
auto it = mapBreakpoints.begin();
|
||||
while (it != mapBreakpoints.end())
|
||||
{
|
||||
Breakpoint bp = it->second;
|
||||
if (bp.enabled)
|
||||
{
|
||||
if (bp.addr > 0xffff)
|
||||
{
|
||||
throw std::out_of_range("Breakpoint address is too large");
|
||||
}
|
||||
|
||||
breakpoints.push_back(static_cast<unsigned short>(bp.addr));
|
||||
}
|
||||
it++;
|
||||
}
|
||||
|
||||
EmuState.Debugger.SetBreakpoints(move(breakpoints)); // FIXME: Check if move is still needed or if this the xlvalue is ....
|
||||
}
|
||||
|
||||
int AddBreakpoint(int line)
|
||||
{
|
||||
// Find first available id
|
||||
int n = 1;
|
||||
while (mapBreakpoints.find(n) != mapBreakpoints.end()) n++;
|
||||
Breakpoint bp;
|
||||
bp.id = n;
|
||||
bp.enabled = true;
|
||||
bp.line = line;
|
||||
bp.addr = mapLineAddr[line];
|
||||
mapBreakpoints[n] = bp;
|
||||
|
||||
UpdateCPUState();
|
||||
|
||||
UpdateBreakpointUI(bp);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
void EnableBreakpoint(int id, bool enable)
|
||||
{
|
||||
HWND hListCtl = GetDlgItem(hWndSourceDebug, IDC_LIST_BREAKPOINTS);
|
||||
|
||||
int cnt = SendMessage(hListCtl, LB_GETCOUNT, 0, 0);
|
||||
for (int n = 0; n < cnt; n++)
|
||||
{
|
||||
int itemId = SendMessage(hListCtl, LB_GETITEMDATA, n, 0);
|
||||
if (itemId == id)
|
||||
{
|
||||
SendMessage(hListCtl, LB_DELETESTRING, n, 0);
|
||||
|
||||
Breakpoint bp = mapBreakpoints[id];
|
||||
bp.enabled = enable;
|
||||
mapBreakpoints[id] = bp;
|
||||
|
||||
UpdateCPUState();
|
||||
|
||||
UpdateBreakpointUI(bp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RemoveBreakpoint(int id)
|
||||
{
|
||||
Breakpoint bp = mapBreakpoints[id];
|
||||
mapBreakpoints.erase(id);
|
||||
|
||||
UpdateCPUState();
|
||||
|
||||
HWND hListCtl = GetDlgItem(hWndSourceDebug, IDC_LIST_BREAKPOINTS);
|
||||
int cnt = SendMessage(hListCtl, LB_GETCOUNT, 0, 0);
|
||||
for (int n = 0; n < cnt; n++)
|
||||
{
|
||||
int itemId = SendMessage(hListCtl, LB_GETITEMDATA, n, 0);
|
||||
if (itemId == id)
|
||||
{
|
||||
SendMessage(hListCtl, LB_DELETESTRING, n, 0);
|
||||
SendMessage(hListCtl, LB_SETCURSEL, WPARAM(-1), 0);
|
||||
|
||||
EnableWindow(GetDlgItem(hWndSourceDebug, IDC_BTN_DEL_BREAKPOINT), false);
|
||||
EnableWindow(GetDlgItem(hWndSourceDebug, IDC_BTN_BREAKPOINT_ON), false);
|
||||
EnableWindow(GetDlgItem(hWndSourceDebug, IDC_BTN_BREAKPOINT_OFF), false);
|
||||
|
||||
SelectSourceText(bp.line, 4);
|
||||
const std::string s(" ");
|
||||
SendDlgItemMessage(hWndSourceDebug, IDC_SOURCE_LISTING, EM_REPLACESEL, WPARAM(FALSE), (LPARAM)ToLPCSTR(s));
|
||||
SetLineColor(bp.line, RGB(255, 255, 255));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NewBreakPoint()
|
||||
{
|
||||
int currentLine = CurrentSourceLine();
|
||||
|
||||
// Can we set a break point on this line?
|
||||
if (mapLineAddr[currentLine] == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SelectSourceText(currentLine, 4);
|
||||
const std::string start = GetSelectedSourceText();
|
||||
if (start.substr(0, 4) == " ")
|
||||
{
|
||||
AddBreakpoint(currentLine);
|
||||
}
|
||||
}
|
||||
|
||||
void ListBoxSelection(int action)
|
||||
{
|
||||
HWND hListCtl = GetDlgItem(hWndSourceDebug, IDC_LIST_BREAKPOINTS);
|
||||
if (action == LBN_SELCHANGE)
|
||||
{
|
||||
int selected = SendMessage(hListCtl, LB_GETCURSEL, 0, 0);
|
||||
if (selected != LB_ERR)
|
||||
{
|
||||
int itemId = SendMessage(hListCtl, LB_GETITEMDATA, selected, 0);
|
||||
Breakpoint bp = mapBreakpoints[itemId];
|
||||
|
||||
int topLine = SendDlgItemMessage(hWndSourceDebug, IDC_SOURCE_LISTING, EM_GETFIRSTVISIBLELINE, 0, 0);
|
||||
int scroll = bp.line - topLine;
|
||||
SendDlgItemMessage(hWndSourceDebug, IDC_SOURCE_LISTING, EM_LINESCROLL, 0, (LPARAM)scroll);
|
||||
|
||||
EnableWindow(GetDlgItem(hWndSourceDebug, IDC_BTN_DEL_BREAKPOINT), true);
|
||||
EnableWindow(GetDlgItem(hWndSourceDebug, IDC_BTN_BREAKPOINT_ON), true);
|
||||
EnableWindow(GetDlgItem(hWndSourceDebug, IDC_BTN_BREAKPOINT_OFF), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
EnableWindow(GetDlgItem(hWndSourceDebug, IDC_BTN_DEL_BREAKPOINT), false);
|
||||
EnableWindow(GetDlgItem(hWndSourceDebug, IDC_BTN_BREAKPOINT_ON), false);
|
||||
EnableWindow(GetDlgItem(hWndSourceDebug, IDC_BTN_BREAKPOINT_OFF), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ListBoxAction(int action)
|
||||
{
|
||||
HWND hListCtl = GetDlgItem(hWndSourceDebug, IDC_LIST_BREAKPOINTS);
|
||||
int selected = SendMessage(hListCtl, LB_GETCURSEL, 0, 0);
|
||||
if (selected != LB_ERR)
|
||||
{
|
||||
int itemId = SendMessage(hListCtl, LB_GETITEMDATA, selected, 0);
|
||||
Breakpoint bp = mapBreakpoints[itemId];
|
||||
switch (action)
|
||||
{
|
||||
case IDC_BTN_DEL_BREAKPOINT:
|
||||
RemoveBreakpoint(bp.id);
|
||||
break;
|
||||
case IDC_BTN_BREAKPOINT_ON:
|
||||
EnableBreakpoint(bp.id, true);
|
||||
break;
|
||||
case IDC_BTN_BREAKPOINT_OFF:
|
||||
EnableBreakpoint(bp.id, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ToggleBreakpoint(int line)
|
||||
{
|
||||
// Can we set a break point on this line?
|
||||
if (mapLineAddr[line] == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SelectSourceText(line, 4);
|
||||
const std::string start(GetSelectedSourceText());
|
||||
if (start.substr(0, 2) == "BK" || start.substr(0, 2) == "--")
|
||||
{
|
||||
const std::string nn = start.substr(2, 2);
|
||||
int id = atoi(nn.c_str());
|
||||
RemoveBreakpoint(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddBreakpoint(line);
|
||||
}
|
||||
}
|
||||
|
||||
void FindSourceLine()
|
||||
{
|
||||
TCHAR buffer[100];
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
SendDlgItemMessage(hWndSourceDebug, IDC_EDIT_FIND_SOURCE, WM_GETTEXT, sizeof(buffer), (LPARAM)(LPCSTR)buffer);
|
||||
|
||||
size_t newsize = strlen(buffer) + 1;
|
||||
wchar_t* wcstring = new wchar_t[newsize];
|
||||
|
||||
// Convert char* string to a wchar_t* string.
|
||||
size_t convertedChars = 0;
|
||||
mbstowcs_s(&convertedChars, wcstring, newsize, buffer, _TRUNCATE);
|
||||
|
||||
HWND hCtl = GetDlgItem(hWndSourceDebug, IDC_SOURCE_LISTING);
|
||||
|
||||
DWORD cPos = 0;
|
||||
SendMessage(hCtl, EM_GETSEL, (WPARAM)&cPos, 0);
|
||||
|
||||
cPos++;
|
||||
|
||||
FINDTEXTEX ft;
|
||||
ft.lpstrText = (LPSTR)wcstring;
|
||||
ft.chrg.cpMin = cPos;
|
||||
ft.chrg.cpMax = -1;
|
||||
int pos = SendMessage(hCtl, EM_FINDTEXTEX, FR_DOWN, (LPARAM)&ft);
|
||||
if (pos == -1)
|
||||
{
|
||||
SelectSourceText(0, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
int line = SendMessage(hCtl, EM_LINEFROMCHAR, pos, 0);
|
||||
int topLine = SendMessage(hCtl, EM_GETFIRSTVISIBLELINE, 0, 0);
|
||||
int scroll = line - topLine;
|
||||
SendMessage(hCtl, EM_LINESCROLL, 0, (LPARAM)scroll);
|
||||
SendMessage(hCtl, EM_SETSEL, ft.chrgText.cpMin, ft.chrgText.cpMax);
|
||||
}
|
||||
|
||||
int HandleKeyDown(DWORD key)
|
||||
{
|
||||
int currentLine = CurrentSourceLine();
|
||||
if (key == 'B' || key == 'b')
|
||||
{
|
||||
ToggleBreakpoint(currentLine);
|
||||
}
|
||||
if (key == 'E' || key == 'e')
|
||||
{
|
||||
SelectSourceText(currentLine, 4);
|
||||
const std::string start = GetSelectedSourceText();
|
||||
if (start.substr(0, 2) == "BK")
|
||||
{
|
||||
const std::string nn = start.substr(2, 2);
|
||||
int id = atoi(nn.c_str());
|
||||
EnableBreakpoint(id, false);
|
||||
}
|
||||
if (start.substr(0, 2) == "--")
|
||||
{
|
||||
const std::string nn = start.substr(2, 2);
|
||||
int id = atoi(nn.c_str());
|
||||
EnableBreakpoint(id, true);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void LocateBreakpoint(unsigned short addr)
|
||||
{
|
||||
// Do we have a line number to show?
|
||||
if (mapAddrLine[addr] == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int line = mapAddrLine[addr];
|
||||
int topLine = SendDlgItemMessage(hWndSourceDebug, IDC_SOURCE_LISTING, EM_GETFIRSTVISIBLELINE, 0, 0);
|
||||
int scroll = line - topLine;
|
||||
SendDlgItemMessage(hWndSourceDebug, IDC_SOURCE_LISTING, EM_LINESCROLL, 0, (LPARAM)scroll);
|
||||
SelectSourceText(line, -1);
|
||||
}
|
||||
|
||||
void CheckCPUState()
|
||||
{
|
||||
unsigned short currentPc;
|
||||
if (EmuState.Debugger.IsHalted(currentPc) && PriorCPUHaltAddress != currentPc)
|
||||
{
|
||||
LocateBreakpoint(currentPc);
|
||||
PriorCPUHaltAddress = currentPc;
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CALLBACK subEditProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case WM_KEYDOWN:
|
||||
switch (wParam)
|
||||
{
|
||||
case VK_RETURN:
|
||||
FindSourceLine();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return CallWindowProc(oldEditProc, wnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
INT_PTR CALLBACK SourceDebugDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
hWndSourceDebug = hDlg;
|
||||
SetupListingControl();
|
||||
|
||||
HWND hCtl = GetDlgItem(hDlg, IDC_EDIT_FIND_SOURCE);
|
||||
oldEditProc = (WNDPROC)SetWindowLongPtr(hCtl, GWLP_WNDPROC, (LONG_PTR)subEditProc);
|
||||
|
||||
SetTimer(hDlg, IDT_BRKP_TIMER, 250, nullptr);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_NOTIFY:
|
||||
switch (((NMHDR*)lParam)->code)
|
||||
{
|
||||
case EN_MSGFILTER:
|
||||
switch (((MSGFILTER*)lParam)->msg)
|
||||
{
|
||||
case WM_KEYDOWN:
|
||||
return HandleKeyDown(((MSGFILTER*)lParam)->wParam);
|
||||
case WM_KEYUP:
|
||||
return TRUE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_GETMINMAXINFO:
|
||||
{
|
||||
LPMINMAXINFO lpMMI = (LPMINMAXINFO)lParam;
|
||||
lpMMI->ptMinTrackSize.x = 525;
|
||||
lpMMI->ptMinTrackSize.y = 400;
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_SIZE:
|
||||
{
|
||||
UINT width = LOWORD(lParam);
|
||||
UINT height = HIWORD(lParam);
|
||||
ResizeWindow(width, height);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case WM_TIMER:
|
||||
|
||||
switch (wParam)
|
||||
{
|
||||
case IDT_BRKP_TIMER:
|
||||
CheckCPUState();
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDC_LIST_BREAKPOINTS:
|
||||
ListBoxSelection(HIWORD(wParam));
|
||||
break;
|
||||
case IDC_BTN_SOURCE_BROWSE:
|
||||
SelectSourceListing(hDlg);
|
||||
break;
|
||||
case IDC_BTN_NEW_BREAKPOINT:
|
||||
NewBreakPoint();
|
||||
break;
|
||||
case IDC_BTN_DEL_BREAKPOINT:
|
||||
case IDC_BTN_BREAKPOINT_ON:
|
||||
case IDC_BTN_BREAKPOINT_OFF:
|
||||
ListBoxAction(LOWORD(wParam));
|
||||
break;
|
||||
case IDC_BTN_FIND_SOURCE:
|
||||
FindSourceLine();
|
||||
break;
|
||||
case IDCLOSE:
|
||||
case WM_DESTROY:
|
||||
KillTimer(hDlg, IDT_BRKP_TIMER);
|
||||
DestroyWindow(hDlg);
|
||||
SourceDebugWindow = nullptr;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
} }
|
||||
|
||||
|
||||
void VCC::Debugger::UI::OpenSourceDebugWindow(HINSTANCE instance, HWND parent)
|
||||
{
|
||||
if (SourceDebugWindow == nullptr)
|
||||
{
|
||||
SourceDebugWindow = CreateDialog(
|
||||
instance,
|
||||
MAKEINTRESOURCE(IDD_BREAKPOINTS),
|
||||
parent,
|
||||
SourceDebugDlgProc);
|
||||
|
||||
ShowWindow(SourceDebugWindow, SW_SHOWNORMAL);
|
||||
}
|
||||
|
||||
SetFocus(SourceDebugWindow);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// 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/>.
|
||||
//
|
||||
// Breakpoint Display - Part of the Debugger package for VCC
|
||||
// Authors: Mike Rojas, Chet Simpson
|
||||
#pragma once
|
||||
#include <Windows.h>
|
||||
|
||||
|
||||
namespace VCC::Debugger::UI
|
||||
{
|
||||
|
||||
void OpenSourceDebugWindow(HINSTANCE instance, HWND parent);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,371 @@
|
||||
//#define USE_LOGGING
|
||||
//======================================================================
|
||||
// This file is part of VCC (Virtual Color Computer).
|
||||
// Vcc is Copyright 2015 by Joseph Forgione
|
||||
//
|
||||
// VCC (Virtual Color Computer) is free software, you can redistribute
|
||||
// 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/>.
|
||||
//
|
||||
//======================================================================
|
||||
|
||||
#include <string>
|
||||
#include "IdeBus.h"
|
||||
#include <stdio.h>
|
||||
#include <Windows.h>
|
||||
#include <vcc/util/logger.h>
|
||||
|
||||
static unsigned int Lba=0,LastLba;
|
||||
static unsigned char XferBuffer[512]="";
|
||||
|
||||
static unsigned int BufferIndex=0;
|
||||
static unsigned int BufferLenth=0;
|
||||
static unsigned char CurrentCommand=0;
|
||||
void ExecuteCommand();
|
||||
void ByteSwap (char *);
|
||||
static IDEINTERFACE Registers;
|
||||
static HANDLE hDiskFile[2] {};
|
||||
static unsigned char DiskSelect=0,LbaEnabled=0;
|
||||
unsigned long BytesMoved=0;
|
||||
unsigned char BusyCounter=BUSYWAIT;
|
||||
HANDLE OpenDisk(const char *,unsigned char);
|
||||
static unsigned short IDBlock[2][256];
|
||||
static unsigned char Mounted=0,ScanCount=0;
|
||||
static char CurrStatus[32]="IDE:Idle ";
|
||||
static char FileNames[2][MAX_PATH]={"",""};
|
||||
|
||||
void IdeInit()
|
||||
{
|
||||
Registers.Command=0;
|
||||
Registers.Cylinderlsb=0;
|
||||
Registers.Cylindermsb=0;
|
||||
Registers.Data=0;
|
||||
Registers.Error[MASTER]=0;
|
||||
Registers.Error[SLAVE]=0;
|
||||
Registers.Head=0;
|
||||
Registers.SecCount=0;
|
||||
Registers.SecNumber=0;
|
||||
Registers.Status[MASTER]=0;
|
||||
Registers.Status[SLAVE]=0;
|
||||
Lba=0;
|
||||
BufferIndex=0;
|
||||
CurrentCommand=0;
|
||||
BufferLenth=0;
|
||||
memset(XferBuffer,0,512);
|
||||
return;
|
||||
}
|
||||
|
||||
void IdeRegWrite(unsigned char Reg,unsigned short Data)
|
||||
{
|
||||
unsigned char SData=(unsigned char)Data&0xFF;
|
||||
|
||||
switch (Reg)
|
||||
{
|
||||
case 0x0:
|
||||
if (!CurrentCommand)
|
||||
return;
|
||||
Registers.Data=Data;
|
||||
XferBuffer[BufferIndex]= Registers.Data & 0xFF;
|
||||
XferBuffer[BufferIndex+1]=(Registers.Data>>8)&0xFF;
|
||||
BufferIndex+=2;
|
||||
if (BufferIndex>=BufferLenth)
|
||||
{
|
||||
if ((CurrentCommand==0x30) | (CurrentCommand==0x31))
|
||||
{
|
||||
SetFilePointer(hDiskFile[DiskSelect],Lba*512,nullptr,FILE_BEGIN);
|
||||
WriteFile(hDiskFile[DiskSelect],XferBuffer,512,&BytesMoved,nullptr);
|
||||
}
|
||||
BufferIndex=0;
|
||||
BufferLenth=0;
|
||||
CurrentCommand=0;
|
||||
Registers.Status[DiskSelect]=RDY;
|
||||
Registers.Error[DiskSelect]=0;
|
||||
}
|
||||
break;
|
||||
case 0x1:
|
||||
// Registers.Error=SData; //Write Precomp on write not used
|
||||
break;
|
||||
case 0x2:
|
||||
Registers.SecCount=SData;
|
||||
break;
|
||||
case 0x3:
|
||||
Registers.SecNumber=SData;
|
||||
break;
|
||||
case 0x4:
|
||||
Registers.Cylinderlsb=SData;
|
||||
break;
|
||||
case 0x5:
|
||||
Registers.Cylindermsb=SData;
|
||||
break;
|
||||
case 0x6:
|
||||
Registers.Head=SData;
|
||||
break;
|
||||
case 0x7:
|
||||
Registers.Command=SData;
|
||||
ExecuteCommand();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
} //End port switch
|
||||
Lba=((Registers.Head&15)<<24)+(Registers.Cylindermsb<<16)+(Registers.Cylinderlsb<<8)+Registers.SecNumber;
|
||||
DiskSelect=(Registers.Head >>4)&1;
|
||||
LbaEnabled=(Registers.Head >>6)&1;
|
||||
//LBa = [ (Cylinder * No of Heads + Heads) * Sectors/Track ] + (Sector-1) //CHS translation
|
||||
}
|
||||
|
||||
unsigned short IdeRegRead(unsigned char Reg)
|
||||
{
|
||||
unsigned short RetVal=0;
|
||||
|
||||
switch (Reg)
|
||||
{
|
||||
case 0x0:
|
||||
if (!CurrentCommand)
|
||||
return 0;
|
||||
Registers.Data=XferBuffer[BufferIndex] + (XferBuffer[BufferIndex+1]<<8);
|
||||
BufferIndex+=2;
|
||||
if (BufferIndex>=BufferLenth)
|
||||
{
|
||||
BufferIndex=0;
|
||||
BufferLenth=0;
|
||||
CurrentCommand=0;
|
||||
Registers.Status[DiskSelect]=RDY;
|
||||
Registers.Error[DiskSelect]=0;
|
||||
}
|
||||
RetVal=Registers.Data;
|
||||
break;
|
||||
case 0x1:
|
||||
RetVal=Registers.Error[DiskSelect];
|
||||
break;
|
||||
case 0x2:
|
||||
RetVal=Registers.SecCount;
|
||||
break;
|
||||
case 0x3:
|
||||
RetVal=Registers.SecNumber;
|
||||
break;
|
||||
case 0x4:
|
||||
RetVal=Registers.Cylinderlsb;
|
||||
break;
|
||||
case 0x5:
|
||||
RetVal=Registers.Cylindermsb;
|
||||
break;
|
||||
case 0x6:
|
||||
RetVal=Registers.Head;
|
||||
break;
|
||||
case 0x7:
|
||||
if (BusyCounter)
|
||||
{
|
||||
BusyCounter--;
|
||||
return BUSY;
|
||||
}
|
||||
RetVal=Registers.Status[DiskSelect];
|
||||
break;
|
||||
|
||||
default:
|
||||
RetVal=0;
|
||||
break;
|
||||
} //End port switch
|
||||
return RetVal;
|
||||
}
|
||||
|
||||
void ExecuteCommand()
|
||||
{
|
||||
CurrentCommand=Registers.Command;
|
||||
char Temp=0;
|
||||
switch (Registers.Command)
|
||||
{
|
||||
|
||||
case 0x90: //Diagnostics
|
||||
for (Temp=0;Temp<=1;Temp++)
|
||||
{
|
||||
Registers.Error[Temp]=0;
|
||||
Registers.Status[Temp]=0;
|
||||
if (hDiskFile[Temp]!=INVALID_HANDLE_VALUE)
|
||||
{
|
||||
Registers.Error[Temp]=0x01;
|
||||
Registers.Status[Temp]=0x50;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 0xEC: //Indentify Drive
|
||||
memcpy(XferBuffer,IDBlock[DiskSelect],512);
|
||||
BufferLenth=512;
|
||||
BufferIndex=0;
|
||||
Registers.Status[DiskSelect]=DRQ|RDY;
|
||||
BusyCounter=BUSYWAIT;
|
||||
break;
|
||||
|
||||
case 0x20: //Read Sectors /w Retry
|
||||
case 0x21: //Read Sectors /wo Retry
|
||||
sprintf(CurrStatus,"IDE: Rd Sec %000000.6X",Lba);
|
||||
BusyCounter=BUSYWAIT;
|
||||
BufferLenth=512;
|
||||
BufferIndex=0;
|
||||
Registers.Status[DiskSelect]=DRQ|RDY;
|
||||
SetFilePointer(hDiskFile[DiskSelect],Lba*512,nullptr,FILE_BEGIN);
|
||||
memset(XferBuffer,0,512);
|
||||
ReadFile(hDiskFile[DiskSelect],XferBuffer,512,&BytesMoved,nullptr);
|
||||
LastLba=Lba;
|
||||
|
||||
break;
|
||||
|
||||
case 0x30: //Write Sectors /w Retry
|
||||
case 0x31: //Write Sectors /wo Retry
|
||||
sprintf(CurrStatus,"IDE: Wr Sec %000000.6X",Lba);
|
||||
BusyCounter=BUSYWAIT;
|
||||
BufferLenth=512;
|
||||
BufferIndex=0;
|
||||
Registers.Status[DiskSelect]=DRQ|RDY;
|
||||
memset(XferBuffer,0,512);
|
||||
break;
|
||||
case 0x50: //Format Track
|
||||
|
||||
break;
|
||||
case 0x10: //All Recalibrate
|
||||
case 0x11:
|
||||
case 0x12:
|
||||
case 0x13:
|
||||
case 0x14:
|
||||
case 0x15:
|
||||
case 0x16:
|
||||
case 0x17:
|
||||
case 0x18:
|
||||
case 0x19:
|
||||
case 0x1A:
|
||||
case 0x1B:
|
||||
case 0x1C:
|
||||
case 0x1D:
|
||||
case 0x1E:
|
||||
case 0x1F:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ByteSwap (char *String)
|
||||
{
|
||||
int Index=0,Index2=0;
|
||||
int Lenth=strlen(String);
|
||||
char *NewString=(char*)malloc(Lenth+1);
|
||||
memset(NewString, 0, Lenth + 1);
|
||||
|
||||
for (Index=0;Index<(Lenth+1);Index++)
|
||||
if (String[Index^1])
|
||||
NewString[Index2++]=String[Index^1];
|
||||
memcpy(String,NewString,Lenth);
|
||||
free(NewString);
|
||||
return;
|
||||
}
|
||||
|
||||
HANDLE OpenDisk(const char *ImageFile,unsigned char DiskNum)
|
||||
{
|
||||
HANDLE hTemp=nullptr;
|
||||
unsigned long FileSize=0;
|
||||
unsigned long LbaSectors=0;
|
||||
char Model[41]="VCC VIRTUAL IDE DISK";
|
||||
char Firmware[9]="0.99BETA";
|
||||
char SerialNumber[21]="SERIAL NUMBER HERE";
|
||||
|
||||
|
||||
strncpy(SerialNumber,ImageFile,20);
|
||||
|
||||
hTemp=CreateFile( ImageFile,GENERIC_READ | GENERIC_WRITE,0,nullptr,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,nullptr);
|
||||
if (hTemp==INVALID_HANDLE_VALUE)
|
||||
return hTemp;
|
||||
|
||||
Registers.Status[DiskNum]=RDY;
|
||||
Registers.Error[DiskNum]=0;
|
||||
FileSize=SetFilePointer(hTemp,0,nullptr,FILE_END);
|
||||
LbaSectors=FileSize>>9;
|
||||
//Build Disk ID return Buffer
|
||||
ByteSwap(Model);
|
||||
ByteSwap(Firmware);
|
||||
ByteSwap(SerialNumber);
|
||||
memcpy (&IDBlock[DiskNum][27],Model,strlen(Model));
|
||||
memcpy (&IDBlock[DiskNum][23],Firmware,strlen(Firmware));
|
||||
memcpy (&IDBlock[DiskNum][10],SerialNumber,strlen(SerialNumber));
|
||||
IDBlock[DiskNum][01]=(unsigned short)(LbaSectors/0x1000); //Logical Cylinders
|
||||
IDBlock[DiskNum][03]=0x0010; //Logical Heads
|
||||
IDBlock[DiskNum][04]=0x2000; //Logical Bytes per Track
|
||||
IDBlock[DiskNum][05]=512; //Logical Bytes per Sector
|
||||
IDBlock[DiskNum][06]=0x0100; //Logical Sectors per Track
|
||||
IDBlock[DiskNum][20]=1; //Controller Type
|
||||
IDBlock[DiskNum][21]=1; //# of 512Byte Buffers
|
||||
IDBlock[DiskNum][49]=0x0200; //Bit 9=1 LBA Mode supported
|
||||
IDBlock[DiskNum][51]=0x0A00; //PIO Cycle Time Bits 15-8
|
||||
IDBlock[DiskNum][54]=(unsigned short)(LbaSectors/0x1000); //Cylinders
|
||||
IDBlock[DiskNum][55]=0x0010; //Number of Heads
|
||||
IDBlock[DiskNum][56]=0x0100; //Sectors per Track
|
||||
IDBlock[DiskNum][61]=(unsigned short)(LbaSectors>>16); //LBA Sectors
|
||||
IDBlock[DiskNum][60]=(unsigned short)(LbaSectors & 0xFFFF);
|
||||
return hTemp;
|
||||
}
|
||||
|
||||
void DiskStatus(char* text_buffer, size_t buffer_size)
|
||||
{
|
||||
strcpy(text_buffer,CurrStatus);
|
||||
ScanCount++;
|
||||
if (Lba != LastLba)
|
||||
{
|
||||
ScanCount=0;
|
||||
LastLba=Lba;
|
||||
}
|
||||
if (ScanCount > 63)
|
||||
{
|
||||
ScanCount=0;
|
||||
if (Mounted==1)
|
||||
strcpy(CurrStatus,"IDE:Idle");
|
||||
else
|
||||
strcpy(CurrStatus,"IDe:No Image!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
unsigned char MountDisk(const char *FileName,unsigned char DiskNumber)
|
||||
{
|
||||
if (DiskNumber>1)
|
||||
return FALSE;
|
||||
hDiskFile[DiskNumber]=OpenDisk( FileName, DiskNumber);
|
||||
if (hDiskFile[DiskNumber]==INVALID_HANDLE_VALUE)
|
||||
return FALSE;
|
||||
strcpy(FileNames[DiskNumber],FileName);
|
||||
Mounted=1;
|
||||
DLOG_C(">>>MountDisk %d %d<<<\n",DiskNumber,hDiskFile[DiskNumber]);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
unsigned char DropDisk(unsigned char DiskNumber)
|
||||
{
|
||||
DLOG_C(">>>DropDisk %d %d<<<\n",DiskNumber,hDiskFile[DiskNumber]);
|
||||
CloseHandle(hDiskFile[DiskNumber]);
|
||||
hDiskFile[DiskNumber]=INVALID_HANDLE_VALUE;
|
||||
strcpy(FileNames[DiskNumber],"");
|
||||
Mounted=0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void QueryDisk(unsigned char DiskNumber,char *Name)
|
||||
{
|
||||
strcpy(Name,FileNames[DiskNumber]);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string QueryDisk(unsigned char DiskNumber)
|
||||
{
|
||||
return FileNames[DiskNumber];
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
#ifndef __IDEBUS_H__
|
||||
#define __IDEBUS_H__
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
#include <string>
|
||||
|
||||
struct IDEINTERFACE {
|
||||
unsigned short Data;
|
||||
unsigned char Error[2];
|
||||
unsigned char SecCount;
|
||||
unsigned char SecNumber;
|
||||
unsigned char Cylinderlsb;
|
||||
unsigned char Cylindermsb;
|
||||
unsigned char Head;
|
||||
unsigned char Command;
|
||||
unsigned char Status[2];
|
||||
};
|
||||
|
||||
void IdeInit();
|
||||
void IdeRegWrite(unsigned char,unsigned short);
|
||||
unsigned short IdeRegRead(unsigned char);
|
||||
void DiskStatus(char* text_buffer, size_t buffer_size);
|
||||
unsigned char MountDisk(const char *,unsigned char );
|
||||
unsigned char DropDisk(unsigned char);
|
||||
void QueryDisk(unsigned char,char *);
|
||||
std::string QueryDisk(unsigned char);
|
||||
|
||||
//Status
|
||||
#define ERR 1 //Previous command ended in an error
|
||||
#define IDX 2 //Unused
|
||||
#define CORR 4 //Unused
|
||||
#define DRQ 8 //Data Request Ready (Sector buffer ready for transfer)
|
||||
#define DSC 16 //Unused
|
||||
#define DF 32 //Write Fault
|
||||
#define RDY 64 //Ready for command
|
||||
#define BUSY 128 //Controller is busy executing a command.
|
||||
|
||||
//Error Codes
|
||||
#define AMNF 1 //Address Mark Not found
|
||||
#define TKONF 2 //Track 0 not found
|
||||
#define ABRT 4 //(Aborted Command) Set when Command Aborted due to drive error.
|
||||
#define MCR 8 //(Media Change Request) Set to 0.
|
||||
#define IDNF 16 //(ID Not Found) Set when Sector ID not found.
|
||||
#define MC 32 //(Media Changed) Set to 0.
|
||||
#define UNC 64 //(Uncorrectable Data Error) Set when Uncorrectable Error is encountered.
|
||||
#define BBK 128 //(Bad Block Detected) Set when a Bad Block is detected.
|
||||
|
||||
|
||||
|
||||
#define BUSYWAIT 5
|
||||
|
||||
#define MASTER 0
|
||||
#define SLAVE 1
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,378 @@
|
||||
//#define USE_LOGGING
|
||||
//======================================================================
|
||||
// This file is part of VCC (Virtual Color Computer).
|
||||
// Vcc is Copyright 2015 by Joseph Forgione
|
||||
//
|
||||
// VCC (Virtual Color Computer) is free software, you can redistribute
|
||||
// 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/>.
|
||||
//
|
||||
//======================================================================
|
||||
|
||||
#include <Windows.h>
|
||||
#include "stdio.h"
|
||||
#include <iostream>
|
||||
#include "resource.h"
|
||||
#include "IdeBus.h"
|
||||
#include <vcc/devices/cloud9.h>
|
||||
#include <vcc/util/FileOps.h>
|
||||
#include <vcc/util/DialogOps.h>
|
||||
#include <vcc/bus/cpak_cartridge_definitions.h>
|
||||
#include <vcc/util/limits.h>
|
||||
#include <vcc/util/logger.h>
|
||||
#include <vcc/bus/cartridge_menu.h>
|
||||
#include <vcc/bus/cartridge_messages.h>
|
||||
#include <vcc/util/fileutil.h>
|
||||
#include <vcc/util/settings.h>
|
||||
|
||||
static char FileName[MAX_PATH] { 0 };
|
||||
static char SuperIDEPath[MAX_PATH];
|
||||
static ::VCC::Device::rtc::cloud9 cloud9_rtc;
|
||||
static unsigned char BaseAddress=0x50;
|
||||
LRESULT CALLBACK IDE_Config(HWND, UINT, WPARAM, LPARAM );
|
||||
void Select_Disk(unsigned char);
|
||||
void SaveConfig();
|
||||
void LoadConfig();
|
||||
unsigned char BaseTable[4]={0x40,0x50,0x60,0x70};
|
||||
bool get_menu_item(menu_item_entry*, size_t index);
|
||||
|
||||
static unsigned char BaseAddr=1;
|
||||
static int ClockEnabled = 1;
|
||||
static int ClockReadOnly = 1;
|
||||
static unsigned char DataLatch=0;
|
||||
static HINSTANCE gModuleInstance;
|
||||
static HWND hConfDlg = nullptr;
|
||||
static slot_id_type gSlotId {};
|
||||
|
||||
static HWND gVccWnd = nullptr;
|
||||
|
||||
using namespace std;
|
||||
|
||||
// Access the settings object
|
||||
static VCC::Util::settings* gpSettings = nullptr;
|
||||
VCC::Util::settings& Setting() {return *gpSettings;}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
extern "C"
|
||||
{
|
||||
|
||||
__declspec(dllexport) const char* PakGetName()
|
||||
{
|
||||
static char string_buffer[MAX_LOADSTRING];
|
||||
|
||||
LoadString(gModuleInstance, IDS_MODULE_NAME, string_buffer, MAX_LOADSTRING);
|
||||
|
||||
return string_buffer;
|
||||
}
|
||||
|
||||
__declspec(dllexport) const char* PakGetCatalogId()
|
||||
{
|
||||
static char string_buffer[MAX_LOADSTRING];
|
||||
|
||||
LoadString(gModuleInstance, IDS_CATNUMBER, string_buffer, MAX_LOADSTRING);
|
||||
|
||||
return string_buffer;
|
||||
}
|
||||
|
||||
__declspec(dllexport) const char* PakGetDescription()
|
||||
{
|
||||
static char string_buffer[MAX_LOADSTRING];
|
||||
|
||||
LoadString(gModuleInstance, IDS_DESCRIPTION, string_buffer, MAX_LOADSTRING);
|
||||
|
||||
return string_buffer;
|
||||
}
|
||||
|
||||
__declspec(dllexport) void PakInitialize(
|
||||
slot_id_type SlotId,
|
||||
const char* const configuration_path,
|
||||
HWND hVccWnd,
|
||||
const cpak_callbacks* const callbacks)
|
||||
{
|
||||
gSlotId = SlotId;
|
||||
gVccWnd = hVccWnd;
|
||||
gpSettings = new VCC::Util::settings(configuration_path);
|
||||
|
||||
LoadConfig();
|
||||
IdeInit();
|
||||
//SendMessage(gVccWnd,WM_COMMAND,(WPARAM) IDC_MSG_UPD_MENU,(LPARAM) 0);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void PakTerminate()
|
||||
{
|
||||
CloseCartDialog(hConfDlg);
|
||||
hConfDlg = nullptr;
|
||||
}
|
||||
|
||||
__declspec(dllexport) void PakWritePort(unsigned char Port,unsigned char Data)
|
||||
{
|
||||
if ( (Port >=BaseAddress) & (Port <= (BaseAddress+8)))
|
||||
switch (Port-BaseAddress)
|
||||
{
|
||||
case 0x0:
|
||||
IdeRegWrite(Port-BaseAddress,(DataLatch<<8)+ Data );
|
||||
break;
|
||||
|
||||
case 0x8:
|
||||
DataLatch=Data & 0xFF; //Latch
|
||||
break;
|
||||
|
||||
default:
|
||||
IdeRegWrite(Port-BaseAddress,Data);
|
||||
break;
|
||||
} //End port switch
|
||||
return;
|
||||
}
|
||||
|
||||
__declspec(dllexport) unsigned char PakReadPort(unsigned char Port)
|
||||
{
|
||||
unsigned char RetVal=0;
|
||||
unsigned short Temp=0;
|
||||
if (((Port == 0x78) || (Port == 0x79) || (Port == 0x7C)) && ClockEnabled)
|
||||
RetVal = cloud9_rtc.read_port(Port);
|
||||
|
||||
if ( (Port >=BaseAddress) & (Port <= (BaseAddress+8)))
|
||||
switch (Port-BaseAddress)
|
||||
{
|
||||
case 0x0:
|
||||
Temp=IdeRegRead(Port-BaseAddress);
|
||||
|
||||
RetVal=Temp & 0xFF;
|
||||
DataLatch= Temp>>8;
|
||||
break;
|
||||
|
||||
case 0x8:
|
||||
RetVal=DataLatch; //Latch
|
||||
break;
|
||||
default:
|
||||
RetVal=IdeRegRead(Port-BaseAddress)& 0xFF;
|
||||
break;
|
||||
|
||||
} //End port switch
|
||||
|
||||
return RetVal;
|
||||
}
|
||||
|
||||
__declspec(dllexport) void PakGetStatus(char* text_buffer, size_t buffer_size)
|
||||
{
|
||||
DiskStatus(text_buffer, buffer_size);
|
||||
}
|
||||
|
||||
|
||||
//PakGetMenuItem export
|
||||
__declspec(dllexport) bool PakGetMenuItem(menu_item_entry* item, size_t index)
|
||||
{
|
||||
return get_menu_item(item, index);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void PakMenuItemClicked(unsigned char MenuID)
|
||||
{
|
||||
switch (MenuID)
|
||||
{
|
||||
case 10:
|
||||
Select_Disk(MASTER);
|
||||
SaveConfig();
|
||||
SendMessage(gVccWnd,WM_VCC_UPD_MENU,(WPARAM) 0,(LPARAM) 0);
|
||||
break;
|
||||
|
||||
case 11:
|
||||
DropDisk(MASTER);
|
||||
SaveConfig();
|
||||
SendMessage(gVccWnd,WM_VCC_UPD_MENU,(WPARAM) 0,(LPARAM) 0);
|
||||
break;
|
||||
|
||||
case 12:
|
||||
Select_Disk(SLAVE);
|
||||
SaveConfig();
|
||||
SendMessage(gVccWnd,WM_VCC_UPD_MENU,(WPARAM) 0,(LPARAM) 0);
|
||||
break;
|
||||
|
||||
case 13:
|
||||
DropDisk(SLAVE);
|
||||
SaveConfig();
|
||||
SendMessage(gVccWnd,WM_VCC_UPD_MENU,(WPARAM) 0,(LPARAM) 0);
|
||||
break;
|
||||
|
||||
case 14:
|
||||
CreateDialog( gModuleInstance, (LPCTSTR) IDD_CONFIG,
|
||||
GetActiveWindow(), (DLGPROC) IDE_Config );
|
||||
ShowWindow(hConfDlg,1);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(
|
||||
HINSTANCE hinstDLL,
|
||||
DWORD reason,
|
||||
LPVOID /*lpReserved*/ )
|
||||
{
|
||||
switch (reason) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
gModuleInstance = hinstDLL;
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
PakTerminate();
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Added for PakGetMenuItem export
|
||||
// Return items for cartridge menu. Called for each item
|
||||
bool get_menu_item(menu_item_entry* item, size_t index)
|
||||
{
|
||||
using VCC::Bus::gDllCartMenu;
|
||||
std::string disk;
|
||||
if (!item) return false;
|
||||
// request zero rebuilds the menu list
|
||||
if (index == 0) {
|
||||
gDllCartMenu.clear();
|
||||
gDllCartMenu.add("", 0, MIT_Seperator);
|
||||
gDllCartMenu.add("IDE Master",0,MIT_Head);
|
||||
gDllCartMenu.add("Insert",ControlId(10),MIT_Slave);
|
||||
disk = VCC::Util::GetFileNamePart(QueryDisk(MASTER));
|
||||
gDllCartMenu.add("Eject: "+disk,ControlId(11),MIT_Slave);
|
||||
gDllCartMenu.add("IDE Slave",0,MIT_Head);
|
||||
gDllCartMenu.add("Insert",ControlId(12),MIT_Slave);
|
||||
disk = VCC::Util::GetFileNamePart(QueryDisk(SLAVE));
|
||||
gDllCartMenu.add("Eject: "+disk,ControlId(13),MIT_Slave);
|
||||
gDllCartMenu.add("IDE Config",ControlId(14),MIT_StandAlone);
|
||||
}
|
||||
// return requested list item or false
|
||||
return gDllCartMenu.copy_item(*item, index);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK IDE_Config(HWND hDlg, UINT message, WPARAM wParam, LPARAM /*lParam*/)
|
||||
{
|
||||
unsigned char BTemp=0;
|
||||
switch (message)
|
||||
{
|
||||
case WM_CLOSE:
|
||||
DestroyWindow(hDlg);
|
||||
hConfDlg=nullptr;
|
||||
return TRUE;
|
||||
break;
|
||||
|
||||
case WM_INITDIALOG:
|
||||
hConfDlg=hDlg;
|
||||
SendDlgItemMessage(hDlg, IDC_CLOCK, BM_SETCHECK, ClockEnabled, 0);
|
||||
SendDlgItemMessage(hDlg, IDC_READONLY, BM_SETCHECK, ClockReadOnly, 0);
|
||||
SendDlgItemMessage(hDlg,IDC_BASEADDR, CB_ADDSTRING, 0, (LPARAM) "40");
|
||||
SendDlgItemMessage(hDlg,IDC_BASEADDR, CB_ADDSTRING, 0, (LPARAM) "50");
|
||||
SendDlgItemMessage(hDlg,IDC_BASEADDR, CB_ADDSTRING, 0, (LPARAM) "60");
|
||||
SendDlgItemMessage(hDlg,IDC_BASEADDR, CB_ADDSTRING, 0, (LPARAM) "70");
|
||||
SendDlgItemMessage(hDlg,IDC_BASEADDR, CB_SETCURSEL,BaseAddr,(LPARAM)0);
|
||||
EnableWindow(GetDlgItem(hDlg, IDC_CLOCK), TRUE);
|
||||
if (BaseAddr==3)
|
||||
{
|
||||
ClockEnabled = 0;
|
||||
SendDlgItemMessage(hDlg,IDC_CLOCK,BM_SETCHECK,ClockEnabled,0);
|
||||
EnableWindow(GetDlgItem(hDlg, IDC_CLOCK), FALSE);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
BaseAddr=(unsigned char)SendDlgItemMessage(
|
||||
hDlg,IDC_BASEADDR,CB_GETCURSEL,0,0);
|
||||
ClockEnabled = SendDlgItemMessage( hDlg, IDC_CLOCK, BM_GETCHECK, 0, 0);
|
||||
ClockReadOnly = SendDlgItemMessage( hDlg, IDC_READONLY, BM_GETCHECK, 0, 0);
|
||||
BaseAddress=BaseTable[BaseAddr & 3];
|
||||
cloud9_rtc.set_read_only(ClockReadOnly);
|
||||
SaveConfig();
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
|
||||
break;
|
||||
|
||||
case IDCANCEL:
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
break;
|
||||
|
||||
case IDC_CLOCK:
|
||||
|
||||
break;
|
||||
|
||||
case IDC_READONLY:
|
||||
break;
|
||||
|
||||
case IDC_BASEADDR:
|
||||
BTemp=(unsigned char)SendDlgItemMessage(hDlg,IDC_BASEADDR,CB_GETCURSEL,0,0);
|
||||
EnableWindow(GetDlgItem(hDlg, IDC_CLOCK), TRUE);
|
||||
if (BTemp==3)
|
||||
{
|
||||
ClockEnabled = 0;
|
||||
SendDlgItemMessage(hDlg,IDC_CLOCK,BM_SETCHECK,ClockEnabled,0);
|
||||
EnableWindow(GetDlgItem(hDlg, IDC_CLOCK), FALSE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Select_Disk(unsigned char Disk)
|
||||
{
|
||||
FileDialog dlg;
|
||||
dlg.setDefExt("IMG");
|
||||
dlg.setTitle("Mount IDE hard Disk Image");
|
||||
dlg.setFilter("Hard Disk Images\0*.img;*.vhd;*.os9\0All files\0*.*\0\0");
|
||||
dlg.setInitialDir(SuperIDEPath);
|
||||
if (dlg.show()) {
|
||||
if (MountDisk(dlg.path(),Disk)) {
|
||||
dlg.getdir(SuperIDEPath);
|
||||
} else {
|
||||
MessageBox(GetActiveWindow(),"Can't Open Image","Error",0);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void SaveConfig()
|
||||
{
|
||||
const char* ModName="SuperIDE";
|
||||
QueryDisk(MASTER,FileName);
|
||||
Setting().write(ModName,"Master",FileName);
|
||||
QueryDisk(SLAVE,FileName);
|
||||
Setting().write(ModName,"Slave",FileName);
|
||||
Setting().write(ModName,"BaseAddr",BaseAddr);
|
||||
Setting().write(ModName,"ClkEnable", ClockEnabled);
|
||||
Setting().write(ModName, "ClkRdOnly", ClockReadOnly);
|
||||
if (strcmp(SuperIDEPath, "") != 0) {
|
||||
Setting().write("DefaultPaths", "SuperIDEPath", SuperIDEPath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void LoadConfig()
|
||||
{
|
||||
const char* ModName="SuperIDE";
|
||||
Setting().read("DefaultPaths", "SuperIDEPath", "", SuperIDEPath, MAX_PATH);
|
||||
Setting().read(ModName,"Master","",FileName,MAX_PATH);
|
||||
MountDisk(FileName ,MASTER);
|
||||
Setting().read(ModName,"Slave","",FileName,MAX_PATH);
|
||||
BaseAddr=Setting().read(ModName,"BaseAddr",1);
|
||||
ClockEnabled = Setting().read(ModName, "ClkEnable", 1);
|
||||
ClockReadOnly = Setting().read(ModName, "ClkRdOnly", 1);
|
||||
BaseAddr&=3;
|
||||
if (BaseAddr == 3)
|
||||
ClockEnabled = 0;
|
||||
BaseAddress=BaseTable[BaseAddr];
|
||||
cloud9_rtc.set_read_only(ClockReadOnly);
|
||||
MountDisk(FileName ,SLAVE);
|
||||
SendMessage(gVccWnd,WM_VCC_UPD_MENU,(WPARAM) 0,(LPARAM) 0);
|
||||
return;
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,162 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 2,1,8,3
|
||||
PRODUCTVERSION 2,1,8,3
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x21L
|
||||
#else
|
||||
FILEFLAGS 0x20L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "Comments", "SuperIDE Disk Controller\0"
|
||||
VALUE "CompanyName", "BitRot Software.\0"
|
||||
VALUE "FileDescription", "SuperIDE\0"
|
||||
VALUE "FileVersion", "2.1.8.3\0"
|
||||
VALUE "InternalName", "SuperIDE\0"
|
||||
VALUE "LegalCopyright", "Copyright � 2010\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "OriginalFilename", "SuperIDE.dll\0"
|
||||
VALUE "PrivateBuild", "\0"
|
||||
VALUE "ProductName", "Vcc Module file\0"
|
||||
VALUE "ProductVersion", "2.1.8.3\0"
|
||||
VALUE "SpecialBuild", "SuperIDE Disk Controller\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // !_MAC
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_CONFIG DIALOG DISCARDABLE 0, 0, 164, 52
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "IDE Drive Configuration"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,107,7,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,107,25,50,14
|
||||
COMBOBOX IDC_BASEADDR,71,7,28,41,CBS_DROPDOWNLIST | CBS_SORT |
|
||||
CBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Base Address 0xFF",IDC_STATIC,9,9,62,8
|
||||
CONTROL "Clock at 0xFF70",IDC_CLOCK,"Button",BS_AUTOCHECKBOX |
|
||||
WS_TABSTOP,7,24,66,10
|
||||
CONTROL "Clock is Read-Only",IDC_READONLY,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,7,35,81,10
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_CONFIG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 157
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 45
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_MODULE_NAME "Glenside-IDE /w Clock"
|
||||
IDS_CATNUMBER "000"
|
||||
IDS_DESCRIPTION "Emulates Glenside IDE disk device. It supports a master and a slave IDE disk image. Also contains a Dallas DS1315 real time clock."
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Legacy|Win32">
|
||||
<Configuration>Legacy</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<SccProjectName />
|
||||
<SccLocalPath />
|
||||
<ProjectGuid>{95713490-9812-4348-9E5E-818F736A271A}</ProjectGuid>
|
||||
<ProjectName>superide</ProjectName>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\vcc-base.props" />
|
||||
<Import Project="..\vcc-debug.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\vcc-base.props" />
|
||||
<Import Project="..\vcc-legacy.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\vcc-base.props" />
|
||||
<Import Project="..\vcc-release.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">
|
||||
<LibraryPath>C:\Program Files %28x86%29\Windows Kits\8.1\Lib\winv6.3\um\x86;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_USRDLL;SUPERIDE_EXPORTS;_LEGACY_VCC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalOptions>/arch:SSE</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<LinkDLL>true</LinkDLL>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;SUPERIDE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalOptions>/arch:SSE</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<ResourceCompile />
|
||||
<Link>
|
||||
<LinkDLL>true</LinkDLL>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;SUPERIDE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ResourceCompile />
|
||||
<Link>
|
||||
<LinkDLL>true</LinkDLL>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="IdeBus.cpp" />
|
||||
<ClCompile Include="SuperIDE.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="IdeBus.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="SuperIDE.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="SuperIDE.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\libcommon\libcommon.vcxproj">
|
||||
<Project>{e0aa25bd-5527-475f-8d8b-b549a6311b0c}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,23 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by SuperIDE.rc
|
||||
//
|
||||
#define IDS_MODULE_NAME 1
|
||||
#define IDS_CATNUMBER 2
|
||||
#define IDS_DESCRIPTION 3
|
||||
#define IDD_DIALOG1 101
|
||||
#define IDD_CONFIG 101
|
||||
#define IDC_BASEADDR 1000
|
||||
#define IDC_CLOCK 1001
|
||||
#define IDC_READONLY 1002
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1003
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,33 @@
|
||||
//======================================================================
|
||||
// This file is part of VCC (Virtual Color Computer).
|
||||
// Vcc is Copyright 2015 by Joseph Forgione
|
||||
//
|
||||
// VCC (Virtual Color Computer) is free software, you can redistribute
|
||||
// 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/>.
|
||||
//======================================================================
|
||||
|
||||
// Vcc.h callable functions exposed to the rest of vcc core
|
||||
|
||||
#pragma once
|
||||
|
||||
void SetCPUMultiplyerFlag (unsigned char); //tcc1014registers.cpp
|
||||
void SetTurboMode(unsigned char); //tcc1014registers.cpp
|
||||
unsigned char SetCPUMultiplyer(unsigned char); //tcc1014registers.cpp, config.cpp
|
||||
unsigned char SetRamSize(unsigned char); //config.cpp
|
||||
unsigned char SetSpeedThrottle(unsigned char); //config.cpp, keyboard.cpp
|
||||
unsigned char SetFrameSkip(unsigned char); //config.cpp
|
||||
unsigned char SetCpuType( unsigned char); //config.cpp
|
||||
unsigned char SetAutoStart(unsigned char); //config.cpp
|
||||
void DoReboot(); //config.cpp
|
||||
|
||||
@@ -0,0 +1,859 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (United States) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
IDR_MENU MENU
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&Run", ID_FILE_RUN
|
||||
MENUITEM "&Save Config", ID_SAVE_CONFIG
|
||||
MENUITEM "&Load Config", ID_FILE_LOAD
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Hard Reset [F9]", ID_FILE_RESET
|
||||
MENUITEM "S&oft Reset [F5]", ID_FILE_RESET_SFT
|
||||
MENUITEM "&Pause [F7]", ID_PAUSE_EMULATION
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", ID_FILE_EXIT
|
||||
END
|
||||
POPUP "&Edit"
|
||||
BEGIN
|
||||
MENUITEM "&Copy Text", ID_COPY_TEXT
|
||||
MENUITEM "&Paste Text", ID_PASTE_TEXT
|
||||
MENUITEM "Paste &Merge BASIC code", ID_PASTE_BASIC
|
||||
MENUITEM "Paste &New BASIC code", ID_PASTE_BASIC_NEW
|
||||
END
|
||||
POPUP "C&onfiguration"
|
||||
BEGIN
|
||||
MENUITEM "&Flip Artifact Colors", ID_FLIP_ARTIFACTS
|
||||
MENUITEM "&Swap Joysticks", ID_SWAP_JOYSTICKS
|
||||
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Audio", ID_AUDIO_CONFIG
|
||||
MENUITEM "&Cpu", ID_CPU_CONFIG
|
||||
MENUITEM "&Display", ID_DISPLAY_CONFIG
|
||||
MENUITEM "&Keyboard", ID_KEYBOARD_CONFIG
|
||||
MENUITEM "&JoySticks", ID_JOYSTICKS_CONFIG
|
||||
MENUITEM "&Tape", ID_TAPE_CONFIG
|
||||
MENUITEM "&BitBanger", ID_BITBANGER_CONFIG
|
||||
|
||||
END
|
||||
// Dummy place holder for Cartrige menu, drawn after carts load
|
||||
POPUP "&Cartridge"
|
||||
BEGIN
|
||||
MENUITEM "Cartridge" ID_CARTS_LOAD
|
||||
END
|
||||
POPUP "&Debugger"
|
||||
BEGIN
|
||||
MENUITEM "&Memory Display", ID_MEMORY_DISPLAY
|
||||
MENUITEM "&Processor State", ID_PROCESSOR_STATE
|
||||
MENUITEM "&Disassembler", ID_DISASSEMBLER
|
||||
MENUITEM "&Source Debugger", ID_BREAKPOINTS
|
||||
MENUITEM "MMU M&onitor", ID_MMU_MONITOR
|
||||
MENUITEM "Execution &Trace", ID_EXEC_TRACE
|
||||
END
|
||||
POPUP "&Help", HELP
|
||||
BEGIN
|
||||
MENUITEM "&About Vcc", IDM_HELP_ABOUT
|
||||
MENUITEM "&Function Keys", IDM_HELP_FUNKEY
|
||||
MENUITEM "&User Guide", IDM_USER_WIKI
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_COCO3 ICON "resources\\icon1.ico"
|
||||
|
||||
IDI_BINFILE ICON "resources\\binfile.ico"
|
||||
|
||||
IDI_CART ICON "resources\\progpack.ico"
|
||||
|
||||
IDI_MOTO ICON "resources\\moto.ico"
|
||||
|
||||
IDI_HITACHI2 ICON "resources\\hitachi.ico"
|
||||
|
||||
IDI_RGB ICON "resources\\rgb.ico"
|
||||
|
||||
IDI_COMPOSITE ICON "resources\\composite.ico"
|
||||
|
||||
IDI_AUDIO ICON "resources\\ico00004.ico"
|
||||
|
||||
IDI_KEYBOARD ICON "resources\\Keyboard.ico"
|
||||
|
||||
IDI_JOYSTICK ICON "resources\\joystick.ico"
|
||||
|
||||
IDI_MOUSE ICON "resources\\mouse.ico"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_ABOUTBOX DIALOGEX 0, 0, 232, 345
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "About"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x1
|
||||
BEGIN
|
||||
CONTROL IDB_VCC,IDC_STATIC,"Static",SS_BITMAP | SS_REALSIZEIMAGE,8,5,217,45
|
||||
CONTROL IDB_3GUYS,IDC_STATIC,"Static",SS_BITMAP | SS_CENTERIMAGE,16,53,77,57,WS_EX_DLGMODALFRAME
|
||||
LTEXT "VCC Version 2.1.10.0",IDC_STATIC,114,65,85,10
|
||||
LTEXT "Another classic computer canceled before it's time!",IDC_STATIC,114,80,85,20
|
||||
LTEXT "Copyright 2015 By Joseph Forgione",IDC_STATIC,8,120,120,15
|
||||
LTEXT "VCC (Virtual Color Computer) is free software: you can redistribute 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.",IDC_STATIC,8,135,210,35
|
||||
LTEXT "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.",IDC_STATIC,8,172,210,35
|
||||
LTEXT "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/.",IDC_STATIC,8,210,215,40
|
||||
LTEXT "VCC Repository and Release Packages maintained by Bill Pierce and Ed Jaquay.",IDC_STATIC,8,250,206,20
|
||||
LTEXT "Adapted to Visual Studio by Gary Coulbourne and Wes Gale. Hitachi 6309 port by Walter Zambotti.",IDC_STATIC,8,270,206,20
|
||||
LTEXT "Bug fixes and Enhancements by Bill Pierce, James Ross, Peter Westberg, James Rye, EJ Jaquay, Mike Rojas, Trey Tomes and Craig Allsop. ",IDC_STATIC,8,290,206,30
|
||||
DEFPUSHBUTTON "OK",IDOK,175,320,50,14
|
||||
END
|
||||
|
||||
IDD_FUNCTION_KEYS DIALOGEX 0,0,166,145
|
||||
STYLE DS_CENTERMOUSE | DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Function Keys"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x1
|
||||
BEGIN
|
||||
GROUPBOX "",IDC_STATIC,3,2,160,121,BS_CENTER
|
||||
LTEXT "Unmodified",IDC_STATIC,30,8,50,10
|
||||
LTEXT " F3 Decrease Overclock", IDC_STATIC,5,20,85,10
|
||||
LTEXT " F4 Increase Overclock", IDC_STATIC,5,30,85,10
|
||||
LTEXT " F5 Soft Reset", IDC_STATIC,5,40,85,10
|
||||
LTEXT " F6 RGB Toggle", IDC_STATIC,5,50,85,10
|
||||
LTEXT " F7 Pause Toggle" IDC_STATIC,5,60,85,10
|
||||
LTEXT " F8 Toggle Throttle", IDC_STATIC,5,70,85,10
|
||||
LTEXT " F9 Stop/Start reset", IDC_STATIC,5,80,85,10
|
||||
LTEXT "F10 FS Cart Menu", IDC_STATIC,5,90,85,10
|
||||
LTEXT "F11 Toggle Fullscreen", IDC_STATIC,5,100,85,10
|
||||
LTEXT "F12 Function Keys", IDC_STATIC,5,110,85,10
|
||||
LTEXT "Shifted", IDC_STATIC,110,8,50,10
|
||||
LTEXT "---", IDC_STATIC,115,20,40,10
|
||||
LTEXT "---", IDC_STATIC,115,30,40,10
|
||||
LTEXT "Hard Reset", IDC_STATIC,100,40,60,10
|
||||
LTEXT "Flip Artifacts", IDC_STATIC,100,50,60,10
|
||||
LTEXT "Swap Joysticks", IDC_STATIC,100,60,60,10
|
||||
LTEXT "Overclock Toggle", IDC_STATIC,100,70,60,10
|
||||
LTEXT "---", IDC_STATIC,115,80,40,10
|
||||
LTEXT "FS Config Menu", IDC_STATIC,100,90,60,10
|
||||
LTEXT "FS Toggle Status", IDC_STATIC,100,100,60,10
|
||||
LTEXT "Take Screenshot", IDC_STATIC,100,110,60,10
|
||||
DEFPUSHBUTTON "OK",IDOK,57,126,50,15
|
||||
END
|
||||
|
||||
IDD_DISPLAY DIALOGEX 0, 0, 254, 220
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Display Configuration"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x1
|
||||
BEGIN
|
||||
GROUPBOX "[F6] Monitor Type",IDC_STATIC,16,12,112,63,BS_CENTER
|
||||
ICON "",IDC_MONTYPE,98,23,21,20
|
||||
RADIOBUTTON "RGB",IDC_RGB,23,23,31,10
|
||||
RADIOBUTTON "Composite",IDC_COMPOSITE,23,37,49,10
|
||||
RADIOBUTTON "Updated Palette",IDC_UPD_PALETTE,33,48,70,11
|
||||
RADIOBUTTON "NTSC Palette", IDC_NTSC5_PALETTE, 33, 60, 70, 11
|
||||
|
||||
GROUPBOX "Frame Skip",IDC_STATIC,16,80,222,35,BS_CENTER
|
||||
CONTROL "Slider1",IDC_FRAMESKIP,"msctls_trackbar32",TBS_TOP | TBS_NOTICKS | WS_TABSTOP,20,92,177,15,WS_EX_CLIENTEDGE
|
||||
EDITTEXT IDC_FRAMEDISPLAY,200,93,33,15,ES_AUTOHSCROLL | ES_READONLY
|
||||
|
||||
CONTROL "Scan Lines",IDC_SCANLINES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,128,70,10
|
||||
CONTROL "Force Aspect",IDC_ASPECT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,141,70,10
|
||||
CONTROL "Remember Size and Position",IDC_REMEMBER_SIZE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,95,128,110,10
|
||||
CONTROL "[F8] Throttle Speed",IDC_THROTTLE,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,95,141,110,10
|
||||
|
||||
CTEXT "WARNING: Unchecking the ""Throttle Speed"" can greatly affect many functions of the VCC emulation including keyboard operation. Use with CAUTION! Please use ""Over-Clocking"" instead",IDC_STATIC,16,160,220,28,SS_SUNKEN,WS_EX_STATICEDGE
|
||||
|
||||
DEFPUSHBUTTON "OK",IDOK,75,200,36,14
|
||||
PUSHBUTTON "Apply",IDAPPLY,120,200,36,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,165,200,36,14
|
||||
END
|
||||
|
||||
IDD_CPU DIALOGEX 0, 0, 268, 220
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "CPU Configuration"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x1
|
||||
BEGIN
|
||||
GROUPBOX "Over-Clocking",IDC_STATIC,16,12,234,36,BS_CENTER
|
||||
CONTROL "",IDC_OVERCLOCK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,28,10,10
|
||||
CONTROL "Slider1",IDC_CLOCKSPEED,"msctls_trackbar32",TBS_TOP | TBS_NOTICKS | WS_TABSTOP,35,26,160,15,WS_EX_CLIENTEDGE
|
||||
EDITTEXT IDC_CLOCKDISPLAY,199,27,45,12,ES_AUTOHSCROLL | ES_READONLY
|
||||
GROUPBOX "Memory Size",IDC_STATIC,17,58,60,54,BS_CENTER
|
||||
RADIOBUTTON "128 K",IDC_128K,27,69,35,10
|
||||
RADIOBUTTON "512 K",IDC_512K,27,79,35,10
|
||||
RADIOBUTTON "2048 K",IDC_2M,27,90,39,10
|
||||
RADIOBUTTON "8192 K",IDC_8M,27,101,39,10
|
||||
GROUPBOX "CPU",IDC_STATIC,87,63,154,45,BS_CENTER
|
||||
RADIOBUTTON "Motorola MC6809 CPU",IDC_6809,97,74,89,10
|
||||
RADIOBUTTON "Hitachi HD6309 CPU",IDC_6309,97,88,87,10,WS_TABSTOP
|
||||
ICON "",IDC_CPUICON,207,77,21,20
|
||||
GROUPBOX "VCC Debug",IDC_STATIC,16,120,110,34,BS_CENTER
|
||||
CONTROL "Enable BREAK ($113E)",IDC_ENABLE_BREAK,"Button",BS_AUTOCHECKBOX|WS_TABSTOP,25,133,90,10
|
||||
GROUPBOX "Auto Start",IDC_STATIC,142,114,98,40,BS_CENTER
|
||||
CONTROL "Auto Start Emulation",IDC_AUTOSTART,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,154,126,80,10
|
||||
CONTROL "Auto Start Cartridge",IDC_AUTOCART,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,154,138,80,10
|
||||
GROUPBOX "Alt Basic Rom",IDC_STATIC,14,160,228,31,BS_CENTER
|
||||
CONTROL "",IDC_USE_EXTROM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,173,10,10
|
||||
EDITTEXT IDC_ROMPATH,34,172,160,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP
|
||||
PUSHBUTTON "Browse",IDC_BROWSE,200,170,35,16
|
||||
DEFPUSHBUTTON "OK",IDOK,65,198,36,14
|
||||
PUSHBUTTON "Apply",IDAPPLY,115,198,36,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,165,198,36,14
|
||||
END
|
||||
|
||||
IDD_AUDIO DIALOGEX 0, 0, 210,110
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Audio Configuration"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x0
|
||||
BEGIN
|
||||
GROUPBOX "Sound",IDC_STATIC,9,2,185,80,BS_CENTER
|
||||
LTEXT "Output device",IDC_STATIC,26,15,46,8
|
||||
CONTROL "Mute",IDC_MUTE,"Button",BS_AUTOCHECKBOX,85,15,50,10
|
||||
//COMBOBOX IDC_RATE,27,49,92,58,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
//LTEXT "Sound Quality",IDC_STATIC,28,39,57,8
|
||||
COMBOBOX IDC_SOUNDCARD,25,28,140,200,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "L",IDC_STATIC,25,50,5,7
|
||||
LTEXT "R",IDC_STATIC,25,60,5,7
|
||||
CONTROL "Progress1",IDC_PROGRESSLEFT,"msctls_progress32",PBS_SMOOTH,35,51,120,7
|
||||
CONTROL "Progress1",IDC_PROGRESSRIGHT,"msctls_progress32",PBS_SMOOTH,35,61,120,7
|
||||
DEFPUSHBUTTON "OK",IDOK,50,90,36,14
|
||||
PUSHBUTTON "Apply",IDAPPLY,90,90,36,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,130,90,36,14
|
||||
END
|
||||
|
||||
IDD_INPUT DIALOGEX 0, 0, 280, 195
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Keyboard Configuration"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x0
|
||||
BEGIN
|
||||
GROUPBOX "Select Keyboard Mapping",IDC_STATIC,7,13,264,64,BS_CENTER
|
||||
RADIOBUTTON "CoCo:",IDC_KEYMAP_COCO,22,23,42,12
|
||||
RADIOBUTTON "Natural:",IDC_KEYMAP_NATURAL,22,35,42,12
|
||||
RADIOBUTTON "Compact:",IDC_KEYMAP_COMPACT,22,47,42,12
|
||||
RADIOBUTTON "Custom:",IDC_KEYMAP_CUSTOM,22,59,42,12
|
||||
LTEXT "Layout resembles the Coco keyboard. (DECB)",IDC_STATIC,67,24,180,12
|
||||
LTEXT "Standard PC keyboard layout.(OS-9)",IDC_STATIC,67,37,180,12
|
||||
LTEXT "Natural PC layout with no number pad.",IDC_STATIC,67,49,180,12
|
||||
LTEXT "User designed custom keyboard layout.",IDC_STATIC,67,61,180,12
|
||||
|
||||
GROUPBOX "Configure Custom Keyboard",IDC_STATIC,7,90,264,68,BS_CENTER
|
||||
PUSHBUTTON "Choose File",IDC_SELECT_KEYMAP,13,103,50,16,BS_MULTILINE
|
||||
CTEXT "",IDC_KEYMAP_FILE,69,106,193,10,SS_NOPREFIX | SS_PATHELLIPSIS,WS_EX_STATICEDGE
|
||||
PUSHBUTTON "EDIT",IDC_KEYMAPED,13,130,50,14
|
||||
LTEXT "Choosing a new file clones the previously selected mapping.\nEdit selects custom and runs the graphical keymap editor.",IDC_STATIC,68,130,190,25
|
||||
|
||||
DEFPUSHBUTTON "OK",IDOK,85,170,36,14
|
||||
PUSHBUTTON "Apply",IDAPPLY,125,170,36,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,165,170,36,14
|
||||
END
|
||||
|
||||
IDD_JOYSTICK DIALOGEX 0, 0, 268, 250
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Joystick Configuration"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x0
|
||||
BEGIN
|
||||
GROUPBOX "Left Joystick",IDC_STATIC,6,6,126,213,BS_CENTER
|
||||
GROUPBOX "Right Joystick",IDC_STATIC,135,6,126,213,BS_CENTER
|
||||
RADIOBUTTON "Audio",IDC_LEFTAUDIO,11,19,34,10,WS_DISABLED
|
||||
RADIOBUTTON "Joystick",IDC_LEFTJOYSTICK,11,34,41,10
|
||||
RADIOBUTTON "Mouse",IDC_LEFT_USEMOUSE,11,48,37,10
|
||||
RADIOBUTTON "Keyboard",IDC_LEFT_KEYBOARD,11,61,46,10
|
||||
RADIOBUTTON "Audio",IDC_RIGHTAUDIO,141,19,34,10,WS_DISABLED
|
||||
RADIOBUTTON "Joystick",IDC_RIGHTJOYSTICK,141,34,41,10
|
||||
RADIOBUTTON "Mouse",IDC_RIGHT_USEMOUSE,141,48,37,10
|
||||
RADIOBUTTON "Keyboard",IDC_RIGHT_KEYBOARD,141,61,46,10
|
||||
COMBOBOX IDC_LEFTAUDIODEVICE,52,17,75,57,CBS_DROPDOWNLIST | WS_DISABLED | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_LEFTJOYSTICKDEVICE,52,33,75,56,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_RIGHTAUDIODEVICE,181,17,75,57,CBS_DROPDOWNLIST | WS_DISABLED | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_RIGHTJOYSTICKDEVICE,181,33,75,56,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Left",IDC_STATIC,60,62,13,8
|
||||
LTEXT "Right",IDC_STATIC,56,77,18,8
|
||||
LTEXT "Up",IDC_STATIC,64,92,10,8
|
||||
LTEXT "Down",IDC_STATIC,54,107,20,8
|
||||
LTEXT "Fire 1",IDC_STATIC,56,121,18,8
|
||||
LTEXT "Fire 2",IDC_STATIC,56,136,18,8
|
||||
LTEXT "Left",IDC_STATIC,189,62,13,8
|
||||
LTEXT "Right",IDC_STATIC,185,77,18,8
|
||||
LTEXT "Up",IDC_STATIC,192,92,10,8
|
||||
LTEXT "Down",IDC_STATIC,183,107,20,8
|
||||
LTEXT "Fire 1",IDC_STATIC,185,121,18,8
|
||||
LTEXT "Fire 2",IDC_STATIC,185,136,18,8
|
||||
COMBOBOX IDC_LEFT_LEFT,77,58,50,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_LEFT_RIGHT,77,73,50,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_LEFT_UP,77,88,50,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_LEFT_DOWN,77,103,50,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_LEFT_FIRE1,77,118,50,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_LEFT_FIRE2,77,133,50,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_RIGHT_LEFT,206,58,50,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_RIGHT_RIGHT,206,73,50,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_RIGHT_UP,206,88,50,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_RIGHT_DOWN,206,103,50,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_RIGHT_FIRE1,206,118,50,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_RIGHT_FIRE2,206,133,50,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
ICON "",IDC_LEFTICON,17,90,20,20
|
||||
ICON "",IDC_RIGHTICON,148,90,20,20
|
||||
GROUPBOX "Emulation Type",IDC_STATIC,28,154,68,56,BS_CENTER
|
||||
GROUPBOX "Emulation Type",IDC_STATIC,157,155,68,56,BS_CENTER
|
||||
RADIOBUTTON "Standard",IDC_LEFTSTANDARD,35,167,58,10
|
||||
RADIOBUTTON "Tandy Hi-res",IDC_LEFTTHIRES,35,181,58,10
|
||||
RADIOBUTTON "CC-MAX ",IDC_LEFTCCMAX,35,195,58,10
|
||||
RADIOBUTTON "Standard",IDC_RIGHTSTANDARD,164,167,58,10
|
||||
RADIOBUTTON "Tandy Hi-res",IDC_RIGHTTHRES,164,181,58,10
|
||||
RADIOBUTTON "CC-MAX ",IDC_RIGHTCCMAX,164,195,58,10
|
||||
CONTROL "Show Windows Mouse Pointer in VCC screen",IDC_SHOWMOUSE,
|
||||
"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,10,220,99,23
|
||||
DEFPUSHBUTTON "OK",IDOK,135,227,36,14
|
||||
PUSHBUTTON "Apply",IDAPPLY,175,227,36,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,215,227,36,14
|
||||
END
|
||||
|
||||
IDD_CASSETTE DIALOGEX 0, 0, 265, 115
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Cassette Tape Configuration"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x1
|
||||
BEGIN
|
||||
LTEXT "",IDC_TAPEFILE,6,12,200,11,SS_NOPREFIX | SS_PATHELLIPSIS,WS_EX_STATICEDGE
|
||||
PUSHBUTTON "Browse",IDC_TBROWSE,210,11,50,14
|
||||
PUSHBUTTON "Rec",IDC_REC, 5, 32,35,18,BS_CENTER,WS_EX_DLGMODALFRAME
|
||||
PUSHBUTTON "Play",IDC_PLAY, 44, 32,35,18,BS_CENTER,WS_EX_DLGMODALFRAME
|
||||
PUSHBUTTON "Stop",IDC_STOP, 83, 32,35,18,BS_CENTER,WS_EX_DLGMODALFRAME
|
||||
PUSHBUTTON "Eject",IDC_EJECT, 122,32,35,18,BS_CENTER,WS_EX_DLGMODALFRAME
|
||||
PUSHBUTTON "Rewind",IDC_RESET,161,32,35,18,BS_CENTER,WS_EX_DLGMODALFRAME
|
||||
CONTROL "", IDC_MODE,"RichEdit20W", WS_BORDER | 0x800, 7, 56,35,14,WS_EX_CLIENTEDGE | WS_EX_STATICEDGE
|
||||
CONTROL "",IDC_TCOUNT,"RichEdit20W",WS_BORDER | 0x2800,53,56,50,15,WS_EX_CLIENTEDGE | WS_EX_RIGHT | WS_EX_STATICEDGE
|
||||
CTEXT "Mode", IDC_STATIC, 7,72,35,8
|
||||
CTEXT "Counter",IDC_STATIC,53,72,50,8
|
||||
|
||||
DEFPUSHBUTTON "OK",IDOK,65,90,36,14
|
||||
PUSHBUTTON "Apply",IDAPPLY,105,90,36,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,145,90,36,14
|
||||
CONTROL "Fast Load",IDC_FASTLOAD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,204,37,48,10
|
||||
END
|
||||
|
||||
IDD_BITBANGER DIALOGEX 0, 0, 255,100
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "BitBanger Configuration"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "",IDC_SERIALFILE,7,7,238,11,SS_NOPREFIX | SS_PATHELLIPSIS,WS_EX_STATICEDGE
|
||||
PUSHBUTTON "Open File",IDC_OPEN,60,25,50,14
|
||||
PUSHBUTTON "Close File",IDC_CLOSE,115,25,50,14
|
||||
CONTROL "Add LF to CR",IDC_LF,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,46,61,10
|
||||
CONTROL "Print Monitor window",IDC_PRINTMON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,58,81,10
|
||||
DEFPUSHBUTTON "OK",IDOK,60,75,36,14
|
||||
PUSHBUTTON "Apply",IDAPPLY,100,75,36,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,140,75,36,14
|
||||
END
|
||||
|
||||
IDD_KEYMAPEDIT DIALOGEX 0, 0, 370, 190
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_NOIDLEMSG | DS_FIXEDSYS | WS_POPUP | WS_CAPTION
|
||||
CAPTION "Edit Custom Key Map"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x1
|
||||
BEGIN
|
||||
PUSHBUTTON "Apply",IDC_SET_CUST_KEYMAP,75,115,50,14,NOT WS_TABSTOP
|
||||
PUSHBUTTON "OK",IDC_KEYMAP_OK,145,115,50,14,NOT WS_TABSTOP
|
||||
PUSHBUTTON "Cancel",IDCANCEL,215,115,50,14,NOT WS_TABSTOP
|
||||
LTEXT "Host Key: ",IDC_STATIC,22,140,38,8
|
||||
LTEXT "",IDC_PCKEY_TXT,56,139,75,12,SS_REALSIZEIMAGE,WS_EX_STATICEDGE
|
||||
LTEXT "CoCo Key:",IDC_STATIC,22,159,38,8
|
||||
LTEXT "",IDC_CCKEY_TXT,56,158,75,12,SS_REALSIZEIMAGE,WS_EX_STATICEDGE
|
||||
LTEXT "Toggle any key on your keyboard to see it's mapping.",IDC_STATIC,145,136,200,10
|
||||
LTEXT "Use CoCo buttons above to change it. Apply each change.",IDC_STATIC,145,146,200,10
|
||||
LTEXT "Optionally toggle SHIFT, CTRL, or ALT modifiers.",IDC_STATIC,145,156,200,10
|
||||
LTEXT "OK button saves changes. Cancel discards changes.",IDC_STATIC,145,166,200,10
|
||||
GROUPBOX "CoCo 3 Keyboard",IDC_STATIC,20,6,330,104,BS_CENTER
|
||||
PUSHBUTTON "1 !",IDC_KEYBTN_1,40,20,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "2 """,IDC_KEYBTN_2,62,20,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "3 #",IDC_KEYBTN_3,84,20,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "4 $",IDC_KEYBTN_4,106,20,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "5 %",IDC_KEYBTN_5,128,20,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "6 &&",IDC_KEYBTN_6,150,20,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "7 '",IDC_KEYBTN_7,172,20,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "8 (",IDC_KEYBTN_8,194,20,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "9 )",IDC_KEYBTN_9,216,20,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "0",IDC_KEYBTN_0,238,20,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON ": *",IDC_KEYBTN_COLON,260,20,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "- =",IDC_KEYBTN_MINUS,282,20,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "Q",IDC_KEYBTN_Q,46,36,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "W",IDC_KEYBTN_W,68,36,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "E",IDC_KEYBTN_E,90,36,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "R",IDC_KEYBTN_R,112,36,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "T",IDC_KEYBTN_T,134,36,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "Y",IDC_KEYBTN_Y,156,36,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "U",IDC_KEYBTN_U,178,36,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "I",IDC_KEYBTN_I,200,36,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "O",IDC_KEYBTN_O,222,36,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "P",IDC_KEYBTN_P,244,36,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "@",IDC_KEYBTN_AT,266,36,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "CLR",IDC_KEYBTN_CLR,288,36,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "A",IDC_KEYBTN_A,50,52,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "S",IDC_KEYBTN_S,72,52,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "D",IDC_KEYBTN_D,94,52,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "F",IDC_KEYBTN_F,116,52,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "G",IDC_KEYBTN_G,138,52,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "H",IDC_KEYBTN_H,160,52,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "J",IDC_KEYBTN_J,182,52,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "K",IDC_KEYBTN_K,204,52,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "L",IDC_KEYBTN_L,226,52,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "; +",IDC_KEYBTN_SEMI,248,52,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "Left",IDC_KEYBTN_LEFT,300,52,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "Z",IDC_KEYBTN_Z,60,68,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "X",IDC_KEYBTN_X,82,68,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "C",IDC_KEYBTN_C,104,68,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "V",IDC_KEYBTN_V,126,68,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "B",IDC_KEYBTN_B,148,68,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "N",IDC_KEYBTN_N,170,68,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "M",IDC_KEYBTN_M,192,68,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON ", <",IDC_KEYBTN_COMMA,214,68,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON ". >",IDC_KEYBTN_PERIOD,236,68,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "/ ?",IDC_KEYBTN_SLASH,258,68,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "ENTER",IDC_KEYBTN_ENTER,270,52,29,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "Down",IDC_KEYBTN_DOWN,310,68,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "Right",IDC_KEYBTN_RIGHT,322,52,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "Up",IDC_KEYBTN_UP,310,36,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "BRK",IDC_KEYBTN_BRK,322,20,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "SPACE",IDC_KEYBTN_SPACE,84,86,177,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "F1",IDC_KEYBTN_F1,300,86,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "F2",IDC_KEYBTN_F2,322,86,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "ALT",IDC_KEYBTN_ALT,24,36,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "CTRL",IDC_KEYBTN_CTRL,28,52,22,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "SHIFT",IDC_KEYBTN_LSHIFT,32,68,29,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
PUSHBUTTON "SHIFT",IDC_KEYBTN_RSHIFT,280,68,29,16,BS_PUSHLIKE | NOT WS_TABSTOP
|
||||
END
|
||||
|
||||
IDD_MEMORY_MAP DIALOGEX 430, 65504, 360, 389
|
||||
STYLE DS_SETFONT | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
|
||||
CAPTION "Memory"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "",IDC_STATIC,0,0,360,20
|
||||
EDITTEXT IDC_EDIT_RANGE_BEG,4,4,30,12,ES_AUTOHSCROLL
|
||||
LTEXT ":",IDC_EDIT_RANGE_SEP,34,6,6,8
|
||||
EDITTEXT IDC_EDIT_RANGE_END,37,4,30,12,ES_AUTOHSCROLL
|
||||
PUSHBUTTON "Export",IDC_BTN_EXPORT_MEM,70,4,31,12
|
||||
CTEXT "",IDC_ADRTXT,104,2,40,16
|
||||
EDITTEXT IDC_EDIT_VALUE,148,4,24,12,ES_AUTOHSCROLL
|
||||
COMBOBOX IDC_MEM_WIDTH,176,4,32,120,CBS_DROPDOWN
|
||||
COMBOBOX IDC_MEM_TYPE,210,4,38,120,CBS_DROPDOWNLIST
|
||||
COMBOBOX IDC_VIEW_TYPE,250,4,65,300,CBS_DROPDOWNLIST
|
||||
PUSHBUTTON "Help",IDC_BTN_HELP,317,3,36,12
|
||||
END
|
||||
|
||||
IDD_PROCESSOR_STATE DIALOGEX 0, 310, 325, 100
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Processor Status"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x0
|
||||
BEGIN
|
||||
EDITTEXT IDC_EDIT_PC_ADDR,155,82,36,14,ES_AUTOHSCROLL
|
||||
PUSHBUTTON "Set PC",IDC_BTN_SET_PC,200,82,36,14
|
||||
PUSHBUTTON "Step",IDC_BTN_CPU_STEP,240,82,36,14
|
||||
PUSHBUTTON "Halt",IDC_BTN_CPU_HALT,280,82,36,14
|
||||
END
|
||||
|
||||
IDD_BREAKPOINTS DIALOGEX 65181, 65504, 340, 300
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
|
||||
CAPTION "Source Debugger"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x0
|
||||
BEGIN
|
||||
GROUPBOX "Load LWASM Source Listing for Symbolic Debugging",IDC_STATIC,10,6,320,58
|
||||
LTEXT "Source Listing",IDC_STATIC,16,23,100,8
|
||||
EDITTEXT IDC_EDIT_SOURCE,16,35,240,14,ES_AUTOHSCROLL
|
||||
PUSHBUTTON "Browse",IDC_BTN_SOURCE_BROWSE,260,35,50,14
|
||||
LTEXT "Lines",IDC_STATIC,20,51,17,8
|
||||
LTEXT "0 lines loaded",IDC_LINES_LOADED,45,51,100,8
|
||||
GROUPBOX "Breakpoints",IDC_STATIC,10,70,320,83
|
||||
LISTBOX IDC_LIST_BREAKPOINTS,18,80,202,65,LBS_SORT | LBS_USETABSTOPS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "New Breakpoint",IDC_BTN_NEW_BREAKPOINT,230,80,73,14
|
||||
PUSHBUTTON "Remove Breakpoint",IDC_BTN_DEL_BREAKPOINT,230,95,73,14
|
||||
PUSHBUTTON "On",IDC_BTN_BREAKPOINT_ON,230,110,35,14
|
||||
PUSHBUTTON "Off",IDC_BTN_BREAKPOINT_OFF,268,110,35,14
|
||||
CONTROL "[Load source listing]",IDC_SOURCE_LISTING,"RichEdit20W",WS_VSCROLL | WS_TABSTOP | 0x9c4,10,155,320,120
|
||||
DEFPUSHBUTTON "Close",IDCLOSE,6,280,36,14
|
||||
EDITTEXT IDC_EDIT_FIND_SOURCE,228,280,70,14,ES_AUTOHSCROLL
|
||||
PUSHBUTTON "Find",IDC_BTN_FIND_SOURCE,298,280,36,14
|
||||
END
|
||||
|
||||
IDD_MMU_MONITOR DIALOGEX 50, 50, 224, 166
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "MMU Monitor"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x0
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Close",IDCLOSE,8,148,36,14
|
||||
END
|
||||
|
||||
IDD_EXEC_TRACE DIALOGEX 65181, 65504, 310, 310
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
|
||||
CAPTION "Execution Trace"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x0
|
||||
BEGIN
|
||||
PUSHBUTTON "Enable",IDC_BTN_ENABLE_TRACE, 12, 5,54,13
|
||||
PUSHBUTTON "Stop", IDC_BTN_STOP_TRACE, 12,20,54,13
|
||||
PUSHBUTTON "Reset", IDC_BTN_RESET_TRACE, 12,35,54,13
|
||||
PUSHBUTTON "Export",IDC_BTN_EXPORT, 12,50,54,13
|
||||
GROUPBOX "Start/Stop Triggers",IDC_STATIC, 83,5,210,60
|
||||
LTEXT "Enter Address",IDC_STATIC, 92,25,80,8
|
||||
EDITTEXT IDC_EDIT_TRACE_ADDR, 138,23,30,14,ES_AUTOHSCROLL
|
||||
LTEXT "Start Addresses",IDC_STATIC, 175,13,50,10
|
||||
LISTBOX IDC_LIST_START_TRACE, 175,23,50,25,LBS_SORT | LBS_USETABSTOPS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "Add",IDC_BTN_ADD_START_TRACE, 178,48,22,12
|
||||
PUSHBUTTON "Del",IDC_BTN_DEL_START_TRACE, 200,48,22,12
|
||||
LTEXT "Stop Addresses",IDC_STATIC, 232,13,50,10
|
||||
LISTBOX IDC_LIST_STOP_TRACE, 232,23,50,25,LBS_SORT | LBS_USETABSTOPS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "Add",IDC_BTN_ADD_STOP_TRACE, 234,48,22,12
|
||||
PUSHBUTTON "Del",IDC_BTN_DEL_STOP_TRACE, 256,48,22,12
|
||||
LTEXT "Trace is disabled",IDC_TRACE_STATUS, 8,70,70,8
|
||||
CONTROL "Screen",IDC_SHOW_SCN_TRACE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,100,70,40,8
|
||||
CONTROL "Emulation",IDC_SHOW_EMU_TRACE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,145,70,50,8
|
||||
LTEXT "Samples",IDC_STATIC,200,70,35,8
|
||||
COMBOBOX IDC_MAX_TRACE_SAMPLES,232,68,60,56,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "",IDC_TRACE_TIMING,66,292,350,14
|
||||
END
|
||||
|
||||
IDD_DISASSEMBLER DIALOGEX 428, 65465, 210, 390
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Disassembler"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x0
|
||||
BEGIN
|
||||
CONTROL "Real Address", IDC_BTN_REAL, "Button",BS_AUTOCHECKBOX,15, 4,55,10
|
||||
LTEXT "Address",IDC_ADRTXT, 10,18, 25,9
|
||||
EDITTEXT IDC_EDIT_PC_ADDR, 38,18, 35,10
|
||||
CONTROL "Os9 Mode", IDC_BTN_OS9, "Button",BS_AUTOCHECKBOX,92, 4,65,10
|
||||
CONTROL "Auto track PC",IDC_BTN_AUTO, "Button",BS_AUTOCHECKBOX,92,18,65,10
|
||||
LTEXT "",IDC_ERROR_TEXT, 4,31,150,10
|
||||
DEFPUSHBUTTON "Decode",IDAPPLY, 164, 3, 38,16
|
||||
PUSHBUTTON "Help", IDC_BTN_HELP, 164,22, 38,16
|
||||
CONTROL "",IDC_DISASSEMBLY_TEXT, "RichEdit20A",ES_MULTILINE|ES_READONLY|WS_VSCROLL,5,43,205,344
|
||||
END
|
||||
|
||||
IDD_BPLISTDIALOG DIALOGEX 160, 40, 85, 102
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Breakpoints"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x0
|
||||
BEGIN
|
||||
LISTBOX IDC_LIST_BREAKPOINTS,12,4,60,84,LBS_SORT | LBS_USETABSTOPS | WS_VSCROLL
|
||||
PUSHBUTTON "Delete",IDC_BTN_DEL_BREAKPOINT,22,82,40,14
|
||||
END
|
||||
|
||||
IDD_EXPORT DIALOG DISCARDABLE 10,5,100,60
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Export Trace"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
LTEXT "First Line",IDC_STATIC,10,2,40,8
|
||||
LTEXT "Last Line", IDC_STATIC,55,2,40,8
|
||||
EDITTEXT IDC_EDIT_START, 7,12,36,12,ES_NUMBER
|
||||
EDITTEXT IDC_EDIT_STOP, 52,12,36,12,ES_NUMBER
|
||||
LTEXT "",IDC_ERROR_TEXT, 7,26,80,10
|
||||
DEFPUSHBUTTON "OK",IDOK, 7,38,36,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,52,38,36,14
|
||||
END
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO
|
||||
BEGIN
|
||||
IDD_ABOUTBOX, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 1
|
||||
RIGHTMARGIN, 231
|
||||
TOPMARGIN, 3
|
||||
BOTTOMMARGIN, 377
|
||||
END
|
||||
|
||||
IDD_TCONFIG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 288
|
||||
VERTGUIDE, 280
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 302
|
||||
END
|
||||
|
||||
IDD_DISPLAY, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 250
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 202
|
||||
END
|
||||
|
||||
IDD_CPU, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 261
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 210
|
||||
END
|
||||
|
||||
IDD_AUDIO, DIALOG
|
||||
BEGIN
|
||||
RIGHTMARGIN, 261
|
||||
BOTTOMMARGIN, 154
|
||||
END
|
||||
|
||||
IDD_INPUT, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 264
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 228
|
||||
END
|
||||
|
||||
IDD_JOYSTICK, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
VERTGUIDE, 270
|
||||
TOPMARGIN, 7
|
||||
HORZGUIDE, 164
|
||||
END
|
||||
|
||||
IDD_MISC, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 4
|
||||
RIGHTMARGIN, 216
|
||||
TOPMARGIN, 3
|
||||
BOTTOMMARGIN, 111
|
||||
END
|
||||
|
||||
IDD_CASSETTE, DIALOG
|
||||
BEGIN
|
||||
RIGHTMARGIN, 257
|
||||
BOTTOMMARGIN, 93
|
||||
END
|
||||
|
||||
IDD_BITBANGER, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 254
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 222
|
||||
END
|
||||
|
||||
IDD_KEYMAPEDIT, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 352
|
||||
TOPMARGIN, 7
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 2,1,10,0
|
||||
PRODUCTVERSION 2,1,10,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x29L
|
||||
#else
|
||||
FILEFLAGS 0x28L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "Comments", "How bored are you that your reading this?"
|
||||
VALUE "CompanyName", "Not Radio Shack"
|
||||
VALUE "FileDescription", "Vcc"
|
||||
VALUE "FileVersion", "2.1.10.0"
|
||||
VALUE "InternalName", "Poco"
|
||||
VALUE "LegalCopyright", "Copyright 2015 by BitRot Software"
|
||||
VALUE "LegalTrademarks", "BLAZEMONGER!"
|
||||
VALUE "OriginalFilename", "Vcc.exe"
|
||||
VALUE "PrivateBuild", "For a good time call 867-5309 Jenny ;)"
|
||||
VALUE "ProductName", "VCC"
|
||||
VALUE "ProductVersion", "26-3334"
|
||||
VALUE "SpecialBuild", "Tandy Color Computer 3"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
//
|
||||
|
||||
IDB_NOMUTE BITMAP "resources\\speaker1.bmp"
|
||||
|
||||
IDB_MUTE BITMAP "resources\\speaker2.bmp"
|
||||
|
||||
IDB_VCC BITMAP "resources\\vcc.bmp"
|
||||
|
||||
IDB_3GUYS BITMAP "resources\\3guys.bmp"
|
||||
|
||||
IDB_FONT_CONSOLA BITMAP "resources\\consola.bmp"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Cursor
|
||||
//
|
||||
|
||||
IDC_NONE CURSOR "resources\\cursor1.cur"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// AFX_DIALOG_LAYOUT
|
||||
//
|
||||
|
||||
IDD_JOYSTICK AFX_DIALOG_LAYOUT
|
||||
BEGIN
|
||||
0
|
||||
END
|
||||
|
||||
IDD_TCONFIG AFX_DIALOG_LAYOUT
|
||||
BEGIN
|
||||
0
|
||||
END
|
||||
|
||||
IDD_INPUT AFX_DIALOG_LAYOUT
|
||||
BEGIN
|
||||
0
|
||||
END
|
||||
|
||||
IDD_MISC AFX_DIALOG_LAYOUT
|
||||
BEGIN
|
||||
0
|
||||
END
|
||||
|
||||
IDD_KEYMAPEDIT AFX_DIALOG_LAYOUT
|
||||
BEGIN
|
||||
0
|
||||
END
|
||||
|
||||
IDD_ABOUTBOX AFX_DIALOG_LAYOUT
|
||||
BEGIN
|
||||
0
|
||||
END
|
||||
|
||||
IDD_DISPLAY AFX_DIALOG_LAYOUT
|
||||
BEGIN
|
||||
0
|
||||
END
|
||||
|
||||
IDD_CPU AFX_DIALOG_LAYOUT
|
||||
BEGIN
|
||||
0
|
||||
END
|
||||
|
||||
IDD_AUDIO AFX_DIALOG_LAYOUT
|
||||
BEGIN
|
||||
0
|
||||
END
|
||||
|
||||
IDD_BITBANGER AFX_DIALOG_LAYOUT
|
||||
BEGIN
|
||||
0
|
||||
END
|
||||
|
||||
IDD_CASSETTE AFX_DIALOG_LAYOUT
|
||||
BEGIN
|
||||
0
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_APP_TITLE "VCC 2.1.10.0pre1 Tandy Color Computer 3 Emulator"
|
||||
IDS_CATNUMBER "26-3334"
|
||||
// TODO: The following should not be used
|
||||
IDS_MODULE_ALREADY_LOADED "Module is already loaded."
|
||||
IDS_MODULE_CANNOT_OPEN "Cannot open module."
|
||||
IDS_MODULE_NOT_FOUND "Module not found."
|
||||
IDS_MODULE_NOT_LOADED "Unable to load module."
|
||||
IDS_MODULE_NOT_ROM "Module is not a valid ROM image."
|
||||
IDS_MODULE_NOT_EXPANSION "Module is not a valid expansion plugin."
|
||||
IDS_UNKNOWN_ERROR "Unknown error."
|
||||
END
|
||||
|
||||
#endif // English (United States) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
@@ -0,0 +1,132 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.10.35027.167
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vcc", "Vcc.vcxproj", "{822E50CF-A326-4B7A-A2CA-2A4C4055FC34}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fd502", "FD502\fd502.vcxproj", "{F4DC9499-4FF1-4A56-83DD-6499062972AA}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "harddisk", "HardDisk\harddisk.vcxproj", "{FC5D90DF-A488-4E57-A4B2-7C74AE861F9E}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpi", "mpi\mpi.vcxproj", "{678097F4-F33B-4739-B3E1-7A72BD1F4A3A}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "orch90", "orch90\orch90.vcxproj", "{89C050F1-9427-4C5F-B260-C5F9EB43E915}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ramdisk", "Ramdisk\Ramdisk.vcxproj", "{23D3931C-364B-45E2-B58C-9B3FBC584C0F}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "superide", "SuperIDE\SuperIDE.vcxproj", "{95713490-9812-4348-9E5E-818F736A271A}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "becker", "becker\becker.vcxproj", "{C78D7242-DB92-49BC-AFF5-433E16C3C9D4}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gmc", "GMC\gmc.vcxproj", "{BD7CA587-71D0-43D6-A730-582126B1C1F4}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "acia", "acia\acia.vcxproj", "{337BE96D-E8B6-4409-BBFD-0AD8C49AF94B}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdc", "sdc\sdc.vcxproj", "{597294EB-A5F9-44C4-A68C-54C3116E8D36}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcommon", "libcommon\libcommon.vcxproj", "{E0AA25BD-5527-475F-8D8B-B549A6311B0C}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssc", "ssc\ssc.vcxproj", "{850B6887-187F-4553-BAEA-B0E19C91EA30}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xsid", "xsid\xsid.vcxproj", "{5E1EE2C3-634D-4129-9687-DE839358FD1F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x86 = Debug|x86
|
||||
Legacy|x86 = Legacy|x86
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{822E50CF-A326-4B7A-A2CA-2A4C4055FC34}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{822E50CF-A326-4B7A-A2CA-2A4C4055FC34}.Debug|x86.Build.0 = Debug|Win32
|
||||
{822E50CF-A326-4B7A-A2CA-2A4C4055FC34}.Legacy|x86.ActiveCfg = Legacy|Win32
|
||||
{822E50CF-A326-4B7A-A2CA-2A4C4055FC34}.Legacy|x86.Build.0 = Legacy|Win32
|
||||
{822E50CF-A326-4B7A-A2CA-2A4C4055FC34}.Release|x86.ActiveCfg = Release|Win32
|
||||
{822E50CF-A326-4B7A-A2CA-2A4C4055FC34}.Release|x86.Build.0 = Release|Win32
|
||||
{F4DC9499-4FF1-4A56-83DD-6499062972AA}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{F4DC9499-4FF1-4A56-83DD-6499062972AA}.Debug|x86.Build.0 = Debug|Win32
|
||||
{F4DC9499-4FF1-4A56-83DD-6499062972AA}.Legacy|x86.ActiveCfg = Legacy|Win32
|
||||
{F4DC9499-4FF1-4A56-83DD-6499062972AA}.Legacy|x86.Build.0 = Legacy|Win32
|
||||
{F4DC9499-4FF1-4A56-83DD-6499062972AA}.Release|x86.ActiveCfg = Release|Win32
|
||||
{F4DC9499-4FF1-4A56-83DD-6499062972AA}.Release|x86.Build.0 = Release|Win32
|
||||
{FC5D90DF-A488-4E57-A4B2-7C74AE861F9E}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{FC5D90DF-A488-4E57-A4B2-7C74AE861F9E}.Debug|x86.Build.0 = Debug|Win32
|
||||
{FC5D90DF-A488-4E57-A4B2-7C74AE861F9E}.Legacy|x86.ActiveCfg = Legacy|Win32
|
||||
{FC5D90DF-A488-4E57-A4B2-7C74AE861F9E}.Legacy|x86.Build.0 = Legacy|Win32
|
||||
{FC5D90DF-A488-4E57-A4B2-7C74AE861F9E}.Release|x86.ActiveCfg = Release|Win32
|
||||
{FC5D90DF-A488-4E57-A4B2-7C74AE861F9E}.Release|x86.Build.0 = Release|Win32
|
||||
{678097F4-F33B-4739-B3E1-7A72BD1F4A3A}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{678097F4-F33B-4739-B3E1-7A72BD1F4A3A}.Debug|x86.Build.0 = Debug|Win32
|
||||
{678097F4-F33B-4739-B3E1-7A72BD1F4A3A}.Legacy|x86.ActiveCfg = Legacy|Win32
|
||||
{678097F4-F33B-4739-B3E1-7A72BD1F4A3A}.Legacy|x86.Build.0 = Legacy|Win32
|
||||
{678097F4-F33B-4739-B3E1-7A72BD1F4A3A}.Release|x86.ActiveCfg = Release|Win32
|
||||
{678097F4-F33B-4739-B3E1-7A72BD1F4A3A}.Release|x86.Build.0 = Release|Win32
|
||||
{89C050F1-9427-4C5F-B260-C5F9EB43E915}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{89C050F1-9427-4C5F-B260-C5F9EB43E915}.Debug|x86.Build.0 = Debug|Win32
|
||||
{89C050F1-9427-4C5F-B260-C5F9EB43E915}.Legacy|x86.ActiveCfg = Legacy|Win32
|
||||
{89C050F1-9427-4C5F-B260-C5F9EB43E915}.Legacy|x86.Build.0 = Legacy|Win32
|
||||
{89C050F1-9427-4C5F-B260-C5F9EB43E915}.Release|x86.ActiveCfg = Release|Win32
|
||||
{89C050F1-9427-4C5F-B260-C5F9EB43E915}.Release|x86.Build.0 = Release|Win32
|
||||
{23D3931C-364B-45E2-B58C-9B3FBC584C0F}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{23D3931C-364B-45E2-B58C-9B3FBC584C0F}.Debug|x86.Build.0 = Debug|Win32
|
||||
{23D3931C-364B-45E2-B58C-9B3FBC584C0F}.Legacy|x86.ActiveCfg = Legacy|Win32
|
||||
{23D3931C-364B-45E2-B58C-9B3FBC584C0F}.Legacy|x86.Build.0 = Legacy|Win32
|
||||
{23D3931C-364B-45E2-B58C-9B3FBC584C0F}.Release|x86.ActiveCfg = Release|Win32
|
||||
{23D3931C-364B-45E2-B58C-9B3FBC584C0F}.Release|x86.Build.0 = Release|Win32
|
||||
{95713490-9812-4348-9E5E-818F736A271A}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{95713490-9812-4348-9E5E-818F736A271A}.Debug|x86.Build.0 = Debug|Win32
|
||||
{95713490-9812-4348-9E5E-818F736A271A}.Legacy|x86.ActiveCfg = Legacy|Win32
|
||||
{95713490-9812-4348-9E5E-818F736A271A}.Legacy|x86.Build.0 = Legacy|Win32
|
||||
{95713490-9812-4348-9E5E-818F736A271A}.Release|x86.ActiveCfg = Release|Win32
|
||||
{95713490-9812-4348-9E5E-818F736A271A}.Release|x86.Build.0 = Release|Win32
|
||||
{C78D7242-DB92-49BC-AFF5-433E16C3C9D4}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{C78D7242-DB92-49BC-AFF5-433E16C3C9D4}.Debug|x86.Build.0 = Debug|Win32
|
||||
{C78D7242-DB92-49BC-AFF5-433E16C3C9D4}.Legacy|x86.ActiveCfg = Legacy|Win32
|
||||
{C78D7242-DB92-49BC-AFF5-433E16C3C9D4}.Legacy|x86.Build.0 = Legacy|Win32
|
||||
{C78D7242-DB92-49BC-AFF5-433E16C3C9D4}.Release|x86.ActiveCfg = Release|Win32
|
||||
{C78D7242-DB92-49BC-AFF5-433E16C3C9D4}.Release|x86.Build.0 = Release|Win32
|
||||
{BD7CA587-71D0-43D6-A730-582126B1C1F4}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{BD7CA587-71D0-43D6-A730-582126B1C1F4}.Debug|x86.Build.0 = Debug|Win32
|
||||
{BD7CA587-71D0-43D6-A730-582126B1C1F4}.Legacy|x86.ActiveCfg = Legacy|Win32
|
||||
{BD7CA587-71D0-43D6-A730-582126B1C1F4}.Legacy|x86.Build.0 = Legacy|Win32
|
||||
{BD7CA587-71D0-43D6-A730-582126B1C1F4}.Release|x86.ActiveCfg = Release|Win32
|
||||
{BD7CA587-71D0-43D6-A730-582126B1C1F4}.Release|x86.Build.0 = Release|Win32
|
||||
{337BE96D-E8B6-4409-BBFD-0AD8C49AF94B}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{337BE96D-E8B6-4409-BBFD-0AD8C49AF94B}.Debug|x86.Build.0 = Debug|Win32
|
||||
{337BE96D-E8B6-4409-BBFD-0AD8C49AF94B}.Legacy|x86.ActiveCfg = Legacy|Win32
|
||||
{337BE96D-E8B6-4409-BBFD-0AD8C49AF94B}.Legacy|x86.Build.0 = Legacy|Win32
|
||||
{337BE96D-E8B6-4409-BBFD-0AD8C49AF94B}.Release|x86.ActiveCfg = Release|Win32
|
||||
{337BE96D-E8B6-4409-BBFD-0AD8C49AF94B}.Release|x86.Build.0 = Release|Win32
|
||||
{597294EB-A5F9-44C4-A68C-54C3116E8D36}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{597294EB-A5F9-44C4-A68C-54C3116E8D36}.Debug|x86.Build.0 = Debug|Win32
|
||||
{597294EB-A5F9-44C4-A68C-54C3116E8D36}.Legacy|x86.ActiveCfg = Legacy|Win32
|
||||
{597294EB-A5F9-44C4-A68C-54C3116E8D36}.Legacy|x86.Build.0 = Legacy|Win32
|
||||
{597294EB-A5F9-44C4-A68C-54C3116E8D36}.Release|x86.ActiveCfg = Release|Win32
|
||||
{597294EB-A5F9-44C4-A68C-54C3116E8D36}.Release|x86.Build.0 = Release|Win32
|
||||
{E0AA25BD-5527-475F-8D8B-B549A6311B0C}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{E0AA25BD-5527-475F-8D8B-B549A6311B0C}.Debug|x86.Build.0 = Debug|Win32
|
||||
{E0AA25BD-5527-475F-8D8B-B549A6311B0C}.Legacy|x86.ActiveCfg = Legacy|Win32
|
||||
{E0AA25BD-5527-475F-8D8B-B549A6311B0C}.Legacy|x86.Build.0 = Legacy|Win32
|
||||
{E0AA25BD-5527-475F-8D8B-B549A6311B0C}.Release|x86.ActiveCfg = Release|Win32
|
||||
{E0AA25BD-5527-475F-8D8B-B549A6311B0C}.Release|x86.Build.0 = Release|Win32
|
||||
{850B6887-187F-4553-BAEA-B0E19C91EA30}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{850B6887-187F-4553-BAEA-B0E19C91EA30}.Debug|x86.Build.0 = Debug|Win32
|
||||
{850B6887-187F-4553-BAEA-B0E19C91EA30}.Legacy|x86.ActiveCfg = Legacy|Win32
|
||||
{850B6887-187F-4553-BAEA-B0E19C91EA30}.Legacy|x86.Build.0 = Legacy|Win32
|
||||
{850B6887-187F-4553-BAEA-B0E19C91EA30}.Release|x86.ActiveCfg = Release|Win32
|
||||
{850B6887-187F-4553-BAEA-B0E19C91EA30}.Release|x86.Build.0 = Release|Win32
|
||||
{5E1EE2C3-634D-4129-9687-DE839358FD1F}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{5E1EE2C3-634D-4129-9687-DE839358FD1F}.Debug|x86.Build.0 = Debug|Win32
|
||||
{5E1EE2C3-634D-4129-9687-DE839358FD1F}.Legacy|x86.ActiveCfg = Legacy|Win32
|
||||
{5E1EE2C3-634D-4129-9687-DE839358FD1F}.Legacy|x86.Build.0 = Legacy|Win32
|
||||
{5E1EE2C3-634D-4129-9687-DE839358FD1F}.Release|x86.ActiveCfg = Release|Win32
|
||||
{5E1EE2C3-634D-4129-9687-DE839358FD1F}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {4AF251C5-5E20-44FC-B459-B7317DBA3470}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,314 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Legacy|Win32">
|
||||
<Configuration>Legacy</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<SccProjectName />
|
||||
<SccLocalPath />
|
||||
<ProjectGuid>{822E50CF-A326-4B7A-A2CA-2A4C4055FC34}</ProjectGuid>
|
||||
<ProjectName>vcc</ProjectName>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'" Label="Configuration">
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="vcc-base.props" />
|
||||
<Import Project="vcc-debug.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="vcc-base.props" />
|
||||
<Import Project="vcc-legacy.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="vcc-base.props" />
|
||||
<Import Project="vcc-release.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">
|
||||
<LibraryPath>C:\Program Files %28x86%29\Windows Kits\8.1\Lib\winv6.3\um\x86;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_LEGACY_VCC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalOptions>/arch:SSE</AdditionalOptions>
|
||||
<AdditionalIncludeDirectories>..\..\third_party\legacy_graphics;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ddraw.lib;comctl32.lib;Winmm.lib;dsound.lib;dinput8.lib;dxguid.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
<IgnoreSpecificDefaultLibraries>
|
||||
</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalOptions>/arch:SSE</AdditionalOptions>
|
||||
<AdditionalIncludeDirectories>..\..\third_party\legacy_graphics;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<ResourceCompile />
|
||||
<Link>
|
||||
<AdditionalDependencies>ddraw.lib;comctl32.lib;Winmm.lib;dsound.lib;dinput8.lib;dxguid.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
<IgnoreSpecificDefaultLibraries>
|
||||
</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\..\third_party\legacy_graphics;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<ResourceCompile />
|
||||
<Link>
|
||||
<AdditionalDependencies>ddraw.lib;dxguid.lib;comctl32.lib;Winmm.lib;dsound.lib;dinput8.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>
|
||||
</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Audio.cpp" />
|
||||
<ClCompile Include="DirectX.cpp" />
|
||||
<ClCompile Include="..\..\src\core\Event.cpp" />
|
||||
<ClCompile Include="..\..\src\core\CpuHost.cpp" />
|
||||
<ClCompile Include="..\..\src\core\VideoHost.cpp" />
|
||||
<ClCompile Include="..\..\src\core\VideoRegisters.cpp" />
|
||||
<ClCompile Include="..\..\src\core\FrameRunner.cpp" />
|
||||
<ClCompile Include="..\..\src\core\CpuMemory.cpp" />
|
||||
<ClCompile Include="..\..\src\core\MachineHost.cpp" />
|
||||
<ClCompile Include="PrinterWin.cpp" />
|
||||
<ClCompile Include="OpenGL.cpp" />
|
||||
<ClCompile Include="OpenGLFontConsola.cpp" />
|
||||
<ClCompile Include="Screenshot.cpp" />
|
||||
<ClCompile Include="SourceDebug.cpp">
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Level4</WarningLevel>
|
||||
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</TreatWarningAsError>
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">Level4</WarningLevel>
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Level4</WarningLevel>
|
||||
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">true</TreatWarningAsError>
|
||||
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Cassette.cpp" />
|
||||
<ClCompile Include="coco3.cpp" />
|
||||
<ClCompile Include="CommandLine.cpp" />
|
||||
<ClCompile Include="config.cpp" />
|
||||
<ClCompile Include="Debugger.cpp">
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Level4</WarningLevel>
|
||||
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</TreatWarningAsError>
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">Level4</WarningLevel>
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Level4</WarningLevel>
|
||||
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">true</TreatWarningAsError>
|
||||
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DebuggerUtils.cpp">
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Level4</WarningLevel>
|
||||
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</TreatWarningAsError>
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">Level4</WarningLevel>
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Level4</WarningLevel>
|
||||
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">true</TreatWarningAsError>
|
||||
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DirectDrawInterface.cpp" />
|
||||
<ClCompile Include="Disassembler.cpp" />
|
||||
<ClCompile Include="ExecutionTrace.cpp" />
|
||||
<ClCompile Include="..\..\src\core\hd6309.cpp" />
|
||||
<ClCompile Include="..\..\src\core\iobus.cpp" />
|
||||
<ClCompile Include="joystickinput.cpp" />
|
||||
<ClCompile Include="keyboard.cpp" />
|
||||
<ClCompile Include="keyboardLayout.cpp" />
|
||||
<ClCompile Include="keyboardEdit.cpp" />
|
||||
<ClCompile Include="memdump.cpp" />
|
||||
<ClCompile Include="..\..\src\core\mc6809.cpp" />
|
||||
<ClCompile Include="..\..\src\core\mc6821.cpp" />
|
||||
<ClCompile Include="MemoryMap.cpp" />
|
||||
<ClCompile Include="MMUMonitor.cpp">
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Level4</WarningLevel>
|
||||
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</TreatWarningAsError>
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">Level4</WarningLevel>
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Level4</WarningLevel>
|
||||
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">true</TreatWarningAsError>
|
||||
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
<ClCompile Include="OpCodeTables.cpp" />
|
||||
<ClCompile Include="OpDecoder.cpp" />
|
||||
<ClCompile Include="pakinterface.cpp" />
|
||||
<ClCompile Include="pakrouter.cpp" />
|
||||
<ClCompile Include="ProcessorState.cpp">
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Level4</WarningLevel>
|
||||
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</TreatWarningAsError>
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">Level4</WarningLevel>
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Level4</WarningLevel>
|
||||
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">true</TreatWarningAsError>
|
||||
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
<ClCompile Include="quickload.cpp" />
|
||||
<ClCompile Include="..\..\src\core\tcc1014graphics.cpp" />
|
||||
<ClCompile Include="..\..\src\core\tcc1014mmu.cpp" />
|
||||
<ClCompile Include="..\..\src\core\tcc1014registers.cpp" />
|
||||
<ClCompile Include="throttle.cpp" />
|
||||
<ClCompile Include="Vcc.cpp" />
|
||||
<ClCompile Include="_xDebug.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="..\..\README.md" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="audio.h" />
|
||||
<ClInclude Include="..\..\src\core\BuildConfig.h" />
|
||||
<ClInclude Include="..\..\src\core\CpuCommon.h" />
|
||||
<ClInclude Include="DirectX.h" />
|
||||
<ClInclude Include="..\..\src\core\DisplayNull.h" />
|
||||
<ClInclude Include="..\..\src\core\Event.h" />
|
||||
<ClInclude Include="..\..\src\core\IDisplay.h" />
|
||||
<ClInclude Include="..\..\src\core\IDisplayDebug.h" />
|
||||
<ClInclude Include="..\..\src\core\DisplayNone.h" />
|
||||
<ClInclude Include="..\..\src\core\Interrupts.h" />
|
||||
<ClInclude Include="OpenGL.h" />
|
||||
<ClInclude Include="OpenGLFont.h" />
|
||||
<ClInclude Include="OpenGLFontConsola.h" />
|
||||
<ClInclude Include="Screenshot.h" />
|
||||
<ClInclude Include="SourceDebug.h" />
|
||||
<ClInclude Include="Cassette.h" />
|
||||
<ClInclude Include="..\..\src\core\cc2font.h" />
|
||||
<ClInclude Include="..\..\src\core\cc3font.h" />
|
||||
<ClInclude Include="coco3.h" />
|
||||
<ClInclude Include="CommandLine.h" />
|
||||
<ClInclude Include="config.h" />
|
||||
<ClInclude Include="Debugger.h" />
|
||||
<ClInclude Include="defines.h" />
|
||||
<ClInclude Include="DirectDrawInterface.h" />
|
||||
<ClInclude Include="Disassembler.h" />
|
||||
<ClInclude Include="ExecutionTrace.h" />
|
||||
<ClInclude Include="..\..\src\core\hd6309.h" />
|
||||
<ClInclude Include="..\..\src\core\hd6309defs.h" />
|
||||
<ClInclude Include="..\..\src\core\iobus.h" />
|
||||
<ClInclude Include="joystickinput.h" />
|
||||
<ClInclude Include="keyboard.h" />
|
||||
<ClInclude Include="keyboardLayout.h" />
|
||||
<ClInclude Include="keyboardEdit.h" />
|
||||
<ClInclude Include="memdump.h" />
|
||||
<ClInclude Include="..\..\src\core\MachineDefs.h" />
|
||||
<ClInclude Include="..\..\src\core\mc6809.h" />
|
||||
<ClInclude Include="..\..\src\core\CpuHost.h" />
|
||||
<ClInclude Include="..\..\src\core\VideoHost.h" />
|
||||
<ClInclude Include="..\..\src\core\VideoRegisters.h" />
|
||||
<ClInclude Include="..\..\src\core\FrameRunner.h" />
|
||||
<ClInclude Include="..\..\src\core\MachineHost.h" />
|
||||
<ClInclude Include="..\..\src\core\CpuMemory.h" />
|
||||
<ClInclude Include="..\..\src\core\mc6809defs.h" />
|
||||
<ClInclude Include="..\..\src\core\mc6821.h" />
|
||||
<ClInclude Include="MemoryMap.h" />
|
||||
<ClInclude Include="MMUMonitor.h" />
|
||||
<ClInclude Include="..\..\src\core\OpCodeTables.h" />
|
||||
<ClInclude Include="OpDecoder.h" />
|
||||
<ClInclude Include="pakinterface.h" />
|
||||
<ClInclude Include="pakrouter.h" />
|
||||
<ClInclude Include="ProcessorState.h" />
|
||||
<ClInclude Include="quickload.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="..\..\src\core\tcc1014graphics.h" />
|
||||
<ClInclude Include="..\..\src\core\tcc1014mmu.h" />
|
||||
<ClInclude Include="..\..\src\core\tcc1014registers.h" />
|
||||
<ClInclude Include="throttle.h" />
|
||||
<ClInclude Include="DebuggerUtils.h" />
|
||||
<ClInclude Include="Vcc.h" />
|
||||
<ClInclude Include="xDebug.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="resources\binfile.ico" />
|
||||
<Image Include="resources\consola.bmp" />
|
||||
<Image Include="resources\hitachi.ico" />
|
||||
<Image Include="resources\ico00004.ico" />
|
||||
<Image Include="resources\icon1.ico" />
|
||||
<Image Include="resources\3guys.bmp" />
|
||||
<Image Include="resources\joystick.ico" />
|
||||
<Image Include="resources\Keyboard.ico" />
|
||||
<Image Include="resources\moto.ico" />
|
||||
<Image Include="resources\mouse.ico" />
|
||||
<Image Include="resources\progpack.ico" />
|
||||
<Image Include="resources\composite.ico" />
|
||||
<Image Include="resources\speaker1.bmp" />
|
||||
<Image Include="resources\speaker2.bmp" />
|
||||
<Image Include="resources\vcc.bmp" />
|
||||
<Image Include="resources\rgb.ico" />
|
||||
<Image Include="speaker.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Vcc.rc" />
|
||||
</ItemGroup>
|
||||
<!--
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="FD502\fd502.vcxproj">
|
||||
<Project>{f4dc9499-4ff1-4a56-83dd-6499062972aa}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="HardDisk\harddisk.vcxproj">
|
||||
<Project>{fc5d90df-a488-4e57-a4b2-7c74ae861f9e}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="mpi\mpi.vcxproj">
|
||||
<Project>{678097f4-f33b-4739-b3e1-7a72bd1f4a3a}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="orch90\orch90.vcxproj">
|
||||
<Project>{89c050f1-9427-4c5f-b260-c5f9eb43e915}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="Ramdisk\Ramdisk.vcxproj">
|
||||
<Project>{23d3931c-364b-45e2-b58c-9b3fbc584c0f}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="SuperIDE\SuperIDE.vcxproj">
|
||||
<Project>{95713490-9812-4348-9e5e-818f736a271a}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
-->
|
||||
<ItemGroup>
|
||||
<None Include="resources\cursor1.cur" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="libcommon\libcommon.vcxproj">
|
||||
<Project>{e0aa25bd-5527-475f-8d8b-b549a6311b0c}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,390 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Audio.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Cassette.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="coco3.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CommandLine.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="config.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DirectDrawInterface.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\hd6309.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="_xDebug.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\iobus.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="keyboard.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="keyboardEdit.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="keyboardLayout.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\mc6809.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\CpuMemory.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\MachineHost.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="PrinterWin.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\VideoHost.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\VideoRegisters.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\FrameRunner.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\CpuHost.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\mc6821.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pakinterface.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="quickload.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\tcc1014registers.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\tcc1014mmu.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\tcc1014graphics.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="throttle.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Vcc.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Debugger.cpp">
|
||||
<Filter>Source\Debugger</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MMUMonitor.cpp">
|
||||
<Filter>Source\Debugger</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ProcessorState.cpp">
|
||||
<Filter>Source\Debugger</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SourceDebug.cpp">
|
||||
<Filter>Source\Debugger</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MemoryMap.cpp">
|
||||
<Filter>Source\Debugger</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DebuggerUtils.cpp">
|
||||
<Filter>Source\Debugger</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ExecutionTrace.cpp">
|
||||
<Filter>Source\Debugger</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="OpDecoder.cpp">
|
||||
<Filter>Source\Debugger</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="OpCodeTables.cpp">
|
||||
<Filter>Source\Debugger</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Disassembler.cpp" />
|
||||
<ClCompile Include="OpenGL.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="OpenGLFontConsola.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="memdump.cpp" />
|
||||
<ClCompile Include="Screenshot.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DirectX.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="joystickinput.cpp" />
|
||||
<ClCompile Include="..\..\src\core\Event.cpp">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="audio.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Cassette.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\cc2font.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\cc3font.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="coco3.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CommandLine.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="config.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="defines.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DirectDrawInterface.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\hd6309.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\hd6309defs.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\iobus.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="joystickinput.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="keyboard.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="keyboardEdit.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="keyboardLayout.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\mc6809.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\MachineHost.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\VideoHost.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\VideoRegisters.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\FrameRunner.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\CpuHost.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\CpuMemory.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\mc6821.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\mc6809defs.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="pakinterface.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="quickload.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Vcc.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="throttle.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\tcc1014registers.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\tcc1014mmu.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\tcc1014graphics.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="xDebug.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SourceDebug.h">
|
||||
<Filter>Headers\Debugger</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MemoryMap.h">
|
||||
<Filter>Headers\Debugger</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MMUMonitor.h">
|
||||
<Filter>Headers\Debugger</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ProcessorState.h">
|
||||
<Filter>Headers\Debugger</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Debugger.h">
|
||||
<Filter>Headers\Debugger</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DebuggerUtils.h">
|
||||
<Filter>Headers\Debugger</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\MachineDefs.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ExecutionTrace.h">
|
||||
<Filter>Headers\Debugger</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="OpDecoder.h">
|
||||
<Filter>Headers\Debugger</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\OpCodeTables.h">
|
||||
<Filter>Headers\Debugger</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Disassembler.h" />
|
||||
<ClInclude Include="OpenGL.h">
|
||||
<Filter>Source</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\IDisplay.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="OpenGLFont.h">
|
||||
<Filter>Source</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="OpenGLFontConsola.h">
|
||||
<Filter>Source</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\IDisplayDebug.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\BuildConfig.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="memdump.h" />
|
||||
<ClInclude Include="Screenshot.h">
|
||||
<Filter>Source</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DirectX.h">
|
||||
<Filter>Source</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\CpuCommon.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\DisplayNull.h">
|
||||
<Filter>Source</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\Interrupts.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\DisplayNone.h">
|
||||
<Filter>Source</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\Event.h">
|
||||
<Filter>Source</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="resources\3guys.bmp">
|
||||
<Filter>Resources</Filter>
|
||||
</Image>
|
||||
<Image Include="resources\binfile.ico">
|
||||
<Filter>Resources</Filter>
|
||||
</Image>
|
||||
<Image Include="resources\composite.ico">
|
||||
<Filter>Resources</Filter>
|
||||
</Image>
|
||||
<Image Include="resources\hitachi.ico">
|
||||
<Filter>Resources</Filter>
|
||||
</Image>
|
||||
<Image Include="resources\ico00004.ico">
|
||||
<Filter>Resources</Filter>
|
||||
</Image>
|
||||
<Image Include="resources\icon1.ico">
|
||||
<Filter>Resources</Filter>
|
||||
</Image>
|
||||
<Image Include="resources\joystick.ico">
|
||||
<Filter>Resources</Filter>
|
||||
</Image>
|
||||
<Image Include="resources\Keyboard.ico">
|
||||
<Filter>Resources</Filter>
|
||||
</Image>
|
||||
<Image Include="resources\speaker1.bmp">
|
||||
<Filter>Resources</Filter>
|
||||
</Image>
|
||||
<Image Include="resources\speaker2.bmp">
|
||||
<Filter>Resources</Filter>
|
||||
</Image>
|
||||
<Image Include="resources\vcc.bmp">
|
||||
<Filter>Resources</Filter>
|
||||
</Image>
|
||||
<Image Include="speaker.ico">
|
||||
<Filter>Resources</Filter>
|
||||
</Image>
|
||||
<Image Include="resources\rgb.ico">
|
||||
<Filter>Resources</Filter>
|
||||
</Image>
|
||||
<Image Include="resources\progpack.ico">
|
||||
<Filter>Resources</Filter>
|
||||
</Image>
|
||||
<Image Include="resources\mouse.ico">
|
||||
<Filter>Resources</Filter>
|
||||
</Image>
|
||||
<Image Include="resources\moto.ico">
|
||||
<Filter>Resources</Filter>
|
||||
</Image>
|
||||
<Image Include="resources\consola.bmp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="..\..\README.md" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Source">
|
||||
<UniqueIdentifier>{0635a928-6fc4-430f-b317-3d9c1a9887fb}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Headers">
|
||||
<UniqueIdentifier>{f166829a-cdba-43c2-803a-9f917201abfd}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Resources">
|
||||
<UniqueIdentifier>{d6184637-cbc4-403b-90e3-ba08f92b040f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source\Debugger">
|
||||
<UniqueIdentifier>{b14bb076-40e2-4e8b-95e5-7646003a0078}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Headers\Debugger">
|
||||
<UniqueIdentifier>{8e101e68-6057-477e-b4ea-0ae8d7d2fdc3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="resources\cursor1.cur">
|
||||
<Filter>Resources</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Vcc.rc">
|
||||
<Filter>Resources</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
||||
@@ -0,0 +1,59 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
xDebug.c
|
||||
|
||||
uEng - micro cross platform engine
|
||||
Copyright 2010 by Wes Gale All rights reserved.
|
||||
Used by permission in VccX
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "xDebug.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <Windows.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
int g_bTraceMessageLogging = TRUE;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#if 0
|
||||
void _xDbgTrace(const void * pFile, const int iLine, const void * pFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args,pFormat);
|
||||
|
||||
fprintf(stdout,"%s(%d) : ", (char *)pFile, iLine);
|
||||
|
||||
vfprintf(stdout,(char *)pFormat,args);
|
||||
|
||||
va_end(args);
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
#else
|
||||
void _xDbgTrace(const char* pFile, const int iLine, const char* pFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
char temp[1024];
|
||||
|
||||
va_start(args, pFormat);
|
||||
|
||||
sprintf(temp, "%s(%d) : ", pFile, iLine);
|
||||
OutputDebugString(temp);
|
||||
|
||||
vsprintf(temp, pFormat, args);
|
||||
OutputDebugString(temp);
|
||||
|
||||
va_end(args);
|
||||
|
||||
// fflush(stdout);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
Loaded 100 of 1192 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user