Compare commits

...

3 Commits

Author SHA1 Message Date
Andrew Alderwick 8c5ab83c02 Correct compiler warnings. 2021-11-17 22:31:31 +00:00
Andrew Alderwick 80f7746c04 Fix DEI values. 2021-11-17 22:23:39 +00:00
Andrew Alderwick aecf0ee58f Fix segfault on exit.
It seems that the audio callback will keep being called after exit
unless rb->pcm_play_stop() is called again.
2021-11-17 21:22:30 +00:00
1 changed files with 13 additions and 7 deletions

View File

@ -32,7 +32,7 @@ static Uxn u;
static Ppu ppu;
static Apu apu[POLYPHONY];
static Device *devctrl, *devsystem, *devconsole, *devscreen, *devaudio0;
unsigned int palette[3];
unsigned int palette[4];
static Uint8 framebuffer[LCD_HEIGHT * LCD_WIDTH * 4];
static fb_data *lcd_fb = NULL;
char audio_buf[AUDIO_BUF_SIZE];
@ -49,6 +49,7 @@ memzero8(void *src, uint64_t n)
}
}
#if 0
/* taken from uxncli */
static void
inspect(Stack *s, char *name)
@ -64,6 +65,7 @@ inspect(Stack *s, char *name)
DEBUGF("\n");
}
}
#endif
static void
set_palette(Uint8 *addr)
@ -104,6 +106,7 @@ static Uint8 system_dei(Device *d, Uint8 port) {
switch(port) {
case 0x2: return d->u->wst.ptr; break;
case 0x3: return d->u->rst.ptr; break;
default: return d->dat[port];
}
}
@ -114,7 +117,7 @@ console_deo(Device *d, Uint8 port)
if(port == 0x1)
d->vector = peek16(d->dat, 0x0);
if(port > 0x7)
DEBUGF("%c",(char *)&d->dat[port]);
DEBUGF("%c", d->dat[port]);
}
/* taken from uxnemu */
@ -128,7 +131,6 @@ screen_dei(Device *d, Uint8 port)
case 0x5: return ppu.height; break;
default: return d->dat[port];
}
return 1;
}
static void
@ -189,9 +191,9 @@ nil_deo(Device *d, Uint8 port)
static Uint8
nil_dei(Device *d, Uint8 port)
{
(void)d;
(void)port;
return d->dat[port];
}
static Uint8
datetime_dei(Device *d, Uint8 port)
{
@ -217,6 +219,7 @@ void
apu_finished_handler(Apu *c)
{
DEBUGF("APU done\n");
(void) c;
}
void audio_callback(const void** start, size_t *size) {
@ -224,7 +227,7 @@ void audio_callback(const void** start, size_t *size) {
*start = audio_buf;
*size = AUDIO_BUF_SIZE;
memzero8(audio_buf, AUDIO_BUF_SIZE);
apu_render(&apu[0], audio_buf, audio_buf + AUDIO_BUF_SIZE);
apu_render(&apu[0], (Sint16 *)audio_buf, (Sint16 *)(audio_buf + AUDIO_BUF_SIZE));
}
static Uint8
@ -291,9 +294,10 @@ uxn_halt(Uxn *u, Uint8 error, char *name, int id)
{
rb->splash(HZ, "Halted\n");
return 0;
(void) u; (void) error; (void) name; (void) id;
}
static void run() {
static void run(void) {
while(!devsystem->dat[0xf]) {
starttick = *rb->current_tick;
uxn_eval(&u, devscreen->vector);
@ -411,6 +415,8 @@ enum plugin_status plugin_start(const void* parameter)
/* empty */ uxn_port(&u, 0xf, nil_dei, nil_deo);
uxn_eval(&u, 0x0100);
run();
rb->pcm_play_stop();
rb->pcm_set_frequency(HW_SAMPR_DEFAULT);
file_cleanup();
return PLUGIN_OK;