... | ... |
@@ -72,6 +72,7 @@ BRK |
72 | 72 |
@on-screen ( -> ) |
73 | 73 |
|
74 | 74 |
;move-head JSR2 |
75 |
+ ;draw-vu JSR2 |
|
75 | 76 |
.head/pos PEK #08 MOD #00 NEQ ,&skip JNZ |
76 | 77 |
;bang JSR2 |
77 | 78 |
&skip |
... | ... |
@@ -421,6 +422,16 @@ RTN |
421 | 422 |
|
422 | 423 |
RTN |
423 | 424 |
|
425 |
+@draw-vu ( -- ) |
|
426 |
+ .ctlframe/x1 PEK2 #0088 ADD2 .ctlframe/y1 PEK2 #0010 ADD2 |
|
427 |
+ .Audio/volume DEI DUP STH #04 SFT |
|
428 |
+ ;draw-knob/force JSR2 |
|
429 |
+ .ctlframe/x1 PEK2 #0098 ADD2 .ctlframe/y1 PEK2 #0010 ADD2 |
|
430 |
+ STHr #0f AND |
|
431 |
+ ;draw-knob/force JSR2 |
|
432 |
+ |
|
433 |
+RTN |
|
434 |
+ |
|
424 | 435 |
@draw-channels |
425 | 436 |
|
426 | 437 |
.chnframe/x1 PEK2 .chnframe/y1 PEK2 .chnframe/x2 PEK2 .chnframe/y2 PEK2 #01 ;line-rect JSR2 |
... | ... |
@@ -79,3 +79,20 @@ apu_start(Apu *c, Uint16 adsr, Uint8 pitch) |
79 | 79 |
else /* sample repeat mode */ |
80 | 80 |
c->period = NOTE_PERIOD; |
81 | 81 |
} |
82 |
+ |
|
83 |
+Uint8 |
|
84 |
+apu_get_vu(Apu *c, Apu *end) |
|
85 |
+{ |
|
86 |
+ size_t i; |
|
87 |
+ Sint32 sum[2] = {0, 0}; |
|
88 |
+ for(; c < end; ++c) { |
|
89 |
+ if(!c->advance) continue; |
|
90 |
+ sum[0] += envelope(c, c->age) * c->volume_l; |
|
91 |
+ sum[1] += envelope(c, c->age) * c->volume_r; |
|
92 |
+ } |
|
93 |
+ for(i = 0; i < 2; ++i) { |
|
94 |
+ sum[i] /= 0x800; |
|
95 |
+ if(sum[i] > 0xf) sum[i] = 0xf; |
|
96 |
+ } |
|
97 |
+ return (sum[0] << 4) | sum[1]; |
|
98 |
+} |
... | ... |
@@ -20,8 +20,10 @@ typedef struct { |
20 | 20 |
Uint8 *addr; |
21 | 21 |
Uint32 count, advance, period, age, a, d, s, r; |
22 | 22 |
Uint16 i, len; |
23 |
- Uint8 volume_l, volume_r, pitch, repeat; |
|
23 |
+ Sint8 volume_l, volume_r; |
|
24 |
+ Uint8 pitch, repeat; |
|
24 | 25 |
} Apu; |
25 | 26 |
|
26 | 27 |
void apu_render(Apu *c, Sint16 *sample, Sint16 *end); |
27 | 28 |
void apu_start(Apu *c, Uint16 adsr, Uint8 pitch); |
29 |
+Uint8 apu_get_vu(Apu *c, Apu *end); |
... | ... |
@@ -248,7 +248,10 @@ static void |
248 | 248 |
audio_talk(Device *d, Uint8 b0, Uint8 w) |
249 | 249 |
{ |
250 | 250 |
Apu *c; |
251 |
- if(!w) return; |
|
251 |
+ if(!w) { |
|
252 |
+ if(b0 == 0xe) d->dat[0xe] = apu_get_vu(apu, apu + POLYPHONY); |
|
253 |
+ return; |
|
254 |
+ } |
|
252 | 255 |
c = &apu[d->dat[0x7] % POLYPHONY]; |
253 | 256 |
SDL_LockAudioDevice(audio_id); |
254 | 257 |
if(b0 == 0x1) c->period -= (Sint16)mempeek16(d->dat, 0x0); |