Author Topic: FPGA VGA Controller for 8-bit computer  (Read 422458 times)

0 Members and 1 Guest are viewing this topic.

Offline nockieboyTopic starter

  • Super Contributor
  • ***
  • Posts: 1812
  • Country: england
Re: FPGA VGA Controller for 8-bit computer
« Reply #3525 on: August 18, 2022, 09:02:56 am »
That's working fine, getting audio from TV via HDMI and via the line out socket on the DECA.  Both sound the same - no loss of bass on the TV compared to the headphone output (which is surprisingly clear and loud, actually).

I'm having some trouble with CP/M at the moment, so can't test music, but beeps and boops in the DMI sound identical between the TV and headphones!

(No need to modify the _top file, worked straight away.)
 

Offline BrianHG

  • Super Contributor
  • ***
  • Posts: 7725
  • Country: ca
Re: FPGA VGA Controller for 8-bit computer
« Reply #3526 on: August 18, 2022, 09:58:12 am »
Ok, only a little work to do on my mixer-filters.  Then you will have the proper equivilant analog sound, with proper bass.
 

Offline nockieboyTopic starter

  • Super Contributor
  • ***
  • Posts: 1812
  • Country: england
Re: FPGA VGA Controller for 8-bit computer
« Reply #3527 on: August 18, 2022, 04:26:48 pm »
I'm not 100% sure on this, but it seems as though one of the channels (probably channel C) is weaker than the other two.  I've listened to a couple of tracks now that start with a beat and a single 'instrument', and when a third 'instrument' starts, the beat becomes very quiet.  It's a song I know pretty well and it seems that the drop in volume for the beat isn't intentional.  Just something to be aware of, I guess, as it's possibly an artefact left over from the way my hardware mixed the three channels together - don't know if that will be fixed with the new filters?
 

Offline BrianHG

  • Super Contributor
  • ***
  • Posts: 7725
  • Country: ca
