Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #28

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions .github/workflows/build_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v3
Expand All @@ -23,8 +23,7 @@ jobs:
sudo apt-get install xorg-dev libx11-xcb-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-xkb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-xinerama0-dev libxcb-dri3-dev libxcb-util-dev --fix-missing
sudo apt-get install libxinerama-dev libxcursor-dev --fix-missing
sudo apt-get install libudev-dev libglu1-mesa-dev libsecret-1-dev libnotify-dev --fix-missing
sudo apt-get install checkinstall libtiff5-dev ubuntu-restricted-extras freeglut3 freeglut3-dev libcairo2-dev --fix-missing
sudo apt-get install libgconf2-dev --fix-missing
sudo apt-get install checkinstall libtiff5-dev ubuntu-restricted-extras freeglut3-dev libcairo2-dev --fix-missing

- name: Checkout submodules
run: git submodule update --init --recursive
Expand All @@ -44,7 +43,7 @@ jobs:
cmake --install ${{github.workspace}}/build

- name: Archive
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: CPCCore_linux
path: |
Expand All @@ -54,4 +53,5 @@ jobs:
${{github.workspace}}/build/UnitTests/Release/CONF/
${{github.workspace}}/build/UnitTests/Release/CART/
${{github.workspace}}/build/UnitTests/Release/ROM/
${{github.workspace}}/build/UnitTests/Release/Keyboards/

10 changes: 8 additions & 2 deletions .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
run: git submodule update --init --recursive

- name: Configure CMake
run: cmake -B ${{github.workspace}}\build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DGENERATE_UNITTESTS=TRUE -DCMAKE_INSTALL_PREFIX=${{github.workspace}}\install -AWin32
run: cmake -B ${{github.workspace}}\build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DGENERATE_UNITTESTS=TRUE -DCMAKE_INSTALL_PREFIX=${{github.workspace}}\install

- name: Build
# Build your program with the given configuration
Expand All @@ -31,13 +31,19 @@ jobs:
dir ${{github.workspace}}\build\UnitTests\Release

- name: Archive zip
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: CPCCore_Win
path: |
${{github.workspace}}/build/UnitTests/Release/unitTests.exe
${{github.workspace}}/build/UnitTests/Release/TestConf.ini
${{github.workspace}}/build/UnitTests/Release/TestConf_0.ini
${{github.workspace}}/build/UnitTests/Release/TestConf_1.ini
${{github.workspace}}/build/UnitTests/Release/TestConf_2.ini
${{github.workspace}}/build/UnitTests/Release/TestConf_3.ini
${{github.workspace}}/build/UnitTests/Release/TestConf_4.ini
${{github.workspace}}/build/UnitTests/Release/res/
${{github.workspace}}/build/UnitTests/Release/CONF/
${{github.workspace}}/build/UnitTests/Release/CART/
${{github.workspace}}/build/UnitTests/Release/ROM/
${{github.workspace}}/build/UnitTests/Release/Keyboards/
2 changes: 1 addition & 1 deletion .github/workflows/test_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: CPCCore_linux

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/test_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ jobs:
runs-on: windows-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: CPCCore_Win

- name: Test
working-directory: ${{github.workspace}}
run: |
dir
dir Keyboards
.\unitTests.exe

1 change: 1 addition & 0 deletions AmstradCore/IComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <string>
#include <vector>


#define DECLARE_REFERENCE_LINE(l) BusLine *l;
#define DECLARE_REFERENCE_BUS_ADDRESS(b) Bus<unsigned short>*b;
#define DECLARE_REFERENCE_BUS_DATA(b) Bus<unsigned char>*b;
Expand Down
1 change: 1 addition & 0 deletions AmstradCore/Motherboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <string>
#include <vector>


#include "IComponent.h"
#include "BusLine.h"
#include "GateArray.h"
Expand Down
1 change: 1 addition & 0 deletions AmstradCore/Sampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <string>
#include <vector>


#include "SingleLineSample.h"


Expand Down
1 change: 0 additions & 1 deletion AmstradCoreTests/Test_GateArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#else
#define fopen_s(pFile,filename,mode) (((*(pFile))=fopen((filename), (mode))) == NULL)
#include <sys/stat.h>
#define fopen_s(pFile,filename,mode) ((*(pFile))=fopen((filename),(mode)))==NULL
#endif
#endif

Expand Down
1 change: 0 additions & 1 deletion AmstradCoreTests/Test_Z80.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#else
#define fopen_s(pFile,filename,mode) (((*(pFile))=fopen((filename), (mode))) == NULL)
#include <sys/stat.h>
#define fopen_s(pFile,filename,mode) ((*(pFile))=fopen((filename),(mode)))==NULL
#endif
#endif

Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ add_subdirectory(AmstradCore)

