Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/lynx/cart.h
2 views
1
//
2
// Copyright (c) 2004 K. Wilkins
3
//
4
// This software is provided 'as-is', without any express or implied warranty.
5
// In no event will the authors be held liable for any damages arising from
6
// the use of this software.
7
//
8
// Permission is granted to anyone to use this software for any purpose,
9
// including commercial applications, and to alter it and redistribute it
10
// freely, subject to the following restrictions:
11
//
12
// 1. The origin of this software must not be misrepresented; you must not
13
// claim that you wrote the original software. If you use this software
14
// in a product, an acknowledgment in the product documentation would be
15
// appreciated but is not required.
16
//
17
// 2. Altered source versions must be plainly marked as such, and must not
18
// be misrepresented as being the original software.
19
//
20
// 3. This notice may not be removed or altered from any source distribution.
21
//
22
23
//////////////////////////////////////////////////////////////////////////////
24
// Handy - An Atari Lynx Emulator //
25
// Copyright (c) 1996,1997 //
26
// K. Wilkins //
27
//////////////////////////////////////////////////////////////////////////////
28
// Lynx cartridge class header file //
29
//////////////////////////////////////////////////////////////////////////////
30
// //
31
// This header file provides the interface definition and code for some of //
32
// the simpler cartridge API. //
33
// //
34
// K. Wilkins //
35
// August 1997 //
36
// //
37
//////////////////////////////////////////////////////////////////////////////
38
// Revision History: //
39
// ----------------- //
40
// //
41
// 01Aug1997 KW Document header added & class documented. //
42
// //
43
//////////////////////////////////////////////////////////////////////////////
44
45
#ifndef CART_H
46
#define CART_H
47
48
#define DEFAULT_CART_CONTENTS 0x11
49
50
enum CTYPE {UNUSED,C64K,C128K,C256K,C512K,C1024K};
51
52
/*
53
#define CART_NO_ROTATE 0
54
#define CART_ROTATE_LEFT 1
55
#define CART_ROTATE_RIGHT 2
56
57
struct LYNX_HEADER
58
{
59
uint8 magic[4]; // "LYNX"
60
uint16 page_size_bank0;
61
uint16 page_size_bank1; // "BS93" for unsupported homebrews
62
uint16 version;
63
uint8 cartname[32];
64
uint8 manufname[16];
65
uint8 rotation;
66
uint8 spare[5];
67
};
68
*/
69
70
class CCart : public CLynxBase
71
{
72
// Function members
73
74
public:
75
CCart(const uint8 *gamedata, uint32 gamesize, int pagesize0, int pagesize1) MDFN_COLD;
76
~CCart() MDFN_COLD;
77
78
public:
79
80
// Access for sensible members of the clan
81
enum { HEADER_RAW_SIZE = 64 };
82
83
//static bool TestMagic(const uint8 *data, uint32 size);
84
85
void Reset(void) MDFN_COLD;
86
void Poke(uint32 addr,uint8 data);
87
uint8 Peek(uint32 addr);
88
uint32 ReadCycle(void) {return 15;};
89
uint32 WriteCycle(void) {return 15;};
90
void BankSelect(EMMODE newbank) {mBank=newbank;}
91
uint32 ObjectSize(void) {return (mBank==bank0)?mMaskBank0+1:mMaskBank1+1;};
92
93
// Access for the lynx itself, it has no idea of address etc as this is done by the
94
// cartridge emulation hardware
95
void CartAddressStrobe(bool strobe);
96
void CartAddressData(bool data);
97
void Poke0(uint8 data);
98
void Poke1(uint8 data);
99
uint8 Peek0(void);
100
uint8 Peek1(void);
101
102
// Data members
103
104
public:
105
bool mWriteEnableBank0; // always false, as all carts have rom here
106
bool mWriteEnableBank1;
107
bool mCartRAM; // always true if there is no second rom segment; probably providing saveram in many cases
108
// when the original cart did not have it
109
110
bool GetSaveRamPtr(int &size, uint8 *&data);
111
void GetReadOnlyPtrs(int &s0, uint8 *&p0, int &s1, uint8 *&p1);
112
113
template<bool isReader>void SyncState(NewState *ns);
114
115
private:
116
EMMODE mBank;
117
uint32 mMaskBank0;
118
uint32 mMaskBank1;
119
uint8 *mCartBank0;
120
uint8 *mCartBank1;
121
122
uint32 mCounter;
123
uint32 mShifter;
124
uint32 mAddrData;
125
uint32 mStrobe;
126
127
uint32 mShiftCount0;
128
uint32 mCountMask0;
129
uint32 mShiftCount1;
130
uint32 mCountMask1;
131
132
int8 last_strobe;
133
};
134
135
#endif
136
137
138