~vcs-imports/qemu/maemo

« back to all changes in this revision

Viewing changes to hw/blizzard.c

  • Committer: Juha Riihimäki
  • Date: 2009-05-12 11:14:12 UTC
  • Revision ID: git-v1:d1a9a1dc0d9d900439de022d5f916ca3c049c4b7
blizzard: fix for non-32bpp host display

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
    uint8_t iformat;
73
73
    uint8_t source;
74
74
    DisplayState *state;
75
 
    blizzard_fn_t *line_fn_tab[2];
76
75
    void *fb;
77
76
 
78
77
    uint8_t hssi_config[3];
118
117
        uint16_t *ptr;
119
118
        int angle;
120
119
        int pitch;
121
 
        blizzard_fn_t line_fn;
122
120
    } data;
123
121
};
124
122
 
136
134
    0, 0, 0, 0, 0, 0,
137
135
};
138
136
 
 
137
#define DEPTH 8
 
138
#include "blizzard_template.h"
 
139
#define DEPTH 15
 
140
#include "blizzard_template.h"
 
141
#define DEPTH 16
 
142
#include "blizzard_template.h"
 
143
#define DEPTH 24
 
144
#include "blizzard_template.h"
 
145
#define DEPTH 32
 
146
#include "blizzard_template.h"
 
147
 
139
148
static inline void blizzard_rgb2yuv(int r, int g, int b,
140
149
                int *y, int *u, int *v)
141
150
{
150
159
    int bypp[2];
151
160
    int bypl[3];
152
161
    int y;
153
 
    blizzard_fn_t fn = s->data.line_fn;
 
162
    blizzard_fn_t fn = 0;
154
163
 
 
164
    /* FIXME: this is a hack - but nseries.c will use this function
 
165
     * before correct DisplayState is initialized so we need a way to
 
166
     * avoid drawing something when we actually have no clue about host bpp */
 
167
        if (!s->state->listeners)
 
168
                return;
 
169
                
 
170
    switch (ds_get_bits_per_pixel(s->state)) {
 
171
        case 8:
 
172
            fn = s->data.angle
 
173
                ? blizzard_draw_fn_r_8[s->iformat]
 
174
                : blizzard_draw_fn_8[s->iformat];
 
175
            break;
 
176
        case 15:
 
177
            fn = s->data.angle
 
178
                ? blizzard_draw_fn_r_15[s->iformat]
 
179
                : blizzard_draw_fn_15[s->iformat];
 
180
            break;
 
181
        case 16:
 
182
            fn = s->data.angle
 
183
                ? blizzard_draw_fn_r_16[s->iformat]
 
184
                : blizzard_draw_fn_16[s->iformat];
 
185
            break;
 
186
        case 24:
 
187
            fn = s->data.angle
 
188
                ? blizzard_draw_fn_r_24[s->iformat]
 
189
                : blizzard_draw_fn_24[s->iformat];
 
190
            break;
 
191
        case 32:
 
192
            fn = s->data.angle
 
193
                ? blizzard_draw_fn_r_32[s->iformat]
 
194
                : blizzard_draw_fn_32[s->iformat];
 
195
            break;
 
196
        default:
 
197
                break;
 
198
    }
155
199
    if (!fn)
156
200
        return;
157
201
    if (s->mx[0] > s->data.x)
182
226
        return 0;
183
227
 
184
228
    s->data.angle = s->effect & 3;
185
 
    s->data.line_fn = s->line_fn_tab[!!s->data.angle][s->iformat];
186
229
    s->data.x = s->ix[0];
187
230
    s->data.y = s->iy[0];
188
231
    s->data.dx = s->ix[1] - s->ix[0] + 1;
942
985
        ppm_save(filename, s->state->surface);
943
986
}
944
987
 
945
 
#define DEPTH 8
946
 
#include "blizzard_template.h"
947
 
#define DEPTH 15
948
 
#include "blizzard_template.h"
949
 
#define DEPTH 16
950
 
#include "blizzard_template.h"
951
 
#define DEPTH 24
952
 
#include "blizzard_template.h"
953
 
#define DEPTH 32
954
 
#include "blizzard_template.h"
955
 
 
956
988
void *s1d13745_init(qemu_irq gpio_int)
957
989
{
958
990
    struct blizzard_s *s = (struct blizzard_s *) qemu_mallocz(sizeof(*s));
959
991
 
960
992
    s->fb = qemu_malloc(0x180000);
961
 
 
 
993
    /* Fill the framebuffer with white color here because the corresponding
 
994
     * code in nseries.c is broken since the DisplayState change in QEMU.
 
995
     * This is supposedly ok since nseries.c is the only user of blizzard.c */
 
996
    memset(s->fb, 0xff, 0x180000);
 
997
    
962
998
    s->state = graphic_console_init(blizzard_update_display,
963
999
                                 blizzard_invalidate_display,
964
1000
                                 blizzard_screen_dump, NULL, s);
965
 
 
966
 
    switch (ds_get_bits_per_pixel(s->state)) {
967
 
    case 0:
968
 
        s->line_fn_tab[0] = s->line_fn_tab[1] =
969
 
                qemu_mallocz(sizeof(blizzard_fn_t) * 0x10);
970
 
        break;
971
 
    case 8:
972
 
        s->line_fn_tab[0] = blizzard_draw_fn_8;
973
 
        s->line_fn_tab[1] = blizzard_draw_fn_r_8;
974
 
        break;
975
 
    case 15:
976
 
        s->line_fn_tab[0] = blizzard_draw_fn_15;
977
 
        s->line_fn_tab[1] = blizzard_draw_fn_r_15;
978
 
        break;
979
 
    case 16:
980
 
        s->line_fn_tab[0] = blizzard_draw_fn_16;
981
 
        s->line_fn_tab[1] = blizzard_draw_fn_r_16;
982
 
        break;
983
 
    case 24:
984
 
        s->line_fn_tab[0] = blizzard_draw_fn_24;
985
 
        s->line_fn_tab[1] = blizzard_draw_fn_r_24;
986
 
        break;
987
 
    case 32:
988
 
        s->line_fn_tab[0] = blizzard_draw_fn_32;
989
 
        s->line_fn_tab[1] = blizzard_draw_fn_r_32;
990
 
        break;
991
 
    default:
992
 
        fprintf(stderr, "%s: Bad color depth\n", __FUNCTION__);
993
 
        exit(1);
994
 
    }
995
 
 
996
1001
    blizzard_reset(s);
997
 
 
998
1002
    return s;
999
1003
}