Re: FPGA VGA Controller for 8-bit computer
« Reply #3528 on: August 18, 2022, 08:43:35 pm »
Could it be this? (jt49's DC filter)



You also see at 100hz, over half of the signal strength is lost.

Also remember, if you have a Headphones on the line out of the DECA, it mutes down it's output with any loud signals because that plug is connected to the DAC's line out (being overloaded) instead of it's high powered headphone outputs.
« Last Edit: August 18, 2022, 09:02:27 pm by BrianHG »
 

Offline nockieboyTopic starter

  • Super Contributor
  • ***
  • Posts: 1812
  • Country: england
Re: FPGA VGA Controller for 8-bit computer
« Reply #3529 on: August 18, 2022, 09:40:48 pm »
Could it be this? (jt49's DC filter)

That doesn't look good. :o

You also see at 100hz, over half of the signal strength is lost.

Also remember, if you have a Headphones on the line out of the DECA, it mutes down it's output with any loud signals because that plug is connected to the DAC's line out (being overloaded) instead of it's high powered headphone outputs.

Something to do with impedances, I'm guessing?  After the initial audio test with my headphones earlier, I've unplugged them and am back to listening on the TV again.  The loss of volume on one channel was through the TV, but as the audio is duplicated after the filters, both outputs should only be affected by the end hardware (i.e. the headphone speakers or whatever DAC/amplifier/speaker is in the TV).
 

Offline BrianHG

  • Super Contributor
  • ***
  • Posts: 7725
  • Country: ca
Re: FPGA VGA Controller for 8-bit computer
« Reply #3530 on: August 18, 2022, 09:54:51 pm »
The line out was only designed to drive 10kohm.  Headphones are 32ohm.  For the same voltage, the headphones draw a tone more current.

No, plugging in and out the headphone should not affect the HDMI sound.  2 completely different things.

You will just have to wait a day for my first filter release to test, but, all 3 channels should have the same volume.

Though, the way the PSG's dac is internally wired on the silicon and the way you resistor load them at the output can have unforeseen effects different than the linear channel mixing we are doing.

Or, the jt49 filters are just crap.
 

Offline BrianHG

  • Super Contributor
  • ***
  • Posts: 7725
  • Country: ca
Re: FPGA VGA Controller for 8-bit computer
« Reply #3531 on: August 19, 2022, 04:41:47 pm »
New filter preview:  All 3 channels playing 27Hz, 100% volume for 100ms, mute 100ms, 100% volume 100ms.

jt49 output:


BHG1, mixer settings=33% A, 33% B, 33% C, bass = 10.


BHG2, mixer settings=16% A, 16% B, 16% C, bass = 10.


BHG3, mixer settings=33% A, 33% B, 33% C, bass = 5.


BHG4, mixer settings=33% A, 33% B, 33% C, bass = 20.


My mixer settings are real-time programmable by the Z80.
The lower the bass#, the more bass.  The higher the bass#, the less bass.

BHG#2 with lower volume per channel mixer settings may be useful as it offers breathing room for the initial DC filter charge generated 'POP' which would more closely replicate the analog DC filter response at the cost of half volume.  BHG#1 engages my 'DC filter Peak Limiter' circuit rapidly pushing the DC offset instantly into the center during the initial peak.  This would lessen that initial POP if all 3 voices of the PSG begin at full volume exactly after half a second of silence.
 

Offline BrianHG

  • Super Contributor
  • ***
  • Posts: 7725
  • Country: ca
Re: FPGA VGA Controller for 8-bit computer
« Reply #3532 on: August 19, 2022, 04:54:19 pm »
Approximating the jt49 without his overflow bug...
BHG5, mixer settings=16% A, 16% B, 16% C, bass = 48.


« Last Edit: August 19, 2022, 07:37:57 pm by BrianHG »
 

Offline BrianHG

  • Super Contributor
  • ***
  • Posts: 7725
  • Country: ca
Re: FPGA VGA Controller for 8-bit computer
« Reply #3533 on: August 20, 2022, 07:12:11 am »
  :phew: OK, here we go.  You'll need to test everything as my availability will be shrinking at the end of the month.

I configured the sound system in Dual YM2149 & Stereo mixer-filter mode.

PSG_a operates on address 0-15 and outputs channels A,B,C.
PSG_b operates on address 16-31 and outputs channels D,E,F.

The Left channel Mixer operates on address 128-143.
The Right channel Mixer operates on address 144-159.

These are each mixer's controls and their power-up defaults:
Code: [Select]
        .RST_REGS   ( '{  64,  64,  64,  64,  64,  64,   0,  8'b00000000 ,   3, 128, 128,  0,  0,  0,  0,  0 } )
                        VolA,VolB,VolC,VolD,VolE,VolF, n/a, INV{xxFEDCBA},bass,treb,mvol,n/a,n/a,n/a,n/a,n/a.

1) Volume A-F:
     A volumes of 255 will output full amplitude for that channel, however, remember that there are normally 3 channels and usually having 3 on means if the PSG outputs full volume on all 3 voices, you will get distortion due to the impossible 300% required output waveform.  For maximum distortion free output, you would want to set each volume to 33.3% of 256, IE: 85,85,85.  Now, this leaves zero room for deliberate analog switching on and off 'POP' effect which you may want.  Cutting this volume in half to 43,43,43 will guarantee every nuance and full amplitude of the effect matches an original analog circuit.  Using values like 64,64,64 offers a middle ground givin you greater sample volume yet still offer most of that 'pop' effect.  If you want to mix all 6 channels, A-F, then I would probably use 43,43,43,43,43,43.

     Note that when changing volume, there will usually be a 'pop' effect due to the DC output nature of the YM2149 PSG.  The only way to get rid of this is to ramp the volume figures up and down.  All 6 channels may be ramped simultaneously and I recommend incrementing / decrementing 1 at a time, ~0.01-0.02 sec each step.  Note that the invert waveform 'INV{F,E,D,C,B,A}' also will make a loud pop, so to prevent this, ramp down the volume of that or all channels down to 0, swap the INV bits you wish to, then ramp back up the volume.  I recommend using Dolby-Pro-Logic 2 mixing factors for side and rear channels to generate your desired simulated surround wide stereo effect.

