libx48ng/src/hp48.h

231 lines
3.8 KiB
C
Raw Normal View History

#ifndef _HP48_H
#define _HP48_H 1
2023-04-28 14:06:51 +02:00
#include "config.h"
#include <sys/time.h>
#include "mmu.h"
2022-03-24 13:41:22 +01:00
#include <stdint.h>
#define RAM_SIZE_SX 0x10000
#define RAM_SIZE_GX 0x40000
2022-03-24 13:41:22 +01:00
#define P_FIELD 0
#define WP_FIELD 1
#define XS_FIELD 2
#define X_FIELD 3
#define S_FIELD 4
#define M_FIELD 5
#define B_FIELD 6
#define W_FIELD 7
#define A_FIELD 15
#define IN_FIELD 16
#define OUT_FIELD 17
#define OUTS_FIELD 18
#define DEC 10
#define HEX 16
#define NR_RSTK 8
#define NR_PSTAT 16
typedef unsigned char word_1;
typedef unsigned char word_4;
typedef unsigned char word_8;
typedef unsigned short word_12;
typedef unsigned short word_16;
2022-03-24 13:41:22 +01:00
typedef long word_20;
typedef long word_32;
#define SIMPLE_64
typedef int64_t word_64;
typedef struct keystate_t {
2023-04-27 12:15:59 +02:00
short rows[ 9 ];
} keystate_t;
typedef struct display_t {
2023-04-27 12:15:59 +02:00
int on;
2023-04-27 12:15:59 +02:00
long disp_start;
long disp_end;
2023-04-27 12:15:59 +02:00
int offset;
int lines;
int nibs_per_line;
2023-04-27 12:15:59 +02:00
int contrast;
2023-04-27 12:15:59 +02:00
long menu_start;
long menu_end;
2023-04-27 12:15:59 +02:00
int annunc;
} display_t;
typedef struct mem_cntl_t {
2023-04-27 12:15:59 +02:00
unsigned short unconfigured;
word_20 config[ 2 ];
} mem_cntl_t;
typedef struct saturn_t {
2023-04-27 12:15:59 +02:00
unsigned long magic;
char version[ 4 ];
2023-04-27 12:15:59 +02:00
unsigned char A[ 16 ], B[ 16 ], C[ 16 ], D[ 16 ];
2023-04-27 12:15:59 +02:00
word_20 d[ 2 ];
2023-04-27 12:15:59 +02:00
#define D0 d[ 0 ]
#define D1 d[ 1 ]
2023-04-27 12:15:59 +02:00
word_4 P;
word_20 PC;
2023-04-27 12:15:59 +02:00
unsigned char R0[ 16 ], R1[ 16 ], R2[ 16 ], R3[ 16 ], R4[ 16 ];
unsigned char IN[ 4 ];
unsigned char OUT[ 3 ];
2023-04-27 12:15:59 +02:00
word_1 CARRY;
2023-04-27 12:15:59 +02:00
unsigned char PSTAT[ NR_PSTAT ];
unsigned char XM, SB, SR, MP;
2023-04-27 12:15:59 +02:00
word_4 hexmode;
2023-04-27 12:15:59 +02:00
word_20 rstk[ NR_RSTK ];
short rstkp;
2023-04-27 12:15:59 +02:00
keystate_t keybuf;
2023-04-27 12:15:59 +02:00
unsigned char intenable;
unsigned char int_pending;
unsigned char kbd_ien;
2023-04-27 12:15:59 +02:00
word_4 disp_io;
2023-04-27 12:15:59 +02:00
word_4 contrast_ctrl;
word_8 disp_test;
2023-04-27 12:15:59 +02:00
word_16 crc;
2023-04-27 12:15:59 +02:00
word_4 power_status;
word_4 power_ctrl;
2023-04-27 12:15:59 +02:00
word_4 mode;
2023-04-27 12:15:59 +02:00
word_8 annunc;
2023-04-27 12:15:59 +02:00
word_4 baud;
2023-04-27 12:15:59 +02:00
word_4 card_ctrl;
word_4 card_status;
2023-04-27 12:15:59 +02:00
word_4 io_ctrl;
word_4 rcs;
word_4 tcs;
2023-04-27 12:15:59 +02:00
word_8 rbr;
word_8 tbr;
2023-04-27 12:15:59 +02:00
word_8 sreq;
2023-04-27 12:15:59 +02:00
word_4 ir_ctrl;
2023-04-27 12:15:59 +02:00
word_4 base_off;
2023-04-27 12:15:59 +02:00
word_4 lcr;
word_4 lbr;
2023-04-27 12:15:59 +02:00
word_4 scratch;
2023-04-27 12:15:59 +02:00
word_4 base_nibble;
2023-04-27 12:15:59 +02:00
word_20 disp_addr;
word_12 line_offset;
word_8 line_count;
2023-04-27 12:15:59 +02:00
word_16 unknown;
2023-04-27 12:15:59 +02:00
word_4 t1_ctrl;
word_4 t2_ctrl;
2023-04-27 12:15:59 +02:00
word_20 menu_addr;
2023-04-27 12:15:59 +02:00
word_8 unknown2;
2023-04-27 12:15:59 +02:00
char timer1; /* may NOT be unsigned !!! */
word_32 timer2;
2023-04-27 12:15:59 +02:00
long t1_instr;
long t2_instr;
2023-04-27 12:15:59 +02:00
short t1_tick;
short t2_tick;
long i_per_s;
word_16 bank_switch;
2023-04-27 12:15:59 +02:00
mem_cntl_t mem_cntl[ NR_MCTL ];
2023-04-27 12:15:59 +02:00
unsigned char* rom;
unsigned char* ram;
unsigned char* port1;
unsigned char* port2;
} saturn_t;
#define NIBBLES_PER_ROW 0x22
#if defined( GUI_IS_SDL1 )
#define DISP_ROWS 64
#define NIBS_PER_BUFFER_ROW ( NIBBLES_PER_ROW + 2 )
extern unsigned char disp_buf[ DISP_ROWS ][ NIBS_PER_BUFFER_ROW ];
extern unsigned char lcd_buffer[ DISP_ROWS ][ NIBS_PER_BUFFER_ROW ];
#endif
2022-03-24 13:41:22 +01:00
extern int got_alarm;
2022-03-24 13:41:22 +01:00
extern int set_t1;
extern long sched_timer1;
extern long sched_timer2;
2022-03-24 13:41:22 +01:00
extern int adj_time_pending;
extern long sched_adjtime;
extern long schedule_event;
2022-03-24 13:41:22 +01:00
extern display_t display;
extern void init_display();
2022-03-24 13:41:22 +01:00
extern saturn_t saturn;
extern int exit_emulator();
extern int init_emulator();
extern void init_active_stuff();
extern int serial_init();
2023-04-27 12:30:36 +02:00
extern void serial_baud( int baud );
extern void transmit_char();
extern void receive_char();
extern void do_kbd_int();
extern void do_interupt();
2023-04-27 12:30:36 +02:00
extern void ( *write_nibble )( long addr, int val );
extern int ( *read_nibble )( long addr );
extern int ( *read_nibble_crc )( long addr );
extern int emulate();
extern int step_instruction();
extern void schedule();
2023-04-27 12:30:36 +02:00
extern int read_rom( const char* fname );
extern int read_files();
extern int write_files();
2023-04-27 12:30:36 +02:00
extern void load_addr( word_20* dat, long addr, int n );
#endif /* !_HP48_H */