Skip to content

Commit

Permalink
add new release (#27)
Browse files Browse the repository at this point in the history
* remove compiler warnings

* remove compiler warnings

* - add a 'spare' debug field of 12 bits to report signals under current debugging. The released version is as follow
  bit 11 : a sector-not-found error has occured
  bit 10 : a track error has occured
  bit 9  : the controller went double-density (which is not implemented whatsoever)
  bit 8  : track in fd1771 is not equal to track in floppy (seek not done)
  bits 7-0 : counter of 'data_lost' authorized slippage (maximum data_lost recovered we had to wait in a sector read))

- modified the way the motor timing is generated to avoid truncature of results like 20/12 = 1, leading to unwanted timeouts
  removing multiply and divide operation is a free bonus

- other minor corrections

* This release tend to make LDOS work. NEWDOS and TRSDOS work fine, but LDOS seems more fragile or more demanding.
Anyway, with this release, it boots, and the MISOSYS C compiler get though compiing UNARC/CCC, sort of.

- generate a sector_not_found error if
  - track in controller differ from track in device
  - track out of bounds (of disk image)
- fix controller track stepping bounds so tracks don't get negative.
- generate a seek error if the track in the drive is different of the desired track in the controller at the end of the seek op.
- add grace steps if data_lost occurs. This is not in the specs of course, but LDOS makes a lot of these errors, so befor we find why, this fixes it.
- change HLD head status so that it stays loaded between tracks
- lower sector_not_found delay because if the floppy motor goes off before operation is finished, everything gets locked up.
- add some debug for error tracking
- fix SECTOR_BASE to 0
- Remove all code for sector len = 128 or 1024, just kept 256 aand 512 if double density is implemented one day
- In the same spirit, keep controller_type at 0, and keep only one way to compute sd_lba JV1 compatble
- remove some useless code
- removed "cmd_rx_i" delay because I can't figure out what it does.

* - I fixed a boo-boo in my last data-lost tolerent algo.
- Fixed the 'BOOT' command in a DO JCL job

This should be now a stable release, at least a Release Candidate.
LDOS boots and a complete C compiling job works flawlessly
(Misosys C compiler, command DO MC (N=UNARC)   )

* disk I/O fixes. LDOS stabilized.

* Fixes in the "PC" section of the keyboard driver.
This should fix issue #14
  • Loading branch information
theflynn49 authored Nov 11, 2024
1 parent a9877f4 commit bda8ee9
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 42 deletions.
Binary file added releases/TRS-80_20241007.rbf
Binary file not shown.
113 changes: 75 additions & 38 deletions rtl/keyboard.sv
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,18 @@ module keyboard
input [7:0] addr, // bottom 7 address lines from CPU for memory-mapped access
output [7:0] key_data, // data lines returned from scanning

input kblayout, // 0 = TRS-80 keyboard arrangement; 1 = PS/2 key assignment
input kblayout // 0 = TRS-80 keyboard arrangement; 1 = PS/2 key assignment

output reg [11:1] Fn = 0,
output reg [2:0] modif = 0
// output reg [11:1] Fn = 0,
// output reg [2:0] modif = 0
);

reg [7:0] keys[7:0];
reg press_btn = 0;
reg [15:0] vkeys_ps2; // virtual key states from ps2, only for some keys, used to retain that the conditions for a key translation
// were met during the down scan code, and then it should be reset during the up scan code of the same key
// it is also used to retain the fact that the simulated shift key should be kept to avoid generating wrong keys
reg state_column = 0 ;
reg press_btn = 0;
reg [7:0] code;
reg shiftstate = 0;

Expand Down Expand Up @@ -89,9 +93,14 @@ always @(posedge clk_sys) begin
keys[5] <= 8'b00000000;
keys[6] <= 8'b00000000;
keys[7] <= 8'b00000000;
vkeys_ps2 <= 16'd0;
state_column <= 0 ;
end


if(input_strobe) begin

/* not used yet
case(code)
8'h59: modif[0]<= press_btn; // right shift
8'h11: modif[1]<= press_btn; // alt
Expand All @@ -108,6 +117,7 @@ always @(posedge clk_sys) begin
8'h09: Fn[10]<= press_btn; // F10
8'h78: Fn[11]<= press_btn; // F11
endcase
*/

case(code)

Expand Down Expand Up @@ -168,56 +178,69 @@ always @(posedge clk_sys) begin
8'h74 : keys[6][6] <= press_btn; // RT ARROW
8'h29 : keys[6][7] <= press_btn; // SPACE


