Revision c78f7137 hw/blizzard.c
b/hw/blizzard.c | ||
---|---|---|
69 | 69 |
uint8_t effect; |
70 | 70 |
uint8_t iformat; |
71 | 71 |
uint8_t source; |
72 |
DisplayState *state;
|
|
72 |
QemuConsole *con;
|
|
73 | 73 |
blizzard_fn_t *line_fn_tab[2]; |
74 | 74 |
void *fb; |
75 | 75 |
|
... | ... | |
144 | 144 |
|
145 | 145 |
static void blizzard_window(BlizzardState *s) |
146 | 146 |
{ |
147 |
DisplaySurface *surface = qemu_console_surface(s->con); |
|
147 | 148 |
uint8_t *src, *dst; |
148 | 149 |
int bypp[2]; |
149 | 150 |
int bypl[3]; |
... | ... | |
162 | 163 |
s->my[1] = s->data.y + s->data.dy; |
163 | 164 |
|
164 | 165 |
bypp[0] = s->bpp; |
165 |
bypp[1] = (ds_get_bits_per_pixel(s->state) + 7) >> 3;
|
|
166 |
bypp[1] = surface_bytes_per_pixel(surface);
|
|
166 | 167 |
bypl[0] = bypp[0] * s->data.pitch; |
167 | 168 |
bypl[1] = bypp[1] * s->x; |
168 | 169 |
bypl[2] = bypp[0] * s->data.dx; |
... | ... | |
883 | 884 |
static void blizzard_update_display(void *opaque) |
884 | 885 |
{ |
885 | 886 |
BlizzardState *s = (BlizzardState *) opaque; |
887 |
DisplaySurface *surface = qemu_console_surface(s->con); |
|
886 | 888 |
int y, bypp, bypl, bwidth; |
887 | 889 |
uint8_t *src, *dst; |
888 | 890 |
|
889 | 891 |
if (!s->enable) |
890 | 892 |
return; |
891 | 893 |
|
892 |
if (s->x != ds_get_width(s->state) || s->y != ds_get_height(s->state)) {
|
|
894 |
if (s->x != surface_width(surface) || s->y != surface_height(surface)) {
|
|
893 | 895 |
s->invalidate = 1; |
894 |
qemu_console_resize(s->state, s->x, s->y); |
|
896 |
qemu_console_resize(s->con, s->x, s->y); |
|
897 |
surface = qemu_console_surface(s->con); |
|
895 | 898 |
} |
896 | 899 |
|
897 | 900 |
if (s->invalidate) { |
898 | 901 |
s->invalidate = 0; |
899 | 902 |
|
900 | 903 |
if (s->blank) { |
901 |
bypp = (ds_get_bits_per_pixel(s->state) + 7) >> 3;
|
|
902 |
memset(ds_get_data(s->state), 0, bypp * s->x * s->y);
|
|
904 |
bypp = surface_bytes_per_pixel(surface);
|
|
905 |
memset(surface_data(surface), 0, bypp * s->x * s->y);
|
|
903 | 906 |
return; |
904 | 907 |
} |
905 | 908 |
|
... | ... | |
912 | 915 |
if (s->mx[1] <= s->mx[0]) |
913 | 916 |
return; |
914 | 917 |
|
915 |
bypp = (ds_get_bits_per_pixel(s->state) + 7) >> 3;
|
|
918 |
bypp = surface_bytes_per_pixel(surface);
|
|
916 | 919 |
bypl = bypp * s->x; |
917 | 920 |
bwidth = bypp * (s->mx[1] - s->mx[0]); |
918 | 921 |
y = s->my[0]; |
919 | 922 |
src = s->fb + bypl * y + bypp * s->mx[0]; |
920 |
dst = ds_get_data(s->state) + bypl * y + bypp * s->mx[0];
|
|
923 |
dst = surface_data(surface) + bypl * y + bypp * s->mx[0];
|
|
921 | 924 |
for (; y < s->my[1]; y ++, src += bypl, dst += bypl) |
922 | 925 |
memcpy(dst, src, bwidth); |
923 | 926 |
|
924 |
dpy_gfx_update(s->state, s->mx[0], s->my[0],
|
|
927 |
dpy_gfx_update(s->con, s->mx[0], s->my[0],
|
|
925 | 928 |
s->mx[1] - s->mx[0], y - s->my[0]); |
926 | 929 |
|
927 | 930 |
s->mx[0] = s->x; |
... | ... | |
934 | 937 |
bool cswitch, Error **errp) |
935 | 938 |
{ |
936 | 939 |
BlizzardState *s = (BlizzardState *) opaque; |
940 |
DisplaySurface *surface = qemu_console_surface(s->con); |
|
937 | 941 |
|
938 | 942 |
blizzard_update_display(opaque); |
939 |
if (s && ds_get_data(s->state)) |
|
940 |
ppm_save(filename, s->state->surface, errp); |
|
943 |
if (s && surface_data(surface)) { |
|
944 |
ppm_save(filename, surface, errp); |
|
945 |
} |
|
941 | 946 |
} |
942 | 947 |
|
943 | 948 |
#define DEPTH 8 |
... | ... | |
954 | 959 |
void *s1d13745_init(qemu_irq gpio_int) |
955 | 960 |
{ |
956 | 961 |
BlizzardState *s = (BlizzardState *) g_malloc0(sizeof(*s)); |
962 |
DisplaySurface *surface; |
|
957 | 963 |
|
958 | 964 |
s->fb = g_malloc(0x180000); |
959 | 965 |
|
960 |
s->state = graphic_console_init(blizzard_update_display, |
|
961 |
blizzard_invalidate_display, |
|
962 |
blizzard_screen_dump, NULL, s); |
|
966 |
s->con = graphic_console_init(blizzard_update_display, |
|
967 |
blizzard_invalidate_display, |
|
968 |
blizzard_screen_dump, NULL, s); |
|
969 |
surface = qemu_console_surface(s->con); |
|
963 | 970 |
|
964 |
switch (ds_get_bits_per_pixel(s->state)) {
|
|
971 |
switch (surface_bits_per_pixel(surface)) {
|
|
965 | 972 |
case 0: |
966 | 973 |
s->line_fn_tab[0] = s->line_fn_tab[1] = |
967 | 974 |
g_malloc0(sizeof(blizzard_fn_t) * 0x10); |
Also available in: Unified diff