Fix memory mapped input addressing

This commit is contained in:
jimmystones
2021-10-19 22:17:48 +01:00
parent be2a9db19c
commit 2a92cff8f0
6 changed files with 1004 additions and 994 deletions

View File

@@ -349,7 +349,6 @@ arcade_video #(320,24) arcade_video
);
/////////////////// MAIN CORE ////////////////////
wire rom_download = ioctl_download && (ioctl_index < 8'd2);
wire reset = (RESET | status[0] | buttons[1] | rom_download);
assign LED_USER = rom_download;

File diff suppressed because it is too large Load Diff

View File

@@ -179,15 +179,15 @@ wire [7:0] chmap_data_out;
// Hardware inputs
wire [7:0] in0_data_out = {VGA_HS, VGA_VS,VGA_HB, VGA_VB, 4'b1000};
wire [7:0] joystick_data_out = joystick[cpu_addr[7:0] +: 8];
wire [7:0] analog_l_data_out = analog_l[cpu_addr[6:0] +: 8];
wire [7:0] analog_r_data_out = analog_r[cpu_addr[6:0] +: 8];
wire [7:0] paddle_data_out = paddle[cpu_addr[5:0] +: 8];
wire [7:0] spinner_data_out = spinner[cpu_addr[6:0] +: 8];
wire [7:0] ps2_key_data_out = ps2_key[cpu_addr[3:0] +: 8];
wire [7:0] ps2_mouse_data_out = ps2_mouse[cpu_addr[5:0] +: 8];
wire [7:0] timestamp_data_out = timestamp[cpu_addr[5:0] +: 8];
wire [7:0] timer_data_out = timer[cpu_addr[3:0] +: 8];
wire [7:0] joystick_data_out = joystick[{cpu_addr[4:0],3'd0} +: 8];
wire [7:0] analog_l_data_out = analog_l[{cpu_addr[3:0],3'd0} +: 8];
wire [7:0] analog_r_data_out = analog_r[{cpu_addr[3:0],3'd0} +: 8];
wire [7:0] paddle_data_out = paddle[{cpu_addr[2:0],3'd0} +: 8];
wire [7:0] spinner_data_out = spinner[{cpu_addr[3:0],3'd0} +: 8];
wire [7:0] ps2_key_data_out = ps2_key[{cpu_addr[0],3'd0} +: 8];
wire [7:0] ps2_mouse_data_out = ps2_mouse[{cpu_addr[2:0],3'd0} +: 8];
wire [7:0] timestamp_data_out = timestamp[{cpu_addr[2:0],3'd0} +: 8];
wire [7:0] timer_data_out = timer[{cpu_addr[0],3'd0} +: 8];
// CPU address decodes
wire pgrom_cs = cpu_addr[15:14] == 2'b00;

View File

@@ -373,10 +373,10 @@ void inputtester_digital()
// Draw control pad buttons
for (char joy = 0; joy < PAD_COUNT; joy++)
{
char index = joy * 32;
char index = joy * 4;
for (char button = 0; button < BUTTON_COUNT; button++)
{
char color = (button < 8 ? CHECK_BIT(joystick[index], button) : CHECK_BIT(joystick[index + 8], button - 8)) ? color_button_active : color_button_inactive;
char color = (button < 8 ? CHECK_BIT(joystick[index], button) : CHECK_BIT(joystick[index + 1], button - 8)) ? color_button_active : color_button_inactive;
write_string(button_symbol[button], color, pad_offset_x[joy] + button_x[button], pad_offset_y[joy] + button_y[button]);
}
}
@@ -439,8 +439,8 @@ void inputtester_analog()
// Reset previous color
set_fgcolour(color_analog_grid, analog_x[side] + mx, analog_y[side] + my);
signed char ax = analog_l[(analog_pad * 16)];
signed char ay = analog_l[(analog_pad * 16) + 8];
signed char ax = analog_l[(analog_pad * 2)];
signed char ay = analog_l[(analog_pad * 2) + 1];
analog_x[side] = ax / analog_ratio;
analog_y[side] = ay / analog_ratio;
@@ -459,8 +459,8 @@ void inputtester_analog()
// Reset previous color
set_fgcolour(color_analog_grid, analog_x[side] + mx, analog_y[side] + my);
ax = analog_r[(analog_pad * 16)];
ay = analog_r[(analog_pad * 16) + 8];
ax = analog_r[(analog_pad * 2)];
ay = analog_r[(analog_pad * 2) + 1];
analog_x[side] = ax / analog_ratio;
analog_y[side] = ay / analog_ratio;
@@ -502,11 +502,11 @@ void inputtester_advanced()
char m = 0b00000001;
char x = 6;
char y = 6 + inputindex;
char inputoffset = (inputindex * 32);
char inputoffset = (inputindex * 2);
char lastoffset = (inputindex * 2);
for (char b = 0; b < 2; b++)
{
char index = (b * 8) + inputoffset;
char index = b + inputoffset;
char lastindex = b + lastoffset;
char joy = joystick[index];
if (joy != joystick_last[lastindex])
@@ -529,8 +529,8 @@ void inputtester_advanced()
char stra[10];
// Draw analog left inputs (only update if value has changed)
signed char ax_l = analog_l[(inputindex * 16)];
signed char ay_l = analog_l[(inputindex * 16) + 8];
signed char ax_l = analog_l[(inputindex * 2)];
signed char ay_l = analog_l[(inputindex * 2) + 1];
if (ax_l != ax_l_last[inputindex] || ay_l != ay_l_last[inputindex])
{
sprintf(stra, "%4d%4d", ax_l, ay_l);
@@ -540,8 +540,8 @@ void inputtester_advanced()
ay_l_last[inputindex] = ay_l;
// Draw analog right inputs (only update if value has changed)
signed char ax_r = analog_r[(inputindex * 16)];
signed char ay_r = analog_r[(inputindex * 16) + 8];
signed char ax_r = analog_r[(inputindex * 2)];
signed char ay_r = analog_r[(inputindex * 2) + 1];
if (ax_r != ax_r_last[inputindex] || ay_r != ay_r_last[inputindex])
{
sprintf(stra, "%4d%4d", ax_r, ay_r);
@@ -551,7 +551,7 @@ void inputtester_advanced()
ay_r_last[inputindex] = ay_r;
// Draw paddle inputs (only update if value has changed)
unsigned char px = paddle[(inputindex * 8)];
unsigned char px = paddle[(inputindex)];
if (px != px_last[inputindex])
{
char strp[5];
@@ -561,8 +561,8 @@ void inputtester_advanced()
px_last[inputindex] = px;
// Draw spinner inputs (only update when update clock changes)
bool sx_toggle = CHECK_BIT(spinner[(inputindex * 16) + 8], 0);
signed char sx = spinner[(inputindex * 16)];
bool sx_toggle = CHECK_BIT(spinner[(inputindex * 8) + 1], 0);
signed char sx = spinner[(inputindex * 8)];
if (sx_toggle != sx_toggle_last[inputindex])
{
sx_pos[inputindex] += sx;
@@ -586,57 +586,72 @@ void inputtester_advanced()
// Scancode output
if (kbd_lastscan != kbd_lastscan_cache || kbd_lastascii != kbd_lastascii_cache)
{
write_stringf("%4x", 0xFF, 10, 21, kbd_lastscan);
write_stringf("%02x", 0xFF, 11, 21, kbd_lastscan);
write_char(kbd_lastascii, 0xFF, 15, 21);
kbd_lastscan_cache = kbd_lastscan;
kbd_lastascii_cache = kbd_lastascii;
}
if (mse_x_last != mse_x)
if (mse_changed)
{
mse_x_acc += mse_x;
write_stringf("%3d", 0xFF, 8, 23, mse_x_acc);
mse_x_last = mse_x;
}
if (mse_y_last != mse_y)
{
mse_y_acc += mse_y;
write_stringf("%3d", 0xFF, 12, 23, mse_y_acc);
mse_y_last = mse_y;
}
if (mse_w_last != mse_w)
{
mse_w_acc += mse_w;
write_stringf("%3d", 0xFF, 8, 23, mse_x_acc);
write_stringf("%3d", 0xFF, 12, 23, mse_y_acc);
write_stringf("%3d", 0xFF, 20, 23, mse_w_acc);
mse_w_last = mse_w;
}
if (mse_button1_last != mse_button1)
{
char x = 28;
char m = 0b00000001;
for (char i = 0; i < 3; i++)
{
x++;
write_char((mse_button1 & m) ? asc_1 : asc_0, 0xFF, x, 23);
m <<= 1;
}
mse_button1_last = mse_button1;
}
if (mse_button2_last != mse_button2)
{
char x = 31;
char m = 0b00000001;
for (char i = 0; i < 5; i++)
{
x++;
write_char((mse_button2 & m) ? asc_1 : asc_0, 0xFF, x, 23);
m <<= 1;
}
mse_button2_last = mse_button2;
if (mse_button1_last != mse_button1)
{
char x = 28;
char m = 0b00000001;
for (char i = 0; i < 3; i++)
{
x++;
write_char((mse_button1 & m) ? asc_1 : asc_0, 0xFF, x, 23);
m <<= 1;
}
mse_button1_last = mse_button1;
}
if (mse_button2_last != mse_button2)
{
char x = 31;
char m = 0b00000001;
for (char i = 0; i < 5; i++)
{
x++;
write_char((mse_button2 & m) ? asc_1 : asc_0, 0xFF, x, 23);
m <<= 1;
}
mse_button2_last = mse_button2;
}
mse_changed = 0;
}
// {
// char m = 0b00000001;
// char x = 2;
// char y = 27;
// for (char b = 0; b < 8; b++)
// {
// char joy = ps2_mouse[b];
// m = 0b00000001;
// for (char i = 0; i < 8; i++)
// {
// x++;
// write_char((joy & m) ? asc_1 : asc_0, 0xFF, x, y);
// m <<= 1;
// }
// x++;
// if (b == 3)
// {
// x = 2;
// y++;
// }
// }
// }
}
}

View File

@@ -193,15 +193,16 @@ char kbd_pressed;
char kbd_extend;
char kbd_lastscan = 0;
char kbd_lastascii = 0;
char kbd_clock_index = 10;
char kbd_clock_index = 1;
char mse_lastclock = 0;
bool mse_changed = 0;
signed char mse_x;
signed char mse_y;
signed char mse_w;
char mse_button1;
char mse_button2;
char mse_clock_index = 24;
char mse_clock_index = 3;
char kbd_buffer[128];
char kbd_buffer_len = 0;
@@ -223,12 +224,12 @@ void get_ascii()
void handle_ps2()
{
bool kbd_clock = CHECK_BIT(ps2_key[kbd_clock_index], 0);
bool kbd_clock = CHECK_BIT(ps2_key[kbd_clock_index], 2);
if (kbd_clock != kbd_lastclock)
{
for (char k = 0; k < 2; k++)
{
kbd_in[k] = ps2_key[k * 8];
kbd_in[k] = ps2_key[k];
}
kbd_extend = CHECK_BIT(kbd_in[1], 0);
kbd_pressed = CHECK_BIT(kbd_in[1], 1);
@@ -271,11 +272,12 @@ void handle_ps2()
bool mse_clock = CHECK_BIT(ps2_mouse[mse_clock_index], 0);
if (mse_clock != mse_lastclock)
{
mse_changed = 1;
mse_button1 = ps2_mouse[0];
mse_button2 = ps2_mouse[40];
mse_x = ps2_mouse[8];
mse_y = ps2_mouse[16];
mse_w = ps2_mouse[32];
mse_button2 = ps2_mouse[5];
mse_x = ps2_mouse[1];
mse_y = ps2_mouse[2];
mse_w = ps2_mouse[4];
}
mse_lastclock = mse_clock;
}

View File

@@ -83,8 +83,8 @@ void basic_input()
input_down = CHECK_BIT(joystick[0], 2);
input_left = CHECK_BIT(joystick[0], 1);
input_right = CHECK_BIT(joystick[0], 0);
input_start = CHECK_BIT(joystick[8], 3);
input_select = CHECK_BIT(joystick[8], 2);
input_start = CHECK_BIT(joystick[1], 3);
input_select = CHECK_BIT(joystick[1], 2);
input_a = CHECK_BIT(joystick[0], 4);
input_b = CHECK_BIT(joystick[0], 5);
}