Commit b2ab4b7f authored by Vladimir Serbinenko's avatar Vladimir Serbinenko
Browse files

Fix a whole bunch of warnings

parent 2a01065c
......@@ -54,7 +54,8 @@ unsigned long pdp_mem_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);
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 +63,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 +88,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 +101,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 +117,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_writeb },
{ 0177764, 4, q_null, tcons_read, tcons_write, tcons_writeb },
{ 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 },
......@@ -171,7 +176,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 +213,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 +332,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 +364,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 +401,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 +436,7 @@ d_byte byte;
* mem_init() - Initialize the memory.
*/
mem_init()
void mem_init()
{
int x;
if (terak) {
......@@ -500,9 +493,8 @@ mem_init()
* q_null() - Null QBUS device switch handler.
*/
int q_null()
static void q_null()
{
return OK;
}
/*
......@@ -525,7 +517,7 @@ int q_errb(c_addr x, d_byte y)
* q_reset() - Reset the UNIBUS devices.
*/
q_reset()
void q_reset()
{
int i;
......
......@@ -33,9 +33,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,7 +55,6 @@ bkplip_init() {
lasttime = 0;
#endif
return OK;
}
static int len_left = 0;
......@@ -67,7 +66,7 @@ static int txlen = 0, txbyte = 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 +110,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 +141,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);
......
......@@ -36,7 +36,7 @@
* 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;
......@@ -83,7 +83,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 * rombuf, int byte_off, const char * rompath, int byte_size) {
char * path;
int i;
......@@ -105,14 +105,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++) {
rombuf += byte_off/2;
for (i = 0; i < byte_size/2; i++, rombuf++) {
int lobyte = getc(romf);
int hibyte = getc(romf);
d_word data;
if (hibyte < 0) break;
data = lobyte | hibyte<<8;
*rom = data;
*rombuf = data;
}
if (i < byte_size/2) {
fprintf(stderr, _("Incomplete or damaged file.\n"));
......@@ -123,7 +123,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;
......
......@@ -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;
......
......@@ -8,27 +8,26 @@
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 {
......
......@@ -63,6 +63,26 @@ 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 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.
*/
......@@ -133,24 +153,43 @@ extern unsigned int hasexit;
#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 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 +201,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,9 +211,7 @@ typedef struct _event {
* Instruction Table for Fast Decode.
*/
struct _itab {
int (*func)();
};
typedef int (*_itab_t)();
/*
......@@ -193,7 +230,7 @@ extern char * bos11rom, * diskrom, * bos11extrom, * basic11arom, * basic11brom;
extern int TICK_RATE;
extern char * floppyA, *floppyB, *floppyC, *floppyD;
extern struct _itab itab[];
extern const _itab_t itab[];
extern unsigned short tty_scroll;
extern unsigned scr_dirty;
extern flag_t key_pressed;
......@@ -331,4 +368,34 @@ extern flag_t timer_intr_enabled;
else \
SET_CC_V()
typedef enum {
nopD, rtcD, stepinD, stepoutD, readtsD, readD, writeD, delD
} disk_cmd;
/* Why bother, let's memory-map the files! */
typedef struct {
unsigned int length;
unsigned short * image;
const unsigned short * ptr;
unsigned char track;
unsigned char side;
unsigned char ro;
unsigned char motor;
unsigned char inprogress;
unsigned char crc;
unsigned char need_sidetrk;
unsigned char need_sectsize;
unsigned char cursec;
disk_cmd cmd;
} disk_t;
extern unsigned long pending_interrupts;
void sim_init(void);
extern int breakpoint;
extern unsigned char change_req;
extern unsigned char param_change_line;
extern unsigned char req_page[512], req_palette[512];
extern int cybuf[1024];
extern int cybufidx;
#endif
......@@ -32,12 +32,12 @@
* otherwise it has no operands.
* Digits mean "look deeper".
*/
char* base[16] = {
static const char *const base[16] = {
"0", "Gmov", "Gcmp", "Gbit", "Gbic", "Gbis", "Gadd", "7",
"8", "Gmovb", "Gcmpb", "Gbitb", "Gbicb", "Gbisb", "Gsub", "N"
};
char* decode0[64] = {
static const char* const decode0[64] = {
/*000*/ "0", "Ojmp", "2", "Oswab", "Bbr", "Bbr", "Bbr", "Bbr",
/*001*/ "Bbne", "Bbne", "Bbne", "Bbne", "Bbeq", "Bbeq", "Bbeq", "Bbeq",
/*002*/ "Bbge", "Bbge", "Bbge", "Bbge", "Bblt", "Bblt", "Bblt", "Bblt",
......@@ -48,7 +48,7 @@ char* decode0[64] = {
/*007*/ "N", "N", "N", "N", "N", "N", "N", "N"
};
char* decode000[64] = {
static const char *const decode000[64] = {
"halt", "wait", "rti", "bpt", "iot", "reset", "rtt", "N",
"N", "N", "N", "N", "N", "N", "N", "N",
"N", "N", "N", "N", "N", "N", "N", "N",
......@@ -60,7 +60,7 @@ char* decode000[64] = {
};
/* Here the instruction is completely decoded, we can print it as is */
char * decode002[64] = {
static const char *const decode002[64] = {
"rts r0", "rts r1", "rts r2", "rts r3", "rts r4", "rts r5", "rts sp", "rts pc",
"N", "N", "N", "N", "N", "N", "N", "N",
"N", "N", "N", "N", "N", "N", "N", "N",
......@@ -71,7 +71,7 @@ char * decode002[64] = {
"sen", "senc", "senv", "senvc", "senz", "senzc", "senzv", "scc"
};
char * decode7[64] = {
static const char *const decode7[64] = {
/*070*/ "Rmul",
/*071*/ "Rdiv",
/*072*/ "Rash",
......@@ -82,16 +82,16 @@ char * decode7[64] = {
/*077*/ "Ssob",
};
char * decode750[4] = {
static const char *const decode750[4] = {
/*07500*/ "Ffadd",
/*07501*/ "Ffsub",
/*07502*/ "Ffmul",
/*07503*/ "Ffdiv",
};
char * regnam[8] = {"r0", "r1", "r2", "r3", "r4", "r5", "sp", "pc" };
static const char *const regnam[8] = {"r0", "r1", "r2", "r3", "r4", "r5", "sp", "pc" };
char * decode8[64] = {
static const char *const decode8[64] = {
/*100*/ "Bbpl", "Bbpl", "Bbpl", "Bbpl", "Bbmi", "Bbmi", "Bbmi", "Bbmi",
/*101*/ "Bbhi", "Bbhi", "Bbhi", "Bbhi", "Bblos", "Bblos", "Bblos", "Bblos",
/*102*/ "Bbvc", "Bbvc", "Bbvc", "Bbvc", "Bbvs", "Bbvs", "Bbvs", "Bbvs",
......@@ -113,7 +113,7 @@ void printop(unsigned rm, c_addr * a, char **destp) {
unsigned mode = rm >> 3;
switch (mode) {
case 0:
sprintf(*destp, regnam[r]);
sprintf(*destp, "%s", regnam[r]);
break;
case 1:
sprintf(*destp, "(%s)", regnam[r]);
......@@ -159,7 +159,7 @@ c_addr disas (c_addr a, char * dest) {
lc_word(a, &inst);
a += 2;
a &= 0177777;
char * code = base[inst >> 12];
const char * code = base[inst >> 12];
char soffset;
unsigned char uoffset;
switch (*code) {
......
......@@ -14,22 +14,6 @@
#define O_BINARY 0
#endif
/* Why bother, let's memory-map the files! */
typedef struct {
unsigned int length;
unsigned short * image;
unsigned short * ptr;
unsigned char track;
unsigned char side;
unsigned char ro;
unsigned char motor;
unsigned char inprogress;
unsigned char crc;
unsigned char need_sidetrk;
unsigned char need_sectsize;
unsigned char cursec;
} disk_t;
disk_t disks[4];
static int selected = -1;
......@@ -38,7 +22,7 @@ void do_disk_io(int drive, int blkno, int nwords, int ioaddr);
/* Pretty much had to rewrite it for portability rofl. - Gameblabla
* This does not seem to handle writes to the file.
* */
void disk_open(disk_t * pdt, char * name)
void disk_open(disk_t * pdt, const char * name)
{
FILE* fp;
int result;
......@@ -99,7 +83,7 @@ void disk_open(disk_t * pdt, char * name)
/* Are there any interrupts to open or close ? */
int disk_init() {
void disk_init() {
static char init_done = 0;
int i;
if (!init_done) {
......@@ -115,7 +99,6 @@ int disk_init() {
disks[i].motor = disks[i].inprogress = 0;
}
selected = -1;
return OK;
}
void disk_finish() {
......@@ -134,7 +117,6 @@ void disk_finish() {
/* The index hole appears for 1 ms every 100 ms,
*/
int index_flag() {
extern double ticks;
unsigned msec = ticks / (TICK_RATE/1000);
return (msec % 100 == 0);
}
......@@ -145,7 +127,7 @@ int index_flag() {
#define DATAFLAG 0120773
#define ENDFLAG 0120770
unsigned short index_marker[] = {
static const unsigned short index_marker[] = {
FILLER, FILLER, FILLER, FILLER, FILLER, FILLER, FILLER, FILLER,
FILLER, FILLER, FILLER, FILLER, FILLER, FILLER, FILLER, FILLER,
0, 0, 0, 0, 0, 0, LAST, IDXFLAG
......@@ -153,13 +135,13 @@ FILLER, FILLER, FILLER, FILLER, FILLER, FILLER, FILLER, FILLER,
#define IDXMRKLEN (sizeof(index_marker)/sizeof(*index_marker))
unsigned short data_marker[] = {
static const unsigned short data_marker[] = {
FILLER, FILLER, FILLER, FILLER, FILLER, FILLER, FILLER, FILLER,
FILLER, FILLER, FILLER, 0, 0, 0, 0, 0, 0, LAST, DATAFLAG
};
#define DATAMRKLEN (sizeof(data_marker)/sizeof(*data_marker))
unsigned short end_marker[] = {
static const unsigned short end_marker[] = {
FILLER, FILLER, FILLER, FILLER, FILLER, FILLER, FILLER, FILLER,
FILLER, FILLER, FILLER, FILLER, FILLER, FILLER, FILLER, FILLER,
FILLER, FILLER, 0, 0, 0, 0, 0, 0, LAST, ENDFLAG
......@@ -232,7 +214,7 @@ disk_read(c_addr addr, d_word *word) {
pdp.regs[PC], *word);
#endif
} else {
static dummy = 0x5555;
static int dummy = 0x5555;
fprintf(stderr, "?");
// fprintf(stderr, _("Reading 177132 when no I/O is progress?\n"));
*word = dummy = ~dummy;
......
......@@ -29,7 +29,7 @@
#include "defines.h"
#include "ops.h"
/*
* mov() - Move Instruction. Move operations with registers
......
......@@ -38,9 +38,7 @@
* load_ea()
*/
load_ea( p, addr )
register pdp_regs *p;
d_word *addr;
int load_ea( register pdp_regs *p, d_word *addr)
{
d_word indirect;
int result;
......@@ -104,9 +102,7 @@ d_word *addr;
* pop()
*/
pop( p, data )
register pdp_regs *p;
d_word *data;
int pop(register pdp_regs *p, d_word *data)
{
int result;
......@@ -121,9 +117,7 @@ d_word *data;
* push()
*/
push( p, data )
register pdp_regs *p;
d_word data;
int push(register pdp_regs *p, d_word data)
{
p->regs[SP] -= 2;