Skip to content

Commit

Permalink
Moved QuickLoad to library
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Hood committed Feb 22, 2021
1 parent 70f0fc4 commit d4ea7fc
Show file tree
Hide file tree
Showing 13 changed files with 228 additions and 273 deletions.
2 changes: 1 addition & 1 deletion EmuLoop.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include "library/Throttle.h"
#include "library/DirectDraw.h"
#include "library/PAKInterface.h"
#include "library/QuickLoad.h"

#include "quickload.h"
#include "HardReset.h"
#include "SoftReset.h"
#include "UpdateConfig.h"
Expand Down
1 change: 0 additions & 1 deletion LoadConfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "library/fileoperations.h"
#include "library/Audio.h"

#include "ReadIniFile.h"
#include "UpdateConfig.h"
#include "GetSoundCardList.h"
#include "SoundInit.h"
Expand Down
1 change: 0 additions & 1 deletion LoadIniFile.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "library/VCC.h"
#include "library/Config.h"

#include "ReadIniFile.h"
#include "UpdateConfig.h"

// LoadIniFile allows user to browse for an ini file and reloads the config from it.
Expand Down
118 changes: 0 additions & 118 deletions ReadIniFile.c

This file was deleted.

5 changes: 0 additions & 5 deletions ReadIniFile.h

This file was deleted.

4 changes: 0 additions & 4 deletions Vcc.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@
<ClCompile Include="MC6809Reset.c" />
<ClCompile Include="mc6809_i.c" />
<ClCompile Include="MiscConfig.c" />
<ClCompile Include="quickload.c" />
<ClCompile Include="ReadIniFile.c" />
<ClCompile Include="RenderFrame.c" />
<ClCompile Include="SendSavedKeyEvents.c" />
<ClCompile Include="SoftReset.c" />
Expand Down Expand Up @@ -268,8 +266,6 @@
<ClInclude Include="MC6809Reset.h" />
<ClInclude Include="mc6809_i.h" />
<ClInclude Include="MiscConfig.h" />
<ClInclude Include="quickload.h" />
<ClInclude Include="ReadIniFile.h" />
<ClInclude Include="RenderFrame.h" />
<ClInclude Include="SendSavedKeyEvents.h" />
<ClInclude Include="SoftReset.h" />
Expand Down
122 changes: 118 additions & 4 deletions library/Config.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
#include <string>

#include "../resources/resource.h"
#include "systemstate.h"
#include "fileoperations.h"
#include "DirectDraw.h"
#include "PAKInterface.h"

#include "Config.h"
#include "DirectDraw.h"
#include "PAKInterface.h"
#include "Keyboard.h"
#include "Cassette.h"
#include "Joystick.h"
#include "MC6821.h"

#include "systemstate.h"
#include "fileoperations.h"

#include "macros.h"

using namespace std;
Expand Down Expand Up @@ -482,4 +484,116 @@ extern "C" {

return(1);
}
}

void SetWindowSize(POINT p) {
int width = p.x + 16;
int height = p.y + 81;

HWND handle = GetActiveWindow();

SetWindowPos(handle, 0, 0, 0, width, height, SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER);
}

