aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/PalmOS/Src/init_stuffs.cpp
blob: 51bfe755eb5ad54fc80c08b886e75df88a5d3fd8 (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
#include <PalmOS.h>

#ifndef DISABLE_SONY
#include <SonyClie.h>
#endif

#include <PalmNavigator.h>
#include <HsExtCommon.h>
#include <HsNavCommon.h>
#include <PalmGoLCD.h>

#include "globals.h"		// for OPTIONS_DEF()
#include "init_stuffs.h"
#include "stuffs.h"

#ifndef DISABLE_TAPWAVE
#define __TWKEYS_H__	// bad hack
#include "tapwave.h"
#endif

#ifndef DISABLE_PA1LIB
#include "Pa1Lib.h"
#endif

#ifndef DISABLE_LIGHTSPEED
#include "lightspeed_public.h"
#endif

// TODO : check the depth to set correct value
// works only for 8bit for now
UInt32 StuffsGetPitch(Coord fullw) {
	UInt32 pitch = 0;

	if (OPTIONS_TST(kOptModeHiDensity)) {
		WinScreenGetAttribute(winScreenRowBytes, &pitch);

		// FIXME : hack for TT3 simulator (and real ?) return 28 on landscape mode
		if (pitch < fullw)
			pitch = fullw;

	} else {
		pitch = fullw;
	}

	return pitch;
}

void *StuffsForceVG() {
	// create an empty form to force the VG to be shown
	FormType *frmP = FrmNewForm(4567, NULL, 0,0,0,0, false, 0, 0, 0);
	FrmDrawForm(frmP);
	return frmP;
}

void StuffsReleaseVG(void *vg) {
	FrmDeleteForm((FormPtr)vg);
}

void StuffsGetFeatures() {
	UInt32 ulProcessorType, manufacturer, version, depth;
	Boolean color;

#ifndef DISABLE_TAPWAVE
	// Tapwave Zodiac libs ?
	if (!FtrGet(sysFileCSystem, sysFtrNumOEMCompanyID, &manufacturer))
		if (manufacturer == twCreatorID) {
			OPTIONS_SET(kOptDeviceZodiac);
			OPTIONS_SET(kOpt5WayNavigatorV2);
		}
#endif

	// Hi-Density present ?
	if (!FtrGet(sysFtrCreator, sysFtrNumWinVersion, &version))
		if (version >= 4)
			OPTIONS_SET(kOptModeHiDensity);

	// OS5 ?
	if (!FtrGet(sysFtrCreator, sysFtrNumROMVersion, &version))
		if (version >= kOS5Version)
			OPTIONS_SET(kOptDeviceOS5);

	// ARM ?
	if (!FtrGet(sysFileCSystem, sysFtrNumProcessorID, &ulProcessorType))
		if (sysFtrNumProcessorIsARM(ulProcessorType))
			OPTIONS_SET(kOptDeviceARM);
		else if (ulProcessorType == sysFtrNumProcessorx86)
			OPTIONS_SET(kOptDeviceProcX86);

	// 5Way Navigator
	if (!FtrGet(hsFtrCreator, hsFtrIDNavigationSupported, &version)) {
		if (version >= 2)
			OPTIONS_SET(kOpt5WayNavigatorV2);

	} else if (!FtrGet(sysFtrCreator, sysFtrNumFiveWayNavVersion, &version)) {
		if (version >= 2)
			OPTIONS_SET(kOpt5WayNavigatorV2);
		else
			OPTIONS_SET(kOpt5WayNavigatorV1);

	} else if (!FtrGet(navFtrCreator, navFtrVersion, &version)) {
		if (version >= 2)
			OPTIONS_SET(kOpt5WayNavigatorV2);
		else
			OPTIONS_SET(kOpt5WayNavigatorV1);
	}

	// Palm Sound API ?
	if (!FtrGet(sysFileCSoundMgr, sndFtrIDVersion, &version))
		if (version >= 1)
			OPTIONS_SET(kOptPalmSoundAPI);

#ifndef DISABLE_PA1LIB
	// Sony Pa1 Sound API
	if (Pa1Lib_Open()) {
		OPTIONS_SET(kOptSonyPa1LibAPI);
		Pa1Lib_Close();
	}
#endif

	// GoLCD
	if (!FtrGet(goLcdLibCreator, goLcdLibFtrNum, &version))
		OPTIONS_SET(kOptGoLcdAPI);

#ifndef DISABLE_LIGHTSPEED
	// Lightspeed
	if (LS_Installed())
		OPTIONS_SET(kOptLightspeedAPI);
#endif

	// check for 16bit mode
	if (!WinScreenMode(winScreenModeGetSupportedDepths, NULL, NULL, &depth, &color))
		OPTIONS_SET(((depth & 0x8000) ? kOptMode16Bit : kOptNone));

}