25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: dev_fb.c,v 1.90 2005/03/29 09:46:06 debug Exp $ |
* $Id: dev_fb.c,v 1.94 2005/05/23 14:22:02 debug Exp $ |
29 |
* |
* |
30 |
* Generic framebuffer device. |
* Generic framebuffer device. |
31 |
* |
* |
65 |
#endif |
#endif |
66 |
|
|
67 |
|
|
68 |
#define FB_TICK_SHIFT 18 |
#define FB_TICK_SHIFT 17 |
69 |
|
|
70 |
#define LOGO_XSIZE 256 |
#define LOGO_XSIZE 256 |
71 |
#define LOGO_YSIZE 256 |
#define LOGO_YSIZE 256 |
115 |
|
|
116 |
|
|
117 |
/* |
/* |
118 |
|
* dev_fb_resize(): |
119 |
|
* |
120 |
|
* Resize a framebuffer window. (This functionality is probably a bit buggy, |
121 |
|
* because I didn't think of including it from the start.) |
122 |
|
*/ |
123 |
|
void dev_fb_resize(struct vfb_data *d, int new_xsize, int new_ysize) |
124 |
|
{ |
125 |
|
unsigned char *new_framebuffer; |
126 |
|
int y, new_bytes_per_line; |
127 |
|
size_t size; |
128 |
|
|
129 |
|
if (d == NULL) { |
130 |
|
fatal("dev_fb_resize(): d == NULL\n"); |
131 |
|
return; |
132 |
|
} |
133 |
|
|
134 |
|
new_bytes_per_line = new_xsize * d->bit_depth / 8; |
135 |
|
size = new_ysize * new_bytes_per_line; |
136 |
|
|
137 |
|
new_framebuffer = malloc(size); |
138 |
|
if (new_framebuffer == NULL) { |
139 |
|
fprintf(stderr, "dev_fb_resize(): out of memory\n"); |
140 |
|
exit(1); |
141 |
|
} |
142 |
|
|
143 |
|
/* Copy the old framebuffer to the new: */ |
144 |
|
if (d->framebuffer != NULL) { |
145 |
|
for (y=0; y<new_ysize; y++) { |
146 |
|
size_t fromofs = d->bytes_per_line * y; |
147 |
|
size_t toofs = new_bytes_per_line * y; |
148 |
|
size_t len_to_copy = d->bytes_per_line < |
149 |
|
new_bytes_per_line? d->bytes_per_line |
150 |
|
: new_bytes_per_line; |
151 |
|
memset(new_framebuffer + toofs, 0, new_bytes_per_line); |
152 |
|
if (y < d->x11_ysize) |
153 |
|
memmove(new_framebuffer + toofs, |
154 |
|
d->framebuffer + fromofs, len_to_copy); |
155 |
|
} |
156 |
|
|
157 |
|
free(d->framebuffer); |
158 |
|
} |
159 |
|
|
160 |
|
d->framebuffer = new_framebuffer; |
161 |
|
d->framebuffer_size = size; |
162 |
|
|
163 |
|
if (new_xsize > d->x11_xsize || new_ysize > d->x11_ysize) { |
164 |
|
d->update_x1 = d->update_y1 = 0; |
165 |
|
d->update_x2 = new_xsize - 1; |
166 |
|
d->update_y2 = new_ysize - 1; |
167 |
|
} |
168 |
|
|
169 |
|
d->bytes_per_line = new_bytes_per_line; |
170 |
|
d->x11_xsize = d->visible_xsize = new_xsize; |
171 |
|
d->x11_ysize = d->visible_ysize = new_ysize; |
172 |
|
|
173 |
|
#ifdef WITH_X11 |
174 |
|
if (d->fb_window != NULL) |
175 |
|
x11_fb_resize(d->fb_window, new_xsize, new_ysize); |
176 |
|
#endif |
177 |
|
} |
178 |
|
|
179 |
|
|
180 |
|
/* |
181 |
* dev_fb_setcursor(): |
* dev_fb_setcursor(): |
182 |
*/ |
*/ |
183 |
void dev_fb_setcursor(struct vfb_data *d, int cursor_x, int cursor_y, int on, |
void dev_fb_setcursor(struct vfb_data *d, int cursor_x, int cursor_y, int on, |
813 |
} |
} |
814 |
#endif |
#endif |
815 |
|
|
816 |
|
if (relative_addr >= d->framebuffer_size) |
817 |
|
return 0; |
818 |
|
|
819 |
/* See if a write actually modifies the framebuffer contents: */ |
/* See if a write actually modifies the framebuffer contents: */ |
820 |
if (writeflag == MEM_WRITE) { |
if (writeflag == MEM_WRITE) { |
821 |
for (i=0; i<len; i++) { |
for (i=0; i<len; i++) { |
1011 |
} |
} |
1012 |
} |
} |
1013 |
|
|
1014 |
snprintf(title, sizeof(title), "GXemul: %ix%ix%i %s framebuffer", |
/* Don't set the title to include the size of the framebuffer for |
1015 |
d->visible_xsize, d->visible_ysize, d->bit_depth, name); |
VGA, since then the resolution might change during runtime. */ |
1016 |
|
if (strcmp(name, "VGA") == 0) |
1017 |
|
snprintf(title, sizeof(title),"GXemul: %s framebuffer", name); |
1018 |
|
else |
1019 |
|
snprintf(title, sizeof(title),"GXemul: %ix%ix%i %s framebuffer", |
1020 |
|
d->visible_xsize, d->visible_ysize, d->bit_depth, name); |
1021 |
title[sizeof(title)-1] = '\0'; |
title[sizeof(title)-1] = '\0'; |
1022 |
|
|
1023 |
#ifdef WITH_X11 |
#ifdef WITH_X11 |
1039 |
if ((baseaddr & 0xfff) == 0) |
if ((baseaddr & 0xfff) == 0) |
1040 |
flags = MEM_BINTRANS_OK | MEM_BINTRANS_WRITE_OK; |
flags = MEM_BINTRANS_OK | MEM_BINTRANS_WRITE_OK; |
1041 |
|
|
1042 |
|
flags |= MEM_READING_HAS_NO_SIDE_EFFECTS; |
1043 |
|
|
1044 |
memory_device_register(mem, name2, baseaddr, size, dev_fb_access, |
memory_device_register(mem, name2, baseaddr, size, dev_fb_access, |
1045 |
d, flags, d->framebuffer); |
d, flags, d->framebuffer); |
1046 |
|
|