-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwinCpctelera.h
133 lines (107 loc) · 3.5 KB
/
winCpctelera.h
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
//-----------------------------LICENSE NOTICE------------------------------------
// This file is part of CPCtelera: An Amstrad CPC Game Engine
// Copyright (C) 2016 Arnaud Bouche
// Copyright (C) 2016 ronaldo / Fremos / Cheesetea / ByteRealms (@FranGallegoBR)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//-------------------------------------------------------------------------------
#include <cpctelera.h>
#define CPCTELERA_VER 1.5.0
#define _USEWINGDI 1
//#define _USESDL 1
#ifdef _USESDL
#include <SDL.h>
#endif
#include <windows.h>
#define NB_COLORS 16
#define BORDER_COLOR 16
#define COEF 2
#define BORDER_CX (32*COEF)
#define BORDER_UP_CY (41*COEF)
#define BORDER_DW_CY (29*COEF)
#define WIDTH_SCREEN (320*COEF)
#define HEIGHT_SCREEN (200*COEF)
#define FULL_SCREEN_CX (BORDER_CX + WIDTH_SCREEN + BORDER_CX) // 384 * 2
#define FULL_SCREEN_CY (BORDER_UP_CY + HEIGHT_SCREEN + BORDER_DW_CY) // 270*2
#define CPC_NB_BANKS 8
#define CPC_BANK_SIZE 0x4000
#define CPC_MEM_SIZE 0x10000
#define INTERRUPT_PER_VBL 6 // 6 interruptions per refresh screen
#define REFRESH_MS (1000/50) // 50 hz
#define INTERRUPT_MS (REFRESH_MS/INTERRUPT_PER_VBL) // 3ms
#define CPC_SCR_CX_BYTES 80
#define CPC_SCR_CY_LINE 200
#define CPC_INTERRUPT_LINE (CPC_SCR_CY_LINE/INTERRUPT_PER_VBL)
#define wincpct_getCurrentVideoMode() gAmstrad._curVideoConf._videoMode
enum
{
MODE_0,
MODE_1,
MODE_2
};
enum
{
SPRITE_NORMAL,
SPRITE_MASKED,
SPRITE_ALIGNEDTABLE,
SPRITE_ZIGZAG,
SPRITE_FLIP_V
};
typedef void(*TInterrupt)(void);
typedef void(*TLoader)(void);
typedef struct tagVideoConf
{
u8 _videoMode;
u8 gCpcPalette[NB_COLORS + 1];
} SVideoConf;
typedef struct tagSAmstrad
{
u8 _currentBank;
u8 _currentPage;
u8 _internalTimer;
TInterrupt _interruptFunction;
SVideoConf _curVideoConf;
u8 _memOffset;
u8 _memCPC[CPC_MEM_SIZE];
u8 _bankCPC[CPC_NB_BANKS][CPC_BANK_SIZE];
} SAmstrad;
typedef struct tagSCPCPalette
{
u8 fw;
u8 hw;
COLORREF rgb;
} SCPCPalette;
extern SCPCPalette gCpcPalette[];
extern BOOL gCurKey;
extern SAmstrad gAmstrad;
/* wincpctelera */
void wincpct_CPCTeleraWin();
void wincpct_msgLoop();
void wincpct_setInterruptFunction(void(*intHandler)(void));
void wincpct_startInterrupt();
u8 wincpct_getAsyncJoyState(u16 vKey);
void wincpct_wait(int ms);
void wincpct_waitVSync();
void wincpct_waitEndInterrupt();
void wincpct_createPaletteCpc();
/* cpct_sprite */
u8 wincpct_convPixSpriteCPCtoPC(u8 pix);
void wincpct_drawSprite(void *sprite, void *memory, int cx, int cy, u8 pSpriteMode);
/* cpct_memutils */
BOOL wincpct_isCpcMem(const u8* pAddress);
u8* wincpct_getMemory(const u8* ptr);
/* cpct_video */
void wincpct_applyLSBOffset(u8* buffVideo);
DWORD wincpct_getVideoArea(uintptr_t pScreenAddr);
uintptr_t wincpct_getPageAddress(int pPage);