//1// Copyright (c) 2004 K. Wilkins2//3// This software is provided 'as-is', without any express or implied warranty.4// In no event will the authors be held liable for any damages arising from5// the use of this software.6//7// Permission is granted to anyone to use this software for any purpose,8// including commercial applications, and to alter it and redistribute it9// freely, subject to the following restrictions:10//11// 1. The origin of this software must not be misrepresented; you must not12// claim that you wrote the original software. If you use this software13// in a product, an acknowledgment in the product documentation would be14// appreciated but is not required.15//16// 2. Altered source versions must be plainly marked as such, and must not17// be misrepresented as being the original software.18//19// 3. This notice may not be removed or altered from any source distribution.20//2122//////////////////////////////////////////////////////////////////////////////23// Handy - An Atari Lynx Emulator //24// Copyright (c) 1996,1997 //25// K. Wilkins //26//////////////////////////////////////////////////////////////////////////////27// Lynx cartridge class header file //28//////////////////////////////////////////////////////////////////////////////29// //30// This header file provides the interface definition and code for some of //31// the simpler cartridge API. //32// //33// K. Wilkins //34// August 1997 //35// //36//////////////////////////////////////////////////////////////////////////////37// Revision History: //38// ----------------- //39// //40// 01Aug1997 KW Document header added & class documented. //41// //42//////////////////////////////////////////////////////////////////////////////4344#ifndef CART_H45#define CART_H4647#define DEFAULT_CART_CONTENTS 0x114849enum CTYPE {UNUSED,C64K,C128K,C256K,C512K,C1024K};5051/*52#define CART_NO_ROTATE 053#define CART_ROTATE_LEFT 154#define CART_ROTATE_RIGHT 25556struct LYNX_HEADER57{58uint8 magic[4]; // "LYNX"59uint16 page_size_bank0;60uint16 page_size_bank1; // "BS93" for unsupported homebrews61uint16 version;62uint8 cartname[32];63uint8 manufname[16];64uint8 rotation;65uint8 spare[5];66};67*/6869class CCart : public CLynxBase70{71// Function members7273public:74CCart(const uint8 *gamedata, uint32 gamesize, int pagesize0, int pagesize1) MDFN_COLD;75~CCart() MDFN_COLD;7677public:7879// Access for sensible members of the clan80enum { HEADER_RAW_SIZE = 64 };8182//static bool TestMagic(const uint8 *data, uint32 size);8384void Reset(void) MDFN_COLD;85void Poke(uint32 addr,uint8 data);86uint8 Peek(uint32 addr);87uint32 ReadCycle(void) {return 15;};88uint32 WriteCycle(void) {return 15;};89void BankSelect(EMMODE newbank) {mBank=newbank;}90uint32 ObjectSize(void) {return (mBank==bank0)?mMaskBank0+1:mMaskBank1+1;};9192// Access for the lynx itself, it has no idea of address etc as this is done by the93// cartridge emulation hardware94void CartAddressStrobe(bool strobe);95void CartAddressData(bool data);96void Poke0(uint8 data);97void Poke1(uint8 data);98uint8 Peek0(void);99uint8 Peek1(void);100101// Data members102103public:104bool mWriteEnableBank0; // always false, as all carts have rom here105bool mWriteEnableBank1;106bool mCartRAM; // always true if there is no second rom segment; probably providing saveram in many cases107// when the original cart did not have it108109bool GetSaveRamPtr(int &size, uint8 *&data);110void GetReadOnlyPtrs(int &s0, uint8 *&p0, int &s1, uint8 *&p1);111112template<bool isReader>void SyncState(NewState *ns);113114private:115EMMODE mBank;116uint32 mMaskBank0;117uint32 mMaskBank1;118uint8 *mCartBank0;119uint8 *mCartBank1;120121uint32 mCounter;122uint32 mShifter;123uint32 mAddrData;124uint32 mStrobe;125126uint32 mShiftCount0;127uint32 mCountMask0;128uint32 mShiftCount1;129uint32 mCountMask1;130131int8 last_strobe;132};133134#endif135136137138