New sounds

Basic and Machine Language

Moderator: Moderators

RJBowman
Vic 20 Enthusiast
Posts: 198
Joined: Tue Oct 25, 2011 7:50 pm

Post by RJBowman »

Elsewhere on these forums, there are discussions of using interrupts to change background, border, and auxiliary colors to create a new graphics mode for display of photographic images.

If you can have an interrupt on every scan line, that's getting pretty close to the compact disk sampling rate. You could use interrupts to modulate the VIC's four-bit volume control register and produce whatever waveform you want. You could write a SID simulator.
User avatar
Kweepa
Vic 20 Scientist
Posts: 1315
Joined: Fri Jan 04, 2008 5:11 pm
Location: Austin, Texas
Occupation: Game maker

Post by Kweepa »

You could write a SID simulator.
It's already been done, by Aleksi of course.
http://sleepingelephant.com/ipw-web/bul ... id+vicious
User avatar
Mike
Herr VC
Posts: 4842
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

RJBowman wrote:Elsewhere on these forums, there are discussions of using interrupts to change background, border, and auxiliary colors to create a new graphics mode for display of photographic images.

If you can have an interrupt on every scan line, [...]
Using interrupts on every scan line would eat up too many cycles.

My VFLI display routine only uses a single interrupt, it fires shortly before the raster beam reaches the display area. The interrupt routine then takes a value in the timer registers to fully stabilize the rasters, it is cycle exact. A loop then runs over the following 256 scan lines, which is timed out to take exactly 71 cycles/line.

In the left and right border, four registers are switched on every scan line. The horizontal display time for the visible area is 52 cycles (208 pixels ≙ 26 characters, one char on the VIC takes 2 cycles), meaning the four writes have to take place within 19 cycles. During the horizontal display area, the registers A, X, Y are set up to contain the correct values for the next line. One register is updated via INC, the three others with STA, STX and STY in quick succession. That takes 13 cycles, counted from the last cycle of the first write to the last cycle of the fourth write. The border/background register is switched exactly at the beginning of the next line. 8)

If the routine were unstabilized, the border colour switch couldn't be guaranteed at that exact horizontal position, also the jitter of up to 9 cycles, plus the 13 cycles needed for all register writes (=21 cycles) would exceed the available 19 cycle budget.
[...] that's getting pretty close to the compact disk sampling rate.
HSync frequency = 15.625 kHz (PAL)
CD sampling rate = 44.100 kHz

Not especially close. If you can't hear the difference, you should consult an otologist. :P
You could use interrupts to modulate the VIC's four-bit volume control register and produce whatever waveform you want. You could write a SID simulator.
What Kweepa said.

Nethertheless, SID Vicious outputs samples at ~6 kHz, which is slightly below telephony quality, but it works well enough. Increasing the sample rate would bring it at odds against the available cycles: the realtime wave sample output is done in the NMI, the 'original' SID player routine still has to run in the IRQ, and there's a noise waveform generator working in the foreground when there's no interrupt occuring at the moment. For this application, the VIC-20 is running exactly at the limit.
Post Reply