Added capability to handle floating point values with save/restore.
Improved OPL3 save/restore support.
This commit is contained in:
parent
8fe902686c
commit
924201f694
@ -2,7 +2,7 @@
|
||||
// $Id$
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2010-2014 The Bochs Project
|
||||
// Copyright (C) 2010-2015 The Bochs Project
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
@ -433,6 +433,19 @@ bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent,
|
||||
}
|
||||
}
|
||||
|
||||
// Double (floating point)
|
||||
bx_shadow_num_c::bx_shadow_num_c(bx_param_c *parent,
|
||||
const char *name,
|
||||
double *ptr_to_real_val)
|
||||
: bx_param_num_c(parent, name, NULL, NULL, BX_MIN_BIT64U, BX_MAX_BIT64U, 0, 1)
|
||||
{
|
||||
this->varsize = 64;
|
||||
this->lowbit = 0;
|
||||
this->mask = BX_MAX_BIT64U;
|
||||
val.pdouble = ptr_to_real_val;
|
||||
this->base = BASE_DOUBLE;
|
||||
}
|
||||
|
||||
Bit64s bx_shadow_num_c::get64()
|
||||
{
|
||||
Bit64u current = 0;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// $Id$
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2010-2013 The Bochs Project
|
||||
// Copyright (C) 2010-2015 The Bochs Project
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
@ -89,6 +89,7 @@ public:
|
||||
|
||||
#define BASE_DEC 10
|
||||
#define BASE_HEX 16
|
||||
#define BASE_DOUBLE 64
|
||||
|
||||
class BOCHSAPI bx_param_c : public bx_object_c {
|
||||
BOCHSAPI_CYGONLY static const char *default_text_format;
|
||||
@ -169,6 +170,7 @@ protected:
|
||||
Bit32s *p32bit; // used by bx_shadow_num_c
|
||||
Bit16s *p16bit; // used by bx_shadow_num_c
|
||||
Bit8s *p8bit; // used by bx_shadow_num_c
|
||||
double *pdouble; // used by bx_shadow_num_c
|
||||
bx_bool *pbool; // used by bx_shadow_bool_c
|
||||
} val;
|
||||
param_event_handler handler;
|
||||
@ -271,6 +273,9 @@ public:
|
||||
int base = BASE_DEC,
|
||||
Bit8u highbit = 7,
|
||||
Bit8u lowbit = 0);
|
||||
bx_shadow_num_c(bx_param_c *parent,
|
||||
const char *name,
|
||||
double *ptr_to_real_val);
|
||||
virtual Bit64s get64();
|
||||
virtual void set(Bit64s val);
|
||||
virtual void reset();
|
||||
|
@ -1183,6 +1183,8 @@ bx_bool bx_real_sim_c::restore_bochs_param(bx_list_c *root, const char *sr_path,
|
||||
char *ret, *ptr;
|
||||
int i, j, p;
|
||||
unsigned n;
|
||||
double fvalue;
|
||||
Bit64u value;
|
||||
bx_param_c *param = NULL;
|
||||
FILE *fp, *fp2;
|
||||
|
||||
@ -1224,7 +1226,11 @@ bx_bool bx_real_sim_c::restore_bochs_param(bx_list_c *root, const char *sr_path,
|
||||
}
|
||||
switch (param->get_type()) {
|
||||
case BXT_PARAM_NUM:
|
||||
if ((ptr[0] == '0') && (ptr[1] == 'x')) {
|
||||
if (((bx_param_num_c*)param)->get_base() == BASE_DOUBLE) {
|
||||
fvalue = strtod(ptr, NULL);
|
||||
memcpy(&value, &fvalue, sizeof(double));
|
||||
((bx_param_num_c*)param)->set(value);
|
||||
} else if ((ptr[0] == '0') && (ptr[1] == 'x')) {
|
||||
((bx_param_num_c*)param)->set(strtoull(ptr, NULL, 16));
|
||||
} else {
|
||||
((bx_param_num_c*)param)->set(strtoull(ptr, NULL, 10));
|
||||
@ -1318,6 +1324,7 @@ bx_bool bx_real_sim_c::save_sr_param(FILE *fp, bx_param_c *node, const char *sr_
|
||||
{
|
||||
int i;
|
||||
Bit64s value;
|
||||
double fvalue;
|
||||
char pname[BX_PATHNAME_LEN], tmpstr[BX_PATHNAME_LEN];
|
||||
FILE *fp2;
|
||||
|
||||
@ -1331,7 +1338,10 @@ bx_bool bx_real_sim_c::save_sr_param(FILE *fp, bx_param_c *node, const char *sr_
|
||||
switch (node->get_type()) {
|
||||
case BXT_PARAM_NUM:
|
||||
value = ((bx_param_num_c*)node)->get64();
|
||||
if (((bx_param_num_c*)node)->get_base() == BASE_DEC) {
|
||||
if (((bx_param_num_c*)node)->get_base() == BASE_DOUBLE) {
|
||||
memcpy(&fvalue, &value, sizeof(double));
|
||||
fprintf(fp, "%f\n", fvalue);
|
||||
} else if (((bx_param_num_c*)node)->get_base() == BASE_DEC) {
|
||||
if (((bx_param_num_c*)node)->get_min() >= BX_MIN_BIT64U) {
|
||||
if ((Bit64u)((bx_param_num_c*)node)->get_max() > BX_MAX_BIT32U) {
|
||||
fprintf(fp, FMT_LL"u\n", value);
|
||||
|
@ -1539,24 +1539,39 @@ void adlib_register_state(bx_list_c *parent)
|
||||
new bx_shadow_num_c(opX, "tcount", &op[i].tcount);
|
||||
new bx_shadow_num_c(opX, "wfpos", &op[i].wfpos);
|
||||
new bx_shadow_num_c(opX, "tinc", &op[i].tinc);
|
||||
new bx_shadow_num_c(opX, "amp", &op[i].amp);
|
||||
new bx_shadow_num_c(opX, "step_amp", &op[i].step_amp);
|
||||
new bx_shadow_num_c(opX, "vol", &op[i].vol);
|
||||
new bx_shadow_num_c(opX, "sustain_level", &op[i].sustain_level);
|
||||
new bx_shadow_num_c(opX, "mfbi", &op[i].mfbi);
|
||||
new bx_shadow_num_c(opX, "a0", &op[i].a0);
|
||||
new bx_shadow_num_c(opX, "a1", &op[i].a1);
|
||||
new bx_shadow_num_c(opX, "a2", &op[i].a2);
|
||||
new bx_shadow_num_c(opX, "a3", &op[i].a3);
|
||||
new bx_shadow_num_c(opX, "decaymul", &op[i].decaymul);
|
||||
new bx_shadow_num_c(opX, "releasemul", &op[i].releasemul);
|
||||
new bx_shadow_num_c(opX, "op_state", &op[i].op_state);
|
||||
new bx_shadow_num_c(opX, "toff", &op[i].toff);
|
||||
new bx_shadow_num_c(opX, "freq_high", &op[i].freq_high);
|
||||
// TODO: cur_wform
|
||||
new bx_shadow_num_c(opX, "cur_wmask", &op[i].cur_wmask);
|
||||
new bx_shadow_num_c(opX, "act_state", &op[i].act_state);
|
||||
new bx_shadow_bool_c(opX, "sys_keep", &op[i].sus_keep);
|
||||
new bx_shadow_bool_c(opX, "vibrato", &op[i].vibrato);
|
||||
new bx_shadow_bool_c(opX, "tremolo", &op[i].tremolo);
|
||||
new bx_shadow_num_c(opX, "generator_pos", &op[i].generator_pos);
|
||||
new bx_shadow_num_c(opX, "cur_env_step", &op[i].cur_env_step);
|
||||
new bx_shadow_num_c(opX, "env_step_a", &op[i].env_step_a);
|
||||
new bx_shadow_num_c(opX, "env_step_d", &op[i].env_step_d);
|
||||
new bx_shadow_num_c(opX, "env_step_r", &op[i].env_step_r);
|
||||
new bx_shadow_num_c(opX, "step_skip_pos_a", &op[i].step_skip_pos_a);
|
||||
new bx_shadow_num_c(opX, "env_step_skip_a", &op[i].env_step_skip_a);
|
||||
#if defined(OPLTYPE_IS_OPL3)
|
||||
new bx_shadow_bool_c(opX, "is_4op", &op[i].is_4op);
|
||||
new bx_shadow_bool_c(opX, "is_4op_attached", &op[i].is_4op_attached);
|
||||
new bx_shadow_num_c(opX, "left_pan", &op[i].left_pan);
|
||||
new bx_shadow_num_c(opX, "right_pan", &op[i].right_pan);
|
||||
#endif
|
||||
// TODO: add more internal settings (other variable types)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user