Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
1. can't have to scaling_param kernel params so adding
   scaling_param2 for the 2nd display or 80 column display
2. need to apply video settings after a frame buffer destroy/re-create (pet model switch)
3. menu was not vertically centered correctly
  • Loading branch information
randyrossi committed Feb 8, 2020
1 parent 9155024 commit ec8b65d
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 55 deletions.
2 changes: 1 addition & 1 deletion sdcard/cmdline.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fast=true machine_timing=pal-hdmi
fast=true machine_timing=pal-hdmi scaling_params=384,240,1152,720

# DO NOT EDIT - This file is no longer edited by hand. Use the
# machines.txt to set both config.txt and cmdline.txt params for
Expand Down
69 changes: 37 additions & 32 deletions sdcard/machines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
# cycles_per_second
# audio_out
# scaling_params
# scaling_params2 (for 2nd display or 80 column display)

#
# NOTE: Always include a valid hdmi mode even for the composite
Expand All @@ -53,31 +54,31 @@ sdtv_mode=16
hdmi_group=1
hdmi_mode=4
machine_timing=ntsc-hdmi
scaling_params=0,414,228,1242,684
scaling_params=414,228,1242,684

[VIC20/NTSC/Composite/VICE 480p@60Hz]
disable_overscan=1
sdtv_mode=16
hdmi_group=1
hdmi_mode=4
machine_timing=ntsc-composite
scaling_params=0,422,228,720,456
scaling_params=422,228,720,456

[VIC20/PAL/HDMI/VICE 720p@50Hz]
disable_overscan=1
sdtv_mode=18
hdmi_group=1
hdmi_mode=19
machine_timing=pal-hdmi
scaling_params=0,414,240,1242,720
scaling_params=414,240,1242,720

[VIC20/PAL/Composite/VICE 576p@50Hz]
disable_overscan=1
sdtv_mode=18
hdmi_group=1
hdmi_mode=19
machine_timing=pal-composite
scaling_params=0,422,240,668,480
scaling_params=422,240,668,480

#
# C64
Expand All @@ -89,31 +90,31 @@ sdtv_mode=16
hdmi_group=1
hdmi_mode=4
machine_timing=ntsc-hdmi
scaling_params=0,384,240,1152,720
scaling_params=384,240,1152,720

[C64/NTSC/Composite/VICE 480p@60Hz]
disable_overscan=1
sdtv_mode=16
hdmi_group=1
hdmi_mode=4
machine_timing=ntsc-composite
scaling_params=0,364,240,600,480
scaling_params=364,240,600,480

[C64/PAL/HDMI/VICE 720p@50Hz]
disable_overscan=1
sdtv_mode=18
hdmi_group=1
hdmi_mode=19
machine_timing=pal-hdmi
scaling_params=0,384,240,1152,720
scaling_params=384,240,1152,720

[C64/PAL/Composite/VICE 576p@50Hz]
disable_overscan=1
sdtv_mode=18
hdmi_group=1
hdmi_mode=19
machine_timing=pal-composite
scaling_params=0,384,272,648,544
scaling_params=384,272,648,544

# This matches the timing of a real NTSC machine but may
# not work on all monitors.
Expand All @@ -124,7 +125,7 @@ hdmi_mode=87
hdmi_timings=768 0 24 72 96 525 1 3 10 9 0 0 0 60 0 31415829 1
machine_timing=ntsc-custom
cycles_per_second=1022708
scaling_params=0,384,246,768,492
scaling_params=384,246,768,492

# This matches the timing of a real PAL machine but may
# not work on all monitors.
Expand All @@ -135,7 +136,7 @@ hdmi_mode=87
hdmi_timings=768 0 24 72 96 544 1 3 2 14 0 0 0 50 0 27092000 1
machine_timing=pal-custom
cycles_per_second=985257
scaling_params=0,384,272,768,544
scaling_params=384,272,768,544


#
Expand All @@ -148,33 +149,33 @@ sdtv_mode=16
hdmi_group=1
hdmi_mode=4
machine_timing=ntsc-hdmi
scaling_params=0,384,240,1152,720
scaling_params=1,864,228,1280,684
scaling_params=384,240,1152,720
scaling_params2=864,228,1280,684

[C128/NTSC/Composite/VICE 480p@60Hz]
disable_overscan=1
sdtv_mode=16
hdmi_group=1
hdmi_mode=4
machine_timing=ntsc-composite
scaling_params=0,364,240,640,480
scaling_params=364,240,640,480

[C128/PAL/HDMI/VICE 720p@50Hz]
disable_overscan=1
sdtv_mode=18
hdmi_group=1
hdmi_mode=19
machine_timing=pal-hdmi
scaling_params=0,384,240,1152,720
scaling_params=1,864,240,1280,684
scaling_params=384,240,1152,720
scaling_params2=864,240,1280,684

[C128/PAL/Composite/VICE 576p@50Hz]
disable_overscan=1
sdtv_mode=18
hdmi_group=1
hdmi_mode=19
machine_timing=pal-composite
scaling_params=0,384,272,648,544
scaling_params=384,272,648,544

