mirror of
https://github.com/Gehstock/Mist_FPGA.git
synced 2026-01-27 04:12:10 +00:00
MCR3 Monoboard: add MAX RPM controls
This commit is contained in:
@@ -20,8 +20,9 @@ cat cpu_3b.bin cpu_5b.bin spr_8e.bin spr_6e.bin spr_5e.bin spr_4e.bin til_15a.bi
|
||||
Max RPM
|
||||
=======
|
||||
Controls:
|
||||
Gear : button1/button2
|
||||
Steering/gas: TODO
|
||||
Gear : Button1/Button2
|
||||
Steering: Left/Right
|
||||
Throttle/Brake: Up/Down
|
||||
|
||||
Creating MAXRPM.ROM on Linux:
|
||||
cat pro.0 pro.1 fg-0 fg-1 fg-2 fg-3 bg-0 bg-1 turbskwk.u5 turbskwk.u4 > MAXRPM.ROM
|
||||
|
||||
@@ -209,8 +209,8 @@ set_global_assignment -name ALLOW_SYNCH_CTRL_USAGE ON
|
||||
set_global_assignment -name PARTITION_NETLIST_TYPE SOURCE -section_id Top
|
||||
set_global_assignment -name PARTITION_FITTER_PRESERVATION_LEVEL PLACEMENT_AND_ROUTING -section_id Top
|
||||
set_global_assignment -name PARTITION_COLOR 16764057 -section_id Top
|
||||
set_instance_assignment -name PARTITION_HIERARCHY root_partition -to | -section_id Top
|
||||
set_global_assignment -name SYSTEMVERILOG_FILE rtl/MCR3Mono_MiST.sv
|
||||
set_global_assignment -name VHDL_FILE rtl/spinner.vhd
|
||||
set_global_assignment -name VHDL_FILE rtl/mcr3mono.vhd
|
||||
set_global_assignment -name VHDL_FILE rtl/gen_ram.vhd
|
||||
set_global_assignment -name VHDL_FILE rtl/dpram.vhd
|
||||
@@ -219,10 +219,10 @@ set_global_assignment -name SYSTEMVERILOG_FILE rtl/sdram.sv
|
||||
set_global_assignment -name VHDL_FILE rtl/pll_mist.vhd
|
||||
set_global_assignment -name VHDL_FILE rtl/sounds_good.vhd
|
||||
set_global_assignment -name VHDL_FILE rtl/turbo_cheap_squeak.vhd
|
||||
set_global_assignment -name VHDL_FILE rtl/spy_hunter_control.vhd
|
||||
set_global_assignment -name QIP_FILE ../../common/IO/Z80CTC/z80ctc.qip
|
||||
set_global_assignment -name QIP_FILE ../../common/CPU/68000/FX68k/fx68k.qip
|
||||
set_global_assignment -name VHDL_FILE ../../common/IO/pia6821.vhd
|
||||
set_global_assignment -name VHDL_FILE ../../common/CPU/MC6809/cpu09l_128a.vhd
|
||||
set_global_assignment -name QIP_FILE ../../common/CPU/T80/T80.qip
|
||||
set_global_assignment -name QIP_FILE ../../common/mist/mist.qip
|
||||
set_instance_assignment -name PARTITION_HIERARCHY root_partition -to | -section_id Top
|
||||
set_global_assignment -name QIP_FILE ../../common/mist/mist.qip
|
||||
@@ -84,7 +84,7 @@ always @(*) begin
|
||||
input2 = ~{m_fire3A | m_fire3B, m_fire3A | m_fire3B, m_fire4A | m_fire4B, m_fire4A | m_fire4B, m_down3, m_up3, m_down4, m_up4};
|
||||
end else if (`CORE_NAME == "MAXRPM") begin
|
||||
input0 = ~{service, 3'b000, m_one_player, m_two_players, m_coin1, m_coin2};
|
||||
input1 = {pedal1[5:2], pedal2[5:2]};
|
||||
input1 = ~{maxrpm_adc_data};
|
||||
input2 = ~{maxrpm_gear1, maxrpm_gear2};
|
||||
end else if (`CORE_NAME == "RAMPAGE") begin
|
||||
// normal controls for 3 players
|
||||
@@ -388,28 +388,47 @@ always @(posedge clk_sys) begin
|
||||
end
|
||||
end
|
||||
|
||||
//Pedals for Max RPM
|
||||
wire [5:0] pedal1;
|
||||
spinner spinner1 (
|
||||
.clock_40(clk_sys),
|
||||
.reset(reset),
|
||||
.btn_acc(),
|
||||
.btn_left(m_up),
|
||||
.btn_right(m_down),
|
||||
.ctc_zc_to_2(vs),
|
||||
.spin_angle(pedal1)
|
||||
);
|
||||
//Pedals/Steering for Max RPM
|
||||
reg [7:0] maxrpm_adc_data;
|
||||
reg [3:0] maxrpm_adc_control;
|
||||
always @(*) begin
|
||||
case (maxrpm_adc_control[1:0])
|
||||
2'b00: maxrpm_adc_data = gas2;
|
||||
2'b01: maxrpm_adc_data = gas1;
|
||||
2'b10: maxrpm_adc_data = steering2;
|
||||
2'b11: maxrpm_adc_data = steering1;
|
||||
endcase
|
||||
end
|
||||
|
||||
wire [5:0] pedal2;
|
||||
spinner spinner2 (
|
||||
always @(posedge clk_sys) if (~output6[6] & ~output6[5]) maxrpm_adc_control <= output5[4:1];
|
||||
|
||||
wire [7:0] gas1;
|
||||
wire [7:0] steering1;
|
||||
spy_hunter_control maxrpm_pl1 (
|
||||
.clock_40(clk_sys),
|
||||
.reset(reset),
|
||||
.btn_acc(),
|
||||
.btn_left(m_up2),
|
||||
.btn_right(m_down2),
|
||||
.ctc_zc_to_2(vs),
|
||||
.spin_angle(pedal2)
|
||||
);
|
||||
.vsync(vs),
|
||||
.gas_plus(m_up),
|
||||
.gas_minus(m_down),
|
||||
.steering_plus(m_right),
|
||||
.steering_minus(m_left),
|
||||
.steering(steering1),
|
||||
.gas(gas1)
|
||||
);
|
||||
|
||||
wire [7:0] gas2;
|
||||
wire [7:0] steering2;
|
||||
spy_hunter_control maxrpm_pl2 (
|
||||
.clock_40(clk_sys),
|
||||
.reset(reset),
|
||||
.vsync(vs),
|
||||
.gas_plus(m_up2),
|
||||
.gas_minus(m_down2),
|
||||
.steering_plus(m_right2),
|
||||
.steering_minus(m_left2),
|
||||
.steering(steering2),
|
||||
.gas(gas2)
|
||||
);
|
||||
|
||||
// MaxRPM gearbox
|
||||
wire [3:0] maxrpm_gear_bits[5] = '{ 4'h0, 4'h5, 4'h6, 4'h1, 4'h2 };
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.std_logic_unsigned.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
entity spinner is
|
||||
port(
|
||||
clock_40 : in std_logic;
|
||||
reset : in std_logic;
|
||||
btn_left : in std_logic;
|
||||
btn_right : in std_logic;
|
||||
btn_acc : in std_logic; -- speed up button
|
||||
ctc_zc_to_2 : in std_logic;
|
||||
spin_angle : out std_logic_vector(6 downto 0)
|
||||
);
|
||||
end spinner;
|
||||
|
||||
architecture rtl of spinner is
|
||||
|
||||
signal ctc_zc_to_2_r : std_logic;
|
||||
signal spin_count : std_logic_vector(9 downto 0);
|
||||
|
||||
begin
|
||||
|
||||
spin_angle <= spin_count(9 downto 3);
|
||||
|
||||
process (clock_40, reset)
|
||||
begin
|
||||
if reset = '1' then
|
||||
spin_count <= (others => '0');
|
||||
elsif rising_edge(clock_40) then
|
||||
ctc_zc_to_2_r <= ctc_zc_to_2;
|
||||
|
||||
if ctc_zc_to_2_r ='0' and ctc_zc_to_2 = '1' then
|
||||
if btn_acc = '0' then -- space -- speed up
|
||||
if btn_left = '1' then spin_count <= spin_count - 40; end if; -- left
|
||||
if btn_right = '1' then spin_count <= spin_count + 40; end if; -- right
|
||||
else
|
||||
if btn_left = '1' then spin_count <= spin_count - 55; end if;
|
||||
if btn_right = '1' then spin_count <= spin_count + 55; end if;
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
end process;
|
||||
|
||||
end rtl;
|
||||
160
Arcade_MiST/Midway MCR 3 Monoboard/rtl/spy_hunter_control.vhd
Normal file
160
Arcade_MiST/Midway MCR 3 Monoboard/rtl/spy_hunter_control.vhd
Normal file
@@ -0,0 +1,160 @@
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.std_logic_unsigned.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
entity spy_hunter_control is
|
||||
port(
|
||||
clock_40 : in std_logic;
|
||||
reset : in std_logic;
|
||||
vsync : in std_logic;
|
||||
|
||||
gas_plus : in std_logic;
|
||||
gas_minus : in std_logic;
|
||||
steering_plus : in std_logic;
|
||||
steering_minus: in std_logic;
|
||||
steering : out std_logic_vector(7 downto 0);
|
||||
gas : out std_logic_vector(7 downto 0)
|
||||
);
|
||||
end spy_hunter_control;
|
||||
|
||||
|
||||
architecture struct of spy_hunter_control is
|
||||
signal steering_r : std_logic_vector(7 downto 0);
|
||||
--signal steering_plus : std_logic;
|
||||
signal steering_plus_r : std_logic;
|
||||
--signal steering_minus : std_logic;
|
||||
signal steering_minus_r : std_logic;
|
||||
signal steering_timer : std_logic_vector(5 downto 0);
|
||||
|
||||
signal gas_r : std_logic_vector(7 downto 0);
|
||||
--signal gas_plus : std_logic;
|
||||
signal gas_plus_r : std_logic;
|
||||
--signal gas_minus : std_logic;
|
||||
signal gas_minus_r : std_logic;
|
||||
signal gas_timer : std_logic_vector(5 downto 0);
|
||||
signal vsync_r : std_logic;
|
||||
begin-- absolute position decoder simulation
|
||||
--
|
||||
-- steering :
|
||||
-- thresholds median
|
||||
-- F5 < left 8 < 34 30
|
||||
-- 35 < left 7 < 3C 38
|
||||
-- 3D < left 6 < 44 40
|
||||
-- 45 < left 5 < 4C 48
|
||||
-- 4D < left 4 < 54 50
|
||||
-- 45 < left 3 < 5C 58
|
||||
-- 5D < left 2 < 64 60
|
||||
-- 65 < left 1 < 6C 68
|
||||
-- 6D < centrered < 74 70
|
||||
-- 75 < right 1 < 7C 78
|
||||
-- 7D < right 2 < 84 80
|
||||
-- 85 < right 3 < 8C 88
|
||||
-- 8D < right 4 < 94 90
|
||||
-- 95 < right 5 < 9C 98
|
||||
-- 9D < right 6 < A4 A0
|
||||
-- A5 < right 7 < AC A8
|
||||
-- AD < right 8 < F4 BO
|
||||
|
||||
-- gas :
|
||||
-- threshold median
|
||||
-- 00 < gas pedal 00 < 3B (39) 3E-5
|
||||
-- 3C < gas pedal 01 < 40 3E
|
||||
-- 41 < gas pedal 02 < 45 43
|
||||
-- 46 < gas pedal 03 < 4A 48
|
||||
-- 4B < gas pedal 04 < 4F 4D
|
||||
-- 50 < gas pedal 05 < 54 52
|
||||
-- 55 < gas pedal 06 < 59 57
|
||||
-- 5A < gas pedal 07 < 5E 5C
|
||||
-- 5F < gas pedal 08 < 63 61
|
||||
-- ...
|
||||
-- FA < gas pedal 27 < FE FC
|
||||
-- FF = gas pedal 28 (FF) FC+4
|
||||
|
||||
|
||||
gas <= gas_r;
|
||||
steering <= steering_r;
|
||||
|
||||
process (clock_40, reset)
|
||||
begin
|
||||
if reset = '1' then
|
||||
gas_r <= x"39";
|
||||
steering_r <= x"70";
|
||||
else
|
||||
|
||||
if rising_edge(clock_40) then
|
||||
gas_plus_r <= gas_plus;
|
||||
gas_minus_r <= gas_minus;
|
||||
steering_plus_r <= steering_plus;
|
||||
steering_minus_r <= steering_minus;
|
||||
vsync_r <= vsync;
|
||||
|
||||
-- gas increase/decrease as long as btn is pushed
|
||||
-- keep current value when no btn is pushed
|
||||
if gas_r < x"39" then
|
||||
gas_r <= x"39";
|
||||
else
|
||||
if (gas_plus_r = not gas_plus) or
|
||||
(gas_minus_r = not gas_minus) then
|
||||
gas_timer <= (others => '0');
|
||||
else
|
||||
if vsync_r ='0' and vsync = '1' then
|
||||
if (gas_timer >= 5 and (gas_minus_r = '1' or gas_plus_r = '1')) then --tune inc/dec rate
|
||||
gas_timer <= (others => '0');
|
||||
else
|
||||
gas_timer <= gas_timer + 1;
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
if vsync_r ='0' and vsync = '1' and gas_timer = 0 then
|
||||
if gas_plus = '1' then
|
||||
if gas_r >= x"FC" then gas_r <= x"FF"; else gas_r <= gas_r + 5; end if;
|
||||
elsif gas_minus = '1' then
|
||||
if gas_r <= x"3E" then gas_r <= x"39"; else gas_r <= gas_r - 5; end if;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
end if;
|
||||
|
||||
-- steering increase/decrease as long as btn is pushed
|
||||
-- return to center value when no btn is pushed
|
||||
if steering_r < x"30" then
|
||||
steering_r <= x"30";
|
||||
elsif steering_r > x"B0" then
|
||||
steering_r <= x"B0";
|
||||
else
|
||||
if (steering_plus_r = not steering_plus) or
|
||||
(steering_minus_r = not steering_minus) then
|
||||
steering_timer <= (others => '0');
|
||||
else
|
||||
if vsync_r ='0' and vsync = '1' then
|
||||
if (steering_timer >= 7 and (steering_minus_r = '1' or steering_plus_r = '1')) or -- tune btn pushed rate
|
||||
(steering_timer >= 3 and (steering_minus_r = '0' and steering_plus_r = '0')) then -- tune btn released rate
|
||||
steering_timer <= (others => '0');
|
||||
else
|
||||
steering_timer <= steering_timer + 1;
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
if vsync_r ='0' and vsync = '1' and steering_timer = 0 then
|
||||
if steering_plus = '1' then
|
||||
if steering_r >= x"A8" then steering_r <= x"B0"; else steering_r <= steering_r + 8; end if;
|
||||
elsif steering_minus = '1' then
|
||||
if steering_r <= x"38" then steering_r <= x"30"; else steering_r <= steering_r - 8; end if;
|
||||
else
|
||||
if steering_r <= x"68" then steering_r <= steering_r + 8; end if;
|
||||
if steering_r >= x"78" then steering_r <= steering_r - 8; end if;
|
||||
if (steering_r > x"68") and (steering_r < x"78") then steering_r <= x"70"; end if;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
end if;
|
||||
|
||||
end if;
|
||||
|
||||
end if;
|
||||
end process;
|
||||
|
||||
end struct;
|
||||
Reference in New Issue
Block a user