Add quirk for Ys (Japan) to fix graphics bug (#132)

This commit is contained in:
birdybro
2022-07-08 05:54:03 -06:00
committed by GitHub
parent 26247dd359
commit 29aa9f2ccf
5 changed files with 37 additions and 12 deletions

24
SMS.sv
View File

@@ -498,6 +498,25 @@ sdramclk_ddr
reg rom_wr = 0;
wire sd_wrack;
reg [23:0] romwr_a;
reg ysj_quirk = 0;
always @(posedge clk_sys) begin
reg [31:0] cart_id;
reg old_download;
old_download <= cart_download;
if(~old_download && cart_download) {ysj_quirk} <= 0;
if(ioctl_wr & cart_download) begin
if(ioctl_addr == 'h7ffc) cart_id[31:24] <= ioctl_dout[7:0];
if(ioctl_addr == 'h7ffd) cart_id[23:16] <= ioctl_dout[7:0];
if(ioctl_addr == 'h7ffe) cart_id[15:08] <= ioctl_dout[7:0];
if(ioctl_addr == 'h7fff) cart_id[07:00] <= ioctl_dout[7:0];
if(ioctl_addr == 'h8000) begin
if(cart_id == 32'h13_70_01_4F) ysj_quirk <= 1; // Ys (Japan) Graphics Fix, forces VDP Version 1
end
end
end
always @(posedge clk_sys) begin
reg old_download, old_reset;
@@ -673,6 +692,7 @@ system #(63) system
.smode_M1(smode_M1),
.smode_M2(smode_M2),
.smode_M3(smode_M3),
.ysj_quirk(ysj_quirk),
.pal(pal),
.region(status[10]),
.mapper_lock(status[15] && ~systeme),
@@ -777,7 +797,7 @@ always @(posedge clk_sys) begin
joya_th <= swap ? 1'b1 : joyser_th;
joyb_th <= swap ? joyser_th : 1'b1;
USER_OUT <= {swap ? joyb_tr_out : joya_tr_out, 1'b1, swap ? joyb_th_out : joya_th_out, 4'b1111, };
USER_OUT <= {swap ? joyb_tr_out : joya_tr_out, 1'b1, swap ? joyb_th_out : joya_th_out, 4'b1111 };
end else begin
joya <= ~joy[jcnt];
@@ -861,7 +881,7 @@ video video
.border(border),
.mask_column(mask_column),
.cut_mask(status[29]),
.smode_M1(smode_M1),
.smode_M1(smode_M1),
.smode_M3(smode_M3),
.x(x),
.y(y),

View File

@@ -82,6 +82,7 @@ entity system is
smode_M1: out STD_LOGIC;
smode_M2: out STD_LOGIC;
smode_M3: out STD_LOGIC;
ysj_quirk: in STD_LOGIC;
pal: in STD_LOGIC;
region: in STD_LOGIC;
mapper_lock: in STD_LOGIC;
@@ -349,6 +350,7 @@ begin
smode_M1 => smode_M1,
smode_M2 => smode_M2,
smode_M3 => smode_M3,
ysj_quirk => ysj_quirk,
mask_column => mask_column,
black_column => black_column,
reset_n => RESET_n
@@ -385,6 +387,7 @@ begin
-- smode_M1 => smode2_M1,
-- smode_M2 => smode2_M2,
-- smode_M3 => smode2_M3,
ysj_quirk => ysj_quirk,
-- mask_column => mask2_column,
black_column => black_column,
reset_n => RESET_n

View File

@@ -35,6 +35,7 @@ entity vdp is
smode_M2: out STD_LOGIC;
smode_M3: out STD_LOGIC;
smode_M4: out STD_LOGIC;
ysj_quirk: in STD_LOGIC;
reset_n: in STD_LOGIC);
end vdp;
@@ -144,6 +145,7 @@ begin
smode_M1 => xmode_M1,
smode_M3 => xmode_M3,
smode_M4 => xmode_M4,
ysj_quirk => ysj_quirk,
display_on => display_on,
mask_column0 => mask_column0,

View File

@@ -16,6 +16,7 @@ port (
smode_M1: in std_logic;
smode_M3: in std_logic;
smode_M4: in std_logic;
ysj_quirk: in std_logic;
y: in std_logic_vector(7 downto 0);
screen_y: in std_logic_vector(8 downto 0);
@@ -85,16 +86,13 @@ begin
char_address(12 downto 5) := table_address(13 downto 12) & ("011100" + y(7 downto 3));
else
char_address(12 downto 10) := table_address(13 downto 11);
-- To enable version 1 of the VDP found on the SMS version 1, and you'd want to do that
-- to play only one game : Japanese version of "Ys", you can re-enable the comment in the next code line.
--
-- Since there seems to be no difference between the Japanese version of Ys and the US one, there is no reasonable need
-- to implement a way to select the code below manually or automatically.
char_address(9) := -- table_address(10) and
y(7) ;
char_address(8 downto 5) := y(6 downto 3);
if ysj_quirk = '1' then -- Enable VDP version 1 for Ys (Japan)
char_address(9) := table_address(10) and y(7);
char_address(8 downto 5) := y(6 downto 3);
else
char_address(9) := y(7);
char_address(8 downto 5) := y(6 downto 3);
end if;
end if;
char_address(4 downto 0) := x(7 downto 3) + 1;
data_address := tile_index & tile_y;

View File

@@ -31,6 +31,7 @@ entity vdp_main is
smode_M1: in std_logic;
smode_M3: in std_logic;
smode_M4: in std_logic;
ysj_quirk: in std_logic;
overscan: in std_logic_vector (3 downto 0);
bg_address: in std_logic_vector (3 downto 0);
@@ -104,6 +105,7 @@ begin
smode_M1 => smode_M1,
smode_M3 => smode_M3,
smode_M4 => smode_M4,
ysj_quirk => ysj_quirk,
priority => bg_priority);