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
179
src/actions.c
179
src/actions.c
|
@ -83,13 +83,13 @@
|
|||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "debugger.h"
|
||||
#include "device.h"
|
||||
#include "hp48.h"
|
||||
#include "hp48_emu.h"
|
||||
#include "device.h"
|
||||
#include "x48_x11.h"
|
||||
#include "timer.h"
|
||||
#include "debugger.h"
|
||||
#include "romio.h"
|
||||
#include "timer.h"
|
||||
#include "x48_x11.h"
|
||||
|
||||
static int interrupt_called = 0;
|
||||
extern long nibble_masks[16];
|
||||
|
@ -121,17 +121,11 @@ void do_in(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void clear_program_stat(int n) {
|
||||
saturn.PSTAT[n] = 0;
|
||||
}
|
||||
void clear_program_stat(int n) { saturn.PSTAT[n] = 0; }
|
||||
|
||||
void set_program_stat(int n) {
|
||||
saturn.PSTAT[n] = 1;
|
||||
}
|
||||
void set_program_stat(int n) { saturn.PSTAT[n] = 1; }
|
||||
|
||||
int get_program_stat(int n) {
|
||||
return saturn.PSTAT[n];
|
||||
}
|
||||
int get_program_stat(int n) { return saturn.PSTAT[n]; }
|
||||
|
||||
void register_to_status(unsigned char *r) {
|
||||
int i;
|
||||
|
@ -179,9 +173,7 @@ void set_register_nibble(unsigned char *reg, int n, unsigned char val) {
|
|||
reg[n] = val;
|
||||
}
|
||||
|
||||
unsigned char get_register_nibble(unsigned char *reg, int n) {
|
||||
return reg[n];
|
||||
}
|
||||
unsigned char get_register_nibble(unsigned char *reg, int n) { return reg[n]; }
|
||||
|
||||
void set_register_bit(unsigned char *reg, int n) {
|
||||
reg[n / 4] |= (1 << (n % 4));
|
||||
|
@ -201,8 +193,7 @@ short conf_tab_gx[] = { 1, 2, 2, 2, 2, 0 };
|
|||
void do_reset(void) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
for (i = 0; i < 6; i++) {
|
||||
if (opt_gx)
|
||||
saturn.mem_cntl[i].unconfigured = conf_tab_gx[i];
|
||||
else
|
||||
|
@ -213,30 +204,24 @@ void do_reset(void) {
|
|||
|
||||
#ifdef DEBUG_CONFIG
|
||||
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)
|
||||
fprintf(stderr, "MEMORY CONTROLLER %d is unconfigured\n", i);
|
||||
else
|
||||
fprintf(stderr, "MEMORY CONTROLLER %d is configured to %.5lx, %.5lx\n",
|
||||
i, saturn.mem_cntl[i].config[0], saturn.mem_cntl[i].config[1]);
|
||||
fprintf(stderr, "MEMORY CONTROLLER %d is configured to %.5lx, %.5lx\n", i,
|
||||
saturn.mem_cntl[i].config[0], saturn.mem_cntl[i].config[1]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void do_inton(void) {
|
||||
saturn.kbd_ien = 1;
|
||||
}
|
||||
void do_inton(void) { saturn.kbd_ien = 1; }
|
||||
|
||||
void do_intoff(void) {
|
||||
saturn.kbd_ien = 0;
|
||||
}
|
||||
void do_intoff(void) { saturn.kbd_ien = 0; }
|
||||
|
||||
void do_return_interupt(void) {
|
||||
if (saturn.int_pending) {
|
||||
#ifdef DEBUG_INTERRUPT
|
||||
fprintf(stderr, "PC = %.5lx: RTI SERVICE PENDING INTERRUPT\n",
|
||||
saturn.PC);
|
||||
fprintf(stderr, "PC = %.5lx: RTI SERVICE PENDING INTERRUPT\n", saturn.PC);
|
||||
#endif
|
||||
saturn.int_pending = 0;
|
||||
saturn.intenable = 0;
|
||||
|
@ -255,7 +240,6 @@ void do_return_interupt(void) {
|
|||
schedule_event = 0;
|
||||
sched_adjtime = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -314,10 +298,8 @@ void do_unconfigure(void) {
|
|||
conf |= saturn.C[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
if (saturn.mem_cntl[i].config[0] == conf)
|
||||
{
|
||||
for (i = 0; i < 6; i++) {
|
||||
if (saturn.mem_cntl[i].config[0] == conf) {
|
||||
if (opt_gx)
|
||||
saturn.mem_cntl[i].unconfigured = conf_tab_gx[i];
|
||||
else
|
||||
|
@ -330,13 +312,12 @@ void do_unconfigure(void) {
|
|||
|
||||
#ifdef DEBUG_CONFIG
|
||||
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)
|
||||
fprintf(stderr, "MEMORY CONTROLLER %d is unconfigured\n", i);
|
||||
else
|
||||
fprintf(stderr, "MEMORY CONTROLLER %d is configured to %.5lx, %.5lx\n",
|
||||
i, saturn.mem_cntl[i].config[0], saturn.mem_cntl[i].config[1]);
|
||||
fprintf(stderr, "MEMORY CONTROLLER %d is configured to %.5lx, %.5lx\n", i,
|
||||
saturn.mem_cntl[i].config[0], saturn.mem_cntl[i].config[1]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -351,10 +332,8 @@ void do_configure(void) {
|
|||
conf |= saturn.C[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
if (saturn.mem_cntl[i].unconfigured)
|
||||
{
|
||||
for (i = 0; i < 6; i++) {
|
||||
if (saturn.mem_cntl[i].unconfigured) {
|
||||
saturn.mem_cntl[i].unconfigured--;
|
||||
saturn.mem_cntl[i].config[saturn.mem_cntl[i].unconfigured] = conf;
|
||||
break;
|
||||
|
@ -363,25 +342,22 @@ void do_configure(void) {
|
|||
|
||||
#ifdef DEBUG_CONFIG
|
||||
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)
|
||||
fprintf(stderr, "MEMORY CONTROLLER %d is unconfigured\n", i);
|
||||
else
|
||||
fprintf(stderr, "MEMORY CONTROLLER %d at %.5lx, %.5lx\n",
|
||||
i, saturn.mem_cntl[i].config[0], saturn.mem_cntl[i].config[1]);
|
||||
fprintf(stderr, "MEMORY CONTROLLER %d at %.5lx, %.5lx\n", i,
|
||||
saturn.mem_cntl[i].config[0], saturn.mem_cntl[i].config[1]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int get_identification(void) {
|
||||
int i;
|
||||
static int chip_id[]
|
||||
= { 0, 0, 0, 0, 0x05, 0xf6, 0x07, 0xf8, 0x01, 0xf2, 0, 0 };
|
||||
static int chip_id[] = {0, 0, 0, 0, 0x05, 0xf6, 0x07, 0xf8, 0x01, 0xf2, 0, 0};
|
||||
int id;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
for (i = 0; i < 6; i++) {
|
||||
if (saturn.mem_cntl[i].unconfigured)
|
||||
break;
|
||||
}
|
||||
|
@ -392,26 +368,22 @@ int get_identification(void) {
|
|||
|
||||
#ifdef DEBUG_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)
|
||||
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);
|
||||
else
|
||||
fprintf(stderr, "MEMORY CONTROLLER %d configured to ????? %.5lx\n",
|
||||
i, 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]);
|
||||
fprintf(stderr, "MEMORY CONTROLLER %d configured to ????? %.5lx\n", i,
|
||||
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
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
for (i = 0; i < 3; i++) {
|
||||
saturn.C[i] = id & 0x0f;
|
||||
id >>= 4;
|
||||
}
|
||||
|
@ -426,7 +398,8 @@ void do_shutdown(void) {
|
|||
device.display_touched = 0;
|
||||
update_display();
|
||||
#ifdef HAVE_XSHM
|
||||
if (disp.display_update) refresh_display();
|
||||
if (disp.display_update)
|
||||
refresh_display();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -463,7 +436,8 @@ void do_shutdown(void) {
|
|||
got_alarm = 0;
|
||||
|
||||
#ifdef HAVE_XSHM
|
||||
if (disp.display_update) refresh_display();
|
||||
if (disp.display_update)
|
||||
refresh_display();
|
||||
#endif
|
||||
|
||||
ticks = get_t1_t2();
|
||||
|
@ -479,29 +453,23 @@ void do_shutdown(void) {
|
|||
wake = 1;
|
||||
}
|
||||
|
||||
if (saturn.timer2 <= 0)
|
||||
{
|
||||
if (saturn.t2_ctrl & 0x04)
|
||||
{
|
||||
if (saturn.timer2 <= 0) {
|
||||
if (saturn.t2_ctrl & 0x04) {
|
||||
wake = 1;
|
||||
}
|
||||
if (saturn.t2_ctrl & 0x02)
|
||||
{
|
||||
if (saturn.t2_ctrl & 0x02) {
|
||||
wake = 1;
|
||||
saturn.t2_ctrl |= 0x08;
|
||||
do_interupt();
|
||||
}
|
||||
}
|
||||
|
||||
if (saturn.timer1 <= 0)
|
||||
{
|
||||
if (saturn.timer1 <= 0) {
|
||||
saturn.timer1 &= 0x0f;
|
||||
if (saturn.t1_ctrl & 0x04)
|
||||
{
|
||||
if (saturn.t1_ctrl & 0x04) {
|
||||
wake = 1;
|
||||
}
|
||||
if (saturn.t1_ctrl & 0x03)
|
||||
{
|
||||
if (saturn.t1_ctrl & 0x03) {
|
||||
wake = 1;
|
||||
saturn.t1_ctrl |= 0x08;
|
||||
do_interupt();
|
||||
|
@ -518,8 +486,7 @@ void do_shutdown(void) {
|
|||
alarms++;
|
||||
}
|
||||
|
||||
if (enter_debugger)
|
||||
{
|
||||
if (enter_debugger) {
|
||||
wake = 1;
|
||||
}
|
||||
} while (wake == 0);
|
||||
|
@ -529,24 +496,40 @@ void do_shutdown(void) {
|
|||
}
|
||||
|
||||
void set_hardware_stat(int op) {
|
||||
if (op & 1) saturn.XM = 1;
|
||||
if (op & 2) saturn.SB = 1;
|
||||
if (op & 4) saturn.SR = 1;
|
||||
if (op & 8) saturn.MP = 1;
|
||||
if (op & 1)
|
||||
saturn.XM = 1;
|
||||
if (op & 2)
|
||||
saturn.SB = 1;
|
||||
if (op & 4)
|
||||
saturn.SR = 1;
|
||||
if (op & 8)
|
||||
saturn.MP = 1;
|
||||
}
|
||||
|
||||
void clear_hardware_stat(int op) {
|
||||
if (op & 1) saturn.XM = 0;
|
||||
if (op & 2) saturn.SB = 0;
|
||||
if (op & 4) saturn.SR = 0;
|
||||
if (op & 8) saturn.MP = 0;
|
||||
if (op & 1)
|
||||
saturn.XM = 0;
|
||||
if (op & 2)
|
||||
saturn.SB = 0;
|
||||
if (op & 4)
|
||||
saturn.SR = 0;
|
||||
if (op & 8)
|
||||
saturn.MP = 0;
|
||||
}
|
||||
|
||||
int is_zero_hardware_stat(int op) {
|
||||
if (op & 1) if (saturn.XM != 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;
|
||||
if (op & 1)
|
||||
if (saturn.XM != 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;
|
||||
}
|
||||
|
||||
|
@ -698,17 +681,11 @@ void add_address(word_20 *dat, int add) {
|
|||
*dat &= 0xfffff;
|
||||
}
|
||||
|
||||
static int start_fields[] = {
|
||||
-1, 0, 2, 0, 15, 3, 0, 0,
|
||||
-1, 0, 2, 0, 15, 3, 0, 0,
|
||||
0, 0, 0
|
||||
};
|
||||
static int start_fields[] = {-1, 0, 2, 0, 15, 3, 0, 0, -1, 0,
|
||||
2, 0, 15, 3, 0, 0, 0, 0, 0};
|
||||
|
||||
static int end_fields[] = {
|
||||
-1, -1, 2, 2, 15, 14, 1, 15,
|
||||
-1, -1, 2, 2, 15, 14, 1, 4,
|
||||
3, 2, 0
|
||||
};
|
||||
static int end_fields[] = {-1, -1, 2, 2, 15, 14, 1, 15, -1, -1,
|
||||
2, 2, 15, 14, 1, 4, 3, 2, 0};
|
||||
|
||||
static inline int get_start(int code) {
|
||||
int s;
|
||||
|
|
|
@ -39,8 +39,8 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "romio.h"
|
||||
|
@ -64,8 +64,7 @@ int main(int argc, char **argv) {
|
|||
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]);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -82,7 +81,6 @@ int main(int argc, char **argv) {
|
|||
version[6] = '\0';
|
||||
printf("ROM Version is %s\n", version);
|
||||
|
||||
|
||||
for (i = 0x100; i < 0x140; i++) {
|
||||
rom[i] = 0x0;
|
||||
}
|
||||
|
|
|
@ -45,4 +45,3 @@
|
|||
#define COLOR_MODE_COLOR 3
|
||||
|
||||
#endif /* !_CONSTANTS_H */
|
||||
|
||||
|
|
950
src/debugger.c
950
src/debugger.c
File diff suppressed because it is too large
Load diff
|
@ -53,9 +53,9 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "device.h"
|
||||
#include "hp48.h"
|
||||
#include "hp48_emu.h"
|
||||
#include "device.h"
|
||||
#include "timer.h"
|
||||
#include "x48_x11.h"
|
||||
|
||||
|
@ -175,10 +175,10 @@ void check_devices(void) {
|
|||
|
||||
#if 0
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
void check_out_register(void) {
|
||||
static int au = -2;
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#define _DEVICE_H 1
|
||||
|
||||
#include "global.h"
|
||||
#include "hp48.h"
|
||||
|
||||
#define DISP_INSTR_OFF 0x10
|
||||
|
||||
|
|
763
src/disasm.c
763
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 $
|
||||
*/
|
||||
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#ifdef SUNOS
|
||||
#include <memory.h>
|
||||
#endif
|
||||
|
@ -67,36 +66,28 @@ int write_mem_file(char *name, unsigned char *mem, int size) {
|
|||
unsigned char byte;
|
||||
int i, j;
|
||||
|
||||
if (NULL == (fp = fopen(name, "w")))
|
||||
{
|
||||
if (NULL == (fp = fopen(name, "w"))) {
|
||||
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++)
|
||||
{
|
||||
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))
|
||||
{
|
||||
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++)
|
||||
{
|
||||
} 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)
|
||||
{
|
||||
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);
|
||||
|
@ -160,8 +151,8 @@ int main(int argc, char **argv) {
|
|||
break;
|
||||
}
|
||||
if (ch != ':') {
|
||||
fprintf(stderr, "%s: Illegal char %c, expected \':\' at %lx\n",
|
||||
argv[0], ch, addr);
|
||||
fprintf(stderr, "%s: Illegal char %c, expected \':\' at %lx\n", argv[0],
|
||||
ch, addr);
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < 16; i++) {
|
||||
|
@ -185,8 +176,8 @@ int main(int argc, char **argv) {
|
|||
if ((ch = fgetc(dump)) < 0)
|
||||
break;
|
||||
if (ch != '\n') {
|
||||
fprintf(stderr, "%s: Illegal char %c, expected \'\\n\' at %lx\n",
|
||||
argv[0], ch, addr);
|
||||
fprintf(stderr, "%s: Illegal char %c, expected \'\\n\' at %lx\n", argv[0],
|
||||
ch, addr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -198,8 +189,7 @@ int main(int argc, char **argv) {
|
|||
size = 0x100000;
|
||||
else
|
||||
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);
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
@ -43,17 +43,16 @@
|
|||
* $Id: emulate.c,v 1.16 1995/01/11 18:20:01 ecd Exp ecd $
|
||||
*/
|
||||
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "debugger.h"
|
||||
#include "device.h"
|
||||
#include "hp48.h"
|
||||
#include "hp48_emu.h"
|
||||
#include "device.h"
|
||||
#include "timer.h"
|
||||
#include "x48_x11.h"
|
||||
#include "debugger.h"
|
||||
|
||||
extern int throttle;
|
||||
|
||||
|
@ -109,10 +108,8 @@ unsigned long delta_t_16;
|
|||
unsigned long delta_i;
|
||||
word_64 run;
|
||||
|
||||
static word_20 jumpmasks[] = {
|
||||
0xffffffff, 0xfffffff0, 0xffffff00, 0xfffff000,
|
||||
0xffff0000, 0xfff00000, 0xff000000, 0xf0000000
|
||||
};
|
||||
static word_20 jumpmasks[] = {0xffffffff, 0xfffffff0, 0xffffff00, 0xfffff000,
|
||||
0xffff0000, 0xfff00000, 0xff000000, 0xf0000000};
|
||||
|
||||
int decode_group_80(void) {
|
||||
int t, op3, op4, op5, op6;
|
||||
|
@ -1186,16 +1183,20 @@ static inline int decode_8_thru_f(int op1) {
|
|||
saturn.CARRY = is_less_register(saturn.D, saturn.C, A_FIELD);
|
||||
break;
|
||||
case 8: /* ?A>=B */
|
||||
saturn.CARRY = is_greater_or_equal_register(saturn.A, saturn.B, A_FIELD);
|
||||
saturn.CARRY =
|
||||
is_greater_or_equal_register(saturn.A, saturn.B, A_FIELD);
|
||||
break;
|
||||
case 9: /* ?B>=C */
|
||||
saturn.CARRY = is_greater_or_equal_register(saturn.B, saturn.C, A_FIELD);
|
||||
saturn.CARRY =
|
||||
is_greater_or_equal_register(saturn.B, saturn.C, A_FIELD);
|
||||
break;
|
||||
case 0xa: /* ?C>=A */
|
||||
saturn.CARRY = is_greater_or_equal_register(saturn.C, saturn.A, A_FIELD);
|
||||
saturn.CARRY =
|
||||
is_greater_or_equal_register(saturn.C, saturn.A, A_FIELD);
|
||||
break;
|
||||
case 0xb: /* ?D>=C */
|
||||
saturn.CARRY = is_greater_or_equal_register(saturn.D, saturn.C, A_FIELD);
|
||||
saturn.CARRY =
|
||||
is_greater_or_equal_register(saturn.D, saturn.C, A_FIELD);
|
||||
break;
|
||||
case 0xc: /* ?A<=B */
|
||||
saturn.CARRY = is_less_or_equal_register(saturn.A, saturn.B, A_FIELD);
|
||||
|
@ -2220,15 +2221,17 @@ inline void schedule(void) {
|
|||
schedule_event = sched_timer2;
|
||||
|
||||
#ifdef DEBUG_SCHED
|
||||
fprintf(stderr, "next timer 2 step: %ld, event: %ld\n",
|
||||
sched_timer2, schedule_event);
|
||||
fprintf(stderr, "next timer 2 step: %ld, event: %ld\n", sched_timer2,
|
||||
schedule_event);
|
||||
#endif
|
||||
|
||||
if (device_check) {
|
||||
device_check = 0;
|
||||
if ((sched_display -= steps) <= 0) {
|
||||
if (device.display_touched) device.display_touched -= steps;
|
||||
if (device.display_touched < 0) device.display_touched = 1;
|
||||
if (device.display_touched)
|
||||
device.display_touched -= steps;
|
||||
if (device.display_touched < 0)
|
||||
device.display_touched = 1;
|
||||
#ifdef DEBUG_DISP_SCHED
|
||||
fprintf(stderr, "check_device: disp_when %d, disp_touched %d\n",
|
||||
sched_display, device.display_touched);
|
||||
|
@ -2239,7 +2242,8 @@ inline void schedule(void) {
|
|||
if (device.display_touched) {
|
||||
if (device.display_touched < sched_display)
|
||||
sched_display = device.display_touched - 1;
|
||||
if (sched_display < schedule_event) schedule_event = sched_display;
|
||||
if (sched_display < schedule_event)
|
||||
schedule_event = sched_display;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2249,11 +2253,12 @@ inline void schedule(void) {
|
|||
receive_char();
|
||||
}
|
||||
}
|
||||
if (sched_receive < schedule_event) schedule_event = sched_receive;
|
||||
if (sched_receive < schedule_event)
|
||||
schedule_event = sched_receive;
|
||||
|
||||
#ifdef DEBUG_SCHED
|
||||
fprintf(stderr, "next receive: %ld, event: %ld\n",
|
||||
sched_receive, schedule_event);
|
||||
fprintf(stderr, "next receive: %ld, event: %ld\n", sched_receive,
|
||||
schedule_event);
|
||||
#endif
|
||||
|
||||
if ((sched_adjtime -= steps) <= 0) {
|
||||
|
@ -2288,14 +2293,14 @@ inline void schedule(void) {
|
|||
} else {
|
||||
|
||||
adj_time_pending = 1;
|
||||
|
||||
}
|
||||
}
|
||||
if (sched_adjtime < schedule_event) schedule_event = sched_adjtime;
|
||||
if (sched_adjtime < schedule_event)
|
||||
schedule_event = sched_adjtime;
|
||||
|
||||
#ifdef DEBUG_SCHED
|
||||
fprintf(stderr, "next adjtime: %ld, event: %ld\n",
|
||||
sched_adjtime, schedule_event);
|
||||
fprintf(stderr, "next adjtime: %ld, event: %ld\n", sched_adjtime,
|
||||
schedule_event);
|
||||
#endif
|
||||
|
||||
if ((sched_timer1 -= steps) <= 0) {
|
||||
|
@ -2311,11 +2316,12 @@ inline void schedule(void) {
|
|||
do_interupt();
|
||||
}
|
||||
}
|
||||
if (sched_timer1 < schedule_event) schedule_event = sched_timer1;
|
||||
if (sched_timer1 < schedule_event)
|
||||
schedule_event = sched_timer1;
|
||||
|
||||
#ifdef DEBUG_SCHED
|
||||
fprintf(stderr, "next timer 1 step: %ld, event: %ld\n",
|
||||
sched_timer1, schedule_event);
|
||||
fprintf(stderr, "next timer 1 step: %ld, event: %ld\n", sched_timer1,
|
||||
schedule_event);
|
||||
#endif
|
||||
|
||||
if ((sched_statistics -= steps) <= 0) {
|
||||
|
@ -2332,11 +2338,13 @@ inline void schedule(void) {
|
|||
delta_i = instructions - old_stat_instr;
|
||||
old_stat_instr = instructions;
|
||||
if (delta_t_1 > 0) {
|
||||
t1_i_per_tick = ((NR_SAMPLES - 1) * t1_i_per_tick +
|
||||
(delta_i / delta_t_16)) / NR_SAMPLES;
|
||||
t1_i_per_tick =
|
||||
((NR_SAMPLES - 1) * t1_i_per_tick + (delta_i / delta_t_16)) /
|
||||
NR_SAMPLES;
|
||||
t2_i_per_tick = t1_i_per_tick / 512;
|
||||
saturn.i_per_s = ((NR_SAMPLES - 1) * saturn.i_per_s +
|
||||
(delta_i / delta_t_1)) / NR_SAMPLES;
|
||||
saturn.i_per_s =
|
||||
((NR_SAMPLES - 1) * saturn.i_per_s + (delta_i / delta_t_1)) /
|
||||
NR_SAMPLES;
|
||||
} else {
|
||||
t1_i_per_tick = 8192;
|
||||
t2_i_per_tick = 16;
|
||||
|
@ -2361,8 +2369,8 @@ inline void schedule(void) {
|
|||
schedule_event = sched_statistics;
|
||||
|
||||
#ifdef DEBUG_SCHED
|
||||
fprintf(stderr, "next statistics: %ld, event: %ld\n",
|
||||
sched_statistics, schedule_event);
|
||||
fprintf(stderr, "next statistics: %ld, event: %ld\n", sched_statistics,
|
||||
schedule_event);
|
||||
#endif
|
||||
|
||||
if ((sched_instr_rollover -= steps) <= 0) {
|
||||
|
@ -2386,7 +2394,8 @@ inline void schedule(void) {
|
|||
if (got_alarm) {
|
||||
got_alarm = 0;
|
||||
#ifdef HAVE_XSHM
|
||||
if (disp.display_update) refresh_display();
|
||||
if (disp.display_update)
|
||||
refresh_display();
|
||||
#endif
|
||||
GetEvent();
|
||||
}
|
||||
|
@ -2427,7 +2436,8 @@ int emulate(void) {
|
|||
#else
|
||||
gettimeofday(&tv, &tz);
|
||||
#endif
|
||||
while ((tv.tv_sec == tv2.tv_sec) && ((tv.tv_usec - tv2.tv_usec) < 2)) {
|
||||
while ((tv.tv_sec == tv2.tv_sec) &&
|
||||
((tv.tv_usec - tv2.tv_usec) < 2)) {
|
||||
gettimeofday(&tv, &tz);
|
||||
}
|
||||
|
||||
|
@ -2444,8 +2454,7 @@ int emulate(void) {
|
|||
// puts("bug");
|
||||
// schedule_event = 0;
|
||||
}
|
||||
if (schedule_event-- <= 0)
|
||||
{
|
||||
if (schedule_event-- <= 0) {
|
||||
schedule();
|
||||
}
|
||||
} while (!enter_debugger);
|
||||
|
|
11
src/errors.c
11
src/errors.c
|
@ -31,15 +31,18 @@
|
|||
#include "global.h"
|
||||
#include "resources.h"
|
||||
|
||||
char errbuf[1024] = { 0, };
|
||||
char fixbuf[1024] = { 0, };
|
||||
char errbuf[1024] = {
|
||||
0,
|
||||
};
|
||||
char fixbuf[1024] = {
|
||||
0,
|
||||
};
|
||||
|
||||
void fatal_exit(void) {
|
||||
if (quiet)
|
||||
exit(1);
|
||||
|
||||
if (errbuf[0] == '\0')
|
||||
{
|
||||
if (errbuf[0] == '\0') {
|
||||
fprintf(stderr, "%s: FATAL ERROR, exit.\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
@ -123,8 +123,8 @@ extern void fclose __ProtoType__((FILE *));
|
|||
extern int fgetc __ProtoType__((FILE *));
|
||||
extern void bzero __ProtoType__((void *, int));
|
||||
extern time_t time __ProtoType__((time_t *));
|
||||
extern int select __ProtoType__((int, fd_set *, fd_set *,
|
||||
fd_set *, struct timeval *));
|
||||
extern int select __ProtoType__((int, fd_set *, fd_set *, fd_set *,
|
||||
struct timeval *));
|
||||
extern int setitimer __ProtoType__((int, struct itimerval *,
|
||||
struct itimerval *));
|
||||
extern int gethostname __ProtoType__((char *, int));
|
||||
|
|
|
@ -288,6 +288,5 @@ extern int read_rom __ProtoType__((const char *fname));
|
|||
extern int read_files __ProtoType__((void));
|
||||
extern int write_files __ProtoType__((void));
|
||||
|
||||
extern void load_addr __ProtoType__((word_20 *dat, long addr,
|
||||
int n));
|
||||
extern void load_addr __ProtoType__((word_20 * dat, long addr, int n));
|
||||
#endif /* !_HP48_H */
|
||||
|
|
|
@ -100,29 +100,23 @@ extern int get_register_bit __ProtoType__((unsigned char *reg, int n));
|
|||
|
||||
extern void set_register_nibble __ProtoType__((unsigned char *reg, int n,
|
||||
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 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 char *make_hexstr __ProtoType__((long addr, int n));
|
||||
extern void load_constant __ProtoType__((unsigned char *reg, int n,
|
||||
long addr));
|
||||
extern void load_address __ProtoType__((unsigned char *reg, long addr,
|
||||
int n));
|
||||
extern void load_constant __ProtoType__((unsigned char *reg, int n, long addr));
|
||||
extern void load_address __ProtoType__((unsigned char *reg, long addr, int n));
|
||||
|
||||
extern void store __ProtoType__((word_20 dat, unsigned char *reg,
|
||||
int code));
|
||||
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 void store __ProtoType__((word_20 dat, unsigned char *reg, int code));
|
||||
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 addr_to_dat __ProtoType__((long addr, unsigned char *dat));
|
||||
|
@ -139,10 +133,10 @@ extern void do_shutdown __ProtoType__((void));
|
|||
extern int get_identification __ProtoType__((void));
|
||||
|
||||
extern void add_p_plus_one __ProtoType__((unsigned char *r));
|
||||
extern void add_register_constant __ProtoType__((unsigned char *res,
|
||||
int code, int val));
|
||||
extern void sub_register_constant __ProtoType__((unsigned char *res,
|
||||
int code, int val));
|
||||
extern void add_register_constant __ProtoType__((unsigned char *res, 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,
|
||||
|
@ -158,44 +152,34 @@ 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_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 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, 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_circ_register __ProtoType__((unsigned char *r, int code));
|
||||
extern void shift_right_bit_register __ProtoType__((unsigned char *r, int code));
|
||||
extern int is_zero_register __ProtoType__((
|
||||
unsigned char *r,
|
||||
extern void shift_right_circ_register __ProtoType__((unsigned char *r,
|
||||
int code));
|
||||
extern int is_not_zero_register __ProtoType__((
|
||||
unsigned char *r,
|
||||
extern void shift_right_bit_register __ProtoType__((unsigned char *r,
|
||||
int code));
|
||||
extern int is_equal_register __ProtoType__((
|
||||
unsigned char *r1,
|
||||
extern int is_zero_register __ProtoType__((unsigned char *r, int code));
|
||||
extern int is_not_zero_register __ProtoType__((unsigned char *r, int code));
|
||||
extern int is_equal_register __ProtoType__((unsigned char *r1,
|
||||
unsigned char *r2, int code));
|
||||
extern int is_not_equal_register __ProtoType__((unsigned char *r1,
|
||||
unsigned char *r2, int code));
|
||||
extern int is_less_register __ProtoType__((unsigned char *r1, unsigned char *r2,
|
||||
int code));
|
||||
extern int is_less_or_equal_register __ProtoType__((unsigned char *r1,
|
||||
unsigned char *r2,
|
||||
int code));
|
||||
extern int is_not_equal_register __ProtoType__((
|
||||
unsigned char *r1,
|
||||
unsigned char *r2,
|
||||
int code));
|
||||
extern int is_less_register __ProtoType__((
|
||||
unsigned char *r1,
|
||||
unsigned char *r2,
|
||||
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,
|
||||
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));
|
||||
|
||||
|
|
324
src/hp48char.h
324
src/hp48char.h
|
@ -44,265 +44,71 @@ typedef struct trans_tbl_t {
|
|||
#ifndef DEFINE_TRANS_TABLE
|
||||
extern trans_tbl_t hp48_trans_tbl[256];
|
||||
#else
|
||||
trans_tbl_t hp48_trans_tbl[256] =
|
||||
{
|
||||
{ 0, "\\0" },
|
||||
{ 1, "\\001" },
|
||||
{ 2, "\\002" },
|
||||
{ 3, "\\003" },
|
||||
{ 4, "\\004" },
|
||||
{ 5, "\\005" },
|
||||
{ 6, "\\006" },
|
||||
{ 7, "\\007" },
|
||||
{ 8, "\\b" },
|
||||
{ 9, "\\t" },
|
||||
{ 10, "\\n" },
|
||||
{ 11, "\\011" },
|
||||
{ 12, "\\f" },
|
||||
{ 13, "\\r" },
|
||||
{ 14, "\\014" },
|
||||
{ 15, "\\015" },
|
||||
{ 16, "\\016" },
|
||||
{ 17, "\\017" },
|
||||
{ 18, "\\018" },
|
||||
{ 19, "\\019" },
|
||||
{ 20, "\\020" },
|
||||
{ 21, "\\021" },
|
||||
{ 22, "\\022" },
|
||||
{ 23, "\\023" },
|
||||
{ 24, "\\024" },
|
||||
{ 25, "\\025" },
|
||||
{ 26, "\\026" },
|
||||
{ 27, "\\027" },
|
||||
{ 28, "\\028" },
|
||||
{ 29, "\\029" },
|
||||
{ 30, "\\030" },
|
||||
{ 31, "\\031" },
|
||||
{ ' ', 0 },
|
||||
{ '!', 0 },
|
||||
{ '"', 0 },
|
||||
{ '#', 0 },
|
||||
{ '$', 0 },
|
||||
{ '%', 0 },
|
||||
{ '&', 0 },
|
||||
{ '\'', 0 },
|
||||
{ '(', 0 },
|
||||
{ ')', 0 },
|
||||
{ '*', 0 },
|
||||
{ '+', 0 },
|
||||
{ ',', 0 },
|
||||
{ '-', 0 },
|
||||
{ '.', 0 },
|
||||
{ '/', 0 },
|
||||
{ '0', 0 },
|
||||
{ '1', 0 },
|
||||
{ '2', 0 },
|
||||
{ '3', 0 },
|
||||
{ '4', 0 },
|
||||
{ '5', 0 },
|
||||
{ '6', 0 },
|
||||
{ '7', 0 },
|
||||
{ '8', 0 },
|
||||
{ '9', 0 },
|
||||
{ ':', 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 },
|
||||
{ '_', 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" }
|
||||
};
|
||||
trans_tbl_t hp48_trans_tbl[256] = {
|
||||
{0, "\\0"}, {1, "\\001"}, {2, "\\002"}, {3, "\\003"},
|
||||
{4, "\\004"}, {5, "\\005"}, {6, "\\006"}, {7, "\\007"},
|
||||
{8, "\\b"}, {9, "\\t"}, {10, "\\n"}, {11, "\\011"},
|
||||
{12, "\\f"}, {13, "\\r"}, {14, "\\014"}, {15, "\\015"},
|
||||
{16, "\\016"}, {17, "\\017"}, {18, "\\018"}, {19, "\\019"},
|
||||
{20, "\\020"}, {21, "\\021"}, {22, "\\022"}, {23, "\\023"},
|
||||
{24, "\\024"}, {25, "\\025"}, {26, "\\026"}, {27, "\\027"},
|
||||
{28, "\\028"}, {29, "\\029"}, {30, "\\030"}, {31, "\\031"},
|
||||
{' ', 0}, {'!', 0}, {'"', 0}, {'#', 0},
|
||||
{'$', 0}, {'%', 0}, {'&', 0}, {'\'', 0},
|
||||
{'(', 0}, {')', 0}, {'*', 0}, {'+', 0},
|
||||
{',', 0}, {'-', 0}, {'.', 0}, {'/', 0},
|
||||
{'0', 0}, {'1', 0}, {'2', 0}, {'3', 0},
|
||||
{'4', 0}, {'5', 0}, {'6', 0}, {'7', 0},
|
||||
{'8', 0}, {'9', 0}, {':', 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}, {'_', 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 /* !_HP48CHAR_H */
|
||||
|
|
702
src/init.c
702
src/init.c
File diff suppressed because it is too large
Load diff
64
src/lcd.c
64
src/lcd.c
|
@ -60,23 +60,22 @@
|
|||
* $Id: lcd.c,v 1.13 1995/01/11 18:20:01 ecd Exp ecd $
|
||||
*/
|
||||
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#ifdef SUNOS
|
||||
#include <memory.h>
|
||||
#endif
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#include "annunc.h"
|
||||
#include "device.h"
|
||||
#include "hp48.h"
|
||||
#include "hp48_emu.h"
|
||||
#include "x48_x11.h"
|
||||
#include "annunc.h"
|
||||
#include "device.h"
|
||||
|
||||
static int last_annunc_state = -1;
|
||||
|
||||
|
@ -91,8 +90,7 @@ unsigned char lcd_buffer[DISP_ROWS][NIBS_PER_BUFFER_ROW];
|
|||
|
||||
Pixmap nibble_maps[16];
|
||||
|
||||
unsigned char nibbles[16][2] =
|
||||
{
|
||||
unsigned char nibbles[16][2] = {
|
||||
{0x00, 0x00}, /* ---- */
|
||||
{0x03, 0x03}, /* *--- */
|
||||
{0x0c, 0x0c}, /* -*-- */
|
||||
|
@ -117,8 +115,8 @@ void init_nibble_maps(void) {
|
|||
int i;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
nibble_maps[i] = XCreateBitmapFromData(dpy, disp.win,
|
||||
(char *)nibbles[i], 8, 2);
|
||||
nibble_maps[i] =
|
||||
XCreateBitmapFromData(dpy, disp.win, (char *)nibbles[i], 8, 2);
|
||||
}
|
||||
#ifdef HAVE_XSHM
|
||||
if (shm_flag) {
|
||||
|
@ -180,8 +178,8 @@ void init_display(void) {
|
|||
else
|
||||
display.nibs_per_line = (NIBBLES_PER_ROW + saturn.line_offset) & 0xfff;
|
||||
|
||||
display.disp_end = display.disp_start +
|
||||
(display.nibs_per_line * (display.lines + 1));
|
||||
display.disp_end =
|
||||
display.disp_start + (display.nibs_per_line * (display.lines + 1));
|
||||
|
||||
display.menu_start = saturn.menu_addr;
|
||||
display.menu_end = saturn.menu_addr + 0x110;
|
||||
|
@ -238,8 +236,7 @@ void update_display(void) {
|
|||
word_20 data_addr, data_addr_2;
|
||||
#endif
|
||||
|
||||
if (!disp.mapped)
|
||||
{
|
||||
if (!disp.mapped) {
|
||||
refresh_icon();
|
||||
return;
|
||||
}
|
||||
|
@ -316,9 +313,11 @@ void update_display(void) {
|
|||
} else {
|
||||
#ifdef HAVE_XSHM
|
||||
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));
|
||||
memset(disp.menu_image->data, 0,
|
||||
memset(
|
||||
disp.menu_image->data, 0,
|
||||
(size_t)(disp.menu_image->bytes_per_line * disp.menu_image->height));
|
||||
disp.display_update = UPDATE_DISP | UPDATE_MENU;
|
||||
} else {
|
||||
|
@ -380,8 +379,7 @@ void disp_draw_nibble(word_20 addr, word_4 val) {
|
|||
for (y = 0; y < display.lines; y++) {
|
||||
disp.disp_image->data[shm_addr] = nibble_bits[val];
|
||||
shm_addr += disp.disp_image->bytes_per_line;
|
||||
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;
|
||||
}
|
||||
disp.display_update |= UPDATE_DISP;
|
||||
|
@ -409,8 +407,9 @@ void menu_draw_nibble(word_20 addr, word_4 val) {
|
|||
offset = (addr - display.menu_start);
|
||||
#ifdef HAVE_XSHM
|
||||
if (shm_flag) {
|
||||
shm_addr = 2 * (offset / NIBBLES_PER_ROW) * disp.menu_image->bytes_per_line
|
||||
+ (offset % NIBBLES_PER_ROW);
|
||||
shm_addr =
|
||||
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 + disp.menu_image->bytes_per_line] =
|
||||
nibble_bits[val];
|
||||
|
@ -428,7 +427,6 @@ void menu_draw_nibble(word_20 addr, word_4 val) {
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
struct ann_struct {
|
||||
int bit;
|
||||
int x;
|
||||
|
@ -445,8 +443,7 @@ struct ann_struct {
|
|||
ann_battery_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},
|
||||
{ 0 }
|
||||
};
|
||||
{0}};
|
||||
|
||||
void draw_annunc(void) {
|
||||
int val;
|
||||
|
@ -457,18 +454,14 @@ void draw_annunc(void) {
|
|||
if (val == last_annunc_state)
|
||||
return;
|
||||
last_annunc_state = val;
|
||||
for (i = 0; ann_tbl[i].bit; i++)
|
||||
{
|
||||
if ((ann_tbl[i].bit & val) == ann_tbl[i].bit)
|
||||
{
|
||||
for (i = 0; ann_tbl[i].bit; i++) {
|
||||
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, ann_tbl[i].y, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
XClearArea(dpy, disp.win, ann_tbl[i].x, ann_tbl[i].y,
|
||||
ann_tbl[i].width, ann_tbl[i].height, False);
|
||||
ann_tbl[i].width, ann_tbl[i].height, ann_tbl[i].x,
|
||||
ann_tbl[i].y, 1);
|
||||
} else {
|
||||
XClearArea(dpy, disp.win, ann_tbl[i].x, ann_tbl[i].y, ann_tbl[i].width,
|
||||
ann_tbl[i].height, False);
|
||||
}
|
||||
}
|
||||
refresh_icon();
|
||||
|
@ -483,9 +476,8 @@ void init_annunc(void) {
|
|||
int i;
|
||||
|
||||
for (i = 0; ann_tbl[i].bit; i++) {
|
||||
ann_tbl[i].pixmap = XCreateBitmapFromData(dpy, disp.win,
|
||||
(char *)ann_tbl[i].bits,
|
||||
ann_tbl[i].width,
|
||||
ann_tbl[i].height);
|
||||
ann_tbl[i].pixmap =
|
||||
XCreateBitmapFromData(dpy, disp.win, (char *)ann_tbl[i].bits,
|
||||
ann_tbl[i].width, ann_tbl[i].height);
|
||||
}
|
||||
}
|
||||
|
|
25
src/main.c
25
src/main.c
|
@ -57,19 +57,18 @@
|
|||
* $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 <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "x48_x11.h"
|
||||
#include "hp48.h"
|
||||
#include "debugger.h"
|
||||
#include "hp48.h"
|
||||
#include "x48_x11.h"
|
||||
|
||||
#include <langinfo.h>
|
||||
#include <locale.h>
|
||||
|
@ -104,20 +103,16 @@ void save_options(int argc, char **argv) {
|
|||
|
||||
saved_argc = argc;
|
||||
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);
|
||||
exit(1);
|
||||
}
|
||||
saved_argv[argc] = (char *)0;
|
||||
while (argc--)
|
||||
{
|
||||
while (argc--) {
|
||||
l = strlen(argv[argc]) + 1;
|
||||
saved_argv[argc] = (char *)malloc(l);
|
||||
if (saved_argv[argc] == (char *)0)
|
||||
{
|
||||
fprintf(stderr, "%s: malloc failed in save_options(), exit\n",
|
||||
progname);
|
||||
if (saved_argv[argc] == (char *)0) {
|
||||
fprintf(stderr, "%s: malloc failed in save_options(), exit\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
memcpy(saved_argv[argc], argv[argc], l);
|
||||
|
|
754
src/memory.c
754
src/memory.c
File diff suppressed because it is too large
Load diff
18
src/mkcard.c
18
src/mkcard.c
|
@ -25,13 +25,12 @@
|
|||
* $Id: mkcard.c,v 1.1 1995/01/11 18:11:25 ecd Exp ecd $
|
||||
*/
|
||||
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#ifdef SUNOS
|
||||
#include <memory.h>
|
||||
#endif
|
||||
|
@ -42,14 +41,12 @@ unsigned char *mem;
|
|||
int write_mem_file(char *name, unsigned char *mem, int size) {
|
||||
FILE *fp;
|
||||
|
||||
if (NULL == (fp = fopen(name, "w")))
|
||||
{
|
||||
if (NULL == (fp = fopen(name, "w"))) {
|
||||
fprintf(stderr, "can\'t open %s\n", name);
|
||||
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);
|
||||
fclose(fp);
|
||||
return 0;
|
||||
|
@ -65,8 +62,7 @@ int main(int argc, char **argv) {
|
|||
char *asize;
|
||||
unsigned char *core;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "usage: %s [32K | 128K | 1M | 2M | 4M] file-name\n",
|
||||
argv[0]);
|
||||
exit(1);
|
||||
|
@ -88,8 +84,7 @@ int main(int argc, char **argv) {
|
|||
size = 0x200000;
|
||||
else if (!strcmp(asize, "4M"))
|
||||
size = 0x400000;
|
||||
else
|
||||
{
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"%s: size must be one of 32K, 128K, 256K, 512K, 1M, 2M, or 4M\n",
|
||||
argv[0]);
|
||||
|
@ -102,8 +97,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
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);
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#ifndef _MMU_H
|
||||
#define _MMU_H 1
|
||||
|
||||
|
||||
#define NR_MCTL 6
|
||||
|
||||
#define MCTL_MMIO_SX 0
|
||||
|
@ -44,7 +43,6 @@
|
|||
#define MCTL_PORT2_GX 4
|
||||
#define MCTL_SysROM_GX 5
|
||||
|
||||
|
||||
#if 0
|
||||
extern void init_mmu __ProtoType__((void));
|
||||
extern void reset_mmu __ProtoType__((void));
|
||||
|
|
|
@ -44,8 +44,8 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "constants.h"
|
||||
#include "resources.h"
|
||||
|
@ -90,7 +90,8 @@ where options include:\n\
|
|||
-xrm <resource> set Xresource <resource>\n\
|
||||
-/+throttle turn off/on speed emulation\n\
|
||||
-/+netbook turn off/on netbook layout\n\
|
||||
\n", VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL, progname);
|
||||
\n",
|
||||
VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL, progname);
|
||||
|
||||
fflush(stdout);
|
||||
exit(1);
|
||||
|
@ -100,8 +101,8 @@ void show_version(void) {
|
|||
fprintf(stdout, "\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",
|
||||
progname, VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL,
|
||||
COMPILE_TIME, COMPILE_BY, COMPILE_VERSION);
|
||||
progname, VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL, COMPILE_TIME,
|
||||
COMPILE_BY, COMPILE_VERSION);
|
||||
}
|
||||
|
||||
void show_copyright(void) {
|
||||
|
|
|
@ -42,28 +42,21 @@
|
|||
* $Id: register.c,v 1.6 1995/01/11 18:20:01 ecd Exp ecd $
|
||||
*/
|
||||
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "hp48.h"
|
||||
#include "hp48_emu.h"
|
||||
|
||||
extern long nibble_masks[16];
|
||||
|
||||
static int start_fields[] = {
|
||||
-1, 0, 2, 0, 15, 3, 0, 0,
|
||||
-1, 0, 2, 0, 15, 3, 0, 0,
|
||||
0, 0, 0
|
||||
};
|
||||
static int start_fields[] = {-1, 0, 2, 0, 15, 3, 0, 0, -1, 0,
|
||||
2, 0, 15, 3, 0, 0, 0, 0, 0};
|
||||
|
||||
static int end_fields[] = {
|
||||
-1, -1, 2, 2, 15, 14, 1, 15,
|
||||
-1, -1, 2, 2, 15, 14, 1, 4,
|
||||
3, 2, 0
|
||||
};
|
||||
static int end_fields[] = {-1, -1, 2, 2, 15, 14, 1, 15, -1, -1,
|
||||
2, 2, 15, 14, 1, 4, 3, 2, 0};
|
||||
|
||||
static inline int get_start(int code) {
|
||||
int s;
|
||||
|
@ -83,8 +76,8 @@ static inline int get_end(int code) {
|
|||
return e;
|
||||
}
|
||||
|
||||
void add_register(unsigned char *res, unsigned char *r1,
|
||||
unsigned char *r2, int code) {
|
||||
void add_register(unsigned char *res, unsigned char *r1, unsigned char *r2,
|
||||
int code) {
|
||||
int t, c, i, s, e;
|
||||
|
||||
s = get_start(code);
|
||||
|
@ -128,8 +121,8 @@ void add_p_plus_one(unsigned char *r) {
|
|||
saturn.CARRY = 0;
|
||||
}
|
||||
|
||||
void sub_register(unsigned char *res, unsigned char *r1,
|
||||
unsigned char *r2, int code) {
|
||||
void sub_register(unsigned char *res, unsigned char *r1, unsigned char *r2,
|
||||
int code) {
|
||||
int t, c, i, s, e;
|
||||
|
||||
s = get_start(code);
|
||||
|
@ -288,8 +281,8 @@ void zero_register(unsigned char *r, int code) {
|
|||
r[i] = 0;
|
||||
}
|
||||
|
||||
void or_register(unsigned char *res, unsigned char *r1,
|
||||
unsigned char *r2, int code) {
|
||||
void or_register(unsigned char *res, unsigned char *r1, unsigned char *r2,
|
||||
int code) {
|
||||
int i, s, e;
|
||||
|
||||
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,
|
||||
unsigned char *r2, int code) {
|
||||
void and_register(unsigned char *res, unsigned char *r1, unsigned char *r2,
|
||||
int code) {
|
||||
int i, s, e;
|
||||
|
||||
s = get_start(code);
|
||||
|
@ -522,7 +515,8 @@ int is_greater_register(unsigned char *r1, unsigned char *r2, int code) {
|
|||
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;
|
||||
|
||||
s = get_start(code);
|
||||
|
|
131
src/resources.c
131
src/resources.c
|
@ -50,14 +50,14 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xresource.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "resources.h"
|
||||
#include "disasm.h"
|
||||
#include "errors.h"
|
||||
#include "resources.h"
|
||||
|
||||
XrmDatabase rdb = (XrmDatabase)0;
|
||||
|
||||
|
@ -92,16 +92,14 @@ void get_resources(void) {
|
|||
useSerial = get_boolean_resource("useSerial", "UseSerial");
|
||||
serialLine = get_string_resource("serialLine", "SerialLine");
|
||||
|
||||
initialize = get_boolean_resource("completeInitialize",
|
||||
"CompleteInitialize");
|
||||
resetOnStartup = get_boolean_resource("resetOnStartup",
|
||||
"ResetOnStartup");
|
||||
initialize = get_boolean_resource("completeInitialize", "CompleteInitialize");
|
||||
resetOnStartup = get_boolean_resource("resetOnStartup", "ResetOnStartup");
|
||||
romFileName = get_string_resource("romFileName", "RomFileName");
|
||||
homeDirectory = get_string_resource("homeDirectory", "HomeDirectory");
|
||||
|
||||
useDebugger = get_boolean_resource("useDebugger", "UseDebugger");
|
||||
disassembler_mode = get_mnemonic_resource("disassemblerMnemonics",
|
||||
"DisassemblerMnemonics");
|
||||
disassembler_mode =
|
||||
get_mnemonic_resource("disassemblerMnemonics", "DisassemblerMnemonics");
|
||||
|
||||
netbook = get_boolean_resource("netbook", "Netbook");
|
||||
|
||||
|
@ -119,8 +117,7 @@ char * get_string_resource_from_db (XrmDatabase db, char *name, char *class) {
|
|||
strcpy(full_class, res_class);
|
||||
strcat(full_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);
|
||||
strncpy(str, (char *)value.addr, value.size);
|
||||
str[value.size] = 0;
|
||||
|
@ -138,7 +135,8 @@ int get_mnemonic_resource (char *name, char *class) {
|
|||
char *s = get_string_resource(name, class);
|
||||
char *os = s;
|
||||
|
||||
if (! s) return CLASS_MNEMONICS;
|
||||
if (!s)
|
||||
return CLASS_MNEMONICS;
|
||||
for (tmp = buf; *s; s++)
|
||||
*tmp++ = isupper(*s) ? _tolower(*s) : *s;
|
||||
*tmp = 0;
|
||||
|
@ -157,7 +155,8 @@ int get_boolean_resource (char *name, char *class) {
|
|||
char *tmp, buf[100];
|
||||
char *s = get_string_resource(name, class);
|
||||
char *os = s;
|
||||
if (! s) return 0;
|
||||
if (!s)
|
||||
return 0;
|
||||
for (tmp = buf; *s; s++)
|
||||
*tmp++ = isupper(*s) ? _tolower(*s) : *s;
|
||||
*tmp = 0;
|
||||
|
@ -167,22 +166,20 @@ int get_boolean_resource (char *name, char *class) {
|
|||
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);
|
||||
fprintf(stderr, "%s: %s must be boolean, not %s.\n", progname, name, buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_integer_resource(char *name, char *class) {
|
||||
int val;
|
||||
char c, *s = get_string_resource(name, class);
|
||||
if (!s) return 0;
|
||||
if (1 == sscanf (s, " %d %c", &val, &c))
|
||||
{
|
||||
if (!s)
|
||||
return 0;
|
||||
if (1 == sscanf(s, " %d %c", &val, &c)) {
|
||||
free(s);
|
||||
return val;
|
||||
}
|
||||
fprintf (stderr, "%s: %s must be an integer, not %s.\n",
|
||||
progname, name, s);
|
||||
fprintf(stderr, "%s: %s must be an integer, not %s.\n", progname, name, s);
|
||||
free(s);
|
||||
return 0;
|
||||
}
|
||||
|
@ -191,37 +188,36 @@ unsigned int get_pixel_resource (char *name, char *class, Display *dpy,
|
|||
Colormap cmap) {
|
||||
XColor color;
|
||||
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);
|
||||
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;
|
||||
}
|
||||
free(s);
|
||||
return color.pixel;
|
||||
DEFAULT:
|
||||
if (s) free (s);
|
||||
return (strcmp (class, "Background")
|
||||
? WhitePixel (dpy, DefaultScreen (dpy))
|
||||
if (s)
|
||||
free(s);
|
||||
return (strcmp(class, "Background") ? WhitePixel(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;
|
||||
int out_count;
|
||||
|
||||
vi_in.class = visual_class;
|
||||
vi_in.screen = DefaultScreen(dpy);
|
||||
vi_out = XGetVisualInfo(dpy, VisualClassMask|VisualScreenMask,
|
||||
&vi_in, &out_count);
|
||||
if (vi_out)
|
||||
{ /* choose the 'best' one, if multiple */
|
||||
vi_out = XGetVisualInfo(dpy, VisualClassMask | VisualScreenMask, &vi_in,
|
||||
&out_count);
|
||||
if (vi_out) { /* choose the 'best' one, if multiple */
|
||||
int i, best;
|
||||
Visual *visual;
|
||||
for (i = 0, best = 0; i < out_count; i++)
|
||||
|
@ -231,9 +227,7 @@ static Visual * pick_visual_of_class (Display *dpy, int visual_class, unsigned i
|
|||
*depth = vi_out[best].depth;
|
||||
XFree((char *)vi_out);
|
||||
return visual;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
*depth = DefaultDepth(dpy, DefaultScreen(dpy));
|
||||
return DefaultVisual(dpy, DefaultScreen(dpy));
|
||||
}
|
||||
|
@ -245,10 +239,9 @@ static Visual * id_to_visual (Display *dpy, int id, unsigned int *depth) {
|
|||
|
||||
vi_in.screen = DefaultScreen(dpy);
|
||||
vi_in.visualid = id;
|
||||
vi_out = XGetVisualInfo(dpy, VisualScreenMask|VisualIDMask,
|
||||
&vi_in, &out_count);
|
||||
if (vi_out)
|
||||
{
|
||||
vi_out =
|
||||
XGetVisualInfo(dpy, VisualScreenMask | VisualIDMask, &vi_in, &out_count);
|
||||
if (vi_out) {
|
||||
Visual *v = vi_out[0].visual;
|
||||
*depth = vi_out[0].depth;
|
||||
XFree((char *)vi_out);
|
||||
|
@ -257,7 +250,8 @@ static Visual * id_to_visual (Display *dpy, int id, unsigned int *depth) {
|
|||
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,
|
||||
unsigned int *depth) {
|
||||
char c;
|
||||
char *tmp, *s;
|
||||
int vclass;
|
||||
|
@ -266,38 +260,45 @@ Visual * get_visual_resource(Display *dpy, char *name, char *class, unsigned int
|
|||
s = get_string_resource(name, class);
|
||||
if (s)
|
||||
for (tmp = s; *tmp; tmp++)
|
||||
if (isupper(*tmp)) *tmp = _tolower(*tmp);
|
||||
if (isupper(*tmp))
|
||||
*tmp = _tolower(*tmp);
|
||||
|
||||
if (!s || !strcmp(s, "default")) vclass = -1;
|
||||
else if (!strcmp (s, "staticgray")) vclass = StaticGray;
|
||||
else if (!strcmp (s, "staticcolor")) vclass = StaticColor;
|
||||
else if (!strcmp (s, "truecolor")) vclass = TrueColor;
|
||||
else if (!strcmp (s, "grayscale")) vclass = GrayScale;
|
||||
else if (!strcmp (s, "pseudocolor")) vclass = PseudoColor;
|
||||
else if (!strcmp (s, "directcolor")) vclass = DirectColor;
|
||||
else if (1 == sscanf (s, " %d %c", &id, &c)) vclass = -2;
|
||||
else if (1 == sscanf (s, " 0x%x %c", &id, &c)) vclass = -2;
|
||||
else
|
||||
{
|
||||
if (!s || !strcmp(s, "default"))
|
||||
vclass = -1;
|
||||
else if (!strcmp(s, "staticgray"))
|
||||
vclass = StaticGray;
|
||||
else if (!strcmp(s, "staticcolor"))
|
||||
vclass = StaticColor;
|
||||
else if (!strcmp(s, "truecolor"))
|
||||
vclass = TrueColor;
|
||||
else if (!strcmp(s, "grayscale"))
|
||||
vclass = GrayScale;
|
||||
else if (!strcmp(s, "pseudocolor"))
|
||||
vclass = PseudoColor;
|
||||
else if (!strcmp(s, "directcolor"))
|
||||
vclass = DirectColor;
|
||||
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 (s)
|
||||
free(s);
|
||||
|
||||
if (vclass == -1)
|
||||
{
|
||||
if (vclass == -1) {
|
||||
*depth = DefaultDepth(dpy, DefaultScreen(dpy));
|
||||
return DefaultVisual(dpy, DefaultScreen(dpy));
|
||||
}
|
||||
else if (vclass == -2)
|
||||
{
|
||||
} else if (vclass == -2) {
|
||||
Visual *v = id_to_visual(dpy, id, depth);
|
||||
if (v) return v;
|
||||
if (v)
|
||||
return v;
|
||||
fprintf(stderr, "%s: no visual with id 0x%x.\n", progname, id);
|
||||
*depth = DefaultDepth(dpy, DefaultScreen(dpy));
|
||||
return DefaultVisual(dpy, DefaultScreen(dpy));
|
||||
}
|
||||
else
|
||||
} else
|
||||
return pick_visual_of_class(dpy, vclass, depth);
|
||||
}
|
||||
|
||||
|
@ -309,13 +310,11 @@ XFontStruct * get_font_resource(Display *dpy, char *name, char *class) {
|
|||
|
||||
if (s)
|
||||
f = XLoadQueryFont(dpy, s);
|
||||
else
|
||||
{
|
||||
else {
|
||||
sprintf(errbuf, "can\'t get resource \'%s\'", name);
|
||||
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);
|
||||
fatal_exit();
|
||||
|
|
|
@ -69,14 +69,10 @@ extern void get_resources __ProtoType__ ((void));
|
|||
extern char *get_string_resource_from_db __ProtoType__((XrmDatabase db,
|
||||
char *name,
|
||||
char *class));
|
||||
extern char * get_string_resource __ProtoType__ ((char *name,
|
||||
char *class));
|
||||
extern int get_boolean_resource __ProtoType__ ((char *name,
|
||||
char *class));
|
||||
extern int get_mnemonic_resource __ProtoType__ ((char *name,
|
||||
char *class));
|
||||
extern Visual * get_visual_resource __ProtoType__ ((Display *dpy,
|
||||
char *name,
|
||||
extern char *get_string_resource __ProtoType__((char *name, char *class));
|
||||
extern int get_boolean_resource __ProtoType__((char *name, char *class));
|
||||
extern int get_mnemonic_resource __ProtoType__((char *name, char *class));
|
||||
extern Visual *get_visual_resource __ProtoType__((Display * dpy, char *name,
|
||||
char *class,
|
||||
unsigned int *depth));
|
||||
extern XFontStruct *get_font_resource __ProtoType__((Display * dpy,
|
||||
|
|
120
src/romio.c
120
src/romio.c
|
@ -27,8 +27,8 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "resources.h"
|
||||
|
@ -47,55 +47,42 @@ int read_rom_file(char *name, unsigned char **mem, int *size) {
|
|||
|
||||
*mem = NULL;
|
||||
*size = 0;
|
||||
if (NULL == (fp = fopen(name, "r")))
|
||||
{
|
||||
if (NULL == (fp = fopen(name, "r"))) {
|
||||
fprintf(stderr, "can\'t open %s\n", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (stat(name, &st) < 0)
|
||||
{
|
||||
if (stat(name, &st) < 0) {
|
||||
fprintf(stderr, "can\'t stat %s\n", name);
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (fread(four, 1, 4, fp) != 4)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
} else if (four[0] == 0x32 && four[1] == 0x96 && four[2] == 0x1b &&
|
||||
four[3] == 0x80) {
|
||||
*size = 2 * st.st_size;
|
||||
}
|
||||
else if (four[1] = 0x49)
|
||||
{
|
||||
} else if (four[1] = 0x49) {
|
||||
fprintf(stderr, "%s is an HP49 ROM\n", name);
|
||||
*size = 2 * st.st_size;
|
||||
}
|
||||
else if (four[0])
|
||||
{
|
||||
} else if (four[0]) {
|
||||
printf("%d\n", st.st_size);
|
||||
*size = st.st_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
fprintf(stderr, "%s is not a HP48 ROM\n", name);
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (fseek(fp, 0, 0) < 0)
|
||||
{
|
||||
if (fseek(fp, 0, 0) < 0) {
|
||||
fprintf(stderr, "can\'t fseek to position 0 in %s\n", name);
|
||||
*size = 0;
|
||||
fclose(fp);
|
||||
|
@ -104,13 +91,11 @@ int read_rom_file(char *name, unsigned char **mem, int *size) {
|
|||
|
||||
*mem = (unsigned char *)malloc(*size);
|
||||
|
||||
if (st.st_size == *size)
|
||||
{
|
||||
if (st.st_size == *size) {
|
||||
/*
|
||||
* size is same as memory size, old version file
|
||||
*/
|
||||
if (fread(*mem, 1, (size_t)*size, fp) != *size)
|
||||
{
|
||||
if (fread(*mem, 1, (size_t)*size, fp) != *size) {
|
||||
fprintf(stderr, "can\'t read %s\n", name);
|
||||
free(*mem);
|
||||
*mem = NULL;
|
||||
|
@ -118,17 +103,14 @@ int read_rom_file(char *name, unsigned char **mem, int *size) {
|
|||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} 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);
|
||||
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;
|
||||
|
@ -136,12 +118,9 @@ int read_rom_file(char *name, unsigned char **mem, int *size) {
|
|||
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))
|
||||
{
|
||||
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;
|
||||
|
@ -152,11 +131,8 @@ int read_rom_file(char *name, unsigned char **mem, int *size) {
|
|||
(*mem)[j++] = byte & 0xf;
|
||||
(*mem)[j++] = (byte >> 4) & 0xf;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fread(tmp_mem, 1, (size_t)*size / 2, fp) != *size / 2)
|
||||
{
|
||||
} 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;
|
||||
|
@ -166,8 +142,7 @@ int read_rom_file(char *name, unsigned char **mem, int *size) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0, j = 0; i < *size / 2; i++)
|
||||
{
|
||||
for (i = 0, j = 0; i < *size / 2; i++) {
|
||||
(*mem)[j++] = tmp_mem[i] & 0xf;
|
||||
(*mem)[j++] = (tmp_mem[i] >> 4) & 0xf;
|
||||
}
|
||||
|
@ -178,46 +153,31 @@ int read_rom_file(char *name, unsigned char **mem, int *size) {
|
|||
|
||||
fclose(fp);
|
||||
|
||||
if ((*mem)[0x29] == 0x00)
|
||||
{
|
||||
if (*size == ROM_SIZE_GX)
|
||||
{
|
||||
if ((*mem)[0x29] == 0x00) {
|
||||
if (*size == ROM_SIZE_GX) {
|
||||
opt_gx = 1;
|
||||
}
|
||||
else
|
||||
if (*size == 4 * ROM_SIZE_GX)
|
||||
{
|
||||
fprintf(stderr, "%s seems to be HP49 ROM, but size is 0x%x\n",
|
||||
name, *size);
|
||||
} else if (*size == 4 * ROM_SIZE_GX) {
|
||||
fprintf(stderr, "%s seems to be HP49 ROM, but size is 0x%x\n", name,
|
||||
*size);
|
||||
opt_gx = 2;
|
||||
}
|
||||
else
|
||||
if (*size == 8 * ROM_SIZE_GX)
|
||||
{
|
||||
fprintf(stderr, "%s seems to be HP49 ROM, but size is 0x%x\n",
|
||||
name, *size);
|
||||
} else if (*size == 8 * ROM_SIZE_GX) {
|
||||
fprintf(stderr, "%s seems to be HP49 ROM, but size is 0x%x\n", name,
|
||||
*size);
|
||||
opt_gx = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s seems to be G/GX ROM, but size is 0x%x\n",
|
||||
name, *size);
|
||||
} 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
|
||||
{
|
||||
if (*size == ROM_SIZE_SX)
|
||||
{
|
||||
} else {
|
||||
if (*size == ROM_SIZE_SX) {
|
||||
opt_gx = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s seems to be S/SX ROM, but size is 0x%x\n",
|
||||
name, *size);
|
||||
} else {
|
||||
fprintf(stderr, "%s seems to be S/SX ROM, but size is 0x%x\n", name,
|
||||
*size);
|
||||
free(*mem);
|
||||
*mem = NULL;
|
||||
*size = 0;
|
||||
|
|
347
src/rpl.c
347
src/rpl.c
|
@ -38,16 +38,16 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "append.h"
|
||||
#include "debugger.h"
|
||||
#include "disasm.h"
|
||||
#include "hp48.h"
|
||||
#include "hp48_emu.h"
|
||||
#include "rpl.h"
|
||||
#include "debugger.h"
|
||||
#include "append.h"
|
||||
#include "disasm.h"
|
||||
#include "romio.h"
|
||||
#include "rpl.h"
|
||||
#define DEFINE_TRANS_TABLE 1
|
||||
#include "hp48char.h"
|
||||
#undef DEFINE_TRANS_TABLE
|
||||
|
@ -57,8 +57,7 @@ struct objfunc {
|
|||
short length;
|
||||
word_20 prolog;
|
||||
char *(*func)__ProtoType__((word_20 * addr, char *string));
|
||||
} objects[] = {
|
||||
{ "System Binary", 0, DOBINT, dec_bin_int },
|
||||
} objects[] = {{"System Binary", 0, DOBINT, dec_bin_int},
|
||||
{"Real", 0, DOREAL, dec_real},
|
||||
{"Long Real", 0, DOEREL, dec_long_real},
|
||||
{"Complex", 0, DOCMP, dec_complex},
|
||||
|
@ -91,8 +90,7 @@ struct objfunc {
|
|||
{"^", 0, UM_POW, dec_unit_op},
|
||||
{" ", 0, UM_PRE, dec_unit_op},
|
||||
{"_", 0, UM_END, dec_unit_op},
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
{0, 0, 0}};
|
||||
|
||||
char *skip_ob(word_20 *addr, char *string) {
|
||||
word_20 size, type;
|
||||
|
@ -100,14 +98,12 @@ char * skip_ob(word_20 *addr, char *string) {
|
|||
struct objfunc *op;
|
||||
|
||||
type = read_nibbles(*addr - 5, 5);
|
||||
for (op = objects; op->prolog != 0; op++)
|
||||
{
|
||||
for (op = objects; op->prolog != 0; op++) {
|
||||
if (op->prolog == type)
|
||||
break;
|
||||
}
|
||||
|
||||
if (op->prolog)
|
||||
{
|
||||
if (op->prolog) {
|
||||
sprintf(p, "%s", op->name);
|
||||
p += strlen(p);
|
||||
}
|
||||
|
@ -122,8 +118,7 @@ char * skip_ob(word_20 *addr, char *string) {
|
|||
long hxs2real(long hxs) {
|
||||
int n = 0, c = 1;
|
||||
|
||||
while (hxs)
|
||||
{
|
||||
while (hxs) {
|
||||
n += (hxs & 0xf) * c;
|
||||
c *= 10;
|
||||
hxs >>= 4;
|
||||
|
@ -168,14 +163,13 @@ char * real_number(word_20 *addr, char *string, int ml, int xl) {
|
|||
* Figure out the exponent
|
||||
*/
|
||||
xs = 5;
|
||||
while (--xl) xs *= 10;
|
||||
while (--xl)
|
||||
xs *= 10;
|
||||
re = hxs2real(r.x);
|
||||
if (re >= xs)
|
||||
re = re - 2 * xs;
|
||||
|
||||
|
||||
if ((re >= 0) && (re < ml + 1))
|
||||
{
|
||||
if ((re >= 0) && (re < ml + 1)) {
|
||||
if (r.s >= 5)
|
||||
*p++ = '-';
|
||||
|
||||
|
@ -188,22 +182,23 @@ char * real_number(word_20 *addr, char *string, int ml, int xl) {
|
|||
for (; i < ml + 1; i++)
|
||||
*p++ = m[i];
|
||||
p--;
|
||||
while(*p == '0') p--;
|
||||
if (*p == '.') p--;
|
||||
while (*p == '0')
|
||||
p--;
|
||||
if (*p == '.')
|
||||
p--;
|
||||
*++p = '\0';
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
if ((re < 0) && (re >= -ml - 1))
|
||||
{
|
||||
if ((re < 0) && (re >= -ml - 1)) {
|
||||
sprintf(fmt, "%%.1X%%.8lX%%.%dlX", ml - 8);
|
||||
sprintf(m, fmt, r.m, r.mh, r.ml);
|
||||
|
||||
for (i = ml; m[i] == '0'; i--) ;
|
||||
for (i = ml; m[i] == '0'; i--)
|
||||
;
|
||||
|
||||
if (-re <= ml - i + 1)
|
||||
{
|
||||
if (-re <= ml - i + 1) {
|
||||
if (r.s >= 5)
|
||||
*p++ = '-';
|
||||
|
||||
|
@ -215,7 +210,8 @@ char * real_number(word_20 *addr, char *string, int ml, int xl) {
|
|||
for (i = 0; i < ml + 1; i++)
|
||||
*p++ = m[i];
|
||||
p--;
|
||||
while(*p == '0') p--;
|
||||
while (*p == '0')
|
||||
p--;
|
||||
*++p = '\0';
|
||||
|
||||
return p;
|
||||
|
@ -227,11 +223,11 @@ char * real_number(word_20 *addr, char *string, int ml, int xl) {
|
|||
|
||||
p += strlen(p) - 1;
|
||||
|
||||
while(*p == '0') p--;
|
||||
while (*p == '0')
|
||||
p--;
|
||||
*++p = '\0';
|
||||
|
||||
if (re)
|
||||
{
|
||||
if (re) {
|
||||
sprintf(p, "E%ld", re);
|
||||
p += strlen(p);
|
||||
*p = '\0';
|
||||
|
@ -288,21 +284,17 @@ char * dec_string(word_20 *addr, char *string) {
|
|||
n = 1000;
|
||||
|
||||
*p++ = '\"';
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
for (i = 0; i < n; i++) {
|
||||
c = read_nibbles(*addr, 2);
|
||||
*addr += 2;
|
||||
if (hp48_trans_tbl[c].trans)
|
||||
{
|
||||
if (hp48_trans_tbl[c].trans) {
|
||||
sprintf(p, hp48_trans_tbl[c].trans);
|
||||
p += strlen(p);
|
||||
}
|
||||
else
|
||||
} else
|
||||
*p++ = c;
|
||||
}
|
||||
|
||||
if (n != len)
|
||||
{
|
||||
if (n != len) {
|
||||
*p++ = '.';
|
||||
*p++ = '.';
|
||||
*p++ = '.';
|
||||
|
@ -322,13 +314,11 @@ char * dec_hex_string(word_20 *addr, char *string) {
|
|||
*addr += 5;
|
||||
len -= 5;
|
||||
|
||||
if (len <= 16)
|
||||
{
|
||||
if (len <= 16) {
|
||||
*p++ = '#';
|
||||
*p++ = ' ';
|
||||
lead = 1;
|
||||
for (i = len - 1; i >= 0; i--)
|
||||
{
|
||||
for (i = len - 1; i >= 0; i--) {
|
||||
*p = hex[read_nibble(*addr + i)];
|
||||
if (lead)
|
||||
if ((i != 0) && (*p == '0'))
|
||||
|
@ -339,9 +329,7 @@ char * dec_hex_string(word_20 *addr, char *string) {
|
|||
}
|
||||
|
||||
*p++ = 'h';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
*p++ = 'C';
|
||||
*p++ = '#';
|
||||
*p++ = ' ';
|
||||
|
@ -358,8 +346,7 @@ char * dec_hex_string(word_20 *addr, char *string) {
|
|||
for (i = 0; i < n; i++)
|
||||
*p++ = hex[read_nibble(*addr + i)];
|
||||
|
||||
if (n != len)
|
||||
{
|
||||
if (n != len) {
|
||||
*p++ = '.';
|
||||
*p++ = '.';
|
||||
*p++ = '.';
|
||||
|
@ -379,12 +366,10 @@ char * dec_list(word_20 *addr, char *string) {
|
|||
*p++ = '{';
|
||||
*p++ = ' ';
|
||||
semi = read_nibbles(*addr, 5);
|
||||
while (semi != SEMI)
|
||||
{
|
||||
while (semi != SEMI) {
|
||||
p = dec_rpl_obj(addr, p);
|
||||
semi = read_nibbles(*addr, 5);
|
||||
if (semi != SEMI)
|
||||
{
|
||||
if (semi != SEMI) {
|
||||
*p++ = ' ';
|
||||
*p = '\0';
|
||||
}
|
||||
|
@ -403,12 +388,10 @@ char * dec_symb(word_20 *addr, char *string) {
|
|||
|
||||
semi = read_nibbles(*addr, 5);
|
||||
*p++ = '\'';
|
||||
while (semi != SEMI)
|
||||
{
|
||||
while (semi != SEMI) {
|
||||
p = dec_rpl_obj(addr, p);
|
||||
semi = read_nibbles(*addr, 5);
|
||||
if (semi != SEMI)
|
||||
{
|
||||
if (semi != SEMI) {
|
||||
*p++ = ' ';
|
||||
*p = '\0';
|
||||
}
|
||||
|
@ -425,12 +408,10 @@ char * dec_unit(word_20 *addr, char *string) {
|
|||
char *p = string;
|
||||
|
||||
semi = read_nibbles(*addr, 5);
|
||||
while (semi != SEMI)
|
||||
{
|
||||
while (semi != SEMI) {
|
||||
p = dec_rpl_obj(addr, p);
|
||||
semi = read_nibbles(*addr, 5);
|
||||
if (semi != SEMI)
|
||||
{
|
||||
if (semi != SEMI) {
|
||||
*p++ = ' ';
|
||||
*p = '\0';
|
||||
}
|
||||
|
@ -444,8 +425,7 @@ char * dec_unit_op(word_20 *addr, char *string) {
|
|||
char *p = string;
|
||||
|
||||
op = read_nibbles(*addr - 5, 5);
|
||||
switch (op)
|
||||
{
|
||||
switch (op) {
|
||||
case UM_MUL:
|
||||
*p++ = '*';
|
||||
break;
|
||||
|
@ -485,15 +465,12 @@ char * dec_library(word_20 *addr, char *string) {
|
|||
sprintf(p, "Library %d: ", libnum);
|
||||
p += strlen(p);
|
||||
|
||||
for (i = 0; i < libidsize; i++)
|
||||
{
|
||||
for (i = 0; i < libidsize; i++) {
|
||||
c = read_nibbles(*addr + 2 * i + 7, 2);
|
||||
if (hp48_trans_tbl[c].trans)
|
||||
{
|
||||
if (hp48_trans_tbl[c].trans) {
|
||||
sprintf(p, hp48_trans_tbl[c].trans);
|
||||
p += strlen(p);
|
||||
}
|
||||
else
|
||||
} else
|
||||
*p++ = c;
|
||||
}
|
||||
|
||||
|
@ -524,8 +501,7 @@ char * dec_acptr(word_20 *addr, char *string) {
|
|||
int i;
|
||||
static char hex[] = "0123456789ABCDEF";
|
||||
|
||||
if (opt_gx)
|
||||
{
|
||||
if (opt_gx) {
|
||||
size = 10;
|
||||
sprintf(p, "ACPTR ");
|
||||
p += strlen(p);
|
||||
|
@ -534,9 +510,7 @@ char * dec_acptr(word_20 *addr, char *string) {
|
|||
*p++ = ' ';
|
||||
for (i = 5; i < 10; i++)
|
||||
*p++ = hex[read_nibble(*addr + i)];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
size = read_nibbles(*addr, 5);
|
||||
sprintf(p, "Ext 1");
|
||||
p += strlen(p);
|
||||
|
@ -553,12 +527,10 @@ char * dec_prog(word_20 *addr, char *string) {
|
|||
char *p = string;
|
||||
|
||||
semi = read_nibbles(*addr, 5);
|
||||
while (semi != SEMI)
|
||||
{
|
||||
while (semi != SEMI) {
|
||||
p = dec_rpl_obj(addr, p);
|
||||
semi = read_nibbles(*addr, 5);
|
||||
if (semi != SEMI)
|
||||
{
|
||||
if (semi != SEMI) {
|
||||
*p++ = ' ';
|
||||
*p = '\0';
|
||||
}
|
||||
|
@ -576,8 +548,7 @@ char * dec_code(word_20 *addr, char *string) {
|
|||
p += strlen(p);
|
||||
|
||||
n = 0;
|
||||
while (n < len)
|
||||
{
|
||||
while (n < len) {
|
||||
/*
|
||||
*addr = disassemble(*addr, p);
|
||||
*/
|
||||
|
@ -600,21 +571,17 @@ char * dec_local_ident(word_20 *addr, char *string) {
|
|||
if (len > 1000)
|
||||
n = 1000;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
for (i = 0; i < n; i++) {
|
||||
c = read_nibbles(*addr, 2);
|
||||
*addr += 2;
|
||||
if (hp48_trans_tbl[c].trans)
|
||||
{
|
||||
if (hp48_trans_tbl[c].trans) {
|
||||
sprintf(p, hp48_trans_tbl[c].trans);
|
||||
p += strlen(p);
|
||||
}
|
||||
else
|
||||
} else
|
||||
*p++ = c;
|
||||
}
|
||||
|
||||
if (n != len)
|
||||
{
|
||||
if (n != len) {
|
||||
*p++ = '.';
|
||||
*p++ = '.';
|
||||
*p++ = '.';
|
||||
|
@ -636,21 +603,17 @@ char * dec_global_ident(word_20 *addr, char *string) {
|
|||
if (len > 1000)
|
||||
n = 1000;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
for (i = 0; i < n; i++) {
|
||||
c = read_nibbles(*addr, 2);
|
||||
*addr += 2;
|
||||
if (hp48_trans_tbl[c].trans)
|
||||
{
|
||||
if (hp48_trans_tbl[c].trans) {
|
||||
sprintf(p, hp48_trans_tbl[c].trans);
|
||||
p += strlen(p);
|
||||
}
|
||||
else
|
||||
} else
|
||||
*p++ = c;
|
||||
}
|
||||
|
||||
if (n != len)
|
||||
{
|
||||
if (n != len) {
|
||||
*p++ = '.';
|
||||
*p++ = '.';
|
||||
*p++ = '.';
|
||||
|
@ -676,14 +639,11 @@ char * xlib_name(int lib, int command, char *string) {
|
|||
*/
|
||||
ram_base = saturn.mem_cntl[1].config[0];
|
||||
ram_mask = saturn.mem_cntl[1].config[1];
|
||||
if (opt_gx)
|
||||
{
|
||||
if (opt_gx) {
|
||||
saturn.mem_cntl[1].config[0] = 0x80000;
|
||||
saturn.mem_cntl[1].config[1] = 0xc0000;
|
||||
romptab = ROMPTAB_GX;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
saturn.mem_cntl[1].config[0] = 0x70000;
|
||||
saturn.mem_cntl[1].config[1] = 0xf0000;
|
||||
romptab = ROMPTAB_SX;
|
||||
|
@ -695,13 +655,11 @@ char * xlib_name(int lib, int command, char *string) {
|
|||
n = read_nibbles(romptab, 3);
|
||||
romptab += 3;
|
||||
|
||||
if (n > 0)
|
||||
{
|
||||
if (n > 0) {
|
||||
/*
|
||||
* look up lib number in romptab
|
||||
*/
|
||||
while (n--)
|
||||
{
|
||||
while (n--) {
|
||||
lib_n = read_nibbles(romptab, 3);
|
||||
romptab += 3;
|
||||
if (lib_n == lib)
|
||||
|
@ -710,18 +668,15 @@ char * xlib_name(int lib, int command, char *string) {
|
|||
if (opt_gx)
|
||||
romptab += 8;
|
||||
}
|
||||
if (lib_n == lib)
|
||||
{
|
||||
if (lib_n == lib) {
|
||||
/*
|
||||
* look at hash table pointer
|
||||
*/
|
||||
lib_addr = read_nibbles(romptab, 5);
|
||||
if (opt_gx)
|
||||
{
|
||||
if (opt_gx) {
|
||||
romptab += 5;
|
||||
acptr = read_nibbles(romptab, 5);
|
||||
if (acptr != 0x00000)
|
||||
{
|
||||
if (acptr != 0x00000) {
|
||||
saturn.mem_cntl[1].config[0] = ram_base;
|
||||
saturn.mem_cntl[1].config[1] = ram_mask;
|
||||
sprintf(p, "XLIB %d %d", lib, command);
|
||||
|
@ -731,8 +686,7 @@ char * xlib_name(int lib, int command, char *string) {
|
|||
}
|
||||
lib_addr += 3;
|
||||
offset = read_nibbles(lib_addr, 5);
|
||||
if (offset > 0)
|
||||
{
|
||||
if (offset > 0) {
|
||||
/*
|
||||
* look at the hash table
|
||||
*/
|
||||
|
@ -749,16 +703,13 @@ char * xlib_name(int lib, int command, char *string) {
|
|||
* check pointer type
|
||||
*/
|
||||
type = read_nibbles(lib_addr, 5);
|
||||
if (type == DOBINT)
|
||||
{
|
||||
if (type == DOBINT) {
|
||||
/*
|
||||
* follow pointer to real address
|
||||
*/
|
||||
lib_addr += 5;
|
||||
lib_addr = read_nibbles(lib_addr, 5);
|
||||
}
|
||||
else if (type == DOACPTR)
|
||||
{
|
||||
} else if (type == DOACPTR) {
|
||||
/*
|
||||
* follow pointer to real address
|
||||
*/
|
||||
|
@ -766,8 +717,7 @@ char * xlib_name(int lib, int command, char *string) {
|
|||
acptr = lib_addr + 5;
|
||||
lib_addr = read_nibbles(lib_addr, 5);
|
||||
acptr = read_nibbles(acptr, 5);
|
||||
if (acptr != 0x00000)
|
||||
{
|
||||
if (acptr != 0x00000) {
|
||||
saturn.mem_cntl[1].config[0] = ram_base;
|
||||
saturn.mem_cntl[1].config[1] = ram_mask;
|
||||
sprintf(p, "XLIB %d %d", lib, command);
|
||||
|
@ -795,25 +745,20 @@ char * xlib_name(int lib, int command, char *string) {
|
|||
*/
|
||||
offset = 5 * command;
|
||||
lib_addr += offset;
|
||||
if (lib_addr < hash_end)
|
||||
{
|
||||
if (lib_addr < hash_end) {
|
||||
offset = read_nibbles(lib_addr, 5);
|
||||
if (offset > 0)
|
||||
{
|
||||
if (offset > 0) {
|
||||
name_addr = lib_addr - offset;
|
||||
len = read_nibbles(name_addr, 2);
|
||||
name_addr += 2;
|
||||
present = 1;
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
for (i = 0; i < len; i++) {
|
||||
c = read_nibbles(name_addr, 2);
|
||||
name_addr += 2;
|
||||
if (hp48_trans_tbl[c].trans)
|
||||
{
|
||||
if (hp48_trans_tbl[c].trans) {
|
||||
sprintf(p, hp48_trans_tbl[c].trans);
|
||||
p += strlen(p);
|
||||
}
|
||||
else
|
||||
} else
|
||||
*p++ = c;
|
||||
}
|
||||
*p = '\0';
|
||||
|
@ -829,8 +774,7 @@ char * xlib_name(int lib, int command, char *string) {
|
|||
saturn.mem_cntl[1].config[0] = ram_base;
|
||||
saturn.mem_cntl[1].config[1] = ram_mask;
|
||||
|
||||
if (!present)
|
||||
{
|
||||
if (!present) {
|
||||
sprintf(p, "XLIB %d %d", lib, command);
|
||||
p += strlen(p);
|
||||
}
|
||||
|
@ -865,8 +809,7 @@ char * any_array(word_20 *addr, char *string, short lnk_flag) {
|
|||
dim = read_nibbles(*addr, 5);
|
||||
*addr += 5;
|
||||
|
||||
for (op = objects; op->prolog != 0; op++)
|
||||
{
|
||||
for (op = objects; op->prolog != 0; op++) {
|
||||
if (op->prolog == type)
|
||||
break;
|
||||
}
|
||||
|
@ -874,24 +817,20 @@ char * any_array(word_20 *addr, char *string, short lnk_flag) {
|
|||
dim_lens = (word_20 *)malloc(dim * sizeof(word_20));
|
||||
dims = (word_20 *)malloc(dim * sizeof(word_20));
|
||||
elems = 1;
|
||||
for (i = 0; i < dim; i++)
|
||||
{
|
||||
for (i = 0; i < dim; i++) {
|
||||
dim_lens[i] = read_nibbles(*addr, 5);
|
||||
dims[i] = dim_lens[i];
|
||||
elems *= dim_lens[i];
|
||||
*addr += 5;
|
||||
}
|
||||
|
||||
if (op->prolog == 0)
|
||||
{
|
||||
if (op->prolog == 0) {
|
||||
sprintf(p, "of Type %.5lX, Dim %ld, Size ", type, (long)dim);
|
||||
p += strlen(p);
|
||||
for (i = 0; i < dim; i++)
|
||||
{
|
||||
for (i = 0; i < dim; i++) {
|
||||
sprintf(p, "%ld", (long)dim_lens[i]);
|
||||
p += strlen(p);
|
||||
if (i < dim - 1)
|
||||
{
|
||||
if (i < dim - 1) {
|
||||
sprintf(p, " x ");
|
||||
p += strlen(p);
|
||||
}
|
||||
|
@ -904,31 +843,25 @@ char * any_array(word_20 *addr, char *string, short lnk_flag) {
|
|||
}
|
||||
|
||||
d = -1;
|
||||
while (elems--)
|
||||
{
|
||||
if (d < dim - 1)
|
||||
{
|
||||
for ( ; d < dim - 1; d++)
|
||||
{
|
||||
while (elems--) {
|
||||
if (d < dim - 1) {
|
||||
for (; d < dim - 1; d++) {
|
||||
*p++ = '[';
|
||||
}
|
||||
d = dim - 1;
|
||||
}
|
||||
if (lnk_flag)
|
||||
{
|
||||
if (lnk_flag) {
|
||||
elem_addr = read_nibbles(*addr, 5);
|
||||
elem_addr += *addr;
|
||||
*addr += 5;
|
||||
p = (*op->func)(&elem_addr, p);
|
||||
}
|
||||
else
|
||||
} else
|
||||
p = (*op->func)(addr, p);
|
||||
*p = '\0';
|
||||
dims[d]--;
|
||||
if (dims[d])
|
||||
*p++ = ' ';
|
||||
while (dims[d] == 0)
|
||||
{
|
||||
while (dims[d] == 0) {
|
||||
dims[d] = dim_lens[d];
|
||||
d--;
|
||||
dims[d]--;
|
||||
|
@ -960,12 +893,10 @@ char * dec_char(word_20 *addr, char *string) {
|
|||
*addr += 2;
|
||||
|
||||
*p++ = '\'';
|
||||
if (hp48_trans_tbl[c].trans)
|
||||
{
|
||||
if (hp48_trans_tbl[c].trans) {
|
||||
sprintf(p, hp48_trans_tbl[c].trans);
|
||||
p += strlen(p);
|
||||
}
|
||||
else
|
||||
} else
|
||||
*p++ = c;
|
||||
*p++ = '\'';
|
||||
|
||||
|
@ -987,14 +918,11 @@ short check_xlib(word_20 addr, char *string) {
|
|||
*/
|
||||
ram_base = saturn.mem_cntl[1].config[0];
|
||||
ram_mask = saturn.mem_cntl[1].config[1];
|
||||
if (opt_gx)
|
||||
{
|
||||
if (opt_gx) {
|
||||
saturn.mem_cntl[1].config[0] = 0x80000;
|
||||
saturn.mem_cntl[1].config[1] = 0xc0000;
|
||||
romptab = ROMPTAB_GX;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
saturn.mem_cntl[1].config[0] = 0x70000;
|
||||
saturn.mem_cntl[1].config[1] = 0xf0000;
|
||||
romptab = ROMPTAB_SX;
|
||||
|
@ -1011,13 +939,11 @@ fprintf(stderr, "Number of Libraries = %d\n", n);
|
|||
fflush(stderr);
|
||||
*/
|
||||
|
||||
if (n > 0)
|
||||
{
|
||||
if (n > 0) {
|
||||
/*
|
||||
* look up lib number in romptab
|
||||
*/
|
||||
while (n--)
|
||||
{
|
||||
while (n--) {
|
||||
lib = read_nibbles(romptab, 3);
|
||||
romptab += 3;
|
||||
/*
|
||||
|
@ -1034,8 +960,7 @@ fflush(stderr);
|
|||
*/
|
||||
romptab += 5;
|
||||
|
||||
if (opt_gx)
|
||||
{
|
||||
if (opt_gx) {
|
||||
acptr = read_nibbles(romptab, 5);
|
||||
romptab += 8;
|
||||
if (acptr != 0x00000)
|
||||
|
@ -1044,8 +969,7 @@ fflush(stderr);
|
|||
|
||||
lib_addr += 13;
|
||||
offset = read_nibbles(lib_addr, 5);
|
||||
if (offset > 0)
|
||||
{
|
||||
if (offset > 0) {
|
||||
/*
|
||||
* look at the link table
|
||||
*/
|
||||
|
@ -1065,8 +989,7 @@ fflush(stderr);
|
|||
* check pointer type
|
||||
*/
|
||||
type = read_nibbles(lib_addr, 5);
|
||||
if (type == DOBINT)
|
||||
{
|
||||
if (type == DOBINT) {
|
||||
/*
|
||||
* follow pointer to real address
|
||||
*/
|
||||
|
@ -1092,13 +1015,10 @@ fflush(stderr);
|
|||
*/
|
||||
lib_addr += 5;
|
||||
command = 0;
|
||||
while (lib_addr < link_end)
|
||||
{
|
||||
while (lib_addr < link_end) {
|
||||
offset = read_nibbles(lib_addr, 5);
|
||||
if (offset > 0)
|
||||
{
|
||||
if (addr == ((lib_addr + offset) & 0xfffff))
|
||||
{
|
||||
if (offset > 0) {
|
||||
if (addr == ((lib_addr + offset) & 0xfffff)) {
|
||||
p = xlib_name(lib, command, p);
|
||||
saturn.mem_cntl[1].config[0] = ram_base;
|
||||
saturn.mem_cntl[1].config[1] = ram_mask;
|
||||
|
@ -1125,7 +1045,6 @@ fflush(stderr);
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
char *dec_rpl_obj(word_20 *addr, char *string) {
|
||||
word_20 prolog = 0;
|
||||
word_20 prolog_2;
|
||||
|
@ -1135,23 +1054,17 @@ char * dec_rpl_obj(word_20 *addr, char *string) {
|
|||
|
||||
prolog = read_nibbles(*addr, 5);
|
||||
|
||||
for (op = objects; op->prolog != 0; op++)
|
||||
{
|
||||
for (op = objects; op->prolog != 0; op++) {
|
||||
if (op->prolog == prolog)
|
||||
break;
|
||||
}
|
||||
|
||||
if (op->prolog == 0)
|
||||
{
|
||||
if (check_xlib(prolog, tmp_str))
|
||||
{
|
||||
if (op->prolog == 0) {
|
||||
if (check_xlib(prolog, tmp_str)) {
|
||||
p = append_str(p, tmp_str);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
prolog_2 = read_nibbles(prolog, 5);
|
||||
for (op = objects; op->prolog != 0; op++)
|
||||
{
|
||||
for (op = objects; op->prolog != 0; op++) {
|
||||
if (op->prolog == prolog_2)
|
||||
break;
|
||||
}
|
||||
|
@ -1181,49 +1094,37 @@ void decode_rpl_obj_2(word_20 addr, char *typ, char *dat) {
|
|||
|
||||
prolog = read_nibbles(addr, 5);
|
||||
|
||||
for (op = objects; op->prolog != 0; op++)
|
||||
{
|
||||
for (op = objects; op->prolog != 0; op++) {
|
||||
if (op->prolog == prolog)
|
||||
break;
|
||||
}
|
||||
|
||||
if (op->prolog == 0)
|
||||
{
|
||||
if (addr == SEMI)
|
||||
{
|
||||
if (op->prolog == 0) {
|
||||
if (addr == SEMI) {
|
||||
append_str(typ, "Primitive Code");
|
||||
append_str(dat, "SEMI");
|
||||
}
|
||||
else if (addr + 5 == prolog)
|
||||
{
|
||||
} else if (addr + 5 == prolog) {
|
||||
append_str(typ, "Primitive Code");
|
||||
sprintf(dat, "at %.5lX", prolog);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
append_str(typ, "PTR");
|
||||
sprintf(dat, "%.5lX", prolog);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (op->prolog == DOCOL)
|
||||
{
|
||||
if (check_xlib(addr, tmp_str))
|
||||
{
|
||||
if (op->prolog == DOCOL) {
|
||||
if (check_xlib(addr, tmp_str)) {
|
||||
append_str(typ, "XLib Call");
|
||||
append_str(dat, tmp_str);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (op->length)
|
||||
{
|
||||
if (op->length) {
|
||||
len = (read_nibbles(addr + 5, 5) - 5) / op->length;
|
||||
sprintf(typ, "%s %d", op->name, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
append_str(typ, op->name);
|
||||
}
|
||||
|
||||
|
@ -1242,30 +1143,23 @@ char * decode_rpl_obj(word_20 addr, char *buf) {
|
|||
|
||||
prolog = read_nibbles(addr, 5);
|
||||
|
||||
for (op = objects; op->prolog != 0; op++)
|
||||
{
|
||||
for (op = objects; op->prolog != 0; op++) {
|
||||
if (op->prolog == prolog)
|
||||
break;
|
||||
}
|
||||
|
||||
if (op->prolog == 0)
|
||||
{
|
||||
if (addr == SEMI)
|
||||
{
|
||||
if (op->prolog == 0) {
|
||||
if (addr == SEMI) {
|
||||
p = append_str(buf, "Primitive Code");
|
||||
p = append_tab_16(buf);
|
||||
p = append_str(p, "SEMI");
|
||||
}
|
||||
else if (addr + 5 == prolog)
|
||||
{
|
||||
} else if (addr + 5 == prolog) {
|
||||
p = append_str(buf, "Primitive Code");
|
||||
p = append_tab_16(buf);
|
||||
sprintf(p, "at %.5lX", prolog);
|
||||
p += strlen(p);
|
||||
*p = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
p = append_str(buf, "PTR");
|
||||
p = append_tab_16(buf);
|
||||
sprintf(p, "%.5lX", prolog);
|
||||
|
@ -1275,10 +1169,8 @@ char * decode_rpl_obj(word_20 addr, char *buf) {
|
|||
return p;
|
||||
}
|
||||
|
||||
if (op->prolog == DOCOL)
|
||||
{
|
||||
if (check_xlib(addr, tmp_str))
|
||||
{
|
||||
if (op->prolog == DOCOL) {
|
||||
if (check_xlib(addr, tmp_str)) {
|
||||
p = append_str(buf, "XLib Call");
|
||||
p = append_tab_16(buf);
|
||||
p = append_str(p, tmp_str);
|
||||
|
@ -1288,8 +1180,7 @@ char * decode_rpl_obj(word_20 addr, char *buf) {
|
|||
|
||||
p = append_str(buf, op->name);
|
||||
|
||||
if (op->length)
|
||||
{
|
||||
if (op->length) {
|
||||
len = (read_nibbles(addr + 5, 5) - 5) / op->length;
|
||||
sprintf(p, " %d", len);
|
||||
p += strlen(p);
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
#define ROMPTAB_SX 0x707d9
|
||||
#define ROMPTAB_GX 0x809a3
|
||||
|
||||
|
||||
/*
|
||||
* Object Prologs
|
||||
*/
|
||||
|
@ -102,7 +101,8 @@ typedef struct hp_real {
|
|||
} hp_real;
|
||||
|
||||
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 *dec_rpl_obj __ProtoType__((word_20 * addr, char *string));
|
||||
|
|
165
src/serial.c
165
src/serial.c
|
@ -60,28 +60,27 @@
|
|||
* $Id: serial.c,v 1.11 1995/01/11 18:20:01 ecd Exp ecd $
|
||||
*/
|
||||
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
#if defined(HPUX) || defined(CSRG_BASED)
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#ifdef SOLARIS
|
||||
#include <sys/stream.h>
|
||||
#include <sys/stropts.h>
|
||||
#include <sys/termios.h>
|
||||
#endif
|
||||
|
||||
#include "hp48.h"
|
||||
#include "device.h"
|
||||
#include "hp48.h"
|
||||
#include "hp48_emu.h"
|
||||
#include "resources.h"
|
||||
#include "x48_x11.h"
|
||||
|
@ -98,14 +97,14 @@ static char *ir_name = (char *)0;
|
|||
/* #define DEBUG_SERIAL */
|
||||
|
||||
void update_connection_display(void) {
|
||||
if (wire_fd == -1)
|
||||
{
|
||||
if (wire_name) free(wire_name);
|
||||
if (wire_fd == -1) {
|
||||
if (wire_name)
|
||||
free(wire_name);
|
||||
wire_name = (char *)0;
|
||||
}
|
||||
if (ir_fd == -1)
|
||||
{
|
||||
if (ir_name) free(ir_name);
|
||||
if (ir_fd == -1) {
|
||||
if (ir_name)
|
||||
free(ir_name);
|
||||
ir_name = (char *)0;
|
||||
}
|
||||
ShowConnections(wire_name, ir_name);
|
||||
|
@ -120,126 +119,98 @@ int serial_init(void) {
|
|||
|
||||
wire_fd = -1;
|
||||
ttyp = -1;
|
||||
if (useTerminal)
|
||||
{
|
||||
if (useTerminal) {
|
||||
#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;
|
||||
ttyp = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((ttyp = open(p, O_RDWR | O_NDELAY, 0666)) < 0)
|
||||
{
|
||||
} else {
|
||||
if ((ttyp = open(p, O_RDWR | O_NDELAY, 0666)) < 0) {
|
||||
close(wire_fd);
|
||||
wire_fd = -1;
|
||||
ttyp = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} 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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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);
|
||||
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)
|
||||
{
|
||||
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 ((ttyp = open(tty_dev_name, O_RDWR | O_NDELAY, 0666)) >= 0) {
|
||||
if (verbose)
|
||||
printf("%s: wire connection on %s\n", progname,
|
||||
tty_dev_name);
|
||||
printf("%s: wire connection on %s\n", progname, tty_dev_name);
|
||||
wire_name = strdup(tty_dev_name);
|
||||
}
|
||||
}
|
||||
/* BSD PTY (Legacy) */
|
||||
else
|
||||
{
|
||||
else {
|
||||
c = 'p';
|
||||
do
|
||||
{
|
||||
for (n = 0; n < 16; n++)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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);
|
||||
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));
|
||||
} while ((wire_fd < 0) && (errno != ENOENT));
|
||||
}
|
||||
#else
|
||||
/*
|
||||
* Here we go for SUNOS, HPUX
|
||||
*/
|
||||
c = 'p';
|
||||
do
|
||||
{
|
||||
for (n = 0; n < 16; n++)
|
||||
{
|
||||
do {
|
||||
for (n = 0; n < 16; n++) {
|
||||
sprintf(tty_dev_name, "/dev/ptyp%x", n);
|
||||
if ((wire_fd = open(tty_dev_name,
|
||||
O_RDWR | O_EXCL | O_NDELAY, 0666)) >= 0)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if ((ttyp = open(tty_dev_name, O_RDWR | O_NDELAY, 0666)) < 0) {
|
||||
wire_fd = -1;
|
||||
ttyp = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (verbose)
|
||||
printf("%s: wire connection on %s\n", progname,
|
||||
tty_dev_name);
|
||||
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));
|
||||
} while ((wire_fd < 0) && (errno != ENOENT));
|
||||
#endif
|
||||
}
|
||||
|
||||
if (ttyp >= 0)
|
||||
{
|
||||
if (ttyp >= 0) {
|
||||
#if defined(TCSANOW)
|
||||
if (tcgetattr(ttyp, &ttybuf) < 0)
|
||||
#else
|
||||
|
@ -263,8 +234,7 @@ int serial_init(void) {
|
|||
ttybuf.c_cc[VTIME] = 0;
|
||||
ttybuf.c_cc[VMIN] = 1;
|
||||
|
||||
if (ttyp >= 0)
|
||||
{
|
||||
if (ttyp >= 0) {
|
||||
#if defined(TCSANOW)
|
||||
if (tcsetattr(ttyp, TCSANOW, &ttybuf) < 0)
|
||||
#else
|
||||
|
@ -280,19 +250,16 @@ int serial_init(void) {
|
|||
}
|
||||
|
||||
ir_fd = -1;
|
||||
if (useSerial)
|
||||
{
|
||||
if (useSerial) {
|
||||
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);
|
||||
ir_name = strdup(tty_dev_name);
|
||||
}
|
||||
}
|
||||
|
||||
if (ir_fd >= 0)
|
||||
{
|
||||
if (ir_fd >= 0) {
|
||||
#if defined(TCSANOW)
|
||||
if (tcgetattr(ir_fd, &ttybuf) < 0)
|
||||
#else
|
||||
|
@ -300,8 +267,8 @@ int serial_init(void) {
|
|||
#endif
|
||||
{
|
||||
if (!quiet)
|
||||
fprintf(stderr, "%s: ioctl(IR, TCGETS) failed, errno = %d\n",
|
||||
progname, errno);
|
||||
fprintf(stderr, "%s: ioctl(IR, TCGETS) failed, errno = %d\n", progname,
|
||||
errno);
|
||||
ir_fd = -1;
|
||||
}
|
||||
}
|
||||
|
@ -315,8 +282,7 @@ int serial_init(void) {
|
|||
ttybuf.c_cc[VTIME] = 0;
|
||||
ttybuf.c_cc[VMIN] = 1;
|
||||
|
||||
if (ir_fd >= 0)
|
||||
{
|
||||
if (ir_fd >= 0) {
|
||||
#if defined(TCSANOW)
|
||||
if (tcsetattr(ir_fd, TCSANOW, &ttybuf) < 0)
|
||||
#else
|
||||
|
@ -324,8 +290,8 @@ int serial_init(void) {
|
|||
#endif
|
||||
{
|
||||
if (!quiet)
|
||||
fprintf(stderr, "%s: ioctl(IR, TCSETS) failed, errno = %d\n",
|
||||
progname, errno);
|
||||
fprintf(stderr, "%s: ioctl(IR, TCSETS) failed, errno = %d\n", progname,
|
||||
errno);
|
||||
ir_fd = -1;
|
||||
}
|
||||
}
|
||||
|
@ -337,8 +303,7 @@ void serial_baud(int baud) {
|
|||
int error = 0;
|
||||
struct termios ttybuf;
|
||||
|
||||
if (ir_fd >= 0)
|
||||
{
|
||||
if (ir_fd >= 0) {
|
||||
#if defined(TCSANOW)
|
||||
if (tcgetattr(ir_fd, &ttybuf) < 0)
|
||||
#else
|
||||
|
@ -346,8 +311,8 @@ void serial_baud(int baud) {
|
|||
#endif
|
||||
{
|
||||
if (!quiet)
|
||||
fprintf(stderr, "%s: ioctl(IR, TCGETS) failed, errno = %d\n",
|
||||
progname, errno);
|
||||
fprintf(stderr, "%s: ioctl(IR, TCGETS) failed, errno = %d\n", progname,
|
||||
errno);
|
||||
ir_fd = -1;
|
||||
error = 1;
|
||||
}
|
||||
|
@ -355,8 +320,7 @@ void serial_baud(int baud) {
|
|||
|
||||
#if defined(__APPLE__)
|
||||
baud &= 0x7;
|
||||
switch (baud)
|
||||
{
|
||||
switch (baud) {
|
||||
case 0: /* 1200 */
|
||||
ttybuf.c_cflag |= B1200;
|
||||
break;
|
||||
|
@ -391,8 +355,7 @@ void serial_baud(int baud) {
|
|||
break;
|
||||
}
|
||||
|
||||
if ((ir_fd >= 0) && ((ttybuf.c_ospeed) == 0))
|
||||
{
|
||||
if ((ir_fd >= 0) && ((ttybuf.c_ospeed) == 0)) {
|
||||
if (!quiet)
|
||||
fprintf(stderr, "%s: can\'t set baud rate, using 9600\n", progname);
|
||||
ttybuf.c_cflag |= B9600;
|
||||
|
@ -401,8 +364,7 @@ void serial_baud(int baud) {
|
|||
ttybuf.c_cflag &= ~CBAUD;
|
||||
|
||||
baud &= 0x7;
|
||||
switch (baud)
|
||||
{
|
||||
switch (baud) {
|
||||
case 0: /* 1200 */
|
||||
ttybuf.c_cflag |= B1200;
|
||||
break;
|
||||
|
@ -437,15 +399,13 @@ void serial_baud(int baud) {
|
|||
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 (ir_fd >= 0) {
|
||||
#if defined(TCSANOW)
|
||||
if (tcsetattr(ir_fd, TCSANOW, &ttybuf) < 0)
|
||||
#else
|
||||
|
@ -453,15 +413,14 @@ void serial_baud(int baud) {
|
|||
#endif
|
||||
{
|
||||
if (!quiet)
|
||||
fprintf(stderr, "%s: ioctl(IR, TCSETS) failed, errno = %d\n",
|
||||
progname, errno);
|
||||
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 (tcgetattr(ttyp, &ttybuf) < 0)
|
||||
#else
|
||||
|
@ -482,8 +441,7 @@ void serial_baud(int baud) {
|
|||
ttybuf.c_cflag &= ~CBAUD;
|
||||
|
||||
baud &= 0x7;
|
||||
switch (baud)
|
||||
{
|
||||
switch (baud) {
|
||||
case 0: /* 1200 */
|
||||
ttybuf.c_cflag |= B1200;
|
||||
break;
|
||||
|
@ -518,15 +476,13 @@ void serial_baud(int baud) {
|
|||
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 (ttyp >= 0) {
|
||||
#if defined(TCSANOW)
|
||||
if (tcsetattr(ttyp, TCSANOW, &ttybuf) < 0)
|
||||
#else
|
||||
|
@ -545,7 +501,6 @@ void serial_baud(int baud) {
|
|||
update_connection_display();
|
||||
}
|
||||
|
||||
|
||||
void transmit_char(void) {
|
||||
#ifdef DEBUG_SERIALx
|
||||
fprintf(stderr, "XMT %s\n", (saturn.ir_ctrl & 0x04) ? "IR" : "wire");
|
||||
|
|
|
@ -323,7 +323,6 @@ letter_t small_font[] = {
|
|||
{0, 0, 0},
|
||||
{rcurly_width, rcurly_height, rcurly_bits},
|
||||
{0, 0, 0},
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
{0, 0, 0}};
|
||||
|
||||
#endif /* !_SMALL_H */
|
||||
|
|
68
src/timer.c
68
src/timer.c
|
@ -40,14 +40,14 @@
|
|||
|
||||
#include "global.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "timer.h"
|
||||
#include "debugger.h"
|
||||
#include "romio.h"
|
||||
#include "timer.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -157,8 +157,7 @@ void set_accesstime(void) {
|
|||
ticks += time_offset;
|
||||
|
||||
timer2 = saturn.timer2;
|
||||
if (saturn.timer2 & 0x80000000)
|
||||
{
|
||||
if (saturn.timer2 & 0x80000000) {
|
||||
assert(timer2 < 0);
|
||||
}
|
||||
|
||||
|
@ -168,39 +167,33 @@ void set_accesstime(void) {
|
|||
|
||||
crc = 0x0;
|
||||
|
||||
if (opt_gx)
|
||||
{
|
||||
if (opt_gx) {
|
||||
accesstime_loc = ACCESSTIME_GX;
|
||||
accesscrc_loc = ACCESSCRC_GX;
|
||||
timeout_loc = TIMEOUT_GX;
|
||||
timeoutclk_loc = TIMEOUTCLK_GX;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
accesstime_loc = ACCESSTIME_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;
|
||||
calc_crc(val);
|
||||
saturn.ram[accesstime_loc + i] = val;
|
||||
ticks >>= 4;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
for (i = 0; i < 4; i++) {
|
||||
saturn.ram[accesscrc_loc + i] = crc & 0xf;
|
||||
crc >>= 4;
|
||||
}
|
||||
|
||||
timeout += ticks_10_min;
|
||||
|
||||
for (i = 0; i < 13; i++)
|
||||
{
|
||||
for (i = 0; i < 13; i++) {
|
||||
val = timeout & 0xf;
|
||||
calc_crc(val);
|
||||
saturn.ram[timeout_loc + i] = val;
|
||||
|
@ -237,7 +230,8 @@ void start_timer(int timer) {
|
|||
timers[timer].start += (tv.tv_usec << 7) / 15625;
|
||||
}
|
||||
#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
|
||||
}
|
||||
|
||||
|
@ -271,8 +265,7 @@ void restart_timer(int timer) {
|
|||
timers[timer].start += (tv.tv_usec << 7) / 15625;
|
||||
}
|
||||
#ifdef DEBUG_TIMER
|
||||
fprintf(stderr, "Timer[%d] restart at 0x%lx\n", timer,
|
||||
timers[timer].start);
|
||||
fprintf(stderr, "Timer[%d] restart at 0x%lx\n", timer, timers[timer].start);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -306,11 +299,12 @@ void stop_timer(int timer) {
|
|||
}
|
||||
|
||||
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
|
||||
fprintf(stderr, "Timer[%d] stop at 0x%llx, value 0x%llx\n",
|
||||
timer, timers[timer].stop, timers[timer].value);
|
||||
fprintf(stderr, "Timer[%d] stop at 0x%llx, value 0x%llx\n", timer,
|
||||
timers[timer].stop, timers[timer].value);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -393,12 +387,10 @@ t1_t2_ticks get_t1_t2(void) {
|
|||
#endif
|
||||
tv.tv_sec -= systime_offset;
|
||||
|
||||
if (timers[T1_TIMER].run)
|
||||
{
|
||||
if (timers[T1_TIMER].run) {
|
||||
stop = (tv.tv_sec << 9);
|
||||
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 {
|
||||
fprintf(stderr, "clock running backwards\n");
|
||||
|
@ -416,32 +408,27 @@ t1_t2_ticks get_t1_t2(void) {
|
|||
|
||||
access_time = 0x0;
|
||||
|
||||
for (i = 13 - 1; i >= 0; i--)
|
||||
{
|
||||
for (i = 13 - 1; i >= 0; i--) {
|
||||
access_time <<= 4;
|
||||
access_time |= ((int)saturn.ram[accesstime_loc + i] & 0xf);
|
||||
}
|
||||
|
||||
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
|
||||
* or we are sleeping in the debugger.
|
||||
* Don't adjust the time, can't come from user, anyhow.
|
||||
*/
|
||||
|
||||
if ((saturn.timer2 >= 0 && access_time < 0)
|
||||
|| ((unsigned long)saturn.timer2 > access_time))
|
||||
{
|
||||
if ((saturn.timer2 >= 0 && access_time < 0) ||
|
||||
((unsigned long)saturn.timer2 > access_time)) {
|
||||
/*
|
||||
* check OK, return calculated time
|
||||
*/
|
||||
ticks.t2_ticks = access_time;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/*
|
||||
* Don't increment timer2, return old value and
|
||||
* slow down timer2.
|
||||
|
@ -473,16 +460,13 @@ t1_t2_ticks get_t1_t2(void) {
|
|||
#endif
|
||||
}
|
||||
|
||||
if ((saturn.timer2 >= 0 && (access_time < 0))
|
||||
|| ((unsigned long)saturn.timer2 > access_time))
|
||||
{
|
||||
if ((saturn.timer2 >= 0 && (access_time < 0)) ||
|
||||
((unsigned long)saturn.timer2 > access_time)) {
|
||||
/*
|
||||
* check OK, return calculated time
|
||||
*/
|
||||
ticks.t2_ticks = access_time;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/*
|
||||
* Don't increment timer2, return old value and
|
||||
* slow down timer2.
|
||||
|
|
1834
src/x48_x11.c
1834
src/x48_x11.c
File diff suppressed because it is too large
Load diff
|
@ -65,9 +65,9 @@
|
|||
|
||||
#include <X11/Xlib.h>
|
||||
#ifdef HAVE_XSHM
|
||||
#include <X11/extensions/XShm.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <X11/extensions/XShm.h>
|
||||
#endif
|
||||
|
||||
#define WHITE 0
|
||||
|
|
Loading…
Reference in a new issue