Racer.

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice. No drama.
Post Reply
lb3361
Posts: 360
Joined: 17 Feb 2021, 23:07

Racer.

Post by lb3361 »

Many of the ROMv5 features envisioned by Marcel have been slowly added into the dev rom by the community: features related to the extension board (memory detection, SPI support, SD card booting), improvements to certain applications (Mandelbrot). One of the few remaining lines concerns the "Racer" application:

Code: Select all

#  XXX  Racer: Control speed with up/down (better for TypeC controllers)
#  XXX  Racer: Make noise when crashing
The first one makes a lot of sense to me. After understanding a bit more about how Racer works, I was able to add alternative keys. The tricky part was to make the code fit in the page containing the key scanning code. We can thanks the new CALLI instruction to save the few bytes I needed (https://github.com/lb3361/gigatron-rom/ ... a4014c67c2, attached ROM).

For the second one, a difficulty is that there is almost no memory left (has to work on a 32k gigatron). I identified two contiguous spaces with respectively 40 and 25 free bytes which could be used for vCPU code producing a crash sound. Given this constraint, how could one use the Gigatron sound machine to produce a decent crash noise: tires screeching, broken glass, as long as the code fits in ~40 bytes. I would love the help of somebody with a taste for sound.
Attachments
dev.rom
(128 KiB) Downloaded 77 times
at67
Site Admin
Posts: 647
Joined: 14 May 2018, 08:29

Re: Racer.

Post by at67 »

You have more than just code space, you also have 3*64 or even 4*64 bytes of waveform space at your disposal, the player explosion in Invader uses all 4 channels from memory.

The way I create Gigatron sound effects for my projects, (this really only works for old school sound effects that were created this way, like 70's and early 80's arcade machines), is to:

1) Analyse the high frequency repetitive frequencies that a sound effect uses, draw or code that as a 64 byte sample, (matching it as closely as possible with the dominant repeating wave shape), and stuff it into one of the wave channels.

2) Use code to modify ADSR and frequency at 60Hz to match the overall shape/envelope/timbre of the sound effect's entire waveform.

This is a highly subjective and erroneous process, that usually takes 30 to 50 iterations to get something resembling what I am trying to replicate, but for me it's also one of the most fun aspects of coding for the Gigatron.

Have a look at the samples I hand drew in the audio editing section of my emulator and the code I used to modify their ADSR and frequency for PucMon and Invader.
lb3361
Posts: 360
Joined: 17 Feb 2021, 23:07

Re: Racer.

Post by lb3361 »

at67 wrote: 26 Oct 2022, 08:58 Have a look at the samples I hand drew in the audio editing section of my emulator and the code I used to modify their ADSR and frequency for PucMon and Invader.
I certainly looked at this code in Invaders. One thing is that I do not have any precise idea about the sound I want there. I am tempted to closely copy your "player explode" sound...
lb3361
Posts: 360
Joined: 17 Feb 2021, 23:07

Re: Racer.

Post by lb3361 »

Curious to know what you think about this version of Racer with a car crash sound?
It comes as a new ROM because Racer depends on private SYS calls whose address changes from ROM to ROM.
dev.rom
(128 KiB) Downloaded 80 times
The engine sound has a bit more noise and a lower frequency. Is this an improvement?

Details:
The car crash sound is quite close to at67's player explosion sound, but using entropy instead of a frequency table to save a lot of space. This also makes the crash sound a little bit different each time. The car engine sound has half the frequency and mixes a bit of noise. Here is the diff:
https://github.com/lb3361/gigatron-rom/ ... e93a66b284

Update:
The following GT1 works with ROMv5a and DevROMs using unholy tricks to locate the private SYS calls in the ROM. This will not work with ROMv4 or ROMvX0. This is a hack for the sole purpose of making it easier to try the new sound effects and key assignments (up/down arrows also work).
Racerx.gt1
(1.92 KiB) Downloaded 82 times
at67
Site Admin
Posts: 647
Joined: 14 May 2018, 08:29

Re: Racer.

Post by at67 »

