Added currently playing volume readout
This commit is contained in:
parent
7034a0cbfb
commit
d01eb6cc45
|
@ -72,6 +72,7 @@ BRK
|
|||
@on-screen ( -> )
|
||||
|
||||
;move-head JSR2
|
||||
;draw-vu JSR2
|
||||
.head/pos PEK #08 MOD #00 NEQ ,&skip JNZ
|
||||
;bang JSR2
|
||||
&skip
|
||||
|
@ -421,6 +422,16 @@ RTN
|
|||
|
||||
RTN
|
||||
|
||||
@draw-vu ( -- )
|
||||
.ctlframe/x1 PEK2 #0088 ADD2 .ctlframe/y1 PEK2 #0010 ADD2
|
||||
.Audio/volume DEI DUP STH #04 SFT
|
||||
;draw-knob/force JSR2
|
||||
.ctlframe/x1 PEK2 #0098 ADD2 .ctlframe/y1 PEK2 #0010 ADD2
|
||||
STHr #0f AND
|
||||
;draw-knob/force JSR2
|
||||
|
||||
RTN
|
||||
|
||||
@draw-channels
|
||||
|
||||
.chnframe/x1 PEK2 .chnframe/y1 PEK2 .chnframe/x2 PEK2 .chnframe/y2 PEK2 #01 ;line-rect JSR2
|
||||
|
|
17
src/apu.c
17
src/apu.c
|
@ -79,3 +79,20 @@ apu_start(Apu *c, Uint16 adsr, Uint8 pitch)
|
|||
else /* sample repeat mode */
|
||||
c->period = NOTE_PERIOD;
|
||||
}
|
||||
|
||||
Uint8
|
||||
apu_get_vu(Apu *c, Apu *end)
|
||||
{
|
||||
size_t i;
|
||||
Sint32 sum[2] = {0, 0};
|
||||
for(; c < end; ++c) {
|
||||
if(!c->advance) continue;
|
||||
sum[0] += envelope(c, c->age) * c->volume_l;
|
||||
sum[1] += envelope(c, c->age) * c->volume_r;
|
||||
}
|
||||
for(i = 0; i < 2; ++i) {
|
||||
sum[i] /= 0x800;
|
||||
if(sum[i] > 0xf) sum[i] = 0xf;
|
||||
}
|
||||
return (sum[0] << 4) | sum[1];
|
||||
}
|
||||
|
|
|
@ -20,8 +20,10 @@ typedef struct {
|
|||
Uint8 *addr;
|
||||
Uint32 count, advance, period, age, a, d, s, r;
|
||||
Uint16 i, len;
|
||||
Uint8 volume_l, volume_r, pitch, repeat;
|
||||
Sint8 volume_l, volume_r;
|
||||
Uint8 pitch, repeat;
|
||||
} Apu;
|
||||
|
||||
void apu_render(Apu *c, Sint16 *sample, Sint16 *end);
|
||||
void apu_start(Apu *c, Uint16 adsr, Uint8 pitch);
|
||||
Uint8 apu_get_vu(Apu *c, Apu *end);
|
||||
|
|
|
@ -248,7 +248,10 @@ static void
|
|||
audio_talk(Device *d, Uint8 b0, Uint8 w)
|
||||
{
|
||||
Apu *c;
|
||||
if(!w) return;
|
||||
if(!w) {
|
||||
if(b0 == 0xe) d->dat[0xe] = apu_get_vu(apu, apu + POLYPHONY);
|
||||
return;
|
||||
}
|
||||
c = &apu[d->dat[0x7] % POLYPHONY];
|
||||
SDL_LockAudioDevice(audio_id);
|
||||
if(b0 == 0x1) c->period -= (Sint16)mempeek16(d->dat, 0x0);
|
||||
|
|
Loading…
Reference in New Issue