The Iron Keep: a top-down escape game, held-key ports, monitor HEX loader

games/keep: an original game in C for the Z-80 using the sprites - twelve
rooms, guards that patrol, see along rows and columns and shoot, keys and
locked doors, gold, ammunition and a crown to steal. gen.py holds the art
and castle map and checks reachability; test-keep.py runs it in z80emu on
a model of the board's ports, takes screenshots and has a bot play it
through. keep.bas loads KEEPGAME at 8600h and CALLs it.

Ports 88h/89h read keys held down (ps2_keystate), the monitor writes
Intel HEX records typed at its prompt, and tools/send-hex.py sends a
whole file and saves it as a memory file. Testbench covers both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
brad ArantandClaude Opus 5.5 committed 2026-11-29 09:21:02 -08:00
1 parent 13373244e8
commit 743071cff3
19 files changed
+3544 -1306

No files matched your search

+29
View File
@@ -237,3 +237,32 @@ module ps2_keymap (
end
end
endmodule
// Which keys are held down, for games: one bit per set-2 scan code, 128 plain
// codes ({0, code}) and 128 after the E0 prefix ({1, code}). The Pause key's
// E1 sequence is skipped.
module ps2_keystate (
input clk,
input rst,
input [7:0] code,
input code_valid,
output reg [255:0] down
);
reg ext, brk, pause;
reg [2:0] skip;
always @(posedge clk)
if (rst) begin
down <= 256'd0;
ext <= 1'b0; brk <= 1'b0; skip <= 3'd0;
end else if (code_valid) begin
if (skip != 3'd0) skip <= skip - 1'b1; // rest of E1 14 77 E1 F0 14 F0 77
else if (code == 8'hE1) skip <= 3'd7;
else if (code == 8'hE0) ext <= 1'b1;
else if (code == 8'hF0) brk <= 1'b1;
else begin
if (!code[7]) down[{ext, code[6:0]}] <= !brk;
ext <= 1'b0;
brk <= 1'b0;
end
end
endmodule