pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Remove nestopia, version in HEAD is newer
Module Name: pkgsrc-wip
Committed By: nia <nia%netbsd.org@localhost>
Pushed By: nee
Date: Tue Jul 30 14:32:02 2019 +0100
Changeset: 6acd964c49b0b102087444f04676dab2b0ce979f
Modified Files:
Makefile
Removed Files:
nestopia/DESCR
nestopia/Makefile
nestopia/PLIST
nestopia/distinfo
nestopia/patches/patch-Makefile
nestopia/patches/patch-source_core_NstMemory.hpp
Log Message:
Remove nestopia, version in HEAD is newer
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=6acd964c49b0b102087444f04676dab2b0ce979f
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
Makefile | 1 -
nestopia/DESCR | 21 -
nestopia/Makefile | 44 -
nestopia/PLIST | 15 -
nestopia/distinfo | 7 -
nestopia/patches/patch-Makefile | 42 -
nestopia/patches/patch-source_core_NstMemory.hpp | 1557 ----------------------
7 files changed, 1687 deletions(-)
diffs:
diff --git a/Makefile b/Makefile
index 9dd45d817c..809f5c1cce 100644
--- a/Makefile
+++ b/Makefile
@@ -2381,7 +2381,6 @@ SUBDIR+= neko
SUBDIR+= nemo
SUBDIR+= neovim
SUBDIR+= neovim-git
-SUBDIR+= nestopia
SUBDIR+= nestopia-rpi
SUBDIR+= nestra
SUBDIR+= net-quanta
diff --git a/nestopia/DESCR b/nestopia/DESCR
deleted file mode 100644
index b9f3d66bb1..0000000000
--- a/nestopia/DESCR
+++ /dev/null
@@ -1,21 +0,0 @@
-NEStopia is a portable Nintendo Entertainment System emulator
-written in C++ by Martin Freij and ported to Linux by R. Belmont.
-NEStopia strives for the most accurate emulation possible at the
-pixel-by-pixel and sample-by-sample level, and it has excellent
-mapper and UNIF board support as well. A few features:
-
-- Supports .nes and .unf/.unif format ROMs
-- Supports .fds discs
-- Supports .nsf music rips
-- All supported files can be extracted from zip or 7zip containers (an
- archive browser is not yet included - this assumes the common
- GoodSet case of one zip or 7zip per game)
-- Supports save states
-- Supports movie recordings
-- Supports the "rewinder" - if you make a bad jump and screw up your game,
- press Backspace and the game will run in reverse. Press \ to take over
- again and try to fix your mistake.
-- Friendly GUI configuration
-- Autodetection of PAL and NTSC format games
-- Supports drag and drop of compatible games and music rips from modern
- Linux file managers, including KDE's Konqueror and GNOME's Nautilus.
diff --git a/nestopia/Makefile b/nestopia/Makefile
deleted file mode 100644
index 2e1569e846..0000000000
--- a/nestopia/Makefile
+++ /dev/null
@@ -1,44 +0,0 @@
-# $NetBSD: Makefile,v 1.5 2015/03/25 02:13:54 othyro Exp $
-#
-
-DISTNAME= nestopia-1.45
-CATEGORIES= emulators
-MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=nestopiaue/}
-EXTRACT_SUFX= .tgz
-
-MAINTAINER= pkgsrc-users%NetBSD.org@localhost
-HOMEPAGE= http://rbelmont.mameworld.info/?page_id=200
-COMMENT= Portable, very accurate NES emulator with UNIF support
-LICENSE= gnu-gpl-v2
-
-USE_LANGUAGES= c c++
-USE_TOOLS= gmake pkg-config
-
-SUBST_CLASSES+= oss
-SUBST_SED.oss= -e "s,/dev/dsp,${DEVOSSAUDIO},g"
-SUBST_FILES.oss= source/unix/oss.cpp
-SUBST_MESSAGE.oss= Fixing path to OSS device.
-SUBST_STAGE.oss= pre-build
-
-SUBST_CLASSES+= prefix
-SUBST_FILES.prefix= Makefile
-SUBST_MESSAGE.prefix= Fixing PREFIX path.
-SUBST_SED.prefix= -e "s|/usr/local|${PREFIX}|1"
-SUBST_STAGE.prefix= post-patch
-
-INSTALLATION_DIRS= share/doc/nestopia
-
-post-install:
- ${INSTALL_DATA} ${WRKSRC}/README.unix \
- ${DESTDIR}${PREFIX}/share/doc/nestopia
- ${INSTALL_DATA} ${WRKSRC}/readme.html \
- ${DESTDIR}${PREFIX}/share/doc/nestopia
-
-.include "../../archivers/libarchive/buildlink3.mk"
-.include "../../sysutils/desktop-file-utils/buildlink3.mk"
-BUILD_DEPENDS+= xdg-utils-[0-9]*:../../misc/xdg-utils
-.include "../../audio/alsa-lib/buildlink3.mk"
-.include "../../devel/SDL/buildlink3.mk"
-.include "../../x11/gtk3/buildlink3.mk"
-.include "../../mk/oss.buildlink3.mk"
-.include "../../mk/bsd.pkg.mk"
diff --git a/nestopia/PLIST b/nestopia/PLIST
deleted file mode 100644
index 792ab603fc..0000000000
--- a/nestopia/PLIST
+++ /dev/null
@@ -1,15 +0,0 @@
-@comment $NetBSD: PLIST,v 1.1 2013/02/07 19:00:32 othyro Exp $
-bin/nestopia
-share/doc/nestopia/README.unix
-share/doc/nestopia/readme.html
-share/nestopia/NstDatabase.xml
-share/nestopia/icons/nespad.svg
-share/nestopia/icons/nestopia.svg
-share/nestopia/icons/nestopia128.png
-share/nestopia/icons/nestopia32.png
-share/nestopia/icons/nestopia48.png
-share/nestopia/icons/nestopia64.png
-share/nestopia/icons/nestopia96.png
-share/nestopia/nestopia.desktop
-share/pixmaps/nestopia.svg
-@pkgdir share/applications
diff --git a/nestopia/distinfo b/nestopia/distinfo
deleted file mode 100644
index 46cd1b3cd9..0000000000
--- a/nestopia/distinfo
+++ /dev/null
@@ -1,7 +0,0 @@
-$NetBSD: distinfo,v 1.4 2014/05/04 03:25:15 othyro Exp $
-
-SHA1 (nestopia-1.45.tgz) = a399e7c0462e0872a23e1d245fa2ccd85f790902
-RMD160 (nestopia-1.45.tgz) = 58215a4c012263b848255da084fa8ec489ca4b55
-Size (nestopia-1.45.tgz) = 1883793 bytes
-SHA1 (patch-Makefile) = 8916b612c6017d0850714c317b76bd1bb66986f0
-SHA1 (patch-source_core_NstMemory.hpp) = 7bbf7dc7ea6439af24447a8ceed5bcc1eec11fae
diff --git a/nestopia/patches/patch-Makefile b/nestopia/patches/patch-Makefile
deleted file mode 100644
index d2685b0d1c..0000000000
--- a/nestopia/patches/patch-Makefile
+++ /dev/null
@@ -1,42 +0,0 @@
-$NetBSD: patch-Makefile,v 1.3 2014/05/04 03:25:15 othyro Exp $
-
-Make package use DESTDIR.
-
---- Makefile.orig 2013-07-29 23:43:11.000000000 +0000
-+++ Makefile
-@@ -180,21 +180,22 @@ $(BIN): $(OBJS)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $(BIN) $^ $(LIBS)
-
- install:
-- mkdir -p $(DATADIR)/icons
-- mkdir -p $(PREFIX)/share/pixmaps
-- install -m 0755 $(BIN) $(BINDIR)
-- install -m 0644 source/unix/icons/nestopia.desktop $(DATADIR)
-- install -m 0644 NstDatabase.xml $(DATADIR)
-- install -m 0644 source/unix/icons/*.png $(DATADIR)/icons
-- install -m 0644 source/unix/icons/*.svg $(DATADIR)/icons
-- install -m 0644 source/unix/icons/nestopia.svg $(PREFIX)/share/pixmaps
-- xdg-desktop-menu install --novendor $(DATADIR)/nestopia.desktop
-+ mkdir -p ${DESTDIR}$(BINDIR)
-+ mkdir -p ${DESTDIR}$(DATADIR)/icons
-+ mkdir -p ${DESTDIR}$(PREFIX)/share/pixmaps
-+ install -m 0755 $(BIN) ${DESTDIR}$(BINDIR)
-+ install -m 0644 source/unix/icons/nestopia.desktop ${DESTDIR}$(DATADIR)
-+ install -m 0644 NstDatabase.xml ${DESTDIR}$(DATADIR)
-+ install -m 0644 source/unix/icons/*.png ${DESTDIR}$(DATADIR)/icons
-+ install -m 0644 source/unix/icons/*.svg ${DESTDIR}$(DATADIR)/icons
-+ install -m 0644 source/unix/icons/nestopia.svg ${DESTDIR}$(PREFIX)/share/pixmaps
-+ #xdg-desktop-menu install --novendor ${DESTDIR}$(DATADIR)/nestopia.desktop
-
- uninstall:
-- xdg-desktop-menu uninstall $(DATADIR)/nestopia.desktop
-- rm $(PREFIX)/share/pixmaps/nestopia.svg
-- rm $(BINDIR)/$(BIN)
-- rm -rf $(DATADIR)
-+ #xdg-desktop-menu uninstall ${DESTDIR}$(DATADIR)/nestopia.desktop
-+ rm ${DESTDIR}$(PREFIX)/share/pixmaps/nestopia.svg
-+ rm ${DESTDIR}$(BINDIR)/$(BIN)
-+ rm -rf ${DESTDIR}$(DATADIR)
-
- clean:
- -@rm -f $(OBJS) $(BIN)
diff --git a/nestopia/patches/patch-source_core_NstMemory.hpp b/nestopia/patches/patch-source_core_NstMemory.hpp
deleted file mode 100644
index 807a4e951b..0000000000
--- a/nestopia/patches/patch-source_core_NstMemory.hpp
+++ /dev/null
@@ -1,1557 +0,0 @@
-$NetBSD: patch-source_core_NstMemory.hpp,v 1.2 2014/05/04 03:25:15 othyro Exp $
-
-Use SwapBank() instead of Source().
-
---- source/core/NstMemory.hpp.orig 2013-07-29 23:43:11.000000000 +0000
-+++ source/core/NstMemory.hpp
-@@ -1,775 +1,775 @@
--////////////////////////////////////////////////////////////////////////////////////////
--//
--// Nestopia - NES/Famicom emulator written in C++
--//
--// Copyright (C) 2003-2008 Martin Freij
--//
--// This file is part of Nestopia.
--//
--// Nestopia is free software; you can redistribute it and/or modify
--// it under the terms of the GNU General Public License as published by
--// the Free Software Foundation; either version 2 of the License, or
--// (at your option) any later version.
--//
--// Nestopia is distributed in the hope that it will be useful,
--// but WITHOUT ANY WARRANTY; without even the implied warranty of
--// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--// GNU General Public License for more details.
--//
--// You should have received a copy of the GNU General Public License
--// along with Nestopia; if not, write to the Free Software
--// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--//
--////////////////////////////////////////////////////////////////////////////////////////
--
--#ifndef NST_MEMORY_H
--#define NST_MEMORY_H
--
--#include "NstRam.hpp"
--
--#ifdef NST_PRAGMA_ONCE
--#pragma once
--#endif
--
--namespace Nes
--{
-- namespace Core
-- {
-- template<typename T> class Pointer : public ImplicitBool< Pointer<T> >
-- {
-- Pointer(const Pointer&);
--
-- T* const ptr;
--
-- public:
--
-- explicit Pointer(T* t)
-- : ptr(t) {}
--
-- ~Pointer()
-- {
-- typedef char TypeComplete[sizeof(T)];
-- delete ptr;
-- }
--
-- T* operator -> () const
-- {
-- return ptr;
-- }
--
-- T& operator * () const
-- {
-- return *ptr;
-- }
--
-- bool operator ! () const
-- {
-- return !ptr;
-- }
-- };
--
-- namespace State
-- {
-- class Saver;
-- class Loader;
-- }
--
-- template<dword SPACE,uint U,uint V>
-- class Memory;
--
-- template<>
-- class Memory<0,0,0>
-- {
-- protected:
--
-- enum
-- {
-- MAX_SOURCES = 2
-- };
--
-- void SaveState
-- (
-- State::Saver&,
-- dword,
-- const Ram* NST_RESTRICT,
-- uint,
-- const byte* NST_RESTRICT,
-- uint
-- ) const;
--
-- bool LoadState
-- (
-- State::Loader&,
-- Ram* NST_RESTRICT,
-- uint,
-- byte* NST_RESTRICT,
-- uint
-- ) const;
--
-- template<uint N> struct Pages
-- {
-- byte* mem[N];
-- byte ref[N];
-- };
--
-- template<uint OFFSET,uint COUNT,uint SIZE,uint I=COUNT>
-- struct Unroller
-- {
-- template<typename Pages>
-- static NST_FORCE_INLINE void SwapBank
-- (
-- Pages* const NST_RESTRICT pages,
-- byte* const NST_RESTRICT mem,
-- const dword mask,
-- const dword bank,
-- const uint offset=0,
-- const uint source=0
-- )
-- {
-- pages->mem[OFFSET+COUNT-I+offset] = mem + (bank & mask);
-- pages->ref[OFFSET+COUNT-I+offset] = source;
--
-- Unroller<OFFSET,COUNT,SIZE,I-1>::SwapBank( pages, mem, mask, bank + SIZE, offset, source );
-- }
--
-- template<typename Pages>
-- static NST_FORCE_INLINE void SwapBanks
-- (
-- Pages* const NST_RESTRICT pages,
-- byte* const NST_RESTRICT mem,
-- const dword mask,
-- const dword bank0,
-- const dword bank1,
-- const uint offset=0
-- )
-- {
-- Unroller<OFFSET+COUNT*0,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank0, offset );
-- Unroller<OFFSET+COUNT*1,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank1, offset );
-- }
--
-- template<typename Pages>
-- static NST_FORCE_INLINE void SwapBanks
-- (
-- Pages* const NST_RESTRICT pages,
-- byte* const NST_RESTRICT mem,
-- const dword mask,
-- const dword bank0,
-- const dword bank1,
-- const dword bank2,
-- const dword bank3,
-- const uint offset=0
-- )
-- {
-- Unroller<OFFSET+COUNT*0,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank0, offset );
-- Unroller<OFFSET+COUNT*1,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank1, offset );
-- Unroller<OFFSET+COUNT*2,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank2, offset );
-- Unroller<OFFSET+COUNT*3,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank3, offset );
-- }
--
-- template<typename Pages>
-- static NST_FORCE_INLINE void SwapBanks
-- (
-- Pages* const NST_RESTRICT pages,
-- byte* const NST_RESTRICT mem,
-- const dword mask,
-- const dword bank0,
-- const dword bank1,
-- const dword bank2,
-- const dword bank3,
-- const dword bank4,
-- const dword bank5,
-- const dword bank6,
-- const dword bank7,
-- const uint offset=0
-- )
-- {
-- Unroller<OFFSET+COUNT*0,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank0, offset );
-- Unroller<OFFSET+COUNT*1,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank1, offset );
-- Unroller<OFFSET+COUNT*2,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank2, offset );
-- Unroller<OFFSET+COUNT*3,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank3, offset );
-- Unroller<OFFSET+COUNT*4,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank4, offset );
-- Unroller<OFFSET+COUNT*5,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank5, offset );
-- Unroller<OFFSET+COUNT*6,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank6, offset );
-- Unroller<OFFSET+COUNT*7,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank7, offset );
-- }
-- };
-- };
--
-- template<>
-- struct Memory<0,0,0>::Pages<1>
-- {
-- byte* mem[1];
-- dword ref[1];
-- };
--
-- template<>
-- struct Memory<0,0,0>::Pages<2>
-- {
-- byte* mem[2];
-- word ref[2];
-- };
--
-- template<uint OFFSET,uint COUNT,uint SIZE>
-- struct Memory<0,0,0>::Unroller<OFFSET,COUNT,SIZE,0U>
-- {
-- template<typename Pages>
-- static NST_FORCE_INLINE void SwapBank(Pages*,byte*,dword,dword,uint,uint) {}
-- };
--
-- template<dword SPACE,uint U,uint V=1>
-- class Memory : Memory<0,0,0>
-- {
-- public:
--
-- enum
-- {
-- NUM_SOURCES = V
-- };
--
-- private:
--
-- NST_COMPILE_ASSERT
-- (
-- ((SPACE & (SPACE-1)) == 0) &&
-- ((U & (U-1)) == 0) &&
-- (SPACE % U == 0) &&
-- (V >= 1 && V <= MAX_SOURCES)
-- );
--
-- enum
-- {
-- MEM_PAGE_SIZE = U,
-- MEM_PAGE_SHIFT = ValueBits<MEM_PAGE_SIZE>::VALUE-1,
-- MEM_PAGE_MASK = MEM_PAGE_SIZE - 1,
-- MEM_NUM_PAGES = SPACE / U
-- };
--
-- typedef Memory<0,0,0>::Pages<MEM_NUM_PAGES> Pages;
--
-- Pages pages;
-- Ram sources[NUM_SOURCES];
--
-- public:
--
-- bool Readable(uint page) const
-- {
-- return sources[pages.ref[page]].Readable();
-- }
--
-- bool Writable(uint page) const
-- {
-- return sources[pages.ref[page]].Writable();
-- }
--
-- const byte& Peek(uint address) const
-- {
-- return pages.mem[address >> MEM_PAGE_SHIFT][address & MEM_PAGE_MASK];
-- }
--
-- byte* operator [] (uint page)
-- {
-- return pages.mem[page];
-- }
--
-- const byte* operator [] (uint page) const
-- {
-- return pages.mem[page];
-- }
--
-- void Poke(uint address,uint data)
-- {
-- const uint page = address >> MEM_PAGE_SHIFT;
-- NST_VERIFY( Writable( page ) );
--
-- if (Writable( page ))
-- pages.mem[page][address & MEM_PAGE_MASK] = data;
-- }
--
-- template<uint SIZE,uint ADDRESS>
-- void SwapBank(dword);
--
-- template<uint SIZE,uint ADDRESS>
-- void SwapBanks(dword,dword);
--
-- template<uint SIZE,uint ADDRESS>
-- void SwapBanks(dword,dword,dword,dword);
--
-- template<uint SIZE,uint ADDRESS>
-- void SwapBanks(dword,dword,dword,dword,dword,dword,dword,dword);
--
-- template<uint SIZE>
-- void SwapBank(uint,dword);
--
-- template<uint SIZE>
-- void SwapBanks(uint,dword,dword);
--
-- template<uint SIZE>
-- void SwapBanks(uint,dword,dword,dword,dword);
--
-- template<uint SIZE>
-- void SwapBanks(uint,dword,dword,dword,dword,dword,dword,dword,dword);
--
-- template<uint SIZE,uint A,uint B>
-- void SwapPages();
--
-- void SaveState(State::Saver&,dword) const;
-- void LoadState(State::Loader&);
--
-- class SourceProxy
-- {
-- typedef Memory<SPACE,U,V> Ref;
--
-- const uint source;
-- Ref& ref;
--
-- public:
--
-- SourceProxy(uint s,Ref& r)
-- : source(s), ref(r)
-- {
-- NST_ASSERT( s < NUM_SOURCES );
-- }
--
-- template<uint SIZE,uint ADDRESS>
-- void SwapBank(dword) const;
--
-- template<uint SIZE>
-- void SwapBank(uint,dword) const;
--
-- void ReadEnable(bool read) const
-- {
-- ref.sources[source].ReadEnable( read );
-- }
--
-- void WriteEnable(bool write) const
-- {
-- ref.sources[source].WriteEnable( write );
-- }
--
-- void SetSecurity(bool read,bool write) const
-- {
-- ref.sources[source].SetSecurity( read, write );
-- }
--
-- bool Readable() const
-- {
-- return ref.sources[source].Readable();
-- }
--
-- bool Writable() const
-- {
-- return ref.sources[source].Writable();
-- }
--
-- Ram::Type GetType() const
-- {
-- return ref.sources[source].GetType();
-- }
--
-- void Set(Ram::Type type,bool read,bool write,dword size,byte* mem) const
-- {
-- ref.sources[source].Set( type, read, write, size, mem );
-- }
--
-- void Set(Ram::Type type,bool read,bool write,dword size) const
-- {
-- ref.sources[source].Set( type, read, write, size );
-- }
--
-- void Set(const Ram& ram) const
-- {
-- ref.sources[source] = ram;
-- }
--
-- void Fill(uint value) const
-- {
-- ref.sources[source].Fill( value );
-- }
--
-- byte* Mem(dword offset=0) const
-- {
-- return ref.sources[source].Mem(offset);
-- }
--
-- byte& operator [] (dword i) const
-- {
-- return ref.sources[source][i];
-- }
--
-- dword Size() const
-- {
-- return ref.sources[source].Size();
-- }
--
-- dword Masking() const
-- {
-- return ref.sources[source].Masking();
-- }
--
-- bool Empty() const
-- {
-- return ref.sources[source].Size() == 0;
-- }
--
-- const Ram& Reference() const
-- {
-- return ref.sources[source];
-- }
-- };
--
-- public:
--
-- const SourceProxy Source(uint i=0)
-- {
-- NST_ASSERT( i < NUM_SOURCES );
-- return SourceProxy( i, *this );
-- }
--
-- const Ram& Source(uint i=0) const
-- {
-- NST_ASSERT( i < NUM_SOURCES );
-- return sources[i];
-- }
--
-- Memory()
-- {
-- }
--
-- Memory(byte* mem,dword size,bool read,bool write)
-- {
-- Source().Set( mem, size, read, write );
-- }
--
-- Memory(dword size,bool read,bool write)
-- {
-- Source().Set( size, read, write );
-- }
--
-- template<uint SIZE,uint ADDRESS>
-- dword GetBank() const
-- {
-- NST_COMPILE_ASSERT( SIZE && (SIZE % MEM_PAGE_SIZE == 0) && (SPACE >= ADDRESS + SIZE) );
--
-- enum {MEM_PAGE = ADDRESS >> MEM_PAGE_SHIFT};
-- return dword(pages.mem[MEM_PAGE] - sources[pages.ref[MEM_PAGE]].Mem()) >> (ValueBits<SIZE>::VALUE-1);
-- }
--
-- template<uint SIZE>
-- dword GetBank(uint address) const
-- {
-- NST_COMPILE_ASSERT( SIZE && (SIZE % MEM_PAGE_SIZE == 0) );
-- NST_ASSERT( SPACE >= address + SIZE );
--
-- address >>= MEM_PAGE_SHIFT;
-- return dword(pages.mem[address] - sources[pages.ref[address]].Mem()) >> (ValueBits<SIZE>::VALUE-1);
-- }
-- };
--
-- template<dword SPACE,uint U,uint V> template<uint SIZE,uint ADDRESS>
-- void Memory<SPACE,U,V>::SwapBank(dword bank)
-- {
-- NST_COMPILE_ASSERT( (SPACE >= ADDRESS + SIZE) && SIZE && (SIZE % MEM_PAGE_SIZE == 0) );
--
-- enum
-- {
-- MEM_OFFSET = ValueBits<SIZE>::VALUE-1,
-- MEM_PAGE_BEGIN = ADDRESS / MEM_PAGE_SIZE,
-- MEM_PAGE_COUNT = SIZE / MEM_PAGE_SIZE
-- };
--
-- Memory<0,0,0>::Unroller<MEM_PAGE_BEGIN,MEM_PAGE_COUNT,MEM_PAGE_SIZE>::SwapBank
-- (
-- &pages,
-- sources[0].Mem(),
-- sources[0].Masking(),
-- bank << MEM_OFFSET
-- );
-- }
--
-- template<dword SPACE,uint U,uint V> template<uint SIZE>
-- void Memory<SPACE,U,V>::SwapBank(uint address,dword bank)
-- {
-- NST_COMPILE_ASSERT( SIZE && (SIZE % MEM_PAGE_SIZE == 0) );
-- NST_ASSERT( SPACE >= address + SIZE );
--
-- enum
-- {
-- MEM_OFFSET = ValueBits<SIZE>::VALUE-1,
-- MEM_PAGE_COUNT = SIZE / MEM_PAGE_SIZE
-- };
--
-- Memory<0,0,0>::Unroller<0,MEM_PAGE_COUNT,MEM_PAGE_SIZE>::SwapBank
-- (
-- &pages,
-- sources[0].Mem(),
-- sources[0].Masking(),
-- bank << MEM_OFFSET,
-- address >> MEM_PAGE_SHIFT
-- );
-- }
--
-- template<dword SPACE,uint U,uint V> template<uint SIZE,uint ADDRESS>
-- void Memory<SPACE,U,V>::SwapBanks(dword bank0,dword bank1)
-- {
-- NST_COMPILE_ASSERT( (SPACE >= ADDRESS + SIZE * 2) && SIZE && (SIZE % MEM_PAGE_SIZE == 0) );
--
-- enum
-- {
-- MEM_OFFSET = ValueBits<SIZE>::VALUE-1,
-- MEM_PAGE_BEGIN = ADDRESS / MEM_PAGE_SIZE,
-- MEM_PAGE_COUNT = SIZE / MEM_PAGE_SIZE
-- };
--
-- Memory<0,0,0>::Unroller<MEM_PAGE_BEGIN,MEM_PAGE_COUNT,MEM_PAGE_SIZE>::SwapBanks
-- (
-- &pages,
-- sources[0].Mem(),
-- sources[0].Masking(),
-- bank0 << MEM_OFFSET,
-- bank1 << MEM_OFFSET
-- );
-- }
--
-- template<dword SPACE,uint U,uint V> template<uint SIZE,uint ADDRESS>
-- void Memory<SPACE,U,V>::SwapBanks(dword bank0,dword bank1,dword bank2,dword bank3)
-- {
-- NST_COMPILE_ASSERT( (SPACE >= ADDRESS + SIZE * 4) && SIZE && (SIZE % MEM_PAGE_SIZE == 0) );
--
-- enum
-- {
-- MEM_OFFSET = ValueBits<SIZE>::VALUE-1,
-- MEM_PAGE_BEGIN = ADDRESS / MEM_PAGE_SIZE,
-- MEM_PAGE_COUNT = SIZE / MEM_PAGE_SIZE
-- };
--
-- Memory<0,0,0>::Unroller<MEM_PAGE_BEGIN,MEM_PAGE_COUNT,MEM_PAGE_SIZE>::SwapBanks
-- (
-- &pages,
-- sources[0].Mem(),
-- sources[0].Masking(),
-- bank0 << MEM_OFFSET,
-- bank1 << MEM_OFFSET,
-- bank2 << MEM_OFFSET,
-- bank3 << MEM_OFFSET
-- );
-- }
--
-- template<dword SPACE,uint U,uint V> template<uint SIZE,uint ADDRESS>
-- void Memory<SPACE,U,V>::SwapBanks(dword bank0,dword bank1,dword bank2,dword bank3,dword bank4,dword bank5,dword bank6,dword bank7)
-- {
-- NST_COMPILE_ASSERT( (SPACE >= ADDRESS + SIZE * 4) && SIZE && (SIZE % MEM_PAGE_SIZE == 0) );
--
-- enum
-- {
-- MEM_OFFSET = ValueBits<SIZE>::VALUE-1,
-- MEM_PAGE_BEGIN = ADDRESS / MEM_PAGE_SIZE,
-- MEM_PAGE_COUNT = SIZE / MEM_PAGE_SIZE
-- };
--
-- Memory<0,0,0>::Unroller<MEM_PAGE_BEGIN,MEM_PAGE_COUNT,MEM_PAGE_SIZE>::SwapBanks
-- (
-- &pages,
-- sources[0].Mem(),
-- sources[0].Masking(),
-- bank0 << MEM_OFFSET,
-- bank1 << MEM_OFFSET,
-- bank2 << MEM_OFFSET,
-- bank3 << MEM_OFFSET,
-- bank4 << MEM_OFFSET,
-- bank5 << MEM_OFFSET,
-- bank6 << MEM_OFFSET,
-- bank7 << MEM_OFFSET
-- );
-- }
--
-- template<dword SPACE,uint U,uint V> template<uint SIZE>
-- void Memory<SPACE,U,V>::SwapBanks(uint address,dword bank0,dword bank1)
-- {
-- NST_COMPILE_ASSERT( SIZE && (SIZE % MEM_PAGE_SIZE == 0) );
-- NST_ASSERT( SPACE >= address + SIZE * 2 );
--
-- enum
-- {
-- MEM_OFFSET = ValueBits<SIZE>::VALUE-1,
-- MEM_PAGE_COUNT = SIZE / MEM_PAGE_SIZE
-- };
--
-- Memory<0,0,0>::Unroller<0,MEM_PAGE_COUNT,MEM_PAGE_SIZE>::SwapBanks
-- (
-- &pages,
-- sources[0].Mem(),
-- sources[0].Masking(),
-- bank0 << MEM_OFFSET,
-- bank1 << MEM_OFFSET,
-- address >> MEM_PAGE_SHIFT
-- );
-- }
--
-- template<dword SPACE,uint U,uint V> template<uint SIZE>
-- void Memory<SPACE,U,V>::SwapBanks(uint address,dword bank0,dword bank1,dword bank2,dword bank3)
-- {
-- NST_COMPILE_ASSERT( SIZE && (SIZE % MEM_PAGE_SIZE == 0) );
-- NST_ASSERT( SPACE >= address + SIZE * 4 );
--
-- enum
-- {
-- MEM_OFFSET = ValueBits<SIZE>::VALUE-1,
-- MEM_PAGE_COUNT = SIZE / MEM_PAGE_SIZE
-- };
--
-- Memory<0,0,0>::Unroller<0,MEM_PAGE_COUNT,MEM_PAGE_SIZE>::SwapBanks
-- (
-- &pages,
-- sources[0].Mem(),
-- sources[0].Masking(),
-- bank0 << MEM_OFFSET,
-- bank1 << MEM_OFFSET,
-- bank2 << MEM_OFFSET,
-- bank3 << MEM_OFFSET,
-- address >> MEM_PAGE_SHIFT
-- );
-- }
--
-- template<dword SPACE,uint U,uint V> template<uint SIZE>
-- void Memory<SPACE,U,V>::SwapBanks(uint address,dword bank0,dword bank1,dword bank2,dword bank3,dword bank4,dword bank5,dword bank6,dword bank7)
-- {
-- NST_COMPILE_ASSERT( SIZE && (SIZE % MEM_PAGE_SIZE == 0) );
-- NST_ASSERT( SPACE >= address + SIZE * 4 );
--
-- enum
-- {
-- MEM_OFFSET = ValueBits<SIZE>::VALUE-1,
-- MEM_PAGE_COUNT = SIZE / MEM_PAGE_SIZE
-- };
--
-- Memory<0,0,0>::Unroller<0,MEM_PAGE_COUNT,MEM_PAGE_SIZE>::SwapBanks
-- (
-- &pages,
-- sources[0].Mem(),
-- sources[0].Masking(),
-- bank0 << MEM_OFFSET,
-- bank1 << MEM_OFFSET,
-- bank2 << MEM_OFFSET,
-- bank3 << MEM_OFFSET,
-- bank4 << MEM_OFFSET,
-- bank5 << MEM_OFFSET,
-- bank6 << MEM_OFFSET,
-- bank7 << MEM_OFFSET,
-- address >> MEM_PAGE_SHIFT
-- );
-- }
--
-- template<dword SPACE,uint U,uint V> template<uint SIZE,uint ADDRESS>
-- void Memory<SPACE,U,V>::SourceProxy::SwapBank(dword bank) const
-- {
-- NST_COMPILE_ASSERT( (SPACE >= ADDRESS + SIZE) && SIZE && (SIZE % MEM_PAGE_SIZE == 0) );
--
-- enum
-- {
-- MEM_OFFSET = ValueBits<SIZE>::VALUE-1,
-- MEM_PAGE_BEGIN = ADDRESS / MEM_PAGE_SIZE,
-- MEM_PAGE_COUNT = SIZE / MEM_PAGE_SIZE
-- };
--
-- Memory<0,0,0>::Unroller<MEM_PAGE_BEGIN,MEM_PAGE_COUNT,MEM_PAGE_SIZE>::SwapBank
-- (
-- &ref.pages,
-- ref.sources[source].Mem(),
-- ref.sources[source].Masking(),
-- bank << MEM_OFFSET,
-- 0,
-- source
-- );
-- }
--
-- template<dword SPACE,uint U,uint V> template<uint SIZE>
-- void Memory<SPACE,U,V>::SourceProxy::SwapBank(uint address,dword bank) const
-- {
-- NST_COMPILE_ASSERT( SIZE && (SIZE % MEM_PAGE_SIZE == 0) );
-- NST_ASSERT( SPACE >= address + SIZE );
--
-- enum
-- {
-- MEM_OFFSET = ValueBits<SIZE>::VALUE-1,
-- MEM_PAGE_COUNT = SIZE / MEM_PAGE_SIZE
-- };
--
-- Memory<0,0,0>::Unroller<0,MEM_PAGE_COUNT,MEM_PAGE_SIZE>::SwapBank
-- (
-- &ref.pages,
-- ref.sources[source].Mem(),
-- ref.sources[source].Masking(),
-- bank << MEM_OFFSET,
-- address >> MEM_PAGE_SHIFT,
-- source
-- );
-- }
--
-- template<dword SPACE,uint U,uint V> template<uint SIZE,uint A,uint B>
-- void Memory<SPACE,U,V>::SwapPages()
-- {
-- NST_COMPILE_ASSERT
-- (
-- (A != B) &&
-- (SPACE >= A + SIZE) &&
-- (SPACE >= B + SIZE) &&
-- (SIZE && (SIZE % MEM_PAGE_SIZE) == 0)
-- );
--
-- enum
-- {
-- MEM_A_BEGIN = A / MEM_PAGE_SIZE,
-- MEM_B_BEGIN = B / MEM_PAGE_SIZE,
-- MEM_PAGE_COUNT = SIZE / MEM_PAGE_SIZE
-- };
--
-- for (uint i=0; i < MEM_PAGE_COUNT; ++i)
-- {
-- byte* const mem = pages.mem[MEM_A_BEGIN+i];
-- const byte ref = pages.ref[MEM_A_BEGIN+i];
--
-- pages.mem[MEM_A_BEGIN+i] = pages.mem[MEM_B_BEGIN+i];
-- pages.ref[MEM_A_BEGIN+i] = pages.ref[MEM_B_BEGIN+i];
--
-- pages.mem[MEM_B_BEGIN+i] = mem;
-- pages.ref[MEM_B_BEGIN+i] = ref;
-- }
-- }
--
-- template<dword SPACE,uint U,uint V>
-- void Memory<SPACE,U,V>::SaveState(State::Saver& state,const dword baseChunk) const
-- {
-- byte pageData[MEM_NUM_PAGES*3];
--
-- for (uint i=0; i < MEM_NUM_PAGES; ++i)
-- {
-- const uint bank = GetBank<MEM_PAGE_SIZE>( i * MEM_PAGE_SIZE );
--
-- pageData[i*3+0] = pages.ref[i];
-- pageData[i*3+1] = bank & 0xFF;
-- pageData[i*3+2] = bank >> 8;
-- }
--
-- Memory<0,0,0>::SaveState( state, baseChunk, sources, NUM_SOURCES, pageData, MEM_NUM_PAGES );
-- }
--
-- template<dword SPACE,uint U,uint V>
-- void Memory<SPACE,U,V>::LoadState(State::Loader& state)
-- {
-- byte pageData[MEM_NUM_PAGES*3];
--
-- if (Memory<0,0,0>::LoadState( state, sources, NUM_SOURCES, pageData, MEM_NUM_PAGES ))
-- {
-- for (uint i=0; i < MEM_NUM_PAGES; ++i)
-- {
-- if (pageData[i*3+0] < NUM_SOURCES)
-- Source( pageData[i*3+0] ).template SwapBank<MEM_PAGE_SIZE>( i * MEM_PAGE_SIZE, pageData[i*3+1] | uint(pageData[i*3+2]) << 8 );
-- else
-- throw RESULT_ERR_CORRUPT_FILE;
-- }
-- }
-- }
-- }
--}
--
--#endif
-+////////////////////////////////////////////////////////////////////////////////////////
-+//
-+// Nestopia - NES/Famicom emulator written in C++
-+//
-+// Copyright (C) 2003-2008 Martin Freij
-+//
-+// This file is part of Nestopia.
-+//
-+// Nestopia is free software; you can redistribute it and/or modify
-+// it under the terms of the GNU General Public License as published by
-+// the Free Software Foundation; either version 2 of the License, or
-+// (at your option) any later version.
-+//
-+// Nestopia is distributed in the hope that it will be useful,
-+// but WITHOUT ANY WARRANTY; without even the implied warranty of
-+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+// GNU General Public License for more details.
-+//
-+// You should have received a copy of the GNU General Public License
-+// along with Nestopia; if not, write to the Free Software
-+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-+//
-+////////////////////////////////////////////////////////////////////////////////////////
-+
-+#ifndef NST_MEMORY_H
-+#define NST_MEMORY_H
-+
-+#include "NstRam.hpp"
-+
-+#ifdef NST_PRAGMA_ONCE
-+#pragma once
-+#endif
-+
-+namespace Nes
-+{
-+ namespace Core
-+ {
-+ template<typename T> class Pointer : public ImplicitBool< Pointer<T> >
-+ {
-+ Pointer(const Pointer&);
-+
-+ T* const ptr;
-+
-+ public:
-+
-+ explicit Pointer(T* t)
-+ : ptr(t) {}
-+
-+ ~Pointer()
-+ {
-+ typedef char TypeComplete[sizeof(T)];
-+ delete ptr;
-+ }
-+
-+ T* operator -> () const
-+ {
-+ return ptr;
-+ }
-+
-+ T& operator * () const
-+ {
-+ return *ptr;
-+ }
-+
-+ bool operator ! () const
-+ {
-+ return !ptr;
-+ }
-+ };
-+
-+ namespace State
-+ {
-+ class Saver;
-+ class Loader;
-+ }
-+
-+ template<dword SPACE,uint U,uint V>
-+ class Memory;
-+
-+ template<>
-+ class Memory<0,0,0>
-+ {
-+ protected:
-+
-+ enum
-+ {
-+ MAX_SOURCES = 2
-+ };
-+
-+ void SaveState
-+ (
-+ State::Saver&,
-+ dword,
-+ const Ram* NST_RESTRICT,
-+ uint,
-+ const byte* NST_RESTRICT,
-+ uint
-+ ) const;
-+
-+ bool LoadState
-+ (
-+ State::Loader&,
-+ Ram* NST_RESTRICT,
-+ uint,
-+ byte* NST_RESTRICT,
-+ uint
-+ ) const;
-+
-+ template<uint N> struct Pages
-+ {
-+ byte* mem[N];
-+ byte ref[N];
-+ };
-+
-+ template<uint OFFSET,uint COUNT,uint SIZE,uint I=COUNT>
-+ struct Unroller
-+ {
-+ template<typename Pages>
-+ static NST_FORCE_INLINE void SwapBank
-+ (
-+ Pages* const NST_RESTRICT pages,
-+ byte* const NST_RESTRICT mem,
-+ const dword mask,
-+ const dword bank,
-+ const uint offset=0,
-+ const uint source=0
-+ )
-+ {
-+ pages->mem[OFFSET+COUNT-I+offset] = mem + (bank & mask);
-+ pages->ref[OFFSET+COUNT-I+offset] = source;
-+
-+ Unroller<OFFSET,COUNT,SIZE,I-1>::SwapBank( pages, mem, mask, bank + SIZE, offset, source );
-+ }
-+
-+ template<typename Pages>
-+ static NST_FORCE_INLINE void SwapBanks
-+ (
-+ Pages* const NST_RESTRICT pages,
-+ byte* const NST_RESTRICT mem,
-+ const dword mask,
-+ const dword bank0,
-+ const dword bank1,
-+ const uint offset=0
-+ )
-+ {
-+ Unroller<OFFSET+COUNT*0,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank0, offset );
-+ Unroller<OFFSET+COUNT*1,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank1, offset );
-+ }
-+
-+ template<typename Pages>
-+ static NST_FORCE_INLINE void SwapBanks
-+ (
-+ Pages* const NST_RESTRICT pages,
-+ byte* const NST_RESTRICT mem,
-+ const dword mask,
-+ const dword bank0,
-+ const dword bank1,
-+ const dword bank2,
-+ const dword bank3,
-+ const uint offset=0
-+ )
-+ {
-+ Unroller<OFFSET+COUNT*0,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank0, offset );
-+ Unroller<OFFSET+COUNT*1,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank1, offset );
-+ Unroller<OFFSET+COUNT*2,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank2, offset );
-+ Unroller<OFFSET+COUNT*3,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank3, offset );
-+ }
-+
-+ template<typename Pages>
-+ static NST_FORCE_INLINE void SwapBanks
-+ (
-+ Pages* const NST_RESTRICT pages,
-+ byte* const NST_RESTRICT mem,
-+ const dword mask,
-+ const dword bank0,
-+ const dword bank1,
-+ const dword bank2,
-+ const dword bank3,
-+ const dword bank4,
-+ const dword bank5,
-+ const dword bank6,
-+ const dword bank7,
-+ const uint offset=0
-+ )
-+ {
-+ Unroller<OFFSET+COUNT*0,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank0, offset );
-+ Unroller<OFFSET+COUNT*1,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank1, offset );
-+ Unroller<OFFSET+COUNT*2,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank2, offset );
-+ Unroller<OFFSET+COUNT*3,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank3, offset );
-+ Unroller<OFFSET+COUNT*4,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank4, offset );
-+ Unroller<OFFSET+COUNT*5,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank5, offset );
-+ Unroller<OFFSET+COUNT*6,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank6, offset );
-+ Unroller<OFFSET+COUNT*7,COUNT,SIZE,I>::SwapBank( pages, mem, mask, bank7, offset );
-+ }
-+ };
-+ };
-+
-+ template<>
-+ struct Memory<0,0,0>::Pages<1>
-+ {
-+ byte* mem[1];
-+ dword ref[1];
-+ };
-+
-+ template<>
-+ struct Memory<0,0,0>::Pages<2>
-+ {
-+ byte* mem[2];
-+ word ref[2];
-+ };
-+
-+ template<uint OFFSET,uint COUNT,uint SIZE>
-+ struct Memory<0,0,0>::Unroller<OFFSET,COUNT,SIZE,0U>
-+ {
-+ template<typename Pages>
-+ static NST_FORCE_INLINE void SwapBank(Pages*,byte*,dword,dword,uint,uint) {}
-+ };
-+
-+ template<dword SPACE,uint U,uint V=1>
-+ class Memory : Memory<0,0,0>
-+ {
-+ public:
-+
-+ enum
-+ {
-+ NUM_SOURCES = V
-+ };
-+
-+ private:
-+
-+ NST_COMPILE_ASSERT
-+ (
-+ ((SPACE & (SPACE-1)) == 0) &&
-+ ((U & (U-1)) == 0) &&
-+ (SPACE % U == 0) &&
-+ (V >= 1 && V <= MAX_SOURCES)
-+ );
-+
-+ enum
-+ {
-+ MEM_PAGE_SIZE = U,
-+ MEM_PAGE_SHIFT = ValueBits<MEM_PAGE_SIZE>::VALUE-1,
-+ MEM_PAGE_MASK = MEM_PAGE_SIZE - 1,
-+ MEM_NUM_PAGES = SPACE / U
-+ };
-+
-+ typedef Memory<0,0,0>::Pages<MEM_NUM_PAGES> Pages;
-+
-+ Pages pages;
-+ Ram sources[NUM_SOURCES];
-+
-+ public:
-+
-+ bool Readable(uint page) const
-+ {
-+ return sources[pages.ref[page]].Readable();
-+ }
-+
-+ bool Writable(uint page) const
-+ {
-+ return sources[pages.ref[page]].Writable();
-+ }
-+
-+ const byte& Peek(uint address) const
-+ {
-+ return pages.mem[address >> MEM_PAGE_SHIFT][address & MEM_PAGE_MASK];
-+ }
-+
-+ byte* operator [] (uint page)
-+ {
-+ return pages.mem[page];
-+ }
-+
-+ const byte* operator [] (uint page) const
-+ {
-+ return pages.mem[page];
-+ }
-+
-+ void Poke(uint address,uint data)
-+ {
-+ const uint page = address >> MEM_PAGE_SHIFT;
-+ NST_VERIFY( Writable( page ) );
-+
-+ if (Writable( page ))
-+ pages.mem[page][address & MEM_PAGE_MASK] = data;
-+ }
-+
-+ template<uint SIZE,uint ADDRESS>
-+ void SwapBank(dword);
-+
-+ template<uint SIZE,uint ADDRESS>
-+ void SwapBanks(dword,dword);
-+
-+ template<uint SIZE,uint ADDRESS>
-+ void SwapBanks(dword,dword,dword,dword);
-+
-+ template<uint SIZE,uint ADDRESS>
-+ void SwapBanks(dword,dword,dword,dword,dword,dword,dword,dword);
-+
-+ template<uint SIZE>
-+ void SwapBank(uint,dword);
-+
-+ template<uint SIZE>
-+ void SwapBanks(uint,dword,dword);
-+
-+ template<uint SIZE>
-+ void SwapBanks(uint,dword,dword,dword,dword);
-+
-+ template<uint SIZE>
-+ void SwapBanks(uint,dword,dword,dword,dword,dword,dword,dword,dword);
-+
-+ template<uint SIZE,uint A,uint B>
-+ void SwapPages();
-+
-+ void SaveState(State::Saver&,dword) const;
-+ void LoadState(State::Loader&);
-+
-+ class SourceProxy
-+ {
-+ typedef Memory<SPACE,U,V> Ref;
-+
-+ const uint source;
-+ Ref& ref;
-+
-+ public:
-+
-+ SourceProxy(uint s,Ref& r)
-+ : source(s), ref(r)
-+ {
-+ NST_ASSERT( s < NUM_SOURCES );
-+ }
-+
-+ template<uint SIZE,uint ADDRESS>
-+ void SwapBank(dword) const;
-+
-+ template<uint SIZE>
-+ void SwapBank(uint,dword) const;
-+
-+ void ReadEnable(bool read) const
-+ {
-+ ref.sources[source].ReadEnable( read );
-+ }
-+
-+ void WriteEnable(bool write) const
-+ {
-+ ref.sources[source].WriteEnable( write );
-+ }
-+
-+ void SetSecurity(bool read,bool write) const
-+ {
-+ ref.sources[source].SetSecurity( read, write );
-+ }
-+
-+ bool Readable() const
-+ {
-+ return ref.sources[source].Readable();
-+ }
-+
-+ bool Writable() const
-+ {
-+ return ref.sources[source].Writable();
-+ }
-+
-+ Ram::Type GetType() const
-+ {
-+ return ref.sources[source].GetType();
-+ }
-+
-+ void Set(Ram::Type type,bool read,bool write,dword size,byte* mem) const
-+ {
-+ ref.sources[source].Set( type, read, write, size, mem );
-+ }
-+
-+ void Set(Ram::Type type,bool read,bool write,dword size) const
-+ {
-+ ref.sources[source].Set( type, read, write, size );
-+ }
-+
-+ void Set(const Ram& ram) const
-+ {
-+ ref.sources[source] = ram;
-+ }
-+
-+ void Fill(uint value) const
-+ {
-+ ref.sources[source].Fill( value );
-+ }
-+
-+ byte* Mem(dword offset=0) const
-+ {
-+ return ref.sources[source].Mem(offset);
-+ }
-+
-+ byte& operator [] (dword i) const
-+ {
-+ return ref.sources[source][i];
-+ }
-+
-+ dword Size() const
-+ {
-+ return ref.sources[source].Size();
-+ }
-+
-+ dword Masking() const
-+ {
-+ return ref.sources[source].Masking();
-+ }
-+
-+ bool Empty() const
-+ {
-+ return ref.sources[source].Size() == 0;
-+ }
-+
-+ const Ram& Reference() const
-+ {
-+ return ref.sources[source];
-+ }
-+ };
-+
-+ public:
-+
-+ const SourceProxy Source(uint i=0)
-+ {
-+ NST_ASSERT( i < NUM_SOURCES );
-+ return SourceProxy( i, *this );
-+ }
-+
-+ const Ram& Source(uint i=0) const
-+ {
-+ NST_ASSERT( i < NUM_SOURCES );
-+ return sources[i];
-+ }
-+
-+ Memory()
-+ {
-+ }
-+
-+ Memory(byte* mem,dword size,bool read,bool write)
-+ {
-+ Source().Set( mem, size, read, write );
-+ }
-+
-+ Memory(dword size,bool read,bool write)
-+ {
-+ Source().Set( size, read, write );
-+ }
-+
-+ template<uint SIZE,uint ADDRESS>
-+ dword GetBank() const
-+ {
-+ NST_COMPILE_ASSERT( SIZE && (SIZE % MEM_PAGE_SIZE == 0) && (SPACE >= ADDRESS + SIZE) );
-+
-+ enum {MEM_PAGE = ADDRESS >> MEM_PAGE_SHIFT};
-+ return dword(pages.mem[MEM_PAGE] - sources[pages.ref[MEM_PAGE]].Mem()) >> (ValueBits<SIZE>::VALUE-1);
-+ }
-+
-+ template<uint SIZE>
-+ dword GetBank(uint address) const
-+ {
-+ NST_COMPILE_ASSERT( SIZE && (SIZE % MEM_PAGE_SIZE == 0) );
-+ NST_ASSERT( SPACE >= address + SIZE );
-+
-+ address >>= MEM_PAGE_SHIFT;
-+ return dword(pages.mem[address] - sources[pages.ref[address]].Mem()) >> (ValueBits<SIZE>::VALUE-1);
-+ }
-+ };
-+
-+ template<dword SPACE,uint U,uint V> template<uint SIZE,uint ADDRESS>
-+ void Memory<SPACE,U,V>::SwapBank(dword bank)
-+ {
-+ NST_COMPILE_ASSERT( (SPACE >= ADDRESS + SIZE) && SIZE && (SIZE % MEM_PAGE_SIZE == 0) );
-+
-+ enum
-+ {
-+ MEM_OFFSET = ValueBits<SIZE>::VALUE-1,
-+ MEM_PAGE_BEGIN = ADDRESS / MEM_PAGE_SIZE,
-+ MEM_PAGE_COUNT = SIZE / MEM_PAGE_SIZE
-+ };
-+
-+ Memory<0,0,0>::Unroller<MEM_PAGE_BEGIN,MEM_PAGE_COUNT,MEM_PAGE_SIZE>::SwapBank
-+ (
-+ &pages,
-+ sources[0].Mem(),
-+ sources[0].Masking(),
-+ bank << MEM_OFFSET
-+ );
-+ }
-+
-+ template<dword SPACE,uint U,uint V> template<uint SIZE>
-+ void Memory<SPACE,U,V>::SwapBank(uint address,dword bank)
-+ {
-+ NST_COMPILE_ASSERT( SIZE && (SIZE % MEM_PAGE_SIZE == 0) );
-+ NST_ASSERT( SPACE >= address + SIZE );
-+
-+ enum
-+ {
-+ MEM_OFFSET = ValueBits<SIZE>::VALUE-1,
-+ MEM_PAGE_COUNT = SIZE / MEM_PAGE_SIZE
-+ };
-+
-+ Memory<0,0,0>::Unroller<0,MEM_PAGE_COUNT,MEM_PAGE_SIZE>::SwapBank
-+ (
-+ &pages,
-+ sources[0].Mem(),
-+ sources[0].Masking(),
-+ bank << MEM_OFFSET,
-+ address >> MEM_PAGE_SHIFT
-+ );
-+ }
-+
-+ template<dword SPACE,uint U,uint V> template<uint SIZE,uint ADDRESS>
-+ void Memory<SPACE,U,V>::SwapBanks(dword bank0,dword bank1)
-+ {
-+ NST_COMPILE_ASSERT( (SPACE >= ADDRESS + SIZE * 2) && SIZE && (SIZE % MEM_PAGE_SIZE == 0) );
-+
-+ enum
-+ {
-+ MEM_OFFSET = ValueBits<SIZE>::VALUE-1,
-+ MEM_PAGE_BEGIN = ADDRESS / MEM_PAGE_SIZE,
-+ MEM_PAGE_COUNT = SIZE / MEM_PAGE_SIZE
-+ };
-+
-+ Memory<0,0,0>::Unroller<MEM_PAGE_BEGIN,MEM_PAGE_COUNT,MEM_PAGE_SIZE>::SwapBanks
-+ (
-+ &pages,
-+ sources[0].Mem(),
-+ sources[0].Masking(),
-+ bank0 << MEM_OFFSET,
-+ bank1 << MEM_OFFSET
-+ );
-+ }
-+
-+ template<dword SPACE,uint U,uint V> template<uint SIZE,uint ADDRESS>
-+ void Memory<SPACE,U,V>::SwapBanks(dword bank0,dword bank1,dword bank2,dword bank3)
-+ {
-+ NST_COMPILE_ASSERT( (SPACE >= ADDRESS + SIZE * 4) && SIZE && (SIZE % MEM_PAGE_SIZE == 0) );
-+
-+ enum
-+ {
-+ MEM_OFFSET = ValueBits<SIZE>::VALUE-1,
-+ MEM_PAGE_BEGIN = ADDRESS / MEM_PAGE_SIZE,
-+ MEM_PAGE_COUNT = SIZE / MEM_PAGE_SIZE
-+ };
-+
-+ Memory<0,0,0>::Unroller<MEM_PAGE_BEGIN,MEM_PAGE_COUNT,MEM_PAGE_SIZE>::SwapBanks
-+ (
-+ &pages,
-+ sources[0].Mem(),
-+ sources[0].Masking(),
-+ bank0 << MEM_OFFSET,
-+ bank1 << MEM_OFFSET,
-+ bank2 << MEM_OFFSET,
-+ bank3 << MEM_OFFSET
-+ );
-+ }
-+
-+ template<dword SPACE,uint U,uint V> template<uint SIZE,uint ADDRESS>
-+ void Memory<SPACE,U,V>::SwapBanks(dword bank0,dword bank1,dword bank2,dword bank3,dword bank4,dword bank5,dword bank6,dword bank7)
-+ {
-+ NST_COMPILE_ASSERT( (SPACE >= ADDRESS + SIZE * 4) && SIZE && (SIZE % MEM_PAGE_SIZE == 0) );
-+
-+ enum
-+ {
-+ MEM_OFFSET = ValueBits<SIZE>::VALUE-1,
-+ MEM_PAGE_BEGIN = ADDRESS / MEM_PAGE_SIZE,
-+ MEM_PAGE_COUNT = SIZE / MEM_PAGE_SIZE
-+ };
-+
-+ Memory<0,0,0>::Unroller<MEM_PAGE_BEGIN,MEM_PAGE_COUNT,MEM_PAGE_SIZE>::SwapBanks
-+ (
-+ &pages,
-+ sources[0].Mem(),
-+ sources[0].Masking(),
-+ bank0 << MEM_OFFSET,
-+ bank1 << MEM_OFFSET,
-+ bank2 << MEM_OFFSET,
-+ bank3 << MEM_OFFSET,
-+ bank4 << MEM_OFFSET,
-+ bank5 << MEM_OFFSET,
-+ bank6 << MEM_OFFSET,
-+ bank7 << MEM_OFFSET
-+ );
-+ }
-+
-+ template<dword SPACE,uint U,uint V> template<uint SIZE>
-+ void Memory<SPACE,U,V>::SwapBanks(uint address,dword bank0,dword bank1)
-+ {
-+ NST_COMPILE_ASSERT( SIZE && (SIZE % MEM_PAGE_SIZE == 0) );
-+ NST_ASSERT( SPACE >= address + SIZE * 2 );
-+
-+ enum
-+ {
-+ MEM_OFFSET = ValueBits<SIZE>::VALUE-1,
-+ MEM_PAGE_COUNT = SIZE / MEM_PAGE_SIZE
-+ };
-+
-+ Memory<0,0,0>::Unroller<0,MEM_PAGE_COUNT,MEM_PAGE_SIZE>::SwapBanks
-+ (
-+ &pages,
-+ sources[0].Mem(),
-+ sources[0].Masking(),
-+ bank0 << MEM_OFFSET,
-+ bank1 << MEM_OFFSET,
-+ address >> MEM_PAGE_SHIFT
-+ );
-+ }
-+
-+ template<dword SPACE,uint U,uint V> template<uint SIZE>
-+ void Memory<SPACE,U,V>::SwapBanks(uint address,dword bank0,dword bank1,dword bank2,dword bank3)
-+ {
-+ NST_COMPILE_ASSERT( SIZE && (SIZE % MEM_PAGE_SIZE == 0) );
-+ NST_ASSERT( SPACE >= address + SIZE * 4 );
-+
-+ enum
-+ {
-+ MEM_OFFSET = ValueBits<SIZE>::VALUE-1,
-+ MEM_PAGE_COUNT = SIZE / MEM_PAGE_SIZE
-+ };
-+
-+ Memory<0,0,0>::Unroller<0,MEM_PAGE_COUNT,MEM_PAGE_SIZE>::SwapBanks
-+ (
-+ &pages,
-+ sources[0].Mem(),
-+ sources[0].Masking(),
-+ bank0 << MEM_OFFSET,
-+ bank1 << MEM_OFFSET,
-+ bank2 << MEM_OFFSET,
-+ bank3 << MEM_OFFSET,
-+ address >> MEM_PAGE_SHIFT
-+ );
-+ }
-+
-+ template<dword SPACE,uint U,uint V> template<uint SIZE>
-+ void Memory<SPACE,U,V>::SwapBanks(uint address,dword bank0,dword bank1,dword bank2,dword bank3,dword bank4,dword bank5,dword bank6,dword bank7)
-+ {
-+ NST_COMPILE_ASSERT( SIZE && (SIZE % MEM_PAGE_SIZE == 0) );
-+ NST_ASSERT( SPACE >= address + SIZE * 4 );
-+
-+ enum
-+ {
-+ MEM_OFFSET = ValueBits<SIZE>::VALUE-1,
-+ MEM_PAGE_COUNT = SIZE / MEM_PAGE_SIZE
-+ };
-+
-+ Memory<0,0,0>::Unroller<0,MEM_PAGE_COUNT,MEM_PAGE_SIZE>::SwapBanks
-+ (
-+ &pages,
-+ sources[0].Mem(),
-+ sources[0].Masking(),
-+ bank0 << MEM_OFFSET,
-+ bank1 << MEM_OFFSET,
-+ bank2 << MEM_OFFSET,
-+ bank3 << MEM_OFFSET,
-+ bank4 << MEM_OFFSET,
-+ bank5 << MEM_OFFSET,
-+ bank6 << MEM_OFFSET,
-+ bank7 << MEM_OFFSET,
-+ address >> MEM_PAGE_SHIFT
-+ );
-+ }
-+
-+ template<dword SPACE,uint U,uint V> template<uint SIZE,uint ADDRESS>
-+ void Memory<SPACE,U,V>::SourceProxy::SwapBank(dword bank) const
-+ {
-+ NST_COMPILE_ASSERT( (SPACE >= ADDRESS + SIZE) && SIZE && (SIZE % MEM_PAGE_SIZE == 0) );
-+
-+ enum
-+ {
-+ MEM_OFFSET = ValueBits<SIZE>::VALUE-1,
-+ MEM_PAGE_BEGIN = ADDRESS / MEM_PAGE_SIZE,
-+ MEM_PAGE_COUNT = SIZE / MEM_PAGE_SIZE
-+ };
-+
-+ Memory<0,0,0>::Unroller<MEM_PAGE_BEGIN,MEM_PAGE_COUNT,MEM_PAGE_SIZE>::SwapBank
-+ (
-+ &ref.pages,
-+ ref.sources[source].Mem(),
-+ ref.sources[source].Masking(),
-+ bank << MEM_OFFSET,
-+ 0,
-+ source
-+ );
-+ }
-+
-+ template<dword SPACE,uint U,uint V> template<uint SIZE>
-+ void Memory<SPACE,U,V>::SourceProxy::SwapBank(uint address,dword bank) const
-+ {
-+ NST_COMPILE_ASSERT( SIZE && (SIZE % MEM_PAGE_SIZE == 0) );
-+ NST_ASSERT( SPACE >= address + SIZE );
-+
-+ enum
-+ {
-+ MEM_OFFSET = ValueBits<SIZE>::VALUE-1,
-+ MEM_PAGE_COUNT = SIZE / MEM_PAGE_SIZE
-+ };
-+
-+ Memory<0,0,0>::Unroller<0,MEM_PAGE_COUNT,MEM_PAGE_SIZE>::SwapBank
-+ (
-+ &ref.pages,
-+ ref.sources[source].Mem(),
-+ ref.sources[source].Masking(),
-+ bank << MEM_OFFSET,
-+ address >> MEM_PAGE_SHIFT,
-+ source
-+ );
-+ }
-+
-+ template<dword SPACE,uint U,uint V> template<uint SIZE,uint A,uint B>
-+ void Memory<SPACE,U,V>::SwapPages()
-+ {
-+ NST_COMPILE_ASSERT
-+ (
-+ (A != B) &&
-+ (SPACE >= A + SIZE) &&
-+ (SPACE >= B + SIZE) &&
-+ (SIZE && (SIZE % MEM_PAGE_SIZE) == 0)
-+ );
-+
-+ enum
-+ {
-+ MEM_A_BEGIN = A / MEM_PAGE_SIZE,
-+ MEM_B_BEGIN = B / MEM_PAGE_SIZE,
-+ MEM_PAGE_COUNT = SIZE / MEM_PAGE_SIZE
-+ };
-+
-+ for (uint i=0; i < MEM_PAGE_COUNT; ++i)
-+ {
-+ byte* const mem = pages.mem[MEM_A_BEGIN+i];
-+ const byte ref = pages.ref[MEM_A_BEGIN+i];
-+
-+ pages.mem[MEM_A_BEGIN+i] = pages.mem[MEM_B_BEGIN+i];
-+ pages.ref[MEM_A_BEGIN+i] = pages.ref[MEM_B_BEGIN+i];
-+
-+ pages.mem[MEM_B_BEGIN+i] = mem;
-+ pages.ref[MEM_B_BEGIN+i] = ref;
-+ }
-+ }
-+
-+ template<dword SPACE,uint U,uint V>
-+ void Memory<SPACE,U,V>::SaveState(State::Saver& state,const dword baseChunk) const
-+ {
-+ byte pageData[MEM_NUM_PAGES*3];
-+
-+ for (uint i=0; i < MEM_NUM_PAGES; ++i)
-+ {
-+ const uint bank = GetBank<MEM_PAGE_SIZE>( i * MEM_PAGE_SIZE );
-+
-+ pageData[i*3+0] = pages.ref[i];
-+ pageData[i*3+1] = bank & 0xFF;
-+ pageData[i*3+2] = bank >> 8;
-+ }
-+
-+ Memory<0,0,0>::SaveState( state, baseChunk, sources, NUM_SOURCES, pageData, MEM_NUM_PAGES );
-+ }
-+
-+ template<dword SPACE,uint U,uint V>
-+ void Memory<SPACE,U,V>::LoadState(State::Loader& state)
-+ {
-+ byte pageData[MEM_NUM_PAGES*3];
-+
-+ if (Memory<0,0,0>::LoadState( state, sources, NUM_SOURCES, pageData, MEM_NUM_PAGES ))
-+ {
-+ for (uint i=0; i < MEM_NUM_PAGES; ++i)
-+ {
-+ if (pageData[i*3+0] < NUM_SOURCES)
-+ SwapBank<MEM_PAGE_SIZE>( i * MEM_PAGE_SIZE, pageData[i*3+1] | uint(pageData[i*3+2]) << 8 );
-+ else
-+ throw RESULT_ERR_CORRUPT_FILE;
-+ }
-+ }
-+ }
-+ }
-+}
-+
-+#endif
Home |
Main Index |
Thread Index |
Old Index