Skip to content

Commit fbcd798

Browse files
committed
Add screen zoom feature for accessibility
Implements a screen zoom setting accessible from the Analogue Pocket interact menu, addressing the request for larger display output to improve readability. The zoom works by remapping framebuffer read addresses to display a cropped/enlarged portion of the 512x512 framebuffer: - Off: Normal 1:1 display (default) - Small: ~1.14x zoom (reads 448px from center, offset 32) - Large: ~1.33x zoom (reads 384px from center, offset 64) The setting persists across sessions via the APF interact system. Closes #1 https://claude.ai/code/session_01NYKHEx1oSSxcWrEi23wb4L
1 parent 34bd205 commit fbcd798

File tree

4 files changed

+68
-7
lines changed

4 files changed

+68
-7
lines changed
Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
{
22
"interact": {
33
"magic": "APF_VER_1",
4-
"variables": [],
4+
"variables": [
5+
{
6+
"id": 0,
7+
"name": "Screen Zoom",
8+
"type": "list",
9+
"enabled": true,
10+
"persist": true,
11+
"address": "0x50000000",
12+
"defaultval": "0x00",
13+
"mask": "0x03",
14+
"options": [
15+
{"value": "0x00", "name": "Off"},
16+
{"value": "0x01", "name": "Small"},
17+
{"value": "0x02", "name": "Large"}
18+
]
19+
}
20+
],
521
"messages": []
622
}
7-
}
23+
}

src/fpga/core/core_top.sv

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,18 @@ assign vpll_feed = 1'bZ;
309309
// for bridge write data, we just broadcast it to all bus devices
310310
// for bridge read data, we have to mux it
311311
// add your own devices here
312+
313+
// Interact variables
314+
reg [31:0] interact_zoom = 32'h0;
315+
316+
always @(posedge clk_74a) begin
317+
if (bridge_wr) begin
318+
casex (bridge_addr)
319+
32'h50000000: interact_zoom <= bridge_wr_data;
320+
endcase
321+
end
322+
end
323+
312324
always @(*) begin
313325
casex(bridge_addr)
314326
default: begin
@@ -319,6 +331,9 @@ always @(*) begin
319331
// bridge_rd_data <= example_device_data;
320332
bridge_rd_data <= 0;
321333
end
334+
32'h50000000: begin
335+
bridge_rd_data <= interact_zoom;
336+
end
322337
32'hF8xxxxxx: begin
323338
bridge_rd_data <= cmd_bridge_rd_data;
324339
end
@@ -766,7 +781,8 @@ LLANDER_TOP LLANDER_TOP
766781
.VID_HBLANK(hblank),
767782
.VID_VBLANK(vblank_lunarlander),
768783
.DIP(m_dip),
769-
.RESET_L (reset_n),
784+
.ZOOM(interact_zoom[1:0]),
785+
.RESET_L (reset_n),
770786
.clk_6(clk_6),
771787
.clk_25(clk_25)
772788
);

src/fpga/core/rtl/asteroids_dw.vhd

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ entity ASTEROIDS_DW is
6767
BEAM_ON : in std_logic;
6868
BEAM_ENA : in std_logic;
6969

70+
ZOOM : in std_logic_vector(1 downto 0);
71+
7072
VIDEO_R_OUT : out std_logic_vector(3 downto 0);
7173
VIDEO_G_OUT : out std_logic_vector(3 downto 0);
7274
VIDEO_B_OUT : out std_logic_vector(3 downto 0);
@@ -125,9 +127,8 @@ architecture RTL of ASTEROIDS_DW is
125127
signal pxcount : std_logic_vector(8 downto 0);
126128
signal vram_wren : std_logic;
127129

128-
129-
130-
130+
signal X_Read : std_logic_vector(8 downto 0);
131+
signal Y_Read : std_logic_vector(8 downto 0);
131132

132133
begin
133134

@@ -317,7 +318,31 @@ begin
317318

318319
end process;
319320

320-
up_addr <= (Y_Vid(8 downto 0) & X_Vid(8 downto 0));
321+
-- Zoom: remap read addresses to display a cropped/enlarged portion of the framebuffer.
322+
-- Small zoom (~1.14x): pixel * 7/8 + 32 => reads 448 pixels from 32..480
323+
-- Large zoom (~1.33x): pixel * 3/4 + 64 => reads 384 pixels from 64..448
324+
zoom_addr : process(X_Vid, Y_Vid, ZOOM)
325+
variable x_shift : std_logic_vector(8 downto 0);
326+
variable y_shift : std_logic_vector(8 downto 0);
327+
begin
328+
case ZOOM is
329+
when "01" =>
330+
x_shift := "000" & X_Vid(8 downto 3);
331+
y_shift := "000" & Y_Vid(8 downto 3);
332+
X_Read <= (X_Vid - x_shift) + 32;
333+
Y_Read <= (Y_Vid - y_shift) + 32;
334+
when "10" | "11" =>
335+
x_shift := "00" & X_Vid(8 downto 2);
336+
y_shift := "00" & Y_Vid(8 downto 2);
337+
X_Read <= (X_Vid - x_shift) + 64;
338+
Y_Read <= (Y_Vid - y_shift) + 64;
339+
when others =>
340+
X_Read <= X_Vid;
341+
Y_Read <= Y_Vid;
342+
end case;
343+
end process;
344+
345+
up_addr <= (Y_Read & X_Read);
321346

322347
clear_ram : process(clk_25, RESET)
323348
variable state : integer range 0 to 4;

src/fpga/core/rtl/llander_top.vhd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ entity LLANDER_TOP is
9999

100100
DIP : in std_logic_vector(7 downto 0);
101101

102+
ZOOM : in std_logic_vector(1 downto 0);
103+
102104
RESET_L : in std_logic;
103105

104106
-- ref clock in
@@ -198,6 +200,8 @@ begin
198200
BEAM_ON => beam_on,
199201
BEAM_ENA => beam_ena,
200202

203+
ZOOM => ZOOM,
204+
201205
VIDEO_R_OUT => VIDEO_R_OUT,
202206
VIDEO_G_OUT => VIDEO_G_OUT,
203207
VIDEO_B_OUT => VIDEO_B_OUT,

0 commit comments

Comments
 (0)