Beta Release...1
Cocosdc is slot 2. Working at 7.16Mhz [rd & wr] EOU can access floppy in slot 4... Menu updated. Mouse sub for right joy including button.
This commit is contained in:
1 parent
7c685576c4
commit
7f9de829a7
4 files changed
+193
-12
No files matched your search
@@ -236,6 +236,7 @@ localparam CONF_STR = {
|
||||
"-;",
|
||||
"ON,D-Pad Joystick emu,No,Yes;",
|
||||
"O6,Swap Joysticks,Off,On;",
|
||||
"OS,Swap Joystick / Mouse,Off,On;",
|
||||
"RA,Easter Egg;",
|
||||
"-;",
|
||||
"OO,Force Turbo,No,Yes;",
|
||||
@@ -347,7 +348,8 @@ hps_io #(.CONF_STR(CONF_STR),.PS2DIV(2400), .VDNUM(6), .BLKSZ(2)) hps_io
|
||||
|
||||
|
||||
.ps2_kbd_clk_out ( ps2_kbd_clk ),
|
||||
.ps2_kbd_data_out ( ps2_kbd_data )
|
||||
.ps2_kbd_data_out ( ps2_kbd_data ),
|
||||
.ps2_mouse(ps2_mouse)
|
||||
);
|
||||
|
||||
// SD block level interface
|
||||
@@ -386,6 +388,7 @@ wire [15:0] coco_ajoy2 = status[6] ? {center_joystick_x1[7:0],center_joystick_y1
|
||||
wire ps2_kbd_clk;
|
||||
wire ps2_kbd_data;
|
||||
|
||||
wire [24:0] ps2_mouse;
|
||||
|
||||
wire hblank, vblank;
|
||||
wire hs, vs;
|
||||
@@ -481,6 +484,8 @@ coco3fpga coco3 (
|
||||
.ps2_clk(ps2_kbd_clk),
|
||||
.ps2_data(ps2_kbd_data),
|
||||
|
||||
.ps2_mouse(ps2_mouse),
|
||||
|
||||
.joy_use_dpad(digitalJoy),
|
||||
|
||||
.joy1(coco_joy1),
|
||||
@@ -489,6 +494,8 @@ coco3fpga coco3 (
|
||||
.joya1(coco_ajoy1),
|
||||
.joya2(coco_ajoy2),
|
||||
|
||||
.SWAP_M_J(SWAP_M_J),
|
||||
|
||||
// R1, L2, R2, L1
|
||||
.P_SWITCH(~{coco_joy2[4],coco_joy1[5],coco_joy2[5],coco_joy1[4]}),
|
||||
.SWITCH(switch),
|
||||
@@ -582,6 +589,7 @@ wire coldboot = status[22];
|
||||
|
||||
wire F_Turbo = status[24];
|
||||
wire [2:0] Mem_Size = status[27:25];
|
||||
wire SWAP_M_J = status[28];
|
||||
|
||||
wire digitalJoy = status[23];
|
||||
reg [2:0] mpi_d = 2'b00;
|
||||
|
||||
@@ -21,6 +21,7 @@ set_global_assignment -name VERILOG_FILE rtl/square_gen.v
|
||||
set_global_assignment -name SYSTEMVERILOG_FILE rtl/fdc.sv
|
||||
set_global_assignment -name SYSTEMVERILOG_FILE rtl/sdc.sv
|
||||
set_global_assignment -name SYSTEMVERILOG_FILE rtl/sdc_top.sv
|
||||
set_global_assignment -name SYSTEMVERILOG_FILE rtl/ps2_mouse.v
|
||||
set_global_assignment -name SYSTEMVERILOG_FILE rtl/sdram/sdram2.sv
|
||||
set_global_assignment -name SYSTEMVERILOG_FILE rtl/wd1793.sv
|
||||
set_global_assignment -name SYSTEMVERILOG_FILE CoCo3.sv
|
||||
|
||||
+91
-11
@@ -103,6 +103,10 @@ output VBLANK,
|
||||
input ps2_clk,
|
||||
input ps2_data,
|
||||
|
||||
//Mouse
|
||||
|
||||
input [24:0] ps2_mouse,
|
||||
|
||||
// RS-232
|
||||
output UART_TXD,
|
||||
input UART_RXD,
|
||||
@@ -128,6 +132,7 @@ input [15:0] joy2,
|
||||
input [15:0] joya1,
|
||||
input [15:0] joya2,
|
||||
input joy_use_dpad,
|
||||
input SWAP_M_J,
|
||||
|
||||
// Config Static switches
|
||||
input [9:0] SWITCH,
|
||||
@@ -754,14 +759,6 @@ assign CART_SEL = (ADDRESS[15:9] == 7'b1
|
||||
//11 32 External
|
||||
|
||||
|
||||
//assign FLASH_ADDRESS = ENA_DSK ? {9'b000000100, ADDRESS[12:0]}: //8K Disk BASIC 8K Slot 4
|
||||
// ENA_DISK2 ? {7'b1111111, ADDRESS[14:0]}: //ROM Anternative Disk Controller
|
||||
// ENA_ORCC ? {9'b000000101, ADDRESS[12:0]}: //8K Orchestra 8K 90CC Slot 1
|
||||
// ({ENA_PAK, ROM[1]} == 2'b10) ? {5'b00000,ROM_BANK, ADDRESS[13:0]}: //16K External R CART ROM
|
||||
// ({ENA_PAK, ROM} == 3'b111) ? {4'b0000,ROM_BANK, ~ADDRESS[14], ADDRESS[13:0]}: //32K External R CART ROM
|
||||
// ROM_SEL
|
||||
// {7'b0000000,ADDRESS[14:0]};
|
||||
|
||||
assign FLASH_ADDRESS = ENA_DSK ? {9'b000000100, ADDRESS[12:0]}: //8K Disk BASIC 8K Slot 4
|
||||
ENA_DISK2 ? {9'b000000100, ADDRESS[12:0]}: //[maps to same disk rom]
|
||||
ENA_ORCC ? {9'b000000101, ADDRESS[12:0]}: //8K Orchestra 8K 90CC Slot 1
|
||||
@@ -968,7 +965,8 @@ assign DATA_IN =
|
||||
// (ADDRESS == 16'hFF88) ? BUFF_DATA[7:0]:
|
||||
|
||||
(ADDRESS == 16'hFF8E) ? GPIO_DIR:
|
||||
(ADDRESS == 16'hFF8F) ? {GPIO[7:0]}:
|
||||
// (ADDRESS == 16'hFF8F) ? {GPIO[7:0]}:
|
||||
(ADDRESS == 16'hFF8F) ? {3'b000, ps2_button, ps2_x1, ps2_y1, ps2_x2, ps2_y2}:
|
||||
|
||||
(ADDRESS == 16'hFF90) ? {COCO1, MMU_EN, GIME_IRQ, GIME_FIRQ, VEC_PAG_RAM, ST_SCS, ROM}:
|
||||
(ADDRESS == 16'hFF91) ? {2'b00, TIMER_INS, 4'b0000, MMU_TR}:
|
||||
@@ -3416,8 +3414,11 @@ begin
|
||||
end
|
||||
else
|
||||
begin
|
||||
dac_joya1 <= joya1;
|
||||
if (SWAP_M_J)
|
||||
dac_joya2 <= mouse_xy_pos;
|
||||
else
|
||||
dac_joya2 <= joya2;
|
||||
dac_joya1 <= joya1;
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3465,7 +3466,7 @@ assign KEYBOARD_IN[0] = !((!KEY_COLUMN[0] & KEY[0]) // @
|
||||
| (!KEY_COLUMN[5] & KEY[5]) // E
|
||||
| (!KEY_COLUMN[6] & KEY[6]) // F
|
||||
| (!KEY_COLUMN[7] & KEY[7]) // G
|
||||
| !P_SWITCH[3]); // Right Joystick Switch 1
|
||||
| !(P_SWITCH[3] & (ps2_button | !SWAP_M_J))); // Right Joystick Switch 1
|
||||
|
||||
assign KEYBOARD_IN[1] = !((!KEY_COLUMN[0] & KEY[8]) // H
|
||||
| (!KEY_COLUMN[1] & KEY[9]) // I
|
||||
@@ -3542,6 +3543,85 @@ COCOKEY coco_keyboard(
|
||||
.RESET(RESET),
|
||||
.RESET_INS(RESET_INS)
|
||||
);
|
||||
|
||||
// PS2 Mouse [MiSTer]
|
||||
// Borrowed from MAC PLUS
|
||||
|
||||
wire ps2_x1, ps2_y1, ps2_x2, ps2_y2;
|
||||
wire ps2_button;
|
||||
|
||||
ps2_mouse coco_ps2_mouse(
|
||||
.clk(clk_sys),
|
||||
.ce(PH_2),
|
||||
.reset(~RESET_N),
|
||||
|
||||
.ps2_mouse(ps2_mouse),
|
||||
|
||||
.x1(ps2_x1),
|
||||
.y1(ps2_y1),
|
||||
.x2(ps2_x2),
|
||||
.y2(ps2_y2),
|
||||
.button(ps2_button)
|
||||
);
|
||||
|
||||
// This code creates a virtual joystick based on mouse movements.
|
||||
// The result is mouse_xy_pos
|
||||
// [note check of boundry before inc / dev]
|
||||
|
||||
reg [7:0] mouse_x_pos, mouse_y_pos;
|
||||
wire [15:0] mouse_xy_pos = {mouse_x_pos, mouse_y_pos};
|
||||
reg [1:0] old_x, old_y;
|
||||
wire [1:0] x_mouse = {ps2_x1, ps2_x2};
|
||||
wire [1:0] y_mouse = {ps2_y1, ps2_y2};
|
||||
|
||||
always @ (posedge clk_sys or negedge RESET_N)
|
||||
begin
|
||||
if(!RESET_N)
|
||||
begin
|
||||
mouse_x_pos <= 8'h80;
|
||||
mouse_y_pos <= 8'h80;
|
||||
old_x <= 2'b00;
|
||||
old_y <= 2'b00;
|
||||
end
|
||||
else
|
||||
begin
|
||||
if (PH_2)
|
||||
begin
|
||||
old_x <= x_mouse;
|
||||
old_y <= y_mouse;
|
||||
if ( !(old_x == x_mouse)) //if a x change
|
||||
begin
|
||||
if (^x_mouse) // xor of x bits show + move ; else neg
|
||||
begin
|
||||
if (!(mouse_x_pos == 8'hff))
|
||||
mouse_x_pos <= mouse_x_pos + 1'b1;
|
||||
end
|
||||
else
|
||||
begin
|
||||
if (!(mouse_x_pos == 8'h00))
|
||||
mouse_x_pos <= mouse_x_pos - 1'b1;
|
||||
end
|
||||
end
|
||||
|
||||
if ( !(old_y == y_mouse)) //if a y change
|
||||
begin
|
||||
if (^y_mouse) // xor of x bits show + move ; else neg
|
||||
begin
|
||||
if (!(mouse_y_pos == 8'h00))
|
||||
mouse_y_pos <= mouse_y_pos - 1'b1;
|
||||
end
|
||||
else
|
||||
begin
|
||||
if (!(mouse_y_pos == 8'hff))
|
||||
mouse_y_pos <= mouse_y_pos + 1'b1;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Video
|
||||
******************************************************************************/
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* PS2 mouse protocol
|
||||
* Bit 7 6 5 4 3 2 1 0
|
||||
* Byte 0: YOVR XOVR YSGN XSGN 1 MBUT RBUT LBUT
|
||||
* Byte 1: XMOVE
|
||||
* Byte 2: YMOVE
|
||||
*/
|
||||
|
||||
/*
|
||||
* PS2 Mouse to Mac interface module
|
||||
*/
|
||||
module ps2_mouse
|
||||
(
|
||||
input clk,
|
||||
input ce,
|
||||
|
||||
input reset,
|
||||
|
||||
input [24:0] ps2_mouse,
|
||||
|
||||
output reg x1,
|
||||
output reg y1,
|
||||
output reg x2,
|
||||
output reg y2,
|
||||
output reg button
|
||||
);
|
||||
|
||||
reg [9:0] xacc;
|
||||
reg [9:0] yacc;
|
||||
reg [11:0] clkdiv;
|
||||
|
||||
wire strobe = (old_stb != ps2_mouse[24]);
|
||||
reg old_stb = 0;
|
||||
always @(posedge clk) old_stb <= ps2_mouse[24];
|
||||
|
||||
/* Capture button state */
|
||||
always@(posedge clk or posedge reset)
|
||||
if (reset) button <= 1;
|
||||
else if (strobe) button <= ~(|ps2_mouse[2:0]);
|
||||
|
||||
/* Clock divider to flush accumulators */
|
||||
always@(posedge clk or posedge reset)
|
||||
if (reset) clkdiv <= 0;
|
||||
else if(ce) clkdiv <= clkdiv + 1'b1;
|
||||
|
||||
wire tick = (ce && clkdiv == 0);
|
||||
|
||||
/* Toggle output lines base on accumulator */
|
||||
always@(posedge clk or posedge reset) begin
|
||||
if (reset) begin
|
||||
x1 <= 0;
|
||||
x2 <= 0;
|
||||
end else if (tick && xacc != 0) begin
|
||||
x1 <= ~x1;
|
||||
x2 <= ~x1 ^ ~xacc[9];
|
||||
end
|
||||
end
|
||||
|
||||
always@(posedge clk or posedge reset) begin
|
||||
if (reset) begin
|
||||
y1 <= 0;
|
||||
y2 <= 0;
|
||||
end else if (tick && yacc != 0) begin
|
||||
y1 <= ~y1;
|
||||
y2 <= ~y1 ^ ~yacc[9];
|
||||
end
|
||||
end
|
||||
|
||||
/* Movement accumulators. Needs tuning ! */
|
||||
always@(posedge clk or posedge reset) begin
|
||||
if (reset) xacc <= 0;
|
||||
else begin
|
||||
/* Add movement, convert to a 10-bit number if not over */
|
||||
if (strobe && xacc[8] == xacc[9]) xacc <= xacc + { ps2_mouse[4], ps2_mouse[4], ps2_mouse[15:8] };
|
||||
else
|
||||
/* Decrement */
|
||||
if (tick && xacc != 0) xacc <= xacc + { {9{~xacc[9]}}, 1'b1 };
|
||||
end
|
||||
end
|
||||
|
||||
always@(posedge clk or posedge reset) begin
|
||||
if (reset) yacc <= 0;
|
||||
else begin
|
||||
/* Add movement, convert to a 10-bit number if not over*/
|
||||
if (strobe && yacc[8] == yacc[9]) yacc <= yacc + { ps2_mouse[5], ps2_mouse[5], ps2_mouse[23:16] };
|
||||
else
|
||||
/* Decrement */
|
||||
if (tick && yacc != 0) yacc <= yacc + { {9{~yacc[9]}}, 1'b1 };
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
Reference in new issue
Block a user