Prev: F2FA Up: Map Next: F39F
F32E: Play a sampled sound effect (mostly speech)
Lives at $8122 when relocated.
"Giddy up boy!"
Input
A Input index (1..5)
speech_samples_table F32E DEFW $0A8C Length
F330 DEFW $C000 Address (in bank 4)
"Let's go Mr. Driver!"
F332 DEFW $14E6 Length
F334 DEFW $CA8C Address (in bank 4)
"Hold on man!"
F336 DEFW $0A5A Length
F338 DEFW $DF72 Address (in bank 4)
"Your time's up"
F33A DEFW $0ABE Length
F33C DEFW $E9CC Address (in bank 4)
Start noise
F33E DEFW $0ADC Length
F340 DEFW $F48A Address (in bank 4)
play_speech_128k F342 EX AF,AF' Bank input index
F343 CALL $8091 Call silence_audio_128k
F346 LD A,$04 128K: Map RAM bank 4 to $C000; Map normal screen; Map ROM 0
F348 LD BC,$7FFD
F34B OUT (C),A
F34D LD C,$FD Set up C as $FD for forming port values
F34F LD HL,$FFBF Set up H as $FF and L as $BF for forming port values
F352 LD D,$08 Set up D as 8 for Channel A volume register
F354 EXX Bank
F355 EX AF,AF' Unbank input index
F356 ADD A,A Compute address of speech_samples_table[A] (accounting for relocation and being 1-indexed)
F357 ADD A,A
F358 LD HL,$811E
F35B LD C,A
F35C LD B,$00
F35E ADD HL,BC
F35F LD E,(HL) Load length into DE and advance HL
F360 INC HL
F361 LD D,(HL)
F362 INC HL
F363 LD A,(HL) Load address into HL
F364 INC HL
F365 LD H,(HL)
F366 LD L,A
There are two samples per byte so we iterate here.
plsp_1 F367 LD C,$02 Set nibble counter to 2
F369 LD A,(HL) Read a byte of sample data
F36A RRA Use high nibble first
F36B RRA
F36C RRA
F36D RRA
plsp_2 F36E AND $0F Isolate next sample
F370 EX AF,AF' Bank it
F371 EXX Unbank
Write sample as Channel A volume.
F372 LD B,H Load $FF into B to set high byte of port
F373 LD A,D Load 8 into A
C is $FD here.
F374 OUT (C),A Write to $FFFD to select register 8: Channel A volume
F376 LD B,L Load $BF into B
F377 EX AF,AF' Unbank sample
F378 OUT (C),A Write to $BFFD to write volume register
F37A EX AF,AF' Bank sample again
Write sample as Channel B volume.
F37B INC A Increment A from 8 to 9
F37C LD B,H Load $FF into B to set high byte of port
F37D OUT (C),A Write to $FFFD to select register 9: Channel B volume
F37F LD B,L Load $BF into B
F380 EX AF,AF' Unbank sample
F381 OUT (C),A Write to register
F383 EX AF,AF' Bank sample again
Write sample as Channel C volume.
F384 INC A Increment A from 9 to 10
F385 LD B,H Load $FF into B to set high byte of port
F386 OUT (C),A Write to $FFFD to select register 10: Channel C volume
F388 LD B,L Load $BF into B
F389 EX AF,AF' Unbank sample
F38A OUT (C),A Write to register
F38C EXX Bank
Delay for 19 DJNZ's.
F38D LD B,$13 Delay loop (lower value => higher frequency)
plsp_delay F38F DJNZ plsp_delay
F391 LD A,(HL) Load next sample (same byte, but next nibble)
F392 DEC C Decrement nibble counter
F393 JR NZ,plsp_2 Loop to plsp_2
F395 INC HL Advance to next byte of sample data
F396 DEC DE Decrement sample data counter
F397 LD A,D Loop to plsp_1 while sample data remains
F398 OR E
F399 JP NZ,$815B
F39C JP $8208 Exit via relocated reset_paging_128k
Prev: F2FA Up: Map Next: F39F