2) Bass :  Supports 1 through 63.  Upper bits are ignored. 0 allows DC through, so, do not use except for special circumstances.  1 has very low frequency support.  I set the default to 3.  32 should have very little bass.  This control can be freely changed without the worry of any 'pop' effect.

3) Treble : 255= unfiltered full bandwidth through. 128 = some really high frequency smoothing.  64= a bit softer. 0 = muffled.  This control can be freely changed without the worry of any 'pop' effect.

4) MVol : Master volume.  128 = default full volume.  255= a 2x boost, signals over the edges here will be clipped. anything below 128 will just lower the volume by that 1/128 factor.  Though this volume wont really pop like the individual volume channels A-F, it is still good practice to smoothly move it.  I personally would leave it at 128 unless you need a headphone volume control for the DECA's line out.

Let me know how it goes.  I could only visually see the PSG waveforms in Modelsim, so I did everything by eye.
« Last Edit: August 20, 2022, 07:24:45 am by BrianHG »
 
The following users thanked this post: nockieboy

Offline BrianHG

  • Super Contributor
  • ***
  • Posts: 7725
  • Country: ca
Re: FPGA VGA Controller for 8-bit computer
« Reply #3534 on: August 20, 2022, 08:34:48 pm »
Here is an update for the 'YM2149_PSG_system' source folder called:
'YM2149_PSG_system_now_with_readback_filter_regs.zip'.

Internal changes: Consolidated an additional multiplier in the audio filter section making the entire filter run on 1 multiplier and 1 adder.  (If I was truly motivated, it could have been possible to run 2 channel stereo from one of these modules.)  Changed the unnecessary 24 bit regs down to 16 bit except for the 1 crucial 24bit DC filter accumulator.  Cleaned up the code comments in the audio mixer / filter section for those who want to know.

External changes:
1) Moved the 'mvol' register from address 4'hA to 4'h6.  New reg addresses:
Code: [Select]
         // Address =      0    1    2    3    4    5    6         7         8    9
        .RST_REGS   ( '{  64,  64,  64,  64,  64,  64, 128,  8'b00000000 ,   3, 128 } )
                     // VolA,VolB,VolC,VolD,VolE,VolF,mvol, INV{xxFEDCBA},bass,treb

2) The Z80 can now read back the stored settings inside the left and right Mixer/Filter's registers.  This will help if you make a master volume/filter configuration utility, reading the current settings before making adjustments to allow you to smoothly step the volume settings to prevent the 'pop' effect.

3) For simulation, I added stereo view and some more specific tests of the filters separated on the left and right channel now using both PSGs simultaneously.

Just replace contents of the .zip with the entire 'YM2149_PSG_system' folder in the GPU project.
****(I also added the Quartus .qsf compiler settings file which generates the best FMAX with the current source files)
« Last Edit: August 20, 2022, 11:02:27 pm by BrianHG »
 
The following users thanked this post: nockieboy

Offline BrianHG

  • Super Contributor
  • ***
  • Posts: 7725
  • Country: ca
Re: FPGA VGA Controller for 8-bit computer
« Reply #3535 on: August 20, 2022, 10:33:25 pm »
This is a comparison of the different volume ramps based on parameter '.YM2149_DAC_BITS ( 8 ),' at line 965 in 'GPU_DECA_DDR3_top.sv'.  What I have done is grabbed the YM2149 .PDF data sheet page 11 and used the D-A converter normalized voltage illustration as a background, ran Modelsim to produce the same ramp at the same scale, copy & pasted Modelsim's analog waveform output (in red) over this graph.

Here are DAC settings 8 through 11:

.YM2149_DAC_BITS ( 8 )


.YM2149_DAC_BITS ( 9 )


