From 2a8056edcd23595ef5cc8272458d3a3595efd3c7 Mon Sep 17 00:00:00 2001 From: Randy Rossi Date: Fri, 7 Feb 2020 21:38:36 -0500 Subject: [PATCH] Need to support scaling_params for two displays 'cause 128 --- kernel.cpp | 11 +++++++---- kernel.h | 4 +++- sdcard/machines.txt | 3 ++- third_party/common/circle.h | 4 +++- third_party/common/menu.c | 2 +- viceoptions.cpp | 38 +++++++++++++++++++++++-------------- viceoptions.h | 10 +++++----- 7 files changed, 45 insertions(+), 27 deletions(-) diff --git a/kernel.cpp b/kernel.cpp index 3d6173c0..5f38497e 100644 --- a/kernel.cpp +++ b/kernel.cpp @@ -269,8 +269,10 @@ void circle_get_fbl_dimensions(int layer, int *display_w, int *display_h, src_w, src_h, dst_w, dst_h); } -void circle_get_scaling_params(int *fbw, int *fbh, int *sx, int *sy) { - static_kernel->circle_get_scaling_params(fbw, fbh, sx, sy); +void circle_get_scaling_params(int display, + int *fbw, int *fbh, + int *sx, int *sy) { + static_kernel->circle_get_scaling_params(display, fbw, fbh, sx, sy); } }; @@ -1553,7 +1555,8 @@ void CKernel::circle_get_fbl_dimensions(int layer, dst_w, dst_h); } -void CKernel::circle_get_scaling_params(int *fbw, int *fbh, +void CKernel::circle_get_scaling_params(int display, + int *fbw, int *fbh, int *sx, int *sy) { - mViceOptions.GetScalingParams(fbw, fbh, sx, sy); + mViceOptions.GetScalingParams(display, fbw, fbh, sx, sy); } diff --git a/kernel.h b/kernel.h index 646a07d1..5020e9c1 100644 --- a/kernel.h +++ b/kernel.h @@ -112,7 +112,9 @@ class CKernel : public ViceStdioApp { int *fb_w, int *fb_h, int *src_w, int *src_h, int *dst_w, int *dst_h); - void circle_get_scaling_params(int *fbw, int *fbh, int *sx, int *sy); + void circle_get_scaling_params(int display, + int *fbw, int *fbh, + int *sx, int *sy); private: void InitSound(); diff --git a/sdcard/machines.txt b/sdcard/machines.txt index 9d112eb4..75b025ab 100644 --- a/sdcard/machines.txt +++ b/sdcard/machines.txt @@ -16,7 +16,7 @@ # SectionHeader = [Machine/TimingStandard/OutputType/ResolutionDesc] # Machine = VIC20|C64|C128|Plus4|Plus4Emu|Pet # TimingStandard = NTSC | PAL -# OutputVideo = HDMI | Composite +# OutputVideo = HDMI | DPI | Composite # ResolutionDesc = Any text (can be used to describe the video resolution) # OptionLine = "key=value\n" # @@ -36,6 +36,7 @@ # machine_timing # cycles_per_second # audio_out +# scaling_params # # NOTE: Always include a valid hdmi mode even for the composite diff --git a/third_party/common/circle.h b/third_party/common/circle.h index 44fc6529..35fb662b 100644 --- a/third_party/common/circle.h +++ b/third_party/common/circle.h @@ -237,7 +237,9 @@ extern void circle_get_fbl_dimensions(int layer, int *fb_w, int *fb_h, int *src_w, int *src_h, int *dst_w, int *dst_h); -extern void circle_get_scaling_params(int *fbw, int *fbh, int *sx, int *sy); +extern void circle_get_scaling_params(int display, + int *fbw, int *fbh, + int *sx, int *sy); // ----------------------------------------------------------------------- // Functions called from kernel layer into emulator layer diff --git a/third_party/common/menu.c b/third_party/common/menu.c index f50dccc6..589712de 100644 --- a/third_party/common/menu.c +++ b/third_party/common/menu.c @@ -725,7 +725,7 @@ void ui_set_joy_items() { // TODO : Handle layer other than VIC static void do_use_int_scaling(int layer, int silent) { int fbw, fbh, sx, sy; - circle_get_scaling_params(&fbw, &fbh, &sx, &sy); + circle_get_scaling_params(0, &fbw, &fbh, &sx, &sy); int dpw, dph, tmp; circle_get_fbl_dimensions(layer, diff --git a/viceoptions.cpp b/viceoptions.cpp index 25c91629..0d67f93f 100644 --- a/viceoptions.cpp +++ b/viceoptions.cpp @@ -14,11 +14,14 @@ // limitations under the License. #include "viceoptions.h" + +#include +#include +#include + #include #include #include -#include -#include extern "C" { #include "third_party/common/circle.h" @@ -33,8 +36,8 @@ ViceOptions::ViceOptions(void) m_bDemoEnabled(false), m_bSerialEnabled(false), m_bGPIOOutputsEnabled(false), m_nCyclesPerSecond(0), m_audioOut(VCHIQSoundDestinationAuto), m_bDPIEnabled(false), - m_scaling_param_fbw(0), m_scaling_param_fbh(0), - m_scaling_param_sx(0), m_scaling_param_sy(0) { + m_scaling_param_fbw{0,0}, m_scaling_param_fbh{0,0}, + m_scaling_param_sx{0,0}, m_scaling_param_sy{0,0} { s_pThis = this; CBcmPropertyTags Tags; @@ -119,7 +122,9 @@ ViceOptions::ViceOptions(void) m_bDPIEnabled = false; } } else if (strcmp(pOption, "scaling_params") == 0) { - char* fbw_s = strtok(pValue, ","); + char* num_s = strtok(pValue, ","); + if (!num_s) continue; + char* fbw_s = strtok(NULL, ","); if (!fbw_s) continue; char* fbh_s = strtok(NULL, ","); if (!fbh_s) continue; @@ -127,10 +132,13 @@ ViceOptions::ViceOptions(void) if (!sx_s) continue; char* sy_s = strtok(NULL, ","); if (!sy_s) continue; - m_scaling_param_fbw = atoi(fbw_s); - m_scaling_param_fbh = atoi(fbh_s); - m_scaling_param_sx = atoi(sx_s); - m_scaling_param_sy = atoi(sy_s); + int num = atoi(num_s); + if (num >=0 && num < 2) { + m_scaling_param_fbw[num] = atoi(fbw_s); + m_scaling_param_fbh[num] = atoi(fbh_s); + m_scaling_param_sx[num] = atoi(sx_s); + m_scaling_param_sy[num] = atoi(sy_s); + } } } @@ -177,11 +185,13 @@ bool ViceOptions::DPIEnabled(void) const { return m_bDPIEnabled; } int ViceOptions::GetDiskPartition(void) const { return m_disk_partition; } -void ViceOptions::GetScalingParams(int *fbw, int *fbh, int *sx, int *sy) { - *fbw = m_scaling_param_fbw; - *fbh = m_scaling_param_fbh; - *sx = m_scaling_param_sx; - *sy = m_scaling_param_sy; +void ViceOptions::GetScalingParams(int display, int *fbw, int *fbh, int *sx, int *sy) { + if (display >=0 && display < 2) { + *fbw = m_scaling_param_fbw[display]; + *fbh = m_scaling_param_fbh[display]; + *sx = m_scaling_param_sx[display]; + *sy = m_scaling_param_sy[display]; + } } const char *ViceOptions::GetDiskVolume(void) const { return m_disk_volume; } diff --git a/viceoptions.h b/viceoptions.h index 4e5bed06..d0ed88e3 100644 --- a/viceoptions.h +++ b/viceoptions.h @@ -36,7 +36,7 @@ class ViceOptions { unsigned long GetCyclesPerSecond(void) const; TVCHIQSoundDestination GetAudioOut(void) const; bool DPIEnabled(void) const; - void GetScalingParams(int *fbw, int *fbh, int *sx, int *sy); + void GetScalingParams(int display, int *fbw, int *fbh, int *sx, int *sy); static ViceOptions *Get(void); @@ -63,10 +63,10 @@ class ViceOptions { unsigned long m_nCyclesPerSecond; TVCHIQSoundDestination m_audioOut; bool m_bDPIEnabled; - int m_scaling_param_fbw; - int m_scaling_param_fbh; - int m_scaling_param_sx; - int m_scaling_param_sy; + int m_scaling_param_fbw[2]; + int m_scaling_param_fbh[2]; + int m_scaling_param_sx[2]; + int m_scaling_param_sy[2]; static ViceOptions *s_pThis; };