# This matches the timing of a real NTSC machine but may
# not work on all monitors.
Expand All @@ -185,8 +186,8 @@ hdmi_mode=87
hdmi_timings=768 0 24 72 96 525 1 3 10 9 0 0 0 60 0 31415829 1
machine_timing=ntsc-custom
cycles_per_second=1022708
scaling_params=0,384,246,1152,492
scaling_params=1,674,228,674,456
scaling_params=384,246,1152,492
scaling_params2=674,228,674,456

# This matches the timing of a real PAL machine but may
# not work on all monitors.
Expand All @@ -197,8 +198,8 @@ hdmi_mode=87
hdmi_timings=768 0 24 72 96 544 1 3 2 14 0 0 0 50 0 27092000 1
machine_timing=pal-custom
cycles_per_second=985257
scaling_params=0,384,272,768,544
scaling_params=1,674,272,674,544
scaling_params=384,272,768,544
scaling_params2=674,272,674,544


#
Expand All @@ -211,31 +212,31 @@ sdtv_mode=16
hdmi_group=1
hdmi_mode=4
machine_timing=ntsc-hdmi
scaling_params=0,384,232,1152,696
scaling_params=384,232,1152,696

[PLUS4/NTSC/Composite/VICE 480p@60Hz]
disable_overscan=1
sdtv_mode=16
hdmi_group=1
hdmi_mode=4
machine_timing=ntsc-composite
scaling_params=0,360,232,640,464
scaling_params=360,232,640,464

[PLUS4/PAL/HDMI/VICE 720p@50Hz]
disable_overscan=1
sdtv_mode=18
hdmi_group=1
hdmi_mode=19
machine_timing=pal-hdmi
scaling_params=0,384,240,1152,720
scaling_params=384,240,1152,720

[PLUS4/PAL/Composite/VICE 576p@50Hz]
disable_overscan=1
sdtv_mode=18
hdmi_group=1
hdmi_mode=19
machine_timing=pal-composite
scaling_params=0,364,280,640,560
scaling_params=364,280,640,560

# PLUS4EMU Is only available for Pi3. It is a more
# accurate Plus/4 emulator but requires more CPU.
Expand All @@ -247,42 +248,44 @@ sdtv_mode=16
hdmi_group=1
hdmi_mode=4
machine_timing=ntsc-hdmi
scaling_params=0,384,240,1152,720
scaling_params=384,240,1152,720

[PLUS4EMU/NTSC/Composite/Plus4Emu 480p@60Hz]
disable_overscan=1
sdtv_mode=16
hdmi_group=1
hdmi_mode=4
machine_timing=ntsc-composite
scaling_params=0,364,240,640,480
scaling_params=364,240,640,480

[PLUS4EMU/PAL/HDMI/Plus4Emu 720p@50Hz]
disable_overscan=1
sdtv_mode=18
hdmi_group=1
hdmi_mode=19
machine_timing=pal-hdmi
scaling_params=0,384,240,1152,720
scaling_params=384,240,1152,720

[PLUS4EMU/PAL/Composite/Plus4Emu 576p@50Hz]
disable_overscan=1
sdtv_mode=18
hdmi_group=1
hdmi_mode=19
machine_timing=pal-composite
scaling_params=0,364,272,640,544
scaling_params=364,272,640,544

#
# PET
#

[PET/NTSC/HDMI/VICE 720p@60Hz]
[PET/NTSC/HDMI/VICE 1080p@60Hz]
disable_overscan=1
sdtv_mode=16
hdmi_group=1
hdmi_mode=4
hdmi_mode=16
machine_timing=ntsc-hdmi
scaling_params=376,464,1504,928
scaling_params2=696,464,1392,928

[PET/NTSC/Composite/VICE 480p@60Hz]
disable_overscan=1
Expand All @@ -291,12 +294,14 @@ hdmi_group=1
hdmi_mode=4
machine_timing=ntsc-composite

[PET/PAL/HDMI/VICE 720p@50Hz]
[PET/PAL/HDMI/VICE 1080p@50Hz]
disable_overscan=1
sdtv_mode=18
hdmi_group=1
hdmi_mode=19
hdmi_mode=31
machine_timing=pal-hdmi
scaling_params=376,464,1504,928
scaling_params2=696,464,1392,928

[PET/PAL/Composite/VICE 576p@50Hz]
disable_overscan=1
Expand Down
6 changes: 6 additions & 0 deletions third_party/common/emux_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ typedef enum {
Setting_SidWriteAccess, // Plus4Emu
Setting_SidDigiblaster, // Plus4Emu
Setting_WarpMode,
Setting_VideoSize, // PET
} IntSetting;