.YM2149_DAC_BITS ( 10 )


.YM2149_DAC_BITS ( 11 )



     As you can see, 10 bits track the amplitude the closest.  Looking at the lower bit depths, the resulting sound output will have a 'brighter' sound with instruments played at lower volume settings, but to the ear, the volume will not appear to ramp up linearly with the 32 available PSG volume steps.  IE: The 8 bit mode will appear to have some slight auto-volume compression like with old analog tape recorders making soft sounds easier to hear while lowering the volume of the louder sounds by comparison.

    As for the original 8bit only jt49 volume table, he tracks the YM2149 exactly as well, however, with only 8 bits, the lower volumes have repeats in them unlike my 10bit modification.

See file 'jt49_hdl/jt49_exp.v' for the original volume VS 8bit DAC levels:
Code: [Select]
initial begin
    lut[0] = 8'd0;
    lut[1] = 8'd1;    <<<
    lut[2] = 8'd1;    <<< These 3 steps are actually all the same amplitude level
    lut[3] = 8'd1;    <<< even though they are volumes 1,2,3.
    lut[4] = 8'd2;
    lut[5] = 8'd2;    <<< These 2 are the same.
    lut[6] = 8'd3;
    lut[7] = 8'd3;    <<< These 2 are the same.
    lut[8] = 8'd4;
    lut[9] = 8'd5;
    lut[10] = 8'd6;
    lut[11] = 8'd7;
    lut[12] = 8'd9;
    lut[13] = 8'd11;
    lut[14] = 8'd13;
    lut[15] = 8'd15;
    lut[16] = 8'd18;
    lut[17] = 8'd22;
    lut[18] = 8'd26;
    lut[19] = 8'd31;
    lut[20] = 8'd37;
    lut[21] = 8'd45;
    lut[22] = 8'd53;
    lut[23] = 8'd63;
    lut[24] = 8'd75;
    lut[25] = 8'd90;
    lut[26] = 8'd107;
    lut[27] = 8'd127;
    lut[28] = 8'd151;
    lut[29] = 8'd180;
    lut[30] = 8'd214;
    lut[31] = 8'd255;

As for my code (BHG_jt49_exp_lut.vh) here are my DAC tables:
Code: [Select]
// *************************************************************************************************************************************
// *** 8  bit DAC LUT with a dynamic range of -48 decibels.
// *************************************************************************************************************************************
localparam logic [15:0] dlut_8  [0:31] = '{   0,   1,   2,   3,   4,   5,   6,   8,  10,  12,  14,  17,  19,  23,  26,  31,
                                             35,  41,  47,  54,  62,  70,  80,  92, 104, 119, 135, 154, 175, 198, 225, 255};
// *************************************************************************************************************************************
// *** 9  bit DAC LUT with a dynamic range of -54 decibels.
// *************************************************************************************************************************************
localparam logic [15:0] dlut_9  [0:31] = '{   0,   1,   2,   3,   4,   6,   7,   9,  12,  14,  17,  21,  25,  30,  36,  42,
                                             50,  59,  69,  81,  95, 111, 130, 151, 177, 206, 240, 279, 325, 378, 439, 511};
// *************************************************************************************************************************************
// *** 10 bit DAC LUT with a dynamic range of -60 decibels.
// *************************************************************************************************************************************
localparam logic [15:0] dlut_10 [0:31] = '{   0,   1,   2,   3,   5,   6,   8,  11,  14,  17,  21,  26,  32,  39,  48,  58,
                                             70,  84, 101, 121, 145, 174, 208, 248, 297, 354, 423, 505, 603, 719, 858,1023};
// *************************************************************************************************************************************
// *** 11 bit DAC LUT with a dynamic range of -66 decibels.
// *************************************************************************************************************************************
localparam logic [15:0] dlut_11 [0:31] = '{   0,   1,   2,   3,   5,   7,   9,  12,  16,  20,  26,  33,  41,  51,  63,  78,
                                             96, 118, 146, 179, 220, 270, 331, 406, 497, 609, 745, 913,1117,1367,1673,2047};