// Left and right shift keys are combined
8'h12 : begin
keys[7][0] <= press_btn; // Left shift
shiftstate <= press_btn;
keys[7][0] <= |(vkeys_ps2 & 16'b1111111111111110) || press_btn; // Left shift
vkeys_ps2[0] <= press_btn;
shiftstate <= vkeys_ps2[1] || press_btn;
end

8'h59 : begin
keys[7][0] <= press_btn; // Right shift
shiftstate <= press_btn;
keys[7][0] <= |(vkeys_ps2 & 16'b1111111111111101) || press_btn; // Right shift
vkeys_ps2[1] <= press_btn;
shiftstate <= vkeys_ps2[0] || press_btn;
end

// 8'h14 : keys[7][1] <= press_btn; // CTRL (Symbol Shift)
// 8'h14 : keys[7][2] <= press_btn; // CTRL (Symbol Shift)
// The very impractical Model I CTRL key is shift-DN ARROW, it can be happily replaced by the PS2 Ctrl key in both Keyb modes
// We should do the same combining logic than the shift keys, but if the latter may pretty well be used for games, CTRL is not.
8'h14 : begin
vkeys_ps2[2] <= press_btn;
keys[6][4] <= press_btn; // CTRL = shift-DN ARROW
keys[7][0] <= press_btn || |(vkeys_ps2 & 16'b1111111111111011); // reset only if no other one wants shift forced
end


// Numpad new keys:

8'h7b : keys[5][5] <= press_btn; // keypad -
8'h6c : keys[6][1] <= press_btn; // KYPD-7 (PC) -> CLEAR (TRS)

8'h7c : begin
vkeys_ps2[3] <= press_btn;
keys[5][2] <= press_btn; // * (shifted)
keys[7][0] <= press_btn;
keys[7][0] <= press_btn || |(vkeys_ps2 & 16'b1111111111110111);
end

8'h79 : begin
vkeys_ps2[4] <= press_btn;
keys[5][3] <= press_btn; // + (shifted)
keys[7][0] <= press_btn;
keys[7][0] <= press_btn || |(vkeys_ps2 & 16'b1111111111101111);
end


//////////////////////////////
// For the next group of keys, results depend on the keyboard mode (TRS or PC)
//////////////////////////////


8'h54 : // [ (PC backslash)
if (kblayout == 0) begin
keys[0][0] <= press_btn; // -> @ TRS (TRS layout)
end // -> no mapping (PC layout)

8'h45 : // 0
if ((kblayout == 1) && (shiftstate == 1)) begin
8'h45 : // 0
if (vkeys_ps2[5] || ((kblayout == 1) && (shiftstate == 1) && (press_btn == 1) )) begin
vkeys_ps2[5] <= press_btn;
keys[5][1] <= press_btn; // PC ')' -> 9 + shift (TRS)
keys[7][0] <= press_btn;
keys[7][0] <= press_btn || |(vkeys_ps2 & 16'b1111111111011111); // reset only if no other one wants shift forced
end
else begin
keys[4][0] <= press_btn; // 0
end

8'h1e : // 2
if ((kblayout == 1) && (shiftstate == 1)) begin
if (vkeys_ps2[6] || ((kblayout == 1) && (shiftstate == 1) && (press_btn == 1) )) begin
vkeys_ps2[6] <= press_btn;
keys[0][0] <= press_btn; // PC '@" -> @ (TRS)
end
else begin
Expand All @@ -226,32 +249,36 @@ always @(posedge clk_sys) begin


8'h36 : // 6
if ((kblayout == 0) || (shiftstate == 0)) begin
if (vkeys_ps2[7] || ((kblayout == 0) || (shiftstate == 0) && (press_btn == 1) )) begin
vkeys_ps2[7] <= press_btn;
keys[4][6] <= press_btn; // 6 (no mapping for '^' from PC)
end

8'h3d : // 7
if ((kblayout == 1) && (shiftstate == 1)) begin
if (vkeys_ps2[8] || ((kblayout == 1) && (shiftstate == 1) && (press_btn == 1) )) begin
vkeys_ps2[8] <= press_btn;
keys[4][6] <= press_btn; // PC '&' -> '6' + shift (TRS)
keys[7][0] <= press_btn;
keys[7][0] <= press_btn || |(vkeys_ps2 & 16'b1111111011111111);
end
else begin
keys[4][7] <= press_btn; // 7
end

8'h3e : // 8
if ((kblayout == 1) && (shiftstate == 1)) begin
if (vkeys_ps2[9] || ((kblayout == 1) && (shiftstate == 1) && (press_btn == 1) )) begin
vkeys_ps2[9] <= press_btn;
keys[5][2] <= press_btn; // PC '*' -> ':' + shift (TRS)
keys[7][0] <= press_btn;
keys[7][0] <= press_btn || |(vkeys_ps2 & 16'b1111110111111111);
end
else begin
keys[5][0] <= press_btn; // 8
end

8'h46 : // 9
if ((kblayout == 1) && (shiftstate == 1)) begin
if (vkeys_ps2[10] || ((kblayout == 1) && (shiftstate == 1) && (press_btn == 1) )) begin
vkeys_ps2[10] <= press_btn;
keys[5][0] <= press_btn; // PC '(' -> '8' + shift (TRS)
keys[7][0] <= press_btn;
keys[7][0] <= press_btn || |(vkeys_ps2 & 16'b1111101111111111);
end
else begin
keys[5][1] <= press_btn; // 9
Expand All @@ -262,44 +289,54 @@ always @(posedge clk_sys) begin
if (kblayout == 0) begin
keys[5][2] <= press_btn; // :* (TRS)
end
else if (shiftstate == 0) begin
else if ((shiftstate == 0) || (press_btn == 0) )begin
keys[5][5] <= press_btn; // - (minus)
end

8'h4c : // ;:
if ((kblayout == 1) && (shiftstate == 1)) begin
keys[5][2] <= press_btn; // ':' (not shifted) (TRS)
keys[7][0] <= ~press_btn;
// if there is another key mapping that requires shift locked-in, we cannot force shift low, so skip it
// we cannot use vkeys_ps2 here, since this would FORCE shift, and we want the opposite
if (state_column || ( ((kblayout == 1) && (shiftstate == 1)) && (press_btn == 1) )) begin
if ( (~|(vkeys_ps2 & 16'b1111111111111100)) || (press_btn == 0) ) begin
keys[5][2] <= press_btn; // ':' (not shifted) (TRS)
if (press_btn == 1)
keys[7][0] <= 1'b0 ; else // upon release, shiftstate==1, so should be set to 1
keys[7][0] <= |vkeys_ps2 ;
end
state_column <= press_btn;
end
else begin
keys[5][3] <= press_btn; // - (minus)
end

8'h55 : // = +
if (kblayout == 1) begin
if (shiftstate == 0) begin // if '=' on PC keyboard
keys[5][5] <= press_btn; // '-' + shift (TRS)
keys[7][0] <= press_btn;
end
else begin // if '+' on PC keyboard
if (vkeys_ps2[13] || (shiftstate == 1)) begin // if '=' on PC keyboard
keys[5][3] <= press_btn; // ';' + shift (TRS)
keys[7][0] <= press_btn;
vkeys_ps2[13] <= press_btn;
end
if (vkeys_ps2[12] || (shiftstate == 0)) begin // if '+' on PC keyboard
keys[5][5] <= press_btn; // '-' + shift (TRS)
vkeys_ps2[12] <= press_btn;
end
keys[7][0] <= press_btn || |(vkeys_ps2 & 16'b1100111111111111) ;
end
else begin
keys[5][5] <= press_btn; // =
end

8'h52 : // ' "
if (kblayout == 1) begin
if (shiftstate == 1) begin // if (double-quote) on PC keyboard
if (vkeys_ps2[14] || (shiftstate == 1)) begin // if (double-quote) on PC keyboard
vkeys_ps2[14] <= press_btn;
keys[4][2] <= press_btn; // '2' + shift (TRS)
keys[7][0] <= press_btn;
end
else begin // if (apostrophe) on PC keyboard
if (vkeys_ps2[15] || (shiftstate == 0)) begin // if (double-quote) on PC keyboard
// if (apostrophe) on PC keyboard
vkeys_ps2[15] <= press_btn;
keys[4][7] <= press_btn; // '7' + shift (TRS)
keys[7][0] <= press_btn;
end
keys[7][0] <= press_btn || |(vkeys_ps2 & 16'b0011111111111111) ;
end // otherwise no mapping (TRS)

default: ;
Expand Down
8 changes: 4 additions & 4 deletions rtl/trs80.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ port (
ps2_key : in std_logic_vector(10 downto 0);
addr : in std_logic_vector(7 downto 0);
key_data : out std_logic_vector(7 downto 0);
kblayout : in std_logic;

Fn : out std_logic_vector(11 downto 1);
modif : out std_logic_vector(2 downto 0)
kblayout : in std_logic
-- Fn : out std_logic_vector(11 downto 1);
-- modif : out std_logic_vector(2 downto 0)
);
end component;

Expand Down

0 comments on commit bda8ee9

Please sign in to comment.