Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] VIDC should trigger sound DMA events #12

Open
RichardBrown384 opened this issue Jul 2, 2024 · 0 comments
Open

[FEATURE] VIDC should trigger sound DMA events #12

RichardBrown384 opened this issue Jul 2, 2024 · 0 comments
Labels
component:vidc enhancement New feature or request

Comments

@RichardBrown384
Copy link
Owner

RichardBrown384 commented Jul 2, 2024

Is your feature request related to a problem? Please describe.
The VIDC should trigger sound DMA events to simulate proper machine behaviour.

Describe the solution you'd like
The VIDC should trigger sound DMA events at appropriate intervals.

Describe alternatives you've considered
None

Additional context
The VIDC is clocked at 24Mhz giving a VIDC tick time of 41.666ns.

Given:

  1. The emulator uses nanoseconds for time advancement notifications.
  2. The basic recipe is to take a chip's clock frequency and multiply it by the amount of time that has passed to give us
    the number of ticks that have passed.
  3. E.g. 250ns * 24Mhz = 6 ticks.
  4. However, (10^-9)*(10^6)=10^-3 so 250 * 24 gives us 6000 * (10^-3) milliticks = (6 ticks).
  5. So by "dropping" the units we can get an 'accuracy' to 1000ths of a tick by just using simple integer arithmetic.

Then:
The VTI documentation doesn't say that much about sound DMA timing.

If you want a sample period of N microseconds you should write N-1 to the sound frequency register.

The Sound FIFO is 16-bytes and one presumes that all samples are 8-bit (see the 255µlaw description in the manual) and therefore it takes:

16 * N microseconds to drain the buffer or,

16 * 1000 * N nanoseconds to drain the buffer

Then using the calculation from above gives

VIDC_Clock_Frequency (Mhz) * 16 * 1000 * N milliticks

between sound DMA requests.

Since VIDC_Sound_Frequency = N - 1 => N = VIDC_Sound_Freqency + 1 the period in ticks is then

VIDC_Clock_Frequency (Mhz) * 16 * 1000 * (VIDC_Sound_Freqency + 1) milliticks
@RichardBrown384 RichardBrown384 added enhancement New feature or request component:vidc labels Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:vidc enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant