1
0
mirror of https://github.com/Gehstock/Mist_FPGA.git synced 2026-01-18 17:06:57 +00:00

Merge pull request #93 from gyurco/spdball

Fix Speed Ball
This commit is contained in:
Marcel 2020-06-19 23:16:26 +02:00 committed by GitHub
commit b4cd8a80eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 176 additions and 133 deletions

View File

@ -1,7 +1,8 @@
robotron-fpga MiST port
=======================
Supported games: Robotron 2048, Joust, Sinistar, Bubbles, Splat, Stargate, Alien Arena, Playball!
Supported games: Robotron 2048, Joust, Splat, Bubbles, Stargate, Alien Arena, Sinistar,
Playball!, Lotto Fun, Speed Ball
After loading the RBF (Core), a CMOS clearing happens. When the message
"Factory Settings Restored" appears, press the MiST soft RESET button (right).
@ -29,6 +30,7 @@ Some of the Williams cores use more buttons than usual and require remaps to be
The file [README-joystick-remaps.txt](https://github.com/Gehstock/Mist_FPGA_Cores/blob/master/Arcade_MiST/Williams%206809%20rev.1%20Hardware/README-joystick-remaps.txt) contains joystick remaps for the Williams cores.
** Note: ** Speed Ball is playable only with two human players. It needs two controllers and two mice (with the appropriate firmware supporting two mice).
---

View File

@ -4,7 +4,8 @@
// Robotron-FPGA is Copyright 2012 ShareBrained Technology, Inc.
//
// Supports:
// Robotron 2048/Joust/Stargate/Bubbles/Splat/Sinistar/Lotto Fun
// Robotron 2048/Joust/Splat/Bubbles/Stargate/Alien Arena/Sinistar/
// Playball!/Lotto Fun/Speed Ball
module RobotronFPGA_MiST(
output LED,
@ -56,8 +57,8 @@ wire rotate = status[2];
wire [1:0] scanlines = status[4:3];
wire blend = status[5];
wire joyswap = status[6];
wire autoup = status[7] | (core_mod != 7'h8);// Memory Protect for Lotto Fun
wire adv = status[8] ;
wire autoup = status[7];
wire adv = status[8];
reg [7:0] SW;
reg [7:0] JA;
@ -91,10 +92,10 @@ always @(*) begin
JA = 8'hFF;
JB = 8'hFF;
BTN = 4'hF;
AN0 = 8'hFF;
AN1 = 8'hFF;
AN2 = 8'hFF;
AN3 = 8'hFF;
AN0 = 8'h80;
AN1 = 8'h80;
AN2 = 8'h80;
AN3 = 8'h80;
blitter_sc2 = 0;
sinistar = 0;
speedball = 0;
@ -163,22 +164,43 @@ always @(*) begin
JA = ~{ 4'b0000, m_right, m_left, m_down, m_up };
JB = 8'b11111111;//IN1
end
7'h9: // Speed Ball
7'h9: // SPEED BALL
begin
speedball = 1;
BTN = { m_two_players, m_one_player, m_coin1 | m_coin2, reset };//IN2
JA = 8'b11111111;//IN0
JB = 8'b11111111;//IN1
//todo
// AN0 =;
// AN1 =;
// AN2 =;
// AN3 =;
BTN = { m_two_players, m_one_player, m_coin1 | m_coin2, reset };
JA = { m_fireD, m_fireC, m_fireB, m_fireA | mouse_btns0[0], m_right, m_left, m_down, m_up };
JB = { m_fire2D, m_fire2C, m_fire2B, m_fire2A | mouse_btns1[0], m_right2, m_left2, m_down2, m_up2 };
AN0 = {~y_pos0[8], y_pos0[7:1]};
AN1 = {~x_pos0[8], x_pos0[7:1]};
AN2 = {~y_pos1[8], y_pos1[7:1]};
AN3 = {~x_pos1[8], x_pos1[7:1]};
end
default: ;
endcase
end
reg signed [9:0] x_pos0;
reg signed [9:0] y_pos0;
reg [1:0] mouse_btns0;
reg signed [9:0] x_pos1;
reg signed [9:0] y_pos1;
reg [1:0] mouse_btns1;
always @(posedge clk_sys) begin
if (mouse_strobe) begin
if (~mouse_idx) begin
mouse_btns0 <= mouse_flags[1:0];
x_pos0 <= x_pos0 + mouse_x;
y_pos0 <= y_pos0 + mouse_y;
end else begin
mouse_btns1 <= mouse_flags[1:0];
x_pos1 <= x_pos1 + mouse_x;
y_pos1 <= y_pos1 + mouse_y;
end
end
end
assign LED = ~ioctl_downl;
assign SDRAM_CLK = clk_mem;
assign SDRAM_CKE = 1;
@ -206,6 +228,12 @@ wire key_pressed;
wire [7:0] key_code;
wire key_strobe;
wire mouse_strobe;
wire signed [8:0] mouse_x;
wire signed [8:0] mouse_y;
wire [7:0] mouse_flags;
wire mouse_idx;
user_io #(
.STRLEN($size(CONF_STR)>>3))
user_io(
@ -224,6 +252,11 @@ user_io(
.key_strobe ( key_strobe ),
.key_pressed ( key_pressed ),
.key_code ( key_code ),
.mouse_idx ( mouse_idx ),
.mouse_strobe ( mouse_strobe ),
.mouse_x ( mouse_x ),
.mouse_y ( mouse_y ),
.mouse_flags ( mouse_flags ),
.joystick_0 ( joystick_0 ),
.joystick_1 ( joystick_1 ),
.status ( status )
@ -352,6 +385,10 @@ robotron_soc robotron_soc (
.SW ( SW ),
.JA ( JA ),
.JB ( JB ),
.AN0 ( AN0 ),
.AN1 ( AN1 ),
.AN2 ( AN2 ),
.AN3 ( AN3 ),
.MemAdr ( mem_addr ),
.MemDin ( mem_di ),

View File

@ -39,7 +39,7 @@ entity robotron_cpu is
clock : in std_logic;
blitter_sc2 : in std_logic;
sinistar : in std_logic;
speedball : in std_logic;
speedball : in std_logic;
-- MC6809 signals
A : in std_logic_vector(15 downto 0);
Dout : in std_logic_vector(7 downto 0);
@ -123,11 +123,11 @@ entity robotron_cpu is
JB : in std_logic_vector(7 downto 0);
SIN_FIRE : in std_logic;
SIN_BOMB : in std_logic;
-- Analog Input
AN0 : in std_logic_vector(7 downto 0);
AN1 : in std_logic_vector(7 downto 0);
AN2 : in std_logic_vector(7 downto 0);
AN3 : in std_logic_vector(7 downto 0);
-- Analog Input
AN0 : in std_logic_vector(7 downto 0);
AN1 : in std_logic_vector(7 downto 0);
AN2 : in std_logic_vector(7 downto 0);
AN3 : in std_logic_vector(7 downto 0);
-- To sound board
HAND : in std_logic := '1';
PB : out std_logic_vector(5 downto 0)
@ -228,13 +228,14 @@ architecture Behavioral of robotron_cpu is
signal hiram_access : boolean; -- Sinistar hiram
signal color_table_access : boolean;
signal widget_pia_access : boolean;
signal extra_pia_access : boolean;
signal extra_pia_access : boolean;
signal rom_pia_access : boolean;
signal blt_register_access : boolean;
signal video_counter_access : boolean;
signal watchdog_access : boolean;
signal control_access : boolean;
signal cmos_access : boolean;
signal trkball_access : boolean;
signal video_counter_value : std_logic_vector(7 downto 0);
@ -248,7 +249,6 @@ architecture Behavioral of robotron_cpu is
signal ADVANCE : std_logic := '1';
signal AUTO_UP : std_logic := '0';
signal rom_pia_rs : std_logic_vector(1 downto 0) := (others => '0');
signal rom_pia_cs : std_logic := '0';
signal rom_pia_write : std_logic := '0';
signal rom_pia_data_in : std_logic_vector(7 downto 0);
@ -292,7 +292,6 @@ architecture Behavioral of robotron_cpu is
signal board_interface_w1 : std_logic := '1'; -- Upright application: '1' = jumper present
signal widget_pia_rs : std_logic_vector(1 downto 0) := (others => '0');
signal widget_pia_cs : std_logic;
signal widget_pia_write : std_logic := '0';
signal widget_pia_data_in : std_logic_vector(7 downto 0);
@ -318,18 +317,9 @@ architecture Behavioral of robotron_cpu is
signal widget_ic4_a : std_logic_vector(4 downto 1);
signal widget_ic4_b : std_logic_vector(4 downto 1);
signal widget_ic4_y : std_logic_vector(4 downto 1);
-------------------------------------------------------------------
-- signal SLAM : std_logic := '1';
-- signal R_COIN : std_logic := '1';
-- signal C_COIN : std_logic := '1';
-- signal L_COIN : std_logic := '1';
-- signal H_S_RESET : std_logic := '1';
-- signal ADVANCE : std_logic := '1';
-- signal AUTO_UP : std_logic := '0';
signal extra_pia_rs : std_logic_vector(1 downto 0) := (others => '0');
signal extra_pia_cs : std_logic := '0';
signal extra_pia_write : std_logic := '0';
signal extra_pia_data_in : std_logic_vector(7 downto 0);
@ -466,8 +456,8 @@ begin
widget_pia_access <= std_match(address, "11001000----01--");
-- Speedball PIA: read/write: C8X8 - C8XB
extra_pia_access <= std_match(address, "11001000----1---");
extra_pia_access <= std_match(address, "11001000----10--");
-- ROM PIA: read/write: C8XC - C8XF
rom_pia_access <= std_match(address, "11001000----11--");
@ -486,6 +476,9 @@ begin
-- CMOS "nonvolatile" RAM: read/write: CC00 - CFFF
cmos_access <= std_match(address, "110011----------");
-- Speedball Trackballs: read C800-C803
trkball_access <= std_match(address, "11001000----00--");
SLAM <= not SW(6);
H_S_RESET <= not SW(2);
ADVANCE <= not SW(1);
@ -704,27 +697,24 @@ begin
end if;
if rom_pia_access then
rom_pia_rs <= address(1 downto 0);
rom_pia_data_in <= mpu_data_in;
rom_pia_write <= to_std_logic(write);
rom_pia_cs <= '1';
end if;
if widget_pia_access then
widget_pia_rs <= address(1 downto 0);
widget_pia_data_in <= mpu_data_in;
widget_pia_write <= to_std_logic(write);
widget_pia_cs <= '1';
end if;
if speedball = '1' then
if extra_pia_access then
extra_pia_rs <= address(1 downto 0);
extra_pia_data_in <= mpu_data_in;
extra_pia_write <= to_std_logic(write);
extra_pia_cs <= '1';
end if;
end if;
if speedball = '1' then
if extra_pia_access then
extra_pia_data_in <= mpu_data_in;
extra_pia_write <= to_std_logic(write);
extra_pia_cs <= '1';
end if;
end if;
if control_access and write then
blt_win_en <= mpu_data_in(2) and sinistar;
@ -748,11 +738,23 @@ begin
if widget_pia_access then
mpu_data_out <= widget_pia_data_out;
end if;
if extra_pia_access then
mpu_data_out <= extra_pia_data_out;
if speedball = '1' then
if extra_pia_access then
mpu_data_out <= extra_pia_data_out;
end if;
if trkball_access then
case address(1 downto 0) is
when "00" => mpu_data_out <= AN0;
when "01" => mpu_data_out <= AN1;
when "10" => mpu_data_out <= AN2;
when "11" => mpu_data_out <= AN3;
when others => null;
end case;
end if;
end if;
if rom_pia_access then
mpu_data_out <= rom_pia_data_out;
end if;
@ -887,36 +889,37 @@ begin
widget_ic4_b <= not (FIRE_RIGHT_1 & FIRE_LEFT_1 & FIRE_DOWN_1 & FIRE_UP_1);
widget_ic4_y <= widget_ic4_b when widget_pia_input_select = '1' else widget_ic4_a;
--IN0
widget_pia_pa_in <= widget_ic4_y(2) &--fire down
widget_ic4_y(1) &--fire up
not PLAYER_2_START &
not PLAYER_1_START &
widget_ic3_y(4) &--right
widget_ic3_y(3) &--left
widget_ic3_y(2) &--down
widget_ic3_y(1) when sinistar = '0' else--up
widget_ic4_y(4) &--fire right
widget_pia_pa_in <= widget_ic4_y(4) &--fire right
widget_ic4_y(3) &--fire left
widget_ic4_y(2) &--fire down
widget_ic4_y(1) &--fire up
widget_ic3_y(4) &--right
widget_ic3_y(3) &--left
widget_ic3_y(2) &--down
widget_ic3_y(1);--up
--IN1
widget_ic3_y(1) when sinistar = '1' else --up
"00000000" when speedball = '1' else
widget_ic4_y(2) &--fire down
widget_ic4_y(1) &--fire up
not PLAYER_2_START &
not PLAYER_1_START &
widget_ic3_y(4) &--right
widget_ic3_y(3) &--left
widget_ic3_y(2) &--down
widget_ic3_y(1); --up
widget_pia_pb_in <= not board_interface_w1 &
"00000" &
widget_ic4_y(4) &--fire right
widget_ic4_y(3) when sinistar = '0' else --fire left
not board_interface_w1 &
"0" &
not PLAYER_2_START &
not PLAYER_1_START &
"00" &
not SIN_BOMB &
not SIN_FIRE;
not SIN_FIRE when sinistar = '1' else
"00000000" when speedball = '1' else
not board_interface_w1 &
"00000" &
widget_ic4_y(4) &
widget_ic4_y(3);
widget_pia: work.pia6821
port map(
@ -950,48 +953,24 @@ begin
);
-------------------------------------------------------------------
-- PORT_START("IN3")
-- PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
-- PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
-- PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
-- PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)
-- PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1)
-- PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
-- PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2)
-- PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
--IN3
extra_pia_pa_in <= '0' & --unknown
FIRE_UP_2 & --fire 2
'0' & --unknown
FIRE_UP_1 & --fire 1
MOVE_DOWN_2 &--down2
MOVE_UP_2 &--up2
MOVE_DOWN_1 &--down1
MOVE_UP_1;--up1
-- PORT_START("IN4")
-- PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)
-- PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
-- PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
-- PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
-- PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN )
-- PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
-- PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START1 )
-- PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_START2 )
--IN4
extra_pia_pa_in <= '0' & --unknown
FIRE_UP_2 &
'0' & --unknown
FIRE_UP_1 &
MOVE_DOWN_2 &
MOVE_UP_2 &
MOVE_DOWN_1 &
MOVE_UP_1;
extra_pia_pb_in <= not PLAYER_2_START &
not PLAYER_1_START &
"00" &
MOVE_RIGHT_2 &
MOVE_LEFT_2 &
MOVE_RIGHT_1 &
MOVE_LEFT_1;
"00" &
MOVE_RIGHT_2 &
MOVE_LEFT_2 &
MOVE_RIGHT_1 &
MOVE_LEFT_1;
extra_pia: work.pia6821
port map(
rst => reset,

View File

@ -84,7 +84,9 @@ port (
AN0 : in std_logic_vector(7 downto 0);
AN1 : in std_logic_vector(7 downto 0);
AN2 : in std_logic_vector(7 downto 0);
AN3 : in std_logic_vector(7 downto 0);
AN3 : in std_logic_vector(7 downto 0);
-- ROM download signals
dl_clock : in std_logic;
dl_addr : in std_logic_vector(16 downto 0);
dl_data : in std_logic_vector(7 downto 0);

View File

@ -12,7 +12,11 @@ use IEEE.numeric_std.all;
package mist is
component user_io
generic(STRLEN : integer := 0 );
generic(
STRLEN : integer := 0;
PS2DIV : integer := 100;
ROM_DIRECT_UPLOAD : boolean := false
);
port (
clk_sys : in std_logic;
clk_sd : in std_logic := '0';
@ -35,14 +39,14 @@ port (
core_mod : out std_logic_vector(6 downto 0);
sd_lba : in std_logic_vector(31 downto 0) := (others => '0');
sd_rd : in std_logic := '0';
sd_wr : in std_logic := '0';
sd_rd : in std_logic_vector(1 downto 0) := (others => '0');
sd_wr : in std_logic_vector(1 downto 0) := (others => '0');
sd_ack : out std_logic;
sd_ack_conf : out std_logic;
sd_conf : in std_logic := '0';
sd_sdhc : in std_logic := '1';
img_size : out std_logic_vector(31 downto 0);
img_mounted : out std_logic;
img_mounted : out std_logic_vector(1 downto 0);
sd_buff_addr : out std_logic_vector(8 downto 0);
sd_dout : out std_logic_vector(7 downto 0);
@ -61,8 +65,10 @@ port (
ps2_mouse_data : out std_logic;
mouse_x : out signed(8 downto 0);
mouse_y : out signed(8 downto 0);
mouse_z : out signed(3 downto 0);
mouse_flags : out std_logic_vector(7 downto 0); -- YOvfl, XOvfl, dy8, dx8, 1, mbtn, rbtn, lbtn
mouse_strobe : out std_logic
mouse_strobe : out std_logic;
mouse_idx : out std_logic
);
end component user_io;
@ -72,7 +78,9 @@ generic (
OSD_X_OFFSET : std_logic_vector(9 downto 0) := (others => '0');
OSD_Y_OFFSET : std_logic_vector(9 downto 0) := (others => '0');
SD_HCNT_WIDTH: integer := 9;
COLOR_DEPTH : integer := 6
COLOR_DEPTH : integer := 6;
OSD_AUTO_CE : boolean := true;
SYNC_AND : boolean := false
);
port (
clk_sys : in std_logic;

View File

@ -52,8 +52,8 @@ module user_io #(parameter STRLEN=0, parameter PS2DIV=100, parameter ROM_DIRECT_
// connection to sd card emulation
input [31:0] sd_lba,
input sd_rd,
input sd_wr,
input [1:0] sd_rd,
input [1:0] sd_wr,
output reg sd_ack,
output reg sd_ack_conf,
input sd_conf,
@ -64,7 +64,7 @@ module user_io #(parameter STRLEN=0, parameter PS2DIV=100, parameter ROM_DIRECT_
output reg sd_din_strobe,
output reg [8:0] sd_buff_addr,
output reg img_mounted, //rising edge if a new image is mounted
output reg [1:0] img_mounted, // rising edge if a new image is mounted
output reg [31:0] img_size, // size of image in bytes
// ps2 keyboard/mouse emulation
@ -82,8 +82,10 @@ module user_io #(parameter STRLEN=0, parameter PS2DIV=100, parameter ROM_DIRECT_
// mouse data
output reg [8:0] mouse_x,
output reg [8:0] mouse_y,
output reg [3:0] mouse_z,
output reg [7:0] mouse_flags, // YOvfl, XOvfl, dy8, dx8, 1, mbtn, rbtn, lbtn
output reg mouse_strobe, // mouse data is valid on mouse_strobe
output reg mouse_idx, // which mouse?
// serial com port
input [7:0] serial_data,
@ -109,8 +111,9 @@ assign conf_addr = byte_cnt;
// bit 4 indicates ROM direct upload capability
wire [7:0] core_type = ROM_DIRECT_UPLOAD ? 8'hb4 : 8'ha4;
wire drive_sel = sd_rd[1] | sd_wr[1];
// command byte read by the io controller
wire [7:0] sd_cmd = { 4'h5, sd_conf, sd_sdhc, sd_wr, sd_rd };
wire [7:0] sd_cmd = { 4'h6, sd_conf, sd_sdhc, sd_wr[drive_sel], sd_rd[drive_sel] };
wire spi_sck = SPI_CLK;
@ -328,6 +331,7 @@ end
always@(posedge spi_sck or posedge SPI_SS_IO) begin
reg [31:0] sd_lba_r;
reg [7:0] drive_sel_r;
if(SPI_SS_IO == 1) begin
spi_byte_out <= core_type;
@ -346,8 +350,10 @@ always@(posedge spi_sck or posedge SPI_SS_IO) begin
8'h16: if(byte_cnt == 0) begin
spi_byte_out <= sd_cmd;
sd_lba_r <= sd_lba;
end
else if(byte_cnt < 5) spi_byte_out <= sd_lba_r[(4-byte_cnt)<<3 +:8];
drive_sel_r <= {7'b0, drive_sel};
end
else if(byte_cnt == 1) spi_byte_out <= drive_sel_r;
else if(byte_cnt < 6) spi_byte_out <= sd_lba_r[(5-byte_cnt)<<3 +:8];
// reading sd card write data
8'h18: spi_byte_out <= sd_din;
@ -397,6 +403,7 @@ always @(posedge clk_sys) begin
reg [7:0] mouse_flags_r;
reg [7:0] mouse_x_r;
reg [7:0] mouse_y_r;
reg key_pressed_r;
reg key_extended_r;
@ -428,18 +435,24 @@ always @(posedge clk_sys) begin
8'h62: if (abyte_cnt < 5) joystick_2[(abyte_cnt-1)<<3 +:8] <= spi_byte_in;
8'h63: if (abyte_cnt < 5) joystick_3[(abyte_cnt-1)<<3 +:8] <= spi_byte_in;
8'h64: if (abyte_cnt < 5) joystick_4[(abyte_cnt-1)<<3 +:8] <= spi_byte_in;
8'h04: begin
8'h70,8'h71: begin
// store incoming ps2 mouse bytes
ps2_mouse_fifo[ps2_mouse_wptr] <= spi_byte_in;
ps2_mouse_wptr <= ps2_mouse_wptr + 1'd1;
if (~acmd[0]) begin
// PS2 serial protocol for the first mouse only
ps2_mouse_fifo[ps2_mouse_wptr] <= spi_byte_in;
ps2_mouse_wptr <= ps2_mouse_wptr + 1'd1;
end
if (abyte_cnt == 1) mouse_flags_r <= spi_byte_in;
else if (abyte_cnt == 2) mouse_x_r <= spi_byte_in;
else if (abyte_cnt == 3) begin
else if (abyte_cnt == 3) mouse_y_r <= spi_byte_in;
else if (abyte_cnt == 4) begin
// flags: YOvfl, XOvfl, dy8, dx8, 1, mbtn, rbtn, lbtn
mouse_flags <= mouse_flags_r;
mouse_x <= { mouse_flags_r[4], mouse_x_r };
mouse_y <= { mouse_flags_r[5], spi_byte_in };
mouse_y <= { mouse_flags_r[5], mouse_y_r };
mouse_z <= spi_byte_in[3:0];
mouse_strobe <= 1;
mouse_idx <= acmd[0];
end
end
8'h05: begin
@ -500,7 +513,7 @@ always @(posedge clk_sd) begin
reg spi_transfer_end;
reg spi_receiver_strobeD;
reg spi_transfer_endD;
reg sd_wrD;
reg [1:0] sd_wrD;
reg [7:0] acmd;
reg [7:0] abyte_cnt; // counts bytes
@ -518,7 +531,7 @@ always @(posedge clk_sd) begin
sd_din_strobe<= 0;
sd_wrD <= sd_wr;
// fetch the first byte immediately after the write command seen
if (~sd_wrD & sd_wr) begin
if ((~sd_wrD[0] & sd_wr[0]) || (~sd_wrD[1] & sd_wrD[1])) begin
sd_buff_addr <= 0;
sd_din_strobe <= 1;
end
@ -560,8 +573,10 @@ always @(posedge clk_sd) begin
// send sector FPGA -> IO
8'h18: begin
sd_din_strobe <= 1'b1;
if(~&sd_buff_addr) sd_buff_addr <= sd_buff_addr + 1'b1;
if(~&sd_buff_addr) begin
sd_din_strobe <= 1'b1;
sd_buff_addr <= sd_buff_addr + 1'b1;
end
end
// send SD config IO -> FPGA
@ -572,7 +587,7 @@ always @(posedge clk_sd) begin
sd_dout <= spi_byte_in;
end
8'h1c: img_mounted <= 1;
8'h1c: img_mounted[spi_byte_in[0]] <= 1;
// send image info
8'h1d: if(abyte_cnt<5) img_size[(abyte_cnt-1)<<3 +:8] <= spi_byte_in;