aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/ps2/Gs2dScreen.h
blob: 1a70dad1706d10716b4c16058549813140ffb8ea (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
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * 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.

 * This program 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 this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#ifndef __GS2DSCREEN_H__
#define __GS2DSCREEN_H__

#include "sysdefs.h"
#include "backends/base-backend.h"

#include "backends/platform/ps2/DmaPipe.h"
#include "graphics/surface.h"

enum TVMode {
	TV_DONT_CARE = 0,
	TV_PAL,
	TV_NTSC
};

enum GsInterlace {
	GS_NON_INTERLACED = 0,
	GS_INTERLACED
};

class Gs2dScreen {
public:
	Gs2dScreen(uint16 width, uint16 height, TVMode mode);
	~Gs2dScreen(void);
	void newScreenSize(uint16 width, uint16 height);
	uint8 tvMode(void);
	uint16 getWidth(void);
	uint16 getHeight(void);

	void copyPrintfOverlay(const uint8* buf);
	void clearPrintfOverlay(void);

	Graphics::Surface *lockScreen();
	void unlockScreen();

	void copyScreenRect(const uint8 *buf, int pitch, int x, int y, int w, int h);
	void setPalette(const uint8 *pal, uint8 start, uint16 num);
	void updateScreen(void);
	void grabPalette(uint8 *pal, uint8 start, uint16 num);
	//- overlay routines
	void copyOverlayRect(const byte *buf, uint16 pitch, uint16 x, uint16 y, uint16 w, uint16 h);
	void grabOverlay(byte *buf, uint16 pitch);
	void clearOverlay(void);
	void showOverlay(void);
	void hideOverlay(void);
	Graphics::PixelFormat getOverlayFormat(void);
	int16 getOverlayWidth(void);
	int16 getOverlayHeight(void);

	//- mouse routines
	void setMouseOverlay(const uint8 *buf, uint16 width, uint16 height, uint16 hotSpotX, uint16 hotSpotY, uint8 transpCol);
	void showMouse(bool show);
	void setMouseXy(int16 x, int16 y);
	void setShakePos(int shake);

	void animThread(void);
	void wantAnim(bool runIt);

	void quit(void);

private:
	void uploadToVram(void);
	void createAnimTextures(void);

	DmaPipe *_dmaPipe;
	uint8 _tvMode;
	uint16 _tvWidth, _tvHeight;
	GsVertex _blitCoords[2];
	TexVertex _texCoords[2];

	uint8  _curDrawBuf;
	uint32 _frameBufPtr[2]; //
	uint32 _clutPtrs[3];    // vram pointers
	uint32 _texPtrs[4];     //

	Graphics::Surface _framebuffer;

	// TODO : check if we do need this
	struct VideoState {
		bool setup;

		bool fullscreen;
		bool aspectRatio;

		int mode;
		int scaleFactor;

		int screenWidth, screenHeight;
		int overlayWidth, overlayHeight;
	};

	VideoState _videoMode;

	uint16 _width, _height, _pitch;
	int16  _mouseX, _mouseY, _hotSpotX, _hotSpotY;
	uint32 _mouseScaleX, _mouseScaleY;
	uint8  _mTraCol;

	int _shakePos;

	bool _showMouse, _showOverlay, _screenChanged, _overlayChanged, _clutChanged;
	uint16 *_overlayBuf;
	uint8 *_screenBuf;
	uint32 *_clut;
	Graphics::PixelFormat _overlayFormat;

	int _screenSema;
	int _vblankStartId, _vblankEndId, _dmacId, _animTid;
	void *_animStack;
	volatile bool _systemQuit;

	static const uint32 _binaryClut[16];
	static const uint8  _binaryData[4 * 14 * 2];
	static const uint16 _binaryPattern[16];
};

#endif // __GS2DSCREEN_H__