// *************************************************************************************************************************************

     Though I do not have the low volume repeats for my 8bit mode, as you see in the above images, I had to loose a proper exponential curve in the process whereas my 10bit table follows the curve almost perfectly without any low volume level repeats.

     The best and most accurate way would have been to use a 16bit table and specifying the -60db over 32 volume steps attenuation level of the YM2149 dac.  But it's a little late now.
« Last Edit: August 20, 2022, 11:55:58 pm by BrianHG »
 
The following users thanked this post: nockieboy

Offline nockieboyTopic starter

  • Super Contributor
  • ***
  • Posts: 1812
  • Country: england
Re: FPGA VGA Controller for 8-bit computer
« Reply #3536 on: August 21, 2022, 06:29:30 pm »
Just compiled the project you've uploaded after including the updated YM2149 project folder and .qsf file and I'm getting no audio at all.  The Z80 can read the registers, including the new registers (mvol, bass, treble etc) and is getting the default values back, but I'm not able to hear anything.  The TV definitely isn't muted. ;)
 

Offline BrianHG

  • Super Contributor
  • ***
  • Posts: 7725
  • Country: ca
Re: FPGA VGA Controller for 8-bit computer
« Reply #3537 on: August 21, 2022, 07:10:34 pm »
Try writing to the second PSG.
I think Quartus only sees the second one for some reason as it only reports the second LUT, I don't know why.

Also, inside 'YM2149_PSG_system.sv', comment out lines 1 and 2 making it a single PSG, mono.

I'll try to rig something here.
 

Offline nockieboyTopic starter

  • Super Contributor
  • ***
  • Posts: 1812
  • Country: england
Re: FPGA VGA Controller for 8-bit computer
« Reply #3538 on: August 21, 2022, 07:39:05 pm »
Try writing to the second PSG.
I think Quartus only sees the second one for some reason as it only reports the second LUT, I don't know why.

Haven't had time to try this yet - it'll require some manual writes to the PSG to target the second module and I won't be able to test that until tomorrow now.

Also, inside 'YM2149_PSG_system.sv', comment out lines 1 and 2 making it a single PSG, mono.

Just compiled and tried the project with the two lines commented out - still no sound.  :(
 

Offline BrianHG

  • Super Contributor
  • ***
  • Posts: 7725
  • Country: ca
Re: FPGA VGA Controller for 8-bit computer
« Reply #3539 on: August 21, 2022, 08:29:03 pm »
Just compiled the project you've uploaded after including the updated YM2149 project folder and .qsf file and I'm getting no audio at all.  The Z80 can read the registers, including the new registers (mvol, bass, treble etc) and is getting the default values back, but I'm not able to hear anything.  The TV definitely isn't muted. ;)
Did you check the headphone out?
 

Offline nockieboyTopic starter

  • Super Contributor
  • ***
  • Posts: 1812
  • Country: england
Re: FPGA VGA Controller for 8-bit computer
« Reply #3540 on: August 21, 2022, 09:21:04 pm »
Just compiled the project you've uploaded after including the updated YM2149 project folder and .qsf file and I'm getting no audio at all.  The Z80 can read the registers, including the new registers (mvol, bass, treble etc) and is getting the default values back, but I'm not able to hear anything.  The TV definitely isn't muted. ;)
Did you check the headphone out?

Yes, no sound there either.  :-\

Try writing to the second PSG.
I think Quartus only sees the second one for some reason as it only reports the second LUT, I don't know why.

I'm getting data back from the first PSG registers - or the only PSG registers with the two lines commented out for single-PSG mode.

I've reloaded the previous version of the GPU project and sound was coming out fine from that, so it's definitely something to do with the latest update.
 

Offline BrianHG

  • Super Contributor
  • ***
  • Posts: 7725
  • Country: ca
