aboutsummaryrefslogtreecommitdiff
path: root/SrcShared/Hardware/EmRegsVZ.h
blob: 42ad3604896290cabdc88f1eada5ef1c0f1995ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/* -*- mode: C++; tab-width: 4 -*- */
/* ===================================================================== *\
	Copyright (c) 2000-2001 Palm, Inc. or its subsidiaries.
	All rights reserved.

	This file is part of the Palm OS Emulator.

	This program 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.
\* ===================================================================== */

#ifndef EmRegsVZ_h
#define EmRegsVZ_h

#include "EmHAL.h"				// EmHALHandler
#include "EmRegs.h"				// EmRegs
#include "EmStructs.h"			// RGBList
#include "EmUARTDragonball.h"	// EmUARTDragonball::State

class EmScreenUpdateInfo;
class EmSPISlave;


class EmRegsVZ : public EmRegs, public EmHALHandler
{
	public:
								EmRegsVZ				(void);
		virtual					~EmRegsVZ				(void);

		// EmRegs overrides
		virtual void			Initialize				(void);
		virtual void			Reset					(Bool hardwareReset);
		virtual void			Save					(SessionFile&);
		virtual void			Load					(SessionFile&);
		virtual void			Dispose					(void);

		virtual void			SetSubBankHandlers		(void);
		virtual uint8*			GetRealAddress			(emuptr address);
		virtual emuptr			GetAddressStart			(void);
		virtual uint32			GetAddressRange			(void);

		// EmHALHandler overrides
		virtual void			Cycle					(Bool sleeping);
		virtual void			CycleSlowly				(Bool sleeping);

		virtual void			ButtonEvent				(SkinElementType, Bool buttonIsDown);
		virtual void			TurnSoundOff			(void);
		virtual void			ResetTimer				(void);
		virtual void			ResetRTC				(void);

		virtual int32			GetInterruptLevel		(void);
		virtual int32			GetInterruptBase		(void);

		virtual Bool			GetLCDScreenOn			(void) = 0;
		virtual Bool			GetLCDBacklightOn		(void) = 0;
		virtual Bool			GetLCDHasFrame			(void);
		virtual void			GetLCDBeginEnd			(emuptr&, emuptr&);
		virtual void			GetLCDScanlines			(EmScreenUpdateInfo& info);

		virtual int32			GetDynamicHeapSize		(void);
		virtual int32			GetROMSize				(void);
		virtual emuptr			GetROMBaseAddress		(void);
		virtual Bool			ChipSelectsConfigured	(void);
		virtual int32			GetSystemClockFrequency	(void);
		virtual Bool			GetCanStop				(void);
		virtual Bool			GetAsleep				(void);

		virtual uint8			GetPortInputValue		(int);
		virtual uint8			GetPortInternalValue	(int);
		virtual void			PortDataChanged			(int, uint8, uint8);
		virtual void			GetKeyInfo				(int* numRows, int* numCols,
														 uint16* keyMap, Bool* rows) = 0;

	private:
		uint32					pllFreqSelRead			(emuptr address, int size);
		uint32					portXDataRead			(emuptr address, int size);
		uint32					tmr1StatusRead			(emuptr address, int size);
		uint32					tmr2StatusRead			(emuptr address, int size);
		uint32					uart1Read				(emuptr address, int size);
		uint32					uart2Read				(emuptr address, int size);
		uint32					rtcHourMinSecRead		(emuptr address, int size);

		void					csControl1Write			(emuptr address, int size, uint32 value);
		void					csASelectWrite			(emuptr address, int size, uint32 value);
		void					csDSelectWrite			(emuptr address, int size, uint32 value);
		void					intMaskHiWrite			(emuptr address, int size, uint32 value);
		void					intMaskLoWrite			(emuptr address, int size, uint32 value);
		void					intStatusHiWrite		(emuptr address, int size, uint32 value);
		void					portXDataWrite			(emuptr address, int size, uint32 value);
		void					portDIntReqEnWrite		(emuptr address, int size, uint32 value);
		void					tmr1StatusWrite			(emuptr address, int size, uint32 value);
		void					tmr2StatusWrite			(emuptr address, int size, uint32 value);
		void					spiCont1Write			(emuptr address, int size, uint32 value);
		void					spiMasterControlWrite	(emuptr address, int size, uint32 value);
		void					uart1Write				(emuptr address, int size, uint32 value);
		void					uart2Write				(emuptr address, int size, uint32 value);
		void					lcdRegisterWrite		(emuptr address, int size, uint32 value);
		void					rtcControlWrite			(emuptr address, int size, uint32 value);
		void					rtcIntStatusWrite		(emuptr address, int size, uint32 value);
		void					rtcIntEnableWrite		(emuptr address, int size, uint32 value);

	protected:
		void					HotSyncEvent			(Bool buttonIsDown);

		virtual uint8			GetKeyBits				(void);
		virtual uint16			ButtonToBits			(SkinElementType);
		virtual EmSPISlave*		GetSPISlave				(void);

	protected:
		void					UpdateInterrupts		(void);
		void					UpdatePortDInterrupts	(void);
		void					UpdateRTCInterrupts		(void);

	protected:
		void					UARTStateChanged		(Bool sendTxData, int uartNum);
		void					UpdateUARTState			(Bool refreshRxData, int uartNum);
		void					UpdateUARTInterrupts	(const EmUARTDragonball::State& state, int uartNum);
		void					MarshalUARTState		(EmUARTDragonball::State& state, int uartNum);
		void					UnmarshalUARTState		(const EmUARTDragonball::State& state, int uartNum);

	protected:
		int						GetPort					(emuptr address);
		void					PrvGetPalette			(RGBList& thePalette);

	protected:
		HwrM68VZ328Type			f68VZ328Regs;
		bool					fHotSyncButtonDown;
		uint16					fKeyBits;
		uint16					fLastTmr1Status;
		uint16					fLastTmr2Status;
		uint8					fPortDEdge;
		uint32					fPortDDataCount;

		uint32					fHour;
		uint32					fMin;
		uint32					fSec;
		uint32					fTick;
		uint32					fCycle;

		EmUARTDragonball*		fUART[2];
};

#endif	/* EmRegsVZ_h */