Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1764 from reicast/skmp/oopify-2
Browse files Browse the repository at this point in the history
OOPIFY: Part Two

- AICA refactors
- DSP implementations w/ dynamic switching (arm64, x86)
- ARM7 implementations w/ dynamic switching (virt: arm32, arm64, x86)
  • Loading branch information
skmp authored Jan 20, 2020
2 parents 08579ee + 5985409 commit 25691af
Show file tree
Hide file tree
Showing 95 changed files with 6,228 additions and 5,583 deletions.
11 changes: 5 additions & 6 deletions libswirl/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
//DC : 16 mb ram, 8 mb vram, 2 mb aram, 2 mb bios, 128k flash
#define RAM_SIZE (16*1024*1024)
#define VRAM_SIZE (8*1024*1024)
#define ARAM_SIZE (2*1024*1024)
#define INTERNAL_ARAM_SIZE (2*1024*1024)
#define BIOS_SIZE (2*1024*1024)
#define FLASH_SIZE (128*1024)

Expand All @@ -362,7 +362,7 @@
//Devkit : 32 mb ram, 8? mb vram, 2? mb aram, 2? mb bios, ? flash
#define RAM_SIZE (32*1024*1024)
#define VRAM_SIZE (8*1024*1024)
#define ARAM_SIZE (2*1024*1024)
#define INTERNAL_ARAM_SIZE (2*1024*1024)
#define BIOS_SIZE (2*1024*1024)
#define FLASH_SIZE (128*1024)

Expand All @@ -375,7 +375,7 @@
//Naomi : 32 mb ram, 16 mb vram, 8 mb aram, 2 mb bios, ? flash
#define RAM_SIZE (32*1024*1024)
#define VRAM_SIZE (16*1024*1024)
#define ARAM_SIZE (8*1024*1024)
#define INTERNAL_ARAM_SIZE (8*1024*1024)
#define BIOS_SIZE (2*1024*1024)
#define BBSRAM_SIZE (32*1024)

Expand All @@ -388,7 +388,7 @@
//Naomi2 : 32 mb ram, 16 mb vram, 8 mb aram, 2 mb bios, ? flash
#define RAM_SIZE (32*1024*1024)
#define VRAM_SIZE (16*1024*1024)
#define ARAM_SIZE (8*1024*1024)
#define INTERNAL_ARAM_SIZE (8*1024*1024)
#define BIOS_SIZE (2*1024*1024)
#define BBSRAM_SIZE (32*1024)

Expand All @@ -403,7 +403,7 @@
//Atomiswave : 16 mb ram, 8 mb vram, 8 mb aram, 128kb bios on flash, 128kb battery-backed ram
#define RAM_SIZE (16*1024*1024)
#define VRAM_SIZE (8*1024*1024)
#define ARAM_SIZE (8*1024*1024)
#define INTERNAL_ARAM_SIZE (8*1024*1024)
#define BIOS_SIZE (128*1024)
#define BBSRAM_SIZE (128*1024)

Expand All @@ -417,7 +417,6 @@

#define RAM_MASK (RAM_SIZE-1)
#define VRAM_MASK (VRAM_SIZE-1)
#define ARAM_MASK (ARAM_SIZE-1)
#define BIOS_MASK (BIOS_SIZE-1)

#ifdef FLASH_SIZE
Expand Down
2 changes: 1 addition & 1 deletion libswirl/core.mk
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ifdef X64_REC
endif

ifdef ARM32_REC
RZDCY_MODULES += jit/backend/arm32/ jit/emitter/arm/
RZDCY_MODULES += jit/backend/arm32/ jit/emitter/arm/ deps/vixl/ deps/vixl/aarch32/
endif

ifdef ARM64_REC
Expand Down
2 changes: 1 addition & 1 deletion libswirl/deps/vixl/aarch32/assembler-aarch32.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Assembler : public internal::AssemblerBase {
bool allow_unpredictable_;
bool allow_strongly_discouraged_;

protected:
public:
void EmitT32_16(uint16_t instr);
void EmitT32_32(uint32_t instr);
void EmitA32(uint32_t instr);
Expand Down
13 changes: 13 additions & 0 deletions libswirl/deps/vixl/aarch32/macro-assembler-aarch32.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,19 @@ class MacroAssembler : public Assembler, public MacroAssemblerInterface {
pool_manager_.Bind(this, label, GetCursorOffset());
}

// ADDED for REICAST -- allows to bind external functions
void BindToOffset(Label* label, ptrdiff_t offset) {
// Assert that we have the correct buffer alignment.
if (IsUsingT32()) {
VIXL_ASSERT(GetBuffer()->Is16bitAligned());
}
else {
VIXL_ASSERT(GetBuffer()->Is32bitAligned());
}

pool_manager_.Bind(this, label, offset);
}

void RegisterLiteralReference(RawLiteral* literal) {
if (literal->IsManuallyPlaced()) return;
RegisterForwardReference(literal);
Expand Down
6 changes: 4 additions & 2 deletions libswirl/deps/vixl/code-buffer-vixl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ extern "C" {

#include "code-buffer-vixl.h"
#include "utils-vixl.h"
#include <string.h>

namespace vixl {

Expand Down Expand Up @@ -103,12 +104,13 @@ void CodeBuffer::SetWritable() {
}
#endif


// MODIFIED FOR REICAST // ANDROID armhf build
void CodeBuffer::EmitString(const char* string) {
VIXL_ASSERT(HasSpaceFor(strlen(string) + 1));
char* dst = reinterpret_cast<char*>(cursor_);
dirty_ = true;
char* null_char = stpcpy(dst, string);
//char* null_char = stpcpy(dst, string);
char* null_char = strcpy(dst, string) + strlen(string);
cursor_ = reinterpret_cast<byte*>(null_char) + 1;
}

Expand Down
2 changes: 2 additions & 0 deletions libswirl/deps/vixl/globals-vixl.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ inline void USE(const T1&, const T2&, const T3&, const T4&) {}
#define VIXL_INCLUDE_TARGET_AARCH64
#endif

#define VIXL_INCLUDE_TARGET_A32

#if defined(VIXL_INCLUDE_TARGET_A32) && defined(VIXL_INCLUDE_TARGET_T32)
#define VIXL_INCLUDE_TARGET_AARCH32
#elif defined(VIXL_INCLUDE_TARGET_A32)
Expand Down
19 changes: 11 additions & 8 deletions libswirl/deps/vixl/pool-manager-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,15 +452,18 @@ T PoolManager<T>::Bind(MacroAssemblerInterface* masm,
min_location = existing_object->min_location_;
}

// Align if needed, and add necessary padding to reach the min_location_.
T aligned_location = AlignUp(location, alignment);
masm->EmitNopBytes(aligned_location - location);
location = aligned_location;
while (location < min_location) {
masm->EmitNopBytes(alignment);
location += alignment;
// hack-fix for negative offsets when aligned
if (alignment != 1) {
// Align if needed, and add necessary padding to reach the min_location_.
T aligned_location = AlignUp(location, alignment);
masm->EmitNopBytes(aligned_location - location);
location = aligned_location;
while (location < min_location) {
masm->EmitNopBytes(alignment);
location += alignment;
}
}

object->SetLocation(masm->AsAssemblerBase(), location);
object->MarkBound();

Expand Down
4 changes: 2 additions & 2 deletions libswirl/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ struct ReicastUI_impl : GUI {
// Exit to main menu
gui_state = Main;
game_started = false;
virtualDreamcast.release();
virtualDreamcast.reset();

cfgSetVirtual("config", "image", "");
}
Expand Down Expand Up @@ -717,7 +717,7 @@ struct ReicastUI_impl : GUI {
{
gui_state = Main;
game_started = false;
virtualDreamcast.release();
virtualDreamcast.reset();

cfgSetVirtual("config", "image", "");
switch (rc) {
Expand Down
36 changes: 30 additions & 6 deletions libswirl/gui/gui_settings_advanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ void gui_settings_advanced()
if (ImGui::BeginTabItem("Advanced"))
{
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, normal_padding);
if (ImGui::CollapsingHeader("CPU Mode", ImGuiTreeNodeFlags_DefaultOpen))
if (ImGui::CollapsingHeader("MCPU Mode", ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::Columns(2, "cpu_modes", false);
ImGui::RadioButton("Dynarec", &dynarec_enabled, 1);
ImGui::Columns(2, "sh4_modes", false);
ImGui::RadioButton("MCPU Dynarec", &dynarec_enabled, 1);
ImGui::SameLine();
gui_ShowHelpMarker("Use the dynamic recompiler. Recommended in most cases");
ImGui::NextColumn();
ImGui::RadioButton("Interpreter", &dynarec_enabled, 0);
ImGui::RadioButton("MCPU Interpreter", &dynarec_enabled, 0);
ImGui::SameLine();
gui_ShowHelpMarker("Use the interpreter. Very slow but may help in case of a dynarec problem");
ImGui::Columns(1, NULL, false);
}
if (ImGui::CollapsingHeader("Dynarec Options", dynarec_enabled ? ImGuiTreeNodeFlags_DefaultOpen : ImGuiTreeNodeFlags_None))
if (ImGui::CollapsingHeader("SH4 Dynarec Options", dynarec_enabled ? ImGuiTreeNodeFlags_DefaultOpen : ImGuiTreeNodeFlags_None))
{
ImGui::Checkbox("Safe Mode", &settings.dynarec.safemode);
ImGui::SameLine();
Expand Down Expand Up @@ -57,7 +57,31 @@ void gui_settings_advanced()
ImGui::SameLine();
gui_ShowHelpMarker("How to detect self-modifying code. Full check recommended");
}
if (ImGui::CollapsingHeader("Other", ImGuiTreeNodeFlags_DefaultOpen))
if (ImGui::CollapsingHeader("SCPU Mode", ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::Columns(2, "arm7_modes", false);
ImGui::RadioButton("SCPU Dynarec", &settings.dynarec.ScpuEnable, 1);
ImGui::SameLine();
gui_ShowHelpMarker("Use the ARM7 dynamic recompiler. Recommended in most cases");
ImGui::NextColumn();
ImGui::RadioButton("SCPU Interpreter", &settings.dynarec.ScpuEnable, 0);
ImGui::SameLine();
gui_ShowHelpMarker("Use the ARM7 interpreter. Very slow but may help in case of a dynarec problem");
ImGui::Columns(1, NULL, false);
}
if (ImGui::CollapsingHeader("DSP Mode", ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::Columns(2, "dsp_modes", false);
ImGui::RadioButton("DSP Dynarec", &settings.dynarec.DspEnable, 1);
ImGui::SameLine();
gui_ShowHelpMarker("Use the DSP dynamic recompiler. Recommended in most cases");
ImGui::NextColumn();
ImGui::RadioButton("DSP Interpreter", &settings.dynarec.DspEnable, 0);
ImGui::SameLine();
gui_ShowHelpMarker("Use the DSP interpreter. Very slow but may help in case of a DSP dynarec problem");
ImGui::Columns(1, NULL, false);
}
if (ImGui::CollapsingHeader("Other", ImGuiTreeNodeFlags_DefaultOpen))
{
#ifndef _ANDROID
ImGui::Checkbox("Serial Console", &settings.debug.SerialConsole);
Expand Down
Loading

0 comments on commit 25691af

Please sign in to comment.