libx48ng/src/hp48.h

293 lines
5.6 KiB
C
Raw Normal View History

/*
* This file is part of x48, an emulator of the HP-48sx Calculator.
* Copyright (C) 1994 Eddie C. Dost (ecd@dressler.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Log: hp48.h,v $
* Revision 1.11 1995/01/11 18:20:01 ecd
* major update to support HP48 G/GX
*
* Revision 1.10 1994/11/28 02:19:22 ecd
* added function serial_baud()
*
* Revision 1.10 1994/11/28 02:19:22 ecd
* added function serial_baud()
*
* Revision 1.9 1994/11/02 14:51:27 ecd
* minor changes
*
* Revision 1.8 1994/10/09 20:26:35 ecd
* changed display_t: display.skip --> display.nibs_per_line
*
* Revision 1.7 1994/10/05 08:33:22 ecd
* added do_interupt definition
*
* Revision 1.6 1994/09/30 12:32:49 ecd
* added some fields for REALTIME support,
* added Scheduler stuff
*
* Revision 1.5 1994/09/18 15:31:58 ecd
* started Real Time support
*
* Revision 1.4 1994/09/13 16:58:42 ecd
* changed to plain X11
*
* Revision 1.3 1994/08/31 18:25:23 ecd
* added read_nibble_crc
*
* Revision 1.2 1994/08/27 11:29:48 ecd
* changed keyboard interrupt handling.
*
* Revision 1.1 1994/08/26 11:09:18 ecd
* Initial revision
*
*
*
* $Id: hp48.h,v 1.11 1995/01/11 18:20:01 ecd Exp ecd $
*/
#ifndef _HP48_H
#define _HP48_H 1
#include "global.h"
#include <sys/time.h>
#include "mmu.h"
2022-03-24 13:41:22 +01:00
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#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;
2022-03-24 13:41:22 +01:00
#ifdef HAVE_STDINT_H
#define SIMPLE_64
typedef int64_t word_64;
#else
typedef struct word_64 {
2023-04-27 12:15:59 +02:00
unsigned long hi, lo;
} word_64;
#endif
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;
2023-04-27 12:15:59 +02:00
short bank_switch;
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
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;
2023-04-27 12:30:36 +02:00
extern void init_display( void );
2022-03-24 13:41:22 +01:00
extern saturn_t saturn;
2023-04-27 12:30:36 +02:00
extern int exit_emulator( void );
extern int init_emulator( void );
extern void init_active_stuff( void );
2023-04-27 12:30:36 +02:00
extern int serial_init( void );
extern void serial_baud( int baud );
extern void transmit_char( void );
extern void receive_char( void );
2023-04-27 12:30:36 +02:00
extern void do_kbd_int( void );
extern void do_interupt( void );
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 );
2023-04-27 12:30:36 +02:00
extern int emulate( void );
extern int step_instruction( void );
extern void schedule( void );
2023-04-27 12:30:36 +02:00
extern int read_rom( const char* fname );
extern int read_files( void );
extern int write_files( void );
2023-04-27 12:30:36 +02:00
extern void load_addr( word_20* dat, long addr, int n );
#endif /* !_HP48_H */