Skip to content

Commit

Permalink
Need to support scaling_params for two displays
Browse files Browse the repository at this point in the history
'cause 128
  • Loading branch information
randyrossi committed Feb 8, 2020
1 parent e39aa98 commit 2a8056e
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 27 deletions.
11 changes: 7 additions & 4 deletions kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

Expand Down Expand Up @@ -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);
}
4 changes: 3 additions & 1 deletion kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion sdcard/machines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
#
Expand All @@ -36,6 +36,7 @@
# machine_timing
# cycles_per_second
# audio_out
# scaling_params

#
# NOTE: Always include a valid hdmi mode even for the composite
Expand Down
4 changes: 3 additions & 1 deletion third_party/common/circle.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion third_party/common/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
38 changes: 24 additions & 14 deletions viceoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@
// limitations under the License.

#include "viceoptions.h"

#include <stdlib.h>
#include <string.h>
#include <algorithm>

#include <circle/logger.h>
#include <circle/sysconfig.h>
#include <circle/util.h>
#include <stdlib.h>
#include <string.h>

extern "C" {
#include "third_party/common/circle.h"
Expand All @@ -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;
Expand Down Expand Up @@ -119,18 +122,23 @@ 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;
char* sx_s = strtok(NULL, ",");
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);
}
}
}

Expand Down Expand Up @@ -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; }
Expand Down
10 changes: 5 additions & 5 deletions viceoptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
};
Expand Down

0 comments on commit 2a8056e

Please sign in to comment.