Unverified Commit 8aba04ef authored by gameblabla's avatar gameblabla Committed by GitHub
Browse files

Merge pull request #1 from phcoder/rebase

Support libretro and various fixes
parents 2a01065c b25aea7c
...@@ -47,13 +47,13 @@ UTILS = maketape readtape ...@@ -47,13 +47,13 @@ UTILS = maketape readtape
# #
SRCS = access.c boot.c branch.c conf.c covox.c double.c ea.c itab.c \ 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 \ 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 \ 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 \ 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 INCS = defines.h scr.h conf.h emu2149.h emutypes.h
USRCS = readtape.c maketape.c pngtorgba.c USRCS = readtape.c maketape.c pngtorgba.c
TEXTS = README.html configure.in icon.c TEXTS = README.html configure.in icon.c
......
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
This diff is collapsed.
...@@ -21,18 +21,7 @@ ...@@ -21,18 +21,7 @@
#include "defines.h" #include "defines.h"
#include <libintl.h> #include "intl.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];
/* /*
* Page mapping, per 8 Kw page. Default is a mapping mimicking BK-0010 * 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 }; ...@@ -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] #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_RAM_ADDRESS(x) ((pdp_ram_map >> ((x) >> 11)) & 1)
#define IS_VALID_ADDRESS(x) ((pdp_mem_map >> ((x) >> 11)) & 1) #define IS_VALID_ADDRESS(x) ((pdp_mem_map >> ((x) >> 11)) & 1)
/* /*
* The QBUS memory map. * 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); 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 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*); 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*); ...@@ -62,7 +44,7 @@ int force_read( c_addr, d_word*), terak_read(c_addr, d_word*);
typedef struct { typedef struct {
c_addr start; c_addr start;
c_addr size; c_addr size;
int (*ifunc)(); void (*ifunc)();
int (*rfunc)(c_addr, d_word*); int (*rfunc)(c_addr, d_word*);
int (*wfunc)(c_addr, d_word); int (*wfunc)(c_addr, d_word);
int (*bwfunc)(c_addr, d_byte); int (*bwfunc)(c_addr, d_byte);
...@@ -87,7 +69,7 @@ pdp_qmap qmap_bk[] = { ...@@ -87,7 +69,7 @@ pdp_qmap qmap_bk[] = {
{ 0, 0, 0, 0, 0, 0 } { 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) { switch (a & 077) {
case 064: case 064:
*d = 0200; *d = 0200;
...@@ -100,7 +82,7 @@ tcons_read(c_addr a, d_word *d) { ...@@ -100,7 +82,7 @@ tcons_read(c_addr a, d_word *d) {
return OK; return OK;
} }
tcons_write(c_addr a, d_word d) { int tcons_write(c_addr a, d_word d) {
switch (a & 077) { switch (a & 077) {
case 064: case 064:
fprintf(stderr, "Writing %06o: %06o\n", a, d); fprintf(stderr, "Writing %06o: %06o\n", a, d);
...@@ -116,11 +98,15 @@ tcons_write(c_addr a, d_word d) { ...@@ -116,11 +98,15 @@ tcons_write(c_addr a, d_word d) {
return OK; return OK;
} }
int tcons_writeb(c_addr a, unsigned char d) {
return tcons_write(a, d);
}
pdp_qmap qmap_terak[] = { pdp_qmap qmap_terak[] = {
{ TERAK_DISK_REG, TERAK_DISK_SIZE, tdisk_init, tdisk_read, { TERAK_DISK_REG, TERAK_DISK_SIZE, tdisk_init, tdisk_read,
tdisk_write, tdisk_bwrite }, tdisk_write, tdisk_bwrite },
{ 0177564, 4, q_null, tcons_read, tcons_write, tcons_write }, { 0177564, 4, q_null, tcons_read, tcons_write, tcons_writeb },
{ 0177764, 4, q_null, tcons_read, tcons_write, tcons_write }, { 0177764, 4, q_null, tcons_read, tcons_write, tcons_writeb },
{ 0177744, 2, q_null, port_read, port_write, port_bwrite }, { 0177744, 2, q_null, port_read, port_write, port_bwrite },
{ 0177560, 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 }, { 0173000, 0200, q_null, terak_read, q_err, q_errb },
...@@ -148,6 +134,12 @@ pdp_qmap q_synth = { ...@@ -148,6 +134,12 @@ pdp_qmap q_synth = {
pdp_qmap q_bkplip = { pdp_qmap q_bkplip = {
PORT_REG, PORT_SIZE, bkplip_init, bkplip_read, bkplip_write, bkplip_bwrite 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_printer() { qmap[0] = q_printer; }
void plug_mouse() { qmap[0] = q_mouse; } void plug_mouse() { qmap[0] = q_mouse; }
void plug_covox() { qmap[0] = q_covox; } void plug_covox() { qmap[0] = q_covox; }
...@@ -171,7 +163,7 @@ int port_bwrite(c_addr a, d_byte d) { ...@@ -171,7 +163,7 @@ int port_bwrite(c_addr a, d_byte d) {
return OK; /* goes nowhere */ return OK; /* goes nowhere */
} }
secret_read(addr, word) int secret_read(addr, word)
c_addr addr; c_addr addr;
d_word *word; d_word *word;
{ {
...@@ -208,9 +200,7 @@ int secret_bwrite(c_addr a, d_byte d) { ...@@ -208,9 +200,7 @@ int secret_bwrite(c_addr a, d_byte d) {
*/ */
int int
lc_word( addr, word ) lc_word(c_addr addr, d_word *word)
c_addr addr;
d_word *word;
{ {
int i; int i;
...@@ -329,11 +319,7 @@ void pagereg_bwrite(d_byte byte) { ...@@ -329,11 +319,7 @@ void pagereg_bwrite(d_byte byte) {
* sc_word() - Store a word at the given core address. * sc_word() - Store a word at the given core address.
*/ */
int int sc_word(c_addr addr, d_word word) {
sc_word( addr, word )
c_addr addr;
d_word word;
{
int i; int i;
addr &= ~1; addr &= ~1;
...@@ -365,10 +351,7 @@ d_word word; ...@@ -365,10 +351,7 @@ d_word word;
*/ */
int int
ll_byte( p, baddr, byte ) ll_byte( register pdp_regs *p, d_word baddr, d_byte *byte )
register pdp_regs *p;
d_word baddr;
d_byte *byte;
{ {
d_word word; d_word word;
d_word laddr; d_word laddr;
...@@ -405,10 +388,7 @@ d_byte *byte; ...@@ -405,10 +388,7 @@ d_byte *byte;
*/ */
int int
sl_byte( p, laddr, byte ) sl_byte(register pdp_regs *p, d_word laddr, d_byte byte)
register pdp_regs *p;
d_word laddr;
d_byte byte;
{ {
d_word t; d_word t;
int i; int i;
...@@ -443,7 +423,7 @@ d_byte byte; ...@@ -443,7 +423,7 @@ d_byte byte;
* mem_init() - Initialize the memory. * mem_init() - Initialize the memory.
*/ */
mem_init() void mem_init()
{ {
int x; int x;
if (terak) { if (terak) {
...@@ -500,9 +480,8 @@ mem_init() ...@@ -500,9 +480,8 @@ mem_init()
* q_null() - Null QBUS device switch handler. * 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) ...@@ -525,7 +504,7 @@ int q_errb(c_addr x, d_byte y)
* q_reset() - Reset the UNIBUS devices. * q_reset() - Reset the UNIBUS devices.
*/ */
q_reset() void q_reset()
{ {
int i; int i;
...@@ -534,3 +513,13 @@ q_reset() ...@@ -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];
}
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <libintl.h> #include "intl.h"
#define _(String) gettext (String)
#include <fcntl.h> #include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -33,9 +32,9 @@ static unsigned lasttime; ...@@ -33,9 +32,9 @@ static unsigned lasttime;
* to receive 16 bit; that is, from PC to BK a whole byte can * to receive 16 bit; that is, from PC to BK a whole byte can
* be sent at once. * be sent at once.
*/ */
bkplip_init() { void bkplip_init() {
#ifdef linux #ifdef linux
if (fd != -1) return OK; if (fd != -1) return;
fd = open(DEVTAP, O_RDWR); fd = open(DEVTAP, O_RDWR);
if(fd == -1) { if(fd == -1) {
...@@ -55,19 +54,17 @@ bkplip_init() { ...@@ -55,19 +54,17 @@ bkplip_init() {
lasttime = 0; lasttime = 0;
#endif #endif
return OK;
} }
static int len_left = 0; static int len_left = 0;
static int curbyte = 0; static int curbyte = 0;
static flag_t nibble = 0;
static int txlen = 0, txbyte = 0; static int txlen = 0, txbyte = 0;
/* /*
* When no data is present, returns 0. * When no data is present, returns 0.
* If a packet is present, returns its length (a word) with bit 15 set, * 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. * 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; c_addr addr;
d_word *word; d_word *word;
{ {
...@@ -111,7 +108,7 @@ d_word *word; ...@@ -111,7 +108,7 @@ d_word *word;
* Expects a packet length (a word) with bit 15 set, * Expects a packet length (a word) with bit 15 set,
* then N bytes. Each write transmits a byte, no strobing yet. * then N bytes. Each write transmits a byte, no strobing yet.
*/ */
bkplip_write(addr, word) int bkplip_write(addr, word)
c_addr addr; c_addr addr;
d_word word; d_word word;
{ {
...@@ -142,7 +139,7 @@ d_word word; ...@@ -142,7 +139,7 @@ d_word word;
return OK; 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 offset = addr & 1;
d_word word; d_word word;
bkplip_read(addr & ~1, &word); bkplip_read(addr & ~1, &word);
......
...@@ -28,18 +28,16 @@ ...@@ -28,18 +28,16 @@
*/ */
#include "defines.h" #include "defines.h"
#include <libintl.h> #include "intl.h"
#define _(String) gettext (String)
/* /*
* load_rom() - Read the contents of the ROM into the array. * load_rom() - Read the contents of the ROM into the array.
* Used for BK-0010 style ROM - stores into the mapped memory. * 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; char * path;
int i; int i;
extern unsigned long pdp_ram_map;
unsigned long saved_ram_map = pdp_ram_map; unsigned long saved_ram_map = pdp_ram_map;
FILE * romf; FILE * romf;
...@@ -83,7 +81,7 @@ void load_rom(unsigned start, char * rompath, unsigned min_size, unsigned max_si ...@@ -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. * 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 * rombuf, int byte_off, const char * rompath, int byte_size) {
char * path; char * path;
int i; int i;
...@@ -105,14 +103,14 @@ void load_rom11(d_word * rom, int byte_off, char * rompath, int byte_size) { ...@@ -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")); fprintf(stderr, _("Couldn't open file.\n"));
exit(1); exit(1);
} }
rom += byte_off/2; rombuf += byte_off/2;
for (i = 0; i < byte_size/2; i++, rom++) { for (i = 0; i < byte_size/2; i++, rombuf++) {
int lobyte = getc(romf); int lobyte = getc(romf);
int hibyte = getc(romf); int hibyte = getc(romf);
d_word data; d_word data;
if (hibyte < 0) break; if (hibyte < 0) break;
data = lobyte | hibyte<<8; data = lobyte | hibyte<<8;
*rom = data; *rombuf = data;
} }
if (i < byte_size/2) { if (i < byte_size/2) {
fprintf(stderr, _("Incomplete or damaged file.\n")); 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) { ...@@ -123,7 +121,7 @@ void load_rom11(d_word * rom, int byte_off, char * rompath, int byte_size) {
fprintf(stderr, _("Done.\n")); fprintf(stderr, _("Done.\n"));
} }
int void
boot_init() boot_init()
{ {
static unsigned char boot_done = 0; static unsigned char boot_done = 0;
......
...@@ -29,17 +29,14 @@ ...@@ -29,17 +29,14 @@
#include "defines.h" #include "defines.h"
#include "ops.h"
/* /*
* brx() - Simple Branch Instructions. * brx() - Simple Branch Instructions.
*/ */
int int
brx( p, clear, set ) brx(register pdp_regs *p, unsigned clear, unsigned set)
register pdp_regs *p;
unsigned clear;
unsigned set;
{ {
d_word offset; d_word offset;
......
...@@ -6,12 +6,11 @@ ...@@ -6,12 +6,11 @@
#include "defines.h" #include "defines.h"
extern char * monitor10rom; extern const char *const monitor10rom;
extern int upper_porch; extern int upper_porch;
extern int lower_porch; extern int lower_porch;
extern int io_sound_freq; extern unsigned io_sound_freq;
extern char * floppyA; extern flag_t fake_tape, telegraph_enabled, fullscreen;
extern char * floppyB; extern flag_t traceflag;
extern char * floppyC; extern FILE * tracefile;
extern char * floppyD; extern const char *floppyA, *floppyB, *floppyC, *floppyD;
extern flag_t fake_tape, fake_disk, telegraph_enabled, fullscreen;
...@@ -2,33 +2,28 @@ ...@@ -2,33 +2,28 @@
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <libintl.h> #include "intl.h"
#define _(String) gettext (String)
unsigned char covox_val; void covox_init() {
unsigned int covox_age;
covox_init() {
covox_val = 0; covox_val = 0;
covox_age = ~0; covox_age = ~0;
} }
covox_read(c_addr addr, d_word *word) int covox_read(c_addr addr, d_word *word)
{ {
*word = 0; /* pulldown */ *word = 0; /* pulldown */
return OK; return OK;
} }
covox_write(c_addr addr, d_word word) int covox_write(c_addr addr, d_word word)
{ {
covox_val = word & 0xFF; covox_val = word & 0xFF;
covox_age = 0; covox_age = 0;
return OK; 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 offset = addr & 1;
d_word word;
if (offset == 0) { if (offset == 0) {
covox_val = byte; covox_val = byte;
} else { } else {
......
...@@ -63,6 +63,27 @@ typedef unsigned short d_word; /* data word (16 bit) */ ...@@ -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 d_byte; /* data byte (8 bit) */
typedef unsigned char flag_t; /* for boolean or small value flags */ 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. * PDP processor defines.
*/ */
...@@ -81,9 +102,12 @@ typedef struct _pdp_regs { ...@@ -81,9 +102,12 @@ typedef struct _pdp_regs {
unsigned look_time; /* when to handle things, saves time */ unsigned look_time; /* when to handle things, saves time */
} pdp_regs; } pdp_regs;
extern unsigned int hasexit;