Merged from sicklittlemonkey branch to trunk

(rev 111-HEAD)
This commit is contained in:
tomch 2007-03-23 22:26:35 +00:00
parent 0d1b9459f5
commit e83a65a9f2
17 changed files with 338 additions and 87 deletions

View File

@ -1,28 +1,19 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppleWin", "Applewin.vcproj", "{C4C93CFD-5B6C-41C5-BF90-17119186120F}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SourceCodeControl) = preSolution
SccNumberOfProjects = 1
SccProjectUniqueName0 = Applewin.vcproj
SccProjectName0 = APPLEWIN
SccLocalPath0 = .
SccProvider0 = MSSCCI:Microsoft\u0020Visual\u0020SourceSafe
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C4C93CFD-5B6C-41C5-BF90-17119186120F}.Debug|Win32.ActiveCfg = Debug|Win32
{C4C93CFD-5B6C-41C5-BF90-17119186120F}.Debug|Win32.Build.0 = Debug|Win32
{C4C93CFD-5B6C-41C5-BF90-17119186120F}.Release|Win32.ActiveCfg = Release|Win32
{C4C93CFD-5B6C-41C5-BF90-17119186120F}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{C4C93CFD-5B6C-41C5-BF90-17119186120F}.Debug.ActiveCfg = Debug|Win32
{C4C93CFD-5B6C-41C5-BF90-17119186120F}.Debug.Build.0 = Debug|Win32
{C4C93CFD-5B6C-41C5-BF90-17119186120F}.Release.ActiveCfg = Release|Win32
{C4C93CFD-5B6C-41C5-BF90-17119186120F}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -286,6 +286,7 @@ END
//
IDR_HDDRVR FIRMWARE "Hddrvr.bin"
IDR_PRINTDRVR FIRMWARE "Parallel.rom"
/////////////////////////////////////////////////////////////////////////////
//

Binary file not shown.

View File

@ -33,6 +33,7 @@
#define IDR_APPLE2E_ROM 128
#define IDC_MB_ENABLE 130
#define IDD_TFE_SETTINGS_DIALOG 131
#define IDR_PRINTDRVR 132
#define IDC_KEYB_BUFFER_ENABLE 1005
#define IDC_SAVESTATE 1006
#define IDC_SAVESTATE_ON_EXIT 1007

View File

@ -133,6 +133,7 @@ void ContinueExecution()
SpkrUpdate(cyclenum);
CommUpdate(cyclenum);
PrintUpdate(cyclenum);
//
@ -323,6 +324,10 @@ void EnterMessageLoop ()
{
DebuggerUpdate();
}
else if (g_nAppMode == MODE_LOGO)
{
Sleep(100); // Stop process hogging CPU
}
}
}

View File

@ -9206,11 +9206,11 @@ void DebuggerCursorUpdate()
return;
const int nUpdatesPerSecond = 4;
const DWORD nHz = 1000 / nUpdatesPerSecond;
const DWORD nUpdateInternal_ms = 1000 / nUpdatesPerSecond;
static DWORD nBeg = GetTickCount(); // timeGetTime();
DWORD nNow = GetTickCount(); // timeGetTime();
if (((nNow - nBeg)) >= nHz)
if (((nNow - nBeg)) >= nUpdateInternal_ms)
{
nBeg = nNow;
@ -9220,6 +9220,10 @@ void DebuggerCursorUpdate()
DrawConsoleCursor();
FrameReleaseDC();
}
else
{
Sleep(10); // Stop process hogging CPU
}
}

View File

@ -3151,7 +3151,7 @@ void UpdateDisplay (Update_t bUpdate)
if (bUpdate & UPDATE_BACKGROUND)
{
#if USE_APPLE_FONT
VideoDrawLogoBitmap( g_hFrameDC );
//VideoDrawLogoBitmap( g_hFrameDC ); // TC: Remove purple-flash after every single-step
SetBkMode( g_hFrameDC, OPAQUE);
SetBkColor(g_hFrameDC, RGB(0,0,0));

View File

@ -29,6 +29,14 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "StdAfx.h"
#pragma hdrstop
#define LOG_DISK_ENABLED 1
#if LOG_DISK_ENABLED
#define LOG_DISK(format, ...) LOG(format, __VA_ARGS__)
#else
#define LOG_DISK(...)
#endif
// Public _________________________________________________________________________________________
BOOL enhancedisk = 1;
@ -55,14 +63,15 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
int nibbles;
};
static int currdrive = 0;
static WORD currdrive = 0;
static BOOL diskaccessed = 0;
static Disk_t g_aFloppyDisk[DRIVES];
static BYTE floppylatch = 0;
static BOOL floppymotoron = 0;
static BOOL floppywritemode = 0;
static WORD phases; // state bits for stepper magnet phases 0 - 3
static void ChecSpinning();
static void CheckSpinning();
static Disk_Status_e GetDriveLightStatus( const int iDrive );
static bool IsDriveValid( const int iDrive );
static void ReadTrack (int drive);
@ -187,6 +196,7 @@ static void ReadTrack (int iDrive)
if (pFloppy->trackimage && pFloppy->imagehandle)
{
LOG_DISK("read track %2X%s\r", pFloppy->track, (pFloppy->phase & 1) ? ".5" : "");
ImageReadTrack(
pFloppy->imagehandle,
pFloppy->track,
@ -268,26 +278,54 @@ BYTE __stdcall DiskControlMotor (WORD, BYTE address, BYTE, BYTE, ULONG) {
}
//===========================================================================
BYTE __stdcall DiskControlStepper (WORD, BYTE address, BYTE, BYTE, ULONG) {
BYTE __stdcall DiskControlStepper (WORD, BYTE address, BYTE, BYTE, ULONG)
{
Disk_t * fptr = &g_aFloppyDisk[currdrive];
if (address & 1) {
int phase = (address >> 1) & 3;
int direction = 0;
if (phase == ((fptr->phase+1) & 3))
direction = 1;
if (phase == ((fptr->phase+3) & 3))
direction = -1;
if (direction) {
fptr->phase = MAX(0,MIN(79,fptr->phase+direction));
if (!(fptr->phase & 1)) {
int newtrack = MIN(TRACKS-1,fptr->phase >> 1);
if (newtrack != fptr->track) {
if (fptr->trackimage && fptr->trackimagedirty)
WriteTrack(currdrive);
fptr->track = newtrack;
fptr->trackimagedata = 0;
}
int phase = (address >> 1) & 3;
int phase_bit = (1 << phase);
// update the magnet states
if (address & 1)
{
// phase on
phases |= phase_bit;
LOG_DISK("track %02X phases %X phase %d on address $C0E%X\r", fptr->phase, phases, phase, address & 0xF);
}
else
{
// phase off
phases &= ~phase_bit;
LOG_DISK("track %02X phases %X phase %d off address $C0E%X\r", fptr->phase, phases, phase, address & 0xF);
}
// check for any stepping effect from a magnet
// - move only when the magnet opposite the cog is off
// - move in the direction of an adjacent magnet if one is on
// - do not move if both adjacent magnets are on
// momentum and timing are not accounted for ... maybe one day!
int direction = 0;
if ((phases & (1 << fptr->phase)) == 0)
{
if (phases & (1 << ((fptr->phase + 1) & 3)))
direction += 1;
if (phases & (1 << ((fptr->phase + 3) & 3)))
direction -= 1;
}
// apply magnet step, if any
if (direction)
{
fptr->phase = MAX(0, MIN(79, fptr->phase + direction));
int newtrack = MIN(TRACKS-1, fptr->phase >> 1); // (round half tracks down)
LOG_DISK("newtrack %2X%s\r", newtrack, (fptr->phase & 1) ? ".5" : "");
if (newtrack != fptr->track)
{
if (fptr->trackimage && fptr->trackimagedirty)
{
WriteTrack(currdrive);
}
fptr->track = newtrack;
fptr->trackimagedata = 0;
}
}
return (address == 0xE0) ? 0xFF : MemReturnRandomData(1);
@ -455,6 +493,12 @@ BYTE __stdcall DiskReadWrite (WORD programcounter, BYTE, BYTE, BYTE, ULONG) {
return 0;
else
result = *(fptr->trackimage+fptr->byte);
#if LOG_DISK_ENABLED
if (0)
{
LOG_DISK("nib %4X = %2X\r", fptr->byte, result);
}
#endif
if (++fptr->byte >= fptr->nibbles)
fptr->byte = 0;
return result;
@ -463,6 +507,7 @@ BYTE __stdcall DiskReadWrite (WORD programcounter, BYTE, BYTE, BYTE, ULONG) {
//===========================================================================
void DiskReset () {
floppymotoron = 0;
phases = 0;
}
//===========================================================================
@ -592,12 +637,13 @@ bool DiskDriveSwap()
DWORD DiskGetSnapshot(SS_CARD_DISK2* pSS, DWORD dwSlot)
{
pSS->Hdr.UnitHdr.dwLength = sizeof(SS_CARD_DISK2);
pSS->Hdr.UnitHdr.dwVersion = MAKE_VERSION(1,0,0,1);
pSS->Hdr.UnitHdr.dwVersion = MAKE_VERSION(1,0,0,2);
pSS->Hdr.dwSlot = dwSlot;
pSS->Hdr.dwType = CT_Disk2;
pSS->currdrive = currdrive;
pSS->phases = phases; // new in 1.0.0.2 disk snapshots
pSS->currdrive = currdrive; // this was an int in 1.0.0.1 disk snapshots
pSS->diskaccessed = diskaccessed;
pSS->enhancedisk = enhancedisk;
pSS->floppylatch = floppylatch;
@ -628,10 +674,13 @@ DWORD DiskGetSnapshot(SS_CARD_DISK2* pSS, DWORD dwSlot)
DWORD DiskSetSnapshot(SS_CARD_DISK2* pSS, DWORD /*dwSlot*/)
{
if(pSS->Hdr.UnitHdr.dwVersion != MAKE_VERSION(1,0,0,1))
return -1;
if(pSS->Hdr.UnitHdr.dwVersion > MAKE_VERSION(1,0,0,2))
{
return -1;
}
currdrive = pSS->currdrive;
phases = pSS->phases; // new in 1.0.0.2 disk snapshots
currdrive = pSS->currdrive; // this was an int in 1.0.0.1 disk snapshots
diskaccessed = pSS->diskaccessed;
enhancedisk = pSS->enhancedisk;
floppylatch = pSS->floppylatch;

View File

@ -338,16 +338,17 @@ DWORD NibblizeTrack (LPBYTE trackimagebuffer, BOOL dosorder, int track) {
*(imageptr++) = 0xD5;
*(imageptr++) = 0xAA;
*(imageptr++) = 0x96;
*(imageptr++) = 0xFF;
*(imageptr++) = 0xFE;
#define VOLUME 0xFE
#define CODE44A(a) ((((a) >> 1) & 0x55) | 0xAA)
#define CODE44B(a) (((a) & 0x55) | 0xAA)
*(imageptr++) = CODE44A(VOLUME);
*(imageptr++) = CODE44B(VOLUME);
*(imageptr++) = CODE44A((BYTE)track);
*(imageptr++) = CODE44B((BYTE)track);
*(imageptr++) = CODE44A(sector);
*(imageptr++) = CODE44B(sector);
*(imageptr++) = CODE44A(0xFE ^ ((BYTE)track) ^ sector);
*(imageptr++) = CODE44B(0xFE ^ ((BYTE)track) ^ sector);
*(imageptr++) = CODE44A(VOLUME ^ ((BYTE)track) ^ sector);
*(imageptr++) = CODE44B(VOLUME ^ ((BYTE)track) ^ sector);
#undef CODE44A
#undef CODE44B
*(imageptr++) = 0xDE;

View File

@ -521,6 +521,7 @@ LRESULT CALLBACK FrameWndProc (
ImageDestroy();
HD_Cleanup();
}
PrintDestroy();
CommDestroy();
CpuDestroy();
MemDestroy();
@ -1071,6 +1072,7 @@ void ResetMachineState () {
DiskBoot();
VideoResetState();
CommReset();
PrintReset();
JoyReset();
MB_Reset();
SpkrReset();

45
AppleWin/source/Log.cpp Normal file
View File

@ -0,0 +1,45 @@
/*
AppleWin : An Apple //e emulator for Windows
Copyright (C) 1994-1996, Michael O'Brien
Copyright (C) 1999-2001, Oliver Schmidt
Copyright (C) 2002-2005, Tom Charlesworth
Copyright (C) 2006, Tom Charlesworth, Michael Pohoreski
AppleWin is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
AppleWin is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with AppleWin; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Description: Log
*
* Author: Nick Westgate
*/
#include "StdAfx.h"
#pragma hdrstop
//---------------------------------------------------------------------------
void LogOutput(LPCTSTR format, ...)
{
TCHAR output[256];
va_list args;
va_start(args, format);
_vsntprintf(output, sizeof(output) - 1, format, args);
OutputDebugString(output);
}
//---------------------------------------------------------------------------

9
AppleWin/source/Log.h Normal file
View File

@ -0,0 +1,9 @@
#pragma once
#if _DEBUG
#define LOG(format, ...) LogOutput(format, __VA_ARGS__)
#else
#define LOG(...)
#endif
extern void LogOutput(LPCTSTR format, ...);

View File

@ -201,22 +201,22 @@ iofunction ioread[0x100] = {KeybReadData, // $C000
MemSetPaging, // $C08D
MemSetPaging, // $C08E
MemSetPaging, // $C08F
NullIo, // $C090
NullIo, // $C091
NullIo, // $C092
NullIo, // $C093
NullIo, // $C094
NullIo, // $C095
NullIo, // $C096
NullIo, // $C097
NullIo, // $C098
NullIo, // $C099
NullIo, // $C09A
NullIo, // $C09B
NullIo, // $C09C
NullIo, // $C09D
NullIo, // $C09E
NullIo, // $C09F
PrintStatus, // $C090
PrintStatus, // $C091
PrintStatus, // $C092
PrintStatus, // $C093
PrintStatus, // $C094
PrintStatus, // $C095
PrintStatus, // $C096
PrintStatus, // $C097
PrintStatus, // $C098
PrintStatus, // $C099
PrintStatus, // $C09A
PrintStatus, // $C09B
PrintStatus, // $C09C
PrintStatus, // $C09D
PrintStatus, // $C09E
PrintStatus, // $C09F
NullIo, // $C0A0
CommDipSw, // $C0A1
CommDipSw, // $C0A2
@ -464,22 +464,22 @@ iofunction iowrite[0x100] = {MemSetPaging, // $C000
MemSetPaging, // $C08D
MemSetPaging, // $C08E
MemSetPaging, // $C08F
NullIo, // $C090
NullIo, // $C091
NullIo, // $C092
NullIo, // $C093
NullIo, // $C094
NullIo, // $C095
NullIo, // $C096
NullIo, // $C097
NullIo, // $C098
NullIo, // $C099
NullIo, // $C09A
NullIo, // $C09B
NullIo, // $C09C
NullIo, // $C09D
NullIo, // $C09E
NullIo, // $C09F
PrintTransmit, // $C090
PrintTransmit, // $C091
PrintTransmit, // $C092
PrintTransmit, // $C093
PrintTransmit, // $C094
PrintTransmit, // $C095
PrintTransmit, // $C096
PrintTransmit, // $C097
PrintTransmit, // $C098
PrintTransmit, // $C099
PrintTransmit, // $C09A
PrintTransmit, // $C09B
PrintTransmit, // $C09C
PrintTransmit, // $C09D
PrintTransmit, // $C09E
PrintTransmit, // $C09F
NullIo, // $C0A0
NullIo, // $C0A1
NullIo, // $C0A2
@ -945,6 +945,7 @@ void MemInitialize () {
*(memrom+0x064E) = 0xEA;
HD_Load_Rom(memrom); // HDD f/w gets loaded to $C700
PrintLoadRom(memrom); // parallel printer firmware gets loaded to $C100
MemReset();
}

View File

@ -0,0 +1,130 @@
/*
AppleWin : An Apple //e emulator for Windows
Copyright (C) 1994-1996, Michael O'Brien
Copyright (C) 1999-2001, Oliver Schmidt
Copyright (C) 2002-2005, Tom Charlesworth
Copyright (C) 2006, Tom Charlesworth, Michael Pohoreski
Copyright (C) 2006, Nick Westgate
AppleWin is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
AppleWin is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with AppleWin; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Description: Parallel Printer Interface Card emulation
*
* Author: Nick Westgate
*/
#include "StdAfx.h"
#pragma hdrstop
#include "..\resource\resource.h"
static DWORD inactivity = 0;
static FILE* file = NULL;
DWORD const PRINTDRVR_SIZE = 0x100;
//===========================================================================
VOID PrintLoadRom(LPBYTE lpMemRom)
{
HRSRC hResInfo = FindResource(NULL, MAKEINTRESOURCE(IDR_PRINTDRVR), "FIRMWARE");
if(hResInfo == NULL)
return;
DWORD dwResSize = SizeofResource(NULL, hResInfo);
if(dwResSize != PRINTDRVR_SIZE)
return;
HGLOBAL hResData = LoadResource(NULL, hResInfo);
if(hResData == NULL)
return;
BYTE* pData = (BYTE*) LockResource(hResData); // NB. Don't need to unlock resource
if(pData == NULL)
return;
memcpy(lpMemRom + 0x100, pData, PRINTDRVR_SIZE);
}
//===========================================================================
static BOOL CheckPrint()
{
inactivity = 0;
if (file == NULL)
{
TCHAR filepath[MAX_PATH * 2];
_tcsncpy(filepath, g_sProgramDir, MAX_PATH);
_tcsncat(filepath, _T("Printer.txt"), MAX_PATH);
file = fopen(filepath, "wb");
}
return (file != NULL);
}
//===========================================================================
static void ClosePrint()
{
if (file != NULL)
{
fclose(file);
file = NULL;
}
inactivity = 0;
}
//===========================================================================
void PrintDestroy()
{
ClosePrint();
}
//===========================================================================
void PrintUpdate(DWORD totalcycles)
{
if (file == NULL)
{
return;
}
if ((inactivity += totalcycles) > (5 * 1000 * 1000)) // around 5 seconds
{
// inactive, so close the file (next print will overwrite it)
ClosePrint();
}
}
//===========================================================================
void PrintReset()
{
ClosePrint();
}
//===========================================================================
BYTE __stdcall PrintStatus(WORD, BYTE, BYTE, BYTE, ULONG)
{
CheckPrint();
return 0xFF; // status - TODO?
}
//===========================================================================
BYTE __stdcall PrintTransmit(WORD, BYTE, BYTE, BYTE value, ULONG)
{
if (!CheckPrint())
{
return 0;
}
char c = value & 0x7F;
fwrite(&c, 1, 1, file);
return 0;
}
//===========================================================================

View File

@ -0,0 +1,9 @@
#pragma once
void PrintDestroy();
void PrintLoadRom(LPBYTE);
void PrintReset();
void PrintUpdate(DWORD);
BYTE __stdcall PrintStatus (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
BYTE __stdcall PrintTransmit (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);

View File

@ -1,4 +1,4 @@
#define WIN32_LEAN_AND_ME
//#define WIN32_LEAN_AND_MEAN
// Mouse Wheel is not supported on Win95.
// If we didn't care about supporting Win95 (compile/run-time errors)
@ -41,8 +41,10 @@
#include "Harddisk.h"
#include "Joystick.h"
#include "Keyboard.h"
#include "Log.h"
#include "Memory.h"
#include "Mockingboard.h"
#include "ParallelPrinter.h"
#include "PropertySheetPage.h"
#include "Registry.h"
#include "Riff.h"

View File

@ -179,7 +179,8 @@ typedef struct
{
SS_CARD_HDR Hdr;
DISK2_Unit Unit[2];
int currdrive;
WORD phases;
WORD currdrive;
BOOL diskaccessed;
BOOL enhancedisk;
BYTE floppylatch;