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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
/*****************************************************************************
Copyright (c) 2025 Jaroslav Hensl <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*****************************************************************************/
/*
Memory layout
+-----------------------------+ <-- WRAM top
| Palette (256 * 4) |
|-----------------------------| <-- 1024 (P=0)
| Gamma table (256 * 3) |
|-----------------------------| <-- 1792 (P=0)
| Registry (64*4) |
|-----------------------------| <-- 2048 (P=0)
| Pad (2048) |
|-----------------------------| <-- 4096 (P=0)
| Cursor |
| AND (32 x 32 x 4) | <-- 8192 (P=1)
| XOR (32 x 32 x 4) | <-- 12288 (P=2)
|-----------------------------| <-- FB top (0x3000)
| Frame buffer 0 |
| |
| |
| |
|-----------------------------|
| Another framebuffer / |
| textures |
| |
| |
|-----------------------------|
| .... |
|-----------------------------| <-- SYSTEM max
| Alternate screen 1-8 (opt) |
| |
| |
+-----------------------------+ <-- WRAM max
*/
#ifndef __WRAM_H__INCLUDED__
#define __WRAM_H__INCLUDED__
#pragma pack(push)
#pragma pack(1)
typedef union _flat_t
{
DWORD dw;
void *ptr;
BYTE *u8;
} flat_t;
typedef union _pixel_32_t
{
DWORD dw;
BYTE b[4];
struct
{
BYTE b;
BYTE g;
BYTE r;
BYTE x;
} c;
} pixel_32_t;
typedef DWORD pixel_16_t;
typedef BYTE pixel_8_t;
typedef union _bitmap_ptr_t
{
pixel_32_t *px32;
pixel_16_t *px16;
pixel_8_t *px8;
flat_t flat;
} bitmap_ptr_t;
#define CURSOR_DMAX 32
#define CURSOR_CB (CURSOR_DMAX*CURSOR_DMAX*sizeof(DWORD))
#define WRAM_FB_TOP 0x3000
#define MODE_32 0
#define MODE_24 1
#define MODE_16 2
#define MODE_15 3
#define MODE_8 4
typedef struct _wram_t
{
pixel_32_t palette[256];
struct
{
BYTE red[256];
BYTE green[256];
BYTE blue[256];
} gamma;
union
{
DWORD dw[64];
struct
{
DWORD fbstart; /* byte offset from WRAM top */
DWORD size; /* size of entire memory */
DWORD width;
DWORD height;
DWORD mode;
DWORD pitch;
DWORD cursor_visible;
DWORD cursor_empty;
LONG cursor_x;
LONG cursor_y;
LONG cursor_w;
LONG cursor_h;
LONG cursor_spotx;
LONG cursor_spoty;
DWORD gamma_enable;
DWORD fbmin;
DWORD fbmax;
} s;
} regs;
BYTE extradata[2048]; // current used for fbhda
struct
{
DWORD andmask[CURSOR_DMAX*CURSOR_DMAX];
DWORD xormask[CURSOR_DMAX*CURSOR_DMAX];
} cursor;
} wram_t;
#define BLIT_MAX_BUFS 3
typedef struct _blit_t
{
flat_t base;
bitmap_ptr_t dst[BLIT_MAX_BUFS];
DWORD dst_mode;
DWORD dst_w;
DWORD dst_h;
DWORD dst_padx;
DWORD dst_pady;
DWORD dst_pitch;
DWORD dst_scans;
DWORD src_sx;
DWORD src_ex;
DWORD src_sy;
DWORD src_ey;
DWORD num_changes;
} blit_t;
#pragma pack(pop)
extern wram_t *wram;
BOOL wram_init(DWORD bytes);
void wram_blit(blit_t *blit);
void wram_clear_target(blit_t *blit);
void wram_clear();
BOOL wram_swap(void *virtptr, blit_t *blit);
void wram_changes(blit_t *blit, DWORD sx, DWORD sy, DWORD ex, DWORD ey);
#define WRAM_MIN_MB 4
#endif /* __WRAM_H__INCLUDED__ */
|