typedef enum {
Expand Down Expand Up @@ -409,4 +410,9 @@ void emux_add_userport_joys(struct menu_item* parent);

void emux_geometry_changed(int layer);

// Indicates the framebuffer (fbl) has changed size and other canvas_state
// parameters may have changed as well. May cause a call to geometry change.
// Video settings needs to be applied.
void emux_frame_buffer_changed(int layer);

#endif
17 changes: 16 additions & 1 deletion third_party/common/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,14 @@ static int do_use_int_scaling(int layer, int silent) {
}

int fbw, fbh, sx, sy;
circle_get_scaling_params(canvas_index, &fbw, &fbh, &sx, &sy);
int display_num = canvas_index;
// For the PET, 1st display is 40 column models, 2nd is 80 column models
if (emux_machine_class == BMC64_MACHINE_CLASS_PET) {
int cols;
emux_get_int(Setting_VideoSize, &cols);
display_num = cols == 40 ? 0 : 1;
}
circle_get_scaling_params(display_num, &fbw, &fbh, &sx, &sy);

int dpw, dph, tmp;
circle_get_fbl_dimensions(layer,
Expand Down Expand Up @@ -3721,3 +3728,11 @@ void emux_geometry_changed(int layer) {
ui_geometry_changed(dpx, dpy, fbw, fbh, sw, sh, dw, dh);
}
}

void emux_frame_buffer_changed(int layer) {
int canvas_index = layer == FB_LAYER_VIC ? VIC_INDEX : VDC_INDEX;
if (use_scaling_params_item[canvas_index]->value) {
do_use_int_scaling(layer, 1 /* silent */);
}
do_video_settings(layer);
}
14 changes: 13 additions & 1 deletion third_party/common/menu_switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ struct s_cfg_flags {
int have_disk_partition;
int have_enable_dpi;
int have_scaling_params;
int have_scaling_params2;

// Have flags for config.txt
int have_kernel;
Expand Down Expand Up @@ -439,6 +440,7 @@ static int apply_override_m(char *line, struct machine_entry *head,
if (strcmp(key,"disk_partition") == 0) { cfg_flags->have_disk_partition = 1; }
if (strcmp(key,"enable_dpi") == 0) { cfg_flags->have_enable_dpi = 1; }
if (strcmp(key,"scaling_params") == 0) { cfg_flags->have_scaling_params = 1; }
if (strcmp(key,"scaling_params2") == 0) { cfg_flags->have_scaling_params2 = 1; }

struct machine_option* found = find_option(key, head->options);
if (found) {
Expand All @@ -456,7 +458,8 @@ static int apply_override_m(char *line, struct machine_entry *head,
strcmp(key,"audio_out")!=0 &&
strcmp(key,"disk_partition")!=0 &&
strcmp(key,"enable_dpi")!=0 &&
strcmp(key,"scaling_params")!=0) {
strcmp(key,"scaling_params")!=0 &&
strcmp(key,"scaling_params2")!=0) {
if (need_space) { strcat(replacement," "); }
snprintf(new_option, OPTION_SCRATCH_LEN, "%s=%s", key, value);
strcat(replacement, new_option);
Expand Down Expand Up @@ -540,6 +543,15 @@ static int apply_override_m(char *line, struct machine_entry *head,
need_space=1;
}
}
if (!cfg_flags->have_scaling_params2) {
struct machine_option* found = find_option("scaling_params2", head->options);
if (found) {
if (need_space) { strcat(replacement," "); }
snprintf(new_option, OPTION_SCRATCH_LEN, "%s=%s", found->key, found->value);
strcat(replacement, new_option);
need_space=1;
}
}

strcat(replacement, "\n");
strcpy(line, replacement);
Expand Down
15 changes: 8 additions & 7 deletions third_party/common/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -1211,13 +1211,14 @@ static int calc_root_menu_left() {
// double the height of the UI frame buffer like we do
// the main display.
static int calc_root_menu_top() {
return
canvas_state[VIC_INDEX].top +
canvas_state[VIC_INDEX].border_h /
canvas_state[VIC_INDEX].raster_skip +
canvas_state[VIC_INDEX].gfx_h / 2 /
canvas_state[VIC_INDEX].raster_skip -
menu_height_chars * 8 / 2;
int raster_skip = canvas_state[VIC_INDEX].raster_skip;

int ui_top = canvas_state[VIC_INDEX].first_displayed_line +
canvas_state[VIC_INDEX].max_border_h / raster_skip;

return ui_top + canvas_state[VIC_INDEX].gfx_h / 2 /
canvas_state[VIC_INDEX].raster_skip -
menu_height_chars * 8 / 2;
}

struct menu_item *ui_push_menu(int w_chars, int h_chars) {
Expand Down
3 changes: 3 additions & 0 deletions third_party/vice-3.3/src/arch/raspi/vice_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,9 @@ void emux_get_int(IntSetting setting, int* dest) {
case Setting_DatasetteResetWithCPU:
resources_get_int("DatasetteResetWithCPU", dest);
break;
case Setting_VideoSize:
resources_get_int("VideoSize", dest);
break;
default:
assert(0);
}
Expand Down
Loading

0 comments on commit ec8b65d

Please sign in to comment.