drop support of loading pre-0.4.0 state files (~/.x48ng/hp48)
This commit is contained in:
parent
5a16dc9318
commit
48dfffc7a1
1 changed files with 13 additions and 649 deletions
662
src/hp48_init.c
662
src/hp48_init.c
|
@ -25,145 +25,6 @@ long port2_size;
|
|||
long port2_mask;
|
||||
short port2_is_ram;
|
||||
|
||||
typedef struct old_keystate_t {
|
||||
int rows[ 9 ];
|
||||
} old_keystate_t;
|
||||
|
||||
typedef struct old_saturn_t {
|
||||
unsigned char A[ 16 ], B[ 16 ], C[ 16 ], D[ 16 ];
|
||||
long d[ 2 ];
|
||||
int P;
|
||||
long PC;
|
||||
unsigned char R0[ 16 ], R1[ 16 ], R2[ 16 ], R3[ 16 ], R4[ 16 ];
|
||||
unsigned char IN[ 4 ];
|
||||
unsigned char OUT[ 3 ];
|
||||
int CARRY;
|
||||
unsigned char PSTAT[ NR_PSTAT ];
|
||||
unsigned char XM, SB, SR, MP;
|
||||
unsigned char hexmode;
|
||||
long rstk[ NR_RSTK ];
|
||||
short rstkp;
|
||||
old_keystate_t keybuf;
|
||||
unsigned char intenable;
|
||||
unsigned char int_pending;
|
||||
unsigned char kbd_ien;
|
||||
long configs[ NR_CONFIG ];
|
||||
short daisy_state;
|
||||
long ram32k;
|
||||
long devices;
|
||||
unsigned char disp_io;
|
||||
unsigned char contrast_ctrl;
|
||||
unsigned char disp_test;
|
||||
unsigned int crc;
|
||||
unsigned char power_status;
|
||||
unsigned char power_ctrl;
|
||||
unsigned char mode;
|
||||
unsigned char annunc;
|
||||
unsigned char baud;
|
||||
unsigned char card_ctrl;
|
||||
unsigned char card_status;
|
||||
unsigned char io_ctrl;
|
||||
unsigned char rcs;
|
||||
unsigned char tcs;
|
||||
unsigned char rbr;
|
||||
unsigned char tbr;
|
||||
unsigned char sreq;
|
||||
unsigned char ir_ctrl;
|
||||
unsigned char base_off;
|
||||
unsigned char lcr;
|
||||
unsigned char lbr;
|
||||
unsigned char scratch;
|
||||
unsigned char base_nibble;
|
||||
long disp_addr;
|
||||
long line_offset;
|
||||
long line_count;
|
||||
long unknown;
|
||||
unsigned char t1_ctrl;
|
||||
unsigned char t2_ctrl;
|
||||
long menu_addr;
|
||||
long unknown2;
|
||||
int timer1;
|
||||
long timer2;
|
||||
long t1_instr;
|
||||
long t2_instr;
|
||||
unsigned char* rom;
|
||||
unsigned char* ram;
|
||||
unsigned char* port1;
|
||||
unsigned char* port2;
|
||||
} old_saturn_t;
|
||||
|
||||
old_saturn_t old_saturn;
|
||||
|
||||
typedef struct saturn_0_3_0_t {
|
||||
unsigned long magic;
|
||||
char version[ 4 ];
|
||||
unsigned char A[ 16 ], B[ 16 ], C[ 16 ], D[ 16 ];
|
||||
word_20 d[ 2 ];
|
||||
word_4 P;
|
||||
word_20 PC;
|
||||
unsigned char R0[ 16 ], R1[ 16 ], R2[ 16 ], R3[ 16 ], R4[ 16 ];
|
||||
unsigned char IN[ 4 ];
|
||||
unsigned char OUT[ 3 ];
|
||||
word_1 CARRY;
|
||||
unsigned char PSTAT[ NR_PSTAT ];
|
||||
unsigned char XM, SB, SR, MP;
|
||||
word_4 hexmode;
|
||||
word_20 rstk[ NR_RSTK ];
|
||||
short rstkp;
|
||||
keystate_t keybuf;
|
||||
unsigned char intenable;
|
||||
unsigned char int_pending;
|
||||
unsigned char kbd_ien;
|
||||
word_20 configs[ NR_CONFIG ];
|
||||
word_16 daisy_state;
|
||||
word_20 ram32k;
|
||||
word_20 devices;
|
||||
word_4 disp_io;
|
||||
word_4 contrast_ctrl;
|
||||
word_8 disp_test;
|
||||
word_16 crc;
|
||||
word_4 power_status;
|
||||
word_4 power_ctrl;
|
||||
word_4 mode;
|
||||
word_8 annunc;
|
||||
word_4 baud;
|
||||
word_4 card_ctrl;
|
||||
word_4 card_status;
|
||||
word_4 io_ctrl;
|
||||
word_4 rcs;
|
||||
word_4 tcs;
|
||||
word_8 rbr;
|
||||
word_8 tbr;
|
||||
word_8 sreq;
|
||||
word_4 ir_ctrl;
|
||||
word_4 base_off;
|
||||
word_4 lcr;
|
||||
word_4 lbr;
|
||||
word_4 scratch;
|
||||
word_4 base_nibble;
|
||||
word_20 disp_addr;
|
||||
word_12 line_offset;
|
||||
word_8 line_count;
|
||||
word_16 unknown;
|
||||
word_4 t1_ctrl;
|
||||
word_4 t2_ctrl;
|
||||
word_20 menu_addr;
|
||||
word_8 unknown2;
|
||||
char timer1;
|
||||
word_32 timer2;
|
||||
long t1_instr;
|
||||
long t2_instr;
|
||||
short t1_tick;
|
||||
short t2_tick;
|
||||
long i_per_s;
|
||||
unsigned char* rom;
|
||||
unsigned char* ram;
|
||||
unsigned char* port1;
|
||||
unsigned char* port2;
|
||||
} saturn_0_3_0_t;
|
||||
|
||||
saturn_0_3_0_t saturn_0_3_0;
|
||||
|
||||
void saturn_config_init( void ) {
|
||||
saturn.version[ 0 ] = VERSION_MAJOR;
|
||||
saturn.version[ 1 ] = VERSION_MINOR;
|
||||
|
@ -213,273 +74,6 @@ void init_saturn( void ) {
|
|||
dev_memory_init();
|
||||
}
|
||||
|
||||
void copy_old_saturn( old_saturn_t* old, saturn_t* newt ) {
|
||||
int i;
|
||||
|
||||
memcpy( &( newt->A[ 0 ] ), &( old->A[ 0 ] ), 16 );
|
||||
memcpy( &( newt->B[ 0 ] ), &( old->B[ 0 ] ), 16 );
|
||||
memcpy( &( newt->C[ 0 ] ), &( old->C[ 0 ] ), 16 );
|
||||
memcpy( &( newt->D[ 0 ] ), &( old->D[ 0 ] ), 16 );
|
||||
newt->d[ 0 ] = old->d[ 0 ];
|
||||
newt->d[ 1 ] = old->d[ 1 ];
|
||||
newt->P = old->P;
|
||||
newt->PC = old->PC;
|
||||
memcpy( &( newt->R0[ 0 ] ), &( old->R0[ 0 ] ), 16 );
|
||||
memcpy( &( newt->R1[ 0 ] ), &( old->R1[ 0 ] ), 16 );
|
||||
memcpy( &( newt->R2[ 0 ] ), &( old->R2[ 0 ] ), 16 );
|
||||
memcpy( &( newt->R3[ 0 ] ), &( old->R3[ 0 ] ), 16 );
|
||||
memcpy( &( newt->R4[ 0 ] ), &( old->R4[ 0 ] ), 16 );
|
||||
memcpy( &( newt->IN[ 0 ] ), &( old->IN[ 0 ] ), 4 );
|
||||
memcpy( &( newt->OUT[ 0 ] ), &( old->OUT[ 0 ] ), 3 );
|
||||
newt->CARRY = old->CARRY;
|
||||
memcpy( &( newt->PSTAT[ 0 ] ), &( old->PSTAT[ 0 ] ), NR_PSTAT );
|
||||
newt->XM = old->XM;
|
||||
newt->SB = old->SB;
|
||||
newt->SR = old->SR;
|
||||
newt->MP = old->MP;
|
||||
newt->hexmode = old->hexmode;
|
||||
memcpy( &( newt->rstk[ 0 ] ), &( old->rstk[ 0 ] ),
|
||||
NR_RSTK * sizeof( word_20 ) );
|
||||
newt->rstkp = old->rstkp;
|
||||
for ( i = 0; i < 9; i++ ) {
|
||||
newt->keybuf.rows[ i ] = old->keybuf.rows[ i ];
|
||||
}
|
||||
newt->intenable = old->intenable;
|
||||
newt->int_pending = old->int_pending;
|
||||
newt->kbd_ien = old->kbd_ien;
|
||||
newt->disp_io = old->disp_io;
|
||||
newt->contrast_ctrl = old->contrast_ctrl;
|
||||
newt->disp_test = old->disp_test;
|
||||
newt->crc = old->crc;
|
||||
newt->power_status = old->power_status;
|
||||
newt->power_ctrl = old->power_ctrl;
|
||||
newt->mode = old->mode;
|
||||
newt->annunc = old->annunc;
|
||||
newt->baud = old->baud;
|
||||
newt->card_ctrl = old->card_ctrl;
|
||||
newt->card_status = old->card_status;
|
||||
newt->io_ctrl = old->io_ctrl;
|
||||
newt->rcs = old->rcs;
|
||||
newt->tcs = old->tcs;
|
||||
newt->rbr = old->rbr;
|
||||
newt->tbr = old->tbr;
|
||||
newt->sreq = old->sreq;
|
||||
newt->ir_ctrl = old->ir_ctrl;
|
||||
newt->base_off = old->base_off;
|
||||
newt->lcr = old->lcr;
|
||||
newt->lbr = old->lbr;
|
||||
newt->scratch = old->scratch;
|
||||
newt->base_nibble = old->base_nibble;
|
||||
newt->disp_addr = old->disp_addr;
|
||||
newt->line_offset = old->line_offset;
|
||||
newt->line_count = old->line_count;
|
||||
newt->unknown = old->unknown;
|
||||
newt->t1_ctrl = old->t1_ctrl;
|
||||
newt->t2_ctrl = old->t2_ctrl;
|
||||
newt->menu_addr = old->menu_addr;
|
||||
newt->unknown2 = old->unknown2;
|
||||
newt->timer1 = old->timer1;
|
||||
newt->timer2 = old->timer2;
|
||||
newt->t1_instr = old->t1_instr;
|
||||
newt->t2_instr = old->t2_instr;
|
||||
newt->bank_switch = 0;
|
||||
if ( opt_gx ) {
|
||||
newt->mem_cntl[ 0 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 0 ].config[ 0 ] = 0x00100;
|
||||
newt->mem_cntl[ 1 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 1 ].config[ 0 ] = 0x80000;
|
||||
newt->mem_cntl[ 1 ].config[ 1 ] = 0xc0000;
|
||||
newt->mem_cntl[ 2 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 2 ].config[ 0 ] = 0x7f000;
|
||||
newt->mem_cntl[ 2 ].config[ 1 ] = 0xff000;
|
||||
newt->mem_cntl[ 3 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 3 ].config[ 0 ] = 0xc0000;
|
||||
newt->mem_cntl[ 3 ].config[ 1 ] = 0xc0000;
|
||||
newt->mem_cntl[ 4 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 4 ].config[ 0 ] = 0xc0000;
|
||||
newt->mem_cntl[ 4 ].config[ 1 ] = 0xc0000;
|
||||
newt->mem_cntl[ 5 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 5 ].config[ 0 ] = 0x00000;
|
||||
newt->mem_cntl[ 5 ].config[ 1 ] = 0x00000;
|
||||
} else {
|
||||
if ( old->devices == 0x100 ) {
|
||||
newt->mem_cntl[ 0 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 0 ].config[ 0 ] = old->devices;
|
||||
} else {
|
||||
newt->mem_cntl[ 0 ].unconfigured = 1;
|
||||
newt->mem_cntl[ 0 ].config[ 0 ] = 0x00000;
|
||||
}
|
||||
if ( old->ram32k == 0x70000 ) {
|
||||
newt->mem_cntl[ 1 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 1 ].config[ 0 ] = 0x70000;
|
||||
newt->mem_cntl[ 1 ].config[ 1 ] = 0xf0000;
|
||||
} else if ( old->ram32k == 0xf0000 ) {
|
||||
newt->mem_cntl[ 1 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 1 ].config[ 0 ] = 0xf0000;
|
||||
newt->mem_cntl[ 1 ].config[ 1 ] = 0xf0000;
|
||||
} else if ( old->ram32k == 0xfc000 ) {
|
||||
newt->mem_cntl[ 1 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 1 ].config[ 0 ] = 0x70000;
|
||||
newt->mem_cntl[ 1 ].config[ 1 ] = 0xfc000;
|
||||
} else if ( old->ram32k == 0xfe000 ) {
|
||||
newt->mem_cntl[ 1 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 1 ].config[ 0 ] = 0x70000;
|
||||
newt->mem_cntl[ 1 ].config[ 1 ] = 0xfe000;
|
||||
} else {
|
||||
newt->mem_cntl[ 1 ].unconfigured = 2;
|
||||
newt->mem_cntl[ 1 ].config[ 0 ] = 0x00000;
|
||||
newt->mem_cntl[ 1 ].config[ 1 ] = 0x00000;
|
||||
}
|
||||
newt->mem_cntl[ 2 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 2 ].config[ 0 ] = 0x80000;
|
||||
newt->mem_cntl[ 2 ].config[ 1 ] = 0xc0000;
|
||||
newt->mem_cntl[ 3 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 3 ].config[ 0 ] = 0xc0000;
|
||||
newt->mem_cntl[ 3 ].config[ 1 ] = 0xc0000;
|
||||
newt->mem_cntl[ 4 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 4 ].config[ 0 ] = 0xd0000;
|
||||
newt->mem_cntl[ 4 ].config[ 1 ] = 0xff000;
|
||||
newt->mem_cntl[ 5 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 5 ].config[ 0 ] = 0x00000;
|
||||
newt->mem_cntl[ 5 ].config[ 1 ] = 0x80000;
|
||||
}
|
||||
}
|
||||
|
||||
void copy_0_3_0_saturn( saturn_0_3_0_t* old, saturn_t* newt ) {
|
||||
int i;
|
||||
|
||||
memcpy( &( newt->A[ 0 ] ), &( old->A[ 0 ] ), 16 );
|
||||
memcpy( &( newt->B[ 0 ] ), &( old->B[ 0 ] ), 16 );
|
||||
memcpy( &( newt->C[ 0 ] ), &( old->C[ 0 ] ), 16 );
|
||||
memcpy( &( newt->D[ 0 ] ), &( old->D[ 0 ] ), 16 );
|
||||
newt->d[ 0 ] = old->d[ 0 ];
|
||||
newt->d[ 1 ] = old->d[ 1 ];
|
||||
newt->P = old->P;
|
||||
newt->PC = old->PC;
|
||||
memcpy( &( newt->R0[ 0 ] ), &( old->R0[ 0 ] ), 16 );
|
||||
memcpy( &( newt->R1[ 0 ] ), &( old->R1[ 0 ] ), 16 );
|
||||
memcpy( &( newt->R2[ 0 ] ), &( old->R2[ 0 ] ), 16 );
|
||||
memcpy( &( newt->R3[ 0 ] ), &( old->R3[ 0 ] ), 16 );
|
||||
memcpy( &( newt->R4[ 0 ] ), &( old->R4[ 0 ] ), 16 );
|
||||
memcpy( &( newt->IN[ 0 ] ), &( old->IN[ 0 ] ), 4 );
|
||||
memcpy( &( newt->OUT[ 0 ] ), &( old->OUT[ 0 ] ), 3 );
|
||||
newt->CARRY = old->CARRY;
|
||||
memcpy( &( newt->PSTAT[ 0 ] ), &( old->PSTAT[ 0 ] ), NR_PSTAT );
|
||||
newt->XM = old->XM;
|
||||
newt->SB = old->SB;
|
||||
newt->SR = old->SR;
|
||||
newt->MP = old->MP;
|
||||
newt->hexmode = old->hexmode;
|
||||
memcpy( &( newt->rstk[ 0 ] ), &( old->rstk[ 0 ] ),
|
||||
NR_RSTK * sizeof( word_20 ) );
|
||||
newt->rstkp = old->rstkp;
|
||||
for ( i = 0; i < 9; i++ ) {
|
||||
newt->keybuf.rows[ i ] = old->keybuf.rows[ i ];
|
||||
}
|
||||
newt->intenable = old->intenable;
|
||||
newt->int_pending = old->int_pending;
|
||||
newt->kbd_ien = old->kbd_ien;
|
||||
newt->disp_io = old->disp_io;
|
||||
newt->contrast_ctrl = old->contrast_ctrl;
|
||||
newt->disp_test = old->disp_test;
|
||||
newt->crc = old->crc;
|
||||
newt->power_status = old->power_status;
|
||||
newt->power_ctrl = old->power_ctrl;
|
||||
newt->mode = old->mode;
|
||||
newt->annunc = old->annunc;
|
||||
newt->baud = old->baud;
|
||||
newt->card_ctrl = old->card_ctrl;
|
||||
newt->card_status = old->card_status;
|
||||
newt->io_ctrl = old->io_ctrl;
|
||||
newt->rcs = old->rcs;
|
||||
newt->tcs = old->tcs;
|
||||
newt->rbr = old->rbr;
|
||||
newt->tbr = old->tbr;
|
||||
newt->sreq = old->sreq;
|
||||
newt->ir_ctrl = old->ir_ctrl;
|
||||
newt->base_off = old->base_off;
|
||||
newt->lcr = old->lcr;
|
||||
newt->lbr = old->lbr;
|
||||
newt->scratch = old->scratch;
|
||||
newt->base_nibble = old->base_nibble;
|
||||
newt->disp_addr = old->disp_addr;
|
||||
newt->line_offset = old->line_offset;
|
||||
newt->line_count = old->line_count;
|
||||
newt->unknown = old->unknown;
|
||||
newt->t1_ctrl = old->t1_ctrl;
|
||||
newt->t2_ctrl = old->t2_ctrl;
|
||||
newt->menu_addr = old->menu_addr;
|
||||
newt->unknown2 = old->unknown2;
|
||||
newt->timer1 = old->timer1;
|
||||
newt->timer2 = old->timer2;
|
||||
newt->t1_instr = old->t1_instr;
|
||||
newt->t2_instr = old->t2_instr;
|
||||
newt->t1_tick = old->t1_tick;
|
||||
newt->t2_tick = old->t2_tick;
|
||||
newt->i_per_s = old->i_per_s;
|
||||
newt->bank_switch = 0;
|
||||
if ( opt_gx ) {
|
||||
newt->mem_cntl[ 0 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 0 ].config[ 0 ] = 0x00100;
|
||||
newt->mem_cntl[ 1 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 1 ].config[ 0 ] = 0x80000;
|
||||
newt->mem_cntl[ 1 ].config[ 1 ] = 0xc0000;
|
||||
newt->mem_cntl[ 2 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 2 ].config[ 0 ] = 0x7f000;
|
||||
newt->mem_cntl[ 2 ].config[ 1 ] = 0xff000;
|
||||
newt->mem_cntl[ 3 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 3 ].config[ 0 ] = 0xc0000;
|
||||
newt->mem_cntl[ 3 ].config[ 1 ] = 0xc0000;
|
||||
newt->mem_cntl[ 4 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 4 ].config[ 0 ] = 0xc0000;
|
||||
newt->mem_cntl[ 4 ].config[ 1 ] = 0xc0000;
|
||||
newt->mem_cntl[ 5 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 5 ].config[ 0 ] = 0x00000;
|
||||
newt->mem_cntl[ 5 ].config[ 1 ] = 0x00000;
|
||||
} else {
|
||||
if ( old->devices == 0x100 ) {
|
||||
newt->mem_cntl[ 0 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 0 ].config[ 0 ] = old->devices;
|
||||
} else {
|
||||
newt->mem_cntl[ 0 ].unconfigured = 1;
|
||||
newt->mem_cntl[ 0 ].config[ 0 ] = 0x00000;
|
||||
}
|
||||
if ( old->ram32k == 0x70000 ) {
|
||||
newt->mem_cntl[ 1 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 1 ].config[ 0 ] = 0x70000;
|
||||
newt->mem_cntl[ 1 ].config[ 1 ] = 0xf0000;
|
||||
} else if ( old->ram32k == 0xf0000 ) {
|
||||
newt->mem_cntl[ 1 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 1 ].config[ 0 ] = 0xf0000;
|
||||
newt->mem_cntl[ 1 ].config[ 1 ] = 0xf0000;
|
||||
} else if ( old->ram32k == 0xfc000 ) {
|
||||
newt->mem_cntl[ 1 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 1 ].config[ 0 ] = 0x70000;
|
||||
newt->mem_cntl[ 1 ].config[ 1 ] = 0xfc000;
|
||||
} else if ( old->ram32k == 0xfe000 ) {
|
||||
newt->mem_cntl[ 1 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 1 ].config[ 0 ] = 0x70000;
|
||||
newt->mem_cntl[ 1 ].config[ 1 ] = 0xfe000;
|
||||
} else {
|
||||
newt->mem_cntl[ 1 ].unconfigured = 2;
|
||||
newt->mem_cntl[ 1 ].config[ 0 ] = 0x00000;
|
||||
newt->mem_cntl[ 1 ].config[ 1 ] = 0x00000;
|
||||
}
|
||||
newt->mem_cntl[ 2 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 2 ].config[ 0 ] = 0x80000;
|
||||
newt->mem_cntl[ 2 ].config[ 1 ] = 0xc0000;
|
||||
newt->mem_cntl[ 3 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 3 ].config[ 0 ] = 0xc0000;
|
||||
newt->mem_cntl[ 3 ].config[ 1 ] = 0xc0000;
|
||||
newt->mem_cntl[ 4 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 4 ].config[ 0 ] = 0xd0000;
|
||||
newt->mem_cntl[ 4 ].config[ 1 ] = 0xff000;
|
||||
newt->mem_cntl[ 5 ].unconfigured = 0;
|
||||
newt->mem_cntl[ 5 ].config[ 0 ] = 0x00000;
|
||||
newt->mem_cntl[ 5 ].config[ 1 ] = 0x80000;
|
||||
}
|
||||
}
|
||||
|
||||
int read_8( FILE* fp, word_8* var ) {
|
||||
unsigned char tmp;
|
||||
|
||||
|
@ -547,171 +141,7 @@ int read_u_long( FILE* fp, unsigned long* var ) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int read_version_0_3_0_file( FILE* fp ) {
|
||||
int i;
|
||||
|
||||
/*
|
||||
* version 0.3.x, read in the saturn_0_3_0_t struct
|
||||
*/
|
||||
for ( i = 0; i < 16; i++ )
|
||||
if ( !read_8( fp, &saturn_0_3_0.A[ i ] ) )
|
||||
return 0;
|
||||
for ( i = 0; i < 16; i++ )
|
||||
if ( !read_8( fp, &saturn_0_3_0.B[ i ] ) )
|
||||
return 0;
|
||||
for ( i = 0; i < 16; i++ )
|
||||
if ( !read_8( fp, &saturn_0_3_0.C[ i ] ) )
|
||||
return 0;
|
||||
for ( i = 0; i < 16; i++ )
|
||||
if ( !read_8( fp, &saturn_0_3_0.D[ i ] ) )
|
||||
return 0;
|
||||
if ( !read_32( fp, &saturn_0_3_0.d[ 0 ] ) )
|
||||
return 0;
|
||||
if ( !read_32( fp, &saturn_0_3_0.d[ 1 ] ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.P ) )
|
||||
return 0;
|
||||
if ( !read_32( fp, &saturn_0_3_0.PC ) )
|
||||
return 0;
|
||||
for ( i = 0; i < 16; i++ )
|
||||
if ( !read_8( fp, &saturn_0_3_0.R0[ i ] ) )
|
||||
return 0;
|
||||
for ( i = 0; i < 16; i++ )
|
||||
if ( !read_8( fp, &saturn_0_3_0.R1[ i ] ) )
|
||||
return 0;
|
||||
for ( i = 0; i < 16; i++ )
|
||||
if ( !read_8( fp, &saturn_0_3_0.R2[ i ] ) )
|
||||
return 0;
|
||||
for ( i = 0; i < 16; i++ )
|
||||
if ( !read_8( fp, &saturn_0_3_0.R3[ i ] ) )
|
||||
return 0;
|
||||
for ( i = 0; i < 16; i++ )
|
||||
if ( !read_8( fp, &saturn_0_3_0.R4[ i ] ) )
|
||||
return 0;
|
||||
for ( i = 0; i < 4; i++ )
|
||||
if ( !read_8( fp, &saturn_0_3_0.IN[ i ] ) )
|
||||
return 0;
|
||||
for ( i = 0; i < 3; i++ )
|
||||
if ( !read_8( fp, &saturn_0_3_0.OUT[ i ] ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.CARRY ) )
|
||||
return 0;
|
||||
for ( i = 0; i < NR_PSTAT; i++ )
|
||||
if ( !read_8( fp, &saturn_0_3_0.PSTAT[ i ] ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.XM ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.SB ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.SR ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.MP ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.hexmode ) )
|
||||
return 0;
|
||||
for ( i = 0; i < NR_RSTK; i++ )
|
||||
if ( !read_32( fp, &saturn_0_3_0.rstk[ i ] ) )
|
||||
return 0;
|
||||
if ( !read_16( fp, ( word_16* )&saturn_0_3_0.rstkp ) )
|
||||
return 0;
|
||||
for ( i = 0; i < 9; i++ )
|
||||
if ( !read_16( fp, ( word_16* )&saturn_0_3_0.keybuf.rows[ i ] ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.intenable ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.int_pending ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.kbd_ien ) )
|
||||
return 0;
|
||||
for ( i = 0; i < NR_CONFIG; i++ )
|
||||
if ( !read_32( fp, &saturn_0_3_0.configs[ i ] ) )
|
||||
return 0;
|
||||
if ( !read_16( fp, ( word_16* )&saturn_0_3_0.daisy_state ) )
|
||||
return 0;
|
||||
if ( !read_32( fp, &saturn_0_3_0.ram32k ) )
|
||||
return 0;
|
||||
if ( !read_32( fp, &saturn_0_3_0.devices ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.disp_io ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.contrast_ctrl ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.disp_test ) )
|
||||
return 0;
|
||||
if ( !read_16( fp, &saturn_0_3_0.crc ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.power_status ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.power_ctrl ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.mode ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.annunc ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.baud ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.card_ctrl ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.card_status ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.io_ctrl ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.rcs ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.tcs ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.rbr ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.tbr ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.sreq ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.ir_ctrl ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.base_off ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.lcr ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.lbr ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.scratch ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.base_nibble ) )
|
||||
return 0;
|
||||
if ( !read_32( fp, &saturn_0_3_0.disp_addr ) )
|
||||
return 0;
|
||||
if ( !read_16( fp, &saturn_0_3_0.line_offset ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.line_count ) )
|
||||
return 0;
|
||||
if ( !read_16( fp, &saturn_0_3_0.unknown ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.t1_ctrl ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.t2_ctrl ) )
|
||||
return 0;
|
||||
if ( !read_32( fp, &saturn_0_3_0.menu_addr ) )
|
||||
return 0;
|
||||
if ( !read_8( fp, &saturn_0_3_0.unknown2 ) )
|
||||
return 0;
|
||||
if ( !read_char( fp, &saturn_0_3_0.timer1 ) )
|
||||
return 0;
|
||||
if ( !read_32( fp, &saturn_0_3_0.timer2 ) )
|
||||
return 0;
|
||||
if ( !read_32( fp, &saturn_0_3_0.t1_instr ) )
|
||||
return 0;
|
||||
if ( !read_32( fp, &saturn_0_3_0.t2_instr ) )
|
||||
return 0;
|
||||
if ( !read_16( fp, ( word_16* )&saturn_0_3_0.t1_tick ) )
|
||||
return 0;
|
||||
if ( !read_16( fp, ( word_16* )&saturn_0_3_0.t2_tick ) )
|
||||
return 0;
|
||||
if ( !read_32( fp, &saturn_0_3_0.i_per_s ) )
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int read_version_0_4_0_file( FILE* fp ) {
|
||||
int read_hp48_file( FILE* fp ) {
|
||||
int i;
|
||||
|
||||
/*
|
||||
|
@ -1056,34 +486,11 @@ int read_files( void ) {
|
|||
|
||||
if ( X48_MAGIC != saturn.magic ) {
|
||||
/*
|
||||
* no MAGIC number, try to read old format file
|
||||
* no MAGIC number, exiting
|
||||
*/
|
||||
fseek( fp, 0, SEEK_SET );
|
||||
if ( fread( ( char* )&old_saturn, 1, sizeof( old_saturn ), fp ) ==
|
||||
sizeof( old_saturn ) ) {
|
||||
/*
|
||||
* seems to work
|
||||
*/
|
||||
copy_old_saturn( &old_saturn, &saturn );
|
||||
if ( !quiet )
|
||||
fprintf( stderr, "%s: %s seems to be an old version file\n",
|
||||
progname, fnam );
|
||||
saturn.magic = X48_MAGIC;
|
||||
saturn.t1_tick = 8192;
|
||||
saturn.t2_tick = 16;
|
||||
saturn.i_per_s = 0;
|
||||
saturn.version[ 0 ] = VERSION_MAJOR;
|
||||
saturn.version[ 1 ] = VERSION_MINOR;
|
||||
saturn.version[ 2 ] = PATCHLEVEL;
|
||||
saturn.version[ 3 ] = COMPILE_VERSION;
|
||||
} else {
|
||||
/*
|
||||
* no, initialize
|
||||
*/
|
||||
if ( !quiet )
|
||||
fprintf( stderr, "%s: can\'t handle %s\n", progname, fnam );
|
||||
init_saturn();
|
||||
}
|
||||
fprintf( stderr, "You seem to try to load an old saved state. Try "
|
||||
"running a recent x48 (0.6.4) before trying x48ng." );
|
||||
exit( 99 );
|
||||
} else {
|
||||
/*
|
||||
* MAGIC ok, read and compare the version
|
||||
|
@ -1107,58 +514,15 @@ int read_files( void ) {
|
|||
v2 |= ( ( int )PATCHLEVEL & 0xff ) << 8;
|
||||
v2 |= ( ( int )COMPILE_VERSION & 0xff );
|
||||
|
||||
if ( ( v1 & 0xffffff00 ) < ( v2 & 0xffffff00 ) ) {
|
||||
/*
|
||||
* try to read latest version file
|
||||
*/
|
||||
if ( !read_hp48_file( fp ) ) {
|
||||
if ( !quiet )
|
||||
fprintf( stderr,
|
||||
"%s: %s is a version %d.%d.%d file, converting\n",
|
||||
progname, fnam, saturn.version[ 0 ],
|
||||
saturn.version[ 1 ], saturn.version[ 2 ] );
|
||||
} else if ( ( v2 & 0xffffff00 ) < ( v1 & 0xffffff00 ) ) {
|
||||
if ( !quiet )
|
||||
fprintf( stderr,
|
||||
"%s: %s is a version %d.%d.%d file, trying ...\n",
|
||||
progname, fnam, saturn.version[ 0 ],
|
||||
saturn.version[ 1 ], saturn.version[ 2 ] );
|
||||
}
|
||||
|
||||
if ( v1 < 0x00040000 ) {
|
||||
/*
|
||||
* read version < 0.4 file
|
||||
*/
|
||||
if ( !read_version_0_3_0_file( fp ) ) {
|
||||
if ( !quiet )
|
||||
fprintf( stderr, "%s: can\'t handle %s\n", progname,
|
||||
fnam );
|
||||
init_saturn();
|
||||
} else {
|
||||
copy_0_3_0_saturn( &saturn_0_3_0, &saturn );
|
||||
if ( verbose )
|
||||
printf( "%s: read %s\n", progname, fnam );
|
||||
}
|
||||
} else if ( v1 <= v2 ) {
|
||||
/*
|
||||
* read latest version file
|
||||
*/
|
||||
if ( !read_version_0_4_0_file( fp ) ) {
|
||||
if ( !quiet )
|
||||
fprintf( stderr, "%s: can\'t handle %s\n", progname,
|
||||
fnam );
|
||||
init_saturn();
|
||||
} else if ( verbose ) {
|
||||
printf( "%s: read %s\n", progname, fnam );
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* try to read latest version file
|
||||
*/
|
||||
if ( !read_version_0_4_0_file( fp ) ) {
|
||||
if ( !quiet )
|
||||
fprintf( stderr, "%s: can\'t handle %s\n", progname,
|
||||
fnam );
|
||||
init_saturn();
|
||||
} else if ( verbose ) {
|
||||
printf( "%s: read %s\n", progname, fnam );
|
||||
}
|
||||
fprintf( stderr, "%s: can\'t handle %s\n", progname, fnam );
|
||||
init_saturn();
|
||||
} else if ( verbose ) {
|
||||
printf( "%s: read %s\n", progname, fnam );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue