AY Help Needed - Pac-Man Sound FX

On the creation of AY or Beeper music, including the packages used to do so.
Post Reply
User avatar
Joefish
Rick Dangerous
Posts: 2062
Joined: Tue Nov 14, 2017 10:26 am

AY Help Needed - Pac-Man Sound FX

Post by Joefish »

Can anyone help me out with some examples of creating sound FX on a 128K?

My game runs at 25fps so can issue instructions to the sound chip every 2 frames.
What I'd like is a simple bit of code that either programmatically, or using a small table, sends a sequence of commands to the sound chip to drive a single tone-only channel to make the effects for a Pac-Man game - particularly the 'waka waka waka' sound while pills are being eaten, and the death sound sequence.

Also any other noises like eating a power pill or a ghost, and the siren that sounds while a power-pill is in use. Though I might leave out the last one as it can be a bit annoying! I don't really know much about the sound chip, or what the pitch / volume profile of those sounds would look like.

Thanks
User avatar
WhatHoSnorkers
Manic Miner
Posts: 254
Joined: Tue Dec 10, 2019 3:22 pm

Re: AY Help Needed - Pac-Man Sound FX

Post by WhatHoSnorkers »

Not sure how much help it is, but Joe Pritchard's box on 128K machine code has a chapter on using the sound chip. I still need to read it (after buying it and scanning it in...)

https://spectrumcomputing.co.uk/entry.php?id=2000381

the PDF is on archive.org
I have a little YouTube channel of nonsense
https://www.youtube.com/c/JamesOGradyWhatHoSnorkers
User avatar
Joefish
Rick Dangerous
Posts: 2062
Joined: Tue Nov 14, 2017 10:26 am

Re: AY Help Needed - Pac-Man Sound FX

Post by Joefish »

Thanks, I know the basics of what the registers do. I needed someone though who knows how these sorts of sound effects are constructed. Things like how to synthesise them - like how a siren is basically a rising / falling pitch at a steady volume. I've managed a sort of 'crunch' before using noise of decreasing pitch, and a metallic 'ting' by increasing pitch. I can even do steam train, explosion and mechanical noises. But I'd like to be able to do these sort of 'squidgy' sounds, bouncing, water drops etc. if it's possible. But right at the moment, mimicking the Pac-Man sounds as closely as possible.
Timmy
Manic Miner
Posts: 231
Joined: Sat Apr 23, 2022 7:13 pm
Location: The Netherlands

Re: AY Help Needed - Pac-Man Sound FX

Post by Timmy »

Joefish wrote: Fri Oct 14, 2022 11:41 am I needed someone though who knows how these sorts of sound effects are constructed. Things like how to synthesise them
That's a short question with a very long answer... Do you have that much time?

Hmmm... I'm a bit too lazy right now, so I'll start with a short introduction text.

We start really simple. You probably know how the beeper works, it makes sounds and music just by sending on or off to the speaker. If you do this fast enough, you will get something.

To make something like a voice, you can then either generate a sound yourself with some code, or you just sample your voice into the speaker and you get a long list of sampled bits.

The AY chip is basically similar. If you want to reproduce a sound effect, you just sample it and then play it back. Basically how Sample Tracker works. For example, you can play that exact beeper sample into one of the AY channel, at the exact rate, you get the same output, but now in AY mode.

That, obviously, is a waste of resources of the AY chip, because you want to try to use the other advantages of the AY chip.