extern "C" {
__declspec(dllexport) unsigned char __cdecl ReadIniFile(SystemState* systemState)
{
HANDLE hr = NULL;
POINT p = POINT();
unsigned char index = 0;

ConfigState* configState = GetConfigState();

//Loads the config structure from the hard disk
configState->CurrentConfig.CPUMultiplyer = GetProfileByte("CPU", "DoubleSpeedClock", 2);
configState->CurrentConfig.FrameSkip = GetProfileByte("CPU", "FrameSkip", 1);
configState->CurrentConfig.SpeedThrottle = GetProfileByte("CPU", "Throttle", 1);
configState->CurrentConfig.CpuType = GetProfileByte("CPU", "CpuType", 0);
configState->CurrentConfig.MaxOverclock = GetProfileShort("CPU", "MaxOverClock", 227);

configState->CurrentConfig.AudioRate = GetProfileShort("Audio", "Rate", 3);

GetPrivateProfileString("Audio", "SndCard", "", configState->CurrentConfig.SoundCardName, 63, configState->IniFilePath);

configState->CurrentConfig.MonitorType = GetProfileByte("Video", "MonitorType", 1);
configState->CurrentConfig.PaletteType = GetProfileByte("Video", "PaletteType", 1);
configState->CurrentConfig.ScanLines = GetProfileByte("Video", "ScanLines", 0);

configState->CurrentConfig.Resize = GetProfileByte("Video", "AllowResize", 0);
configState->CurrentConfig.Aspect = GetProfileByte("Video", "ForceAspect", 0);
configState->CurrentConfig.RememberSize = GetProfileShort("Video", "RememberSize", 0);
configState->CurrentConfig.WindowSizeX = GetProfileShort("Video", "WindowSizeX", 640);
configState->CurrentConfig.WindowSizeY = GetProfileShort("Video", "WindowSizeY", 480);
configState->CurrentConfig.AutoStart = GetProfileByte("Misc", "AutoStart", 1);
configState->CurrentConfig.CartAutoStart = GetProfileByte("Misc", "CartAutoStart", 1);

configState->CurrentConfig.RamSize = GetProfileByte("Memory", "RamSize", 1);

GetProfileText("Memory", "ExternalBasicImage", "", configState->CurrentConfig.ExternalBasicImage);

GetProfileText("Module", "OnBoot", "", configState->CurrentConfig.ModulePath);

configState->CurrentConfig.KeyMap = GetProfileByte("Misc", "KeyMapIndex", 0);

if (configState->CurrentConfig.KeyMap > 3) {
configState->CurrentConfig.KeyMap = 0; //Default to DECB Mapping
}

vccKeyboardBuildRuntimeTable((keyboardlayout_e)(configState->CurrentConfig.KeyMap));

FileCheckPath(configState->CurrentConfig.ModulePath);
FileCheckPath(configState->CurrentConfig.ExternalBasicImage);

JoystickState* joystickState = GetJoystickState();

joystickState->Left.UseMouse = GetProfileByte("LeftJoyStick", "UseMouse", 1);
joystickState->Left.Left = GetProfileByte("LeftJoyStick", "Left", 75);
joystickState->Left.Right = GetProfileByte("LeftJoyStick", "Right", 77);
joystickState->Left.Up = GetProfileByte("LeftJoyStick", "Up", 72);
joystickState->Left.Down = GetProfileByte("LeftJoyStick", "Down", 80);
joystickState->Left.Fire1 = GetProfileByte("LeftJoyStick", "Fire1", 59);
joystickState->Left.Fire2 = GetProfileByte("LeftJoyStick", "Fire2", 60);
joystickState->Left.DiDevice = GetProfileByte("LeftJoyStick", "DiDevice", 0);
joystickState->Left.HiRes = GetProfileByte("LeftJoyStick", "HiResDevice", 0);
joystickState->Right.UseMouse = GetProfileByte("RightJoyStick", "UseMouse", 1);
joystickState->Right.Left = GetProfileByte("RightJoyStick", "Left", 75);
joystickState->Right.Right = GetProfileByte("RightJoyStick", "Right", 77);
joystickState->Right.Up = GetProfileByte("RightJoyStick", "Up", 72);
joystickState->Right.Down = GetProfileByte("RightJoyStick", "Down", 80);
joystickState->Right.Fire1 = GetProfileByte("RightJoyStick", "Fire1", 59);
joystickState->Right.Fire2 = GetProfileByte("RightJoyStick", "Fire2", 60);
joystickState->Right.DiDevice = GetProfileByte("RightJoyStick", "DiDevice", 0);
joystickState->Right.HiRes = GetProfileByte("RightJoyStick", "HiResDevice", 0);

GetProfileText("DefaultPaths", "CassPath", "", configState->CurrentConfig.CassPath);
GetProfileText("DefaultPaths", "FloppyPath", "", configState->CurrentConfig.FloppyPath);
GetProfileText("DefaultPaths", "COCO3ROMPath", "", configState->CurrentConfig.COCO3ROMPath);

for (index = 0; index < configState->NumberOfSoundCards; index++) {
if (!strcmp(configState->SoundCards[index].CardName, configState->CurrentConfig.SoundCardName)) {
configState->CurrentConfig.SndOutDev = index;
}
}

configState->TempConfig = configState->CurrentConfig;

InsertModule(systemState, configState->CurrentConfig.ModulePath); // Should this be here?

configState->CurrentConfig.Resize = 1; //Checkbox removed. Remove this from the ini?

if (configState->CurrentConfig.RememberSize) {
p.x = configState->CurrentConfig.WindowSizeX;
p.y = configState->CurrentConfig.WindowSizeY;

SetWindowSize(p);
}
else {
p.x = 640;
p.y = 480;

SetWindowSize(p);
}

return(0);
}
}
1 change: 1 addition & 0 deletions library/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,4 @@ extern "C" __declspec(dllexport) unsigned char __cdecl TranslateScan2Display(int

extern "C" __declspec(dllexport) void __cdecl RefreshJoystickStatus(void);
extern "C" __declspec(dllexport) int __cdecl SelectFile(SystemState* systemState, char* filename);
extern "C" __declspec(dllexport) unsigned char __cdecl ReadIniFile(SystemState* systemState);
Loading

0 comments on commit d4ea7fc

Please sign in to comment.