]> Joshua Wise's Git repositories - fpgaboy.git/commitdiff
Sound: Leave it to Dennis.
authorJoshua Wise <joshua@nyus.joshuawise.com>
Mon, 28 Apr 2008 10:41:24 +0000 (06:41 -0400)
committerJoshua Wise <joshua@nyus.joshuawise.com>
Mon, 28 Apr 2008 10:41:24 +0000 (06:41 -0400)
Sound1.v
Sound2.v
Soundcore.v
bootrom.asm

index 9444dbf19e775a2c62ebee95cd1e5a907af87b33..41abaa539e844f84f72d0cf890a45297b8450a4b 100644 (file)
--- a/Sound1.v
+++ b/Sound1.v
@@ -17,11 +17,11 @@ module Sound1(
        );
 
        /* can be optimized as register file */
-       reg [7:0] nr10, nr11, nr12, nr13, nr14;
+       reg [7:0] nr10 = 0, nr11 = 0, nr12 = 0, nr13 = 0, nr14 = 0;
        reg [10:0] counter = 0;
        reg [4:0] lencnt = 0;
        reg [3:0] delta = 4'b1111;
-       reg [2:0] dutycnt;
+       reg toggle = 0;
        reg [3:0] snd_out = 0;
 
        assign snd_data = en ? snd_out : 0;
@@ -58,15 +58,10 @@ module Sound1(
                        counter <= counter - 1;
                else begin
                        counter <= ~{nr14[2:0],nr13} + 1;  /* possible A */
-                       dutycnt <= dutycnt + 1;
+                       toggle <= ~toggle;
                end
-
-               case (nr11[7:6])
-               2'b00: snd_out <= dutycnt ? 0 : delta;   /* probable A */
-               2'b01: snd_out <= (dutycnt[2:1] == 2'b0) ? delta : 0;
-               2'b10: snd_out <= dutycnt[2] ? delta : 0;
-               2'b11: snd_out <= (dutycnt[2:1] == 2'b0) ? 0 : delta;
-               endcase
+               
+               snd_out <= toggle ? delta : 0;  /* Leave it to Dennis. */
        end
 
        always @ (posedge lenclk) begin
index fa5e5e793c6ef664ee7b659ff42896cc58cd888e..2bb959861dcd9f5ebf48bc64b4bda1e02b490e63 100644 (file)
--- a/Sound2.v
+++ b/Sound2.v
@@ -16,7 +16,7 @@ module Sound2(
        );
 
        /* can be optimized as register file */
-       reg [7:0] nr21, nr22, nr23, nr24;
+       reg [7:0] nr21 = 0, nr22 = 0, nr23 = 0, nr24 = 0;
        reg [10:0] counter = 0;
        reg [4:0] lencnt = 0;
        reg [3:0] delta = 4'b1111;
index 16d6067c490317e6609cf88168e7bb857556ff4e..b2c4d35288f8f87897115d36cad85a44418741ea 100644 (file)
@@ -17,9 +17,16 @@ module Soundcore(
        reg [4:0] cntclk;
        reg [13:0] lenclk;
        wire [3:0] sndout1,sndout2,sndout3,sndout4;
-       wire [3:0] right_snd = nr51[0] ? sndout1 : 4'b0;
-       wire [3:0] left_snd = nr51[4] ? sndout1 : 4'b0;
-
+       wire [3:0] right_snd =
+               (nr51[0] ? sndout1 : 4'b0) +
+               (nr51[1] ? sndout2 : 4'b0) +
+               (nr51[2] ? sndout3 : 4'b0) +
+               (nr51[3] ? sndout4 : 4'b0);
+       wire [3:0] left_snd =
+               (nr51[4] ? sndout1 : 4'b0) +
+               (nr51[5] ? sndout2 : 4'b0) +
+               (nr51[6] ? sndout3 : 4'b0) +
+               (nr51[7] ? sndout4 : 4'b0);
        assign sndout3 = 0;
        assign sndout4 = 0;
 
@@ -34,14 +41,14 @@ module Soundcore(
                        case(addr)
                        `ADDR_NR50: nr50 <= data;
                        `ADDR_NR51: nr51 <= data;
-                       `ADDR_NR52: nr52 <= {data[7],3'b1,data[3:0]};
+                       `ADDR_NR52: nr52 <= {data[7],7'b1111111};
                        endcase
                end
                cntclk <= cntclk + 1;
                lenclk <= lenclk + 1;
                pwmcnt <= pwmcnt + 1; 
-               snd_data_l <= (pwmcnt <= left_snd) ? 1 : 0;
-               snd_data_r <= (pwmcnt <= right_snd) ? 1 : 0;
+               snd_data_l <= (pwmcnt <= left_snd) ? nr50[7] : 0;
+               snd_data_r <= (pwmcnt <= right_snd) ? nr50[3] : 0;
        end
 
        Sound1 s1(
@@ -52,7 +59,7 @@ module Soundcore(
                .data(data),
                .cntclk(cntclk[4]),
                .lenclk(lenclk[13]),
-               .en(nr52[7] & nr52[0]),
+               .en(nr52[7]),
                .snd_data(sndout1)
        );
        
@@ -64,7 +71,7 @@ module Soundcore(
                .data(data),
                .cntclk(cntclk[4]),
                .lenclk(lenclk[13]),
-               .en(nr52[7] & nr52[0]),
+               .en(nr52[7]),
                .snd_data(sndout2)
        );
 
index cd760973ec199b7fb6fc16472894391576ab562e..4e780bf2918e045112731d9484c9c8afe172b3a7 100644 (file)
@@ -185,8 +185,12 @@ boot:      jr .running     ; $0100
 .running:
        ld a, $FF
        ld [$FF51], A
+       ld a, $00
+       ld [$FF25], a
 .diq:  ld A, [$FF51]
        cp 0
        jr z, .diq
+       ld a, 0
+       LD [$FF40],A
        jp $0000
 
This page took 0.0364 seconds and 4 git commands to generate.