Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 27 additions & 22 deletions Vcc.cpp
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
/*
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 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/>.
//======================================================================

/*---------------------------------------------------------------------*/
//#define STRICT
//#define WIN32_LEAN_AND_MEAN
/*--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------*/

// FIXME: This should be defined on the command line
#define DIRECTINPUT_VERSION 0x0800
Expand Down Expand Up @@ -604,6 +604,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
return 0;
break;

// Don't send click that activates window to emulation
case WM_MOUSEACTIVATE:
return MA_ACTIVATEANDEAT;
break;

case WM_LBUTTONDOWN: //0 = Left 1=right
SetButtonStatus(0,1);
break;
Expand Down
25 changes: 25 additions & 0 deletions docs/namespaces.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
We let namspaces get a bit overboard. Namespaces are for preventing
name collisions, not to fully classify sources or to define directory
or common library structures.

Also we let the case of the VCC namespace change. This gains nothing
but confusion. I see two choices here. a) go all lowercase or
b) use CamelCase. Since we already had CamelCase I suggest we stick
with it:

Valid VCC namespaces

VCC // The VCC core emulator
VCC::UI // The VCC core user interface (future)
VCC::Util // Generic utilities used by VCC
VCC::Debugger // Coco Debugger code
VCC::Debugger::UI // Coco Debugger user interface

The following are invalid and should be changed when touched:

namespace vcc -> namespace VCC
namespace vcc::core -> namespace VCC
namespace vcc::core::cartridges -> namespace VCC
namespace vcc::core::utils -> namespace VCC::Util
namespace vcc::devices::rtc -> namespace VCC
namespace vcc::modules::mpi -> namespace VCC
24 changes: 0 additions & 24 deletions joystickinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,14 @@ static unsigned char RightButton1Status = 0;
static unsigned char LeftButton2Status = 0;
static unsigned char RightButton2Status = 0;

// FIXME Direct input not working for ARM - disable joysticks for arm builds
#ifdef _M_ARM
unsigned int Joysticks[MAXSTICKS] = {nullptr};
#else
static LPDIRECTINPUTDEVICE8 Joysticks[MAXSTICKS];
#endif

char StickName[MAXSTICKS][STRLEN];
static unsigned char JoyStickIndex=0;

#ifdef _M_ARM
#else
static LPDIRECTINPUT8 di;
BOOL CALLBACK enumCallback(const DIDEVICEINSTANCE* , VOID* );
BOOL CALLBACK enumAxesCallback(const DIDEVICEOBJECTINSTANCE* , VOID* );
#endif

static unsigned char CurrentStick;