Re: FPGA VGA Controller for 8-bit computer
« Reply #3541 on: August 21, 2022, 10:21:53 pm »
When you write a register, do you read back the written value.
Check my mixer-filter values.
If any of the volumes are 0, or the mvol is set to 0, there will be no sound.
 

Offline BrianHG

  • Super Contributor
  • ***
  • Posts: 7725
  • Country: ca
Re: FPGA VGA Controller for 8-bit computer
« Reply #3542 on: August 22, 2022, 01:51:53 am »
Hmmm, Running my FP clock divider at 100MHz to create the I2S 3.072Mhz clock has a jitter too high for the audio codec's PLL to function properly.

Running with a source clock of 148.5MHz, 150MHz or 200MHz, works fine.  I'm assuming even higher frequencies will work fine too as my FP clock divider's output jitter spec drops as the source clock frequency increases.

Maybe the 100MHz sits on a 'flaky' functional point.  But, this shouldn't have affected the HDMI sound.

Ok, here is what I did.  I've sent you a new test project which has nothing but the Dual Stereo PSG system wired up to the RS232 debugger.  I provided multiple 'sound.bin's to load in the RS232 debugger which turns on everything for testing.  I have proven it functional here as I now can hear Dual PSGs with functional Stereo sound settings.

* Don't forget to check lines 525-533 in the GPU_DECA_top.sv to verify the RS232 connections.  Absolutely everything else has been removed from the project.

Only the 'Line-Out' should generate sound as there is no longer any video GPU system to drive the HDMI.

*** I changed the Bass settings.  They can now go from 1 to 255.
*** Reading off-address registers now returns '0's instead of repeats.
*** I also now mimicked my DDR3 dual clock PLL running the PSG at 100MHz CMD_CLK and the I2S transmitter at the 200MHz DDR3_CLK_50 core to get the Line out to work.

******** Yes I did listen turning on and off different voices.  Turning up the volume of one voice does not lower the volume of the other voices.  (Test file 'sound_surround.bin' performs this test continuously automatically ramping in and out 3 additional voices on top of the background 3.)  Could your TV have a built in auto-level / auto-volume feature?  I know Windows has one and if you arent aware (called loudness equalization), it's usually turned on, hidden in the system settings and it 'Fucks' up music.  Though it does makes Youtube videos easier to hear forcing everything to 1 volume level.
« Last Edit: August 22, 2022, 04:45:15 am by BrianHG »
 

Offline BrianHG

  • Super Contributor
  • ***
  • Posts: 7725
  • Country: ca
Re: FPGA VGA Controller for 8-bit computer
« Reply #3543 on: August 22, 2022, 04:41:14 am »
Ok, after you tested the above post, next move onto the new 'GPU_DECA_Stereo_Dual_PSG_beta_2.zip'.

I know that the 'Line Out' on this one does indeed now activate after programming the DECA as it makes a 'click' sound after reset.  This did not happen with the earlier test release.

Possible failure modes:

1)  If the Line Out works, but not the HDMI, then go to line 1270 in 'GPU_DECA_DDR3_top.sv' and re-enable / comment in the '!HDMI_TX_INT'.

2)  If there is still no sound on either outputs, then verify that when the Z80 writes to the PSG system, you can read back what was written and not the defaults.  If you only read the defaults back, then something happened to the 'Strobe' signal for the write enable.
« Last Edit: August 22, 2022, 04:47:43 am by BrianHG »
 

Offline nockieboyTopic starter

  • Super Contributor
  • ***
  • Posts: 1812
  • Country: england
Re: FPGA VGA Controller for 8-bit computer
« Reply #3544 on: August 22, 2022, 10:41:37 am »
When you write a register, do you read back the written value.
Check my mixer-filter values.
If any of the volumes are 0, or the mvol is set to 0, there will be no sound.

I can write to the registers and read back the written values.  The mixer-filter defaults are all as you've posted in your previous post here:

