summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/formats/fs_prodos.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/formats/fs_prodos.cpp')
-rw-r--r--src/lib/formats/fs_prodos.cpp187
1 files changed, 138 insertions, 49 deletions
diff --git a/src/lib/formats/fs_prodos.cpp b/src/lib/formats/fs_prodos.cpp
index 5a4d3e6edf5..a5a6b11eea3 100644
--- a/src/lib/formats/fs_prodos.cpp
+++ b/src/lib/formats/fs_prodos.cpp
@@ -7,6 +7,19 @@
#include "fs_prodos.h"
#include "ap_dsk35.h"
+
+const fs_prodos FS_PRODOS;
+
+const char *fs_prodos::name() const
+{
+ return "prodos";
+}
+
+const char *fs_prodos::description() const
+{
+ return "Apple ProDOS";
+}
+
const u8 fs_prodos::impl::boot[512] = {
0x01, 0x38, 0xb0, 0x03, 0x4c, 0x1c, 0x09, 0x78, 0x86, 0x43, 0xc9, 0x03, 0x08, 0x8a, 0x29, 0x70,
0x4a, 0x4a, 0x4a, 0x4a, 0x09, 0xc0, 0x85, 0x49, 0xa0, 0xff, 0x84, 0x48, 0x28, 0xc8, 0xb1, 0x48,
@@ -45,9 +58,9 @@ const u8 fs_prodos::impl::boot[512] = {
void fs_prodos::enumerate_f(floppy_enumerator &fe, uint32_t form_factor, const std::vector<uint32_t> &variants) const
{
if(has(form_factor, variants, floppy_image::FF_35, floppy_image::DSDD))
- fe.add(this, FLOPPY_APPLE_GCR_FORMAT, 819200, "prodos_800k", "Apple ProDOS 800K");
+ fe.add(FLOPPY_APPLE_GCR_FORMAT, 819200, "prodos_800k", "Apple ProDOS 800K");
if(has(form_factor, variants, floppy_image::FF_35, floppy_image::SSDD))
- fe.add(this, FLOPPY_APPLE_GCR_FORMAT, 409600, "prodos_400k", "Apple ProDOS 400K");
+ fe.add(FLOPPY_APPLE_GCR_FORMAT, 409600, "prodos_400k", "Apple ProDOS 400K");
}
std::unique_ptr<filesystem_t> fs_prodos::mount(fsblk_t &blockdev) const
@@ -70,6 +83,11 @@ bool fs_prodos::can_write() const
return false;
}
+bool fs_prodos::has_rsrc() const
+{
+ return true;
+}
+
char fs_prodos::directory_separator() const
{
return '/';
@@ -118,7 +136,7 @@ std::vector<fs_meta_description> fs_prodos::directory_meta_description() const
void fs_prodos::impl::format(const fs_meta_data &meta)
{
- std::string volume_name = meta.find(fs_meta_name::name)->second.as_string();
+ std::string volume_name = meta.get_string(fs_meta_name::name, "UNTITLED");
u32 blocks = m_blockdev.block_count();
// Maximum usable partition size = 32M - 512 bytes (65535 blocks)
@@ -183,7 +201,7 @@ void fs_prodos::impl::format(const fs_meta_data &meta)
}
fs_prodos::impl::impl(fsblk_t &blockdev) : filesystem_t(blockdev, 512), m_root(true)
-{
+{
}
util::arbitrary_datetime fs_prodos::impl::prodos_to_dt(u32 date)
@@ -206,18 +224,18 @@ fs_meta_data fs_prodos::impl::metadata()
fs_meta_data res;
auto bdir = m_blockdev.get(2);
int len = bdir.r8(0x04) & 0xf;
- res[fs_meta_name::name] = bdir.rstr(0x05, len);
- res[fs_meta_name::os_version] = uint64_t(bdir.r8(0x20));
- res[fs_meta_name::os_minimum_version] = uint64_t(bdir.r8(0x21));
- res[fs_meta_name::creation_date] = prodos_to_dt(bdir.r32l(0x1c));
- res[fs_meta_name::modification_date] = prodos_to_dt(bdir.r32l(0x16));
- return res;
+ res.set(fs_meta_name::name, bdir.rstr(0x05, len));
+ res.set(fs_meta_name::os_version, bdir.r8(0x20));
+ res.set(fs_meta_name::os_minimum_version, bdir.r8(0x21));
+ res.set(fs_meta_name::creation_date, prodos_to_dt(bdir.r32l(0x1c)));
+ res.set(fs_meta_name::modification_date, prodos_to_dt(bdir.r32l(0x16)));
+ return res;
}
filesystem_t::dir_t fs_prodos::impl::root()
{
if(!m_root)
- m_root = new dir(*this, 2);
+ m_root = new root_dir(*this, 2);
return m_root.strong();
}
@@ -227,29 +245,18 @@ void fs_prodos::impl::drop_root_ref()
}
-void fs_prodos::impl::dir::drop_weak_references()
+void fs_prodos::impl::root_dir::drop_weak_references()
{
if(m_base_block == 2)
m_fs.drop_root_ref();
}
-fs_meta_data fs_prodos::impl::dir::metadata()
+fs_meta_data fs_prodos::impl::root_dir::metadata()
{
- fs_meta_data res;
- if(m_base_block == 2)
- return res;
-
- auto bdir = m_fs.m_blockdev.get(m_base_block);
- int len = bdir.r8(0x04) & 0xf;
- res[fs_meta_name::name] = bdir.rstr(0x05, len);
- res[fs_meta_name::os_version] = uint64_t(bdir.r8(0x20));
- res[fs_meta_name::os_minimum_version] = uint64_t(bdir.r8(0x21));
- res[fs_meta_name::creation_date] = prodos_to_dt(bdir.r32l(0x1c));
- res[fs_meta_name::modification_date] = prodos_to_dt(bdir.r32l(0x16));
- return res;
+ return fs_meta_data();
}
-std::vector<fs_dir_entry> fs_prodos::impl::dir::contents()
+std::vector<fs_dir_entry> fs_prodos::impl::root_dir::contents()
{
std::vector<fs_dir_entry> res;
@@ -277,7 +284,8 @@ std::vector<fs_dir_entry> fs_prodos::impl::dir::contents()
return res;
}
-std::pair<fsblk_t::block_t, const u8 *> fs_prodos::impl::dir::get_entry_ro(uint64_t key)
+
+std::pair<fsblk_t::block_t, const u8 *> fs_prodos::impl::root_dir::get_entry_ro(uint64_t key)
{
std::pair<fsblk_t::block_t, const u8 *> res;
res.first = m_fs.m_blockdev.get(m_base_block);
@@ -295,7 +303,7 @@ std::pair<fsblk_t::block_t, const u8 *> fs_prodos::impl::dir::get_entry_ro(uint6
return res;
}
-std::pair<fsblk_t::block_t, u8 *> fs_prodos::impl::dir::get_entry(uint64_t key)
+std::pair<fsblk_t::block_t, u8 *> fs_prodos::impl::root_dir::get_entry(uint64_t key)
{
std::pair<fsblk_t::block_t, u8 *> res;
res.first = m_fs.m_blockdev.get(m_base_block);
@@ -313,7 +321,7 @@ std::pair<fsblk_t::block_t, u8 *> fs_prodos::impl::dir::get_entry(uint64_t key)
return res;
}
-filesystem_t::file_t fs_prodos::impl::dir::file_get(uint64_t key)
+filesystem_t::file_t fs_prodos::impl::root_dir::file_get(uint64_t key)
{
auto [blk, entry] = get_entry_ro(key);
if(!blk)
@@ -321,10 +329,10 @@ filesystem_t::file_t fs_prodos::impl::dir::file_get(uint64_t key)
u8 type = entry[0] >> 4;
if(type == 0 || type == 4 || type > 5)
fatalerror("Unhandled file type %x\n", type);
- return new file(m_fs, entry, key);
+ return new file(m_fs, entry, key, this);
}
-filesystem_t::dir_t fs_prodos::impl::dir::dir_get(uint64_t key)
+filesystem_t::dir_t fs_prodos::impl::root_dir::dir_get(uint64_t key)
{
auto [blk, entry] = get_entry_ro(key);
if(!blk)
@@ -333,12 +341,21 @@ filesystem_t::dir_t fs_prodos::impl::dir::dir_get(uint64_t key)
if(type != 0xd)
fatalerror("Unhandled directory type %x\n", type);
- return new dir(m_fs, entry[17] | (entry[18] << 8), key);
+ return new dir(m_fs, entry, r16l(entry+0x11), key, this);
+}
+
+fs_prodos::impl::dir::dir(impl &fs, const u8 *entry, u16 base_block, u16 key, root_dir *parent_dir) : root_dir(fs, base_block), m_parent_dir(parent_dir), m_key(key)
+{
+ memcpy(m_entry, entry, 39);
+ (void)m_key;
+ (void)m_parent_dir;
}
-fs_prodos::impl::file::file(impl &fs, const u8 *entry, u16 key) : m_fs(fs), m_key(key)
+fs_prodos::impl::file::file(impl &fs, const u8 *entry, u16 key, root_dir *parent_dir) : m_fs(fs), m_parent_dir(parent_dir), m_key(key)
{
memcpy(m_entry, entry, 39);
+ (void)m_key;
+ (void)m_parent_dir;
}
void fs_prodos::impl::file::drop_weak_references()
@@ -348,31 +365,103 @@ void fs_prodos::impl::file::drop_weak_references()
fs_meta_data fs_prodos::impl::file::metadata()
{
fs_meta_data res;
- std::string name;
- u8 type = m_entry[0];
- for(u8 i = 0; i != (type & 0xf); i++)
- name += char(m_entry[i+1]);
+ u8 type = r8(m_entry);
+ std::string name = rstr(m_entry+1, type & 0xf);
type >>= 4;
- res[fs_meta_name::name] = name;
+ res.set(fs_meta_name::name, name);
if(type == 5) {
- auto rootblk = m_fs.m_blockdev.get(m_entry[0x11] | (m_entry[0x12] << 8));
- res[fs_meta_name::length] = rootblk.r24l(0x005);
- res[fs_meta_name::rsrc_length] = rootblk.r24l(0x105);
-
- } else if((type >= 1 && type <= 3) || 1)
- res[fs_meta_name::length] = m_entry[0x15] | (m_entry[0x16] << 8) | (m_entry[0x17] << 16);
+ auto rootblk = m_fs.m_blockdev.get(r16l(m_entry+0x11));
+ res.set(fs_meta_name::length, rootblk.r24l(0x005));
+ res.set(fs_meta_name::rsrc_length, rootblk.r24l(0x105));
+
+ } else if(type >= 1 && type <= 3)
+ res.set(fs_meta_name::length, r24l(m_entry + 0x15));
+
+ else
+ fatalerror("fs_prodos::impl::file::metadata: Unhandled file type %d\n", type);
return res;
}
-std::vector<u8> fs_prodos::impl::file::read_all()
+fs_meta_data fs_prodos::impl::dir::metadata()
{
- abort();
+ fs_meta_data res;
+ u8 type = r8(m_entry);
+ std::string name = rstr(m_entry+1, type & 0xf);
+ res.set(fs_meta_name::name, name);
+
+ return res;
}
-std::vector<u8> fs_prodos::impl::file::read(u64 start, u64 length)
+std::vector<u8> fs_prodos::impl::file::any_read_all(uint8_t type, u16 block, u32 length)
{
- abort();
+ std::vector<u8> data((length + 511) & ~511);
+ u32 nb = data.size()/512;
+ if(!nb)
+ return data;
+
+ u8 *dst = data.data();
+ u8 *end = dst + data.size();
+ switch(type) {
+ case 1:
+ memcpy(dst, m_fs.m_blockdev.get(block).rodata(), 512);
+ dst += 512;
+ break;
+
+ case 2: {
+ auto iblk = m_fs.m_blockdev.get(block);
+ for(u32 i=0; i != 256 && dst != end; i++) {
+ u16 blk = iblk.r8(i) | (iblk.r8(i | 0x100) << 8);
+ memcpy(dst, m_fs.m_blockdev.get(blk).rodata(), 512);
+ dst += 512;
+ }
+ break;
+ }
+
+ case 3: {
+ auto mblk = m_fs.m_blockdev.get(block);
+ for(u32 j=0; dst != end; j += 256) {
+ u32 idx = j/256;
+ auto iblk = m_fs.m_blockdev.get(mblk.r8(idx) | (mblk.r8(idx | 0x100) << 8));
+ for(u32 i=0; i != 256 && dst != end; i++) {
+ u16 blk = iblk.r8(i) | (iblk.r8(i | 0x100) << 8);
+ memcpy(dst, m_fs.m_blockdev.get(blk).rodata(), 512);
+ dst += 512;
+ }
+ }
+ break;
+ }
+
+ default:
+ fatalerror("fs_prodos::impl::file::get_file_blocks: unknown file type %d\n", type);
+ }
+
+ data.resize(length);
+ return data;
+}
+
+std::vector<u8> fs_prodos::impl::file::read_all()
+{
+ u8 type = r8(m_entry) >> 4;
+ if(type >= 1 && type <= 3)
+ return any_read_all(type, r16l(m_entry+0x11), r24l(m_entry + 0x15));
+
+ else if(type == 5) {
+ auto kblk = m_fs.m_blockdev.get(r16l(m_entry+0x11));
+ return any_read_all(kblk.r8(0x000), kblk.r16l(0x001), kblk.r24l(0x005));
+
+ } else
+ fatalerror("fs_prodos::impl::file::read_all: Unhandled file type %d\n", type);
}
-const filesystem_manager_type FS_PRODOS = &filesystem_manager_creator<fs_prodos>;;
+std::vector<u8> fs_prodos::impl::file::rsrc_read_all()
+{
+ u8 type = r8(m_entry) >> 4;
+
+ if(type == 5) {
+ auto kblk = m_fs.m_blockdev.get(r16l(m_entry+0x11));
+ return any_read_all(kblk.r8(0x100), kblk.r16l(0x101), kblk.r24l(0x105));
+
+ } else
+ fatalerror("fs_prodos::impl::file::rsrc_blocks: Unhandled file type %d\n", type);
+}
: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
// license:BSD-3-Clause
// copyright-holders:Sergey Svishchev
/***************************************************************************

TV test pattern generators

Radio, 1983, N5
    http://radioway.ru/1983/05/generator_telesignalov.html
    http://radioway.ru/1984/04/generator_telesignalov.html

Radio, 1985, N6
    http://radioway.ru/1985/06/generator_ispytatelnyh_signalov.html

***************************************************************************/

#include "emu.h"

#include "machine/netlist.h"

#include "video/fixfreq.h"

#include "netlist/devices/net_lib.h"

#include "machine/nl_tp1983.h"
#include "machine/nl_tp1985.h"

#include "screen.h"

#include <cmath>


namespace {

#define MASTER_CLOCK    (4000000)
#define V_TOTAL_PONG    315
#define H_TOTAL_PONG    256     // tbc

class tp1983_state : public driver_device
{
public:
	tp1983_state(const machine_config &mconfig, device_type type, const char *tag)
		: driver_device(mconfig, type, tag)
		, m_maincpu(*this, "maincpu")
		, m_video(*this, "fixfreq")
	{
	}

	// devices
	required_device<netlist_mame_device> m_maincpu;
	required_device<fixedfreq_device> m_video;

	void tp1983(machine_config &config);

protected:
	// driver_device overrides
	virtual void machine_start() override { }
	virtual void machine_reset() override { }

	virtual void video_start() override { }

private:
};


class tp1985_state : public driver_device
{
public:
	tp1985_state(const machine_config &mconfig, device_type type, const char *tag)
		: driver_device(mconfig, type, tag)
		, m_maincpu(*this, "maincpu")
		, m_video(*this, "fixfreq")
	{
	}

	// devices
	required_device<netlist_mame_device> m_maincpu;
	required_device<fixedfreq_device> m_video;

	void tp1985(machine_config &config);

protected:
	// driver_device overrides
	virtual void machine_start() override { }
	virtual void machine_reset() override { }

	virtual void video_start() override { }

private:
	NETDEV_ANALOG_CALLBACK_MEMBER(video_out_cb);
};

NETDEV_ANALOG_CALLBACK_MEMBER(tp1985_state::video_out_cb)
{
	m_video->update_composite_monochrome(4.0 - data, time);
}


static INPUT_PORTS_START(tp1983)
INPUT_PORTS_END

static INPUT_PORTS_START(tp1985)
INPUT_PORTS_END


void tp1983_state::tp1983(machine_config &config)
{
	NETLIST_CPU(config, m_maincpu, netlist::config::DEFAULT_CLOCK()).set_source(netlist_tp1983);

	NETLIST_ANALOG_OUTPUT(config, "maincpu:vid0").set_params("videomix", m_video, FUNC(fixedfreq_device::update_composite_monochrome));

	SCREEN(config, "screen", SCREEN_TYPE_RASTER);
	FIXFREQ(config, m_video).set_screen("screen");
	m_video->set_monitor_clock(MASTER_CLOCK);
	m_video->set_horz_params(H_TOTAL_PONG-64,H_TOTAL_PONG-40,H_TOTAL_PONG-8,H_TOTAL_PONG);
	m_video->set_vert_params(V_TOTAL_PONG-19,V_TOTAL_PONG-16,V_TOTAL_PONG-12,V_TOTAL_PONG);
	m_video->set_fieldcount(1);
	m_video->set_threshold(1);
	m_video->set_gain(0.36);
}

void tp1985_state::tp1985(machine_config &config)
{
	NETLIST_CPU(config, m_maincpu, netlist::config::DEFAULT_CLOCK()).set_source(netlist_tp1985);

	NETLIST_ANALOG_OUTPUT(config, "maincpu:vid0").set_params("videomix", FUNC(tp1985_state::video_out_cb));

	SCREEN(config, "screen", SCREEN_TYPE_RASTER);
	FIXFREQ(config, m_video).set_screen("screen");
	m_video->set_monitor_clock(MASTER_CLOCK);
	m_video->set_horz_params(H_TOTAL_PONG-80,H_TOTAL_PONG-56,H_TOTAL_PONG-8,H_TOTAL_PONG);
	m_video->set_vert_params(V_TOTAL_PONG-19,V_TOTAL_PONG-15,V_TOTAL_PONG-12,V_TOTAL_PONG);
	m_video->set_fieldcount(1);
	m_video->set_threshold(1);
	m_video->set_gain(0.36);
}


ROM_START( tp1983 ) /* dummy to satisfy game entry*/
	ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASE00 )
ROM_END

ROM_START( tp1985 ) /* dummy to satisfy game entry*/
	ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASE00 )
ROM_END

} // anonymous namespace


SYST(  1983, tp1983, 0, 0, tp1983,   tp1983,    tp1983_state,   empty_init, "Radio", "TV Test Pattern Generator 1983", MACHINE_NOT_WORKING | MACHINE_NO_SOUND_HW)
SYST(  1985, tp1985, 0, 0, tp1985,   tp1985,    tp1985_state,   empty_init, "Radio", "TV Test Pattern Generator 1985", MACHINE_NO_SOUND_HW)