Merge remote-tracking branch 'upstream/master'

This commit is contained in:
FakeShemp 2016-10-15 21:46:41 +02:00
commit 3fad928706
55 changed files with 2671 additions and 1230 deletions

View File

@ -1048,6 +1048,7 @@ function linkProjects_mame_mess(_target, _subtarget)
"unisys", "unisys",
"usp", "usp",
"veb", "veb",
"verifone",
"vidbrain", "vidbrain",
"videoton", "videoton",
"visual", "visual",
@ -3087,6 +3088,12 @@ files {
MAME_DIR .. "src/mame/drivers/sc2.cpp", MAME_DIR .. "src/mame/drivers/sc2.cpp",
} }
createMESSProjects(_target, _subtarget, "verifone")
files {
MAME_DIR .. "src/mame/drivers/tranz330.cpp",
MAME_DIR .. "src/mame/includes/tranz330.h"
}
createMESSProjects(_target, _subtarget, "vidbrain") createMESSProjects(_target, _subtarget, "vidbrain")
files { files {
MAME_DIR .. "src/mame/drivers/vidbrain.cpp", MAME_DIR .. "src/mame/drivers/vidbrain.cpp",
@ -3210,6 +3217,7 @@ files {
MAME_DIR .. "src/mame/drivers/alphasma.cpp", MAME_DIR .. "src/mame/drivers/alphasma.cpp",
MAME_DIR .. "src/mame/drivers/ampro.cpp", MAME_DIR .. "src/mame/drivers/ampro.cpp",
MAME_DIR .. "src/mame/drivers/amust.cpp", MAME_DIR .. "src/mame/drivers/amust.cpp",
MAME_DIR .. "src/mame/drivers/anzterm.cpp",
MAME_DIR .. "src/mame/drivers/applix.cpp", MAME_DIR .. "src/mame/drivers/applix.cpp",
MAME_DIR .. "src/mame/drivers/argox.cpp", MAME_DIR .. "src/mame/drivers/argox.cpp",
MAME_DIR .. "src/mame/drivers/attache.cpp", MAME_DIR .. "src/mame/drivers/attache.cpp",

View File

@ -128,17 +128,17 @@ WRITE8_MEMBER(sega_fm_unit_device::peripheral_w)
m_audio_control = data & 0x01; m_audio_control = data & 0x01;
if (m_audio_control == 0x01) if (m_audio_control == 0x01)
{ {
m_ym->set_output_gain(0, 1.0); m_ym->set_output_gain(ALL_OUTPUTS, 1.0);
// assume the PSG output is muted when FM is active. // assume the PSG output is muted when FM is active.
// Out Run need this. Needs confirmation (see TODO). // Out Run need this. Needs confirmation (see TODO).
if (m_psg.found()) if (m_psg.found())
m_psg->set_output_gain(0, 0.0); m_psg->set_output_gain(ALL_OUTPUTS, 0.0);
} }
else else
{ {
m_ym->set_output_gain(0, 0.0); m_ym->set_output_gain(ALL_OUTPUTS, 0.0);
if (m_psg.found()) if (m_psg.found())
m_psg->set_output_gain(0, 1.0); m_psg->set_output_gain(ALL_OUTPUTS, 1.0);
} }
break; break;
default: default:

View File

@ -530,7 +530,7 @@ void scc8530_t::write_reg(int offset, UINT8 data)
case 0: /* Channel B (Printer Port) Control */ case 0: /* Channel B (Printer Port) Control */
case 1: /* Channel A (Modem Port) Control */ case 1: /* Channel A (Modem Port) Control */
{ {
int chan = ((offset == 2) ? 1 : 0); int chan = ((offset == 0) ? 1 : 0);
if (mode == 0) if (mode == 0)
{ {
if((data & 0xf0) == 0) // not a reset command if((data & 0xf0) == 0) // not a reset command

View File

@ -125,8 +125,6 @@ static const int roc10937poslut[]=
0//15 0//15
}; };
const device_type ROC10937 = &device_creator<roc10937_t>;
rocvfd_t::rocvfd_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) : rocvfd_t::rocvfd_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
device_t(mconfig, type, name, tag, owner, clock, shortname, source) device_t(mconfig, type, name, tag, owner, clock, shortname, source)
{ {
@ -246,6 +244,8 @@ void rocvfd_t::shift_clock(int state)
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
const device_type ROC10937 = &device_creator<roc10937_t>;
roc10937_t::roc10937_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) roc10937_t::roc10937_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: rocvfd_t(mconfig, ROC10937, "Rockwell 10937 VFD controller and compatible", tag, owner, clock, "roc10937", __FILE__) : rocvfd_t(mconfig, ROC10937, "Rockwell 10937 VFD controller and compatible", tag, owner, clock, "roc10937", __FILE__)
{ {
@ -260,6 +260,22 @@ msc1937_t::msc1937_t(const machine_config &mconfig, const char *tag, device_t *o
m_port_val=0; m_port_val=0;
} }
const device_type MIC10937 = &device_creator<mic10937_t>;
mic10937_t::mic10937_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: rocvfd_t(mconfig, MIC10937, "Micrel MIC10937 VFD controller", tag, owner, clock, "mic10937", __FILE__)
{
m_port_val=0;
}
const device_type S16LF01 = &device_creator<s16lf01_t>;
s16lf01_t::s16lf01_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: rocvfd_t(mconfig, S16LF01, "Samsung 16LF01 Series VFD controller and compatible", tag, owner, clock, "s16lf01", __FILE__)
{
m_port_val=0;
}
void rocvfd_t::write_char(int data) void rocvfd_t::write_char(int data)
{ {
if ( data & 0x80 ) if ( data & 0x80 )
@ -378,11 +394,3 @@ void roc10957_t::write_char(int data)
} }
} }
} }
const device_type S16LF01 = &device_creator<s16lf01_t>;
s16lf01_t::s16lf01_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: rocvfd_t(mconfig, S16LF01, "Samsung 16LF01 Series VFD controller and compatible", tag, owner, clock, "s16lf01", __FILE__)
{
m_port_val=0;
}

View File

@ -40,6 +40,16 @@
#define MCFG_MSC1937_REMOVE(_tag) \ #define MCFG_MSC1937_REMOVE(_tag) \
MCFG_DEVICE_REMOVE(_tag) MCFG_DEVICE_REMOVE(_tag)
#define MCFG_MIC10937_ADD(_tag,_val) \
MCFG_DEVICE_ADD(_tag, MIC10937,60)\
MCFG_MIC10937_PORT(_val)
#define MCFG_MIC10937_PORT(_val) \
MCFG_ROC10937_PORT(_val)
#define MCFG_MIC10937_REMOVE(_tag) \
MCFG_DEVICE_REMOVE(_tag)
#define MCFG_S16LF01_ADD(_tag,_val) \ #define MCFG_S16LF01_ADD(_tag,_val) \
MCFG_DEVICE_ADD(_tag, S16LF01,60)\ MCFG_DEVICE_ADD(_tag, S16LF01,60)\
MCFG_S16LF01_PORT(_val) MCFG_S16LF01_PORT(_val)
@ -95,6 +105,11 @@ public:
msc1937_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); msc1937_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
}; };
class mic10937_t : public rocvfd_t {
public:
mic10937_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
};
class roc10957_t : public rocvfd_t { class roc10957_t : public rocvfd_t {
public: public:
roc10957_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); roc10957_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
@ -109,6 +124,7 @@ public:
extern const device_type ROC10937; extern const device_type ROC10937;
extern const device_type MSC1937; extern const device_type MSC1937;
extern const device_type MIC10937;
extern const device_type ROC10957; extern const device_type ROC10957;
extern const device_type S16LF01; extern const device_type S16LF01;

View File

@ -122,6 +122,7 @@ void menu_input_general::populate()
item->defseq = &entry.defseq(seqtype); item->defseq = &entry.defseq(seqtype);
item->sortorder = sortorder * 4 + suborder[seqtype]; item->sortorder = sortorder * 4 + suborder[seqtype];
item->type = ioport_manager::type_is_analog(entry.type()) ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL; item->type = ioport_manager::type_is_analog(entry.type()) ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL;
item->is_optional = false;
item->name = entry.name(); item->name = entry.name();
item->owner_name = nullptr; item->owner_name = nullptr;
item->next = itemlist; item->next = itemlist;
@ -199,6 +200,7 @@ void menu_input_specific::populate()
item->defseq = &field.defseq(seqtype); item->defseq = &field.defseq(seqtype);
item->sortorder = sortorder + suborder[seqtype]; item->sortorder = sortorder + suborder[seqtype];
item->type = field.is_analog() ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL; item->type = field.is_analog() ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL;
item->is_optional = field.optional();
item->name = field.name(); item->name = field.name();
item->owner_name = field.device().tag(); item->owner_name = field.device().tag();
item->next = itemlist; item->next = itemlist;
@ -420,6 +422,8 @@ void menu_input::populate_and_sort(input_item_data *itemlist)
} }
std::string text = string_format(nameformat[item->type], item->name); std::string text = string_format(nameformat[item->type], item->name);
if (item->is_optional)
text = "(" + text + ")";
/* if we're polling this item, use some spaces with left/right arrows */ /* if we're polling this item, use some spaces with left/right arrows */
if (pollingref == item->ref) if (pollingref == item->ref)

View File

@ -55,6 +55,7 @@ protected:
const char * owner_name; /* pointer to the name of the owner of the item */ const char * owner_name; /* pointer to the name of the owner of the item */
UINT32 sortorder; /* sorting information */ UINT32 sortorder; /* sorting information */
UINT8 type; /* type of port */ UINT8 type; /* type of port */
bool is_optional; /* true if this input is considered optional */
}; };
void populate_and_sort(struct input_item_data *itemlist); void populate_and_sort(struct input_item_data *itemlist);

View File

@ -0,0 +1,479 @@
// license:BSD-3-Clause
// copyright-holders:Vas Crabb
/**************************************************************************
Burroughs EF315-I220 bank teller terminal
These 8-bit terminals were used by banks before they were displaced
by cheap PCs. There's an external customer PIN pad with its own
ROMs, and a keyboard for the teller. Unfortunately the teller
keyboard was missing from the unit that was dumped. These terminals
contain a hardware DES chip which was a controlled item due to trade
restrictions on encryption technology.
The main system consists of three large boards in a stack: D8302
(I/O board), A8301 (memory board), and C8209 (CPU board).
The MICR/OCR unit appears to be an off-the-shelf unit built by
Recognition Equipment and has a single board mounted in the top
case. Its main CPU is a MOSTEK MK3870/42 which has an undumped
4032-byte internal mask ROM.
Onboard peripherals:
- Small "green-screen" CRT display mounted on an adjustable "stalk"
- Thermal printer
- Card swipe
- MICR/OCR for reading cheque numbers (swiped the same way as cards)
Rear panel connectors:
- J1 (25-pin D-sub male)
- J2 (25-pin D-sub male)
- J3 (7-pin MIL-C-5015 connector)
- J4 (5-pin 180-degree DIN female)
- J5 (25-pin D-sub male)
- J6 (15-pin D-sub female)
TODO:
- Check designation of MICR board.
- Does U2 on the MICR board exist? I can't find it on the overlay.
- Finish parts list and ASCII art for CPU board.
- Do IC50 and IC56 on the I/O board exist? I can't find them on the overlay.
- Work out how clocks are derived.
- Hook everything up.
- Emulate DES engine.
- Photograph the guts of the PIN pad and check ROM labels.
- Find way to dump MK3870/42 in MICR reader.
****************************************************************************/
/*
(Despite my ASCII art, the main boards are actually all the same size.)
C8209 CPU Board
==================
Components:
IC1 - SN75189N
IC3 - unpopulated (16-pin DIP)
IC7 - SN75174NG
IC8 - SN75175N
IC9 - MC6850P
IC12 - SN75189N
IC13 - SN75188N
IC14, IC15 - unpopulated (16-pin DIP)
IC16 - MC6854P
IC17 - MC6850P
IC18 - HD46850P
IC19 - MC6854P
IC20 - unpopulated (24-pin DIP)
IC21 - SN74LS74AN
IC22 - SN74LS51N
IC23 - SN75189N
IC24 - unpopulated (16-pin DIP)
IC25 - SN74LS08N
IC26 - SN74LS00N
IC27 - DM74LS04N
IC28 - SN74LS367AN
IC29 - SN74LS161AN
IC30, IC31, IC32 - SN74LS367AN
IC33 - SN74LS74AN
IC34 - SN74LS393N
IC36 - SN74LS367AN
IC37 - SN74LS20N
IC38 - SN74LS74AN
IC39 - P8214
IC42 - SN74LS245N
IC45 - SN74LS10N
IC46 - SN74LS86N
IC48 - 74LS05N
IC50 - WD200IAH-20
IC51 - DM74LS04N
IC52 - CD4093BE
IC53 - SN74LS393N
IC54 - SN74LS74AN
IC55 - SN74LS00AN
IC56 - SN74LS367AN
IC57 - SN74LS132AN
IC58 - SN74LS32N
IC60 - unpopulated (16-pin DIP)
J7 - System bus (50-pin DIL IDC)
J8 - Power (24-pin SIL)
A8301 Memory Board
==================
+------------------------------+------------J1------------+---+ +---+
| +--------------------------+ +---------J2---------+ |
| [=IC9==] [=IC19=] +--------------------+ |
| |
| +--J-IC8---+ +--A-IC18--+ [=IC25=] [=IC29=] [=IC34=] [=RP12=] |
| +----------+ +----------+ Q5 Q6 Q7 |
| +--IC23---+ |
| +--K-IC7---+ +--B-IC17--+ +---------+ [=IC28==] [=IC42==] |
| +----------+ +----------+ [=IC55=] [=IC66=] |
| [=IC22=] [=RP10=] [=IC33=] [=RP11=] |
| +--L-IC6---+ +--C-IC16--+ [=IC54=] [=IC65=] |
| +----------+ +----------+ |
| [=HP3==] [=IC27=] [=IC41=] [=IC53=] [=RP14=] |
| +--M-IC5---+ +--D-IC15--+ |
| +----------+ +----------+ [=HP2==] [=IC52=] [=IC64=] |
| [=IC40=] |
| +--N-IC4--+ +--E-IC14-+ +---HP1---+ [=IC26=] [=IC51=] [=IC63=] |
| +---------+ +---------+ +---------+ [=IC39==] [=IC50=] [=IC62=] |
| +-----+ [=IC49=] [=IC61=] |
| +--P-IC3--+ +--F-IC13-+ | | [=IC21=] [=IC32=] [=IC38=] |
| +---------+ +---------+ | B1 | [=IC48=] [=IC60=] |
| | B2 | [=IC31=] [=IC37=] [=IC47=] [=IC59=] |
| +--Q-IC2--+ +--G-IC12-+ | B3 | Q4 [=IC46=] [=IC58=] |
| +---------+ +---------+ | B4 | Q2 [=IC30=] [=IC36=] [=IC45=] [=IC57=] |
| | B5 | Q3 |
| +--R-IC1--+ +--H-IC11-+ | | Q1 [=IC35=] [=IC44=] [=IC56=] |
| +---------+ +---------+ +-----+ |
| [=RP2=] [=IC10=] [=IC43=] |
+--------------------------------------------------------------------------------------+
Components:
B1, B2, B3, B4, B5 - space provided for various NiCd batteries - B4 is populated (3.6V 100mAh)
HP1 - 24-pin DIP wired links - 1/2/16/22/24 3/4/5 6 7/8/9/10 11/12 13/14 15/17/18 19/20 21 23
HP2 - 16-pin DIP wired links - 1/2/3/16 4/6/7/8/14 5/9/10/12 11/13/15
HP3 - 16-pin DIP wired links - 1/4 2 3 5/12 6/11 7/10 8/9 13 14 15 16
IC1, IC2 - HM6116LP-3
IC3, IC4 - unpopulated (24-pin DIP socket)
IC5, IC6, IC7, IC8 - HN482764G
IC9 - HM6147LP-3 (18-pin DIP in 20-pin socket; overlay says "CMOS PARITY 1")
IC10 - DM74LS156N
IC11, IC12 - unpopulated (24-pin DIP socket)
IC13, IC14 - TMS2516JL-45
IC15 - unpopulated (28-pin DIP socket)
IC16, IC17, IC18 - HN482764G
IC19 - unpopulated (20-pin DIP socket; overlay says "CMOS PARITY 2")
IC20 - location for 14-pin DIP integrated transistor pack replacing Q1/Q2/Q3/Q4
IC21 - SN74LS03N
IC22 - DM74LS156N
IC23 - TBP28S166N
IC24 - location for 16-pin DIP under IC23 (for smaller address decoding ROM/PLD?)
IC25 - SN74LS367AN
IC26 - DM74LS156N
IC27 - SN74LS157N
IC28 - SN74LS273N
IC29 - SN74LS367AN
IC30 - SN74LS139N
IC31 - SN74LS32N
IC32 - SN74LS20N
IC33 - SN74LS280N
IC34 - SN74LS367AN
IC35 - SN74LS32N
IC36 - SN74LS13N
IC37 - SN74LS163AN
IC38 - SN74S74N
IC39 - BELFUSE 8331 0447-0439-99 (DRAM timing device?)
IC40 - SN74LS132N
IC41 - SN74S02N
IC42 - SN74LS245N
IC43 - SN74S08N
IC44 - IC52 - HM4864P-2 (DRAM BANK 1 BIT 0 - 8 and PARITY, respectively)
IC53, IC54 - SN74LS158N
IC55 - SN74LS393N
IC56 - IC64 - HM4864P-2 (DRAM BANK 2 BIT 0 - 8 and PARITY, respectively)
IC65, IC66 - SN74LS158N
J1 - System bus (50-pin DIL IDC)
J2 - Power (24-pin SIL)
D8302 I/O Board
==================
+----------------------------+--------------J5--------------+----+ +----+
| +------------------------------+ +-----------J7-----------+ |
| J4 | +------------------------+ |
| | |
| J1 | | [=IC18=] [=RP2=] |
| | [==IC26=] |
| J3 | +---IC25---+ |
| [=IC7=] | [=IC17=] +----------+ [=IC45=] |
| [=IC44=] |
| +---IC6---+ +---IC16--+ |
| +---------+ +---------+ [==IC34=] [=IC43=] |
| |
| [==IC5==] +-------IC15-------+ ++
| +------------------+ [=IC33=] [=IC42=] Q12 [=IC51=] Q13 ||
| [==IC4==] ||
| [=IC11=] [=IC24=] [=IC41=] ||
| [==IC3==] [==IC32=] ||
| [=IC10=] [=IC14=] [=IC23=] [=IC40=] [=IC62=] [=IC61=] J9 ||
| [==IC2==] [==IC31=] ||
| +-------IC39-------+ [=IC55=] ||
| [==IC1==] [=IC22=] [==IC30=] +------------------+ ||
| ++ [=IC29=] [==IC38=] [=IC49=] ++
| J2 [=IC54=] [=IC60=] |
| || [=IC21=] IC28 +---IC37--+ |
| ++ +---------+ [=IC48=] [=IC53=] [=IC59=] |
| J6 [=IC27=] [=IC36=] [=IC63=] [=IC47=] [=IC58=] |
| [=IC9==] | [=IC13=] [=IC20=]+-X1-+ |
| [=IC8==] | [=IC12=] [=IC19=]+----+ [J10] [=IC35=] [=IC46=] [=IC52=] [=IC57=] |
+----------------------------------------------------------------------------------------------+
Components:
IC1, IC2 - SN74LS273N
IC3, IC4 - SN74LS245N
IC5 - SN74LS273N
IC6 - D2716D
IC7 - DM7404N
IC8 - SN74LS04N
IC9 - SN74LS74AN
IC10 - SN74LS157N
IC11 - SN74LS166AN
IC12 - SN74LS21N
IC13 - SN74LS93N
IC14 - SN74LS157N
IC15 - HD46505SP-1 HD68A45SP
IC16 - HD46850P HD6850P
IC17 - MC1488 75188N
IC18 - SN74LS86N
IC19 - SN74LS08N
IC20 - SN74LS93N
IC21 - SN74LS132N
IC22 - SN74LS08N
IC23 - MC1489A SN75189AN
IC24 - SN74LS157N
IC25 - D8251AC
IC26 - SN74LS245N
IC27 - SN7406N
IC28 - NE555P
IC29 - DM74LS00N
IC30, IC31, IC32 - MCM2114P20
IC33 - SN74LS157N
IC34 - SN74LS273N
IC35 - SN74LS27N
IC36 - 74LS168
IC37 - D2716D
IC38 - SN74LS273N
IC39 - HD46821P HD6821P
IC40 - SN74LS74AN
IC41, IC42, IC43 - 74LS32
IC44 - SN74LS04N
IC45 - SN74LS367AN
IC47 - SN74LS10N
IC48 - SN74LS74AN
IC49 - 74LS03
IC51 - 74LS138N
IC52 - 74LS02
IC53 - 74LS00N
IC54 - SN74121N
IC55 - SN74LS09N
IC57, IC58 - SN74LS74AN
IC59 - SN74LS14N
IC60 - 74LS132N
IC61 - SN74LS09N
IC62 - SN74LS08N
IC63 - 74LS03
J1 - Card Swipe (6-pin SIL)
J2 - MICR Reader Board (10-pin DIL IDC)
J3 - not populated (6-pin SIL)
J4 - CRT (8-pin SIL)
J5 - System bus (50-pin DIL IDC)
J6 - External connector on left side of case (6-pin SIL)
J7 - Power (24-pin SIL)
J9 - Printer (30-pin double-sided female edge connector)
J10 - Possibly service mode - case contains a loose connector for shorting two pins (6-pin SIL)
X1 - CK1100AC 15974.40KHz (oscillator module)
MICR Board
==================
+-------------------------------------------------------------+
| +---K1---+ |
| +---U15----+ +--------+ |
| Q5 [=U23=] +----------+ [=U1==] |
| Q6 |
| +---U16----+ Q8 |
| Q7 [=U24=] +----------+ Q10 Q3 |
| |
| +---U17----+ +---U11---+ +---U7----+ |
| [=U25=] +----------+ +---------+ +---------+ U4 |
| |
| ++ [=U26=] +---U18----+ |
| || +----------+ [=U12=] +-----U5------+ |
| || JP5 +-------------+ U3 |
| || [=U27=] +---U19----+ ++ |
| || +----------+ U6 |
| || +---U8----+ ++ |
| ++ [=U28=] +---U20----+ +---------+ |
| Q9 [=JP==] +----------+ ++ |
| || |
| +---U29---+ +----+ Q2 Q1 || |
| +---------+ +U13 | U10 || |
| Q4 +----+ || |
| [=U31=] [=U21=] || |
| +-----U14-----+ [=U9==] ++ |
| [=U30=] [=U22=] +-------------+ |
+-------------------------------------------------------------+
Components:
JP - Jumpers JP1, JP2, JP3, JP4
K1 - SPDT Relay
U1 - TL497ACN
U3, U4 - DS0026CN
U5 - CF11000A
U6 - CXO-043D 36.0000MHz 4E (oscillator module)
U7 - AMI 8336CK 5020056 CO4423
U8 - 5020884-002 853C
U9 - SN7414N
U10 - ICL8211CPA
U11 - ET2732Q-3
U12 - SN74LS00N
U13 - MB63303A
U14 - MK3870/42
U15 - AM2716DC (24-pin DIP in 28-pin socket)
U16 - ET2732Q-3 (24-pin DIP in 28-pin socket)
U17, U18, U19 - unpopulated (28-pin DIP socket)
U20 - ET2732Q-3 (24-pin DIP in 28-pin socket)
U21 - SN74LS26N
U22 - SN74LS245N
U23 - SN7406N
U24 - unpopulated (14-pin DIP socket)
U25 - SN74LS08N
U26, U27 - SN75189AN
U28 - SN74LS367AN
U29 - TMS2732AJL-45
U30 - unpopulated (20-pin SDIP socket)
U31 - SN74LS374N
*/
#include "emu.h"
#include "cpu/m6809/m6809.h"
#include "machine/6850acia.h"
#include "machine/i8214.h"
#include "machine/mc6854.h"
namespace {
class anzterm_state : public driver_device
{
public:
anzterm_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag)
{
}
UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
return 0;
}
};
gfx_layout const screenfont =
{
8, 16, // 8x8
RGN_FRAC(1, 1), // whole region
1, // 1bpp
{ 0 }, // bitplane offset
{ 0*1, 1*1, 2*1, 3*1, 4*1, 5*1, 6*1, 7*1 }, // x offsets
{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 }, // y offsets
128 // stride
};
gfx_layout const printfont =
{
8, 8, // 7x8
RGN_FRAC(1, 1), // whole region
1, // 1bpp
{ 0 }, // bitplane offset
{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, // x offsets
{ 7*1, 6*1, 5*1, 4*1, 3*1, 2*1, 1*1, 0*1 }, // y offsets
64 // stride
};
GFXDECODE_START( anzterm )
GFXDECODE_ENTRY("crtc", 0x0000, screenfont, 0, 1)
GFXDECODE_ENTRY("prnt", 0x0000, printfont, 0, 1)
GFXDECODE_END
ADDRESS_MAP_START( anzterm, AS_PROGRAM, 8, driver_device )
// There are two battery-backed 2kB SRAM chips with a 4kb SRAM chip for parity
// There are two 64kB DRAM banks (with parity)
// There's also a whole lot of ROM
AM_RANGE(0x0000, 0xffff) AM_ROM
ADDRESS_MAP_END
MACHINE_CONFIG_START( anzterm, anzterm_state )
MCFG_CPU_ADD("maincpu", M6809, 15974400/4)
MCFG_CPU_PROGRAM_MAP(anzterm)
MCFG_DEVICE_ADD("pic.ic39", I8214, 0)
MCFG_DEVICE_ADD("adlc.ic16", MC6854, 0)
MCFG_DEVICE_ADD("adlc.1c19", MC6854, 0)
MCFG_DEVICE_ADD("acia.ic17", ACIA6850, 0)
MCFG_DEVICE_ADD("acia.ic18", ACIA6850, 0)
MCFG_SCREEN_ADD_MONOCHROME("screen", RASTER, rgb_t::green)
MCFG_SCREEN_UPDATE_DRIVER(anzterm_state, screen_update)
MCFG_SCREEN_PALETTE("palette")
MCFG_SCREEN_RAW_PARAMS(15974400/4, 1024, 0, 104*8, 260, 0, 24*10) // this is totally wrong, it just stops a validation error
MCFG_PALETTE_ADD_MONOCHROME("palette")
MCFG_GFXDECODE_ADD("gfxdecode", "palette", anzterm)
MACHINE_CONFIG_END
INPUT_PORTS_START( anzterm )
INPUT_PORTS_END
} // anonymous namespace
ROM_START( anzterm )
// Main program on memory board - loading is definitely wrong
ROM_REGION( 0x10000, "maincpu", 0 )
ROM_LOAD( "fj-a-25.ic18", 0x0000, 0x2000, CRC(8c31a9dd) SHA1(864babf6c77813f17ce9082013098e8a677b0af6) )
ROM_LOAD( "fj-b-25.ic17", 0x2000, 0x2000, CRC(a893aeaf) SHA1(64e8a935fe37195533a0a19f00bdc4e6a2007728) )
ROM_LOAD( "fj-c-25.ic16", 0x4000, 0x2000, CRC(ae678bde) SHA1(b41da540b99a0c3ef9489d9cd25e5fa32e2d13f9) )
ROM_LOAD( "fj-e-25.ic14", 0x6000, 0x0800, CRC(786beceb) SHA1(d20b870528d12f8457e3c746b539fcfc3ded3b0b) )
ROM_LOAD( "fj-f-25.ic13", 0x6800, 0x0800, CRC(2890d808) SHA1(6871f4c5fd1bc7e2d1db2e663ffb342988de94b7) )
ROM_LOAD( "fj-j-25.ic8", 0x8000, 0x2000, CRC(23fa4b36) SHA1(b3676579b2ea4efb0bf867557b53a6ccba7cc60f) )
ROM_LOAD( "fj-k-25.ic7", 0xa000, 0x2000, CRC(cbd17462) SHA1(7e7460f99e7dd5c9ae113f69b67e2b6079a57c6d) )
ROM_LOAD( "fj-l-25.ic6", 0xc000, 0x2000, CRC(8989c2ed) SHA1(912d8152f8f67a964dcd360151d8c8438a652d58) )
ROM_LOAD( "fj-m-25.ic5", 0xe000, 0x2000, CRC(82762fee) SHA1(234a438abab91936e7073bd7cc62414dfae10373) )
// BPROM on memory board - address decoding?
ROM_REGION( 0x0800, "prom", 0 )
ROM_LOAD( "08177-80002.ic23", 0x0000, 0x0800, CRC(3cec2386) SHA1(a1ae5e07756eac5abbb3e178e12b213770432b5f) )
// CRTC character ROM on I/O board
ROM_REGION( 0x0800, "crtc", 0 )
ROM_LOAD( "crt-5080-2.ic6", 0x0000, 0x0800, CRC(cdea8532) SHA1(683743e477518695c2a1d9510bee25b7ef3f909b) )
// Printer font ROM on I/O board
ROM_REGION( 0x0800, "prnt", 0 )
ROM_LOAD( "prt-04.ic37", 0x0000, 0x0800, CRC(68870564) SHA1(06819a633dc545f103e8b843a2f553ac46a16a05) )
// ROMs in PIN pad
ROM_REGION( 0x1000, "pinpad", 0 )
ROM_LOAD( "ck-a-pr01.ic4", 0x0000, 0x0800, CRC(d0981882) SHA1(b55fd313c9b3e00039501a53a53c820d98f2258a) )
ROM_LOAD( "ck-b-pr01.ic3", 0x0000, 0x0800, CRC(96c9d90d) SHA1(400980c7a2c5306be28b74284c626ef2ed24c1a5) )
// Undumped microcontroller ROM in MICR reader
ROM_REGION( 0x0fc0, "micrmcu", 0 )
ROM_LOAD( "mk3870.u14", 0x0000, 0x0fc0, NO_DUMP )
// MICR reader data table ROMS, no idea how this stuff is used but dumps should be preserved
ROM_REGION( 0x5000, "micrdata", 0 )
ROM_LOAD( "cdn1-ebb.u20", 0x0000, 0x1000, CRC(0f9a9db3) SHA1(aedfe3ba7afb1d0a827fec5418369fca9348940f) )
ROM_LOAD( "cdn2-ebb.u16", 0x1000, 0x1000, CRC(648fff69) SHA1(59653d34067d9a3061857507868fd2147dadf537) )
ROM_LOAD( "6047204005.u15", 0x2000, 0x0800, CRC(70bfac37) SHA1(84081249ead5b957d98b3bd06665ef52d0a0243c) )
ROM_LOAD( "6048225001.u29", 0x3000, 0x1000, CRC(59c73999) SHA1(7dd12b500e13b177d19a24d148310541f7e660b4) )
ROM_LOAD( "ebb-fea-v96-9-23-83-f43a.u11", 0x4000, 0x1000, CRC(0e572470) SHA1(966e5eeb0114589a7cab3c29a1db48cdd8634be5) )
ROM_END
COMP( 1986?, anzterm, 0, 0, anzterm, anzterm, driver_device, 0, "Burroughs", "EF315-I220 Teller Terminal (ANZ)", MACHINE_IS_SKELETON ) // year comes from sticker on bottom of case, it's more likely a 1983 revision

View File

@ -260,7 +260,7 @@ Notes:
CN5 - USB connector joining to JVS I/O board with standard USB cable CN5 - USB connector joining to JVS I/O board with standard USB cable
CN8 - A/V input connector (from XBox board via short A/V cable) CN8 - A/V input connector (from XBox board via short A/V cable)
CN9 - VGA output connector CN9 - VGA output connector
CN10 - 14 pin connector (purpose unknown but appears to be unused) CN10 - 14 pin connector (purpose unknown, maybe another video connector)
CN11 - 16-pin flat cable connector joining to LPC connector on XBox board CN11 - 16-pin flat cable connector joining to LPC connector on XBox board
CN12 - 40-pin IDE flat cable connector joining to IDE connector on XBox board CN12 - 40-pin IDE flat cable connector joining to IDE connector on XBox board
CN14S - 7-pin power output connector joining to XBox board CN14S - 7-pin power output connector joining to XBox board
@ -869,9 +869,10 @@ int ohci_hlean2131qc_device::handle_nonstandard_request(int endpoint, USBSetupPa
sense = 3; sense = 3;
else else
sense = 0; // need to check sense = 0; // need to check
// PINSA register, bits 4-1 special value, must be 10 xor 15, but bit 3 is ignored since its used as the CS pin of the chip // PINSA register, bits 0-2 connected do dip switches 1-3 on filter board, bit 4 to dip switch 4, bit 5 to dip switch 5, bits 6-7 to buttons 1-2 on filter board
// bits 4-1 value must be 10 xor 15, and bit 3 is ignored since its used as the CS pin of the chip
endpoints[endpoint].buffer[1] = 0x4b; endpoints[endpoint].buffer[1] = 0x4b;
// PINSB register, bit 4 connected to re/de pins of max485, bits 2-3 used as uart pins, bit 0-1 is the sense pin of the jvs connector // PINSB register, bits 5-7 connected to 3 leds not mounted on pcb, bit 4 connected to re/de pins of max485, bits 2-3 used as uart pins, bit 0-1 give the status of the sense pin of the jvs connector
// if bits 0-1 are 11, the not all the connected jvs devices have been assigned an address yet // if bits 0-1 are 11, the not all the connected jvs devices have been assigned an address yet
endpoints[endpoint].buffer[2] = 0x52 | sense; endpoints[endpoint].buffer[2] = 0x52 | sense;
// OUTB register // OUTB register

View File

@ -270,6 +270,8 @@ public:
DECLARE_WRITE32_MEMBER(trivrus_input_w); DECLARE_WRITE32_MEMBER(trivrus_input_w);
UINT8 m_trivrus_input; UINT8 m_trivrus_input;
DECLARE_READ32_MEMBER(crzyddz2_4_r);
virtual void machine_start() override; virtual void machine_start() override;
virtual void machine_reset() override; virtual void machine_reset() override;
UINT32 screen_update_crystal(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); UINT32 screen_update_crystal(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
@ -284,8 +286,6 @@ public:
void PatchReset( ); void PatchReset( );
UINT16 GetVidReg( address_space &space, UINT16 reg ); UINT16 GetVidReg( address_space &space, UINT16 reg );
void SetVidReg( address_space &space, UINT16 reg, UINT16 val ); void SetVidReg( address_space &space, UINT16 reg, UINT16 val );
}; };
void crystal_state::IntReq( int num ) void crystal_state::IntReq( int num )
@ -664,6 +664,48 @@ static ADDRESS_MAP_START( trivrus_mem, AS_PROGRAM, 32, crystal_state )
ADDRESS_MAP_END ADDRESS_MAP_END
// Crazy Dou Di Zhu II
// To do: HY04 (pic?) protection
READ32_MEMBER(crystal_state::crzyddz2_4_r)
{
return 0xffffff3f | (machine().rand() & 0xc0);
}
static ADDRESS_MAP_START( crzyddz2_mem, AS_PROGRAM, 32, crystal_state )
AM_RANGE(0x00000000, 0x00ffffff) AM_ROM AM_WRITENOP
AM_RANGE(0x01280000, 0x01280003) AM_WRITE(Banksw_w)
AM_RANGE(0x01400000, 0x0140ffff) AM_RAM AM_SHARE("nvram")
AM_RANGE(0x01500000, 0x01500003) AM_READ_PORT("P1_P2")
AM_RANGE(0x01500004, 0x01500007) AM_READ(crzyddz2_4_r)
AM_RANGE(0x01801400, 0x01801403) AM_READWRITE(Timer0_r, Timer0_w)
AM_RANGE(0x01801408, 0x0180140b) AM_READWRITE(Timer1_r, Timer1_w)
AM_RANGE(0x01801410, 0x01801413) AM_READWRITE(Timer2_r, Timer2_w)
AM_RANGE(0x01801418, 0x0180141b) AM_READWRITE(Timer3_r, Timer3_w)
AM_RANGE(0x01802004, 0x01802007) AM_READWRITE(PIO_r, PIO_w)
AM_RANGE(0x01800800, 0x01800803) AM_READWRITE(DMA0_r, DMA0_w)
AM_RANGE(0x01800810, 0x01800813) AM_READWRITE(DMA1_r, DMA1_w)
AM_RANGE(0x01800c04, 0x01800c07) AM_WRITE(IntAck_w)
AM_RANGE(0x01800000, 0x0180ffff) AM_RAM AM_SHARE("sysregs")
AM_RANGE(0x02000000, 0x027fffff) AM_RAM AM_SHARE("workram")
AM_RANGE(0x030000a4, 0x030000a7) AM_READWRITE(FlipCount_r, FlipCount_w)
AM_RANGE(0x03000000, 0x0300ffff) AM_RAM AM_SHARE("vidregs")
AM_RANGE(0x03800000, 0x03ffffff) AM_RAM AM_SHARE("textureram")
AM_RANGE(0x04000000, 0x047fffff) AM_RAM AM_SHARE("frameram")
AM_RANGE(0x04800000, 0x04800fff) AM_DEVREADWRITE("vrender", vrender0_device, vr0_snd_read, vr0_snd_write)
AM_RANGE(0x05000000, 0x05000003) AM_READWRITE(FlashCmd_r, FlashCmd_w)
AM_RANGE(0x05000000, 0x05ffffff) AM_ROMBANK("bank1")
// AM_RANGE(0x44414F4C, 0x44414F7F) AM_RAM AM_SHARE("reset_patch")
ADDRESS_MAP_END
void crystal_state::PatchReset( ) void crystal_state::PatchReset( )
{ {
@ -1174,6 +1216,12 @@ static MACHINE_CONFIG_DERIVED( trivrus, crystal )
MACHINE_CONFIG_END MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( crzyddz2, crystal )
MCFG_CPU_MODIFY("maincpu")
MCFG_CPU_PROGRAM_MAP(crzyddz2_mem)
MACHINE_CONFIG_END
ROM_START( crysbios ) ROM_START( crysbios )
ROM_REGION( 0x20000, "maincpu", 0 ) // bios ROM_REGION( 0x20000, "maincpu", 0 ) // bios
ROM_LOAD("mx27l1000.u14", 0x000000, 0x020000, CRC(beff39a9) SHA1(b6f6dda58d9c82273f9422c1bd623411e58982cb) ) ROM_LOAD("mx27l1000.u14", 0x000000, 0x020000, CRC(beff39a9) SHA1(b6f6dda58d9c82273f9422c1bd623411e58982cb) )
@ -1287,6 +1335,68 @@ ROM_START( ddz )
ROM_REGION( 0x1000000, "user2", ROMREGION_ERASEFF ) ROM_REGION( 0x1000000, "user2", ROMREGION_ERASEFF )
ROM_END ROM_END
/***************************************************************************
Crazy Dou Di Zhu II
Sealy, 2006
PCB Layout
----------
070405-fd-VER1.2
|--------------------------------------|
| PAL 27C322.U36 |
| BATTERY|
| M59PW1282 62256 14.31818MHz |
| W9864G66 |
| |
|J VRENDERZERO+ |
|A W9864G66 |
|M W9864G66 |
|M 8MHz |
|A HY04 0260F8A |
| 28.63636MHz |
| |
| VR1 TLDA1311 |
| TDA1519|
| 18WAY VOL 10WAY |
|--------------------------------------|
Notes:
0260F8A - unknown TQFP44
HY04 - rebadged DIP8 PIC - type unknown *
W9864G66 - Winbond 64MBit DRAM
M59PW1282 - ST Microelectronics 128MBit SOP44 FlashROM.
This is two 64MB SOP44 ROMs in one package
* The pins are:
1 ground
2 nothing
3 data (only active for 1/4 second when the playing cards or "PASS" shows in game next to each player)
4 nothing
5 nothing
6 clock
7 +5V (could be VPP for programming voltage)
8 +5V
***************************************************************************/
// if you bypass the hy04 error, if fails with "THERE IS NO IMAGE" as it tries to load files from the flash.
// Indeed, apart from logo.bmp, the rest of the filenames it tries to load are not in the flash.
ROM_START( crzyddz2 )
ROM_REGION32_LE( 0x3000000, "user1", ROMREGION_ERASEFF ) // Flash
ROM_LOAD( "rom.u48", 0x000000, 0x1000000, CRC(e24257c4) SHA1(569d79a61ff6d35100ba5727069363146df9e0b7) )
ROM_REGION( 0x1000000, "maincpu", ROMREGION_ERASEFF )
ROM_COPY( "user1", 0x000000, 0x000000, 0x1000000 ) // copy flash here
ROM_LOAD( "27c322.u36", 0x000000, 0x0200000, CRC(b3177f39) SHA1(2a28bf8045bd2e053d88549b79fbc11f30ef9a32) ) // 1ST AND 2ND HALF IDENTICAL
ROM_CONTINUE( 0x000000, 0x0200000 )
ROM_REGION( 0x4280, "pic", 0 ) // hy04
ROM_LOAD("hy04", 0x000000, 0x4280, NO_DUMP )
ROM_REGION( 0x1000000, "user2", ROMREGION_ERASEFF ) // Unmapped flash
ROM_END
@ -1416,8 +1526,9 @@ GAME( 2001, crysbios, 0, crystal, crystal, driver_device, 0, ROT
GAME( 2001, crysking, crysbios, crystal, crystal, crystal_state, crysking, ROT0, "BrezzaSoft", "The Crystal of Kings", 0 ) GAME( 2001, crysking, crysbios, crystal, crystal, crystal_state, crysking, ROT0, "BrezzaSoft", "The Crystal of Kings", 0 )
GAME( 2001, evosocc, crysbios, crystal, crystal, crystal_state, evosocc, ROT0, "Evoga", "Evolution Soccer", 0 ) GAME( 2001, evosocc, crysbios, crystal, crystal, crystal_state, evosocc, ROT0, "Evoga", "Evolution Soccer", 0 )
GAME( 2003, topbladv, crysbios, crystal, crystal, crystal_state, topbladv, ROT0, "SonoKong / Expotato", "Top Blade V", 0 ) GAME( 2003, topbladv, crysbios, crystal, crystal, crystal_state, topbladv, ROT0, "SonoKong / Expotato", "Top Blade V", 0 )
GAME( 2001, officeye, 0, crystal, officeye,crystal_state, officeye, ROT0, "Danbi", "Office Yeo In Cheon Ha (version 1.2)", MACHINE_NOT_WORKING ) // still has some instability issues GAME( 2001, officeye, 0, crystal, officeye,crystal_state, officeye, ROT0, "Danbi", "Office Yeo In Cheon Ha (version 1.2)", MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION ) // still has some instability issues
GAME( 2001, donghaer, 0, crystal, crystal, crystal_state, donghaer, ROT0, "Danbi", "Donggul Donggul Haerong", MACHINE_NOT_WORKING ) GAME( 2001, donghaer, 0, crystal, crystal, crystal_state, donghaer, ROT0, "Danbi", "Donggul Donggul Haerong", MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION )
GAME( 2006, crzyddz2, 0, crzyddz2, crystal, driver_device, 0, ROT0, "Sealy", "Crazy Dou Di Zhu II", MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION )
GAME( 2009, trivrus, 0, trivrus, trivrus, driver_device, 0, ROT0, "AGT", "Trivia R Us (v1.07)", 0 ) GAME( 2009, trivrus, 0, trivrus, trivrus, driver_device, 0, ROT0, "AGT", "Trivia R Us (v1.07)", 0 )
// has a CF card instead of flash roms // has a CF card instead of flash roms
GAME( 2004, psattack, 0, crystal, crystal, crystal_state, psattack, ROT0, "Uniana", "P's Attack", MACHINE_IS_SKELETON ) GAME( 2004, psattack, 0, crystal, crystal, crystal_state, psattack, ROT0, "Uniana", "P's Attack", MACHINE_IS_SKELETON )

View File

@ -1084,8 +1084,8 @@ static ADDRESS_MAP_START( mjelctrn_io_map, AS_IO, 8, dynax_state )
AM_RANGE( 0x81, 0x81 ) AM_READ_PORT("COINS") // Coins AM_RANGE( 0x81, 0x81 ) AM_READ_PORT("COINS") // Coins
AM_RANGE( 0x82, 0x82 ) AM_READ(mjelctrn_keyboard_1_r) // P2 AM_RANGE( 0x82, 0x82 ) AM_READ(mjelctrn_keyboard_1_r) // P2
AM_RANGE( 0x83, 0x83 ) AM_READ(hanamai_keyboard_0_r) // P1 AM_RANGE( 0x83, 0x83 ) AM_READ(hanamai_keyboard_0_r) // P1
AM_RANGE( 0x84, 0x84 ) AM_READ(mjelctrn_dsw_r) // DSW x 4 AM_RANGE( 0x84, 0x84 ) AM_READ(mjelctrn_dsw_r) // DSW8 x 4
AM_RANGE( 0x85, 0x85 ) AM_READ(ret_ff) // ? AM_RANGE( 0x85, 0x85 ) AM_READ_PORT("SW1") // DSW2
AM_RANGE( 0xa1, 0xa7 ) AM_WRITE(dynax_blitter_rev2_w) // Blitter AM_RANGE( 0xa1, 0xa7 ) AM_WRITE(dynax_blitter_rev2_w) // Blitter
AM_RANGE( 0xc0, 0xc0 ) AM_WRITE(dynax_flipscreen_w) // Flip Screen AM_RANGE( 0xc0, 0xc0 ) AM_WRITE(dynax_flipscreen_w) // Flip Screen
AM_RANGE( 0xc1, 0xc1 ) AM_WRITE(hanamai_layer_half_w) // half of the interleaved layer to write to AM_RANGE( 0xc1, 0xc1 ) AM_WRITE(hanamai_layer_half_w) // half of the interleaved layer to write to
@ -2627,15 +2627,14 @@ static INPUT_PORTS_START( mjdialq2 )
PORT_DIPSETTING( 0x04, DEF_STR( Off ) ) PORT_DIPSETTING( 0x04, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x38, 0x20, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW1:4,5,6") PORT_DIPNAME( 0x38, 0x20, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW1:4,5,6")
PORT_DIPSETTING( 0x38, "1 (Easy)" ) PORT_DIPSETTING( 0x38, "1 (Easy)" )
PORT_DIPSETTING( 0x30, "2" ) PORT_DIPSETTING( 0x30, "2" )
PORT_DIPSETTING( 0x28, "3" ) PORT_DIPSETTING( 0x28, "3" )
PORT_DIPSETTING( 0x20, "4" ) PORT_DIPSETTING( 0x20, "4" )
PORT_DIPSETTING( 0x18, "5" ) PORT_DIPSETTING( 0x18, "5" )
PORT_DIPSETTING( 0x10, "6" ) PORT_DIPSETTING( 0x10, "6" )
PORT_DIPSETTING( 0x08, "7" ) PORT_DIPSETTING( 0x08, "7" )
PORT_DIPSETTING( 0x00, "8 (Hard)" ) PORT_DIPSETTING( 0x00, "8 (Hard)" )
PORT_DIPNAME( 0x40, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW1:7") PORT_DIPNAME( 0x40, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW1:7")
PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) )
@ -3402,32 +3401,49 @@ static INPUT_PORTS_START( mjembase )
INPUT_PORTS_END INPUT_PORTS_END
// dip locations verified on mjelctrb pcb
static INPUT_PORTS_START( mjelct3 ) static INPUT_PORTS_START( mjelct3 )
PORT_START("COINS")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_GAMBLE_PAYOUT ) PORT_CODE(KEYCODE_4) // Pay
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN ) // 18B
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) // Test
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE2 ) // Analyzer
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MEMORY_RESET ) // Memory Reset
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 ) // Note
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) // Coin
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 ) // Service
PORT_INCLUDE( MAHJONG_KEYS_BET )
PORT_START("SW1") // port 85
PORT_DIPUNKNOWN_DIPLOC(0x01, 0x01, "SW1:1")
PORT_DIPUNKNOWN_DIPLOC(0x02, 0x02, "SW1:2")
PORT_START("DSW0") /* 7c21 (select = 00) */ PORT_START("DSW0") /* 7c21 (select = 00) */
PORT_DIPNAME( 0x03, 0x03, "Difficulty?" ) PORT_DIPNAME( 0x03, 0x03, "Difficulty?" ) PORT_DIPLOCATION("SW3:1,2")
PORT_DIPSETTING( 0x03, "0" ) // 20 PORT_DIPSETTING( 0x03, "0" ) // 20
PORT_DIPSETTING( 0x00, "1" ) // 32 PORT_DIPSETTING( 0x00, "1" ) // 32
PORT_DIPSETTING( 0x01, "2" ) // 64 PORT_DIPSETTING( 0x01, "2" ) // 64
PORT_DIPSETTING( 0x02, "3" ) // c8 PORT_DIPSETTING( 0x02, "3" ) // c8
PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Coin_A ) ) PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SW3:3,4")
PORT_DIPSETTING( 0x0c, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x0c, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x08, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x08, DEF_STR( 1C_2C ) )
PORT_DIPSETTING( 0x04, DEF_STR( 1C_5C ) ) PORT_DIPSETTING( 0x04, DEF_STR( 1C_5C ) )
PORT_DIPSETTING( 0x00, "1 Coin/10 Credits" ) PORT_DIPSETTING( 0x00, "1 Coin/10 Credits" )
PORT_DIPNAME( 0x30, 0x30, "Min Pay?" ) PORT_DIPNAME( 0x30, 0x30, "Min Pay?" ) PORT_DIPLOCATION("SW3:5,6")
PORT_DIPSETTING( 0x30, "1" ) PORT_DIPSETTING( 0x30, "1" )
PORT_DIPSETTING( 0x20, "2" ) PORT_DIPSETTING( 0x20, "2" )
PORT_DIPSETTING( 0x10, "3" ) PORT_DIPSETTING( 0x10, "3" )
PORT_DIPSETTING( 0x00, "5" ) PORT_DIPSETTING( 0x00, "5" )
PORT_DIPNAME( 0x40, 0x40, "Allow Coin Out" ) PORT_DIPNAME( 0x40, 0x40, "Allow Coin Out" ) PORT_DIPLOCATION("SW3:7")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x40, DEF_STR( On ) ) PORT_DIPSETTING( 0x40, DEF_STR( On ) )
PORT_DIPNAME( 0x80, 0x80, "Win A Prize?" ) PORT_DIPNAME( 0x80, 0x80, "Win A Prize?" ) PORT_DIPLOCATION("SW3:8")
PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_START("DSW1") /* 7c20 (select = 40) */ PORT_START("DSW1") /* 7c20 (select = 40) */
PORT_DIPNAME( 0x0f, 0x07, "Pay Out Rate" ) PORT_DIPNAME( 0x0f, 0x07, "Pay Out Rate" ) PORT_DIPLOCATION("SW4:1,2,3,4")
PORT_DIPSETTING( 0x00, "50" ) PORT_DIPSETTING( 0x00, "50" )
PORT_DIPSETTING( 0x01, "53" ) PORT_DIPSETTING( 0x01, "53" )
PORT_DIPSETTING( 0x02, "56" ) PORT_DIPSETTING( 0x02, "56" )
@ -3444,32 +3460,20 @@ static INPUT_PORTS_START( mjelct3 )
PORT_DIPSETTING( 0x0d, "90" ) PORT_DIPSETTING( 0x0d, "90" )
PORT_DIPSETTING( 0x0e, "93" ) PORT_DIPSETTING( 0x0e, "93" )
PORT_DIPSETTING( 0x0f, "96" ) PORT_DIPSETTING( 0x0f, "96" )
PORT_DIPNAME( 0x30, 0x30, "Max Bet" ) PORT_DIPNAME( 0x30, 0x30, "Max Bet" ) PORT_DIPLOCATION("SW4:5,6")
PORT_DIPSETTING( 0x30, "1" ) PORT_DIPSETTING( 0x30, "1" )
PORT_DIPSETTING( 0x20, "5" ) PORT_DIPSETTING( 0x20, "5" )
PORT_DIPSETTING( 0x10, "10" ) PORT_DIPSETTING( 0x10, "10" )
PORT_DIPSETTING( 0x00, "20" ) PORT_DIPSETTING( 0x00, "20" )
PORT_DIPNAME( 0x40, 0x40, DEF_STR( Coin_B ) ) PORT_DIPNAME( 0x40, 0x40, DEF_STR( Coin_B ) ) PORT_DIPLOCATION("SW4:7")
PORT_DIPSETTING( 0x40, DEF_STR( 1C_5C ) ) PORT_DIPSETTING( 0x40, DEF_STR( 1C_5C ) )
PORT_DIPSETTING( 0x00, "1 Coin/10 Credits" ) PORT_DIPSETTING( 0x00, "1 Coin/10 Credits" )
PORT_DIPNAME( 0x80, 0x80, DEF_STR( Flip_Screen ) ) PORT_DIPNAME( 0x80, 0x80, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW4:8")
PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_START("COINS")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_GAMBLE_PAYOUT ) PORT_CODE(KEYCODE_4) // Pay
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN ) // 18B
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) // Test
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE2 ) // Analyzer
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MEMORY_RESET ) // Memory Reset
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 ) // Note
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) // Coin
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 ) // Service
PORT_INCLUDE( MAHJONG_KEYS_BET )
PORT_START("DSW2") /* 7c22 (select = 80) */ PORT_START("DSW2") /* 7c22 (select = 80) */
PORT_DIPNAME( 0x07, 0x07, "YAKUMAN Bonus" ) PORT_DIPNAME( 0x07, 0x07, "YAKUMAN Bonus" ) PORT_DIPLOCATION("SW2:1,2,3")
PORT_DIPSETTING( 0x07, "Cut" ) PORT_DIPSETTING( 0x07, "Cut" )
PORT_DIPSETTING( 0x06, "1 T" ) PORT_DIPSETTING( 0x06, "1 T" )
PORT_DIPSETTING( 0x05, "300" ) PORT_DIPSETTING( 0x05, "300" )
@ -3478,45 +3482,45 @@ static INPUT_PORTS_START( mjelct3 )
PORT_DIPSETTING( 0x02, "1000" ) PORT_DIPSETTING( 0x02, "1000" )
// PORT_DIPSETTING( 0x01, "1000" ) // PORT_DIPSETTING( 0x01, "1000" )
// PORT_DIPSETTING( 0x00, "1000" ) // PORT_DIPSETTING( 0x00, "1000" )
PORT_DIPNAME( 0x08, 0x08, "YAKU times" ) PORT_DIPNAME( 0x08, 0x08, "YAKU times" ) PORT_DIPLOCATION("SW2:4")
PORT_DIPSETTING( 0x08, "1" ) PORT_DIPSETTING( 0x08, "1" )
PORT_DIPSETTING( 0x00, "2" ) PORT_DIPSETTING( 0x00, "2" )
PORT_DIPNAME( 0x10, 0x10, "Win Rate?" ) PORT_DIPNAME( 0x10, 0x10, "Win Rate?" ) PORT_DIPLOCATION("SW2:5")
PORT_DIPSETTING( 0x10, DEF_STR( High ) ) PORT_DIPSETTING( 0x10, DEF_STR( High ) )
PORT_DIPSETTING( 0x00, DEF_STR( Low ) ) PORT_DIPSETTING( 0x00, DEF_STR( Low ) )
PORT_DIPNAME( 0x20, 0x20, "Draw New Tile (Part 3 Only)" ) PORT_DIPNAME( 0x20, 0x20, "Draw New Tile (Part 3 Only)" ) PORT_DIPLOCATION("SW2:6")
PORT_DIPSETTING( 0x00, "Automatic" ) PORT_DIPSETTING( 0x00, "Automatic" )
PORT_DIPSETTING( 0x20, "Manual" ) PORT_DIPSETTING( 0x20, "Manual" )
PORT_DIPNAME( 0x40, 0x40, "DonDen Key" ) PORT_DIPNAME( 0x40, 0x40, "DonDen Key" ) PORT_DIPLOCATION("SW2:7")
PORT_DIPSETTING( 0x40, "A" ) PORT_DIPSETTING( 0x40, "A" )
PORT_DIPSETTING( 0x00, "Flip Flop" ) PORT_DIPSETTING( 0x00, "Flip Flop" )
PORT_DIPNAME( 0x80, 0x00, "Subtitle" ) PORT_DIPNAME( 0x80, 0x00, "Subtitle" ) PORT_DIPLOCATION("SW2:8")
PORT_DIPSETTING( 0x80, "None (Part 2)" ) PORT_DIPSETTING( 0x80, "None (Part 2)" )
PORT_DIPSETTING( 0x00, "Super Express (Part 3)" ) PORT_DIPSETTING( 0x00, "Super Express (Part 3)" )
PORT_START("DSW3") /* 7c23 (select = c0) */ PORT_START("DSW3") /* 7c23 (select = c0) */
PORT_DIPNAME( 0x01, 0x01, "Last Chance" ) PORT_DIPNAME( 0x01, 0x01, "Last Chance" ) PORT_DIPLOCATION("SW5:1")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x01, DEF_STR( On ) ) PORT_DIPSETTING( 0x01, DEF_STR( On ) )
PORT_DIPNAME( 0x02, 0x02, "Pay Rate?" ) PORT_DIPNAME( 0x02, 0x02, "Pay Rate?" ) PORT_DIPLOCATION("SW5:2")
PORT_DIPSETTING( 0x02, DEF_STR( High ) ) PORT_DIPSETTING( 0x02, DEF_STR( High ) )
PORT_DIPSETTING( 0x00, DEF_STR( Low ) ) PORT_DIPSETTING( 0x00, DEF_STR( Low ) )
PORT_DIPNAME( 0x04, 0x04, "Choose Bonus" ) PORT_DIPNAME( 0x04, 0x04, "Choose Bonus" ) PORT_DIPLOCATION("SW5:3")
PORT_DIPSETTING( 0x04, DEF_STR( Off ) ) PORT_DIPSETTING( 0x04, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x08, 0x08, "In-Game Bet?" ) PORT_DIPNAME( 0x08, 0x08, "In-Game Bet?" ) PORT_DIPLOCATION("SW5:4")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x08, DEF_STR( On ) ) PORT_DIPSETTING( 0x08, DEF_STR( On ) )
PORT_DIPNAME( 0x10, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPNAME( 0x10, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW5:5")
PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) PORT_DIPSETTING( 0x10, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x20, 0x00, "In-Game Music" ) PORT_DIPNAME( 0x20, 0x00, "In-Game Music" ) PORT_DIPLOCATION("SW5:6")
PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) PORT_DIPSETTING( 0x20, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x40, 0x40, "Select Girl" ) PORT_DIPNAME( 0x40, 0x40, "Select Girl" ) PORT_DIPLOCATION("SW5:7")
PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x80, 0x00, "Nudity" ) PORT_DIPNAME( 0x80, 0x00, "Nudity" ) PORT_DIPLOCATION("SW5:8")
PORT_DIPSETTING( 0x00, DEF_STR( Yes ) ) PORT_DIPSETTING( 0x00, DEF_STR( Yes ) )
PORT_DIPSETTING( 0x80, DEF_STR( No ) ) // Moles On Gal's Face PORT_DIPSETTING( 0x80, DEF_STR( No ) ) // Moles On Gal's Face
@ -3528,31 +3532,47 @@ INPUT_PORTS_END
static INPUT_PORTS_START( mjelctrn ) static INPUT_PORTS_START( mjelctrn )
PORT_START("COINS")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_GAMBLE_PAYOUT ) PORT_CODE(KEYCODE_4) // Pay
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN ) // 18B
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) // Test
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE2 ) // Analyzer
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MEMORY_RESET ) // Memory Reset
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 ) // Note
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) // Coin
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 ) // Service
PORT_INCLUDE( MAHJONG_KEYS_BET )
PORT_START("SW1") // port 85
PORT_DIPUNKNOWN_DIPLOC(0x01, 0x01, "SW1:1")
PORT_DIPUNKNOWN_DIPLOC(0x02, 0x02, "SW1:2")
PORT_START("DSW0") /* 7c21 (select = 00) */ PORT_START("DSW0") /* 7c21 (select = 00) */
PORT_DIPNAME( 0x03, 0x03, "Difficulty?" ) PORT_DIPNAME( 0x03, 0x03, "Difficulty?" ) PORT_DIPLOCATION("SW3:1,2")
PORT_DIPSETTING( 0x03, "0" ) // 20 PORT_DIPSETTING( 0x03, "0" ) // 20
PORT_DIPSETTING( 0x00, "1" ) // 32 PORT_DIPSETTING( 0x00, "1" ) // 32
PORT_DIPSETTING( 0x01, "2" ) // 64 PORT_DIPSETTING( 0x01, "2" ) // 64
PORT_DIPSETTING( 0x02, "3" ) // c8 PORT_DIPSETTING( 0x02, "3" ) // c8
PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Coin_A ) ) PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SW3:3,4")
PORT_DIPSETTING( 0x0c, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x0c, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x08, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x08, DEF_STR( 1C_2C ) )
PORT_DIPSETTING( 0x04, DEF_STR( 1C_5C ) ) PORT_DIPSETTING( 0x04, DEF_STR( 1C_5C ) )
PORT_DIPSETTING( 0x00, "1 Coin/10 Credits" ) PORT_DIPSETTING( 0x00, "1 Coin/10 Credits" )
PORT_DIPNAME( 0x30, 0x30, "Min Pay?" ) PORT_DIPNAME( 0x30, 0x30, "Min Pay?" ) PORT_DIPLOCATION("SW3:5,6")
PORT_DIPSETTING( 0x30, "1" ) PORT_DIPSETTING( 0x30, "1" )
PORT_DIPSETTING( 0x20, "2" ) PORT_DIPSETTING( 0x20, "2" )
PORT_DIPSETTING( 0x10, "3" ) PORT_DIPSETTING( 0x10, "3" )
PORT_DIPSETTING( 0x00, "5" ) PORT_DIPSETTING( 0x00, "5" )
PORT_DIPNAME( 0x40, 0x40, "Allow Coin Out" ) PORT_DIPNAME( 0x40, 0x40, "Allow Coin Out" ) PORT_DIPLOCATION("SW3:7")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x40, DEF_STR( On ) ) PORT_DIPSETTING( 0x40, DEF_STR( On ) )
PORT_DIPNAME( 0x80, 0x80, "Win A Prize?" ) PORT_DIPNAME( 0x80, 0x80, "Win A Prize?" ) PORT_DIPLOCATION("SW3:8")
PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_START("DSW1") /* 7c20 (select = 40) */ PORT_START("DSW1") /* 7c20 (select = 40) */
PORT_DIPNAME( 0x0f, 0x07, "Pay Out Rate" ) PORT_DIPNAME( 0x0f, 0x07, "Pay Out Rate" ) PORT_DIPLOCATION("SW4:1,2,3,4")
PORT_DIPSETTING( 0x00, "50" ) PORT_DIPSETTING( 0x00, "50" )
PORT_DIPSETTING( 0x01, "53" ) PORT_DIPSETTING( 0x01, "53" )
PORT_DIPSETTING( 0x02, "56" ) PORT_DIPSETTING( 0x02, "56" )
@ -3569,32 +3589,20 @@ static INPUT_PORTS_START( mjelctrn )
PORT_DIPSETTING( 0x0d, "90" ) PORT_DIPSETTING( 0x0d, "90" )
PORT_DIPSETTING( 0x0e, "93" ) PORT_DIPSETTING( 0x0e, "93" )
PORT_DIPSETTING( 0x0f, "96" ) PORT_DIPSETTING( 0x0f, "96" )
PORT_DIPNAME( 0x30, 0x30, "Max Bet" ) PORT_DIPNAME( 0x30, 0x30, "Max Bet" ) PORT_DIPLOCATION("SW4:5,6")
PORT_DIPSETTING( 0x30, "1" ) PORT_DIPSETTING( 0x30, "1" )
PORT_DIPSETTING( 0x20, "5" ) PORT_DIPSETTING( 0x20, "5" )
PORT_DIPSETTING( 0x10, "10" ) PORT_DIPSETTING( 0x10, "10" )
PORT_DIPSETTING( 0x00, "20" ) PORT_DIPSETTING( 0x00, "20" )
PORT_DIPNAME( 0x40, 0x40, DEF_STR( Coin_B ) ) PORT_DIPNAME( 0x40, 0x40, DEF_STR( Coin_B ) ) PORT_DIPLOCATION("SW4:7")
PORT_DIPSETTING( 0x40, DEF_STR( 1C_5C ) ) PORT_DIPSETTING( 0x40, DEF_STR( 1C_5C ) )
PORT_DIPSETTING( 0x00, "1 Coin/10 Credits" ) PORT_DIPSETTING( 0x00, "1 Coin/10 Credits" )
PORT_DIPNAME( 0x80, 0x80, DEF_STR( Flip_Screen ) ) PORT_DIPNAME( 0x80, 0x80, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW4:8")
PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_START("COINS") PORT_START("DSW2") /* 7c22 (select = 80) */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_GAMBLE_PAYOUT ) PORT_CODE(KEYCODE_4) // Pay PORT_DIPNAME( 0x07, 0x07, "YAKUMAN Bonus" ) PORT_DIPLOCATION("SW2:1,2,3")
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN ) // 18B
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) // Test
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE2 ) // Analyzer
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MEMORY_RESET ) // Memory Reset
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 ) // Note
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) // Coin
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 ) // Service
PORT_INCLUDE( MAHJONG_KEYS_BET )
PORT_START("DSW2") /* 7c22 (select = 80) */
PORT_DIPNAME( 0x07, 0x07, "YAKUMAN Bonus" )
PORT_DIPSETTING( 0x07, "Cut" ) PORT_DIPSETTING( 0x07, "Cut" )
PORT_DIPSETTING( 0x06, "1 T" ) PORT_DIPSETTING( 0x06, "1 T" )
PORT_DIPSETTING( 0x05, "300" ) PORT_DIPSETTING( 0x05, "300" )
@ -3603,45 +3611,45 @@ static INPUT_PORTS_START( mjelctrn )
PORT_DIPSETTING( 0x02, "1000" ) PORT_DIPSETTING( 0x02, "1000" )
// PORT_DIPSETTING( 0x01, "1000" ) // PORT_DIPSETTING( 0x01, "1000" )
// PORT_DIPSETTING( 0x00, "1000" ) // PORT_DIPSETTING( 0x00, "1000" )
PORT_DIPNAME( 0x08, 0x08, "YAKU times" ) PORT_DIPNAME( 0x08, 0x08, "YAKU times" ) PORT_DIPLOCATION("SW2:4")
PORT_DIPSETTING( 0x08, "1" ) PORT_DIPSETTING( 0x08, "1" )
PORT_DIPSETTING( 0x00, "2" ) PORT_DIPSETTING( 0x00, "2" )
PORT_DIPNAME( 0x10, 0x10, "Win Rate?" ) PORT_DIPNAME( 0x10, 0x10, "Win Rate?" ) PORT_DIPLOCATION("SW2:5")
PORT_DIPSETTING( 0x10, DEF_STR( High ) ) PORT_DIPSETTING( 0x10, DEF_STR( High ) )
PORT_DIPSETTING( 0x00, DEF_STR( Low ) ) PORT_DIPSETTING( 0x00, DEF_STR( Low ) )
PORT_DIPNAME( 0x20, 0x20, "Draw New Tile (Part 4 Only)" ) PORT_DIPNAME( 0x20, 0x20, "Draw New Tile (Part 4 Only)" ) PORT_DIPLOCATION("SW2:6")
PORT_DIPSETTING( 0x00, "Automatic" ) PORT_DIPSETTING( 0x00, "Automatic" )
PORT_DIPSETTING( 0x20, "Manual" ) PORT_DIPSETTING( 0x20, "Manual" )
PORT_DIPNAME( 0x40, 0x40, "DonDen Key" ) PORT_DIPNAME( 0x40, 0x40, "DonDen Key" ) PORT_DIPLOCATION("SW2:7")
PORT_DIPSETTING( 0x40, "A" ) PORT_DIPSETTING( 0x40, "A" )
PORT_DIPSETTING( 0x00, "Flip Flop" ) PORT_DIPSETTING( 0x00, "Flip Flop" )
PORT_DIPNAME( 0x80, 0x00, "Subtitle" ) PORT_DIPNAME( 0x80, 0x00, "Subtitle" ) PORT_DIPLOCATION("SW2:8")
PORT_DIPSETTING( 0x80, "None (Part 2)" ) PORT_DIPSETTING( 0x80, "None (Part 2)" )
PORT_DIPSETTING( 0x00, "???? (Part 4)" ) PORT_DIPSETTING( 0x00, "???? (Part 4)" )
PORT_START("DSW3") // 7c23 (select = c0) PORT_START("DSW3") /* 7c23 (select = c0) */
PORT_DIPNAME( 0x01, 0x01, "Last Chance" ) PORT_DIPNAME( 0x01, 0x01, "Last Chance" ) PORT_DIPLOCATION("SW5:1")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x01, DEF_STR( On ) ) PORT_DIPSETTING( 0x01, DEF_STR( On ) )
PORT_DIPNAME( 0x02, 0x02, "Pay Rate?" ) PORT_DIPNAME( 0x02, 0x02, "Pay Rate?" ) PORT_DIPLOCATION("SW5:2")
PORT_DIPSETTING( 0x02, DEF_STR( High ) ) PORT_DIPSETTING( 0x02, DEF_STR( High ) )
PORT_DIPSETTING( 0x00, DEF_STR( Low ) ) PORT_DIPSETTING( 0x00, DEF_STR( Low ) )
PORT_DIPNAME( 0x04, 0x04, "Choose Bonus" ) PORT_DIPNAME( 0x04, 0x04, "Choose Bonus" ) PORT_DIPLOCATION("SW5:3")
PORT_DIPSETTING( 0x04, DEF_STR( Off ) ) PORT_DIPSETTING( 0x04, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x08, 0x08, "In-Game Bet?" ) PORT_DIPNAME( 0x08, 0x08, "In-Game Bet?" ) PORT_DIPLOCATION("SW5:4")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x08, DEF_STR( On ) ) PORT_DIPSETTING( 0x08, DEF_STR( On ) )
PORT_DIPNAME( 0x10, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPNAME( 0x10, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW5:5")
PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) PORT_DIPSETTING( 0x10, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x20, 0x00, "In-Game Music" ) PORT_DIPNAME( 0x20, 0x00, "In-Game Music" ) PORT_DIPLOCATION("SW5:6")
PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) PORT_DIPSETTING( 0x20, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x40, 0x40, "Select Girl" ) PORT_DIPNAME( 0x40, 0x40, "Select Girl" ) PORT_DIPLOCATION("SW5:7")
PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x80, 0x00, "Girls" ) PORT_DIPNAME( 0x80, 0x00, "Girls" ) PORT_DIPLOCATION("SW5:8")
PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) )
@ -3774,6 +3782,9 @@ static INPUT_PORTS_START( majxtal7 )
PORT_DIPNAME( 0xff, 0xff, DEF_STR( Unknown ) ) PORT_DIPNAME( 0xff, 0xff, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0xff, DEF_STR( On ) ) PORT_DIPSETTING( 0xff, DEF_STR( On ) )
/* the following are needed to make happy the read handlers shared with mjelctrn */
PORT_START("SW1")
INPUT_PORTS_END INPUT_PORTS_END
static INPUT_PORTS_START( neruton ) static INPUT_PORTS_START( neruton )
@ -3841,6 +3852,7 @@ static INPUT_PORTS_START( neruton )
PORT_INCLUDE( MAHJONG_KEYS ) PORT_INCLUDE( MAHJONG_KEYS )
/* 2008-06 FP: the following are needed to make happy the read handlers shared with mjelctrn */ /* 2008-06 FP: the following are needed to make happy the read handlers shared with mjelctrn */
PORT_START("SW1")
PORT_START("DSW2") PORT_START("DSW2")
PORT_START("DSW3") PORT_START("DSW3")
PORT_START("FAKE") PORT_START("FAKE")
@ -6236,9 +6248,6 @@ ROM_END
/*************************************************************************** /***************************************************************************
Mahjong Electron Base (bootleg) Mahjong Electron Base (bootleg)
PCB works (see s/shot in archive), but I couldn't get it
to do anything other than show a diagnostic screen??
PCB Layout PCB Layout
---------- ----------

View File

@ -21,8 +21,8 @@ Year + Game PCB CPU Sound Custom
98 Mj Long Hu Zheng Ba 2 NO-0206 68000 M6295 IGS031 IGS025 IGS022* Battery 98 Mj Long Hu Zheng Ba 2 NO-0206 68000 M6295 IGS031 IGS025 IGS022* Battery
98 Mj Shuang Long Qiang Zhu 2 NO-0207 68000 M6295 IGS031 IGS025 IGS022 Battery 98 Mj Shuang Long Qiang Zhu 2 NO-0207 68000 M6295 IGS031 IGS025 IGS022 Battery
98 Mj Man Guan Cai Shen NO-0192-1 68000 M6295 IGS017 IGS025 IGS029 Battery 98 Mj Man Guan Cai Shen NO-0192-1 68000 M6295 IGS017 IGS025 IGS029 Battery
99? Tarzan (V107)? NO-0248-1 Z180 M6295 IGS031 IGS025 Battery 99 Tarzan (V107) NO-0228? Z180 M6295 IGS031 IGS025 IGS029 Battery
99? Tarzan (V109C)? NO-0228? Z180 M6295 IGS031 IGS025 IGS029 Battery 99 Tarzan (V109C) NO-0248-1 Z180 M6295 IGS031 IGS025 Battery
00? Super Tarzan (V100I) NO-0230-1 Z180 M6295 IGS031 IGS025 Battery 00? Super Tarzan (V100I) NO-0230-1 Z180 M6295 IGS031 IGS025 Battery
?? Super Poker / Formosa NO-0187 Z180 M6295 YM2413 IGS017 IGS025 Battery ?? Super Poker / Formosa NO-0187 Z180 M6295 YM2413 IGS017 IGS025 Battery
------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------
@ -181,6 +181,9 @@ public:
void mgcs_flip_sprites(); void mgcs_flip_sprites();
void mgcs_patch_rom(); void mgcs_patch_rom();
void mgcs_igs029_run(); void mgcs_igs029_run();
void tarzan_decrypt_tiles();
void tarzan_decrypt_program_rom();
void tarzana_decrypt_program_rom();
void starzan_decrypt(UINT8 *ROM, int size, bool isOpcode); void starzan_decrypt(UINT8 *ROM, int size, bool isOpcode);
void lhzb2_patch_rom(); void lhzb2_patch_rom();
void lhzb2_decrypt_tiles(); void lhzb2_decrypt_tiles();
@ -488,8 +491,23 @@ DRIVER_INIT_MEMBER(igs017_state,mgcs)
// tarzan, tarzana // tarzan, tarzana
void igs017_state::tarzan_decrypt_tiles()
{
int length = memregion("tilemaps")->bytes();
UINT8 *rom = memregion("tilemaps")->base();
dynamic_buffer tmp(length);
int i;
memcpy(&tmp[0],rom,length);
for (i = 0;i < length;i++)
{
int addr = (i & ~0xffff) | BITSWAP16(i,15,14,13,12,11,7,8,6,10,9,5,4,3,2,1,0);
rom[i] = BITSWAP8(tmp[addr],0,1,2,3,4,5,6,7);
}
}
// decryption is incomplete, the first part of code doesn't seem right. // decryption is incomplete, the first part of code doesn't seem right.
DRIVER_INIT_MEMBER(igs017_state,tarzan) void igs017_state::tarzan_decrypt_program_rom()
{ {
UINT16 *ROM = (UINT16 *)memregion("maincpu")->base(); UINT16 *ROM = (UINT16 *)memregion("maincpu")->base();
int i; int i;
@ -515,7 +533,7 @@ DRIVER_INIT_MEMBER(igs017_state,tarzan)
} }
} }
// by iq_132 // by iq_132
DRIVER_INIT_MEMBER(igs017_state,tarzana) void igs017_state::tarzana_decrypt_program_rom()
{ {
UINT8 *ROM = memregion("maincpu")->base(); UINT8 *ROM = memregion("maincpu")->base();
int i; int i;
@ -533,6 +551,17 @@ DRIVER_INIT_MEMBER(igs017_state,tarzana)
} }
} }
DRIVER_INIT_MEMBER(igs017_state,tarzan)
{
tarzan_decrypt_program_rom();
tarzan_decrypt_tiles();
}
DRIVER_INIT_MEMBER(igs017_state,tarzana)
{
tarzana_decrypt_program_rom();
// tarzana_decrypt_tiles(); // to do
}
// starzan // starzan
@ -4089,17 +4118,75 @@ ROM_END
/*************************************************************************** /***************************************************************************
Tarzan Taishan (Tarzan) Chuang Tian Guan
IGS 1999
PCB Layout
----------
IGS PCB NO-0248-1
|------------------------------|
| J A M M A |
|1 22MHz T2105.U5 A2104.U15 |
|8 DIP42 |
|W |
|A IGS031 U19 |
|Y 24257 |
| |
| IGS025 PAL.U20|
| DSW1 |
| Z180 |
| DSW2 16MHz |
|1 PAL.U21|
|0 DSW3 |
|W BATT |
|A VOL LM7805 RES_SW|
|Y UPC1242 M6295 U14 |
|------------------------------|
Notes:
IGS025 - custom IGS chip labelled 'TARZAN 1'
IGS031 - custom IGS chip
VSync - 60.0060Hz
HSync - 15.3002kHz
M6295 - Clock 1.000MHz [16/16], pin 7 high
Z180 - Clock 16.000MHz
DIP42 - Empty socket
U19 - 28F2000 Flash ROM (DIP32)
U14 - 23C4000 mask ROM (DIP32)
U5 - 23C2048 mask ROM (DIP40)
U15 - 23C3210 mask ROM (DIP42)
24257 - 32kx8 SRAM
***************************************************************************/ ***************************************************************************/
// IGS PCB NO-0248-1
ROM_START( tarzanc )
ROM_REGION( 0x40000, "maincpu", 0 ) // V109C TARZAN C (same as tarzan set)
ROM_LOAD( "u19", 0x00000, 0x40000, CRC(e6c552a5) SHA1(f156de9459833474c85a1f5b35917881b390d34c) )
ROM_REGION( 0x400000, "sprites", 0 )
ROM_LOAD( "igs_a2104_cg_v110.u15", 0x00000, 0x400000, CRC(dcbff16f) SHA1(2bf77ef4448c26124c8d8d18bb7ffe4105cfa940) ) // FIXED BITS (xxxxxxx0xxxxxxxx)
ROM_REGION( 0x80000, "tilemaps", 0 )
ROM_LOAD( "igs_t2105_cg_v110.u5", 0x00000, 0x80000, CRC(1d4be260) SHA1(6374c61735144b3ff54d5e490f26adac4a10b14d) ) // 27C4096 (27C2048 printed on the PCB)
ROM_REGION( 0x80000, "oki", 0 )
ROM_LOAD( "igs_s2102_sp_v102.u14", 0x00000, 0x80000, CRC(90dda82d) SHA1(67fbc1e8d76b85e124136e2f1df09c8b6c5a8f97) )
ROM_REGION( 0x2dd * 2, "plds", 0 )
ROM_LOAD( "eg.u20", 0x000, 0x2dd, NO_DUMP )
ROM_LOAD( "eg.u21", 0x2dd, 0x2dd, NO_DUMP )
ROM_END
// sets below are guesswork, assembled from partial dumps...
// IGS NO-0248-1? Mislabeled? // IGS NO-0248-1? Mislabeled?
ROM_START( tarzan ) ROM_START( tarzan )
ROM_REGION( 0x40000, "maincpu", 0 ) // V109C TARZAN C ROM_REGION( 0x40000, "maincpu", 0 ) // V109C TARZAN C (same as tarzanc set)
ROM_LOAD( "0228-u16.bin", 0x00000, 0x40000, CRC(e6c552a5) SHA1(f156de9459833474c85a1f5b35917881b390d34c) ) ROM_LOAD( "0228-u16.bin", 0x00000, 0x40000, CRC(e6c552a5) SHA1(f156de9459833474c85a1f5b35917881b390d34c) )
ROM_REGION( 0x80000, "sprites", 0 ) ROM_REGION( 0x80000, "sprites", 0 )
ROM_LOAD( "a2104_cg_v110.u15", 0x00000, 0x80000, NO_DUMP ) ROM_LOAD( "sprites.u15", 0x00000, 0x80000, NO_DUMP )
ROM_REGION( 0x80000, "tilemaps", 0 ) ROM_REGION( 0x80000, "tilemaps", 0 )
ROM_LOAD( "0228-u6.bin", 0x00000, 0x80000, CRC(55e94832) SHA1(b15409f4f1264b6d1218d5dc51c5bd1de2e40284) ) ROM_LOAD( "0228-u6.bin", 0x00000, 0x80000, CRC(55e94832) SHA1(b15409f4f1264b6d1218d5dc51c5bd1de2e40284) )
@ -4108,20 +4195,20 @@ ROM_START( tarzan )
ROM_LOAD( "sound.u14", 0x00000, 0x40000, NO_DUMP ) ROM_LOAD( "sound.u14", 0x00000, 0x40000, NO_DUMP )
ROM_REGION( 0x2dd * 2, "plds", 0 ) ROM_REGION( 0x2dd * 2, "plds", 0 )
ROM_LOAD( "eg.u20", 0x000, 0x2dd, NO_DUMP ) ROM_LOAD( "pal1", 0x000, 0x2dd, NO_DUMP )
ROM_LOAD( "eg.u21", 0x2dd, 0x2dd, NO_DUMP ) ROM_LOAD( "pal2", 0x2dd, 0x2dd, NO_DUMP )
ROM_END ROM_END
// IGS NO-0228? // IGS NO-0228?
ROM_START( tarzana ) ROM_START( tarzana )
ROM_REGION( 0x80000, "maincpu", 0 ) // V107 TAISAN ROM_REGION( 0x80000, "maincpu", 0 ) // V107 TAISAN
ROM_LOAD( "0228-u21.bin", 0x00000, 0x80000, CRC(80aaece4) SHA1(07cad92492c5de36c3915867ed4c6544b1a30c07) ) ROM_LOAD( "0228-u21.bin", 0x00000, 0x80000, CRC(80aaece4) SHA1(07cad92492c5de36c3915867ed4c6544b1a30c07) ) // 1ST AND 2ND HALF IDENTICAL
ROM_REGION( 0x80000, "sprites", 0 ) ROM_REGION( 0x80000, "sprites", 0 )
ROM_LOAD( "sprites.u17", 0x00000, 0x80000, NO_DUMP ) ROM_LOAD( "sprites.u17", 0x00000, 0x80000, NO_DUMP )
ROM_REGION( 0x80000, "tilemaps", 0 ) ROM_REGION( 0x80000, "tilemaps", 0 )
ROM_LOAD( "text.u6", 0x00000, 0x80000, NO_DUMP ) ROM_LOAD( "0228-u6.bin", 0x00000, 0x80000, CRC(55e94832) SHA1(b15409f4f1264b6d1218d5dc51c5bd1de2e40284) )
ROM_REGION( 0x40000, "oki", ROMREGION_ERASE ) ROM_REGION( 0x40000, "oki", ROMREGION_ERASE )
ROM_LOAD( "sound.u16", 0x00000, 0x40000, NO_DUMP ) ROM_LOAD( "sound.u16", 0x00000, 0x40000, NO_DUMP )
@ -4232,19 +4319,20 @@ ROM_START( spkrform )
ROM_END ROM_END
GAME( 1996, iqblocka, iqblock, iqblocka, iqblocka, igs017_state, iqblocka, ROT0, "IGS", "Shu Zi Le Yuan (V127M)", MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION ) GAME( 1996, iqblocka, iqblock, iqblocka, iqblocka, igs017_state, iqblocka, ROT0, "IGS", "Shu Zi Le Yuan (V127M)", MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION )
GAME( 1996, iqblockf, iqblock, iqblocka, iqblocka, igs017_state, iqblockf, ROT0, "IGS", "Shu Zi Le Yuan (V113FR)", MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION ) GAME( 1996, iqblockf, iqblock, iqblocka, iqblocka, igs017_state, iqblockf, ROT0, "IGS", "Shu Zi Le Yuan (V113FR)", MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION )
GAME( 1997, mgdh, 0, mgdha, mgdh, igs017_state, mgdh, ROT0, "IGS", "Mahjong Man Guan Da Heng (Taiwan, V125T1)", 0 ) GAME( 1997, mgdh, 0, mgdha, mgdh, igs017_state, mgdh, ROT0, "IGS", "Mahjong Man Guan Da Heng (Taiwan, V125T1)", 0 )
GAME( 1997, mgdha, mgdh, mgdha, mgdh , igs017_state, mgdha, ROT0, "IGS", "Mahjong Man Guan Da Heng (Taiwan, V123T1)", 0 ) GAME( 1997, mgdha, mgdh, mgdha, mgdh , igs017_state, mgdha, ROT0, "IGS", "Mahjong Man Guan Da Heng (Taiwan, V123T1)", 0 )
GAME( 1997, sdmg2, 0, sdmg2, sdmg2, igs017_state, sdmg2, ROT0, "IGS", "Mahjong Super Da Man Guan II (China, V754C)", 0 ) GAME( 1997, sdmg2, 0, sdmg2, sdmg2, igs017_state, sdmg2, ROT0, "IGS", "Mahjong Super Da Man Guan II (China, V754C)", 0 )
GAME( 1997, tjsb, 0, tjsb, tjsb, igs017_state, tjsb, ROT0, "IGS", "Mahjong Tian Jiang Shen Bing (V137C)", MACHINE_UNEMULATED_PROTECTION ) GAME( 1997, tjsb, 0, tjsb, tjsb, igs017_state, tjsb, ROT0, "IGS", "Mahjong Tian Jiang Shen Bing (V137C)", MACHINE_UNEMULATED_PROTECTION )
GAME( 1998, mgcs, 0, mgcs, mgcs, igs017_state, mgcs, ROT0, "IGS", "Mahjong Man Guan Cai Shen (V103CS)", MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION | MACHINE_IMPERFECT_SOUND ) GAME( 1998, mgcs, 0, mgcs, mgcs, igs017_state, mgcs, ROT0, "IGS", "Mahjong Man Guan Cai Shen (V103CS)", MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION | MACHINE_IMPERFECT_SOUND )
GAME( 1998, lhzb2, 0, lhzb2, lhzb2, igs017_state, lhzb2, ROT0, "IGS", "Mahjong Long Hu Zheng Ba 2 (set 1)", MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION ) GAME( 1998, lhzb2, 0, lhzb2, lhzb2, igs017_state, lhzb2, ROT0, "IGS", "Mahjong Long Hu Zheng Ba 2 (set 1)", MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION )
GAME( 1998, lhzb2a, lhzb2, lhzb2a, lhzb2a, igs017_state, lhzb2a, ROT0, "IGS", "Mahjong Long Hu Zheng Ba 2 (VS221M)", 0 ) GAME( 1998, lhzb2a, lhzb2, lhzb2a, lhzb2a, igs017_state, lhzb2a, ROT0, "IGS", "Mahjong Long Hu Zheng Ba 2 (VS221M)", 0 )
GAME( 1998, slqz2, 0, slqz2, slqz2, igs017_state, slqz2, ROT0, "IGS", "Mahjong Shuang Long Qiang Zhu 2 (VS203J)", MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION ) GAME( 1998, slqz2, 0, slqz2, slqz2, igs017_state, slqz2, ROT0, "IGS", "Mahjong Shuang Long Qiang Zhu 2 (VS203J)", MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION )
GAME( 1999?, tarzan, 0, iqblocka, iqblocka, igs017_state, tarzan, ROT0, "IGS", "Tarzan (V109C)", MACHINE_NOT_WORKING ) GAME( 1999, tarzanc, 0, iqblocka, iqblocka, igs017_state, tarzan, ROT0, "IGS", "Tarzan Chuang Tian Guan (V109C, set 1)", MACHINE_NOT_WORKING )
GAME( 1999?, tarzana, tarzan, iqblocka, iqblocka, igs017_state, tarzana, ROT0, "IGS", "Tarzan (V107)", MACHINE_NOT_WORKING ) GAME( 1999, tarzan, tarzanc, iqblocka, iqblocka, igs017_state, tarzan, ROT0, "IGS", "Tarzan Chuang Tian Guan (V109C, set 2)", MACHINE_NOT_WORKING )
GAME( 2000?, starzan, 0, starzan, iqblocka, igs017_state, starzan, ROT0, "IGS / G.F. Gioca", "Super Tarzan (Italy, V100I)", MACHINE_NOT_WORKING ) GAME( 1999, tarzana, tarzanc, iqblocka, iqblocka, igs017_state, tarzana, ROT0, "IGS", "Tarzan (V107)", MACHINE_NOT_WORKING )
GAME( 2000?, starzan, 0, starzan, iqblocka, igs017_state, starzan, ROT0, "IGS (G.F. Gioca license)", "Super Tarzan (Italy, V100I)", MACHINE_NOT_WORKING )
/* Parent spk306us in driver spoker.cpp. Move this set to that driver? */ /* Parent spk306us in driver spoker.cpp. Move this set to that driver? */
GAME( ????, spkrform, spk306us, spkrform, spkrform, igs017_state, spkrform, ROT0, "IGS", "Super Poker (v100xD03) / Formosa", MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION ) GAME( ????, spkrform, spk306us, spkrform, spkrform, igs017_state, spkrform, ROT0, "IGS", "Super Poker (v100xD03) / Formosa", MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION )

View File

@ -385,6 +385,7 @@ Cosmic Smash 840-0044C 23428 8 (64Mb)
Cosmic Smash (Rev A) 840-0044C 23428A 8 (64Mb) ? 315-6213 317-0289-COM joystick + 2 buttons Cosmic Smash (Rev A) 840-0044C 23428A 8 (64Mb) ? 315-6213 317-0289-COM joystick + 2 buttons
Crazy Taxi 840-0002C 21684 13 (64Mb)* present 315-6213 317-0248-COM * ic8 and ic9 are not present Crazy Taxi 840-0002C 21684 13 (64Mb)* present 315-6213 317-0248-COM * ic8 and ic9 are not present
Dead Or Alive 2 (Rev A) 841-0003C 22121A 21 (64Mb) present 315-6213 317-5048-COM joystick + 3 buttons Dead Or Alive 2 (Rev A) 841-0003C 22121A 21 (64Mb) present 315-6213 317-5048-COM joystick + 3 buttons
Dead Or Alive 2 841-0003C-01 22207 21 (64Mb) present 315-6213 317-5048-COM have unlocked Tag and Survival game modes, possible USA or international release
Dead Or Alive 2 Millennium 841-0003C DOA2 M 21 (64Mb) present 315-6213 317-5048-COM joystick + 3 buttons Dead Or Alive 2 Millennium 841-0003C DOA2 M 21 (64Mb) present 315-6213 317-5048-COM joystick + 3 buttons
Death Crimson OX 841-0016C 23524 10 (64Mb) present 315-6213 317-5066-COM Death Crimson OX 841-0016C 23524 10 (64Mb) present 315-6213 317-5066-COM
Dengen Tenshi Taisen Janshi Shangri-La 841-0004C 22060 12 (64Mb) ? 315-6213 317-5050-JPN Dengen Tenshi Taisen Janshi Shangri-La 841-0004C 22060 12 (64Mb) ? 315-6213 317-5050-JPN
@ -3441,7 +3442,7 @@ IC21 64M 002C 8ECA
*/ */
ROM_START( doa2 ) ROM_START( doa2a )
NAOMI_BIOS NAOMI_BIOS
NAOMI_DEFAULT_EEPROM_NO_BD NAOMI_DEFAULT_EEPROM_NO_BD
@ -3478,6 +3479,46 @@ ROM_START( doa2 )
ROM_PARAMETER( ":rom_board:segam2crypt:key", "0008ad01" ) ROM_PARAMETER( ":rom_board:segam2crypt:key", "0008ad01" )
ROM_END ROM_END
// later original version, have unlocked Tag and Survival game modes, but unlike Millennium have no option to disable them
// like original rev have 1 life in story mode and no way to tweak it (Millennium have it 2 and test mode option to change it)
// possible USA or international release
ROM_START( doa2 )
NAOMI_BIOS
NAOMI_DEFAULT_EEPROM_NO_BD
ROM_REGION( 0xb000000, "rom_board", ROMREGION_ERASEFF)
ROM_LOAD("epr-22207.ic22", 0x0000000, 0x0400000, CRC(313d0e55) SHA1(e2c8b99ef4041ecfa90cb534b160f4ca741e0bf5) )
ROM_LOAD("mpr-22100.ic1", 0x0800000, 0x0800000, CRC(92a53e5e) SHA1(87fcdeee9c4e65a3eb6eb345eed85d4f2df26c3c) )
ROM_LOAD("mpr-22101.ic2", 0x1000000, 0x0800000, CRC(14cd7dce) SHA1(5df14a5dad14bc922b4f88881dc2e9c8e74d6170) )
ROM_LOAD("mpr-22102.ic3", 0x1800000, 0x0800000, CRC(34e778b1) SHA1(750ddf5cda9622dd2b0f7069d247ffd55911c38f) )
ROM_LOAD("mpr-22103.ic4", 0x2000000, 0x0800000, CRC(6f3db8df) SHA1(e9bbcf7897594ae47a9e3c8641ccb2c09b0809fe) )
ROM_LOAD("mpr-22104.ic5", 0x2800000, 0x0800000, CRC(fcc2787f) SHA1(c28eaf91fa64e49e2276702678a4f8f17e09c3b9) )
ROM_LOAD("mpr-22105.ic6", 0x3000000, 0x0800000, CRC(3e2da942) SHA1(d8f28c40ab59fa96a1fb19ad3adbee687088a5ab) )
ROM_LOAD("mpr-22106.ic7", 0x3800000, 0x0800000, CRC(03aceaaf) SHA1(977e5b660254e7c5fdbd9d52c1f00c8a174a5d7b) )
ROM_LOAD("mpr-22107.ic8", 0x4000000, 0x0800000, CRC(6f1705e4) SHA1(b8215dd4ef7214e75c2ec79ad974a32422c17647) )
ROM_LOAD("mpr-22108.ic9", 0x4800000, 0x0800000, CRC(d34d3d8a) SHA1(910f1e4d8a54a621d9212e1425152c3029c96234) )
ROM_LOAD("mpr-22109.ic10", 0x5000000, 0x0800000, CRC(00ef44dd) SHA1(3fd100007daf59693de2329df1b4981dcdf435cd) )
ROM_LOAD("mpr-22110.ic11", 0x5800000, 0x0800000, CRC(a193b577) SHA1(3513853f88c491905481dadc5ce00cc5819b2663) )
ROM_LOAD("mpr-22111.ic12s",0x6000000, 0x0800000, CRC(55dddebf) SHA1(a7b8702cf578f5be4dcf8e2eaf11bf8b71d1b4ad) )
ROM_LOAD("mpr-22112.ic13s",0x6800000, 0x0800000, CRC(c5ffe564) SHA1(efe4d0cb5a536b26489c6dd31b1e446a9be643c9) )
ROM_LOAD("mpr-22113.ic14s",0x7000000, 0x0800000, CRC(12e7adf0) SHA1(2755c3efc6ca6d5680ead1489f42798c0187c5a4) )
ROM_LOAD("mpr-22114.ic15s",0x7800000, 0x0800000, CRC(d181d0a0) SHA1(2a0e46dbb31f5c11b6ae2fc8c786192bf3701ec5) )
ROM_LOAD("mpr-22115.ic16s",0x8000000, 0x0800000, CRC(ee2c842d) SHA1(8e33f241300481bb8875bda37e3917be71ed2594) )
ROM_LOAD("mpr-22116.ic17s",0x8800000, 0x0800000, CRC(224ab770) SHA1(85d849ee077e36da1df759caa4a32525395f741c) )
ROM_LOAD("mpr-22117.ic18s",0x9000000, 0x0800000, CRC(884a45a9) SHA1(d947cb3a045c5463523355fa631d55148e12c31e) )
ROM_LOAD("mpr-22118.ic19s",0x9800000, 0x0800000, CRC(8d631cbf) SHA1(fe8a65d35b1cdaed650ddde931e59f0768ffff53) )
ROM_LOAD("mpr-22119.ic20s",0xa000000, 0x0800000, CRC(d608fa86) SHA1(54c8107cccec8cbb536f13cda5b220b7972190b7) )
ROM_LOAD("mpr-22120.ic21s",0xa800000, 0x0800000, CRC(a30facb4) SHA1(70415ca34095c795297486bce1f956f6a8d4817f) )
// on-cart X76F100 eeprom contents
ROM_REGION( 0x84, "naomibd_eeprom", 0 )
ROM_LOAD( "841-0003.sf", 0x000000, 0x000084, CRC(3a119a17) SHA1(d37a092cca7c9cfc5f2637b355af90a65d04013e) )
// 841-0003 1999 317-5048-COM Naomi
ROM_PARAMETER( ":rom_board:segam2crypt:key", "0008ad01" )
ROM_END
/* /*
SYSTEMID: NAOMI SYSTEMID: NAOMI
@ -9678,7 +9719,8 @@ GAME( 2003, puyofevp, naomi, naomim1, naomi, naomi_state, naomi, ROT0, "Sega", "
/* 841-xxxxx ("Licensed by Sega" Naomi cart games)*/ /* 841-xxxxx ("Licensed by Sega" Naomi cart games)*/
/* 0001 */ GAME( 1999, pstone, naomi, naomim2, naomi, naomi_state, naomi, ROT0, "Capcom", "Power Stone", GAME_FLAGS ) /* 0001 */ GAME( 1999, pstone, naomi, naomim2, naomi, naomi_state, naomi, ROT0, "Capcom", "Power Stone", GAME_FLAGS )
/* 0002 */ GAME( 1999, suchie3, naomi, naomim2, suchie3, naomi_state,naomi_mp,ROT0, "Jaleco", "Idol Janshi Suchie-Pai 3 (JPN)", MACHINE_IMPERFECT_GRAPHICS|MACHINE_IMPERFECT_SOUND ) /* 0002 */ GAME( 1999, suchie3, naomi, naomim2, suchie3, naomi_state,naomi_mp,ROT0, "Jaleco", "Idol Janshi Suchie-Pai 3 (JPN)", MACHINE_IMPERFECT_GRAPHICS|MACHINE_IMPERFECT_SOUND )
/* 0003 */ GAME( 1999, doa2, naomi, naomim2, naomi, naomi_state, naomi, ROT0, "Tecmo", "Dead or Alive 2 (Rev A)", GAME_FLAGS ) /* 0003 */ GAME( 1999, doa2a, doa2, naomim2, naomi, naomi_state, naomi, ROT0, "Tecmo", "Dead or Alive 2 (Rev A)", GAME_FLAGS )
/* 0003-01 */ GAME( 1999, doa2, naomi, naomim2, naomi, naomi_state, naomi, ROT0, "Tecmo", "Dead or Alive 2", GAME_FLAGS )
/* 0003 */ GAME( 2000, doa2m, doa2, naomim2, naomi, naomi_state, naomi, ROT0, "Tecmo", "Dead or Alive 2 Millennium", GAME_FLAGS ) /* 0003 */ GAME( 2000, doa2m, doa2, naomim2, naomi, naomi_state, naomi, ROT0, "Tecmo", "Dead or Alive 2 Millennium", GAME_FLAGS )
/* 0004 */ GAME( 1999, shangril, naomi, naomim2, naomi_mp,naomi_state,naomi_mp,ROT0, "Marvelous Ent.", "Dengen Tenshi Taisen Janshi Shangri-la (Build 0728)", GAME_FLAGS ) // version taken from service mode /* 0004 */ GAME( 1999, shangril, naomi, naomim2, naomi_mp,naomi_state,naomi_mp,ROT0, "Marvelous Ent.", "Dengen Tenshi Taisen Janshi Shangri-la (Build 0728)", GAME_FLAGS ) // version taken from service mode
/* 0005 */ GAME( 1999, spawn, naomi, naomim2, naomi, naomi_state, naomi, ROT0, "Todd Mc Farlane / Capcom","Spawn In the Demon's Hand (Rev B)", GAME_FLAGS ) /* 0005 */ GAME( 1999, spawn, naomi, naomim2, naomi, naomi_state, naomi, ROT0, "Todd Mc Farlane / Capcom","Spawn In the Demon's Hand (Rev B)", GAME_FLAGS )

View File

@ -124,6 +124,12 @@ Its BIOS performs POST and halts as there's no keyboard.
#include "machine/octo_kbd.h" #include "machine/octo_kbd.h"
#include "machine/bankdev.h" #include "machine/bankdev.h"
#include "machine/ram.h" #include "machine/ram.h"
#include "bus/centronics/ctronics.h"
#include "bus/centronics/comxpl80.h"
#include "bus/centronics/epson_ex800.h"
#include "bus/centronics/epson_lx800.h"
#include "bus/centronics/epson_lx810l.h"
#include "bus/centronics/printer.h"
class octopus_state : public driver_device class octopus_state : public driver_device
{ {
@ -148,6 +154,7 @@ public:
m_ppi(*this, "ppi"), m_ppi(*this, "ppi"),
m_speaker(*this, "speaker"), m_speaker(*this, "speaker"),
m_serial(*this, "serial"), m_serial(*this, "serial"),
m_parallel(*this, "parallel"),
m_z80_bankdev(*this, "z80_bank"), m_z80_bankdev(*this, "z80_bank"),
m_ram(*this, "ram"), m_ram(*this, "ram"),
m_current_dma(-1), m_current_dma(-1),
@ -184,11 +191,15 @@ public:
DECLARE_WRITE8_MEMBER(rtc_w); DECLARE_WRITE8_MEMBER(rtc_w);
DECLARE_READ8_MEMBER(z80_vector_r); DECLARE_READ8_MEMBER(z80_vector_r);
DECLARE_WRITE8_MEMBER(z80_vector_w); DECLARE_WRITE8_MEMBER(z80_vector_w);
DECLARE_READ8_MEMBER(parallel_r);
DECLARE_WRITE8_MEMBER(parallel_w);
DECLARE_WRITE_LINE_MEMBER(spk_w); DECLARE_WRITE_LINE_MEMBER(spk_w);
DECLARE_WRITE_LINE_MEMBER(spk_freq_w); DECLARE_WRITE_LINE_MEMBER(spk_freq_w);
DECLARE_WRITE_LINE_MEMBER(beep_w); DECLARE_WRITE_LINE_MEMBER(beep_w);
DECLARE_WRITE_LINE_MEMBER(serial_clock_w); DECLARE_WRITE_LINE_MEMBER(serial_clock_w);
DECLARE_WRITE_LINE_MEMBER(parallel_busy_w) { m_printer_busy = state; }
DECLARE_WRITE_LINE_MEMBER(parallel_slctout_w) { m_printer_slctout = state; }
DECLARE_WRITE_LINE_MEMBER(dack0_w) { m_dma1->hack_w(state ? 0 : 1); } // for all unused DMA channel? DECLARE_WRITE_LINE_MEMBER(dack0_w) { m_dma1->hack_w(state ? 0 : 1); } // for all unused DMA channel?
DECLARE_WRITE_LINE_MEMBER(dack1_w) { if(!state) m_current_dma = 1; else if(m_current_dma == 1) m_current_dma = -1; } // HD DECLARE_WRITE_LINE_MEMBER(dack1_w) { if(!state) m_current_dma = 1; else if(m_current_dma == 1) m_current_dma = -1; } // HD
@ -226,6 +237,7 @@ private:
required_device<i8255_device> m_ppi; required_device<i8255_device> m_ppi;
required_device<speaker_sound_device> m_speaker; required_device<speaker_sound_device> m_speaker;
required_device<z80sio2_device> m_serial; required_device<z80sio2_device> m_serial;
required_device<centronics_device> m_parallel;
required_device<address_map_bank_device> m_z80_bankdev; required_device<address_map_bank_device> m_z80_bankdev;
required_device<ram_device> m_ram; required_device<ram_device> m_ram;
@ -246,6 +258,8 @@ private:
UINT8 m_prev_cntl; UINT8 m_prev_cntl;
UINT8 m_rs232_vector; UINT8 m_rs232_vector;
UINT8 m_rs422_vector; UINT8 m_rs422_vector;
bool m_printer_busy;
bool m_printer_slctout;
emu_timer* m_timer_beep; emu_timer* m_timer_beep;
}; };
@ -288,7 +302,7 @@ static ADDRESS_MAP_START( octopus_io, AS_IO, 8, octopus_state )
// 0xcf: mode control // 0xcf: mode control
AM_RANGE(0xd0, 0xd3) AM_DEVREADWRITE("fdc", fd1793_t, read, write) AM_RANGE(0xd0, 0xd3) AM_DEVREADWRITE("fdc", fd1793_t, read, write)
AM_RANGE(0xe0, 0xe4) AM_READWRITE(z80_vector_r, z80_vector_w) AM_RANGE(0xe0, 0xe4) AM_READWRITE(z80_vector_r, z80_vector_w)
// 0xf0-f1: Parallel interface data I/O (Centronics), and control/status AM_RANGE(0xf0, 0xf1) AM_READWRITE(parallel_r, parallel_w)
AM_RANGE(0xf8, 0xff) AM_DEVREADWRITE("ppi", i8255_device, read, write) AM_RANGE(0xf8, 0xff) AM_DEVREADWRITE("ppi", i8255_device, read, write)
ADDRESS_MAP_END ADDRESS_MAP_END
@ -414,10 +428,14 @@ WRITE8_MEMBER(octopus_state::system_w)
READ8_MEMBER(octopus_state::system_r) READ8_MEMBER(octopus_state::system_r)
{ {
UINT8 val = 0x00;
switch(offset) switch(offset)
{ {
case 0: case 0:
return 0x1f; // do bits 0-4 mean anything? Language DIPs? val = 0x1f;
if(m_printer_slctout)
val |= 0x20;
return val; // do bits 0-4 mean anything? Language DIPs?
} }
return 0xff; return 0xff;
@ -613,6 +631,50 @@ WRITE_LINE_MEMBER(octopus_state::serial_clock_w)
m_serial->txca_w(state); m_serial->txca_w(state);
} }
// Parallel Centronics port
// 0xf0 : data
// 0xf1 : control
// bit 2 = INIT? On boot, bits 0 and 1 are set high, bit 2 is set low then high again, all other bits are set low
// can generate interrupts - tech manual suggests that Strobe, Init, Ack, and Busy can trigger an interrupt (IRQ14)
READ8_MEMBER(octopus_state::parallel_r)
{
switch(offset)
{
case 0:
return 0;
case 1:
return m_printer_busy ? 0x01 : 0x00; // correct? Tech manual doesn't explain which bit is which
}
return 0xff;
}
WRITE8_MEMBER(octopus_state::parallel_w)
{
switch(offset)
{
case 0: // data
if(!(m_gpo & 0x02)) // parallel data direction
{
m_parallel->write_data0(BIT(data,0));
m_parallel->write_data1(BIT(data,1));
m_parallel->write_data2(BIT(data,2));
m_parallel->write_data3(BIT(data,3));
m_parallel->write_data4(BIT(data,4));
m_parallel->write_data5(BIT(data,5));
m_parallel->write_data6(BIT(data,6));
m_parallel->write_data7(BIT(data,7));
}
break;
case 1: // control (bit order unknown?)
if(!(m_gpo & 0x01)) // parallel control direction
{
m_parallel->write_init(BIT(data,2));
m_pic2->ir6_w(!BIT(data,2));
}
break;
}
}
READ8_MEMBER(octopus_state::dma_read) READ8_MEMBER(octopus_state::dma_read)
{ {
UINT8 byte; UINT8 byte;
@ -642,13 +704,14 @@ WRITE_LINE_MEMBER( octopus_state::dma_hrq_changed )
// Any interrupt will also give bus control back to the 8088 // Any interrupt will also give bus control back to the 8088
IRQ_CALLBACK_MEMBER(octopus_state::x86_irq_cb) IRQ_CALLBACK_MEMBER(octopus_state::x86_irq_cb)
{ {
UINT8 vector;
m_subcpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE); m_subcpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
m_maincpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE); m_maincpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
m_z80_active = false; m_z80_active = false;
if((strcmp(device.tag(),"pic_master") == 0) && irqline == 1) vector = m_pic1->inta_cb(device,irqline);
return m_serial->m1_r(); if(vector == 0x61) // if we have hit a serial comms IRQ, then also have the Z80SIO/2 acknowledge the interrupt
else vector = m_serial->m1_r();
return m_pic1->inta_cb(device,irqline); return vector;
} }
void octopus_state::machine_start() void octopus_state::machine_start()
@ -707,6 +770,15 @@ static SLOT_INTERFACE_START(keyboard)
SLOT_INTERFACE("octopus", OCTOPUS_KEYBOARD) SLOT_INTERFACE("octopus", OCTOPUS_KEYBOARD)
SLOT_INTERFACE_END SLOT_INTERFACE_END
SLOT_INTERFACE_START(octopus_centronics_devices)
SLOT_INTERFACE("pl80", COMX_PL80)
SLOT_INTERFACE("ex800", EPSON_EX800)
SLOT_INTERFACE("lx800", EPSON_LX800)
SLOT_INTERFACE("lx810l", EPSON_LX810L)
SLOT_INTERFACE("ap2000", EPSON_AP2000)
SLOT_INTERFACE("printer", CENTRONICS_PRINTER)
SLOT_INTERFACE_END
static MACHINE_CONFIG_START( octopus, octopus_state ) static MACHINE_CONFIG_START( octopus, octopus_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu",I8088, XTAL_24MHz / 3) // 8MHz MCFG_CPU_ADD("maincpu",I8088, XTAL_24MHz / 3) // 8MHz
@ -763,7 +835,7 @@ static MACHINE_CONFIG_START( octopus, octopus_state )
MCFG_I8255_OUT_PORTB_CB(WRITE8(octopus_state,cntl_w)) MCFG_I8255_OUT_PORTB_CB(WRITE8(octopus_state,cntl_w))
MCFG_I8255_OUT_PORTC_CB(WRITE8(octopus_state,gpo_w)) MCFG_I8255_OUT_PORTC_CB(WRITE8(octopus_state,gpo_w))
MCFG_MC146818_ADD("rtc", XTAL_32_768kHz) MCFG_MC146818_ADD("rtc", XTAL_32_768kHz)
MCFG_MC146818_IRQ_HANDLER(DEVWRITELINE("pic_slave",pic8259_device, ir2_w)) MCFG_MC146818_IRQ_HANDLER(DEVWRITELINE("pic_slave",pic8259_device, ir2_w)) MCFG_DEVCB_INVERT
// Keyboard UART // Keyboard UART
MCFG_DEVICE_ADD("keyboard", I8251, 0) MCFG_DEVICE_ADD("keyboard", I8251, 0)
@ -804,9 +876,10 @@ static MACHINE_CONFIG_START( octopus, octopus_state )
MCFG_RS232_CTS_HANDLER(DEVWRITELINE("serial",z80sio2_device, ctsb_w)) MCFG_RS232_CTS_HANDLER(DEVWRITELINE("serial",z80sio2_device, ctsb_w))
MCFG_RS232_RI_HANDLER(DEVWRITELINE("serial",z80sio2_device, rib_w)) MCFG_DEVCB_INVERT MCFG_RS232_RI_HANDLER(DEVWRITELINE("serial",z80sio2_device, rib_w)) MCFG_DEVCB_INVERT
// TODO: add components MCFG_CENTRONICS_ADD("parallel", octopus_centronics_devices, "printer")
// Centronics parallel interface MCFG_CENTRONICS_BUSY_HANDLER(WRITELINE(octopus_state, parallel_busy_w))
// Winchester HD controller (Xebec/SASI compatible? uses TTL logic) MCFG_CENTRONICS_SELECT_HANDLER(WRITELINE(octopus_state, parallel_slctout_w))
// TODO: Winchester HD controller (Xebec/SASI compatible? uses TTL logic)
/* video hardware */ /* video hardware */
MCFG_SCREEN_ADD("screen", RASTER) MCFG_SCREEN_ADD("screen", RASTER)

View File

@ -13,12 +13,7 @@ ToDo:
- Everything - Everything
Issues: Issues:
- Floppy disc isn't being detected. - Floppy disc error.
(bios 1 issues)
- Daisy chain:
- Hitting a key causes CTC to interrupt, even though CTC and PIO are not connected.
- After that, IRQ isn't released, causing the system to be stuck in a loop.
****************************************************************************************************************/ ****************************************************************************************************************/
@ -353,6 +348,7 @@ static MACHINE_CONFIG_START( rc702, rc702_state )
MCFG_DEVICE_ADD("ctc1", Z80CTC, XTAL_8MHz / 2) MCFG_DEVICE_ADD("ctc1", Z80CTC, XTAL_8MHz / 2)
MCFG_Z80CTC_ZC0_CB(WRITELINE(rc702_state, zc0_w)) MCFG_Z80CTC_ZC0_CB(WRITELINE(rc702_state, zc0_w))
MCFG_Z80CTC_ZC1_CB(DEVWRITELINE("sio1", z80dart_device, rxtxcb_w)) MCFG_Z80CTC_ZC1_CB(DEVWRITELINE("sio1", z80dart_device, rxtxcb_w))
MCFG_Z80CTC_INTR_CB(INPUTLINE("maincpu", INPUT_LINE_IRQ0))
MCFG_Z80DART_ADD("sio1", XTAL_8MHz / 2, 0, 0, 0, 0 ) MCFG_Z80DART_ADD("sio1", XTAL_8MHz / 2, 0, 0, 0, 0 )
MCFG_Z80DART_OUT_INT_CB(INPUTLINE("maincpu", INPUT_LINE_IRQ0)) MCFG_Z80DART_OUT_INT_CB(INPUTLINE("maincpu", INPUT_LINE_IRQ0))

View File

@ -523,7 +523,7 @@ ROM_START(wldcp_l1)
ROM_LOAD("white2wc.716", 0x1800, 0x0800, CRC(618d15b5) SHA1(527387893eeb2cd4aa563a4cfb1948a15d2ed741)) ROM_LOAD("white2wc.716", 0x1800, 0x0800, CRC(618d15b5) SHA1(527387893eeb2cd4aa563a4cfb1948a15d2ed741))
ROM_REGION(0x0800, "audioroms", 0) ROM_REGION(0x0800, "audioroms", 0)
ROM_LOAD("sound1.716", 0x0000, 0x0800, CRC(f4190ca3) SHA1(ee234fb5c894fca5876ee6dc7ea8e89e7e0aec9c)) ROM_LOAD("481_s0_world_cup.716", 0x0000, 0x0800, CRC(cf012812) SHA1(26074f6a44075a94e6f91de1dbf92f8ec3ff8ca4))
ROM_END ROM_END
/*------------------------------------- /*-------------------------------------
@ -536,7 +536,7 @@ ROM_START(cntct_l1)
ROM_LOAD("white2.716", 0x1800, 0x0800, CRC(4d4010dd) SHA1(11221124fef3b7bf82d353d65ce851495f6946a7)) ROM_LOAD("white2.716", 0x1800, 0x0800, CRC(4d4010dd) SHA1(11221124fef3b7bf82d353d65ce851495f6946a7))
ROM_REGION(0x0800, "audioroms", 0) ROM_REGION(0x0800, "audioroms", 0)
ROM_LOAD("sound1.716", 0x0000, 0x0800, CRC(f4190ca3) SHA1(ee234fb5c894fca5876ee6dc7ea8e89e7e0aec9c)) ROM_LOAD("482_s0_contact.716", 0x0000, 0x0800, CRC(d3c713da) SHA1(1fc4a8fadf472e9a04b3a86f60a9d625d07764e1))
ROM_END ROM_END
/*------------------------------------- /*-------------------------------------
@ -549,7 +549,7 @@ ROM_START(disco_l1)
ROM_LOAD("white2.716", 0x1800, 0x0800, CRC(4d4010dd) SHA1(11221124fef3b7bf82d353d65ce851495f6946a7)) ROM_LOAD("white2.716", 0x1800, 0x0800, CRC(4d4010dd) SHA1(11221124fef3b7bf82d353d65ce851495f6946a7))
ROM_REGION(0x0800, "audioroms", 0) ROM_REGION(0x0800, "audioroms", 0)
ROM_LOAD("sound1.716", 0x0000, 0x0800, CRC(f4190ca3) SHA1(ee234fb5c894fca5876ee6dc7ea8e89e7e0aec9c)) ROM_LOAD("483_s0_disco_fever.716", 0x0000, 0x0800, CRC(d1cb5047) SHA1(7f36296975df19feecc6456ffb91f4a23bcad037))
ROM_END ROM_END
/*-------------------------------- /*--------------------------------
@ -562,7 +562,7 @@ ROM_START(phnix_l1)
ROM_LOAD("white2.716", 0x1800, 0x0800, CRC(4d4010dd) SHA1(11221124fef3b7bf82d353d65ce851495f6946a7)) ROM_LOAD("white2.716", 0x1800, 0x0800, CRC(4d4010dd) SHA1(11221124fef3b7bf82d353d65ce851495f6946a7))
ROM_REGION(0x0800, "audioroms", 0) ROM_REGION(0x0800, "audioroms", 0)
ROM_LOAD("sound1.716", 0x0000, 0x0800, CRC(f4190ca3) SHA1(ee234fb5c894fca5876ee6dc7ea8e89e7e0aec9c)) ROM_LOAD("485_s0_phoenix.716", 0x0000, 0x0800, CRC(1c3dea6e) SHA1(04bfe952be2eab66f023b204c21a1bd461ea572f))
ROM_END ROM_END
/*-------------------------------- /*--------------------------------

View File

@ -0,0 +1,184 @@
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
/**************************************************************************
VeriFone Tranz 330
All information gleaned from:
http://www.bigmessowires.com/2011/05/10/mapping-the-tranz-330/
Currently sits in a loop doing very little, based on the disassembly
it presumably needs some kind of interrupt in order to kick it into
running.
Interrupt Vectors are located at 0200-02FF.
Display ram at 9000-90FF says GRAMING ERR 0 (part of PROGRAMING ERR message)
TODO:
- get working, driver needs a Z80 peripheral expert to look at it.
- hook up magstripe reader
****************************************************************************/
#include "includes/tranz330.h"
#include "tranz330.lh"
static ADDRESS_MAP_START( tranz330_mem, AS_PROGRAM, 8, tranz330_state )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0xffff) AM_RAM
ADDRESS_MAP_END
static ADDRESS_MAP_START( tranz330_io, AS_IO, 8, tranz330_state )
ADDRESS_MAP_GLOBAL_MASK(0xff)
AM_RANGE(0x00, 0x03) AM_DEVREADWRITE(PIO_TAG, z80pio_device, read_alt, write_alt)
AM_RANGE(0x10, 0x13) AM_DEVREADWRITE(CTC_TAG, z80ctc_device, read, write)
AM_RANGE(0x20, 0x23) AM_DEVREADWRITE(DART_TAG, z80dart_device, ba_cd_r, ba_cd_w)
AM_RANGE(0x30, 0x3f) AM_DEVREADWRITE(RTC_TAG, msm6242_device, read, write)
ADDRESS_MAP_END
static INPUT_PORTS_START( tranz330 )
PORT_START("COL.0")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(KEYCODE_1) PORT_NAME("1 QZ.")
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(KEYCODE_4) PORT_NAME("4 GHI")
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CODE(KEYCODE_7) PORT_NAME("7 PRS")
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CODE(KEYCODE_ASTERISK) PORT_NAME("* ,'\"")
PORT_START("COL.1")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_2) PORT_NAME("2 ABC")
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_CODE(KEYCODE_5) PORT_NAME("5 JKL")
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_CODE(KEYCODE_8) PORT_NAME("8 TUV")
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_CODE(KEYCODE_0) PORT_NAME("0 -SP")
PORT_START("COL.2")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON9 ) PORT_CODE(KEYCODE_3) PORT_NAME("3 DEF")
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON10 ) PORT_CODE(KEYCODE_6) PORT_NAME("6 MNO")
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON11 ) PORT_CODE(KEYCODE_9) PORT_NAME("9 WXY")
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON13 ) PORT_CODE(KEYCODE_H) PORT_NAME("#") // KEYCODE_H for 'hash mark'
PORT_START("COL.3")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON14 ) PORT_CODE(KEYCODE_C) PORT_NAME("CLEAR") // KEYCODE_C so as to not collide with potentially-used UI keys
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON15 ) PORT_CODE(KEYCODE_BACKSPACE) PORT_NAME("BACK SPACE")
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON16 ) PORT_CODE(KEYCODE_A) PORT_NAME("ALPHA")
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 ) PORT_CODE(KEYCODE_ENTER) PORT_NAME("FUNC | ENTER")
INPUT_PORTS_END
void tranz330_state::machine_start()
{
}
void tranz330_state::machine_reset()
{
}
WRITE_LINE_MEMBER( tranz330_state::syncb_w )
{
}
WRITE_LINE_MEMBER( tranz330_state::sound_w )
{
m_speaker->level_w(state);
m_ctc->trg3(state);
}
WRITE_LINE_MEMBER( tranz330_state::clock_w )
{
// Ch 0 and 1 might be DART Ch A & B baud clocks
//m_ctc->trg0(state);
//m_ctc->trg1(state);
// Ch 2 speaker clock
m_ctc->trg2(state);
}
READ8_MEMBER( tranz330_state::card_r )
{
// return 0xff for a magstripe 0, return 0x00 for a magstripe 1.
// an interrupt should be triggered on the Z80 when magstripe reading begins.
// external contributors are encouraged to hook this up.
return 0xff;
}
WRITE8_MEMBER( tranz330_state::pio_a_w )
{
m_keypad_col_mask = data & 0xf;
m_vfd->por ((data >> 4) & 1);
m_vfd->data((data >> 5) & 1);
m_vfd->sclk((data >> 6) & 1);
}
READ8_MEMBER( tranz330_state::pio_b_r )
{
UINT8 input_mask = 0xf;
for (int i = 0; i < 4; i++)
{
if (!BIT(m_keypad_col_mask, i))
{
input_mask &= m_keypad[i]->read();
}
}
return input_mask;
}
static const z80_daisy_config tranz330_daisy_chain[] =
{
{ DART_TAG },
{ CTC_TAG },
{ PIO_TAG },
{ nullptr }
};
// * - check clocks
// ? - check purported RS232 hookup, inconsistent information found at the relevant webpage vs. user-submitted errata
static MACHINE_CONFIG_START( tranz330, tranz330_state )
MCFG_CPU_ADD(CPU_TAG, Z80, XTAL_7_15909MHz/2) //*
MCFG_CPU_PROGRAM_MAP(tranz330_mem)
MCFG_CPU_IO_MAP(tranz330_io)
MCFG_Z80_DAISY_CHAIN(tranz330_daisy_chain)
MCFG_DEVICE_ADD("ctc_clock", CLOCK, XTAL_7_15909MHz/4) // ?
MCFG_CLOCK_SIGNAL_HANDLER(WRITELINE(tranz330_state, clock_w))
MCFG_DEVICE_ADD(RTC_TAG, MSM6242, XTAL_32_768kHz)
MCFG_DEVICE_ADD(PIO_TAG, Z80PIO, XTAL_7_15909MHz/2) //*
MCFG_Z80PIO_OUT_INT_CB(INPUTLINE(CPU_TAG, INPUT_LINE_IRQ0)) //*
MCFG_Z80PIO_OUT_PA_CB(WRITE8(tranz330_state, pio_a_w))
MCFG_Z80PIO_IN_PA_CB(READ8(tranz330_state, card_r))
MCFG_Z80PIO_IN_PB_CB(READ8(tranz330_state, pio_b_r))
MCFG_Z80DART_ADD(DART_TAG, XTAL_7_15909MHz/2, 0, 0, 0, 0 ) //*
MCFG_Z80DART_OUT_SYNCB_CB(WRITELINE(tranz330_state, syncb_w))
MCFG_Z80DART_OUT_TXDB_CB(DEVWRITELINE(RS232_TAG, rs232_port_device, write_txd)) //?
MCFG_Z80DART_OUT_DTRB_CB(DEVWRITELINE(RS232_TAG, rs232_port_device, write_dtr)) //?
MCFG_Z80DART_OUT_RTSB_CB(DEVWRITELINE(RS232_TAG, rs232_port_device, write_rts)) //?
MCFG_Z80DART_OUT_INT_CB(INPUTLINE(CPU_TAG, INPUT_LINE_IRQ0))
MCFG_DEVICE_ADD(CTC_TAG, Z80CTC, XTAL_7_15909MHz/2) //*
MCFG_Z80CTC_ZC2_CB(WRITELINE(tranz330_state, sound_w))
MCFG_Z80CTC_INTR_CB(INPUTLINE(CPU_TAG, INPUT_LINE_IRQ0))
MCFG_RS232_PORT_ADD(RS232_TAG, default_rs232_devices, nullptr)
MCFG_RS232_RXD_HANDLER(DEVWRITELINE(DART_TAG, z80dart_device, rxb_w))
MCFG_RS232_DCD_HANDLER(DEVWRITELINE(DART_TAG, z80dart_device, dcdb_w))
MCFG_RS232_CTS_HANDLER(DEVWRITELINE(DART_TAG, z80dart_device, ctsb_w))
// video
MCFG_MIC10937_ADD(VFD_TAG, 0)
MCFG_DEFAULT_LAYOUT( layout_tranz330 )
// sound
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
MACHINE_CONFIG_END
ROM_START( tranz330 )
ROM_REGION( 0x8000, CPU_TAG, 0 )
ROM_LOAD( "tranz330-original.bin", 0x0000, 0x8000, CRC(af2bf474) SHA1(7896ed23b22b8e1730b689df83eb7bbf7b8dd130))
ROM_END
// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS
COMP( 1985, tranz330, 0, 0, tranz330, tranz330, driver_device, 0, "VeriFone", "Tranz 330", MACHINE_CLICKABLE_ARTWORK )

View File

@ -0,0 +1,73 @@
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
#pragma once
#ifndef VERIFONE_TRANZ330_H
#define VERIFONE_TRANZ330_H
// single-driver build must have emu.h here
#include "emu.h"
#include "cpu/z80/z80.h"
#include "cpu/z80/z80daisy.h"
#include "machine/z80ctc.h"
#include "machine/z80dart.h"
#include "machine/z80pio.h"
#include "machine/msm6242.h"
#include "machine/roc10937.h"
#include "bus/rs232/rs232.h"
#include "sound/speaker.h"
#include "machine/clock.h"
#define CPU_TAG "cpu"
#define DART_TAG "dart"
#define CTC_TAG "ctc"
#define PIO_TAG "pio"
#define RTC_TAG "rtc"
#define VFD_TAG "vfd"
#define RS232_TAG "rs232"
#define SPEAKER_TAG "speaker"
class tranz330_state : public driver_device
{
public:
tranz330_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag)
, m_cpu(*this, CPU_TAG)
, m_ctc(*this, CTC_TAG)
, m_dart(*this, DART_TAG)
, m_pio(*this, PIO_TAG)
, m_rtc(*this, RTC_TAG)
, m_vfd(*this, VFD_TAG)
, m_rs232(*this, RS232_TAG)
, m_speaker(*this, SPEAKER_TAG)
, m_keypad(*this, "COL.%u", 0)
{ }
virtual void machine_start() override;
virtual void machine_reset() override;
DECLARE_WRITE_LINE_MEMBER( syncb_w );
DECLARE_WRITE_LINE_MEMBER(clock_w);
DECLARE_WRITE_LINE_MEMBER( sound_w );
DECLARE_WRITE8_MEMBER( pio_a_w );
DECLARE_READ8_MEMBER( pio_b_r );
DECLARE_READ8_MEMBER( card_r );
private:
required_device<cpu_device> m_cpu;
required_device<z80ctc_device> m_ctc;
required_device<z80dart_device> m_dart;
required_device<z80pio_device> m_pio;
required_device<msm6242_device> m_rtc;
required_device<mic10937_t> m_vfd;
required_device<rs232_port_device> m_rs232;
required_device<speaker_sound_device> m_speaker;
required_ioport_array<4> m_keypad;
UINT8 m_keypad_col_mask;
};
#endif // VERIFONE_TRANZ330_H

View File

@ -0,0 +1,227 @@
<?xml version="1.0"?>
<mamelayout version="2">
<element name="vfd0"><led16segsc><color red="0" green="0.6" blue="1.0" /></led16segsc></element>
<element name="front"><rect><color red="0.15" green="0.15" blue="0.15" /></rect></element>
<element name="vfd_back"><rect><color red="0.03" green="0.03" blue="0.03" /></rect></element>
<element name="button_digit_back"><rect><color red="0.75" green="0.75" blue="0.75" /></rect></element>
<element name="button_aux_back"><rect><color red="0.57" green="0.57" blue="0.57" /></rect></element>
<element name="button_enter_back"><rect><color red="0.25" green="0.625" blue="0.875" /></rect></element>
<element name="hl" defstate="0">
<text string=" ">
<bounds x="0.0" y="0.0" width="1.0" height="1.0" />
<color red="0.0" green="0.0" blue="0.0" />
</text>
<rect state="1">
<bounds x="0.0" y="0.0" width="1.0" height="1.0" />
<color red="0.0" green="0.0" blue="0.0" />
</rect>
</element>
<element name="button_1_text">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string="QZ."><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_1_num">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string="1"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_2_text">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string="ABC"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_2_num">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string="2"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_3_text">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string="DEF"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_3_num">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string="3"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_4_text">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string="GHI"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_4_num">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string="4"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_5_text">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string="JKL"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_5_num">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string="5"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_6_text">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string="MNO"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_6_num">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string="6"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_7_text">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string="PRS"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_7_num">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string="7"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_8_text">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string="TUV"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_8_num">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string="8"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_9_text">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string="WXY"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_9_num">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string="9"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_0_text">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string="-SP"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_0_num">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string="0"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_star_text">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string=",'&quot;"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_star_num">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string="*"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_hash_num">
<rect><color red="0.75" green="0.75" blue="0.75" /></rect>
<text string="#"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_clear_text">
<rect><color red="0.57" green="0.57" blue="0.57" /></rect>
<text string="CLEAR"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_back_text">
<rect><color red="0.57" green="0.57" blue="0.57" /></rect>
<text string="BACK"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_space_text">
<rect><color red="0.57" green="0.57" blue="0.57" /></rect>
<text string="SPACE"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_alpha_text">
<rect><color red="0.57" green="0.57" blue="0.57" /></rect>
<text string="ALPHA"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_func_text">
<rect><color red="0.25" green="0.625" blue="0.875" /></rect>
<text string="FUNC"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_enter_text">
<rect><color red="0.25" green="0.625" blue="0.875" /></rect>
<text string="ENTER"><color red="0.0" green="0.0" blue="0.0" /></text>
</element>
<element name="button_enter_line"><rect><color red="0.0" green="0.0" blue="0.0" /></rect></element>
<view name="Internal Layout">
<backdrop name="case_bg" element="front"> <bounds x=" 0" y=" 0" width="162" height="190"/></backdrop>
<backdrop name="button_1" element="button_digit_back"><bounds x=" 18" y=" 50" width="25" height="25"/></backdrop>
<backdrop name="button_2" element="button_digit_back"><bounds x=" 52" y=" 50" width="25" height="25"/></backdrop>
<backdrop name="button_3" element="button_digit_back"><bounds x=" 86" y=" 50" width="25" height="25"/></backdrop>
<backdrop name="button_4" element="button_digit_back"><bounds x=" 18" y=" 84" width="25" height="25"/></backdrop>
<backdrop name="button_5" element="button_digit_back"><bounds x=" 52" y=" 84" width="25" height="25"/></backdrop>
<backdrop name="button_6" element="button_digit_back"><bounds x=" 86" y=" 84" width="25" height="25"/></backdrop>
<backdrop name="button_7" element="button_digit_back"><bounds x=" 18" y="118" width="25" height="25"/></backdrop>
<backdrop name="button_8" element="button_digit_back"><bounds x=" 52" y="118" width="25" height="25"/></backdrop>
<backdrop name="button_9" element="button_digit_back"><bounds x=" 86" y="118" width="25" height="25"/></backdrop>
<backdrop name="button_0" element="button_digit_back"><bounds x=" 52" y="152" width="25" height="25"/></backdrop>
<backdrop name="button_star" element="button_digit_back"><bounds x=" 18" y="152" width="25" height="25"/></backdrop>
<backdrop name="button_hash" element="button_digit_back"><bounds x=" 86" y="152" width="25" height="25"/></backdrop>
<backdrop name="button_clear" element="button_aux_back"> <bounds x="120" y=" 50" width="25" height="25"/></backdrop>
<backdrop name="button_back" element="button_aux_back"> <bounds x="120" y=" 84" width="25" height="25"/></backdrop>
<backdrop name="button_alpha" element="button_aux_back"> <bounds x="120" y="118" width="25" height="25"/></backdrop>
<backdrop name="button_enter" element="button_enter_back"><bounds x="120" y="152" width="25" height="25"/></backdrop>
<backdrop name="vfd_backdrop" element="vfd_back"> <bounds x=" 0" y=" 0" width="162" height="32"/></backdrop>
<bezel name="vfd0" element="vfd0" state="0"><bounds x=" 9" y="9" width="9" height="14"/></bezel>
<bezel name="vfd1" element="vfd0" state="0"><bounds x=" 18" y="9" width="9" height="14"/></bezel>
<bezel name="vfd2" element="vfd0" state="0"><bounds x=" 27" y="9" width="9" height="14"/></bezel>
<bezel name="vfd3" element="vfd0" state="0"><bounds x=" 36" y="9" width="9" height="14"/></bezel>
<bezel name="vfd4" element="vfd0" state="0"><bounds x=" 45" y="9" width="9" height="14"/></bezel>
<bezel name="vfd5" element="vfd0" state="0"><bounds x=" 54" y="9" width="9" height="14"/></bezel>
<bezel name="vfd6" element="vfd0" state="0"><bounds x=" 63" y="9" width="9" height="14"/></bezel>
<bezel name="vfd7" element="vfd0" state="0"><bounds x=" 72" y="9" width="9" height="14"/></bezel>
<bezel name="vfd8" element="vfd0" state="0"><bounds x=" 81" y="9" width="9" height="14"/></bezel>
<bezel name="vfd9" element="vfd0" state="0"><bounds x=" 90" y="9" width="9" height="14"/></bezel>
<bezel name="vfd10" element="vfd0" state="0"><bounds x=" 99" y="9" width="9" height="14"/></bezel>
<bezel name="vfd11" element="vfd0" state="0"><bounds x="108" y="9" width="9" height="14"/></bezel>
<bezel name="vfd12" element="vfd0" state="0"><bounds x="117" y="9" width="9" height="14"/></bezel>
<bezel name="vfd13" element="vfd0" state="0"><bounds x="126" y="9" width="9" height="14"/></bezel>
<bezel name="vfd14" element="vfd0" state="0"><bounds x="135" y="9" width="9" height="14"/></bezel>
<bezel name="vfd15" element="vfd0" state="0"><bounds x="144" y="9" width="9" height="14"/></bezel>
<bezel name="button_1_text1" element="button_1_text"> <bounds x=" 18" y=" 54" width="25" height="8"/></bezel>
<bezel name="button_1_text2" element="button_1_num"> <bounds x=" 18" y=" 64" width="25" height="8"/></bezel>
<bezel name="button_2_text1" element="button_2_text"> <bounds x=" 52" y=" 54" width="25" height="8"/></bezel>
<bezel name="button_2_text2" element="button_2_num"> <bounds x=" 52" y=" 64" width="25" height="8"/></bezel>
<bezel name="button_3_text1" element="button_3_text"> <bounds x=" 86" y=" 54" width="25" height="8"/></bezel>
<bezel name="button_3_text2" element="button_3_num"> <bounds x=" 86" y=" 64" width="25" height="8"/></bezel>
<bezel name="button_4_text1" element="button_4_text"> <bounds x=" 18" y=" 88" width="25" height="8"/></bezel>
<bezel name="button_4_text2" element="button_4_num"> <bounds x=" 18" y=" 98" width="25" height="8"/></bezel>
<bezel name="button_5_text1" element="button_5_text"> <bounds x=" 52" y=" 88" width="25" height="8"/></bezel>
<bezel name="button_5_text2" element="button_5_num"> <bounds x=" 52" y=" 98" width="25" height="8"/></bezel>
<bezel name="button_6_text1" element="button_6_text"> <bounds x=" 86" y=" 88" width="25" height="8"/></bezel>
<bezel name="button_6_text2" element="button_6_num"> <bounds x=" 86" y=" 98" width="25" height="8"/></bezel>
<bezel name="button_7_text1" element="button_7_text"> <bounds x=" 18" y="122" width="25" height="8"/></bezel>
<bezel name="button_7_text2" element="button_7_num"> <bounds x=" 18" y="132" width="25" height="8"/></bezel>
<bezel name="button_8_text1" element="button_8_text"> <bounds x=" 52" y="122" width="25" height="8"/></bezel>
<bezel name="button_8_text2" element="button_8_num"> <bounds x=" 52" y="132" width="25" height="8"/></bezel>
<bezel name="button_9_text1" element="button_9_text"> <bounds x=" 86" y="122" width="25" height="8"/></bezel>
<bezel name="button_9_text2" element="button_9_num"> <bounds x=" 86" y="132" width="25" height="8"/></bezel>
<bezel name="button_star_text1" element="button_star_text"> <bounds x=" 18" y="156" width="25" height="8"/></bezel>
<bezel name="button_star_text2" element="button_star_num"> <bounds x=" 18" y="166" width="25" height="8"/></bezel>
<bezel name="button_0_text1" element="button_0_text"> <bounds x=" 52" y="156" width="25" height="8"/></bezel>
<bezel name="button_0_text2" element="button_0_num"> <bounds x=" 52" y="166" width="25" height="8"/></bezel>
<bezel name="button_hash_text" element="button_hash_num"> <bounds x=" 86" y="161" width="25" height="8"/></bezel>
<bezel name="button_clear_text1" element="button_clear_text"><bounds x="120" y=" 59" width="25" height="7"/></bezel>
<bezel name="button_back_text1" element="button_back_text"> <bounds x="120" y=" 88" width="25" height="7"/></bezel>
<bezel name="button_space_text1" element="button_space_text"><bounds x="120" y=" 98" width="25" height="7"/></bezel>
<bezel name="button_alpha_text1" element="button_alpha_text"><bounds x="120" y="127" width="25" height="7"/></bezel>
<bezel name="button_func_text1" element="button_func_text"> <bounds x="120" y="156" width="25" height="7"/></bezel>
<bezel name="button_enter_text1" element="button_enter_text"><bounds x="120" y="166" width="25" height="7"/></bezel>
<bezel name="enter_line_strike" element="button_enter_line"><bounds x="122.5" y="164" width="20" height="1"/></bezel>
<bezel element="hl" inputtag="COL.0" inputmask="0x01"><bounds x=" 20" y=" 52" width="21" height="21" /><color alpha="0.2" /></bezel>
<bezel element="hl" inputtag="COL.0" inputmask="0x02"><bounds x=" 20" y=" 86" width="21" height="21" /><color alpha="0.2" /></bezel>
<bezel element="hl" inputtag="COL.0" inputmask="0x04"><bounds x=" 20" y="120" width="21" height="21" /><color alpha="0.2" /></bezel>
<bezel element="hl" inputtag="COL.0" inputmask="0x08"><bounds x=" 20" y="154" width="21" height="21" /><color alpha="0.2" /></bezel>
<bezel element="hl" inputtag="COL.1" inputmask="0x01"><bounds x=" 54" y=" 52" width="21" height="21" /><color alpha="0.2" /></bezel>
<bezel element="hl" inputtag="COL.1" inputmask="0x02"><bounds x=" 54" y=" 86" width="21" height="21" /><color alpha="0.2" /></bezel>
<bezel element="hl" inputtag="COL.1" inputmask="0x04"><bounds x=" 54" y="120" width="21" height="21" /><color alpha="0.2" /></bezel>
<bezel element="hl" inputtag="COL.1" inputmask="0x08"><bounds x=" 54" y="154" width="21" height="21" /><color alpha="0.2" /></bezel>
<bezel element="hl" inputtag="COL.2" inputmask="0x01"><bounds x=" 88" y=" 52" width="21" height="21" /><color alpha="0.2" /></bezel>
<bezel element="hl" inputtag="COL.2" inputmask="0x02"><bounds x=" 88" y=" 86" width="21" height="21" /><color alpha="0.2" /></bezel>
<bezel element="hl" inputtag="COL.2" inputmask="0x04"><bounds x=" 88" y="120" width="21" height="21" /><color alpha="0.2" /></bezel>
<bezel element="hl" inputtag="COL.2" inputmask="0x08"><bounds x=" 88" y="154" width="21" height="21" /><color alpha="0.2" /></bezel>
<bezel element="hl" inputtag="COL.3" inputmask="0x01"><bounds x="122" y=" 52" width="21" height="21" /><color alpha="0.2" /></bezel>
<bezel element="hl" inputtag="COL.3" inputmask="0x02"><bounds x="122" y=" 86" width="21" height="21" /><color alpha="0.2" /></bezel>
<bezel element="hl" inputtag="COL.3" inputmask="0x04"><bounds x="122" y="120" width="21" height="21" /><color alpha="0.2" /></bezel>
<bezel element="hl" inputtag="COL.3" inputmask="0x08"><bounds x="122" y="154" width="21" height="21" /><color alpha="0.2" /></bezel>
</view>
</mamelayout>

View File

@ -466,14 +466,14 @@ WRITE8_MEMBER(sms_state::smsj_audio_control_w)
1,1 : Both PSG and FM enabled 1,1 : Both PSG and FM enabled
*/ */
if (m_smsj_audio_control == 0x00 || m_smsj_audio_control == 0x03) if (m_smsj_audio_control == 0x00 || m_smsj_audio_control == 0x03)
m_psg_sms->set_output_gain(0, 1.0); m_psg_sms->set_output_gain(ALL_OUTPUTS, 1.0);
else else
m_psg_sms->set_output_gain(0, 0.0); m_psg_sms->set_output_gain(ALL_OUTPUTS, 0.0);
if (m_smsj_audio_control == 0x01 || m_smsj_audio_control == 0x03) if (m_smsj_audio_control == 0x01 || m_smsj_audio_control == 0x03)
m_ym->set_output_gain(0, 1.0); m_ym->set_output_gain(ALL_OUTPUTS, 1.0);
else else
m_ym->set_output_gain(0, 0.0); m_ym->set_output_gain(ALL_OUTPUTS, 0.0);
} }

View File

@ -4,9 +4,9 @@
mame.lst mame.lst
This is not automatically generated file, and should be manually updated when This is not an automatically generated file, and it should be manually
new driver is added. From time to time we will auto update comments updated when new driver is added. From time to time, we will auto-update
according to meta-data from source files. comments according to metadata from source files.
******************************************************************************/ ******************************************************************************/
@ -1166,6 +1166,9 @@ amust //
angelkds // 833-6599 (c) 1988 Sega / Nasco? angelkds // 833-6599 (c) 1988 Sega / Nasco?
spcpostn // (c) 1986 Sega / Nasco" spcpostn // (c) 1986 Sega / Nasco"
@source:anzterm.cpp
anzterm // Burroughs EF315-I220
@source:apc.cpp @source:apc.cpp
apc // apc //
@ -10317,7 +10320,8 @@ wizzard //
@source:crystal.cpp @source:crystal.cpp
crysbios // crysbios //
crysking // 2001 Brezzasoft. Crystal of the kings crysking // 2001 Brezzasoft. Crystal of the kings
ddz // (c) 200? crzyddz2 // 2006 Sealy
ddz // 200?
donghaer // donghaer //
evosocc // 2001 Evoga. Evolution Soccer evosocc // 2001 Evoga. Evolution Soccer
officeye // officeye //
@ -14593,8 +14597,9 @@ sdmg2 // (c) 1997
slqz2 // (c) 1998 slqz2 // (c) 1998
spkrform // (c) ???? spkrform // (c) ????
starzan // (c) 2000? starzan // (c) 2000?
tarzan // (c) 1999? tarzan // (c) 1999
tarzana // (c) 1999? tarzana // (c) 1999
tarzanc // (c) 1999
tjsb // (c) 1997 tjsb // (c) 1997
@source:igspc.cpp @source:igspc.cpp
@ -28157,7 +28162,8 @@ derbyoc // 1999.10 Derby Owners Club (Japan) (Rev B)
derbyoc2 // 2001.10 Derby Owners Club II Ver.2.1 (Japan) (Rev B) derbyoc2 // 2001.10 Derby Owners Club II Ver.2.1 (Japan) (Rev B)
derbyocw // 2005.?? Derby Owners Club World Edition EX (Rev D) derbyocw // 2005.?? Derby Owners Club World Edition EX (Rev D)
dirtypig // 2004.09 Dirty Pig Skin Football dirtypig // 2004.09 Dirty Pig Skin Football
doa2 // 1999.11 Dead or Alive 2 doa2 // 1999.12? Dead or Alive 2
doa2a // 1999.11 Dead or Alive 2 (Rev A)
doa2m // 2000.01 Dead or Alive 2 Millennium doa2m // 2000.01 Dead or Alive 2 Millennium
dolphin // 2003.08 Dolphin Blue dolphin // 2003.08 Dolphin Blue
dragntr2 // 2004.?? Dragon Treasure 2 (Rev A) dragntr2 // 2004.?? Dragon Treasure 2 (Rev A)
@ -35796,6 +35802,9 @@ wizzquiz // (c) 1985 Konami
wizzquiza // (c) 1985 Zilec-Zenitone wizzquiza // (c) 1985 Zilec-Zenitone
yieartf // GX361 (c) 1985 yieartf // GX361 (c) 1985
@source:tranz330.cpp
tranz330 // (c) 1985 VeriFone
@source:travrusa.cpp @source:travrusa.cpp
motorace // (c) 1983 Williams license motorace // (c) 1983 Williams license
mototour // (c) 1983 Tecfri mototour // (c) 1983 Tecfri

View File

@ -34,6 +34,7 @@ ampro.cpp
amstr_pc.cpp amstr_pc.cpp
amstrad.cpp amstrad.cpp
amust.cpp amust.cpp
anzterm.cpp
apc.cpp apc.cpp
apexc.cpp apexc.cpp
apf.cpp apf.cpp
@ -616,6 +617,7 @@ tmc1800.cpp
tmc2000e.cpp tmc2000e.cpp
tmc600.cpp tmc600.cpp
tr606.cpp tr606.cpp
tranz330.cpp
tricep.cpp tricep.cpp
trs80.cpp trs80.cpp
trs80m2.cpp trs80m2.cpp

View File

@ -70,10 +70,10 @@ struct basictokens
static imgtoolerr_t basic_readfile(const basictokens *tokens, static imgtoolerr_t basic_readfile(const basictokens *tokens,
imgtool::partition *partition, const char *filename, imgtool::partition *partition, const char *filename,
const char *fork, imgtool_stream *destf) const char *fork, imgtool::stream &destf)
{ {
imgtoolerr_t err; imgtoolerr_t err;
imgtool_stream *mem_stream; imgtool::stream *mem_stream;
UINT8 line_header[4]; UINT8 line_header[4];
UINT16 line_number; //, address; UINT16 line_number; //, address;
UINT8 b, shift; UINT8 b, shift;
@ -83,7 +83,7 @@ static imgtoolerr_t basic_readfile(const basictokens *tokens,
const char *token; const char *token;
/* open a memory stream */ /* open a memory stream */
mem_stream = stream_open_mem(nullptr, 0); mem_stream = imgtool::stream::open_mem(nullptr, 0);
if (mem_stream == nullptr) if (mem_stream == nullptr)
{ {
err = IMGTOOLERR_OUTOFMEMORY; err = IMGTOOLERR_OUTOFMEMORY;
@ -91,15 +91,15 @@ static imgtoolerr_t basic_readfile(const basictokens *tokens,
} }
/* read actual file */ /* read actual file */
err = partition->read_file(filename, fork, mem_stream, nullptr); err = partition->read_file(filename, fork, *mem_stream, nullptr);
if (err) if (err)
goto done; goto done;
/* skip first few bytes */ /* skip first few bytes */
stream_seek(mem_stream, tokens->skip_bytes, SEEK_SET); mem_stream->seek(tokens->skip_bytes, SEEK_SET);
/* keep reading line headers */ /* keep reading line headers */
while(stream_read(mem_stream, line_header, sizeof(line_header)) == sizeof(line_header)) while(mem_stream->read(line_header, sizeof(line_header)) == sizeof(line_header))
{ {
/* pluck the address and line number out */ /* pluck the address and line number out */
if (tokens->be) if (tokens->be)
@ -116,10 +116,10 @@ static imgtoolerr_t basic_readfile(const basictokens *tokens,
} }
/* write the line number */ /* write the line number */
stream_printf(destf, "%u ", (unsigned) line_number); destf.printf("%u ", (unsigned) line_number);
shift = 0x00; shift = 0x00;
while((stream_read(mem_stream, &b, 1) > 0) && (b != 0x00)) while((mem_stream->read(&b, 1) > 0) && (b != 0x00))
{ {
if (b == 0x22) if (b == 0x22)
in_string = in_string ? FALSE : TRUE; in_string = in_string ? FALSE : TRUE;
@ -149,20 +149,20 @@ static imgtoolerr_t basic_readfile(const basictokens *tokens,
} }
if (shift == 0x00) if (shift == 0x00)
stream_puts(destf, token ? token : "!"); destf.puts(token ? token : "!");
} }
else else
{ {
stream_putc(destf, (char) b); destf.putc((char) b);
} }
} }
stream_puts(destf, EOLN); destf.puts(EOLN);
} }
done: done:
if (mem_stream != nullptr) if (mem_stream != nullptr)
stream_close(mem_stream); delete mem_stream;
return err; return err;
} }
@ -175,10 +175,10 @@ done:
static imgtoolerr_t basic_writefile(const basictokens *tokens, static imgtoolerr_t basic_writefile(const basictokens *tokens,
imgtool::partition *partition, const char *filename, imgtool::partition *partition, const char *filename,
const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{ {
imgtoolerr_t err; imgtoolerr_t err;
imgtool_stream *mem_stream; imgtool::stream *mem_stream;
char buf[1024]; char buf[1024];
int eof = FALSE; int eof = FALSE;
UINT32 len; UINT32 len;
@ -193,7 +193,7 @@ static imgtoolerr_t basic_writefile(const basictokens *tokens,
UINT16 address; UINT16 address;
/* open a memory stream */ /* open a memory stream */
mem_stream = stream_open_mem(nullptr, 0); mem_stream = imgtool::stream::open_mem(nullptr, 0);
if (mem_stream == nullptr) if (mem_stream == nullptr)
{ {
err = IMGTOOLERR_OUTOFMEMORY; err = IMGTOOLERR_OUTOFMEMORY;
@ -201,14 +201,14 @@ static imgtoolerr_t basic_writefile(const basictokens *tokens,
} }
/* skip first few bytes */ /* skip first few bytes */
stream_fill(mem_stream, 0x00, tokens->skip_bytes); mem_stream->fill(0x00, tokens->skip_bytes);
/* loop until the file is complete */ /* loop until the file is complete */
while(!eof) while(!eof)
{ {
/* read a line */ /* read a line */
pos = 0; pos = 0;
while((len = stream_read(sourcef, &c, 1)) > 0) while((len = sourcef.read(&c, 1)) > 0)
{ {
/* break if at end of line */ /* break if at end of line */
if ((c == '\r') || (c == '\n')) if ((c == '\r') || (c == '\n'))
@ -239,7 +239,7 @@ static imgtoolerr_t basic_writefile(const basictokens *tokens,
/* determine address */ /* determine address */
if (tokens->baseaddress != 0) if (tokens->baseaddress != 0)
{ {
address = tokens->baseaddress + (UINT16)stream_size(mem_stream) + 4; address = tokens->baseaddress + (UINT16)mem_stream->size() + 4;
} }
else else
{ {
@ -260,7 +260,7 @@ static imgtoolerr_t basic_writefile(const basictokens *tokens,
} }
/* emit line header */ /* emit line header */
stream_write(mem_stream, line_header, sizeof(line_header)); mem_stream->write(line_header, sizeof(line_header));
/* skip spaces */ /* skip spaces */
while(isspace(buf[pos])) while(isspace(buf[pos]))
@ -304,26 +304,26 @@ static imgtoolerr_t basic_writefile(const basictokens *tokens,
{ {
/* emit the token */ /* emit the token */
if (token_shift != 0) if (token_shift != 0)
stream_write(mem_stream, &token_shift, 1); mem_stream->write(&token_shift, 1);
stream_write(mem_stream, &token_value, 1); mem_stream->write(&token_value, 1);
} }
else else
{ {
/* no token; emit the byte */ /* no token; emit the byte */
stream_write(mem_stream, &buf[pos++], 1); mem_stream->write(&buf[pos++], 1);
} }
} }
/* emit line terminator */ /* emit line terminator */
stream_fill(mem_stream, 0x00, 1); mem_stream->fill(0x00, 1);
} }
} }
/* emit program terminator */ /* emit program terminator */
stream_fill(mem_stream, 0x00, 2); mem_stream->fill(0x00, 2);
/* reset stream */ /* reset stream */
stream_seek(mem_stream, 0, SEEK_SET); mem_stream->seek(0, SEEK_SET);
/* this is somewhat gross */ /* this is somewhat gross */
if (tokens->skip_bytes >= 3) if (tokens->skip_bytes >= 3)
@ -331,25 +331,25 @@ static imgtoolerr_t basic_writefile(const basictokens *tokens,
if (tokens->be) if (tokens->be)
{ {
place_integer_be(file_header, 0, 1, 0xFF); place_integer_be(file_header, 0, 1, 0xFF);
place_integer_be(file_header, 1, 2, stream_size(mem_stream)); place_integer_be(file_header, 1, 2, mem_stream->size());
} }
else else
{ {
place_integer_le(file_header, 0, 1, 0xFF); place_integer_le(file_header, 0, 1, 0xFF);
place_integer_le(file_header, 1, 2, stream_size(mem_stream)); place_integer_le(file_header, 1, 2, mem_stream->size());
} }
stream_write(mem_stream, file_header, 3); mem_stream->write(file_header, 3);
stream_seek(mem_stream, 0, SEEK_SET); mem_stream->seek(0, SEEK_SET);
} }
/* write actual file */ /* write actual file */
err = partition->write_file(filename, fork, mem_stream, opts, nullptr); err = partition->write_file(filename, fork, *mem_stream, opts, nullptr);
if (err) if (err)
goto done; goto done;
done: done:
if (mem_stream != nullptr) if (mem_stream != nullptr)
stream_close(mem_stream); delete mem_stream;
return err; return err;
} }
@ -2959,13 +2959,13 @@ static const basictokens cocobas_tokens =
}; };
static imgtoolerr_t cocobas_readfile(imgtool::partition *partition, const char *filename, static imgtoolerr_t cocobas_readfile(imgtool::partition *partition, const char *filename,
const char *fork, imgtool_stream *destf) const char *fork, imgtool::stream &destf)
{ {
return basic_readfile(&cocobas_tokens, partition, filename, fork, destf); return basic_readfile(&cocobas_tokens, partition, filename, fork, destf);
} }
static imgtoolerr_t cocobas_writefile(imgtool::partition *partition, const char *filename, static imgtoolerr_t cocobas_writefile(imgtool::partition *partition, const char *filename,
const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{ {
return basic_writefile(&cocobas_tokens, partition, filename, fork, sourcef, opts); return basic_writefile(&cocobas_tokens, partition, filename, fork, sourcef, opts);
} }
@ -3003,13 +3003,13 @@ static const basictokens dragonbas_tokens =
}; };
static imgtoolerr_t dragonbas_readfile(imgtool::partition *partition, const char *filename, static imgtoolerr_t dragonbas_readfile(imgtool::partition *partition, const char *filename,
const char *fork, imgtool_stream *destf) const char *fork, imgtool::stream &destf)
{ {
return basic_readfile(&dragonbas_tokens, partition, filename, fork, destf); return basic_readfile(&dragonbas_tokens, partition, filename, fork, destf);
} }
static imgtoolerr_t dragonbas_writefile(imgtool::partition *partition, const char *filename, static imgtoolerr_t dragonbas_writefile(imgtool::partition *partition, const char *filename,
const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{ {
return basic_writefile(&dragonbas_tokens, partition, filename, fork, sourcef, opts); return basic_writefile(&dragonbas_tokens, partition, filename, fork, sourcef, opts);
} }
@ -3048,13 +3048,13 @@ static const basictokens vzbas_tokens =
}; };
static imgtoolerr_t vzbas_readfile(imgtool::partition *partition, const char *filename, static imgtoolerr_t vzbas_readfile(imgtool::partition *partition, const char *filename,
const char *fork, imgtool_stream *destf) const char *fork, imgtool::stream &destf)
{ {
return basic_readfile(&vzbas_tokens, partition, filename, fork, destf); return basic_readfile(&vzbas_tokens, partition, filename, fork, destf);
} }
static imgtoolerr_t vzbas_writefile(imgtool::partition *partition, const char *filename, static imgtoolerr_t vzbas_writefile(imgtool::partition *partition, const char *filename,
const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{ {
return basic_writefile(&vzbas_tokens, partition, filename, fork, sourcef, opts); return basic_writefile(&vzbas_tokens, partition, filename, fork, sourcef, opts);
} }
@ -3092,13 +3092,13 @@ static const basictokens bml3bas_tokens =
}; };
static imgtoolerr_t bml3bas_readfile(imgtool::partition *partition, const char *filename, static imgtoolerr_t bml3bas_readfile(imgtool::partition *partition, const char *filename,
const char *fork, imgtool_stream *destf) const char *fork, imgtool::stream &destf)
{ {
return basic_readfile(&bml3bas_tokens, partition, filename, fork, destf); return basic_readfile(&bml3bas_tokens, partition, filename, fork, destf);
} }
static imgtoolerr_t bml3bas_writefile(imgtool::partition *partition, const char *filename, static imgtoolerr_t bml3bas_writefile(imgtool::partition *partition, const char *filename,
const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{ {
return basic_writefile(&bml3bas_tokens, partition, filename, fork, sourcef, opts); return basic_writefile(&bml3bas_tokens, partition, filename, fork, sourcef, opts);
} }

View File

@ -16,13 +16,13 @@
static imgtoolerr_t convert_stream_eolns(imgtool_stream *source, imgtool_stream *dest, const char *eoln) static imgtoolerr_t convert_stream_eolns(imgtool::stream &source, imgtool::stream &dest, const char *eoln)
{ {
size_t len, i, pos; size_t len, i, pos;
char buffer[2000]; char buffer[2000];
int hit_cr = FALSE; int hit_cr = FALSE;
while((len = stream_read(source, buffer, sizeof(buffer))) > 0) while((len = source.read(buffer, sizeof(buffer))) > 0)
{ {
pos = 0; pos = 0;
@ -35,8 +35,8 @@ static imgtoolerr_t convert_stream_eolns(imgtool_stream *source, imgtool_stream
if (!hit_cr || (buffer[i] != '\n')) if (!hit_cr || (buffer[i] != '\n'))
{ {
if (i > pos) if (i > pos)
stream_write(dest, buffer + pos, i - pos); dest.write(buffer + pos, i - pos);
stream_write(dest, eoln, strlen(eoln)); dest.write(eoln, strlen(eoln));
} }
pos = i + 1; pos = i + 1;
break; break;
@ -45,7 +45,7 @@ static imgtoolerr_t convert_stream_eolns(imgtool_stream *source, imgtool_stream
} }
if (i > pos) if (i > pos)
stream_write(dest, buffer + pos, i - pos); dest.write(buffer + pos, i - pos);
} }
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
@ -53,43 +53,43 @@ static imgtoolerr_t convert_stream_eolns(imgtool_stream *source, imgtool_stream
static imgtoolerr_t ascii_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *destf) static imgtoolerr_t ascii_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{ {
imgtoolerr_t err; imgtoolerr_t err;
imgtool_stream *mem_stream; imgtool::stream *mem_stream;
mem_stream = stream_open_mem(nullptr, 0); mem_stream = imgtool::stream::open_mem(nullptr, 0);
if (!mem_stream) if (!mem_stream)
{ {
err = IMGTOOLERR_OUTOFMEMORY; err = IMGTOOLERR_OUTOFMEMORY;
goto done; goto done;
} }
err = partition->read_file(filename, fork, mem_stream, nullptr); err = partition->read_file(filename, fork, *mem_stream, nullptr);
if (err) if (err)
goto done; goto done;
stream_seek(mem_stream, SEEK_SET, 0); mem_stream->seek(SEEK_SET, 0);
err = convert_stream_eolns(mem_stream, destf, EOLN); err = convert_stream_eolns(*mem_stream, destf, EOLN);
if (err) if (err)
goto done; goto done;
done: done:
if (mem_stream) if (mem_stream)
stream_close(mem_stream); delete mem_stream;
return err; return err;
} }
static imgtoolerr_t ascii_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) static imgtoolerr_t ascii_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{ {
imgtoolerr_t err; imgtoolerr_t err;
imgtool_stream *mem_stream = nullptr; imgtool::stream *mem_stream = nullptr;
const char *eoln; const char *eoln;
/* create a stream */ /* create a stream */
mem_stream = stream_open_mem(nullptr, 0); mem_stream = imgtool::stream::open_mem(nullptr, 0);
if (!mem_stream) if (!mem_stream)
{ {
err = IMGTOOLERR_OUTOFMEMORY; err = IMGTOOLERR_OUTOFMEMORY;
@ -98,18 +98,18 @@ static imgtoolerr_t ascii_writefile(imgtool::partition *partition, const char *f
eoln = partition->get_info_string(IMGTOOLINFO_STR_EOLN); eoln = partition->get_info_string(IMGTOOLINFO_STR_EOLN);
err = convert_stream_eolns(sourcef, mem_stream, eoln); err = convert_stream_eolns(sourcef, *mem_stream, eoln);
if (err) if (err)
goto done; goto done;
stream_seek(mem_stream, SEEK_SET, 0); mem_stream->seek(SEEK_SET, 0);
err = partition->write_file(filename, fork, mem_stream, opts, nullptr); err = partition->write_file(filename, fork, *mem_stream, opts, nullptr);
if (err) if (err)
goto done; goto done;
done: done:
if (mem_stream) if (mem_stream)
stream_close(mem_stream); delete mem_stream;
return err; return err;
} }

View File

@ -45,29 +45,29 @@ imgtoolerr_t imgtool_floppy_error(floperr_t err)
static void imgtool_floppy_closeproc(void *file) static void imgtool_floppy_closeproc(void *file)
{ {
stream_close((imgtool_stream *) file); delete reinterpret_cast<imgtool::stream *>(file);
} }
static int imgtool_floppy_seekproc(void *file, INT64 offset, int whence) static int imgtool_floppy_seekproc(void *file, INT64 offset, int whence)
{ {
stream_seek((imgtool_stream *) file, offset, whence); reinterpret_cast<imgtool::stream *>(file)->seek(offset, whence);
return 0; return 0;
} }
static size_t imgtool_floppy_readproc(void *file, void *buffer, size_t length) static size_t imgtool_floppy_readproc(void *file, void *buffer, size_t length)
{ {
return stream_read((imgtool_stream *) file, buffer, length); return reinterpret_cast<imgtool::stream *>(file)->read(buffer, length);
} }
static size_t imgtool_floppy_writeproc(void *file, const void *buffer, size_t length) static size_t imgtool_floppy_writeproc(void *file, const void *buffer, size_t length)
{ {
stream_write((imgtool_stream *) file, buffer, length); reinterpret_cast<imgtool::stream *>(file)->write(buffer, length);
return length; return length;
} }
static UINT64 imgtool_floppy_filesizeproc(void *file) static UINT64 imgtool_floppy_filesizeproc(void *file)
{ {
return stream_size((imgtool_stream *) file); return reinterpret_cast<imgtool::stream *>(file)->size();
} }
static const struct io_procs imgtool_ioprocs = static const struct io_procs imgtool_ioprocs =
@ -102,22 +102,22 @@ struct imgtool_floppy_image
static imgtoolerr_t imgtool_floppy_open_internal(imgtool::image *image, imgtool_stream *f, int noclose) static imgtoolerr_t imgtool_floppy_open_internal(imgtool::image *image, imgtool::stream &f, int noclose)
{ {
floperr_t ferr; floperr_t ferr;
imgtoolerr_t err; imgtoolerr_t err;
struct imgtool_floppy_image *fimg; struct imgtool_floppy_image *fimg;
const imgtool_class *imgclass; const imgtool_class *imgclass;
const struct FloppyFormat *format; const struct FloppyFormat *format;
imgtoolerr_t (*open)(imgtool::image *image, imgtool_stream *f); imgtoolerr_t (*open)(imgtool::image *image, imgtool::stream *f);
fimg = (struct imgtool_floppy_image *) image->extra_bytes(); fimg = (struct imgtool_floppy_image *) image->extra_bytes();
imgclass = &image->module().imgclass; imgclass = &image->module().imgclass;
format = (const struct FloppyFormat *) imgclass->derived_param; format = (const struct FloppyFormat *) imgclass->derived_param;
open = (imgtoolerr_t (*)(imgtool::image *, imgtool_stream *)) imgtool_get_info_ptr(imgclass, IMGTOOLINFO_PTR_FLOPPY_OPEN); open = (imgtoolerr_t (*)(imgtool::image *, imgtool::stream *)) imgtool_get_info_ptr(imgclass, IMGTOOLINFO_PTR_FLOPPY_OPEN);
/* open up the floppy */ /* open up the floppy */
ferr = floppy_open(f, noclose ? &imgtool_noclose_ioprocs : &imgtool_ioprocs, ferr = floppy_open(&f, noclose ? &imgtool_noclose_ioprocs : &imgtool_ioprocs,
"", format, FLOPPY_FLAGS_READWRITE, &fimg->floppy); "", format, FLOPPY_FLAGS_READWRITE, &fimg->floppy);
if (ferr) if (ferr)
{ {
@ -137,31 +137,31 @@ static imgtoolerr_t imgtool_floppy_open_internal(imgtool::image *image, imgtool_
static imgtoolerr_t imgtool_floppy_open(imgtool::image *image, imgtool_stream *f) static imgtoolerr_t imgtool_floppy_open(imgtool::image *image, imgtool::stream &f)
{ {
return imgtool_floppy_open_internal(image, f, FALSE); return imgtool_floppy_open_internal(image, f, FALSE);
} }
static imgtoolerr_t imgtool_floppy_create(imgtool::image *image, imgtool_stream *f, util::option_resolution *opts) static imgtoolerr_t imgtool_floppy_create(imgtool::image *image, imgtool::stream &f, util::option_resolution *opts)
{ {
floperr_t ferr; floperr_t ferr;
imgtoolerr_t err = IMGTOOLERR_SUCCESS; imgtoolerr_t err = IMGTOOLERR_SUCCESS;
struct imgtool_floppy_image *fimg; struct imgtool_floppy_image *fimg;
const imgtool_class *imgclass; const imgtool_class *imgclass;
const struct FloppyFormat *format; const struct FloppyFormat *format;
imgtoolerr_t (*create)(imgtool::image *, imgtool_stream *, util::option_resolution *); imgtoolerr_t (*create)(imgtool::image *, imgtool::stream *, util::option_resolution *);
imgtoolerr_t (*open)(imgtool::image *image, imgtool_stream *f); imgtoolerr_t (*open)(imgtool::image *image, imgtool::stream *f);
fimg = (struct imgtool_floppy_image *) image->extra_bytes(); fimg = (struct imgtool_floppy_image *) image->extra_bytes();
imgclass = &image->module().imgclass; imgclass = &image->module().imgclass;
format = (const struct FloppyFormat *) imgclass->derived_param; format = (const struct FloppyFormat *) imgclass->derived_param;
create = (imgtoolerr_t (*)(imgtool::image *, imgtool_stream *, util::option_resolution *)) imgtool_get_info_ptr(imgclass, IMGTOOLINFO_PTR_FLOPPY_CREATE); create = (imgtoolerr_t (*)(imgtool::image *, imgtool::stream *, util::option_resolution *)) imgtool_get_info_ptr(imgclass, IMGTOOLINFO_PTR_FLOPPY_CREATE);
open = (imgtoolerr_t (*)(imgtool::image *, imgtool_stream *)) imgtool_get_info_ptr(imgclass, IMGTOOLINFO_PTR_FLOPPY_OPEN); open = (imgtoolerr_t (*)(imgtool::image *, imgtool::stream *)) imgtool_get_info_ptr(imgclass, IMGTOOLINFO_PTR_FLOPPY_OPEN);
/* open up the floppy */ /* open up the floppy */
ferr = floppy_create(f, &imgtool_ioprocs, format, opts, &fimg->floppy); ferr = floppy_create(&f, &imgtool_ioprocs, format, opts, &fimg->floppy);
if (ferr) if (ferr)
{ {
err = imgtool_floppy_error(ferr); err = imgtool_floppy_error(ferr);
@ -305,7 +305,7 @@ floppy_image_legacy *imgtool_floppy(imgtool::image *img)
static imgtoolerr_t imgtool_floppy_transfer_sector_tofrom_stream(imgtool::image *img, int head, int track, int sector, int offset, size_t length, imgtool_stream *f, int direction) static imgtoolerr_t imgtool_floppy_transfer_sector_tofrom_stream(imgtool::image *img, int head, int track, int sector, int offset, size_t length, imgtool::stream &f, int direction)
{ {
floperr_t err; floperr_t err;
floppy_image_legacy *floppy; floppy_image_legacy *floppy;
@ -320,11 +320,11 @@ static imgtoolerr_t imgtool_floppy_transfer_sector_tofrom_stream(imgtool::image
err = floppy_read_sector(floppy, head, track, sector, offset, &buffer[0], length); err = floppy_read_sector(floppy, head, track, sector, offset, &buffer[0], length);
if (err) if (err)
goto done; goto done;
stream_write(f, &buffer[0], length); f.write(&buffer[0], length);
} }
else else
{ {
stream_read(f, &buffer[0], length); f.read(&buffer[0], length);
err = floppy_write_sector(floppy, head, track, sector, offset, &buffer[0], length, 0); /* TODO: pass ddam argument from imgtool */ err = floppy_write_sector(floppy, head, track, sector, offset, &buffer[0], length, 0); /* TODO: pass ddam argument from imgtool */
if (err) if (err)
goto done; goto done;
@ -338,14 +338,14 @@ done:
imgtoolerr_t imgtool_floppy_read_sector_to_stream(imgtool::image *img, int head, int track, int sector, int offset, size_t length, imgtool_stream *f) imgtoolerr_t imgtool_floppy_read_sector_to_stream(imgtool::image *img, int head, int track, int sector, int offset, size_t length, imgtool::stream &f)
{ {
return imgtool_floppy_transfer_sector_tofrom_stream(img, head, track, sector, offset, length, f, 1); return imgtool_floppy_transfer_sector_tofrom_stream(img, head, track, sector, offset, length, f, 1);
} }
imgtoolerr_t imgtool_floppy_write_sector_from_stream(imgtool::image *img, int head, int track, int sector, int offset, size_t length, imgtool_stream *f) imgtoolerr_t imgtool_floppy_write_sector_from_stream(imgtool::image *img, int head, int track, int sector, int offset, size_t length, imgtool::stream &f)
{ {
return imgtool_floppy_transfer_sector_tofrom_stream(img, head, track, sector, offset, length, f, 0); return imgtool_floppy_transfer_sector_tofrom_stream(img, head, track, sector, offset, length, f, 0);
} }

View File

@ -32,8 +32,8 @@ int imgtool_floppy_make_class(int index, imgtool_class *imgclass);
floppy_image_legacy *imgtool_floppy(imgtool::image *img); floppy_image_legacy *imgtool_floppy(imgtool::image *img);
imgtoolerr_t imgtool_floppy_error(floperr_t err); imgtoolerr_t imgtool_floppy_error(floperr_t err);
imgtoolerr_t imgtool_floppy_read_sector_to_stream(imgtool::image *img, int head, int track, int sector, int offset, size_t length, imgtool_stream *f); imgtoolerr_t imgtool_floppy_read_sector_to_stream(imgtool::image *img, int head, int track, int sector, int offset, size_t length, imgtool::stream &f);
imgtoolerr_t imgtool_floppy_write_sector_from_stream(imgtool::image *img, int head, int track, int sector, int offset, size_t length, imgtool_stream *f); imgtoolerr_t imgtool_floppy_write_sector_from_stream(imgtool::image *img, int head, int track, int sector, int offset, size_t length, imgtool::stream &f);
void *imgtool_floppy_extrabytes(imgtool::image *img); void *imgtool_floppy_extrabytes(imgtool::image *img);

View File

@ -46,7 +46,7 @@ static imgtoolerr_t map_chd_error(chd_error chderr)
Create a MAME HD image Create a MAME HD image
*/ */
imgtoolerr_t imghd_create(imgtool_stream *stream, UINT32 hunksize, UINT32 cylinders, UINT32 heads, UINT32 sectors, UINT32 seclen) imgtoolerr_t imghd_create(imgtool::stream &stream, UINT32 hunksize, UINT32 cylinders, UINT32 heads, UINT32 sectors, UINT32 seclen)
{ {
imgtoolerr_t err = IMGTOOLERR_SUCCESS; imgtoolerr_t err = IMGTOOLERR_SUCCESS;
chd_file chd; chd_file chd;
@ -63,7 +63,7 @@ imgtoolerr_t imghd_create(imgtool_stream *stream, UINT32 hunksize, UINT32 cylind
hunksize = 1024; /* default value */ hunksize = 1024; /* default value */
/* bail if we are read only */ /* bail if we are read only */
if (stream_isreadonly(stream)) if (stream.is_read_only())
{ {
err = IMGTOOLERR_READONLY; err = IMGTOOLERR_READONLY;
return err; return err;
@ -73,7 +73,7 @@ imgtoolerr_t imghd_create(imgtool_stream *stream, UINT32 hunksize, UINT32 cylind
const UINT64 logicalbytes = (UINT64)cylinders * heads * sectors * seclen; const UINT64 logicalbytes = (UINT64)cylinders * heads * sectors * seclen;
/* create the new hard drive */ /* create the new hard drive */
rc = chd.create(*stream_core_file(stream), logicalbytes, hunksize, seclen, compression); rc = chd.create(*stream.core_file(), logicalbytes, hunksize, seclen, compression);
if (rc != CHDERR_NONE) if (rc != CHDERR_NONE)
{ {
err = map_chd_error(rc); err = map_chd_error(rc);
@ -81,7 +81,7 @@ imgtoolerr_t imghd_create(imgtool_stream *stream, UINT32 hunksize, UINT32 cylind
} }
/* open the new hard drive */ /* open the new hard drive */
rc = chd.open(*stream_core_file(stream)); rc = chd.open(*stream.core_file());
if (rc != CHDERR_NONE) if (rc != CHDERR_NONE)
{ {
@ -125,7 +125,7 @@ imgtoolerr_t imghd_create(imgtool_stream *stream, UINT32 hunksize, UINT32 cylind
Open stream as a MAME HD image Open stream as a MAME HD image
*/ */
imgtoolerr_t imghd_open(imgtool_stream *stream, struct mess_hard_disk_file *hard_disk) imgtoolerr_t imghd_open(imgtool::stream &stream, struct mess_hard_disk_file *hard_disk)
{ {
chd_error chderr; chd_error chderr;
imgtoolerr_t err = IMGTOOLERR_SUCCESS; imgtoolerr_t err = IMGTOOLERR_SUCCESS;
@ -133,7 +133,7 @@ imgtoolerr_t imghd_open(imgtool_stream *stream, struct mess_hard_disk_file *hard
hard_disk->hard_disk = nullptr; hard_disk->hard_disk = nullptr;
hard_disk->chd = nullptr; hard_disk->chd = nullptr;
chderr = hard_disk->chd->open(*stream_core_file(stream), stream_isreadonly(stream)); chderr = hard_disk->chd->open(*stream.core_file(), stream.is_read_only());
if (chderr) if (chderr)
{ {
err = map_chd_error(chderr); err = map_chd_error(chderr);
@ -146,7 +146,7 @@ imgtoolerr_t imghd_open(imgtool_stream *stream, struct mess_hard_disk_file *hard
err = IMGTOOLERR_UNEXPECTED; err = IMGTOOLERR_UNEXPECTED;
goto done; goto done;
} }
hard_disk->stream = stream; hard_disk->stream = &stream;
done: done:
if (err) if (err)
@ -169,7 +169,10 @@ void imghd_close(struct mess_hard_disk_file *disk)
disk->hard_disk = nullptr; disk->hard_disk = nullptr;
} }
if (disk->stream) if (disk->stream)
stream_close(disk->stream); {
delete disk->stream;
disk->stream = nullptr;
}
} }
@ -215,7 +218,7 @@ const hard_disk_info *imghd_get_header(struct mess_hard_disk_file *disk)
} }
static imgtoolerr_t mess_hd_image_create(imgtool::image *image, imgtool_stream *f, util::option_resolution *createoptions); static imgtoolerr_t mess_hd_image_create(imgtool::image *image, imgtool::stream &f, util::option_resolution *createoptions);
enum enum
{ {
@ -254,7 +257,7 @@ void hd_get_info(const imgtool_class *imgclass, UINT32 state, union imgtoolinfo
static imgtoolerr_t mess_hd_image_create(imgtool::image *image, imgtool_stream *f, util::option_resolution *createoptions) static imgtoolerr_t mess_hd_image_create(imgtool::image *image, imgtool::stream &f, util::option_resolution *createoptions)
{ {
UINT32 blocksize, cylinders, heads, sectors, seclen; UINT32 blocksize, cylinders, heads, sectors, seclen;

View File

@ -15,17 +15,17 @@
struct mess_hard_disk_file struct mess_hard_disk_file
{ {
imgtool_stream *stream; imgtool::stream *stream;
hard_disk_file *hard_disk; hard_disk_file *hard_disk;
chd_file *chd; chd_file *chd;
}; };
/* create a new hard disk */ /* create a new hard disk */
imgtoolerr_t imghd_create(imgtool_stream *stream, UINT32 blocksize, UINT32 cylinders, UINT32 heads, UINT32 sectors, UINT32 seclen); imgtoolerr_t imghd_create(imgtool::stream &stream, UINT32 blocksize, UINT32 cylinders, UINT32 heads, UINT32 sectors, UINT32 seclen);
/* opens a hard disk given an Imgtool stream */ /* opens a hard disk given an Imgtool stream */
imgtoolerr_t imghd_open(imgtool_stream *stream, struct mess_hard_disk_file *hard_disk); imgtoolerr_t imghd_open(imgtool::stream &stream, struct mess_hard_disk_file *hard_disk);
/* close a hard disk */ /* close a hard disk */
void imghd_close(struct mess_hard_disk_file *disk); void imghd_close(struct mess_hard_disk_file *disk);

View File

@ -573,8 +573,8 @@ imgtool::partition::partition(imgtool::image &image, imgtool_class &imgclass, in
m_next_enum = (imgtoolerr_t(*)(imgtool::directory *, imgtool_dirent *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_NEXT_ENUM); m_next_enum = (imgtoolerr_t(*)(imgtool::directory *, imgtool_dirent *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_NEXT_ENUM);
m_close_enum = (void(*)(imgtool::directory *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_CLOSE_ENUM); m_close_enum = (void(*)(imgtool::directory *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_CLOSE_ENUM);
m_free_space = (imgtoolerr_t(*)(imgtool::partition *, UINT64 *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_FREE_SPACE); m_free_space = (imgtoolerr_t(*)(imgtool::partition *, UINT64 *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_FREE_SPACE);
m_read_file = (imgtoolerr_t(*)(imgtool::partition *, const char *, const char *, imgtool_stream *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_READ_FILE); m_read_file = (imgtoolerr_t(*)(imgtool::partition *, const char *, const char *, imgtool::stream &)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_READ_FILE);
m_write_file = (imgtoolerr_t(*)(imgtool::partition *, const char *, const char *, imgtool_stream *, util::option_resolution *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_WRITE_FILE); m_write_file = (imgtoolerr_t(*)(imgtool::partition *, const char *, const char *, imgtool::stream &, util::option_resolution *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_WRITE_FILE);
m_delete_file = (imgtoolerr_t(*)(imgtool::partition *, const char *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_DELETE_FILE); m_delete_file = (imgtoolerr_t(*)(imgtool::partition *, const char *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_DELETE_FILE);
m_list_forks = (imgtoolerr_t(*)(imgtool::partition *, const char *, imgtool_forkent *, size_t)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_LIST_FORKS); m_list_forks = (imgtoolerr_t(*)(imgtool::partition *, const char *, imgtool_forkent *, size_t)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_LIST_FORKS);
m_create_dir = (imgtoolerr_t(*)(imgtool::partition *, const char *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_CREATE_DIR); m_create_dir = (imgtoolerr_t(*)(imgtool::partition *, const char *)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_CREATE_DIR);
@ -896,7 +896,7 @@ imgtoolerr_t imgtool::image::internal_open(const imgtool_module *module, const c
int read_or_write, util::option_resolution *createopts, imgtool::image::ptr &outimg) int read_or_write, util::option_resolution *createopts, imgtool::image::ptr &outimg)
{ {
imgtoolerr_t err; imgtoolerr_t err;
imgtool_stream *f = nullptr; imgtool::stream *f = nullptr;
imgtool::image::ptr image; imgtool::image::ptr image;
object_pool *pool = nullptr; object_pool *pool = nullptr;
void *extra_bytes = nullptr; void *extra_bytes = nullptr;
@ -919,7 +919,7 @@ imgtoolerr_t imgtool::image::internal_open(const imgtool_module *module, const c
} }
// open the stream // open the stream
f = stream_open(fname, read_or_write); f = imgtool::stream::open(fname, read_or_write);
if (!f) if (!f)
{ {
err = (imgtoolerr_t)(IMGTOOLERR_FILENOTFOUND | IMGTOOLERR_SRC_IMAGEFILE); err = (imgtoolerr_t)(IMGTOOLERR_FILENOTFOUND | IMGTOOLERR_SRC_IMAGEFILE);
@ -966,7 +966,7 @@ imgtoolerr_t imgtool::image::internal_open(const imgtool_module *module, const c
done: done:
if (err && f) if (err && f)
stream_close(f); delete f;
if (pool) if (pool)
pool_free_lib(pool); pool_free_lib(pool);
@ -1502,12 +1502,12 @@ done:
//------------------------------------------------- //-------------------------------------------------
imgtoolerr_t imgtool::partition::suggest_file_filters(const char *path, imgtoolerr_t imgtool::partition::suggest_file_filters(const char *path,
imgtool_stream *stream, imgtool_transfer_suggestion *suggestions, size_t suggestions_length) imgtool::stream *stream, imgtool_transfer_suggestion *suggestions, size_t suggestions_length)
{ {
imgtoolerr_t err; imgtoolerr_t err;
int i, j; int i, j;
char *alloc_path = nullptr; char *alloc_path = nullptr;
imgtoolerr_t (*check_stream)(imgtool_stream *stream, imgtool_suggestion_viability_t *viability); imgtoolerr_t (*check_stream)(imgtool::stream &stream, imgtool_suggestion_viability_t *viability);
size_t position; size_t position;
// clear out buffer // clear out buffer
@ -1537,12 +1537,12 @@ imgtoolerr_t imgtool::partition::suggest_file_filters(const char *path,
{ {
if (stream && suggestions[i].filter) if (stream && suggestions[i].filter)
{ {
check_stream = (imgtoolerr_t (*)(imgtool_stream *, imgtool_suggestion_viability_t *)) filter_get_info_fct(suggestions[i].filter, FILTINFO_PTR_CHECKSTREAM); check_stream = (imgtoolerr_t (*)(imgtool::stream &, imgtool_suggestion_viability_t *)) filter_get_info_fct(suggestions[i].filter, FILTINFO_PTR_CHECKSTREAM);
if (check_stream) if (check_stream)
{ {
position = stream_tell(stream); position = stream->tell();
err = check_stream(stream, &suggestions[i].viability); err = check_stream(*stream, &suggestions[i].viability);
stream_seek(stream, position, SEEK_SET); stream->seek(position, SEEK_SET);
if (err) if (err)
goto done; goto done;
} }
@ -1697,7 +1697,7 @@ imgtoolerr_t imgtool::partition::get_free_space(UINT64 &sz)
// from a file on a partition with a stream // from a file on a partition with a stream
//------------------------------------------------- //-------------------------------------------------
imgtoolerr_t imgtool::partition::read_file(const char *filename, const char *fork, imgtool_stream *destf, filter_getinfoproc filter) imgtoolerr_t imgtool::partition::read_file(const char *filename, const char *fork, imgtool::stream &destf, filter_getinfoproc filter)
{ {
imgtoolerr_t err; imgtoolerr_t err;
char *alloc_path = nullptr; char *alloc_path = nullptr;
@ -1758,7 +1758,7 @@ done:
// to a new file on an image with a stream // to a new file on an image with a stream
//------------------------------------------------- //-------------------------------------------------
imgtoolerr_t imgtool::partition::write_file(const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts, filter_getinfoproc filter) imgtoolerr_t imgtool::partition::write_file(const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts, filter_getinfoproc filter)
{ {
imgtoolerr_t err; imgtoolerr_t err;
char *buf = nullptr; char *buf = nullptr;
@ -1842,7 +1842,7 @@ imgtoolerr_t imgtool::partition::write_file(const char *filename, const char *fo
goto done; goto done;
} }
file_size = stream_size(sourcef); file_size = sourcef.size();
if (file_size > free_space) if (file_size > free_space)
{ {
@ -1878,7 +1878,7 @@ imgtoolerr_t imgtool::partition::get_file(const char *filename, const char *fork
const char *dest, filter_getinfoproc filter) const char *dest, filter_getinfoproc filter)
{ {
imgtoolerr_t err; imgtoolerr_t err;
imgtool_stream *f; imgtool::stream *f;
char *new_fname = nullptr; char *new_fname = nullptr;
char *alloc_dest = nullptr; char *alloc_dest = nullptr;
const char *filter_extension = nullptr; const char *filter_extension = nullptr;
@ -1907,7 +1907,7 @@ imgtoolerr_t imgtool::partition::get_file(const char *filename, const char *fork
} }
} }
f = stream_open(dest, OSD_FOPEN_WRITE); f = imgtool::stream::open(dest, OSD_FOPEN_WRITE);
if (!f) if (!f)
{ {
err = (imgtoolerr_t)(IMGTOOLERR_FILENOTFOUND | IMGTOOLERR_SRC_NATIVEFILE); err = (imgtoolerr_t)(IMGTOOLERR_FILENOTFOUND | IMGTOOLERR_SRC_NATIVEFILE);
@ -1921,13 +1921,13 @@ imgtoolerr_t imgtool::partition::get_file(const char *filename, const char *fork
goto done; goto done;
} }
err = read_file(new_fname, fork, f, filter); err = read_file(new_fname, fork, *f, filter);
if (err) if (err)
goto done; goto done;
done: done:
if (f != nullptr) if (f != nullptr)
stream_close(f); delete f;
if (alloc_dest != nullptr) if (alloc_dest != nullptr)
free(alloc_dest); free(alloc_dest);
if (new_fname != nullptr) if (new_fname != nullptr)
@ -1945,7 +1945,7 @@ imgtoolerr_t imgtool::partition::put_file(const char *newfname, const char *fork
const char *source, util::option_resolution *opts, filter_getinfoproc filter) const char *source, util::option_resolution *opts, filter_getinfoproc filter)
{ {
imgtoolerr_t err; imgtoolerr_t err;
imgtool_stream *f = nullptr; imgtool::stream *f = nullptr;
imgtool_charset charset; imgtool_charset charset;
char *alloc_newfname = nullptr; char *alloc_newfname = nullptr;
std::string basename; std::string basename;
@ -1970,16 +1970,16 @@ imgtoolerr_t imgtool::partition::put_file(const char *newfname, const char *fork
newfname = alloc_newfname; newfname = alloc_newfname;
} }
f = stream_open(source, OSD_FOPEN_READ); f = imgtool::stream::open(source, OSD_FOPEN_READ);
if (f) if (f)
err = write_file(newfname, fork, f, opts, filter); err = write_file(newfname, fork, *f, opts, filter);
else else
err = (imgtoolerr_t)(IMGTOOLERR_FILENOTFOUND | IMGTOOLERR_SRC_NATIVEFILE); err = (imgtoolerr_t)(IMGTOOLERR_FILENOTFOUND | IMGTOOLERR_SRC_NATIVEFILE);
done: done:
/* clean up */ /* clean up */
if (f != nullptr) if (f != nullptr)
stream_close(f); delete f;
if (alloc_newfname != nullptr) if (alloc_newfname != nullptr)
osd_free(alloc_newfname); osd_free(alloc_newfname);
return err; return err;

View File

@ -153,8 +153,8 @@ namespace imgtool
imgtoolerr_t get_directory_entry(const char *path, int index, imgtool_dirent &ent); imgtoolerr_t get_directory_entry(const char *path, int index, imgtool_dirent &ent);
imgtoolerr_t get_file_size(const char *filename, UINT64 &filesize); imgtoolerr_t get_file_size(const char *filename, UINT64 &filesize);
imgtoolerr_t get_free_space(UINT64 &sz); imgtoolerr_t get_free_space(UINT64 &sz);
imgtoolerr_t read_file(const char *filename, const char *fork, imgtool_stream *destf, filter_getinfoproc filter); imgtoolerr_t read_file(const char *filename, const char *fork, imgtool::stream &destf, filter_getinfoproc filter);
imgtoolerr_t write_file(const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *resolution, filter_getinfoproc filter); imgtoolerr_t write_file(const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *resolution, filter_getinfoproc filter);
imgtoolerr_t get_file(const char *filename, const char *fork, const char *dest, filter_getinfoproc filter); imgtoolerr_t get_file(const char *filename, const char *fork, const char *dest, filter_getinfoproc filter);
imgtoolerr_t put_file(const char *newfname, const char *fork, const char *source, util::option_resolution *opts, filter_getinfoproc filter); imgtoolerr_t put_file(const char *newfname, const char *fork, const char *source, util::option_resolution *opts, filter_getinfoproc filter);
imgtoolerr_t delete_file(const char *fname); imgtoolerr_t delete_file(const char *fname);
@ -168,7 +168,7 @@ namespace imgtool
imgtoolerr_t put_file_attribute(const char *path, UINT32 attr, const imgtool_attribute &value); imgtoolerr_t put_file_attribute(const char *path, UINT32 attr, const imgtool_attribute &value);
void get_attribute_name(UINT32 attribute, const imgtool_attribute *attr_value, char *buffer, size_t buffer_len); void get_attribute_name(UINT32 attribute, const imgtool_attribute *attr_value, char *buffer, size_t buffer_len);
imgtoolerr_t get_icon_info(const char *path, imgtool_iconinfo *iconinfo); imgtoolerr_t get_icon_info(const char *path, imgtool_iconinfo *iconinfo);
imgtoolerr_t suggest_file_filters(const char *path, imgtool_stream *stream, imgtool_transfer_suggestion *suggestions, size_t suggestions_length); imgtoolerr_t suggest_file_filters(const char *path, imgtool::stream *stream, imgtool_transfer_suggestion *suggestions, size_t suggestions_length);
imgtoolerr_t get_block_size(UINT32 &length); imgtoolerr_t get_block_size(UINT32 &length);
imgtoolerr_t read_block(UINT64 block, void *buffer); imgtoolerr_t read_block(UINT64 block, void *buffer);
imgtoolerr_t write_block(UINT64 block, const void *buffer); imgtoolerr_t write_block(UINT64 block, const void *buffer);
@ -206,8 +206,8 @@ namespace imgtool
imgtoolerr_t(*m_next_enum) (imgtool::directory *enumeration, imgtool_dirent *ent); imgtoolerr_t(*m_next_enum) (imgtool::directory *enumeration, imgtool_dirent *ent);
void(*m_close_enum) (imgtool::directory *enumeration); void(*m_close_enum) (imgtool::directory *enumeration);
imgtoolerr_t(*m_free_space) (imgtool::partition *partition, UINT64 *size); imgtoolerr_t(*m_free_space) (imgtool::partition *partition, UINT64 *size);
imgtoolerr_t(*m_read_file) (imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *destf); imgtoolerr_t(*m_read_file) (imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf);
imgtoolerr_t(*m_write_file) (imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts); imgtoolerr_t(*m_write_file) (imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts);
imgtoolerr_t(*m_delete_file) (imgtool::partition *partition, const char *filename); imgtoolerr_t(*m_delete_file) (imgtool::partition *partition, const char *filename);
imgtoolerr_t(*m_list_forks) (imgtool::partition *partition, const char *path, imgtool_forkent *ents, size_t len); imgtoolerr_t(*m_list_forks) (imgtool::partition *partition, const char *path, imgtool_forkent *ents, size_t len);
imgtoolerr_t(*m_create_dir) (imgtool::partition *partition, const char *path); imgtoolerr_t(*m_create_dir) (imgtool::partition *partition, const char *path);

View File

@ -69,8 +69,8 @@ void library::add_class(const imgtool_class *imgclass)
module->tracks_are_called_cylinders = imgtool_get_info_int(imgclass, IMGTOOLINFO_INT_TRACKS_ARE_CALLED_CYLINDERS) ? 1 : 0; module->tracks_are_called_cylinders = imgtool_get_info_int(imgclass, IMGTOOLINFO_INT_TRACKS_ARE_CALLED_CYLINDERS) ? 1 : 0;
module->writing_untested = imgtool_get_info_int(imgclass, IMGTOOLINFO_INT_WRITING_UNTESTED) ? 1 : 0; module->writing_untested = imgtool_get_info_int(imgclass, IMGTOOLINFO_INT_WRITING_UNTESTED) ? 1 : 0;
module->creation_untested = imgtool_get_info_int(imgclass, IMGTOOLINFO_INT_CREATION_UNTESTED) ? 1 : 0; module->creation_untested = imgtool_get_info_int(imgclass, IMGTOOLINFO_INT_CREATION_UNTESTED) ? 1 : 0;
module->open = (imgtoolerr_t (*)(imgtool::image *, imgtool_stream *)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_OPEN); module->open = (imgtoolerr_t (*)(imgtool::image *, imgtool::stream *)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_OPEN);
module->create = (imgtoolerr_t (*)(imgtool::image *, imgtool_stream *, util::option_resolution *)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_CREATE); module->create = (imgtoolerr_t (*)(imgtool::image *, imgtool::stream *, util::option_resolution *)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_CREATE);
module->close = (void (*)(imgtool::image *)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_CLOSE); module->close = (void (*)(imgtool::image *)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_CLOSE);
module->info = (void (*)(imgtool::image *, char *, size_t)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_INFO); module->info = (void (*)(imgtool::image *, char *, size_t)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_INFO);
module->read_sector = (imgtoolerr_t (*)(imgtool::image *, UINT32, UINT32, UINT32, std::vector<UINT8> &)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_READ_SECTOR); module->read_sector = (imgtoolerr_t (*)(imgtool::image *, UINT32, UINT32, UINT32, std::vector<UINT8> &)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_READ_SECTOR);

View File

@ -48,9 +48,9 @@ union filterinfo
void * f; /* generic function pointers */ void * f; /* generic function pointers */
const char *s; /* generic strings */ const char *s; /* generic strings */
imgtoolerr_t (*read_file)(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *destf); imgtoolerr_t (*read_file)(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf);
imgtoolerr_t (*write_file)(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts); imgtoolerr_t (*write_file)(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts);
imgtoolerr_t (*check_stream)(imgtool_stream *stream, imgtool_suggestion_viability_t *viability); imgtoolerr_t (*check_stream)(imgtool::stream &stream, imgtool_suggestion_viability_t *viability);
}; };
typedef void (*filter_getinfoproc)(UINT32 state, union filterinfo *info); typedef void (*filter_getinfoproc)(UINT32 state, union filterinfo *info);
@ -254,9 +254,9 @@ union imgtoolinfo
void * f; /* generic function pointers */ void * f; /* generic function pointers */
char * s; /* generic strings */ char * s; /* generic strings */
imgtoolerr_t (*open) (imgtool::image *image, imgtool_stream *stream); imgtoolerr_t (*open) (imgtool::image *image, imgtool::stream &stream);
void (*close) (imgtool::image *image); void (*close) (imgtool::image *image);
imgtoolerr_t (*create) (imgtool::image *image, imgtool_stream *stream, util::option_resolution *opts); imgtoolerr_t (*create) (imgtool::image *image, imgtool::stream &stream, util::option_resolution *opts);
imgtoolerr_t (*create_partition) (imgtool::image *image, UINT64 first_block, UINT64 block_count); imgtoolerr_t (*create_partition) (imgtool::image *image, UINT64 first_block, UINT64 block_count);
void (*info) (imgtool::image *image, char *string, size_t len); void (*info) (imgtool::image *image, char *string, size_t len);
imgtoolerr_t (*begin_enum) (imgtool::directory *enumeration, const char *path); imgtoolerr_t (*begin_enum) (imgtool::directory *enumeration, const char *path);
@ -264,8 +264,8 @@ union imgtoolinfo
void (*close_enum) (imgtool::directory *enumeration); void (*close_enum) (imgtool::directory *enumeration);
imgtoolerr_t (*open_partition) (imgtool::partition *partition, UINT64 first_block, UINT64 block_count); imgtoolerr_t (*open_partition) (imgtool::partition *partition, UINT64 first_block, UINT64 block_count);
imgtoolerr_t (*free_space) (imgtool::partition *partition, UINT64 *size); imgtoolerr_t (*free_space) (imgtool::partition *partition, UINT64 *size);
imgtoolerr_t (*read_file) (imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *destf); imgtoolerr_t (*read_file) (imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf);
imgtoolerr_t (*write_file) (imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts); imgtoolerr_t (*write_file) (imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts);
imgtoolerr_t (*delete_file) (imgtool::partition *partition, const char *filename); imgtoolerr_t (*delete_file) (imgtool::partition *partition, const char *filename);
imgtoolerr_t (*list_forks) (imgtool::partition *partition, const char *path, imgtool_forkent *ents, size_t len); imgtoolerr_t (*list_forks) (imgtool::partition *partition, const char *path, imgtool_forkent *ents, size_t len);
imgtoolerr_t (*create_dir) (imgtool::partition *partition, const char *path); imgtoolerr_t (*create_dir) (imgtool::partition *partition, const char *path);
@ -347,10 +347,10 @@ struct imgtool_module
unsigned int writing_untested : 1; /* used when we support writing, but not in main build */ unsigned int writing_untested : 1; /* used when we support writing, but not in main build */
unsigned int creation_untested : 1; /* used when we support creation, but not in main build */ unsigned int creation_untested : 1; /* used when we support creation, but not in main build */
imgtoolerr_t (*open) (imgtool::image *image, imgtool_stream *f); imgtoolerr_t (*open) (imgtool::image *image, imgtool::stream *f);
void (*close) (imgtool::image *image); void (*close) (imgtool::image *image);
void (*info) (imgtool::image *image, char *string, size_t len); void (*info) (imgtool::image *image, char *string, size_t len);
imgtoolerr_t (*create) (imgtool::image *image, imgtool_stream *f, util::option_resolution *opts); imgtoolerr_t (*create) (imgtool::image *image, imgtool::stream *f, util::option_resolution *opts);
imgtoolerr_t (*get_geometry) (imgtool::image *image, UINT32 *track, UINT32 *heads, UINT32 *sectors); imgtoolerr_t (*get_geometry) (imgtool::image *image, UINT32 *track, UINT32 *heads, UINT32 *sectors);
imgtoolerr_t (*read_sector) (imgtool::image *image, UINT32 track, UINT32 head, UINT32 sector, std::vector<UINT8> &buffer); imgtoolerr_t (*read_sector) (imgtool::image *image, UINT32 track, UINT32 head, UINT32 sector, std::vector<UINT8> &buffer);
imgtoolerr_t (*write_sector) (imgtool::image *image, UINT32 track, UINT32 head, UINT32 sector, const void *buffer, size_t len); imgtoolerr_t (*write_sector) (imgtool::image *image, UINT32 track, UINT32 head, UINT32 sector, const void *buffer, size_t len);

View File

@ -587,7 +587,7 @@ static int cmd_readsector(const struct command *c, int argc, char *argv[])
{ {
imgtoolerr_t err; imgtoolerr_t err;
std::unique_ptr<imgtool::image> img; std::unique_ptr<imgtool::image> img;
imgtool_stream *stream = nullptr; imgtool::stream *stream = nullptr;
std::vector<UINT8> buffer; std::vector<UINT8> buffer;
UINT32 track, head, sector; UINT32 track, head, sector;
@ -604,18 +604,18 @@ static int cmd_readsector(const struct command *c, int argc, char *argv[])
if (err) if (err)
goto done; goto done;
stream = stream_open(argv[5], OSD_FOPEN_WRITE); stream = imgtool::stream::open(argv[5], OSD_FOPEN_WRITE);
if (!stream) if (!stream)
{ {
err = (imgtoolerr_t)(IMGTOOLERR_FILENOTFOUND | IMGTOOLERR_SRC_NATIVEFILE); err = (imgtoolerr_t)(IMGTOOLERR_FILENOTFOUND | IMGTOOLERR_SRC_NATIVEFILE);
goto done; goto done;
} }
stream_write(stream, &buffer[0], buffer.size()); stream->write(&buffer[0], buffer.size());
done: done:
if (stream) if (stream)
stream_close(stream); delete stream;
if (err) if (err)
reporterror(err, c, argv[0], argv[1], nullptr, nullptr, nullptr); reporterror(err, c, argv[0], argv[1], nullptr, nullptr, nullptr);
return err ? -1 : 0; return err ? -1 : 0;
@ -627,7 +627,7 @@ static int cmd_writesector(const struct command *c, int argc, char *argv[])
{ {
imgtoolerr_t err; imgtoolerr_t err;
std::unique_ptr<imgtool::image> img; std::unique_ptr<imgtool::image> img;
imgtool_stream *stream = nullptr; imgtool::stream *stream = nullptr;
dynamic_buffer buffer; dynamic_buffer buffer;
UINT32 size, track, head, sector; UINT32 size, track, head, sector;
@ -640,18 +640,18 @@ static int cmd_writesector(const struct command *c, int argc, char *argv[])
head = atoi(argv[3]); head = atoi(argv[3]);
sector = atoi(argv[4]); sector = atoi(argv[4]);
stream = stream_open(argv[5], OSD_FOPEN_READ); stream = imgtool::stream::open(argv[5], OSD_FOPEN_READ);
if (!stream) if (!stream)
{ {
err = (imgtoolerr_t)(IMGTOOLERR_FILENOTFOUND | IMGTOOLERR_SRC_NATIVEFILE); err = (imgtoolerr_t)(IMGTOOLERR_FILENOTFOUND | IMGTOOLERR_SRC_NATIVEFILE);
goto done; goto done;
} }
size = (UINT32) stream_size(stream); size = (UINT32) stream->size();
buffer.resize(size); buffer.resize(size);
stream_read(stream, &buffer[0], size); stream->read(&buffer[0], size);
err = img->write_sector(track, head, sector, &buffer[0], size); err = img->write_sector(track, head, sector, &buffer[0], size);
if (err) if (err)
@ -659,7 +659,7 @@ static int cmd_writesector(const struct command *c, int argc, char *argv[])
done: done:
if (stream) if (stream)
stream_close(stream); delete stream;
if (err) if (err)
reporterror(err, c, argv[0], argv[1], nullptr, nullptr, nullptr); reporterror(err, c, argv[0], argv[1], nullptr, nullptr, nullptr);
return err ? -1 : 0; return err ? -1 : 0;

View File

@ -209,7 +209,7 @@ struct softlink_block
/* Basic Amiga floppy disk image info */ /* Basic Amiga floppy disk image info */
struct amiga_floppy struct amiga_floppy
{ {
imgtool_stream *stream; imgtool::stream *stream;
UINT8 sectors; UINT8 sectors;
}; };
@ -1567,7 +1567,7 @@ static imgtoolerr_t checkdir(imgtool::image *img, const char *path, int parent)
/* Writes the file data from the specified block into the stream */ /* Writes the file data from the specified block into the stream */
static imgtoolerr_t write_file_block_data(imgtool::image *img, int block, int size, imgtool_stream *destf) static imgtoolerr_t write_file_block_data(imgtool::image *img, int block, int size, imgtool::stream &destf)
{ {
imgtoolerr_t ret; imgtoolerr_t ret;
UINT8 buffer[BSIZE]; UINT8 buffer[BSIZE];
@ -1606,7 +1606,7 @@ static imgtoolerr_t write_file_block_data(imgtool::image *img, int block, int si
} }
/* Write data to stream */ /* Write data to stream */
if (stream_write (destf, buffer, size) != size) if (destf.write(buffer, size) != size)
{ {
return IMGTOOLERR_WRITEERROR; return IMGTOOLERR_WRITEERROR;
} }
@ -1615,7 +1615,7 @@ static imgtoolerr_t write_file_block_data(imgtool::image *img, int block, int si
} }
static imgtoolerr_t walk_data_block_ptr(imgtool::image *img, UINT32 *ptr, int *filesize, imgtool_stream *destf, int write) static imgtoolerr_t walk_data_block_ptr(imgtool::image *img, UINT32 *ptr, int *filesize, imgtool::stream *destf, bool write)
{ {
int i, blocksize = is_ffs(img) ? BSIZE : BSIZE-24; int i, blocksize = is_ffs(img) ? BSIZE : BSIZE-24;
imgtoolerr_t ret; imgtoolerr_t ret;
@ -1627,7 +1627,7 @@ static imgtoolerr_t walk_data_block_ptr(imgtool::image *img, UINT32 *ptr, int *f
if (write) if (write)
{ {
ret = write_file_block_data(img, ptr[i], bytes_left, destf); ret = write_file_block_data(img, ptr[i], bytes_left, *destf);
if (ret) return ret; if (ret) return ret;
} }
else else
@ -1646,20 +1646,20 @@ static imgtoolerr_t walk_data_block_ptr(imgtool::image *img, UINT32 *ptr, int *f
} }
static imgtoolerr_t write_data_block_ptr(imgtool::image *img, UINT32 *ptr, int *filesize, imgtool_stream *destf) static imgtoolerr_t write_data_block_ptr(imgtool::image *img, UINT32 *ptr, int *filesize, imgtool::stream &destf)
{ {
return walk_data_block_ptr(img, ptr, filesize, destf, TRUE); return walk_data_block_ptr(img, ptr, filesize, &destf, true);
} }
/* Marks all blocks pointed to by the data block pointers as free */ /* Marks all blocks pointed to by the data block pointers as free */
static imgtoolerr_t clear_data_block_ptr(imgtool::image *img, UINT32 *ptr, int *filesize) static imgtoolerr_t clear_data_block_ptr(imgtool::image *img, UINT32 *ptr, int *filesize)
{ {
return walk_data_block_ptr(img, ptr, filesize, NULL, FALSE); return walk_data_block_ptr(img, ptr, filesize, nullptr, false);
} }
static imgtoolerr_t walk_file_ext_data(imgtool::image *img, int block, int *filesize, imgtool_stream *destf, int write) static imgtoolerr_t walk_file_ext_data(imgtool::image *img, int block, int *filesize, imgtool::stream *destf, int write)
{ {
file_ext_block file_ext; file_ext_block file_ext;
imgtoolerr_t ret; imgtoolerr_t ret;
@ -1698,7 +1698,7 @@ static imgtoolerr_t walk_file_ext_data(imgtool::image *img, int block, int *file
} }
static imgtoolerr_t write_file_ext_data(imgtool::image *img, int block, int *filesize, imgtool_stream *destf) static imgtoolerr_t write_file_ext_data(imgtool::image *img, int block, int *filesize, imgtool::stream *destf)
{ {
return walk_file_ext_data(img, block, filesize, destf, TRUE); return walk_file_ext_data(img, block, filesize, destf, TRUE);
} }
@ -1742,12 +1742,12 @@ static imgtoolerr_t update_disk_alteration_date(imgtool::image *img)
*****************************************************************************/ *****************************************************************************/
static imgtoolerr_t amiga_image_open(imgtool::image *img, imgtool_stream *stream) static imgtoolerr_t amiga_image_open(imgtool::image *img, imgtool::stream &stream)
{ {
amiga_floppy *f = (amiga_floppy *) img->extra_bytes(); amiga_floppy *f = (amiga_floppy *) img->extra_bytes();
UINT64 size = stream_size(stream); UINT64 size = stream.size();
f->stream = stream; f->stream = &stream;
f->sectors = size/BSIZE/80/2; f->sectors = size/BSIZE/80/2;
if (f->sectors != 11 && f->sectors != 22) if (f->sectors != 11 && f->sectors != 22)
@ -1801,15 +1801,15 @@ static imgtoolerr_t amiga_image_read_sector(imgtool::image* img, UINT32 track, U
amiga_floppy *f = (amiga_floppy *) img->extra_bytes(); amiga_floppy *f = (amiga_floppy *) img->extra_bytes();
/* skip ahead to the area we want to read */ /* skip ahead to the area we want to read */
stream_seek(f->stream, track * (head+1) * f->sectors * BSIZE + sector * BSIZE, SEEK_CUR); f->stream->seek(track * (head+1) * f->sectors * BSIZE + sector * BSIZE, SEEK_CUR);
if (stream_read(f->stream, buf, len) != len) if (f->stream->read(buf, len) != len)
{ {
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
} }
/* reset stream */ /* reset stream */
stream_seek(f->stream, 0, 0); f->stream->seek(0, 0);
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
@ -1830,16 +1830,16 @@ static imgtoolerr_t amiga_image_write_sector(imgtool::image* img, UINT32 track,
amiga_floppy *f = (amiga_floppy *) img->extra_bytes(); amiga_floppy *f = (amiga_floppy *) img->extra_bytes();
/* skip ahead to the area we want to write */ /* skip ahead to the area we want to write */
stream_seek(f->stream, track * (head+1) * f->sectors * BSIZE + sector * BSIZE, SEEK_CUR); f->stream->seek(track * (head+1) * f->sectors * BSIZE + sector * BSIZE, SEEK_CUR);
/* write data */ /* write data */
if (stream_write(f->stream, buf, len) != len) if (f->stream->write(buf, len) != len)
{ {
return IMGTOOLERR_WRITEERROR; return IMGTOOLERR_WRITEERROR;
} }
/* reset stream */ /* reset stream */
stream_seek(f->stream, 0, 0); f->stream->seek(0, 0);
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
@ -2079,7 +2079,7 @@ static imgtoolerr_t amiga_image_freespace(imgtool::partition *partition, UINT64
} }
static imgtoolerr_t amiga_image_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *destf) static imgtoolerr_t amiga_image_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{ {
imgtool::image *img = &partition->image(); imgtool::image *img = &partition->image();
imgtoolerr_t ret; imgtoolerr_t ret;
@ -2105,7 +2105,7 @@ static imgtoolerr_t amiga_image_readfile(imgtool::partition *partition, const ch
if (filesize == 0) return IMGTOOLERR_SUCCESS; if (filesize == 0) return IMGTOOLERR_SUCCESS;
/* Phase 2: Follow file extension blocks */ /* Phase 2: Follow file extension blocks */
ret = write_file_ext_data(img, file.extension, &filesize, destf); ret = write_file_ext_data(img, file.extension, &filesize, &destf);
if (ret) return ret; if (ret) return ret;
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
@ -2189,13 +2189,13 @@ static imgtoolerr_t amiga_image_deletefile(imgtool::partition *partition, const
} }
static imgtoolerr_t amiga_image_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) static imgtoolerr_t amiga_image_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{ {
return IMGTOOLERR_UNIMPLEMENTED; return IMGTOOLERR_UNIMPLEMENTED;
} }
static imgtoolerr_t amiga_image_create(imgtool::image *img, imgtool_stream *stream, util::option_resolution *opts) static imgtoolerr_t amiga_image_create(imgtool::image *img, imgtool::stream &stream, util::option_resolution *opts)
{ {
amiga_floppy *f = (amiga_floppy *) img->extra_bytes(); amiga_floppy *f = (amiga_floppy *) img->extra_bytes();
const std::string &dskname = opts->lookup_string('N'); const std::string &dskname = opts->lookup_string('N');
@ -2206,7 +2206,7 @@ static imgtoolerr_t amiga_image_create(imgtool::image *img, imgtool_stream *stre
time_t now; time_t now;
int blocks; int blocks;
f->stream = stream; f->stream = &stream;
switch (opts->lookup_int('S')) switch (opts->lookup_int('S'))
{ {

View File

@ -283,7 +283,7 @@ static void granule_location(imgtool::image *image, UINT8 granule, UINT8 *head,
static imgtoolerr_t transfer_granule(imgtool::image *img, UINT8 granule, int length, imgtool_stream *f, imgtoolerr_t (*proc)(imgtool::image *, int, int, int, int, size_t, imgtool_stream *)) static imgtoolerr_t transfer_granule(imgtool::image *img, UINT8 granule, int length, imgtool::stream &f, imgtoolerr_t (*proc)(imgtool::image *, int, int, int, int, size_t, imgtool::stream &))
{ {
imgtoolerr_t err = IMGTOOLERR_SUCCESS; imgtoolerr_t err = IMGTOOLERR_SUCCESS;
UINT8 head, track, sector; UINT8 head, track, sector;
@ -294,14 +294,14 @@ static imgtoolerr_t transfer_granule(imgtool::image *img, UINT8 granule, int len
} }
static imgtoolerr_t transfer_from_granule(imgtool::image *img, UINT8 granule, int length, imgtool_stream *destf) static imgtoolerr_t transfer_from_granule(imgtool::image *img, UINT8 granule, int length, imgtool::stream &destf)
{ {
return transfer_granule(img, granule, length, destf, imgtool_floppy_read_sector_to_stream); return transfer_granule(img, granule, length, destf, imgtool_floppy_read_sector_to_stream);
} }
static imgtoolerr_t transfer_to_granule(imgtool::image *img, UINT8 granule, int length, imgtool_stream *sourcef) static imgtoolerr_t transfer_to_granule(imgtool::image *img, UINT8 granule, int length, imgtool::stream &sourcef)
{ {
return transfer_granule(img, granule, length, sourcef, imgtool_floppy_write_sector_from_stream); return transfer_granule(img, granule, length, sourcef, imgtool_floppy_write_sector_from_stream);
} }
@ -422,7 +422,7 @@ static imgtoolerr_t get_file_size(struct bml3_dirent *ent, imgtool::image *img,
static imgtoolerr_t process_bml3_file(struct bml3_dirent *ent, imgtool::image *img, imgtool_stream *destf, size_t *size) static imgtoolerr_t process_bml3_file(struct bml3_dirent *ent, imgtool::image *img, imgtool::stream *destf, size_t *size)
{ {
imgtoolerr_t err; imgtoolerr_t err;
size_t remaining_size, granule_size; size_t remaining_size, granule_size;
@ -444,7 +444,7 @@ static imgtoolerr_t process_bml3_file(struct bml3_dirent *ent, imgtool::image *i
for (int c = 0; c < granule_list.granule_count; c++) { for (int c = 0; c < granule_list.granule_count; c++) {
if (granule_size >= remaining_size) if (granule_size >= remaining_size)
granule_size = remaining_size; granule_size = remaining_size;
transfer_from_granule(img, granule_list.granules[c], granule_size, destf); transfer_from_granule(img, granule_list.granules[c], granule_size, *destf);
remaining_size -= granule_size; remaining_size -= granule_size;
} }
} }
@ -498,7 +498,7 @@ static imgtoolerr_t prepare_dirent(UINT8 variant, struct bml3_dirent *ent, const
static imgtoolerr_t bml3_diskimage_open(imgtool::image *image, imgtool_stream *stream) static imgtoolerr_t bml3_diskimage_open(imgtool::image *image, imgtool::stream &stream)
{ {
// imgtoolerr_t err; // imgtoolerr_t err;
floperr_t ferr; floperr_t ferr;
@ -586,7 +586,7 @@ eof:
else else
{ {
/* Not the end of file */ /* Not the end of file */
err = process_bml3_file(&rsent, image, NULL, &filesize); err = process_bml3_file(&rsent, image, nullptr, &filesize);
if (err) if (err)
return err; return err;
@ -673,18 +673,18 @@ static imgtoolerr_t delete_entry(imgtool::image *img, struct bml3_dirent *ent, i
static imgtoolerr_t bml3_diskimage_readfile(imgtool::partition *partition, const char *fname, const char *fork, imgtool_stream *destf) static imgtoolerr_t bml3_diskimage_readfile(imgtool::partition *partition, const char *fname, const char *fork, imgtool::stream &destf)
{ {
imgtoolerr_t err; imgtoolerr_t err;
struct bml3_dirent ent; struct bml3_dirent ent;
size_t size; size_t size;
imgtool::image *img = &partition->image(); imgtool::image *img = &partition->image();
err = lookup_bml3_file(img, fname, &ent, NULL); err = lookup_bml3_file(img, fname, &ent, nullptr);
if (err) if (err)
return err; return err;
err = process_bml3_file(&ent, img, destf, &size); err = process_bml3_file(&ent, img, &destf, &size);
if (err) if (err)
return err; return err;
@ -696,7 +696,7 @@ static imgtoolerr_t bml3_diskimage_readfile(imgtool::partition *partition, const
static imgtoolerr_t bml3_diskimage_writefile(imgtool::partition *partition, const char *fname, const char *fork, imgtool_stream *sourcef, util::option_resolution *writeoptions) static imgtoolerr_t bml3_diskimage_writefile(imgtool::partition *partition, const char *fname, const char *fork, imgtool::stream &sourcef, util::option_resolution *writeoptions)
{ {
floperr_t ferr; floperr_t ferr;
imgtoolerr_t err; imgtoolerr_t err;
@ -724,7 +724,7 @@ static imgtoolerr_t bml3_diskimage_writefile(imgtool::partition *partition, cons
return err; return err;
/* is there enough space? */ /* is there enough space? */
sz = read_sz = stream_size(sourcef); sz = read_sz = sourcef.size();
if (info->variant == 0) { if (info->variant == 0) {
// also need to write EOF // also need to write EOF
sz++; sz++;

View File

@ -112,7 +112,7 @@ struct concept_dev_dir
*/ */
struct concept_image struct concept_image
{ {
imgtool_stream *file_handle; /* imgtool file handle */ imgtool::stream *file_handle; /* imgtool file handle */
concept_dev_dir dev_dir; /* cached copy of device directory */ concept_dev_dir dev_dir; /* cached copy of device directory */
}; };
@ -126,18 +126,18 @@ struct concept_iterator
}; };
static imgtoolerr_t concept_image_init(imgtool::image *img, imgtool_stream *f); static imgtoolerr_t concept_image_init(imgtool::image *img, imgtool::stream &f);
static void concept_image_exit(imgtool::image *img); static void concept_image_exit(imgtool::image *img);
static void concept_image_info(imgtool::image *img, char *string, size_t len); static void concept_image_info(imgtool::image *img, char *string, size_t len);
static imgtoolerr_t concept_image_beginenum(imgtool::directory *enumeration, const char *path); static imgtoolerr_t concept_image_beginenum(imgtool::directory *enumeration, const char *path);
static imgtoolerr_t concept_image_nextenum(imgtool::directory *enumeration, imgtool_dirent *ent); static imgtoolerr_t concept_image_nextenum(imgtool::directory *enumeration, imgtool_dirent *ent);
static void concept_image_closeenum(imgtool::directory *enumeration); static void concept_image_closeenum(imgtool::directory *enumeration);
static imgtoolerr_t concept_image_freespace(imgtool::partition *partition, UINT64 *size); static imgtoolerr_t concept_image_freespace(imgtool::partition *partition, UINT64 *size);
static imgtoolerr_t concept_image_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *destf); static imgtoolerr_t concept_image_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf);
#if 0 #if 0
static imgtoolerr_t concept_image_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *writeoptions); static imgtoolerr_t concept_image_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *sourcef, util::option_resolution *writeoptions);
static imgtoolerr_t concept_image_deletefile(imgtool::partition *partition, const char *filename); static imgtoolerr_t concept_image_deletefile(imgtool::partition *partition, const char *filename);
static imgtoolerr_t concept_image_create(const imgtool_module *mod, imgtool_stream *f, util::option_resolution *createoptions); static imgtoolerr_t concept_image_create(const imgtool_module *mod, imgtool::stream *f, util::option_resolution *createoptions);
#endif #endif
void concept_get_info(const imgtool_class *imgclass, UINT32 state, union imgtoolinfo *info) void concept_get_info(const imgtool_class *imgclass, UINT32 state, union imgtoolinfo *info)
@ -180,16 +180,16 @@ void concept_get_info(const imgtool_class *imgclass, UINT32 state, union imgtool
Return non-zero on error Return non-zero on error
*/ */
static int read_physical_record(imgtool_stream *file_handle, int secnum, void *dest) static int read_physical_record(imgtool::stream &file_handle, int secnum, void *dest)
{ {
int reply; int reply;
/* seek to sector */ /* seek to sector */
reply = stream_seek(file_handle, secnum*512, SEEK_SET); reply = file_handle.seek(secnum*512, SEEK_SET);
if (reply) if (reply)
return 1; return 1;
/* read it */ /* read it */
reply = stream_read(file_handle, dest, 512); reply = file_handle.read(dest, 512);
if (reply != 512) if (reply != 512)
return 1; return 1;
@ -208,16 +208,16 @@ static int read_physical_record(imgtool_stream *file_handle, int secnum, void *d
Return non-zero on error Return non-zero on error
*/ */
static int write_physical_record(imgtool_stream *file_handle, int secnum, const void *src) static int write_physical_record(imgtool::stream *file_handle, int secnum, const void *src)
{ {
int reply; int reply;
/* seek to sector */ /* seek to sector */
reply = stream_seek(file_handle, secnum*512, SEEK_SET); reply = file_handle->seek(secnum*512, SEEK_SET);
if (reply) if (reply)
return 1; return 1;
/* read it */ /* read it */
reply = stream_write(file_handle, src, 512); reply = file_handle->write(src, 512);
if (reply != 512) if (reply != 512)
return 1; return 1;
@ -260,14 +260,14 @@ static int get_catalog_entry(concept_image *image, const unsigned char *filename
/* /*
Open a file as a concept_image. Open a file as a concept_image.
*/ */
static imgtoolerr_t concept_image_init(imgtool::image *img, imgtool_stream *f) static imgtoolerr_t concept_image_init(imgtool::image *img, imgtool::stream &f)
{ {
concept_image *image = (concept_image *) img->extra_bytes(); concept_image *image = (concept_image *) img->extra_bytes();
int reply; int reply;
int i; int i;
unsigned totphysrecs; unsigned totphysrecs;
image->file_handle = f; image->file_handle = &f;
/* read device directory */ /* read device directory */
for (i=0; i<4; i++) for (i=0; i<4; i++)
@ -283,7 +283,7 @@ static imgtoolerr_t concept_image_init(imgtool::image *img, imgtool_stream *f)
if ((get_UINT16xE(image->dev_dir.vol_hdr.disk_flipped, image->dev_dir.vol_hdr.first_block) != 0) if ((get_UINT16xE(image->dev_dir.vol_hdr.disk_flipped, image->dev_dir.vol_hdr.first_block) != 0)
|| (get_UINT16xE(image->dev_dir.vol_hdr.disk_flipped, image->dev_dir.vol_hdr.next_block) != 6) || (get_UINT16xE(image->dev_dir.vol_hdr.disk_flipped, image->dev_dir.vol_hdr.next_block) != 6)
|| (totphysrecs < 6) /*|| (stream_size(f) != totphysrecs*512)*/ || (totphysrecs < 6) /*|| (f->size() != totphysrecs*512)*/
|| (image->dev_dir.vol_hdr.volname[0] > 7)) || (image->dev_dir.vol_hdr.volname[0] > 7))
{ {
return IMGTOOLERR_CORRUPTIMAGE; return IMGTOOLERR_CORRUPTIMAGE;
@ -426,7 +426,7 @@ static imgtoolerr_t concept_image_freespace(imgtool::partition *partition, UINT6
/* /*
Extract a file from a concept_image. Extract a file from a concept_image.
*/ */
static imgtoolerr_t concept_image_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *destf) static imgtoolerr_t concept_image_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{ {
imgtool::image *img = &partition->image(); imgtool::image *img = &partition->image();
concept_image *image = (concept_image *) img->extra_bytes(); concept_image *image = (concept_image *) img->extra_bytes();
@ -449,10 +449,10 @@ static imgtoolerr_t concept_image_readfile(imgtool::partition *partition, const
i < get_UINT16xE(image->dev_dir.vol_hdr.disk_flipped, image->dev_dir.file_dir[catalog_index].next_block); i < get_UINT16xE(image->dev_dir.vol_hdr.disk_flipped, image->dev_dir.file_dir[catalog_index].next_block);
i++) i++)
{ {
if (read_physical_record(image->file_handle, i, buf)) if (read_physical_record(*image->file_handle, i, buf))
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
if (stream_write(destf, buf, 512) != 512) if (destf.write(buf, 512) != 512)
return IMGTOOLERR_WRITEERROR; return IMGTOOLERR_WRITEERROR;
} }
@ -463,7 +463,7 @@ static imgtoolerr_t concept_image_readfile(imgtool::partition *partition, const
/* /*
Add a file to a concept_image. Add a file to a concept_image.
*/ */
static imgtoolerr_t concept_image_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *writeoptions) static imgtoolerr_t concept_image_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream *sourcef, util::option_resolution *writeoptions)
{ {
/* ... */ /* ... */
@ -483,7 +483,7 @@ static imgtoolerr_t concept_image_deletefile(imgtool::partition *partition, cons
/* /*
Create a blank concept_image. Create a blank concept_image.
*/ */
static imgtoolerr_t concept_image_create(const imgtool_module *mod, imgtool_stream *f, util::option_resolution *createoptions) static imgtoolerr_t concept_image_create(const imgtool_module *mod, imgtool::stream *f, util::option_resolution *createoptions)
{ {
/* ... */ /* ... */

View File

@ -14,7 +14,7 @@
struct cybiko_file_system struct cybiko_file_system
{ {
imgtool_stream *stream; imgtool::stream *stream;
UINT32 page_count, page_size, block_count_boot, block_count_file; UINT32 page_count, page_size, block_count_boot, block_count_file;
UINT16 write_count; UINT16 write_count;
}; };
@ -161,16 +161,16 @@ static int cfs_page_to_block( cybiko_file_system *cfs, UINT32 page, int *block_t
static int cfs_page_read( cybiko_file_system *cfs, UINT8 *buffer, UINT32 page) static int cfs_page_read( cybiko_file_system *cfs, UINT8 *buffer, UINT32 page)
{ {
if (page >= cfs->page_count) return FALSE; if (page >= cfs->page_count) return FALSE;
stream_seek( cfs->stream, page * cfs->page_size, SEEK_SET); cfs->stream->seek(page * cfs->page_size, SEEK_SET);
stream_read( cfs->stream, buffer, cfs->page_size); cfs->stream->read(buffer, cfs->page_size);
return TRUE; return TRUE;
} }
static int cfs_page_write( cybiko_file_system *cfs, UINT8 *buffer, UINT32 page) static int cfs_page_write( cybiko_file_system *cfs, UINT8 *buffer, UINT32 page)
{ {
if (page >= cfs->page_count) return FALSE; if (page >= cfs->page_count) return FALSE;
stream_seek( cfs->stream, page * cfs->page_size, SEEK_SET); cfs->stream->seek(page * cfs->page_size, SEEK_SET);
stream_write( cfs->stream, buffer, cfs->page_size); cfs->stream->write(buffer, cfs->page_size);
return TRUE; return TRUE;
} }
@ -252,32 +252,32 @@ static int cfs_file_find( cybiko_file_system *cfs, const char *filename, UINT16
return FALSE; return FALSE;
} }
static int cfs_verify( cybiko_file_system *cfs) static int cfs_verify(cybiko_file_system &cfs)
{ {
UINT8 buffer[MAX_PAGE_SIZE]; UINT8 buffer[MAX_PAGE_SIZE];
int i, block_type; int i, block_type;
for (i=0;i<cfs->page_count;i++) for (i = 0; i < cfs.page_count; i++)
{ {
if (!cfs_page_read( cfs, buffer, i)) return FALSE; if (!cfs_page_read(&cfs, buffer, i)) return FALSE;
if (!cfs_page_to_block( cfs, i, &block_type, NULL)) return FALSE; if (!cfs_page_to_block(&cfs, i, &block_type, NULL)) return FALSE;
if (!page_buffer_verify( buffer, cfs->page_size, block_type)) return FALSE; if (!page_buffer_verify(buffer, cfs.page_size, block_type)) return FALSE;
} }
return TRUE; return TRUE;
} }
static int cfs_init( cybiko_file_system *cfs, imgtool_stream *stream, int flash_type) static int cfs_init(cybiko_file_system &cfs, imgtool::stream &stream, int flash_type)
{ {
cfs->stream = stream; cfs.stream = &stream;
switch (flash_type) switch (flash_type)
{ {
case FLASH_TYPE_AT45DB041 : cfs->page_count = 2048; cfs->page_size = 264; break; case FLASH_TYPE_AT45DB041 : cfs.page_count = 2048; cfs.page_size = 264; break;
case FLASH_TYPE_AT45DB081 : cfs->page_count = 4096; cfs->page_size = 264; break; case FLASH_TYPE_AT45DB081 : cfs.page_count = 4096; cfs.page_size = 264; break;
case FLASH_TYPE_AT45DB161 : cfs->page_count = 4096; cfs->page_size = 528; break; case FLASH_TYPE_AT45DB161 : cfs.page_count = 4096; cfs.page_size = 528; break;
default : return FALSE; default : return FALSE;
} }
cfs->block_count_boot = 5; cfs.block_count_boot = 5;
cfs->block_count_file = cfs->page_count - cfs->block_count_boot; cfs.block_count_file = cfs.page_count - cfs.block_count_boot;
cfs->write_count = 0; cfs.write_count = 0;
return TRUE; return TRUE;
} }
@ -345,15 +345,15 @@ static int flash_option_to_flash_type( int option)
} }
} }
static imgtoolerr_t cybiko_image_open( imgtool::image *image, imgtool_stream *stream) static imgtoolerr_t cybiko_image_open(imgtool::image *image, imgtool::stream &stream)
{ {
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes(); cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
int flash_type; int flash_type;
// init // init
flash_type = flash_size_to_flash_type( stream_size( stream)); flash_type = flash_size_to_flash_type(stream.size());
if (!cfs_init( cfs, stream, flash_type)) return IMGTOOLERR_CORRUPTIMAGE; if (!cfs_init(*cfs, stream, flash_type)) return IMGTOOLERR_CORRUPTIMAGE;
// verify // verify
if (!cfs_verify( cfs)) return IMGTOOLERR_CORRUPTIMAGE; if (!cfs_verify(*cfs)) return IMGTOOLERR_CORRUPTIMAGE;
// ok // ok
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
@ -361,18 +361,18 @@ static imgtoolerr_t cybiko_image_open( imgtool::image *image, imgtool_stream *st
static void cybiko_image_close( imgtool::image *image) static void cybiko_image_close( imgtool::image *image)
{ {
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes(); cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
stream_close( cfs->stream); delete cfs->stream;
} }
static imgtoolerr_t cybiko_image_create( imgtool::image *image, imgtool_stream *stream, util::option_resolution *opts) static imgtoolerr_t cybiko_image_create( imgtool::image *image, imgtool::stream &stream, util::option_resolution *opts)
{ {
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes(); cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
int flash_type; int flash_type;
// init // init
flash_type = flash_option_to_flash_type(opts->lookup_int('F')); flash_type = flash_option_to_flash_type(opts->lookup_int('F'));
if (!cfs_init( cfs, stream, flash_type)) return IMGTOOLERR_CORRUPTIMAGE; if (!cfs_init(*cfs, stream, flash_type)) return IMGTOOLERR_CORRUPTIMAGE;
// format // format
if (!cfs_format( cfs)) return IMGTOOLERR_CORRUPTIMAGE; if (!cfs_format(cfs)) return IMGTOOLERR_CORRUPTIMAGE;
// ok // ok
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
@ -423,7 +423,7 @@ static void cybiko_image_close_enum( imgtool::directory *enumeration)
// nothing // nothing
} }
static imgtoolerr_t cybiko_image_free_space( imgtool::partition *partition, UINT64 *size) static imgtoolerr_t cybiko_image_free_space(imgtool::partition *partition, UINT64 *size)
{ {
imgtool::image *image = &partition->image(); imgtool::image *image = &partition->image();
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes(); cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
@ -431,7 +431,7 @@ static imgtoolerr_t cybiko_image_free_space( imgtool::partition *partition, UINT
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
static imgtoolerr_t cybiko_image_read_file( imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *destf) static imgtoolerr_t cybiko_image_read_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{ {
imgtool::image *image = &partition->image(); imgtool::image *image = &partition->image();
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes(); cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
@ -449,7 +449,7 @@ static imgtoolerr_t cybiko_image_read_file( imgtool::partition *partition, const
if (!cfs_block_read( cfs, buffer, BLOCK_TYPE_FILE, i)) return IMGTOOLERR_READERROR; if (!cfs_block_read( cfs, buffer, BLOCK_TYPE_FILE, i)) return IMGTOOLERR_READERROR;
if (BLOCK_USED(buffer) && (BLOCK_FILE_ID(buffer) == file_id) && (BLOCK_PART_ID(buffer) == part_id)) if (BLOCK_USED(buffer) && (BLOCK_FILE_ID(buffer) == file_id) && (BLOCK_PART_ID(buffer) == part_id))
{ {
stream_write( destf, buffer + 6 + ((part_id == 0) ? FILE_HEADER_SIZE : 0), buffer[1]); destf.write(buffer + 6 + ((part_id == 0) ? FILE_HEADER_SIZE : 0), buffer[1]);
part_id++; part_id++;
} }
} }
@ -458,7 +458,7 @@ static imgtoolerr_t cybiko_image_read_file( imgtool::partition *partition, const
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
static imgtoolerr_t cybiko_image_write_file( imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) static imgtoolerr_t cybiko_image_write_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{ {
imgtool::image *image = &partition->image(); imgtool::image *image = &partition->image();
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes(); cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
@ -468,22 +468,22 @@ static imgtoolerr_t cybiko_image_write_file( imgtool::partition *partition, cons
cfs_file file; cfs_file file;
int i; int i;
// find file // find file
if (!cfs_file_find( cfs, filename, &file_id)) file_id = INVALID_FILE_ID; if (!cfs_file_find(cfs, filename, &file_id)) file_id = INVALID_FILE_ID;
// check free space // check free space
free_blocks = cfs_calc_free_blocks( cfs); free_blocks = cfs_calc_free_blocks( cfs);
if (file_id != INVALID_FILE_ID) if (file_id != INVALID_FILE_ID)
{ {
if (!cfs_file_info( cfs, file_id, &file)) return IMGTOOLERR_UNEXPECTED; if (!cfs_file_info(cfs, file_id, &file)) return IMGTOOLERR_UNEXPECTED;
free_blocks += file.blocks; free_blocks += file.blocks;
} }
if (cfs_calc_free_space( cfs, free_blocks) < stream_size( sourcef)) return IMGTOOLERR_NOSPACE; if (cfs_calc_free_space(cfs, free_blocks) < sourcef.size()) return IMGTOOLERR_NOSPACE;
// delete file // delete file
if (file_id != INVALID_FILE_ID) if (file_id != INVALID_FILE_ID)
{ {
if (!cfs_file_delete( cfs, file_id)) return IMGTOOLERR_UNEXPECTED; if (!cfs_file_delete( cfs, file_id)) return IMGTOOLERR_UNEXPECTED;
} }
// create/write destination file // create/write destination file
bytes_left = stream_size( sourcef); bytes_left = sourcef.size();
i = 0; i = 0;
while ((bytes_left > 0) && (i < cfs->block_count_file)) while ((bytes_left > 0) && (i < cfs->block_count_file))
{ {
@ -500,13 +500,13 @@ static imgtoolerr_t cybiko_image_write_file( imgtool::partition *partition, cons
if (part_id == 0) if (part_id == 0)
{ {
buffer[6] = 0; buffer[6] = 0;
strcpy( BLOCK_FILENAME(buffer), filename); strcpy(BLOCK_FILENAME(buffer), filename);
buffer_write_32_be( buffer + 6 + FILE_HEADER_SIZE - 4, time_setup( time( NULL))); buffer_write_32_be( buffer + 6 + FILE_HEADER_SIZE - 4, time_setup( time( NULL)));
stream_read( sourcef, buffer + 6 + FILE_HEADER_SIZE, buffer[1]); sourcef.read(buffer + 6 + FILE_HEADER_SIZE, buffer[1]);
} }
else else
{ {
stream_read( sourcef, buffer + 6, buffer[1]); sourcef.read(buffer + 6, buffer[1]);
} }
if (!cfs_block_write( cfs, buffer, BLOCK_TYPE_FILE, i)) return IMGTOOLERR_WRITEERROR; if (!cfs_block_write( cfs, buffer, BLOCK_TYPE_FILE, i)) return IMGTOOLERR_WRITEERROR;
bytes_left -= buffer[1]; bytes_left -= buffer[1];

View File

@ -14,7 +14,7 @@
struct cybiko_file_system struct cybiko_file_system
{ {
imgtool_stream *stream; imgtool::stream *stream;
UINT32 page_count, page_size, block_count_boot, block_count_file; UINT32 page_count, page_size, block_count_boot, block_count_file;
UINT16 write_count; UINT16 write_count;
}; };
@ -150,16 +150,16 @@ static int cfs_page_to_block( cybiko_file_system *cfs, UINT32 page, int *block_t
static int cfs_page_read( cybiko_file_system *cfs, UINT8 *buffer, UINT32 page) static int cfs_page_read( cybiko_file_system *cfs, UINT8 *buffer, UINT32 page)
{ {
if (page >= cfs->page_count) return FALSE; if (page >= cfs->page_count) return FALSE;
stream_seek( cfs->stream, page * cfs->page_size, SEEK_SET); cfs->stream->seek(page * cfs->page_size, SEEK_SET);
stream_read( cfs->stream, buffer, cfs->page_size); cfs->stream->read(buffer, cfs->page_size);
return TRUE; return TRUE;
} }
static int cfs_page_write( cybiko_file_system *cfs, UINT8 *buffer, UINT32 page) static int cfs_page_write( cybiko_file_system *cfs, UINT8 *buffer, UINT32 page)
{ {
if (page >= cfs->page_count) return FALSE; if (page >= cfs->page_count) return FALSE;
stream_seek( cfs->stream, page * cfs->page_size, SEEK_SET); cfs->stream->seek(page * cfs->page_size, SEEK_SET);
stream_write( cfs->stream, buffer, cfs->page_size); cfs->stream->write(buffer, cfs->page_size);
return TRUE; return TRUE;
} }
@ -247,31 +247,31 @@ static int cfs_file_find( cybiko_file_system *cfs, const char *filename, UINT16
return FALSE; return FALSE;
} }
static int cfs_verify( cybiko_file_system *cfs) static bool cfs_verify(cybiko_file_system &cfs)
{ {
UINT8 buffer[MAX_PAGE_SIZE]; UINT8 buffer[MAX_PAGE_SIZE];
int i, block_type; int i, block_type;
for (i=0;i<cfs->page_count;i++) for (i = 0; i < cfs.page_count; i++)
{ {
if (!cfs_page_read( cfs, buffer, i)) return FALSE; if (!cfs_page_read(&cfs, buffer, i)) return false;
if (!cfs_page_to_block( cfs, i, &block_type, NULL)) return FALSE; if (!cfs_page_to_block(&cfs, i, &block_type, NULL)) return false;
if (!page_buffer_verify( buffer, cfs->page_size, block_type)) return FALSE; if (!page_buffer_verify(buffer, cfs.page_size, block_type)) return false;
} }
return TRUE; return true;
} }
static int cfs_init( cybiko_file_system *cfs, imgtool_stream *stream) static bool cfs_init(cybiko_file_system &cfs, imgtool::stream &stream)
{ {
cfs->stream = stream; cfs.stream = &stream;
cfs->page_count = 2005; cfs.page_count = 2005;
cfs->page_size = 258; cfs.page_size = 258;
cfs->block_count_boot = 5; cfs.block_count_boot = 5;
cfs->block_count_file = cfs->page_count - cfs->block_count_boot; cfs.block_count_file = cfs.page_count - cfs.block_count_boot;
cfs->write_count = 0; cfs.write_count = 0;
return TRUE; return true;
} }
static int cfs_format( cybiko_file_system *cfs) static int cfs_format(cybiko_file_system *cfs)
{ {
UINT8 buffer[MAX_PAGE_SIZE]; UINT8 buffer[MAX_PAGE_SIZE];
int i; int i;
@ -292,7 +292,7 @@ static int cfs_format( cybiko_file_system *cfs)
buffer[0] = 0xFF; buffer[0] = 0xFF;
for (i=0;i<0x1B56;i++) for (i=0;i<0x1B56;i++)
{ {
stream_write( cfs->stream, buffer, 1); cfs->stream->write(buffer, 1);
} }
// ok // ok
return TRUE; return TRUE;
@ -319,30 +319,30 @@ static UINT32 cfs_calc_free_space( cybiko_file_system *cfs, UINT16 blocks)
return free_space; return free_space;
} }
static imgtoolerr_t cybiko_image_open( imgtool::image *image, imgtool_stream *stream) static imgtoolerr_t cybiko_image_open(imgtool::image *image, imgtool::stream &stream)
{ {
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes(); cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
// init // init
if (!cfs_init( cfs, stream)) return IMGTOOLERR_CORRUPTIMAGE; if (!cfs_init(*cfs, stream)) return IMGTOOLERR_CORRUPTIMAGE;
// verify // verify
if (!cfs_verify( cfs)) return IMGTOOLERR_CORRUPTIMAGE; if (!cfs_verify(*cfs)) return IMGTOOLERR_CORRUPTIMAGE;
// ok // ok
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
static void cybiko_image_close( imgtool::image *image) static void cybiko_image_close(imgtool::image *image)
{ {
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes(); cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
stream_close( cfs->stream); delete cfs->stream;
} }
static imgtoolerr_t cybiko_image_create( imgtool::image *image, imgtool_stream *stream, util::option_resolution *opts) static imgtoolerr_t cybiko_image_create(imgtool::image *image, imgtool::stream &stream, util::option_resolution *opts)
{ {
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes(); cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
// init // init
if (!cfs_init( cfs, stream)) return IMGTOOLERR_CORRUPTIMAGE; if (!cfs_init(*cfs, stream)) return IMGTOOLERR_CORRUPTIMAGE;
// format // format
if (!cfs_format( cfs)) return IMGTOOLERR_CORRUPTIMAGE; if (!cfs_format(cfs)) return IMGTOOLERR_CORRUPTIMAGE;
// ok // ok
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
@ -401,7 +401,7 @@ static imgtoolerr_t cybiko_image_free_space( imgtool::partition *partition, UINT
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
static imgtoolerr_t cybiko_image_read_file( imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *destf) static imgtoolerr_t cybiko_image_read_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{ {
imgtool::image *image = &partition->image(); imgtool::image *image = &partition->image();
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes(); cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
@ -421,7 +421,7 @@ static imgtoolerr_t cybiko_image_read_file( imgtool::partition *partition, const
if (!cfs_block_read( cfs, buffer, BLOCK_TYPE_FILE, i)) return IMGTOOLERR_READERROR; if (!cfs_block_read( cfs, buffer, BLOCK_TYPE_FILE, i)) return IMGTOOLERR_READERROR;
if (BLOCK_USED(buffer) && (BLOCK_FILE_ID(buffer) == file_id) && (BLOCK_PART_ID(buffer) == part_id)) if (BLOCK_USED(buffer) && (BLOCK_FILE_ID(buffer) == file_id) && (BLOCK_PART_ID(buffer) == part_id))
{ {
stream_write( destf, buffer + 6 + ((part_id == 0) ? FILE_HEADER_SIZE : 0), buffer[1]); destf.write(buffer + 6 + ((part_id == 0) ? FILE_HEADER_SIZE : 0), buffer[1]);
part_id++; part_id++;
} }
} }
@ -430,7 +430,7 @@ static imgtoolerr_t cybiko_image_read_file( imgtool::partition *partition, const
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
static imgtoolerr_t cybiko_image_write_file( imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) static imgtoolerr_t cybiko_image_write_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{ {
imgtool::image *image = &partition->image(); imgtool::image *image = &partition->image();
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes(); cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
@ -444,20 +444,20 @@ static imgtoolerr_t cybiko_image_write_file( imgtool::partition *partition, cons
// find file // find file
if (!cfs_file_find( cfs, filename, &file_id)) file_id = INVALID_FILE_ID; if (!cfs_file_find( cfs, filename, &file_id)) file_id = INVALID_FILE_ID;
// check free space // check free space
free_blocks = cfs_calc_free_blocks( cfs); free_blocks = cfs_calc_free_blocks(cfs);
if (file_id != INVALID_FILE_ID) if (file_id != INVALID_FILE_ID)
{ {
if (!cfs_file_info( cfs, file_id, &file)) return IMGTOOLERR_UNEXPECTED; if (!cfs_file_info(cfs, file_id, &file)) return IMGTOOLERR_UNEXPECTED;
free_blocks += file.blocks; free_blocks += file.blocks;
} }
if (cfs_calc_free_space( cfs, free_blocks) < stream_size( sourcef)) return IMGTOOLERR_NOSPACE; if (cfs_calc_free_space(cfs, free_blocks) < sourcef.size()) return IMGTOOLERR_NOSPACE;
// delete file // delete file
if (file_id != INVALID_FILE_ID) if (file_id != INVALID_FILE_ID)
{ {
if (!cfs_file_delete( cfs, file_id)) return IMGTOOLERR_UNEXPECTED; if (!cfs_file_delete(cfs, file_id)) return IMGTOOLERR_UNEXPECTED;
} }
// create/write destination file // create/write destination file
bytes_left = stream_size( sourcef); bytes_left = sourcef.size();
i = 0; i = 0;
while (i < cfs->block_count_file) while (i < cfs->block_count_file)
{ {
@ -474,13 +474,13 @@ static imgtoolerr_t cybiko_image_write_file( imgtool::partition *partition, cons
if (part_id == 0) if (part_id == 0)
{ {
buffer[6] = 0x20; buffer[6] = 0x20;
strcpy( BLOCK_FILENAME(buffer), filename); strcpy(BLOCK_FILENAME(buffer), filename);
buffer_write_32_be( buffer + 6 + FILE_HEADER_SIZE - 4, time_setup( time( NULL))); buffer_write_32_be( buffer + 6 + FILE_HEADER_SIZE - 4, time_setup( time( NULL)));
stream_read( sourcef, buffer + 6 + FILE_HEADER_SIZE, buffer[1]); sourcef.read(buffer + 6 + FILE_HEADER_SIZE, buffer[1]);
} }
else else
{ {
stream_read( sourcef, buffer + 6, buffer[1]); sourcef.read(buffer + 6, buffer[1]);
} }
if (!cfs_block_write( cfs, buffer, BLOCK_TYPE_FILE, i)) return IMGTOOLERR_WRITEERROR; if (!cfs_block_write( cfs, buffer, BLOCK_TYPE_FILE, i)) return IMGTOOLERR_WRITEERROR;
bytes_left -= buffer[1]; bytes_left -= buffer[1];
@ -499,11 +499,11 @@ static imgtoolerr_t cybiko_image_delete_file( imgtool::partition *partition, con
cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes(); cybiko_file_system *cfs = (cybiko_file_system*)image->extra_bytes();
UINT16 file_id; UINT16 file_id;
// check filename // check filename
if (strlen( filename) > 58) return IMGTOOLERR_BADFILENAME; if (strlen(filename) > 58) return IMGTOOLERR_BADFILENAME;
// find file // find file
if (!cfs_file_find( cfs, filename, &file_id)) return IMGTOOLERR_FILENOTFOUND; if (!cfs_file_find(cfs, filename, &file_id)) return IMGTOOLERR_FILENOTFOUND;
// delete file // delete file
if (!cfs_file_delete( cfs, file_id)) return IMGTOOLERR_UNEXPECTED; if (!cfs_file_delete(cfs, file_id)) return IMGTOOLERR_UNEXPECTED;
// ok // ok
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }

View File

@ -1850,7 +1850,7 @@ static imgtoolerr_t fat_partition_nextenum(imgtool::directory *enumeration, imgt
static imgtoolerr_t fat_read_bootblock(imgtool::partition *partition, imgtool_stream *stream) static imgtoolerr_t fat_read_bootblock(imgtool::partition *partition, imgtool::stream &stream)
{ {
imgtoolerr_t err; imgtoolerr_t err;
UINT8 block[FAT_SECLEN]; UINT8 block[FAT_SECLEN];
@ -1859,21 +1859,21 @@ static imgtoolerr_t fat_read_bootblock(imgtool::partition *partition, imgtool_st
if (err) if (err)
return err; return err;
stream_write(stream, block, sizeof(block)); stream.write(block, sizeof(block));
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
static imgtoolerr_t fat_write_bootblock(imgtool::partition *partition, imgtool_stream *stream) static imgtoolerr_t fat_write_bootblock(imgtool::partition *partition, imgtool::stream &stream)
{ {
imgtoolerr_t err; imgtoolerr_t err;
UINT8 block[FAT_SECLEN]; UINT8 block[FAT_SECLEN];
UINT8 new_block[FAT_SECLEN]; UINT8 new_block[FAT_SECLEN];
if (stream_size(stream) != sizeof(new_block)) if (stream.size() != sizeof(new_block))
return IMGTOOLERR_UNEXPECTED; return IMGTOOLERR_UNEXPECTED;
stream_read(stream, new_block, sizeof(new_block)); stream.read(new_block, sizeof(new_block));
if (new_block[510] != 0x55) if (new_block[510] != 0x55)
return IMGTOOLERR_UNEXPECTED; return IMGTOOLERR_UNEXPECTED;
@ -1899,7 +1899,7 @@ static imgtoolerr_t fat_write_bootblock(imgtool::partition *partition, imgtool_s
static imgtoolerr_t fat_partition_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *destf) static imgtoolerr_t fat_partition_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{ {
imgtoolerr_t err; imgtoolerr_t err;
fat_file file; fat_file file;
@ -1923,7 +1923,7 @@ static imgtoolerr_t fat_partition_readfile(imgtool::partition *partition, const
if (err) if (err)
return err; return err;
stream_write(destf, buffer, bytes_read); destf.write(buffer, bytes_read);
} }
while(bytes_read > 0); while(bytes_read > 0);
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
@ -1931,7 +1931,7 @@ static imgtoolerr_t fat_partition_readfile(imgtool::partition *partition, const
static imgtoolerr_t fat_partition_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) static imgtoolerr_t fat_partition_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{ {
imgtoolerr_t err; imgtoolerr_t err;
fat_file file; fat_file file;
@ -1949,7 +1949,7 @@ static imgtoolerr_t fat_partition_writefile(imgtool::partition *partition, const
if (file.directory) if (file.directory)
return IMGTOOLERR_FILENOTFOUND; return IMGTOOLERR_FILENOTFOUND;
bytes_left = (UINT32) stream_size(sourcef); bytes_left = (UINT32) sourcef.size();
err = fat_set_file_size(partition, &file, bytes_left); err = fat_set_file_size(partition, &file, bytes_left);
if (err) if (err)
@ -1958,7 +1958,7 @@ static imgtoolerr_t fat_partition_writefile(imgtool::partition *partition, const
while(bytes_left > 0) while(bytes_left > 0)
{ {
len = (std::min<size_t>)(bytes_left, sizeof(buffer)); len = (std::min<size_t>)(bytes_left, sizeof(buffer));
stream_read(sourcef, buffer, len); sourcef.read(buffer, len);
err = fat_write_file(partition, &file, buffer, len, NULL); err = fat_write_file(partition, &file, buffer, len, NULL);
if (err) if (err)

View File

@ -95,7 +95,7 @@
struct hp48_card struct hp48_card
{ {
imgtool_stream *stream; imgtool::stream *stream;
int modified; int modified;
/* size, in bytes of card data: from 32 KB to 4 MB */ /* size, in bytes of card data: from 32 KB to 4 MB */
@ -327,36 +327,36 @@ static UINT16 crc(UINT8* data, int len)
*****************************************************************************/ *****************************************************************************/
static imgtoolerr_t hp48_open(imgtool::image *img, imgtool_stream *stream) static imgtoolerr_t hp48_open(imgtool::image *img, imgtool::stream &stream)
{ {
hp48_card* c = (hp48_card*) img->extra_bytes(); hp48_card* c = (hp48_card*) img->extra_bytes();
int size = stream_size( stream ); int size = stream.size();
/* check that size is a power of 2 between 32 KB and 4 MG */ /* check that size is a power of 2 between 32 KB and 4 MG */
if ( (size < 32 * 1024) || if ( (size < 32 * 1024) ||
(size > 4 * 1024 * 1024) || (size > 4 * 1024 * 1024) ||
(size & (size-1)) ) (size & (size-1)) )
{ {
return IMGTOOLERR_CORRUPTIMAGE; return IMGTOOLERR_CORRUPTIMAGE;
} }
/* store info */ /* store info */
c->stream = stream; c->stream = &stream;
c->modified = 0; c->modified = 0;
c->size = size; c->size = size;
c->data = (UINT8*) malloc( 2 * size ); c->data = (UINT8*) malloc( 2 * size );
if ( !c->data ) if ( !c->data )
{ {
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
} }
/* fully load image */ /* fully load image */
stream_seek( stream, 0, SEEK_SET ); stream.seek(0, SEEK_SET);
if ( stream_read( stream, c->data, size ) < size ) if (stream.read(c->data, size) < size)
{ {
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
} }
unpack( c->data, c->data, 2 * size ); unpack( c->data, c->data, 2 * size );
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
@ -364,25 +364,25 @@ static imgtoolerr_t hp48_open(imgtool::image *img, imgtool_stream *stream)
static imgtoolerr_t hp48_create(imgtool::image* img, static imgtoolerr_t hp48_create(imgtool::image* img,
imgtool_stream *stream, imgtool::stream &stream,
util::option_resolution *opts) util::option_resolution *opts)
{ {
hp48_card* c = (hp48_card*) img->extra_bytes(); hp48_card* c = (hp48_card*) img->extra_bytes();
int size; int size;
size = opts->lookup_int('S'); size = opts->lookup_int('S');
c->stream = stream; c->stream = &stream;
c->modified = 1; c->modified = 1;
c->size = size * 1024; c->size = size * 1024;
c->data = (UINT8*) malloc( 2 * c->size ); c->data = (UINT8*) malloc( 2 * c->size );
if ( !c->data ) if ( !c->data )
{ {
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
} }
/* zeroing the image seems fine */ /* zeroing the image seems fine */
memset( c->data, 0, 2 * c->size ); memset( c->data, 0, 2 * c->size );
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
@ -397,13 +397,13 @@ static void hp48_close(imgtool::image *img)
{ {
/* save image */ /* save image */
pack( c->data, c->data, 2 * c->size ); pack( c->data, c->data, 2 * c->size );
stream_seek( c->stream, 0, SEEK_SET ); c->stream->seek(0, SEEK_SET);
stream_write( c->stream, c->data, c->size ); c->stream->write(c->data, c->size);
} }
/* clean up */ /* clean up */
free( c->data ); free( c->data );
stream_close( c->stream ); delete c->stream;
} }
@ -542,7 +542,7 @@ static imgtoolerr_t hp48_freespace(imgtool::partition *part, UINT64 *size)
static imgtoolerr_t hp48_readfile(imgtool::partition *part, static imgtoolerr_t hp48_readfile(imgtool::partition *part,
const char *filename, const char *filename,
const char *fork, const char *fork,
imgtool_stream *destf) imgtool::stream &destf)
{ {
//imgtool::image* img = &part->image(); //imgtool::image* img = &part->image();
//hp48_card* c = (hp48_card*) img->extra_bytes(); //hp48_card* c = (hp48_card*) img->extra_bytes();
@ -566,7 +566,7 @@ static imgtoolerr_t hp48_readfile(imgtool::partition *part,
size -= 10; size -= 10;
/* save header */ /* save header */
stream_write( destf, hp48_prefix, 8); destf.write(hp48_prefix, 8);
/* save contents to host file */ /* save contents to host file */
int bytesize = (size + 1) / 2; int bytesize = (size + 1) / 2;
@ -576,7 +576,7 @@ static imgtoolerr_t hp48_readfile(imgtool::partition *part,
return IMGTOOLERR_FILENOTFOUND; return IMGTOOLERR_FILENOTFOUND;
} }
pack( buf, p->data + start, size ); pack( buf, p->data + start, size );
stream_write( destf, buf, bytesize ); destf.write(buf, bytesize);
free( buf ); free( buf );
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
@ -613,7 +613,7 @@ static imgtoolerr_t hp48_deletefile(imgtool::partition *part,
static imgtoolerr_t hp48_writefile(imgtool::partition *part, static imgtoolerr_t hp48_writefile(imgtool::partition *part,
const char *filename, const char *filename,
const char *fork, const char *fork,
imgtool_stream *sourcef, imgtool::stream &sourcef,
util::option_resolution *opts) util::option_resolution *opts)
{ {
imgtool::image* img = &part->image(); imgtool::image* img = &part->image();
@ -622,7 +622,7 @@ static imgtoolerr_t hp48_writefile(imgtool::partition *part,
/* check header */ /* check header */
char head[8]; char head[8];
stream_read( sourcef, head, 8 ); sourcef.read(head, 8);
if ( memcmp( head, hp48_prefix, 7) ) if ( memcmp( head, hp48_prefix, 7) )
{ {
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
@ -640,7 +640,7 @@ static imgtoolerr_t hp48_writefile(imgtool::partition *part,
if ( len > 255 ) len = 255; if ( len > 255 ) len = 255;
/* check size */ /* check size */
int filesize = stream_size( sourcef ) - 8; int filesize = sourcef.size() - 8;
if ( pos + 2*filesize + 24 + 2*len > 2 * p->size ) if ( pos + 2*filesize + 24 + 2*len > 2 * p->size )
{ {
return IMGTOOLERR_NOSPACE; return IMGTOOLERR_NOSPACE;
@ -649,7 +649,7 @@ static imgtoolerr_t hp48_writefile(imgtool::partition *part,
/* load file */ /* load file */
UINT8* buf = (UINT8*) malloc( filesize ); UINT8* buf = (UINT8*) malloc( filesize );
if ( !buf ) return IMGTOOLERR_NOSPACE; if ( !buf ) return IMGTOOLERR_NOSPACE;
stream_read( sourcef, buf, filesize ); sourcef.read(buf, filesize);
/* store backup object */ /* store backup object */
int org = pos; int org = pos;

View File

@ -216,8 +216,8 @@ public:
void format_img(void); void format_img(void);
imgtoolerr_t load_from_file(imgtool_stream *stream); imgtoolerr_t load_from_file(imgtool::stream *stream);
imgtoolerr_t save_to_file(imgtool_stream *stream); imgtoolerr_t save_to_file(imgtool::stream *stream);
unsigned free_sectors(void) const; unsigned free_sectors(void) const;
@ -259,8 +259,8 @@ private:
bool decode_dir(void); bool decode_dir(void);
static tape_pos_t word_length(tape_word_t w); static tape_pos_t word_length(tape_word_t w);
static tape_pos_t block_end_pos(tape_pos_t pos , const tape_word_t *block , unsigned block_len); static tape_pos_t block_end_pos(tape_pos_t pos , const tape_word_t *block , unsigned block_len);
static bool save_word(imgtool_stream *stream , tape_pos_t& pos , tape_word_t w); static bool save_word(imgtool::stream *stream , tape_pos_t& pos , tape_word_t w);
static bool save_words(imgtool_stream *stream , tape_pos_t& pos , const tape_word_t *block , unsigned block_len); static bool save_words(imgtool::stream *stream , tape_pos_t& pos , const tape_word_t *block , unsigned block_len);
static tape_word_t checksum(const tape_word_t *block , unsigned block_len); static tape_word_t checksum(const tape_word_t *block , unsigned block_len);
}; };
@ -268,7 +268,7 @@ private:
* Image state * Image state
********************************************************************************/ ********************************************************************************/
typedef struct { typedef struct {
imgtool_stream *stream; imgtool::stream *stream;
tape_image_t *img; tape_image_t *img;
} tape_state_t; } tape_state_t;
@ -298,13 +298,13 @@ void tape_image_t::format_img(void)
dirty = true; dirty = true;
} }
imgtoolerr_t tape_image_t::load_from_file(imgtool_stream *stream) imgtoolerr_t tape_image_t::load_from_file(imgtool::stream *stream)
{ {
stream_seek(stream , 0 , SEEK_SET); stream->seek(0 , SEEK_SET);
UINT8 tmp[ 4 ]; UINT8 tmp[ 4 ];
if (stream_read(stream , tmp , 4) != 4) { if (stream->read(tmp , 4) != 4) {
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
} }
@ -323,7 +323,7 @@ imgtoolerr_t tape_image_t::load_from_file(imgtool_stream *stream)
state = 0; state = 0;
while (1) { while (1) {
if (stream_read(stream , tmp , 4) != 4) { if (stream->read(tmp , 4) != 4) {
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
} }
UINT32 words_no = pick_integer_le(tmp , 0 , 4); UINT32 words_no = pick_integer_le(tmp , 0 , 4);
@ -331,13 +331,13 @@ imgtoolerr_t tape_image_t::load_from_file(imgtool_stream *stream)
// Track ended // Track ended
break; break;
} }
if (stream_read(stream , tmp , 4) != 4) { if (stream->read(tmp , 4) != 4) {
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
} }
tape_pos_t pos = pick_integer_le(tmp , 0 , 4); tape_pos_t pos = pick_integer_le(tmp , 0 , 4);
tape_word_t buffer[ WORDS_PER_SECTOR_W_MARGIN ]; tape_word_t buffer[ WORDS_PER_SECTOR_W_MARGIN ];
for (unsigned i = 0; i < words_no; i++) { for (unsigned i = 0; i < words_no; i++) {
if (stream_read(stream , tmp , 2) != 2) { if (stream->read(tmp , 2) != 2) {
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
} }
if (i < WORDS_PER_SECTOR_W_MARGIN) { if (i < WORDS_PER_SECTOR_W_MARGIN) {
@ -432,12 +432,12 @@ tape_pos_t tape_image_t::block_end_pos(tape_pos_t pos , const tape_word_t *block
return pos; return pos;
} }
bool tape_image_t::save_word(imgtool_stream *stream , tape_pos_t& pos , tape_word_t w) bool tape_image_t::save_word(imgtool::stream *stream , tape_pos_t& pos , tape_word_t w)
{ {
UINT8 tmp[ 2 ]; UINT8 tmp[ 2 ];
place_integer_le(tmp , 0 , 2 , w); place_integer_le(tmp , 0 , 2 , w);
if (stream_write(stream , tmp , 2) != 2) { if (stream->write(tmp , 2) != 2) {
return false; return false;
} }
@ -446,18 +446,18 @@ bool tape_image_t::save_word(imgtool_stream *stream , tape_pos_t& pos , tape_wor
return true; return true;
} }
bool tape_image_t::save_words(imgtool_stream *stream , tape_pos_t& pos , const tape_word_t *block , unsigned block_len) bool tape_image_t::save_words(imgtool::stream *stream , tape_pos_t& pos , const tape_word_t *block , unsigned block_len)
{ {
UINT8 tmp[ 4 ]; UINT8 tmp[ 4 ];
// Number of words (including preamble) // Number of words (including preamble)
place_integer_le(tmp , 0 , 4 , block_len + 1); place_integer_le(tmp , 0 , 4 , block_len + 1);
if (stream_write(stream , tmp , 4) != 4) { if (stream->write(tmp , 4) != 4) {
return false; return false;
} }
// Start position // Start position
place_integer_le(tmp , 0 , 4 , pos); place_integer_le(tmp , 0 , 4 , pos);
if (stream_write(stream , tmp , 4) != 4) { if (stream->write(tmp , 4) != 4) {
return false; return false;
} }
// Preamble // Preamble
@ -483,18 +483,18 @@ tape_word_t tape_image_t::checksum(const tape_word_t *block , unsigned block_len
return csum & 0xffff; return csum & 0xffff;
} }
imgtoolerr_t tape_image_t::save_to_file(imgtool_stream *stream) imgtoolerr_t tape_image_t::save_to_file(imgtool::stream *stream)
{ {
// Encode copies of directory into sectors // Encode copies of directory into sectors
encode_dir(); encode_dir();
// Store sectors // Store sectors
stream_seek(stream , 0 , SEEK_SET); stream->seek(0 , SEEK_SET);
UINT8 tmp[ 4 ]; UINT8 tmp[ 4 ];
place_integer_be(tmp , 0 , 4 , MAGIC); place_integer_be(tmp , 0 , 4 , MAGIC);
if (stream_write(stream , tmp , 4) != 4) { if (stream->write(tmp , 4) != 4) {
return IMGTOOLERR_WRITEERROR; return IMGTOOLERR_WRITEERROR;
} }
@ -504,7 +504,7 @@ imgtoolerr_t tape_image_t::save_to_file(imgtool_stream *stream)
if (i == TOT_SECTORS / 2) { if (i == TOT_SECTORS / 2) {
// Track 0 -> 1 // Track 0 -> 1
place_integer_le(tmp , 0 , 4 , (UINT32)-1); place_integer_le(tmp , 0 , 4 , (UINT32)-1);
if (stream_write(stream , tmp , 4) != 4) { if (stream->write(tmp , 4) != 4) {
return IMGTOOLERR_WRITEERROR; return IMGTOOLERR_WRITEERROR;
} }
} }
@ -574,7 +574,7 @@ imgtoolerr_t tape_image_t::save_to_file(imgtool_stream *stream)
} }
place_integer_le(tmp , 0 , 4 , (UINT32)-1); place_integer_le(tmp , 0 , 4 , (UINT32)-1);
if (stream_write(stream , tmp , 4) != 4) { if (stream->write(tmp , 4) != 4) {
return IMGTOOLERR_WRITEERROR; return IMGTOOLERR_WRITEERROR;
} }
@ -1042,22 +1042,22 @@ static tape_image_t& get_tape_image(tape_state_t& ts)
/******************************************************************************** /********************************************************************************
* Imgtool functions * Imgtool functions
********************************************************************************/ ********************************************************************************/
static imgtoolerr_t hp9845_tape_open(imgtool::image *image, imgtool_stream *stream) static imgtoolerr_t hp9845_tape_open(imgtool::image *image, imgtool::stream &stream)
{ {
tape_state_t& state = get_tape_state(image); tape_state_t& state = get_tape_state(image);
state.stream = stream; state.stream = &stream;
tape_image_t& tape_image = get_tape_image(state); tape_image_t& tape_image = get_tape_image(state);
return tape_image.load_from_file(stream); return tape_image.load_from_file(&stream);
} }
static imgtoolerr_t hp9845_tape_create(imgtool::image *image, imgtool_stream *stream, util::option_resolution *opts) static imgtoolerr_t hp9845_tape_create(imgtool::image *image, imgtool::stream &stream, util::option_resolution *opts)
{ {
tape_state_t& state = get_tape_state(image); tape_state_t& state = get_tape_state(image);
state.stream = stream; state.stream = &stream;
tape_image_t& tape_image = get_tape_image(state); tape_image_t& tape_image = get_tape_image(state);
@ -1075,7 +1075,7 @@ static void hp9845_tape_close(imgtool::image *image)
(void)tape_image.save_to_file(state.stream); (void)tape_image.save_to_file(state.stream);
} }
stream_close(state.stream); delete state.stream;
// Free tape_image // Free tape_image
global_free(&tape_image); global_free(&tape_image);
@ -1125,7 +1125,7 @@ static imgtoolerr_t hp9845_tape_free_space(imgtool::partition *partition, UINT64
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
static imgtoolerr_t hp9845_tape_read_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *destf) static imgtoolerr_t hp9845_tape_read_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{ {
tape_state_t& state = get_tape_state(&partition->image()); tape_state_t& state = get_tape_state(&partition->image());
tape_image_t& tape_image = get_tape_image(state); tape_image_t& tape_image = get_tape_image(state);
@ -1153,13 +1153,13 @@ static imgtoolerr_t hp9845_tape_read_file(imgtool::partition *partition, const c
tape_image_t::tape_word_to_bytes(buff_w[ i ], buff_b[ i * 2 ], buff_b[ i * 2 + 1 ]); tape_image_t::tape_word_to_bytes(buff_w[ i ], buff_b[ i * 2 ], buff_b[ i * 2 + 1 ]);
} }
stream_write(destf , buff_b , SECTOR_LEN); destf.write(buff_b , SECTOR_LEN);
} }
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
static imgtoolerr_t hp9845_tape_write_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) static imgtoolerr_t hp9845_tape_write_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{ {
tape_state_t& state = get_tape_state(&partition->image()); tape_state_t& state = get_tape_state(&partition->image());
tape_image_t& tape_image = get_tape_image(state); tape_image_t& tape_image = get_tape_image(state);
@ -1171,7 +1171,7 @@ static imgtoolerr_t hp9845_tape_write_file(imgtool::partition *partition, const
tape_image.delete_dir_entry(idx); tape_image.delete_dir_entry(idx);
} }
unsigned blocks = (unsigned)((stream_size(sourcef) + SECTOR_LEN - 1) / SECTOR_LEN); unsigned blocks = (unsigned)((sourcef.size() + SECTOR_LEN - 1) / SECTOR_LEN);
if (!blocks) { if (!blocks) {
fprintf(stderr , "Null file, not writing..\n"); fprintf(stderr , "Null file, not writing..\n");
@ -1199,7 +1199,7 @@ static imgtoolerr_t hp9845_tape_write_file(imgtool::partition *partition, const
memset(&buff_b[ 0 ] , 0 , sizeof(buff_b)); memset(&buff_b[ 0 ] , 0 , sizeof(buff_b));
if (stream_read(sourcef , buff_b , SECTOR_LEN) != SECTOR_LEN && i != (blocks - 1)) { if (sourcef.read(buff_b , SECTOR_LEN) != SECTOR_LEN && i != (blocks - 1)) {
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
} }
for (unsigned j = 0; j < WORDS_PER_SECTOR; j++) { for (unsigned j = 0; j < WORDS_PER_SECTOR; j++) {
@ -1354,22 +1354,22 @@ void hp9845_tape_get_info(const imgtool_class *imgclass, UINT32 state, union img
/******************************************************************************** /********************************************************************************
* Filter functions * Filter functions
********************************************************************************/ ********************************************************************************/
static unsigned len_to_eor(imgtool_stream *inp) static unsigned len_to_eor(imgtool::stream &inp)
{ {
return SECTOR_LEN - (unsigned)(stream_tell(inp) % SECTOR_LEN); return SECTOR_LEN - (unsigned)(inp.tell() % SECTOR_LEN);
} }
static bool get_record_part(imgtool_stream *inp , void *buf , unsigned len) static bool get_record_part(imgtool::stream &inp , void *buf , unsigned len)
{ {
// Reading must never cross sector boundary // Reading must never cross sector boundary
if (len > len_to_eor(inp)) { if (len > len_to_eor(inp)) {
return false; return false;
} }
return stream_read(inp , buf , len) == len; return inp.read(buf, len) == len;
} }
static bool dump_string(imgtool_stream *inp, imgtool_stream *out , unsigned len , bool add_eoln) static bool dump_string(imgtool::stream &inp, imgtool::stream &out , unsigned len , bool add_eoln)
{ {
UINT8 tmp[ SECTOR_LEN ]; UINT8 tmp[ SECTOR_LEN ];
@ -1384,32 +1384,32 @@ static bool dump_string(imgtool_stream *inp, imgtool_stream *out , unsigned len
} }
} }
stream_write(out , tmp , len); out.write(tmp , len);
if (add_eoln) { if (add_eoln) {
stream_puts(out , EOLN); out.puts(EOLN);
} }
return true; return true;
} }
static imgtoolerr_t hp9845data_read_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *destf) static imgtoolerr_t hp9845data_read_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{ {
imgtool_stream *inp_data; imgtool::stream *inp_data;
imgtoolerr_t res; imgtoolerr_t res;
UINT8 tmp[ 2 ]; UINT8 tmp[ 2 ];
inp_data = stream_open_mem(NULL , 0); inp_data = imgtool::stream::open_mem(NULL , 0);
if (inp_data == nullptr) { if (inp_data == nullptr) {
return IMGTOOLERR_OUTOFMEMORY; return IMGTOOLERR_OUTOFMEMORY;
} }
res = hp9845_tape_read_file(partition , filename , fork , inp_data); res = hp9845_tape_read_file(partition , filename , fork , *inp_data);
if (res != IMGTOOLERR_SUCCESS) { if (res != IMGTOOLERR_SUCCESS) {
stream_close(inp_data); delete inp_data;
return res; return res;
} }
stream_seek(inp_data , 0 , SEEK_SET); inp_data->seek(0, SEEK_SET);
UINT16 rec_type; UINT16 rec_type;
unsigned rec_len; unsigned rec_len;
@ -1418,7 +1418,7 @@ static imgtoolerr_t hp9845data_read_file(imgtool::partition *partition, const ch
do { do {
// Get record type // Get record type
if (!get_record_part(inp_data , tmp , 2)) { if (!get_record_part(*inp_data , tmp , 2)) {
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
} }
rec_type = (UINT16)pick_integer_be(tmp , 0 , 2); rec_type = (UINT16)pick_integer_be(tmp , 0 , 2);
@ -1441,7 +1441,7 @@ static imgtoolerr_t hp9845data_read_file(imgtool::partition *partition, const ch
return IMGTOOLERR_CORRUPTFILE; return IMGTOOLERR_CORRUPTFILE;
} }
if (!get_record_part(inp_data , tmp , 2)) { if (!get_record_part(*inp_data , tmp , 2)) {
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
} }
tmp_len = (unsigned)pick_integer_be(tmp , 0 , 2); tmp_len = (unsigned)pick_integer_be(tmp , 0 , 2);
@ -1456,14 +1456,14 @@ static imgtoolerr_t hp9845data_read_file(imgtool::partition *partition, const ch
if (rec_type == REC_TYPE_FULLSTR || rec_type == REC_TYPE_ENDSTR) { if (rec_type == REC_TYPE_FULLSTR || rec_type == REC_TYPE_ENDSTR) {
rec_len = accum_len; rec_len = accum_len;
} else { } else {
rec_len = std::min(accum_len , len_to_eor(inp_data)); rec_len = std::min(accum_len , len_to_eor(*inp_data));
} }
if (!dump_string(inp_data , destf , rec_len , rec_type == REC_TYPE_FULLSTR || rec_type == REC_TYPE_ENDSTR)) { if (!dump_string(*inp_data , destf , rec_len , rec_type == REC_TYPE_FULLSTR || rec_type == REC_TYPE_ENDSTR)) {
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
} }
if (rec_len & 1) { if (rec_len & 1) {
// Keep length of string pieces even // Keep length of string pieces even
get_record_part(inp_data , tmp , 1); get_record_part(*inp_data , tmp , 1);
} }
accum_len -= rec_len; accum_len -= rec_len;
break; break;
@ -1481,7 +1481,7 @@ static imgtoolerr_t hp9845data_read_file(imgtool::partition *partition, const ch
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
static bool split_string_n_dump(const char *s , imgtool_stream *dest) static bool split_string_n_dump(const char *s , imgtool::stream &dest)
{ {
unsigned s_len = strlen(s); unsigned s_len = strlen(s);
UINT16 rec_type = REC_TYPE_1STSTR; UINT16 rec_type = REC_TYPE_1STSTR;
@ -1494,7 +1494,7 @@ static bool split_string_n_dump(const char *s , imgtool_stream *dest)
// Not enough free space at end of current record: fill with EORs // Not enough free space at end of current record: fill with EORs
place_integer_be(tmp , 0 , 2 , REC_TYPE_EOR); place_integer_be(tmp , 0 , 2 , REC_TYPE_EOR);
while (free_len) { while (free_len) {
if (stream_write(dest , tmp , 2) != 2) { if (dest.write(tmp , 2) != 2) {
return false; return false;
} }
free_len -= 2; free_len -= 2;
@ -1507,8 +1507,8 @@ static bool split_string_n_dump(const char *s , imgtool_stream *dest)
} }
place_integer_be(tmp , 0 , 2 , rec_type); place_integer_be(tmp , 0 , 2 , rec_type);
place_integer_be(tmp , 2 , 2 , s_len); place_integer_be(tmp , 2 , 2 , s_len);
if (stream_write(dest , tmp , 4) != 4 || if (dest.write(tmp , 4) != 4 ||
stream_write(dest , s , s_part_len) != s_part_len) { dest.write(s, s_part_len) != s_part_len) {
return false; return false;
} }
rec_type = REC_TYPE_MIDSTR; rec_type = REC_TYPE_MIDSTR;
@ -1520,24 +1520,24 @@ static bool split_string_n_dump(const char *s , imgtool_stream *dest)
place_integer_be(tmp , 0 , 2 , at_least_one ? REC_TYPE_ENDSTR : REC_TYPE_FULLSTR); place_integer_be(tmp , 0 , 2 , at_least_one ? REC_TYPE_ENDSTR : REC_TYPE_FULLSTR);
place_integer_be(tmp , 2 , 2 , s_len); place_integer_be(tmp , 2 , 2 , s_len);
if (stream_write(dest , tmp , 4) != 4 || if (dest.write(tmp , 4) != 4 ||
stream_write(dest , s , s_len) != s_len) { dest.write(s , s_len) != s_len) {
return false; return false;
} }
if (s_len & 1) { if (s_len & 1) {
tmp[ 0 ] = 0; tmp[ 0 ] = 0;
if (stream_write(dest , tmp , 1) != 1) { if (dest.write(tmp , 1) != 1) {
return false; return false;
} }
} }
return true; return true;
} }
static imgtoolerr_t hp9845data_write_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) static imgtoolerr_t hp9845data_write_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{ {
imgtool_stream *out_data; imgtool::stream *out_data;
out_data = stream_open_mem(NULL , 0); out_data = imgtool::stream::open_mem(NULL , 0);
if (out_data == nullptr) { if (out_data == nullptr) {
return IMGTOOLERR_OUTOFMEMORY; return IMGTOOLERR_OUTOFMEMORY;
} }
@ -1546,7 +1546,7 @@ static imgtoolerr_t hp9845data_write_file(imgtool::partition *partition, const c
char line[ 256 ]; char line[ 256 ];
// Read input file one line at time // Read input file one line at time
if (stream_core_file(sourcef)->gets(line , sizeof(line)) == nullptr) { if (sourcef.core_file()->gets(line , sizeof(line)) == nullptr) {
// EOF // EOF
break; break;
} }
@ -1568,28 +1568,28 @@ static imgtoolerr_t hp9845data_write_file(imgtool::partition *partition, const c
continue; continue;
} }
if (!split_string_n_dump(line , out_data)) { if (!split_string_n_dump(line, *out_data)) {
return IMGTOOLERR_WRITEERROR; return IMGTOOLERR_WRITEERROR;
} }
} }
// Fill free space of last record with EOFs // Fill free space of last record with EOFs
unsigned free_len = len_to_eor(out_data); unsigned free_len = len_to_eor(*out_data);
UINT8 tmp[ 2 ]; UINT8 tmp[ 2 ];
place_integer_be(tmp , 0 , 2 , REC_TYPE_EOF); place_integer_be(tmp , 0 , 2 , REC_TYPE_EOF);
while (free_len) { while (free_len) {
if (stream_write(out_data , tmp , 2 ) != 2) { if (out_data->write(tmp , 2 ) != 2) {
return IMGTOOLERR_WRITEERROR; return IMGTOOLERR_WRITEERROR;
} }
free_len -= 2; free_len -= 2;
} }
stream_seek(out_data , 0 , SEEK_SET); out_data->seek(0 , SEEK_SET);
imgtoolerr_t res = hp9845_tape_write_file(partition , filename , fork , out_data , opts); imgtoolerr_t res = hp9845_tape_write_file(partition, filename, fork, *out_data, opts);
stream_close(out_data); delete out_data;
return res; return res;
} }

View File

@ -1542,7 +1542,7 @@ struct mfs_dirref
static imgtoolerr_t mfs_image_create(imgtool::image *image, imgtool_stream *stream, util::option_resolution *opts) static imgtoolerr_t mfs_image_create(imgtool::image *image, imgtool::stream &stream, util::option_resolution *opts)
{ {
imgtoolerr_t err; imgtoolerr_t err;
UINT8 buffer[512]; UINT8 buffer[512];
@ -1606,7 +1606,7 @@ static imgtoolerr_t mfs_image_create(imgtool::image *image, imgtool_stream *stre
Return imgtool error code Return imgtool error code
*/ */
static imgtoolerr_t mfs_image_open(imgtool::image *image, imgtool_stream *stream) static imgtoolerr_t mfs_image_open(imgtool::image *image, imgtool::stream &stream)
{ {
imgtoolerr_t err; imgtoolerr_t err;
struct mac_l2_imgref *l2_img; struct mac_l2_imgref *l2_img;
@ -3033,7 +3033,7 @@ static int hfs_catKey_compare(const void *p1, const void *p2)
Return imgtool error code Return imgtool error code
*/ */
static imgtoolerr_t hfs_image_open(imgtool::image *image, imgtool_stream *stream) static imgtoolerr_t hfs_image_open(imgtool::image *image, imgtool::stream &stream)
{ {
imgtoolerr_t err; imgtoolerr_t err;
struct mac_l2_imgref *l2_img; struct mac_l2_imgref *l2_img;
@ -5277,8 +5277,8 @@ static void mac_image_info(imgtool::image *img, char *string, size_t len);
static imgtoolerr_t mac_image_beginenum(imgtool::directory *enumeration, const char *path); static imgtoolerr_t mac_image_beginenum(imgtool::directory *enumeration, const char *path);
static imgtoolerr_t mac_image_nextenum(imgtool::directory *enumeration, imgtool_dirent *ent); static imgtoolerr_t mac_image_nextenum(imgtool::directory *enumeration, imgtool_dirent *ent);
static imgtoolerr_t mac_image_freespace(imgtool::partition *partition, UINT64 *size); static imgtoolerr_t mac_image_freespace(imgtool::partition *partition, UINT64 *size);
static imgtoolerr_t mac_image_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *destf); static imgtoolerr_t mac_image_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf);
static imgtoolerr_t mac_image_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *writeoptions); static imgtoolerr_t mac_image_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *writeoptions);
#ifdef UNUSED_FUNCTION #ifdef UNUSED_FUNCTION
/* /*
@ -5610,7 +5610,7 @@ static imgtoolerr_t mac_get_comment(struct mac_l2_imgref *image, mac_str255 file
/* /*
Extract a file from a disk image. Extract a file from a disk image.
*/ */
static imgtoolerr_t mac_image_readfile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool_stream *destf) static imgtoolerr_t mac_image_readfile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool::stream &destf)
{ {
imgtoolerr_t err; imgtoolerr_t err;
imgtool::image *img = &partition->image(); imgtool::image *img = &partition->image();
@ -5650,7 +5650,7 @@ static imgtoolerr_t mac_image_readfile(imgtool::partition *partition, const char
err = mac_file_read(&fileref, run_len, buf); err = mac_file_read(&fileref, run_len, buf);
if (err) if (err)
return err; return err;
if (stream_write(destf, buf, run_len) != run_len) if (destf.write(buf, run_len) != run_len)
return IMGTOOLERR_WRITEERROR; return IMGTOOLERR_WRITEERROR;
i += run_len; i += run_len;
} }
@ -5661,7 +5661,7 @@ static imgtoolerr_t mac_image_readfile(imgtool::partition *partition, const char
/* /*
Add a file to a disk image. Add a file to a disk image.
*/ */
static imgtoolerr_t mac_image_writefile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool_stream *sourcef, util::option_resolution *writeoptions) static imgtoolerr_t mac_image_writefile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool::stream &sourcef, util::option_resolution *writeoptions)
{ {
imgtool::image *img = &partition->image(); imgtool::image *img = &partition->image();
struct mac_l2_imgref *image = get_imgref(img); struct mac_l2_imgref *image = get_imgref(img);
@ -5694,7 +5694,7 @@ static imgtoolerr_t mac_image_writefile(imgtool::partition *partition, const cha
memset(&cat_info, 0, sizeof(cat_info)); memset(&cat_info, 0, sizeof(cat_info));
set_UINT32BE(&cat_info.flFinderInfo.type, 0x3F3F3F3F); set_UINT32BE(&cat_info.flFinderInfo.type, 0x3F3F3F3F);
set_UINT32BE(&cat_info.flFinderInfo.creator, 0x3F3F3F3F); set_UINT32BE(&cat_info.flFinderInfo.creator, 0x3F3F3F3F);
fork_len = stream_size(sourcef); fork_len = sourcef.size();
/*comment[0] = get_UINT16BE(header.comment_len);*/ /* comment length */ /*comment[0] = get_UINT16BE(header.comment_len);*/ /* comment length */
/* Next two fields are set to 0 with MFS volumes. IIRC, 0 normally /* Next two fields are set to 0 with MFS volumes. IIRC, 0 normally
means system script: I don't think MFS stores the file name script code means system script: I don't think MFS stores the file name script code
@ -5726,7 +5726,7 @@ static imgtoolerr_t mac_image_writefile(imgtool::partition *partition, const cha
run_len = fork_len - i; run_len = fork_len - i;
if (run_len > 512) if (run_len > 512)
run_len = 512; run_len = 512;
if (stream_read(sourcef, buf, run_len) != run_len) if (sourcef.read(buf, run_len) != run_len)
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
err = mac_file_write(&fileref, run_len, buf); err = mac_file_write(&fileref, run_len, buf);
if (err) if (err)
@ -6179,7 +6179,7 @@ static imgtoolerr_t mac_image_geticoninfo(imgtool::partition *partition, const c
imgtoolerr_t err; imgtoolerr_t err;
imgtool_attribute attr_values[3]; imgtool_attribute attr_values[3];
UINT32 type_code, creator_code, finder_flags; UINT32 type_code, creator_code, finder_flags;
imgtool_stream *stream = NULL; imgtool::stream *stream = NULL;
const void *resource_fork; const void *resource_fork;
UINT64 resource_fork_length; UINT64 resource_fork_length;
const void *bundle; const void *bundle;
@ -6205,7 +6205,7 @@ static imgtoolerr_t mac_image_geticoninfo(imgtool::partition *partition, const c
if (!(finder_flags & 0x2000) && (type_code != /* APPL */ 0x4150504C)) if (!(finder_flags & 0x2000) && (type_code != /* APPL */ 0x4150504C))
path = "Desktop\0"; path = "Desktop\0";
stream = stream_open_mem(NULL, 0); stream = imgtool::stream::open_mem(NULL, 0);
if (!stream) if (!stream)
{ {
err = IMGTOOLERR_SUCCESS; err = IMGTOOLERR_SUCCESS;
@ -6213,11 +6213,11 @@ static imgtoolerr_t mac_image_geticoninfo(imgtool::partition *partition, const c
} }
/* read in the resource fork */ /* read in the resource fork */
err = mac_image_readfile(partition, path, "RESOURCE_FORK", stream); err = mac_image_readfile(partition, path, "RESOURCE_FORK", *stream);
if (err) if (err)
goto done; goto done;
resource_fork = stream_getptr(stream); resource_fork = stream->getptr();
resource_fork_length = stream_size(stream); resource_fork_length = stream->size();
/* attempt to look up the bundle */ /* attempt to look up the bundle */
bundle = mac_walk_resources(resource_fork, resource_fork_length, /* BNDL */ 0x424E444C, bundle = mac_walk_resources(resource_fork, resource_fork_length, /* BNDL */ 0x424E444C,
@ -6305,7 +6305,7 @@ static imgtoolerr_t mac_image_geticoninfo(imgtool::partition *partition, const c
done: done:
if (stream) if (stream)
stream_close(stream); delete stream;
return err; return err;
} }

View File

@ -63,7 +63,7 @@ static UINT32 pad128(UINT32 length)
static imgtoolerr_t macbinary_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *destf) static imgtoolerr_t macbinary_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{ {
static const UINT32 attrs[] = static const UINT32 attrs[] =
{ {
@ -156,7 +156,7 @@ static imgtoolerr_t macbinary_readfile(imgtool::partition *partition, const char
place_integer_be(header, 123, 1, 0x81); place_integer_be(header, 123, 1, 0x81);
place_integer_be(header, 124, 2, ccitt_crc16(0, header, 124)); place_integer_be(header, 124, 2, ccitt_crc16(0, header, 124));
stream_write(destf, header, sizeof(header)); destf.write(header, sizeof(header));
if (data_fork) if (data_fork)
{ {
@ -164,7 +164,7 @@ static imgtoolerr_t macbinary_readfile(imgtool::partition *partition, const char
if (err) if (err)
return err; return err;
stream_fill(destf, 0, pad128(data_fork->size)); destf.fill(0, pad128(data_fork->size));
} }
if (resource_fork) if (resource_fork)
@ -173,7 +173,7 @@ static imgtoolerr_t macbinary_readfile(imgtool::partition *partition, const char
if (err) if (err)
return err; return err;
stream_fill(destf, 0, pad128(resource_fork->size)); destf.fill(0, pad128(resource_fork->size));
} }
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
@ -182,41 +182,41 @@ static imgtoolerr_t macbinary_readfile(imgtool::partition *partition, const char
static imgtoolerr_t write_fork(imgtool::partition *partition, const char *filename, const char *fork, static imgtoolerr_t write_fork(imgtool::partition *partition, const char *filename, const char *fork,
imgtool_stream *sourcef, UINT64 pos, UINT64 fork_len, util::option_resolution *opts) imgtool::stream &sourcef, UINT64 pos, UINT64 fork_len, util::option_resolution *opts)
{ {
imgtoolerr_t err = IMGTOOLERR_SUCCESS; imgtoolerr_t err = IMGTOOLERR_SUCCESS;
imgtool_stream *mem_stream = NULL; imgtool::stream *mem_stream = NULL;
size_t len; size_t len;
if (fork_len > 0) if (fork_len > 0)
{ {
mem_stream = stream_open_mem(NULL, 0); mem_stream = imgtool::stream::open_mem(NULL, 0);
if (!mem_stream) if (!mem_stream)
{ {
err = IMGTOOLERR_OUTOFMEMORY; err = IMGTOOLERR_OUTOFMEMORY;
goto done; goto done;
} }
stream_seek(sourcef, pos, SEEK_SET); sourcef.seek(pos, SEEK_SET);
len = stream_transfer(mem_stream, sourcef, fork_len); len = imgtool::stream::transfer(*mem_stream, sourcef, fork_len);
if (len < fork_len) if (len < fork_len)
stream_fill(mem_stream, 0, fork_len); mem_stream->fill(0, fork_len);
stream_seek(mem_stream, 0, SEEK_SET); mem_stream->seek(0, SEEK_SET);
err = partition->write_file(filename, fork, mem_stream, opts, NULL); err = partition->write_file(filename, fork, *mem_stream, opts, NULL);
if (err) if (err)
goto done; goto done;
} }
done: done:
if (mem_stream) if (mem_stream)
stream_close(mem_stream); delete mem_stream;
return err; return err;
} }
static imgtoolerr_t macbinary_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) static imgtoolerr_t macbinary_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{ {
static const UINT32 attrs[] = static const UINT32 attrs[] =
{ {
@ -254,7 +254,7 @@ static imgtoolerr_t macbinary_writefile(imgtool::partition *partition, const cha
/* read in the header */ /* read in the header */
memset(header, 0, sizeof(header)); memset(header, 0, sizeof(header));
stream_read(sourcef, header, sizeof(header)); sourcef.read(header, sizeof(header));
/* check magic and zero fill bytes */ /* check magic and zero fill bytes */
if (header[0] != 0x00) if (header[0] != 0x00)
@ -266,7 +266,7 @@ static imgtoolerr_t macbinary_writefile(imgtool::partition *partition, const cha
datafork_size = pick_integer_be(header, 83, 4); datafork_size = pick_integer_be(header, 83, 4);
resourcefork_size = pick_integer_be(header, 87, 4); resourcefork_size = pick_integer_be(header, 87, 4);
total_size = stream_size(sourcef); total_size = sourcef.size();
/* size of a MacBinary header is always 128 bytes */ /* size of a MacBinary header is always 128 bytes */
if (total_size - pad128(datafork_size) - pad128(resourcefork_size) != 128) if (total_size - pad128(datafork_size) - pad128(resourcefork_size) != 128)
@ -342,7 +342,7 @@ static imgtoolerr_t macbinary_writefile(imgtool::partition *partition, const cha
static imgtoolerr_t macbinary_checkstream(imgtool_stream *stream, imgtool_suggestion_viability_t *viability) static imgtoolerr_t macbinary_checkstream(imgtool::stream &stream, imgtool_suggestion_viability_t *viability)
{ {
imgtoolerr_t err; imgtoolerr_t err;

View File

@ -622,7 +622,7 @@ done:
static imgtoolerr_t os9_diskimage_open(imgtool::image *image, imgtool_stream *stream) static imgtoolerr_t os9_diskimage_open(imgtool::image *image, imgtool::stream &stream)
{ {
imgtoolerr_t err; imgtoolerr_t err;
floperr_t ferr; floperr_t ferr;
@ -710,7 +710,7 @@ static imgtoolerr_t os9_diskimage_open(imgtool::image *image, imgtool_stream *st
static imgtoolerr_t os9_diskimage_create(imgtool::image *img, imgtool_stream *stream, util::option_resolution *opts) static imgtoolerr_t os9_diskimage_create(imgtool::image *img, imgtool::stream &stream, util::option_resolution *opts)
{ {
imgtoolerr_t err; imgtoolerr_t err;
dynamic_buffer header; dynamic_buffer header;
@ -988,7 +988,7 @@ static imgtoolerr_t os9_diskimage_freespace(imgtool::partition *partition, UINT6
static imgtoolerr_t os9_diskimage_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *destf) static imgtoolerr_t os9_diskimage_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{ {
imgtoolerr_t err; imgtoolerr_t err;
imgtool::image *img = &partition->image(); imgtool::image *img = &partition->image();
@ -1017,7 +1017,7 @@ static imgtoolerr_t os9_diskimage_readfile(imgtool::partition *partition, const
buffer, used_size); buffer, used_size);
if (err) if (err)
return err; return err;
stream_write(destf, buffer, used_size); destf.write(buffer, used_size);
file_size -= used_size; file_size -= used_size;
} }
} }
@ -1026,7 +1026,7 @@ static imgtoolerr_t os9_diskimage_readfile(imgtool::partition *partition, const
static imgtoolerr_t os9_diskimage_writefile(imgtool::partition *partition, const char *path, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) static imgtoolerr_t os9_diskimage_writefile(imgtool::partition *partition, const char *path, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{ {
imgtoolerr_t err; imgtoolerr_t err;
imgtool::image *image = &partition->image(); imgtool::image *image = &partition->image();
@ -1047,7 +1047,7 @@ static imgtoolerr_t os9_diskimage_writefile(imgtool::partition *partition, const
if (err) if (err)
goto done; goto done;
sz = (UINT32) stream_size(sourcef); sz = (UINT32) sourcef.size();
err = os9_set_file_size(image, &file_info, sz); err = os9_set_file_size(image, &file_info, sz);
if (err) if (err)
@ -1057,7 +1057,7 @@ static imgtoolerr_t os9_diskimage_writefile(imgtool::partition *partition, const
{ {
write_size = (std::min<UINT64>)(sz, disk_info->sector_size); write_size = (std::min<UINT64>)(sz, disk_info->sector_size);
stream_read(sourcef, &buf[0], write_size); sourcef.read(&buf[0], write_size);
while(count == 0) while(count == 0)
{ {

View File

@ -17,7 +17,7 @@
#define FAT_SECLEN 512 #define FAT_SECLEN 512
static imgtoolerr_t fat_image_create(imgtool::image *image, imgtool_stream *stream, util::option_resolution *opts) static imgtoolerr_t fat_image_create(imgtool::image *image, imgtool::stream &stream, util::option_resolution *opts)
{ {
imgtoolerr_t err; imgtoolerr_t err;
UINT32 tracks, heads, sectors; UINT32 tracks, heads, sectors;

View File

@ -94,14 +94,14 @@ struct pc_chd_image_info
static pc_chd_image_info *pc_chd_get_image_info(imgtool::image *image) static pc_chd_image_info *pc_chd_get_image_info(imgtool::image &image)
{ {
return (pc_chd_image_info *) image->extra_bytes(); return (pc_chd_image_info *) image.extra_bytes();
} }
static void pc_chd_locate_block(imgtool::image *image, UINT64 block, UINT32 *cylinder, UINT32 *head, UINT32 *sector) static void pc_chd_locate_block(imgtool::image &image, UINT64 block, UINT32 *cylinder, UINT32 *head, UINT32 *sector)
{ {
pc_chd_image_info *info; pc_chd_image_info *info;
const hard_disk_info *hd_info; const hard_disk_info *hd_info;
@ -116,7 +116,7 @@ static void pc_chd_locate_block(imgtool::image *image, UINT64 block, UINT32 *cyl
static imgtoolerr_t pc_chd_partition_create(imgtool::image *image, int partition_index, UINT64 first_block, UINT64 block_count) static imgtoolerr_t pc_chd_partition_create(imgtool::image &image, int partition_index, UINT64 first_block, UINT64 block_count)
{ {
imgtoolerr_t err; imgtoolerr_t err;
UINT8 header_block[FAT_SECLEN]; UINT8 header_block[FAT_SECLEN];
@ -141,12 +141,12 @@ static imgtoolerr_t pc_chd_partition_create(imgtool::image *image, int partition
imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_CREATE_PARTITION); imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_CREATE_PARTITION);
/* first create the actual partition */ /* first create the actual partition */
err = fat_partition_create(image, first_block, block_count); err = fat_partition_create(&image, first_block, block_count);
if (err) if (err)
goto done; goto done;
/* read the first block of the partition, to determine the type of FAT */ /* read the first block of the partition, to determine the type of FAT */
err = image->read_block(first_block, partition_block); err = image.read_block(first_block, partition_block);
if (err) if (err)
goto done; goto done;
fat_type = &partition_block[54]; fat_type = &partition_block[54];
@ -162,7 +162,7 @@ static imgtoolerr_t pc_chd_partition_create(imgtool::image *image, int partition
partition_type = 0x0B; partition_type = 0x0B;
/* read the partition header */ /* read the partition header */
err = image->read_block(0, header_block); err = image.read_block(0, header_block);
if (err) if (err)
goto done; goto done;
@ -180,7 +180,7 @@ static imgtoolerr_t pc_chd_partition_create(imgtool::image *image, int partition
place_integer_le(partition_entry, 12, 4, block_count); place_integer_le(partition_entry, 12, 4, block_count);
/* write the partition header */ /* write the partition header */
err = image->write_block(0, header_block); err = image.write_block(0, header_block);
if (err) if (err)
goto done; goto done;
@ -190,7 +190,7 @@ done:
static imgtoolerr_t pc_chd_read_partition_header(imgtool::image *image) static imgtoolerr_t pc_chd_read_partition_header(imgtool::image &image)
{ {
imgtoolerr_t err; imgtoolerr_t err;
int i; int i;
@ -201,7 +201,7 @@ static imgtoolerr_t pc_chd_read_partition_header(imgtool::image *image)
info = pc_chd_get_image_info(image); info = pc_chd_get_image_info(image);
/* read the initial block */ /* read the initial block */
err = image->read_block(0, buffer); err = image.read_block(0, buffer);
if (err) if (err)
return err; return err;
@ -232,7 +232,7 @@ static imgtoolerr_t pc_chd_read_partition_header(imgtool::image *image)
static imgtoolerr_t pc_chd_image_create(imgtool::image *image, imgtool_stream *f, util::option_resolution *opts) static imgtoolerr_t pc_chd_image_create(imgtool::image *image, imgtool::stream &f, util::option_resolution *opts)
{ {
imgtoolerr_t err; imgtoolerr_t err;
UINT32 cylinders, heads, sectors; UINT32 cylinders, heads, sectors;
@ -243,7 +243,7 @@ static imgtoolerr_t pc_chd_image_create(imgtool::image *image, imgtool_stream *f
heads = opts->lookup_int('H'); heads = opts->lookup_int('H');
sectors = opts->lookup_int('S'); sectors = opts->lookup_int('S');
info = pc_chd_get_image_info(image); info = pc_chd_get_image_info(*image);
/* create the hard disk image */ /* create the hard disk image */
err = imghd_create(f, 0, cylinders, heads, sectors, FAT_SECLEN); err = imghd_create(f, 0, cylinders, heads, sectors, FAT_SECLEN);
@ -262,11 +262,11 @@ static imgtoolerr_t pc_chd_image_create(imgtool::image *image, imgtool_stream *f
if (err) if (err)
goto done; goto done;
err = pc_chd_partition_create(image, 0, 1, cylinders * heads * sectors - 1); err = pc_chd_partition_create(*image, 0, 1, cylinders * heads * sectors - 1);
if (err) if (err)
goto done; goto done;
err = pc_chd_read_partition_header(image); err = pc_chd_read_partition_header(*image);
if (err) if (err)
goto done; goto done;
@ -278,19 +278,19 @@ done:
static imgtoolerr_t pc_chd_image_open(imgtool::image *image, imgtool_stream *stream) static imgtoolerr_t pc_chd_image_open(imgtool::image *image, imgtool::stream &stream)
{ {
imgtoolerr_t err; imgtoolerr_t err;
pc_chd_image_info *info; pc_chd_image_info *info;
info = pc_chd_get_image_info(image); info = pc_chd_get_image_info(*image);
/* open the hard drive */ /* open the hard drive */
err = imghd_open(stream, &info->hard_disk); err = imghd_open(stream, &info->hard_disk);
if (err) if (err)
return err; return err;
err = pc_chd_read_partition_header(image); err = pc_chd_read_partition_header(*image);
if (err) if (err)
return err; return err;
@ -302,7 +302,7 @@ static imgtoolerr_t pc_chd_image_open(imgtool::image *image, imgtool_stream *str
static void pc_chd_image_close(imgtool::image *image) static void pc_chd_image_close(imgtool::image *image)
{ {
pc_chd_image_info *info; pc_chd_image_info *info;
info = pc_chd_get_image_info(image); info = pc_chd_get_image_info(*image);
imghd_close(&info->hard_disk); imghd_close(&info->hard_disk);
} }
@ -313,7 +313,7 @@ static imgtoolerr_t pc_chd_image_get_geometry(imgtool::image *image, UINT32 *tra
pc_chd_image_info *info; pc_chd_image_info *info;
const hard_disk_info *hd_info; const hard_disk_info *hd_info;
info = pc_chd_get_image_info(image); info = pc_chd_get_image_info(*image);
hd_info = imghd_get_header(&info->hard_disk); hd_info = imghd_get_header(&info->hard_disk);
*tracks = hd_info->cylinders; *tracks = hd_info->cylinders;
@ -324,12 +324,12 @@ static imgtoolerr_t pc_chd_image_get_geometry(imgtool::image *image, UINT32 *tra
static UINT32 pc_chd_calc_lbasector(pc_chd_image_info *info, UINT32 track, UINT32 head, UINT32 sector) static UINT32 pc_chd_calc_lbasector(pc_chd_image_info &info, UINT32 track, UINT32 head, UINT32 sector)
{ {
UINT32 lbasector; UINT32 lbasector;
const hard_disk_info *hd_info; const hard_disk_info *hd_info;
hd_info = imghd_get_header(&info->hard_disk); hd_info = imghd_get_header(&info.hard_disk);
lbasector = track; lbasector = track;
lbasector *= hd_info->heads; lbasector *= hd_info->heads;
lbasector += head; lbasector += head;
@ -342,7 +342,7 @@ static UINT32 pc_chd_calc_lbasector(pc_chd_image_info *info, UINT32 track, UINT3
static imgtoolerr_t pc_chd_image_readsector(imgtool::image *image, UINT32 track, UINT32 head, UINT32 sector, std::vector<UINT8> &buffer) static imgtoolerr_t pc_chd_image_readsector(imgtool::image *image, UINT32 track, UINT32 head, UINT32 sector, std::vector<UINT8> &buffer)
{ {
pc_chd_image_info *info = pc_chd_get_image_info(image); pc_chd_image_info *info = pc_chd_get_image_info(*image);
// get the sector size and resize the buffer // get the sector size and resize the buffer
UINT32 sector_size = imghd_get_header(&info->hard_disk)->sectorbytes; UINT32 sector_size = imghd_get_header(&info->hard_disk)->sectorbytes;
@ -351,7 +351,7 @@ static imgtoolerr_t pc_chd_image_readsector(imgtool::image *image, UINT32 track,
// read the data // read the data
return imghd_read(&info->hard_disk, return imghd_read(&info->hard_disk,
pc_chd_calc_lbasector(info, track, head, sector), pc_chd_calc_lbasector(*info, track, head, sector),
&buffer[0]); &buffer[0]);
} }
@ -360,9 +360,9 @@ static imgtoolerr_t pc_chd_image_readsector(imgtool::image *image, UINT32 track,
static imgtoolerr_t pc_chd_image_writesector(imgtool::image *image, UINT32 track, UINT32 head, UINT32 sector, const void *buffer, size_t len, int ddam) static imgtoolerr_t pc_chd_image_writesector(imgtool::image *image, UINT32 track, UINT32 head, UINT32 sector, const void *buffer, size_t len, int ddam)
{ {
pc_chd_image_info *info; pc_chd_image_info *info;
info = pc_chd_get_image_info(image); info = pc_chd_get_image_info(*image);
return imghd_write(&info->hard_disk, return imghd_write(&info->hard_disk,
pc_chd_calc_lbasector(info, track, head, sector), pc_chd_calc_lbasector(*info, track, head, sector),
buffer); buffer);
} }
@ -371,7 +371,7 @@ static imgtoolerr_t pc_chd_image_writesector(imgtool::image *image, UINT32 track
static imgtoolerr_t pc_chd_image_readblock(imgtool::image *image, void *buffer, UINT64 block) static imgtoolerr_t pc_chd_image_readblock(imgtool::image *image, void *buffer, UINT64 block)
{ {
pc_chd_image_info *info; pc_chd_image_info *info;
info = pc_chd_get_image_info(image); info = pc_chd_get_image_info(*image);
return imghd_read(&info->hard_disk, block, buffer); return imghd_read(&info->hard_disk, block, buffer);
} }
@ -380,7 +380,7 @@ static imgtoolerr_t pc_chd_image_readblock(imgtool::image *image, void *buffer,
static imgtoolerr_t pc_chd_image_writeblock(imgtool::image *image, const void *buffer, UINT64 block) static imgtoolerr_t pc_chd_image_writeblock(imgtool::image *image, const void *buffer, UINT64 block)
{ {
pc_chd_image_info *info; pc_chd_image_info *info;
info = pc_chd_get_image_info(image); info = pc_chd_get_image_info(*image);
return imghd_write(&info->hard_disk, block, buffer); return imghd_write(&info->hard_disk, block, buffer);
} }
@ -391,7 +391,7 @@ static imgtoolerr_t pc_chd_list_partitions(imgtool::image *image, imgtool_partit
pc_chd_image_info *info; pc_chd_image_info *info;
size_t i; size_t i;
info = pc_chd_get_image_info(image); info = pc_chd_get_image_info(*image);
for (i = 0; i < std::min(size_t(4), len); i++) for (i = 0; i < std::min(size_t(4), len); i++)
{ {

View File

@ -502,7 +502,7 @@ static imgtoolerr_t prodos_diskimage_open(imgtool::image *image)
static imgtoolerr_t prodos_diskimage_open_525(imgtool::image *image, imgtool_stream *stream) static imgtoolerr_t prodos_diskimage_open_525(imgtool::image *image, imgtool::stream &stream)
{ {
prodos_setprocs_525(image); prodos_setprocs_525(image);
return prodos_diskimage_open(image); return prodos_diskimage_open(image);
@ -510,7 +510,7 @@ static imgtoolerr_t prodos_diskimage_open_525(imgtool::image *image, imgtool_str
static imgtoolerr_t prodos_diskimage_open_35(imgtool::image *image, imgtool_stream *stream) static imgtoolerr_t prodos_diskimage_open_35(imgtool::image *image, imgtool::stream &stream)
{ {
prodos_setprocs_35(image); prodos_setprocs_35(image);
return prodos_diskimage_open(image); return prodos_diskimage_open(image);
@ -702,7 +702,7 @@ static imgtoolerr_t prodos_diskimage_create(imgtool::image *image, util::option_
static imgtoolerr_t prodos_diskimage_create_525(imgtool::image *image, imgtool_stream *stream, util::option_resolution *opts) static imgtoolerr_t prodos_diskimage_create_525(imgtool::image *image, imgtool::stream &stream, util::option_resolution *opts)
{ {
prodos_setprocs_525(image); prodos_setprocs_525(image);
return prodos_diskimage_create(image, opts); return prodos_diskimage_create(image, opts);
@ -710,7 +710,7 @@ static imgtoolerr_t prodos_diskimage_create_525(imgtool::image *image, imgtool_s
static imgtoolerr_t prodos_diskimage_create_35(imgtool::image *image, imgtool_stream *stream, util::option_resolution *opts) static imgtoolerr_t prodos_diskimage_create_35(imgtool::image *image, imgtool::stream &stream, util::option_resolution *opts)
{ {
prodos_setprocs_35(image); prodos_setprocs_35(image);
return prodos_diskimage_create(image, opts); return prodos_diskimage_create(image, opts);
@ -1571,7 +1571,7 @@ static imgtoolerr_t prodos_diskimage_nextenum(imgtool::directory *enumeration, i
static imgtoolerr_t prodos_read_file_tree(imgtool::image *image, UINT32 *filesize, static imgtoolerr_t prodos_read_file_tree(imgtool::image *image, UINT32 *filesize,
UINT32 block, int nest_level, imgtool_stream *destf) UINT32 block, int nest_level, imgtool::stream &destf)
{ {
imgtoolerr_t err; imgtoolerr_t err;
prodos_diskinfo *di; prodos_diskinfo *di;
@ -1612,7 +1612,7 @@ static imgtoolerr_t prodos_read_file_tree(imgtool::image *image, UINT32 *filesiz
{ {
/* this is a leaf block */ /* this is a leaf block */
bytes_to_write = std::min(size_t(*filesize), sizeof(buffer)); bytes_to_write = std::min(size_t(*filesize), sizeof(buffer));
stream_write(destf, buffer, bytes_to_write); destf.write(buffer, bytes_to_write);
*filesize -= bytes_to_write; *filesize -= bytes_to_write;
} }
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
@ -1621,7 +1621,7 @@ static imgtoolerr_t prodos_read_file_tree(imgtool::image *image, UINT32 *filesiz
static imgtoolerr_t prodos_write_file_tree(imgtool::image *image, UINT32 *filesize, static imgtoolerr_t prodos_write_file_tree(imgtool::image *image, UINT32 *filesize,
UINT32 block, int nest_level, imgtool_stream *sourcef) UINT32 block, int nest_level, imgtool::stream &sourcef)
{ {
imgtoolerr_t err; imgtoolerr_t err;
prodos_diskinfo *di; prodos_diskinfo *di;
@ -1663,7 +1663,7 @@ static imgtoolerr_t prodos_write_file_tree(imgtool::image *image, UINT32 *filesi
{ {
/* this is a leaf block */ /* this is a leaf block */
bytes_to_read = std::min(size_t(*filesize), sizeof(buffer)); bytes_to_read = std::min(size_t(*filesize), sizeof(buffer));
stream_read(sourcef, buffer, bytes_to_read); sourcef.read(buffer, bytes_to_read);
*filesize -= bytes_to_read; *filesize -= bytes_to_read;
err = prodos_save_block(image, block, buffer); err = prodos_save_block(image, block, buffer);
@ -1704,7 +1704,7 @@ done:
static imgtoolerr_t prodos_diskimage_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *destf) static imgtoolerr_t prodos_diskimage_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{ {
imgtoolerr_t err; imgtoolerr_t err;
imgtool::image *image = &partition->image(); imgtool::image *image = &partition->image();
@ -1737,14 +1737,14 @@ static imgtoolerr_t prodos_diskimage_readfile(imgtool::partition *partition, con
/* have we not actually received the correct amount of bytes? if not, fill in the rest */ /* have we not actually received the correct amount of bytes? if not, fill in the rest */
if (ent.filesize[fork_num] > 0) if (ent.filesize[fork_num] > 0)
stream_fill(destf, 0, ent.filesize[fork_num]); destf.fill(0, ent.filesize[fork_num]);
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
static imgtoolerr_t prodos_diskimage_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) static imgtoolerr_t prodos_diskimage_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{ {
imgtoolerr_t err; imgtoolerr_t err;
imgtool::image *image = &partition->image(); imgtool::image *image = &partition->image();
@ -1753,7 +1753,7 @@ static imgtoolerr_t prodos_diskimage_writefile(imgtool::partition *partition, co
UINT64 file_size; UINT64 file_size;
mac_fork_t fork_num; mac_fork_t fork_num;
file_size = stream_size(sourcef); file_size = sourcef.size();
err = prodos_lookup_path(image, filename, CREATE_FILE, &direnum, &ent); err = prodos_lookup_path(image, filename, CREATE_FILE, &direnum, &ent);
if (err) if (err)

View File

@ -38,7 +38,7 @@ struct psion_file
struct psion_pack struct psion_pack
{ {
imgtool_stream *stream; imgtool::stream *stream;
UINT16 eop; UINT16 eop;
struct psion_file pack_index[MAXFILES]; struct psion_file pack_index[MAXFILES];
@ -59,12 +59,12 @@ UINT16 head_checksum(UINT8* data)
return checksum; return checksum;
} }
UINT16 get_long_rec_size(imgtool_stream *stream) UINT16 get_long_rec_size(imgtool::stream &stream)
{ {
UINT8 size_h, size_l; UINT8 size_h, size_l;
stream_read(stream, &size_h, 1); stream.read(&size_h, 1);
stream_read(stream, &size_l, 1); stream.read(&size_l, 1);
return (size_h<<8) | size_l; return (size_h<<8) | size_l;
} }
@ -78,88 +78,88 @@ UINT32 update_pack_index(psion_pack *pack)
memset(pack->pack_index, 0, sizeof(psion_file) * MAXFILES); memset(pack->pack_index, 0, sizeof(psion_file) * MAXFILES);
// start at the first record // start at the first record
stream_seek(pack->stream, 0x10, SEEK_SET); pack->stream->seek(0x10, SEEK_SET);
do do
{ {
stream_read(pack->stream, &data, 1); pack->stream->read(&data, 1);
if(data == 0xff) if(data == 0xff)
{ {
pack->eop = stream_tell(pack->stream) - 1; pack->eop = pack->stream->tell() - 1;
return TRUE; return TRUE;
} }
else if (data == 0x02) else if (data == 0x02)
{ {
// long record without name are ignored // long record without name are ignored
stream_read(pack->stream, &data, 1); pack->stream->read(&data, 1);
size = get_long_rec_size(pack->stream); size = get_long_rec_size(*pack->stream);
stream_seek(pack->stream, size, SEEK_CUR); pack->stream->seek(size, SEEK_CUR);
} }
else else
{ {
stream_read(pack->stream, &type, 1); pack->stream->read(&type, 1);
// deleted record are not listed // deleted record are not listed
if (type < 0x90 && (type & 0x80)) if (type < 0x90 && (type & 0x80))
{ {
pack->pack_index[index].type = type; pack->pack_index[index].type = type;
stream_read(pack->stream, &pack->pack_index[index].filename, 8); pack->stream->read(&pack->pack_index[index].filename, 8);
stream_read(pack->stream, &pack->pack_index[index].id, 1); pack->stream->read(&pack->pack_index[index].id, 1);
pack->pack_index[index].name_rec = stream_tell(pack->stream) - 11; pack->pack_index[index].name_rec = pack->stream->tell() - 11;
//check for data record //check for data record
stream_read(pack->stream, &data, 1); pack->stream->read(&data, 1);
if (data == 0x02) if (data == 0x02)
pack->pack_index[index].data_rec = stream_tell(pack->stream) - 1; pack->pack_index[index].data_rec = pack->stream->tell() - 1;
stream_seek(pack->stream, -1, SEEK_CUR); pack->stream->seek(-1, SEEK_CUR);
index++; index++;
} }
else else
stream_seek(pack->stream, data, SEEK_CUR); pack->stream->seek(data, SEEK_CUR);
} }
} while (stream_size(pack->stream) > stream_tell(pack->stream)); } while (pack->stream->size() > pack->stream->tell());
// corrupted image // corrupted image
return FALSE; return FALSE;
} }
int seek_next_record(imgtool_stream *stream, UINT8 id) int seek_next_record(imgtool::stream &stream, UINT8 id)
{ {
UINT8 data, rec_id; UINT8 data, rec_id;
UINT16 size; UINT16 size;
do do
{ {
stream_read(stream, &data, 1); stream.read(&data, 1);
if(data == 0xff) if(data == 0xff)
break; break;
if (data == 2) if (data == 2)
{ {
stream_read(stream, &rec_id, 1); stream.read(&rec_id, 1);
size = get_long_rec_size(stream); size = get_long_rec_size(stream);
} }
else else
{ {
stream_read(stream, &rec_id, 1); stream.read(&rec_id, 1);
if (id == rec_id) if (id == rec_id)
{ {
stream_seek(stream, -2, SEEK_CUR); stream.seek(-2, SEEK_CUR);
return TRUE; return TRUE;
} }
size = data; size = data;
} }
// next record // next record
stream_seek(stream, size, SEEK_CUR); stream.seek(size, SEEK_CUR);
} while (stream_size(stream) > stream_tell(stream)); } while (stream.size() > stream.tell());
return FALSE; return FALSE;
} }
@ -194,7 +194,7 @@ UINT8 get_free_file_id(psion_pack *pack)
return 0xff; return 0xff;
} }
void put_name_record(imgtool_stream *stream, const char* filename, UINT8 record_type, UINT8 record_id) static void put_name_record(imgtool::stream &stream, const char* filename, UINT8 record_type, UINT8 record_id)
{ {
char data[0x10]; char data[0x10];
int i = 0; int i = 0;
@ -211,35 +211,35 @@ void put_name_record(imgtool_stream *stream, const char* filename, UINT8 record_
data[i++] = record_id; data[i++] = record_id;
stream_write(stream, data, i); stream.write(data, i);
} }
void update_opk_head(imgtool_stream *stream) static void update_opk_head(imgtool::stream &stream)
{ {
UINT16 size = stream_size(stream) - 6; UINT16 size = stream.size() - 6;
stream_seek(stream, 4, SEEK_SET); stream.seek(4, SEEK_SET);
stream_putc(stream, (size>>8) & 0xff); stream.putc((size>>8) & 0xff);
stream_putc(stream, size & 0xff); stream.putc(size & 0xff);
} }
char *stream_getline(imgtool_stream *source, UINT16 max_len) char *stream_getline(imgtool::stream &source, UINT16 max_len)
{ {
UINT16 pos = 0; UINT16 pos = 0;
char data; char data;
char *line = (char*)malloc(max_len); char *line = (char*)malloc(max_len);
memset(line, 0, max_len); memset(line, 0, max_len);
while (pos < max_len && stream_size(source) > stream_tell(source)) while (pos < max_len && source.size() > source.tell())
{ {
stream_read(source, &data, 1); source.read(&data, 1);
switch(data) switch(data)
{ {
case '\r': case '\r':
stream_read(source, &data, 1); source.read(&data, 1);
if (data != '\n') if (data != '\n')
stream_seek(source, -1, SEEK_CUR); source.seek(-1, SEEK_CUR);
case '\n': case '\n':
return line; return line;
default: default:
@ -255,21 +255,21 @@ char *stream_getline(imgtool_stream *source, UINT16 max_len)
return NULL; return NULL;
} }
UINT16 put_odb(imgtool_stream *instream, imgtool_stream *outstream, UINT8 file_id) UINT16 put_odb(imgtool::stream &instream, imgtool::stream &outstream, UINT8 file_id)
{ {
char *line; char *line;
UINT16 out_size = 0; UINT16 out_size = 0;
// reset stream // reset stream
stream_seek(instream, 0, SEEK_SET); instream.seek(0, SEEK_SET);
while ((line = stream_getline(instream, 256))) while ((line = stream_getline(instream, 256)))
{ {
UINT16 len = strlen(line); UINT16 len = strlen(line);
stream_putc(outstream, (UINT8)len); outstream.putc((UINT8)len);
stream_putc(outstream, file_id); outstream.putc(file_id);
stream_write(outstream, line, len); outstream.write(line, len);
out_size += (len + 1); out_size += (len + 1);
@ -277,37 +277,37 @@ UINT16 put_odb(imgtool_stream *instream, imgtool_stream *outstream, UINT8 file_i
} }
// end of pack // end of pack
stream_fill(outstream, 0xff, 2); outstream.fill(0xff, 2);
return out_size + 4; return out_size + 4;
} }
UINT16 put_ob3(imgtool_stream *instream, imgtool_stream *outstream) UINT16 put_ob3(imgtool::stream &instream, imgtool::stream &outstream)
{ {
UINT16 size = stream_size(instream) - 6; UINT16 size = instream.size() - 6;
dynamic_buffer buffer(size); dynamic_buffer buffer(size);
stream_seek(instream, 6, SEEK_SET); instream.seek(6, SEEK_SET);
stream_read(instream, &buffer[0], size); instream.read(&buffer[0], size);
stream_write(outstream, &buffer[0], size); outstream.write(&buffer[0], size);
// end of pack // end of pack
stream_fill(outstream, 0xff, 2); outstream.fill(0xff, 2);
return size; return size;
} }
UINT16 put_opl(imgtool_stream *instream, imgtool_stream *outstream) UINT16 put_opl(imgtool::stream &instream, imgtool::stream &outstream)
{ {
UINT16 out_size = 0; UINT16 out_size = 0;
UINT32 rec_start = stream_tell(outstream); UINT32 rec_start = outstream.tell();
char *line; char *line;
// reset stream // reset stream
stream_seek(instream, 0, SEEK_SET); instream.seek(0, SEEK_SET);
stream_fill(outstream, 0x00, 4); outstream.fill(0x00, 4);
// replace all eol with 0x00 // replace all eol with 0x00
while ((line = stream_getline(instream, 256))) while ((line = stream_getline(instream, 256)))
@ -316,24 +316,24 @@ UINT16 put_opl(imgtool_stream *instream, imgtool_stream *outstream)
for (int i=0; i<strlen(line); i++) for (int i=0; i<strlen(line); i++)
if (line[i] == '\t') line[i] = ' '; if (line[i] == '\t') line[i] = ' ';
stream_write(outstream, line, strlen(line)); outstream.write(line, strlen(line));
stream_putc(outstream, 0x00); outstream.putc(0x00);
out_size += strlen(line) + 1; out_size += strlen(line) + 1;
free(line); free(line);
} }
// end of pack // end of pack
stream_fill(outstream, 0xff, 2); outstream.fill(0xff, 2);
// update the size in the head // update the size in the head
stream_seek(outstream, rec_start + 2, SEEK_SET); outstream.seek(rec_start + 2, SEEK_SET);
stream_putc(outstream, (out_size>>8) & 0xff); outstream.putc((out_size>>8) & 0xff);
stream_putc(outstream, out_size & 0xff); outstream.putc(out_size & 0xff);
return out_size + 4; return out_size + 4;
} }
UINT16 get_odb(imgtool_stream *instream, imgtool_stream *outstream, UINT8 type, UINT8 file_id) UINT16 get_odb(imgtool::stream &instream, imgtool::stream &outstream, UINT8 type, UINT8 file_id)
{ {
UINT8 data, *buffer; UINT8 data, *buffer;
UINT16 out_size = 0; UINT16 out_size = 0;
@ -341,13 +341,13 @@ UINT16 get_odb(imgtool_stream *instream, imgtool_stream *outstream, UINT8 type,
if (file_id >= 0x90) if (file_id >= 0x90)
while (seek_next_record(instream, file_id)) while (seek_next_record(instream, file_id))
{ {
stream_read(instream, &data, 1); instream.read(&data, 1);
stream_seek(instream, 1, SEEK_CUR); instream.seek(1, SEEK_CUR);
buffer = (UINT8*)malloc(data); buffer = (UINT8*)malloc(data);
stream_read(instream, buffer, data); instream.read(buffer, data);
stream_write(outstream, buffer, data); outstream.write(buffer, data);
stream_putc(outstream, '\r'); outstream.putc('\r');
stream_putc(outstream, '\n'); outstream.putc('\n');
free (buffer); free (buffer);
out_size += data; out_size += data;
} }
@ -355,47 +355,47 @@ UINT16 get_odb(imgtool_stream *instream, imgtool_stream *outstream, UINT8 type,
return out_size; return out_size;
} }
UINT16 get_ob3(imgtool_stream *instream, imgtool_stream *outstream, UINT8 type, UINT8 file_id) UINT16 get_ob3(imgtool::stream &instream, imgtool::stream &outstream, UINT8 type, UINT8 file_id)
{ {
UINT8 data, *buffer = NULL; UINT8 data, *buffer = NULL;
UINT16 size = 0; UINT16 size = 0;
static const char ob3_magic[3] = {'O', 'R', 'G'}; static const char ob3_magic[3] = {'O', 'R', 'G'};
stream_read(instream, &data, 1); instream.read(&data, 1);
if (data == 0x02) if (data == 0x02)
{ {
stream_seek(instream, 1, SEEK_CUR); instream.seek(1, SEEK_CUR);
size = get_long_rec_size(instream); size = get_long_rec_size(instream);
buffer = (UINT8*)malloc(size); buffer = (UINT8*)malloc(size);
stream_read(instream, buffer, size); instream.read(buffer, size);
} }
stream_write(outstream, ob3_magic, 3); outstream.write(ob3_magic, 3);
stream_putc(outstream, (size>>8) & 0xff); outstream.putc((size>>8) & 0xff);
stream_putc(outstream, size & 0xff); outstream.putc(size & 0xff);
stream_putc(outstream, type | 0x80); outstream.putc(type | 0x80);
if (buffer) if (buffer)
{ {
stream_write(outstream, buffer, size); outstream.write(buffer, size);
free (buffer); free (buffer);
} }
return size; return size;
} }
static imgtoolerr_t datapack_open( imgtool::image *image, imgtool_stream *stream) static imgtoolerr_t datapack_open(imgtool::image *image, imgtool::stream &stream)
{ {
psion_pack *pack = (psion_pack*)image->extra_bytes(); psion_pack *pack = (psion_pack*)image->extra_bytes();
char opk_magic[4]; char opk_magic[4];
stream_read(stream, opk_magic, 4); stream.read(opk_magic, 4);
if(strcmp(opk_magic, "OPK\0")) if(strcmp(opk_magic, "OPK\0"))
return IMGTOOLERR_UNEXPECTED; return IMGTOOLERR_UNEXPECTED;
pack->stream = stream; pack->stream = &stream;
if (update_pack_index(pack)) if (update_pack_index(pack))
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
@ -403,7 +403,7 @@ static imgtoolerr_t datapack_open( imgtool::image *image, imgtool_stream *stream
return IMGTOOLERR_CORRUPTIMAGE; return IMGTOOLERR_CORRUPTIMAGE;
} }
static imgtoolerr_t datapack_create( imgtool::image *image, imgtool_stream *stream, util::option_resolution *opts) static imgtoolerr_t datapack_create(imgtool::image *image, imgtool::stream &stream, util::option_resolution *opts)
{ {
psion_pack *pack = (psion_pack*)image->extra_bytes(); psion_pack *pack = (psion_pack*)image->extra_bytes();
static const UINT8 opk_magic[4] = {'O', 'P', 'K', 0x00}; static const UINT8 opk_magic[4] = {'O', 'P', 'K', 0x00};
@ -419,20 +419,20 @@ static imgtoolerr_t datapack_create( imgtool::image *image, imgtool_stream *stre
checksum = head_checksum(pack_head); checksum = head_checksum(pack_head);
stream_write(stream, opk_magic, 4); stream.write(opk_magic, 4);
stream_fill(stream, 0x00, 2); stream.fill(0x00, 2);
stream_write(stream, pack_head, 8); stream.write(pack_head, 8);
stream_putc(stream, (checksum>>8) & 0xff); stream.putc((checksum>>8) & 0xff);
stream_putc(stream, checksum & 0xff); stream.putc(checksum & 0xff);
put_name_record(stream, "MAIN", 0x81, 0x90); put_name_record(stream, "MAIN", 0x81, 0x90);
stream_fill(stream, 0xff, 2); stream.fill(0xff, 2);
update_opk_head(stream); update_opk_head(stream);
pack->stream = stream; pack->stream = &stream;
if (update_pack_index(pack)) if (update_pack_index(pack))
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
@ -444,7 +444,7 @@ static void datapack_close( imgtool::image *image)
{ {
psion_pack *pack = (psion_pack*)image->extra_bytes(); psion_pack *pack = (psion_pack*)image->extra_bytes();
stream_close( pack->stream ); delete pack->stream;
} }
static imgtoolerr_t datapack_begin_enum(imgtool::directory *enumeration, const char *path) static imgtoolerr_t datapack_begin_enum(imgtool::directory *enumeration, const char *path)
@ -472,18 +472,18 @@ static imgtoolerr_t datapack_next_enum(imgtool::directory *enumeration, imgtool_
if (pack->pack_index[iter->index].data_rec) if (pack->pack_index[iter->index].data_rec)
{ {
stream_seek(pack->stream, pack->pack_index[iter->index].data_rec + 2, SEEK_SET); pack->stream->seek(pack->pack_index[iter->index].data_rec + 2, SEEK_SET);
ent->filesize = get_long_rec_size(pack->stream); ent->filesize = get_long_rec_size(*pack->stream);
} }
// seek all file's records // seek all file's records
if (pack->pack_index[iter->index].id >= 0x90) if (pack->pack_index[iter->index].id >= 0x90)
{ {
stream_seek(pack->stream, 0x10, SEEK_SET); pack->stream->seek(0x10, SEEK_SET);
while (seek_next_record(pack->stream, pack->pack_index[iter->index].id)) while (seek_next_record(*pack->stream, pack->pack_index[iter->index].id))
{ {
stream_read(pack->stream, &data, 1); pack->stream->read(&data, 1);
stream_seek(pack->stream, data + 1, SEEK_CUR); pack->stream->seek(data + 1, SEEK_CUR);
ent->filesize +=data; ent->filesize +=data;
} }
} }
@ -502,8 +502,8 @@ static imgtoolerr_t datapack_free_space( imgtool::partition *partition, UINT64 *
psion_pack *pack = (psion_pack*)image->extra_bytes(); psion_pack *pack = (psion_pack*)image->extra_bytes();
UINT32 pack_size = 0; UINT32 pack_size = 0;
stream_seek(pack->stream, 0x07, SEEK_SET); pack->stream->seek(0x07, SEEK_SET);
stream_read(pack->stream, &pack_size, 1); pack->stream->read(&pack_size, 1);
if (size) if (size)
*size = (pack_size * 0x2000) - pack->eop; *size = (pack_size * 0x2000) - pack->eop;
@ -511,7 +511,7 @@ static imgtoolerr_t datapack_free_space( imgtool::partition *partition, UINT64 *
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
static imgtoolerr_t datapack_read_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *destf) static imgtoolerr_t datapack_read_file(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{ {
imgtool::image *image = &partition->image(); imgtool::image *image = &partition->image();
psion_pack *pack = (psion_pack*)image->extra_bytes(); psion_pack *pack = (psion_pack*)image->extra_bytes();
@ -522,14 +522,14 @@ static imgtoolerr_t datapack_read_file(imgtool::partition *partition, const char
if ((pack->pack_index[index].type & 0x7f) == 0x01) if ((pack->pack_index[index].type & 0x7f) == 0x01)
{ {
// ODB files // ODB files
stream_seek(pack->stream, 0x10, SEEK_SET); pack->stream->seek(0x10, SEEK_SET);
get_odb(pack->stream, destf, pack->pack_index[index].type, pack->pack_index[index].id); get_odb(*pack->stream, destf, pack->pack_index[index].type, pack->pack_index[index].id);
} }
else if ((pack->pack_index[index].type & 0x7f) == 0x03) else if ((pack->pack_index[index].type & 0x7f) == 0x03)
{ {
// OB3/OPL files // OB3/OPL files
stream_seek(pack->stream, pack->pack_index[index].data_rec, SEEK_SET); pack->stream->seek(pack->pack_index[index].data_rec, SEEK_SET);
get_ob3(pack->stream, destf, pack->pack_index[index].type, pack->pack_index[index].id); get_ob3(*pack->stream, destf, pack->pack_index[index].type, pack->pack_index[index].id);
} }
else else
{ {
@ -543,7 +543,7 @@ static imgtoolerr_t datapack_read_file(imgtool::partition *partition, const char
return IMGTOOLERR_FILENOTFOUND; return IMGTOOLERR_FILENOTFOUND;
} }
static imgtoolerr_t datapack_write_file( imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) static imgtoolerr_t datapack_write_file( imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{ {
imgtool::image *image = &partition->image(); imgtool::image *image = &partition->image();
psion_pack *pack = (psion_pack*)image->extra_bytes(); psion_pack *pack = (psion_pack*)image->extra_bytes();
@ -565,8 +565,8 @@ static imgtoolerr_t datapack_write_file( imgtool::partition *partition, const ch
return IMGTOOLERR_NOSPACE; return IMGTOOLERR_NOSPACE;
} }
stream_read(sourcef, head, 3); sourcef.read(head, 3);
stream_seek(pack->stream, pack->eop, SEEK_SET); pack->stream->seek(pack->eop, SEEK_SET);
if (type == 0) if (type == 0)
type = (!strncmp((char*)head, "ORG", 3)) ? 1 : 2; type = (!strncmp((char*)head, "ORG", 3)) ? 1 : 2;
@ -574,30 +574,30 @@ static imgtoolerr_t datapack_write_file( imgtool::partition *partition, const ch
switch (type) switch (type)
{ {
case 1: //OB3 file case 1: //OB3 file
put_name_record(pack->stream, filename, 0x83, file_id); put_name_record(*pack->stream, filename, 0x83, file_id);
stream_write(pack->stream, data_head, 4); pack->stream->write(data_head, 4);
size = put_ob3(sourcef, pack->stream); size = put_ob3(sourcef, *pack->stream);
break; break;
case 2: //OPL file case 2: //OPL file
put_name_record(pack->stream, filename, 0x83, file_id); put_name_record(*pack->stream, filename, 0x83, file_id);
stream_write(pack->stream, data_head, 4); pack->stream->write(data_head, 4);
size = put_opl(sourcef, pack->stream); size = put_opl(sourcef, *pack->stream);
break; break;
case 3: //ODB file case 3: //ODB file
put_name_record(pack->stream, filename, 0x81, file_id); put_name_record(*pack->stream, filename, 0x81, file_id);
size = put_odb(sourcef, pack->stream, file_id); size = put_odb(sourcef, *pack->stream, file_id);
break; break;
} }
if (type != 3) if (type != 3)
{ {
// update the OB3/OPL long record size // update the OB3/OPL long record size
stream_seek(pack->stream, pack->eop + 13, SEEK_SET); pack->stream->seek(pack->eop + 13, SEEK_SET);
stream_putc(pack->stream, (size>>8) & 0xff); pack->stream->putc((size>>8) & 0xff);
stream_putc(pack->stream, size & 0xff); pack->stream->putc(size & 0xff);
} }
update_opk_head(pack->stream); update_opk_head(*pack->stream);
if (update_pack_index(pack)) if (update_pack_index(pack))
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
@ -614,8 +614,8 @@ static imgtoolerr_t datapack_delete_file( imgtool::partition *partition, const c
if (index >= 0) if (index >= 0)
{ {
// clear the bit 7 of the file type to mark the file as deleted // clear the bit 7 of the file type to mark the file as deleted
stream_seek(pack->stream, pack->pack_index[index].name_rec + 1, SEEK_SET); pack->stream->seek(pack->pack_index[index].name_rec + 1, SEEK_SET);
stream_putc(pack->stream, pack->pack_index[index].type & 0x7f); pack->stream->putc(pack->pack_index[index].type & 0x7f);
if (update_pack_index(pack)) if (update_pack_index(pack))
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;

View File

@ -149,7 +149,7 @@ static floperr_t put_granule_map(imgtool::image *img, const UINT8 *granule_map,
static imgtoolerr_t transfer_granule(imgtool::image *img, UINT8 granule, int length, imgtool_stream *f, imgtoolerr_t (*proc)(imgtool::image *, int, int, int, int, size_t, imgtool_stream *)) static imgtoolerr_t transfer_granule(imgtool::image *img, UINT8 granule, int length, imgtool::stream &f, imgtoolerr_t (*proc)(imgtool::image *, int, int, int, int, size_t, imgtool::stream &))
{ {
imgtoolerr_t err = IMGTOOLERR_SUCCESS; imgtoolerr_t err = IMGTOOLERR_SUCCESS;
UINT8 track, sector; UINT8 track, sector;
@ -167,21 +167,21 @@ static imgtoolerr_t transfer_granule(imgtool::image *img, UINT8 granule, int len
static imgtoolerr_t transfer_from_granule(imgtool::image *img, UINT8 granule, int length, imgtool_stream *destf) static imgtoolerr_t transfer_from_granule(imgtool::image *img, UINT8 granule, int length, imgtool::stream &destf)
{ {
return transfer_granule(img, granule, length, destf, imgtool_floppy_read_sector_to_stream); return transfer_granule(img, granule, length, destf, imgtool_floppy_read_sector_to_stream);
} }
static imgtoolerr_t transfer_to_granule(imgtool::image *img, UINT8 granule, int length, imgtool_stream *sourcef) static imgtoolerr_t transfer_to_granule(imgtool::image *img, UINT8 granule, int length, imgtool::stream &sourcef)
{ {
return transfer_granule(img, granule, length, sourcef, imgtool_floppy_write_sector_from_stream); return transfer_granule(img, granule, length, sourcef, imgtool_floppy_write_sector_from_stream);
} }
static imgtoolerr_t process_rsdos_file(struct rsdos_dirent *ent, imgtool::image *img, imgtool_stream *destf, size_t *size) static imgtoolerr_t process_rsdos_file(struct rsdos_dirent *ent, imgtool::image *img, imgtool::stream *destf, size_t *size)
{ {
floperr_t ferr; floperr_t ferr;
size_t s, lastgransize; size_t s, lastgransize;
@ -204,7 +204,7 @@ static imgtoolerr_t process_rsdos_file(struct rsdos_dirent *ent, imgtool::image
{ {
usedmap[granule] = 1; usedmap[granule] = 1;
if (destf) if (destf)
transfer_from_granule(img, granule, 9*256, destf); transfer_from_granule(img, granule, 9*256, *destf);
/* i is the next granule */ /* i is the next granule */
s += (256 * 9); s += (256 * 9);
@ -219,7 +219,7 @@ static imgtoolerr_t process_rsdos_file(struct rsdos_dirent *ent, imgtool::image
lastgransize += (256 * (i - 0xc0)); lastgransize += (256 * (i - 0xc0));
if (destf) if (destf)
transfer_from_granule(img, granule, lastgransize, destf); transfer_from_granule(img, granule, lastgransize, *destf);
if (size) if (size)
*size = s + lastgransize; *size = s + lastgransize;
@ -300,7 +300,7 @@ eof:
else else
{ {
/* Not the end of file */ /* Not the end of file */
err = process_rsdos_file(&rsent, image, NULL, &filesize); err = process_rsdos_file(&rsent, image, nullptr, &filesize);
if (err) if (err)
return err; return err;
@ -386,7 +386,7 @@ static imgtoolerr_t delete_entry(imgtool::image *img, struct rsdos_dirent *ent,
static imgtoolerr_t rsdos_diskimage_readfile(imgtool::partition *partition, const char *fname, const char *fork, imgtool_stream *destf) static imgtoolerr_t rsdos_diskimage_readfile(imgtool::partition *partition, const char *fname, const char *fork, imgtool::stream &destf)
{ {
imgtoolerr_t err; imgtoolerr_t err;
struct rsdos_dirent ent; struct rsdos_dirent ent;
@ -397,7 +397,7 @@ static imgtoolerr_t rsdos_diskimage_readfile(imgtool::partition *partition, cons
if (err) if (err)
return err; return err;
err = process_rsdos_file(&ent, img, destf, &size); err = process_rsdos_file(&ent, img, &destf, &size);
if (err) if (err)
return err; return err;
@ -409,7 +409,7 @@ static imgtoolerr_t rsdos_diskimage_readfile(imgtool::partition *partition, cons
static imgtoolerr_t rsdos_diskimage_writefile(imgtool::partition *partition, const char *fname, const char *fork, imgtool_stream *sourcef, util::option_resolution *writeoptions) static imgtoolerr_t rsdos_diskimage_writefile(imgtool::partition *partition, const char *fname, const char *fork, imgtool::stream &sourcef, util::option_resolution *writeoptions)
{ {
floperr_t ferr; floperr_t ferr;
imgtoolerr_t err; imgtoolerr_t err;
@ -432,7 +432,7 @@ static imgtoolerr_t rsdos_diskimage_writefile(imgtool::partition *partition, con
return err; return err;
/* is there enough space? */ /* is there enough space? */
sz = stream_size(sourcef); sz = sourcef.size();
if (sz > freespace) if (sz > freespace)
return IMGTOOLERR_NOSPACE; return IMGTOOLERR_NOSPACE;

View File

@ -120,7 +120,7 @@
#define MAXSIZE 80*16*256*2 /* room for two faces, double-density, 80 tracks */ #define MAXSIZE 80*16*256*2 /* room for two faces, double-density, 80 tracks */
struct thom_floppy { struct thom_floppy {
imgtool_stream *stream; imgtool::stream *stream;
UINT16 sector_size; /* 128 or 256 */ UINT16 sector_size; /* 128 or 256 */
UINT16 sectuse_size; /* bytes used in sector: 128 or 255 */ UINT16 sectuse_size; /* bytes used in sector: 128 or 255 */
@ -177,12 +177,12 @@ static UINT8* thom_get_sector(thom_floppy* f, unsigned head,
(.fd have 40 or 80 tracks, .qd have 25 tracks) and the file size. (.fd have 40 or 80 tracks, .qd have 25 tracks) and the file size.
*/ */
static imgtoolerr_t thom_open_fd_qd(imgtool::image *img, imgtool_stream *stream) static imgtoolerr_t thom_open_fd_qd(imgtool::image *img, imgtool::stream &stream)
{ {
thom_floppy* f = (thom_floppy*) img->extra_bytes(); thom_floppy* f = (thom_floppy*) img->extra_bytes();
int size = stream_size( stream ); int size = stream.size();
f->stream = stream; f->stream = &stream;
f->modified = 0; f->modified = 0;
/* guess format */ /* guess format */
@ -238,8 +238,8 @@ static imgtoolerr_t thom_open_fd_qd(imgtool::image *img, imgtool_stream *stream)
assert( size == f->heads * f->tracks * 16 * f->sector_size ); assert( size == f->heads * f->tracks * 16 * f->sector_size );
stream_seek( stream, 0, SEEK_SET ); stream.seek(0, SEEK_SET);
if ( stream_read( stream, f->data, size ) < size ) if ( stream.read(f->data, size ) < size )
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
@ -252,14 +252,14 @@ static void thom_close_fd_qd(imgtool::image *img)
/* save image */ /* save image */
if ( f->modified ) { if ( f->modified ) {
int size = f->heads * f->tracks * 16 * f->sector_size; int size = f->heads * f->tracks * 16 * f->sector_size;
stream_seek( f->stream, 0, SEEK_SET ); f->stream->seek(0, SEEK_SET);
if ( stream_write( f->stream, f->data, size ) < size ) if (f->stream->write(f->data, size) < size)
{ {
/* logerror( "thom_diskimage_close_fd_qd: write error\n" ); */ /* logerror( "thom_diskimage_close_fd_qd: write error\n" ); */
} }
} }
stream_close( f->stream ); delete f->stream;
} }
@ -308,21 +308,21 @@ static UINT16 thom_sap_crc( UINT8* data, int size )
return crc; return crc;
} }
static imgtoolerr_t thom_open_sap(imgtool::image *img, imgtool_stream *stream) static imgtoolerr_t thom_open_sap(imgtool::image *img, imgtool::stream &stream)
{ {
thom_floppy* f = (thom_floppy*) img->extra_bytes(); thom_floppy* f = (thom_floppy*) img->extra_bytes();
UINT8 buf[262]; UINT8 buf[262];
f->stream = stream; f->stream = &stream;
f->modified = 0; f->modified = 0;
/* check image header */ /* check image header */
stream_seek( stream, 0, SEEK_SET ); stream.seek(0, SEEK_SET);
stream_read( stream, buf, 66 ); stream.read(buf, 66 );
if ( memcmp( buf+1, sap_header+1, 65 ) ) return IMGTOOLERR_CORRUPTIMAGE; if ( memcmp( buf+1, sap_header+1, 65 ) ) return IMGTOOLERR_CORRUPTIMAGE;
/* guess format */ /* guess format */
stream_read( stream, buf, 1 ); stream.read(buf, 1 );
switch ( buf[0] ) { switch ( buf[0] ) {
case 1: case 1:
case 3: case 3:
@ -342,13 +342,13 @@ static imgtoolerr_t thom_open_sap(imgtool::image *img, imgtool_stream *stream)
default: return IMGTOOLERR_CORRUPTIMAGE; default: return IMGTOOLERR_CORRUPTIMAGE;
} }
stream_seek( stream, 66, SEEK_SET ); stream.seek(66, SEEK_SET);
while ( 1) { while ( 1) {
int i, sector, track; int i, sector, track;
UINT16 crc; UINT16 crc;
/* load sector */ /* load sector */
if ( stream_read( stream, buf, 6 + f->sector_size ) < 6 + f->sector_size ) if ( stream.read(buf, 6 + f->sector_size ) < 6 + f->sector_size )
break; break;
/* parse sector header */ /* parse sector header */
@ -381,10 +381,10 @@ static void thom_close_sap(imgtool::image *img)
UINT16 crc; UINT16 crc;
/* rewind */ /* rewind */
stream_seek( f->stream, 0, SEEK_SET ); f->stream->seek(0, SEEK_SET);
/* image header */ /* image header */
if ( stream_write( f->stream, sap_header, 66 ) < 66 ) { if ( f->stream->write(sap_header, 66) < 66) {
/* logerror( "thom_diskimage_close_sap: write error\n" ); */ /* logerror( "thom_diskimage_close_sap: write error\n" ); */
return; return;
} }
@ -408,15 +408,15 @@ static void thom_close_sap(imgtool::image *img)
for ( i = 0; i < f->sector_size; i++ ) buf[ i + 4 ] ^= sap_magic_num; for ( i = 0; i < f->sector_size; i++ ) buf[ i + 4 ] ^= sap_magic_num;
/* save */ /* save */
if ( stream_write( f->stream, buf, f->sector_size + 6 ) < if (f->stream->write(buf, f->sector_size + 6) <
f->sector_size + 6 ) { f->sector_size + 6) {
/* logerror( "thom_diskimage_close_sap: write error\n" ); */ /* logerror( "thom_diskimage_close_sap: write error\n" ); */
return; return;
} }
} }
} }
stream_close( f->stream ); delete f->stream;
} }
@ -678,44 +678,50 @@ static int thom_get_free_blocks(thom_floppy* f, unsigned head)
/* dump file contents into dst */ /* dump file contents into dst */
static void thom_get_file(thom_floppy* f, unsigned head, static void thom_get_file(thom_floppy* f, unsigned head,
thom_dirent* d, imgtool_stream *dst) thom_dirent* d, imgtool::stream &dst)
{ {
UINT8* fat = thom_get_sector( f, head, 20, 2 ); UINT8* fat = thom_get_sector( f, head, 20, 2 );
int nbblocks = thom_nb_blocks(f); int nbblocks = thom_nb_blocks(f);
int block = d->firstblock; int block = d->firstblock;
if ( block >= nbblocks ) return; if ( block >= nbblocks ) return;
while ( 1 ) { while ( 1 )
int nextblock = fat[ block + 1 ]; {
int track = block / 2; int nextblock = fat[ block + 1 ];
int firstsect = (block % 2) ? 9 : 1; int track = block / 2;
if ( nextblock < nbblocks ) { int firstsect = (block % 2) ? 9 : 1;
/* full block */ if ( nextblock < nbblocks )
int i; {
for ( i = 0; i < 8; i++ ) { /* full block */
UINT8* data = thom_get_sector( f, head, track, firstsect + i ); int i;
stream_write( dst, data, f->sectuse_size ); for ( i = 0; i < 8; i++ )
{
UINT8* data = thom_get_sector( f, head, track, firstsect + i );
dst.write(data, f->sectuse_size);
}
block = fat[ block + 1 ];
} }
block = fat[ block + 1 ]; else if ( nextblock >= 0xc1 && nextblock <= 0xc8 )
} {
else if ( nextblock >= 0xc1 && nextblock <= 0xc8 ) { /* last block in file */
/* last block in file */ int i;
int i; UINT8* data;
UINT8* data; for ( i = 0; i < nextblock - 0xc1; i++ )
for ( i = 0; i < nextblock - 0xc1; i++ ) { {
data = thom_get_sector( f, head, track, firstsect + i ); data = thom_get_sector( f, head, track, firstsect + i );
stream_write( dst, data, f->sectuse_size ); dst.write(data, f->sectuse_size);
}
data = thom_get_sector( f, head, track, firstsect + i );
dst.write(data, d->lastsectsize);
return;
} }
data = thom_get_sector( f, head, track, firstsect + i ); else
stream_write( dst, data, d->lastsectsize ); {
return; /* invalid, assume last block */
} UINT8* data = thom_get_sector( f, head, track, firstsect );
else { dst.write(data, d->lastsectsize);
/* invalid, assume last block */ return;
UINT8* data = thom_get_sector( f, head, track, firstsect ); }
stream_write( dst, data, d->lastsectsize ); block = nextblock;
return;
}
block = nextblock;
} }
} }
@ -739,9 +745,9 @@ static void thom_del_file(thom_floppy* f, unsigned head, thom_dirent* d)
/* create a new file or overwrite an old one, with the contents of src */ /* create a new file or overwrite an old one, with the contents of src */
static void thom_put_file(thom_floppy* f, unsigned head, static void thom_put_file(thom_floppy* f, unsigned head,
thom_dirent* d, imgtool_stream *src) thom_dirent* d, imgtool::stream &src)
{ {
int size = stream_size( src ); int size = src.size();
UINT8* fat = thom_get_sector( f, head, 20, 2 ); UINT8* fat = thom_get_sector( f, head, 20, 2 );
int nbblocks = thom_nb_blocks(f); int nbblocks = thom_nb_blocks(f);
int block; int block;
@ -760,14 +766,14 @@ static void thom_put_file(thom_floppy* f, unsigned head,
/* store data, full sectors */ /* store data, full sectors */
for ( i = 0; i < 8 && size > f->sectuse_size; i++ ) { for ( i = 0; i < 8 && size > f->sectuse_size; i++ ) {
UINT8* dst = thom_get_sector( f, head, track, firstsect + i ); UINT8* dst = thom_get_sector( f, head, track, firstsect + i );
stream_read( src, dst, f->sectuse_size ); src.read(dst, f->sectuse_size);
size -= f->sectuse_size; size -= f->sectuse_size;
} }
/* store data, last sector */ /* store data, last sector */
if ( i < 8 ) { if ( i < 8 ) {
UINT8* dst = thom_get_sector( f, head, track, firstsect + i ); UINT8* dst = thom_get_sector( f, head, track, firstsect + i );
stream_read( src, dst, size ); src.read(dst, size);
fat[ block + 1 ] = 0xc1 + i; fat[ block + 1 ] = 0xc1 + i;
d->lastsectsize = size; d->lastsectsize = size;
break; break;
@ -823,7 +829,7 @@ static imgtoolerr_t thom_write_sector(imgtool::image *img, UINT32 track,
const void *buf, size_t len, int ddam) const void *buf, size_t len, int ddam)
{ {
thom_floppy* f = (thom_floppy*) img->extra_bytes(); thom_floppy* f = (thom_floppy*) img->extra_bytes();
if ( stream_isreadonly( f->stream ) ) return IMGTOOLERR_WRITEERROR; if ( f->stream->is_read_only() ) return IMGTOOLERR_WRITEERROR;
if ( head >= f->heads || sector < 1 || sector > 16 || track >= f->tracks ) if ( head >= f->heads || sector < 1 || sector > 16 || track >= f->tracks )
return IMGTOOLERR_SEEKERROR; return IMGTOOLERR_SEEKERROR;
if ( len > f->sector_size) return IMGTOOLERR_WRITEERROR; if ( len > f->sector_size) return IMGTOOLERR_WRITEERROR;
@ -937,7 +943,7 @@ static imgtoolerr_t thom_free_space(imgtool::partition *part, UINT64 *size)
static imgtoolerr_t thom_read_file(imgtool::partition *part, static imgtoolerr_t thom_read_file(imgtool::partition *part,
const char *filename, const char *filename,
const char *fork, const char *fork,
imgtool_stream *destf) imgtool::stream &destf)
{ {
int head = *( (int*) part->extra_bytes() ); int head = *( (int*) part->extra_bytes() );
imgtool::image* img = &part->image(); imgtool::image* img = &part->image();
@ -974,7 +980,7 @@ static imgtoolerr_t thom_delete_file(imgtool::partition *part,
if ( ! thom_find_dirent( f, head, fname, &d ) ) if ( ! thom_find_dirent( f, head, fname, &d ) )
return IMGTOOLERR_FILENOTFOUND; return IMGTOOLERR_FILENOTFOUND;
/*if ( thom_get_file_size( f, head, &d ) < 0 ) return IMGTOOLERR_CORRUPTFILE;*/ /*if ( thom_get_file_size( f, head, &d ) < 0 ) return IMGTOOLERR_CORRUPTFILE;*/
if ( stream_isreadonly( f->stream ) ) return IMGTOOLERR_WRITEERROR; if ( f->stream->is_read_only() ) return IMGTOOLERR_WRITEERROR;
thom_del_file( f, head, &d ); thom_del_file( f, head, &d );
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
@ -982,19 +988,19 @@ static imgtoolerr_t thom_delete_file(imgtool::partition *part,
static imgtoolerr_t thom_write_file(imgtool::partition *part, static imgtoolerr_t thom_write_file(imgtool::partition *part,
const char *filename, const char *filename,
const char *fork, const char *fork,
imgtool_stream *sourcef, imgtool::stream &sourcef,
util::option_resolution *opts) util::option_resolution *opts)
{ {
int head = *( (int*) part->extra_bytes() ); int head = *( (int*) part->extra_bytes() );
imgtool::image* img = &part->image(); imgtool::image* img = &part->image();
thom_floppy* f = (thom_floppy*) img->extra_bytes(); thom_floppy* f = (thom_floppy*) img->extra_bytes();
thom_dirent d; thom_dirent d;
int size = stream_size( sourcef ); int size = sourcef.size();
int blocks = thom_get_free_blocks( f, head ); int blocks = thom_get_free_blocks( f, head );
char name[9], ext[4], fname[14]; char name[9], ext[4], fname[14];
int is_new = 1; int is_new = 1;
if ( stream_isreadonly( f->stream ) ) return IMGTOOLERR_WRITEERROR; if ( f->stream->is_read_only() ) return IMGTOOLERR_WRITEERROR;
/* convert filename */ /* convert filename */
thom_conv_filename( filename, name, ext ); thom_conv_filename( filename, name, ext );
@ -1107,7 +1113,7 @@ static imgtoolerr_t thom_suggest_transfer(imgtool::partition *part,
} }
static imgtoolerr_t thom_create(imgtool::image* img, static imgtoolerr_t thom_create(imgtool::image* img,
imgtool_stream *stream, imgtool::stream &stream,
util::option_resolution *opts) util::option_resolution *opts)
{ {
thom_floppy* f = (thom_floppy*) img->extra_bytes(); thom_floppy* f = (thom_floppy*) img->extra_bytes();
@ -1115,7 +1121,7 @@ static imgtoolerr_t thom_create(imgtool::image* img,
UINT8* buf; UINT8* buf;
const char* name; const char* name;
f->stream = stream; f->stream = &stream;
f->modified = 0; f->modified = 0;
/* get parameters */ /* get parameters */
@ -1274,92 +1280,98 @@ static const UINT8 crypt2[13] = {
}; };
/* decrypt BASIC protected files */ /* decrypt BASIC protected files */
static void thom_decrypt(imgtool_stream* out, imgtool_stream* in) static void thom_decrypt(imgtool::stream &out, imgtool::stream &in)
{ {
int i1 = 11, i2 = 13; int i1 = 11, i2 = 13;
while ( 1 ) { while ( 1 )
UINT8 b; {
if ( stream_read( in, &b, 1) < 1 ) break; UINT8 b;
b = ( (UINT8)(b - i2) ^ crypt2[i2-1] ^ crypt1[i1-1] ) + i1; if ( in.read(&b, 1) < 1 ) break;
stream_putc( out, b ); b = ( (UINT8)(b - i2) ^ crypt2[i2-1] ^ crypt1[i1-1] ) + i1;
i1--; i2--; out.putc(b );
if ( !i1 ) i1 = 11; i1--; i2--;
if ( !i2 ) i2 = 13; if ( !i1 ) i1 = 11;
if ( !i2 ) i2 = 13;
} }
} }
/* encrypt BASIC protected files */ /* encrypt BASIC protected files */
static void thom_encrypt(imgtool_stream* out, imgtool_stream* in) static void thom_encrypt(imgtool::stream &out, imgtool::stream &in)
{ {
int i1 = 11, i2 = 13; int i1 = 11, i2 = 13;
while ( 1 ) { while ( 1 )
UINT8 b; {
if ( stream_read( in, &b, 1) < 1 ) break; UINT8 b;
b = ( (UINT8)(b - i1) ^ crypt2[i2-1] ^ crypt1[i1-1] ) + i2; if ( in.read(&b, 1) < 1 ) break;
stream_putc( out, b ); b = ( (UINT8)(b - i1) ^ crypt2[i2-1] ^ crypt1[i1-1] ) + i2;
i1--; i2--; out.putc(b );
if ( !i1 ) i1 = 11; i1--; i2--;
if ( !i2 ) i2 = 13; if ( !i1 ) i1 = 11;
if ( !i2 ) i2 = 13;
} }
} }
static imgtoolerr_t thomcrypt_read_file(imgtool::partition *part, static imgtoolerr_t thomcrypt_read_file(imgtool::partition *part,
const char *name, const char *name,
const char *fork, imgtool_stream *dst) const char *fork, imgtool::stream &dst)
{ {
UINT8 buf[3]; UINT8 buf[3];
imgtool_stream *org = stream_open_mem( NULL, 0 ); imgtool::stream *org = imgtool::stream::open_mem( NULL, 0 );
imgtoolerr_t err; imgtoolerr_t err;
if ( !org ) return IMGTOOLERR_OUTOFMEMORY; if ( !org ) return IMGTOOLERR_OUTOFMEMORY;
/* read file */ /* read file */
err = thom_read_file( part, name, fork, org ); err = thom_read_file( part, name, fork, *org );
if ( err ) { if ( err ) {
stream_close( org ); delete org;
return err; return err;
} }
stream_seek( org, 0, SEEK_SET ); org->seek(0, SEEK_SET);
if ( stream_read( org, buf, 3 ) < 3 || buf[0] != 0xfe ) { if ( org->read(buf, 3 ) < 3 || buf[0] != 0xfe )
/* regular file */ {
stream_seek( org, 0, SEEK_SET ); /* regular file */
stream_transfer_all( dst, org ); org->seek(0, SEEK_SET);
imgtool::stream::transfer_all( dst, *org );
} }
else { else
/* encrypted file */ {
stream_putc( dst, '\xff' ); /* encrypted file */
stream_write( dst, buf+1, 2 ); dst.putc( '\xff' );
thom_decrypt( dst, org ); dst.write(buf+1, 2);
thom_decrypt( dst, *org );
} }
stream_close( org ); delete org;
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
static imgtoolerr_t thomcrypt_write_file(imgtool::partition *part, static imgtoolerr_t thomcrypt_write_file(imgtool::partition *part,
const char *name, const char *name,
const char *fork, imgtool_stream *src, const char *fork, imgtool::stream &src,
util::option_resolution *opts) util::option_resolution *opts)
{ {
UINT8 buf[3]; UINT8 buf[3];
if ( stream_read( src, buf, 3 ) < 3 || buf[0] == 0xfe ) { if ( src.read(buf, 3 ) < 3 || buf[0] == 0xfe )
/* too short or already encrypted file */ {
stream_seek( src, 0, SEEK_SET ); /* too short or already encrypted file */
return thom_write_file( part, name, fork, src, opts ); src.seek(0, SEEK_SET);
return thom_write_file( part, name, fork, src, opts );
} }
else { else
/* regular file */ {
imgtool_stream *dst = stream_open_mem( NULL, 0 ); /* regular file */
imgtoolerr_t err; imgtool::stream *dst = imgtool::stream::open_mem( NULL, 0 );
if ( !dst ) return IMGTOOLERR_OUTOFMEMORY; imgtoolerr_t err;
stream_putc( dst, '\xfe' ); if ( !dst ) return IMGTOOLERR_OUTOFMEMORY;
stream_write( dst, buf+1, 2 ); dst->putc( '\xfe' );
thom_encrypt( dst, src ); dst->write(buf+1, 2);
stream_seek( dst, 0, SEEK_SET ); thom_encrypt( *dst, src );
err = thom_write_file( part, name, fork, dst, opts ); dst->seek(0, SEEK_SET);
stream_close( dst); err = thom_write_file( part, name, fork, *dst, opts );
return err; delete dst;
return err;
} }
} }
@ -1385,77 +1397,84 @@ void filter_thomcrypt_getinfo(UINT32 state, union filterinfo *info)
static imgtoolerr_t thom_basic_read_file(imgtool::partition *part, static imgtoolerr_t thom_basic_read_file(imgtool::partition *part,
const char *name, const char *name,
const char *fork, const char *fork,
imgtool_stream *dst, imgtool::stream &dst,
const char *const table[2][128]) const char *const table[2][128])
{ {
imgtool_stream *org = stream_open_mem( NULL, 0 ); imgtool::stream *org = imgtool::stream::open_mem( NULL, 0 );
imgtoolerr_t err; imgtoolerr_t err;
UINT8 buf[4]; UINT8 buf[4];
int i; int i;
if ( !org ) return IMGTOOLERR_OUTOFMEMORY; if ( !org ) return IMGTOOLERR_OUTOFMEMORY;
err = thomcrypt_read_file( part, name, fork, org ); err = thomcrypt_read_file( part, name, fork, *org );
if ( err ) { if (err)
stream_close( org ); {
return err; delete org;
return err;
} }
stream_seek( org, 3, SEEK_SET ); /* skip header */ org->seek(3, SEEK_SET); /* skip header */
while ( 1 ) { while ( 1 )
int in_str = 0, in_fun = 0; {
int linelength, linenum; int in_str = 0, in_fun = 0;
int linelength, linenum;
/* line header: line length and line number */ /* line header: line length and line number */
/* I am not sure this is 100% correct but it works in many cases */ /* I am not sure this is 100% correct but it works in many cases */
if ( stream_read( org, buf, 2 ) < 2 ) goto end; if ( org->read(buf, 2 ) < 2 ) goto end;
linelength = ((int)buf[0] << 8) + (int)buf[1] - 4; linelength = ((int)buf[0] << 8) + (int)buf[1] - 4;
if ( linelength <= 0 ) goto end; if ( linelength <= 0 ) goto end;
if ( stream_read( org, buf, 2 ) < 2 ) goto end; if ( org->read(buf, 2 ) < 2 ) goto end;
linenum = ((int)buf[0] << 8) + buf[1]; linenum = ((int)buf[0] << 8) + buf[1];
stream_printf( dst, "%u ", linenum ); dst.printf( "%u ", linenum );
/* process line */ /* process line */
for ( i = 0; i < linelength; i++ ) { for ( i = 0; i < linelength; i++ )
UINT8 c; {
if ( stream_read( org, &c, 1 ) < 1 ) break; UINT8 c;
if ( c == 0 ) { if ( org->read(&c, 1 ) < 1 ) break;
/* Sometimes, linelength seems wrong and we must rely on the fact that if ( c == 0 )
BASIC lines are 0-terminated. {
At other times, there are 0 embedded within lines or extra stuff /* Sometimes, linelength seems wrong and we must rely on the fact that
between the 0 and the following line, and so, we must rely BASIC lines are 0-terminated.
on linelength to cut the line (!) At other times, there are 0 embedded within lines or extra stuff
*/ between the 0 and the following line, and so, we must rely
if ( linelength > 256 ) break; on linelength to cut the line (!)
*/
if ( linelength > 256 ) break;
}
else if ( c == 0xff && ! in_str ) in_fun = 1; /* function prefix */
else
{
if ( c >= 0x80 && ! in_str )
{
/* token */
const char* token = table[ in_fun ][ c - 0x80 ];
if ( token ) dst.puts(token );
else dst.puts("???" );
}
else
{
/* regular character */
if ( c == '"' ) in_str = 1 - in_str;
dst.putc( c ); /* normal letter */
}
in_fun = 0;
}
} }
else if ( c == 0xff && ! in_str ) in_fun = 1; /* function prefix */ dst.putc( '\n' );
else {
if ( c >= 0x80 && ! in_str ) {
/* token */
const char* token = table[ in_fun ][ c - 0x80 ];
if ( token ) stream_puts( dst, token );
else stream_puts( dst, "???" );
}
else {
/* regular character */
if ( c == '"' ) in_str = 1 - in_str;
stream_putc( dst, c ); /* normal letter */
}
in_fun = 0;
}
}
stream_putc( dst, '\n' );
} }
end: end:
stream_close( org ); delete org;
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
static imgtoolerr_t thom_basic_write_file(imgtool::partition *part, static imgtoolerr_t thom_basic_write_file(imgtool::partition *part,
const char *name, const char *name,
const char *fork, const char *fork,
imgtool_stream *src, imgtool::stream &src,
util::option_resolution *opts, util::option_resolution *opts,
const char *const table[2][128]) const char *const table[2][128])
{ {
@ -1467,14 +1486,14 @@ static imgtoolerr_t thom_basic_write_file(imgtool::partition *part,
static imgtoolerr_t short##_read_file(imgtool::partition *part, \ static imgtoolerr_t short##_read_file(imgtool::partition *part, \
const char *name, \ const char *name, \
const char *fork, \ const char *fork, \
imgtool_stream *dst) \ imgtool::stream &dst) \
{ \ { \
return thom_basic_read_file( part, name, fork, dst, short ); \ return thom_basic_read_file( part, name, fork, dst, short ); \
} \ } \
static imgtoolerr_t short##_write_file(imgtool::partition *part, \ static imgtoolerr_t short##_write_file(imgtool::partition *part, \
const char *name, \ const char *name, \
const char *fork, \ const char *fork, \
imgtool_stream *src, \ imgtool::stream &src, \
util::option_resolution *opts) \ util::option_resolution *opts) \
{ \ { \
return thom_basic_write_file( part, name, fork, src, opts, short ); \ return thom_basic_write_file( part, name, fork, src, opts, short ); \

View File

@ -545,7 +545,7 @@ enum ti99_img_format
struct ti99_lvl1_imgref struct ti99_lvl1_imgref
{ {
ti99_img_format img_format; /* tells the image format */ ti99_img_format img_format; /* tells the image format */
imgtool_stream *file_handle; /* imgtool file handle */ imgtool::stream *file_handle; /* imgtool file handle */
struct mess_hard_disk_file harddisk_handle; /* MAME harddisk handle (harddisk format) */ struct mess_hard_disk_file harddisk_handle; /* MAME harddisk handle (harddisk format) */
ti99_geometry geometry; /* geometry */ ti99_geometry geometry; /* geometry */
unsigned pc99_track_len; /* unformatted track length (pc99 format) */ unsigned pc99_track_len; /* unformatted track length (pc99 format) */
@ -597,7 +597,7 @@ static void calc_crc(UINT16 *crc, UINT8 value)
*/ */
#define MAX_TRACK_LEN 6872 #define MAX_TRACK_LEN 6872
#define DATA_OFFSET_NONE 0xffffffff #define DATA_OFFSET_NONE 0xffffffff
static int parse_pc99_image(imgtool_stream *file_handle, int fm_format, int pass, dsk_vib *vib, const ti99_geometry *geometry, UINT32 *data_offset_array, unsigned *out_track_len) static int parse_pc99_image(imgtool::stream &file_handle, int fm_format, int pass, dsk_vib *vib, const ti99_geometry *geometry, UINT32 *data_offset_array, unsigned *out_track_len)
{ {
int track_len, num_tracks; /* length of a track in bytes, and number of tracks */ int track_len, num_tracks; /* length of a track in bytes, and number of tracks */
int phys_track; int phys_track;
@ -620,10 +620,10 @@ static int parse_pc99_image(imgtool_stream *file_handle, int fm_format, int pass
if (out_track_len) if (out_track_len)
*out_track_len = track_len; *out_track_len = track_len;
if (stream_size(file_handle) % track_len) if (file_handle.size() % track_len)
return IMGTOOLERR_CORRUPTIMAGE; return IMGTOOLERR_CORRUPTIMAGE;
num_tracks = stream_size(file_handle) / track_len; num_tracks = file_handle.size() / track_len;
if (num_tracks <= 0) if (num_tracks <= 0)
return IMGTOOLERR_CORRUPTIMAGE; return IMGTOOLERR_CORRUPTIMAGE;
@ -640,12 +640,12 @@ static int parse_pc99_image(imgtool_stream *file_handle, int fm_format, int pass
data_offset_array[(head*geometry->cylinders + cylinder)*geometry->secspertrack + sector] = DATA_OFFSET_NONE; data_offset_array[(head*geometry->cylinders + cylinder)*geometry->secspertrack + sector] = DATA_OFFSET_NONE;
} }
/* rewind to start of file */ /* rewind to start of file */
stream_seek(file_handle, 0, SEEK_SET); file_handle.seek(0, SEEK_SET);
/* pass 0 only looks for vib in track 0; pass 1 scans every track */ /* pass 0 only looks for vib in track 0; pass 1 scans every track */
for (phys_track=0; phys_track < ((pass == 1) ? num_tracks : 1); phys_track++) for (phys_track=0; phys_track < ((pass == 1) ? num_tracks : 1); phys_track++)
{ {
if (stream_read(file_handle, track_buf, track_len) != track_len) if (file_handle.read(track_buf, track_len) != track_len)
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
/* we only support 40-track-per-side images */ /* we only support 40-track-per-side images */
@ -926,7 +926,7 @@ static int parse_pc99_image(imgtool_stream *file_handle, int fm_format, int pass
Return imgtool error code Return imgtool error code
*/ */
static int read_image_vib_no_geometry(imgtool_stream *file_handle, ti99_img_format img_format, dsk_vib *dest) static int read_image_vib_no_geometry(imgtool::stream &file_handle, ti99_img_format img_format, dsk_vib *dest)
{ {
int reply; int reply;
@ -935,11 +935,11 @@ static int read_image_vib_no_geometry(imgtool_stream *file_handle, ti99_img_form
case if_mess: case if_mess:
case if_v9t9: case if_v9t9:
/* seek to sector */ /* seek to sector */
reply = stream_seek(file_handle, 0, SEEK_SET); reply = file_handle.seek(0, SEEK_SET);
if (reply) if (reply)
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
/* read it */ /* read it */
reply = stream_read(file_handle, dest, 256); reply = file_handle.read(dest, 256);
if (reply != 256) if (reply != 256)
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
return 0; return 0;
@ -966,7 +966,7 @@ static int read_image_vib_no_geometry(imgtool_stream *file_handle, ti99_img_form
Return imgtool error code Return imgtool error code
*/ */
static imgtoolerr_t open_image_lvl1(imgtool_stream *file_handle, ti99_img_format img_format, ti99_lvl1_imgref *l1_img, dsk_vib *vib) static imgtoolerr_t open_image_lvl1(imgtool::stream &file_handle, ti99_img_format img_format, ti99_lvl1_imgref *l1_img, dsk_vib *vib)
{ {
imgtoolerr_t err; imgtoolerr_t err;
int reply; int reply;
@ -974,7 +974,7 @@ static imgtoolerr_t open_image_lvl1(imgtool_stream *file_handle, ti99_img_format
l1_img->img_format = img_format; l1_img->img_format = img_format;
l1_img->file_handle = file_handle; l1_img->file_handle = &file_handle;
if (img_format == if_harddisk) if (img_format == if_harddisk)
{ {
@ -1032,7 +1032,7 @@ static imgtoolerr_t open_image_lvl1(imgtool_stream *file_handle, ti99_img_format
|| (totphysrecs < 2) || (totphysrecs < 2)
|| memcmp(vib->id, "DSK", 3) || (! strchr(" P", vib->protection)) || memcmp(vib->id, "DSK", 3) || (! strchr(" P", vib->protection))
|| (((img_format == if_mess) || (img_format == if_v9t9)) || (((img_format == if_mess) || (img_format == if_v9t9))
&& (stream_size(file_handle) != totphysrecs*256U))) && (file_handle.size() != totphysrecs*256U)))
return (imgtoolerr_t)IMGTOOLERR_CORRUPTIMAGE; return (imgtoolerr_t)IMGTOOLERR_CORRUPTIMAGE;
if ((img_format == if_pc99_fm) || (img_format == if_pc99_mfm)) if ((img_format == if_pc99_fm) || (img_format == if_pc99_mfm))
@ -1066,7 +1066,7 @@ static void close_image_lvl1(ti99_lvl1_imgref *l1_img)
imghd_close(&l1_img->harddisk_handle); imghd_close(&l1_img->harddisk_handle);
} }
stream_close(l1_img->file_handle); delete l1_img->file_handle;
if ((l1_img->img_format == if_pc99_fm) || (l1_img->img_format == if_pc99_mfm)) if ((l1_img->img_format == if_pc99_fm) || (l1_img->img_format == if_pc99_mfm))
free(l1_img->pc99_data_offset_array); free(l1_img->pc99_data_offset_array);
@ -1134,11 +1134,11 @@ static int read_sector(ti99_lvl1_imgref *l1_img, const ti99_sector_address *addr
case if_v9t9: case if_v9t9:
/* V9T9 format */ /* V9T9 format */
/* seek to sector */ /* seek to sector */
reply = stream_seek(l1_img->file_handle, sector_address_to_image_offset(l1_img, address), SEEK_SET); reply = l1_img->file_handle->seek(sector_address_to_image_offset(l1_img, address), SEEK_SET);
if (reply) if (reply)
return 1; return 1;
/* read it */ /* read it */
reply = stream_read(l1_img->file_handle, dest, 256); reply = l1_img->file_handle->read(dest, 256);
if (reply != 256) if (reply != 256)
return 1; return 1;
break; break;
@ -1153,31 +1153,31 @@ static int read_sector(ti99_lvl1_imgref *l1_img, const ti99_sector_address *addr
if ((sector_offset + 256) <= track_len) if ((sector_offset + 256) <= track_len)
{ {
/* seek to sector */ /* seek to sector */
reply = stream_seek(l1_img->file_handle, track_offset+sector_offset, SEEK_SET); reply = l1_img->file_handle->seek(track_offset+sector_offset, SEEK_SET);
if (reply) if (reply)
return 1; return 1;
/* read it */ /* read it */
reply = stream_read(l1_img->file_handle, dest, 256); reply = l1_img->file_handle->read(dest, 256);
if (reply != 256) if (reply != 256)
return 1; return 1;
} }
else else
{ {
/* seek to sector */ /* seek to sector */
reply = stream_seek(l1_img->file_handle, track_offset+sector_offset, SEEK_SET); reply = l1_img->file_handle->seek(track_offset+sector_offset, SEEK_SET);
if (reply) if (reply)
return 1; return 1;
/* read first chunk (until end of track) */ /* read first chunk (until end of track) */
reply = stream_read(l1_img->file_handle, (UINT8 *)dest, track_len-sector_offset); reply = l1_img->file_handle->read((UINT8 *)dest, track_len-sector_offset);
if (reply != track_len-sector_offset) if (reply != track_len-sector_offset)
return 1; return 1;
/* wrap to start of track */ /* wrap to start of track */
reply = stream_seek(l1_img->file_handle, track_offset, SEEK_SET); reply = l1_img->file_handle->seek(track_offset, SEEK_SET);
if (reply) if (reply)
return 1; return 1;
/* read remnant of sector */ /* read remnant of sector */
reply = stream_read(l1_img->file_handle, (UINT8 *)dest + (track_len-sector_offset), 256-(track_len-sector_offset)); reply = l1_img->file_handle->read((UINT8 *)dest + (track_len-sector_offset), 256-(track_len-sector_offset));
if (reply != 256-(track_len-sector_offset)) if (reply != 256-(track_len-sector_offset))
return 1; return 1;
} }
@ -1214,11 +1214,11 @@ static int write_sector(ti99_lvl1_imgref *l1_img, const ti99_sector_address *add
case if_v9t9: case if_v9t9:
/* V9T9 format */ /* V9T9 format */
/* seek to sector */ /* seek to sector */
reply = stream_seek(l1_img->file_handle, sector_address_to_image_offset(l1_img, address), SEEK_SET); reply = l1_img->file_handle->seek(sector_address_to_image_offset(l1_img, address), SEEK_SET);
if (reply) if (reply)
return 1; return 1;
/* write it */ /* write it */
reply = stream_write(l1_img->file_handle, src, 256); reply = l1_img->file_handle->write(src, 256);
if (reply != 256) if (reply != 256)
return 1; return 1;
break; break;
@ -1233,31 +1233,31 @@ static int write_sector(ti99_lvl1_imgref *l1_img, const ti99_sector_address *add
if ((sector_offset + 256) <= track_len) if ((sector_offset + 256) <= track_len)
{ {
/* seek to sector */ /* seek to sector */
reply = stream_seek(l1_img->file_handle, track_offset+sector_offset, SEEK_SET); reply = l1_img->file_handle->seek(track_offset+sector_offset, SEEK_SET);
if (reply) if (reply)
return 1; return 1;
/* write it */ /* write it */
reply = stream_write(l1_img->file_handle, src, 256); reply = l1_img->file_handle->write(src, 256);
if (reply != 256) if (reply != 256)
return 1; return 1;
} }
else else
{ {
/* seek to sector */ /* seek to sector */
reply = stream_seek(l1_img->file_handle, track_offset+sector_offset, SEEK_SET); reply = l1_img->file_handle->seek(track_offset+sector_offset, SEEK_SET);
if (reply) if (reply)
return 1; return 1;
/* write first chunk (until end of track) */ /* write first chunk (until end of track) */
reply = stream_write(l1_img->file_handle, (UINT8 *)src, track_len-sector_offset); reply = l1_img->file_handle->write((UINT8 *)src, track_len-sector_offset);
if (reply != track_len-sector_offset) if (reply != track_len-sector_offset)
return 1; return 1;
/* wrap to start of track */ /* wrap to start of track */
reply = stream_seek(l1_img->file_handle, track_offset, SEEK_SET); reply = l1_img->file_handle->seek(track_offset, SEEK_SET);
if (reply) if (reply)
return 1; return 1;
/* write remnant of sector */ /* write remnant of sector */
reply = stream_write(l1_img->file_handle, (UINT8 *)src + (track_len-sector_offset), 256-(track_len-sector_offset)); reply = l1_img->file_handle->write((UINT8 *)src + (track_len-sector_offset), 256-(track_len-sector_offset));
if (reply != 256-(track_len-sector_offset)) if (reply != 256-(track_len-sector_offset))
return 1; return 1;
} }
@ -1723,7 +1723,7 @@ struct ti99_lvl2_fileref_win
struct ti99_lvl2_fileref_tifiles struct ti99_lvl2_fileref_tifiles
{ {
imgtool_stream *file_handle; imgtool::stream *file_handle;
tifile_header hdr; tifile_header hdr;
}; };
@ -2909,11 +2909,11 @@ static int new_file_lvl2_win(struct ti99_lvl2_imgref *l2_img, ti99_catalog *pare
/* /*
Allocate a new (empty) file Allocate a new (empty) file
*/ */
static int new_file_lvl2_tifiles(imgtool_stream *file_handle, struct ti99_lvl2_fileref *l2_file) static int new_file_lvl2_tifiles(imgtool::stream &file_handle, struct ti99_lvl2_fileref *l2_file)
{ {
/* set up file handle */ /* set up file handle */
l2_file->type = L2F_TIFILES; l2_file->type = L2F_TIFILES;
l2_file->tifiles.file_handle = file_handle; l2_file->tifiles.file_handle = &file_handle;
memset(&l2_file->tifiles.hdr, 0, sizeof(l2_file->tifiles.hdr)); memset(&l2_file->tifiles.hdr, 0, sizeof(l2_file->tifiles.hdr));
l2_file->tifiles.hdr.tifiles[0] = '\7'; l2_file->tifiles.hdr.tifiles[0] = '\7';
l2_file->tifiles.hdr.tifiles[1] = 'T'; l2_file->tifiles.hdr.tifiles[1] = 'T';
@ -3087,17 +3087,17 @@ static int open_file_lvl2_win(struct ti99_lvl2_imgref *l2_img, const char *fpath
/* /*
Open an existing file in TIFILES format Open an existing file in TIFILES format
*/ */
static int open_file_lvl2_tifiles(imgtool_stream *file_handle, struct ti99_lvl2_fileref *l2_file) static int open_file_lvl2_tifiles(imgtool::stream &file_handle, struct ti99_lvl2_fileref *l2_file)
{ {
/* set up file handle */ /* set up file handle */
l2_file->type = L2F_TIFILES; l2_file->type = L2F_TIFILES;
l2_file->tifiles.file_handle = file_handle; l2_file->tifiles.file_handle = &file_handle;
/* seek to header */ /* seek to header */
if (stream_seek(l2_file->tifiles.file_handle, 0, SEEK_SET)) if (l2_file->tifiles.file_handle->seek(0, SEEK_SET))
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
/* read it */ /* read it */
if (stream_read(l2_file->tifiles.file_handle, &l2_file->tifiles.hdr, sizeof(l2_file->tifiles.hdr)) != sizeof(l2_file->tifiles.hdr)) if (l2_file->tifiles.file_handle->read(&l2_file->tifiles.hdr, sizeof(l2_file->tifiles.hdr)) != sizeof(l2_file->tifiles.hdr))
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
return 0; return 0;
@ -3242,10 +3242,10 @@ static int read_file_physrec(struct ti99_lvl2_fileref *l2_file, unsigned fphysre
case L2F_TIFILES: case L2F_TIFILES:
/* seek to physrec */ /* seek to physrec */
if (stream_seek(l2_file->tifiles.file_handle, 128+256*fphysrec, SEEK_SET)) if (l2_file->tifiles.file_handle->seek(128+256*fphysrec, SEEK_SET))
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
/* read it */ /* read it */
if (stream_read(l2_file->tifiles.file_handle, dest, 256) != 256) if (l2_file->tifiles.file_handle->read(dest, 256) != 256)
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
break; break;
} }
@ -3285,10 +3285,10 @@ static int write_file_physrec(struct ti99_lvl2_fileref *l2_file, unsigned fphysr
case L2F_TIFILES: case L2F_TIFILES:
/* seek to physrec */ /* seek to physrec */
if (stream_seek(l2_file->tifiles.file_handle, 128+256*fphysrec, SEEK_SET)) if (l2_file->tifiles.file_handle->seek(128+256*fphysrec, SEEK_SET))
return IMGTOOLERR_WRITEERROR; return IMGTOOLERR_WRITEERROR;
/* write it */ /* write it */
if (stream_write(l2_file->tifiles.file_handle, src, 256) != 256) if (l2_file->tifiles.file_handle->write(src, 256) != 256)
return IMGTOOLERR_WRITEERROR; return IMGTOOLERR_WRITEERROR;
break; break;
} }
@ -3848,11 +3848,11 @@ struct win_iterator
}; };
static imgtoolerr_t dsk_image_init_mess(imgtool::image *image, imgtool_stream *f); static imgtoolerr_t dsk_image_init_mess(imgtool::image *image, imgtool::stream &f);
static imgtoolerr_t dsk_image_init_v9t9(imgtool::image *image, imgtool_stream *f); static imgtoolerr_t dsk_image_init_v9t9(imgtool::image *image, imgtool::stream &f);
static imgtoolerr_t dsk_image_init_pc99_fm(imgtool::image *image, imgtool_stream *f); static imgtoolerr_t dsk_image_init_pc99_fm(imgtool::image *image, imgtool::stream &f);
static imgtoolerr_t dsk_image_init_pc99_mfm(imgtool::image *image, imgtool_stream *f); static imgtoolerr_t dsk_image_init_pc99_mfm(imgtool::image *image, imgtool::stream &f);
static imgtoolerr_t win_image_init(imgtool::image *image, imgtool_stream *f); static imgtoolerr_t win_image_init(imgtool::image *image, imgtool::stream &f);
static void ti99_image_exit(imgtool::image *img); static void ti99_image_exit(imgtool::image *img);
static void ti99_image_info(imgtool::image *img, char *string, size_t len); static void ti99_image_info(imgtool::image *img, char *string, size_t len);
static imgtoolerr_t dsk_image_beginenum(imgtool::directory *enumeration, const char *path); static imgtoolerr_t dsk_image_beginenum(imgtool::directory *enumeration, const char *path);
@ -3860,12 +3860,12 @@ static imgtoolerr_t dsk_image_nextenum(imgtool::directory *enumeration, imgtool_
static imgtoolerr_t win_image_beginenum(imgtool::directory *enumeration, const char *path); static imgtoolerr_t win_image_beginenum(imgtool::directory *enumeration, const char *path);
static imgtoolerr_t win_image_nextenum(imgtool::directory *enumeration, imgtool_dirent *ent); static imgtoolerr_t win_image_nextenum(imgtool::directory *enumeration, imgtool_dirent *ent);
static imgtoolerr_t ti99_image_freespace(imgtool::partition *partition, UINT64 *size); static imgtoolerr_t ti99_image_freespace(imgtool::partition *partition, UINT64 *size);
static imgtoolerr_t ti99_image_readfile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool_stream *destf); static imgtoolerr_t ti99_image_readfile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool::stream &destf);
static imgtoolerr_t ti99_image_writefile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool_stream *sourcef, util::option_resolution *writeoptions); static imgtoolerr_t ti99_image_writefile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool::stream &sourcef, util::option_resolution *writeoptions);
static imgtoolerr_t dsk_image_deletefile(imgtool::partition *partition, const char *fpath); static imgtoolerr_t dsk_image_deletefile(imgtool::partition *partition, const char *fpath);
static imgtoolerr_t win_image_deletefile(imgtool::partition *partition, const char *fpath); static imgtoolerr_t win_image_deletefile(imgtool::partition *partition, const char *fpath);
static imgtoolerr_t dsk_image_create_mess(imgtool::image *image, imgtool_stream *f, util::option_resolution *createoptions); static imgtoolerr_t dsk_image_create_mess(imgtool::image *image, imgtool::stream &f, util::option_resolution *createoptions);
static imgtoolerr_t dsk_image_create_v9t9(imgtool::image *image, imgtool_stream *f, util::option_resolution *createoptions); static imgtoolerr_t dsk_image_create_v9t9(imgtool::image *image, imgtool::stream &f, util::option_resolution *createoptions);
enum enum
{ {
@ -3995,7 +3995,7 @@ void ti99_ti99hd_get_info(const imgtool_class *imgclass, UINT32 state, union img
/* /*
Open a file as a ti99_image (common code). Open a file as a ti99_image (common code).
*/ */
static int dsk_image_init(imgtool::image *img, imgtool_stream *f, ti99_img_format img_format) static int dsk_image_init(imgtool::image *img, imgtool::stream &f, ti99_img_format img_format)
{ {
struct ti99_lvl2_imgref *image = (struct ti99_lvl2_imgref *) img->extra_bytes(); struct ti99_lvl2_imgref *image = (struct ti99_lvl2_imgref *) img->extra_bytes();
dsk_vib vib; dsk_vib vib;
@ -4096,7 +4096,7 @@ static int dsk_image_init(imgtool::image *img, imgtool_stream *f, ti99_img_forma
/* /*
Open a file as a ti99_image (MESS format). Open a file as a ti99_image (MESS format).
*/ */
static imgtoolerr_t dsk_image_init_mess(imgtool::image *image, imgtool_stream *f) static imgtoolerr_t dsk_image_init_mess(imgtool::image *image, imgtool::stream &f)
{ {
return (imgtoolerr_t)dsk_image_init(image, f, if_mess); return (imgtoolerr_t)dsk_image_init(image, f, if_mess);
} }
@ -4104,7 +4104,7 @@ static imgtoolerr_t dsk_image_init_mess(imgtool::image *image, imgtool_stream *f
/* /*
Open a file as a ti99_image (V9T9 format). Open a file as a ti99_image (V9T9 format).
*/ */
static imgtoolerr_t dsk_image_init_v9t9(imgtool::image *image, imgtool_stream *f) static imgtoolerr_t dsk_image_init_v9t9(imgtool::image *image, imgtool::stream &f)
{ {
return (imgtoolerr_t)dsk_image_init(image, f, if_v9t9); return (imgtoolerr_t)dsk_image_init(image, f, if_v9t9);
} }
@ -4112,7 +4112,7 @@ static imgtoolerr_t dsk_image_init_v9t9(imgtool::image *image, imgtool_stream *f
/* /*
Open a file as a ti99_image (PC99 FM format). Open a file as a ti99_image (PC99 FM format).
*/ */
static imgtoolerr_t dsk_image_init_pc99_fm(imgtool::image *image, imgtool_stream *f) static imgtoolerr_t dsk_image_init_pc99_fm(imgtool::image *image, imgtool::stream &f)
{ {
return (imgtoolerr_t)dsk_image_init(image, f, if_pc99_fm); return (imgtoolerr_t)dsk_image_init(image, f, if_pc99_fm);
} }
@ -4120,7 +4120,7 @@ static imgtoolerr_t dsk_image_init_pc99_fm(imgtool::image *image, imgtool_stream
/* /*
Open a file as a ti99_image (PC99 MFM format). Open a file as a ti99_image (PC99 MFM format).
*/ */
static imgtoolerr_t dsk_image_init_pc99_mfm(imgtool::image *image, imgtool_stream *f) static imgtoolerr_t dsk_image_init_pc99_mfm(imgtool::image *image, imgtool::stream &f)
{ {
return (imgtoolerr_t)dsk_image_init(image, f, if_pc99_mfm); return (imgtoolerr_t)dsk_image_init(image, f, if_pc99_mfm);
} }
@ -4128,7 +4128,7 @@ static imgtoolerr_t dsk_image_init_pc99_mfm(imgtool::image *image, imgtool_strea
/* /*
Open a file as a ti99_image (harddisk format). Open a file as a ti99_image (harddisk format).
*/ */
static imgtoolerr_t win_image_init(imgtool::image *img, imgtool_stream *f) static imgtoolerr_t win_image_init(imgtool::image *img, imgtool::stream &f)
{ {
struct ti99_lvl2_imgref *image = (struct ti99_lvl2_imgref *) img->extra_bytes(); struct ti99_lvl2_imgref *image = (struct ti99_lvl2_imgref *) img->extra_bytes();
win_vib_ddr vib; win_vib_ddr vib;
@ -4502,7 +4502,7 @@ static imgtoolerr_t ti99_image_freespace(imgtool::partition *partition, UINT64 *
/* /*
Extract a file from a ti99_image. The file is saved in tifile format. Extract a file from a ti99_image. The file is saved in tifile format.
*/ */
static imgtoolerr_t ti99_image_readfile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool_stream *destf) static imgtoolerr_t ti99_image_readfile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool::stream &destf)
{ {
imgtool::image *img = &partition->image(); imgtool::image *img = &partition->image();
#if 1 #if 1
@ -4574,7 +4574,7 @@ static imgtoolerr_t ti99_image_readfile(imgtool::partition *partition, const cha
#endif #endif
set_file_update_date(&dst_file, date_time); set_file_update_date(&dst_file, date_time);
if (stream_write(destf, & dst_file.tifiles.hdr, 128) != 128) if (destf.write(& dst_file.tifiles.hdr, 128) != 128)
return (imgtoolerr_t)IMGTOOLERR_WRITEERROR; return (imgtoolerr_t)IMGTOOLERR_WRITEERROR;
/* copy data to TIFILE */ /* copy data to TIFILE */
@ -4630,9 +4630,9 @@ static imgtoolerr_t ti99_image_readfile(imgtool::partition *partition, const cha
errorcode = read_next_record(& src_file, buf, & reclen); errorcode = read_next_record(& src_file, buf, & reclen);
if (errorcode) if (errorcode)
return errorcode; return errorcode;
if (stream_write(destf, buf, reclen) != reclen) if (destf.write(buf, reclen) != reclen)
return IMGTOOLERR_WRITEERROR; return IMGTOOLERR_WRITEERROR;
if (stream_write(destf, &lineend, 1) != 1) if (destf.write(&lineend, 1) != 1)
return IMGTOOLERR_WRITEERROR; return IMGTOOLERR_WRITEERROR;
} }
@ -4644,7 +4644,7 @@ static imgtoolerr_t ti99_image_readfile(imgtool::partition *partition, const cha
/* /*
Add a file to a ti99_image. The file must be in tifile format. Add a file to a ti99_image. The file must be in tifile format.
*/ */
static imgtoolerr_t ti99_image_writefile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool_stream *sourcef, util::option_resolution *writeoptions) static imgtoolerr_t ti99_image_writefile(imgtool::partition *partition, const char *fpath, const char *fork, imgtool::stream &sourcef, util::option_resolution *writeoptions)
{ {
imgtool::image *img = &partition->image(); imgtool::image *img = &partition->image();
struct ti99_lvl2_imgref *image = (struct ti99_lvl2_imgref *) img->extra_bytes(); struct ti99_lvl2_imgref *image = (struct ti99_lvl2_imgref *) img->extra_bytes();
@ -4766,7 +4766,7 @@ static imgtoolerr_t ti99_image_writefile(imgtool::partition *partition, const ch
/* copy data */ /* copy data */
for (i=0; i<fphysrecs; i++) for (i=0; i<fphysrecs; i++)
{ {
if (stream_read(sourcef, buf, 256) != 256) if (sourcef.read(buf, 256) != 256)
return (imgtoolerr_t)IMGTOOLERR_READERROR; return (imgtoolerr_t)IMGTOOLERR_READERROR;
errorcode = (imgtoolerr_t)write_file_physrec(& dst_file, i, buf); errorcode = (imgtoolerr_t)write_file_physrec(& dst_file, i, buf);
@ -5226,7 +5226,7 @@ static imgtoolerr_t win_image_deletefile(imgtool::partition *partition, const ch
Supports MESS and V9T9 formats only Supports MESS and V9T9 formats only
*/ */
static imgtoolerr_t dsk_image_create(imgtool::image *image, imgtool_stream *f, util::option_resolution *createoptions, ti99_img_format img_format) static imgtoolerr_t dsk_image_create(imgtool::image *image, imgtool::stream &f, util::option_resolution *createoptions, ti99_img_format img_format)
{ {
const char *volname; const char *volname;
int density; int density;
@ -5241,7 +5241,7 @@ static imgtoolerr_t dsk_image_create(imgtool::image *image, imgtool_stream *f, u
int i; int i;
l1_img.img_format = img_format; l1_img.img_format = img_format;
l1_img.file_handle = f; l1_img.file_handle = &f;
/* read options */ /* read options */
volname = createoptions->lookup_string(dsk_createopts_volname).c_str(); volname = createoptions->lookup_string(dsk_createopts_volname).c_str();
@ -5346,7 +5346,7 @@ static imgtoolerr_t dsk_image_create(imgtool::image *image, imgtool_stream *f, u
/* /*
Create a blank ti99_image (MESS format). Create a blank ti99_image (MESS format).
*/ */
static imgtoolerr_t dsk_image_create_mess(imgtool::image *image, imgtool_stream *f, util::option_resolution *createoptions) static imgtoolerr_t dsk_image_create_mess(imgtool::image *image, imgtool::stream &f, util::option_resolution *createoptions)
{ {
return dsk_image_create(image, f, createoptions, if_mess); return dsk_image_create(image, f, createoptions, if_mess);
} }
@ -5354,7 +5354,7 @@ static imgtoolerr_t dsk_image_create_mess(imgtool::image *image, imgtool_stream
/* /*
Create a blank ti99_image (V9T9 format). Create a blank ti99_image (V9T9 format).
*/ */
static imgtoolerr_t dsk_image_create_v9t9(imgtool::image *image, imgtool_stream *f, util::option_resolution *createoptions) static imgtoolerr_t dsk_image_create_v9t9(imgtool::image *image, imgtool::stream &f, util::option_resolution *createoptions)
{ {
return dsk_image_create(image, f, createoptions, if_v9t9); return dsk_image_create(image, f, createoptions, if_v9t9);
} }

View File

@ -368,7 +368,7 @@ struct ti990_phys_sec_address
*/ */
struct ti990_image struct ti990_image
{ {
imgtool_stream *file_handle; /* imgtool file handle */ imgtool::stream *file_handle; /* imgtool file handle */
ti990_geometry geometry; /* geometry */ ti990_geometry geometry; /* geometry */
ti990_sc0 sec0; /* cached copy of sector 0 */ ti990_sc0 sec0; /* cached copy of sector 0 */
}; };
@ -386,7 +386,7 @@ struct ti990_iterator
}; };
static imgtoolerr_t ti990_image_init(imgtool::image *img, imgtool_stream *f); static imgtoolerr_t ti990_image_init(imgtool::image *img, imgtool::stream &f);
static void ti990_image_exit(imgtool::image *img); static void ti990_image_exit(imgtool::image *img);
static void ti990_image_info(imgtool::image *img, char *string, size_t len); static void ti990_image_info(imgtool::image *img, char *string, size_t len);
static imgtoolerr_t ti990_image_beginenum(imgtool::directory *enumeration, const char *path); static imgtoolerr_t ti990_image_beginenum(imgtool::directory *enumeration, const char *path);
@ -394,11 +394,11 @@ static imgtoolerr_t ti990_image_nextenum(imgtool::directory *enumeration, imgtoo
static void ti990_image_closeenum(imgtool::directory *enumeration); static void ti990_image_closeenum(imgtool::directory *enumeration);
static imgtoolerr_t ti990_image_freespace(imgtool::partition *partition, UINT64 *size); static imgtoolerr_t ti990_image_freespace(imgtool::partition *partition, UINT64 *size);
#ifdef UNUSED_FUNCTION #ifdef UNUSED_FUNCTION
static imgtoolerr_t ti990_image_readfile(imgtool::partition *partition, const char *fpath, imgtool_stream *destf); static imgtoolerr_t ti990_image_readfile(imgtool::partition *partition, const char *fpath, imgtool::stream *destf);
static imgtoolerr_t ti990_image_writefile(imgtool::partition *partition, const char *fpath, imgtool_stream *sourcef, util::option_resolution *writeoptions); static imgtoolerr_t ti990_image_writefile(imgtool::partition *partition, const char *fpath, imgtool::stream *sourcef, util::option_resolution *writeoptions);
static imgtoolerr_t ti990_image_deletefile(imgtool::partition *partition, const char *fpath); static imgtoolerr_t ti990_image_deletefile(imgtool::partition *partition, const char *fpath);
#endif #endif
static imgtoolerr_t ti990_image_create(imgtool::image *image, imgtool_stream *f, util::option_resolution *createoptions); static imgtoolerr_t ti990_image_create(imgtool::image *image, imgtool::stream &f, util::option_resolution *createoptions);
enum enum
{ {
@ -531,7 +531,7 @@ static unsigned phys_address_to_offset(const ti990_phys_sec_address *address, co
dest: pointer to destination buffer dest: pointer to destination buffer
len: length of data to read len: length of data to read
*/ */
static int read_sector_physical_len(imgtool_stream *file_handle, const ti990_phys_sec_address *address, const ti990_geometry *geometry, void *dest, int len) static int read_sector_physical_len(imgtool::stream &file_handle, const ti990_phys_sec_address *address, const ti990_geometry *geometry, void *dest, int len)
{ {
int reply; int reply;
@ -539,11 +539,11 @@ static int read_sector_physical_len(imgtool_stream *file_handle, const ti990_phy
return 1; return 1;
/* seek to sector */ /* seek to sector */
reply = stream_seek(file_handle, phys_address_to_offset(address, geometry), SEEK_SET); reply = file_handle.seek(phys_address_to_offset(address, geometry), SEEK_SET);
if (reply) if (reply)
return 1; return 1;
/* read it */ /* read it */
reply = stream_read(file_handle, dest, len); reply = file_handle.read(dest, len);
if (reply != len) if (reply != len)
return 1; return 1;
@ -559,7 +559,7 @@ static int read_sector_physical_len(imgtool_stream *file_handle, const ti990_phy
geometry: disk geometry (sectors per track, tracks per side, sides) geometry: disk geometry (sectors per track, tracks per side, sides)
dest: pointer to a destination buffer of geometry->bytes_per_sector bytes dest: pointer to a destination buffer of geometry->bytes_per_sector bytes
*/ */
static int read_sector_physical(imgtool_stream *file_handle, const ti990_phys_sec_address *address, const ti990_geometry *geometry, void *dest) static int read_sector_physical(imgtool::stream *file_handle, const ti990_phys_sec_address *address, const ti990_geometry *geometry, void *dest)
{ {
return read_sector_physical_len(file_handle, address, geometry, dest, geometry->bytes_per_sector); return read_sector_physical_len(file_handle, address, geometry, dest, geometry->bytes_per_sector);
} }
@ -574,7 +574,7 @@ static int read_sector_physical(imgtool_stream *file_handle, const ti990_phys_se
src: pointer to source buffer src: pointer to source buffer
len: length of source buffer len: length of source buffer
*/ */
static int write_sector_physical_len(imgtool_stream *file_handle, const ti990_phys_sec_address *address, const ti990_geometry *geometry, const void *src, int len) static int write_sector_physical_len(imgtool::stream &file_handle, const ti990_phys_sec_address *address, const ti990_geometry *geometry, const void *src, int len)
{ {
int reply; int reply;
@ -582,17 +582,17 @@ static int write_sector_physical_len(imgtool_stream *file_handle, const ti990_ph
return 1; return 1;
/* seek to sector */ /* seek to sector */
reply = stream_seek(file_handle, phys_address_to_offset(address, geometry), SEEK_SET); reply = file_handle.seek(phys_address_to_offset(address, geometry), SEEK_SET);
if (reply) if (reply)
return 1; return 1;
/* write it */ /* write it */
reply = stream_write(file_handle, src, len); reply = file_handle.write(src, len);
if (reply != len) if (reply != len)
return 1; return 1;
/* pad with 0s if needed */ /* pad with 0s if needed */
if (len < geometry->bytes_per_sector) if (len < geometry->bytes_per_sector)
{ {
reply = stream_fill(file_handle, 0, geometry->bytes_per_sector - len); reply = file_handle.fill(0, geometry->bytes_per_sector - len);
if (reply != geometry->bytes_per_sector - len) if (reply != geometry->bytes_per_sector - len)
return 1; return 1;
@ -610,7 +610,7 @@ static int write_sector_physical_len(imgtool_stream *file_handle, const ti990_ph
geometry: disk geometry (sectors per track, tracks per side, sides) geometry: disk geometry (sectors per track, tracks per side, sides)
dest: pointer to a source buffer of geometry->bytes_per_sector bytes dest: pointer to a source buffer of geometry->bytes_per_sector bytes
*/ */
static int write_sector_physical(imgtool_stream *file_handle, const ti990_phys_sec_address *address, const ti990_geometry *geometry, const void *src) static int write_sector_physical(imgtool::stream *file_handle, const ti990_phys_sec_address *address, const ti990_geometry *geometry, const void *src)
{ {
return write_sector_physical_len(file_handle, address, geometry, src, geometry->bytes_per_sector); return write_sector_physical_len(file_handle, address, geometry, src, geometry->bytes_per_sector);
} }
@ -636,7 +636,7 @@ static void log_address_to_phys_address(int secnum, const ti990_geometry *geomet
dest: pointer to destination buffer dest: pointer to destination buffer
len: length of data to read len: length of data to read
*/ */
static int read_sector_logical_len(imgtool_stream *file_handle, int secnum, const ti990_geometry *geometry, void *dest, int len) static int read_sector_logical_len(imgtool::stream &file_handle, int secnum, const ti990_geometry *geometry, void *dest, int len)
{ {
ti990_phys_sec_address address; ti990_phys_sec_address address;
@ -655,7 +655,7 @@ static int read_sector_logical_len(imgtool_stream *file_handle, int secnum, cons
geometry: disk geometry (sectors per track, tracks per side, sides) geometry: disk geometry (sectors per track, tracks per side, sides)
dest: pointer to a destination buffer of geometry->bytes_per_sector bytes dest: pointer to a destination buffer of geometry->bytes_per_sector bytes
*/ */
static int read_sector_logical(imgtool_stream *file_handle, int secnum, const ti990_geometry *geometry, void *dest) static int read_sector_logical(imgtool::stream *file_handle, int secnum, const ti990_geometry *geometry, void *dest)
{ {
return read_sector_logical_len(file_handle, secnum, geometry, dest, geometry->bytes_per_sector); return read_sector_logical_len(file_handle, secnum, geometry, dest, geometry->bytes_per_sector);
} }
@ -670,7 +670,7 @@ static int read_sector_logical(imgtool_stream *file_handle, int secnum, const ti
src: pointer to source buffer src: pointer to source buffer
len: length of source buffer len: length of source buffer
*/ */
static int write_sector_logical_len(imgtool_stream *file_handle, int secnum, const ti990_geometry *geometry, const void *src, int len) static int write_sector_logical_len(imgtool::stream &file_handle, int secnum, const ti990_geometry *geometry, const void *src, int len)
{ {
ti990_phys_sec_address address; ti990_phys_sec_address address;
@ -688,7 +688,7 @@ static int write_sector_logical_len(imgtool_stream *file_handle, int secnum, con
geometry: disk geometry (sectors per track, tracks per side, sides) geometry: disk geometry (sectors per track, tracks per side, sides)
dest: pointer to a source buffer of geometry->bytes_per_sector bytes dest: pointer to a source buffer of geometry->bytes_per_sector bytes
*/ */
static int write_sector_logical(imgtool_stream *file_handle, int secnum, const ti990_geometry *geometry, const void *src) static int write_sector_logical(imgtool::stream &file_handle, int secnum, const ti990_geometry *geometry, const void *src)
{ {
return write_sector_logical_len(file_handle, secnum, geometry, src, geometry->bytes_per_sector); return write_sector_logical_len(file_handle, secnum, geometry, src, geometry->bytes_per_sector);
} }
@ -1106,15 +1106,15 @@ static int qsort_catalog_compare(const void *p1, const void *p2)
/* /*
Open a file as a ti990_image. Open a file as a ti990_image.
*/ */
static imgtoolerr_t ti990_image_init(imgtool::image *img, imgtool_stream *f) static imgtoolerr_t ti990_image_init(imgtool::image *img, imgtool::stream &f)
{ {
ti990_image *image = (ti990_image *) img->extra_bytes(); ti990_image *image = (ti990_image *) img->extra_bytes();
disk_image_header header; disk_image_header header;
int reply; int reply;
unsigned totsecs; unsigned totsecs;
image->file_handle = f; image->file_handle = &f;
reply = stream_read(f, &header, sizeof(header)); reply = f.read(&header, sizeof(header));
if (reply != sizeof(header)) if (reply != sizeof(header))
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
@ -1131,7 +1131,7 @@ static imgtoolerr_t ti990_image_init(imgtool::image *img, imgtool_stream *f)
|| (image->geometry.heads > MAX_HEADS) || (image->geometry.heads > MAX_HEADS)
|| (image->geometry.cylinders > MAX_CYLINDERS) || (image->geometry.cylinders > MAX_CYLINDERS)
|| (totsecs < 1) || (totsecs < 1)
|| (stream_size(f) != header_len + totsecs*image->geometry.bytes_per_sector)) || (f.size() != header_len + totsecs*image->geometry.bytes_per_sector))
{ {
return IMGTOOLERR_CORRUPTIMAGE; return IMGTOOLERR_CORRUPTIMAGE;
} }
@ -1165,7 +1165,7 @@ static imgtoolerr_t ti990_image_init(imgtool::image *img, imgtool_stream *f)
static void ti990_image_exit(imgtool::image *img) static void ti990_image_exit(imgtool::image *img)
{ {
ti990_image *image = (ti990_image *) img->extra_bytes(); ti990_image *image = (ti990_image *) img->extra_bytes();
stream_close(image->file_handle); delete image->file_handle;
} }
/* /*
@ -1195,7 +1195,7 @@ static imgtoolerr_t ti990_image_beginenum(imgtool::directory *enumeration, const
iter->image = image; iter->image = image;
reply = read_sector_logical_len(iter->image->file_handle, reply = read_sector_logical_len(*iter->image->file_handle,
(unsigned) get_UINT16BE(iter->image->sec0.vda) * get_UINT16BE(iter->image->sec0.spa), (unsigned) get_UINT16BE(iter->image->sec0.vda) * get_UINT16BE(iter->image->sec0.spa),
& iter->image->geometry, &dor, sizeof(dor)); & iter->image->geometry, &dor, sizeof(dor));
@ -1223,7 +1223,7 @@ static imgtoolerr_t ti990_image_nextenum(imgtool::directory *enumeration, imgtoo
ent->eof = 0; ent->eof = 0;
while ((iter->level >= 0) while ((iter->level >= 0)
&& (! (reply = read_sector_logical_len(iter->image->file_handle, && (! (reply = read_sector_logical_len(*iter->image->file_handle,
iter->level ? (unsigned) get_UINT16BE(iter->xdr[iter->level-1].fdr.paa) * get_UINT16BE(iter->image->sec0.spa) + (iter->index[iter->level]+1) iter->level ? (unsigned) get_UINT16BE(iter->xdr[iter->level-1].fdr.paa) * get_UINT16BE(iter->image->sec0.spa) + (iter->index[iter->level]+1)
: (unsigned) get_UINT16BE(iter->image->sec0.vda) * get_UINT16BE(iter->image->sec0.spa) + (iter->index[iter->level]+1), : (unsigned) get_UINT16BE(iter->image->sec0.vda) * get_UINT16BE(iter->image->sec0.spa) + (iter->index[iter->level]+1),
& iter->image->geometry, &iter->xdr[iter->level], & iter->image->geometry, &iter->xdr[iter->level],
@ -1276,7 +1276,7 @@ static imgtoolerr_t ti990_image_nextenum(imgtool::directory *enumeration, imgtoo
ti990_fdr target_fdr; ti990_fdr target_fdr;
char buf[9]; char buf[9];
reply = read_sector_logical_len(iter->image->file_handle, reply = read_sector_logical_len(*iter->image->file_handle,
iter->level ? ((unsigned) get_UINT16BE(iter->xdr[iter->level-1].fdr.paa) * get_UINT16BE(iter->image->sec0.spa) + get_UINT16BE(iter->xdr[iter->level].adr.raf)) iter->level ? ((unsigned) get_UINT16BE(iter->xdr[iter->level-1].fdr.paa) * get_UINT16BE(iter->image->sec0.spa) + get_UINT16BE(iter->xdr[iter->level].adr.raf))
: ((unsigned) get_UINT16BE(iter->image->sec0.vda) * get_UINT16BE(iter->image->sec0.spa) + get_UINT16BE(iter->xdr[iter->level].adr.raf)), : ((unsigned) get_UINT16BE(iter->image->sec0.vda) * get_UINT16BE(iter->image->sec0.spa) + get_UINT16BE(iter->xdr[iter->level].adr.raf)),
& iter->image->geometry, &target_fdr, & iter->image->geometry, &target_fdr,
@ -1382,7 +1382,7 @@ static imgtoolerr_t ti990_image_nextenum(imgtool::directory *enumeration, imgtoo
if (get_UINT16BE(iter->xdr[iter->level].fdr.saa) != 0) if (get_UINT16BE(iter->xdr[iter->level].fdr.saa) != 0)
printf("ninou"); printf("ninou");
read_sector_logical_len(iter->image->file_handle, read_sector_logical_len(*iter->image->file_handle,
get_UINT16BE(iter->xdr[iter->level].fdr.paa) * get_UINT16BE(iter->image->sec0.spa), get_UINT16BE(iter->xdr[iter->level].fdr.paa) * get_UINT16BE(iter->image->sec0.spa),
& iter->image->geometry, &dor, sizeof(dor)); & iter->image->geometry, &dor, sizeof(dor));
@ -1431,7 +1431,7 @@ static imgtoolerr_t ti990_image_freespace(imgtool::partition *partition, UINT64
sub_adu = 0; sub_adu = 0;
while (adu<totadus) while (adu<totadus)
{ {
read_sector_logical_len(image->file_handle, image->sec0.sbm + record, &image->geometry, buf, sizeof(buf)); read_sector_logical_len(*image->file_handle, image->sec0.sbm + record, &image->geometry, buf, sizeof(buf));
while ((adu < totadus) && (sub_adu < 2032)) while ((adu < totadus) && (sub_adu < 2032))
{ {
@ -1453,7 +1453,7 @@ static imgtoolerr_t ti990_image_freespace(imgtool::partition *partition, UINT64
/* /*
Extract a file from a ti990_image. Extract a file from a ti990_image.
*/ */
static imgtoolerr_t ti990_image_readfile(imgtool::partition *partition, const char *fpath, imgtool_stream *destf) static imgtoolerr_t ti990_image_readfile(imgtool::partition *partition, const char *fpath, imgtool::stream *destf)
{ {
imgtool::image *img = &partition->image(); imgtool::image *img = &partition->image();
ti990_image *image = (ti990_image *) img->extra_bytes(); ti990_image *image = (ti990_image *) img->extra_bytes();
@ -1506,7 +1506,7 @@ static imgtoolerr_t ti990_image_readfile(imgtool::partition *partition, const ch
for (i=0; i<(128-14); i++) for (i=0; i<(128-14); i++)
dst_header.res[i] = 0; dst_header.res[i] = 0;
if (stream_write(destf, & dst_header, 128) != 128) if (destf->write(& dst_header, 128) != 128)
return IMGTOOLERR_WRITEERROR; return IMGTOOLERR_WRITEERROR;
@ -1532,7 +1532,7 @@ static imgtoolerr_t ti990_image_readfile(imgtool::partition *partition, const ch
if (read_sector_logical(image->file_handle, cur_sec, & image->geometry, buf)) if (read_sector_logical(image->file_handle, cur_sec, & image->geometry, buf))
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
if (stream_write(destf, buf, 256) != 256) if (destf->write(buf, 256) != 256)
return IMGTOOLERR_WRITEERROR; return IMGTOOLERR_WRITEERROR;
i++; i++;
@ -1550,7 +1550,7 @@ static imgtoolerr_t ti990_image_readfile(imgtool::partition *partition, const ch
/* /*
Add a file to a ti990_image. Add a file to a ti990_image.
*/ */
static imgtoolerr_t ti990_image_writefile(imgtool::partition *partition, const char *fpath, imgtool_stream *sourcef, util::option_resolution *writeoptions) static imgtoolerr_t ti990_image_writefile(imgtool::partition *partition, const char *fpath, imgtool::stream *sourcef, util::option_resolution *writeoptions)
{ {
imgtool::image *img = &partition->image(); imgtool::image *img = &partition->image();
ti990_image *image = (ti990_image *) img->extra_bytes(); ti990_image *image = (ti990_image *) img->extra_bytes();
@ -1592,7 +1592,7 @@ static imgtoolerr_t ti990_image_writefile(imgtool::partition *partition, const c
return reply; return reply;
} }
if (stream_read(sourcef, & src_header, 128) != 128) if (sourcef->read(& src_header, 128) != 128)
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
/* create new file */ /* create new file */
@ -1637,7 +1637,7 @@ static imgtoolerr_t ti990_image_writefile(imgtool::partition *partition, const c
if (cur_sec >= totsecs) if (cur_sec >= totsecs)
return IMGTOOLERR_CORRUPTIMAGE; return IMGTOOLERR_CORRUPTIMAGE;
if (stream_read(sourcef, buf, 256) != 256) if (sourcef->read(buf, 256) != 256)
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
if (write_sector_logical(image->file_handle, cur_sec, & image->geometry, buf)) if (write_sector_logical(image->file_handle, cur_sec, & image->geometry, buf))
@ -1764,7 +1764,7 @@ static imgtoolerr_t ti990_image_deletefile(imgtool::partition *partition, const
/* /*
Create a blank ti990_image. Create a blank ti990_image.
*/ */
static imgtoolerr_t ti990_image_create(imgtool::image *image, imgtool_stream *f, util::option_resolution *createoptions) static imgtoolerr_t ti990_image_create(imgtool::image *image, imgtool::stream &f, util::option_resolution *createoptions)
{ {
//const char *volname; //const char *volname;
ti990_geometry geometry; ti990_geometry geometry;
@ -1790,7 +1790,7 @@ static imgtoolerr_t ti990_image_create(imgtool::image *image, imgtool_stream *f,
set_UINT32BE(& header.sectors_per_track, geometry.sectors_per_track); set_UINT32BE(& header.sectors_per_track, geometry.sectors_per_track);
set_UINT32BE(& header.bytes_per_sector, geometry.bytes_per_sector); set_UINT32BE(& header.bytes_per_sector, geometry.bytes_per_sector);
reply = stream_write(f, &header, sizeof(header)); reply = f.write(&header, sizeof(header));
if (reply != sizeof(header)) if (reply != sizeof(header))
{ {
return IMGTOOLERR_WRITEERROR; return IMGTOOLERR_WRITEERROR;

View File

@ -478,7 +478,7 @@ static imgtoolerr_t vzdos_diskimage_freespace(imgtool::partition *partition, UIN
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
static imgtoolerr_t vzdos_diskimage_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *destf) static imgtoolerr_t vzdos_diskimage_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{ {
imgtoolerr_t ret; imgtoolerr_t ret;
imgtool::image *image = &partition->image(); imgtool::image *image = &partition->image();
@ -514,7 +514,7 @@ static imgtoolerr_t vzdos_diskimage_readfile(imgtool::partition *partition, cons
/* write either DATA_SIZE or the remaining bytes */ /* write either DATA_SIZE or the remaining bytes */
towrite = filesize > DATA_SIZE ? DATA_SIZE : filesize; towrite = filesize > DATA_SIZE ? DATA_SIZE : filesize;
if (stream_write(destf, buffer, towrite) != towrite) if (destf.write(buffer, towrite) != towrite)
return IMGTOOLERR_WRITEERROR; return IMGTOOLERR_WRITEERROR;
filesize -= DATA_SIZE; filesize -= DATA_SIZE;
@ -602,7 +602,7 @@ static imgtoolerr_t vzdos_diskimage_deletefile(imgtool::partition *partition, co
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
static imgtoolerr_t vzdos_writefile(imgtool::partition *partition, int offset, imgtool_stream *sourcef, vzdos_dirent *entry) static imgtoolerr_t vzdos_writefile(imgtool::partition *partition, int offset, imgtool::stream &sourcef, vzdos_dirent *entry)
{ {
imgtoolerr_t ret; imgtoolerr_t ret;
imgtool::image *img = &partition->image(); imgtool::image *img = &partition->image();
@ -629,11 +629,11 @@ static imgtoolerr_t vzdos_writefile(imgtool::partition *partition, int offset, i
return ret; return ret;
} }
ret = (imgtoolerr_t)stream_seek(sourcef, offset, SEEK_SET); ret = (imgtoolerr_t) sourcef.seek(offset, SEEK_SET);
if (ret) return ret; if (ret) return ret;
/* check if there is enough space */ /* check if there is enough space */
filesize = stream_size(sourcef) - offset; filesize = sourcef.size() - offset;
ret = vzdos_diskimage_freespace(partition, &freespace); ret = vzdos_diskimage_freespace(partition, &freespace);
if (ret) return ret; if (ret) return ret;
@ -668,7 +668,7 @@ static imgtoolerr_t vzdos_writefile(imgtool::partition *partition, int offset, i
/* write data to disk */ /* write data to disk */
while (filesize > 0) { while (filesize > 0) {
toread = filesize > DATA_SIZE ? DATA_SIZE : filesize; toread = filesize > DATA_SIZE ? DATA_SIZE : filesize;
stream_read(sourcef, buffer, toread); sourcef.read(buffer, toread);
filesize -= toread; filesize -= toread;
@ -700,7 +700,7 @@ static imgtoolerr_t vzdos_writefile(imgtool::partition *partition, int offset, i
} }
/* create a new file or overwrite a file */ /* create a new file or overwrite a file */
static imgtoolerr_t vzdos_diskimage_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) static imgtoolerr_t vzdos_diskimage_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{ {
imgtoolerr_t ret; imgtoolerr_t ret;
int ftype; int ftype;
@ -789,7 +789,7 @@ static imgtoolerr_t vzdos_diskimage_suggesttransfer(imgtool::partition *partitio
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
static imgtoolerr_t vzdos_diskimage_create(imgtool::image *img, imgtool_stream *stream, util::option_resolution *opts) static imgtoolerr_t vzdos_diskimage_create(imgtool::image *img, imgtool::stream &stream, util::option_resolution *opts)
{ {
imgtoolerr_t ret; imgtoolerr_t ret;
int track, sector; int track, sector;
@ -808,7 +808,7 @@ static imgtoolerr_t vzdos_diskimage_create(imgtool::image *img, imgtool_stream *
Imgtool vz filter code Imgtool vz filter code
*********************************************************************/ *********************************************************************/
static imgtoolerr_t vzsnapshot_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *destf) static imgtoolerr_t vzsnapshot_readfile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &destf)
{ {
imgtoolerr_t ret; imgtoolerr_t ret;
imgtool::image *image = &partition->image(); imgtool::image *image = &partition->image();
@ -843,7 +843,7 @@ static imgtoolerr_t vzsnapshot_readfile(imgtool::partition *partition, const cha
place_integer_le(header, 22, 2, entry.start_address); place_integer_le(header, 22, 2, entry.start_address);
/* write header to file */ /* write header to file */
stream_write(destf, header, sizeof(header)); destf.write(header, sizeof(header));
/* write data to file */ /* write data to file */
ret = vzdos_diskimage_readfile(partition, filename, "", destf); ret = vzdos_diskimage_readfile(partition, filename, "", destf);
@ -852,7 +852,7 @@ static imgtoolerr_t vzsnapshot_readfile(imgtool::partition *partition, const cha
return IMGTOOLERR_SUCCESS; return IMGTOOLERR_SUCCESS;
} }
static imgtoolerr_t vzsnapshot_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool_stream *sourcef, util::option_resolution *opts) static imgtoolerr_t vzsnapshot_writefile(imgtool::partition *partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{ {
imgtoolerr_t ret; imgtoolerr_t ret;
int fnameopt; int fnameopt;
@ -860,7 +860,7 @@ static imgtoolerr_t vzsnapshot_writefile(imgtool::partition *partition, const ch
UINT8 header[24]; UINT8 header[24];
/* get header infos from file */ /* get header infos from file */
stream_read(sourcef, header, sizeof(header)); sourcef.read(header, sizeof(header));
/* prepare directory entry */ /* prepare directory entry */
entry.ftype = header[21] == 0xF1 ? 'B' : 'T'; entry.ftype = header[21] == 0xF1 ? 'B' : 'T';

View File

@ -2,7 +2,7 @@
// copyright-holders:Nathan Woods // copyright-holders:Nathan Woods
/*************************************************************************** /***************************************************************************
stream.c stream.cpp
Code for implementing Imgtool streams Code for implementing Imgtool streams
@ -16,80 +16,87 @@
#include "osdcore.h" #include "osdcore.h"
#include "imgtool.h" #include "imgtool.h"
enum imgtype_t
//-------------------------------------------------
// ctor
//-------------------------------------------------
imgtool::stream::stream(bool wp)
: imgtype(IMG_FILE)
, write_protect(wp)
, name(nullptr)
, position(0)
, filesize(0)
, file()
, buffer(nullptr)
{ {
IMG_FILE, }
IMG_MEM
};
struct imgtool_stream
//-------------------------------------------------
// ctor
//-------------------------------------------------
imgtool::stream::stream(bool wp, util::core_file::ptr &&f)
: imgtype(IMG_FILE)
, write_protect(wp)
, name(nullptr)
, position(0)
, filesize(f->size())
, file(std::move(f))
, buffer(nullptr)
{ {
typedef std::unique_ptr<imgtool_stream> ptr; }
imgtool_stream(bool wp)
: imgtype(IMG_FILE)
, write_protect(wp)
, name(nullptr)
, position(0)
, filesize(0)
, file()
, buffer(nullptr)
{
}
imgtool_stream( //-------------------------------------------------
bool wp, // ctor
util::core_file::ptr &&f) //-------------------------------------------------
: imgtype(IMG_FILE)
, write_protect(wp)
, name(nullptr)
, position(0)
, filesize(f->size())
, file(std::move(f))
, buffer(nullptr)
{
}
imgtool_stream(bool wp, std::size_t size) imgtool::stream::stream(bool wp, std::size_t size)
: imgtype(IMG_MEM) : imgtype(IMG_MEM)
, write_protect(wp) , write_protect(wp)
, name(nullptr) , name(nullptr)
, position(0) , position(0)
, filesize(size) , filesize(size)
, file() , file()
, buffer(reinterpret_cast<std::uint8_t *>(malloc(size))) , buffer(reinterpret_cast<std::uint8_t *>(malloc(size)))
{ {
} }
imgtool_stream(bool wp, std::size_t size, void *buf)
: imgtype(IMG_MEM)
, write_protect(wp)
, name(nullptr)
, position(0)
, filesize(size)
, file()
, buffer(reinterpret_cast<std::uint8_t *>(buf))
{
}
~imgtool_stream() //-------------------------------------------------
{ // ctor
//-------------------------------------------------
imgtool::stream::stream(bool wp, std::size_t size, void *buf)
: imgtype(IMG_MEM)
, write_protect(wp)
, name(nullptr)
, position(0)
, filesize(size)
, file()
, buffer(reinterpret_cast<std::uint8_t *>(buf))
{
}
//-------------------------------------------------
// dtor
//-------------------------------------------------
imgtool::stream::~stream()
{
if (buffer)
free(buffer); free(buffer);
} }
imgtype_t imgtype;
bool write_protect;
const char *name; // needed for clear
std::uint64_t position;
std::uint64_t filesize;
util::core_file::ptr file;
std::uint8_t *buffer;
};
//-------------------------------------------------
// open_zip
//-------------------------------------------------
static imgtool_stream *stream_open_zip(const char *zipname, const char *subname, int read_or_write) imgtool::stream *imgtool::stream::open_zip(const char *zipname, const char *subname, int read_or_write)
{ {
if (read_or_write) if (read_or_write)
return nullptr; return nullptr;
@ -100,7 +107,7 @@ static imgtool_stream *stream_open_zip(const char *zipname, const char *subname,
return nullptr; return nullptr;
fclose(f); fclose(f);
imgtool_stream::ptr imgfile(new imgtool_stream(true)); imgtool::stream::ptr imgfile(new imgtool::stream(true));
imgfile->imgtype = IMG_MEM; imgfile->imgtype = IMG_MEM;
@ -128,7 +135,11 @@ static imgtool_stream *stream_open_zip(const char *zipname, const char *subname,
imgtool_stream *stream_open(const char *fname, int read_or_write) //-------------------------------------------------
// open
//-------------------------------------------------
imgtool::stream *imgtool::stream::open(const char *fname, int read_or_write)
{ {
static const UINT32 write_modes[] = static const UINT32 write_modes[] =
{ {
@ -137,13 +148,13 @@ imgtool_stream *stream_open(const char *fname, int read_or_write)
OPEN_FLAG_READ | OPEN_FLAG_WRITE, OPEN_FLAG_READ | OPEN_FLAG_WRITE,
OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE
}; };
imgtool_stream *s = nullptr; imgtool::stream *s = nullptr;
char c; char c;
/* maybe we are just a ZIP? */ /* maybe we are just a ZIP? */
const char *ext = strrchr(fname, '.'); const char *ext = strrchr(fname, '.');
if (ext && !core_stricmp(ext, ".zip")) if (ext && !core_stricmp(ext, ".zip"))
return stream_open_zip(fname, nullptr, read_or_write); return open_zip(fname, nullptr, read_or_write);
util::core_file::ptr f = nullptr; util::core_file::ptr f = nullptr;
auto const filerr = util::core_file::open(fname, write_modes[read_or_write], f); auto const filerr = util::core_file::open(fname, write_modes[read_or_write], f);
@ -163,7 +174,7 @@ imgtool_stream *stream_open(const char *fname, int read_or_write)
{ {
c = buf[i]; c = buf[i];
buf[i] = '\0'; buf[i] = '\0';
s = stream_open_zip(&buf[0], &buf[i + 1], read_or_write); s = open_zip(&buf[0], &buf[i + 1], read_or_write);
buf[i] = c; buf[i] = c;
} }
} }
@ -176,7 +187,7 @@ imgtool_stream *stream_open(const char *fname, int read_or_write)
return nullptr; return nullptr;
} }
imgtool_stream::ptr imgfile(new imgtool_stream(read_or_write ? false : true, std::move(f))); imgtool::stream::ptr imgfile(new imgtool::stream(read_or_write ? false : true, std::move(f)));
/* Normal file */ /* Normal file */
imgfile->name = fname; imgfile->name = fname;
@ -184,10 +195,13 @@ imgtool_stream *stream_open(const char *fname, int read_or_write)
} }
//-------------------------------------------------
// open_write_stream
//-------------------------------------------------
imgtool_stream *stream_open_write_stream(int size) imgtool::stream *imgtool::stream::open_write_stream(int size)
{ {
imgtool_stream::ptr imgfile(new imgtool_stream(false, size)); imgtool::stream::ptr imgfile(new imgtool::stream(false, size));
if (!imgfile->buffer) if (!imgfile->buffer)
return nullptr; return nullptr;
@ -195,50 +209,50 @@ imgtool_stream *stream_open_write_stream(int size)
} }
//-------------------------------------------------
// open_mem
//-------------------------------------------------
imgtool_stream *stream_open_mem(void *buf, size_t sz) imgtool::stream *imgtool::stream::open_mem(void *buf, size_t sz)
{ {
imgtool_stream::ptr imgfile(new imgtool_stream(false, sz, buf)); imgtool::stream::ptr imgfile(new imgtool::stream(false, sz, buf));
return imgfile.release(); return imgfile.release();
} }
//-------------------------------------------------
// core_file
//-------------------------------------------------
void stream_close(imgtool_stream *s) util::core_file *imgtool::stream::core_file()
{ {
assert(s != nullptr); return (imgtype == IMG_FILE) ? file.get() : nullptr;
delete s;
} }
//-------------------------------------------------
// read
//-------------------------------------------------
util::core_file *stream_core_file(imgtool_stream *stream) UINT32 imgtool::stream::read(void *buf, UINT32 sz)
{
return (stream->imgtype == IMG_FILE) ? stream->file.get() : nullptr;
}
UINT32 stream_read(imgtool_stream *stream, void *buf, UINT32 sz)
{ {
UINT32 result = 0; UINT32 result = 0;
switch(stream->imgtype) switch(imgtype)
{ {
case IMG_FILE: case IMG_FILE:
assert(sz == (UINT32) sz); assert(sz == (UINT32) sz);
stream->file->seek(stream->position, SEEK_SET); file->seek(position, SEEK_SET);
result = stream->file->read(buf, (UINT32) sz); result = file->read(buf, (UINT32) sz);
break; break;
case IMG_MEM: case IMG_MEM:
/* do we have to limit sz? */ /* do we have to limit sz? */
if (sz > (stream->filesize - stream->position)) if (sz > (filesize - position))
sz = (UINT32) (stream->filesize - stream->position); sz = (UINT32) (filesize - position);
memcpy(buf, stream->buffer + stream->position, sz); memcpy(buf, buffer + position, sz);
result = sz; result = sz;
break; break;
@ -246,46 +260,49 @@ UINT32 stream_read(imgtool_stream *stream, void *buf, UINT32 sz)
assert(0); assert(0);
break; break;
} }
stream->position += result; position += result;
return result; return result;
} }
//-------------------------------------------------
// write
//-------------------------------------------------
UINT32 stream_write(imgtool_stream *s, const void *buf, UINT32 sz) UINT32 imgtool::stream::write(const void *buf, UINT32 sz)
{ {
void *new_buffer; void *new_buffer;
UINT32 result = 0; UINT32 result = 0;
switch(s->imgtype) switch(imgtype)
{ {
case IMG_MEM: case IMG_MEM:
if (!s->write_protect) if (!write_protect)
{ {
/* do we have to expand the buffer? */ /* do we have to expand the buffer? */
if (s->filesize < s->position + sz) if (filesize < position + sz)
{ {
/* try to expand the buffer */ /* try to expand the buffer */
new_buffer = realloc(s->buffer , s->position + sz); new_buffer = realloc(buffer , position + sz);
if (new_buffer) if (new_buffer)
{ {
s->buffer = (UINT8*)new_buffer; buffer = (UINT8*)new_buffer;
s->filesize = s->position + sz; filesize = position + sz;
} }
} }
/* do we have to limit sz? */ /* do we have to limit sz? */
if (sz > (s->filesize - s->position)) if (sz > (filesize - position))
sz = (UINT32) (s->filesize - s->position); sz = (UINT32) (filesize - position);
memcpy(s->buffer + s->position, buf, sz); memcpy(buffer + position, buf, sz);
result = sz; result = sz;
} }
break; break;
case IMG_FILE: case IMG_FILE:
s->file->seek(s->position, SEEK_SET); file->seek(position, SEEK_SET);
result = s->file->write(buf, sz); result = file->write(buf, sz);
break; break;
default: default:
@ -294,31 +311,37 @@ UINT32 stream_write(imgtool_stream *s, const void *buf, UINT32 sz)
} }
/* advance the file pointer */ /* advance the file pointer */
s->position += result; position += result;
/* did we grow the file */ /* did we grow the file */
if (s->position > s->filesize) if (position > filesize)
s->filesize = s->position; filesize = position;
return result; return result;
} }
//-------------------------------------------------
// size
//-------------------------------------------------
UINT64 stream_size(imgtool_stream *s) UINT64 imgtool::stream::size() const
{ {
return s->filesize; return filesize;
} }
//-------------------------------------------------
// getptr
//-------------------------------------------------
void *stream_getptr(imgtool_stream *f) void *imgtool::stream::getptr()
{ {
void *ptr; void *ptr;
switch(f->imgtype) switch(imgtype)
{ {
case IMG_MEM: case IMG_MEM:
ptr = f->buffer; ptr = buffer;
break; break;
default: default:
@ -329,52 +352,57 @@ void *stream_getptr(imgtool_stream *f)
} }
//-------------------------------------------------
// seek
//-------------------------------------------------
int stream_seek(imgtool_stream *s, INT64 pos, int where) int imgtool::stream::seek(INT64 pos, int where)
{ {
UINT64 size;
size = stream_size(s);
switch(where) switch(where)
{ {
case SEEK_CUR: case SEEK_CUR:
pos += s->position; pos += position;
break; break;
case SEEK_END: case SEEK_END:
pos += size; pos += size();
break; break;
} }
if (pos < 0) if (pos < 0)
s->position = 0; position = 0;
else else
s->position = std::min(size, UINT64(pos)); position = std::min(size(), UINT64(pos));
if (s->position < pos) if (position < pos)
stream_fill(s, '\0', pos - s->position); fill('\0', pos - position);
return 0; return 0;
} }
//-------------------------------------------------
// tell
//-------------------------------------------------
UINT64 stream_tell(imgtool_stream *s) UINT64 imgtool::stream::tell()
{ {
return s->position; return position;
} }
//-------------------------------------------------
// transfer
//-------------------------------------------------
UINT64 stream_transfer(imgtool_stream *dest, imgtool_stream *source, UINT64 sz) UINT64 imgtool::stream::transfer(imgtool::stream &dest, imgtool::stream &source, UINT64 sz)
{ {
UINT64 result = 0; UINT64 result = 0;
UINT64 readsz; UINT64 readsz;
char buf[1024]; char buf[1024];
while(sz && (readsz = stream_read(source, buf, std::min(sz, UINT64(sizeof(buf)))))) while(sz && (readsz = source.read(buf, std::min(sz, UINT64(sizeof(buf))))))
{ {
stream_write(dest, buf, readsz); dest.write(buf, readsz);
sz -= readsz; sz -= readsz;
result += readsz; result += readsz;
} }
@ -382,32 +410,38 @@ UINT64 stream_transfer(imgtool_stream *dest, imgtool_stream *source, UINT64 sz)
} }
//-------------------------------------------------
// transfer_all
//-------------------------------------------------
UINT64 stream_transfer_all(imgtool_stream *dest, imgtool_stream *source) UINT64 imgtool::stream::transfer_all(imgtool::stream &dest, imgtool::stream &source)
{ {
return stream_transfer(dest, source, stream_size(source)); return transfer(dest, source, source.size());
} }
//-------------------------------------------------
// crc
//-------------------------------------------------
int stream_crc(imgtool_stream *s, unsigned long *result) int imgtool::stream::crc(unsigned long *result)
{ {
size_t sz; size_t sz;
void *ptr; void *ptr;
switch(s->imgtype) switch(imgtype)
{ {
case IMG_MEM: case IMG_MEM:
*result = crc32(0, (unsigned char *) s->buffer, (size_t) s->filesize); *result = crc32(0, (unsigned char *) buffer, (size_t) filesize);
break; break;
default: default:
sz = stream_size(s); sz = size();
ptr = malloc(sz); ptr = malloc(sz);
if (!ptr) if (!ptr)
return IMGTOOLERR_OUTOFMEMORY; return IMGTOOLERR_OUTOFMEMORY;
stream_seek(s, 0, SEEK_SET); seek(0, SEEK_SET);
if (stream_read(s, ptr, sz) != sz) if (read(ptr, sz) != sz)
{ {
free(ptr); free(ptr);
return IMGTOOLERR_READERROR; return IMGTOOLERR_READERROR;
@ -420,24 +454,30 @@ int stream_crc(imgtool_stream *s, unsigned long *result)
} }
//-------------------------------------------------
// file_crc
//-------------------------------------------------
int file_crc(const char *fname, unsigned long *result) int imgtool::stream::file_crc(const char *fname, unsigned long *result)
{ {
int err; int err;
imgtool_stream *f; imgtool::stream *f;
f = stream_open(fname, OSD_FOPEN_READ); f = imgtool::stream::open(fname, OSD_FOPEN_READ);
if (!f) if (!f)
return IMGTOOLERR_FILENOTFOUND; return IMGTOOLERR_FILENOTFOUND;
err = stream_crc(f, result); err = f->crc(result);
stream_close(f); delete f;
return err; return err;
} }
//-------------------------------------------------
// fill
//-------------------------------------------------
UINT64 stream_fill(imgtool_stream *f, unsigned char b, UINT64 sz) UINT64 imgtool::stream::fill(unsigned char b, UINT64 sz)
{ {
UINT64 outsz; UINT64 outsz;
char buf[1024]; char buf[1024];
@ -447,36 +487,48 @@ UINT64 stream_fill(imgtool_stream *f, unsigned char b, UINT64 sz)
while (sz) while (sz)
{ {
outsz += stream_write(f, buf, (std::min<UINT64>)(sz, sizeof(buf))); outsz += write(buf, (std::min<UINT64>)(sz, sizeof(buf)));
sz -= (std::min<UINT64>)(sz, sizeof(buf)); sz -= (std::min<UINT64>)(sz, sizeof(buf));
} }
return outsz; return outsz;
} }
//-------------------------------------------------
// is_read_only
//-------------------------------------------------
int stream_isreadonly(imgtool_stream *s) int imgtool::stream::is_read_only()
{ {
return s->write_protect; return write_protect;
} }
//-------------------------------------------------
// putc
//-------------------------------------------------
UINT32 stream_putc(imgtool_stream *stream, char c) UINT32 imgtool::stream::putc(char c)
{ {
return stream_write(stream, &c, 1); return write(&c, 1);
} }
//-------------------------------------------------
// puts
//-------------------------------------------------
UINT32 stream_puts(imgtool_stream *stream, const char *s) UINT32 imgtool::stream::puts(const char *s)
{ {
return stream_write(stream, s, strlen(s)); return write(s, strlen(s));
} }
//-------------------------------------------------
// printf
//-------------------------------------------------
UINT32 stream_printf(imgtool_stream *stream, const char *fmt, ...) UINT32 imgtool::stream::printf(const char *fmt, ...)
{ {
va_list va; va_list va;
char buf[256]; char buf[256];
@ -485,5 +537,5 @@ UINT32 stream_printf(imgtool_stream *stream, const char *fmt, ...)
vsprintf(buf, fmt, va); vsprintf(buf, fmt, va);
va_end(va); va_end(va);
return stream_puts(stream, buf); return puts(buf);
} }

View File

@ -14,35 +14,71 @@
#include "imgterrs.h" #include "imgterrs.h"
#include "corefile.h" #include "corefile.h"
struct imgtool_stream; namespace imgtool
{
class stream
{
public:
typedef std::unique_ptr<stream> ptr;
imgtool_stream *stream_open(const char *fname, int read_or_write); /* similar params to mame_fopen */ ~stream();
imgtool_stream *stream_open_write_stream(int filesize);
imgtool_stream *stream_open_mem(void *buf, size_t sz);
void stream_close(imgtool_stream *stream);
util::core_file *stream_core_file(imgtool_stream *stream);
UINT32 stream_read(imgtool_stream *stream, void *buf, UINT32 sz);
UINT32 stream_write(imgtool_stream *stream, const void *buf, UINT32 sz);
UINT64 stream_size(imgtool_stream *stream);
int stream_seek(imgtool_stream *stream, INT64 pos, int where);
UINT64 stream_tell(imgtool_stream *stream);
void *stream_getptr(imgtool_stream *stream);
UINT32 stream_putc(imgtool_stream *stream, char c);
UINT32 stream_puts(imgtool_stream *stream, const char *s);
UINT32 stream_printf(imgtool_stream *stream, const char *fmt, ...) ATTR_PRINTF(2,3);
/* Transfers sz bytes from source to dest */ static imgtool::stream *open(const char *fname, int read_or_write); /* similar params to mame_fopen */
UINT64 stream_transfer(imgtool_stream *dest, imgtool_stream *source, UINT64 sz); static imgtool::stream *open_write_stream(int filesize);
UINT64 stream_transfer_all(imgtool_stream *dest, imgtool_stream *source); static imgtool::stream *open_mem(void *buf, size_t sz);
util::core_file *core_file();
UINT32 read(void *buf, UINT32 sz);
UINT32 write(const void *buf, UINT32 sz);
UINT64 size() const;
int seek(INT64 pos, int where);
UINT64 tell();
void *getptr();
UINT32 putc(char c);
UINT32 puts(const char *s);
UINT32 printf(const char *fmt, ...) ATTR_PRINTF(2, 3);
/* Fills sz bytes with b */ // transfers sz bytes from source to dest
UINT64 stream_fill(imgtool_stream *f, unsigned char b, UINT64 sz); static UINT64 transfer(imgtool::stream &dest, imgtool::stream &source, UINT64 sz);
static UINT64 transfer_all(imgtool::stream &dest, imgtool::stream &source);
// fills sz bytes with b
UINT64 fill(unsigned char b, UINT64 sz);
// returns the CRC of a file
int crc(unsigned long *result);
static int file_crc(const char *fname, unsigned long *result);
// returns whether a stream is read only or not
int is_read_only();
private:
enum imgtype_t
{
IMG_FILE,
IMG_MEM
};
imgtype_t imgtype;
bool write_protect;
const char *name; // needed for clear
std::uint64_t position;
std::uint64_t filesize;
util::core_file::ptr file;
std::uint8_t *buffer;
// ctors
stream(bool wp);
stream(bool wp, util::core_file::ptr &&f);
stream(bool wp, std::size_t size);
stream(bool wp, std::size_t size, void *buf);
// private methods
static stream *open_zip(const char *zipname, const char *subname, int read_or_write);
};
}
/* Returns the CRC of a file */
int stream_crc(imgtool_stream *f, unsigned long *result);
int file_crc(const char *fname, unsigned long *result);
/* Returns whether a stream is read only or not */
int stream_isreadonly(imgtool_stream *f);
#endif /* STREAM_H */ #endif /* STREAM_H */