![]() |
Routines |
| Prev: A3BD | Up: Map | Next: A3E0 |
|
Called every frame by all three characters' handlers -- UPDATE_KNIGHT, UPDATE_WIZARD and UPDATE_SERF -- so walking sounds the same whoever is doing it. A counter at $5E2F advances on every call and its bottom two bits do all the work: bit 0 decides whether to make a sound at all, so only every other call does, and bit 1 chooses which of two notes.
The two are four cycles each, of half-period $60 and $40 -- which measure at about 1360 Hz and 2005 Hz. They alternate, so a walking character produces low, high, low, high rather than one repeated click. That is the whole footstep: two tones and a counter.
|
||||||||
| SOUND_FOOTSTEP | A3C7 | LD HL,$5E2F | The step counter, advanced on every call. | |||||
| A3CA | INC (HL) | |||||||
| A3CB | LD A,(HL) | |||||||
| A3CC | BIT 1,A | Bit 1 picks the note. | ||||||
| A3CE | JR Z,SOUND_FOOTSTEP_0 | |||||||
| A3D0 | AND $01 | Bit 0 silences every other call, which is what sets the pace. | ||||||
| A3D2 | RET Z | |||||||
| A3D3 | LD BC,$4004 | The higher of the two, about 2005 Hz. | ||||||
| A3D6 | JR BEEP_BC | |||||||
| SOUND_FOOTSTEP_0 | A3D8 | AND $01 | The same gate on the other branch. | |||||
| A3DA | RET Z | |||||||
| A3DB | LD BC,$6004 | The lower, about 1360 Hz. | ||||||
| A3DE | JR BEEP_BC | |||||||
| Prev: A3BD | Up: Map | Next: A3E0 |