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

mixer: implement panning settings

This commit is contained in:
UzixLS
2021-06-18 22:34:17 +03:00
parent 1435f856b3
commit ca42c05ce6
3 changed files with 41 additions and 22 deletions

View File

@ -21,8 +21,8 @@ module magic(
output reg joy_sinclair,
output reg rom_plus3,
output reg rom_alt48,
output reg ay_abc,
output reg ay_mono,
output reg mix_abc,
output reg mix_mono,
output reg divmmc_en
);
@ -72,8 +72,8 @@ always @(posedge clk28 or negedge rst_n) begin
magic_beeper <= 0;
timings <= TIMINGS_PENT;
turbo <= TURBO_NONE;
ay_abc <= 1'b1;
ay_mono <= 0;
mix_abc <= 1'b1;
mix_mono <= 0;
ram_mode <= RAM_512;
rom_plus3 <= 0;
rom_alt48 <= 0;
@ -85,7 +85,7 @@ always @(posedge clk28 or negedge rst_n) begin
8'h01: magic_beeper <= bus.d_reg[0];
8'h02: timings <= timings_t'(bus.d_reg[1:0]);
8'h03: turbo <= turbo_t'(bus.d_reg[1:0]);
8'h04: {ay_mono, ay_abc} <= bus.d_reg[1:0];
8'h04: {mix_mono, mix_abc} <= bus.d_reg[1:0];
8'h05: rom_plus3 <= bus.d_reg[0];
8'h06: rom_alt48 <= bus.d_reg[0];
8'h07: joy_sinclair <= bus.d_reg[0];

View File

@ -17,29 +17,48 @@ module mixer(
input [7:0] sd_r1,
input ay_abc,
input ay_mono,
input mono,
output dac_l,
output dac_r
);
localparam WIDTH = 11;
localparam WIDTH = 13;
reg [WIDTH:0] dac_l_cnt, dac_r_cnt;
assign dac_l = dac_l_cnt[WIDTH];
assign dac_r = dac_r_cnt[WIDTH];
wire [WIDTH-1:0] dac_next_l =
sd_l0 + sd_l1 +
ay_a0 + ay_b0 +
ay_a1 + ay_b1 +
{beeper, tape_out, tape_in, 6'b000000}
{sd_l0, 1'b0} +
{sd_l1, 1'b0} +
{ay_a0, 1'b0} +
{ay_a1, 1'b0} +
(ay_abc? ay_b0 : ay_c0) +
(ay_abc? ay_b1 : ay_c1) +
{beeper, tape_out, tape_in, 7'b000000}
;
wire [WIDTH-1:0] dac_next_r =
sd_r0 + sd_r1 +
ay_b0 + ay_c0 +
ay_b1 + ay_c1 +
{beeper, tape_out, tape_in, 6'b000000}
{sd_r0, 1'b0} +
{sd_r1, 1'b0} +
(ay_abc? {ay_c0, 1'b0} : {ay_b0, 1'b0}) +
(ay_abc? {ay_c1, 1'b0} : {ay_b1, 1'b0}) +
(ay_abc? ay_b0 : ay_c0) +
(ay_abc? ay_b1 : ay_c1) +
{beeper, tape_out, tape_in, 7'b000000}
;
wire [WIDTH-1:0] dac_next_mono =
sd_r0 +
sd_r1 +
sd_l0 +
sd_l1 +
ay_a0 +
ay_a1 +
ay_b0 +
ay_b1 +
ay_c0 +
ay_c1 +
{beeper, tape_out, tape_in, 7'b000000}
;
always @(posedge clk28 or negedge rst_n) begin
@ -48,8 +67,8 @@ always @(posedge clk28 or negedge rst_n) begin
dac_r_cnt <= 0;
end
else begin
dac_l_cnt <= dac_l_cnt[WIDTH-1:0] + dac_next_l;
dac_r_cnt <= dac_r_cnt[WIDTH-1:0] + dac_next_r;
dac_l_cnt <= dac_l_cnt[WIDTH-1:0] + (mono? dac_next_mono : dac_next_l);
dac_r_cnt <= dac_r_cnt[WIDTH-1:0] + (mono? dac_next_mono : dac_next_r);
end
end

View File

@ -229,7 +229,7 @@ cpucontrol cpucontrol0(
/* MAGIC */
wire magic_mode, magic_map;
wire divmmc_en, joy_sinclair, rom_plus3, rom_alt48, ay_abc, ay_mono;
wire divmmc_en, joy_sinclair, rom_plus3, rom_alt48, mix_abc, mix_mono;
magic magic0(
.rst_n(usrrst_n),
.clk28(clk28),
@ -252,8 +252,8 @@ magic magic0(
.joy_sinclair(joy_sinclair),
.rom_plus3(rom_plus3),
.rom_alt48(rom_alt48),
.ay_abc(ay_abc),
.ay_mono(ay_mono),
.mix_abc(mix_abc),
.mix_mono(mix_mono),
.divmmc_en(divmmc_en)
);
@ -365,8 +365,8 @@ mixer mixer0(
.sd_r0(soundrive_r0),
.sd_r1(soundrive_r1),
.ay_abc(ay_abc),
.ay_mono(ay_mono),
.ay_abc(mix_abc),
.mono(mix_mono),
.dac_l(snd_l),
.dac_r(snd_r)