1
0
mirror of https://github.com/UzixLS/zx-sizif-512.git synced 2025-07-19 07:11:36 +03:00

limit max cpu freq to 7MHz for NMOS CPU's

This commit is contained in:
Eugene Lozovoy
2024-10-02 20:00:03 +03:00
parent 2407b41764
commit 23445b482e
4 changed files with 49 additions and 21 deletions

View File

@ -129,6 +129,7 @@ initial sd_indication_en = 1'b1;
initial bright_boost = 1'b0;
`endif
reg autoturbo_en = 1'b0;
reg cmoscpu = 1'b0;
initial zxkit1 = 1'b0;
initial joy_a_up = 1'b0;
@ -158,11 +159,12 @@ always @(posedge clk28 or negedge rst_n) begin
8'h0F: zxkit1 <= bus.d[0];
8'h10: joy_a_up <= bus.d[0];
8'h11: fastforward <= bus.d[0];
8'h12: cmoscpu <= bus.d[0];
endcase
end
reg config_rd;
wire [7:0] config_data = {4'b0000, div_paged, fastforward_button, pause_button, magic_button};
wire [7:0] config_data = {3'b000, cmoscpu, div_paged, fastforward_button, pause_button, magic_button};
always @(posedge clk28 or negedge rst_n) begin
if (!rst_n)
config_rd <= 0;
@ -194,13 +196,13 @@ always @(posedge clk28 or negedge rst_n) begin
if (!rst_n)
turbo <= TURBO_NONE;
else if (fastforward)
turbo <= TURBO_14;
turbo <= cmoscpu? TURBO_14 : TURBO_7;
else if (autoturbo_en && div_paged && !magic_map)
turbo <= TURBO_14;
turbo <= cmoscpu? TURBO_14 : TURBO_7;
else if (autoturbo_en && |portfe_noturbo)
turbo <= TURBO_NONE;
else if (autoturbo_en && basic48_ramclear_turbo)
turbo <= TURBO_14;
turbo <= cmoscpu? TURBO_14 : TURBO_7;
else
turbo <= turbo0;
end

View File

@ -47,6 +47,7 @@ autoturbo DB 0
zxkit1 DB 0
joy_a_up DB 0
fastforward DB 0
cmoscpu DB 0
ENDS
STRUCT CFGEXT_T

View File

@ -1,5 +1,6 @@
ASSERT __SJASMPLUS__ >= 0x011402 ; SjASMPlus 1.20.2
OPT --syntax=abf
OPT -Wno-out0
DEVICE ZXSPECTRUM48
; Startup handler
@ -50,6 +51,7 @@ startup_handler:
djnz .loop ; ...
call init_default_config
call load_user_config
call detect_cpu
call detect_sd_card
call detect_ext_board
call detect_external_ay
@ -309,7 +311,28 @@ init_cpld:
inc b ; ...
dec d ; ...
jr nz, .do_load_ext_loop ; ...
ret
ret ;
detect_cpu:
ld bc, #12ff ;
out (c), 0 ; on NMOS Z80 0x00 will be written, on CMOS Z80 - 0xFF
ld b, 0 ;
in a, (c) ; port #00FF bit 4 contains value we wrote
and #10 ;
jr z, .nmos ;
.cmos:
ld a, 1 ;
ld (cfg_saved.cmoscpu), a ;
ret ;
.nmos:
ld (cfg_saved.cmoscpu), a ;
ld a, (cfg_saved.clock) ; if clock >= 14MHz then clock = 7MHz
cp 4 ; ...
ret c ; ...
ld a, 3 ; ...
ld (cfg_saved.clock), a ; ...
ret ;
detect_sd_card:

View File

@ -272,8 +272,10 @@ menu_machine_cb:
ret
menu_clock_cb:
ld a, (cfg.cmoscpu) ; for CMOS - max clock is 4 (14MHz)
add 3 ; for NMOS - max clock is 3 (7MHz)
ld c, a ; ...
ld a, (cfg.clock)
ld c, 4
call menu_handle_press
ld (cfg.clock), a
ld bc, #03ff