mirror of
https://github.com/MiSTer-devel/C128_MiSTer.git
synced 2026-05-24 03:02:59 +00:00
Update sys. Support for custom AR.
This commit is contained in:
49
c64.sv
49
c64.sv
@@ -43,8 +43,8 @@ module emu
|
||||
output CE_PIXEL,
|
||||
|
||||
//Video aspect ratio for HDMI. Most retro systems have ratio 4:3.
|
||||
output [7:0] VIDEO_ARX,
|
||||
output [7:0] VIDEO_ARY,
|
||||
output [11:0] VIDEO_ARX,
|
||||
output [11:0] VIDEO_ARY,
|
||||
|
||||
output [7:0] VGA_R,
|
||||
output [7:0] VGA_G,
|
||||
@@ -54,6 +54,7 @@ module emu
|
||||
output VGA_DE, // = ~(VBlank | HBlank)
|
||||
output VGA_F1,
|
||||
output [1:0] VGA_SL,
|
||||
output VGA_SCALER, // Force VGA scaler
|
||||
|
||||
output LED_USER, // 1 - ON, 0 - OFF.
|
||||
|
||||
@@ -141,12 +142,13 @@ assign LED_DISK = 0;
|
||||
assign LED_POWER = 0;
|
||||
assign LED_USER = c1541_1_led | c1541_2_led | ioctl_download | tape_led;
|
||||
assign BUTTONS = 0;
|
||||
assign VGA_SCALER = 0;
|
||||
|
||||
// Status Bit Map:
|
||||
// 0 1 2 3
|
||||
// 01234567890123456789012345678901
|
||||
// 0123456789ABCDEFGHIJKLMNOPQRSTUV
|
||||
// XXXXXXXXXXXXXXXXXXXXXXXX XXXXX
|
||||
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
|
||||
`include "build_id.v"
|
||||
localparam CONF_STR = {
|
||||
@@ -163,26 +165,27 @@ localparam CONF_STR = {
|
||||
"RN,Tape Unload;",
|
||||
"OB,Tape Sound,Off,On;",
|
||||
"-;",
|
||||
"O2,Video standard,PAL,NTSC;",
|
||||
"O45,Aspect ratio,Original,Wide,Zoom;",
|
||||
"O2,Video Standard,PAL,NTSC;",
|
||||
"OO,Video Format,Original,Wide;",
|
||||
"O45,Aspect Ratio,Original,Full Screen,[ARC1],[ARC2];",
|
||||
"O8A,Scandoubler Fx,None,HQ2x-320,HQ2x-160,CRT 25%,CRT 50%,CRT 75%;",
|
||||
"-;",
|
||||
"OD,SID left,6581,8580;",
|
||||
"OG,SID right,6581,8580;",
|
||||
"OKM,SID right addr,Same,DE00,D420,D500,DF00;",
|
||||
"O6,Audio filter,On,Off;",
|
||||
"OC,Sound expander,No,OPL2;",
|
||||
"OIJ,Stereo mix,none,25%,50%,100%;",
|
||||
"OD,SID Left,6581,8580;",
|
||||
"OG,SID Right,6581,8580;",
|
||||
"OKM,SID Right addr,Same,DE00,D420,D500,DF00;",
|
||||
"O6,Audio Filter,On,Off;",
|
||||
"OC,Sound Expander,No,OPL2;",
|
||||
"OIJ,Stereo Mix,None,25%,50%,100%;",
|
||||
"-;",
|
||||
"O3,Swap joysticks,No,Yes;",
|
||||
"O1,User port,Joysticks,UART;",
|
||||
"O3,Swap Joysticks,No,Yes;",
|
||||
"O1,User Port,Joysticks,UART;",
|
||||
"OQR,Pot 1&2,Joy 1 Fire 2/3,Mouse,Paddles 1&2;",
|
||||
"OST,Pot 3&4,Joy 2 Fire 2/3,Mouse,Paddles 3&4;",
|
||||
"-;",
|
||||
"OEF,Kernal,Loadable C64,Standard C64,C64GS;",
|
||||
"-;",
|
||||
"RH,Reset;",
|
||||
"R0,Reset & Detach cartridge;",
|
||||
"R0,Reset & Detach Cartridge;",
|
||||
"J,Fire 1,Fire 2,Fire 3,Paddle Btn;",
|
||||
"jn,A,B,Y,X|P;",
|
||||
"jp,A,B,Y,X|P;",
|
||||
@@ -941,7 +944,7 @@ video_sync sync
|
||||
.hsync(hsync),
|
||||
.vsync(vsync),
|
||||
.ntsc(ntsc),
|
||||
.wide(status[5]),
|
||||
.wide(status[24]),
|
||||
.hsync_out(hsync_out),
|
||||
.vsync_out(vsync_out),
|
||||
.hblank(hblank),
|
||||
@@ -971,11 +974,13 @@ end
|
||||
wire scandoubler = status[10:8] || forced_scandoubler;
|
||||
|
||||
assign CLK_VIDEO = clk64;
|
||||
assign VIDEO_ARX = status[5:4] ? 8'd16 : 8'd4;
|
||||
assign VIDEO_ARY = status[5:4] ? 8'd9 : 8'd3;
|
||||
assign VIDEO_ARX = (!ar) ? (status[24] ? 8'd16 : 8'd4) : (ar - 1'd1);
|
||||
assign VIDEO_ARY = (!ar) ? (status[24] ? 8'd9 : 8'd3) : 12'd0;
|
||||
assign VGA_SL = (status[10:8] > 2) ? status[9:8] - 2'd2 : 2'd0;
|
||||
assign VGA_F1 = 0;
|
||||
|
||||
wire [1:0] ar = status[5:4];
|
||||
|
||||
video_mixer #(.GAMMA(1)) video_mixer
|
||||
(
|
||||
.clk_vid(CLK_VIDEO),
|
||||
@@ -1075,18 +1080,18 @@ sid8580 sid_8580
|
||||
|
||||
wire [17:0] audio_r = status[16] ? audio8580_r : audio6581_r;
|
||||
|
||||
reg [15:0] al,ar;
|
||||
reg [15:0] alo,aro;
|
||||
always @(posedge clk_sys) begin
|
||||
reg [16:0] alm,arm;
|
||||
|
||||
alm <= {opl_out[15],opl_out} + {audio_l[17],audio_l[17:2]} + {cass_snd, 10'd0};
|
||||
arm <= {opl_out[15],opl_out} + {audio_r[17],audio_r[17:2]} + {cass_snd, 10'd0};
|
||||
al <= ($signed(alm) > $signed(17'd32767)) ? 16'd32767 : ($signed(alm) < $signed(-17'd32768)) ? -16'd32768 : alm[15:0];
|
||||
ar <= ($signed(arm) > $signed(17'd32767)) ? 16'd32767 : ($signed(arm) < $signed(-17'd32768)) ? -16'd32768 : arm[15:0];
|
||||
alo <= ($signed(alm) > $signed(17'd32767)) ? 16'd32767 : ($signed(alm) < $signed(-17'd32768)) ? -16'd32768 : alm[15:0];
|
||||
aro <= ($signed(arm) > $signed(17'd32767)) ? 16'd32767 : ($signed(arm) < $signed(-17'd32768)) ? -16'd32768 : arm[15:0];
|
||||
end
|
||||
|
||||
assign AUDIO_L = al;
|
||||
assign AUDIO_R = ar;
|
||||
assign AUDIO_L = alo;
|
||||
assign AUDIO_R = aro;
|
||||
assign AUDIO_S = 1;
|
||||
assign AUDIO_MIX = status[19:18];
|
||||
|
||||
|
||||
@@ -462,8 +462,8 @@ ARCHITECTURE rtl OF ascal IS
|
||||
SIGNAL o_fload : natural RANGE 0 TO 3;
|
||||
SIGNAL o_acpt,o_acpt1,o_acpt2,o_acpt3,o_acpt4 : natural RANGE 0 TO 15; -- Alternance pixels FIFO
|
||||
SIGNAL o_dshi : natural RANGE 0 TO 3;
|
||||
SIGNAL o_first,o_last,o_last1,o_last2,o_last3 : std_logic;
|
||||
SIGNAL o_lastt1,o_lastt2,o_lastt3 : std_logic;
|
||||
SIGNAL o_first,o_last,o_last1,o_last2 : std_logic;
|
||||
SIGNAL o_lastt1,o_lastt2,o_lastt3,o_lastt4 : std_logic;
|
||||
SIGNAL o_alt,o_altx : unsigned(3 DOWNTO 0);
|
||||
SIGNAL o_hdown,o_vdown : std_logic;
|
||||
SIGNAL o_primv,o_lastv,o_bibv : unsigned(0 TO 2);
|
||||
@@ -2029,7 +2029,8 @@ BEGIN
|
||||
o_acpt1<=o_acpt; o_acpt2<=o_acpt1; o_acpt3<=o_acpt2; o_acpt4<=o_acpt3;
|
||||
o_ad1<=o_ad; o_ad2<=o_ad1; o_ad3<=o_ad2;
|
||||
o_sh1<=o_sh; o_sh2<=o_sh1; o_sh3<=o_sh2; o_sh4<=o_sh3;
|
||||
o_lastt1<=o_last; o_lastt2<=o_lastt1; o_lastt3<=o_lastt2;
|
||||
o_lastt1<=o_last; o_lastt2<=o_lastt1;
|
||||
o_lastt3<=o_lastt2; o_lastt4<=o_lastt3;
|
||||
|
||||
------------------------------------------------------
|
||||
IF o_sh3='1' THEN
|
||||
@@ -2059,7 +2060,7 @@ BEGIN
|
||||
o_hpix2<=hpix_v;
|
||||
o_first<='0';
|
||||
END IF;
|
||||
IF o_lastt3='1' THEN
|
||||
IF o_lastt4='1' THEN
|
||||
-- Right edge. Keep last pixel.
|
||||
o_hpix0<=o_hpix0;
|
||||
END IF;
|
||||
|
||||
@@ -52,3 +52,9 @@ set_false_path -from {FB_BASE[*] FB_BASE[*] FB_WIDTH[*] FB_HEIGHT[*] LFB_HMIN[*]
|
||||
set_false_path -to {vol_att[*] scaler_flt[*] led_overtake[*] led_state[*]}
|
||||
set_false_path -from {vol_att[*] scaler_flt[*] led_overtake[*] led_state[*]}
|
||||
set_false_path -from {aflt_* acx* acy* areset*}
|
||||
|
||||
set_false_path -from {ascal|o_ihsize*}
|
||||
set_false_path -from {ascal|o_ivsize*}
|
||||
set_false_path -from {ascal|o_format*}
|
||||
set_false_path -from {ascal|o_hdown}
|
||||
set_false_path -from {ascal|o_vdown}
|
||||
|
||||
@@ -287,7 +287,7 @@ cyclonev_hps_interface_mpu_general_purpose h2f_gp
|
||||
reg [15:0] cfg;
|
||||
|
||||
reg cfg_set = 0;
|
||||
wire vga_fb = cfg[12];
|
||||
wire vga_fb = cfg[12] | vga_force_scaler;
|
||||
wire [1:0] hdmi_limited = {cfg[11],cfg[8]};
|
||||
|
||||
`ifdef DEBUG_NOHDMI
|
||||
@@ -303,7 +303,7 @@ wire ypbpr_en = cfg[5];
|
||||
wire io_osd_vga = io_ss1 & ~io_ss2;
|
||||
`ifndef DUAL_SDRAM
|
||||
wire sog = cfg[9];
|
||||
wire vga_scaler = cfg[2];
|
||||
wire vga_scaler = cfg[2] | vga_force_scaler;
|
||||
`endif
|
||||
|
||||
reg cfg_custom_t = 0;
|
||||
@@ -316,7 +316,7 @@ reg [6:0] coef_addr;
|
||||
reg [8:0] coef_data;
|
||||
reg coef_wr = 0;
|
||||
|
||||
wire [7:0] ARX, ARY;
|
||||
wire[11:0] ARX, ARY;
|
||||
reg [11:0] VSET = 0, HSET = 0;
|
||||
reg FREESCALE = 0;
|
||||
reg [2:0] scaler_flt;
|
||||
@@ -337,6 +337,10 @@ reg [23:0] acy0 = -24'd6216759;
|
||||
reg [23:0] acy1 = 24'd6143386;
|
||||
reg [23:0] acy2 = -24'd2023767;
|
||||
reg areset = 0;
|
||||
reg [11:0] arc1x = 0;
|
||||
reg [11:0] arc1y = 0;
|
||||
reg [11:0] arc2x = 0;
|
||||
reg [11:0] arc2y = 0;
|
||||
|
||||
always@(posedge clk_sys) begin
|
||||
reg [7:0] cmd;
|
||||
@@ -455,6 +459,15 @@ always@(posedge clk_sys) begin
|
||||
14: acy2[23:16] <= io_din[7:0];
|
||||
endcase
|
||||
end
|
||||
if(cmd == 'h3A) begin
|
||||
cnt <= cnt + 1'd1;
|
||||
case(cnt[3:0])
|
||||
0: arc1x <= io_din[11:0];
|
||||
1: arc1y <= io_din[11:0];
|
||||
2: arc2x <= io_din[11:0];
|
||||
3: arc2y <= io_din[11:0];
|
||||
endcase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -778,9 +791,30 @@ always @(posedge clk_vid) begin
|
||||
reg [11:0] videoh;
|
||||
reg [11:0] height;
|
||||
reg [11:0] width;
|
||||
reg [11:0] arx;
|
||||
reg [11:0] ary;
|
||||
|
||||
height <= (VSET && (VSET < HEIGHT)) ? VSET : HEIGHT;
|
||||
width <= (HSET && (HSET < WIDTH)) ? HSET : WIDTH;
|
||||
|
||||
if(!ARY) begin
|
||||
if(ARX == 1) begin
|
||||
arx <= arc1x;
|
||||
ary <= arc1y;
|
||||
end
|
||||
else if(ARX == 2) begin
|
||||
arx <= arc2x;
|
||||
ary <= arc2y;
|
||||
end
|
||||
else begin
|
||||
arx <= 0;
|
||||
ary <= 0;
|
||||
end
|
||||
end
|
||||
else begin
|
||||
arx <= ARX;
|
||||
ary <= ARY;
|
||||
end
|
||||
|
||||
state <= state + 1'd1;
|
||||
case(state)
|
||||
@@ -791,18 +825,20 @@ always @(posedge clk_vid) begin
|
||||
vmax <= LFB_VMAX;
|
||||
state<= 0;
|
||||
end
|
||||
else if(ARX && ARY && !FREESCALE) begin
|
||||
wcalc <= (height*ARX)/ARY;
|
||||
hcalc <= (width*ARY)/ARX;
|
||||
end
|
||||
else begin
|
||||
else if(FREESCALE || !arx || !ary) begin
|
||||
wcalc <= width;
|
||||
hcalc <= height;
|
||||
end
|
||||
else begin
|
||||
wcalc <= (height*arx)/ary;
|
||||
hcalc <= (width*ary)/arx;
|
||||
end
|
||||
|
||||
6: begin
|
||||
videow <= (wcalc > width) ? width : wcalc[11:0];
|
||||
videoh <= (hcalc > height) ? height : hcalc[11:0];
|
||||
end
|
||||
|
||||
7: begin
|
||||
hmin <= ((WIDTH - videow)>>1);
|
||||
hmax <= ((WIDTH - videow)>>1) + videow - 1'd1;
|
||||
@@ -1335,6 +1371,7 @@ wire [7:0] r_out, g_out, b_out, hr_out, hg_out, hb_out;
|
||||
wire vs_fix, hs_fix, de_emu, vs_emu, hs_emu, f1;
|
||||
wire hvs_fix, hhs_fix, hde_emu;
|
||||
wire clk_vid, ce_pix, clk_ihdmi, ce_hpix;
|
||||
wire vga_force_scaler;
|
||||
|
||||
`ifdef USE_DDRAM
|
||||
wire ram_clk;
|
||||
@@ -1422,6 +1459,7 @@ emu emu
|
||||
.VGA_VS(vs_emu),
|
||||
.VGA_DE(de_emu),
|
||||
.VGA_F1(f1),
|
||||
.VGA_SCALER(vga_force_scaler),
|
||||
|
||||
.CLK_VIDEO(clk_vid),
|
||||
.CE_PIXEL(ce_pix),
|
||||
|
||||
Reference in New Issue
Block a user