if (GENERATE_UNITTESTS)

add_subdirectory(googletest/googletest)
#add_subdirectory(googletest/googletest)
add_subdirectory(googletest)
set (USE_SFML TRUE)
add_subdirectory(UnitTests)
add_subdirectory(AmstradCoreTests)
Expand Down
2 changes: 1 addition & 1 deletion CPCCoreEmu/Breakpoint.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

#pragma once
#include "simple_string.h"
#include <string>

class EmulatorEngine;
class Memory;
Expand Down
2 changes: 1 addition & 1 deletion CPCCoreEmu/CAPSFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.*/

#pragma once

#include "simple_vector.hpp"
#include <vector>
#include "ILoadingProgress.h"
#include "IDisk.h"

Expand Down
10 changes: 9 additions & 1 deletion CPCCoreEmu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,21 @@ set (EXTRA
../.github/workflows/test_windows.yml
)

set (CONFIG
Keyboards/101_keyboard
Keyboards/101_keyboard_win
Keyboards/101_keyboard_linux
)

source_group("Github Action" FILES ${EXTRA} )
source_group("Keyboards" FILES ${CONFIG} )

list(REMOVE_ITEM SRCS ${CMAKE_CURRENT_SOURCE_DIR}/rand.cpp)

#Fichier ressource
MESSAGE ("CMAKE_CURRENT_BINARY_DIR =" ${CMAKE_CURRENT_BINARY_DIR})
include_directories(${INSTALL_INC_DIR} ${CMAKE_CURRENT_BINARY_DIR}/../zlib)
add_library(CPCCoreEmu ${SRCS} ${HEADERS} ${EXTRA})
add_library(CPCCoreEmu ${SRCS} ${HEADERS} ${EXTRA} ${CONFIG} )
target_include_directories( CPCCoreEmu PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../zlib ${CMAKE_CURRENT_BINARY_DIR}/../zlib ${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(CPCCoreEmu PROPERTIES POSITION_INDEPENDENT_CODE ON)

Expand Down Expand Up @@ -62,3 +68,5 @@ endif()
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set ( CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} --std=c++1z )
endif()

install ( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Keyboards" DESTINATION .)
3 changes: 2 additions & 1 deletion CPCCoreEmu/DiskBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ int DiskBuilder::LoadDisk(const char* file_path, IDisk*& created_disk, ILoadingP
{
if ((*it)->CanLoad(file_path))
{
return (*it)->LoadDisk(file_path, created_disk, loading_progress);
if ((*it)->LoadDisk(file_path, created_disk, loading_progress) == 0)
return 0;
}
}

Expand Down
4 changes: 3 additions & 1 deletion CPCCoreEmu/DiskBuilder.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "simple_string.h"
#include <string.h>

#include "ILoadingProgress.h"
#include "IDisk.h"
Expand All @@ -19,6 +19,8 @@ class FormatType
OK = 0
};

virtual ~FormatType(){}

//////////////////////////////////////////////////////////
// Format description : Name, descriptor, extension
virtual const char* GetFormatName() = 0;
Expand Down
6 changes: 3 additions & 3 deletions CPCCoreEmu/DiskContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "DiskContainer.h"
#include "FileAccess.h"
#include "simple_stdio.h"
#include <stdio.h>

#ifndef NOZLIB
#include "zlib.h"
Expand Down Expand Up @@ -120,7 +120,7 @@ NodeFS* NodeFS::InsertNode(std::string node_name)
NodeFS* NodeFS::InsertDir(std::string node_name)
{
// Parse the name to get the complete tree
int pos = node_name.find('/', 0);
size_t pos = node_name.find('/', 0);
if (pos != std::string::npos)
{
// Subdirectory inside :
Expand All @@ -140,7 +140,7 @@ NodeFS* NodeFS::InsertDir(std::string node_name)
NodeFS* NodeFS::InsertFile(std::string node_name, unsigned char* full_buffer)
{
// Parse the name to get the complete tree
int pos = node_name.find('/', 0);
size_t pos = node_name.find('/', 0);
if (pos != std::string::npos)
{
// Subdirectory inside :
Expand Down
4 changes: 2 additions & 2 deletions CPCCoreEmu/DiskContainer.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "simple_vector.hpp"
#include "simple_string.h"
#include <vector>
#include <string>

#define CPCCOREEMU_API

Expand Down
24 changes: 15 additions & 9 deletions CPCCoreEmu/DiskGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
#include "DiskGen.h"
//#include "rand.h"
#include <stdlib.h>
#include "simple_vector.hpp"
#include <vector>
#include "MediaManager.h"

#define LOGFDC
#ifdef __circle__
#include <strings.h>
#define stricmp strcasecmp
#define strnicmp strncasecmp
#endif

#define SPEED_COUNTER 1
#define SPEED_CHANGE 20 /*20000*/
Expand Down Expand Up @@ -366,8 +370,10 @@ IDisk* DiskGen::CreateDisk(const char* path, ILoadingProgress* loading_progress,
FormatType* format;
if (disk_builder_.CanLoad(path, format))
{
LOG ("DiskGen::CreateDisk - CanLoad ok")
if (disk_builder_.LoadDisk(path, new_disk, loading_progress) == 0)
{
LOG ("DiskGen::CreateDisk - LoadDisk ok")
current_disk_format_ = format;
}
}
Expand Down Expand Up @@ -539,13 +545,13 @@ bool CompareStringFromCat(const char* track, const char* searched_string, const
&& strnicmp(file_ext, search_ext, strlen(search_ext)) == 0);
}

int NbIdenticalCar(const char* track, const char* searched_string, int size_max)
size_t NbIdenticalCar(const char* track, const char* searched_string, size_t size_max)
{
int i = 0;
int lg_max = strlen(searched_string);
int nb_car_found = 0;
size_t i = 0;
size_t lg_max = strlen(searched_string);
size_t nb_car_found = 0;

for (int j = 0; j < lg_max; j++)
for (size_t j = 0; j < lg_max; j++)
{
bool correct = true;
for (i = 0; i < size_max && i < 8 && i < lg_max - j && correct; i++)
Expand Down Expand Up @@ -587,7 +593,7 @@ IDisk::AutorunType DiskGen::GetAutorun(char* buffer, unsigned int size_of_buffer
{
IDisk::AutorunType ret;
bool end = false;
int nb_correct_char = 0;
size_t nb_correct_char = 0;
bool correct_hidden = 1;

std::vector<std::string> filename_vector = disk_->GetCat(ret);
Expand Down Expand Up @@ -667,7 +673,7 @@ IDisk::AutorunType DiskGen::GetAutorun(char* buffer, unsigned int size_of_buffer
|| strnicmp((char*)&filename[8], " ", 3) == 0)
{
// Priority : If it's call "sav?????.b??", it's less priority thant any other
int nbcar = NbIdenticalCar(it->c_str(), disk_filename.c_str(), disk_filename.size());
size_t nbcar = NbIdenticalCar(it->c_str(), disk_filename.c_str(), disk_filename.size());
if (strncmp(&it->c_str()[8], "BIN", 3) == 0
|| strncmp(&it->c_str()[8], "BAS", 3) == 0
)
Expand Down
2 changes: 1 addition & 1 deletion CPCCoreEmu/DiskGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "DskTypeManager.h"
#include "ILoadingProgress.h"

#include "simple_string.h"
#include <string.h>

#define NB_ROUND_SPEED_MAX 50
#define SPEED_MAX_READY 203000
Expand Down
25 changes: 19 additions & 6 deletions CPCCoreEmu/DskTypeManager.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "stdafx.h"
#include <filesystem>
#include <algorithm>

#include "DskTypeManager.h"
#include "simple_regex.h"
//#include "simple_regex.h"



Expand Down Expand Up @@ -54,23 +57,33 @@ int DskTypeManager::GetTypeFromBuffer (unsigned char* buffer, int size)

int DskTypeManager::GetTypeFromFile(const char* str)
{
if (IsExtensionMatch(str, "rom"))
std::filesystem::path file_ext (str);
std::string ext = file_ext.extension().string();
std::transform(ext.begin(), ext.end(), ext.begin(),
[](unsigned char c) { return std::tolower(c); });

if ( strcmp( ext.c_str(), ".rom") == 0)
//if (IsExtensionMatch(str, "rom"))
{
return 2;
}
else if (IsExtensionMatch(str, "raw"))
//else if (IsExtensionMatch(str, "raw"))
else if ( strcmp(ext.c_str(), ".raw" ) ==0)
{
return 3;
}
else if (IsExtensionMatch(str, "tap"))
//else if (IsExtensionMatch(str, "tap"))
else if ( strcmp(ext.c_str(), ".tap" ) ==0)
{
return 4;
}
else if (IsExtensionMatch(str, "bin"))
//else if (IsExtensionMatch(str, "bin"))
else if ( strcmp(ext.c_str(), ".bin" )==0)
{
return 6;
}
else if (IsExtensionMatch(str, "cpr"))
//else if (IsExtensionMatch(str, "cpr"))
else if ( strcmp(ext.c_str(), ".cpr" )==0)
{
return 7;
}
Expand Down
1 change: 0 additions & 1 deletion CPCCoreEmu/DskTypeManager.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include "simple_string.h"
#include "ILog.h"

#include "DiskContainer.h"
Expand Down
Loading
Loading