1
0
mirror of https://github.com/mist-devel/mist-board.git synced 2026-02-06 08:04:41 +00:00

Merge pull request #94 from gyurco/c64

C64 TAP, keyboard, CIA, RAM erase fixes
This commit is contained in:
gyurco
2019-04-13 23:59:21 +02:00
committed by GitHub
3 changed files with 50 additions and 60 deletions

View File

@@ -72,10 +72,14 @@ architecture rtl of fpga64_keyboard_matrix is
signal key_return: std_logic := '0';
signal key_left: std_logic := '0';
signal key_right: std_logic := '0';
signal key_f7: std_logic := '0';
signal key_f1: std_logic := '0';
signal key_f2: std_logic := '0';
signal key_f3: std_logic := '0';
signal key_f4: std_logic := '0';
signal key_f5: std_logic := '0';
signal key_f6: std_logic := '0';
signal key_f7: std_logic := '0';
signal key_f8: std_logic := '0';
signal key_up: std_logic := '0';
signal key_down: std_logic := '0';
@@ -144,7 +148,7 @@ architecture rtl of fpga64_keyboard_matrix is
-- for joystick emulation on PS2
signal joySelKey : std_logic;
signal joyKeys : std_logic_vector(joyA'range); -- active high
signal joyKeys : std_logic_vector(joyA'range) := (others => '0'); -- active high
signal joyA_s : unsigned(joyA'range); -- active low
signal joyB_s : unsigned(joyB'range); -- active low
signal joySel : std_logic_vector(1 downto 0) := "00";
@@ -206,10 +210,10 @@ begin
((pbi(0) or not key_del) and
(pbi(1) or not key_return) and
(pbi(2) or not (key_left or key_right)) and
(pbi(3) or not key_f7) and
(pbi(4) or not key_f1) and
(pbi(5) or not key_f3) and
(pbi(6) or not key_f5) and
(pbi(3) or not (key_f7 or key_f8)) and
(pbi(4) or not (key_f1 or key_f2)) and
(pbi(5) or not (key_f3 or key_f4)) and
(pbi(6) or not (key_f5 or key_f6)) and
(pbi(7) or not (key_up or key_down))));
pao(1) <= pai(1) and joyA_s(1) and
((not backwardsReadingEnabled) or
@@ -220,7 +224,7 @@ begin
(pbi(4) or not key_Z) and
(pbi(5) or not key_S) and
(pbi(6) or not key_E) and
(pbi(7) or not (key_left or key_up or key_shiftL))));
(pbi(7) or not (key_left or key_up or key_shiftL or key_f2 or key_f4 or key_f6 or key_f8))));
pao(2) <= pai(2) and joyA_s(2) and
((not backwardsReadingEnabled) or
((pbi(0) or not key_5) and
@@ -348,7 +352,7 @@ begin
(pai(7) or not key_Q);
pbo(7) <= pbi(7) and
(pai(0) or not (key_up or key_down)) and
(pai(1) or not (key_left or key_up or key_shiftL)) and
(pai(1) or not (key_left or key_up or key_shiftL or key_f2 or key_f4 or key_f6 or key_f8)) and
(pai(2) or not key_X) and
(pai(3) or not key_V) and
(pai(4) or not key_N) and
@@ -371,25 +375,22 @@ begin
releaseFlag <= '0';
extendedFlag <= '0';
case theScanCode is
when X"01" => key_pound <= not releaseFlag;
when X"03" => key_F5 <= not releaseFlag;
when X"04" => key_F3 <= not releaseFlag;
when X"05" => key_F1 <= not releaseFlag;
when X"06" => -- F2
if releaseFlag = '0' then
traceKey <= '1';
end if;
when X"09" => key_plus <= not releaseFlag;
when X"0A" => -- F8
if releaseFlag = '0' then
diskChgKey <= '1';
end if;
when X"0B" => -- F6
if releaseFlag = '0' then
trace2Key <= '1';
end if;
when X"0C" => restore_key <= not releaseFlag; -- F4
when X"06" => key_F2 <= not releaseFlag;
when X"04" => key_F3 <= not releaseFlag;
when X"0C" => key_F4 <= not releaseFlag;
when X"03" => key_F5 <= not releaseFlag;
when X"0B" => key_F6 <= not releaseFlag;
when X"83" => key_F7 <= not releaseFlag;
when X"0A" => key_F8 <= not releaseFlag;
when X"01" => key_pound <= not releaseFlag; -- F9
when X"09" => key_plus <= not releaseFlag; -- F10
when X"78" => -- F11
if key_ctrl = '1' then
reset_key <= not releaseFlag;
else
restore_key <= not releaseFlag;
end if;
when X"0E" => key_arrowleft <= not releaseFlag;
when X"11" => key_commodore <= not releaseFlag;
when X"12" => if extendedFlag = '0' then key_shiftl <= not releaseFlag; end if;
@@ -458,14 +459,6 @@ begin
when X"74" => if extendedFlag = '0' then joyKeys(3) <= not releaseFlag; else key_right <= not releaseFlag; end if;
when X"75" => if extendedFlag = '0' then joyKeys(0) <= not releaseFlag; else key_up <= not releaseFlag; end if;
when X"76" => key_runstop <= not releaseFlag;
when X"78" => -- F11
if key_ctrl = '1' then
reset_key <= not releaseFlag;
else
if releaseFlag = '0' then
joySelKey <= '1';
end if;
end if;
when others => null;
end case;
end if;

View File

@@ -348,8 +348,6 @@ end component cartridge;
signal c64_data_out: std_logic_vector(7 downto 0);
signal sdram_addr: std_logic_vector(24 downto 0);
signal sdram_data_out: std_logic_vector(7 downto 0);
-- cartridge signals LCA
signal cart_id : std_logic_vector(15 downto 0); -- cart ID or cart type
@@ -509,7 +507,6 @@ end component cartridge;
signal tap_wrreq : std_logic;
signal tap_wrfull : std_logic;
signal tap_fifo_error : std_logic;
signal tap_loaded : std_logic;
signal tap_mode : std_logic;
signal tap_play : std_logic;
signal tap_play_btn: std_logic;
@@ -652,35 +649,38 @@ begin
joyA_c64 <= joyB_int when status(3)='1' else joyA_int;
joyB_c64 <= joyA_int when status(3)='1' else joyB_int;
sdram_addr <= c64_addr_temp when iec_cycle='0' else ioctl_ram_addr when ioctl_download = '1' else tap_play_addr;
sdram_addr <= c64_addr_temp when iec_cycle='0' else ioctl_ram_addr when ioctl_download = '1' or erasing = '1' else tap_play_addr;
sdram_data_out <= c64_data_out when iec_cycle='0' else ioctl_ram_data;
-- ram_we and ce are active low
sdram_ce <= mem_ce when iec_cycle='0' else ioctl_iec_cycle_used or tap_mem_ce;
sdram_we <= not ram_we when iec_cycle='0' else ioctl_iec_cycle_used when ioctl_download = '1' else '0';
sdram_we <= not ram_we when iec_cycle='0' else ioctl_iec_cycle_used when ioctl_download = '1' or erasing = '1' else '0';
process(clk_c64)
begin
if falling_edge(clk_c64) then
if rising_edge(clk_c64) then
old_download <= ioctl_download;
iec_cycleD <= iec_cycle;
cart_hdr_wr <= '0';
if(iec_cycle='1' and iec_cycleD='0' and ioctl_ram_wr='1') then
if iec_cycle = '0' and iec_cycleD = '1' and ioctl_ram_wr = '1' then
ioctl_ram_wr <= '0';
ioctl_iec_cycle_used <= '1';
ioctl_ram_addr <= ioctl_load_addr;
ioctl_load_addr <= ioctl_load_addr + "1";
ioctl_ram_addr <= ioctl_load_addr;
ioctl_load_addr <= ioctl_load_addr + 1;
if erasing = '1' then
ioctl_ram_data <= (others => '0');
-- fill RAM with 64 bytes 0, 64 bytes ff
-- same as VICE uses
-- Freeload and probably some more code depend on some kind of pattern
ioctl_ram_data <= (others => ioctl_load_addr(6));
else
ioctl_ram_data <= ioctl_data;
end if;
else
if(iec_cycle='0') then
ioctl_iec_cycle_used <= '0';
end if;
ioctl_iec_cycle_used <= '1';
end if;
-- second IEC cycle - SDRAM data written, disable WE on the next
if iec_cycle = '1' and iec_cycleD = '1' and ioctl_iec_cycle_used = '1' then
ioctl_iec_cycle_used <= '0';
end if;
if ioctl_wr='1' then
@@ -740,9 +740,8 @@ begin
if ioctl_addr = 0 then
ioctl_load_addr <= '0' & X"200000";
ioctl_ram_data <= ioctl_data;
else
ioctl_ram_wr <= '1';
end if;
ioctl_ram_wr <= '1';
end if;
end if;
@@ -752,10 +751,6 @@ begin
erase_cram <= '1';
end if;
if old_download /= ioctl_download and ioctl_index = x"42" then
tap_loaded <= old_download;
end if;
if status(5)='1' or buttons(1)='1' then
cart_attached <= '0';
end if;
@@ -1212,21 +1207,23 @@ begin
end if;
tap_play_btnD <= tap_play_btn;
if tap_loaded = '1' and tap_play_btnD = '0' and tap_play_btn = '1' then
if tap_play_btnD = '0' and tap_play_btn = '1' then
tap_play <= not tap_play;
end if;
if tap_fifo_error = '1' or tap_play_addr = tap_last_addr then tap_play <= '0'; end if;
-- if tap_fifo_error = '1' then tap_play <= '0'; end if;
iec_cycle_rD <= iec_cycle;
tap_wrreq <= '0';
if iec_cycle = '0' and iec_cycle_rD = '1' and tap_play = '1' and tap_wrfull = '0' then
tap_play_addr <= tap_play_addr + 1;
if iec_cycle = '0' and iec_cycle_rD = '1' and
ioctl_download = '0' and tap_play_addr /= tap_last_addr and tap_wrfull = '0' then
tap_mem_ce <= '1';
end if;
-- second IEC cycle - SDRAM data ready on the next
if iec_cycle = '1' and iec_cycle_rD = '1' and tap_mem_ce = '1' then
tap_mem_ce <= '0';
tap_wrreq <= '1';
tap_play_addr <= tap_play_addr + 1;
end if;
end if;
end process;

View File

@@ -155,11 +155,11 @@ end
always @(posedge clk) begin
if (!res_n) icr[4] <= 1'b0;
else begin
if (!flag_n && flag_n_prev) icr[4] <= 1'b1;
if (phi2_p) begin
flag_n_prev <= flag_n;
if (int_reset) icr[4] <= 1'b0;
end
flag_n_prev <= flag_n;
if (!flag_n && flag_n_prev) icr[4] <= 1'b1;
end
end