Skip to content

Commit

Permalink
Use of new property system to handle more generic core properties, fi…
Browse files Browse the repository at this point in the history
…x for spinner issue, better error handling in VIP.
  • Loading branch information
gulrak committed Apr 5, 2024
1 parent 012ed81 commit c9d258f
Show file tree
Hide file tree
Showing 26 changed files with 522 additions and 212 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.1.9] (wip)
## [1.1.9-1.1.11] (wip)

### Added

- New test for CHIP-8E in `test-roms`
- New high-level variant `CHIP-8E`, the emulator will by default still use the real `VIP-CHIP-8E`
due to more accurate timing, but the generic one will take up less resources for more constrained
platforms
- Programs that are loaded from source are now also checked for their assembled binary being known
and options set accordingly.
- COSMAC VIP now supports up to 32k RAM, the interpreters will still put their screen data at
the end of the actual memory, theoretically expanding the CHIP-8 space (even if the max. 12
bit operands limit usability quite a bit)

### Fixed

- The VIP-CHIP-8E interpreter had a typo leading to `BBnn` not working ([#12](https://github.com/gulrak/cadmium/issues/12))
- Disassembling 0x7C, 0x7D or 0x7F generated single byte opcodes instead two byte ones ([#13](https://github.com/gulrak/cadmium/issues/12))
- Octo-Assembler would hang on macro definitions without name or parameter
- High-level emulation didn't finish a frame with the right amount of cycles if part of it was
single stepped or breakpoints involved.
single stepped or breakpoints involved
- Wrong initial cycles after a reset for the COSMAC VIP and the CHIP-8 strict timing core, the
time in ROM was not counted in


## [1.1.8] - 2024-01-01

Expand Down
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
cmake_minimum_required(VERSION 3.16)

project(cadmium VERSION 1.1.9 LANGUAGES C CXX)
project(cadmium VERSION 1.1.11 LANGUAGES C CXX)
cmake_policy(VERSION 3.16)

include(cmake/BuildSettings.cmake)
include(${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake)
enable_testing()
include_directories(src external)

if(WITH_ASAN)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif()

add_subdirectory(external)
add_subdirectory(tools)
add_subdirectory(resources)
Expand Down
1 change: 1 addition & 0 deletions cmake/BuildSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ FetchContent_GetProperties(Chiplet)
if(NOT chiplet_POPULATED)
FetchContent_Populate(Chiplet)
add_subdirectory(${chiplet_SOURCE_DIR} ${chiplet_BINARY_DIR})
include_directories(${chiplet_SOURCE_DIR}/external)
endif()

find_package(Git)
Expand Down
Binary file removed examples/MegaChip8/mcblendtest.mc8
Binary file not shown.
68 changes: 68 additions & 0 deletions external/ghc/random.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//---------------------------------------------------------------------------------------
// src/random.hpp - warning this is not for cryptographic use, it's used for emulation!!!
//---------------------------------------------------------------------------------------
//
// Copyright (c) 2024, Steffen Schümann <s.schuemann@pobox.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
//---------------------------------------------------------------------------------------
#pragma once

#include <cstdint>
#include <random>

namespace ghc
{

class RandomLCG
{
public:
enum Type { };
explicit RandomLCG(uint32_t seed = 1)
: _state(seed ? seed : 1)
{}
uint16_t operator()()
{
next();
return _state >> 16;
}
private:
void next()
{
_state = ((_state * 1103515245) + 12345) & 0x7FFFFFFF;
}
uint32_t _state{1};
};

class RandomMT
{
public:
RandomMT(uint32_t seed = 0)
: _engine(seed ? seed : std::random_device()())
{}
uint16_t operator()()
{
return _engine();
}
private:
std::mt19937 _engine;
};

}
8 changes: 5 additions & 3 deletions external/rlguipp/rlguipp4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ RLGUIPP_API int ToggleGroup(const char* text, int active);
RLGUIPP_API bool CheckBox(const char* text, bool checked); // Check Box control, returns true when active
RLGUIPP_API int ComboBox(const char* text, int active); // Combo Box control, returns selected item index
RLGUIPP_API bool DropdownBox(const char* text, int* active, bool directionUp = false); // Dropdown Box control, returns selected item
RLGUIPP_API bool Spinner(const char* text, int* value, int minValue, int maxValue); // Spinner control, returns selected value
RLGUIPP_API bool ValueBox(const char* text, int* value, int minValue, int maxValue); // Value Box control, updates input text with numbers
RLGUIPP_API bool Spinner(const char* text, int* value, int minValue, int maxValue); // Spinner control, returns selected value
RLGUIPP_API bool ValueBox(const char* text, int* value, int minValue, int maxValue); // Value Box control, updates input text with numbers
RLGUIPP_API void SetKeyboardFocus(void* key); // Claim keyboard focus and set focus key to `key`
RLGUIPP_API bool HasKeyboardFocus(void* key); // Check if key is current key for keyboard focus
RLGUIPP_API bool TextBox(char* text, int textSize); // Text Box control, updates input text
Expand Down Expand Up @@ -1490,7 +1490,9 @@ bool DropdownBox(const char* text, int* active, bool directionUp)

bool Spinner(const char* text, int* value, int minValue, int maxValue)
{
return detail::editableWidget(GuiSpinner, (void*)value, text, value, minValue, maxValue);
auto rc = detail::editableWidget(GuiSpinner, (void*)value, text, value, minValue, maxValue);
*value = std::clamp(*value, minValue, maxValue);
return rc;
}

bool ValueBox(const char* text, int* value, int minValue, int maxValue)
Expand Down
Loading

0 comments on commit c9d258f

Please sign in to comment.