mirror of
https://github.com/holub/mame
synced 2025-06-06 04:43:45 +03:00
Merge branch 'master' of https://github.com/mamedev/mame
This commit is contained in:
commit
ea2762e799
@ -350,12 +350,16 @@ Configuration options
|
||||
- <mymame>.ini (i.e. if MAME was renamed mame060.exe, MAME
|
||||
parses mame060.ini here)
|
||||
- debug.ini (if the debugger is enabled)
|
||||
- <driver>.ini (based on the source filename of the driver)
|
||||
- vertical.ini (for games with vertical monitor orientation)
|
||||
- horizont.ini (for games with horizontal monitor orientation)
|
||||
- arcade.ini (for games in source added with GAME() macro)
|
||||
- console.ini (for games in source added with CONS() macro)
|
||||
- computer.ini (for games in source added with COMP() macro)
|
||||
- othersys.ini (for games in source added with SYST() macro)
|
||||
- vector.ini (for vector games only)
|
||||
- <parent>.ini (for clones only, may be called recursively)
|
||||
- <gamename>.ini
|
||||
- vertical.ini (for games with vertical monitor orientation)
|
||||
- horizont.ini (for games with horizontal monitor orientation)
|
||||
- vector.ini (for vector games only)
|
||||
- <driver>.ini (based on the source filename of the driver)
|
||||
|
||||
|
||||
The settings in the later ini's override those in the earlier ini's.
|
||||
@ -376,6 +380,13 @@ Core search path options
|
||||
The default is 'roms' (that is, a directory "roms" in the same directory
|
||||
as the MAME executable).
|
||||
|
||||
-hashpath <path>
|
||||
|
||||
Specifies a list of paths within which to find Software List HASH files.
|
||||
Multiple paths can be specified by separating them with semicolons.
|
||||
The default is 'hash' (that is, a directory "roms" in the same directory
|
||||
as the MAME executable).
|
||||
|
||||
-samplepath / -sp <path>
|
||||
|
||||
Specifies a list of paths within which to find sample files. Multiple
|
||||
@ -449,16 +460,6 @@ Core Output Directory Options
|
||||
"nvram" in the same directory as the MAME executable). If this
|
||||
directory does not exist, it will be automatically created.
|
||||
|
||||
-memcard_directory <path>
|
||||
|
||||
Specifies a single directory where memory card files are stored.
|
||||
Memory card files store the contents of removable memory cards for
|
||||
games which used this type of hardware. This data is read and written
|
||||
under control of the user via the "Memory Card" menu in the user
|
||||
interface. The default is 'memcard' (that is, a directory "memcard"
|
||||
in the same directory as the MAME executable). If this directory does
|
||||
not exist, it will be automatically created.
|
||||
|
||||
-input_directory <path>
|
||||
|
||||
Specifies a single directory where input recording files are stored.
|
||||
@ -604,6 +605,12 @@ Core state/playback options
|
||||
<viewname> can also be 'auto', which selects the first view with all
|
||||
screens present. The default value is 'internal'.
|
||||
|
||||
-[no]snapbilinear
|
||||
|
||||
Specify if the snapshot or movie should have bilinear filtering
|
||||
applied. Shutting this off can make a difference in some performance
|
||||
while recording video to a file. The default is ON (-snapbilinear).
|
||||
|
||||
-statename <name>
|
||||
|
||||
Describes how MAME should store save state files, relative to the
|
||||
@ -1087,12 +1094,6 @@ Core input automatic enable options
|
||||
Debugging options
|
||||
-----------------
|
||||
|
||||
-[no]log
|
||||
|
||||
Creates a file called error.log which contains all of the internal
|
||||
log messages generated by the MAME core and game drivers. The default
|
||||
is OFF (-nolog).
|
||||
|
||||
-[no]verbose / -[no]v
|
||||
|
||||
Displays internal diagnostic information. This information is very
|
||||
@ -1100,12 +1101,16 @@ Debugging options
|
||||
reporting bugs, please run with mame -verbose and include the
|
||||
resulting information. The default is OFF (-noverbose).
|
||||
|
||||
-[no]update_in_pause
|
||||
-[no]oslog
|
||||
|
||||
Enables updating of the main screen bitmap while the game is paused.
|
||||
This means that the VIDEO_UPDATE callback will be called repeatedly
|
||||
during pause, which can be useful for debugging. The default is OFF
|
||||
(-noupdate_in_pause).
|
||||
Output error.log data to the system debugger. The default is OFF
|
||||
(-nooslog).
|
||||
|
||||
-[no]log
|
||||
|
||||
Creates a file called error.log which contains all of the internal
|
||||
log messages generated by the MAME core and game drivers. The default
|
||||
is OFF (-nolog).
|
||||
|
||||
-[no]debug
|
||||
|
||||
@ -1118,16 +1123,36 @@ Debugging options
|
||||
Specifies a file that contains a list of debugger commands to execute
|
||||
immediately upon startup. The default is NULL (no commands).
|
||||
|
||||
-debug_internal
|
||||
-[no]update_in_pause
|
||||
|
||||
A special 'internal' debugger for debugging. Activated when used along
|
||||
with -debug. The default if OFF (-nodebug_internal).
|
||||
Enables updating of the main screen bitmap while the game is paused.
|
||||
This means that the VIDEO_UPDATE callback will be called repeatedly
|
||||
during pause, which can be useful for debugging. The default is OFF
|
||||
(-noupdate_in_pause).
|
||||
|
||||
|
||||
|
||||
Core misc options
|
||||
-----------------
|
||||
|
||||
-[no]drc
|
||||
Enable DRC cpu core if available. The default is ON (-drc).
|
||||
|
||||
-drc_use_c
|
||||
|
||||
Force DRC use the C code backend. The default is OFF
|
||||
(-nodrc_use_c).
|
||||
|
||||
-drc_log_uml
|
||||
|
||||
Write DRC UML disassembly log. The default is OFF
|
||||
(-nodrc_log_uml).
|
||||
|
||||
-drc_log_native
|
||||
|
||||
write DRC native disassembly log. The default is OFF
|
||||
(-nodrc_log_native).
|
||||
|
||||
-bios <biosname>
|
||||
|
||||
Specifies the specific BIOS to use with the current game, for game
|
||||
|
7
makefile
7
makefile
@ -358,11 +358,7 @@ endif
|
||||
|
||||
# specify a default optimization level if none explicitly stated
|
||||
ifndef OPTIMIZE
|
||||
ifndef SYMBOLS
|
||||
OPTIMIZE = 3
|
||||
else
|
||||
OPTIMIZE = 0
|
||||
endif
|
||||
endif
|
||||
|
||||
# set the symbols level
|
||||
@ -741,6 +737,9 @@ vs2013_xp: generate
|
||||
vs2013_clang: generate
|
||||
$(SILENT) $(GENIE) $(PARAMS) --vs=vs2013-clang vs2013
|
||||
|
||||
vs2013_winrt: generate
|
||||
$(SILENT) $(GENIE) $(PARAMS) --vs=winstore81 vs2013
|
||||
|
||||
vs2015: generate
|
||||
$(SILENT) $(GENIE) $(PARAMS) vs2015
|
||||
|
||||
|
@ -3,6 +3,43 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "netlist/devices/net_lib.h"
|
||||
|
||||
NETLIST_START(7400_TTL)
|
||||
NET_REGISTER_DEV(7400, s1)
|
||||
NET_REGISTER_DEV(7400, s2)
|
||||
NET_REGISTER_DEV(7400, s3)
|
||||
NET_REGISTER_DEV(7400, s4)
|
||||
|
||||
ALIAS(1, s1.A);
|
||||
ALIAS(2, s1.B);
|
||||
ALIAS(3, s1.Q);
|
||||
|
||||
ALIAS(4, s2.A);
|
||||
ALIAS(5, s2.B);
|
||||
ALIAS(6, s2.Q);
|
||||
|
||||
ALIAS(9, s3.A);
|
||||
ALIAS(10, s3.B)
|
||||
ALIAS(8, s3.Q);
|
||||
|
||||
ALIAS(12, s4.A);
|
||||
ALIAS(13, s4.B);
|
||||
ALIAS(11, s4.Q);
|
||||
|
||||
NETLIST_END()
|
||||
|
||||
NETLIST_START(lib)
|
||||
TRUTHTABLE_START(7400A, 2, 1, 0, "+A,B")
|
||||
TT_HEAD(" A , B | Q ")
|
||||
TT_LINE(" 0 , X | 1 |22")
|
||||
TT_LINE(" X , 0 | 1 |22")
|
||||
TT_LINE(" 1 , 1 | 0 |15")
|
||||
TRUTHTABLE_END()
|
||||
NETLIST_END()
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
RES(R1, 10)
|
||||
RES(R2, 10)
|
||||
@ -98,4 +135,4 @@
|
||||
LOG(logY, 4V)
|
||||
|
||||
#endif
|
||||
d
|
||||
|
||||
|
@ -1112,6 +1112,21 @@ configuration { "x64", "vs*" }
|
||||
MAME_DIR .. "3rdparty/dxsdk/lib/x64",
|
||||
}
|
||||
|
||||
configuration { "winphone8* or winstore8*" }
|
||||
removelinks {
|
||||
"DelayImp",
|
||||
"gdi32",
|
||||
"psapi"
|
||||
}
|
||||
links {
|
||||
"d3d11",
|
||||
"dxgi"
|
||||
}
|
||||
linkoptions {
|
||||
"/ignore:4264" -- LNK4264: archiving object file compiled with /ZW into a static library; note that when authoring Windows Runtime types it is not recommended to link with a static library that contains Windows Runtime metadata
|
||||
}
|
||||
|
||||
|
||||
configuration { }
|
||||
|
||||
|
||||
|
@ -623,8 +623,18 @@ project "portaudio"
|
||||
"-Wno-maybe-uninitialized",
|
||||
"-Wno-unused-value",
|
||||
"-Wno-unused-function",
|
||||
"-Wno-unknown-pragmas",
|
||||
"-Wno-sometimes-uninitialized",
|
||||
}
|
||||
|
||||
local version = str_to_version(_OPTIONS["gcc_version"])
|
||||
if (_OPTIONS["gcc"]~=nil) and string.find(_OPTIONS["gcc"], "clang") then
|
||||
buildoptions_c {
|
||||
"-Wno-unknown-warning-option",
|
||||
"-Wno-absolute-value",
|
||||
}
|
||||
end
|
||||
|
||||
configuration { "vs*" }
|
||||
buildoptions {
|
||||
"/wd4204", -- warning C4204: nonstandard extension used : non-constant aggregate initializer
|
||||
@ -656,21 +666,16 @@ project "portaudio"
|
||||
"PA_USE_DS=1",
|
||||
"PA_USE_WDMKS=1",
|
||||
"PA_USE_WMME=1",
|
||||
"PA_USE_WASAPI=1",
|
||||
}
|
||||
includedirs {
|
||||
MAME_DIR .. "3rdparty/portaudio/src/os/win",
|
||||
}
|
||||
configuration { "mingw*" }
|
||||
includedirs {
|
||||
MAME_DIR .. "3rdparty/portaudio/src/hostapi/wasapi/mingw-include",
|
||||
}
|
||||
|
||||
configuration { }
|
||||
files {
|
||||
MAME_DIR .. "3rdparty/portaudio/src/os/win/pa_win_util.c",
|
||||
MAME_DIR .. "3rdparty/portaudio/src/os/win/pa_win_waveformat.c",
|
||||
MAME_DIR .. "3rdparty/portaudio/src/os/win/pa_win_hostapis.c",
|
||||
MAME_DIR .. "3rdparty/portaudio/src/os/win/pa_x86_plain_converters.c",
|
||||
MAME_DIR .. "3rdparty/portaudio/src/os/win/pa_win_wdmks_utils.c",
|
||||
MAME_DIR .. "3rdparty/portaudio/src/os/win/pa_win_coinitialize.c",
|
||||
MAME_DIR .. "3rdparty/portaudio/src/hostapi/dsound/pa_win_ds.c",
|
||||
@ -678,7 +683,6 @@ project "portaudio"
|
||||
MAME_DIR .. "3rdparty/portaudio/src/hostapi/wdmks/pa_win_wdmks.c",
|
||||
MAME_DIR .. "3rdparty/portaudio/src/common/pa_ringbuffer.c",
|
||||
MAME_DIR .. "3rdparty/portaudio/src/hostapi/wmme/pa_win_wmme.c",
|
||||
MAME_DIR .. "3rdparty/portaudio/src/hostapi/wasapi/pa_win_wasapi.c",
|
||||
}
|
||||
|
||||
end
|
||||
|
@ -391,8 +391,6 @@ project "formats"
|
||||
MAME_DIR .. "src/lib/formats/x1_tap.h",
|
||||
MAME_DIR .. "src/lib/formats/xdf_dsk.c",
|
||||
MAME_DIR .. "src/lib/formats/xdf_dsk.h",
|
||||
MAME_DIR .. "src/lib/formats/z80ne_dsk.c",
|
||||
MAME_DIR .. "src/lib/formats/z80ne_dsk.h",
|
||||
MAME_DIR .. "src/lib/formats/zx81_p.c",
|
||||
MAME_DIR .. "src/lib/formats/zx81_p.h",
|
||||
MAME_DIR .. "src/lib/formats/hxcmfm_dsk.c",
|
||||
|
@ -15,16 +15,17 @@ files {
|
||||
MAME_DIR .. "src/emu/netlist/nl_setup.h",
|
||||
MAME_DIR .. "src/emu/netlist/nl_factory.c",
|
||||
MAME_DIR .. "src/emu/netlist/nl_factory.h",
|
||||
MAME_DIR .. "src/emu/netlist/pconfig.h",
|
||||
MAME_DIR .. "src/emu/netlist/palloc.c",
|
||||
MAME_DIR .. "src/emu/netlist/palloc.h",
|
||||
MAME_DIR .. "src/emu/netlist/plists.h",
|
||||
MAME_DIR .. "src/emu/netlist/pparser.c",
|
||||
MAME_DIR .. "src/emu/netlist/pparser.h",
|
||||
MAME_DIR .. "src/emu/netlist/pstate.c",
|
||||
MAME_DIR .. "src/emu/netlist/pstate.h",
|
||||
MAME_DIR .. "src/emu/netlist/pstring.c",
|
||||
MAME_DIR .. "src/emu/netlist/pstring.h",
|
||||
MAME_DIR .. "src/emu/netlist/plib/pconfig.h",
|
||||
MAME_DIR .. "src/emu/netlist/plib/palloc.c",
|
||||
MAME_DIR .. "src/emu/netlist/plib/palloc.h",
|
||||
MAME_DIR .. "src/emu/netlist/plib/plists.h",
|
||||
MAME_DIR .. "src/emu/netlist/plib/poptions.h",
|
||||
MAME_DIR .. "src/emu/netlist/plib/pparser.c",
|
||||
MAME_DIR .. "src/emu/netlist/plib/pparser.h",
|
||||
MAME_DIR .. "src/emu/netlist/plib/pstate.c",
|
||||
MAME_DIR .. "src/emu/netlist/plib/pstate.h",
|
||||
MAME_DIR .. "src/emu/netlist/plib/pstring.c",
|
||||
MAME_DIR .. "src/emu/netlist/plib/pstring.h",
|
||||
MAME_DIR .. "src/emu/netlist/analog/nld_bjt.c",
|
||||
MAME_DIR .. "src/emu/netlist/analog/nld_bjt.h",
|
||||
MAME_DIR .. "src/emu/netlist/analog/nld_fourterm.c",
|
||||
|
@ -448,7 +448,7 @@ links {
|
||||
includedirs {
|
||||
MAME_DIR .. "src/osd",
|
||||
MAME_DIR .. "src/lib/util",
|
||||
MAME_DIR .. "src/emu",
|
||||
MAME_DIR .. "src/emu/netlist",
|
||||
}
|
||||
|
||||
files {
|
||||
|
@ -46,6 +46,8 @@ newoption {
|
||||
{ "vs2013-xp", "Visual Studio 2013 targeting XP" },
|
||||
{ "winphone8", "Windows Phone 8.0" },
|
||||
{ "winphone81", "Windows Phone 8.1" },
|
||||
{ "winstore81", "Windows Store 8.1" },
|
||||
{ "winstore82", "Universal Windows App" }
|
||||
},
|
||||
}
|
||||
|
||||
@ -317,6 +319,20 @@ function toolchain(_buildDir, _subDir)
|
||||
location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-winphone81")
|
||||
end
|
||||
|
||||
if "winstore81" == _OPTIONS["vs"] then
|
||||
premake.vstudio.toolset = "v120"
|
||||
premake.vstudio.storeapp = "8.1"
|
||||
platforms { "ARM" }
|
||||
location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-winstore81")
|
||||
end
|
||||
|
||||
if "winstore82" == _OPTIONS["vs"] then
|
||||
premake.vstudio.toolset = "v140"
|
||||
premake.vstudio.storeapp = "8.2"
|
||||
platforms { "ARM" }
|
||||
location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-winstore82")
|
||||
end
|
||||
|
||||
if "intel-14" == _OPTIONS["vs"] then
|
||||
premake.vstudio.toolset = "Intel C++ Compiler XE 14.0"
|
||||
location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-intel")
|
||||
@ -407,12 +423,19 @@ function toolchain(_buildDir, _subDir)
|
||||
|
||||
configuration { "x64", "vs*-clang", "Debug" }
|
||||
targetdir (_buildDir .. _ACTION .. "-clang/bin/x64/Debug")
|
||||
|
||||
|
||||
configuration { "vs*-clang" }
|
||||
buildoptions {
|
||||
"-Qunused-arguments",
|
||||
}
|
||||
|
||||
configuration { "winphone8* or winstore8*" }
|
||||
removeflags {
|
||||
"StaticRuntime",
|
||||
"NoExceptions",
|
||||
"EnableMinimalRebuild",
|
||||
}
|
||||
|
||||
configuration { "mingw*" }
|
||||
defines { "WIN32" }
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Fabio Priuli,Pierpaolo Prazzoli,Grazvydas Ignotas
|
||||
/****************************************** SVP related *****************************************/
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Fabio Priuli,Pierpaolo Prazzoli,Grazvydas Ignotas
|
||||
#ifndef __MD_SVP_H
|
||||
#define __MD_SVP_H
|
||||
|
@ -1010,8 +1010,7 @@ inline bool mips3_device::RBYTE(offs_t address, UINT32 *result)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
UINT8 *fastbase = (UINT8*)m_fastram[ramnum].base - m_fastram[ramnum].start;
|
||||
*result = fastbase[tlbaddress ^ m_byte_xor];
|
||||
*result = m_fastram[ramnum].offset_base8[tlbaddress ^ m_byte_xor];
|
||||
return true;
|
||||
}
|
||||
*result = (*m_memory.read_byte)(*m_program, tlbaddress);
|
||||
@ -1044,8 +1043,7 @@ inline bool mips3_device::RHALF(offs_t address, UINT32 *result)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
UINT8 *fastbase = (UINT8*)m_fastram[ramnum].base - m_fastram[ramnum].start;
|
||||
*result = ((UINT16*)fastbase)[(tlbaddress ^ m_word_xor) >> 1];
|
||||
*result = m_fastram[ramnum].offset_base16[(tlbaddress ^ m_word_xor) >> 1];
|
||||
return true;
|
||||
}
|
||||
*result = (*m_memory.read_word)(*m_program, tlbaddress);
|
||||
@ -1078,8 +1076,7 @@ inline bool mips3_device::RWORD(offs_t address, UINT32 *result)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
UINT8 *fastbase = (UINT8*)m_fastram[ramnum].base - m_fastram[ramnum].start;
|
||||
*result = ((UINT32*)fastbase)[tlbaddress >> 2];
|
||||
*result = m_fastram[ramnum].offset_base32[tlbaddress >> 2];
|
||||
return true;
|
||||
}
|
||||
*result = (*m_memory.read_dword)(*m_program, tlbaddress);
|
||||
@ -1181,8 +1178,7 @@ inline void mips3_device::WBYTE(offs_t address, UINT8 data)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
UINT8 *fastbase = (UINT8*)m_fastram[ramnum].base - m_fastram[ramnum].start;
|
||||
fastbase[tlbaddress ^ m_byte_xor] = data;
|
||||
m_fastram[ramnum].offset_base8[tlbaddress ^ m_byte_xor] = data;
|
||||
return;
|
||||
}
|
||||
(*m_memory.write_byte)(*m_program, tlbaddress, data);
|
||||
@ -1216,8 +1212,7 @@ inline void mips3_device::WHALF(offs_t address, UINT16 data)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
void *fastbase = (UINT8*)m_fastram[ramnum].base - m_fastram[ramnum].start;
|
||||
((UINT16*)fastbase)[(tlbaddress ^ m_word_xor) >> 1] = data;
|
||||
m_fastram[ramnum].offset_base16[(tlbaddress ^ m_word_xor) >> 1] = data;
|
||||
return;
|
||||
}
|
||||
(*m_memory.write_word)(*m_program, tlbaddress, data);
|
||||
@ -1251,8 +1246,7 @@ inline void mips3_device::WWORD(offs_t address, UINT32 data)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
void *fastbase = (UINT8*)m_fastram[ramnum].base - m_fastram[ramnum].start;
|
||||
((UINT32*)fastbase)[tlbaddress >> 2] = data;
|
||||
m_fastram[ramnum].offset_base32[tlbaddress >> 2] = data;
|
||||
return;
|
||||
}
|
||||
(*m_memory.write_dword)(*m_program, tlbaddress, data);
|
||||
|
@ -416,6 +416,9 @@ private:
|
||||
offs_t end; /* end of the RAM block */
|
||||
UINT8 readonly; /* TRUE if read-only */
|
||||
void * base; /* base in memory where the RAM lives */
|
||||
UINT8 * offset_base8; /* base in memory where the RAM lives, 8-bit pointer, with the start offset pre-applied */
|
||||
UINT16 * offset_base16; /* base in memory where the RAM lives, 16-bit pointer, with the start offset pre-applied */
|
||||
UINT32 * offset_base32; /* base in memory where the RAM lives, 32-bit pointer, with the start offset pre-applied */
|
||||
} m_fastram[MIPS3_MAX_FASTRAM];
|
||||
|
||||
UINT64 m_debugger_temp;
|
||||
|
@ -182,6 +182,9 @@ void mips3_device::add_fastram(offs_t start, offs_t end, UINT8 readonly, void *b
|
||||
m_fastram[m_fastram_select].end = end;
|
||||
m_fastram[m_fastram_select].readonly = readonly;
|
||||
m_fastram[m_fastram_select].base = base;
|
||||
m_fastram[m_fastram_select].offset_base8 = (UINT8*)base - start;
|
||||
m_fastram[m_fastram_select].offset_base16 = (UINT16*)((UINT8*)base - start);
|
||||
m_fastram[m_fastram_select].offset_base32 = (UINT32*)((UINT8*)base - start);
|
||||
m_fastram_select++;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Pierpaolo Prazzoli,Grazvydas Ignotas
|
||||
/*
|
||||
* Samsung SSP1601 DSP emulator
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Nathan Woods, Raphael Nabet, Miodrag Milanovic
|
||||
/*********************************************************************
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Nathan Woods, Raphael Nabet, Miodrag Milanovic
|
||||
/*********************************************************************
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Raphael Nabet, Michael Zapf
|
||||
/*
|
||||
Atmel at29c040a flash EEPROM
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Raphael Nabet, Michael Zapf
|
||||
/*
|
||||
ATMEL 29040a
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Raphael Nabet, R. Belmont
|
||||
/*
|
||||
rtc65271 emulation
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Raphael Nabet, R. Belmont
|
||||
/*
|
||||
rtc65271.h: include file for rtc65271.c
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Raphael Nabet, Michael Zapf
|
||||
/*
|
||||
HDC9224 and HDC9234 Hard and Floppy Disk Controller
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Raphael Nabet, Michael Zapf
|
||||
/* Interface */
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Frank Palazzolo, Aaron Giles, Jonathan Gevaryahu, Raphael Nabet, Couriersud, Michael Zapf
|
||||
/*
|
||||
spchroms.c - This is an emulator for "typical" speech ROMs from TI, as used by TI99/4(a).
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Frank Palazzolo, Aaron Giles, Jonathan Gevaryahu, Raphael Nabet, Couriersud, Michael Zapf
|
||||
/*
|
||||
* Voice Synthesis Memory
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Raphael Nabet, Michael Zapf
|
||||
/*
|
||||
Intel 28F640J5 Flash ROM emulation (could also handle 28F320J5 with minor
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Raphael Nabet, Michael Zapf
|
||||
/*
|
||||
strata.h: header file for strata.c
|
||||
|
@ -233,7 +233,7 @@ void wd_fdc_t::seek_start(int state)
|
||||
{
|
||||
if (TRACE_COMMAND) logerror("%s: seek %d (track=%d)\n", tag(), data, track);
|
||||
main_state = state;
|
||||
status = (status & ~(S_CRC|S_RNF|S_SPIN)) | S_BUSY;
|
||||
status &= ~(S_CRC|S_RNF|S_SPIN);
|
||||
if(head_control) {
|
||||
// TODO get value from HLT callback
|
||||
if(command & 8)
|
||||
@ -420,7 +420,7 @@ void wd_fdc_t::read_sector_start()
|
||||
}
|
||||
|
||||
main_state = READ_SECTOR;
|
||||
status = (status & ~(S_CRC|S_LOST|S_RNF|S_WP|S_DDM)) | S_BUSY;
|
||||
status &= ~(S_CRC|S_LOST|S_RNF|S_WP|S_DDM);
|
||||
drop_drq();
|
||||
if(side_control && floppy)
|
||||
floppy->ss_w((command & 0x02) ? 1 : 0);
|
||||
@ -521,7 +521,7 @@ void wd_fdc_t::read_track_start()
|
||||
}
|
||||
|
||||
main_state = READ_TRACK;
|
||||
status = (status & ~(S_LOST|S_RNF)) | S_BUSY;
|
||||
status &= ~(S_LOST|S_RNF);
|
||||
drop_drq();
|
||||
if(side_control && floppy)
|
||||
floppy->ss_w((command & 0x02) ? 1 : 0);
|
||||
@ -599,7 +599,7 @@ void wd_fdc_t::read_id_start()
|
||||
}
|
||||
|
||||
main_state = READ_ID;
|
||||
status = (status & ~(S_WP|S_DDM|S_LOST|S_RNF)) | S_BUSY;
|
||||
status &= ~(S_WP|S_DDM|S_LOST|S_RNF);
|
||||
drop_drq();
|
||||
if(side_control && floppy)
|
||||
floppy->ss_w((command & 0x02) ? 1 : 0);
|
||||
@ -675,7 +675,7 @@ void wd_fdc_t::write_track_start()
|
||||
}
|
||||
|
||||
main_state = WRITE_TRACK;
|
||||
status = (status & ~(S_WP|S_DDM|S_LOST|S_RNF)) | S_BUSY;
|
||||
status &= ~(S_WP|S_DDM|S_LOST|S_RNF);
|
||||
drop_drq();
|
||||
if(side_control && floppy)
|
||||
floppy->ss_w((command & 0x02) ? 1 : 0);
|
||||
@ -785,7 +785,7 @@ void wd_fdc_t::write_sector_start()
|
||||
}
|
||||
|
||||
main_state = WRITE_SECTOR;
|
||||
status = (status & ~(S_CRC|S_LOST|S_RNF|S_WP|S_DDM)) | S_BUSY;
|
||||
status &= ~(S_CRC|S_LOST|S_RNF|S_WP|S_DDM);
|
||||
drop_drq();
|
||||
if(side_control && floppy)
|
||||
floppy->ss_w((command & 0x02) ? 1 : 0);
|
||||
@ -1041,7 +1041,17 @@ void wd_fdc_t::cmd_w(UINT8 val)
|
||||
|
||||
cmd_buffer = val;
|
||||
|
||||
delay_cycles(t_cmd, dden ? delay_command_commit*2 : delay_command_commit);
|
||||
if ((val & 0xf0) == 0xd0)
|
||||
{
|
||||
// force interrupt is executed instantly (?)
|
||||
delay_cycles(t_cmd, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// set busy, then set a timer to process the command
|
||||
status |= S_BUSY;
|
||||
delay_cycles(t_cmd, dden ? delay_command_commit*2 : delay_command_commit);
|
||||
}
|
||||
}
|
||||
|
||||
UINT8 wd_fdc_t::status_r()
|
||||
@ -1649,6 +1659,10 @@ void wd_fdc_t::live_run(attotime limit)
|
||||
cur_live.shift_reg == 0xf56b ? 0x9fc6 :
|
||||
cur_live.shift_reg == 0xf56e ? 0xafa5 :
|
||||
0xbf84;
|
||||
|
||||
if((cur_live.data_reg & 0xfe) == 0xf8)
|
||||
status |= S_DDM;
|
||||
|
||||
cur_live.data_separator_phase = false;
|
||||
cur_live.bit_counter = 0;
|
||||
cur_live.state = READ_SECTOR_DATA;
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#include "nld_solver.h"
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
class netlist_matrix_solver_direct_t: public netlist_matrix_solver_t
|
||||
{
|
||||
public:
|
||||
@ -23,7 +23,7 @@ public:
|
||||
/* ATTR_COLD */ virtual void vsetup(netlist_analog_net_t::list_t &nets);
|
||||
/* ATTR_COLD */ virtual void reset() { netlist_matrix_solver_t::reset(); }
|
||||
|
||||
ATTR_HOT inline int N() const { return (m_N == 0 ? m_dim : m_N); }
|
||||
ATTR_HOT inline unsigned N() const { if (m_N == 0) return m_dim; else return m_N; }
|
||||
|
||||
ATTR_HOT inline int vsolve_non_dynamic(const bool newton_raphson);
|
||||
|
||||
@ -56,7 +56,7 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
const int m_dim;
|
||||
const unsigned m_dim;
|
||||
nl_double m_lp_fact;
|
||||
};
|
||||
|
||||
@ -64,10 +64,10 @@ private:
|
||||
// netlist_matrix_solver_direct
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
netlist_matrix_solver_direct_t<m_N, _storage_N>::~netlist_matrix_solver_direct_t()
|
||||
{
|
||||
for (int k = 0; k < N(); k++)
|
||||
for (unsigned k = 0; k < N(); k++)
|
||||
{
|
||||
pfree(m_terms[k]);
|
||||
}
|
||||
@ -75,7 +75,7 @@ netlist_matrix_solver_direct_t<m_N, _storage_N>::~netlist_matrix_solver_direct_t
|
||||
pfree_array(m_rails_temp);
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::compute_next_timestep()
|
||||
{
|
||||
nl_double new_solver_timestep = m_params.m_max_timestep;
|
||||
@ -86,7 +86,7 @@ ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::compute_next
|
||||
* FIXME: We should extend the logic to use either all nets or
|
||||
* only output nets.
|
||||
*/
|
||||
for (int k = 0; k < N(); k++)
|
||||
for (unsigned k = 0; k < N(); k++)
|
||||
{
|
||||
netlist_analog_net_t *n = m_nets[k];
|
||||
|
||||
@ -114,7 +114,7 @@ ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::compute_next
|
||||
return new_solver_timestep;
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::add_term(int k, netlist_terminal_t *term)
|
||||
{
|
||||
if (term->m_otherterm->net().isRailNet())
|
||||
@ -139,13 +139,13 @@ ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::add_term(int k,
|
||||
}
|
||||
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(netlist_analog_net_t::list_t &nets)
|
||||
{
|
||||
if (m_dim < nets.size())
|
||||
netlist().error("Dimension %d less than %" SIZETFMT, m_dim, nets.size());
|
||||
|
||||
for (int k = 0; k < N(); k++)
|
||||
for (unsigned k = 0; k < N(); k++)
|
||||
{
|
||||
m_terms[k]->clear();
|
||||
m_rails_temp[k].clear();
|
||||
@ -153,10 +153,10 @@ ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(netlist_a
|
||||
|
||||
netlist_matrix_solver_t::setup(nets);
|
||||
|
||||
for (int k = 0; k < N(); k++)
|
||||
for (unsigned k = 0; k < N(); k++)
|
||||
{
|
||||
m_terms[k]->m_railstart = m_terms[k]->count();
|
||||
for (int i = 0; i < m_rails_temp[k].count(); i++)
|
||||
for (unsigned i = 0; i < m_rails_temp[k].count(); i++)
|
||||
this->m_terms[k]->add(m_rails_temp[k].terms()[i], m_rails_temp[k].net_other()[i]);
|
||||
|
||||
m_rails_temp[k].clear(); // no longer needed
|
||||
@ -187,8 +187,8 @@ ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(netlist_a
|
||||
|
||||
int sort_order = (type() == GAUSS_SEIDEL ? 1 : -1);
|
||||
|
||||
for (int k = 0; k < N() / 2; k++)
|
||||
for (int i = 0; i < N() - 1; i++)
|
||||
for (unsigned k = 0; k < N() / 2; k++)
|
||||
for (unsigned i = 0; i < N() - 1; i++)
|
||||
{
|
||||
if ((m_terms[i]->m_railstart - m_terms[i+1]->m_railstart) * sort_order < 0)
|
||||
{
|
||||
@ -197,10 +197,10 @@ ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(netlist_a
|
||||
}
|
||||
}
|
||||
|
||||
for (int k = 0; k < N(); k++)
|
||||
for (unsigned k = 0; k < N(); k++)
|
||||
{
|
||||
int *other = m_terms[k]->net_other();
|
||||
for (int i = 0; i < m_terms[k]->count(); i++)
|
||||
for (unsigned i = 0; i < m_terms[k]->count(); i++)
|
||||
if (other[i] != -1)
|
||||
other[i] = get_net_idx(&m_terms[k]->terms()[i]->m_otherterm->net());
|
||||
}
|
||||
@ -209,35 +209,35 @@ ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(netlist_a
|
||||
}
|
||||
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::build_LE_A()
|
||||
{
|
||||
for (int k = 0; k < N(); k++)
|
||||
for (unsigned k = 0; k < N(); k++)
|
||||
{
|
||||
for (int i=0; i < N(); i++)
|
||||
for (unsigned i=0; i < N(); i++)
|
||||
m_A[k][i] = 0.0;
|
||||
|
||||
nl_double akk = 0.0;
|
||||
const int terms_count = m_terms[k]->count();
|
||||
const int railstart = m_terms[k]->m_railstart;
|
||||
const unsigned terms_count = m_terms[k]->count();
|
||||
const unsigned railstart = m_terms[k]->m_railstart;
|
||||
const nl_double * RESTRICT gt = m_terms[k]->gt();
|
||||
const nl_double * RESTRICT go = m_terms[k]->go();
|
||||
const int * RESTRICT net_other = m_terms[k]->net_other();
|
||||
|
||||
for (int i = 0; i < terms_count; i++)
|
||||
for (unsigned i = 0; i < terms_count; i++)
|
||||
akk = akk + gt[i];
|
||||
|
||||
m_A[k][k] += akk;
|
||||
|
||||
for (int i = 0; i < railstart; i++)
|
||||
for (unsigned i = 0; i < railstart; i++)
|
||||
m_A[k][net_other[i]] += -go[i];
|
||||
}
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::build_LE_RHS()
|
||||
{
|
||||
for (int k = 0; k < N(); k++)
|
||||
for (unsigned k = 0; k < N(); k++)
|
||||
{
|
||||
nl_double rhsk_a = 0.0;
|
||||
nl_double rhsk_b = 0.0;
|
||||
@ -258,7 +258,7 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::build_LE_RHS()
|
||||
}
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_solve()
|
||||
{
|
||||
#if 0
|
||||
@ -271,15 +271,15 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_solve()
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
const int kN = N();
|
||||
const unsigned kN = N();
|
||||
|
||||
for (int i = 0; i < kN; i++) {
|
||||
for (unsigned i = 0; i < kN; i++) {
|
||||
// FIXME: use a parameter to enable pivoting?
|
||||
if (USE_PIVOT_SEARCH)
|
||||
{
|
||||
/* Find the row with the largest first value */
|
||||
int maxrow = i;
|
||||
for (int j = i + 1; j < kN; j++)
|
||||
unsigned maxrow = i;
|
||||
for (unsigned j = i + 1; j < kN; j++)
|
||||
{
|
||||
if (nl_math::abs(m_A[j][i]) > nl_math::abs(m_A[maxrow][i]))
|
||||
maxrow = j;
|
||||
@ -288,7 +288,7 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_solve()
|
||||
if (maxrow != i)
|
||||
{
|
||||
/* Swap the maxrow and ith row */
|
||||
for (int k = i; k < kN; k++) {
|
||||
for (unsigned k = i; k < kN; k++) {
|
||||
std::swap(m_A[i][k], m_A[maxrow][k]);
|
||||
}
|
||||
std::swap(m_RHS[i], m_RHS[maxrow]);
|
||||
@ -300,12 +300,12 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_solve()
|
||||
|
||||
/* Eliminate column i from row j */
|
||||
|
||||
for (int j = i + 1; j < kN; j++)
|
||||
for (unsigned j = i + 1; j < kN; j++)
|
||||
{
|
||||
const nl_double f1 = - m_A[j][i] * f;
|
||||
if (f1 != NL_FCONST(0.0))
|
||||
{
|
||||
for (int k = i + 1; k < kN; k++)
|
||||
for (unsigned k = i + 1; k < kN; k++)
|
||||
m_A[j][k] += m_A[i][k] * f1;
|
||||
m_RHS[j] += m_RHS[i] * f1;
|
||||
}
|
||||
@ -313,18 +313,18 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_solve()
|
||||
}
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_back_subst(
|
||||
nl_double * RESTRICT x)
|
||||
{
|
||||
const int kN = N();
|
||||
const unsigned kN = N();
|
||||
|
||||
/* back substitution */
|
||||
for (int j = kN - 1; j >= 0; j--)
|
||||
{
|
||||
nl_double tmp = 0;
|
||||
|
||||
for (int k = j + 1; k < kN; k++)
|
||||
for (unsigned k = j + 1; k < kN; k++)
|
||||
tmp += m_A[j][k] * x[k];
|
||||
|
||||
x[j] = (m_RHS[j] - tmp) / m_A[j][j];
|
||||
@ -342,13 +342,13 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_back_subst(
|
||||
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::delta(
|
||||
const nl_double * RESTRICT V)
|
||||
{
|
||||
nl_double cerr = 0;
|
||||
nl_double cerr2 = 0;
|
||||
for (int i = 0; i < this->N(); i++)
|
||||
for (unsigned i = 0; i < this->N(); i++)
|
||||
{
|
||||
const nl_double e = nl_math::abs(V[i] - this->m_nets[i]->m_cur_Analog);
|
||||
const nl_double e2 = nl_math::abs(m_RHS[i] - this->m_last_RHS[i]);
|
||||
@ -359,24 +359,24 @@ ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::delta(
|
||||
return cerr + cerr2*NL_FCONST(100000.0);
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::store(
|
||||
const nl_double * RESTRICT V, const bool store_RHS)
|
||||
{
|
||||
for (int i = 0; i < this->N(); i++)
|
||||
for (unsigned i = 0; i < this->N(); i++)
|
||||
{
|
||||
this->m_nets[i]->m_cur_Analog = V[i];
|
||||
}
|
||||
if (store_RHS)
|
||||
{
|
||||
for (int i = 0; i < this->N(); i++)
|
||||
for (unsigned i = 0; i < this->N(); i++)
|
||||
{
|
||||
this->m_last_RHS[i] = m_RHS[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve()
|
||||
{
|
||||
solve_base<netlist_matrix_solver_direct_t>(this);
|
||||
@ -384,7 +384,7 @@ ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve()
|
||||
}
|
||||
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT int netlist_matrix_solver_direct_t<m_N, _storage_N>::solve_non_dynamic(ATTR_UNUSED const bool newton_raphson)
|
||||
{
|
||||
nl_double new_v[_storage_N]; // = { 0.0 };
|
||||
@ -406,7 +406,7 @@ ATTR_HOT int netlist_matrix_solver_direct_t<m_N, _storage_N>::solve_non_dynamic(
|
||||
}
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT inline int netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve_non_dynamic(const bool newton_raphson)
|
||||
{
|
||||
this->build_LE_A();
|
||||
@ -416,7 +416,7 @@ ATTR_HOT inline int netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve_non_
|
||||
return this->solve_non_dynamic(newton_raphson);
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
netlist_matrix_solver_direct_t<m_N, _storage_N>::netlist_matrix_solver_direct_t(const netlist_solver_parameters_t ¶ms, const int size)
|
||||
: netlist_matrix_solver_t(GAUSSIAN_ELIMINATION, params)
|
||||
, m_dim(size)
|
||||
@ -425,7 +425,7 @@ netlist_matrix_solver_direct_t<m_N, _storage_N>::netlist_matrix_solver_direct_t(
|
||||
m_terms = palloc_array(terms_t *, N());
|
||||
m_rails_temp = palloc_array(terms_t, N());
|
||||
|
||||
for (int k = 0; k < N(); k++)
|
||||
for (unsigned k = 0; k < N(); k++)
|
||||
{
|
||||
m_terms[k] = palloc(terms_t);
|
||||
m_last_RHS[k] = 0.0;
|
||||
@ -433,7 +433,7 @@ netlist_matrix_solver_direct_t<m_N, _storage_N>::netlist_matrix_solver_direct_t(
|
||||
}
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
netlist_matrix_solver_direct_t<m_N, _storage_N>::netlist_matrix_solver_direct_t(const eSolverType type, const netlist_solver_parameters_t ¶ms, const int size)
|
||||
: netlist_matrix_solver_t(type, params)
|
||||
, m_dim(size)
|
||||
@ -442,7 +442,7 @@ netlist_matrix_solver_direct_t<m_N, _storage_N>::netlist_matrix_solver_direct_t(
|
||||
m_terms = palloc_array(terms_t *, N());
|
||||
m_rails_temp = palloc_array(terms_t, N());
|
||||
|
||||
for (int k = 0; k < N(); k++)
|
||||
for (unsigned k = 0; k < N(); k++)
|
||||
{
|
||||
m_terms[k] = palloc(terms_t);
|
||||
m_last_RHS[k] = 0.0;
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "nld_solver.h"
|
||||
#include "nld_ms_direct.h"
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
class netlist_matrix_solver_SOR_t: public netlist_matrix_solver_direct_t<m_N, _storage_N>
|
||||
{
|
||||
public:
|
||||
@ -46,7 +46,7 @@ private:
|
||||
// netlist_matrix_solver - Gauss - Seidel
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
void netlist_matrix_solver_SOR_t<m_N, _storage_N>::log_stats()
|
||||
{
|
||||
if (this->m_stat_calculations != 0 && this->m_params.m_log_stats)
|
||||
@ -66,14 +66,14 @@ void netlist_matrix_solver_SOR_t<m_N, _storage_N>::log_stats()
|
||||
}
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT nl_double netlist_matrix_solver_SOR_t<m_N, _storage_N>::vsolve()
|
||||
{
|
||||
this->solve_base(this);
|
||||
return this->compute_next_timestep();
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT inline int netlist_matrix_solver_SOR_t<m_N, _storage_N>::vsolve_non_dynamic(const bool newton_raphson)
|
||||
{
|
||||
const int iN = this->N();
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "nld_solver.h"
|
||||
#include "nld_ms_direct.h"
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
class netlist_matrix_solver_SOR_mat_t: public netlist_matrix_solver_direct_t<m_N, _storage_N>
|
||||
{
|
||||
public:
|
||||
@ -57,7 +57,7 @@ private:
|
||||
// netlist_matrix_solver - Gauss - Seidel
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
void netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::log_stats()
|
||||
{
|
||||
if (this->m_stat_calculations != 0 && m_log_stats)
|
||||
@ -77,7 +77,7 @@ void netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::log_stats()
|
||||
}
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT nl_double netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::vsolve()
|
||||
{
|
||||
/*
|
||||
@ -85,13 +85,13 @@ ATTR_HOT nl_double netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::vsolve()
|
||||
*/
|
||||
|
||||
if (USE_LINEAR_PREDICTION)
|
||||
for (int k = 0; k < this->N(); k++)
|
||||
for (unsigned k = 0; k < this->N(); k++)
|
||||
{
|
||||
this->m_last_V[k] = this->m_nets[k]->m_cur_Analog;
|
||||
this->m_nets[k]->m_cur_Analog = this->m_nets[k]->m_cur_Analog + this->m_Vdelta[k] * this->current_timestep() * m_lp_fact;
|
||||
}
|
||||
else
|
||||
for (int k = 0; k < this->N(); k++)
|
||||
for (unsigned k = 0; k < this->N(); k++)
|
||||
{
|
||||
this->m_last_V[k] = this->m_nets[k]->m_cur_Analog;
|
||||
}
|
||||
@ -103,7 +103,7 @@ ATTR_HOT nl_double netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::vsolve()
|
||||
nl_double sq = 0;
|
||||
nl_double sqo = 0;
|
||||
const nl_double rez_cts = 1.0 / this->current_timestep();
|
||||
for (int k = 0; k < this->N(); k++)
|
||||
for (unsigned k = 0; k < this->N(); k++)
|
||||
{
|
||||
const netlist_analog_net_t *n = this->m_nets[k];
|
||||
const nl_double nv = (n->m_cur_Analog - this->m_last_V[k]) * rez_cts ;
|
||||
@ -123,7 +123,7 @@ ATTR_HOT nl_double netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::vsolve()
|
||||
return this->compute_next_timestep();
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT inline int netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::vsolve_non_dynamic(const bool newton_raphson)
|
||||
{
|
||||
/* The matrix based code looks a lot nicer but actually is 30% slower than
|
||||
|
@ -51,7 +51,7 @@ ATTR_COLD void terms_t::add(netlist_terminal_t *term, int net_other)
|
||||
|
||||
ATTR_COLD void terms_t::set_pointers()
|
||||
{
|
||||
for (int i = 0; i < count(); i++)
|
||||
for (unsigned i = 0; i < count(); i++)
|
||||
{
|
||||
m_term[i]->m_gt1 = &m_gt[i];
|
||||
m_term[i]->m_go1 = &m_go[i];
|
||||
@ -156,7 +156,7 @@ ATTR_COLD void netlist_matrix_solver_t::setup(netlist_analog_net_t::list_t &nets
|
||||
break;
|
||||
}
|
||||
}
|
||||
NL_VERBOSE_OUT(("added net with %d populated connections\n", net->m_core_terms.size()));
|
||||
//NL_VERBOSE_OUT(("added net with %" SIZETFMT " populated connections\n", net->m_core_terms.size()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ class terms_t
|
||||
|
||||
ATTR_COLD void add(netlist_terminal_t *term, int net_other);
|
||||
|
||||
ATTR_HOT inline int count() { return m_term.size(); }
|
||||
ATTR_HOT inline unsigned count() { return m_term.size(); }
|
||||
|
||||
ATTR_HOT inline netlist_terminal_t **terms() { return m_term.data(); }
|
||||
ATTR_HOT inline int *net_other() { return m_net_other.data(); }
|
||||
@ -76,7 +76,7 @@ class terms_t
|
||||
|
||||
ATTR_COLD void set_pointers();
|
||||
|
||||
int m_railstart;
|
||||
unsigned m_railstart;
|
||||
|
||||
private:
|
||||
plist_t<netlist_terminal_t *> m_term;
|
||||
|
@ -41,7 +41,7 @@ NETLIST_END()
|
||||
#define ENTRY1(_nic, _name, _defparam) factory.register_device<_nic>( # _name, xstr(_nic), _defparam );
|
||||
#define ENTRY(_nic, _name, _defparam) ENTRY1(NETLIB_NAME(_nic), _name, _defparam)
|
||||
|
||||
void nl_initialize_factory(netlist_factory_t &factory)
|
||||
void nl_initialize_factory(netlist_factory_list_t &factory)
|
||||
{
|
||||
ENTRY(R, RES, "R")
|
||||
ENTRY(POT, POT, "R")
|
||||
|
@ -67,6 +67,6 @@
|
||||
NETLIST_EXTERNAL(diode_models);
|
||||
NETLIST_EXTERNAL(bjt_models);
|
||||
|
||||
void nl_initialize_factory(netlist_factory_t &factory);
|
||||
void nl_initialize_factory(netlist_factory_list_t &factory);
|
||||
|
||||
#endif
|
||||
|
@ -76,7 +76,7 @@ NETLIB_START(extclock)
|
||||
connect(m_feedback, m_Q);
|
||||
{
|
||||
netlist_time base = netlist_time::from_hz(m_freq.Value()*2);
|
||||
nl_util::pstring_list pat = nl_util::split(m_pattern.Value(),",");
|
||||
pstring_list_t pat(m_pattern.Value(),",");
|
||||
m_off = netlist_time::from_double(m_offset.Value());
|
||||
|
||||
int pati[256];
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "nld_truthtable.h"
|
||||
#include "../plists.h"
|
||||
#include "../plib/plists.h"
|
||||
|
||||
unsigned truthtable_desc_t::count_bits(UINT32 v)
|
||||
{
|
||||
@ -97,7 +97,7 @@ UINT32 truthtable_desc_t::get_ignored_extended(UINT32 i)
|
||||
// desc
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
ATTR_COLD void truthtable_desc_t::help(unsigned cur, nl_util::pstring_list list,
|
||||
ATTR_COLD void truthtable_desc_t::help(unsigned cur, pstring_list_t list,
|
||||
UINT64 state,UINT16 val, UINT8 *timing_index)
|
||||
{
|
||||
pstring elem = list[cur].trim();
|
||||
@ -142,15 +142,17 @@ ATTR_COLD void truthtable_desc_t::help(unsigned cur, nl_util::pstring_list list,
|
||||
}
|
||||
}
|
||||
|
||||
ATTR_COLD void truthtable_desc_t::setup(const char **truthtable, UINT32 disabled_ignore)
|
||||
ATTR_COLD void truthtable_desc_t::setup(const pstring_list_t &truthtable, UINT32 disabled_ignore)
|
||||
{
|
||||
unsigned line = 0;
|
||||
|
||||
if (*m_initialized)
|
||||
return;
|
||||
|
||||
pstring ttline = pstring(truthtable[0]);
|
||||
truthtable++;
|
||||
ttline = pstring(truthtable[0]);
|
||||
truthtable++;
|
||||
pstring ttline = truthtable[line];
|
||||
line++;
|
||||
ttline = truthtable[line];
|
||||
line++;
|
||||
|
||||
for (unsigned j=0; j < m_size; j++)
|
||||
m_outs[j] = ~0L;
|
||||
@ -160,14 +162,14 @@ ATTR_COLD void truthtable_desc_t::setup(const char **truthtable, UINT32 disabled
|
||||
|
||||
while (!ttline.equals(""))
|
||||
{
|
||||
nl_util::pstring_list io = nl_util::split(ttline,"|");
|
||||
pstring_list_t io(ttline,"|");
|
||||
// checks
|
||||
nl_assert_always(io.size() == 3, "io.count mismatch");
|
||||
nl_util::pstring_list inout = nl_util::split(io[0], ",");
|
||||
pstring_list_t inout(io[0], ",");
|
||||
nl_assert_always(inout.size() == m_num_bits, "number of bits not matching");
|
||||
nl_util::pstring_list out = nl_util::split(io[1], ",");
|
||||
pstring_list_t out(io[1], ",");
|
||||
nl_assert_always(out.size() == m_NO, "output count not matching");
|
||||
nl_util::pstring_list times = nl_util::split(io[2], ",");
|
||||
pstring_list_t times(io[2], ",");
|
||||
nl_assert_always(times.size() == m_NO, "timing count not matching");
|
||||
|
||||
UINT16 val = 0;
|
||||
@ -189,8 +191,8 @@ ATTR_COLD void truthtable_desc_t::setup(const char **truthtable, UINT32 disabled
|
||||
}
|
||||
|
||||
help(0, inout, 0 , val, tindex.data());
|
||||
ttline = pstring(truthtable[0]);
|
||||
truthtable++;
|
||||
ttline = truthtable[line];
|
||||
line++;
|
||||
}
|
||||
|
||||
// determine ignore
|
||||
@ -233,3 +235,35 @@ ATTR_COLD void truthtable_desc_t::setup(const char **truthtable, UINT32 disabled
|
||||
*m_initialized = true;
|
||||
|
||||
}
|
||||
|
||||
#define ENTRYX(_n,_m,_h) case (_n * 1000 + _m * 10 + _h): \
|
||||
{ typedef netlist_factory_truthtable_t<_n,_m,_h> xtype; \
|
||||
return palloc(xtype,name,classname,def_param); } break
|
||||
|
||||
#define ENTRYY(_n,_m) ENTRYX(_n,_m,0); ENTRYX(_n,_m,1)
|
||||
|
||||
#define ENTRY(_n) ENTRYY(_n, 1); ENTRYY(_n, 2); ENTRYY(_n, 3); ENTRYY(_n, 4); ENTRYY(_n, 5); ENTRYY(_n, 6)
|
||||
|
||||
netlist_base_factory_truthtable_t *nl_tt_factory_create(const unsigned ni, const unsigned no,
|
||||
const unsigned has_state,
|
||||
const pstring &name, const pstring &classname,
|
||||
const pstring &def_param)
|
||||
{
|
||||
switch (ni * 1000 + no * 10 + has_state)
|
||||
{
|
||||
ENTRY(1);
|
||||
ENTRY(2);
|
||||
ENTRY(3);
|
||||
ENTRY(4);
|
||||
ENTRY(5);
|
||||
ENTRY(6);
|
||||
ENTRY(7);
|
||||
ENTRY(8);
|
||||
ENTRY(9);
|
||||
ENTRY(10);
|
||||
default:
|
||||
pstring msg = pstring::sprintf("unable to create truthtable<%d,%d,%d>", ni, no, has_state);
|
||||
nl_assert_always(false, msg.cstr());
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#define NLD_TRUTHTABLE_H_
|
||||
|
||||
#include "../nl_base.h"
|
||||
#include "../nl_factory.h"
|
||||
|
||||
#define NETLIB_TRUTHTABLE(_name, _nIN, _nOUT, _state) \
|
||||
class NETLIB_NAME(_name) : public nld_truthtable_t<_nIN, _nOUT, _state> \
|
||||
@ -44,10 +45,10 @@ struct truthtable_desc_t
|
||||
{
|
||||
}
|
||||
|
||||
ATTR_COLD void setup(const char **truthtable, UINT32 disabled_ignore);
|
||||
ATTR_COLD void setup(const pstring_list_t &desc, UINT32 disabled_ignore);
|
||||
|
||||
private:
|
||||
ATTR_COLD void help(unsigned cur, nl_util::pstring_list list,
|
||||
ATTR_COLD void help(unsigned cur, pstring_list_t list,
|
||||
UINT64 state,UINT16 val, UINT8 *timing_index);
|
||||
static unsigned count_bits(UINT32 v);
|
||||
static UINT32 set_bits(UINT32 v, UINT32 b);
|
||||
@ -89,28 +90,40 @@ public:
|
||||
};
|
||||
|
||||
nld_truthtable_t(truthtable_t *ttbl, const char *desc[])
|
||||
: netlist_device_t(), m_last_state(0), m_ign(0), m_active(1), m_ttp(ttbl), m_desc(desc)
|
||||
: netlist_device_t(), m_last_state(0), m_ign(0), m_active(1), m_ttp(ttbl)
|
||||
{
|
||||
while (*desc != NULL && **desc != 0 )
|
||||
{
|
||||
m_desc.add(*desc);
|
||||
desc++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
nld_truthtable_t(truthtable_t *ttbl, const pstring_list_t &desc)
|
||||
: netlist_device_t(), m_last_state(0), m_ign(0), m_active(1), m_ttp(ttbl)
|
||||
{
|
||||
m_desc = desc;
|
||||
}
|
||||
|
||||
/* ATTR_COLD */ virtual void start()
|
||||
{
|
||||
pstring ttline = pstring(m_desc[0]);
|
||||
pstring header = m_desc[0];
|
||||
|
||||
nl_util::pstring_list io = nl_util::split(ttline,"|");
|
||||
pstring_list_t io(header,"|");
|
||||
// checks
|
||||
nl_assert_always(io.size() == 2, "too many '|'");
|
||||
nl_util::pstring_list inout = nl_util::split(io[0], ",");
|
||||
pstring_list_t inout(io[0], ",");
|
||||
nl_assert_always(inout.size() == m_num_bits, "bitcount wrong");
|
||||
nl_util::pstring_list out = nl_util::split(io[1], ",");
|
||||
pstring_list_t out(io[1], ",");
|
||||
nl_assert_always(out.size() == m_NO, "output count wrong");
|
||||
|
||||
for (int i=0; i < m_NI; i++)
|
||||
for (unsigned i=0; i < m_NI; i++)
|
||||
{
|
||||
inout[i] = inout[i].trim();
|
||||
register_input(inout[i], m_i[i]);
|
||||
}
|
||||
for (int i=0; i < m_NO; i++)
|
||||
for (unsigned i=0; i < m_NO; i++)
|
||||
{
|
||||
out[i] = out[i].trim();
|
||||
register_output(out[i], m_Q[i]);
|
||||
@ -118,7 +131,7 @@ public:
|
||||
// Connect output "Q" to input "_Q" if this exists
|
||||
// This enables timed state without having explicit state ....
|
||||
UINT32 disabled_ignore = 0;
|
||||
for (int i=0; i < m_NO; i++)
|
||||
for (unsigned i=0; i < m_NO; i++)
|
||||
{
|
||||
pstring tmp = "_" + out[i];
|
||||
const int idx = inout.indexof(tmp);
|
||||
@ -154,7 +167,7 @@ public:
|
||||
ATTR_COLD void reset()
|
||||
{
|
||||
m_active = 0;
|
||||
for (int i=0; i<m_NO;i++)
|
||||
for (unsigned i=0; i<m_NO;i++)
|
||||
if (this->m_Q[i].net().num_cons()>0)
|
||||
m_active++;
|
||||
m_last_state = 0;
|
||||
@ -193,14 +206,14 @@ public:
|
||||
const UINT32 timebase = nstate * m_NO;
|
||||
if (doOUT)
|
||||
{
|
||||
for (int i = 0; i < m_NO; i++)
|
||||
for (unsigned i = 0; i < m_NO; i++)
|
||||
OUTLOGIC(m_Q[i], (out >> i) & 1, m_ttp->m_timing_nt[m_ttp->m_timing[timebase + i]]);
|
||||
}
|
||||
else
|
||||
for (int i = 0; i < m_NO; i++)
|
||||
for (unsigned i = 0; i < m_NO; i++)
|
||||
m_Q[i].net().set_Q_time((out >> i) & 1, mt + m_ttp->m_timing_nt[m_ttp->m_timing[timebase + i]]);
|
||||
|
||||
for (int i = 0; i < m_NI; i++)
|
||||
for (unsigned i = 0; i < m_NI; i++)
|
||||
if (m_ign & (1 << i))
|
||||
m_i[i].inactivate();
|
||||
|
||||
@ -227,7 +240,7 @@ public:
|
||||
if (has_state == 0)
|
||||
if (--m_active == 0)
|
||||
{
|
||||
for (int i = 0; i< m_NI; i++)
|
||||
for (unsigned i = 0; i< m_NI; i++)
|
||||
m_i[i].inactivate();
|
||||
}
|
||||
}
|
||||
@ -242,10 +255,60 @@ private:
|
||||
INT32 m_active;
|
||||
|
||||
truthtable_t *m_ttp;
|
||||
const char **m_desc;
|
||||
pstring_list_t m_desc;
|
||||
};
|
||||
|
||||
class netlist_base_factory_truthtable_t : public netlist_base_factory_t
|
||||
{
|
||||
NETLIST_PREVENT_COPYING(netlist_base_factory_truthtable_t)
|
||||
public:
|
||||
ATTR_COLD netlist_base_factory_truthtable_t(const pstring &name, const pstring &classname,
|
||||
const pstring &def_param)
|
||||
: netlist_base_factory_t(name, classname, def_param)
|
||||
{}
|
||||
pstring_list_t m_desc;
|
||||
};
|
||||
|
||||
|
||||
template<unsigned m_NI, unsigned m_NO, int has_state>
|
||||
class netlist_factory_truthtable_t : public netlist_base_factory_truthtable_t
|
||||
{
|
||||
NETLIST_PREVENT_COPYING(netlist_factory_truthtable_t)
|
||||
public:
|
||||
ATTR_COLD netlist_factory_truthtable_t(const pstring &name, const pstring &classname,
|
||||
const pstring &def_param)
|
||||
: netlist_base_factory_truthtable_t(name, classname, def_param) { }
|
||||
|
||||
ATTR_COLD netlist_device_t *Create()
|
||||
{
|
||||
typedef nld_truthtable_t<m_NI, m_NO, has_state> tt_type;
|
||||
netlist_device_t *r = palloc(tt_type, &m_ttbl, m_desc);
|
||||
//r->init(setup, name);
|
||||
return r;
|
||||
}
|
||||
private:
|
||||
typename nld_truthtable_t<m_NI, m_NO, has_state>::truthtable_t m_ttbl;
|
||||
};
|
||||
|
||||
netlist_base_factory_truthtable_t *nl_tt_factory_create(const unsigned ni, const unsigned no,
|
||||
const unsigned has_state,
|
||||
const pstring &name, const pstring &classname,
|
||||
const pstring &def_param);
|
||||
|
||||
#define TRUTHTABLE_START(_name, _in, _out, _has_state, _def_params) \
|
||||
{ \
|
||||
netlist_base_factory_truthtable_t *ttd = nl_tt_factory_create(_in, _out, _has_state, \
|
||||
# _name, # _name, "+" _def_params);
|
||||
|
||||
#define TT_HEAD(_x) \
|
||||
ttd->m_desc.add(_x);
|
||||
|
||||
#define TT_LINE(_x) \
|
||||
ttd->m_desc.add(_x);
|
||||
|
||||
#define TRUTHTABLE_END() \
|
||||
setup.factory().register_device(ttd); \
|
||||
}
|
||||
|
||||
|
||||
#endif /* NLD_TRUTHTABLE_H_ */
|
||||
|
@ -7,12 +7,11 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "palloc.h"
|
||||
#include "plib/palloc.h"
|
||||
|
||||
#include "nl_base.h"
|
||||
#include "devices/nld_system.h"
|
||||
#include "analog/nld_solver.h"
|
||||
#include "pstring.h"
|
||||
#include "nl_util.h"
|
||||
|
||||
const netlist_time netlist_time::zero = netlist_time::from_raw(0);
|
||||
|
@ -158,8 +158,7 @@
|
||||
#include "nl_lists.h"
|
||||
#include "nl_time.h"
|
||||
#include "nl_util.h"
|
||||
#include "pstring.h"
|
||||
#include "pstate.h"
|
||||
#include "plib/pstate.h"
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
@ -1197,7 +1196,7 @@ public:
|
||||
plist_t<_C *> get_device_list()
|
||||
{
|
||||
plist_t<_C *> tmp;
|
||||
for (int i = 0; i < m_devices.size(); i++)
|
||||
for (std::size_t i = 0; i < m_devices.size(); i++)
|
||||
{
|
||||
_C *dev = dynamic_cast<_C *>(m_devices[i]);
|
||||
if (dev != NULL)
|
||||
@ -1209,7 +1208,7 @@ public:
|
||||
template<class _C>
|
||||
_C *get_first_device()
|
||||
{
|
||||
for (int i = 0; i < m_devices.size(); i++)
|
||||
for (std::size_t i = 0; i < m_devices.size(); i++)
|
||||
{
|
||||
_C *dev = dynamic_cast<_C *>(m_devices[i]);
|
||||
if (dev != NULL)
|
||||
@ -1222,7 +1221,7 @@ public:
|
||||
_C *get_single_device(const char *classname)
|
||||
{
|
||||
_C *ret = NULL;
|
||||
for (int i = 0; i < m_devices.size(); i++)
|
||||
for (std::size_t i = 0; i < m_devices.size(); i++)
|
||||
{
|
||||
_C *dev = dynamic_cast<_C *>(m_devices[i]);
|
||||
if (dev != NULL)
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef NLCONFIG_H_
|
||||
#define NLCONFIG_H_
|
||||
|
||||
#include "pconfig.h"
|
||||
#include "plib/pconfig.h"
|
||||
|
||||
//============================================================
|
||||
// SETUP
|
||||
@ -101,7 +101,7 @@
|
||||
#if (NL_VERBOSE)
|
||||
#define NL_VERBOSE_OUT(x) printf x
|
||||
#else
|
||||
#define NL_VERBOSE_OUT(x) do { } while (0)
|
||||
#define NL_VERBOSE_OUT(x) do { if(0) printf x ; } while (0)
|
||||
#endif
|
||||
|
||||
//============================================================
|
||||
|
@ -15,42 +15,42 @@
|
||||
// net_device_t_base_factory
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
ATTR_COLD const nl_util::pstring_list net_device_t_base_factory::term_param_list()
|
||||
ATTR_COLD const pstring_list_t netlist_base_factory_t::term_param_list()
|
||||
{
|
||||
if (m_def_param.startsWith("+"))
|
||||
return nl_util::split(m_def_param.substr(1), ",");
|
||||
return pstring_list_t(m_def_param.substr(1), ",");
|
||||
else
|
||||
return nl_util::pstring_list();
|
||||
return pstring_list_t();
|
||||
}
|
||||
|
||||
ATTR_COLD const nl_util::pstring_list net_device_t_base_factory::def_params()
|
||||
ATTR_COLD const pstring_list_t netlist_base_factory_t::def_params()
|
||||
{
|
||||
if (m_def_param.startsWith("+") || m_def_param.equals("-"))
|
||||
return nl_util::pstring_list();
|
||||
return pstring_list_t();
|
||||
else
|
||||
return nl_util::split(m_def_param, ",");
|
||||
return pstring_list_t(m_def_param, ",");
|
||||
}
|
||||
|
||||
|
||||
netlist_factory_t::netlist_factory_t()
|
||||
netlist_factory_list_t::netlist_factory_list_t()
|
||||
{
|
||||
}
|
||||
|
||||
netlist_factory_t::~netlist_factory_t()
|
||||
netlist_factory_list_t::~netlist_factory_list_t()
|
||||
{
|
||||
for (std::size_t i=0; i < m_list.size(); i++)
|
||||
{
|
||||
net_device_t_base_factory *p = m_list[i];
|
||||
netlist_base_factory_t *p = m_list[i];
|
||||
pfree(p);
|
||||
}
|
||||
m_list.clear();
|
||||
}
|
||||
|
||||
netlist_device_t *netlist_factory_t::new_device_by_classname(const pstring &classname) const
|
||||
netlist_device_t *netlist_factory_list_t::new_device_by_classname(const pstring &classname) const
|
||||
{
|
||||
for (std::size_t i=0; i < m_list.size(); i++)
|
||||
{
|
||||
net_device_t_base_factory *p = m_list[i];
|
||||
netlist_base_factory_t *p = m_list[i];
|
||||
if (p->classname() == classname)
|
||||
{
|
||||
netlist_device_t *ret = p->Create();
|
||||
@ -61,17 +61,17 @@ netlist_device_t *netlist_factory_t::new_device_by_classname(const pstring &clas
|
||||
return NULL; // appease code analysis
|
||||
}
|
||||
|
||||
netlist_device_t *netlist_factory_t::new_device_by_name(const pstring &name, netlist_setup_t &setup) const
|
||||
netlist_device_t *netlist_factory_list_t::new_device_by_name(const pstring &name, netlist_setup_t &setup) const
|
||||
{
|
||||
net_device_t_base_factory *f = factory_by_name(name, setup);
|
||||
netlist_base_factory_t *f = factory_by_name(name, setup);
|
||||
return f->Create();
|
||||
}
|
||||
|
||||
net_device_t_base_factory * netlist_factory_t::factory_by_name(const pstring &name, netlist_setup_t &setup) const
|
||||
netlist_base_factory_t * netlist_factory_list_t::factory_by_name(const pstring &name, netlist_setup_t &setup) const
|
||||
{
|
||||
for (std::size_t i=0; i < m_list.size(); i++)
|
||||
{
|
||||
net_device_t_base_factory *p = m_list[i];
|
||||
netlist_base_factory_t *p = m_list[i];
|
||||
if (p->name() == name)
|
||||
{
|
||||
return p;
|
||||
|
@ -10,33 +10,32 @@
|
||||
#define NLFACTORY_H_
|
||||
|
||||
#include "nl_config.h"
|
||||
#include "palloc.h"
|
||||
#include "plists.h"
|
||||
#include "plib/palloc.h"
|
||||
#include "plib/plists.h"
|
||||
#include "nl_base.h"
|
||||
#include "pstring.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// net_dev class factory
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
class net_device_t_base_factory
|
||||
class netlist_base_factory_t
|
||||
{
|
||||
NETLIST_PREVENT_COPYING(net_device_t_base_factory)
|
||||
NETLIST_PREVENT_COPYING(netlist_base_factory_t)
|
||||
public:
|
||||
ATTR_COLD net_device_t_base_factory(const pstring &name, const pstring &classname,
|
||||
ATTR_COLD netlist_base_factory_t(const pstring &name, const pstring &classname,
|
||||
const pstring &def_param)
|
||||
: m_name(name), m_classname(classname), m_def_param(def_param)
|
||||
{}
|
||||
|
||||
/* ATTR_COLD */ virtual ~net_device_t_base_factory() {}
|
||||
/* ATTR_COLD */ virtual ~netlist_base_factory_t() {}
|
||||
|
||||
/* ATTR_COLD */ virtual netlist_device_t *Create() const = 0;
|
||||
/* ATTR_COLD */ virtual netlist_device_t *Create() = 0;
|
||||
|
||||
ATTR_COLD const pstring &name() const { return m_name; }
|
||||
ATTR_COLD const pstring &classname() const { return m_classname; }
|
||||
ATTR_COLD const pstring ¶m_desc() const { return m_def_param; }
|
||||
ATTR_COLD const nl_util::pstring_list term_param_list();
|
||||
ATTR_COLD const nl_util::pstring_list def_params();
|
||||
ATTR_COLD const pstring_list_t term_param_list();
|
||||
ATTR_COLD const pstring_list_t def_params();
|
||||
|
||||
protected:
|
||||
pstring m_name; /* device name */
|
||||
@ -45,15 +44,15 @@ protected:
|
||||
};
|
||||
|
||||
template <class C>
|
||||
class net_device_t_factory : public net_device_t_base_factory
|
||||
class net_list_factory_t : public netlist_base_factory_t
|
||||
{
|
||||
NETLIST_PREVENT_COPYING(net_device_t_factory)
|
||||
NETLIST_PREVENT_COPYING(net_list_factory_t)
|
||||
public:
|
||||
ATTR_COLD net_device_t_factory(const pstring &name, const pstring &classname,
|
||||
ATTR_COLD net_list_factory_t(const pstring &name, const pstring &classname,
|
||||
const pstring &def_param)
|
||||
: net_device_t_base_factory(name, classname, def_param) { }
|
||||
: netlist_base_factory_t(name, classname, def_param) { }
|
||||
|
||||
ATTR_COLD netlist_device_t *Create() const
|
||||
ATTR_COLD netlist_device_t *Create()
|
||||
{
|
||||
netlist_device_t *r = palloc(C);
|
||||
//r->init(setup, name);
|
||||
@ -61,24 +60,29 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class netlist_factory_t
|
||||
class netlist_factory_list_t
|
||||
{
|
||||
public:
|
||||
typedef plist_t<net_device_t_base_factory *> list_t;
|
||||
typedef plist_t<netlist_base_factory_t *> list_t;
|
||||
|
||||
netlist_factory_t();
|
||||
~netlist_factory_t();
|
||||
netlist_factory_list_t();
|
||||
~netlist_factory_list_t();
|
||||
|
||||
template<class _C>
|
||||
ATTR_COLD void register_device(const pstring &name, const pstring &classname,
|
||||
const pstring &def_param)
|
||||
{
|
||||
m_list.add(palloc(net_device_t_factory< _C >, name, classname, def_param));
|
||||
m_list.add(palloc(net_list_factory_t< _C >, name, classname, def_param));
|
||||
}
|
||||
|
||||
ATTR_COLD void register_device(netlist_base_factory_t *factory)
|
||||
{
|
||||
m_list.add(factory);
|
||||
}
|
||||
|
||||
ATTR_COLD netlist_device_t *new_device_by_classname(const pstring &classname) const;
|
||||
ATTR_COLD netlist_device_t *new_device_by_name(const pstring &name, netlist_setup_t &setup) const;
|
||||
ATTR_COLD net_device_t_base_factory * factory_by_name(const pstring &name, netlist_setup_t &setup) const;
|
||||
ATTR_COLD netlist_base_factory_t * factory_by_name(const pstring &name, netlist_setup_t &setup) const;
|
||||
|
||||
const list_t &list() { return m_list; }
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "nl_parser.h"
|
||||
#include "nl_factory.h"
|
||||
#include "devices/nld_truthtable.h"
|
||||
|
||||
//#undef NL_VERBOSE_OUT
|
||||
//#define NL_VERBOSE_OUT(x) printf x
|
||||
@ -33,7 +34,7 @@ bool netlist_parser::parse(const char *buf, const pstring nlname)
|
||||
|
||||
reset(m_buf);
|
||||
set_identifier_chars("abcdefghijklmnopqrstuvwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_.-");
|
||||
set_number_chars("01234567890eE-."); //FIXME: processing of numbers
|
||||
set_number_chars(".0123456789", "0123456789eE-."); //FIXME: processing of numbers
|
||||
char ws[5];
|
||||
ws[0] = ' ';
|
||||
ws[1] = 9;
|
||||
@ -54,6 +55,10 @@ bool netlist_parser::parse(const char *buf, const pstring nlname)
|
||||
m_tok_SUBMODEL = register_token("SUBMODEL");
|
||||
m_tok_NETLIST_START = register_token("NETLIST_START");
|
||||
m_tok_NETLIST_END = register_token("NETLIST_END");
|
||||
m_tok_TRUTHTABLE_START = register_token("TRUTHTABLE_START");
|
||||
m_tok_TRUTHTABLE_END = register_token("TRUTHTABLE_END");
|
||||
m_tok_TT_HEAD = register_token("TT_HEAD");
|
||||
m_tok_TT_LINE = register_token("TT_LINE");
|
||||
|
||||
bool in_nl = false;
|
||||
|
||||
@ -119,6 +124,8 @@ void netlist_parser::parse_netlist(ATTR_UNUSED const pstring &nlname)
|
||||
net_submodel();
|
||||
else if (token.is(m_tok_INCLUDE))
|
||||
net_include();
|
||||
else if (token.is(m_tok_TRUTHTABLE_START))
|
||||
net_truthtable_start();
|
||||
else if (token.is(m_tok_NETLIST_END))
|
||||
{
|
||||
netdev_netlist_end();
|
||||
@ -129,6 +136,49 @@ void netlist_parser::parse_netlist(ATTR_UNUSED const pstring &nlname)
|
||||
}
|
||||
}
|
||||
|
||||
void netlist_parser::net_truthtable_start()
|
||||
{
|
||||
pstring name = get_identifier();
|
||||
require_token(m_tok_comma);
|
||||
unsigned ni = get_number_long();
|
||||
require_token(m_tok_comma);
|
||||
unsigned no = get_number_long();
|
||||
require_token(m_tok_comma);
|
||||
unsigned hs = get_number_long();
|
||||
require_token(m_tok_comma);
|
||||
pstring def_param = get_string();
|
||||
require_token(m_tok_param_right);
|
||||
|
||||
netlist_base_factory_truthtable_t *ttd = nl_tt_factory_create(ni, no, hs,
|
||||
name, name, "+" + def_param);
|
||||
|
||||
while (true)
|
||||
{
|
||||
token_t token = get_token();
|
||||
|
||||
if (token.is(m_tok_TT_HEAD))
|
||||
{
|
||||
require_token(m_tok_param_left);
|
||||
ttd->m_desc.add(get_string());
|
||||
require_token(m_tok_param_right);
|
||||
}
|
||||
else if (token.is(m_tok_TT_LINE))
|
||||
{
|
||||
require_token(m_tok_param_left);
|
||||
ttd->m_desc.add(get_string());
|
||||
require_token(m_tok_param_right);
|
||||
}
|
||||
else
|
||||
{
|
||||
require_token(token, m_tok_TRUTHTABLE_END);
|
||||
require_token(m_tok_param_left);
|
||||
require_token(m_tok_param_right);
|
||||
m_setup.factory().register_device(ttd);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void netlist_parser::netdev_netlist_start()
|
||||
{
|
||||
@ -198,7 +248,7 @@ void netlist_parser::net_c()
|
||||
{
|
||||
pstring t1 = get_identifier();
|
||||
m_setup.register_link(first , t1);
|
||||
NL_VERBOSE_OUT(("Parser: Connect: %s %s\n", last.cstr(), t1.cstr()));
|
||||
NL_VERBOSE_OUT(("Parser: Connect: %s %s\n", first.cstr(), t1.cstr()));
|
||||
token_t n = get_token();
|
||||
if (n.is(m_tok_param_right))
|
||||
break;
|
||||
@ -223,10 +273,10 @@ void netlist_parser::netdev_param()
|
||||
void netlist_parser::device(const pstring &dev_type)
|
||||
{
|
||||
pstring devname;
|
||||
net_device_t_base_factory *f = m_setup.factory().factory_by_name(dev_type, m_setup);
|
||||
netlist_base_factory_t *f = m_setup.factory().factory_by_name(dev_type, m_setup);
|
||||
netlist_device_t *dev;
|
||||
nl_util::pstring_list termlist = f->term_param_list();
|
||||
nl_util::pstring_list def_params = f->def_params();
|
||||
pstring_list_t termlist = f->term_param_list();
|
||||
pstring_list_t def_params = f->def_params();
|
||||
|
||||
std::size_t cnt;
|
||||
|
||||
@ -293,6 +343,23 @@ nl_double netlist_parser::eval_param(const token_t tok)
|
||||
for (i=1; i<6;i++)
|
||||
if (tok.str().equals(macs[i]))
|
||||
f = i;
|
||||
#if 1
|
||||
if (f>0)
|
||||
{
|
||||
require_token(m_tok_param_left);
|
||||
ret = get_number_double();
|
||||
require_token(m_tok_param_right);
|
||||
}
|
||||
else
|
||||
{
|
||||
val = tok.str();
|
||||
ret = val.as_double(&e);
|
||||
if (e)
|
||||
error("Error with parameter ...\n");
|
||||
}
|
||||
return ret * facs[f];
|
||||
|
||||
#else
|
||||
if (f>0)
|
||||
{
|
||||
require_token(m_tok_param_left);
|
||||
@ -308,4 +375,5 @@ nl_double netlist_parser::eval_param(const token_t tok)
|
||||
if (f>0)
|
||||
require_token(m_tok_param_right);
|
||||
return ret * facs[f];
|
||||
#endif
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#include "nl_setup.h"
|
||||
#include "nl_util.h"
|
||||
#include "pparser.h"
|
||||
#include "plib/pparser.h"
|
||||
|
||||
class netlist_parser : public ptokenizer
|
||||
{
|
||||
@ -31,6 +31,7 @@ public:
|
||||
void net_model();
|
||||
void net_submodel();
|
||||
void net_include();
|
||||
void net_truthtable_start();
|
||||
|
||||
protected:
|
||||
virtual void verror(pstring msg, int line_num, pstring line);
|
||||
@ -49,6 +50,10 @@ private:
|
||||
token_id_t m_tok_NETLIST_END;
|
||||
token_id_t m_tok_SUBMODEL;
|
||||
token_id_t m_tok_INCLUDE;
|
||||
token_id_t m_tok_TRUTHTABLE_START;
|
||||
token_id_t m_tok_TRUTHTABLE_END;
|
||||
token_id_t m_tok_TT_HEAD;
|
||||
token_id_t m_tok_TT_LINE;
|
||||
|
||||
netlist_setup_t &m_setup;
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "palloc.h"
|
||||
#include "plib/palloc.h"
|
||||
#include "nl_base.h"
|
||||
#include "nl_setup.h"
|
||||
#include "nl_parser.h"
|
||||
@ -39,7 +39,7 @@ netlist_setup_t::netlist_setup_t(netlist_base_t &netlist)
|
||||
, m_proxy_cnt(0)
|
||||
{
|
||||
netlist.set_setup(this);
|
||||
m_factory = palloc(netlist_factory_t);
|
||||
m_factory = palloc(netlist_factory_list_t);
|
||||
}
|
||||
|
||||
void netlist_setup_t::init()
|
||||
@ -286,7 +286,7 @@ void netlist_setup_t::register_object(netlist_device_t &dev, const pstring &name
|
||||
|
||||
void netlist_setup_t::register_link_arr(const pstring &terms)
|
||||
{
|
||||
nl_util::pstring_list list = nl_util::split(terms,", ");
|
||||
pstring_list_t list(terms,", ");
|
||||
if (list.size() < 2)
|
||||
netlist().error("You must pass at least 2 terminals to NET_C");
|
||||
for (std::size_t i = 1; i < list.size(); i++)
|
||||
@ -776,8 +776,8 @@ void netlist_setup_t::start_devices()
|
||||
if (env != "")
|
||||
{
|
||||
NL_VERBOSE_OUT(("Creating dynamic logs ...\n"));
|
||||
nl_util::pstring_list ll = nl_util::split(env, ":");
|
||||
for (std::size_t i=0; i < ll.size(); i++)
|
||||
pstring_list_t ll(env, ":");
|
||||
for (unsigned i=0; i < ll.size(); i++)
|
||||
{
|
||||
NL_VERBOSE_OUT(("%d: <%s>\n",i, ll[i].cstr()));
|
||||
NL_VERBOSE_OUT(("%d: <%s>\n",i, ll[i].cstr()));
|
||||
|
@ -25,6 +25,10 @@
|
||||
#define NET_REGISTER_DEV(_type, _name) \
|
||||
setup.register_dev(NETLIB_NAME_STR(_type), # _name);
|
||||
|
||||
/* to be used to reference new library truthtable devices */
|
||||
#define NET_REGISTER_DEV_X(_type, _name) \
|
||||
setup.register_dev(# _type, # _name);
|
||||
|
||||
#define NET_REMOVE_DEV(_name) \
|
||||
setup.remove_dev(# _name);
|
||||
|
||||
@ -66,7 +70,7 @@ ATTR_COLD void NETLIST_NAME(_name)(netlist_setup_t &setup)
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
// Forward definition so we keep nl_factory.h out of the public
|
||||
class netlist_factory_t;
|
||||
class netlist_factory_list_t;
|
||||
|
||||
class netlist_setup_t
|
||||
{
|
||||
@ -143,8 +147,8 @@ public:
|
||||
void namespace_push(const pstring &aname);
|
||||
void namespace_pop();
|
||||
|
||||
netlist_factory_t &factory() { return *m_factory; }
|
||||
const netlist_factory_t &factory() const { return *m_factory; }
|
||||
netlist_factory_list_t &factory() { return *m_factory; }
|
||||
const netlist_factory_list_t &factory() const { return *m_factory; }
|
||||
|
||||
/* not ideal, but needed for save_state */
|
||||
tagmap_terminal_t m_terminals;
|
||||
@ -162,7 +166,7 @@ private:
|
||||
tagmap_link_t m_links;
|
||||
tagmap_nstring_t m_params_temp;
|
||||
|
||||
netlist_factory_t *m_factory;
|
||||
netlist_factory_list_t *m_factory;
|
||||
|
||||
plist_t<pstring> m_models;
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#define NLTIME_H_
|
||||
|
||||
#include "nl_config.h"
|
||||
#include "pstate.h"
|
||||
#include "plib/pstate.h"
|
||||
|
||||
//============================================================
|
||||
// MACROS
|
||||
|
@ -8,11 +8,12 @@
|
||||
#ifndef NL_UTIL_H_
|
||||
#define NL_UTIL_H_
|
||||
|
||||
#include "pstring.h"
|
||||
#include "plists.h"
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
#include "plib/pstring.h"
|
||||
#include "plib/plists.h"
|
||||
|
||||
class nl_util
|
||||
{
|
||||
// this is purely static
|
||||
@ -20,68 +21,7 @@ private:
|
||||
nl_util() {};
|
||||
|
||||
public:
|
||||
typedef plist_t<pstring> pstring_list;
|
||||
|
||||
static pstring_list split(const pstring &str, const pstring &onstr, bool ignore_empty = false)
|
||||
{
|
||||
pstring_list temp;
|
||||
|
||||
int p = 0;
|
||||
int pn;
|
||||
|
||||
pn = str.find(onstr, p);
|
||||
while (pn>=0)
|
||||
{
|
||||
pstring t = str.substr(p, pn - p);
|
||||
if (!ignore_empty || t.len() != 0)
|
||||
temp.add(t);
|
||||
p = pn + onstr.len();
|
||||
pn = str.find(onstr, p);
|
||||
}
|
||||
if (p<str.len())
|
||||
{
|
||||
pstring t = str.substr(p);
|
||||
if (!ignore_empty || t.len() != 0)
|
||||
temp.add(t);
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
static pstring_list splitexpr(const pstring &str, const pstring_list &onstrl)
|
||||
{
|
||||
pstring_list temp;
|
||||
pstring col = "";
|
||||
|
||||
int i = 0;
|
||||
while (i<str.len())
|
||||
{
|
||||
int p = -1;
|
||||
for (std::size_t j=0; j < onstrl.size(); j++)
|
||||
{
|
||||
if (std::strncmp(onstrl[j].cstr(), &(str.cstr()[i]), onstrl[j].len())==0)
|
||||
{
|
||||
p = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (p>=0)
|
||||
{
|
||||
if (col != "")
|
||||
temp.add(col);
|
||||
col = "";
|
||||
temp.add(onstrl[p]);
|
||||
i += onstrl[p].len();
|
||||
}
|
||||
else
|
||||
{
|
||||
col += str.cstr()[i];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (col != "")
|
||||
temp.add(col);
|
||||
return temp;
|
||||
}
|
||||
|
||||
static const pstring environment(const pstring &var, const pstring &default_val = "")
|
||||
{
|
||||
|
@ -77,6 +77,23 @@ typedef int64_t INT64;
|
||||
#define S64(val) val
|
||||
#endif
|
||||
|
||||
/* MINGW has adopted the MSVC formatting for 64-bit ints as of gcc 4.4 */
|
||||
#if (defined(__MINGW32__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))) || defined(_MSC_VER)
|
||||
#define I64FMT "I64"
|
||||
#else
|
||||
#define I64FMT "ll"
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#ifdef PTR64
|
||||
#define SIZETFMT "I64u"
|
||||
#else
|
||||
#define SIZETFMT "u"
|
||||
#endif
|
||||
#else
|
||||
#define SIZETFMT "zu"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* PCONFIG_H_ */
|
@ -10,6 +10,8 @@
|
||||
#ifndef PLISTS_H_
|
||||
#define PLISTS_H_
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "palloc.h"
|
||||
#include "pstring.h"
|
||||
|
||||
@ -236,7 +238,7 @@ public:
|
||||
{
|
||||
//nl_assert((pos>=0) && (pos<m_count));
|
||||
m_count--;
|
||||
for (int i = pos; i < m_count; i++)
|
||||
for (std::size_t i = pos; i < m_count; i++)
|
||||
{
|
||||
m_list[i] = m_list[i+1];
|
||||
}
|
||||
@ -339,7 +341,7 @@ class pnamedlist_t : public plist_t<_ListClass>
|
||||
public:
|
||||
_ListClass find(const pstring &name) const
|
||||
{
|
||||
for (int i=0; i < this->size(); i++)
|
||||
for (std::size_t i=0; i < this->size(); i++)
|
||||
if (get_name((*this)[i]) == name)
|
||||
return (*this)[i];
|
||||
return _ListClass(NULL);
|
||||
@ -510,4 +512,74 @@ private:
|
||||
_ListClass *m_head;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// string list
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
class pstring_list_t : public plist_t<pstring>
|
||||
{
|
||||
public:
|
||||
pstring_list_t() : plist_t<pstring>() { }
|
||||
|
||||
pstring_list_t(const pstring &str, const pstring &onstr, bool ignore_empty = false)
|
||||
: plist_t<pstring>()
|
||||
{
|
||||
|
||||
int p = 0;
|
||||
int pn;
|
||||
|
||||
pn = str.find(onstr, p);
|
||||
while (pn>=0)
|
||||
{
|
||||
pstring t = str.substr(p, pn - p);
|
||||
if (!ignore_empty || t.len() != 0)
|
||||
this->add(t);
|
||||
p = pn + onstr.len();
|
||||
pn = str.find(onstr, p);
|
||||
}
|
||||
if (p<str.len())
|
||||
{
|
||||
pstring t = str.substr(p);
|
||||
if (!ignore_empty || t.len() != 0)
|
||||
this->add(t);
|
||||
}
|
||||
}
|
||||
|
||||
static pstring_list_t splitexpr(const pstring &str, const pstring_list_t &onstrl)
|
||||
{
|
||||
pstring_list_t temp;
|
||||
pstring col = "";
|
||||
|
||||
int i = 0;
|
||||
while (i<str.len())
|
||||
{
|
||||
int p = -1;
|
||||
for (std::size_t j=0; j < onstrl.size(); j++)
|
||||
{
|
||||
if (std::strncmp(onstrl[j].cstr(), &(str.cstr()[i]), onstrl[j].len())==0)
|
||||
{
|
||||
p = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (p>=0)
|
||||
{
|
||||
if (col != "")
|
||||
temp.add(col);
|
||||
col = "";
|
||||
temp.add(onstrl[p]);
|
||||
i += onstrl[p].len();
|
||||
}
|
||||
else
|
||||
{
|
||||
col += str.cstr()[i];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (col != "")
|
||||
temp.add(col);
|
||||
return temp;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* PLISTS_H_ */
|
@ -96,6 +96,34 @@ pstring ptokenizer::get_identifier()
|
||||
return tok.str();
|
||||
}
|
||||
|
||||
double ptokenizer::get_number_double()
|
||||
{
|
||||
token_t tok = get_token();
|
||||
if (!tok.is_type(NUMBER))
|
||||
{
|
||||
error("Error: expected a number, got <%s>\n", tok.str().cstr());
|
||||
}
|
||||
bool err = false;
|
||||
double ret = tok.str().as_double(&err);
|
||||
if (err)
|
||||
error("Error: expected a number, got <%s>\n", tok.str().cstr());
|
||||
return ret;
|
||||
}
|
||||
|
||||
long ptokenizer::get_number_long()
|
||||
{
|
||||
token_t tok = get_token();
|
||||
if (!tok.is_type(NUMBER))
|
||||
{
|
||||
error("Error: expected a long int, got <%s>\n", tok.str().cstr());
|
||||
}
|
||||
bool err = false;
|
||||
long ret = tok.str().as_long(&err);
|
||||
if (err)
|
||||
error("Error: expected a long int, got <%s>\n", tok.str().cstr());
|
||||
return ret;
|
||||
}
|
||||
|
||||
ptokenizer::token_t ptokenizer::get_token()
|
||||
{
|
||||
while (true)
|
||||
@ -135,7 +163,26 @@ ptokenizer::token_t ptokenizer::get_token_internal()
|
||||
return token_t(ENDOFFILE);
|
||||
}
|
||||
}
|
||||
if (m_identifier_chars.find(c)>=0)
|
||||
if (m_number_chars_start.find(c)>=0)
|
||||
{
|
||||
/* read number while we receive number or identifier chars
|
||||
* treat it as an identifier when there are identifier chars in it
|
||||
*
|
||||
*/
|
||||
token_type ret = NUMBER;
|
||||
pstring tokstr = "";
|
||||
while (true) {
|
||||
if (m_identifier_chars.find(c)>=0 && m_number_chars.find(c)<0)
|
||||
ret = IDENTIFIER;
|
||||
else if (m_number_chars.find(c)<0)
|
||||
break;
|
||||
tokstr += c;
|
||||
c = getc();
|
||||
}
|
||||
ungetc();
|
||||
return token_t(ret, tokstr);
|
||||
}
|
||||
else if (m_identifier_chars.find(c)>=0)
|
||||
{
|
||||
/* read identifier till non identifier char */
|
||||
pstring tokstr = "";
|
||||
@ -218,6 +265,8 @@ ppreprocessor::ppreprocessor()
|
||||
m_expr_sep.add("==");
|
||||
m_expr_sep.add(" ");
|
||||
m_expr_sep.add("\t");
|
||||
|
||||
m_defines.add(define_t("__PLIB_PREPROCESSOR__", "1"));
|
||||
}
|
||||
|
||||
void ppreprocessor::error(const pstring &err)
|
||||
@ -227,7 +276,7 @@ void ppreprocessor::error(const pstring &err)
|
||||
|
||||
|
||||
|
||||
double ppreprocessor::expr(const nl_util::pstring_list &sexpr, std::size_t &start, int prio)
|
||||
double ppreprocessor::expr(const pstring_list_t &sexpr, std::size_t &start, int prio)
|
||||
{
|
||||
double val;
|
||||
pstring tok=sexpr[start];
|
||||
@ -300,7 +349,7 @@ ppreprocessor::define_t *ppreprocessor::get_define(const pstring &name)
|
||||
|
||||
pstring ppreprocessor::replace_macros(const pstring &line)
|
||||
{
|
||||
nl_util::pstring_list elems = nl_util::splitexpr(line, m_expr_sep);
|
||||
pstring_list_t elems = pstring_list_t::splitexpr(line, m_expr_sep);
|
||||
pstringbuffer ret = "";
|
||||
for (std::size_t i=0; i<elems.size(); i++)
|
||||
{
|
||||
@ -313,7 +362,7 @@ pstring ppreprocessor::replace_macros(const pstring &line)
|
||||
return pstring(ret.cstr());
|
||||
}
|
||||
|
||||
static pstring catremainder(const nl_util::pstring_list &elems, std::size_t start, pstring sep)
|
||||
static pstring catremainder(const pstring_list_t &elems, std::size_t start, pstring sep)
|
||||
{
|
||||
pstringbuffer ret = "";
|
||||
for (std::size_t i=start; i<elems.size(); i++)
|
||||
@ -327,7 +376,7 @@ static pstring catremainder(const nl_util::pstring_list &elems, std::size_t star
|
||||
pstring ppreprocessor::process(const pstring &contents)
|
||||
{
|
||||
pstringbuffer ret = "";
|
||||
nl_util::pstring_list lines = nl_util::split(contents,"\n", false);
|
||||
pstring_list_t lines(contents,"\n", false);
|
||||
UINT32 ifflag = 0; // 31 if levels
|
||||
int level = 0;
|
||||
|
||||
@ -336,15 +385,16 @@ pstring ppreprocessor::process(const pstring &contents)
|
||||
{
|
||||
pstring line = lines[i];
|
||||
pstring lt = line.replace("\t"," ").trim();
|
||||
lt = replace_macros(lt);
|
||||
// FIXME ... revise and extend macro handling
|
||||
if (lt.startsWith("#"))
|
||||
{
|
||||
nl_util::pstring_list lti = nl_util::split(lt, " ", true);
|
||||
pstring_list_t lti(lt, " ", true);
|
||||
if (lti[0].equals("#if"))
|
||||
{
|
||||
level++;
|
||||
std::size_t start = 0;
|
||||
nl_util::pstring_list t = nl_util::splitexpr(lt.substr(3).replace(" ",""), m_expr_sep);
|
||||
lt = replace_macros(lt);
|
||||
pstring_list_t t = pstring_list_t::splitexpr(lt.substr(3).replace(" ",""), m_expr_sep);
|
||||
int val = expr(t, start, 0);
|
||||
if (val == 0)
|
||||
ifflag |= (1 << level);
|
||||
@ -376,7 +426,7 @@ pstring ppreprocessor::process(const pstring &contents)
|
||||
}
|
||||
else if (lti[0].equals("#pragma"))
|
||||
{
|
||||
if (lti.size() > 3 && lti[1].equals("NETLIST"))
|
||||
if (ifflag == 0 && lti.size() > 3 && lti[1].equals("NETLIST"))
|
||||
{
|
||||
if (lti[2].equals("warning"))
|
||||
error("NETLIST: " + catremainder(lti, 3, " "));
|
||||
@ -384,9 +434,12 @@ pstring ppreprocessor::process(const pstring &contents)
|
||||
}
|
||||
else if (lti[0].equals("#define"))
|
||||
{
|
||||
if (lti.size() != 3)
|
||||
error(pstring::sprintf("PREPRO: only simple defines allowed: %s", line.cstr()));
|
||||
m_defines.add(define_t(lti[1], lti[2]));
|
||||
if (ifflag == 0)
|
||||
{
|
||||
if (lti.size() != 3)
|
||||
error(pstring::sprintf("PREPRO: only simple defines allowed: %s", line.cstr()));
|
||||
m_defines.add(define_t(lti[1], lti[2]));
|
||||
}
|
||||
}
|
||||
else
|
||||
error(pstring::sprintf("unknown directive on line %" SIZETFMT ": %s\n", i, line.cstr()));
|
||||
@ -395,9 +448,10 @@ pstring ppreprocessor::process(const pstring &contents)
|
||||
{
|
||||
//if (ifflag == 0 && level > 0)
|
||||
// fprintf(stderr, "conditional: %s\n", line.cstr());
|
||||
lt = replace_macros(lt);
|
||||
if (ifflag == 0)
|
||||
{
|
||||
ret.cat(line);
|
||||
ret.cat(lt);
|
||||
ret.cat("\n");
|
||||
}
|
||||
}
|
@ -9,8 +9,8 @@
|
||||
#define PPARSER_H_
|
||||
|
||||
#include "pconfig.h"
|
||||
#include "nl_config.h" // FIXME
|
||||
#include "nl_util.h"
|
||||
#include "../nl_config.h" // FIXME
|
||||
#include "../nl_util.h"
|
||||
|
||||
class ptokenizer
|
||||
{
|
||||
@ -86,6 +86,8 @@ public:
|
||||
token_t get_token();
|
||||
pstring get_string();
|
||||
pstring get_identifier();
|
||||
double get_number_double();
|
||||
long get_number_long();
|
||||
|
||||
void require_token(const token_id_t &token_num);
|
||||
void require_token(const token_t tok, const token_id_t &token_num);
|
||||
@ -97,7 +99,7 @@ public:
|
||||
}
|
||||
|
||||
void set_identifier_chars(pstring s) { m_identifier_chars = s; }
|
||||
void set_number_chars(pstring s) { m_number_chars = s; }
|
||||
void set_number_chars(pstring st, pstring rem) { m_number_chars_start = st; m_number_chars = rem; }
|
||||
void set_whitespace(pstring s) { m_whitespace = s; }
|
||||
void set_comment(pstring start, pstring end, pstring line)
|
||||
{
|
||||
@ -129,6 +131,7 @@ private:
|
||||
|
||||
pstring m_identifier_chars;
|
||||
pstring m_number_chars;
|
||||
pstring m_number_chars_start;
|
||||
plist_t<pstring> m_tokens;
|
||||
pstring m_whitespace;
|
||||
char m_string;
|
||||
@ -161,7 +164,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
double expr(const nl_util::pstring_list &sexpr, std::size_t &start, int prio);
|
||||
double expr(const pstring_list_t &sexpr, std::size_t &start, int prio);
|
||||
|
||||
define_t *get_define(const pstring &name);
|
||||
|
||||
@ -172,7 +175,7 @@ protected:
|
||||
private:
|
||||
|
||||
plist_t<define_t> m_defines;
|
||||
nl_util::pstring_list m_expr_sep;
|
||||
pstring_list_t m_expr_sep;
|
||||
};
|
||||
|
||||
#endif /* PPARSER_H_ */
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:ElSemi, kingshriek, Deunan Knute, R. Belmont
|
||||
/*
|
||||
Sega/Yamaha AICA emulation
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:ElSemi, kingshriek, Deunan Knute, R. Belmont
|
||||
/*
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:ElSemi, kingshriek, Deunan Knute, R. Belmont
|
||||
#include "emu.h"
|
||||
#include "aicadsp.h"
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:ElSemi, kingshriek, Deunan Knute, R. Belmont
|
||||
#pragma once
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:K.Wilkins, Derrick Renaud, F.Palazzolo, Couriersud
|
||||
#pragma once
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:K.Wilkins, Derrick Renaud, Frank Palazzolo, Couriersud
|
||||
/************************************************************************
|
||||
*
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:K.Wilkins, Derrick Renaud, Frank Palazzolo, Couriersud
|
||||
#pragma once
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Alex Marshall,nimitz,austere
|
||||
//ICS2115 by Raiden II team (c) 2010
|
||||
//members: austere, nimitz, Alex Marshal
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Alex Marshall,nimitz,austere
|
||||
#pragma once
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Brad Oliver, Eric Smith, Juergen Buchmueller
|
||||
/*****************************************************************************
|
||||
*
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Brad Oliver, Eric Smith, Juergen Buchmueller
|
||||
/*****************************************************************************
|
||||
*
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Paul Leaman, Miguel Angel Horna
|
||||
/***************************************************************************
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Paul Leaman, Miguel Angel Horna
|
||||
/*********************************************************
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Frank Palazzolo, Jarek Burczynski, Aaron Giles, Jonathan Gevaryahu, Couriersud
|
||||
/**********************************************************************************************
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Frank Palazzolo, Jarek Burczynski, Aaron Giles, Jonathan Gevaryahu, Couriersud
|
||||
#pragma once
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Frank Palazzolo, Aaron Giles, Jonathan Gevaryahu, Raphael Nabet, Couriersud, Michael Zapf
|
||||
/**********************************************************************************************
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Frank Palazzolo, Aaron Giles, Jonathan Gevaryahu, Raphael Nabet, Couriersud, Michael Zapf
|
||||
#pragma once
|
||||
|
||||
|
@ -1,807 +0,0 @@
|
||||
// license:???
|
||||
// copyright-holders:Roberto Lavarone
|
||||
/*********************************************************************
|
||||
|
||||
formats/z80ne_dsk.c
|
||||
|
||||
Nuova Elettronica Z80NE disk images
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "z80ne_dsk.h"
|
||||
#include "basicdsk.h"
|
||||
#include "imageutl.h"
|
||||
#include "coretmpl.h"
|
||||
|
||||
/* -----------------------------------------------------------------------
|
||||
* DMK file format
|
||||
*
|
||||
* David M. Keil's disk image format is aptly called an 'on disk' image
|
||||
* format. This means that whatever written to the disk is encoded into
|
||||
* the image file. IDAMS, sector headers, trailing CRCs, and intra-sector
|
||||
* spacing. *
|
||||
*
|
||||
* HEADER DESCRIPTION:
|
||||
*
|
||||
* Offset Bytes Field Description
|
||||
* ------ ----- ------------ -----------
|
||||
* 0 1 write_prot 0xff = Write Protected, 0x00 = R/W
|
||||
* 1 1 tracks Number of tracks
|
||||
* 2 2 track_length Bytes per track on DMK file (little endian)
|
||||
* 4 1 disk_options Miscellaneous flags
|
||||
* bit 0-3: Unused
|
||||
* bit 4: Sides on DMK file
|
||||
* 1=single, 0=double
|
||||
* bit 5: Unused
|
||||
* bit 6: Single Density DMK file
|
||||
* 1=single (bytes written once
|
||||
* on IDAMs)
|
||||
* 0=double (bytes written
|
||||
* two times for SD IDAMs)
|
||||
* 5 7 reserved Reserved for future use
|
||||
* 12 4 real_disk_code If this is 0x12345678 (little endian)
|
||||
* then access a real disk drive
|
||||
* (unsupported)
|
||||
*
|
||||
* Each track begins with a track TOC, consisting of 64 little endian 16-bit
|
||||
* integers. Each integer has the following format:
|
||||
* bit 0-13: Offset from beginning of track to 'FE' byte of IDAM
|
||||
* Note these are always sorted from first to last. All empty
|
||||
* entries are 0x00
|
||||
* bit 14: Undefined (reserved)
|
||||
* bit 15: Sector double density (0=SD 1=DD)
|
||||
* If not set and SD DMK flag is set then bytes are written
|
||||
* once.
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
struct dmk_tag
|
||||
{
|
||||
int heads;
|
||||
int tracks;
|
||||
UINT32 track_size;
|
||||
};
|
||||
|
||||
/* DMK file structure
|
||||
* See WD1711 documentation
|
||||
*/
|
||||
/* DMK file header */
|
||||
#define DMK_HEADER_LEN 16 /* DMK header */
|
||||
/* For every track (40) */
|
||||
#define DMK_TOC_LEN 128 /* 64 16-bit relative offsets to IDAMs */
|
||||
#define DMK_GAP1_LEN 32 /* GAP1 (26 bytes 0xFF and 6 bytes 0x00) */
|
||||
|
||||
/* For every sector (10) 301 bytes */
|
||||
#define DMK_IDAM_LEN 7 /* IDAM (0xFE, Track, 0x00, Sector, 0x00, CRChi, CRClo) */
|
||||
#define DMK_ID_GAP_LEN 17 /* GAP2 (11 bytes 0xFF and 6 bytes 0x00) */
|
||||
#define DMK_DAM_LEN 1 /* Data Address Mark (0xFB) */
|
||||
#define DMK_DATA_LEN 256 /* Data */
|
||||
#define DMK_DATA_CRC_LEN 2 /* Data CRC (CRChi, CRClo) */
|
||||
#define DMK_DATA_GAP_LEN 18 /* GAP3 (12 bytes 0xFF and 6 bytes 0x00) (not for last sector) */
|
||||
|
||||
#define DMK_EXTRA_TRACK_LENGTH (176) /* GAP4 (192 bytes 0xFF) */
|
||||
/* End of DMK file structure */
|
||||
|
||||
#define dmk_idam_type(x) (x)[0]
|
||||
#define dmk_idam_track(x) (x)[1]
|
||||
#define dmk_idam_side(x) (x)[2]
|
||||
#define dmk_idam_sector(x) (x)[3]
|
||||
#define dmk_idam_sectorlength(x) (x)[4]
|
||||
#define dmk_idam_crc(x) (((x)[5] << 8) + (x)[6])
|
||||
#define dmk_idam_set_crc(x, crc) (x)[5] = ((crc) >> 8); (x)[6] = ((crc) >> 0);
|
||||
|
||||
static const char needle_data[] = "\x00\x00\x00\x00\x00\x00\x00\x00\xFB\xFB";
|
||||
static const char needle_deleted_data_fa[] = "\x00\x00\x00\x00\x00\x00\x00\x00\xFA\xFA";
|
||||
static const char needle_deleted_data_f8[] = "\x00\x00\x00\x00\x00\x00\x00\x00\xF8\xF8";
|
||||
|
||||
|
||||
static struct dmk_tag *get_dmk_tag(floppy_image_legacy *floppy)
|
||||
{
|
||||
return (dmk_tag *)floppy_tag(floppy);
|
||||
}
|
||||
|
||||
|
||||
static floperr_t z80ne_dmk_get_track_offset(floppy_image_legacy *floppy, int head, int track, UINT64 *offset)
|
||||
{
|
||||
struct dmk_tag *tag = get_dmk_tag(floppy);
|
||||
|
||||
if ((head < 0) || (head >= tag->heads) || (track < 0) || (track >= tag->tracks))
|
||||
return FLOPPY_ERROR_SEEKERROR;
|
||||
|
||||
*offset = track;
|
||||
*offset *= tag->heads;
|
||||
*offset += head;
|
||||
*offset *= tag->track_size;
|
||||
*offset += DMK_HEADER_LEN;
|
||||
return FLOPPY_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static UINT32 z80ne_dmk_min_track_size(int sectors, int sector_length)
|
||||
{
|
||||
int sector_physical_length;
|
||||
sector_physical_length = (DMK_IDAM_LEN + DMK_ID_GAP_LEN + DMK_DAM_LEN + sector_length + DMK_DATA_CRC_LEN + DMK_DATA_GAP_LEN);
|
||||
return DMK_TOC_LEN + 2 * (DMK_GAP1_LEN + (sectors * sector_physical_length) - DMK_DATA_GAP_LEN + DMK_EXTRA_TRACK_LENGTH);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static floperr_t z80ne_dmk_read_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen)
|
||||
{
|
||||
floperr_t err;
|
||||
UINT64 track_offset;
|
||||
|
||||
err = z80ne_dmk_get_track_offset(floppy, head, track, &track_offset);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
floppy_image_read(floppy, buffer, offset + track_offset, buflen);
|
||||
return FLOPPY_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static floperr_t z80ne_dmk_write_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen)
|
||||
{
|
||||
floperr_t err;
|
||||
UINT64 track_offset;
|
||||
|
||||
err = z80ne_dmk_get_track_offset(floppy, head, track, &track_offset);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
floppy_image_write(floppy, buffer, offset + track_offset, buflen);
|
||||
return FLOPPY_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static floperr_t z80ne_dmk_get_track_data_offset(floppy_image_legacy *floppy, int head, int track, UINT64 *offset)
|
||||
{
|
||||
*offset = DMK_TOC_LEN + 1;
|
||||
return FLOPPY_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static floperr_t z80ne_dmk_format_track(floppy_image_legacy *floppy, int head, int track, option_resolution *params)
|
||||
{
|
||||
int sectors;
|
||||
int sector_length;
|
||||
int interleave;
|
||||
int first_sector_id;
|
||||
floperr_t err;
|
||||
int physical_sector;
|
||||
int logical_sector;
|
||||
int track_position;
|
||||
UINT16 idam_offset;
|
||||
UINT16 crc;
|
||||
UINT8 *track_data;
|
||||
void *track_data_v;
|
||||
UINT32 max_track_size;
|
||||
std::vector<int> sector_map;
|
||||
dynamic_buffer local_sector;
|
||||
int local_sector_size;
|
||||
int sector_position;
|
||||
int i;
|
||||
|
||||
sectors = option_resolution_lookup_int(params, PARAM_SECTORS);
|
||||
sector_length = option_resolution_lookup_int(params, PARAM_SECTOR_LENGTH);
|
||||
interleave = option_resolution_lookup_int(params, PARAM_INTERLEAVE);
|
||||
first_sector_id = option_resolution_lookup_int(params, PARAM_FIRST_SECTOR_ID);
|
||||
|
||||
max_track_size = get_dmk_tag(floppy)->track_size;
|
||||
|
||||
if (sectors > DMK_TOC_LEN/2)
|
||||
{
|
||||
err = FLOPPY_ERROR_INTERNAL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (max_track_size < z80ne_dmk_min_track_size(sectors, sector_length))
|
||||
{
|
||||
err = FLOPPY_ERROR_NOSPACE;
|
||||
goto done;
|
||||
}
|
||||
|
||||
err = floppy_load_track(floppy, head, track, TRUE, &track_data_v, NULL);
|
||||
if (err)
|
||||
goto done;
|
||||
track_data = (UINT8 *) track_data_v;
|
||||
|
||||
/* set up sector map */
|
||||
sector_map.resize(sectors);
|
||||
memset(§or_map, 0xff, sectors);
|
||||
|
||||
physical_sector = 0;
|
||||
for (logical_sector = 0; logical_sector < sectors; logical_sector++)
|
||||
{
|
||||
while(sector_map[physical_sector] >= 0)
|
||||
{
|
||||
physical_sector++;
|
||||
physical_sector %= sectors;
|
||||
}
|
||||
|
||||
sector_map[physical_sector] = logical_sector + first_sector_id;
|
||||
physical_sector += interleave + 1;
|
||||
physical_sector %= sectors;
|
||||
}
|
||||
|
||||
/* set up a local physical sector template */
|
||||
local_sector_size = (DMK_IDAM_LEN +
|
||||
DMK_ID_GAP_LEN +
|
||||
DMK_DAM_LEN +
|
||||
sector_length +
|
||||
DMK_DATA_CRC_LEN +
|
||||
DMK_DATA_GAP_LEN);
|
||||
local_sector.resize(local_sector_size);
|
||||
memset(&local_sector, 0, local_sector_size);
|
||||
|
||||
/* set up track table of contents */
|
||||
physical_sector = 0;
|
||||
|
||||
/* write GAP1 (track lead in) */
|
||||
memset(&track_data[DMK_TOC_LEN], 0xFF, 52);
|
||||
memset(&track_data[DMK_TOC_LEN+52], 0x00, 12);
|
||||
track_position = DMK_TOC_LEN + DMK_GAP1_LEN * 2;
|
||||
|
||||
/*
|
||||
* prepare template in local sector
|
||||
*/
|
||||
|
||||
/* IDAM */
|
||||
sector_position = 0;
|
||||
dmk_idam_type( &local_sector[sector_position]) = 0xFE;
|
||||
dmk_idam_track( &local_sector[sector_position]) = track;
|
||||
dmk_idam_side( &local_sector[sector_position]) = head;
|
||||
dmk_idam_sector( &local_sector[sector_position]) = 0; /* replace in sector instances */
|
||||
dmk_idam_sectorlength( &local_sector[sector_position]) = compute_log2(sector_length / 128);
|
||||
dmk_idam_set_crc( &local_sector[sector_position], 0); /* replace in sector instances */
|
||||
sector_position += 7;
|
||||
|
||||
/* GAP2 (ID GAP) */
|
||||
memset(&local_sector[sector_position], 0xFF, 11);
|
||||
sector_position += 11;
|
||||
memset(&local_sector[sector_position], 0x00, 6);
|
||||
sector_position += 6;
|
||||
|
||||
/* sector body */
|
||||
local_sector[sector_position] = 0xFB;
|
||||
memset(&local_sector[sector_position + 1], floppy_get_filler(floppy), sector_length);
|
||||
crc = ccitt_crc16(0xffff, &local_sector[sector_position], sector_length + 1);
|
||||
local_sector[sector_position + sector_length + 1] = (UINT8) (crc >> 8);
|
||||
local_sector[sector_position + sector_length + 2] = (UINT8) (crc >> 0);
|
||||
sector_position += sector_length + 3;
|
||||
|
||||
/* GAP3 (Data GAP) */
|
||||
memset(&local_sector[sector_position], 0xFF, 12);
|
||||
sector_position += 12;
|
||||
memset(&local_sector[sector_position], 0x00, 6);
|
||||
sector_position += 6;
|
||||
|
||||
/*
|
||||
* start of track data
|
||||
*/
|
||||
while(physical_sector < DMK_TOC_LEN/2)
|
||||
{
|
||||
if (physical_sector >= sectors)
|
||||
{
|
||||
/* no more sectors */
|
||||
idam_offset = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* this is a sector */
|
||||
idam_offset = track_position;
|
||||
logical_sector = sector_map[physical_sector];
|
||||
|
||||
/* update IDAM in local sector template */
|
||||
dmk_idam_sector( &local_sector[0]) = logical_sector; /* update sector number in sector instance */
|
||||
crc = ccitt_crc16(0xffff, &local_sector[0], DMK_IDAM_LEN - 2); /* and recalculate crc */
|
||||
dmk_idam_set_crc( &local_sector[0], crc);
|
||||
|
||||
/* write local sector in track doubling every byte (DMK double density mode) */
|
||||
for(i=0; i<local_sector_size; i++)
|
||||
track_data[track_position + i*2] = track_data[track_position + (i*2) + 1] = local_sector[i];
|
||||
track_position += (2 * local_sector_size);
|
||||
if (physical_sector == (sectors-1)) /* on last sector remove GAP3 */
|
||||
track_position -= (2 * DMK_DATA_GAP_LEN);
|
||||
}
|
||||
|
||||
/* write the TOC entry */
|
||||
track_data[physical_sector * 2 + 0] = (UINT8) (idam_offset >> 0);
|
||||
track_data[physical_sector * 2 + 1] = (UINT8) (idam_offset >> 8);
|
||||
|
||||
physical_sector++;
|
||||
}
|
||||
|
||||
/* write track footer GAP4 */
|
||||
assert(max_track_size >= (UINT32)track_position);
|
||||
memset(&track_data[track_position], 0xFF, max_track_size - track_position);
|
||||
|
||||
done:
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int z80ne_dmk_get_heads_per_disk(floppy_image_legacy *floppy)
|
||||
{
|
||||
return get_dmk_tag(floppy)->heads;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int z80ne_dmk_get_tracks_per_disk(floppy_image_legacy *floppy)
|
||||
{
|
||||
return get_dmk_tag(floppy)->tracks;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static UINT32 z80ne_dmk_get_track_size(floppy_image_legacy *floppy, int head, int track)
|
||||
{
|
||||
return get_dmk_tag(floppy)->track_size;
|
||||
}
|
||||
|
||||
static UINT8 * my_memmem(UINT8 *haystack, size_t haystacklen,
|
||||
UINT8 *needle, size_t needlelen)
|
||||
{
|
||||
register UINT8 *h = haystack;
|
||||
register UINT8 *n = needle;
|
||||
register size_t hl = haystacklen;
|
||||
register size_t nl = needlelen;
|
||||
register size_t i;
|
||||
|
||||
if (nl == 0) return haystack; /* The first occurrence of the empty string is deemed to occur at
|
||||
the beginning of the string. */
|
||||
if (hl < nl)
|
||||
return NULL;
|
||||
|
||||
for( i = 0; (i < hl) && (i + nl <= hl ); i++ )
|
||||
if (h[i] == *n) /* first match */
|
||||
if ( !memcmp(&h[i]+1, n + 1, nl - 1) )
|
||||
return (haystack+i); /* returns a pointer to the substring */
|
||||
|
||||
return (UINT8 *)NULL; /* not found */
|
||||
}
|
||||
|
||||
|
||||
|
||||
static floperr_t z80ne_dmk_seek_sector_in_track(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, int dirtify, UINT8 **sector_data, UINT32 *sector_length)
|
||||
{
|
||||
struct dmk_tag *tag = get_dmk_tag(floppy);
|
||||
floperr_t err;
|
||||
size_t idam_offset = 0;
|
||||
UINT16 calculated_crc;
|
||||
size_t i, j;
|
||||
size_t offs;
|
||||
/*int state;*/
|
||||
UINT8 *track_data;
|
||||
void *track_data_v;
|
||||
size_t track_length;
|
||||
size_t sec_len;
|
||||
dynamic_buffer local_idam;
|
||||
int local_idam_size;
|
||||
UINT8 *sec_data;
|
||||
|
||||
err = floppy_load_track(floppy, head, track, dirtify, &track_data_v, &track_length);
|
||||
if (err)
|
||||
goto done;
|
||||
track_data = (UINT8 *) track_data_v;
|
||||
|
||||
/* set up a local IDAM space */
|
||||
local_idam_size = (DMK_IDAM_LEN +
|
||||
DMK_ID_GAP_LEN +
|
||||
DMK_DAM_LEN +
|
||||
DMK_DATA_GAP_LEN);
|
||||
local_idam.resize(local_idam_size);
|
||||
memset(&local_idam[0], 0, local_idam_size);
|
||||
|
||||
/* search for matching IDAM */
|
||||
for (i = 0; i < DMK_TOC_LEN / 2; i++)
|
||||
{
|
||||
idam_offset = track_data[i * 2 + 1];
|
||||
idam_offset <<= 8;
|
||||
idam_offset |= track_data[i * 2 + 0];
|
||||
idam_offset &= 0x3FFF;
|
||||
|
||||
if (idam_offset == 0)
|
||||
{
|
||||
/* we've reached the end of the road */
|
||||
i = DMK_TOC_LEN;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((idam_offset + DMK_IDAM_LEN * 2) >= tag->track_size)
|
||||
continue;
|
||||
|
||||
/* overflowing the track? */
|
||||
if ((idam_offset + local_idam_size * 2) >= tag->track_size)
|
||||
{
|
||||
err = FLOPPY_ERROR_SEEKERROR;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* create a local copy of sector of IDAM */
|
||||
for(j = 0; j < (DMK_IDAM_LEN + DMK_ID_GAP_LEN + DMK_DAM_LEN); j++)
|
||||
local_idam[j] = track_data[idam_offset + j*2];
|
||||
|
||||
/* from now on all operations are done in local copy of IDAM */
|
||||
calculated_crc = ccitt_crc16(0xffff, &local_idam[0], DMK_IDAM_LEN - 2);
|
||||
|
||||
/* check IDAM integrity and check for matching sector */
|
||||
if (calculated_crc == dmk_idam_crc(&local_idam[0]))
|
||||
{
|
||||
if (sector_is_index)
|
||||
{
|
||||
/* the sector is indexed; decrement the index and go */
|
||||
if (sector-- == 0)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* check for matching sector ID */
|
||||
if (sector == dmk_idam_sector(&local_idam[0]))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= DMK_TOC_LEN / 2)
|
||||
{
|
||||
err = FLOPPY_ERROR_SEEKERROR;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* we found a matching sector ID */
|
||||
/*state = 0;*/
|
||||
offs = idam_offset + 2 * DMK_IDAM_LEN;
|
||||
|
||||
/* find pattern 0x0000FB; this represents the start of a data sector */
|
||||
sec_data = my_memmem(&track_data[offs], 4 * (DMK_ID_GAP_LEN + DMK_DAM_LEN), (UINT8 *)needle_data, 10);
|
||||
if(!sec_data)
|
||||
{
|
||||
/* find pattern 0x0000FA; this represents the start of a deleted data sector (used for system sectors) */
|
||||
sec_data = my_memmem(&track_data[offs], 4 * (DMK_ID_GAP_LEN + DMK_DAM_LEN), (UINT8 *)needle_deleted_data_fa, 10);
|
||||
}
|
||||
if(!sec_data)
|
||||
{
|
||||
/* find pattern 0x0000F8; this represents the start of a deleted data sector (used for system sectors) */
|
||||
sec_data = my_memmem(&track_data[offs], 4 * (DMK_ID_GAP_LEN + DMK_DAM_LEN), (UINT8 *)needle_deleted_data_f8, 10);
|
||||
}
|
||||
|
||||
if(sec_data)
|
||||
sec_data += 10;
|
||||
else
|
||||
{
|
||||
err = FLOPPY_ERROR_SEEKERROR;
|
||||
goto done;
|
||||
}
|
||||
offs = sec_data - &track_data[offs];
|
||||
|
||||
sec_len = 128 << dmk_idam_sectorlength(&local_idam[0]);
|
||||
|
||||
if ((offs + 2 * sec_len) > track_length)
|
||||
{
|
||||
err = FLOPPY_ERROR_INVALIDIMAGE;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (sector_data)
|
||||
*sector_data = sec_data;
|
||||
if (sector_length)
|
||||
*sector_length = sec_len;
|
||||
done:
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static floperr_t z80ne_dmk_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length)
|
||||
{
|
||||
return z80ne_dmk_seek_sector_in_track(floppy, head, track, sector, FALSE, FALSE, NULL, sector_length);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static floperr_t z80ne_dmk_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags)
|
||||
{
|
||||
floperr_t err;
|
||||
size_t idam_offset;
|
||||
UINT8 *track_data;
|
||||
void *track_data_v;
|
||||
unsigned long dam;
|
||||
|
||||
if (sector_index * 2 >= DMK_TOC_LEN)
|
||||
return FLOPPY_ERROR_SEEKERROR;
|
||||
|
||||
err = floppy_load_track(floppy, head, track, FALSE, &track_data_v, NULL);
|
||||
if (err)
|
||||
return err;
|
||||
track_data = (UINT8 *) track_data_v;
|
||||
|
||||
idam_offset = track_data[sector_index * 2 + 1];
|
||||
idam_offset <<= 8;
|
||||
idam_offset |= track_data[sector_index * 2 + 0];
|
||||
idam_offset &= 0x3FFF;
|
||||
|
||||
if (idam_offset == 0)
|
||||
return FLOPPY_ERROR_SEEKERROR;
|
||||
|
||||
/* determine type of data sector */
|
||||
/* find pattern 0x0000FB; this represents the start of a data sector */
|
||||
if ( my_memmem(&track_data[idam_offset+14], 4 * (DMK_ID_GAP_LEN + DMK_DAM_LEN), (UINT8 *)needle_data, 10) )
|
||||
dam = 0;
|
||||
/* find pattern 0x0000FA; this represents the start of a deleted data sector (used for system sectors) */
|
||||
else if ( my_memmem(&track_data[idam_offset+14], 4 * (DMK_ID_GAP_LEN + DMK_DAM_LEN), (UINT8 *)needle_deleted_data_fa, 10) )
|
||||
dam = ID_FLAG_DELETED_DATA;
|
||||
/* find pattern 0x0000F8; this represents the start of a deleted data sector (used for system sectors) */
|
||||
else if ( my_memmem(&track_data[idam_offset+14], 4 * (DMK_ID_GAP_LEN + DMK_DAM_LEN), (UINT8 *)needle_deleted_data_f8, 10) )
|
||||
dam = ID_FLAG_DELETED_DATA;
|
||||
else
|
||||
return FLOPPY_ERROR_SEEKERROR;
|
||||
|
||||
if (cylinder)
|
||||
*cylinder = (&track_data[idam_offset])[2];
|
||||
if (side)
|
||||
*side = (&track_data[idam_offset])[4];
|
||||
if (sector)
|
||||
*sector = (&track_data[idam_offset])[6];
|
||||
if (sector_length)
|
||||
*sector_length = 128 << (&track_data[idam_offset])[8];
|
||||
if (flags)
|
||||
*flags = dam;
|
||||
return FLOPPY_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static floperr_t internal_z80ne_dmk_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen)
|
||||
{
|
||||
floperr_t err;
|
||||
UINT32 sector_length;
|
||||
UINT16 crc_on_disk;
|
||||
UINT16 calculated_crc;
|
||||
UINT8 *sector_data = NULL;
|
||||
dynamic_buffer local_sector;
|
||||
int local_sector_size;
|
||||
int i;
|
||||
|
||||
/* get sector length and data pointer */
|
||||
err = z80ne_dmk_seek_sector_in_track(floppy, head, track, sector, sector_is_index, FALSE, §or_data, §or_length);
|
||||
if (err)
|
||||
goto done;
|
||||
|
||||
/* set up a local physical sector space (DAM + data + crc + GAP) */
|
||||
local_sector_size = (DMK_DAM_LEN + sector_length + DMK_DATA_CRC_LEN + DMK_DATA_GAP_LEN);
|
||||
local_sector.resize(local_sector_size);
|
||||
memset(&local_sector, 0, local_sector_size);
|
||||
|
||||
/* get sector data */
|
||||
/* create a local copy of sector data including DAM (for crc calculation) */
|
||||
for(i = 0; i < (DMK_DAM_LEN + sector_length + DMK_DATA_CRC_LEN); i++)
|
||||
local_sector[i] = (sector_data - 2)[i*2];
|
||||
|
||||
crc_on_disk = local_sector[sector_length + 0 + 1];
|
||||
crc_on_disk <<= 8;
|
||||
crc_on_disk += local_sector[sector_length + 1 + 1];
|
||||
|
||||
/* crc calculated including DAM */
|
||||
calculated_crc = ccitt_crc16(0xffff, &local_sector[0], sector_length+1);
|
||||
if (calculated_crc != crc_on_disk)
|
||||
{
|
||||
err = FLOPPY_ERROR_INVALIDIMAGE;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* copy local sector data excluding DAM */
|
||||
memcpy(buffer, &local_sector[1], MIN(sector_length, buflen));
|
||||
|
||||
done:
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static floperr_t internal_z80ne_dmk_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam)
|
||||
{
|
||||
floperr_t err;
|
||||
UINT32 sector_length;
|
||||
UINT8 *sector_data;
|
||||
UINT16 crc;
|
||||
dynamic_buffer local_sector;
|
||||
int local_sector_size;
|
||||
int i;
|
||||
|
||||
/* get sector length */
|
||||
err = z80ne_dmk_seek_sector_in_track(floppy, head, track, sector, sector_is_index, TRUE, §or_data, §or_length);
|
||||
if (err)
|
||||
goto done;
|
||||
|
||||
/* set up a local physical sector space */
|
||||
local_sector_size = (DMK_DAM_LEN + sector_length + DMK_DATA_CRC_LEN + DMK_DATA_GAP_LEN);
|
||||
local_sector.resize(local_sector_size);
|
||||
memset(&local_sector[0], 0, local_sector_size);
|
||||
if(!ddam)
|
||||
local_sector[0] = 0xFB;
|
||||
else
|
||||
local_sector[0] = 0xFA;
|
||||
|
||||
if (buflen > sector_length)
|
||||
{
|
||||
err = FLOPPY_ERROR_INTERNAL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
memcpy(&local_sector[1], buffer, buflen);
|
||||
|
||||
crc = ccitt_crc16(0xffff, &local_sector[0], DMK_DAM_LEN + sector_length);
|
||||
local_sector[DMK_DAM_LEN + sector_length + 0] = crc >> 8;
|
||||
local_sector[DMK_DAM_LEN + sector_length + 1] = crc >> 0;
|
||||
|
||||
/* write local sector in track doubling every byte (DMK double density mode) */
|
||||
/* write DAM or DDAM too */
|
||||
sector_data -= 2;
|
||||
for(i=0; i < (DMK_DAM_LEN + sector_length + DMK_DATA_CRC_LEN); i++)
|
||||
sector_data[i*2] = sector_data[(i*2)+1] = local_sector[i];
|
||||
|
||||
done:
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static floperr_t z80ne_dmk_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen)
|
||||
{
|
||||
return internal_z80ne_dmk_read_sector(floppy, head, track, sector, FALSE, buffer, buflen);
|
||||
}
|
||||
|
||||
static floperr_t z80ne_dmk_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam)
|
||||
{
|
||||
return internal_z80ne_dmk_write_sector(floppy, head, track, sector, FALSE, buffer, buflen, ddam);
|
||||
}
|
||||
|
||||
static floperr_t z80ne_dmk_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen)
|
||||
{
|
||||
return internal_z80ne_dmk_read_sector(floppy, head, track, sector, TRUE, buffer, buflen);
|
||||
}
|
||||
|
||||
static floperr_t z80ne_dmk_write_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam)
|
||||
{
|
||||
return internal_z80ne_dmk_write_sector(floppy, head, track, sector, TRUE, buffer, buflen, ddam);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void z80ne_dmk_interpret_header(floppy_image_legacy *floppy, int *heads, int *tracks, int * sectors, int *track_size)
|
||||
{
|
||||
UINT8 header[DMK_HEADER_LEN + DMK_TOC_LEN];
|
||||
int i;
|
||||
int idam_offset;
|
||||
int sects;
|
||||
|
||||
floppy_image_read(floppy, header, 0, DMK_HEADER_LEN + DMK_TOC_LEN);
|
||||
|
||||
if (tracks)
|
||||
*tracks = header[1];
|
||||
if (heads)
|
||||
*heads = (header[4] & 0x10) ? 1 : 2;
|
||||
if (track_size)
|
||||
*track_size = ((int) header[3]) * 0x100 + header[2];
|
||||
if(sectors)
|
||||
{
|
||||
/* count sectors on first track */
|
||||
sects = 0;
|
||||
for (i = 0; i < DMK_TOC_LEN / 2; i++)
|
||||
{
|
||||
idam_offset = header[DMK_HEADER_LEN + i * 2 + 1];
|
||||
idam_offset <<= 8;
|
||||
idam_offset |= header[DMK_HEADER_LEN + i * 2 + 0];
|
||||
idam_offset &= 0x3FFF;
|
||||
|
||||
if (idam_offset == 0)
|
||||
break;
|
||||
else
|
||||
sects++;
|
||||
}
|
||||
*sectors = sects;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
FLOPPY_CONSTRUCT(z80ne_dmk_construct)
|
||||
{
|
||||
struct FloppyCallbacks *callbacks;
|
||||
struct dmk_tag *tag;
|
||||
UINT8 header[DMK_HEADER_LEN];
|
||||
int heads, tracks, track_size, sectors, sector_length;
|
||||
|
||||
if (params)
|
||||
{
|
||||
heads = option_resolution_lookup_int(params, PARAM_HEADS);
|
||||
tracks = option_resolution_lookup_int(params, PARAM_TRACKS);
|
||||
sectors = option_resolution_lookup_int(params, PARAM_SECTORS);
|
||||
sector_length = option_resolution_lookup_int(params, PARAM_SECTOR_LENGTH);
|
||||
|
||||
track_size = z80ne_dmk_min_track_size(sectors, sector_length);
|
||||
|
||||
memset(header, 0, sizeof(header));
|
||||
header[1] = tracks;
|
||||
header[2] = track_size >> 0;
|
||||
header[3] = track_size >> 8;
|
||||
header[4] = (heads == 2) ? 0x00 : 0x10;
|
||||
|
||||
floppy_image_write(floppy, header, 0, sizeof(header));
|
||||
}
|
||||
else
|
||||
{
|
||||
z80ne_dmk_interpret_header(floppy, &heads, &tracks, §ors, &track_size);
|
||||
}
|
||||
|
||||
tag = (dmk_tag*)floppy_create_tag(floppy, sizeof(struct dmk_tag));
|
||||
if (!tag)
|
||||
return FLOPPY_ERROR_OUTOFMEMORY;
|
||||
tag->heads = heads;
|
||||
tag->track_size = track_size;
|
||||
tag->tracks = tracks;
|
||||
|
||||
callbacks = floppy_callbacks(floppy);
|
||||
callbacks->read_track = z80ne_dmk_read_track;
|
||||
callbacks->write_track = z80ne_dmk_write_track;
|
||||
callbacks->get_track_data_offset = z80ne_dmk_get_track_data_offset;
|
||||
callbacks->format_track = z80ne_dmk_format_track;
|
||||
callbacks->get_heads_per_disk = z80ne_dmk_get_heads_per_disk;
|
||||
callbacks->get_tracks_per_disk = z80ne_dmk_get_tracks_per_disk;
|
||||
callbacks->get_track_size = z80ne_dmk_get_track_size;
|
||||
callbacks->get_sector_length = z80ne_dmk_get_sector_length;
|
||||
callbacks->get_indexed_sector_info = z80ne_dmk_get_indexed_sector_info;
|
||||
callbacks->read_sector = z80ne_dmk_read_sector;
|
||||
callbacks->write_sector = z80ne_dmk_write_sector;
|
||||
callbacks->read_indexed_sector = z80ne_dmk_read_indexed_sector;
|
||||
callbacks->write_indexed_sector = z80ne_dmk_write_indexed_sector;
|
||||
|
||||
return FLOPPY_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
FLOPPY_IDENTIFY(z80ne_dmk_identify)
|
||||
{
|
||||
int heads, tracks, sectors, track_size;
|
||||
UINT64 size, expected_size;
|
||||
|
||||
size = floppy_image_size(floppy);
|
||||
z80ne_dmk_interpret_header(floppy, &heads, &tracks, §ors, &track_size);
|
||||
expected_size = DMK_HEADER_LEN + (heads * tracks * track_size);
|
||||
*vote = (size == expected_size) ? 90 : 0;
|
||||
*vote += (sectors == 10) ? 10 : 0;
|
||||
return FLOPPY_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
LEGACY_FLOPPY_OPTIONS_START( z80ne )
|
||||
/*
|
||||
* Single side
|
||||
* Single density
|
||||
* FM, 125 kbit/s,
|
||||
* 40 tracks, track ID: 0..39
|
||||
* 10 sectors/track, sector ID: 0..9
|
||||
* 256 bytes/sector
|
||||
* Interleave 1 (sector ID sequence on track: 0 5 1 6 2 7 3 8 4 9)
|
||||
* 3125 byte/track unformatted
|
||||
* Rotation speed 300 rpm (5 rps)
|
||||
*/
|
||||
LEGACY_FLOPPY_OPTION( z80ne_dmk, "zmk", "Z80NE DMK disk image", z80ne_dmk_identify, z80ne_dmk_construct, NULL,
|
||||
HEADS([1])
|
||||
TRACKS([40])
|
||||
SECTORS([10])
|
||||
SECTOR_LENGTH([256])
|
||||
INTERLEAVE([1])
|
||||
FIRST_SECTOR_ID([0]))
|
||||
LEGACY_FLOPPY_OPTIONS_END
|
@ -1,24 +0,0 @@
|
||||
// license:???
|
||||
// copyright-holders:Roberto Lavarone
|
||||
/*********************************************************************
|
||||
|
||||
formats/z80ne_dsk.h
|
||||
|
||||
Nuova Elettronica Z80NE disk images
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef Z80NE_DSK_H
|
||||
#define Z80NE_DSK_H
|
||||
|
||||
#include "flopimg.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
LEGACY_FLOPPY_OPTIONS_EXTERN(z80ne);
|
||||
|
||||
FLOPPY_IDENTIFY(z80ne_dmk_identify);
|
||||
FLOPPY_CONSTRUCT(z80ne_dmk_construct);
|
||||
|
||||
#endif /* Z80NE_DSK_H */
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Michael Strutts,Nicola Salmoria,Tormod Tjaberg,Mirko Buffoni,Lee Taylor,Valerio Verrando,Marco Cassili,Zsolt Vasvari,Aaron Giles,Jonathan Gevaryahu,hap,Robbbert
|
||||
/* 8080bw.c *******************************************/
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Mike Balfour, Patrick Lawrence, Brad Oliver
|
||||
/*************************************************************************
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Mike Coates, Peter J.C.Clare
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:hap, insideoutboy
|
||||
/* Clarue Flower sound driver.
|
||||
Initial version was based on the Wiping sound driver, which was based on the old namco.c sound driver.
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Derrick Renaud
|
||||
/***************************************************************************
|
||||
galaga.c
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Derrick Renaud
|
||||
/************************************************************************
|
||||
* m79amb Sound System Analog emulation
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:GPL-2.0+
|
||||
// license:???
|
||||
// copyright-holders:Derrick Renaud
|
||||
/************************************************************************
|
||||
* madalien Sound System Analog emulation
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Michael Strutts, Nicola Salmoria, Tormod Tjaberg, Mirko Buffoni,Lee Taylor, Valerio Verrando, Marco Cassili, Zsolt Vasvari,Derrick Renaud
|
||||
/***************************************************************************
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Derrick Renaud
|
||||
/*************************************************************************
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Derrick Renaud, Roberto Fresca
|
||||
/************************************************************************
|
||||
* Noraut/Kimble/Kramer Poker Sound System Analog emulation
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:GPL-2.0+
|
||||
// license:???
|
||||
// copyright-holders:Juergen Buchmueller, Derrick Renaud
|
||||
/****************************************************************************
|
||||
*
|
||||
|
@ -1,8 +1,8 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:John Butler, Ed Mueller, Aaron Giles
|
||||
/*************************************************************************
|
||||
|
||||
audio\qix.c
|
||||
audio/qix.c
|
||||
|
||||
*************************************************************************/
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Derrick Renaud
|
||||
/*************************************************************************
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Derrick Renaud
|
||||
/***************************************************************************
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Steve Baines, Frank Palazzolo
|
||||
/***************************************************************************
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Derrick Renaud
|
||||
/*************************************************************************
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Bryan McPhail, David Graves
|
||||
/***************************************************************************
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Bryan McPhail, David Graves
|
||||
/***************************************************************************
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Derrick Renaud, Couriersud
|
||||
/*************************************************************************
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Derrick Renaud
|
||||
/*************************************************************************
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// license:BSD-3-Clause
|
||||
// license:???
|
||||
// copyright-holders:Paul Leaman, Couriersud
|
||||
/***************************************************************************
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user