* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "qemu-common.h"
typedef void (*blizzard_fn_t)(uint8_t *, const uint8_t *, unsigned int);
-struct blizzard_s {
+typedef struct {
uint8_t reg;
uint32_t addr;
int swallow;
uint8_t iformat;
uint8_t source;
DisplayState *state;
- QEMUConsole *console;
blizzard_fn_t *line_fn_tab[2];
void *fb;
int pitch;
blizzard_fn_t line_fn;
} data;
-};
+} BlizzardState;
/* Bytes(!) per pixel */
static const int blizzard_iformat_bpp[0x10] = {
*v = 0x80 + ((0xe0e * r - 0x0bc7 * g - 0x247 * b) >> 13);
}
-static void blizzard_window(struct blizzard_s *s)
+static void blizzard_window(BlizzardState *s)
{
uint8_t *src, *dst;
int bypp[2];
s->my[1] = s->data.y + s->data.dy;
bypp[0] = s->bpp;
- bypp[1] = (s->state->depth + 7) >> 3;
+ bypp[1] = (ds_get_bits_per_pixel(s->state) + 7) >> 3;
bypl[0] = bypp[0] * s->data.pitch;
bypl[1] = bypp[1] * s->x;
bypl[2] = bypp[0] * s->data.dx;
fn(dst, src, bypl[2]);
}
-static int blizzard_transfer_setup(struct blizzard_s *s)
+static int blizzard_transfer_setup(BlizzardState *s)
{
if (s->source > 3 || !s->bpp ||
s->ix[1] < s->ix[0] || s->iy[1] < s->iy[0])
return 1;
}
-static void blizzard_reset(struct blizzard_s *s)
+static void blizzard_reset(BlizzardState *s)
{
s->reg = 0;
s->swallow = 0;
}
static inline void blizzard_invalidate_display(void *opaque) {
- struct blizzard_s *s = (struct blizzard_s *) opaque;
+ BlizzardState *s = (BlizzardState *) opaque;
s->invalidate = 1;
}
static uint16_t blizzard_reg_read(void *opaque, uint8_t reg)
{
- struct blizzard_s *s = (struct blizzard_s *) opaque;
+ BlizzardState *s = (BlizzardState *) opaque;
switch (reg) {
case 0x00: /* Revision Code */
static void blizzard_reg_write(void *opaque, uint8_t reg, uint16_t value)
{
- struct blizzard_s *s = (struct blizzard_s *) opaque;
+ BlizzardState *s = (BlizzardState *) opaque;
switch (reg) {
case 0x04: /* PLL M-Divider */
uint16_t s1d13745_read(void *opaque, int dc)
{
- struct blizzard_s *s = (struct blizzard_s *) opaque;
+ BlizzardState *s = (BlizzardState *) opaque;
uint16_t value = blizzard_reg_read(s, s->reg);
if (s->swallow -- > 0)
void s1d13745_write(void *opaque, int dc, uint16_t value)
{
- struct blizzard_s *s = (struct blizzard_s *) opaque;
+ BlizzardState *s = (BlizzardState *) opaque;
if (s->swallow -- > 0)
return;
void s1d13745_write_block(void *opaque, int dc,
void *buf, size_t len, int pitch)
{
- struct blizzard_s *s = (struct blizzard_s *) opaque;
+ BlizzardState *s = (BlizzardState *) opaque;
while (len > 0) {
if (s->reg == 0x90 && dc &&
static void blizzard_update_display(void *opaque)
{
- struct blizzard_s *s = (struct blizzard_s *) opaque;
+ BlizzardState *s = (BlizzardState *) opaque;
int y, bypp, bypl, bwidth;
uint8_t *src, *dst;
if (!s->enable)
return;
- if (s->x != s->state->width || s->y != s->state->height) {
+ if (s->x != ds_get_width(s->state) || s->y != ds_get_height(s->state)) {
s->invalidate = 1;
- qemu_console_resize(s->console, s->x, s->y);
+ qemu_console_resize(s->state, s->x, s->y);
}
if (s->invalidate) {
s->invalidate = 0;
if (s->blank) {
- bypp = (s->state->depth + 7) >> 3;
- memset(s->state->data, 0, bypp * s->x * s->y);
+ bypp = (ds_get_bits_per_pixel(s->state) + 7) >> 3;
+ memset(ds_get_data(s->state), 0, bypp * s->x * s->y);
return;
}
if (s->mx[1] <= s->mx[0])
return;
- bypp = (s->state->depth + 7) >> 3;
+ bypp = (ds_get_bits_per_pixel(s->state) + 7) >> 3;
bypl = bypp * s->x;
bwidth = bypp * (s->mx[1] - s->mx[0]);
y = s->my[0];
src = s->fb + bypl * y + bypp * s->mx[0];
- dst = s->state->data + bypl * y + bypp * s->mx[0];
+ dst = ds_get_data(s->state) + bypl * y + bypp * s->mx[0];
for (; y < s->my[1]; y ++, src += bypl, dst += bypl)
memcpy(dst, src, bwidth);
}
static void blizzard_screen_dump(void *opaque, const char *filename) {
- struct blizzard_s *s = (struct blizzard_s *) opaque;
+ BlizzardState *s = (BlizzardState *) opaque;
blizzard_update_display(opaque);
- if (s && s->state->data)
- ppm_save(filename, s->state->data, s->x, s->y, s->state->linesize);
+ if (s && ds_get_data(s->state))
+ ppm_save(filename, s->state->surface);
}
#define DEPTH 8
#define DEPTH 32
#include "blizzard_template.h"
-void *s1d13745_init(qemu_irq gpio_int, DisplayState *ds)
+void *s1d13745_init(qemu_irq gpio_int)
{
- struct blizzard_s *s = (struct blizzard_s *) qemu_mallocz(sizeof(*s));
+ BlizzardState *s = (BlizzardState *) qemu_mallocz(sizeof(*s));
- s->state = ds;
s->fb = qemu_malloc(0x180000);
- switch (s->state->depth) {
+ s->state = graphic_console_init(blizzard_update_display,
+ blizzard_invalidate_display,
+ blizzard_screen_dump, NULL, s);
+
+ switch (ds_get_bits_per_pixel(s->state)) {
case 0:
s->line_fn_tab[0] = s->line_fn_tab[1] =
qemu_mallocz(sizeof(blizzard_fn_t) * 0x10);
blizzard_reset(s);
- s->console = graphic_console_init(s->state, blizzard_update_display,
- blizzard_invalidate_display,
- blizzard_screen_dump, NULL, s);
-
return s;
}