mirror of
https://github.com/gwenhael-le-moine/x48.git
synced 2025-01-12 20:01:13 +01:00
format all sources
This commit is contained in:
parent
b50a915e0a
commit
33c0a11156
38 changed files with 10403 additions and 11434 deletions
327
src/actions.c
327
src/actions.c
|
@ -83,21 +83,21 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "debugger.h"
|
||||||
|
#include "device.h"
|
||||||
#include "hp48.h"
|
#include "hp48.h"
|
||||||
#include "hp48_emu.h"
|
#include "hp48_emu.h"
|
||||||
#include "device.h"
|
|
||||||
#include "x48_x11.h"
|
|
||||||
#include "timer.h"
|
|
||||||
#include "debugger.h"
|
|
||||||
#include "romio.h"
|
#include "romio.h"
|
||||||
|
#include "timer.h"
|
||||||
|
#include "x48_x11.h"
|
||||||
|
|
||||||
static int interrupt_called = 0;
|
static int interrupt_called = 0;
|
||||||
extern long nibble_masks[16];
|
extern long nibble_masks[16];
|
||||||
|
|
||||||
int got_alarm;
|
int got_alarm;
|
||||||
|
|
||||||
int conf_bank1 = 0x00000;
|
int conf_bank1 = 0x00000;
|
||||||
int conf_bank2 = 0x00000;
|
int conf_bank2 = 0x00000;
|
||||||
|
|
||||||
void do_in(void) {
|
void do_in(void) {
|
||||||
int i, in, out;
|
int i, in, out;
|
||||||
|
@ -121,17 +121,11 @@ void do_in(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_program_stat(int n) {
|
void clear_program_stat(int n) { saturn.PSTAT[n] = 0; }
|
||||||
saturn.PSTAT[n] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_program_stat(int n) {
|
void set_program_stat(int n) { saturn.PSTAT[n] = 1; }
|
||||||
saturn.PSTAT[n] = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int get_program_stat(int n) {
|
int get_program_stat(int n) { return saturn.PSTAT[n]; }
|
||||||
return saturn.PSTAT[n];
|
|
||||||
}
|
|
||||||
|
|
||||||
void register_to_status(unsigned char *r) {
|
void register_to_status(unsigned char *r) {
|
||||||
int i;
|
int i;
|
||||||
|
@ -179,64 +173,55 @@ void set_register_nibble(unsigned char *reg, int n, unsigned char val) {
|
||||||
reg[n] = val;
|
reg[n] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char get_register_nibble(unsigned char *reg, int n) {
|
unsigned char get_register_nibble(unsigned char *reg, int n) { return reg[n]; }
|
||||||
return reg[n];
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_register_bit(unsigned char *reg, int n) {
|
void set_register_bit(unsigned char *reg, int n) {
|
||||||
reg[n/4] |= (1 << (n%4));
|
reg[n / 4] |= (1 << (n % 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_register_bit(unsigned char *reg, int n) {
|
void clear_register_bit(unsigned char *reg, int n) {
|
||||||
reg[n/4] &= ~(1 << (n%4));
|
reg[n / 4] &= ~(1 << (n % 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_register_bit(unsigned char *reg, int n) {
|
int get_register_bit(unsigned char *reg, int n) {
|
||||||
return ((int)(reg[n/4] & (1 << (n%4))) > 0)?1:0;
|
return ((int)(reg[n / 4] & (1 << (n % 4))) > 0) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
short conf_tab_sx[] = { 1, 2, 2, 2, 2, 0 };
|
short conf_tab_sx[] = {1, 2, 2, 2, 2, 0};
|
||||||
short conf_tab_gx[] = { 1, 2, 2, 2, 2, 0 };
|
short conf_tab_gx[] = {1, 2, 2, 2, 2, 0};
|
||||||
|
|
||||||
void do_reset(void) {
|
void do_reset(void) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 6; i++) {
|
||||||
{
|
if (opt_gx)
|
||||||
if (opt_gx)
|
saturn.mem_cntl[i].unconfigured = conf_tab_gx[i];
|
||||||
saturn.mem_cntl[i].unconfigured = conf_tab_gx[i];
|
else
|
||||||
else
|
saturn.mem_cntl[i].unconfigured = conf_tab_sx[i];
|
||||||
saturn.mem_cntl[i].unconfigured = conf_tab_sx[i];
|
saturn.mem_cntl[i].config[0] = 0x0;
|
||||||
saturn.mem_cntl[i].config[0] = 0x0;
|
saturn.mem_cntl[i].config[1] = 0x0;
|
||||||
saturn.mem_cntl[i].config[1] = 0x0;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG_CONFIG
|
#ifdef DEBUG_CONFIG
|
||||||
fprintf(stderr, "%.5lx: RESET\n", saturn.PC);
|
fprintf(stderr, "%.5lx: RESET\n", saturn.PC);
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 6; i++) {
|
||||||
{
|
if (saturn.mem_cntl[i].unconfigured)
|
||||||
if (saturn.mem_cntl[i].unconfigured)
|
fprintf(stderr, "MEMORY CONTROLLER %d is unconfigured\n", i);
|
||||||
fprintf(stderr, "MEMORY CONTROLLER %d is unconfigured\n", i);
|
else
|
||||||
else
|
fprintf(stderr, "MEMORY CONTROLLER %d is configured to %.5lx, %.5lx\n", i,
|
||||||
fprintf(stderr, "MEMORY CONTROLLER %d is configured to %.5lx, %.5lx\n",
|
saturn.mem_cntl[i].config[0], saturn.mem_cntl[i].config[1]);
|
||||||
i, saturn.mem_cntl[i].config[0], saturn.mem_cntl[i].config[1]);
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_inton(void) {
|
void do_inton(void) { saturn.kbd_ien = 1; }
|
||||||
saturn.kbd_ien = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void do_intoff(void) {
|
void do_intoff(void) { saturn.kbd_ien = 0; }
|
||||||
saturn.kbd_ien = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void do_return_interupt(void) {
|
void do_return_interupt(void) {
|
||||||
if (saturn.int_pending) {
|
if (saturn.int_pending) {
|
||||||
#ifdef DEBUG_INTERRUPT
|
#ifdef DEBUG_INTERRUPT
|
||||||
fprintf(stderr, "PC = %.5lx: RTI SERVICE PENDING INTERRUPT\n",
|
fprintf(stderr, "PC = %.5lx: RTI SERVICE PENDING INTERRUPT\n", saturn.PC);
|
||||||
saturn.PC);
|
|
||||||
#endif
|
#endif
|
||||||
saturn.int_pending = 0;
|
saturn.int_pending = 0;
|
||||||
saturn.intenable = 0;
|
saturn.intenable = 0;
|
||||||
|
@ -255,7 +240,6 @@ void do_return_interupt(void) {
|
||||||
schedule_event = 0;
|
schedule_event = 0;
|
||||||
sched_adjtime = 0;
|
sched_adjtime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,30 +298,27 @@ void do_unconfigure(void) {
|
||||||
conf |= saturn.C[i];
|
conf |= saturn.C[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 6; i++) {
|
||||||
{
|
if (saturn.mem_cntl[i].config[0] == conf) {
|
||||||
if (saturn.mem_cntl[i].config[0] == conf)
|
if (opt_gx)
|
||||||
{
|
saturn.mem_cntl[i].unconfigured = conf_tab_gx[i];
|
||||||
if (opt_gx)
|
else
|
||||||
saturn.mem_cntl[i].unconfigured = conf_tab_gx[i];
|
saturn.mem_cntl[i].unconfigured = conf_tab_sx[i];
|
||||||
else
|
saturn.mem_cntl[i].config[0] = 0x0;
|
||||||
saturn.mem_cntl[i].unconfigured = conf_tab_sx[i];
|
saturn.mem_cntl[i].config[1] = 0x0;
|
||||||
saturn.mem_cntl[i].config[0] = 0x0;
|
break;
|
||||||
saturn.mem_cntl[i].config[1] = 0x0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_CONFIG
|
#ifdef DEBUG_CONFIG
|
||||||
fprintf(stderr, "%.5lx: UNCNFG %.5x:\n", saturn.PC, conf);
|
fprintf(stderr, "%.5lx: UNCNFG %.5x:\n", saturn.PC, conf);
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 6; i++) {
|
||||||
{
|
if (saturn.mem_cntl[i].unconfigured)
|
||||||
if (saturn.mem_cntl[i].unconfigured)
|
fprintf(stderr, "MEMORY CONTROLLER %d is unconfigured\n", i);
|
||||||
fprintf(stderr, "MEMORY CONTROLLER %d is unconfigured\n", i);
|
else
|
||||||
else
|
fprintf(stderr, "MEMORY CONTROLLER %d is configured to %.5lx, %.5lx\n", i,
|
||||||
fprintf(stderr, "MEMORY CONTROLLER %d is configured to %.5lx, %.5lx\n",
|
saturn.mem_cntl[i].config[0], saturn.mem_cntl[i].config[1]);
|
||||||
i, saturn.mem_cntl[i].config[0], saturn.mem_cntl[i].config[1]);
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,40 +332,35 @@ void do_configure(void) {
|
||||||
conf |= saturn.C[i];
|
conf |= saturn.C[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 6; i++) {
|
||||||
{
|
if (saturn.mem_cntl[i].unconfigured) {
|
||||||
if (saturn.mem_cntl[i].unconfigured)
|
saturn.mem_cntl[i].unconfigured--;
|
||||||
{
|
saturn.mem_cntl[i].config[saturn.mem_cntl[i].unconfigured] = conf;
|
||||||
saturn.mem_cntl[i].unconfigured--;
|
break;
|
||||||
saturn.mem_cntl[i].config[saturn.mem_cntl[i].unconfigured] = conf;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_CONFIG
|
#ifdef DEBUG_CONFIG
|
||||||
fprintf(stderr, "%.5lx: CONFIG %.5lx:\n", saturn.PC, conf);
|
fprintf(stderr, "%.5lx: CONFIG %.5lx:\n", saturn.PC, conf);
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 6; i++) {
|
||||||
{
|
if (saturn.mem_cntl[i].unconfigured)
|
||||||
if (saturn.mem_cntl[i].unconfigured)
|
fprintf(stderr, "MEMORY CONTROLLER %d is unconfigured\n", i);
|
||||||
fprintf(stderr, "MEMORY CONTROLLER %d is unconfigured\n", i);
|
else
|
||||||
else
|
fprintf(stderr, "MEMORY CONTROLLER %d at %.5lx, %.5lx\n", i,
|
||||||
fprintf(stderr, "MEMORY CONTROLLER %d at %.5lx, %.5lx\n",
|
saturn.mem_cntl[i].config[0], saturn.mem_cntl[i].config[1]);
|
||||||
i, saturn.mem_cntl[i].config[0], saturn.mem_cntl[i].config[1]);
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_identification(void) {
|
int get_identification(void) {
|
||||||
int i;
|
int i;
|
||||||
static int chip_id[]
|
static int chip_id[] = {0, 0, 0, 0, 0x05, 0xf6, 0x07, 0xf8, 0x01, 0xf2, 0, 0};
|
||||||
= { 0, 0, 0, 0, 0x05, 0xf6, 0x07, 0xf8, 0x01, 0xf2, 0, 0 };
|
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 6; i++) {
|
||||||
{
|
if (saturn.mem_cntl[i].unconfigured)
|
||||||
if (saturn.mem_cntl[i].unconfigured)
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
if (i < 6)
|
if (i < 6)
|
||||||
id = chip_id[2 * i + (2 - saturn.mem_cntl[i].unconfigured)];
|
id = chip_id[2 * i + (2 - saturn.mem_cntl[i].unconfigured)];
|
||||||
else
|
else
|
||||||
|
@ -392,29 +368,25 @@ int get_identification(void) {
|
||||||
|
|
||||||
#ifdef DEBUG_ID
|
#ifdef DEBUG_ID
|
||||||
fprintf(stderr, "%.5lx: C=ID, returning: %x\n", saturn.PC, id);
|
fprintf(stderr, "%.5lx: C=ID, returning: %x\n", saturn.PC, id);
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 6; i++) {
|
||||||
{
|
if (saturn.mem_cntl[i].unconfigured == 2)
|
||||||
if (saturn.mem_cntl[i].unconfigured == 2)
|
fprintf(stderr, "MEMORY CONTROLLER %d is unconfigured\n", i);
|
||||||
fprintf(stderr, "MEMORY CONTROLLER %d is unconfigured\n", i);
|
else if (saturn.mem_cntl[i].unconfigured == 1) {
|
||||||
else if (saturn.mem_cntl[i].unconfigured == 1)
|
if (i == 0)
|
||||||
{
|
fprintf(stderr, "MEMORY CONTROLLER %d unconfigured\n", i);
|
||||||
if (i == 0)
|
|
||||||
fprintf(stderr, "MEMORY CONTROLLER %d unconfigured\n", i);
|
|
||||||
else
|
|
||||||
fprintf(stderr, "MEMORY CONTROLLER %d configured to ????? %.5lx\n",
|
|
||||||
i, saturn.mem_cntl[i].config[1]);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
fprintf(stderr, "MEMORY CONTROLLER %d configured to %.5lx, %.5lx\n",
|
fprintf(stderr, "MEMORY CONTROLLER %d configured to ????? %.5lx\n", i,
|
||||||
i, saturn.mem_cntl[i].config[0], saturn.mem_cntl[i].config[1]);
|
saturn.mem_cntl[i].config[1]);
|
||||||
}
|
} else
|
||||||
|
fprintf(stderr, "MEMORY CONTROLLER %d configured to %.5lx, %.5lx\n", i,
|
||||||
|
saturn.mem_cntl[i].config[0], saturn.mem_cntl[i].config[1]);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++) {
|
||||||
{
|
saturn.C[i] = id & 0x0f;
|
||||||
saturn.C[i] = id & 0x0f;
|
id >>= 4;
|
||||||
id >>= 4;
|
}
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,7 +398,8 @@ void do_shutdown(void) {
|
||||||
device.display_touched = 0;
|
device.display_touched = 0;
|
||||||
update_display();
|
update_display();
|
||||||
#ifdef HAVE_XSHM
|
#ifdef HAVE_XSHM
|
||||||
if (disp.display_update) refresh_display();
|
if (disp.display_update)
|
||||||
|
refresh_display();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,7 +436,8 @@ void do_shutdown(void) {
|
||||||
got_alarm = 0;
|
got_alarm = 0;
|
||||||
|
|
||||||
#ifdef HAVE_XSHM
|
#ifdef HAVE_XSHM
|
||||||
if (disp.display_update) refresh_display();
|
if (disp.display_update)
|
||||||
|
refresh_display();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ticks = get_t1_t2();
|
ticks = get_t1_t2();
|
||||||
|
@ -479,34 +453,28 @@ void do_shutdown(void) {
|
||||||
wake = 1;
|
wake = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (saturn.timer2 <= 0)
|
if (saturn.timer2 <= 0) {
|
||||||
{
|
if (saturn.t2_ctrl & 0x04) {
|
||||||
if (saturn.t2_ctrl & 0x04)
|
wake = 1;
|
||||||
{
|
|
||||||
wake = 1;
|
|
||||||
}
|
|
||||||
if (saturn.t2_ctrl & 0x02)
|
|
||||||
{
|
|
||||||
wake = 1;
|
|
||||||
saturn.t2_ctrl |= 0x08;
|
|
||||||
do_interupt();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (saturn.t2_ctrl & 0x02) {
|
||||||
|
wake = 1;
|
||||||
|
saturn.t2_ctrl |= 0x08;
|
||||||
|
do_interupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (saturn.timer1 <= 0)
|
if (saturn.timer1 <= 0) {
|
||||||
{
|
saturn.timer1 &= 0x0f;
|
||||||
saturn.timer1 &= 0x0f;
|
if (saturn.t1_ctrl & 0x04) {
|
||||||
if (saturn.t1_ctrl & 0x04)
|
wake = 1;
|
||||||
{
|
|
||||||
wake = 1;
|
|
||||||
}
|
|
||||||
if (saturn.t1_ctrl & 0x03)
|
|
||||||
{
|
|
||||||
wake = 1;
|
|
||||||
saturn.t1_ctrl |= 0x08;
|
|
||||||
do_interupt();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (saturn.t1_ctrl & 0x03) {
|
||||||
|
wake = 1;
|
||||||
|
saturn.t1_ctrl |= 0x08;
|
||||||
|
do_interupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (wake == 0) {
|
if (wake == 0) {
|
||||||
interrupt_called = 0;
|
interrupt_called = 0;
|
||||||
|
@ -518,10 +486,9 @@ void do_shutdown(void) {
|
||||||
alarms++;
|
alarms++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enter_debugger)
|
if (enter_debugger) {
|
||||||
{
|
wake = 1;
|
||||||
wake = 1;
|
}
|
||||||
}
|
|
||||||
} while (wake == 0);
|
} while (wake == 0);
|
||||||
|
|
||||||
stop_timer(IDLE_TIMER);
|
stop_timer(IDLE_TIMER);
|
||||||
|
@ -529,24 +496,40 @@ void do_shutdown(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_hardware_stat(int op) {
|
void set_hardware_stat(int op) {
|
||||||
if (op & 1) saturn.XM = 1;
|
if (op & 1)
|
||||||
if (op & 2) saturn.SB = 1;
|
saturn.XM = 1;
|
||||||
if (op & 4) saturn.SR = 1;
|
if (op & 2)
|
||||||
if (op & 8) saturn.MP = 1;
|
saturn.SB = 1;
|
||||||
|
if (op & 4)
|
||||||
|
saturn.SR = 1;
|
||||||
|
if (op & 8)
|
||||||
|
saturn.MP = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_hardware_stat(int op) {
|
void clear_hardware_stat(int op) {
|
||||||
if (op & 1) saturn.XM = 0;
|
if (op & 1)
|
||||||
if (op & 2) saturn.SB = 0;
|
saturn.XM = 0;
|
||||||
if (op & 4) saturn.SR = 0;
|
if (op & 2)
|
||||||
if (op & 8) saturn.MP = 0;
|
saturn.SB = 0;
|
||||||
|
if (op & 4)
|
||||||
|
saturn.SR = 0;
|
||||||
|
if (op & 8)
|
||||||
|
saturn.MP = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_zero_hardware_stat(int op) {
|
int is_zero_hardware_stat(int op) {
|
||||||
if (op & 1) if (saturn.XM != 0) return 0;
|
if (op & 1)
|
||||||
if (op & 2) if (saturn.SB != 0) return 0;
|
if (saturn.XM != 0)
|
||||||
if (op & 4) if (saturn.SR != 0) return 0;
|
return 0;
|
||||||
if (op & 8) if (saturn.MP != 0) return 0;
|
if (op & 2)
|
||||||
|
if (saturn.SB != 0)
|
||||||
|
return 0;
|
||||||
|
if (op & 4)
|
||||||
|
if (saturn.SR != 0)
|
||||||
|
return 0;
|
||||||
|
if (op & 8)
|
||||||
|
if (saturn.MP != 0)
|
||||||
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -561,7 +544,7 @@ void push_return_addr(long addr) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
for (i = 1; i < NR_RSTK; i++)
|
for (i = 1; i < NR_RSTK; i++)
|
||||||
saturn.rstk[i-1] = saturn.rstk[i];
|
saturn.rstk[i - 1] = saturn.rstk[i];
|
||||||
saturn.rstkp--;
|
saturn.rstkp--;
|
||||||
}
|
}
|
||||||
saturn.rstk[saturn.rstkp] = addr;
|
saturn.rstk[saturn.rstkp] = addr;
|
||||||
|
@ -581,14 +564,14 @@ long pop_return_addr(void) {
|
||||||
fprintf(stderr, "RSTK[%d] %.5x\n", i, saturn.rstk[i]);
|
fprintf(stderr, "RSTK[%d] %.5x\n", i, saturn.rstk[i]);
|
||||||
}
|
}
|
||||||
fprintf(stderr, "POP %.5x:\n",
|
fprintf(stderr, "POP %.5x:\n",
|
||||||
(saturn.rstkp >= 0) ? saturn.rstk[saturn.rstkp]:0);
|
(saturn.rstkp >= 0) ? saturn.rstk[saturn.rstkp] : 0);
|
||||||
#endif
|
#endif
|
||||||
if (saturn.rstkp < 0)
|
if (saturn.rstkp < 0)
|
||||||
return 0;
|
return 0;
|
||||||
return saturn.rstk[saturn.rstkp--];
|
return saturn.rstk[saturn.rstkp--];
|
||||||
}
|
}
|
||||||
|
|
||||||
char * make_hexstr(long addr, int n) {
|
char *make_hexstr(long addr, int n) {
|
||||||
static char str[44];
|
static char str[44];
|
||||||
int i, t, trunc;
|
int i, t, trunc;
|
||||||
|
|
||||||
|
@ -598,7 +581,7 @@ char * make_hexstr(long addr, int n) {
|
||||||
trunc = 1;
|
trunc = 1;
|
||||||
}
|
}
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
t = read_nibble(addr+i);
|
t = read_nibble(addr + i);
|
||||||
if (t <= 9)
|
if (t <= 9)
|
||||||
str[i] = '0' + t;
|
str[i] = '0' + t;
|
||||||
else
|
else
|
||||||
|
@ -607,9 +590,9 @@ char * make_hexstr(long addr, int n) {
|
||||||
str[n] = '\0';
|
str[n] = '\0';
|
||||||
if (trunc) {
|
if (trunc) {
|
||||||
str[n] = '.';
|
str[n] = '.';
|
||||||
str[n+1] = '.';
|
str[n + 1] = '.';
|
||||||
str[n+2] = '.';
|
str[n + 2] = '.';
|
||||||
str[n+3] = '\0';
|
str[n + 3] = '\0';
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -698,17 +681,11 @@ void add_address(word_20 *dat, int add) {
|
||||||
*dat &= 0xfffff;
|
*dat &= 0xfffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int start_fields[] = {
|
static int start_fields[] = {-1, 0, 2, 0, 15, 3, 0, 0, -1, 0,
|
||||||
-1, 0, 2, 0, 15, 3, 0, 0,
|
2, 0, 15, 3, 0, 0, 0, 0, 0};
|
||||||
-1, 0, 2, 0, 15, 3, 0, 0,
|
|
||||||
0, 0, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
static int end_fields[] = {
|
static int end_fields[] = {-1, -1, 2, 2, 15, 14, 1, 15, -1, -1,
|
||||||
-1, -1, 2, 2, 15, 14, 1, 15,
|
2, 2, 15, 14, 1, 4, 3, 2, 0};
|
||||||
-1, -1, 2, 2, 15, 14, 1, 4,
|
|
||||||
3, 2, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline int get_start(int code) {
|
static inline int get_start(int code) {
|
||||||
int s;
|
int s;
|
||||||
|
|
|
@ -38,8 +38,8 @@
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
extern char * append_str __ProtoType__((char *buf, char *string));
|
extern char *append_str __ProtoType__((char *buf, char *string));
|
||||||
extern char * append_tab __ProtoType__((char *buf));
|
extern char *append_tab __ProtoType__((char *buf));
|
||||||
extern char * append_tab_16 __ProtoType__((char *buf));
|
extern char *append_tab_16 __ProtoType__((char *buf));
|
||||||
|
|
||||||
#endif /* !_APPEND_H */
|
#endif /* !_APPEND_H */
|
||||||
|
|
|
@ -39,8 +39,8 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "romio.h"
|
#include "romio.h"
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
unsigned char *rom;
|
unsigned char *rom;
|
||||||
unsigned short rom_crc, crc;
|
unsigned short rom_crc, crc;
|
||||||
|
|
||||||
int verbose = 0;
|
int verbose = 0;
|
||||||
char *progname;
|
char *progname;
|
||||||
|
|
||||||
#define calc_crc(n) (crc = ((crc >> 4) ^ (((crc ^ n) & 0xf) * 0x1081)))
|
#define calc_crc(n) (crc = ((crc >> 4) ^ (((crc ^ n) & 0xf) * 0x1081)))
|
||||||
|
@ -61,14 +61,13 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
fprintf(stderr, "usage: %s rom-file\n", argv[0]);
|
fprintf(stderr, "usage: %s rom-file\n", argv[0]);
|
||||||
exit (1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!read_rom_file(argv[1], &rom, &rom_size))
|
if (!read_rom_file(argv[1], &rom, &rom_size)) {
|
||||||
{
|
fprintf(stderr, "%s: can\'t read ROM from %s\n", argv[0], argv[1]);
|
||||||
fprintf(stderr, "%s: can\'t read ROM from %s\n", argv[0], argv[1]);
|
exit(1);
|
||||||
exit (1);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (opt_gx != 0)
|
if (opt_gx != 0)
|
||||||
ver_addr = 0x7ffbf;
|
ver_addr = 0x7ffbf;
|
||||||
|
@ -82,7 +81,6 @@ int main(int argc, char **argv) {
|
||||||
version[6] = '\0';
|
version[6] = '\0';
|
||||||
printf("ROM Version is %s\n", version);
|
printf("ROM Version is %s\n", version);
|
||||||
|
|
||||||
|
|
||||||
for (i = 0x100; i < 0x140; i++) {
|
for (i = 0x100; i < 0x140; i++) {
|
||||||
rom[i] = 0x0;
|
rom[i] = 0x0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,9 +40,8 @@
|
||||||
/*
|
/*
|
||||||
* Color modes this program can cope with
|
* Color modes this program can cope with
|
||||||
*/
|
*/
|
||||||
#define COLOR_MODE_MONO 1
|
#define COLOR_MODE_MONO 1
|
||||||
#define COLOR_MODE_GRAY 2
|
#define COLOR_MODE_GRAY 2
|
||||||
#define COLOR_MODE_COLOR 3
|
#define COLOR_MODE_COLOR 3
|
||||||
|
|
||||||
#endif /* !_CONSTANTS_H */
|
#endif /* !_CONSTANTS_H */
|
||||||
|
|
||||||
|
|
2040
src/debugger.c
2040
src/debugger.c
File diff suppressed because it is too large
Load diff
|
@ -38,29 +38,29 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _DEBUGGER_H
|
#ifndef _DEBUGGER_H
|
||||||
#define _DEBUGGER_H 1
|
#define _DEBUGGER_H 1
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "hp48.h"
|
#include "hp48.h"
|
||||||
|
|
||||||
#define USER_INTERRUPT 1
|
#define USER_INTERRUPT 1
|
||||||
#define ILLEGAL_INSTRUCTION 2
|
#define ILLEGAL_INSTRUCTION 2
|
||||||
#define BREAKPOINT_HIT 4
|
#define BREAKPOINT_HIT 4
|
||||||
#define TRAP_INSTRUCTION 8
|
#define TRAP_INSTRUCTION 8
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* exec_flags values
|
* exec_flags values
|
||||||
*/
|
*/
|
||||||
#define EXEC_BKPT 1
|
#define EXEC_BKPT 1
|
||||||
|
|
||||||
extern int enter_debugger;
|
extern int enter_debugger;
|
||||||
extern int in_debugger;
|
extern int in_debugger;
|
||||||
extern int exec_flags;
|
extern int exec_flags;
|
||||||
|
|
||||||
extern void init_debugger __ProtoType__((void));
|
extern void init_debugger __ProtoType__((void));
|
||||||
extern int debug __ProtoType__((void));
|
extern int debug __ProtoType__((void));
|
||||||
extern int emulate_debug __ProtoType__((void));
|
extern int emulate_debug __ProtoType__((void));
|
||||||
|
|
||||||
extern char *str_nibbles __ProtoType__((word_20 addr, int n));
|
extern char *str_nibbles __ProtoType__((word_20 addr, int n));
|
||||||
|
|
||||||
#endif /* !_DEBUGGER_H */
|
#endif /* !_DEBUGGER_H */
|
||||||
|
|
|
@ -53,9 +53,9 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "device.h"
|
||||||
#include "hp48.h"
|
#include "hp48.h"
|
||||||
#include "hp48_emu.h"
|
#include "hp48_emu.h"
|
||||||
#include "device.h"
|
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "x48_x11.h"
|
#include "x48_x11.h"
|
||||||
|
|
||||||
|
@ -175,10 +175,10 @@ void check_devices(void) {
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
void check_out_register(void) {
|
void check_out_register(void) {
|
||||||
static int au = -2;
|
static int au = -2;
|
||||||
|
|
37
src/device.h
37
src/device.h
|
@ -51,24 +51,25 @@
|
||||||
#define _DEVICE_H 1
|
#define _DEVICE_H 1
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
#include "hp48.h"
|
||||||
|
|
||||||
#define DISP_INSTR_OFF 0x10
|
#define DISP_INSTR_OFF 0x10
|
||||||
|
|
||||||
#define ANN_LEFT 0x81
|
#define ANN_LEFT 0x81
|
||||||
#define ANN_RIGHT 0x82
|
#define ANN_RIGHT 0x82
|
||||||
#define ANN_ALPHA 0x84
|
#define ANN_ALPHA 0x84
|
||||||
#define ANN_BATTERY 0x88
|
#define ANN_BATTERY 0x88
|
||||||
#define ANN_BUSY 0x90
|
#define ANN_BUSY 0x90
|
||||||
#define ANN_IO 0xa0
|
#define ANN_IO 0xa0
|
||||||
|
|
||||||
typedef struct device_t {
|
typedef struct device_t {
|
||||||
|
|
||||||
int display_touched;
|
int display_touched;
|
||||||
|
|
||||||
char contrast_touched;
|
char contrast_touched;
|
||||||
|
|
||||||
char disp_test_touched;
|
char disp_test_touched;
|
||||||
|
|
||||||
char crc_touched;
|
char crc_touched;
|
||||||
|
|
||||||
char power_status_touched;
|
char power_status_touched;
|
||||||
|
@ -77,7 +78,7 @@ typedef struct device_t {
|
||||||
char mode_touched;
|
char mode_touched;
|
||||||
|
|
||||||
char ann_touched;
|
char ann_touched;
|
||||||
|
|
||||||
char baud_touched;
|
char baud_touched;
|
||||||
|
|
||||||
char card_ctrl_touched;
|
char card_ctrl_touched;
|
||||||
|
@ -102,7 +103,7 @@ typedef struct device_t {
|
||||||
|
|
||||||
char scratch_touched;
|
char scratch_touched;
|
||||||
char base_nibble_touched;
|
char base_nibble_touched;
|
||||||
|
|
||||||
char unknown_touched;
|
char unknown_touched;
|
||||||
|
|
||||||
char t1_ctrl_touched;
|
char t1_ctrl_touched;
|
||||||
|
@ -116,16 +117,16 @@ typedef struct device_t {
|
||||||
} device_t;
|
} device_t;
|
||||||
|
|
||||||
extern device_t device;
|
extern device_t device;
|
||||||
extern void check_devices __ProtoType__((void));
|
extern void check_devices __ProtoType__((void));
|
||||||
#if 0
|
#if 0
|
||||||
extern void check_out_register __ProtoType__((void));
|
extern void check_out_register __ProtoType__((void));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void update_display __ProtoType__((void));
|
extern void update_display __ProtoType__((void));
|
||||||
extern void redraw_display __ProtoType__((void));
|
extern void redraw_display __ProtoType__((void));
|
||||||
extern void disp_draw_nibble __ProtoType__((word_20 addr, word_4 val));
|
extern void disp_draw_nibble __ProtoType__((word_20 addr, word_4 val));
|
||||||
extern void menu_draw_nibble __ProtoType__((word_20 addr, word_4 val));
|
extern void menu_draw_nibble __ProtoType__((word_20 addr, word_4 val));
|
||||||
extern void draw_annunc __ProtoType__((void));
|
extern void draw_annunc __ProtoType__((void));
|
||||||
extern void redraw_annunc __ProtoType__((void));
|
extern void redraw_annunc __ProtoType__((void));
|
||||||
|
|
||||||
#endif /* !_DEVICE_H */
|
#endif /* !_DEVICE_H */
|
||||||
|
|
2457
src/disasm.c
2457
src/disasm.c
File diff suppressed because it is too large
Load diff
|
@ -45,13 +45,12 @@
|
||||||
* $Id: dump2rom.c,v 1.7 1995/01/11 18:20:01 ecd Exp ecd $
|
* $Id: dump2rom.c,v 1.7 1995/01/11 18:20:01 ecd Exp ecd $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#ifdef SUNOS
|
#ifdef SUNOS
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -67,44 +66,36 @@ int write_mem_file(char *name, unsigned char *mem, int size) {
|
||||||
unsigned char byte;
|
unsigned char byte;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
if (NULL == (fp = fopen(name, "w")))
|
if (NULL == (fp = fopen(name, "w"))) {
|
||||||
{
|
fprintf(stderr, "can\'t open %s\n", name);
|
||||||
fprintf(stderr, "can\'t open %s\n", name);
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL == (tmp_mem = (unsigned char *)malloc((size_t)size / 2))) {
|
||||||
|
for (i = 0, j = 0; i < size / 2; i++) {
|
||||||
|
byte = (mem[j++] & 0x0f);
|
||||||
|
byte |= (mem[j++] << 4) & 0xf0;
|
||||||
|
if (1 != fwrite(&byte, 1, 1, fp)) {
|
||||||
|
fprintf(stderr, "can\'t write %s\n", name);
|
||||||
|
fclose(fp);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (i = 0, j = 0; i < size / 2; i++) {
|
||||||
|
tmp_mem[i] = (mem[j++] & 0x0f);
|
||||||
|
tmp_mem[i] |= (mem[j++] << 4) & 0xf0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fwrite(tmp_mem, 1, (size_t)size / 2, fp) != size / 2) {
|
||||||
|
fprintf(stderr, "can\'t write %s\n", name);
|
||||||
|
fclose(fp);
|
||||||
|
free(tmp_mem);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL == (tmp_mem = (unsigned char *)malloc((size_t)size / 2)))
|
free(tmp_mem);
|
||||||
{
|
}
|
||||||
for (i = 0, j = 0; i < size / 2; i++)
|
|
||||||
{
|
|
||||||
byte = (mem[j++] & 0x0f);
|
|
||||||
byte |= (mem[j++] << 4) & 0xf0;
|
|
||||||
if (1 != fwrite(&byte, 1, 1, fp))
|
|
||||||
{
|
|
||||||
fprintf(stderr, "can\'t write %s\n", name);
|
|
||||||
fclose(fp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (i = 0, j = 0; i < size / 2; i++)
|
|
||||||
{
|
|
||||||
tmp_mem[i] = (mem[j++] & 0x0f);
|
|
||||||
tmp_mem[i] |= (mem[j++] << 4) & 0xf0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fwrite(tmp_mem, 1, (size_t)size / 2, fp) != size / 2)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "can\'t write %s\n", name);
|
|
||||||
fclose(fp);
|
|
||||||
free(tmp_mem);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(tmp_mem);
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -117,17 +108,17 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
fprintf(stderr, "usage: %s hp48-dump-file\n", argv[0]);
|
fprintf(stderr, "usage: %s hp48-dump-file\n", argv[0]);
|
||||||
exit (1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((dump = fopen(argv[1], "r")) == NULL) {
|
if ((dump = fopen(argv[1], "r")) == NULL) {
|
||||||
fprintf(stderr, "%s: can\'t open %s\n", argv[0], argv[1]);
|
fprintf(stderr, "%s: can\'t open %s\n", argv[0], argv[1]);
|
||||||
exit (1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((core = (unsigned char *)malloc(0x100000)) == NULL) {
|
if ((core = (unsigned char *)malloc(0x100000)) == NULL) {
|
||||||
fprintf(stderr, "%s: can\'t malloc %d bytes\n", argv[0], 0x100000);
|
fprintf(stderr, "%s: can\'t malloc %d bytes\n", argv[0], 0x100000);
|
||||||
exit (1);
|
exit(1);
|
||||||
}
|
}
|
||||||
memset(core, 0, 0x100000);
|
memset(core, 0, 0x100000);
|
||||||
|
|
||||||
|
@ -160,8 +151,8 @@ int main(int argc, char **argv) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ch != ':') {
|
if (ch != ':') {
|
||||||
fprintf(stderr, "%s: Illegal char %c, expected \':\' at %lx\n",
|
fprintf(stderr, "%s: Illegal char %c, expected \':\' at %lx\n", argv[0],
|
||||||
argv[0], ch, addr);
|
ch, addr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (i = 0; i < 16; i++) {
|
for (i = 0; i < 16; i++) {
|
||||||
|
@ -185,8 +176,8 @@ int main(int argc, char **argv) {
|
||||||
if ((ch = fgetc(dump)) < 0)
|
if ((ch = fgetc(dump)) < 0)
|
||||||
break;
|
break;
|
||||||
if (ch != '\n') {
|
if (ch != '\n') {
|
||||||
fprintf(stderr, "%s: Illegal char %c, expected \'\\n\' at %lx\n",
|
fprintf(stderr, "%s: Illegal char %c, expected \'\\n\' at %lx\n", argv[0],
|
||||||
argv[0], ch, addr);
|
ch, addr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,11 +189,10 @@ int main(int argc, char **argv) {
|
||||||
size = 0x100000;
|
size = 0x100000;
|
||||||
else
|
else
|
||||||
size = 0x80000;
|
size = 0x80000;
|
||||||
if (!write_mem_file(DEFAULT_ROM_FILE, core, size))
|
if (!write_mem_file(DEFAULT_ROM_FILE, core, size)) {
|
||||||
{
|
fprintf(stderr, "%s: can\'t write to %s\n", argv[0], DEFAULT_ROM_FILE);
|
||||||
fprintf(stderr, "%s: can\'t write to %s\n", argv[0], DEFAULT_ROM_FILE);
|
exit(1);
|
||||||
exit (1);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
exit (0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
3519
src/emulate.c
3519
src/emulate.c
File diff suppressed because it is too large
Load diff
21
src/errors.c
21
src/errors.c
|
@ -31,23 +31,26 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "resources.h"
|
#include "resources.h"
|
||||||
|
|
||||||
char errbuf[1024] = { 0, };
|
char errbuf[1024] = {
|
||||||
char fixbuf[1024] = { 0, };
|
0,
|
||||||
|
};
|
||||||
|
char fixbuf[1024] = {
|
||||||
|
0,
|
||||||
|
};
|
||||||
|
|
||||||
void fatal_exit(void) {
|
void fatal_exit(void) {
|
||||||
if (quiet)
|
if (quiet)
|
||||||
exit (1);
|
exit(1);
|
||||||
|
|
||||||
if (errbuf[0] == '\0')
|
if (errbuf[0] == '\0') {
|
||||||
{
|
fprintf(stderr, "%s: FATAL ERROR, exit.\n", progname);
|
||||||
fprintf(stderr, "%s: FATAL ERROR, exit.\n", progname);
|
exit(1);
|
||||||
exit (1);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(stderr, "%s: FATAL ERROR, exit.\n - %s\n", progname, errbuf);
|
fprintf(stderr, "%s: FATAL ERROR, exit.\n - %s\n", progname, errbuf);
|
||||||
|
|
||||||
if (fixbuf[0] != '\0')
|
if (fixbuf[0] != '\0')
|
||||||
fprintf(stderr, " - %s\n", fixbuf);
|
fprintf(stderr, " - %s\n", fixbuf);
|
||||||
|
|
||||||
exit (1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,6 @@
|
||||||
extern char errbuf[1024];
|
extern char errbuf[1024];
|
||||||
extern char fixbuf[1024];
|
extern char fixbuf[1024];
|
||||||
|
|
||||||
extern void fatal_exit __ProtoType__ ((void));
|
extern void fatal_exit __ProtoType__((void));
|
||||||
|
|
||||||
#endif /* !_ERRORS_H */
|
#endif /* !_ERRORS_H */
|
||||||
|
|
60
src/global.h
60
src/global.h
|
@ -60,41 +60,41 @@
|
||||||
#if defined(linux)
|
#if defined(linux)
|
||||||
|
|
||||||
#ifndef LINUX
|
#ifndef LINUX
|
||||||
#define LINUX 1
|
#define LINUX 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SYSV_TIME 1
|
#define SYSV_TIME 1
|
||||||
|
|
||||||
#else /* Not Linux */
|
#else /* Not Linux */
|
||||||
|
|
||||||
#if defined(sun) && defined(unix)
|
#if defined(sun) && defined(unix)
|
||||||
|
|
||||||
#if defined(__svr4__) || defined(SVR4) || defined(SYSV)
|
#if defined(__svr4__) || defined(SVR4) || defined(SYSV)
|
||||||
|
|
||||||
#ifndef SOLARIS
|
#ifndef SOLARIS
|
||||||
#define SOLARIS 1
|
#define SOLARIS 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SYSV_TIME 1
|
#define SYSV_TIME 1
|
||||||
|
|
||||||
#else /* Not Solaris */
|
#else /* Not Solaris */
|
||||||
|
|
||||||
#if defined(hpux)
|
#if defined(hpux)
|
||||||
|
|
||||||
#ifndef HPUX
|
#ifndef HPUX
|
||||||
#define HPUX 1
|
#define HPUX 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else /* Not HP-UX */
|
#else /* Not HP-UX */
|
||||||
|
|
||||||
#ifndef SUNOS
|
#ifndef SUNOS
|
||||||
#define SUNOS 1
|
#define SUNOS 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* Not HP-UX */
|
#endif /* Not HP-UX */
|
||||||
#endif /* Not Solaris */
|
#endif /* Not Solaris */
|
||||||
#endif /* Sun && Unix */
|
#endif /* Sun && Unix */
|
||||||
#endif /* Not Linux */
|
#endif /* Not Linux */
|
||||||
|
|
||||||
#ifdef SYSV
|
#ifdef SYSV
|
||||||
#ifndef SYSV_TIME
|
#ifndef SYSV_TIME
|
||||||
|
@ -112,28 +112,28 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
extern int printf __ProtoType__((char *, ...));
|
extern int printf __ProtoType__((char *, ...));
|
||||||
extern int fprintf __ProtoType__((FILE *, char *, ...));
|
extern int fprintf __ProtoType__((FILE *, char *, ...));
|
||||||
extern int sscanf __ProtoType__((char *, char *, ...));
|
extern int sscanf __ProtoType__((char *, char *, ...));
|
||||||
extern void fflush __ProtoType__((FILE *));
|
extern void fflush __ProtoType__((FILE *));
|
||||||
extern int fseek __ProtoType__((FILE *, long, int));
|
extern int fseek __ProtoType__((FILE *, long, int));
|
||||||
extern int fread __ProtoType__((void *, int, int, FILE*));
|
extern int fread __ProtoType__((void *, int, int, FILE *));
|
||||||
extern int fwrite __ProtoType__((void *, int, int, FILE*));
|
extern int fwrite __ProtoType__((void *, int, int, FILE *));
|
||||||
extern void fclose __ProtoType__((FILE *));
|
extern void fclose __ProtoType__((FILE *));
|
||||||
extern int fgetc __ProtoType__((FILE *));
|
extern int fgetc __ProtoType__((FILE *));
|
||||||
extern void bzero __ProtoType__((void *, int));
|
extern void bzero __ProtoType__((void *, int));
|
||||||
extern time_t time __ProtoType__((time_t *));
|
extern time_t time __ProtoType__((time_t *));
|
||||||
extern int select __ProtoType__((int, fd_set *, fd_set *,
|
extern int select __ProtoType__((int, fd_set *, fd_set *, fd_set *,
|
||||||
fd_set *, struct timeval *));
|
struct timeval *));
|
||||||
extern int setitimer __ProtoType__((int, struct itimerval *,
|
extern int setitimer __ProtoType__((int, struct itimerval *,
|
||||||
struct itimerval *));
|
struct itimerval *));
|
||||||
extern int gethostname __ProtoType__((char *, int));
|
extern int gethostname __ProtoType__((char *, int));
|
||||||
#ifdef HAVE_XSHM
|
#ifdef HAVE_XSHM
|
||||||
#include <sys/ipc.h>
|
#include <sys/ipc.h>
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
extern int shmget __ProtoType__((key_t, int, int));
|
extern int shmget __ProtoType__((key_t, int, int));
|
||||||
extern int shmat __ProtoType__((int, void *, int));
|
extern int shmat __ProtoType__((int, void *, int));
|
||||||
extern int shmctl __ProtoType__((int, int, struct shmid_ds *));
|
extern int shmctl __ProtoType__((int, int, struct shmid_ds *));
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
221
src/hp48.h
221
src/hp48.h
|
@ -68,41 +68,41 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
#include "mmu.h"
|
#include "mmu.h"
|
||||||
#ifdef HAVE_STDINT_H
|
#ifdef HAVE_STDINT_H
|
||||||
# include <stdint.h>
|
#include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define RAM_SIZE_SX 0x10000
|
#define RAM_SIZE_SX 0x10000
|
||||||
#define RAM_SIZE_GX 0x40000
|
#define RAM_SIZE_GX 0x40000
|
||||||
|
|
||||||
#define P_FIELD 0
|
#define P_FIELD 0
|
||||||
#define WP_FIELD 1
|
#define WP_FIELD 1
|
||||||
#define XS_FIELD 2
|
#define XS_FIELD 2
|
||||||
#define X_FIELD 3
|
#define X_FIELD 3
|
||||||
#define S_FIELD 4
|
#define S_FIELD 4
|
||||||
#define M_FIELD 5
|
#define M_FIELD 5
|
||||||
#define B_FIELD 6
|
#define B_FIELD 6
|
||||||
#define W_FIELD 7
|
#define W_FIELD 7
|
||||||
#define A_FIELD 15
|
#define A_FIELD 15
|
||||||
#define IN_FIELD 16
|
#define IN_FIELD 16
|
||||||
#define OUT_FIELD 17
|
#define OUT_FIELD 17
|
||||||
#define OUTS_FIELD 18
|
#define OUTS_FIELD 18
|
||||||
|
|
||||||
#define DEC 10
|
#define DEC 10
|
||||||
#define HEX 16
|
#define HEX 16
|
||||||
|
|
||||||
#define NR_RSTK 8
|
#define NR_RSTK 8
|
||||||
#define NR_PSTAT 16
|
#define NR_PSTAT 16
|
||||||
|
|
||||||
typedef unsigned char word_1;
|
typedef unsigned char word_1;
|
||||||
typedef unsigned char word_4;
|
typedef unsigned char word_4;
|
||||||
typedef unsigned char word_8;
|
typedef unsigned char word_8;
|
||||||
typedef unsigned short word_12;
|
typedef unsigned short word_12;
|
||||||
typedef unsigned short word_16;
|
typedef unsigned short word_16;
|
||||||
typedef long word_20;
|
typedef long word_20;
|
||||||
typedef long word_32;
|
typedef long word_32;
|
||||||
|
|
||||||
#ifdef HAVE_STDINT_H
|
#ifdef HAVE_STDINT_H
|
||||||
#define SIMPLE_64
|
#define SIMPLE_64
|
||||||
typedef int64_t word_64;
|
typedef int64_t word_64;
|
||||||
#else
|
#else
|
||||||
|
@ -117,21 +117,21 @@ typedef struct keystate_t {
|
||||||
|
|
||||||
typedef struct display_t {
|
typedef struct display_t {
|
||||||
|
|
||||||
int on;
|
int on;
|
||||||
|
|
||||||
long disp_start;
|
long disp_start;
|
||||||
long disp_end;
|
long disp_end;
|
||||||
|
|
||||||
int offset;
|
int offset;
|
||||||
int lines;
|
int lines;
|
||||||
int nibs_per_line;
|
int nibs_per_line;
|
||||||
|
|
||||||
int contrast;
|
int contrast;
|
||||||
|
|
||||||
long menu_start;
|
long menu_start;
|
||||||
long menu_end;
|
long menu_end;
|
||||||
|
|
||||||
int annunc;
|
int annunc;
|
||||||
|
|
||||||
} display_t;
|
} display_t;
|
||||||
|
|
||||||
|
@ -143,102 +143,102 @@ typedef struct mem_cntl_t {
|
||||||
typedef struct saturn_t {
|
typedef struct saturn_t {
|
||||||
|
|
||||||
unsigned long magic;
|
unsigned long magic;
|
||||||
char version[4];
|
char version[4];
|
||||||
|
|
||||||
unsigned char A[16], B[16], C[16], D[16];
|
unsigned char A[16], B[16], C[16], D[16];
|
||||||
|
|
||||||
word_20 d[2];
|
word_20 d[2];
|
||||||
|
|
||||||
#define D0 d[0]
|
#define D0 d[0]
|
||||||
#define D1 d[1]
|
#define D1 d[1]
|
||||||
|
|
||||||
word_4 P;
|
word_4 P;
|
||||||
word_20 PC;
|
word_20 PC;
|
||||||
|
|
||||||
unsigned char R0[16], R1[16], R2[16], R3[16], R4[16];
|
unsigned char R0[16], R1[16], R2[16], R3[16], R4[16];
|
||||||
unsigned char IN[4];
|
unsigned char IN[4];
|
||||||
unsigned char OUT[3];
|
unsigned char OUT[3];
|
||||||
|
|
||||||
word_1 CARRY;
|
word_1 CARRY;
|
||||||
|
|
||||||
unsigned char PSTAT[NR_PSTAT];
|
unsigned char PSTAT[NR_PSTAT];
|
||||||
unsigned char XM, SB, SR, MP;
|
unsigned char XM, SB, SR, MP;
|
||||||
|
|
||||||
word_4 hexmode;
|
word_4 hexmode;
|
||||||
|
|
||||||
word_20 rstk[NR_RSTK];
|
word_20 rstk[NR_RSTK];
|
||||||
short rstkp;
|
short rstkp;
|
||||||
|
|
||||||
keystate_t keybuf;
|
keystate_t keybuf;
|
||||||
|
|
||||||
unsigned char intenable;
|
unsigned char intenable;
|
||||||
unsigned char int_pending;
|
unsigned char int_pending;
|
||||||
unsigned char kbd_ien;
|
unsigned char kbd_ien;
|
||||||
|
|
||||||
word_4 disp_io;
|
word_4 disp_io;
|
||||||
|
|
||||||
word_4 contrast_ctrl;
|
word_4 contrast_ctrl;
|
||||||
word_8 disp_test;
|
word_8 disp_test;
|
||||||
|
|
||||||
word_16 crc;
|
word_16 crc;
|
||||||
|
|
||||||
word_4 power_status;
|
word_4 power_status;
|
||||||
word_4 power_ctrl;
|
word_4 power_ctrl;
|
||||||
|
|
||||||
word_4 mode;
|
word_4 mode;
|
||||||
|
|
||||||
word_8 annunc;
|
word_8 annunc;
|
||||||
|
|
||||||
word_4 baud;
|
word_4 baud;
|
||||||
|
|
||||||
word_4 card_ctrl;
|
word_4 card_ctrl;
|
||||||
word_4 card_status;
|
word_4 card_status;
|
||||||
|
|
||||||
word_4 io_ctrl;
|
word_4 io_ctrl;
|
||||||
word_4 rcs;
|
word_4 rcs;
|
||||||
word_4 tcs;
|
word_4 tcs;
|
||||||
|
|
||||||
word_8 rbr;
|
word_8 rbr;
|
||||||
word_8 tbr;
|
word_8 tbr;
|
||||||
|
|
||||||
word_8 sreq;
|
word_8 sreq;
|
||||||
|
|
||||||
word_4 ir_ctrl;
|
word_4 ir_ctrl;
|
||||||
|
|
||||||
word_4 base_off;
|
word_4 base_off;
|
||||||
|
|
||||||
word_4 lcr;
|
word_4 lcr;
|
||||||
word_4 lbr;
|
word_4 lbr;
|
||||||
|
|
||||||
word_4 scratch;
|
word_4 scratch;
|
||||||
|
|
||||||
word_4 base_nibble;
|
word_4 base_nibble;
|
||||||
|
|
||||||
word_20 disp_addr;
|
word_20 disp_addr;
|
||||||
word_12 line_offset;
|
word_12 line_offset;
|
||||||
word_8 line_count;
|
word_8 line_count;
|
||||||
|
|
||||||
word_16 unknown;
|
word_16 unknown;
|
||||||
|
|
||||||
word_4 t1_ctrl;
|
word_4 t1_ctrl;
|
||||||
word_4 t2_ctrl;
|
word_4 t2_ctrl;
|
||||||
|
|
||||||
word_20 menu_addr;
|
word_20 menu_addr;
|
||||||
|
|
||||||
word_8 unknown2;
|
word_8 unknown2;
|
||||||
|
|
||||||
char timer1; /* may NOT be unsigned !!! */
|
char timer1; /* may NOT be unsigned !!! */
|
||||||
word_32 timer2;
|
word_32 timer2;
|
||||||
|
|
||||||
long t1_instr;
|
long t1_instr;
|
||||||
long t2_instr;
|
long t2_instr;
|
||||||
|
|
||||||
short t1_tick;
|
short t1_tick;
|
||||||
short t2_tick;
|
short t2_tick;
|
||||||
long i_per_s;
|
long i_per_s;
|
||||||
|
|
||||||
short bank_switch;
|
short bank_switch;
|
||||||
mem_cntl_t mem_cntl[NR_MCTL];
|
mem_cntl_t mem_cntl[NR_MCTL];
|
||||||
|
|
||||||
unsigned char *rom;
|
unsigned char *rom;
|
||||||
unsigned char *ram;
|
unsigned char *ram;
|
||||||
|
@ -249,45 +249,44 @@ typedef struct saturn_t {
|
||||||
|
|
||||||
#define NIBBLES_PER_ROW 0x22
|
#define NIBBLES_PER_ROW 0x22
|
||||||
|
|
||||||
extern int got_alarm;
|
extern int got_alarm;
|
||||||
|
|
||||||
extern int set_t1;
|
extern int set_t1;
|
||||||
extern long sched_timer1;
|
extern long sched_timer1;
|
||||||
extern long sched_timer2;
|
extern long sched_timer2;
|
||||||
|
|
||||||
extern int adj_time_pending;
|
extern int adj_time_pending;
|
||||||
extern long sched_adjtime;
|
extern long sched_adjtime;
|
||||||
extern long schedule_event;
|
extern long schedule_event;
|
||||||
|
|
||||||
extern display_t display;
|
extern display_t display;
|
||||||
extern void init_display __ProtoType__((void));
|
extern void init_display __ProtoType__((void));
|
||||||
|
|
||||||
extern saturn_t saturn;
|
extern saturn_t saturn;
|
||||||
|
|
||||||
extern int exit_emulator __ProtoType__((void));
|
extern int exit_emulator __ProtoType__((void));
|
||||||
extern int init_emulator __ProtoType__((void));
|
extern int init_emulator __ProtoType__((void));
|
||||||
extern void init_active_stuff __ProtoType__((void));
|
extern void init_active_stuff __ProtoType__((void));
|
||||||
|
|
||||||
extern int serial_init __ProtoType__((void));
|
extern int serial_init __ProtoType__((void));
|
||||||
extern void serial_baud __ProtoType__((int baud));
|
extern void serial_baud __ProtoType__((int baud));
|
||||||
extern void transmit_char __ProtoType__((void));
|
extern void transmit_char __ProtoType__((void));
|
||||||
extern void receive_char __ProtoType__((void));
|
extern void receive_char __ProtoType__((void));
|
||||||
|
|
||||||
extern void do_kbd_int __ProtoType__((void));
|
extern void do_kbd_int __ProtoType__((void));
|
||||||
extern void do_interupt __ProtoType__((void));
|
extern void do_interupt __ProtoType__((void));
|
||||||
|
|
||||||
extern void (*write_nibble) __ProtoType__((long addr, int val));
|
extern void(*write_nibble) __ProtoType__((long addr, int val));
|
||||||
extern int (*read_nibble) __ProtoType__((long addr));
|
extern int(*read_nibble) __ProtoType__((long addr));
|
||||||
extern int (*read_nibble_crc) __ProtoType__((long addr));
|
extern int(*read_nibble_crc) __ProtoType__((long addr));
|
||||||
|
|
||||||
extern int emulate __ProtoType__((void));
|
extern int emulate __ProtoType__((void));
|
||||||
extern int step_instruction __ProtoType__((void));
|
extern int step_instruction __ProtoType__((void));
|
||||||
extern void schedule __ProtoType__((void));
|
extern void schedule __ProtoType__((void));
|
||||||
|
|
||||||
extern int read_rom __ProtoType__((const char *fname));
|
extern int read_rom __ProtoType__((const char *fname));
|
||||||
extern int read_files __ProtoType__((void));
|
extern int read_files __ProtoType__((void));
|
||||||
extern int write_files __ProtoType__((void));
|
extern int write_files __ProtoType__((void));
|
||||||
|
|
||||||
extern void load_addr __ProtoType__((word_20 *dat, long addr,
|
extern void load_addr __ProtoType__((word_20 * dat, long addr, int n));
|
||||||
int n));
|
|
||||||
#endif /* !_HP48_H */
|
#endif /* !_HP48_H */
|
||||||
|
|
210
src/hp48_emu.h
210
src/hp48_emu.h
|
@ -68,135 +68,119 @@ extern Display *dpy;
|
||||||
extern Window dispW;
|
extern Window dispW;
|
||||||
extern GC gc;
|
extern GC gc;
|
||||||
|
|
||||||
extern void push_return_addr __ProtoType__((long addr));
|
extern void push_return_addr __ProtoType__((long addr));
|
||||||
extern long pop_return_addr __ProtoType__((void));
|
extern long pop_return_addr __ProtoType__((void));
|
||||||
|
|
||||||
extern void init_annunc __ProtoType__((void));
|
extern void init_annunc __ProtoType__((void));
|
||||||
|
|
||||||
extern void init_saturn __ProtoType__((void));
|
extern void init_saturn __ProtoType__((void));
|
||||||
|
|
||||||
extern void check_timer __ProtoType__((void));
|
extern void check_timer __ProtoType__((void));
|
||||||
|
|
||||||
extern void register_to_status __ProtoType__((unsigned char *r));
|
extern void register_to_status __ProtoType__((unsigned char *r));
|
||||||
extern void status_to_register __ProtoType__((unsigned char *r));
|
extern void status_to_register __ProtoType__((unsigned char *r));
|
||||||
extern void swap_register_status __ProtoType__((unsigned char *r));
|
extern void swap_register_status __ProtoType__((unsigned char *r));
|
||||||
extern void clear_status __ProtoType__((void));
|
extern void clear_status __ProtoType__((void));
|
||||||
|
|
||||||
extern long read_nibbles __ProtoType__((long addr, int len));
|
extern long read_nibbles __ProtoType__((long addr, int len));
|
||||||
extern void write_nibbles __ProtoType__((long addr, long val, int len));
|
extern void write_nibbles __ProtoType__((long addr, long val, int len));
|
||||||
extern void dev_memory_init __ProtoType__((void));
|
extern void dev_memory_init __ProtoType__((void));
|
||||||
|
|
||||||
extern void set_program_stat __ProtoType__((int n));
|
extern void set_program_stat __ProtoType__((int n));
|
||||||
extern void clear_program_stat __ProtoType__((int n));
|
extern void clear_program_stat __ProtoType__((int n));
|
||||||
extern int get_program_stat __ProtoType__((int n));
|
extern int get_program_stat __ProtoType__((int n));
|
||||||
|
|
||||||
extern void set_hardware_stat __ProtoType__((int op));
|
extern void set_hardware_stat __ProtoType__((int op));
|
||||||
extern void clear_hardware_stat __ProtoType__((int op));
|
extern void clear_hardware_stat __ProtoType__((int op));
|
||||||
extern int is_zero_hardware_stat __ProtoType__((int op));
|
extern int is_zero_hardware_stat __ProtoType__((int op));
|
||||||
|
|
||||||
extern void set_register_bit __ProtoType__((unsigned char *reg, int n));
|
extern void set_register_bit __ProtoType__((unsigned char *reg, int n));
|
||||||
extern void clear_register_bit __ProtoType__((unsigned char *reg, int n));
|
extern void clear_register_bit __ProtoType__((unsigned char *reg, int n));
|
||||||
extern int get_register_bit __ProtoType__((unsigned char *reg, int n));
|
extern int get_register_bit __ProtoType__((unsigned char *reg, int n));
|
||||||
|
|
||||||
extern void set_register_nibble __ProtoType__((unsigned char *reg, int n,
|
extern void set_register_nibble __ProtoType__((unsigned char *reg, int n,
|
||||||
unsigned char val));
|
unsigned char val));
|
||||||
extern unsigned char get_register_nibble __ProtoType__((unsigned char *reg, int n));
|
extern unsigned char get_register_nibble __ProtoType__((unsigned char *reg,
|
||||||
|
int n));
|
||||||
|
|
||||||
|
extern void register_to_address __ProtoType__((unsigned char *reg, word_20 *dat,
|
||||||
|
int s));
|
||||||
|
extern void address_to_register __ProtoType__((word_20 dat, unsigned char *reg,
|
||||||
|
int s));
|
||||||
|
extern void add_address __ProtoType__((word_20 * dat, int add));
|
||||||
|
|
||||||
extern void register_to_address __ProtoType__((unsigned char *reg,
|
extern char *make_hexstr __ProtoType__((long addr, int n));
|
||||||
word_20 *dat, int s));
|
extern void load_constant __ProtoType__((unsigned char *reg, int n, long addr));
|
||||||
extern void address_to_register __ProtoType__((word_20 dat,
|
extern void load_address __ProtoType__((unsigned char *reg, long addr, int n));
|
||||||
unsigned char *reg, int s));
|
|
||||||
extern void add_address __ProtoType__((word_20 *dat, int add));
|
|
||||||
|
|
||||||
extern char * make_hexstr __ProtoType__((long addr, int n));
|
extern void store __ProtoType__((word_20 dat, unsigned char *reg, int code));
|
||||||
extern void load_constant __ProtoType__((unsigned char *reg, int n,
|
extern void store_n __ProtoType__((word_20 dat, unsigned char *reg, int n));
|
||||||
long addr));
|
extern void recall __ProtoType__((unsigned char *reg, word_20 dat, int code));
|
||||||
extern void load_address __ProtoType__((unsigned char *reg, long addr,
|
extern void recall_n __ProtoType__((unsigned char *reg, word_20 dat, int n));
|
||||||
int n));
|
|
||||||
|
|
||||||
extern void store __ProtoType__((word_20 dat, unsigned char *reg,
|
extern long dat_to_addr __ProtoType__((unsigned char *dat));
|
||||||
int code));
|
extern void addr_to_dat __ProtoType__((long addr, unsigned char *dat));
|
||||||
extern void store_n __ProtoType__((word_20 dat, unsigned char *reg,
|
|
||||||
int n));
|
|
||||||
extern void recall __ProtoType__((unsigned char *reg, word_20 dat,
|
|
||||||
int code));
|
|
||||||
extern void recall_n __ProtoType__((unsigned char *reg, word_20 dat,
|
|
||||||
int n));
|
|
||||||
|
|
||||||
extern long dat_to_addr __ProtoType__((unsigned char *dat));
|
extern void do_in __ProtoType__((void));
|
||||||
extern void addr_to_dat __ProtoType__((long addr, unsigned char *dat));
|
extern void do_reset __ProtoType__((void));
|
||||||
|
extern void do_configure __ProtoType__((void));
|
||||||
|
extern void do_unconfigure __ProtoType__((void));
|
||||||
|
extern void do_inton __ProtoType__((void));
|
||||||
|
extern void do_intoff __ProtoType__((void));
|
||||||
|
extern void do_return_interupt __ProtoType__((void));
|
||||||
|
extern void do_reset_interrupt_system __ProtoType__((void));
|
||||||
|
extern void do_shutdown __ProtoType__((void));
|
||||||
|
extern int get_identification __ProtoType__((void));
|
||||||
|
|
||||||
extern void do_in __ProtoType__((void));
|
extern void add_p_plus_one __ProtoType__((unsigned char *r));
|
||||||
extern void do_reset __ProtoType__((void));
|
extern void add_register_constant __ProtoType__((unsigned char *res, int code,
|
||||||
extern void do_configure __ProtoType__((void));
|
int val));
|
||||||
extern void do_unconfigure __ProtoType__((void));
|
extern void sub_register_constant __ProtoType__((unsigned char *res, int code,
|
||||||
extern void do_inton __ProtoType__((void));
|
int val));
|
||||||
extern void do_intoff __ProtoType__((void));
|
extern void add_register __ProtoType__((unsigned char *res, unsigned char *r1,
|
||||||
extern void do_return_interupt __ProtoType__((void));
|
unsigned char *r2, int code));
|
||||||
extern void do_reset_interrupt_system __ProtoType__((void));
|
extern void sub_register __ProtoType__((unsigned char *res, unsigned char *r1,
|
||||||
extern void do_shutdown __ProtoType__((void));
|
unsigned char *r2, int code));
|
||||||
extern int get_identification __ProtoType__((void));
|
extern void complement_2_register __ProtoType__((unsigned char *r, int code));
|
||||||
|
extern void complement_1_register __ProtoType__((unsigned char *r, int code));
|
||||||
|
extern void inc_register __ProtoType__((unsigned char *r, int code));
|
||||||
|
extern void dec_register __ProtoType__((unsigned char *r, int code));
|
||||||
|
extern void zero_register __ProtoType__((unsigned char *r, int code));
|
||||||
|
extern void or_register __ProtoType__((unsigned char *res, unsigned char *r1,
|
||||||
|
unsigned char *r2, int code));
|
||||||
|
extern void and_register __ProtoType__((unsigned char *res, unsigned char *r1,
|
||||||
|
unsigned char *r2, int code));
|
||||||
|
extern void copy_register __ProtoType__((unsigned char *to, unsigned char *from,
|
||||||
|
int code));
|
||||||
|
extern void exchange_register __ProtoType__((unsigned char *r1,
|
||||||
|
unsigned char *r2, int code));
|
||||||
|
|
||||||
extern void add_p_plus_one __ProtoType__((unsigned char *r));
|
extern void exchange_reg __ProtoType__((unsigned char *r, word_20 *d,
|
||||||
extern void add_register_constant __ProtoType__((unsigned char *res,
|
int code));
|
||||||
int code, int val));
|
|
||||||
extern void sub_register_constant __ProtoType__((unsigned char *res,
|
|
||||||
int code, int val));
|
|
||||||
extern void add_register __ProtoType__((unsigned char *res, unsigned char *r1,
|
|
||||||
unsigned char *r2, int code));
|
|
||||||
extern void sub_register __ProtoType__((unsigned char *res, unsigned char *r1,
|
|
||||||
unsigned char *r2, int code));
|
|
||||||
extern void complement_2_register __ProtoType__((unsigned char *r, int code));
|
|
||||||
extern void complement_1_register __ProtoType__((unsigned char *r, int code));
|
|
||||||
extern void inc_register __ProtoType__((unsigned char *r, int code));
|
|
||||||
extern void dec_register __ProtoType__((unsigned char *r, int code));
|
|
||||||
extern void zero_register __ProtoType__((unsigned char *r, int code));
|
|
||||||
extern void or_register __ProtoType__((unsigned char *res, unsigned char *r1,
|
|
||||||
unsigned char *r2, int code));
|
|
||||||
extern void and_register __ProtoType__((unsigned char *res, unsigned char *r1,
|
|
||||||
unsigned char *r2, int code));
|
|
||||||
extern void copy_register __ProtoType__((unsigned char *to, unsigned char *from,
|
|
||||||
int code));
|
|
||||||
extern void exchange_register __ProtoType__((unsigned char *r1, unsigned char *r2,
|
|
||||||
int code));
|
|
||||||
|
|
||||||
extern void exchange_reg __ProtoType__((unsigned char *r, word_20 *d, int code));
|
extern void shift_left_register __ProtoType__((unsigned char *r, int code));
|
||||||
|
extern void shift_left_circ_register __ProtoType__((unsigned char *r,
|
||||||
extern void shift_left_register __ProtoType__((unsigned char *r, int code));
|
int code));
|
||||||
extern void shift_left_circ_register __ProtoType__((unsigned char *r, int code));
|
extern void shift_right_register __ProtoType__((unsigned char *r, int code));
|
||||||
extern void shift_right_register __ProtoType__((unsigned char *r, int code));
|
extern void shift_right_circ_register __ProtoType__((unsigned char *r,
|
||||||
extern void shift_right_circ_register __ProtoType__((unsigned char *r, int code));
|
int code));
|
||||||
extern void shift_right_bit_register __ProtoType__((unsigned char *r, int code));
|
extern void shift_right_bit_register __ProtoType__((unsigned char *r,
|
||||||
extern int is_zero_register __ProtoType__((
|
int code));
|
||||||
unsigned char *r,
|
extern int is_zero_register __ProtoType__((unsigned char *r, int code));
|
||||||
int code));
|
extern int is_not_zero_register __ProtoType__((unsigned char *r, int code));
|
||||||
extern int is_not_zero_register __ProtoType__((
|
extern int is_equal_register __ProtoType__((unsigned char *r1,
|
||||||
unsigned char *r,
|
unsigned char *r2, int code));
|
||||||
int code));
|
extern int is_not_equal_register __ProtoType__((unsigned char *r1,
|
||||||
extern int is_equal_register __ProtoType__((
|
unsigned char *r2, int code));
|
||||||
unsigned char *r1,
|
extern int is_less_register __ProtoType__((unsigned char *r1, unsigned char *r2,
|
||||||
unsigned char *r2,
|
int code));
|
||||||
int code));
|
extern int is_less_or_equal_register __ProtoType__((unsigned char *r1,
|
||||||
extern int is_not_equal_register __ProtoType__((
|
unsigned char *r2,
|
||||||
unsigned char *r1,
|
int code));
|
||||||
unsigned char *r2,
|
extern int is_greater_register __ProtoType__((unsigned char *r1,
|
||||||
int code));
|
unsigned char *r2, int code));
|
||||||
extern int is_less_register __ProtoType__((
|
extern int is_greater_or_equal_register __ProtoType__((unsigned char *r1,
|
||||||
unsigned char *r1,
|
unsigned char *r2,
|
||||||
unsigned char *r2,
|
int code));
|
||||||
int code));
|
|
||||||
extern int is_less_or_equal_register __ProtoType__((
|
|
||||||
unsigned char *r1,
|
|
||||||
unsigned char *r2,
|
|
||||||
int code));
|
|
||||||
extern int is_greater_register __ProtoType__((
|
|
||||||
unsigned char *r1,
|
|
||||||
unsigned char *r2,
|
|
||||||
int code));
|
|
||||||
extern int is_greater_or_equal_register __ProtoType__((
|
|
||||||
unsigned char *r1,
|
|
||||||
unsigned char *r2,
|
|
||||||
int code));
|
|
||||||
|
|
||||||
#endif /* !_HP48_EMU_H */
|
#endif /* !_HP48_EMU_H */
|
||||||
|
|
330
src/hp48char.h
330
src/hp48char.h
|
@ -34,275 +34,81 @@
|
||||||
* $Id: hp48char.h,v 1.3 1995/01/11 18:20:01 ecd Exp ecd $
|
* $Id: hp48char.h,v 1.3 1995/01/11 18:20:01 ecd Exp ecd $
|
||||||
*/
|
*/
|
||||||
#ifndef _HP48CHAR_H
|
#ifndef _HP48CHAR_H
|
||||||
#define _HP48CHAR_H 1
|
#define _HP48CHAR_H 1
|
||||||
|
|
||||||
typedef struct trans_tbl_t {
|
typedef struct trans_tbl_t {
|
||||||
unsigned char hp48_char;
|
unsigned char hp48_char;
|
||||||
char *trans;
|
char *trans;
|
||||||
} trans_tbl_t;
|
} trans_tbl_t;
|
||||||
|
|
||||||
#ifndef DEFINE_TRANS_TABLE
|
#ifndef DEFINE_TRANS_TABLE
|
||||||
extern trans_tbl_t hp48_trans_tbl[256];
|
extern trans_tbl_t hp48_trans_tbl[256];
|
||||||
#else
|
#else
|
||||||
trans_tbl_t hp48_trans_tbl[256] =
|
trans_tbl_t hp48_trans_tbl[256] = {
|
||||||
{
|
{0, "\\0"}, {1, "\\001"}, {2, "\\002"}, {3, "\\003"},
|
||||||
{ 0, "\\0" },
|
{4, "\\004"}, {5, "\\005"}, {6, "\\006"}, {7, "\\007"},
|
||||||
{ 1, "\\001" },
|
{8, "\\b"}, {9, "\\t"}, {10, "\\n"}, {11, "\\011"},
|
||||||
{ 2, "\\002" },
|
{12, "\\f"}, {13, "\\r"}, {14, "\\014"}, {15, "\\015"},
|
||||||
{ 3, "\\003" },
|
{16, "\\016"}, {17, "\\017"}, {18, "\\018"}, {19, "\\019"},
|
||||||
{ 4, "\\004" },
|
{20, "\\020"}, {21, "\\021"}, {22, "\\022"}, {23, "\\023"},
|
||||||
{ 5, "\\005" },
|
{24, "\\024"}, {25, "\\025"}, {26, "\\026"}, {27, "\\027"},
|
||||||
{ 6, "\\006" },
|
{28, "\\028"}, {29, "\\029"}, {30, "\\030"}, {31, "\\031"},
|
||||||
{ 7, "\\007" },
|
{' ', 0}, {'!', 0}, {'"', 0}, {'#', 0},
|
||||||
{ 8, "\\b" },
|
{'$', 0}, {'%', 0}, {'&', 0}, {'\'', 0},
|
||||||
{ 9, "\\t" },
|
{'(', 0}, {')', 0}, {'*', 0}, {'+', 0},
|
||||||
{ 10, "\\n" },
|
{',', 0}, {'-', 0}, {'.', 0}, {'/', 0},
|
||||||
{ 11, "\\011" },
|
{'0', 0}, {'1', 0}, {'2', 0}, {'3', 0},
|
||||||
{ 12, "\\f" },
|
{'4', 0}, {'5', 0}, {'6', 0}, {'7', 0},
|
||||||
{ 13, "\\r" },
|
{'8', 0}, {'9', 0}, {':', 0}, {';', 0},
|
||||||
{ 14, "\\014" },
|
{'<', 0}, {'=', 0}, {'>', 0}, {'?', 0},
|
||||||
{ 15, "\\015" },
|
{'@', 0}, {'A', 0}, {'B', 0}, {'C', 0},
|
||||||
{ 16, "\\016" },
|
{'D', 0}, {'E', 0}, {'F', 0}, {'G', 0},
|
||||||
{ 17, "\\017" },
|
{'H', 0}, {'I', 0}, {'J', 0}, {'K', 0},
|
||||||
{ 18, "\\018" },
|
{'L', 0}, {'M', 0}, {'N', 0}, {'O', 0},
|
||||||
{ 19, "\\019" },
|
{'P', 0}, {'Q', 0}, {'R', 0}, {'S', 0},
|
||||||
{ 20, "\\020" },
|
{'T', 0}, {'U', 0}, {'V', 0}, {'W', 0},
|
||||||
{ 21, "\\021" },
|
{'X', 0}, {'Y', 0}, {'Z', 0}, {'[', 0},
|
||||||
{ 22, "\\022" },
|
{'\\', 0}, {']', 0}, {'^', 0}, {'_', 0},
|
||||||
{ 23, "\\023" },
|
{'`', 0}, {'a', 0}, {'b', 0}, {'c', 0},
|
||||||
{ 24, "\\024" },
|
{'d', 0}, {'e', 0}, {'f', 0}, {'g', 0},
|
||||||
{ 25, "\\025" },
|
{'h', 0}, {'i', 0}, {'j', 0}, {'k', 0},
|
||||||
{ 26, "\\026" },
|
{'l', 0}, {'m', 0}, {'n', 0}, {'o', 0},
|
||||||
{ 27, "\\027" },
|
{'p', 0}, {'q', 0}, {'r', 0}, {'s', 0},
|
||||||
{ 28, "\\028" },
|
{'t', 0}, {'u', 0}, {'v', 0}, {'w', 0},
|
||||||
{ 29, "\\029" },
|
{'x', 0}, {'y', 0}, {'z', 0}, {'{', 0},
|
||||||
{ 30, "\\030" },
|
{'|', 0}, {'}', 0}, {'~', 0}, {127, "\\127"},
|
||||||
{ 31, "\\031" },
|
{128, "\\<)"}, {129, "\\x-"}, {130, "\\.V"}, {131, "\\v/"},
|
||||||
{ ' ', 0 },
|
{132, "\\.S"}, {133, "\\GS"}, {134, "\\|>"}, {135, "\\pi"},
|
||||||
{ '!', 0 },
|
{136, "\\.d"}, {137, "\\<="}, {138, "\\>="}, {139, "\\=/"},
|
||||||
{ '"', 0 },
|
{140, "\\Ga"}, {141, "\\->"}, {142, "\\<-"}, {143, "\\|v"},
|
||||||
{ '#', 0 },
|
{144, "\\|^"}, {145, "\\Gg"}, {146, "\\Gd"}, {147, "\\Ge"},
|
||||||
{ '$', 0 },
|
{148, "\\Gn"}, {149, "\\Gh"}, {150, "\\Gl"}, {151, "\\Gr"},
|
||||||
{ '%', 0 },
|
{152, "\\Gs"}, {153, "\\Gt"}, {154, "\\Gw"}, {155, "\\GD"},
|
||||||
{ '&', 0 },
|
{156, "\\PI"}, {157, "\\GW"}, {158, "\\[]"}, {159, "\\oo"},
|
||||||
{ '\'', 0 },
|
{160, "\\160"}, {161, "\\161"}, {162, "\\162"}, {163, "\\163"},
|
||||||
{ '(', 0 },
|
{164, "\\164"}, {165, "\\165"}, {166, "\\166"}, {167, "\\167"},
|
||||||
{ ')', 0 },
|
{168, "\\168"}, {169, "\\169"}, {170, "\\170"}, {171, "\\<<"},
|
||||||
{ '*', 0 },
|
{172, "\\172"}, {173, "\\173"}, {174, "\\174"}, {175, "\\175"},
|
||||||
{ '+', 0 },
|
{176, "\\^o"}, {177, "\\177"}, {178, "\\178"}, {179, "\\179"},
|
||||||
{ ',', 0 },
|
{180, "\\180"}, {181, "\\Gm"}, {182, "\\182"}, {183, "\\183"},
|
||||||
{ '-', 0 },
|
{184, "\\184"}, {185, "\\185"}, {186, "\\186"}, {187, "\\>>"},
|
||||||
{ '.', 0 },
|
{188, "\\188"}, {189, "\\189"}, {190, "\\190"}, {191, "\\191"},
|
||||||
{ '/', 0 },
|
{192, "\\192"}, {193, "\\193"}, {194, "\\194"}, {195, "\\195"},
|
||||||
{ '0', 0 },
|
{196, "\\196"}, {197, "\\197"}, {198, "\\198"}, {199, "\\199"},
|
||||||
{ '1', 0 },
|
{200, "\\200"}, {201, "\\201"}, {202, "\\202"}, {203, "\\203"},
|
||||||
{ '2', 0 },
|
{204, "\\204"}, {205, "\\205"}, {206, "\\206"}, {207, "\\207"},
|
||||||
{ '3', 0 },
|
{208, "\\208"}, {209, "\\209"}, {210, "\\210"}, {211, "\\211"},
|
||||||
{ '4', 0 },
|
{212, "\\212"}, {213, "\\213"}, {214, "\\214"}, {215, "\\.x"},
|
||||||
{ '5', 0 },
|
{216, "\\O/"}, {217, "\\217"}, {218, "\\218"}, {219, "\\219"},
|
||||||
{ '6', 0 },
|
{220, "\\220"}, {221, "\\221"}, {222, "\\222"}, {223, "\\223"},
|
||||||
{ '7', 0 },
|
{224, "\\224"}, {225, "\\225"}, {226, "\\226"}, {227, "\\227"},
|
||||||
{ '8', 0 },
|
{228, "\\228"}, {229, "\\229"}, {230, "\\230"}, {231, "\\231"},
|
||||||
{ '9', 0 },
|
{232, "\\232"}, {233, "\\233"}, {234, "\\234"}, {235, "\\235"},
|
||||||
{ ':', 0 },
|
{236, "\\236"}, {237, "\\237"}, {238, "\\238"}, {239, "\\239"},
|
||||||
{ ';', 0 },
|
{240, "\\240"}, {241, "\\241"}, {242, "\\242"}, {243, "\\243"},
|
||||||
{ '<', 0 },
|
{244, "\\244"}, {245, "\\245"}, {246, "\\246"}, {247, "\\:-"},
|
||||||
{ '=', 0 },
|
{248, "\\248"}, {249, "\\249"}, {250, "\\250"}, {251, "\\251"},
|
||||||
{ '>', 0 },
|
{252, "\\252"}, {253, "\\253"}, {254, "\\254"}, {255, "\\255"}};
|
||||||
{ '?', 0 },
|
|
||||||
{ '@', 0 },
|
|
||||||
{ 'A', 0 },
|
|
||||||
{ 'B', 0 },
|
|
||||||
{ 'C', 0 },
|
|
||||||
{ 'D', 0 },
|
|
||||||
{ 'E', 0 },
|
|
||||||
{ 'F', 0 },
|
|
||||||
{ 'G', 0 },
|
|
||||||
{ 'H', 0 },
|
|
||||||
{ 'I', 0 },
|
|
||||||
{ 'J', 0 },
|
|
||||||
{ 'K', 0 },
|
|
||||||
{ 'L', 0 },
|
|
||||||
{ 'M', 0 },
|
|
||||||
{ 'N', 0 },
|
|
||||||
{ 'O', 0 },
|
|
||||||
{ 'P', 0 },
|
|
||||||
{ 'Q', 0 },
|
|
||||||
{ 'R', 0 },
|
|
||||||
{ 'S', 0 },
|
|
||||||
{ 'T', 0 },
|
|
||||||
{ 'U', 0 },
|
|
||||||
{ 'V', 0 },
|
|
||||||
{ 'W', 0 },
|
|
||||||
{ 'X', 0 },
|
|
||||||
{ 'Y', 0 },
|
|
||||||
{ 'Z', 0 },
|
|
||||||
{ '[', 0 },
|
|
||||||
{ '\\', 0 },
|
|
||||||
{ ']', 0 },
|
|
||||||
{ '^', 0 },
|
|
||||||
{ '_', 0 },
|
|
||||||
{ '`', 0 },
|
|
||||||
{ 'a', 0 },
|
|
||||||
{ 'b', 0 },
|
|
||||||
{ 'c', 0 },
|
|
||||||
{ 'd', 0 },
|
|
||||||
{ 'e', 0 },
|
|
||||||
{ 'f', 0 },
|
|
||||||
{ 'g', 0 },
|
|
||||||
{ 'h', 0 },
|
|
||||||
{ 'i', 0 },
|
|
||||||
{ 'j', 0 },
|
|
||||||
{ 'k', 0 },
|
|
||||||
{ 'l', 0 },
|
|
||||||
{ 'm', 0 },
|
|
||||||
{ 'n', 0 },
|
|
||||||
{ 'o', 0 },
|
|
||||||
{ 'p', 0 },
|
|
||||||
{ 'q', 0 },
|
|
||||||
{ 'r', 0 },
|
|
||||||
{ 's', 0 },
|
|
||||||
{ 't', 0 },
|
|
||||||
{ 'u', 0 },
|
|
||||||
{ 'v', 0 },
|
|
||||||
{ 'w', 0 },
|
|
||||||
{ 'x', 0 },
|
|
||||||
{ 'y', 0 },
|
|
||||||
{ 'z', 0 },
|
|
||||||
{ '{', 0 },
|
|
||||||
{ '|', 0 },
|
|
||||||
{ '}', 0 },
|
|
||||||
{ '~', 0 },
|
|
||||||
{ 127, "\\127" },
|
|
||||||
{ 128, "\\<)" },
|
|
||||||
{ 129, "\\x-" },
|
|
||||||
{ 130, "\\.V" },
|
|
||||||
{ 131, "\\v/" },
|
|
||||||
{ 132, "\\.S" },
|
|
||||||
{ 133, "\\GS" },
|
|
||||||
{ 134, "\\|>" },
|
|
||||||
{ 135, "\\pi" },
|
|
||||||
{ 136, "\\.d" },
|
|
||||||
{ 137, "\\<=" },
|
|
||||||
{ 138, "\\>=" },
|
|
||||||
{ 139, "\\=/" },
|
|
||||||
{ 140, "\\Ga" },
|
|
||||||
{ 141, "\\->" },
|
|
||||||
{ 142, "\\<-" },
|
|
||||||
{ 143, "\\|v" },
|
|
||||||
{ 144, "\\|^" },
|
|
||||||
{ 145, "\\Gg" },
|
|
||||||
{ 146, "\\Gd" },
|
|
||||||
{ 147, "\\Ge" },
|
|
||||||
{ 148, "\\Gn" },
|
|
||||||
{ 149, "\\Gh" },
|
|
||||||
{ 150, "\\Gl" },
|
|
||||||
{ 151, "\\Gr" },
|
|
||||||
{ 152, "\\Gs" },
|
|
||||||
{ 153, "\\Gt" },
|
|
||||||
{ 154, "\\Gw" },
|
|
||||||
{ 155, "\\GD" },
|
|
||||||
{ 156, "\\PI" },
|
|
||||||
{ 157, "\\GW" },
|
|
||||||
{ 158, "\\[]" },
|
|
||||||
{ 159, "\\oo" },
|
|
||||||
{ 160, "\\160" },
|
|
||||||
{ 161, "\\161" },
|
|
||||||
{ 162, "\\162" },
|
|
||||||
{ 163, "\\163" },
|
|
||||||
{ 164, "\\164" },
|
|
||||||
{ 165, "\\165" },
|
|
||||||
{ 166, "\\166" },
|
|
||||||
{ 167, "\\167" },
|
|
||||||
{ 168, "\\168" },
|
|
||||||
{ 169, "\\169" },
|
|
||||||
{ 170, "\\170" },
|
|
||||||
{ 171, "\\<<" },
|
|
||||||
{ 172, "\\172" },
|
|
||||||
{ 173, "\\173" },
|
|
||||||
{ 174, "\\174" },
|
|
||||||
{ 175, "\\175" },
|
|
||||||
{ 176, "\\^o" },
|
|
||||||
{ 177, "\\177" },
|
|
||||||
{ 178, "\\178" },
|
|
||||||
{ 179, "\\179" },
|
|
||||||
{ 180, "\\180" },
|
|
||||||
{ 181, "\\Gm" },
|
|
||||||
{ 182, "\\182" },
|
|
||||||
{ 183, "\\183" },
|
|
||||||
{ 184, "\\184" },
|
|
||||||
{ 185, "\\185" },
|
|
||||||
{ 186, "\\186" },
|
|
||||||
{ 187, "\\>>" },
|
|
||||||
{ 188, "\\188" },
|
|
||||||
{ 189, "\\189" },
|
|
||||||
{ 190, "\\190" },
|
|
||||||
{ 191, "\\191" },
|
|
||||||
{ 192, "\\192" },
|
|
||||||
{ 193, "\\193" },
|
|
||||||
{ 194, "\\194" },
|
|
||||||
{ 195, "\\195" },
|
|
||||||
{ 196, "\\196" },
|
|
||||||
{ 197, "\\197" },
|
|
||||||
{ 198, "\\198" },
|
|
||||||
{ 199, "\\199" },
|
|
||||||
{ 200, "\\200" },
|
|
||||||
{ 201, "\\201" },
|
|
||||||
{ 202, "\\202" },
|
|
||||||
{ 203, "\\203" },
|
|
||||||
{ 204, "\\204" },
|
|
||||||
{ 205, "\\205" },
|
|
||||||
{ 206, "\\206" },
|
|
||||||
{ 207, "\\207" },
|
|
||||||
{ 208, "\\208" },
|
|
||||||
{ 209, "\\209" },
|
|
||||||
{ 210, "\\210" },
|
|
||||||
{ 211, "\\211" },
|
|
||||||
{ 212, "\\212" },
|
|
||||||
{ 213, "\\213" },
|
|
||||||
{ 214, "\\214" },
|
|
||||||
{ 215, "\\.x" },
|
|
||||||
{ 216, "\\O/" },
|
|
||||||
{ 217, "\\217" },
|
|
||||||
{ 218, "\\218" },
|
|
||||||
{ 219, "\\219" },
|
|
||||||
{ 220, "\\220" },
|
|
||||||
{ 221, "\\221" },
|
|
||||||
{ 222, "\\222" },
|
|
||||||
{ 223, "\\223" },
|
|
||||||
{ 224, "\\224" },
|
|
||||||
{ 225, "\\225" },
|
|
||||||
{ 226, "\\226" },
|
|
||||||
{ 227, "\\227" },
|
|
||||||
{ 228, "\\228" },
|
|
||||||
{ 229, "\\229" },
|
|
||||||
{ 230, "\\230" },
|
|
||||||
{ 231, "\\231" },
|
|
||||||
{ 232, "\\232" },
|
|
||||||
{ 233, "\\233" },
|
|
||||||
{ 234, "\\234" },
|
|
||||||
{ 235, "\\235" },
|
|
||||||
{ 236, "\\236" },
|
|
||||||
{ 237, "\\237" },
|
|
||||||
{ 238, "\\238" },
|
|
||||||
{ 239, "\\239" },
|
|
||||||
{ 240, "\\240" },
|
|
||||||
{ 241, "\\241" },
|
|
||||||
{ 242, "\\242" },
|
|
||||||
{ 243, "\\243" },
|
|
||||||
{ 244, "\\244" },
|
|
||||||
{ 245, "\\245" },
|
|
||||||
{ 246, "\\246" },
|
|
||||||
{ 247, "\\:-" },
|
|
||||||
{ 248, "\\248" },
|
|
||||||
{ 249, "\\249" },
|
|
||||||
{ 250, "\\250" },
|
|
||||||
{ 251, "\\251" },
|
|
||||||
{ 252, "\\252" },
|
|
||||||
{ 253, "\\253" },
|
|
||||||
{ 254, "\\254" },
|
|
||||||
{ 255, "\\255" }
|
|
||||||
};
|
|
||||||
#endif /* DEFINE_TRANS_TABLE */
|
#endif /* DEFINE_TRANS_TABLE */
|
||||||
|
|
||||||
#endif /* !_HP48CHAR_H */
|
#endif /* !_HP48CHAR_H */
|
||||||
|
|
1534
src/init.c
1534
src/init.c
File diff suppressed because it is too large
Load diff
216
src/lcd.c
216
src/lcd.c
|
@ -60,55 +60,53 @@
|
||||||
* $Id: lcd.c,v 1.13 1995/01/11 18:20:01 ecd Exp ecd $
|
* $Id: lcd.c,v 1.13 1995/01/11 18:20:01 ecd Exp ecd $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#ifdef SUNOS
|
#ifdef SUNOS
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#endif
|
#endif
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
|
#include "annunc.h"
|
||||||
|
#include "device.h"
|
||||||
#include "hp48.h"
|
#include "hp48.h"
|
||||||
#include "hp48_emu.h"
|
#include "hp48_emu.h"
|
||||||
#include "x48_x11.h"
|
#include "x48_x11.h"
|
||||||
#include "annunc.h"
|
|
||||||
#include "device.h"
|
|
||||||
|
|
||||||
static int last_annunc_state = -1;
|
static int last_annunc_state = -1;
|
||||||
|
|
||||||
display_t display;
|
display_t display;
|
||||||
|
|
||||||
#define DISP_ROWS 64
|
#define DISP_ROWS 64
|
||||||
|
|
||||||
#define NIBS_PER_BUFFER_ROW (NIBBLES_PER_ROW + 2)
|
#define NIBS_PER_BUFFER_ROW (NIBBLES_PER_ROW + 2)
|
||||||
|
|
||||||
unsigned char disp_buf[DISP_ROWS][NIBS_PER_BUFFER_ROW];
|
unsigned char disp_buf[DISP_ROWS][NIBS_PER_BUFFER_ROW];
|
||||||
unsigned char lcd_buffer[DISP_ROWS][NIBS_PER_BUFFER_ROW];
|
unsigned char lcd_buffer[DISP_ROWS][NIBS_PER_BUFFER_ROW];
|
||||||
|
|
||||||
Pixmap nibble_maps[16];
|
Pixmap nibble_maps[16];
|
||||||
|
|
||||||
unsigned char nibbles[16][2] =
|
unsigned char nibbles[16][2] = {
|
||||||
{
|
{0x00, 0x00}, /* ---- */
|
||||||
{ 0x00, 0x00 }, /* ---- */
|
{0x03, 0x03}, /* *--- */
|
||||||
{ 0x03, 0x03 }, /* *--- */
|
{0x0c, 0x0c}, /* -*-- */
|
||||||
{ 0x0c, 0x0c }, /* -*-- */
|
{0x0f, 0x0f}, /* **-- */
|
||||||
{ 0x0f, 0x0f }, /* **-- */
|
{0x30, 0x30}, /* --*- */
|
||||||
{ 0x30, 0x30 }, /* --*- */
|
{0x33, 0x33}, /* *-*- */
|
||||||
{ 0x33, 0x33 }, /* *-*- */
|
{0x3c, 0x3c}, /* -**- */
|
||||||
{ 0x3c, 0x3c }, /* -**- */
|
{0x3f, 0x3f}, /* ***- */
|
||||||
{ 0x3f, 0x3f }, /* ***- */
|
{0xc0, 0xc0}, /* ---* */
|
||||||
{ 0xc0, 0xc0 }, /* ---* */
|
{0xc3, 0xc3}, /* *--* */
|
||||||
{ 0xc3, 0xc3 }, /* *--* */
|
{0xcc, 0xcc}, /* -*-* */
|
||||||
{ 0xcc, 0xcc }, /* -*-* */
|
{0xcf, 0xcf}, /* **-* */
|
||||||
{ 0xcf, 0xcf }, /* **-* */
|
{0xf0, 0xf0}, /* --** */
|
||||||
{ 0xf0, 0xf0 }, /* --** */
|
{0xf3, 0xf3}, /* *-** */
|
||||||
{ 0xf3, 0xf3 }, /* *-** */
|
{0xfc, 0xfc}, /* -*** */
|
||||||
{ 0xfc, 0xfc }, /* -*** */
|
{0xff, 0xff} /* **** */
|
||||||
{ 0xff, 0xff } /* **** */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static unsigned char nibble_bits[16];
|
static unsigned char nibble_bits[16];
|
||||||
|
@ -117,45 +115,45 @@ void init_nibble_maps(void) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 16; i++) {
|
for (i = 0; i < 16; i++) {
|
||||||
nibble_maps[i] = XCreateBitmapFromData(dpy, disp.win,
|
nibble_maps[i] =
|
||||||
(char *)nibbles[i], 8, 2);
|
XCreateBitmapFromData(dpy, disp.win, (char *)nibbles[i], 8, 2);
|
||||||
}
|
}
|
||||||
#ifdef HAVE_XSHM
|
#ifdef HAVE_XSHM
|
||||||
if (shm_flag) {
|
if (shm_flag) {
|
||||||
if (disp.disp_image->bitmap_bit_order == MSBFirst) {
|
if (disp.disp_image->bitmap_bit_order == MSBFirst) {
|
||||||
nibble_bits[0x0] = 0x00; /* ---- */
|
nibble_bits[0x0] = 0x00; /* ---- */
|
||||||
nibble_bits[0x1] = 0xc0; /* *--- */
|
nibble_bits[0x1] = 0xc0; /* *--- */
|
||||||
nibble_bits[0x2] = 0x30; /* -*-- */
|
nibble_bits[0x2] = 0x30; /* -*-- */
|
||||||
nibble_bits[0x3] = 0xf0; /* **-- */
|
nibble_bits[0x3] = 0xf0; /* **-- */
|
||||||
nibble_bits[0x4] = 0x0c; /* --*- */
|
nibble_bits[0x4] = 0x0c; /* --*- */
|
||||||
nibble_bits[0x5] = 0xcc; /* *-*- */
|
nibble_bits[0x5] = 0xcc; /* *-*- */
|
||||||
nibble_bits[0x6] = 0x3c; /* -**- */
|
nibble_bits[0x6] = 0x3c; /* -**- */
|
||||||
nibble_bits[0x7] = 0xfc; /* ***- */
|
nibble_bits[0x7] = 0xfc; /* ***- */
|
||||||
nibble_bits[0x8] = 0x03; /* ---* */
|
nibble_bits[0x8] = 0x03; /* ---* */
|
||||||
nibble_bits[0x9] = 0xc3; /* *--* */
|
nibble_bits[0x9] = 0xc3; /* *--* */
|
||||||
nibble_bits[0xa] = 0x33; /* -*-* */
|
nibble_bits[0xa] = 0x33; /* -*-* */
|
||||||
nibble_bits[0xb] = 0xf3; /* **-* */
|
nibble_bits[0xb] = 0xf3; /* **-* */
|
||||||
nibble_bits[0xc] = 0x0f; /* --** */
|
nibble_bits[0xc] = 0x0f; /* --** */
|
||||||
nibble_bits[0xd] = 0xcf; /* *-** */
|
nibble_bits[0xd] = 0xcf; /* *-** */
|
||||||
nibble_bits[0xe] = 0x3f; /* -*** */
|
nibble_bits[0xe] = 0x3f; /* -*** */
|
||||||
nibble_bits[0xf] = 0xff; /* **** */
|
nibble_bits[0xf] = 0xff; /* **** */
|
||||||
} else {
|
} else {
|
||||||
nibble_bits[0x0] = 0x00; /* ---- */
|
nibble_bits[0x0] = 0x00; /* ---- */
|
||||||
nibble_bits[0x1] = 0x03; /* *--- */
|
nibble_bits[0x1] = 0x03; /* *--- */
|
||||||
nibble_bits[0x2] = 0x0c; /* -*-- */
|
nibble_bits[0x2] = 0x0c; /* -*-- */
|
||||||
nibble_bits[0x3] = 0x0f; /* **-- */
|
nibble_bits[0x3] = 0x0f; /* **-- */
|
||||||
nibble_bits[0x4] = 0x30; /* --*- */
|
nibble_bits[0x4] = 0x30; /* --*- */
|
||||||
nibble_bits[0x5] = 0x33; /* *-*- */
|
nibble_bits[0x5] = 0x33; /* *-*- */
|
||||||
nibble_bits[0x6] = 0x3c; /* -**- */
|
nibble_bits[0x6] = 0x3c; /* -**- */
|
||||||
nibble_bits[0x7] = 0x3f; /* ***- */
|
nibble_bits[0x7] = 0x3f; /* ***- */
|
||||||
nibble_bits[0x8] = 0xc0; /* ---* */
|
nibble_bits[0x8] = 0xc0; /* ---* */
|
||||||
nibble_bits[0x9] = 0xc3; /* *--* */
|
nibble_bits[0x9] = 0xc3; /* *--* */
|
||||||
nibble_bits[0xa] = 0xcc; /* -*-* */
|
nibble_bits[0xa] = 0xcc; /* -*-* */
|
||||||
nibble_bits[0xb] = 0xcf; /* **-* */
|
nibble_bits[0xb] = 0xcf; /* **-* */
|
||||||
nibble_bits[0xc] = 0xf0; /* --** */
|
nibble_bits[0xc] = 0xf0; /* --** */
|
||||||
nibble_bits[0xd] = 0xf3; /* *-** */
|
nibble_bits[0xd] = 0xf3; /* *-** */
|
||||||
nibble_bits[0xe] = 0xfc; /* -*** */
|
nibble_bits[0xe] = 0xfc; /* -*** */
|
||||||
nibble_bits[0xf] = 0xff; /* **** */
|
nibble_bits[0xf] = 0xff; /* **** */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -176,12 +174,12 @@ void init_display(void) {
|
||||||
disp.lines = 110;
|
disp.lines = 110;
|
||||||
|
|
||||||
if (display.offset > 3)
|
if (display.offset > 3)
|
||||||
display.nibs_per_line = (NIBBLES_PER_ROW+saturn.line_offset+2) & 0xfff;
|
display.nibs_per_line = (NIBBLES_PER_ROW + saturn.line_offset + 2) & 0xfff;
|
||||||
else
|
else
|
||||||
display.nibs_per_line = (NIBBLES_PER_ROW+saturn.line_offset) & 0xfff;
|
display.nibs_per_line = (NIBBLES_PER_ROW + saturn.line_offset) & 0xfff;
|
||||||
|
|
||||||
display.disp_end = display.disp_start +
|
display.disp_end =
|
||||||
(display.nibs_per_line * (display.lines + 1));
|
display.disp_start + (display.nibs_per_line * (display.lines + 1));
|
||||||
|
|
||||||
display.menu_start = saturn.menu_addr;
|
display.menu_start = saturn.menu_addr;
|
||||||
display.menu_end = saturn.menu_addr + 0x110;
|
display.menu_end = saturn.menu_addr + 0x110;
|
||||||
|
@ -238,11 +236,10 @@ void update_display(void) {
|
||||||
word_20 data_addr, data_addr_2;
|
word_20 data_addr, data_addr_2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!disp.mapped)
|
if (!disp.mapped) {
|
||||||
{
|
refresh_icon();
|
||||||
refresh_icon();
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
if (display.on) {
|
if (display.on) {
|
||||||
addr = display.disp_start;
|
addr = display.disp_start;
|
||||||
#ifdef HAVE_XSHM
|
#ifdef HAVE_XSHM
|
||||||
|
@ -269,9 +266,9 @@ void update_display(void) {
|
||||||
#endif
|
#endif
|
||||||
if (display.offset != old_offset) {
|
if (display.offset != old_offset) {
|
||||||
memset(disp_buf, 0xf0,
|
memset(disp_buf, 0xf0,
|
||||||
(size_t)((display.lines+1) * NIBS_PER_BUFFER_ROW));
|
(size_t)((display.lines + 1) * NIBS_PER_BUFFER_ROW));
|
||||||
memset(lcd_buffer, 0xf0,
|
memset(lcd_buffer, 0xf0,
|
||||||
(size_t)((display.lines+1) * NIBS_PER_BUFFER_ROW));
|
(size_t)((display.lines + 1) * NIBS_PER_BUFFER_ROW));
|
||||||
old_offset = display.offset;
|
old_offset = display.offset;
|
||||||
}
|
}
|
||||||
if (display.lines != old_lines) {
|
if (display.lines != old_lines) {
|
||||||
|
@ -316,9 +313,11 @@ void update_display(void) {
|
||||||
} else {
|
} else {
|
||||||
#ifdef HAVE_XSHM
|
#ifdef HAVE_XSHM
|
||||||
if (shm_flag) {
|
if (shm_flag) {
|
||||||
memset(disp.disp_image->data, 0,
|
memset(
|
||||||
|
disp.disp_image->data, 0,
|
||||||
(size_t)(disp.disp_image->bytes_per_line * disp.disp_image->height));
|
(size_t)(disp.disp_image->bytes_per_line * disp.disp_image->height));
|
||||||
memset(disp.menu_image->data, 0,
|
memset(
|
||||||
|
disp.menu_image->data, 0,
|
||||||
(size_t)(disp.menu_image->bytes_per_line * disp.menu_image->height));
|
(size_t)(disp.menu_image->bytes_per_line * disp.menu_image->height));
|
||||||
disp.display_update = UPDATE_DISP | UPDATE_MENU;
|
disp.display_update = UPDATE_DISP | UPDATE_MENU;
|
||||||
} else {
|
} else {
|
||||||
|
@ -361,8 +360,8 @@ void disp_draw_nibble(word_20 addr, word_4 val) {
|
||||||
if (shm_flag) {
|
if (shm_flag) {
|
||||||
shm_addr = (2 * y * disp.disp_image->bytes_per_line) + x;
|
shm_addr = (2 * y * disp.disp_image->bytes_per_line) + x;
|
||||||
disp.disp_image->data[shm_addr] = nibble_bits[val];
|
disp.disp_image->data[shm_addr] = nibble_bits[val];
|
||||||
disp.disp_image->data[shm_addr+disp.disp_image->bytes_per_line] =
|
disp.disp_image->data[shm_addr + disp.disp_image->bytes_per_line] =
|
||||||
nibble_bits[val];
|
nibble_bits[val];
|
||||||
disp.display_update |= UPDATE_DISP;
|
disp.display_update |= UPDATE_DISP;
|
||||||
} else {
|
} else {
|
||||||
#endif
|
#endif
|
||||||
|
@ -380,8 +379,7 @@ void disp_draw_nibble(word_20 addr, word_4 val) {
|
||||||
for (y = 0; y < display.lines; y++) {
|
for (y = 0; y < display.lines; y++) {
|
||||||
disp.disp_image->data[shm_addr] = nibble_bits[val];
|
disp.disp_image->data[shm_addr] = nibble_bits[val];
|
||||||
shm_addr += disp.disp_image->bytes_per_line;
|
shm_addr += disp.disp_image->bytes_per_line;
|
||||||
disp.disp_image->data[shm_addr]
|
disp.disp_image->data[shm_addr] = nibble_bits[val];
|
||||||
= nibble_bits[val];
|
|
||||||
shm_addr += disp.disp_image->bytes_per_line;
|
shm_addr += disp.disp_image->bytes_per_line;
|
||||||
}
|
}
|
||||||
disp.display_update |= UPDATE_DISP;
|
disp.display_update |= UPDATE_DISP;
|
||||||
|
@ -409,11 +407,12 @@ void menu_draw_nibble(word_20 addr, word_4 val) {
|
||||||
offset = (addr - display.menu_start);
|
offset = (addr - display.menu_start);
|
||||||
#ifdef HAVE_XSHM
|
#ifdef HAVE_XSHM
|
||||||
if (shm_flag) {
|
if (shm_flag) {
|
||||||
shm_addr = 2 * (offset / NIBBLES_PER_ROW) * disp.menu_image->bytes_per_line
|
shm_addr =
|
||||||
+ (offset % NIBBLES_PER_ROW);
|
2 * (offset / NIBBLES_PER_ROW) * disp.menu_image->bytes_per_line +
|
||||||
|
(offset % NIBBLES_PER_ROW);
|
||||||
disp.menu_image->data[shm_addr] = nibble_bits[val];
|
disp.menu_image->data[shm_addr] = nibble_bits[val];
|
||||||
disp.menu_image->data[shm_addr+disp.menu_image->bytes_per_line] =
|
disp.menu_image->data[shm_addr + disp.menu_image->bytes_per_line] =
|
||||||
nibble_bits[val];
|
nibble_bits[val];
|
||||||
disp.display_update |= UPDATE_MENU;
|
disp.display_update |= UPDATE_MENU;
|
||||||
} else {
|
} else {
|
||||||
#endif
|
#endif
|
||||||
|
@ -428,25 +427,23 @@ void menu_draw_nibble(word_20 addr, word_4 val) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct ann_struct {
|
struct ann_struct {
|
||||||
int bit;
|
int bit;
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
unsigned char *bits;
|
unsigned char *bits;
|
||||||
Pixmap pixmap;
|
Pixmap pixmap;
|
||||||
} ann_tbl[] = {
|
} ann_tbl[] = {
|
||||||
{ ANN_LEFT, 16, 4, ann_left_width, ann_left_height, ann_left_bits },
|
{ANN_LEFT, 16, 4, ann_left_width, ann_left_height, ann_left_bits},
|
||||||
{ ANN_RIGHT, 61, 4, ann_right_width, ann_right_height, ann_right_bits },
|
{ANN_RIGHT, 61, 4, ann_right_width, ann_right_height, ann_right_bits},
|
||||||
{ ANN_ALPHA, 106, 4, ann_alpha_width, ann_alpha_height, ann_alpha_bits },
|
{ANN_ALPHA, 106, 4, ann_alpha_width, ann_alpha_height, ann_alpha_bits},
|
||||||
{ ANN_BATTERY, 151, 4, ann_battery_width, ann_battery_height,
|
{ANN_BATTERY, 151, 4, ann_battery_width, ann_battery_height,
|
||||||
ann_battery_bits },
|
ann_battery_bits},
|
||||||
{ ANN_BUSY, 196, 4, ann_busy_width, ann_busy_height, ann_busy_bits },
|
{ANN_BUSY, 196, 4, ann_busy_width, ann_busy_height, ann_busy_bits},
|
||||||
{ ANN_IO, 241, 4, ann_io_width, ann_io_height, ann_io_bits },
|
{ANN_IO, 241, 4, ann_io_width, ann_io_height, ann_io_bits},
|
||||||
{ 0 }
|
{0}};
|
||||||
};
|
|
||||||
|
|
||||||
void draw_annunc(void) {
|
void draw_annunc(void) {
|
||||||
int val;
|
int val;
|
||||||
|
@ -457,20 +454,16 @@ void draw_annunc(void) {
|
||||||
if (val == last_annunc_state)
|
if (val == last_annunc_state)
|
||||||
return;
|
return;
|
||||||
last_annunc_state = val;
|
last_annunc_state = val;
|
||||||
for (i = 0; ann_tbl[i].bit; i++)
|
for (i = 0; ann_tbl[i].bit; i++) {
|
||||||
{
|
if ((ann_tbl[i].bit & val) == ann_tbl[i].bit) {
|
||||||
if ((ann_tbl[i].bit & val) == ann_tbl[i].bit)
|
XCopyPlane(dpy, ann_tbl[i].pixmap, disp.win, disp.gc, 0, 0,
|
||||||
{
|
ann_tbl[i].width, ann_tbl[i].height, ann_tbl[i].x,
|
||||||
XCopyPlane(dpy, ann_tbl[i].pixmap, disp.win, disp.gc, 0, 0,
|
ann_tbl[i].y, 1);
|
||||||
ann_tbl[i].width, ann_tbl[i].height,
|
} else {
|
||||||
ann_tbl[i].x, ann_tbl[i].y, 1);
|
XClearArea(dpy, disp.win, ann_tbl[i].x, ann_tbl[i].y, ann_tbl[i].width,
|
||||||
}
|
ann_tbl[i].height, False);
|
||||||
else
|
|
||||||
{
|
|
||||||
XClearArea(dpy, disp.win, ann_tbl[i].x, ann_tbl[i].y,
|
|
||||||
ann_tbl[i].width, ann_tbl[i].height, False);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
refresh_icon();
|
refresh_icon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,9 +476,8 @@ void init_annunc(void) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; ann_tbl[i].bit; i++) {
|
for (i = 0; ann_tbl[i].bit; i++) {
|
||||||
ann_tbl[i].pixmap = XCreateBitmapFromData(dpy, disp.win,
|
ann_tbl[i].pixmap =
|
||||||
(char *)ann_tbl[i].bits,
|
XCreateBitmapFromData(dpy, disp.win, (char *)ann_tbl[i].bits,
|
||||||
ann_tbl[i].width,
|
ann_tbl[i].width, ann_tbl[i].height);
|
||||||
ann_tbl[i].height);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
79
src/main.c
79
src/main.c
|
@ -57,45 +57,44 @@
|
||||||
* $Id: main.c,v 1.11 1995/01/11 18:20:01 ecd Exp ecd $
|
* $Id: main.c,v 1.11 1995/01/11 18:20:01 ecd Exp ecd $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <signal.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <fcntl.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "x48_x11.h"
|
|
||||||
#include "hp48.h"
|
|
||||||
#include "debugger.h"
|
#include "debugger.h"
|
||||||
|
#include "hp48.h"
|
||||||
|
#include "x48_x11.h"
|
||||||
|
|
||||||
#include <langinfo.h>
|
#include <langinfo.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
char *progname;
|
char *progname;
|
||||||
char *res_name;
|
char *res_name;
|
||||||
char *res_class;
|
char *res_class;
|
||||||
|
|
||||||
int saved_argc;
|
int saved_argc;
|
||||||
char **saved_argv;
|
char **saved_argv;
|
||||||
|
|
||||||
saturn_t saturn;
|
saturn_t saturn;
|
||||||
|
|
||||||
void signal_handler(int sig) {
|
void signal_handler(int sig) {
|
||||||
switch (sig) {
|
switch (sig) {
|
||||||
case SIGINT:
|
case SIGINT:
|
||||||
enter_debugger |= USER_INTERRUPT;
|
enter_debugger |= USER_INTERRUPT;
|
||||||
break;
|
break;
|
||||||
case SIGALRM:
|
case SIGALRM:
|
||||||
got_alarm = 1;
|
got_alarm = 1;
|
||||||
break;
|
break;
|
||||||
case SIGPIPE:
|
case SIGPIPE:
|
||||||
exit_x48(0);
|
exit_x48(0);
|
||||||
exit (0);
|
exit(0);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,24 +103,20 @@ void save_options(int argc, char **argv) {
|
||||||
|
|
||||||
saved_argc = argc;
|
saved_argc = argc;
|
||||||
saved_argv = (char **)malloc((argc + 2) * sizeof(char *));
|
saved_argv = (char **)malloc((argc + 2) * sizeof(char *));
|
||||||
if (saved_argv == (char **)0)
|
if (saved_argv == (char **)0) {
|
||||||
{
|
fprintf(stderr, "%s: malloc failed in save_options(), exit\n", progname);
|
||||||
fprintf(stderr, "%s: malloc failed in save_options(), exit\n", progname);
|
exit(1);
|
||||||
exit (1);
|
}
|
||||||
}
|
|
||||||
saved_argv[argc] = (char *)0;
|
saved_argv[argc] = (char *)0;
|
||||||
while (argc--)
|
while (argc--) {
|
||||||
{
|
l = strlen(argv[argc]) + 1;
|
||||||
l = strlen(argv[argc]) + 1;
|
saved_argv[argc] = (char *)malloc(l);
|
||||||
saved_argv[argc] = (char *)malloc(l);
|
if (saved_argv[argc] == (char *)0) {
|
||||||
if (saved_argv[argc] == (char *)0)
|
fprintf(stderr, "%s: malloc failed in save_options(), exit\n", progname);
|
||||||
{
|
exit(1);
|
||||||
fprintf(stderr, "%s: malloc failed in save_options(), exit\n",
|
|
||||||
progname);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
memcpy(saved_argv[argc], argv[argc], l);
|
|
||||||
}
|
}
|
||||||
|
memcpy(saved_argv[argc], argv[argc], l);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
@ -152,7 +147,7 @@ int main(int argc, char **argv) {
|
||||||
* Open up the display
|
* Open up the display
|
||||||
*/
|
*/
|
||||||
if (InitDisplay(argc, argv) < 0) {
|
if (InitDisplay(argc, argv) < 0) {
|
||||||
exit (1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -165,7 +160,7 @@ int main(int argc, char **argv) {
|
||||||
*/
|
*/
|
||||||
if (CreateWindows(saved_argc, saved_argv) < 0) {
|
if (CreateWindows(saved_argc, saved_argv) < 0) {
|
||||||
fprintf(stderr, "%s: can\'t create window\n", progname);
|
fprintf(stderr, "%s: can\'t create window\n", progname);
|
||||||
exit (1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -229,9 +224,9 @@ int main(int argc, char **argv) {
|
||||||
do {
|
do {
|
||||||
|
|
||||||
if (!exec_flags)
|
if (!exec_flags)
|
||||||
emulate ();
|
emulate();
|
||||||
else
|
else
|
||||||
emulate_debug ();
|
emulate_debug();
|
||||||
|
|
||||||
debug();
|
debug();
|
||||||
|
|
||||||
|
|
2324
src/memory.c
2324
src/memory.c
File diff suppressed because it is too large
Load diff
60
src/mkcard.c
60
src/mkcard.c
|
@ -25,13 +25,12 @@
|
||||||
* $Id: mkcard.c,v 1.1 1995/01/11 18:11:25 ecd Exp ecd $
|
* $Id: mkcard.c,v 1.1 1995/01/11 18:11:25 ecd Exp ecd $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#ifdef SUNOS
|
#ifdef SUNOS
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -42,18 +41,16 @@ unsigned char *mem;
|
||||||
int write_mem_file(char *name, unsigned char *mem, int size) {
|
int write_mem_file(char *name, unsigned char *mem, int size) {
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
if (NULL == (fp = fopen(name, "w")))
|
if (NULL == (fp = fopen(name, "w"))) {
|
||||||
{
|
fprintf(stderr, "can\'t open %s\n", name);
|
||||||
fprintf(stderr, "can\'t open %s\n", name);
|
return 0;
|
||||||
return 0;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (fwrite(mem, 1, (size_t)size, fp) != size)
|
if (fwrite(mem, 1, (size_t)size, fp) != size) {
|
||||||
{
|
fprintf(stderr, "can\'t write %s\n", name);
|
||||||
fprintf(stderr, "can\'t write %s\n", name);
|
fclose(fp);
|
||||||
fclose(fp);
|
return 0;
|
||||||
return 0;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -65,12 +62,11 @@ int main(int argc, char **argv) {
|
||||||
char *asize;
|
char *asize;
|
||||||
unsigned char *core;
|
unsigned char *core;
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2) {
|
||||||
{
|
fprintf(stderr, "usage: %s [32K | 128K | 1M | 2M | 4M] file-name\n",
|
||||||
fprintf(stderr, "usage: %s [32K | 128K | 1M | 2M | 4M] file-name\n",
|
argv[0]);
|
||||||
argv[0]);
|
exit(1);
|
||||||
exit (1);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
name = argv[2];
|
name = argv[2];
|
||||||
asize = argv[1];
|
asize = argv[1];
|
||||||
|
@ -88,25 +84,23 @@ int main(int argc, char **argv) {
|
||||||
size = 0x200000;
|
size = 0x200000;
|
||||||
else if (!strcmp(asize, "4M"))
|
else if (!strcmp(asize, "4M"))
|
||||||
size = 0x400000;
|
size = 0x400000;
|
||||||
else
|
else {
|
||||||
{
|
fprintf(stderr,
|
||||||
fprintf(stderr,
|
"%s: size must be one of 32K, 128K, 256K, 512K, 1M, 2M, or 4M\n",
|
||||||
"%s: size must be one of 32K, 128K, 256K, 512K, 1M, 2M, or 4M\n",
|
argv[0]);
|
||||||
argv[0]);
|
exit(1);
|
||||||
exit (1);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ((core = (unsigned char *)malloc(size)) == NULL) {
|
if ((core = (unsigned char *)malloc(size)) == NULL) {
|
||||||
fprintf(stderr, "%s: can\'t malloc %ld bytes\n", argv[0], size);
|
fprintf(stderr, "%s: can\'t malloc %ld bytes\n", argv[0], size);
|
||||||
exit (1);
|
exit(1);
|
||||||
}
|
}
|
||||||
memset(core, 0, size);
|
memset(core, 0, size);
|
||||||
|
|
||||||
if (!write_mem_file(name, core, size))
|
if (!write_mem_file(name, core, size)) {
|
||||||
{
|
fprintf(stderr, "%s: can\'t write to %s\n", argv[0], name);
|
||||||
fprintf(stderr, "%s: can\'t write to %s\n", argv[0], name);
|
exit(1);
|
||||||
exit (1);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
exit (0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
28
src/mmu.h
28
src/mmu.h
|
@ -27,23 +27,21 @@
|
||||||
#ifndef _MMU_H
|
#ifndef _MMU_H
|
||||||
#define _MMU_H 1
|
#define _MMU_H 1
|
||||||
|
|
||||||
|
#define NR_MCTL 6
|
||||||
|
|
||||||
#define NR_MCTL 6
|
#define MCTL_MMIO_SX 0
|
||||||
|
#define MCTL_SysRAM_SX 1
|
||||||
#define MCTL_MMIO_SX 0
|
#define MCTL_PORT1_SX 2
|
||||||
#define MCTL_SysRAM_SX 1
|
#define MCTL_PORT2_SX 3
|
||||||
#define MCTL_PORT1_SX 2
|
#define MCTL_EXTRA_SX 4
|
||||||
#define MCTL_PORT2_SX 3
|
#define MCTL_SysROM_SX 5
|
||||||
#define MCTL_EXTRA_SX 4
|
|
||||||
#define MCTL_SysROM_SX 5
|
|
||||||
|
|
||||||
#define MCTL_MMIO_GX 0
|
|
||||||
#define MCTL_SysRAM_GX 1
|
|
||||||
#define MCTL_BANK_GX 2
|
|
||||||
#define MCTL_PORT1_GX 3
|
|
||||||
#define MCTL_PORT2_GX 4
|
|
||||||
#define MCTL_SysROM_GX 5
|
|
||||||
|
|
||||||
|
#define MCTL_MMIO_GX 0
|
||||||
|
#define MCTL_SysRAM_GX 1
|
||||||
|
#define MCTL_BANK_GX 2
|
||||||
|
#define MCTL_PORT1_GX 3
|
||||||
|
#define MCTL_PORT2_GX 4
|
||||||
|
#define MCTL_SysROM_GX 5
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
extern void init_mmu __ProtoType__((void));
|
extern void init_mmu __ProtoType__((void));
|
||||||
|
|
|
@ -44,8 +44,8 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "resources.h"
|
#include "resources.h"
|
||||||
|
@ -90,18 +90,19 @@ where options include:\n\
|
||||||
-xrm <resource> set Xresource <resource>\n\
|
-xrm <resource> set Xresource <resource>\n\
|
||||||
-/+throttle turn off/on speed emulation\n\
|
-/+throttle turn off/on speed emulation\n\
|
||||||
-/+netbook turn off/on netbook layout\n\
|
-/+netbook turn off/on netbook layout\n\
|
||||||
\n", VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL, progname);
|
\n",
|
||||||
|
VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL, progname);
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
exit (1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_version(void) {
|
void show_version(void) {
|
||||||
fprintf(stdout, "\n\
|
fprintf(stdout, "\n\
|
||||||
%s Version %d.%d.%d, x48 is Copyright (c) 1994-2005 by Eddie C. Dost <ecd@dressler.de>.\n\
|
%s Version %d.%d.%d, x48 is Copyright (c) 1994-2005 by Eddie C. Dost <ecd@dressler.de>.\n\
|
||||||
Compiled on %s by <%s> #%d\n\n",
|
Compiled on %s by <%s> #%d\n\n",
|
||||||
progname, VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL,
|
progname, VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL, COMPILE_TIME,
|
||||||
COMPILE_TIME, COMPILE_BY, COMPILE_VERSION);
|
COMPILE_BY, COMPILE_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_copyright(void) {
|
void show_copyright(void) {
|
||||||
|
|
110
src/options.h
110
src/options.h
|
@ -49,72 +49,72 @@
|
||||||
#include <X11/Xresource.h>
|
#include <X11/Xresource.h>
|
||||||
|
|
||||||
static XrmOptionDescRec options[] = {
|
static XrmOptionDescRec options[] = {
|
||||||
{ "-display", ".display", XrmoptionSepArg, (void *) 0 },
|
{"-display", ".display", XrmoptionSepArg, (void *)0},
|
||||||
{ "-geometry", "*geometry", XrmoptionSepArg, (void *) 0 },
|
{"-geometry", "*geometry", XrmoptionSepArg, (void *)0},
|
||||||
{ "-iconGeom", "*iconGeom", XrmoptionSepArg, (void *) 0 },
|
{"-iconGeom", "*iconGeom", XrmoptionSepArg, (void *)0},
|
||||||
{ "-iconName", "*iconName", XrmoptionSepArg, (void *) 0 },
|
{"-iconName", "*iconName", XrmoptionSepArg, (void *)0},
|
||||||
{ "-iconic", "*iconic", XrmoptionNoArg, (void *) "True" },
|
{"-iconic", "*iconic", XrmoptionNoArg, (void *)"True"},
|
||||||
{ "-name", (char *) 0, XrmoptionSepArg, (void *) 0 },
|
{"-name", (char *)0, XrmoptionSepArg, (void *)0},
|
||||||
{ "-title", "*title", XrmoptionSepArg, (void *) 0 },
|
{"-title", "*title", XrmoptionSepArg, (void *)0},
|
||||||
|
|
||||||
{ "-xshm", "*useXShm", XrmoptionNoArg, (void *) "True" },
|
{"-xshm", "*useXShm", XrmoptionNoArg, (void *)"True"},
|
||||||
{ "+xshm", "*useXShm", XrmoptionNoArg, (void *)"False" },
|
{"+xshm", "*useXShm", XrmoptionNoArg, (void *)"False"},
|
||||||
|
|
||||||
{ "-visual", "*visual", XrmoptionSepArg, (void *) 0 },
|
{"-visual", "*visual", XrmoptionSepArg, (void *)0},
|
||||||
{ "-mono", "*mono", XrmoptionNoArg, (void *) "True" },
|
{"-mono", "*mono", XrmoptionNoArg, (void *)"True"},
|
||||||
{ "-gray", "*gray", XrmoptionNoArg, (void *) "True" },
|
{"-gray", "*gray", XrmoptionNoArg, (void *)"True"},
|
||||||
{ "-monoIcon", "*monoIcon", XrmoptionNoArg, (void *) "True" },
|
{"-monoIcon", "*monoIcon", XrmoptionNoArg, (void *)"True"},
|
||||||
|
|
||||||
{ "-version", "*printVersion", XrmoptionNoArg, (void *) "True" },
|
{"-version", "*printVersion", XrmoptionNoArg, (void *)"True"},
|
||||||
{ "-copyright", "*printCopyright",XrmoptionNoArg, (void *) "True" },
|
{"-copyright", "*printCopyright", XrmoptionNoArg, (void *)"True"},
|
||||||
{ "-warranty", "*printWarranty", XrmoptionNoArg, (void *) "True" },
|
{"-warranty", "*printWarranty", XrmoptionNoArg, (void *)"True"},
|
||||||
|
|
||||||
{ "-smallFont", "*smallLabelFont",XrmoptionSepArg, (void *) 0 },
|
{"-smallFont", "*smallLabelFont", XrmoptionSepArg, (void *)0},
|
||||||
{ "-mediumFont", "*mediumLabelFont",XrmoptionSepArg, (void *) 0 },
|
{"-mediumFont", "*mediumLabelFont", XrmoptionSepArg, (void *)0},
|
||||||
{ "-largeFont", "*largeLabelFont",XrmoptionSepArg, (void *) 0 },
|
{"-largeFont", "*largeLabelFont", XrmoptionSepArg, (void *)0},
|
||||||
{ "-connFont", "*connectionFont",XrmoptionSepArg, (void *) 0 },
|
{"-connFont", "*connectionFont", XrmoptionSepArg, (void *)0},
|
||||||
|
|
||||||
{ "-verbose", "*verbose", XrmoptionNoArg, (void *) "True" },
|
{"-verbose", "*verbose", XrmoptionNoArg, (void *)"True"},
|
||||||
{ "-quiet", "*quiet", XrmoptionNoArg, (void *) "True" },
|
{"-quiet", "*quiet", XrmoptionNoArg, (void *)"True"},
|
||||||
|
|
||||||
{ "-terminal", "*useTerminal", XrmoptionNoArg, (void *) "True" },
|
{"-terminal", "*useTerminal", XrmoptionNoArg, (void *)"True"},
|
||||||
{ "+terminal", "*useTerminal", XrmoptionNoArg, (void *)"False" },
|
{"+terminal", "*useTerminal", XrmoptionNoArg, (void *)"False"},
|
||||||
{ "-serial", "*useSerial", XrmoptionNoArg, (void *) "True" },
|
{"-serial", "*useSerial", XrmoptionNoArg, (void *)"True"},
|
||||||
{ "+serial", "*useSerial", XrmoptionNoArg, (void *)"False" },
|
{"+serial", "*useSerial", XrmoptionNoArg, (void *)"False"},
|
||||||
{ "-line", "*serialLine", XrmoptionSepArg, (void *) 0 },
|
{"-line", "*serialLine", XrmoptionSepArg, (void *)0},
|
||||||
|
|
||||||
{ "-initialize", "*completeInitialize",XrmoptionNoArg,(void *) "True" },
|
{"-initialize", "*completeInitialize", XrmoptionNoArg, (void *)"True"},
|
||||||
{ "-reset", "*resetOnStartup",XrmoptionNoArg, (void *) "True" },
|
{"-reset", "*resetOnStartup", XrmoptionNoArg, (void *)"True"},
|
||||||
{ "-rom", "*romFileName", XrmoptionSepArg, (void *) 0 },
|
{"-rom", "*romFileName", XrmoptionSepArg, (void *)0},
|
||||||
{ "-home", "*homeDirectory", XrmoptionSepArg, (void *) 0 },
|
{"-home", "*homeDirectory", XrmoptionSepArg, (void *)0},
|
||||||
|
|
||||||
{ "-debug", "*useDebugger", XrmoptionNoArg, (void *)"False" },
|
{"-debug", "*useDebugger", XrmoptionNoArg, (void *)"False"},
|
||||||
{ "+debug", "*useDebugger", XrmoptionNoArg, (void *) "True" },
|
{"+debug", "*useDebugger", XrmoptionNoArg, (void *)"True"},
|
||||||
{ "-disasm", "*disassemblerMnemonics",XrmoptionSepArg,(void *) 0 },
|
{"-disasm", "*disassemblerMnemonics", XrmoptionSepArg, (void *)0},
|
||||||
|
|
||||||
{ "-xrm", (char *) 0, XrmoptionResArg, (void *) 0 },
|
{"-xrm", (char *)0, XrmoptionResArg, (void *)0},
|
||||||
{ "-netbook", "*netbook", XrmoptionNoArg, (void *)"False" },
|
{"-netbook", "*netbook", XrmoptionNoArg, (void *)"False"},
|
||||||
{ "+netbook", "*netbook", XrmoptionNoArg, (void *) "True" },
|
{"+netbook", "*netbook", XrmoptionNoArg, (void *)"True"},
|
||||||
|
|
||||||
{ "-throttle", "*throttle", XrmoptionNoArg, (void *)"False" },
|
{"-throttle", "*throttle", XrmoptionNoArg, (void *)"False"},
|
||||||
{ "+throttle", "*throttle", XrmoptionNoArg, (void *) "True" },
|
{"+throttle", "*throttle", XrmoptionNoArg, (void *)"True"},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* these are parsed for compatibility, but not used yet.
|
* these are parsed for compatibility, but not used yet.
|
||||||
*/
|
*/
|
||||||
{ "-bg", "*background", XrmoptionSepArg, (void *) 0 },
|
{"-bg", "*background", XrmoptionSepArg, (void *)0},
|
||||||
{ "-background", "*background", XrmoptionSepArg, (void *) 0 },
|
{"-background", "*background", XrmoptionSepArg, (void *)0},
|
||||||
{ "-bd", "*borderColor", XrmoptionSepArg, (void *) 0 },
|
{"-bd", "*borderColor", XrmoptionSepArg, (void *)0},
|
||||||
{ "-bordercolor", "*borderColor", XrmoptionSepArg, (void *) 0 },
|
{"-bordercolor", "*borderColor", XrmoptionSepArg, (void *)0},
|
||||||
{ "-bw", "*borderWidth", XrmoptionSepArg, (void *) 0 },
|
{"-bw", "*borderWidth", XrmoptionSepArg, (void *)0},
|
||||||
{ "-borderwidth", "*borderWidth", XrmoptionSepArg, (void *) 0 },
|
{"-borderwidth", "*borderWidth", XrmoptionSepArg, (void *)0},
|
||||||
{ "-fg", "*foreground", XrmoptionSepArg, (void *) 0 },
|
{"-fg", "*foreground", XrmoptionSepArg, (void *)0},
|
||||||
{ "-foreground", "*foreground", XrmoptionSepArg, (void *) 0 },
|
{"-foreground", "*foreground", XrmoptionSepArg, (void *)0},
|
||||||
{ "-fn", "*fontName", XrmoptionSepArg, (void *) 0 },
|
{"-fn", "*fontName", XrmoptionSepArg, (void *)0},
|
||||||
{ "-font", "*fontName", XrmoptionSepArg, (void *) 0 },
|
{"-font", "*fontName", XrmoptionSepArg, (void *)0},
|
||||||
{ "-rv", "*reverseVideo", XrmoptionNoArg, (void *) "True" },
|
{"-rv", "*reverseVideo", XrmoptionNoArg, (void *)"True"},
|
||||||
{ "+rv", "*reverseVideo", XrmoptionNoArg, (void *)"False" },
|
{"+rv", "*reverseVideo", XrmoptionNoArg, (void *)"False"},
|
||||||
{ "-reverse", "*reverseVideo", XrmoptionNoArg, (void *) "True" },
|
{"-reverse", "*reverseVideo", XrmoptionNoArg, (void *)"True"},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -42,28 +42,21 @@
|
||||||
* $Id: register.c,v 1.6 1995/01/11 18:20:01 ecd Exp ecd $
|
* $Id: register.c,v 1.6 1995/01/11 18:20:01 ecd Exp ecd $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "hp48.h"
|
#include "hp48.h"
|
||||||
#include "hp48_emu.h"
|
#include "hp48_emu.h"
|
||||||
|
|
||||||
extern long nibble_masks[16];
|
extern long nibble_masks[16];
|
||||||
|
|
||||||
static int start_fields[] = {
|
static int start_fields[] = {-1, 0, 2, 0, 15, 3, 0, 0, -1, 0,
|
||||||
-1, 0, 2, 0, 15, 3, 0, 0,
|
2, 0, 15, 3, 0, 0, 0, 0, 0};
|
||||||
-1, 0, 2, 0, 15, 3, 0, 0,
|
|
||||||
0, 0, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
static int end_fields[] = {
|
static int end_fields[] = {-1, -1, 2, 2, 15, 14, 1, 15, -1, -1,
|
||||||
-1, -1, 2, 2, 15, 14, 1, 15,
|
2, 2, 15, 14, 1, 4, 3, 2, 0};
|
||||||
-1, -1, 2, 2, 15, 14, 1, 4,
|
|
||||||
3, 2, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline int get_start(int code) {
|
static inline int get_start(int code) {
|
||||||
int s;
|
int s;
|
||||||
|
@ -83,8 +76,8 @@ static inline int get_end(int code) {
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_register(unsigned char *res, unsigned char *r1,
|
void add_register(unsigned char *res, unsigned char *r1, unsigned char *r2,
|
||||||
unsigned char *r2, int code) {
|
int code) {
|
||||||
int t, c, i, s, e;
|
int t, c, i, s, e;
|
||||||
|
|
||||||
s = get_start(code);
|
s = get_start(code);
|
||||||
|
@ -128,8 +121,8 @@ void add_p_plus_one(unsigned char *r) {
|
||||||
saturn.CARRY = 0;
|
saturn.CARRY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sub_register(unsigned char *res, unsigned char *r1,
|
void sub_register(unsigned char *res, unsigned char *r1, unsigned char *r2,
|
||||||
unsigned char *r2, int code) {
|
int code) {
|
||||||
int t, c, i, s, e;
|
int t, c, i, s, e;
|
||||||
|
|
||||||
s = get_start(code);
|
s = get_start(code);
|
||||||
|
@ -288,8 +281,8 @@ void zero_register(unsigned char *r, int code) {
|
||||||
r[i] = 0;
|
r[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void or_register(unsigned char *res, unsigned char *r1,
|
void or_register(unsigned char *res, unsigned char *r1, unsigned char *r2,
|
||||||
unsigned char *r2, int code) {
|
int code) {
|
||||||
int i, s, e;
|
int i, s, e;
|
||||||
|
|
||||||
s = get_start(code);
|
s = get_start(code);
|
||||||
|
@ -299,8 +292,8 @@ void or_register(unsigned char *res, unsigned char *r1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void and_register(unsigned char *res, unsigned char *r1,
|
void and_register(unsigned char *res, unsigned char *r1, unsigned char *r2,
|
||||||
unsigned char *r2, int code) {
|
int code) {
|
||||||
int i, s, e;
|
int i, s, e;
|
||||||
|
|
||||||
s = get_start(code);
|
s = get_start(code);
|
||||||
|
@ -350,7 +343,7 @@ void shift_left_register(unsigned char *r, int code) {
|
||||||
s = get_start(code);
|
s = get_start(code);
|
||||||
e = get_end(code);
|
e = get_end(code);
|
||||||
for (i = e; i > s; i--) {
|
for (i = e; i > s; i--) {
|
||||||
r[i] = r[i-1] & 0x0f;
|
r[i] = r[i - 1] & 0x0f;
|
||||||
}
|
}
|
||||||
r[s] = 0;
|
r[s] = 0;
|
||||||
}
|
}
|
||||||
|
@ -362,7 +355,7 @@ void shift_left_circ_register(unsigned char *r, int code) {
|
||||||
e = get_end(code);
|
e = get_end(code);
|
||||||
t = r[e] & 0x0f;
|
t = r[e] & 0x0f;
|
||||||
for (i = e; i > s; i--) {
|
for (i = e; i > s; i--) {
|
||||||
r[i] = r[i-1] & 0x0f;
|
r[i] = r[i - 1] & 0x0f;
|
||||||
}
|
}
|
||||||
r[s] = t;
|
r[s] = t;
|
||||||
}
|
}
|
||||||
|
@ -375,7 +368,7 @@ void shift_right_register(unsigned char *r, int code) {
|
||||||
if (r[s] & 0x0f)
|
if (r[s] & 0x0f)
|
||||||
saturn.SB = 1;
|
saturn.SB = 1;
|
||||||
for (i = s; i < e; i++) {
|
for (i = s; i < e; i++) {
|
||||||
r[i] = r[i+1] & 0x0f;
|
r[i] = r[i + 1] & 0x0f;
|
||||||
}
|
}
|
||||||
r[e] = 0;
|
r[e] = 0;
|
||||||
}
|
}
|
||||||
|
@ -387,7 +380,7 @@ void shift_right_circ_register(unsigned char *r, int code) {
|
||||||
e = get_end(code);
|
e = get_end(code);
|
||||||
t = r[s] & 0x0f;
|
t = r[s] & 0x0f;
|
||||||
for (i = s; i < e; i++) {
|
for (i = s; i < e; i++) {
|
||||||
r[i] = r[i+1] & 0x0f;
|
r[i] = r[i + 1] & 0x0f;
|
||||||
}
|
}
|
||||||
r[e] = t;
|
r[e] = t;
|
||||||
if (t)
|
if (t)
|
||||||
|
@ -522,7 +515,8 @@ int is_greater_register(unsigned char *r1, unsigned char *r2, int code) {
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_greater_or_equal_register(unsigned char *r1, unsigned char *r2, int code) {
|
int is_greater_or_equal_register(unsigned char *r1, unsigned char *r2,
|
||||||
|
int code) {
|
||||||
int z, i, s, e;
|
int z, i, s, e;
|
||||||
|
|
||||||
s = get_start(code);
|
s = get_start(code);
|
||||||
|
|
347
src/resources.c
347
src/resources.c
|
@ -50,30 +50,30 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
|
||||||
#include <X11/Xresource.h>
|
#include <X11/Xresource.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "resources.h"
|
|
||||||
#include "disasm.h"
|
#include "disasm.h"
|
||||||
#include "errors.h"
|
#include "errors.h"
|
||||||
|
#include "resources.h"
|
||||||
|
|
||||||
XrmDatabase rdb = (XrmDatabase)0;
|
XrmDatabase rdb = (XrmDatabase)0;
|
||||||
|
|
||||||
int verbose;
|
int verbose;
|
||||||
int quiet;
|
int quiet;
|
||||||
int useTerminal;
|
int useTerminal;
|
||||||
int useSerial;
|
int useSerial;
|
||||||
char *serialLine;
|
char *serialLine;
|
||||||
int useXShm;
|
int useXShm;
|
||||||
int useDebugger;
|
int useDebugger;
|
||||||
int netbook;
|
int netbook;
|
||||||
int throttle;
|
int throttle;
|
||||||
int initialize;
|
int initialize;
|
||||||
int resetOnStartup;
|
int resetOnStartup;
|
||||||
char *romFileName;
|
char *romFileName;
|
||||||
char *homeDirectory;
|
char *homeDirectory;
|
||||||
|
|
||||||
void get_resources(void) {
|
void get_resources(void) {
|
||||||
if (get_boolean_resource("printVersion", "PrintVersion"))
|
if (get_boolean_resource("printVersion", "PrintVersion"))
|
||||||
|
@ -92,216 +92,217 @@ void get_resources(void) {
|
||||||
useSerial = get_boolean_resource("useSerial", "UseSerial");
|
useSerial = get_boolean_resource("useSerial", "UseSerial");
|
||||||
serialLine = get_string_resource("serialLine", "SerialLine");
|
serialLine = get_string_resource("serialLine", "SerialLine");
|
||||||
|
|
||||||
initialize = get_boolean_resource("completeInitialize",
|
initialize = get_boolean_resource("completeInitialize", "CompleteInitialize");
|
||||||
"CompleteInitialize");
|
resetOnStartup = get_boolean_resource("resetOnStartup", "ResetOnStartup");
|
||||||
resetOnStartup = get_boolean_resource("resetOnStartup",
|
|
||||||
"ResetOnStartup");
|
|
||||||
romFileName = get_string_resource("romFileName", "RomFileName");
|
romFileName = get_string_resource("romFileName", "RomFileName");
|
||||||
homeDirectory = get_string_resource("homeDirectory", "HomeDirectory");
|
homeDirectory = get_string_resource("homeDirectory", "HomeDirectory");
|
||||||
|
|
||||||
useDebugger = get_boolean_resource("useDebugger", "UseDebugger");
|
useDebugger = get_boolean_resource("useDebugger", "UseDebugger");
|
||||||
disassembler_mode = get_mnemonic_resource("disassemblerMnemonics",
|
disassembler_mode =
|
||||||
"DisassemblerMnemonics");
|
get_mnemonic_resource("disassemblerMnemonics", "DisassemblerMnemonics");
|
||||||
|
|
||||||
netbook = get_boolean_resource("netbook", "Netbook");
|
netbook = get_boolean_resource("netbook", "Netbook");
|
||||||
|
|
||||||
throttle = get_boolean_resource("throttle", "Throttle");
|
throttle = get_boolean_resource("throttle", "Throttle");
|
||||||
}
|
}
|
||||||
|
|
||||||
char * get_string_resource_from_db (XrmDatabase db, char *name, char *class) {
|
char *get_string_resource_from_db(XrmDatabase db, char *name, char *class) {
|
||||||
XrmValue value;
|
XrmValue value;
|
||||||
char *type;
|
char *type;
|
||||||
char full_name [1024], full_class [1024];
|
char full_name[1024], full_class[1024];
|
||||||
|
|
||||||
strcpy (full_name, res_name);
|
strcpy(full_name, res_name);
|
||||||
strcat (full_name, ".");
|
strcat(full_name, ".");
|
||||||
strcat (full_name, name);
|
strcat(full_name, name);
|
||||||
strcpy (full_class, res_class);
|
strcpy(full_class, res_class);
|
||||||
strcat (full_class, ".");
|
strcat(full_class, ".");
|
||||||
strcat (full_class, class);
|
strcat(full_class, class);
|
||||||
if (XrmGetResource (db, full_name, full_class, &type, &value))
|
if (XrmGetResource(db, full_name, full_class, &type, &value)) {
|
||||||
{
|
char *str = (char *)malloc(value.size + 1);
|
||||||
char *str = (char *) malloc (value.size + 1);
|
strncpy(str, (char *)value.addr, value.size);
|
||||||
strncpy (str, (char *) value.addr, value.size);
|
str[value.size] = 0;
|
||||||
str [value.size] = 0;
|
return str;
|
||||||
return str;
|
}
|
||||||
}
|
|
||||||
return (char *)0;
|
return (char *)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * get_string_resource (char *name, char *class) {
|
char *get_string_resource(char *name, char *class) {
|
||||||
return get_string_resource_from_db(rdb, name, class);
|
return get_string_resource_from_db(rdb, name, class);
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_mnemonic_resource (char *name, char *class) {
|
int get_mnemonic_resource(char *name, char *class) {
|
||||||
char *tmp, buf [100];
|
char *tmp, buf[100];
|
||||||
char *s = get_string_resource (name, class);
|
char *s = get_string_resource(name, class);
|
||||||
char *os = s;
|
char *os = s;
|
||||||
|
|
||||||
if (! s) return CLASS_MNEMONICS;
|
if (!s)
|
||||||
for (tmp = buf; *s; s++)
|
|
||||||
*tmp++ = isupper (*s) ? _tolower (*s) : *s;
|
|
||||||
*tmp = 0;
|
|
||||||
free (os);
|
|
||||||
|
|
||||||
if (!strcmp (buf, "hp"))
|
|
||||||
return HP_MNEMONICS;
|
|
||||||
if (!strcmp (buf, "class"))
|
|
||||||
return CLASS_MNEMONICS;
|
return CLASS_MNEMONICS;
|
||||||
fprintf (stderr, "%s: %s must be one of \'HP\' or \'class\', not %s.\n",
|
for (tmp = buf; *s; s++)
|
||||||
progname, name, buf);
|
*tmp++ = isupper(*s) ? _tolower(*s) : *s;
|
||||||
|
*tmp = 0;
|
||||||
|
free(os);
|
||||||
|
|
||||||
|
if (!strcmp(buf, "hp"))
|
||||||
|
return HP_MNEMONICS;
|
||||||
|
if (!strcmp(buf, "class"))
|
||||||
|
return CLASS_MNEMONICS;
|
||||||
|
fprintf(stderr, "%s: %s must be one of \'HP\' or \'class\', not %s.\n",
|
||||||
|
progname, name, buf);
|
||||||
return CLASS_MNEMONICS;
|
return CLASS_MNEMONICS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_boolean_resource (char *name, char *class) {
|
int get_boolean_resource(char *name, char *class) {
|
||||||
char *tmp, buf [100];
|
char *tmp, buf[100];
|
||||||
char *s = get_string_resource (name, class);
|
char *s = get_string_resource(name, class);
|
||||||
char *os = s;
|
char *os = s;
|
||||||
if (! s) return 0;
|
if (!s)
|
||||||
for (tmp = buf; *s; s++)
|
|
||||||
*tmp++ = isupper (*s) ? _tolower (*s) : *s;
|
|
||||||
*tmp = 0;
|
|
||||||
free (os);
|
|
||||||
|
|
||||||
if (!strcmp (buf, "on") || !strcmp (buf, "true") || !strcmp (buf, "yes"))
|
|
||||||
return 1;
|
|
||||||
if (!strcmp (buf, "off") || !strcmp (buf, "false") || !strcmp (buf, "no"))
|
|
||||||
return 0;
|
return 0;
|
||||||
fprintf (stderr, "%s: %s must be boolean, not %s.\n",
|
for (tmp = buf; *s; s++)
|
||||||
progname, name, buf);
|
*tmp++ = isupper(*s) ? _tolower(*s) : *s;
|
||||||
|
*tmp = 0;
|
||||||
|
free(os);
|
||||||
|
|
||||||
|
if (!strcmp(buf, "on") || !strcmp(buf, "true") || !strcmp(buf, "yes"))
|
||||||
|
return 1;
|
||||||
|
if (!strcmp(buf, "off") || !strcmp(buf, "false") || !strcmp(buf, "no"))
|
||||||
|
return 0;
|
||||||
|
fprintf(stderr, "%s: %s must be boolean, not %s.\n", progname, name, buf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_integer_resource (char *name, char *class) {
|
int get_integer_resource(char *name, char *class) {
|
||||||
int val;
|
int val;
|
||||||
char c, *s = get_string_resource (name, class);
|
char c, *s = get_string_resource(name, class);
|
||||||
if (!s) return 0;
|
if (!s)
|
||||||
if (1 == sscanf (s, " %d %c", &val, &c))
|
return 0;
|
||||||
{
|
if (1 == sscanf(s, " %d %c", &val, &c)) {
|
||||||
free (s);
|
free(s);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
fprintf (stderr, "%s: %s must be an integer, not %s.\n",
|
fprintf(stderr, "%s: %s must be an integer, not %s.\n", progname, name, s);
|
||||||
progname, name, s);
|
free(s);
|
||||||
free (s);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int get_pixel_resource (char *name, char *class, Display *dpy,
|
unsigned int get_pixel_resource(char *name, char *class, Display *dpy,
|
||||||
Colormap cmap) {
|
Colormap cmap) {
|
||||||
XColor color;
|
XColor color;
|
||||||
char *s = get_string_resource (name, class);
|
char *s = get_string_resource(name, class);
|
||||||
if (!s) goto DEFAULT;
|
if (!s)
|
||||||
|
goto DEFAULT;
|
||||||
|
|
||||||
if (! XParseColor (dpy, cmap, s, &color))
|
if (!XParseColor(dpy, cmap, s, &color)) {
|
||||||
{
|
fprintf(stderr, "%s: can't parse color %s\n", progname, s);
|
||||||
fprintf (stderr, "%s: can't parse color %s\n", progname, s);
|
goto DEFAULT;
|
||||||
goto DEFAULT;
|
}
|
||||||
}
|
if (!XAllocColor(dpy, cmap, &color)) {
|
||||||
if (! XAllocColor (dpy, cmap, &color))
|
fprintf(stderr, "%s: couldn't allocate color %s\n", progname, s);
|
||||||
{
|
goto DEFAULT;
|
||||||
fprintf (stderr, "%s: couldn't allocate color %s\n", progname, s);
|
}
|
||||||
goto DEFAULT;
|
free(s);
|
||||||
}
|
|
||||||
free (s);
|
|
||||||
return color.pixel;
|
return color.pixel;
|
||||||
DEFAULT:
|
DEFAULT:
|
||||||
if (s) free (s);
|
if (s)
|
||||||
return (strcmp (class, "Background")
|
free(s);
|
||||||
? WhitePixel (dpy, DefaultScreen (dpy))
|
return (strcmp(class, "Background") ? WhitePixel(dpy, DefaultScreen(dpy))
|
||||||
: BlackPixel (dpy, DefaultScreen (dpy)));
|
: BlackPixel(dpy, DefaultScreen(dpy)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Visual * pick_visual_of_class (Display *dpy, int visual_class, unsigned int *depth) {
|
static Visual *pick_visual_of_class(Display *dpy, int visual_class,
|
||||||
|
unsigned int *depth) {
|
||||||
XVisualInfo vi_in, *vi_out;
|
XVisualInfo vi_in, *vi_out;
|
||||||
int out_count;
|
int out_count;
|
||||||
|
|
||||||
vi_in.class = visual_class;
|
vi_in.class = visual_class;
|
||||||
vi_in.screen = DefaultScreen(dpy);
|
vi_in.screen = DefaultScreen(dpy);
|
||||||
vi_out = XGetVisualInfo(dpy, VisualClassMask|VisualScreenMask,
|
vi_out = XGetVisualInfo(dpy, VisualClassMask | VisualScreenMask, &vi_in,
|
||||||
&vi_in, &out_count);
|
&out_count);
|
||||||
if (vi_out)
|
if (vi_out) { /* choose the 'best' one, if multiple */
|
||||||
{ /* choose the 'best' one, if multiple */
|
int i, best;
|
||||||
int i, best;
|
Visual *visual;
|
||||||
Visual *visual;
|
for (i = 0, best = 0; i < out_count; i++)
|
||||||
for (i = 0, best = 0; i < out_count; i++)
|
if (vi_out[i].depth > vi_out[best].depth)
|
||||||
if (vi_out[i].depth > vi_out[best].depth)
|
best = i;
|
||||||
best = i;
|
visual = vi_out[best].visual;
|
||||||
visual = vi_out[best].visual;
|
*depth = vi_out[best].depth;
|
||||||
*depth = vi_out[best].depth;
|
XFree((char *)vi_out);
|
||||||
XFree ((char *)vi_out);
|
return visual;
|
||||||
return visual;
|
} else {
|
||||||
}
|
*depth = DefaultDepth(dpy, DefaultScreen(dpy));
|
||||||
else
|
return DefaultVisual(dpy, DefaultScreen(dpy));
|
||||||
{
|
}
|
||||||
*depth = DefaultDepth(dpy, DefaultScreen(dpy));
|
|
||||||
return DefaultVisual(dpy, DefaultScreen(dpy));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Visual * id_to_visual (Display *dpy, int id, unsigned int *depth) {
|
static Visual *id_to_visual(Display *dpy, int id, unsigned int *depth) {
|
||||||
XVisualInfo vi_in, *vi_out;
|
XVisualInfo vi_in, *vi_out;
|
||||||
int out_count;
|
int out_count;
|
||||||
|
|
||||||
vi_in.screen = DefaultScreen(dpy);
|
vi_in.screen = DefaultScreen(dpy);
|
||||||
vi_in.visualid = id;
|
vi_in.visualid = id;
|
||||||
vi_out = XGetVisualInfo(dpy, VisualScreenMask|VisualIDMask,
|
vi_out =
|
||||||
&vi_in, &out_count);
|
XGetVisualInfo(dpy, VisualScreenMask | VisualIDMask, &vi_in, &out_count);
|
||||||
if (vi_out)
|
if (vi_out) {
|
||||||
{
|
Visual *v = vi_out[0].visual;
|
||||||
Visual *v = vi_out[0].visual;
|
*depth = vi_out[0].depth;
|
||||||
*depth = vi_out[0].depth;
|
XFree((char *)vi_out);
|
||||||
XFree((char *)vi_out);
|
return v;
|
||||||
return v;
|
}
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Visual * get_visual_resource(Display *dpy, char *name, char *class, unsigned int *depth) {
|
Visual *get_visual_resource(Display *dpy, char *name, char *class,
|
||||||
char c;
|
unsigned int *depth) {
|
||||||
|
char c;
|
||||||
char *tmp, *s;
|
char *tmp, *s;
|
||||||
int vclass;
|
int vclass;
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
s = get_string_resource(name, class);
|
s = get_string_resource(name, class);
|
||||||
if (s)
|
if (s)
|
||||||
for (tmp = s; *tmp; tmp++)
|
for (tmp = s; *tmp; tmp++)
|
||||||
if (isupper(*tmp)) *tmp = _tolower(*tmp);
|
if (isupper(*tmp))
|
||||||
|
*tmp = _tolower(*tmp);
|
||||||
|
|
||||||
if (!s || !strcmp(s, "default")) vclass = -1;
|
if (!s || !strcmp(s, "default"))
|
||||||
else if (!strcmp (s, "staticgray")) vclass = StaticGray;
|
vclass = -1;
|
||||||
else if (!strcmp (s, "staticcolor")) vclass = StaticColor;
|
else if (!strcmp(s, "staticgray"))
|
||||||
else if (!strcmp (s, "truecolor")) vclass = TrueColor;
|
vclass = StaticGray;
|
||||||
else if (!strcmp (s, "grayscale")) vclass = GrayScale;
|
else if (!strcmp(s, "staticcolor"))
|
||||||
else if (!strcmp (s, "pseudocolor")) vclass = PseudoColor;
|
vclass = StaticColor;
|
||||||
else if (!strcmp (s, "directcolor")) vclass = DirectColor;
|
else if (!strcmp(s, "truecolor"))
|
||||||
else if (1 == sscanf (s, " %d %c", &id, &c)) vclass = -2;
|
vclass = TrueColor;
|
||||||
else if (1 == sscanf (s, " 0x%x %c", &id, &c)) vclass = -2;
|
else if (!strcmp(s, "grayscale"))
|
||||||
else
|
vclass = GrayScale;
|
||||||
{
|
else if (!strcmp(s, "pseudocolor"))
|
||||||
fprintf (stderr, "%s: unrecognized visual \"%s\".\n", progname, s);
|
vclass = PseudoColor;
|
||||||
vclass = -1;
|
else if (!strcmp(s, "directcolor"))
|
||||||
}
|
vclass = DirectColor;
|
||||||
if (s) free (s);
|
else if (1 == sscanf(s, " %d %c", &id, &c))
|
||||||
|
vclass = -2;
|
||||||
|
else if (1 == sscanf(s, " 0x%x %c", &id, &c))
|
||||||
|
vclass = -2;
|
||||||
|
else {
|
||||||
|
fprintf(stderr, "%s: unrecognized visual \"%s\".\n", progname, s);
|
||||||
|
vclass = -1;
|
||||||
|
}
|
||||||
|
if (s)
|
||||||
|
free(s);
|
||||||
|
|
||||||
if (vclass == -1)
|
if (vclass == -1) {
|
||||||
{
|
*depth = DefaultDepth(dpy, DefaultScreen(dpy));
|
||||||
*depth = DefaultDepth(dpy, DefaultScreen(dpy));
|
return DefaultVisual(dpy, DefaultScreen(dpy));
|
||||||
return DefaultVisual(dpy, DefaultScreen(dpy));
|
} else if (vclass == -2) {
|
||||||
}
|
Visual *v = id_to_visual(dpy, id, depth);
|
||||||
else if (vclass == -2)
|
if (v)
|
||||||
{
|
return v;
|
||||||
Visual *v = id_to_visual (dpy, id, depth);
|
fprintf(stderr, "%s: no visual with id 0x%x.\n", progname, id);
|
||||||
if (v) return v;
|
*depth = DefaultDepth(dpy, DefaultScreen(dpy));
|
||||||
fprintf (stderr, "%s: no visual with id 0x%x.\n", progname, id);
|
return DefaultVisual(dpy, DefaultScreen(dpy));
|
||||||
*depth = DefaultDepth(dpy, DefaultScreen(dpy));
|
} else
|
||||||
return DefaultVisual(dpy, DefaultScreen(dpy));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return pick_visual_of_class(dpy, vclass, depth);
|
return pick_visual_of_class(dpy, vclass, depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
XFontStruct * get_font_resource(Display *dpy, char *name, char *class) {
|
XFontStruct *get_font_resource(Display *dpy, char *name, char *class) {
|
||||||
char *s;
|
char *s;
|
||||||
XFontStruct *f = (XFontStruct *)0;
|
XFontStruct *f = (XFontStruct *)0;
|
||||||
|
|
||||||
|
@ -309,16 +310,14 @@ XFontStruct * get_font_resource(Display *dpy, char *name, char *class) {
|
||||||
|
|
||||||
if (s)
|
if (s)
|
||||||
f = XLoadQueryFont(dpy, s);
|
f = XLoadQueryFont(dpy, s);
|
||||||
else
|
else {
|
||||||
{
|
sprintf(errbuf, "can\'t get resource \'%s\'", name);
|
||||||
sprintf(errbuf, "can\'t get resource \'%s\'", name);
|
fatal_exit();
|
||||||
fatal_exit();
|
}
|
||||||
}
|
if (f == (XFontStruct *)0) {
|
||||||
if (f == (XFontStruct *)0)
|
sprintf(errbuf, "can\'t load font \'%s\'", s);
|
||||||
{
|
sprintf(fixbuf, "Please change resource \'%s\'", name);
|
||||||
sprintf(errbuf, "can\'t load font \'%s\'", s);
|
fatal_exit();
|
||||||
sprintf(fixbuf, "Please change resource \'%s\'", name);
|
}
|
||||||
fatal_exit();
|
|
||||||
}
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,59 +41,55 @@
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xresource.h>
|
#include <X11/Xresource.h>
|
||||||
|
|
||||||
extern int verbose;
|
extern int verbose;
|
||||||
extern int quiet;
|
extern int quiet;
|
||||||
extern int useTerminal;
|
extern int useTerminal;
|
||||||
extern int useSerial;
|
extern int useSerial;
|
||||||
extern int useXShm;
|
extern int useXShm;
|
||||||
extern int useDebugger;
|
extern int useDebugger;
|
||||||
extern int netbook;
|
extern int netbook;
|
||||||
extern int throttle;
|
extern int throttle;
|
||||||
extern char *serialLine;
|
extern char *serialLine;
|
||||||
extern int initialize;
|
extern int initialize;
|
||||||
extern int resetOnStartup;
|
extern int resetOnStartup;
|
||||||
extern char *romFileName;
|
extern char *romFileName;
|
||||||
extern char *homeDirectory;
|
extern char *homeDirectory;
|
||||||
|
|
||||||
extern char *progname;
|
extern char *progname;
|
||||||
extern char *res_name;
|
extern char *res_name;
|
||||||
extern char *res_class;
|
extern char *res_class;
|
||||||
|
|
||||||
extern XrmDatabase rdb;
|
extern XrmDatabase rdb;
|
||||||
|
|
||||||
extern void usage __ProtoType__ ((void));
|
extern void usage __ProtoType__((void));
|
||||||
extern void show_version __ProtoType__ ((void));
|
extern void show_version __ProtoType__((void));
|
||||||
extern void show_copyright __ProtoType__ ((void));
|
extern void show_copyright __ProtoType__((void));
|
||||||
extern void show_warranty __ProtoType__ ((void));
|
extern void show_warranty __ProtoType__((void));
|
||||||
extern void get_resources __ProtoType__ ((void));
|
extern void get_resources __ProtoType__((void));
|
||||||
extern char * get_string_resource_from_db __ProtoType__ ((XrmDatabase db,
|
extern char *get_string_resource_from_db __ProtoType__((XrmDatabase db,
|
||||||
char *name,
|
char *name,
|
||||||
char *class));
|
char *class));
|
||||||
extern char * get_string_resource __ProtoType__ ((char *name,
|
extern char *get_string_resource __ProtoType__((char *name, char *class));
|
||||||
char *class));
|
extern int get_boolean_resource __ProtoType__((char *name, char *class));
|
||||||
extern int get_boolean_resource __ProtoType__ ((char *name,
|
extern int get_mnemonic_resource __ProtoType__((char *name, char *class));
|
||||||
char *class));
|
extern Visual *get_visual_resource __ProtoType__((Display * dpy, char *name,
|
||||||
extern int get_mnemonic_resource __ProtoType__ ((char *name,
|
char *class,
|
||||||
char *class));
|
unsigned int *depth));
|
||||||
extern Visual * get_visual_resource __ProtoType__ ((Display *dpy,
|
extern XFontStruct *get_font_resource __ProtoType__((Display * dpy,
|
||||||
char *name,
|
char *res_name,
|
||||||
char *class,
|
char *res_class));
|
||||||
unsigned int *depth));
|
|
||||||
extern XFontStruct * get_font_resource __ProtoType__ ((Display *dpy,
|
|
||||||
char *res_name,
|
|
||||||
char *res_class));
|
|
||||||
|
|
||||||
#ifndef isupper
|
#ifndef isupper
|
||||||
# define isupper(c) ((c) >= 'A' && (c) <= 'Z')
|
#define isupper(c) ((c) >= 'A' && (c) <= 'Z')
|
||||||
#endif
|
#endif
|
||||||
#ifndef islower
|
#ifndef islower
|
||||||
# define islower(c) ((c) >= 'a' && (c) <= 'z')
|
#define islower(c) ((c) >= 'a' && (c) <= 'z')
|
||||||
#endif
|
#endif
|
||||||
#ifndef _tolower
|
#ifndef _tolower
|
||||||
# define _tolower(c) ((c) - 'A' + 'a')
|
#define _tolower(c) ((c) - 'A' + 'a')
|
||||||
#endif
|
#endif
|
||||||
#ifndef _toupper
|
#ifndef _toupper
|
||||||
# define _toupper(c) ((c) - 'a' + 'A')
|
#define _toupper(c) ((c) - 'a' + 'A')
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* !_RESOURCES_H */
|
#endif /* !_RESOURCES_H */
|
||||||
|
|
270
src/romio.c
270
src/romio.c
|
@ -27,8 +27,8 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "resources.h"
|
#include "resources.h"
|
||||||
|
@ -47,70 +47,80 @@ int read_rom_file(char *name, unsigned char **mem, int *size) {
|
||||||
|
|
||||||
*mem = NULL;
|
*mem = NULL;
|
||||||
*size = 0;
|
*size = 0;
|
||||||
if (NULL == (fp = fopen(name, "r")))
|
if (NULL == (fp = fopen(name, "r"))) {
|
||||||
{
|
fprintf(stderr, "can\'t open %s\n", name);
|
||||||
fprintf(stderr, "can\'t open %s\n", name);
|
return 0;
|
||||||
return 0;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (stat(name, &st) < 0)
|
if (stat(name, &st) < 0) {
|
||||||
{
|
fprintf(stderr, "can\'t stat %s\n", name);
|
||||||
fprintf(stderr, "can\'t stat %s\n", name);
|
fclose(fp);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fread(four, 1, 4, fp) != 4) {
|
||||||
|
fprintf(stderr, "can\'t read first 4 bytes of %s\n", name);
|
||||||
|
fclose(fp);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (four[0] == 0x02 && four[1] == 0x03 && four[2] == 0x06 &&
|
||||||
|
four[3] == 0x09) {
|
||||||
|
*size = st.st_size;
|
||||||
|
} else if (four[0] == 0x32 && four[1] == 0x96 && four[2] == 0x1b &&
|
||||||
|
four[3] == 0x80) {
|
||||||
|
*size = 2 * st.st_size;
|
||||||
|
} else if (four[1] = 0x49) {
|
||||||
|
fprintf(stderr, "%s is an HP49 ROM\n", name);
|
||||||
|
*size = 2 * st.st_size;
|
||||||
|
} else if (four[0]) {
|
||||||
|
printf("%d\n", st.st_size);
|
||||||
|
*size = st.st_size;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "%s is not a HP48 ROM\n", name);
|
||||||
|
fclose(fp);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fseek(fp, 0, 0) < 0) {
|
||||||
|
fprintf(stderr, "can\'t fseek to position 0 in %s\n", name);
|
||||||
|
*size = 0;
|
||||||
|
fclose(fp);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
*mem = (unsigned char *)malloc(*size);
|
||||||
|
|
||||||
|
if (st.st_size == *size) {
|
||||||
|
/*
|
||||||
|
* size is same as memory size, old version file
|
||||||
|
*/
|
||||||
|
if (fread(*mem, 1, (size_t)*size, fp) != *size) {
|
||||||
|
fprintf(stderr, "can\'t read %s\n", name);
|
||||||
|
free(*mem);
|
||||||
|
*mem = NULL;
|
||||||
|
*size = 0;
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* size is different, check size and decompress memory
|
||||||
|
*/
|
||||||
|
|
||||||
if (fread(four, 1, 4, fp) != 4)
|
if (st.st_size != *size / 2) {
|
||||||
{
|
fprintf(stderr, "strange size %s, expected %d, found %ld\n", name,
|
||||||
fprintf(stderr, "can\'t read first 4 bytes of %s\n", name);
|
*size / 2, st.st_size);
|
||||||
fclose(fp);
|
free(*mem);
|
||||||
return 0;
|
*mem = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
if (four[0] == 0x02 && four[1] == 0x03 &&
|
|
||||||
four[2] == 0x06 && four[3] == 0x09)
|
|
||||||
{
|
|
||||||
*size = st.st_size;
|
|
||||||
}
|
|
||||||
else if (four[0] == 0x32 && four[1] == 0x96 &&
|
|
||||||
four[2] == 0x1b && four[3] == 0x80)
|
|
||||||
{
|
|
||||||
*size = 2 * st.st_size;
|
|
||||||
}
|
|
||||||
else if (four[1] = 0x49)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "%s is an HP49 ROM\n", name);
|
|
||||||
*size = 2 * st.st_size;
|
|
||||||
}
|
|
||||||
else if (four[0])
|
|
||||||
{
|
|
||||||
printf("%d\n", st.st_size);
|
|
||||||
*size = st.st_size;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf(stderr, "%s is not a HP48 ROM\n", name);
|
|
||||||
fclose(fp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fseek(fp, 0, 0) < 0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "can\'t fseek to position 0 in %s\n", name);
|
|
||||||
*size = 0;
|
*size = 0;
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
*mem = (unsigned char *)malloc(*size);
|
if (NULL == (tmp_mem = (unsigned char *)malloc((size_t)st.st_size))) {
|
||||||
|
for (i = 0, j = 0; i < *size / 2; i++) {
|
||||||
if (st.st_size == *size)
|
if (1 != fread(&byte, 1, 1, fp)) {
|
||||||
{
|
|
||||||
/*
|
|
||||||
* size is same as memory size, old version file
|
|
||||||
*/
|
|
||||||
if (fread(*mem, 1, (size_t)*size, fp) != *size)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "can\'t read %s\n", name);
|
fprintf(stderr, "can\'t read %s\n", name);
|
||||||
free(*mem);
|
free(*mem);
|
||||||
*mem = NULL;
|
*mem = NULL;
|
||||||
|
@ -118,112 +128,62 @@ int read_rom_file(char *name, unsigned char **mem, int *size) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
(*mem)[j++] = byte & 0xf;
|
||||||
|
(*mem)[j++] = (byte >> 4) & 0xf;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (fread(tmp_mem, 1, (size_t)*size / 2, fp) != *size / 2) {
|
||||||
|
fprintf(stderr, "can\'t read %s\n", name);
|
||||||
|
free(*mem);
|
||||||
|
*mem = NULL;
|
||||||
|
*size = 0;
|
||||||
|
fclose(fp);
|
||||||
|
free(tmp_mem);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0, j = 0; i < *size / 2; i++) {
|
||||||
|
(*mem)[j++] = tmp_mem[i] & 0xf;
|
||||||
|
(*mem)[j++] = (tmp_mem[i] >> 4) & 0xf;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(tmp_mem);
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
|
||||||
/*
|
|
||||||
* size is different, check size and decompress memory
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (st.st_size != *size / 2)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "strange size %s, expected %d, found %ld\n",
|
|
||||||
name, *size / 2, st.st_size);
|
|
||||||
free(*mem);
|
|
||||||
*mem = NULL;
|
|
||||||
*size = 0;
|
|
||||||
fclose(fp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NULL == (tmp_mem = (unsigned char *)malloc((size_t)st.st_size)))
|
|
||||||
{
|
|
||||||
for (i = 0, j = 0; i < *size / 2; i++)
|
|
||||||
{
|
|
||||||
if (1 != fread(&byte, 1, 1, fp))
|
|
||||||
{
|
|
||||||
fprintf(stderr, "can\'t read %s\n", name);
|
|
||||||
free(*mem);
|
|
||||||
*mem = NULL;
|
|
||||||
*size = 0;
|
|
||||||
fclose(fp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
(*mem)[j++] = byte & 0xf;
|
|
||||||
(*mem)[j++] = (byte >> 4) & 0xf;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (fread(tmp_mem, 1, (size_t)*size / 2, fp) != *size / 2)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "can\'t read %s\n", name);
|
|
||||||
free(*mem);
|
|
||||||
*mem = NULL;
|
|
||||||
*size = 0;
|
|
||||||
fclose(fp);
|
|
||||||
free(tmp_mem);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0, j = 0; i < *size / 2; i++)
|
|
||||||
{
|
|
||||||
(*mem)[j++] = tmp_mem[i] & 0xf;
|
|
||||||
(*mem)[j++] = (tmp_mem[i] >> 4) & 0xf;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(tmp_mem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
if ((*mem)[0x29] == 0x00)
|
if ((*mem)[0x29] == 0x00) {
|
||||||
{
|
if (*size == ROM_SIZE_GX) {
|
||||||
if (*size == ROM_SIZE_GX)
|
opt_gx = 1;
|
||||||
{
|
} else if (*size == 4 * ROM_SIZE_GX) {
|
||||||
opt_gx = 1;
|
fprintf(stderr, "%s seems to be HP49 ROM, but size is 0x%x\n", name,
|
||||||
}
|
*size);
|
||||||
else
|
opt_gx = 2;
|
||||||
if (*size == 4 * ROM_SIZE_GX)
|
} else if (*size == 8 * ROM_SIZE_GX) {
|
||||||
{
|
fprintf(stderr, "%s seems to be HP49 ROM, but size is 0x%x\n", name,
|
||||||
fprintf(stderr, "%s seems to be HP49 ROM, but size is 0x%x\n",
|
*size);
|
||||||
name, *size);
|
opt_gx = 2;
|
||||||
opt_gx = 2;
|
} else {
|
||||||
}
|
fprintf(stderr, "%s seems to be G/GX ROM, but size is 0x%x\n", name,
|
||||||
else
|
*size);
|
||||||
if (*size == 8 * ROM_SIZE_GX)
|
free(*mem);
|
||||||
{
|
*mem = NULL;
|
||||||
fprintf(stderr, "%s seems to be HP49 ROM, but size is 0x%x\n",
|
*size = 0;
|
||||||
name, *size);
|
return 0;
|
||||||
opt_gx = 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf(stderr, "%s seems to be G/GX ROM, but size is 0x%x\n",
|
|
||||||
name, *size);
|
|
||||||
free(*mem);
|
|
||||||
*mem = NULL;
|
|
||||||
*size = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
} else {
|
||||||
{
|
if (*size == ROM_SIZE_SX) {
|
||||||
if (*size == ROM_SIZE_SX)
|
opt_gx = 0;
|
||||||
{
|
} else {
|
||||||
opt_gx = 0;
|
fprintf(stderr, "%s seems to be S/SX ROM, but size is 0x%x\n", name,
|
||||||
}
|
*size);
|
||||||
else
|
free(*mem);
|
||||||
{
|
*mem = NULL;
|
||||||
fprintf(stderr, "%s seems to be S/SX ROM, but size is 0x%x\n",
|
*size = 0;
|
||||||
name, *size);
|
return 0;
|
||||||
free(*mem);
|
|
||||||
*mem = NULL;
|
|
||||||
*size = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
printf("%s: read %s\n", progname, name);
|
printf("%s: read %s\n", progname, name);
|
||||||
|
|
136
src/rpl.h
136
src/rpl.h
|
@ -43,90 +43,90 @@
|
||||||
/*
|
/*
|
||||||
* Addresses in SX ROM
|
* Addresses in SX ROM
|
||||||
*/
|
*/
|
||||||
#define ROMPTAB_SX 0x707d9
|
#define ROMPTAB_SX 0x707d9
|
||||||
#define ROMPTAB_GX 0x809a3
|
#define ROMPTAB_GX 0x809a3
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Object Prologs
|
* Object Prologs
|
||||||
*/
|
*/
|
||||||
#define DOBINT 0x02911 /* System Binary */
|
#define DOBINT 0x02911 /* System Binary */
|
||||||
#define DOREAL 0x02933 /* Real */
|
#define DOREAL 0x02933 /* Real */
|
||||||
#define DOEREL 0x02955 /* Extended Real */
|
#define DOEREL 0x02955 /* Extended Real */
|
||||||
#define DOCMP 0x02977 /* Complex */
|
#define DOCMP 0x02977 /* Complex */
|
||||||
#define DOECMP 0x0299d /* Extended Complex */
|
#define DOECMP 0x0299d /* Extended Complex */
|
||||||
#define DOCHAR 0x029bf /* Character */
|
#define DOCHAR 0x029bf /* Character */
|
||||||
#define DOARRY 0x029e8 /* Array */
|
#define DOARRY 0x029e8 /* Array */
|
||||||
#define DOLNKARRY 0x02a0a /* Linked Array */
|
#define DOLNKARRY 0x02a0a /* Linked Array */
|
||||||
#define DOCSTR 0x02a2c /* String */
|
#define DOCSTR 0x02a2c /* String */
|
||||||
#define DOHSTR 0x02a4e /* Binary Integer */
|
#define DOHSTR 0x02a4e /* Binary Integer */
|
||||||
#define DOLIST 0x02a74 /* List */
|
#define DOLIST 0x02a74 /* List */
|
||||||
#define DORRP 0x02a96 /* Directory */
|
#define DORRP 0x02a96 /* Directory */
|
||||||
#define DOSYMB 0x02ab8 /* Algebraic */
|
#define DOSYMB 0x02ab8 /* Algebraic */
|
||||||
#define DOEXT 0x02ada /* Unit */
|
#define DOEXT 0x02ada /* Unit */
|
||||||
#define DOTAG 0x02afc /* Tagged */
|
#define DOTAG 0x02afc /* Tagged */
|
||||||
#define DOGROB 0x02b1e /* Graphic Object */
|
#define DOGROB 0x02b1e /* Graphic Object */
|
||||||
#define DOLIB 0x02b40 /* Library */
|
#define DOLIB 0x02b40 /* Library */
|
||||||
#define DOBAK 0x02b62 /* Backup */
|
#define DOBAK 0x02b62 /* Backup */
|
||||||
#define DOEXT0 0x02b88 /* Library Data */
|
#define DOEXT0 0x02b88 /* Library Data */
|
||||||
#define DOACPTR 0x02baa /* */
|
#define DOACPTR 0x02baa /* */
|
||||||
#define DOEXT2 0x02bcc /* */
|
#define DOEXT2 0x02bcc /* */
|
||||||
#define DOEXT3 0x02bee /* */
|
#define DOEXT3 0x02bee /* */
|
||||||
#define DOEXT4 0x02c10 /* */
|
#define DOEXT4 0x02c10 /* */
|
||||||
#define DOCOL 0x02d9d /* Program */
|
#define DOCOL 0x02d9d /* Program */
|
||||||
#define DOCODE 0x02dcc /* Code */
|
#define DOCODE 0x02dcc /* Code */
|
||||||
#define DOIDNT 0x02e48 /* Global Name */
|
#define DOIDNT 0x02e48 /* Global Name */
|
||||||
#define DOLAM 0x02e6d /* Local Name */
|
#define DOLAM 0x02e6d /* Local Name */
|
||||||
#define DOROMP 0x02e92 /* XLib Name */
|
#define DOROMP 0x02e92 /* XLib Name */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Terminates composite objects
|
* Terminates composite objects
|
||||||
*/
|
*/
|
||||||
#define SEMI 0x0312b /* Semi */
|
#define SEMI 0x0312b /* Semi */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Unit Operators
|
* Unit Operators
|
||||||
*/
|
*/
|
||||||
#define UM_MUL 0x10b5e /* Unit Operator * */
|
#define UM_MUL 0x10b5e /* Unit Operator * */
|
||||||
#define UM_DIV 0x10b68 /* Unit Operator / */
|
#define UM_DIV 0x10b68 /* Unit Operator / */
|
||||||
#define UM_POW 0x10b72 /* Unit Operator ^ */
|
#define UM_POW 0x10b72 /* Unit Operator ^ */
|
||||||
#define UM_PRE 0x10b7c /* Unit Operator prefix */
|
#define UM_PRE 0x10b7c /* Unit Operator prefix */
|
||||||
#define UM_END 0x10b86 /* Unit Operator _ */
|
#define UM_END 0x10b86 /* Unit Operator _ */
|
||||||
|
|
||||||
typedef struct hp_real {
|
typedef struct hp_real {
|
||||||
word_20 x;
|
word_20 x;
|
||||||
word_32 ml;
|
word_32 ml;
|
||||||
word_32 mh;
|
word_32 mh;
|
||||||
word_4 m;
|
word_4 m;
|
||||||
word_1 s;
|
word_1 s;
|
||||||
} hp_real;
|
} hp_real;
|
||||||
|
|
||||||
extern char *decode_rpl_obj __ProtoType__((word_20 addr, char *buf));
|
extern char *decode_rpl_obj __ProtoType__((word_20 addr, char *buf));
|
||||||
extern void decode_rpl_obj_2 __ProtoType__((word_20 addr, char *typ, char *dat));
|
extern void decode_rpl_obj_2 __ProtoType__((word_20 addr, char *typ,
|
||||||
|
char *dat));
|
||||||
|
|
||||||
extern char *skip_ob __ProtoType__((word_20 *addr, char *string));
|
extern char *skip_ob __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_rpl_obj __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_rpl_obj __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_bin_int __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_bin_int __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_real __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_real __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_long_real __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_long_real __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_complex __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_complex __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_long_complex __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_long_complex __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_char __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_char __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_array __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_array __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_lnk_array __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_lnk_array __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_string __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_string __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_hex_string __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_hex_string __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_list __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_list __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_symb __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_symb __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_unit __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_unit __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_library __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_library __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_library_data __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_library_data __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_acptr __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_acptr __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_prog __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_prog __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_code __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_code __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_global_ident __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_global_ident __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_local_ident __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_local_ident __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_xlib_name __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_xlib_name __ProtoType__((word_20 * addr, char *string));
|
||||||
extern char *dec_unit_op __ProtoType__((word_20 *addr, char *string));
|
extern char *dec_unit_op __ProtoType__((word_20 * addr, char *string));
|
||||||
|
|
||||||
#endif /* !_RPL_H */
|
#endif /* !_RPL_H */
|
||||||
|
|
675
src/serial.c
675
src/serial.c
|
@ -60,28 +60,27 @@
|
||||||
* $Id: serial.c,v 1.11 1995/01/11 18:20:01 ecd Exp ecd $
|
* $Id: serial.c,v 1.11 1995/01/11 18:20:01 ecd Exp ecd $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <fcntl.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#if defined(HPUX) || defined(CSRG_BASED)
|
#if defined(HPUX) || defined(CSRG_BASED)
|
||||||
# include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#endif
|
#endif
|
||||||
#include <unistd.h>
|
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
|
#include <unistd.h>
|
||||||
#ifdef SOLARIS
|
#ifdef SOLARIS
|
||||||
# include <sys/stream.h>
|
#include <sys/stream.h>
|
||||||
# include <sys/stropts.h>
|
#include <sys/stropts.h>
|
||||||
# include <sys/termios.h>
|
#include <sys/termios.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "hp48.h"
|
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
|
#include "hp48.h"
|
||||||
#include "hp48_emu.h"
|
#include "hp48_emu.h"
|
||||||
#include "resources.h"
|
#include "resources.h"
|
||||||
#include "x48_x11.h"
|
#include "x48_x11.h"
|
||||||
|
@ -98,161 +97,133 @@ static char *ir_name = (char *)0;
|
||||||
/* #define DEBUG_SERIAL */
|
/* #define DEBUG_SERIAL */
|
||||||
|
|
||||||
void update_connection_display(void) {
|
void update_connection_display(void) {
|
||||||
if (wire_fd == -1)
|
if (wire_fd == -1) {
|
||||||
{
|
if (wire_name)
|
||||||
if (wire_name) free(wire_name);
|
free(wire_name);
|
||||||
wire_name = (char *)0;
|
wire_name = (char *)0;
|
||||||
}
|
}
|
||||||
if (ir_fd == -1)
|
if (ir_fd == -1) {
|
||||||
{
|
if (ir_name)
|
||||||
if (ir_name) free(ir_name);
|
free(ir_name);
|
||||||
ir_name = (char *)0;
|
ir_name = (char *)0;
|
||||||
}
|
}
|
||||||
ShowConnections(wire_name, ir_name);
|
ShowConnections(wire_name, ir_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int serial_init(void) {
|
int serial_init(void) {
|
||||||
char *p;
|
char *p;
|
||||||
int c;
|
int c;
|
||||||
int n;
|
int n;
|
||||||
char tty_dev_name[128];
|
char tty_dev_name[128];
|
||||||
struct termios ttybuf;
|
struct termios ttybuf;
|
||||||
|
|
||||||
wire_fd = -1;
|
wire_fd = -1;
|
||||||
ttyp = -1;
|
ttyp = -1;
|
||||||
if (useTerminal)
|
if (useTerminal) {
|
||||||
{
|
|
||||||
#if defined(IRIX)
|
#if defined(IRIX)
|
||||||
if ((p = _getpty(&wire_fd, O_RDWR | O_EXCL | O_NDELAY, 0666, 0)) == NULL)
|
if ((p = _getpty(&wire_fd, O_RDWR | O_EXCL | O_NDELAY, 0666, 0)) == NULL) {
|
||||||
{
|
wire_fd = -1;
|
||||||
wire_fd = -1;
|
ttyp = -1;
|
||||||
ttyp = -1;
|
} else {
|
||||||
}
|
if ((ttyp = open(p, O_RDWR | O_NDELAY, 0666)) < 0) {
|
||||||
else
|
close(wire_fd);
|
||||||
{
|
wire_fd = -1;
|
||||||
if ((ttyp = open(p, O_RDWR | O_NDELAY, 0666)) < 0)
|
ttyp = -1;
|
||||||
{
|
} else {
|
||||||
close(wire_fd);
|
if (verbose)
|
||||||
wire_fd = -1;
|
printf("%s: wire connection on %s\n", progname, p);
|
||||||
ttyp = -1;
|
wire_name = strdup(p);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (verbose)
|
|
||||||
printf("%s: wire connection on %s\n", progname, p);
|
|
||||||
wire_name = strdup(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#elif defined(SOLARIS)
|
|
||||||
if ((wire_fd = open("/dev/ptmx", O_RDWR | O_NONBLOCK, 0666)) >= 0)
|
|
||||||
{
|
|
||||||
grantpt(wire_fd);
|
|
||||||
unlockpt(wire_fd);
|
|
||||||
p = ptsname(wire_fd);
|
|
||||||
strcpy(tty_dev_name, p);
|
|
||||||
if ((ttyp = open(tty_dev_name, O_RDWR | O_NDELAY, 0666)) >= 0)
|
|
||||||
{
|
|
||||||
ioctl(ttyp, I_PUSH, "ptem");
|
|
||||||
ioctl(ttyp, I_PUSH, "ldterm");
|
|
||||||
if (verbose)
|
|
||||||
printf("%s: wire connection on %s\n", progname,
|
|
||||||
tty_dev_name);
|
|
||||||
wire_name = strdup(tty_dev_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#elif defined(LINUX)
|
|
||||||
/* Unix98 PTY (Preferred) */
|
|
||||||
if ((wire_fd = open("/dev/ptmx", O_RDWR | O_NONBLOCK, 0666)) >= 0)
|
|
||||||
{
|
|
||||||
grantpt(wire_fd);
|
|
||||||
unlockpt(wire_fd);
|
|
||||||
if (ptsname_r(wire_fd, tty_dev_name, 128)) {
|
|
||||||
perror("Could not get the name of the wire device.");
|
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
if ((ttyp = open(tty_dev_name, O_RDWR | O_NDELAY, 0666)) >= 0)
|
|
||||||
{
|
|
||||||
if (verbose)
|
|
||||||
printf("%s: wire connection on %s\n", progname,
|
|
||||||
tty_dev_name);
|
|
||||||
wire_name = strdup(tty_dev_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* BSD PTY (Legacy) */
|
|
||||||
else
|
|
||||||
{
|
|
||||||
c = 'p';
|
|
||||||
do
|
|
||||||
{
|
|
||||||
for (n = 0; n < 16; n++)
|
|
||||||
{
|
|
||||||
sprintf(tty_dev_name, "/dev/pty%c%x", c, n);
|
|
||||||
if ((wire_fd = open(tty_dev_name,
|
|
||||||
O_RDWR | O_EXCL | O_NDELAY, 0666)) >= 0)
|
|
||||||
{
|
|
||||||
ttyp = wire_fd;
|
|
||||||
sprintf(tty_dev_name, "/dev/tty%c%x", c, n);
|
|
||||||
if (verbose)
|
|
||||||
printf("%s: wire connection on %s\n", progname,
|
|
||||||
tty_dev_name);
|
|
||||||
wire_name = strdup(tty_dev_name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
while ((wire_fd < 0) && (errno != ENOENT));
|
|
||||||
}
|
}
|
||||||
#else
|
#elif defined(SOLARIS)
|
||||||
/*
|
if ((wire_fd = open("/dev/ptmx", O_RDWR | O_NONBLOCK, 0666)) >= 0) {
|
||||||
* Here we go for SUNOS, HPUX
|
grantpt(wire_fd);
|
||||||
*/
|
unlockpt(wire_fd);
|
||||||
|
p = ptsname(wire_fd);
|
||||||
|
strcpy(tty_dev_name, p);
|
||||||
|
if ((ttyp = open(tty_dev_name, O_RDWR | O_NDELAY, 0666)) >= 0) {
|
||||||
|
ioctl(ttyp, I_PUSH, "ptem");
|
||||||
|
ioctl(ttyp, I_PUSH, "ldterm");
|
||||||
|
if (verbose)
|
||||||
|
printf("%s: wire connection on %s\n", progname, tty_dev_name);
|
||||||
|
wire_name = strdup(tty_dev_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#elif defined(LINUX)
|
||||||
|
/* Unix98 PTY (Preferred) */
|
||||||
|
if ((wire_fd = open("/dev/ptmx", O_RDWR | O_NONBLOCK, 0666)) >= 0) {
|
||||||
|
grantpt(wire_fd);
|
||||||
|
unlockpt(wire_fd);
|
||||||
|
if (ptsname_r(wire_fd, tty_dev_name, 128)) {
|
||||||
|
perror("Could not get the name of the wire device.");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
if ((ttyp = open(tty_dev_name, O_RDWR | O_NDELAY, 0666)) >= 0) {
|
||||||
|
if (verbose)
|
||||||
|
printf("%s: wire connection on %s\n", progname, tty_dev_name);
|
||||||
|
wire_name = strdup(tty_dev_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* BSD PTY (Legacy) */
|
||||||
|
else {
|
||||||
c = 'p';
|
c = 'p';
|
||||||
do
|
do {
|
||||||
{
|
for (n = 0; n < 16; n++) {
|
||||||
for (n = 0; n < 16; n++)
|
sprintf(tty_dev_name, "/dev/pty%c%x", c, n);
|
||||||
{
|
if ((wire_fd =
|
||||||
sprintf(tty_dev_name, "/dev/ptyp%x", n);
|
open(tty_dev_name, O_RDWR | O_EXCL | O_NDELAY, 0666)) >= 0) {
|
||||||
if ((wire_fd = open(tty_dev_name,
|
ttyp = wire_fd;
|
||||||
O_RDWR | O_EXCL | O_NDELAY, 0666)) >= 0)
|
sprintf(tty_dev_name, "/dev/tty%c%x", c, n);
|
||||||
{
|
if (verbose)
|
||||||
sprintf(tty_dev_name, "/dev/tty%c%x", c, n);
|
printf("%s: wire connection on %s\n", progname, tty_dev_name);
|
||||||
if ((ttyp = open(tty_dev_name, O_RDWR | O_NDELAY, 0666)) < 0)
|
wire_name = strdup(tty_dev_name);
|
||||||
{
|
break;
|
||||||
wire_fd = -1;
|
}
|
||||||
ttyp = -1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (verbose)
|
|
||||||
printf("%s: wire connection on %s\n", progname,
|
|
||||||
tty_dev_name);
|
|
||||||
wire_name = strdup(tty_dev_name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c++;
|
|
||||||
}
|
}
|
||||||
while ((wire_fd < 0) && (errno != ENOENT));
|
c++;
|
||||||
#endif
|
} while ((wire_fd < 0) && (errno != ENOENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ttyp >= 0)
|
|
||||||
{
|
|
||||||
#if defined(TCSANOW)
|
|
||||||
if (tcgetattr(ttyp, &ttybuf) < 0)
|
|
||||||
#else
|
#else
|
||||||
if (ioctl(ttyp, TCGETS, (char *)&ttybuf) < 0)
|
/*
|
||||||
#endif
|
* Here we go for SUNOS, HPUX
|
||||||
{
|
*/
|
||||||
if (!quiet)
|
c = 'p';
|
||||||
fprintf(stderr, "%s: ioctl(wire, TCGETS) failed, errno = %d\n",
|
do {
|
||||||
progname, errno);
|
for (n = 0; n < 16; n++) {
|
||||||
wire_fd = -1;
|
sprintf(tty_dev_name, "/dev/ptyp%x", n);
|
||||||
ttyp = -1;
|
if ((wire_fd = open(tty_dev_name, O_RDWR | O_EXCL | O_NDELAY, 0666)) >=
|
||||||
|
0) {
|
||||||
|
sprintf(tty_dev_name, "/dev/tty%c%x", c, n);
|
||||||
|
if ((ttyp = open(tty_dev_name, O_RDWR | O_NDELAY, 0666)) < 0) {
|
||||||
|
wire_fd = -1;
|
||||||
|
ttyp = -1;
|
||||||
|
} else {
|
||||||
|
if (verbose)
|
||||||
|
printf("%s: wire connection on %s\n", progname, tty_dev_name);
|
||||||
|
wire_name = strdup(tty_dev_name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
c++;
|
||||||
|
} while ((wire_fd < 0) && (errno != ENOENT));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ttyp >= 0) {
|
||||||
|
#if defined(TCSANOW)
|
||||||
|
if (tcgetattr(ttyp, &ttybuf) < 0)
|
||||||
|
#else
|
||||||
|
if (ioctl(ttyp, TCGETS, (char *)&ttybuf) < 0)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
if (!quiet)
|
||||||
|
fprintf(stderr, "%s: ioctl(wire, TCGETS) failed, errno = %d\n",
|
||||||
|
progname, errno);
|
||||||
|
wire_fd = -1;
|
||||||
|
ttyp = -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ttybuf.c_lflag = 0;
|
ttybuf.c_lflag = 0;
|
||||||
ttybuf.c_iflag = 0;
|
ttybuf.c_iflag = 0;
|
||||||
|
@ -263,48 +234,44 @@ int serial_init(void) {
|
||||||
ttybuf.c_cc[VTIME] = 0;
|
ttybuf.c_cc[VTIME] = 0;
|
||||||
ttybuf.c_cc[VMIN] = 1;
|
ttybuf.c_cc[VMIN] = 1;
|
||||||
|
|
||||||
if (ttyp >= 0)
|
if (ttyp >= 0) {
|
||||||
{
|
|
||||||
#if defined(TCSANOW)
|
#if defined(TCSANOW)
|
||||||
if (tcsetattr(ttyp, TCSANOW, &ttybuf) < 0)
|
if (tcsetattr(ttyp, TCSANOW, &ttybuf) < 0)
|
||||||
#else
|
#else
|
||||||
if (ioctl(ttyp, TCSETS, (char *)&ttybuf) < 0)
|
if (ioctl(ttyp, TCSETS, (char *)&ttybuf) < 0)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
fprintf(stderr, "%s: ioctl(wire, TCSETS) failed, errno = %d\n",
|
fprintf(stderr, "%s: ioctl(wire, TCSETS) failed, errno = %d\n",
|
||||||
progname, errno);
|
progname, errno);
|
||||||
wire_fd = -1;
|
wire_fd = -1;
|
||||||
ttyp = -1;
|
ttyp = -1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ir_fd = -1;
|
ir_fd = -1;
|
||||||
if (useSerial)
|
if (useSerial) {
|
||||||
{
|
sprintf(tty_dev_name, serialLine);
|
||||||
sprintf(tty_dev_name, serialLine);
|
if ((ir_fd = open(tty_dev_name, O_RDWR | O_NDELAY)) >= 0) {
|
||||||
if ((ir_fd = open(tty_dev_name, O_RDWR | O_NDELAY)) >= 0)
|
if (verbose)
|
||||||
{
|
printf("%s: IR connection on %s\n", progname, tty_dev_name);
|
||||||
if (verbose)
|
ir_name = strdup(tty_dev_name);
|
||||||
printf("%s: IR connection on %s\n", progname, tty_dev_name);
|
|
||||||
ir_name = strdup(tty_dev_name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ir_fd >= 0)
|
if (ir_fd >= 0) {
|
||||||
{
|
|
||||||
#if defined(TCSANOW)
|
#if defined(TCSANOW)
|
||||||
if (tcgetattr(ir_fd, &ttybuf) < 0)
|
if (tcgetattr(ir_fd, &ttybuf) < 0)
|
||||||
#else
|
#else
|
||||||
if (ioctl(ir_fd, TCGETS, (char *)&ttybuf) < 0)
|
if (ioctl(ir_fd, TCGETS, (char *)&ttybuf) < 0)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
fprintf(stderr, "%s: ioctl(IR, TCGETS) failed, errno = %d\n",
|
fprintf(stderr, "%s: ioctl(IR, TCGETS) failed, errno = %d\n", progname,
|
||||||
progname, errno);
|
errno);
|
||||||
ir_fd = -1;
|
ir_fd = -1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ttybuf.c_lflag = 0;
|
ttybuf.c_lflag = 0;
|
||||||
ttybuf.c_iflag = 0;
|
ttybuf.c_iflag = 0;
|
||||||
|
@ -315,20 +282,19 @@ int serial_init(void) {
|
||||||
ttybuf.c_cc[VTIME] = 0;
|
ttybuf.c_cc[VTIME] = 0;
|
||||||
ttybuf.c_cc[VMIN] = 1;
|
ttybuf.c_cc[VMIN] = 1;
|
||||||
|
|
||||||
if (ir_fd >= 0)
|
if (ir_fd >= 0) {
|
||||||
{
|
|
||||||
#if defined(TCSANOW)
|
#if defined(TCSANOW)
|
||||||
if (tcsetattr(ir_fd, TCSANOW, &ttybuf) < 0)
|
if (tcsetattr(ir_fd, TCSANOW, &ttybuf) < 0)
|
||||||
#else
|
#else
|
||||||
if (ioctl(ir_fd, TCSETS, (char *)&ttybuf) < 0)
|
if (ioctl(ir_fd, TCSETS, (char *)&ttybuf) < 0)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
fprintf(stderr, "%s: ioctl(IR, TCSETS) failed, errno = %d\n",
|
fprintf(stderr, "%s: ioctl(IR, TCSETS) failed, errno = %d\n", progname,
|
||||||
progname, errno);
|
errno);
|
||||||
ir_fd = -1;
|
ir_fd = -1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
update_connection_display();
|
update_connection_display();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -337,215 +303,204 @@ void serial_baud(int baud) {
|
||||||
int error = 0;
|
int error = 0;
|
||||||
struct termios ttybuf;
|
struct termios ttybuf;
|
||||||
|
|
||||||
if (ir_fd >= 0)
|
if (ir_fd >= 0) {
|
||||||
{
|
|
||||||
#if defined(TCSANOW)
|
#if defined(TCSANOW)
|
||||||
if (tcgetattr(ir_fd, &ttybuf) < 0)
|
if (tcgetattr(ir_fd, &ttybuf) < 0)
|
||||||
#else
|
#else
|
||||||
if (ioctl(ir_fd, TCGETS, (char *)&ttybuf) < 0)
|
if (ioctl(ir_fd, TCGETS, (char *)&ttybuf) < 0)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
fprintf(stderr, "%s: ioctl(IR, TCGETS) failed, errno = %d\n",
|
fprintf(stderr, "%s: ioctl(IR, TCGETS) failed, errno = %d\n", progname,
|
||||||
progname, errno);
|
errno);
|
||||||
ir_fd = -1;
|
ir_fd = -1;
|
||||||
error = 1;
|
error = 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
baud &= 0x7;
|
baud &= 0x7;
|
||||||
switch (baud)
|
switch (baud) {
|
||||||
{
|
case 0: /* 1200 */
|
||||||
case 0: /* 1200 */
|
ttybuf.c_cflag |= B1200;
|
||||||
ttybuf.c_cflag |= B1200;
|
break;
|
||||||
break;
|
case 1: /* 1920 */
|
||||||
case 1: /* 1920 */
|
#ifdef B1920
|
||||||
# ifdef B1920
|
ttybuf.c_cflag |= B1920;
|
||||||
ttybuf.c_cflag |= B1920;
|
#endif
|
||||||
# endif
|
break;
|
||||||
break;
|
case 2: /* 2400 */
|
||||||
case 2: /* 2400 */
|
ttybuf.c_cflag |= B2400;
|
||||||
ttybuf.c_cflag |= B2400;
|
break;
|
||||||
break;
|
case 3: /* 3840 */
|
||||||
case 3: /* 3840 */
|
#ifdef B3840
|
||||||
# ifdef B3840
|
ttybuf.c_cflag |= B3840;
|
||||||
ttybuf.c_cflag |= B3840;
|
#endif
|
||||||
# endif
|
break;
|
||||||
break;
|
case 4: /* 4800 */
|
||||||
case 4: /* 4800 */
|
ttybuf.c_cflag |= B4800;
|
||||||
ttybuf.c_cflag |= B4800;
|
break;
|
||||||
break;
|
case 5: /* 7680 */
|
||||||
case 5: /* 7680 */
|
#ifdef B7680
|
||||||
# ifdef B7680
|
ttybuf.c_cflag |= B7680;
|
||||||
ttybuf.c_cflag |= B7680;
|
#endif
|
||||||
# endif
|
break;
|
||||||
break;
|
case 6: /* 9600 */
|
||||||
case 6: /* 9600 */
|
ttybuf.c_cflag |= B9600;
|
||||||
ttybuf.c_cflag |= B9600;
|
break;
|
||||||
break;
|
case 7: /* 15360 */
|
||||||
case 7: /* 15360 */
|
#ifdef B15360
|
||||||
# ifdef B15360
|
ttybuf.c_cflag |= B15360;
|
||||||
ttybuf.c_cflag |= B15360;
|
#endif
|
||||||
# endif
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ((ir_fd >= 0) && ((ttybuf.c_ospeed) == 0))
|
if ((ir_fd >= 0) && ((ttybuf.c_ospeed) == 0)) {
|
||||||
{
|
if (!quiet)
|
||||||
if (!quiet)
|
fprintf(stderr, "%s: can\'t set baud rate, using 9600\n", progname);
|
||||||
fprintf(stderr, "%s: can\'t set baud rate, using 9600\n", progname);
|
ttybuf.c_cflag |= B9600;
|
||||||
ttybuf.c_cflag |= B9600;
|
}
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
ttybuf.c_cflag &= ~CBAUD;
|
ttybuf.c_cflag &= ~CBAUD;
|
||||||
|
|
||||||
baud &= 0x7;
|
baud &= 0x7;
|
||||||
switch (baud)
|
switch (baud) {
|
||||||
{
|
case 0: /* 1200 */
|
||||||
case 0: /* 1200 */
|
ttybuf.c_cflag |= B1200;
|
||||||
ttybuf.c_cflag |= B1200;
|
break;
|
||||||
break;
|
case 1: /* 1920 */
|
||||||
case 1: /* 1920 */
|
#ifdef B1920
|
||||||
# ifdef B1920
|
ttybuf.c_cflag |= B1920;
|
||||||
ttybuf.c_cflag |= B1920;
|
#endif
|
||||||
# endif
|
break;
|
||||||
break;
|
case 2: /* 2400 */
|
||||||
case 2: /* 2400 */
|
ttybuf.c_cflag |= B2400;
|
||||||
ttybuf.c_cflag |= B2400;
|
break;
|
||||||
break;
|
case 3: /* 3840 */
|
||||||
case 3: /* 3840 */
|
#ifdef B3840
|
||||||
# ifdef B3840
|
ttybuf.c_cflag |= B3840;
|
||||||
ttybuf.c_cflag |= B3840;
|
#endif
|
||||||
# endif
|
break;
|
||||||
break;
|
case 4: /* 4800 */
|
||||||
case 4: /* 4800 */
|
ttybuf.c_cflag |= B4800;
|
||||||
ttybuf.c_cflag |= B4800;
|
break;
|
||||||
break;
|
case 5: /* 7680 */
|
||||||
case 5: /* 7680 */
|
#ifdef B7680
|
||||||
# ifdef B7680
|
ttybuf.c_cflag |= B7680;
|
||||||
ttybuf.c_cflag |= B7680;
|
#endif
|
||||||
# endif
|
break;
|
||||||
break;
|
case 6: /* 9600 */
|
||||||
case 6: /* 9600 */
|
ttybuf.c_cflag |= B9600;
|
||||||
ttybuf.c_cflag |= B9600;
|
break;
|
||||||
break;
|
case 7: /* 15360 */
|
||||||
case 7: /* 15360 */
|
#ifdef B15360
|
||||||
# ifdef B15360
|
ttybuf.c_cflag |= B15360;
|
||||||
ttybuf.c_cflag |= B15360;
|
#endif
|
||||||
# endif
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ((ir_fd >= 0) && ((ttybuf.c_cflag & CBAUD) == 0))
|
if ((ir_fd >= 0) && ((ttybuf.c_cflag & CBAUD) == 0)) {
|
||||||
|
if (!quiet)
|
||||||
|
fprintf(stderr, "%s: can\'t set baud rate, using 9600\n", progname);
|
||||||
|
ttybuf.c_cflag |= B9600;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (ir_fd >= 0) {
|
||||||
|
#if defined(TCSANOW)
|
||||||
|
if (tcsetattr(ir_fd, TCSANOW, &ttybuf) < 0)
|
||||||
|
#else
|
||||||
|
if (ioctl(ir_fd, TCSETS, (char *)&ttybuf) < 0)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
fprintf(stderr, "%s: can\'t set baud rate, using 9600\n", progname);
|
fprintf(stderr, "%s: ioctl(IR, TCSETS) failed, errno = %d\n", progname,
|
||||||
ttybuf.c_cflag |= B9600;
|
errno);
|
||||||
}
|
ir_fd = -1;
|
||||||
#endif
|
error = 1;
|
||||||
if (ir_fd >= 0)
|
|
||||||
{
|
|
||||||
#if defined(TCSANOW)
|
|
||||||
if (tcsetattr(ir_fd, TCSANOW, &ttybuf) < 0)
|
|
||||||
#else
|
|
||||||
if (ioctl(ir_fd, TCSETS, (char *)&ttybuf) < 0)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
if (!quiet)
|
|
||||||
fprintf(stderr, "%s: ioctl(IR, TCSETS) failed, errno = %d\n",
|
|
||||||
progname, errno);
|
|
||||||
ir_fd = -1;
|
|
||||||
error = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ttyp >= 0)
|
if (ttyp >= 0) {
|
||||||
{
|
|
||||||
#if defined(TCSANOW)
|
#if defined(TCSANOW)
|
||||||
if (tcgetattr(ttyp, &ttybuf) < 0)
|
if (tcgetattr(ttyp, &ttybuf) < 0)
|
||||||
#else
|
#else
|
||||||
if (ioctl(ttyp, TCGETS, (char *)&ttybuf) < 0)
|
if (ioctl(ttyp, TCGETS, (char *)&ttybuf) < 0)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
fprintf(stderr, "%s: ioctl(wire, TCGETS) failed, errno = %d\n",
|
fprintf(stderr, "%s: ioctl(wire, TCGETS) failed, errno = %d\n",
|
||||||
progname, errno);
|
progname, errno);
|
||||||
wire_fd = -1;
|
wire_fd = -1;
|
||||||
ttyp = -1;
|
ttyp = -1;
|
||||||
error = 1;
|
error = 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
#else
|
#else
|
||||||
ttybuf.c_cflag &= ~CBAUD;
|
ttybuf.c_cflag &= ~CBAUD;
|
||||||
|
|
||||||
baud &= 0x7;
|
baud &= 0x7;
|
||||||
switch (baud)
|
switch (baud) {
|
||||||
{
|
case 0: /* 1200 */
|
||||||
case 0: /* 1200 */
|
ttybuf.c_cflag |= B1200;
|
||||||
ttybuf.c_cflag |= B1200;
|
break;
|
||||||
break;
|
case 1: /* 1920 */
|
||||||
case 1: /* 1920 */
|
#ifdef B1920
|
||||||
# ifdef B1920
|
ttybuf.c_cflag |= B1920;
|
||||||
ttybuf.c_cflag |= B1920;
|
#endif
|
||||||
# endif
|
break;
|
||||||
break;
|
case 2: /* 2400 */
|
||||||
case 2: /* 2400 */
|
ttybuf.c_cflag |= B2400;
|
||||||
ttybuf.c_cflag |= B2400;
|
break;
|
||||||
break;
|
case 3: /* 3840 */
|
||||||
case 3: /* 3840 */
|
#ifdef B3840
|
||||||
# ifdef B3840
|
ttybuf.c_cflag |= B3840;
|
||||||
ttybuf.c_cflag |= B3840;
|
#endif
|
||||||
# endif
|
break;
|
||||||
break;
|
case 4: /* 4800 */
|
||||||
case 4: /* 4800 */
|
ttybuf.c_cflag |= B4800;
|
||||||
ttybuf.c_cflag |= B4800;
|
break;
|
||||||
break;
|
case 5: /* 7680 */
|
||||||
case 5: /* 7680 */
|
#ifdef B7680
|
||||||
# ifdef B7680
|
ttybuf.c_cflag |= B7680;
|
||||||
ttybuf.c_cflag |= B7680;
|
#endif
|
||||||
# endif
|
break;
|
||||||
break;
|
case 6: /* 9600 */
|
||||||
case 6: /* 9600 */
|
ttybuf.c_cflag |= B9600;
|
||||||
ttybuf.c_cflag |= B9600;
|
break;
|
||||||
break;
|
case 7: /* 15360 */
|
||||||
case 7: /* 15360 */
|
#ifdef B15360
|
||||||
# ifdef B15360
|
ttybuf.c_cflag |= B15360;
|
||||||
ttybuf.c_cflag |= B15360;
|
#endif
|
||||||
# endif
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ((ttyp >= 0) && ((ttybuf.c_cflag & CBAUD) == 0))
|
if ((ttyp >= 0) && ((ttybuf.c_cflag & CBAUD) == 0)) {
|
||||||
|
if (!quiet)
|
||||||
|
fprintf(stderr, "%s: can\'t set baud rate, using 9600\n", progname);
|
||||||
|
ttybuf.c_cflag |= B9600;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (ttyp >= 0) {
|
||||||
|
#if defined(TCSANOW)
|
||||||
|
if (tcsetattr(ttyp, TCSANOW, &ttybuf) < 0)
|
||||||
|
#else
|
||||||
|
if (ioctl(ttyp, TCSETS, (char *)&ttybuf) < 0)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
fprintf(stderr, "%s: can\'t set baud rate, using 9600\n", progname);
|
fprintf(stderr, "%s: ioctl(wire, TCSETS) failed, errno = %d\n",
|
||||||
ttybuf.c_cflag |= B9600;
|
progname, errno);
|
||||||
}
|
wire_fd = -1;
|
||||||
#endif
|
ttyp = -1;
|
||||||
if (ttyp >= 0)
|
error = 1;
|
||||||
{
|
|
||||||
#if defined(TCSANOW)
|
|
||||||
if (tcsetattr(ttyp, TCSANOW, &ttybuf) < 0)
|
|
||||||
#else
|
|
||||||
if (ioctl(ttyp, TCSETS, (char *)&ttybuf) < 0)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
if (!quiet)
|
|
||||||
fprintf(stderr, "%s: ioctl(wire, TCSETS) failed, errno = %d\n",
|
|
||||||
progname, errno);
|
|
||||||
wire_fd = -1;
|
|
||||||
ttyp = -1;
|
|
||||||
error = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (error)
|
if (error)
|
||||||
update_connection_display();
|
update_connection_display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void transmit_char(void) {
|
void transmit_char(void) {
|
||||||
#ifdef DEBUG_SERIALx
|
#ifdef DEBUG_SERIALx
|
||||||
fprintf(stderr, "XMT %s\n", (saturn.ir_ctrl & 0x04) ? "IR" : "wire");
|
fprintf(stderr, "XMT %s\n", (saturn.ir_ctrl & 0x04) ? "IR" : "wire");
|
||||||
|
|
259
src/small.h
259
src/small.h
|
@ -191,139 +191,138 @@
|
||||||
#include "bitmaps/equal_gx.h"
|
#include "bitmaps/equal_gx.h"
|
||||||
|
|
||||||
typedef struct letter_t {
|
typedef struct letter_t {
|
||||||
unsigned int w, h;
|
unsigned int w, h;
|
||||||
unsigned char *bits;
|
unsigned char *bits;
|
||||||
} letter_t;
|
} letter_t;
|
||||||
|
|
||||||
letter_t small_font[] = {
|
letter_t small_font[] = {
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ nl_gx_width, nl_gx_height, nl_gx_bits }, /* \001 == \n gx */
|
{nl_gx_width, nl_gx_height, nl_gx_bits}, /* \001 == \n gx */
|
||||||
{ comma_gx_width, comma_gx_height, comma_gx_bits }, /* \002 == comma gx */
|
{comma_gx_width, comma_gx_height, comma_gx_bits}, /* \002 == comma gx */
|
||||||
{ arrow_gx_width, arrow_gx_height, arrow_gx_bits }, /* \003 == \-> gx */
|
{arrow_gx_width, arrow_gx_height, arrow_gx_bits}, /* \003 == \-> gx */
|
||||||
{ equal_gx_width, equal_gx_height, equal_gx_bits }, /* \004 == equal gx */
|
{equal_gx_width, equal_gx_height, equal_gx_bits}, /* \004 == equal gx */
|
||||||
{ pi_gx_width, pi_gx_height, pi_gx_bits }, /* \005 == pi gx */
|
{pi_gx_width, pi_gx_height, pi_gx_bits}, /* \005 == pi gx */
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 }, /* # 16 */
|
{0, 0, 0}, /* # 16 */
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ blank_width, blank_height, blank_bits }, /* # 32 */
|
{blank_width, blank_height, blank_bits}, /* # 32 */
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ hash_width, hash_height, hash_bits },
|
{hash_width, hash_height, hash_bits},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ lbrace_width, lbrace_height, lbrace_bits },
|
{lbrace_width, lbrace_height, lbrace_bits},
|
||||||
{ rbrace_width, rbrace_height, rbrace_bits },
|
{rbrace_width, rbrace_height, rbrace_bits},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ comma_width, comma_height, comma_bits },
|
{comma_width, comma_height, comma_bits},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ slash_width, slash_height, slash_bits },
|
{slash_width, slash_height, slash_bits},
|
||||||
{ 0, 0, 0 }, /* # 48 */
|
{0, 0, 0}, /* # 48 */
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ two_width, two_height, two_bits },
|
{two_width, two_height, two_bits},
|
||||||
{ three_width, three_height, three_bits },
|
{three_width, three_height, three_bits},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ small_colon_width, small_colon_height, small_colon_bits },
|
{small_colon_width, small_colon_height, small_colon_bits},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ equal_width, equal_height, equal_bits },
|
{equal_width, equal_height, equal_bits},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 }, /* # 64 */
|
{0, 0, 0}, /* # 64 */
|
||||||
{ A_width, A_height, A_bits },
|
{A_width, A_height, A_bits},
|
||||||
{ B_width, B_height, B_bits },
|
{B_width, B_height, B_bits},
|
||||||
{ C_width, C_height, C_bits },
|
{C_width, C_height, C_bits},
|
||||||
{ D_width, D_height, D_bits },
|
{D_width, D_height, D_bits},
|
||||||
{ E_width, E_height, E_bits },
|
{E_width, E_height, E_bits},
|
||||||
{ F_width, F_height, F_bits },
|
{F_width, F_height, F_bits},
|
||||||
{ G_width, G_height, G_bits },
|
{G_width, G_height, G_bits},
|
||||||
{ H_width, H_height, H_bits },
|
{H_width, H_height, H_bits},
|
||||||
{ I_width, I_height, I_bits },
|
{I_width, I_height, I_bits},
|
||||||
{ J_width, J_height, J_bits },
|
{J_width, J_height, J_bits},
|
||||||
{ K_width, K_height, K_bits },
|
{K_width, K_height, K_bits},
|
||||||
{ L_width, L_height, L_bits },
|
{L_width, L_height, L_bits},
|
||||||
{ M_width, M_height, M_bits },
|
{M_width, M_height, M_bits},
|
||||||
{ N_width, N_height, N_bits },
|
{N_width, N_height, N_bits},
|
||||||
{ O_width, O_height, O_bits },
|
{O_width, O_height, O_bits},
|
||||||
{ P_width, P_height, P_bits }, /* # 80 */
|
{P_width, P_height, P_bits}, /* # 80 */
|
||||||
{ Q_width, Q_height, Q_bits },
|
{Q_width, Q_height, Q_bits},
|
||||||
{ R_width, R_height, R_bits },
|
{R_width, R_height, R_bits},
|
||||||
{ S_width, S_height, S_bits },
|
{S_width, S_height, S_bits},
|
||||||
{ T_width, T_height, T_bits },
|
{T_width, T_height, T_bits},
|
||||||
{ U_width, U_height, U_bits },
|
{U_width, U_height, U_bits},
|
||||||
{ V_width, V_height, V_bits },
|
{V_width, V_height, V_bits},
|
||||||
{ W_width, W_height, W_bits },
|
{W_width, W_height, W_bits},
|
||||||
{ X_width, X_height, X_bits },
|
{X_width, X_height, X_bits},
|
||||||
{ Y_width, Y_height, Y_bits },
|
{Y_width, Y_height, Y_bits},
|
||||||
{ Z_width, Z_height, Z_bits },
|
{Z_width, Z_height, Z_bits},
|
||||||
{ lbracket_width, lbracket_height, lbracket_bits },
|
{lbracket_width, lbracket_height, lbracket_bits},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ rbracket_width, rbracket_height, rbracket_bits },
|
{rbracket_width, rbracket_height, rbracket_bits},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ under_width, under_height, under_bits },
|
{under_width, under_height, under_bits},
|
||||||
{ 0, 0, 0 }, /* # 96 */
|
{0, 0, 0}, /* # 96 */
|
||||||
{ arrow_width, arrow_height, arrow_bits }, /* a == left arrow */
|
{arrow_width, arrow_height, arrow_bits}, /* a == left arrow */
|
||||||
{ diff_width, diff_height, diff_bits }, /* b == differential */
|
{diff_width, diff_height, diff_bits}, /* b == differential */
|
||||||
{ integral_width, integral_height, integral_bits }, /* c == integral */
|
{integral_width, integral_height, integral_bits}, /* c == integral */
|
||||||
{ sigma_width, sigma_height, sigma_bits }, /* d == sigma */
|
{sigma_width, sigma_height, sigma_bits}, /* d == sigma */
|
||||||
{ sqr_width, sqr_height, sqr_bits }, /* e == sqr */
|
{sqr_width, sqr_height, sqr_bits}, /* e == sqr */
|
||||||
{ root_width, root_height, root_bits }, /* f == root */
|
{root_width, root_height, root_bits}, /* f == root */
|
||||||
{ pow10_width, pow10_height, pow10_bits }, /* g == pow10 */
|
{pow10_width, pow10_height, pow10_bits}, /* g == pow10 */
|
||||||
{ exp_width, exp_height, exp_bits }, /* h == exp */
|
{exp_width, exp_height, exp_bits}, /* h == exp */
|
||||||
{ prog_width, prog_height, prog_bits }, /* i == << >> */
|
{prog_width, prog_height, prog_bits}, /* i == << >> */
|
||||||
{ string_width, string_height, string_bits }, /* j == " " */
|
{string_width, string_height, string_bits}, /* j == " " */
|
||||||
{ nl_width, nl_height, nl_bits }, /* k == New Line */
|
{nl_width, nl_height, nl_bits}, /* k == New Line */
|
||||||
{ pi_width, pi_height, pi_bits }, /* l == pi */
|
{pi_width, pi_height, pi_bits}, /* l == pi */
|
||||||
{ angle_width, angle_height, angle_bits }, /* m == angle */
|
{angle_width, angle_height, angle_bits}, /* m == angle */
|
||||||
{ sqr_gx_width, sqr_gx_height, sqr_gx_bits }, /* n == sqr gx */
|
{sqr_gx_width, sqr_gx_height, sqr_gx_bits}, /* n == sqr gx */
|
||||||
{ root_gx_width, root_gx_height, root_gx_bits }, /* o == root gx */
|
{root_gx_width, root_gx_height, root_gx_bits}, /* o == root gx */
|
||||||
{ pow10_gx_width, pow10_gx_height, pow10_gx_bits }, /* p == pow10 gx */
|
{pow10_gx_width, pow10_gx_height, pow10_gx_bits}, /* p == pow10 gx */
|
||||||
{ exp_gx_width, exp_gx_height, exp_gx_bits }, /* q == exp gx */
|
{exp_gx_width, exp_gx_height, exp_gx_bits}, /* q == exp gx */
|
||||||
{ parens_gx_width, parens_gx_height, parens_gx_bits },/* r == ( ) gx */
|
{parens_gx_width, parens_gx_height, parens_gx_bits}, /* r == ( ) gx */
|
||||||
{ hash_gx_width, hash_gx_height, hash_gx_bits }, /* s == # gx */
|
{hash_gx_width, hash_gx_height, hash_gx_bits}, /* s == # gx */
|
||||||
{ bracket_gx_width, bracket_gx_height, bracket_gx_bits }, /* t == [] gx */
|
{bracket_gx_width, bracket_gx_height, bracket_gx_bits}, /* t == [] gx */
|
||||||
{ under_gx_width, under_gx_height, under_gx_bits }, /* u == _ gx */
|
{under_gx_width, under_gx_height, under_gx_bits}, /* u == _ gx */
|
||||||
{ prog_gx_width, prog_gx_height, prog_gx_bits }, /* v == << >> gx */
|
{prog_gx_width, prog_gx_height, prog_gx_bits}, /* v == << >> gx */
|
||||||
{ quote_gx_width, quote_gx_height, quote_gx_bits }, /* w == " " gx */
|
{quote_gx_width, quote_gx_height, quote_gx_bits}, /* w == " " gx */
|
||||||
{ curly_gx_width, curly_gx_height, curly_gx_bits }, /* x == {} gx */
|
{curly_gx_width, curly_gx_height, curly_gx_bits}, /* x == {} gx */
|
||||||
{ colon_gx_width, colon_gx_height, colon_gx_bits }, /* y == :: gx */
|
{colon_gx_width, colon_gx_height, colon_gx_bits}, /* y == :: gx */
|
||||||
{ angle_gx_width, angle_gx_height, angle_gx_bits }, /* z == angle gx */
|
{angle_gx_width, angle_gx_height, angle_gx_bits}, /* z == angle gx */
|
||||||
{ lcurly_width, lcurly_height, lcurly_bits },
|
{lcurly_width, lcurly_height, lcurly_bits},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ rcurly_width, rcurly_height, rcurly_bits },
|
{rcurly_width, rcurly_height, rcurly_bits},
|
||||||
{ 0, 0, 0 },
|
{0, 0, 0},
|
||||||
{ 0, 0, 0 }
|
{0, 0, 0}};
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* !_SMALL_H */
|
#endif /* !_SMALL_H */
|
||||||
|
|
286
src/timer.c
286
src/timer.c
|
@ -40,14 +40,14 @@
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "timer.h"
|
|
||||||
#include "debugger.h"
|
#include "debugger.h"
|
||||||
#include "romio.h"
|
#include "romio.h"
|
||||||
|
#include "timer.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
@ -55,14 +55,14 @@
|
||||||
/* #define DEBUG_TIMER_ADJUST 1 */
|
/* #define DEBUG_TIMER_ADJUST 1 */
|
||||||
|
|
||||||
#ifdef SOLARIS
|
#ifdef SOLARIS
|
||||||
extern int gettimeofday __ProtoType__((struct timeval *tp));
|
extern int gettimeofday __ProtoType__((struct timeval * tp));
|
||||||
#endif
|
#endif
|
||||||
#ifdef SUNOS
|
#ifdef SUNOS
|
||||||
extern int gettimeofday __ProtoType__((struct timeval *, struct timezone *));
|
extern int gettimeofday __ProtoType__((struct timeval *, struct timezone *));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct x48_timer_t {
|
typedef struct x48_timer_t {
|
||||||
word_1 run;
|
word_1 run;
|
||||||
word_64 start;
|
word_64 start;
|
||||||
word_64 stop;
|
word_64 stop;
|
||||||
word_64 value;
|
word_64 value;
|
||||||
|
@ -75,7 +75,7 @@ static long systime_offset = 0;
|
||||||
/*
|
/*
|
||||||
* Ticks for THU 01.01.1970 00:00:00
|
* Ticks for THU 01.01.1970 00:00:00
|
||||||
*/
|
*/
|
||||||
word_64 unix_0_time = 0x1CF2E8F800000L;
|
word_64 unix_0_time = 0x1CF2E8F800000L;
|
||||||
word_64 ticks_10_min = 0x00b40000L;
|
word_64 ticks_10_min = 0x00b40000L;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -88,17 +88,17 @@ word_64 set_0_time = 0x0;
|
||||||
*/
|
*/
|
||||||
word_64 time_offset = 0x0;
|
word_64 time_offset = 0x0;
|
||||||
|
|
||||||
#define RAM_BASE_SX 0x70000
|
#define RAM_BASE_SX 0x70000
|
||||||
#define ACCESSTIME_SX (0x70052 - RAM_BASE_SX)
|
#define ACCESSTIME_SX (0x70052 - RAM_BASE_SX)
|
||||||
#define ACCESSCRC_SX (0x7005F - RAM_BASE_SX)
|
#define ACCESSCRC_SX (0x7005F - RAM_BASE_SX)
|
||||||
#define TIMEOUT_SX (0x70063 - RAM_BASE_SX)
|
#define TIMEOUT_SX (0x70063 - RAM_BASE_SX)
|
||||||
#define TIMEOUTCLK_SX (0x70070 - RAM_BASE_SX)
|
#define TIMEOUTCLK_SX (0x70070 - RAM_BASE_SX)
|
||||||
|
|
||||||
#define RAM_BASE_GX 0x80000
|
#define RAM_BASE_GX 0x80000
|
||||||
#define ACCESSTIME_GX (0x80058 - RAM_BASE_GX)
|
#define ACCESSTIME_GX (0x80058 - RAM_BASE_GX)
|
||||||
#define ACCESSCRC_GX (0x80065 - RAM_BASE_GX)
|
#define ACCESSCRC_GX (0x80065 - RAM_BASE_GX)
|
||||||
#define TIMEOUT_GX (0x80069 - RAM_BASE_GX)
|
#define TIMEOUT_GX (0x80069 - RAM_BASE_GX)
|
||||||
#define TIMEOUTCLK_GX (0x80076 - RAM_BASE_GX)
|
#define TIMEOUTCLK_GX (0x80076 - RAM_BASE_GX)
|
||||||
|
|
||||||
#define calc_crc(nib) (crc = (crc >> 4) ^ (((crc ^ (nib)) & 0xf) * 0x1081))
|
#define calc_crc(nib) (crc = (crc >> 4) ^ (((crc ^ (nib)) & 0xf) * 0x1081))
|
||||||
|
|
||||||
|
@ -116,18 +116,18 @@ word_64 time_offset = 0x0;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void set_accesstime(void) {
|
void set_accesstime(void) {
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
#ifndef SOLARIS
|
#ifndef SOLARIS
|
||||||
struct timezone tz;
|
struct timezone tz;
|
||||||
#endif
|
#endif
|
||||||
word_64 ticks, timeout, timer2;
|
word_64 ticks, timeout, timer2;
|
||||||
word_20 accesstime_loc, timeout_loc;
|
word_20 accesstime_loc, timeout_loc;
|
||||||
word_20 accesscrc_loc, timeoutclk_loc;
|
word_20 accesscrc_loc, timeoutclk_loc;
|
||||||
word_16 crc;
|
word_16 crc;
|
||||||
word_4 val;
|
word_4 val;
|
||||||
int i;
|
int i;
|
||||||
time_t gmt;
|
time_t gmt;
|
||||||
struct tm *ltm;
|
struct tm *ltm;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is done to set the variable 'timezone' on SYSV systems
|
* This is done to set the variable 'timezone' on SYSV systems
|
||||||
|
@ -136,7 +136,7 @@ void set_accesstime(void) {
|
||||||
ltm = localtime(&gmt);
|
ltm = localtime(&gmt);
|
||||||
#if defined(SYSV_TIME) || defined(__sgi)
|
#if defined(SYSV_TIME) || defined(__sgi)
|
||||||
systime_offset = timezone;
|
systime_offset = timezone;
|
||||||
if( ltm->tm_isdst )
|
if (ltm->tm_isdst)
|
||||||
systime_offset -= 3600;
|
systime_offset -= 3600;
|
||||||
#else
|
#else
|
||||||
systime_offset = -ltm->tm_gmtoff;
|
systime_offset = -ltm->tm_gmtoff;
|
||||||
|
@ -157,10 +157,9 @@ void set_accesstime(void) {
|
||||||
ticks += time_offset;
|
ticks += time_offset;
|
||||||
|
|
||||||
timer2 = saturn.timer2;
|
timer2 = saturn.timer2;
|
||||||
if (saturn.timer2 & 0x80000000)
|
if (saturn.timer2 & 0x80000000) {
|
||||||
{
|
assert(timer2 < 0);
|
||||||
assert(timer2 < 0);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ticks += timer2;
|
ticks += timer2;
|
||||||
|
|
||||||
|
@ -168,50 +167,44 @@ void set_accesstime(void) {
|
||||||
|
|
||||||
crc = 0x0;
|
crc = 0x0;
|
||||||
|
|
||||||
if (opt_gx)
|
if (opt_gx) {
|
||||||
{
|
accesstime_loc = ACCESSTIME_GX;
|
||||||
accesstime_loc = ACCESSTIME_GX;
|
accesscrc_loc = ACCESSCRC_GX;
|
||||||
accesscrc_loc = ACCESSCRC_GX;
|
timeout_loc = TIMEOUT_GX;
|
||||||
timeout_loc = TIMEOUT_GX;
|
timeoutclk_loc = TIMEOUTCLK_GX;
|
||||||
timeoutclk_loc = TIMEOUTCLK_GX;
|
} else {
|
||||||
}
|
accesstime_loc = ACCESSTIME_SX;
|
||||||
else
|
accesscrc_loc = ACCESSCRC_SX;
|
||||||
{
|
timeout_loc = TIMEOUT_SX;
|
||||||
accesstime_loc = ACCESSTIME_SX;
|
timeoutclk_loc = TIMEOUTCLK_SX;
|
||||||
accesscrc_loc = ACCESSCRC_SX;
|
}
|
||||||
timeout_loc = TIMEOUT_SX;
|
|
||||||
timeoutclk_loc = TIMEOUTCLK_SX;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < 13; i++)
|
for (i = 0; i < 13; i++) {
|
||||||
{
|
val = ticks & 0xf;
|
||||||
val = ticks & 0xf;
|
calc_crc(val);
|
||||||
calc_crc(val);
|
saturn.ram[accesstime_loc + i] = val;
|
||||||
saturn.ram[accesstime_loc + i] = val;
|
ticks >>= 4;
|
||||||
ticks >>= 4;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++) {
|
||||||
{
|
saturn.ram[accesscrc_loc + i] = crc & 0xf;
|
||||||
saturn.ram[accesscrc_loc + i] = crc & 0xf;
|
crc >>= 4;
|
||||||
crc >>= 4;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
timeout += ticks_10_min;
|
timeout += ticks_10_min;
|
||||||
|
|
||||||
for (i = 0; i < 13; i++)
|
for (i = 0; i < 13; i++) {
|
||||||
{
|
val = timeout & 0xf;
|
||||||
val = timeout & 0xf;
|
calc_crc(val);
|
||||||
calc_crc(val);
|
saturn.ram[timeout_loc + i] = val;
|
||||||
saturn.ram[timeout_loc + i] = val;
|
timeout >>= 4;
|
||||||
timeout >>= 4;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
saturn.ram[timeoutclk_loc] = 0xf;
|
saturn.ram[timeoutclk_loc] = 0xf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void start_timer(int timer) {
|
void start_timer(int timer) {
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
#ifndef SOLARIS
|
#ifndef SOLARIS
|
||||||
struct timezone tz;
|
struct timezone tz;
|
||||||
#endif
|
#endif
|
||||||
|
@ -237,12 +230,13 @@ void start_timer(int timer) {
|
||||||
timers[timer].start += (tv.tv_usec << 7) / 15625;
|
timers[timer].start += (tv.tv_usec << 7) / 15625;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_TIMER
|
#ifdef DEBUG_TIMER
|
||||||
fprintf(stderr, "Timer%c[%d] start at 0x%lx\n", timer == T1_TIMER?'*':' ', timer, timers[timer].start);
|
fprintf(stderr, "Timer%c[%d] start at 0x%lx\n", timer == T1_TIMER ? '*' : ' ',
|
||||||
|
timer, timers[timer].start);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void restart_timer(int timer) {
|
void restart_timer(int timer) {
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
#ifndef SOLARIS
|
#ifndef SOLARIS
|
||||||
struct timezone tz;
|
struct timezone tz;
|
||||||
#endif
|
#endif
|
||||||
|
@ -271,13 +265,12 @@ void restart_timer(int timer) {
|
||||||
timers[timer].start += (tv.tv_usec << 7) / 15625;
|
timers[timer].start += (tv.tv_usec << 7) / 15625;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_TIMER
|
#ifdef DEBUG_TIMER
|
||||||
fprintf(stderr, "Timer[%d] restart at 0x%lx\n", timer,
|
fprintf(stderr, "Timer[%d] restart at 0x%lx\n", timer, timers[timer].start);
|
||||||
timers[timer].start);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void stop_timer(int timer) {
|
void stop_timer(int timer) {
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
#ifndef SOLARIS
|
#ifndef SOLARIS
|
||||||
struct timezone tz;
|
struct timezone tz;
|
||||||
#endif
|
#endif
|
||||||
|
@ -306,11 +299,12 @@ void stop_timer(int timer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
timers[timer].value += timers[timer].stop - timers[timer].start;
|
timers[timer].value += timers[timer].stop - timers[timer].start;
|
||||||
// add_sub_64(&timers[timer].stop, &timers[timer].start, &timers[timer].value);
|
// add_sub_64(&timers[timer].stop, &timers[timer].start,
|
||||||
|
// &timers[timer].value);
|
||||||
|
|
||||||
#ifdef DEBUG_TIMER
|
#ifdef DEBUG_TIMER
|
||||||
fprintf(stderr, "Timer[%d] stop at 0x%llx, value 0x%llx\n",
|
fprintf(stderr, "Timer[%d] stop at 0x%llx, value 0x%llx\n", timer,
|
||||||
timer, timers[timer].stop, timers[timer].value);
|
timers[timer].stop, timers[timer].value);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,11 +323,11 @@ void reset_timer(int timer) {
|
||||||
static word_64 zero = 0;
|
static word_64 zero = 0;
|
||||||
|
|
||||||
word_64 get_timer(int timer) {
|
word_64 get_timer(int timer) {
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
#ifndef SOLARIS
|
#ifndef SOLARIS
|
||||||
struct timezone tz;
|
struct timezone tz;
|
||||||
#endif
|
#endif
|
||||||
word_64 stop;
|
word_64 stop;
|
||||||
|
|
||||||
if (timer > NR_TIMERS)
|
if (timer > NR_TIMERS)
|
||||||
return zero;
|
return zero;
|
||||||
|
@ -373,18 +367,18 @@ word_64 get_timer(int timer) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
t1_t2_ticks get_t1_t2(void) {
|
t1_t2_ticks get_t1_t2(void) {
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
#ifndef SOLARIS
|
#ifndef SOLARIS
|
||||||
struct timezone tz;
|
struct timezone tz;
|
||||||
#endif
|
#endif
|
||||||
word_64 stop;
|
word_64 stop;
|
||||||
t1_t2_ticks ticks;
|
t1_t2_ticks ticks;
|
||||||
word_64 access_time;
|
word_64 access_time;
|
||||||
word_64 adj_time;
|
word_64 adj_time;
|
||||||
word_64 diff_time;
|
word_64 diff_time;
|
||||||
word_64 delta;
|
word_64 delta;
|
||||||
word_20 accesstime_loc;
|
word_20 accesstime_loc;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
#ifdef SOLARIS
|
#ifdef SOLARIS
|
||||||
gettimeofday(&tv);
|
gettimeofday(&tv);
|
||||||
|
@ -393,17 +387,15 @@ t1_t2_ticks get_t1_t2(void) {
|
||||||
#endif
|
#endif
|
||||||
tv.tv_sec -= systime_offset;
|
tv.tv_sec -= systime_offset;
|
||||||
|
|
||||||
if (timers[T1_TIMER].run)
|
if (timers[T1_TIMER].run) {
|
||||||
{
|
stop = (tv.tv_sec << 9);
|
||||||
stop = (tv.tv_sec << 9);
|
stop += (tv.tv_usec / 15625) >> 3;
|
||||||
stop += (tv.tv_usec / 15625) >> 3;
|
if (timers[T1_TIMER].start <= stop) {
|
||||||
if (timers[T1_TIMER].start <= stop)
|
timers[T1_TIMER].value += stop - timers[T1_TIMER].start;
|
||||||
{
|
} else {
|
||||||
timers[T1_TIMER].value += stop - timers[T1_TIMER].start;
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, "clock running backwards\n");
|
fprintf(stderr, "clock running backwards\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ticks.t1_ticks = timers[T1_TIMER].value;
|
ticks.t1_ticks = timers[T1_TIMER].value;
|
||||||
|
|
||||||
stop = tv.tv_sec;
|
stop = tv.tv_sec;
|
||||||
|
@ -416,73 +408,27 @@ t1_t2_ticks get_t1_t2(void) {
|
||||||
|
|
||||||
access_time = 0x0;
|
access_time = 0x0;
|
||||||
|
|
||||||
for (i = 13 - 1; i >= 0; i--)
|
for (i = 13 - 1; i >= 0; i--) {
|
||||||
{
|
access_time <<= 4;
|
||||||
access_time <<= 4;
|
access_time |= ((int)saturn.ram[accesstime_loc + i] & 0xf);
|
||||||
access_time |= ((int)saturn.ram[accesstime_loc + i] & 0xf);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
access_time -= stop;
|
access_time -= stop;
|
||||||
|
|
||||||
if (adj_time_pending || in_debugger)
|
if (adj_time_pending || in_debugger) {
|
||||||
{
|
/*
|
||||||
/*
|
* We have been inside an interrupt for very long, maybe
|
||||||
* We have been inside an interrupt for very long, maybe
|
* or we are sleeping in the debugger.
|
||||||
* or we are sleeping in the debugger.
|
* Don't adjust the time, can't come from user, anyhow.
|
||||||
* Don't adjust the time, can't come from user, anyhow.
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
if ((saturn.timer2 >= 0 && access_time < 0)
|
if ((saturn.timer2 >= 0 && access_time < 0) ||
|
||||||
|| ((unsigned long)saturn.timer2 > access_time))
|
((unsigned long)saturn.timer2 > access_time)) {
|
||||||
{
|
|
||||||
/*
|
|
||||||
* check OK, return calculated time
|
|
||||||
*/
|
|
||||||
ticks.t2_ticks = access_time;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Don't increment timer2, return old value and
|
|
||||||
* slow down timer2.
|
|
||||||
*/
|
|
||||||
ticks.t2_ticks = saturn.timer2;
|
|
||||||
saturn.t2_tick++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ticks;
|
|
||||||
}
|
|
||||||
|
|
||||||
diff_time = saturn.timer2;
|
|
||||||
|
|
||||||
adj_time = access_time - diff_time;
|
|
||||||
delta = abs(adj_time);
|
|
||||||
|
|
||||||
if (delta > 0x3c000) /* Half a minute */
|
|
||||||
{
|
|
||||||
set_0_time += adj_time;
|
|
||||||
time_offset += adj_time;
|
|
||||||
access_time -= adj_time;
|
|
||||||
|
|
||||||
#ifdef DEBUG_TIMER_ADJUST
|
|
||||||
fprintf(stderr, "Time adjusted by ");
|
|
||||||
fprintf(stderr, "%lX", adj_time);
|
|
||||||
fprintf(stderr, " TICKS, Total offset ");
|
|
||||||
fprintf(stderr, "%lX", set_0_time);
|
|
||||||
fprintf(stderr, " TICKS\n");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((saturn.timer2 >= 0 && (access_time < 0))
|
|
||||||
|| ((unsigned long)saturn.timer2 > access_time))
|
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
* check OK, return calculated time
|
* check OK, return calculated time
|
||||||
*/
|
*/
|
||||||
ticks.t2_ticks = access_time;
|
ticks.t2_ticks = access_time;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
* Don't increment timer2, return old value and
|
* Don't increment timer2, return old value and
|
||||||
* slow down timer2.
|
* slow down timer2.
|
||||||
|
@ -491,5 +437,43 @@ t1_t2_ticks get_t1_t2(void) {
|
||||||
saturn.t2_tick++;
|
saturn.t2_tick++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ticks;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff_time = saturn.timer2;
|
||||||
|
|
||||||
|
adj_time = access_time - diff_time;
|
||||||
|
delta = abs(adj_time);
|
||||||
|
|
||||||
|
if (delta > 0x3c000) /* Half a minute */
|
||||||
|
{
|
||||||
|
set_0_time += adj_time;
|
||||||
|
time_offset += adj_time;
|
||||||
|
access_time -= adj_time;
|
||||||
|
|
||||||
|
#ifdef DEBUG_TIMER_ADJUST
|
||||||
|
fprintf(stderr, "Time adjusted by ");
|
||||||
|
fprintf(stderr, "%lX", adj_time);
|
||||||
|
fprintf(stderr, " TICKS, Total offset ");
|
||||||
|
fprintf(stderr, "%lX", set_0_time);
|
||||||
|
fprintf(stderr, " TICKS\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((saturn.timer2 >= 0 && (access_time < 0)) ||
|
||||||
|
((unsigned long)saturn.timer2 > access_time)) {
|
||||||
|
/*
|
||||||
|
* check OK, return calculated time
|
||||||
|
*/
|
||||||
|
ticks.t2_ticks = access_time;
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* Don't increment timer2, return old value and
|
||||||
|
* slow down timer2.
|
||||||
|
*/
|
||||||
|
ticks.t2_ticks = saturn.timer2;
|
||||||
|
saturn.t2_tick++;
|
||||||
|
}
|
||||||
|
|
||||||
return ticks;
|
return ticks;
|
||||||
}
|
}
|
||||||
|
|
26
src/timer.h
26
src/timer.h
|
@ -37,26 +37,26 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "hp48.h"
|
#include "hp48.h"
|
||||||
|
|
||||||
#define NR_TIMERS 4
|
#define NR_TIMERS 4
|
||||||
|
|
||||||
#define T1_TIMER 0
|
#define T1_TIMER 0
|
||||||
#define T2_TIMER 1
|
#define T2_TIMER 1
|
||||||
#define RUN_TIMER 2
|
#define RUN_TIMER 2
|
||||||
#define IDLE_TIMER 3
|
#define IDLE_TIMER 3
|
||||||
|
|
||||||
typedef struct t1_t2_ticks {
|
typedef struct t1_t2_ticks {
|
||||||
unsigned long t1_ticks;
|
unsigned long t1_ticks;
|
||||||
unsigned long t2_ticks;
|
unsigned long t2_ticks;
|
||||||
} t1_t2_ticks;
|
} t1_t2_ticks;
|
||||||
|
|
||||||
extern void reset_timer __ProtoType__((int timer));
|
extern void reset_timer __ProtoType__((int timer));
|
||||||
extern void start_timer __ProtoType__((int timer));
|
extern void start_timer __ProtoType__((int timer));
|
||||||
extern void restart_timer __ProtoType__((int timer));
|
extern void restart_timer __ProtoType__((int timer));
|
||||||
extern void stop_timer __ProtoType__((int timer));
|
extern void stop_timer __ProtoType__((int timer));
|
||||||
extern word_64 get_timer __ProtoType__((int timer));
|
extern word_64 get_timer __ProtoType__((int timer));
|
||||||
extern long diff_timer __ProtoType__((word_64 *t1, word_64 *t2));
|
extern long diff_timer __ProtoType__((word_64 * t1, word_64 *t2));
|
||||||
|
|
||||||
extern t1_t2_ticks get_t1_t2 __ProtoType__((void));
|
extern t1_t2_ticks get_t1_t2 __ProtoType__((void));
|
||||||
extern void set_accesstime __ProtoType__((void));
|
extern void set_accesstime __ProtoType__((void));
|
||||||
|
|
||||||
#endif /* !_TIMER_H */
|
#endif /* !_TIMER_H */
|
||||||
|
|
|
@ -34,10 +34,10 @@
|
||||||
#ifndef _VERSION_H
|
#ifndef _VERSION_H
|
||||||
#define _VERSION_H 1
|
#define _VERSION_H 1
|
||||||
|
|
||||||
extern int VERSION_MAJOR;
|
extern int VERSION_MAJOR;
|
||||||
extern int VERSION_MINOR;
|
extern int VERSION_MINOR;
|
||||||
extern int PATCHLEVEL;
|
extern int PATCHLEVEL;
|
||||||
extern int COMPILE_VERSION;
|
extern int COMPILE_VERSION;
|
||||||
extern char *COMPILE_TIME;
|
extern char *COMPILE_TIME;
|
||||||
extern char *COMPILE_BY;
|
extern char *COMPILE_BY;
|
||||||
|
|
||||||
|
|
4354
src/x48_x11.c
4354
src/x48_x11.c
File diff suppressed because it is too large
Load diff
|
@ -65,31 +65,31 @@
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#ifdef HAVE_XSHM
|
#ifdef HAVE_XSHM
|
||||||
|
#include <X11/extensions/XShm.h>
|
||||||
#include <sys/ipc.h>
|
#include <sys/ipc.h>
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
#include <X11/extensions/XShm.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define WHITE 0
|
#define WHITE 0
|
||||||
#define LEFT 1
|
#define LEFT 1
|
||||||
#define RIGHT 2
|
#define RIGHT 2
|
||||||
#define BUT_TOP 3
|
#define BUT_TOP 3
|
||||||
#define BUTTON 4
|
#define BUTTON 4
|
||||||
#define BUT_BOT 5
|
#define BUT_BOT 5
|
||||||
#define LCD 6
|
#define LCD 6
|
||||||
#define PIXEL 7
|
#define PIXEL 7
|
||||||
#define PAD_TOP 8
|
#define PAD_TOP 8
|
||||||
#define PAD 9
|
#define PAD 9
|
||||||
#define PAD_BOT 10
|
#define PAD_BOT 10
|
||||||
#define DISP_PAD_TOP 11
|
#define DISP_PAD_TOP 11
|
||||||
#define DISP_PAD 12
|
#define DISP_PAD 12
|
||||||
#define DISP_PAD_BOT 13
|
#define DISP_PAD_BOT 13
|
||||||
#define LOGO 14
|
#define LOGO 14
|
||||||
#define LOGO_BACK 15
|
#define LOGO_BACK 15
|
||||||
#define LABEL 16
|
#define LABEL 16
|
||||||
#define FRAME 17
|
#define FRAME 17
|
||||||
#define UNDERLAY 18
|
#define UNDERLAY 18
|
||||||
#define BLACK 19
|
#define BLACK 19
|
||||||
|
|
||||||
typedef struct color_t {
|
typedef struct color_t {
|
||||||
char *name;
|
char *name;
|
||||||
|
@ -101,49 +101,49 @@ typedef struct color_t {
|
||||||
|
|
||||||
extern color_t *colors;
|
extern color_t *colors;
|
||||||
|
|
||||||
#define COLOR(c) (colors[(c)].xcolor.pixel)
|
#define COLOR(c) (colors[(c)].xcolor.pixel)
|
||||||
|
|
||||||
#define UPDATE_MENU 1
|
#define UPDATE_MENU 1
|
||||||
#define UPDATE_DISP 2
|
#define UPDATE_DISP 2
|
||||||
|
|
||||||
typedef struct disp_t {
|
typedef struct disp_t {
|
||||||
unsigned int w, h;
|
unsigned int w, h;
|
||||||
Window win;
|
Window win;
|
||||||
GC gc;
|
GC gc;
|
||||||
short mapped;
|
short mapped;
|
||||||
int offset;
|
int offset;
|
||||||
int lines;
|
int lines;
|
||||||
#ifdef HAVE_XSHM
|
#ifdef HAVE_XSHM
|
||||||
int display_update;
|
int display_update;
|
||||||
XShmSegmentInfo disp_info;
|
XShmSegmentInfo disp_info;
|
||||||
XImage *disp_image;
|
XImage *disp_image;
|
||||||
XShmSegmentInfo menu_info;
|
XShmSegmentInfo menu_info;
|
||||||
XImage *menu_image;
|
XImage *menu_image;
|
||||||
#endif
|
#endif
|
||||||
} disp_t;
|
} disp_t;
|
||||||
|
|
||||||
extern disp_t disp;
|
extern disp_t disp;
|
||||||
|
|
||||||
#ifdef HAVE_XSHM
|
#ifdef HAVE_XSHM
|
||||||
extern int shm_flag;
|
extern int shm_flag;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern Display *dpy;
|
extern Display *dpy;
|
||||||
extern int screen;
|
extern int screen;
|
||||||
|
|
||||||
extern int InitDisplay __ProtoType__((int argc, char **argv));
|
extern int InitDisplay __ProtoType__((int argc, char **argv));
|
||||||
extern int CreateWindows __ProtoType__((int argc, char **argv));
|
extern int CreateWindows __ProtoType__((int argc, char **argv));
|
||||||
extern int GetEvent __ProtoType__((void));
|
extern int GetEvent __ProtoType__((void));
|
||||||
|
|
||||||
extern void adjust_contrast __ProtoType__((int contrast));
|
extern void adjust_contrast __ProtoType__((int contrast));
|
||||||
extern void refresh_icon __ProtoType__((void));
|
extern void refresh_icon __ProtoType__((void));
|
||||||
|
|
||||||
extern void ShowConnections __ProtoType__((char *w, char *i));
|
extern void ShowConnections __ProtoType__((char *w, char *i));
|
||||||
|
|
||||||
extern void exit_x48 __ProtoType__((int tell_x11));
|
extern void exit_x48 __ProtoType__((int tell_x11));
|
||||||
|
|
||||||
#ifdef HAVE_XSHM
|
#ifdef HAVE_XSHM
|
||||||
extern void refresh_display __ProtoType__((void));
|
extern void refresh_display __ProtoType__((void));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* !_X48_X11_H */
|
#endif /* !_X48_X11_H */
|
||||||
|
|
Loading…
Reference in a new issue