Skip to content

Commit

Permalink
Fix NES controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitalita committed May 23, 2024
1 parent e4e9c5c commit 5a2c8fa
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/controller_snes.v
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,14 @@ always @(posedge clk) begin
bits <= bits + 1;
if (bits == 4'd15) begin // scan complete
state <= 3;
buttons <= buttons_buf[11:0];
// check if buttons_buf[15:12] are 0; if not, this is an NES controller
if (buttons_buf[15:12] != 4'b0000) begin
// NES controller
buttons <= {0, 0, 0, 0, buttons_buf[7:0]};
end else begin
// SNES controller
buttons <= buttons_buf[11:0];
end
end else
state <= 1;
end
Expand Down

0 comments on commit 5a2c8fa

Please sign in to comment.