(Taking a break now, perhaps I'll write the second part later today, or perhaps you can figure out the next steps yourself. :) )
User avatar
Joefish
Rick Dangerous
Posts: 2062
Joined: Tue Nov 14, 2017 10:26 am

Re: AY Help Needed - Pac-Man Sound FX

Post by Joefish »

I know the AY can play samples if called upon, but it takes nearly all of the processor time. And I'm not trying to play multi-channel music.

What I'm talking about are the sound effects of early arcade games which were often generated by manipulating a single tone generator. Very simple stuff like envelopes of rising and falling volumes and pitch, triangular and sawtooth profiles. What all those different effects sound like and when and where to use them. I don't mean perfect replication through samples, just crude analogies of sound effects using a single tone generator. Again, I know the AY can do three tones at once and mix noise onto them, but I just want to use one channel at a time to keep it simple.

I know what the individual registers control. I guess I can just write some code to drive the chip directly, with volume and pitch ramps re-calculated in software at 25fps and see what noises I can make. I gather I need to set the bits to enable tone on a channel and disable noise, set the pitch and volume register(s) for that channel and out comes a tone? The rest will just be trial and error then.
User avatar
Stefan
Manic Miner
Posts: 819
Joined: Mon Nov 13, 2017 9:51 pm
Location: Belgium
Contact:

Re: AY Help Needed - Pac-Man Sound FX

Post by Stefan »

Would the Pac-Man Emulator be a good source to look at?
catmeows
Manic Miner
Posts: 718
Joined: Tue May 28, 2019 12:02 pm
Location: Prague

Re: AY Help Needed - Pac-Man Sound FX

Post by catmeows »

Joefish wrote: Fri Oct 14, 2022 2:37 pm What I'm talking about are the sound effects of early arcade games which were often generated by manipulating a single tone generator.
But thats not case of Pac-man, arcade uses quite advanced chip.

https://www.walkofmind.com/programming/pie/wsg3.htm
Proud owner of Didaktik M
User avatar
Joefish
Rick Dangerous
Posts: 2062
Joined: Tue Nov 14, 2017 10:26 am

Re: AY Help Needed - Pac-Man Sound FX

Post by Joefish »

Stefan wrote: Fri Oct 14, 2022 4:58 pm Would the Pac-Man Emulator be a good source to look at?
Good idea, it certainly sounds the part. I've had a look at the source code and it seems to be translating some simple pitch / volume registers into AY equivalents and passing them on. So the exact sequences are coming from the PacMan source code, which is harder to extract. Might be able to run it in a debugger though, or alter it to log the output to memory.

I did find this, though, running the PacMan sounds through an oscilloscope. Top line seems to be a triangular waveform generator, bottom line seems to have a deliberate noisy glitch in it.

The 'waka' seems to be a rapidly descending pitch, then a gap, then a rise again, then a gap, and repeat for as long as you're still eating dots.

Also this:


The death sound seems to be a rise/fall in pitch repeating but overall ending up a little lower each time.
Can't figure out what's going on in the 'eat ghost' sound though. Seems to be a rising pitch but with some sort of wobble. But the scope view is contaminated by the 'power pill siren' sound going on at the same time too.
User avatar
Joefish
Rick Dangerous
Posts: 2062
Joined: Tue Nov 14, 2017 10:26 am

Re: AY Help Needed - Pac-Man Sound FX

Post by Joefish »

catmeows wrote: Fri Oct 14, 2022 5:25 pm But thats not case of Pac-man, arcade uses quite advanced chip.
https://www.walkofmind.com/programming/pie/wsg3.htm
It's not completely out of reach. Although it's playing back waveforms as samples, there are only 32 samples per waveform and they're looped at a given frequency. It's not as if the whole sound effect is a sample. They let the programmer design a square or triangular or sinusoidal or more complex shaped waveform, which alters the tone of the sound that comes out, but they're still subject to a single frequency (repetition) and volume setting.

If you look at the bottom line in the still picture from that first oscilloscope view, you can actually count the 32 samples that make up that glitched sine wave pattern. Then it's repeating that "wave-wave-glitch" waveform at a variable frequency.

Somewhere else is the code that picks the waveform, then drives the frequency and volume up and down to make an effect or play a tune. If you take the programmed frequency, maybe double or treble it if there are two or three or more major cycles within the 32-step waveform definition (as above), you'll get an approximation of the original sound out of a single tone generator. That seems to be what the PacMan Emulator is doing.
User avatar
Joefish
Rick Dangerous
Posts: 2062
Joined: Tue Nov 14, 2017 10:26 am

Re: AY Help Needed - Pac-Man Sound FX

Post by Joefish »

I actually found a copy of the waveforms:
Image
The third one along is the one used in the 'wakka' sound - it matches what you can see on the oscilloscope. There are three major cycles within the waveform, that shorten in wavelength each time. But then it's looped and replayed at a rate (frequency) that ramps down and then back up again. I'd guess that a single tone could mimic that if its frequency were set to three times that waveform's replay rate. Not perfect, but close enough for a Speccy?
Timmy
Manic Miner
Posts: 231
Joined: Sat Apr 23, 2022 7:13 pm
Location: The Netherlands

Re: AY Help Needed - Pac-Man Sound FX

Post by Timmy »

I see you're just too impatient to read what I'm going to write, so I'm going to skip everything I was trying to write, and just condense it onto one short sentence.

To convert from a sample back to a note frequency, use FFT.

This is obviously losing all the nuances and stuff, but I'm pretty sure you can figure it out yourself. Or ask the rest of the forums.
(It's already hard to write and compose sentences for me as English is still not my first language, and I'm already too busy.)

EDIT: It might not help you, and it might be much easier to just figure out how the original program works.
User avatar
Joefish
Rick Dangerous
Posts: 2062
Joined: Tue Nov 14, 2017 10:26 am

Re: AY Help Needed - Pac-Man Sound FX

Post by Joefish »

Timmy wrote: Fri Oct 14, 2022 7:10 pmI see you're just too impatient to read what I'm going to write, so I'm going to skip everything I was trying to write, and just condense it onto one short sentence.
You were not answering my original question. I wanted maybe someone who could write a bit of usable game code for me as an example. I don't need more lessons in signal analysis. I had enough of those at University!
User avatar
Lee Bee
Dynamite Dan
Posts: 1303
Joined: Sat Nov 16, 2019 11:01 pm
Location: Devon, England
Contact:

Re: AY Help Needed - Pac-Man Sound FX

Post by Lee Bee »

Hi, I love recreating classic arcade music and SFX. While I can't program the sound chip directly, I can do it with trackers :-) For example, here's my version of the "eat ghost" sound in Vortex Tracker:

https://soundcloud.com/user-211102493/eat-ghost

These old sound effects might sound simple, but that's deceptive. There are actually plenty of little nuances which often make them tricky to replicate.

In case it helps, let me break down the steps I did with this one:

• First I made an ascending tone, sliding up from around C3 to F6
• I then adjusted the ascent so that instead of being linear, it deccelerates - rising quickly to start, then slowing as it reaches the top
• There is also an envelope used here, so I added an envelope (giving that slightly 'crunchy' sound)
• Like the main tone, the envelope also slides up, though less dramatically
• In the Pac-Man sound effect, the envelope isn't too loud, however the Spectrum has no envelope volume control, which means:
• I increased the volume of the main tone by doubling it up using a second channel. I adjusted the volume to get the balance right
• I also felt that the main pitch had a subtle chorus effect, so I adjusted its vibrato to 'double it up' into two near-pitches
• It took plenty of adjustments to get all this to sound close to the original
azesmbog
Manic Miner
Posts: 307
Joined: Sat May 16, 2020 8:43 am

Re: AY Help Needed - Pac-Man Sound FX

Post by azesmbog »

https://vtrd.in/pcutilz/AYFXEDIT.zip
by Shiru'17 - cross-editor of sound effects for AY (Windows)
With examples and test compiled file
User avatar
Joefish
Rick Dangerous
Posts: 2062
Joined: Tue Nov 14, 2017 10:26 am

Re: AY Help Needed - Pac-Man Sound FX

Post by Joefish »

Lee Bee wrote: Fri Oct 14, 2022 9:14 pm Hi, I love recreating classic arcade music and SFX. While I can't program the sound chip directly, I can do it with trackers :-) For example, here's my version of the "eat ghost" sound in Vortex Tracker:
https://soundcloud.com/user-211102493/eat-ghost
Thanks, just what I'm looking for! That's really impressive - I'll have to see if I can do that in code. I wasn't sure if I needed to add a tuned semitone table if driving the chip directly for effects, but I think I will, as it seems to make pitch ramps sound more natural.
Last edited by Joefish on Sat Oct 15, 2022 6:21 pm, edited 1 time in total.
User avatar
Joefish
Rick Dangerous
Posts: 2062
Joined: Tue Nov 14, 2017 10:26 am

Re: AY Help Needed - Pac-Man Sound FX

Post by Joefish »

azesmbog wrote: Fri Oct 14, 2022 10:05 pm https://vtrd.in/pcutilz/AYFXEDIT.zip
by Shiru'17 - cross-editor of sound effects for AY (Windows)
With examples and test compiled file
Clever tool, but it takes a lot of work to come up with an effect and it produces a lot of data, whereas being able to enter ramping parameters would cut all that down enormously. Nicely integrated with the soundchip emulator though.
User avatar
Joefish
Rick Dangerous
Posts: 2062
Joined: Tue Nov 14, 2017 10:26 am

Re: AY Help Needed - Pac-Man Sound FX

Post by Joefish »

Also found this information, trying to find the answer to a question I had about driving the sound chip via the volume control:

https://softspectrum48.weebly.com/notes ... y389108912

So DISABLING both Tone and Noise on a channel leaves the (square wave) oscillator output permanently high, which means you can then directly manipulate the line output level with the volume register.

From code, you can then play back 4-bit samples or shape your own waveform. Now I want to see if I can make some smoother sine-wave sounds for that seaside bingo machine effect. Does anyone know the note sequence of that old doo-doo-doo attract mode sound they made?

And presumably, a fast enough waveform envelope can make low-frequency sounds, which I have heard tell of, as a better bass effect than using the square-wave tone generator.
User avatar
Joefish
Rick Dangerous
Posts: 2062
Joined: Tue Nov 14, 2017 10:26 am

Re: AY Help Needed - Pac-Man Sound FX

Post by Joefish »

I've been doing some tests to get familiar with the AY. This is just using a single channel and ramping notes up and down. For the kill-ghost I added a volume envelope too.

I'm not sure I can do a pitch vibrato as in my game loop I'll only be accessing this routine at 25fps; I can't change the pitch any faster, and varying it at 25fps is all too obvious.

https://cluster3.secure-staging.uk/rail ... emo_02.tap

There are also some experiments with an attract-melody where I tried using the envelope generator to make triangular waveform bass tones. See thread on Seaside Sounds.

Source code for PASMO. There's a new font in there too, if anyone wants to steal it! :D

Code: Select all

ENTRY_POINT     EQU 32768

AY_WRITE_BC     EQU $FFFD   ; 65533
AY_WRITE_B      EQU $FF
AY_DATA_BC      EQU $BFFD   ; 49149
AY_DATA_B       EQU $BF

AY_PITCH_0_LO   EQU $0  ; 8 bits
AY_PITCH_0_HI   EQU $1  ; 4 bits
AY_PITCH_1_LO   EQU $2  ; 8 bits
AY_PITCH_1_HI   EQU $3  ; 4 bits
AY_PITCH_2_LO   EQU $4  ; 8 bits
AY_PITCH_2_HI   EQU $5  ; 4 bits
AY_CONTROL      EQU $7  ; 0=Tone1, 0=Tone2, 0=Tone3, 0=Noise1, 0=Noise2, 0=Noise3, 0, 0
AY_VOLUME_0     EQU $8  ; 4 bits
AY_VOLUME_1     EQU $9  ; 4 bits
AY_VOLUME_2     EQU $A  ; 4 bits
AY_ENVELOPE_LO  EQU $B  ; 8 bits
AY_ENVELOPE_HI  EQU $C  ; 4 bits
AY_ENVELOPE     EQU $D  ; 4 bits

AY_ENV_RAMP_DOWN    EQU 8
AY_ENV_RAMP_UP      EQU 12
AY_ENV_RAMP_UP_DOWN EQU 14
AY_ENV_RAMP_DOWN_UP EQU 10


org ENTRY_POINT
    call do_cls
    ld a,1
    call new_line_indent
    
    ld hl,string_0
    call do_print
    
    call new_line
    
    ld hl,string_1
    call do_print
        
    ld hl,string_2
    call do_print
        
    call new_line
    
    ld hl,string_3
    call do_print
        
    ld hl,string_4
    call do_print
        
    ld hl,string_5
    call do_print
        
    call new_line
    
    ld hl,string_6
    call do_print
        
    ld hl,string_7
    call do_print
        
menu_loop
    ld bc,0xF7FE
    in a,(c)
    
    rrca
    push af
    call nc,wakka
    pop af
    
    rrca
    push af
    call nc,kill_ghost
    pop af
    
    rrca
    push af
    call nc,attract_sound
    pop af
    
    rrca
    push af
    call nc,attract_low
    pop af
    
    rrca
    push af
    call nc,attract_lower
    pop af
    
    
    ld bc,0xEFFE
    in a,(c)
    rlca
    rlca
    rlca
    
    rlca
    push af
    call nc,attract_bass_low
    pop af
    
    rlca
    push af
    call nc,attract_bass_lower
    pop af
    
    jp menu_loop
    
string_0
    defb 'SOUND DEMO',0
string_1
    defb '1. WAKKA',0
string_2
    defb '2. KILL GHOST',0
string_3
    defb '3. ATTRACT',0
string_4
    defb '4. ATTRACT (LOW)',0
string_5
    defb '5. ATTRACT (LOWER)',0

string_6
    defb '6. ATTRACT (LOW BASS)',0
string_7
    defb '7. ATTRACT (LOWER BASS)',0

    
wakka    
    ld a,$ff
    ld (ay_ch0_on),a  
    call ay_put_control
    
    ld c,0  ; channel
    ld e,11 ; volume / envelope
    call ay_put_volume_e_c
    
    ld d,OCT_4+NT_D  ; start
    ld e,-7  ; inc
    ld b,3  ; count
    call fx_loop
    
    ld e,0 ; volume / envelope
    call ay_put_volume_e_c
    halt
    halt
    
    ld e,11 ; volume / envelope
    call ay_put_volume_e_c
    ld d,OCT_3+NT_G  ; start
    ld e,7  ; inc
    ld b,2  ; count
    call fx_loop
        
    ld e,0 ; volume / envelope
    call ay_put_volume_e_c
    halt
    halt
    halt
    halt
    
    ret
        
    
kill_ghost
    ld a,$ff
    ld (ay_ch0_on),a  
    call ay_put_control
    
    call ay_warble_envelope
        
    ld c,0  ; channel
    
    ld e,16 ; volume / envelope
    call ay_put_volume_e_c
    
    ld d,OCT_3+NT_G   ; start
    ld e,7            ; inc
    ld b,8            ; count
    call fx_loop
            
    ld e,0 ; volume / envelope
    call ay_put_volume_e_c
    
    ret
    
    
attract_sound
    ld hl,melody_attract
    jp play_melody
    
    
attract_low
    ld hl,melody_attract_low
    jp play_melody
        
attract_lower
    ld hl,melody_attract_lower
    jp play_melody
    
    
attract_bass_low
    ld hl,melody_attract_low
    jp play_bass
    
attract_bass_lower
    ld hl,melody_attract_lower
    jp play_bass
    
    
play_melody
    ld c,0  ; channel
        
play_melody_loop
    ld a,$ff
    ld (ay_ch0_on),a  
    call ay_put_control
    
    ld e,11 ; volume / envelope
    call ay_put_volume_e_c
    
    ld d,(hl)
    inc hl 
    ld a,d   
    and a
    jp z,play_melody_pause
    
    call ay_put_pitch_d_c

    ld b,(hl)
    inc hl
play_melody_wait
    halt
    halt
    djnz play_melody_wait
    
    jp play_melody_loop    
    
play_melody_pause  
    ld e,0 ; volume / envelope
    call ay_put_volume_e_c
     
    ld a,(hl)
    inc hl
    and a
    ret z
    
    ld b,a
    jp play_melody_wait

    
play_bass
    ld a,$0
    ld (ay_ch0_on),a  
    call ay_put_control
            
    ld c,0  ; channel
    
    ld d,0
    call ay_put_pitch_d_c
    
    ld e,16 ; volume / envelope
    call ay_put_volume_e_c
    
play_bass_loop
    
    ld a,(hl)
    inc hl 
    and a
    jp z,play_bass_pause
    
    call ay_put_bass_a

    ld c,0  ; channel
    ld e,16 ; volume / envelope
    call ay_put_volume_e_c
        
    ld b,(hl)
    inc hl
play_bass_wait
    halt
    halt
    djnz play_bass_wait
    
    jp play_bass_loop    
    
play_bass_pause  
    ld e,0 ; volume / envelope
    call ay_put_volume_e_c
     
    ld a,(hl)
    inc hl
    and a
    ret z
    
    ld b,a
    jp play_bass_wait

    
             

fx_loop
    call ay_put_pitch_d_c
    
    ld a,e
    add a,d
    ld d,a
    
    halt
    halt
    djnz fx_loop  
      
    ret   
    
    
ay_put_control
    push af
    push bc
    
    ld bc,AY_WRITE_BC
    ld a,AY_CONTROL
    out (c),a
    
    ld a,(ay_ch0_on)
    and 1
    ld b,a
    ld a,(ay_ch1_on)
    and 2
    or b
    ld b,a
    ld a,(ay_ch2_on)
    and 4
    or b
    xor 00111111b
    
    ld b,AY_DATA_B
    out (c),a
    
    pop bc
    pop af
    ret
    
    
; Program channel C (0..2) with tone D (0..63)
ay_put_pitch_d_c
    push af
    push bc
    push de
    push hl
    
    ld a,AY_PITCH_0_LO    
    add a,c
    add a,c
    
    ld hl,semitone_table
    ld b,0
    ld c,d
    add hl,bc
    add hl,bc
    ld e,(hl)
    inc hl
    ld d,(hl)
    
    ld bc,AY_WRITE_BC
    out (c),a
    ld b,AY_DATA_B
    out (c),e
    
    inc a
    ld b,AY_WRITE_B
    out (c),a
    ld b,AY_DATA_B
    out (c),d
    
    pop hl
    pop de
    pop bc
    pop af
    
    ret
    

ay_put_volume_e_c
    push af
    push bc
    
    ld a,AY_VOLUME_0    
    add a,c
    ld bc,AY_WRITE_BC
    out (c),a
    ld b,AY_DATA_B
    out (c),e
    
    pop bc
    pop af
    
    ret

    
ay_warble_envelope  
    push af
    push bc
     
    ld a,AY_ENVELOPE 
    ld bc,AY_WRITE_BC
    out (c),a
    ld a,AY_ENV_RAMP_UP_DOWN 
    ld b,AY_DATA_B
    out (c),a
    
    ld a,AY_ENVELOPE_LO 
    ld b,AY_WRITE_B
    out (c),a
    ld a,$8A 
    ld b,AY_DATA_B
    out (c),a
    
    ld a,AY_ENVELOPE_HI 
    ld b,AY_WRITE_B
    out (c),a
    ld a,$00 
    ld b,AY_DATA_B
    out (c),a
    
    pop bc
    pop af
    
    ret

    
ay_put_bass_a
    push af
    push bc
    push de
    push hl

    ld hl,semitone_table+120
    ld b,0
    ld c,a
    add hl,bc
    add hl,bc
    ld e,(hl)
    inc hl
    ld d,(hl)
        
    ld a,AY_ENVELOPE 
    ld bc,AY_WRITE_BC
    out (c),a
    ld a,AY_ENV_RAMP_UP_DOWN 
    ld b,AY_DATA_B
    out (c),a
    
    ld a,AY_ENVELOPE_LO 
    ld b,AY_WRITE_B
    out (c),a
    ld b,AY_DATA_B
    out (c),e
    
    ld a,AY_ENVELOPE_HI 
    ld b,AY_WRITE_B
    out (c),a
    ld b,AY_DATA_B
    out (c),d
    
    pop hl
    pop de
    pop bc
    pop af
    
    ret  
    
    
do_cls
    ld hl,16384
    ld de,16385
    ld bc,6144
    ld (hl),0
    ldir
    ld (hl),01001110b
    ld bc,767
    ldir
    ld a,1
    out (254),a
    
    ld bc,0
    ld (cursor_xy),bc
    
    ret
 

new_line_indent
    ld (cursor_x),a
    
new_line
    ld a,(cursor_y)
    inc a
    ld (cursor_y),a
    ret
    
do_print
    push hl
    
    ld bc,(cursor_xy)
    
    ld d,0
    ld e,c
    sla e
    ld hl,row_table    
    add hl,de
    ld e,(hl)
    inc hl
    ld d,(hl)
    ld h,0
    ld l,b
    add hl,de
    ex de,hl
    
    inc c
    ld (cursor_xy),bc
    
do_print_loop
    pop hl
    ld a,(hl)
    sub 32
    ret c
    inc hl
    push hl    
    rla
    rla
    ld b,0
    ld c,a
    ld hl,char_font
    add hl,bc
    add hl,bc
    
    push de
    REPT 7
        ld a,(hl)
        ld (de),a
        inc hl
        inc d
    ENDM
    ld a,(hl)
    ld (de),a
    pop de
    inc e    
jp do_print_loop


    
ay_ch0_on
    db 0
ay_ch1_on
    db 0
ay_ch2_on
    db 0
   
cursor_xy
cursor_y
    db 0 
cursor_x
    db 0
    
semitone_table
    dw 0
;        C      C#     D      D#     E      F      F#     G      G#     A      A#     B
;Octave 0: +00 => Middle C = 16.35 Hz
    dw $1A7B, $18FF, $1798, $1642, $1504, $13D5, $12BA, $11AC, $10AD, $0FBE, $0EDB, $0E06
;Octave 1: +12 => C1 = 32.7 Hz
    dw $0D3D, $0C7E, $0BCB, $0B22, $0A82, $09EB, $095C, $08D6, $0857, $07DF, $076E, $0703
;Octave 2: +24 => C2 = 65.41 Hz
    dw $069E, $063F, $05E5, $0591, $0541, $04F5, $04AE, $046B, $042B, $03EF, $03B7, $0381   
;Octave 3: +36 => C3 = 130.81 Hz
    dw $034F, $031F, $02F2, $02C8, $02A0, $027A, $0257, $0235, $0215, $01F7, $01DB, $01C0
;Octave 4: +48 => Middle C = 261.63 Hz
    dw $01A7, $018F, $0179, $0164, $0150, $013D, $012B, $011A, $010A, $00FB, $00ED, $00E0
;Octave 5: +60 => C5 = 523.25 Hz
    dw $00D3, $00C7, $00BC, $00B2, $00A8, $009E, $0095, $008D, $0085, $007D, $0076, $0070
;Octave 6: +72 => C6 = 1046.50 Hz
    dw $0069, $0063, $005E, $0059, $0054, $004F, $004A, $0046, $0042, $003E, $003B, $0038
;Octave 7: +84 => C7 = 2093.00 Hz
    dw $0034, $0031, $002F, $002C, $002A, $0027, $0025, $0023, $0021, $001F, $001D, $001C
;Octave 8: +96 => C8 = 4186.01 Hz
    dw $001A, $0018, $0017, $0016, $0015, $0013, $0012, $0011, $0010, $000F, $000E, $000E

    OCT_0 EQU 00
    OCT_1 EQU 12
    OCT_2 EQU 24
    OCT_3 EQU 36
    OCT_4 EQU 48
    OCT_5 EQU 60
    OCT_6 EQU 72
    OCT_7 EQU 84
    OCT_8 EQU 96
    
    NT_C  EQU  1
    NT_Cs EQU  2
    NT_D  EQU  3
    NT_Ds EQU  4
    NT_E  EQU  5
    NT_F  EQU  6
    NT_Fs EQU  7
    NT_G  EQU  8
    NT_Gs EQU  9
    NT_A  EQU 10
    NT_As EQU 11
    NT_bF EQU 11
    NT_B  EQU 12
    
melody_attract
    db OCT_4+NT_C,8, OCT_3+NT_G,8, OCT_3+NT_A,12, 0,4
    db OCT_4+NT_E,4, OCT_4+NT_D,4  
    db OCT_4+NT_C,8, OCT_3+NT_G,8, OCT_3+NT_A,12, 0,4
    db 0,0
    
melody_attract_low
    db OCT_3+NT_C,8, OCT_2+NT_G,8, OCT_2+NT_A,12, 0,4
    db OCT_3+NT_E,4, OCT_3+NT_D,4  
    db OCT_3+NT_C,8, OCT_2+NT_G,8, OCT_2+NT_A,12, 0,4
    db 0,0
    
melody_attract_lower
    db OCT_2+NT_C,8, OCT_1+NT_G,8, OCT_1+NT_A,12, 0,4
    db OCT_2+NT_E,4, OCT_2+NT_D,4  
    db OCT_2+NT_C,8, OCT_1+NT_G,8, OCT_1+NT_A,12, 0,4
    db 0,0
    
    
row_table
    REPT 3,row_table_scr_third
        REPT 8,row_table_scr_row
            defw 16384+(2048*row_table_scr_third)+(32*row_table_scr_row)
        ENDM
    ENDM

char_font
;include "Revue_Font.asm"   
;64 characters, 8x8 pixels, ASCII 32-95, 512 bytes
font_space
	DEFB	00000000b;' '
	DEFB	00000000b
	DEFB	00000000b
	DEFB	00000000b
	DEFB	00000000b
	DEFB	00000000b
	DEFB	00000000b
	DEFB	00000000b
font_puctuation
	DEFB	00111000b;!
	DEFB	00111000b
	DEFB	00111000b
	DEFB	00111000b
	DEFB	00111000b
	DEFB	00000000b
	DEFB	00111000b
	DEFB	00111000b

	DEFB	11101110b;"
	DEFB	11101110b
	DEFB	11001100b
	DEFB	00000000b
	DEFB	00000000b
	DEFB	00000000b
	DEFB	00000000b
	DEFB	00000000b

	DEFB	00000000b;#
	DEFB	01101100b
	DEFB	11111110b
	DEFB	11111110b
	DEFB	01101100b
	DEFB	11111110b
	DEFB	11111110b
	DEFB	01101100b

	DEFB	00010000b;$ {Symbol Shift Keypress}
	DEFB	00111000b
	DEFB	01000100b
	DEFB	10011110b
	DEFB	11000110b
	DEFB	11110010b
	DEFB	11000110b
	DEFB	11111110b

	DEFB	01100000b;%
	DEFB	11110110b
	DEFB	01101100b
	DEFB	00011000b
	DEFB	00110000b
	DEFB	01101100b
	DEFB	11011110b
	DEFB	00001100b

	DEFB	00111000b;&
	DEFB	01111100b
	DEFB	01101100b
	DEFB	00111010b
	DEFB	01111110b
	DEFB	11101100b
	DEFB	11111110b
	DEFB	01110110b

	DEFB	00111000b;'
	DEFB	00111000b
	DEFB	01110000b
	DEFB	00000000b
	DEFB	00000000b
	DEFB	00000000b
	DEFB	00000000b
	DEFB	00000000b

	DEFB	00011100b;(
	DEFB	00111000b
	DEFB	01110000b
	DEFB	01110000b
	DEFB	01110000b
	DEFB	01110000b
	DEFB	00111000b
	DEFB	00011100b

	DEFB	01110000b;)
	DEFB	00111000b
	DEFB	00011100b
	DEFB	00011100b
	DEFB	00011100b
	DEFB	00011100b
	DEFB	00111000b
	DEFB	01110000b

	DEFB	11111110b;* {Enter Keypress}
	DEFB	11111110b
	DEFB	11111010b
	DEFB	11111010b
	DEFB	11011010b
	DEFB	10000010b
	DEFB	11011110b
	DEFB	11111110b

	DEFB	00000000b;+
	DEFB	00111000b
	DEFB	00111000b
	DEFB	11111110b
	DEFB	11111110b
	DEFB	00111000b
	DEFB	00111000b
	DEFB	00000000b

	DEFB	00000000b;,
	DEFB	00000000b
	DEFB	00000000b
	DEFB	00000000b
	DEFB	00000000b
	DEFB	00111000b
	DEFB	00111000b
	DEFB	01110000b

	DEFB	00000000b;-
	DEFB	00000000b
	DEFB	00000000b
	DEFB	01111100b
	DEFB	01111100b
	DEFB	00000000b
	DEFB	00000000b
	DEFB	00000000b

	DEFB	00000000b;.
	DEFB	00000000b
	DEFB	00000000b
	DEFB	00000000b
	DEFB	00000000b
	DEFB	00111000b
	DEFB	00111000b
	DEFB	00111000b

	DEFB	00011100b;/
	DEFB	00011100b
	DEFB	00111000b
	DEFB	00111000b
	DEFB	01110000b
	DEFB	01110000b
	DEFB	11100000b
	DEFB	11100000b
font_zero
	DEFB	00111110b;0
	DEFB	11111110b
	DEFB	11000110b
	DEFB	11000110b
	DEFB	01101100b
	DEFB	01111100b
	DEFB	00111000b
	DEFB	00000000b
                    
	DEFB	00011100b;1
	DEFB	00111100b
	DEFB	00001100b
	DEFB	00001100b
	DEFB	00001100b
	DEFB	00001100b
	DEFB	00001100b
	DEFB	00000000b
                    
	DEFB	00111100b;2
	DEFB	01111110b
	DEFB	00001110b
	DEFB	00001100b
	DEFB	00011000b
	DEFB	00111110b
	DEFB	01111100b
	DEFB	00000000b
                    
	DEFB	00111100b;3
	DEFB	01111110b
	DEFB	00001110b
	DEFB	00011100b
	DEFB	00001110b
	DEFB	01111110b
	DEFB	00111100b
	DEFB	00000000b
                    
	DEFB	00011000b;4
	DEFB	00110000b
	DEFB	00110000b
	DEFB	01101100b
	DEFB	01111110b
	DEFB	01111110b
	DEFB	00001100b
	DEFB	00000000b
                    
	DEFB	01111100b;5
	DEFB	01111110b
	DEFB	01100000b
	DEFB	01111110b
	DEFB	01100110b
	DEFB	01111100b
	DEFB	00111000b
	DEFB	00000000b
                    
	DEFB	00110000b;6
	DEFB	00110000b
	DEFB	01100000b
	DEFB	01111100b
	DEFB	01100110b
	DEFB	01111110b
	DEFB	00111100b
	DEFB	00000000b
                    
	DEFB	00111110b;7
	DEFB	01111100b
	DEFB	00001100b
	DEFB	00011000b
	DEFB	00011000b
	DEFB	00110000b
	DEFB	00110000b
	DEFB	00000000b

	DEFB	00111100b;8
	DEFB	01111110b
	DEFB	01100110b
	DEFB	00111100b
	DEFB	01100110b
	DEFB	01111110b
	DEFB	00111100b
	DEFB	00000000b
                    
	DEFB	00111100b;9
	DEFB	01111110b
	DEFB	01110110b
	DEFB	00111110b
	DEFB	00000110b
	DEFB	00011110b
	DEFB	00001100b
	DEFB	00000000b
font_separators	
	DEFB	00000000b;:
	DEFB	00111000b
	DEFB	00111000b
	DEFB	00111000b
	DEFB	00000000b
	DEFB	00111000b
	DEFB	00111000b
	DEFB	00111000b

	DEFB	00000000b;;
	DEFB	00111000b
	DEFB	00111000b
	DEFB	00111000b
	DEFB	00000000b
	DEFB	00111000b
	DEFB	00111000b
	DEFB	01110000b

	DEFB	00010000b;< "<" = Caps Shift Keypress
	DEFB	00111000b
	DEFB	01000100b
	DEFB	10010010b
	DEFB	10011110b
	DEFB	10010010b
	DEFB	11000110b
	DEFB	11111110b

	DEFB	00000000b;=
	DEFB	00000000b
	DEFB	01111100b
	DEFB	01111100b
	DEFB	00000000b
	DEFB	01111100b
	DEFB	01111100b
	DEFB	00000000b

	DEFB	11111110b;> ">" = Space Keypress (as opposed to a printable space)
	DEFB	11111110b
	DEFB	10010010b
	DEFB	10110010b
	DEFB	10010010b
	DEFB	11010110b
	DEFB	10010110b
	DEFB	11111110b

	DEFB	01111100b;?
	DEFB	11111110b
	DEFB	11101110b
	DEFB	00011100b
	DEFB	00111000b
	DEFB	00000000b
	DEFB	00111000b
	DEFB	00111000b

	DEFB	01111100b;@
	DEFB	11111110b
	DEFB	11000010b
	DEFB	11011010b
	DEFB	11011110b
	DEFB	11000000b
	DEFB	11111110b
	DEFB	01111100b
font_A
	DEFB	00111100b;A
	DEFB	01111110b
	DEFB	11100000b
	DEFB	11001100b
	DEFB	11111100b
	DEFB	11001100b
	DEFB	11001100b
	DEFB	01100000b
                    
	DEFB	01111100b;B
	DEFB	11111110b
	DEFB	01100110b
	DEFB	01101100b
	DEFB	01100110b
	DEFB	01111110b
	DEFB	01111100b
	DEFB	00000000b
                    
	DEFB	00111100b;C
	DEFB	01111110b
	DEFB	01100000b
	DEFB	01100000b
	DEFB	00110000b
	DEFB	00111110b
	DEFB	00011100b
	DEFB	00000000b
                    
	DEFB	01111100b;D
	DEFB	11111110b
	DEFB	01100110b
	DEFB	01100110b
	DEFB	01101110b
	DEFB	01111100b
	DEFB	01111000b
	DEFB	00000000b
                    
	DEFB	01111100b;E
	DEFB	01111110b
	DEFB	01100000b
	DEFB	01111000b
	DEFB	01100000b
	DEFB	01111110b
	DEFB	01111100b
	DEFB	00000000b
                    
	DEFB	01111100b;F
	DEFB	01111110b
	DEFB	01100000b
	DEFB	01111000b
	DEFB	01100000b
	DEFB	01100000b
	DEFB	01100000b
	DEFB	00110000b
                    
	DEFB	00111100b;G
	DEFB	01111110b
	DEFB	01100000b
	DEFB	01100110b
	DEFB	00110010b
	DEFB	00111110b
	DEFB	00011100b
	DEFB	00000000b
                    
	DEFB	01100110b;H
	DEFB	01100110b
	DEFB	01111110b
	DEFB	01111110b
	DEFB	01100110b
	DEFB	01100110b
	DEFB	01100110b
	DEFB	00110000b
                    
	DEFB	00011000b;I
	DEFB	00011000b
	DEFB	00011000b
	DEFB	00011000b
	DEFB	00011000b
	DEFB	00011000b
	DEFB	00011000b
	DEFB	00000000b
                    
	DEFB	00011100b;J
	DEFB	00111100b
	DEFB	00001100b
	DEFB	00001100b
	DEFB	00001100b
	DEFB	00011100b
	DEFB	00111000b
	DEFB	00010000b
                    
	DEFB	01100110b;K
	DEFB	01101100b
	DEFB	01101100b
	DEFB	01111000b
	DEFB	01101100b
	DEFB	01101100b
	DEFB	01100110b
	DEFB	00000000b
                    
	DEFB	00110000b;L
	DEFB	00110000b
	DEFB	00110000b
	DEFB	00110000b
	DEFB	00110000b
	DEFB	00111110b
	DEFB	00111100b
	DEFB	00000000b
                    
	DEFB	11000110b;M
	DEFB	11101110b
	DEFB	11111110b
	DEFB	11010110b
	DEFB	11000110b
	DEFB	11000110b
	DEFB	11000110b
	DEFB	00000000b
                    
	DEFB	01100110b;N
	DEFB	01110110b
	DEFB	01111110b
	DEFB	01101110b
	DEFB	01100110b
	DEFB	01100110b
	DEFB	01100110b
	DEFB	00000000b
                    
	DEFB	01111100b;O
	DEFB	11111110b
	DEFB	11000110b
	DEFB	11000110b
	DEFB	01101100b
	DEFB	01111100b
	DEFB	00111000b
	DEFB	00000000b
                    
	DEFB	01111000b;P
	DEFB	11111100b
	DEFB	01100110b
	DEFB	01101100b
	DEFB	01111000b
	DEFB	01100000b
	DEFB	01100000b
	DEFB	00000000b
                    
	DEFB	01111100b;Q
	DEFB	11111110b
	DEFB	11000110b
	DEFB	11000110b
	DEFB	01101100b
	DEFB	01111110b
	DEFB	00111110b
	DEFB	00000000b
                    
	DEFB	01111000b;R
	DEFB	11111100b
	DEFB	01100110b
	DEFB	01101100b
	DEFB	01111000b
	DEFB	01101100b
	DEFB	01101110b
	DEFB	01000100b
                    
	DEFB	00111100b;S
	DEFB	01111110b
	DEFB	00110000b
	DEFB	00011000b
	DEFB	00001100b
	DEFB	01111110b
	DEFB	00111100b
	DEFB	00000000b
                    
	DEFB	00111100b;T
	DEFB	01111110b
	DEFB	00011000b
	DEFB	00011000b
	DEFB	00011000b
	DEFB	00011000b
	DEFB	00011000b
	DEFB	00000000b
                    
	DEFB	00110110b;U
	DEFB	00110110b
	DEFB	01100110b
	DEFB	01100110b
	DEFB	01100110b
	DEFB	01111110b
	DEFB	00111100b
	DEFB	00000000b
                    
	DEFB	01100110b;V
	DEFB	01100110b
	DEFB	01100110b
	DEFB	00111100b
	DEFB	00111100b
	DEFB	00011000b
	DEFB	00011000b
	DEFB	00000000b
                    
	DEFB	11010110b;W
	DEFB	11010110b
	DEFB	11010110b
	DEFB	11010110b
	DEFB	01111100b
	DEFB	01101100b
	DEFB	01101100b
	DEFB	00000000b
                    
	DEFB	01100110b;X
	DEFB	01100110b
	DEFB	00111100b
	DEFB	00011000b
	DEFB	00111100b
	DEFB	01100110b
	DEFB	01100010b
	DEFB	00000000b
                    
	DEFB	01100110b;Y
	DEFB	01100110b
	DEFB	01100110b
	DEFB	00111100b
	DEFB	00111100b
	DEFB	00011000b
	DEFB	00011000b
	DEFB	00001100b
                    
	DEFB	00111110b;Z
	DEFB	01111100b
	DEFB	00001100b
	DEFB	00011000b
	DEFB	00110000b
	DEFB	00111110b
	DEFB	01111100b
	DEFB	00000000b
font_extras
	DEFB	01111110b;[ {Copyright}
	DEFB	10000001b
	DEFB	10011101b
	DEFB	10110001b
	DEFB	10110001b
	DEFB	10011101b
	DEFB	10000001b
	DEFB	01111110b

	DEFB	00010001b; \ {Left}
	DEFB	00110011b
	DEFB	01110111b
	DEFB	11111111b
	DEFB	11111111b
	DEFB	01110111b
	DEFB	00110011b
	DEFB	00010001b

	DEFB	10001000b;] {Right}
	DEFB	11001100b
	DEFB	11101110b
	DEFB	11111111b
	DEFB	11111111b
	DEFB	11101110b
	DEFB	11001100b
	DEFB	10001000b

	DEFB	00111100b;^ {Fire}
	DEFB	01000010b
	DEFB	10011001b
	DEFB	10111101b
	DEFB	10111101b
	DEFB	10011001b
	DEFB	01000010b
	DEFB	00111100b

	DEFB	00000000b;_
	DEFB	00000000b
	DEFB	00000000b
	DEFB	00000000b
	DEFB	00000000b
	DEFB	00000000b
	DEFB	11111111b
	DEFB	11111111b    
        
end ENTRY_POINT
User avatar
Lee Bee
Dynamite Dan
Posts: 1303
Joined: Sat Nov 16, 2019 11:01 pm
Location: Devon, England
Contact:

Re: AY Help Needed - Pac-Man Sound FX

Post by Lee Bee »

↑ Wow! This is awesome! :-) Fantastic work, Jason, and very exciting. The triangle wave is also really impressive!

Sound effects are so important; whatever game you put these sounds into is going to be extremely satisfying to play! Grongy's Spekku Man is impressive, but I have a feeling this is going to be even moreso. Do you have any graphics previews yet?
Post Reply