Expand All @@ -131,9 +123,6 @@ inline int vccJoystickType();
// Locate connected joysticks. Called by config.c
int EnumerateJoysticks()
{
#ifdef _M_ARM
return(0);
#else
HRESULT hr;
JoyStickIndex=0;
if (FAILED(hr = DirectInput8Create(GetModuleHandle(nullptr),
Expand All @@ -145,11 +134,9 @@ int EnumerateJoysticks()
return 0;

return JoyStickIndex;
#endif
}

/*****************************************************************************/
#ifndef _M_ARM
BOOL CALLBACK enumCallback(const DIDEVICEINSTANCE* instance, VOID* /*context*/)
{
HRESULT hr;
Expand All @@ -158,13 +145,11 @@ BOOL CALLBACK enumCallback(const DIDEVICEINSTANCE* instance, VOID* /*context*/)
JoyStickIndex++;
return(JoyStickIndex<MAXSTICKS);
}
#endif

/*****************************************************************************/
// Init joystick called by config.c
bool InitJoyStick (unsigned char StickNumber)
{
#ifndef _M_ARM
HRESULT hr;
CurrentStick=StickNumber;
if (Joysticks[StickNumber]==nullptr)
Expand All @@ -177,13 +162,9 @@ bool InitJoyStick (unsigned char StickNumber)
return false;

return true; //return true on success
#else
return(1);
#endif
}

/*****************************************************************************/
#ifndef _M_ARM
BOOL CALLBACK enumAxesCallback(const DIDEVICEOBJECTINSTANCE* instance, VOID* /*context*/)
{
DIPROPRANGE propRange;
Expand All @@ -199,11 +180,9 @@ BOOL CALLBACK enumAxesCallback(const DIDEVICEOBJECTINSTANCE* instance, VOID* /*c

return DIENUM_CONTINUE;
}
#endif

/*****************************************************************************/
// Called by get_pot_value to read data from physical joystick
#ifndef _M_ARM
HRESULT
JoyStickPoll(DIJOYSTATE2 *js,unsigned char StickNumber)
{
Expand All @@ -228,7 +207,6 @@ JoyStickPoll(DIJOYSTATE2 *js,unsigned char StickNumber)
return hr;
return(S_OK);
}
#endif

/*****************************************************************************/
// inline function returns joystick emulation type
Expand Down Expand Up @@ -365,7 +343,6 @@ SetStickNumbers(unsigned char Temp1,unsigned char Temp2)
unsigned int
get_pot_value(unsigned char pot)
{
#ifndef _M_ARM
DIJOYSTATE2 Stick1 = { 0 };

// Poll left joystick if attached
Expand All @@ -385,7 +362,6 @@ get_pot_value(unsigned char pot)
RightButton1Status= Stick1.rgbButtons[0]>>7;
RightButton2Status= Stick1.rgbButtons[1]>>7;
}
#endif

switch (pot) {
case 0:
Expand Down
42 changes: 24 additions & 18 deletions keyboard.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
/*****************************************************************************/
/*
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.
//#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/>.
//======================================================================

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/>.
*/
/*****************************************************************************/
/*
Keyboard handling / translation - system -> emulator
Expand Down Expand Up @@ -50,7 +52,7 @@ This file is part of VCC (Virtual Color Computer).

#include <queue>
#include <sstream>

#include <vcc/core/logger.h>

/*****************************************************************************/
/*
Expand Down Expand Up @@ -244,6 +246,9 @@ void _vccKeyboardUpdateRolloverTable()

void vccKeyboardHandleKey(unsigned char ScanCode, keyevent_e keyState)
{

DLOG_C("HandleKey %d %d\n",ScanCode,keyState);

//If requested, abort pasting operation.
if (ScanCode == 0x01 || ScanCode == 0x43 || ScanCode == 0x3F) { pasting = false; }

Expand All @@ -253,6 +258,7 @@ void vccKeyboardHandleKey(unsigned char ScanCode, keyevent_e keyState)
{
ScanCode = DIK_LSHIFT;
}

#if 0 // TODO: CTRL and/or ALT?
// CTRL key - right -> left
if (ScanCode == DIK_RCONTROL)
Expand Down
6 changes: 2 additions & 4 deletions libcommon/include/vcc/core/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@
#include <string>
#include <Windows.h>

//TODO replace get_directory_from_path and get_filename with fileutil functions
//TODO move find_pak_module_path to point of use
namespace vcc::core::utils
{

LIBCOMMON_EXPORT std::string get_module_path(HMODULE module_handle = nullptr);
LIBCOMMON_EXPORT std::string find_pak_module_path(std::string path);
LIBCOMMON_EXPORT std::string get_directory_from_path(std::string path);
LIBCOMMON_EXPORT std::string get_filename(std::string path);
LIBCOMMON_EXPORT std::string strip_application_path(std::string path);

}
62 changes: 62 additions & 0 deletions libcommon/include/vcc/core/fileutil.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//======================================================================
// General purpose Host file utilities. EJ Jaquay 2026
//
// 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/>.
//
//======================================================================
#pragma once

#include <string>
#include <filesystem>
#include <Shlwapi.h>

// FIXME: directory names in libcommon are wrong
// libcommon/include/vcc/core should be libcommon/include/vcc/util
// libcommon/src/core should be libcommon/include/util

//=========================================================================
// Host file utilities. Most of these are general purpose
//=========================================================================

namespace VCC::Util {

// Get most recent windows error text
std::string LastErrorString();
const char * LastErrorTxt();

// Convert backslashes to slashes in directory string
void FixDirSlashes(std::string &dir);

// Return copy of string with spaces trimmed from end of a string
std::string trim_right_spaces(const std::string &s);

// Return slash normalized directory part of a path
std::string GetDirectoryPart(const std::string& input);

// Return filename part of a path
std::string GetFileNamePart(const std::string& input);

// Determine if path is a direcory
bool IsDirectory(const std::string& path);

// Get path of loaded module or current application
std::string get_module_path(HMODULE module_handle);

// If path is in the application directory strip directory
std::string strip_application_path(std::string path);
}
2 changes: 2 additions & 0 deletions libcommon/libcommon.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
<ClCompile Include="src\core\DialogOps.cpp" />
<ClCompile Include="src\core\Fileops.cpp" />
<ClCompile Include="src\core\logger.cpp" />
<ClCompile Include="src\core\fileutil.cpp" />
<ClCompile Include="src\devices\cloud9.cpp" />
<ClCompile Include="src\main.cpp" />
</ItemGroup>
Expand All @@ -138,6 +139,7 @@
<ClInclude Include="include\vcc\core\interrupts.h" />
<ClInclude Include="include\vcc\core\limits.h" />
<ClInclude Include="include\vcc\core\logger.h" />
<ClInclude Include="include\vcc\core\fileutil.h" />
<ClInclude Include="include\vcc\core\initial_settings.h" />
<ClInclude Include="include\vcc\core\critical_section.h" />
<ClInclude Include="include\vcc\core\filesystem.h" />
Expand Down
3 changes: 3 additions & 0 deletions libcommon/src/core/FileOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
// 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/>.
////////////////////////////////////////////////////////////////////////////////

// TODO: FileOps should be depreciated and functions moved to fileutil.cpp

#include <Windows.h>
#include <stdio.h>
#include <stdbool.h>
Expand Down
Loading