Code: [Select]
         // Address =      0    1    2    3    4    5    6         7         8    9
        .RST_REGS   ( '{  64,  64,  64,  64,  64,  64, 128,  8'b00000000 ,   3, 128 } )
                     // VolA,VolB,VolC,VolD,VolE,VolF,mvol, INV{xxFEDCBA},bass,treb

I've written 0x07 to register 7 in the above table (address 135) to see if the enable bits (for channels A, B and C at least) are inverted, but still nothing.  All volumes are positive (and default settings).

I'll move on to your more recent posts now.

 

Offline nockieboyTopic starter

  • Super Contributor
  • ***
  • Posts: 1812
  • Country: england
Re: FPGA VGA Controller for 8-bit computer
« Reply #3545 on: August 22, 2022, 11:28:20 am »
Ok, after you tested the above post, next move onto the new 'GPU_DECA_Stereo_Dual_PSG_beta_2.zip'.

I know that the 'Line Out' on this one does indeed now activate after programming the DECA as it makes a 'click' sound after reset.  This did not happen with the earlier test release.

Possible failure modes:

1)  If the Line Out works, but not the HDMI, then go to line 1270 in 'GPU_DECA_DDR3_top.sv' and re-enable / comment in the '!HDMI_TX_INT'.

2)  If there is still no sound on either outputs, then verify that when the Z80 writes to the PSG system, you can read back what was written and not the defaults.  If you only read the defaults back, then something happened to the 'Strobe' signal for the write enable.

I jumped straight to testing this last project version instead of the previous PSG-only one as I don't have the spare TTL-serial adapter available at the moment.  Will be able to test it later tonight if it's still beneficial to run through the different setups, but I can confirm that I've got sound from the latest project files you uploaded.  I can't verify the audio quality at the moment (too noisy) but will give it all a good test later. :-+
 

Offline nockieboyTopic starter

  • Super Contributor
  • ***
  • Posts: 1812
  • Country: england
Re: FPGA VGA Controller for 8-bit computer
« Reply #3546 on: August 22, 2022, 01:28:27 pm »
I've been playing some music and marvelling at the sound quality - sounds as close to the old chiptunes as it can possibly be, absolutely marvellous!  Well done on an excellent piece of work with that PSG, it's fantastic!  :-+ :clap:

I'll get the github repo set up tomorrow, unless there's any more testing or development that needs to be done?
 

Offline BrianHG

  • Super Contributor
  • ***
  • Posts: 7725
  • Country: ca
Re: FPGA VGA Controller for 8-bit computer
« Reply #3547 on: August 22, 2022, 01:54:36 pm »
I guess I have a 'good eye' for sound...  Still, try playing with the treble and bass settings (left and right simultaneously) to be sure.  Also prepare a .mp3 example sampled from the line-out direct to a PC's line in making sure you don't have the volume up too high.

2 things left.  I also have 1 item to minimize in the new code. and some documentation as I added a few things.

a) My metastability code is overkill and just needs a few regs to minimize.
b) A 'legacy' Z80 port which would allow you to access the PSG the old way instead of the current direct access.  Yes, we can have both access methods running in parallel as you can use a group of 2 separate Z80 ports, one old, one new to do this.
c) Interrupt timer if needed.

For ' b) ', I need an example of a read/write sequence used to make this work for you.
For ' c) ', I guess most of these old systems might use interrupt or reg timers to time the music.  Some may be tied to video hardware timers like h-sync / v-sync, or system clocks.  If you need any of these, let me know.

Let's start with ' b) '.  Please provide me with an example read and write steps to the Z80 port so I can compare with the data sheet and make you a proper translation layer.

Also let me know if I should be thinking about ' c) '.

*Bonus, going by eye, I bet if you were to change line 966 in you GPU _top.sv from 10 to ' .YM2149_DAC_BITS ( 9 ),   I bet it will sound a little better.  10 is a bit too quiet at lower volumes which may be hiding some minor subtlety as 9 it a bit too loud, but at least you could hear it.  I can always do it right and provide a true 14bit authentic dead perfect table output instead of the current bit-depth tapered versions of the tables.
« Last Edit: August 22, 2022, 01:59:08 pm by BrianHG »
 