lb3361 wrote: 29 Oct 2022, 11:43 Curious to know what you think about this version of Racer with a car crash sound?
Personally I think it's too long/abrupt and too binary, I know there's no code space left, but a skid type sound as you get closer to the rail ramping in intensity before you explode would probably do the trick. Maybe try a linear/non-linear reduction in volume as the crash sound is played.
lb3361 wrote: 29 Oct 2022, 11:43 The engine sound has a bit more noise and a lower frequency. Is this an improvement?
It starts off great, but quickly devolves into a muddy tone, I'd limit the upper frequency of the tone channel/s and add more noise, maybe varying the percentage of noise added as the rpm's are increased, (by adjusting volumes of tone and noise channels appropriately).

Like I said, this is very subjective when working with such limited audio capabilities and can take many iterations to get something satisfying.

I would also find videos of a similar audio vintage/capability, (late 70's early 80's racing arcade machines), and listen to what they achieved and try and emulate them, or at least draw inspiration from them.
lb3361
Posts: 360
Joined: 17 Feb 2021, 23:07

Re: Racer.

Post by lb3361 »

Here is another version with small changes. I have added a bit more noise into the engine sound and blunted the crash sound. I like it a bit better.
Racerx.gt1
(1.93 KiB) Downloaded 98 times
Memory is very tight. Everything after address $1000 is busy with pixel rows that are shifted as needed. What is left now are two contiguous segments of about 20 bytes and two segments of about 12 bytes. I understand one can overwrite the waveforms with new ones. One can model the high frequencies in this way. But one then needs to modulate the low frequencies with code, and that takes code space...
Last edited by lb3361 on 31 Oct 2022, 19:33, edited 1 time in total.
veekoo
Posts: 121
Joined: 07 Jun 2021, 07:07

Re: Racer.

Post by veekoo »

I think I vote no to engine sound changes so far and explosion is ok.
lb3361
Posts: 360
Joined: 17 Feb 2021, 23:07

Re: Racer

Post by lb3361 »

Interactive sound makes up for other defects.

Two variants:
Racerx.gt1
(1.95 KiB) Downloaded 93 times
Racerx2.gt1
(1.95 KiB) Downloaded 81 times
And my final version with some tweaks on the slowdown. With the new acceleration noise, it made little sense to not let the car slow down to a rest when not accelerating. This also hides the fact that the not-under-acceleration noise for slow speeds is not too good (it is good at idle or fast, in my opinion). That also makes the game a lot more tense.
Racerx_final.gt1
(1.95 KiB) Downloaded 85 times
qwertyface
Posts: 68
Joined: 16 Jul 2019, 09:19
Location: UK

Re: Racer.

Post by qwertyface »

Since you've been looking at Racer, I wonder if you have any insights into the inversion table in ROM page 10.

I couldn't easily work out how it's being used from reading the Racer source, and the comment in the ROM source source ("Unit 64, table offset 16 (=1/4), value offset 1: (x+16)*(y+1) == 64*64 - e") is cryptic to say the least. I my guess is that it holds reciprocals for some sort of division operation, but I really can't see how to use it.

It's something I've been curious about for a long time.
lb3361
Posts: 360
Joined: 17 Feb 2021, 23:07

=

Post by lb3361 »

qwertyface wrote: 07 Nov 2022, 12:00 Since you've been looking at Racer, I wonder if you have any insights into the inversion table in ROM page 10. I couldn't easily work out how it's being used from reading the Racer source, and the comment in the ROM source source ("Unit 64, table offset 16 (=1/4), value offset 1: (x+16)*(y+1) == 64*64 - e") is cryptic to say the least. I my guess is that it holds reciprocals for some sort of division operation, but I really can't see how to use it.
I think this is best answered by looking at the python code that computes the table:

Code: Select all

# Unit 64, table offset 16 (=1/4), value offset 1: (x+16)*(y+1) == 64*64 - e
for i in range(251):
  ld(4096//(i+16)-1)
I believe that the important part of the comment is "(x+16)*(y+1) == 64*64" where 0 <= y <= 255 is the value stored at offset 0 <= x <= 250 in the table.

One can interpret this as a fixed point inversion table for numbers with a 6 bit fractional part. Suppose 16/64 <= Z <= 266/64 is represented by the integer FZ ~= Z*64. We are looking for 1/Z expressed as the integer FI ~= 64/Z. Then FI = invTable[FZ-16]+1. This is how I understand the cryptic "table offset 16 (=1/4)" and "value offset 1".
Post Reply