Skip to content

Commit bf1502e

Browse files
committed
new emulator; will replace the other one eventually
1 parent 5190890 commit bf1502e

File tree

18 files changed

+12232
-0
lines changed

18 files changed

+12232
-0
lines changed

newemu/Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
INC=
2+
LIBS=-lpthread -lm -lSDL2
3+
#CFLAGS=-Wall -Wextra -g -O3
4+
#CFLAGS=-g -O3 -mcpu=cortex-a53 -mtune=cortex-a53
5+
CFLAGS=-g -Wall -Wno-parentheses
6+
7+
pdp6: main.c panel6.c pdp6.c tty.c pt.c dis340.c dc.c ut.c ge.c audio.c common.c
8+
cc $(CFLAGS) -o $@ $^ $(INC) $(LIBS)
9+
10+
run: pdp6
11+
./pdp6

newemu/args.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#ifndef USED
2+
#define USED(x) ((void)x)
3+
#endif
4+
#define SET(x) ((x)=0)
5+
6+
extern char *argv0;
7+
8+
#define ARGBEGIN for((void)(argv0||(argv0=*argv)),argv++,argc--;\
9+
argv[0] && argv[0][0]=='-' && argv[0][1];\
10+
argc--, argv++) {\
11+
char *_args, *_argt;\
12+
char _argc;\
13+
_args = &argv[0][1];\
14+
if(_args[0]=='-' && _args[1]==0){\
15+
argc--; argv++; break;\
16+
}\
17+
_argc = 0;\
18+
while(*_args && (_argc = *_args++))\
19+
switch(_argc)
20+
#define ARGEND SET(_argt);USED(_argt);USED(_argc);USED(_args);}USED(argv);USED(argc);
21+
#define ARGF() (_argt=_args, _args=(char*)"",\
22+
(*_argt? _argt: argv[1]? (argc--, *++argv): 0))
23+
#define EARGF(x) (_argt=_args, _args=(char*)"",\
24+
(*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
25+
26+
#define ARGC() _argc
27+

newemu/audio.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#include "common.h"
2+
#include "pdp6.h"
3+
4+
#include <SDL2/SDL.h>
5+
6+
static SDL_AudioDeviceID dev;
7+
static int nsamples;
8+
static u64 nexttime;
9+
10+
#define SAMPLE_TIME (1000000000/48000)
11+
12+
void
13+
initmusic(void)
14+
{
15+
SDL_AudioSpec spec;
16+
17+
SDL_Init(SDL_INIT_AUDIO);
18+
19+
memset(&spec, 0, sizeof(spec));
20+
spec.freq = 48000;
21+
spec.format = AUDIO_U8;
22+
spec.channels = 1;
23+
spec.samples = 1024; // whatever this is
24+
spec.callback = nil;
25+
dev = SDL_OpenAudioDevice(nil, 0, &spec, nil, 0);
26+
}
27+
28+
void
29+
stopmusic(void)
30+
{
31+
if(dev == 0)
32+
return;
33+
34+
SDL_PauseAudioDevice(dev, 1);
35+
SDL_ClearQueuedAudio(dev);
36+
nsamples = 0;
37+
nexttime = 0;
38+
}
39+
40+
void
41+
svc_music(PDP6 *pdp)
42+
{
43+
u8 s;
44+
45+
if(dev == 0 || nexttime >= simtime)
46+
return;
47+
48+
if(nexttime == 0)
49+
nexttime = simtime + SAMPLE_TIME;
50+
else
51+
nexttime += SAMPLE_TIME;
52+
53+
// queue up a few samples
54+
if(nsamples < 10) {
55+
nsamples++;
56+
// then start playing
57+
if(nsamples == 10)
58+
SDL_PauseAudioDevice(dev, 0);
59+
}
60+
61+
s = 0;
62+
for(int i = 0; i < 6; i++)
63+
if(pdp->mi & (1<<i))
64+
s += 40;
65+
SDL_QueueAudio(dev, &s, 1);
66+
}

0 commit comments

Comments
 (0)