Audio.pitch MSB must be 1 to use current synth
This commit is contained in:
parent
2ea85815f6
commit
43cde08b68
|
@ -120,7 +120,7 @@ BRK
|
||||||
|
|
||||||
@play ( pitch -- )
|
@play ( pitch -- )
|
||||||
|
|
||||||
=Audio.pitch
|
#80 ORA =Audio.pitch
|
||||||
,triangle-wave =Audio.wave
|
,triangle-wave =Audio.wave
|
||||||
~track.active =Audio.play
|
~track.active =Audio.play
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ BRK
|
||||||
DUP #ff NEQ ^$skip1 JNZ
|
DUP #ff NEQ ^$skip1 JNZ
|
||||||
POP ^$listen2 JMP
|
POP ^$listen2 JMP
|
||||||
$skip1
|
$skip1
|
||||||
#00 SWP ,notes ADD2 PEK2 =Audio.pitch
|
#00 SWP ,notes ADD2 PEK2 #80 ORA =Audio.pitch
|
||||||
~volume.ch1 =Audio.volume
|
~volume.ch1 =Audio.volume
|
||||||
,square-wave =Audio.wave
|
,square-wave =Audio.wave
|
||||||
#00 =Audio.play
|
#00 =Audio.play
|
||||||
|
@ -200,7 +200,7 @@ BRK
|
||||||
DUP #ff NEQ ^$skip2 JNZ
|
DUP #ff NEQ ^$skip2 JNZ
|
||||||
POP ^$listen3 JMP
|
POP ^$listen3 JMP
|
||||||
$skip2
|
$skip2
|
||||||
#00 SWP ,notes ADD2 PEK2 =Audio.pitch
|
#00 SWP ,notes ADD2 PEK2 #80 ORA =Audio.pitch
|
||||||
~volume.ch2 =Audio.volume
|
~volume.ch2 =Audio.volume
|
||||||
,square-wave =Audio.wave
|
,square-wave =Audio.wave
|
||||||
#01 =Audio.play
|
#01 =Audio.play
|
||||||
|
@ -210,7 +210,7 @@ BRK
|
||||||
DUP #ff NEQ ^$skip3 JNZ
|
DUP #ff NEQ ^$skip3 JNZ
|
||||||
POP ^$end JMP
|
POP ^$end JMP
|
||||||
$skip3
|
$skip3
|
||||||
#00 SWP ,notes ADD2 PEK2 =Audio.pitch
|
#00 SWP ,notes ADD2 PEK2 #80 ORA =Audio.pitch
|
||||||
~volume.ch3 =Audio.volume
|
~volume.ch3 =Audio.volume
|
||||||
,triangle-wave =Audio.wave
|
,triangle-wave =Audio.wave
|
||||||
#02 =Audio.play
|
#02 =Audio.play
|
||||||
|
|
|
@ -78,10 +78,12 @@ apu_render(Apu *apu, Uxn *u, Sint16 *samples, int n_samples)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
apu_play_note(Note *note, Uint16 wave_vector, Uint16 envelope_vector, Uint8 volume, Uint8 pitch)
|
apu_play_note(Note *note, Uint16 wave_vector, Uint16 envelope_vector, Uint8 volume, Uint8 pitch, Uint8 impl)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
if(pitch >= 108 || impl == 0) return;
|
||||||
note->playing = 1;
|
note->playing = 1;
|
||||||
|
note->impl = impl;
|
||||||
for(i = 0; i < 2; ++i) {
|
for(i = 0; i < 2; ++i) {
|
||||||
note->volume[i] = 0xf & (volume >> 4 * (1 - i));
|
note->volume[i] = 0xf & (volume >> 4 * (1 - i));
|
||||||
note->wv[i].count = note->wv[i].period = 0;
|
note->wv[i].count = note->wv[i].period = 0;
|
||||||
|
|
|
@ -29,7 +29,8 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
WaveformGenerator wv[2];
|
WaveformGenerator wv[2];
|
||||||
Sint8 volume[2], playing;
|
Sint8 volume[2];
|
||||||
|
Uint8 playing, impl;
|
||||||
} Note;
|
} Note;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -40,4 +41,4 @@ typedef struct {
|
||||||
} Apu;
|
} Apu;
|
||||||
|
|
||||||
void apu_render(Apu *apu, Uxn *u, Sint16 *samples, int n_samples);
|
void apu_render(Apu *apu, Uxn *u, Sint16 *samples, int n_samples);
|
||||||
void apu_play_note(Note *note, Uint16 wave_vector, Uint16 envelope_vector, Uint8 volume, Uint8 pitch);
|
void apu_play_note(Note *note, Uint16 wave_vector, Uint16 envelope_vector, Uint8 volume, Uint8 pitch, Uint8 impl);
|
||||||
|
|
|
@ -247,7 +247,7 @@ audio_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1)
|
||||||
if(b0 == 0xa) {
|
if(b0 == 0xa) {
|
||||||
if(b1 >= apu.n_notes) apu.notes = SDL_realloc(apu.notes, (b1 + 1) * sizeof(Note));
|
if(b1 >= apu.n_notes) apu.notes = SDL_realloc(apu.notes, (b1 + 1) * sizeof(Note));
|
||||||
while(b1 >= apu.n_notes) SDL_zero(apu.notes[apu.n_notes++]);
|
while(b1 >= apu.n_notes) SDL_zero(apu.notes[apu.n_notes++]);
|
||||||
apu_play_note(&apu.notes[b1], (m[0x0] << 8) + m[0x1], (m[0x2] << 8) + m[0x3], m[0x8], m[0x9]);
|
apu_play_note(&apu.notes[b1], (m[0x0] << 8) + m[0x1], (m[0x2] << 8) + m[0x3], m[0x8], m[0x9] & 0x7f, m[0x9] > 0x7f);
|
||||||
} else if(b0 == 0xe && apu.queue != NULL) {
|
} else if(b0 == 0xe && apu.queue != NULL) {
|
||||||
if(apu.queue->n == apu.queue->sz) {
|
if(apu.queue->n == apu.queue->sz) {
|
||||||
apu.queue->sz = apu.queue->sz < 4 ? 4 : apu.queue->sz * 2;
|
apu.queue->sz = apu.queue->sz < 4 ? 4 : apu.queue->sz * 2;
|
||||||
|
|
Loading…
Reference in New Issue