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

add auto cpu frequency

When this feature enabled:
* Frequency sets to 14MHz on esxdos activity - for fastest loading from
sd card;
* Frequency sets to 3.5MHz within ~1ms after #FE port access - this
allows to load from tape within turbo mode. Also this improves beeper
sound effects;
* Otherwise user configured frequency is used.
This commit is contained in:
Eugene Lozovoy
2022-08-30 21:56:43 +03:00
parent 3b043445a6
commit d2bbd13f7d
5 changed files with 58 additions and 10 deletions

View File

@ -2,6 +2,7 @@ import common::*;
module magic(
input rst_n,
input clk28,
input ck35,
cpu_bus bus,
output [7:0] d_out,
@ -102,6 +103,8 @@ end
/* MAGIC CONFIG */
turbo_t turbo0;
reg autoturbo_en;
wire config_cs = magic_map && bus.ioreq && bus.a[7:0] == 8'hFF;
always @(posedge clk28 or negedge rst_n) begin
if (!rst_n) begin
@ -109,7 +112,7 @@ always @(posedge clk28 or negedge rst_n) begin
magic_beeper <= 0;
rom_wren <= 0;
machine <= MACHINE_PENT;
turbo <= TURBO_NONE;
turbo0 <= TURBO_NONE;
panning <= PANNING_ABC;
rom_custom_en <= 0;
rom_custom <= 0;
@ -128,11 +131,12 @@ always @(posedge clk28 or negedge rst_n) begin
`else
bright_boost <= 1'b0;
`endif
autoturbo_en <= 1'b0;
end
else if (config_cs && bus.wr) case (bus.a[15:8])
8'h01: {rom_wren, magic_reboot, magic_beeper} <= bus.d[2:0];
8'h02: machine <= machine_t'(bus.d[2:0]);
8'h03: turbo <= turbo_t'(bus.d[2:0]);
8'h03: turbo0 <= turbo_t'(bus.d[2:0]);
8'h04: panning <= panning_t'(bus.d[1:0]);
8'h05: {rom_custom_en, rom_custom} <= {bus.d[7], bus.d[1:0]};
8'h06: {rom_alt48_en, rom_alt48} <= {bus.d[0] | bus.d[1], bus.d[1]};
@ -143,6 +147,7 @@ always @(posedge clk28 or negedge rst_n) begin
8'h0B: {soundrive_en, covox_en} <= bus.d[1:0];
8'h0C: sd_indication_en <= bus.d[0];
8'h0D: bright_boost <= bus.d[0];
8'h0E: autoturbo_en <= bus.d[0];
endcase
end
@ -156,6 +161,28 @@ always @(posedge clk28 or negedge rst_n) begin
end
/* AUTOMATIC TURBO */
reg [11:0] portfe_noturbo; // 1170uS
always @(posedge clk28 or negedge rst_n) begin
if (!rst_n)
portfe_noturbo <= 0;
else if (bus.ioreq && !bus.a[0])
portfe_noturbo <= 1'b1;
else if (|portfe_noturbo && ck35)
portfe_noturbo <= portfe_noturbo + 1'b1;
end
always @(posedge clk28 or negedge rst_n) begin
if (!rst_n)
turbo <= TURBO_NONE;
else if (autoturbo_en && div_paged && !magic_map)
turbo <= TURBO_14;
else if (autoturbo_en && |portfe_noturbo)
turbo <= TURBO_NONE;
else
turbo <= turbo0;
end
/* BUS CONTROLLER */
assign d_out_active = config_rd;
assign d_out = config_data;

View File

@ -336,6 +336,7 @@ assign sd_indication = sd_indication_en & ~sd_cs;
magic magic0(
.rst_n(n_rstcpu_in),
.clk28(clk28),
.ck35(ck35),
.bus(bus),
.d_out(magic_dout),

View File

@ -43,6 +43,7 @@ ulaplus DB 1
dac DB 3
sdind DB 1
bright DB BRIGHT_DEFAULT
autoturbo DB 0
ENDIF
ENDS

View File

@ -63,6 +63,7 @@ menuext: MENU_DEF 20
menuadv: MENU_DEF 22
MENUENTRY_T str_sd_indication menu_sdind_value_cb menu_sdind_cb
MENUENTRY_T str_bright_boost menu_bright_value_cb menu_bright_cb
MENUENTRY_T str_autoturbo menu_autoturbo_value_cb menu_autoturbo_cb
MENUENTRY_T str_save_settings menu_cfgsave_value_cb menu_cfgsave_cb
MENUENTRY_T str_back 0 menu_back_cb
MENUENTRY_T 0
@ -215,6 +216,14 @@ menu_bright_value_cb:
DW str_off_short_end-2
DW str_on_short_end-2
menu_autoturbo_value_cb:
ld ix, .values_table
ld a, (cfg.autoturbo)
jp menu_value_get
.values_table:
DW str_off_short_end-2
DW str_on_short_end-2
menu_cfgsave_value_cb:
ld ix, .values_table
ld a, (var_flash_error)
@ -385,6 +394,15 @@ menu_bright_cb:
out (c), a
ret
menu_autoturbo_cb:
ld a, (cfg.autoturbo)
ld c, 1
call menu_handle_press
ld (cfg.autoturbo), a
ld bc, #0eff
out (c), a
ret
menu_cfgsave_cb:
bit 4, d ; action?
ret z
@ -397,7 +415,7 @@ menu_cfgsave_cb:
.loop: ; ...
push bc ; ...
call .save_animation_effect ; ...
pop bc ; ...
pop bc ; ...
djnz .loop ; ...
pop de
ret
@ -414,7 +432,7 @@ menu_cfgsave_cb:
jr nz, .loop_inner
dec e
jr nz, .loop_outer
ret
ret
menu_back_cb:
call restore_screen
@ -425,7 +443,7 @@ menu_boot_normal_cb:
bit 4, d ; action?
ret z
ld a, 0
ld (cfg_saved.custom_rom), a
ld (cfg_saved.custom_rom), a
ld a, 1
ld (var_exit_flag), a
ret
@ -434,7 +452,7 @@ menu_boot_zx80_cb:
bit 4, d ; action?
ret z
ld a, #81
ld (cfg_saved.custom_rom), a
ld (cfg_saved.custom_rom), a
ld a, 1
ld (var_exit_flag), a
ret
@ -443,7 +461,7 @@ menu_boot_zx81_cb:
bit 4, d ; action?
ret z
ld a, #80
ld (cfg_saved.custom_rom), a
ld (cfg_saved.custom_rom), a
ld a, 1
ld (var_exit_flag), a
ret
@ -452,7 +470,7 @@ menu_boot_negluk_cb:
bit 4, d ; action?
ret z
ld a, #83
ld (cfg_saved.custom_rom), a
ld (cfg_saved.custom_rom), a
ld a, 1
ld (var_exit_flag), a
ret
@ -486,4 +504,3 @@ menu_handle_press:
.decrement_roll:
ld a, c ; value = max
ret

View File

@ -135,6 +135,9 @@ str_sd_indication_end:
str_bright_boost: DB "Bright boost",0
str_bright_boost_end:
str_autoturbo: DB "Auto CPU freq",0
str_autoturbo_end:
str_save_settings: DB "Save settings",0
str_save_settings_end:
@ -158,4 +161,3 @@ str_zx81_end:
str_negluk: DB "HE GLUK",0
str_negluk_end: