Merge branch 'main' of git.sr.ht:~rabbits/uxn
This commit is contained in:
commit
cc2b2e77b0
|
@ -46,7 +46,7 @@ tasks:
|
|||
done
|
||||
[ -e ~/.ssh/id_rsa ] || complete-build
|
||||
- build-windows: |
|
||||
if ssh -o ConnectTimeout=10 win true; then
|
||||
if false && ssh -o ConnectTimeout=10 win true; then
|
||||
ssh win "export PATH=\"\${PATH}:/mingw64/bin\"; set -ex; cd uxn; git fetch; git checkout .; git clean -xfd; git checkout $(cd uxn && git rev-parse HEAD); MSYSTEM=MSYS ./build.sh --no-run"
|
||||
rsync -rp win:uxn/bin/ build/uxn-win64/uxn/
|
||||
else
|
||||
|
|
|
@ -86,14 +86,14 @@ expect_failure 'Memory overwrite: SUB' <<'EOD'
|
|||
|2000 ADD
|
||||
|1000 SUB
|
||||
EOD
|
||||
expect_failure 'Recursion level too deep:' <<'EOD'
|
||||
%me { you }
|
||||
%you { me }
|
||||
|1000 me
|
||||
EOD
|
||||
expect_failure 'Recursion level too deep: ~asma-test/in.tal' <<'EOD'
|
||||
~asma-test/in.tal
|
||||
EOD
|
||||
# expect_failure 'Recursion level too deep:' <<'EOD'
|
||||
# %me { you }
|
||||
# %you { me }
|
||||
# |1000 me
|
||||
# EOD
|
||||
# expect_failure 'Recursion level too deep: ~asma-test/in.tal' <<'EOD'
|
||||
# ~asma-test/in.tal
|
||||
# EOD
|
||||
expect_failure 'Label not found: ;blah' <<'EOD'
|
||||
|1000 ;blah
|
||||
EOD
|
||||
|
|
|
@ -833,7 +833,6 @@
|
|||
( hex short ) ,asma-short-helper/raw JMP
|
||||
|
||||
¬-hex
|
||||
.System/rst DEI #e0 GTH ,&too-deep JCN
|
||||
;asma-trees/macros ;asma-traverse-tree JSR2 ,¬-macro JCN
|
||||
|
||||
¯o-loop
|
||||
|
@ -855,12 +854,7 @@
|
|||
;asma-msg-token ;asma/error STA2
|
||||
JMP2r
|
||||
|
||||
&too-deep
|
||||
;asma-msg-too-deep ;asma/error STA2
|
||||
JMP2r
|
||||
|
||||
@asma-include
|
||||
.System/rst DEI #e0 GTH ,asma-normal-body/too-deep JCN
|
||||
;heap LDA2
|
||||
;asma/token LDA2 ;append-heap-string JSR2
|
||||
;asma-assemble-file-pass JSR2
|
||||
|
@ -876,7 +870,6 @@
|
|||
@asma-msg-token "Unrecognised 20 "token 00
|
||||
@asma-msg-macro "Macro 20 "already 20 "exists 00
|
||||
@asma-msg-rewound "Memory 20 "overwrite 00
|
||||
@asma-msg-too-deep "Recursion 20 "level 20 "too 20 "deep 00
|
||||
@asma-msg-redefined "Label 20 "redefined 00
|
||||
|
||||
( trees )
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
#include "audio.h"
|
||||
|
||||
/*
|
||||
Copyright (c) 2021 Devine Lu Linvega
|
||||
Copyright (c) 2021 Andrew Alderwick
|
||||
Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -73,21 +72,21 @@ audio_render(int instance, Sint16 *sample, Sint16 *end)
|
|||
}
|
||||
|
||||
void
|
||||
audio_start(int instance, Device *d)
|
||||
audio_start(int instance, Uint8 *d, Uxn *u)
|
||||
{
|
||||
UxnAudio *c = &uxn_audio[instance];
|
||||
Uint16 addr, adsr;
|
||||
Uint8 pitch;
|
||||
DEVPEEK16(adsr, 0x8);
|
||||
DEVPEEK16(c->len, 0xa);
|
||||
DEVPEEK16(addr, 0xc);
|
||||
PEKDEV(adsr, 0x8);
|
||||
PEKDEV(c->len, 0xa);
|
||||
PEKDEV(addr, 0xc);
|
||||
if(c->len > 0x10000 - addr)
|
||||
c->len = 0x10000 - addr;
|
||||
c->addr = &d->u->ram[addr];
|
||||
c->volume[0] = d->dat[0xe] >> 4;
|
||||
c->volume[1] = d->dat[0xe] & 0xf;
|
||||
c->repeat = !(d->dat[0xf] & 0x80);
|
||||
pitch = d->dat[0xf] & 0x7f;
|
||||
c->addr = &u->ram[addr];
|
||||
c->volume[0] = d[0xe] >> 4;
|
||||
c->volume[1] = d[0xe] & 0xf;
|
||||
c->repeat = !(d[0xf] & 0x80);
|
||||
pitch = d[0xf] & 0x7f;
|
||||
if(pitch < 108 && c->len)
|
||||
c->advance = advances[pitch % 12] >> (8 - pitch / 12);
|
||||
else {
|
||||
|
|
|
@ -15,25 +15,8 @@ typedef signed int Sint32;
|
|||
#define SAMPLE_FREQUENCY 44100
|
||||
#define POLYPHONY 4
|
||||
|
||||
#define DEVPEEK16(o, x) \
|
||||
{ \
|
||||
(o) = (d->dat[(x)] << 8) + d->dat[(x) + 1]; \
|
||||
}
|
||||
#define DEVPOKE16(x, y) \
|
||||
{ \
|
||||
d->dat[(x)] = (y) >> 8; \
|
||||
d->dat[(x) + 1] = (y); \
|
||||
}
|
||||
|
||||
typedef struct Device {
|
||||
struct Uxn *u;
|
||||
Uint8 dat[16];
|
||||
Uint8 (*dei)(struct Device *d, Uint8);
|
||||
void (*deo)(struct Device *d, Uint8);
|
||||
} Device;
|
||||
|
||||
Uint8 audio_get_vu(int instance);
|
||||
Uint16 audio_get_position(int instance);
|
||||
int audio_render(int instance, Sint16 *sample, Sint16 *end);
|
||||
void audio_start(int instance, Device *d);
|
||||
void audio_start(int instance, Uint8 *d, Uxn *u);
|
||||
void audio_finished_handler(int instance);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "controller.h"
|
||||
|
||||
/*
|
||||
Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
|
||||
Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "datetime.h"
|
||||
|
||||
/*
|
||||
Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
|
||||
Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "file.h"
|
||||
|
||||
/*
|
||||
Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
|
||||
Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -132,7 +132,9 @@ retry_realpath(const char *file_name)
|
|||
else
|
||||
return NULL;
|
||||
}
|
||||
return strdup(r);
|
||||
x = malloc(strlen(r) + 1);
|
||||
strcpy(x, r);
|
||||
return x;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "mouse.h"
|
||||
|
||||
/*
|
||||
Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
|
||||
Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
#include "screen.h"
|
||||
|
||||
/*
|
||||
Copyright (c) 2021 Devine Lu Linvega
|
||||
Copyright (c) 2021 Andrew Alderwick
|
||||
Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "system.h"
|
||||
|
||||
/*
|
||||
Copyright (c) 2022 Devine Lu Linvega, Andrew Alderwick
|
||||
Copyright (c) 2022-2023 Devine Lu Linvega, Andrew Alderwick
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "uxn.h"
|
||||
|
||||
/*
|
||||
Copyright (u) 2022 Devine Lu Linvega, Andrew Alderwick, Andrew Richards
|
||||
Copyright (u) 2022-2023 Devine Lu Linvega, Andrew Alderwick, Andrew Richards
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
Copyright (c) 2021 Devine Lu Linvega
|
||||
Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "devices/datetime.h"
|
||||
|
||||
/*
|
||||
Copyright (c) 2021 Devine Lu Linvega
|
||||
Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
62
src/uxnemu.c
62
src/uxnemu.c
|
@ -23,7 +23,7 @@
|
|||
#pragma clang diagnostic pop
|
||||
|
||||
/*
|
||||
Copyright (c) 2021 Devine Lu Linvega
|
||||
Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -48,7 +48,6 @@ static SDL_Thread *stdin_thread;
|
|||
|
||||
/* devices */
|
||||
|
||||
static Device *devaudio0;
|
||||
static Uint8 zoom = 1;
|
||||
static Uint32 stdin_event, audio0_event;
|
||||
static Uint64 exec_deadline, deadline_interval, ms_interval;
|
||||
|
@ -82,12 +81,39 @@ console_deo(Uint8 *d, Uint8 port)
|
|||
}
|
||||
}
|
||||
|
||||
static Uint8
|
||||
audio_dei(int instance, Uint8 *d, Uint8 port)
|
||||
{
|
||||
if(!audio_id) return d[port];
|
||||
switch(port) {
|
||||
case 0x4: return audio_get_vu(instance);
|
||||
case 0x2: POKDEV(0x2, audio_get_position(instance)); /* fall through */
|
||||
default: return d[port];
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
audio_deo(int instance, Uint8 *d, Uint8 port, Uxn *u)
|
||||
{
|
||||
if(!audio_id) return;
|
||||
if(port == 0xf) {
|
||||
SDL_LockAudioDevice(audio_id);
|
||||
audio_start(instance, d, u);
|
||||
SDL_UnlockAudioDevice(audio_id);
|
||||
SDL_PauseAudioDevice(audio_id, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static Uint8
|
||||
emu_dei(Uxn *u, Uint8 addr)
|
||||
{
|
||||
Uint8 p = addr & 0x0f, d = addr & 0xf0;
|
||||
switch(d) {
|
||||
case 0x20: return screen_dei(&u->dev[d], p);
|
||||
case 0x30: return audio_dei(0, &u->dev[d], p);
|
||||
case 0x40: return audio_dei(1, &u->dev[d], p);
|
||||
case 0x50: return audio_dei(2, &u->dev[d], p);
|
||||
case 0x60: return audio_dei(3, &u->dev[d], p);
|
||||
case 0xa0: return file_dei(0, &u->dev[d], p);
|
||||
case 0xb0: return file_dei(1, &u->dev[d], p);
|
||||
case 0xc0: return datetime_dei(&u->dev[d], p);
|
||||
|
@ -109,6 +135,10 @@ emu_deo(Uxn *u, Uint8 addr, Uint8 v)
|
|||
break;
|
||||
case 0x10: console_deo(&u->dev[d], p); break;
|
||||
case 0x20: screen_deo(u->ram, &u->dev[d], p); break;
|
||||
case 0x30: audio_deo(0, &u->dev[d], p, u); break;
|
||||
case 0x40: audio_deo(1, &u->dev[d], p, u); break;
|
||||
case 0x50: audio_deo(2, &u->dev[d], p, u); break;
|
||||
case 0x60: audio_deo(3, &u->dev[d], p, u); break;
|
||||
case 0xa0: file_deo(0, u->ram, &u->dev[d], p); break;
|
||||
case 0xb0: file_deo(1, u->ram, &u->dev[d], p); break;
|
||||
}
|
||||
|
@ -227,31 +257,6 @@ init(void)
|
|||
|
||||
#pragma mark - Devices
|
||||
|
||||
static Uint8
|
||||
audio_dei(Device *d, Uint8 port)
|
||||
{
|
||||
int instance = d - devaudio0;
|
||||
if(!audio_id) return d->dat[port];
|
||||
switch(port) {
|
||||
case 0x4: return audio_get_vu(instance);
|
||||
case 0x2: DEVPOKE16(0x2, audio_get_position(instance)); /* fall through */
|
||||
default: return d->dat[port];
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
audio_deo(Device *d, Uint8 port)
|
||||
{
|
||||
int instance = d - devaudio0;
|
||||
if(!audio_id) return;
|
||||
if(port == 0xf) {
|
||||
SDL_LockAudioDevice(audio_id);
|
||||
audio_start(instance, d);
|
||||
SDL_UnlockAudioDevice(audio_id);
|
||||
SDL_PauseAudioDevice(audio_id, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Boot */
|
||||
|
||||
static int
|
||||
|
@ -379,8 +384,7 @@ handle_events(Uxn *u)
|
|||
}
|
||||
/* Audio */
|
||||
else if(event.type >= audio0_event && event.type < audio0_event + POLYPHONY) {
|
||||
/* Device *d = devaudio0 + (event.type - audio0_event);
|
||||
uxn_eval(u, GETVECTOR(d)); */
|
||||
uxn_eval(u, GETVEC(&u->dev[0x30 + 0x10 * (event.type - audio0_event)]));
|
||||
}
|
||||
/* Mouse */
|
||||
else if(event.type == SDL_MOUSEMOTION)
|
||||
|
|
Loading…
Reference in New Issue