Claim set · data/claims/pokered-av.yaml

Pokémon Red and Blue sound (pret/pokered)

Game: Pokémon Red and Blue.

The sound engine runs once a frame from the vertical blank handler. A note lasts ⌊(ℓ⋅s⋅T+f)/256⌋ frames, where ℓ is its length in 16ths, s the channel's note speed, T the song's 16-bit tempo, and f the channel's leftover fraction, which the low byte carries to the next note. pokered-av/note-timing

About: Pokémon Red and Blue Music driver

Codepokered: disassembly of Pokémon Red and Blue · home/vblank.asm#L59-L72cp BANK(Audio1_UpdateMusic) jr nz, .checkForAudio2 .audio1 call Audio1_UpdateMusicpokered: disassembly of Pokémon Red and Blue · audio/engine_1.asm#L39-L47ld hl, wChannelNoteDelayCounters ; delay until next note … cp 1 ; if the delay is 1, play next note jp z, Audio1_PlayNextNote dec a ; otherwise, decrease the delay timerpokered: disassembly of Pokémon Red and Blue · audio/engine_1.asm#L690-L737Audio1_note_length: … ld e, a ; store note length (in 16ths) … ld hl, wChannelNoteSpeeds … call Audio1_MultiplyAdd … ld a, [wMusicTempo] … ld a, l ; a = note_length * note_speed … ld hl, wChannelNoteDelayCountersFractionalPart … ld d, h ; de = note_delay_frac_part + (note_length * note_speed * tempo) … ld [hl], e ld a, d ld hl, wChannelNoteDelayCountersChecked by claude-agent, 2026-10-21 — read the VBlank call into the engine, the per-channel delay countdown, and Audio1_note_length's two multiplies and its split of the result into the fraction (low byte) and the frame count (high byte)

Pallet Town's theme sets tempo 160 and, on channel 3, note_type 12 (audio/music/pallettown.asm), so a sixteenth there is 12 × 160 / 256 = 7.5 frames, played as 7 and 8 in turn. The engine is included three times (engine_1 to engine_3), one per audio ROM bank; only engine 1 was read.

Cited by: Music driver

Channel 3 plays one of six 32-step waveforms, numbered 0 to 5. A song's note_type command picks one with its low nibble, and on each note the engine stops the wave channel, copies the 16 bytes into wave RAM, and starts it again. pokered-av/wave-instruments

About: Pokémon Red and Blue Sampled sound

Value
{
 "waves": 6,
 "steps": 32,
 "wave0": [
  0,
  2,
  4,
  6,
  8,
  10,
  12,
  14,
  15,
  15,
  15,
  14,
  14,
  13,
  13,
  12,
  12,
  11,
  10,
  9,
  8,
  7,
  6,
  5,
  4,
  4,
  3,
  3,
  2,
  2,
  1,
  1
 ]
}
Codepokered: disassembly of Pokémon Red and Blue · audio/wave_samples.asm#L3-L16dw .wave0 … dw .wave5 ; used in the Lavender Town and Pokemon Tower themes … ; these are the definitions for the channel 3 instruments ; each instrument definition is made up of 32 points (nibbles) that form ; the graph of the wave ; the current instrument is copied to AUD3WAVERAMpokered: disassembly of Pokémon Red and Blue · audio/engine_1.asm#L343-L355cp CHAN3 jr z, .musicChannel3 … .musicChannel3 ld hl, wMusicWaveInstrument .channel3 ld a, d and $f ld [hl], a ; store low nibble of param as wave instrumentpokered: disassembly of Pokémon Red and Blue · audio/engine_1.asm#L906-L944Audio1_ApplyWavePatternAndFrequency: … ld hl, Audio1_WavePointers … ld hl, AUD3WAVERAM ld b, AUD3WAVE_SIZE - 1 ld a, $0 ; stop hardware channel 3 ldh [rAUD3ENA], a .loop ld a, [de] inc de ld [hli], a … ld a, AUD3ENA_ON ; start hardware channel 3 ldh [rAUD3ENA], aChecked by claude-agent, 2026-10-21 — read the wave pointer table and its comments, note_type's channel 3 branch, and the copy loop into wave RAM; wave0's values are from the .wave0 line (L17)

The pointer table has nine entries, but entries 6 to 8 repeat wave 5 and are marked unused. Wave RAM is 16 bytes of two 4-bit samples (gb-hardware/wave).

Cited by: Sampled sound