Offline BrianHG

  • Super Contributor
  • ***
  • Posts: 7725
  • Country: ca
Re: FPGA VGA Controller for 8-bit computer
« Reply #3548 on: August 22, 2022, 02:21:05 pm »
Before making the .mp3, give this a try:

On the left and right channels, assuming that a volume of 64 is our 100% default reference...

Change channel B on the left and right to 90% volume.
Change channel A on the right to INVerted 80% volume.
Change channel C on the left to INVerted 80% volume.

Now give a listen, especially with headphones and compare to the default mono.

 

Offline nockieboyTopic starter

  • Super Contributor
  • ***
  • Posts: 1812
  • Country: england
Re: FPGA VGA Controller for 8-bit computer
« Reply #3549 on: August 22, 2022, 03:50:09 pm »
Before making the .mp3, give this a try:

On the left and right channels, assuming that a volume of 64 is our 100% default reference...

Change channel B on the left and right to 90% volume.
Change channel A on the right to INVerted 80% volume.
Change channel C on the left to INVerted 80% volume.

Now give a listen, especially with headphones and compare to the default mono.

Hmmmm... not sure I can tell a difference, but as I said previously, my ears aren't my most finely-tuned organs.  I've attached a zip with three mp3s in it - two are the same game soundtrack, PULSE1 and PULSE2.  PULSE2 was recorded after the volume changes you suggested above were made.  I think the original soundtrack was based on the screen update, as there's a couple of longer-than-usual pauses in the soundtrack that coincide with big screen updates in the original game, so pay them no attention in the recording.

IMPERIAL.mp3 is not from any game (or source) I recognise, included for a change of tune, recorded after the suggested volume changes.

b) A 'legacy' Z80 port which would allow you to access the PSG the old way instead of the current direct access.  Yes, we can have both access methods running in parallel as you can use a group of 2 separate Z80 ports, one old, one new to do this.
...
For ' b) ', I need an example of a read/write sequence used to make this work for you.

Are you talking about a legacy YM2149 port, with BDIR and BC1 pins?  I've not changed any host code at all to access the PSG - the music I've been playing (and recorded as mp3s) are being played in a generic CP/M MYM/PT2/PT3 player - all I had to change was the IO port addresses for the PSG specific to my uCOM.  Bridgette already does the job of interfacing to the PSG module?

c) Interrupt timer if needed.
...
For ' c) ', I guess most of these old systems might use interrupt or reg timers to time the music.  Some may be tied to video hardware timers like h-sync / v-sync, or system clocks.  If you need any of these, let me know.

The CP/M player can either use interrupts or a loop-based timer (the option I'm using at the moment as it works well enough for the player).  The interrupts would be driven by the Z80's CTC, a dedicated counter/timer chip, but in the original hardware of the day could well have been driven by a video interrupt or similar.  In any case, the timing of the commands being sent to the PSG are handled by the CPU, not by the PSG - unless you have other plans?

Let's start with ' b) '.  Please provide me with an example read and write steps to the Z80 port so I can compare with the data sheet and make you a proper translation layer.

As I mentioned above, I'm not sure exactly what you're asking for here.  In the YM2149_PSG_system/jt49_hdl folder, there's a file called jt49_bus.v.  That implements the original BDIR/BC1/DIN/DOUT interface - if you want to create an authentic YM2149/AY-3-891x interface then that provides a working template that could be tweaked as necessary?

*Bonus, going by eye, I bet if you were to change line 966 in you GPU _top.sv from 10 to ' .YM2149_DAC_BITS ( 9 ),   I bet it will sound a little better.  10 is a bit too quiet at lower volumes which may be hiding some minor subtlety as 9 it a bit too loud, but at least you could hear it.  I can always do it right and provide a true 14bit authentic dead perfect table output instead of the current bit-depth tapered versions of the tables.

I'll try this out later. :-+
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf