Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
bk-emulator
Commits
8aba04ef
Unverified
Commit
8aba04ef
authored
Jan 31, 2020
by
gameblabla
Committed by
GitHub
Jan 31, 2020
Browse files
Merge pull request #1 from phcoder/rebase
Support libretro and various fixes
parents
2a01065c
b25aea7c
Changes
51
Expand all
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
8aba04ef
...
...
@@ -47,13 +47,13 @@ UTILS = maketape readtape
#
SRCS
=
access.c boot.c branch.c conf.c covox.c double.c ea.c itab.c
\
main.c service.c ui.c scr.c timer.c tape.c disk.c mouse.c printer.c
\
main.c service.c ui.c
scr-sdl.c
scr.c timer.c tape.c disk.c mouse.c printer.c
\
single.c weird.c tty.c io.c timing.c sound.c disas.c serial.c bkplip.c
\
terakdisk.c synth.c emu2149.c
terakdisk.c synth.c emu2149.c
standalone.c sdlsound.c sdltty.c joystick.c
OBJS
=
access.o boot.o branch.o conf.o covox.o double.o ea.o itab.o icon.o
\
main.o service.o ui.o scr.o timer.o tape.o disk.o mouse.o printer.o
\
main.o service.o ui.o
scr-sdl.o
scr.o timer.o tape.o disk.o mouse.o printer.o
\
single.o weird.o tty.o io.o timing.o sound.o disas.o serial.o bkplip.o
\
terakdisk.o synth.o emu2149.o
terakdisk.o synth.o emu2149.o
standalone.o sdlsound.o sdltty.o joystick.o
INCS
=
defines.h scr.h conf.h emu2149.h emutypes.h
USRCS
=
readtape.c maketape.c pngtorgba.c
TEXTS
=
README.html configure.in icon.c
...
...
Makefile.common
0 → 100644
View file @
8aba04ef
CFLAGS
+=
-Wall
-Wno-switch
-Wno-parentheses
-Wno-format
-Wno-unused-variable
-Wno-unused-but-set-variable
-Wextra
-Wno-unused-parameter
-Wno-sign-compare
-Wmissing-prototypes
SOURCES_C
:=
$(CORE_DIR)
/access.c
$(CORE_DIR)
/boot.c
$(CORE_DIR)
/branch.c
\
$(CORE_DIR)
/covox.c
$(CORE_DIR)
/double.c
$(CORE_DIR)
/ea.c
\
$(CORE_DIR)
/itab.c
\
$(CORE_DIR)
/libretro.c
$(CORE_DIR)
/service.c
$(CORE_DIR)
/timer.c
\
$(CORE_DIR)
/tape.c
$(CORE_DIR)
/disk.c
$(CORE_DIR)
/mouse.c
\
$(CORE_DIR)
/printer.c
\
$(CORE_DIR)
/single.c
$(CORE_DIR)
/weird.c
$(CORE_DIR)
/tty.c
\
$(CORE_DIR)
/io.c
\
$(CORE_DIR)
/timing.c
$(CORE_DIR)
/sound.c
$(CORE_DIR)
/disas.c
\
$(CORE_DIR)
/serial.c
$(CORE_DIR)
/bkplip.c
\
$(CORE_DIR)
/terakdisk.c
$(CORE_DIR)
/synth.c
$(CORE_DIR)
/emu2149.c
\
$(CORE_DIR)
/main.c
$(CORE_DIR)
/scr-libretro.c
$(CORE_DIR)
/scr.c
\
$(CORE_DIR)
/tty-libretro.c
$(CORE_DIR)
/joystick.c
Makefile.libretro
0 → 100644
View file @
8aba04ef
This diff is collapsed.
Click to expand it.
access.c
View file @
8aba04ef
...
...
@@ -21,18 +21,7 @@
#include "defines.h"
#include <libintl.h>
#define _(String) gettext (String)
/*
* BK-0011 has 8 8Kw RAM pages and 4 8 Kw ROM pages.
* RAM pages 1 and 7 are video RAM.
*/
d_word
ram
[
8
][
8192
];
d_word
rom
[
4
][
8192
];
d_word
system_rom
[
8192
];
unsigned
char
umr
[
65536
];
#include "intl.h"
/*
* Page mapping, per 8 Kw page. Default is a mapping mimicking BK-0010
*/
...
...
@@ -40,21 +29,14 @@ d_word * pagemap[4] = { ram[6], ram[1], rom[0], system_rom };
#define mem(x) pagemap[(x)>>14][((x) & 037777) >> 1]
/*
* Each bit corresponds to a Kword,
* the lowest 8 Kwords are RAM, the next 8 are screen memory,
* the rest is usually ROM.
*/
unsigned
long
pdp_ram_map
=
0x0000ffff
;
unsigned
long
pdp_mem_map
;
#define IS_RAM_ADDRESS(x) ((pdp_ram_map >> ((x) >> 11)) & 1)
#define IS_VALID_ADDRESS(x) ((pdp_mem_map >> ((x) >> 11)) & 1)
/*
* The QBUS memory map.
*/
int
q_null
(),
q_err
(
c_addr
,
d_word
),
q_errb
(
c_addr
,
d_byte
),
static
void
q_null
();
int
q_err
(
c_addr
,
d_word
),
q_errb
(
c_addr
,
d_byte
),
port_read
(
c_addr
,
d_word
*
),
port_write
(
c_addr
,
d_word
),
port_bwrite
(
c_addr
,
d_byte
);
int
secret_read
(
c_addr
,
d_word
*
),
secret_write
(
c_addr
,
d_word
),
secret_bwrite
(
c_addr
,
d_byte
);
int
force_read
(
c_addr
,
d_word
*
),
terak_read
(
c_addr
,
d_word
*
);
...
...
@@ -62,7 +44,7 @@ int force_read( c_addr, d_word*), terak_read(c_addr, d_word*);
typedef
struct
{
c_addr
start
;
c_addr
size
;
int
(
*
ifunc
)();
void
(
*
ifunc
)();
int
(
*
rfunc
)(
c_addr
,
d_word
*
);
int
(
*
wfunc
)(
c_addr
,
d_word
);
int
(
*
bwfunc
)(
c_addr
,
d_byte
);
...
...
@@ -87,7 +69,7 @@ pdp_qmap qmap_bk[] = {
{
0
,
0
,
0
,
0
,
0
,
0
}
};
tcons_read
(
c_addr
a
,
d_word
*
d
)
{
int
tcons_read
(
c_addr
a
,
d_word
*
d
)
{
switch
(
a
&
077
)
{
case
064
:
*
d
=
0200
;
...
...
@@ -100,7 +82,7 @@ tcons_read(c_addr a, d_word *d) {
return
OK
;
}
tcons_write
(
c_addr
a
,
d_word
d
)
{
int
tcons_write
(
c_addr
a
,
d_word
d
)
{
switch
(
a
&
077
)
{
case
064
:
fprintf
(
stderr
,
"Writing %06o: %06o
\n
"
,
a
,
d
);
...
...
@@ -116,11 +98,15 @@ tcons_write(c_addr a, d_word d) {
return
OK
;
}
int
tcons_writeb
(
c_addr
a
,
unsigned
char
d
)
{
return
tcons_write
(
a
,
d
);
}
pdp_qmap
qmap_terak
[]
=
{
{
TERAK_DISK_REG
,
TERAK_DISK_SIZE
,
tdisk_init
,
tdisk_read
,
tdisk_write
,
tdisk_bwrite
},
{
0177564
,
4
,
q_null
,
tcons_read
,
tcons_write
,
tcons_write
},
{
0177764
,
4
,
q_null
,
tcons_read
,
tcons_write
,
tcons_write
},
{
0177564
,
4
,
q_null
,
tcons_read
,
tcons_write
,
tcons_write
b
},
{
0177764
,
4
,
q_null
,
tcons_read
,
tcons_write
,
tcons_write
b
},
{
0177744
,
2
,
q_null
,
port_read
,
port_write
,
port_bwrite
},
{
0177560
,
2
,
q_null
,
port_read
,
port_write
,
port_bwrite
},
{
0173000
,
0200
,
q_null
,
terak_read
,
q_err
,
q_errb
},
...
...
@@ -148,6 +134,12 @@ pdp_qmap q_synth = {
pdp_qmap
q_bkplip
=
{
PORT_REG
,
PORT_SIZE
,
bkplip_init
,
bkplip_read
,
bkplip_write
,
bkplip_bwrite
};
pdp_qmap
q_joystick
=
{
PORT_REG
,
PORT_SIZE
,
joystick_init
,
joystick_read
,
joystick_write
,
joystick_bwrite
};
void
plug_joystick
()
{
qmap
[
0
]
=
q_joystick
;
}
void
plug_printer
()
{
qmap
[
0
]
=
q_printer
;
}
void
plug_mouse
()
{
qmap
[
0
]
=
q_mouse
;
}
void
plug_covox
()
{
qmap
[
0
]
=
q_covox
;
}
...
...
@@ -171,7 +163,7 @@ int port_bwrite(c_addr a, d_byte d) {
return
OK
;
/* goes nowhere */
}
secret_read
(
addr
,
word
)
int
secret_read
(
addr
,
word
)
c_addr
addr
;
d_word
*
word
;
{
...
...
@@ -208,9 +200,7 @@ int secret_bwrite(c_addr a, d_byte d) {
*/
int
lc_word
(
addr
,
word
)
c_addr
addr
;
d_word
*
word
;
lc_word
(
c_addr
addr
,
d_word
*
word
)
{
int
i
;
...
...
@@ -329,11 +319,7 @@ void pagereg_bwrite(d_byte byte) {
* sc_word() - Store a word at the given core address.
*/
int
sc_word
(
addr
,
word
)
c_addr
addr
;
d_word
word
;
{
int
sc_word
(
c_addr
addr
,
d_word
word
)
{
int
i
;
addr
&=
~
1
;
...
...
@@ -365,10 +351,7 @@ d_word word;
*/
int
ll_byte
(
p
,
baddr
,
byte
)
register
pdp_regs
*
p
;
d_word
baddr
;
d_byte
*
byte
;
ll_byte
(
register
pdp_regs
*
p
,
d_word
baddr
,
d_byte
*
byte
)
{
d_word
word
;
d_word
laddr
;
...
...
@@ -405,10 +388,7 @@ d_byte *byte;
*/
int
sl_byte
(
p
,
laddr
,
byte
)
register
pdp_regs
*
p
;
d_word
laddr
;
d_byte
byte
;
sl_byte
(
register
pdp_regs
*
p
,
d_word
laddr
,
d_byte
byte
)
{
d_word
t
;
int
i
;
...
...
@@ -443,7 +423,7 @@ d_byte byte;
* mem_init() - Initialize the memory.
*/
mem_init
()
void
mem_init
()
{
int
x
;
if
(
terak
)
{
...
...
@@ -500,9 +480,8 @@ mem_init()
* q_null() - Null QBUS device switch handler.
*/
int
q_null
()
static
void
q_null
()
{
return
OK
;
}
/*
...
...
@@ -525,7 +504,7 @@ int q_errb(c_addr x, d_byte y)
* q_reset() - Reset the UNIBUS devices.
*/
q_reset
()
void
q_reset
()
{
int
i
;
...
...
@@ -534,3 +513,13 @@ q_reset()
}
}
unsigned
short
*
get_vram_line
(
int
bufno
,
int
line
)
{
int
i
;
for
(
i
=
0
;
i
<
4
;
i
++
)
if
(
video_map
[
i
]
==
bufno
+
1
)
break
;
if
(
i
==
4
)
i
=
1
;
return
&
pagemap
[
i
][
line
<<
5
];
}
bkplip.c
View file @
8aba04ef
...
...
@@ -2,8 +2,7 @@
#include <fcntl.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <libintl.h>
#define _(String) gettext (String)
#include "intl.h"
#include <fcntl.h>
#include <stdlib.h>
...
...
@@ -33,9 +32,9 @@ static unsigned lasttime;
* to receive 16 bit; that is, from PC to BK a whole byte can
* be sent at once.
*/
bkplip_init
()
{
void
bkplip_init
()
{
#ifdef linux
if
(
fd
!=
-
1
)
return
OK
;
if
(
fd
!=
-
1
)
return
;
fd
=
open
(
DEVTAP
,
O_RDWR
);
if
(
fd
==
-
1
)
{
...
...
@@ -55,19 +54,17 @@ bkplip_init() {
lasttime
=
0
;
#endif
return
OK
;
}
static
int
len_left
=
0
;
static
int
curbyte
=
0
;
static
flag_t
nibble
=
0
;
static
int
txlen
=
0
,
txbyte
=
0
;
/*
* When no data is present, returns 0.
* If a packet is present, returns its length (a word) with bit 15 set,
* then its contents (N bytes). Each read returns a new byte, no strobing yet.
*/
bkplip_read
(
addr
,
word
)
int
bkplip_read
(
addr
,
word
)
c_addr
addr
;
d_word
*
word
;
{
...
...
@@ -111,7 +108,7 @@ d_word *word;
* Expects a packet length (a word) with bit 15 set,
* then N bytes. Each write transmits a byte, no strobing yet.
*/
bkplip_write
(
addr
,
word
)
int
bkplip_write
(
addr
,
word
)
c_addr
addr
;
d_word
word
;
{
...
...
@@ -142,7 +139,7 @@ d_word word;
return
OK
;
}
bkplip_bwrite
(
c_addr
addr
,
d_byte
byte
)
{
int
bkplip_bwrite
(
c_addr
addr
,
d_byte
byte
)
{
d_word
offset
=
addr
&
1
;
d_word
word
;
bkplip_read
(
addr
&
~
1
,
&
word
);
...
...
boot.c
View file @
8aba04ef
...
...
@@ -28,18 +28,16 @@
*/
#include "defines.h"
#include <libintl.h>
#define _(String) gettext (String)
#include "intl.h"
/*
* load_rom() - Read the contents of the ROM into the array.
* Used for BK-0010 style ROM - stores into the mapped memory.
*/
void
load_rom
(
unsigned
start
,
char
*
rompath
,
unsigned
min_size
,
unsigned
max_size
)
{
void
load_rom
(
unsigned
start
,
const
char
*
rompath
,
unsigned
min_size
,
unsigned
max_size
)
{
char
*
path
;
int
i
;
extern
unsigned
long
pdp_ram_map
;
unsigned
long
saved_ram_map
=
pdp_ram_map
;
FILE
*
romf
;
...
...
@@ -83,7 +81,7 @@ void load_rom(unsigned start, char * rompath, unsigned min_size, unsigned max_si
/*
* Loads BK-0011 ROM into the givem ROM block from a given offset.
*/
void
load_rom11
(
d_word
*
rom
,
int
byte_off
,
char
*
rompath
,
int
byte_size
)
{
void
load_rom11
(
d_word
*
rom
buf
,
int
byte_off
,
const
char
*
rompath
,
int
byte_size
)
{
char
*
path
;
int
i
;
...
...
@@ -105,14 +103,14 @@ void load_rom11(d_word * rom, int byte_off, char * rompath, int byte_size) {
fprintf
(
stderr
,
_
(
"Couldn't open file.
\n
"
));
exit
(
1
);
}
rom
+=
byte_off
/
2
;
for
(
i
=
0
;
i
<
byte_size
/
2
;
i
++
,
rom
++
)
{
rom
buf
+=
byte_off
/
2
;
for
(
i
=
0
;
i
<
byte_size
/
2
;
i
++
,
rom
buf
++
)
{
int
lobyte
=
getc
(
romf
);
int
hibyte
=
getc
(
romf
);
d_word
data
;
if
(
hibyte
<
0
)
break
;
data
=
lobyte
|
hibyte
<<
8
;
*
rom
=
data
;
*
rom
buf
=
data
;
}
if
(
i
<
byte_size
/
2
)
{
fprintf
(
stderr
,
_
(
"Incomplete or damaged file.
\n
"
));
...
...
@@ -123,7 +121,7 @@ void load_rom11(d_word * rom, int byte_off, char * rompath, int byte_size) {
fprintf
(
stderr
,
_
(
"Done.
\n
"
));
}
int
void
boot_init
()
{
static
unsigned
char
boot_done
=
0
;
...
...
branch.c
View file @
8aba04ef
...
...
@@ -29,17 +29,14 @@
#include "defines.h"
#include "ops.h"
/*
* brx() - Simple Branch Instructions.
*/
int
brx
(
p
,
clear
,
set
)
register
pdp_regs
*
p
;
unsigned
clear
;
unsigned
set
;
brx
(
register
pdp_regs
*
p
,
unsigned
clear
,
unsigned
set
)
{
d_word
offset
;
...
...
conf.h
View file @
8aba04ef
...
...
@@ -6,12 +6,11 @@
#include "defines.h"
extern
c
har
*
monitor10rom
;
extern
c
onst
char
*
const
monitor10rom
;
extern
int
upper_porch
;
extern
int
lower_porch
;
extern
int
io_sound_freq
;
extern
char
*
floppyA
;
extern
char
*
floppyB
;
extern
char
*
floppyC
;
extern
char
*
floppyD
;
extern
flag_t
fake_tape
,
fake_disk
,
telegraph_enabled
,
fullscreen
;
extern
unsigned
io_sound_freq
;
extern
flag_t
fake_tape
,
telegraph_enabled
,
fullscreen
;
extern
flag_t
traceflag
;
extern
FILE
*
tracefile
;
extern
const
char
*
floppyA
,
*
floppyB
,
*
floppyC
,
*
floppyD
;
covox.c
View file @
8aba04ef
...
...
@@ -2,33 +2,28 @@
#include <fcntl.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <libintl.h>
#define _(String) gettext (String)
#include "intl.h"
unsigned
char
covox_val
;
unsigned
int
covox_age
;
covox_init
()
{
void
covox_init
()
{
covox_val
=
0
;
covox_age
=
~
0
;
}
covox_read
(
c_addr
addr
,
d_word
*
word
)
int
covox_read
(
c_addr
addr
,
d_word
*
word
)
{
*
word
=
0
;
/* pulldown */
return
OK
;
}
covox_write
(
c_addr
addr
,
d_word
word
)
int
covox_write
(
c_addr
addr
,
d_word
word
)
{
covox_val
=
word
&
0xFF
;
covox_age
=
0
;
return
OK
;
}
covox_bwrite
(
c_addr
addr
,
d_byte
byte
)
{
int
covox_bwrite
(
c_addr
addr
,
d_byte
byte
)
{
d_word
offset
=
addr
&
1
;
d_word
word
;
if
(
offset
==
0
)
{
covox_val
=
byte
;
}
else
{
...
...
defines.h
View file @
8aba04ef
...
...
@@ -63,6 +63,27 @@ typedef unsigned short d_word; /* data word (16 bit) */
typedef
unsigned
char
d_byte
;
/* data byte (8 bit) */
typedef
unsigned
char
flag_t
;
/* for boolean or small value flags */
void
plug_joystick
(
void
);
void
plug_printer
(
void
);
void
plug_mouse
(
void
);
void
plug_covox
(
void
);
void
plug_synth
(
void
);
void
plug_bkplip
(
void
);
void
tty_keyevent
(
int
c
);
void
fake_disk_io
(
void
);
void
fake_sector_io
(
void
);
c_addr
disas
(
c_addr
a
,
char
*
dest
);
void
fake_tuneup_sequence
(
void
);
void
fake_array_with_tuneup
(
void
);
void
fake_read_strobe
(
void
);
void
fake_write_file
(
void
);
void
sound_discard
(
void
);
void
sound_semwait
(
void
);
void
platform_sound_init
(
void
);
void
sound_write_sample
(
short
val
);
void
sound_flush
(
void
);
void
platform_sound_flush
(
void
);
/*
* PDP processor defines.
*/
...
...
@@ -81,9 +102,12 @@ typedef struct _pdp_regs {
unsigned
look_time
;
/* when to handle things, saves time */
}
pdp_regs
;
extern
unsigned
int
hasexit
;
void
timing
(
register
pdp_regs
*
p
);
int
lc_word
(
c_addr
addr
,
d_word
*
word
);
int
sc_word
(
c_addr
addr
,
d_word
word
);
int
load_src
(
register
pdp_regs
*
p
,
d_word
*
data
);
/*
* Definitions for the memory map and memory operations.
*/
...
...
@@ -132,25 +156,43 @@ extern unsigned int hasexit;
#define PDP_READABLE_MEM_SIZE (63 * 512)
/* 0 - 175777 */
#define PDP_FULL_MEM_SIZE (64 * 512)
/* 0 - 177777 */
extern
d_word
rom
[
4
][
8192
],
ram
[
8
][
8192
],
system_rom
[
8192
];
extern
int
boot_init
(),
boot_read
(),
boot_write
(
c_addr
,
d_word
),
boot_bwrite
(
c_addr
,
d_byte
);
extern
int
scr_init
(),
scr_write
(
int
,
c_addr
,
d_word
),
scr_switch
(
int
,
int
);
extern
int
tty_init
(),
tty_read
(),
tty_write
(
c_addr
,
d_word
),
tty_bwrite
(
c_addr
,
d_byte
);
extern
int
io_init
(),
io_read
(),
io_write
(
c_addr
,
d_word
),
io_bwrite
(
c_addr
,
d_byte
);
extern
int
disk_init
(),
disk_read
(),
disk_write
(
c_addr
,
d_word
),
disk_bwrite
(
c_addr
,
d_byte
);
extern
int
tdisk_init
(),
tdisk_read
(),
tdisk_write
(
c_addr
,
d_word
),
tdisk_bwrite
(
c_addr
,
d_byte
);
extern
void
disk_finish
();
extern
void
tdisk_finish
();
extern
void
io_read_start
();
extern
int
timer_init
(),
timer_read
(),
timer_write
(
c_addr
,
d_word
),
timer_bwrite
(
c_addr
,
d_byte
);
extern
int
line_init
(),
line_read
(),
line_write
(
c_addr
,
d_word
),
line_bwrite
(
c_addr
,
d_byte
);
extern
int
printer_init
(),
printer_read
(),
printer_write
(
c_addr
,
d_word
),
printer_bwrite
(
c_addr
,
d_byte
);
extern
int
mouse_init
(),
mouse_read
(),
mouse_write
(
c_addr
,
d_word
),
mouse_bwrite
(
c_addr
,
d_byte
);
extern
int
covox_init
(),
covox_read
(),
covox_write
(
c_addr
,
d_word
),
covox_bwrite
(
c_addr
,
d_byte
);
extern
int
synth_init
(),
synth_read
(),
synth_write
(
c_addr
,
d_word
),
synth_bwrite
(
c_addr
,
d_byte
),
synth_next
(
void
);
extern
int
bkplip_init
(),
bkplip_read
(),
bkplip_write
(
c_addr
,
d_word
),
bkplip_bwrite
(
c_addr
,
d_byte
);
extern
void
line_init
(
void
);
void
bk_scr_init
(
void
);
void
boot_init
(
void
);
void
timer_init
(
void
);
void
printer_init
(
void
);
void
covox_init
(
void
);
void
synth_init
(
void
);
void
mouse_init
(
void
);
void
tty_init
(
void
);
void
bkplip_init
(
void
);
void
io_init
(
void
);
void
disk_init
(
void
);
void
tdisk_init
(
void
);
extern
int
boot_read
(
void
),
boot_write
(
c_addr
,
d_word
),
boot_bwrite
(
c_addr
,
d_byte
);
extern
int
scr_write
(
int
,
c_addr
,
d_word
),
scr_switch
(
int
,
int
);
extern
int
tty_read
(
c_addr
addr
,
d_word
*
word
);
extern
int
tty_write
(
c_addr
,
d_word
),
tty_bwrite
(
c_addr
,
d_byte
);
extern
int
io_read
(
c_addr
addr
,
d_word
*
word
),
io_write
(
c_addr
,
d_word
),
io_bwrite
(
c_addr
,
d_byte
);
extern
int
disk_read
(
c_addr
addr
,
d_word
*
word
),
disk_write
(
c_addr
,
d_word
),
disk_bwrite
(
c_addr
,
d_byte
);
extern
int
tdisk_read
(
c_addr
addr
,
d_word
*
word
),
tdisk_write
(
c_addr
,
d_word
),
tdisk_bwrite
(
c_addr
,
d_byte
);
extern
void
disk_finish
(
void
);
extern
void
tdisk_finish
(
void
);
extern
void
io_read_start
(
void
);
extern
int
timer_read
(
c_addr
addr
,
d_word
*
word
);
extern
int
timer_write
(
c_addr
,
d_word
),
timer_bwrite
(
c_addr
,
d_byte
);
extern
int
line_read
(
c_addr
addr
,
d_word
*
word
),
line_write
(
c_addr
,
d_word
),
line_bwrite
(
c_addr
,
d_byte
);
extern
int
printer_read
(
c_addr
addr
,
d_word
*
word
),
printer_write
(
c_addr
,
d_word
),
printer_bwrite
(
c_addr
,
d_byte
);
extern
int
mouse_read
(
c_addr
addr
,
d_word
*
word
),
mouse_write
(
c_addr
,
d_word
),
mouse_bwrite
(
c_addr
,
d_byte
);
extern
int
covox_read
(
c_addr
addr
,
d_word
*
word
);
extern
int
covox_write
(
c_addr
,
d_word
),
covox_bwrite
(
c_addr
,
d_byte
);
extern
int
synth_read
(
c_addr
addr
,
d_word
*
word
),
synth_write
(
c_addr
,
d_word
),
synth_bwrite
(
c_addr
,
d_byte
),
synth_next
(
void
);
extern
int
bkplip_read
(
c_addr
addr
,
d_word
*
word
),
bkplip_write
(
c_addr
,
d_word
),
bkplip_bwrite
(
c_addr
,
d_byte
);
extern
int
service
(
d_word
);
unsigned
short
*
get_vram_line
(
int
bufno
,
int
line
);
void
tape_read_start
(
void
);
void
tape_read_finish
(
void
);
/*
* Defines for the event handling system.
*/
...
...
@@ -162,7 +204,7 @@ extern int service(d_word);
#define TTY_PRI 1
typedef
struct
_event
{
int
(
*
handler
)();
/* handler function */
int
(
*
handler
)(
d_word
);
/* handler function */
d_word
info
;
/* info or vector number */
double
when
;
/* when to fire this event */
}
event
;
...
...
@@ -172,38 +214,138 @@ typedef struct _event {
* Instruction Table for Fast Decode.
*/
struct
_itab
{
int
(
*
func
)();
};
typedef
int
(
*
_itab_t
)();
/*
* Global variables.
*/
extern
struct
timeval
real_time
;
extern
int
ui_done
;
extern
unsigned
short
last_branch
;
extern
pdp_regs
pdp
;
extern
event
*
event_list
[
NUM_PRI
];
extern
char
*
printer_file
;
struct
bk_state
{
int
ui_done
;
unsigned
short
_last_branch
;
pdp_regs
_pdp
;
/* internal processor registers */
int
_TICK_RATE
;
unsigned
short
_tty_scroll
;
flag_t
_key_pressed
;
flag_t
_fake_disk
;
/* 1 if interrupt requested while WAIT was in effect */
flag_t
_in_wait_instr
;
unsigned
io_sound_val
;
flag_t
_io_stop_happened
;
int
io_tape_mode
,
io_tape_val
,
io_tape_bit
;
flag_t
_nflag
;
/* audio flag */
flag_t
_mouseflag
;
/* mouse flag */
flag_t
_fullspeed
;
/* do not slow down to real BK speed */
flag_t
_tapeflag
;
/* Disable reading from tape */
double
_frame_delay
;
/* Delay in ticks between video frames */
double
_half_frame_delay
;
flag_t
_cflag
,
_bkmodel
,
_terak
;
long
long
_ticks_timer
;
long
long
_ticks
,
io_tape_ticks
;
/* in main clock freq, integral */
long
long
_tape_read_ticks
,
_tape_write_ticks
;
flag_t
_timer_intr_enabled
;
volatile
int
_stop_it
;
/* set when a SIGINT happens during execution */
/*
* BK-0011 has 8 8Kw RAM pages and 4 8 Kw ROM pages.
* RAM pages 1 and 7 are video RAM.
*/
d_word
_ram
[
8
][
8192
];
d_word
_rom
[
4
][
8192
];
d_word
_system_rom
[
8192
];
unsigned
char
_umr
[
65536
];
/*
* Each bit corresponds to a Kword,
* the lowest 8 Kwords are RAM, the next 8 are screen memory,
* the rest is usually ROM.
*/
unsigned
long
_pdp_ram_map
;
unsigned
long
_pdp_mem_map
;
d_word
_timer_count
,
_timer_setup
,
_timer_control
;
long
long
_ticks_start
;
unsigned
int
_timer_period
;
long
long
_framectr
;
long
long
_soundctr
;
unsigned
_scan_line_duration
;
unsigned
char
_covox_val
;
unsigned
int
_covox_age
;
unsigned
_io_sound_val
;
unsigned
_io_max_sound_age
;
unsigned
_io_sound_age
;
/* in io_sound_pace's since last change */
double
_io_sound_pace
;
double
_io_sound_count
;
};
extern
const
char
*
printer_file
;
extern
const
char
*
rompath10
,
*
rompath12
,
*
rompath16
;
extern
const
char
*
const
bos11rom
,
*
const
diskrom
,
*
const
bos11extrom
;
extern
const
char
*
const
basic11arom
,
*
const
basic11brom
;
extern
struct
bk_state
current_state
;
extern
flag_t
traceflag
;
/* print all instruction addresses */
extern
FILE
*
tracefile
;
/* trace goes here */
extern
char
*
romdir
;
extern
char
*
rompath10
,
*
rompath12
,
*
rompath16
;
extern
char
*
bos11rom
,
*
diskrom
,
*
bos11extrom
,
*
basic11arom
,
*
basic11brom
;
extern
int
TICK_RATE
;