2003-09-11 02:46:56 +04:00
|
|
|
/*
|
|
|
|
* This file is part of NetSurf, http://netsurf.sourceforge.net/
|
|
|
|
* Licensed under the GNU General Public License,
|
|
|
|
* http://www.opensource.org/licenses/gpl-license
|
|
|
|
* Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
2004-01-05 05:10:59 +03:00
|
|
|
#include "netsurf/utils/config.h"
|
2003-09-11 02:46:56 +04:00
|
|
|
#include "netsurf/content/content.h"
|
|
|
|
#include "netsurf/riscos/sprite.h"
|
|
|
|
#include "netsurf/utils/utils.h"
|
|
|
|
#include "netsurf/utils/log.h"
|
|
|
|
#include "oslib/colourtrans.h"
|
|
|
|
#include "oslib/osspriteop.h"
|
|
|
|
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_SPRITE
|
|
|
|
|
2003-12-27 23:15:23 +03:00
|
|
|
void sprite_create(struct content *c, const char *params[])
|
2003-09-11 02:46:56 +04:00
|
|
|
{
|
2003-09-11 22:37:25 +04:00
|
|
|
c->data.sprite.data = xcalloc(4, 1);
|
|
|
|
c->data.sprite.length = 4;
|
2003-09-11 02:46:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sprite_process_data(struct content *c, char *data, unsigned long size)
|
|
|
|
{
|
|
|
|
c->data.sprite.data = xrealloc(c->data.sprite.data, c->data.sprite.length + size);
|
2003-12-27 03:11:57 +03:00
|
|
|
memcpy((char*)(c->data.sprite.data) + c->data.sprite.length, data, size);
|
2003-09-11 02:46:56 +04:00
|
|
|
c->data.sprite.length += size;
|
|
|
|
c->size += size;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int sprite_convert(struct content *c, unsigned int width, unsigned int height)
|
|
|
|
{
|
|
|
|
os_error *error;
|
|
|
|
int w, h;
|
2003-12-27 03:11:57 +03:00
|
|
|
osspriteop_area *area = (osspriteop_area*)c->data.sprite.data;
|
2003-09-11 02:46:56 +04:00
|
|
|
|
2003-09-11 22:37:25 +04:00
|
|
|
/* fill in the size (first word) of the area */
|
2003-09-12 23:51:17 +04:00
|
|
|
area->size = c->data.sprite.length;
|
2003-09-11 22:37:25 +04:00
|
|
|
|
|
|
|
error = xosspriteop_read_sprite_info(osspriteop_PTR,
|
2003-09-12 23:51:17 +04:00
|
|
|
area,
|
2003-12-27 03:11:57 +03:00
|
|
|
(osspriteop_id)((char*)(c->data.sprite.data) + area->first),
|
2003-09-11 02:46:56 +04:00
|
|
|
&w, &h, NULL, NULL);
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
LOG(("error: %s", error->errmess));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
c->width = w;
|
|
|
|
c->height = h;
|
|
|
|
c->title = xcalloc(100, 1);
|
|
|
|
sprintf(c->title, "Sprite image (%lux%lu, %lu bytes)", c->width,
|
|
|
|
c->height, c->data.sprite.length);
|
|
|
|
c->status = CONTENT_STATUS_DONE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sprite_revive(struct content *c, unsigned int width, unsigned int height)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sprite_reformat(struct content *c, unsigned int width, unsigned int height)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sprite_destroy(struct content *c)
|
|
|
|
{
|
|
|
|
xfree(c->data.sprite.data);
|
|
|
|
xfree(c->title);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sprite_redraw(struct content *c, long x, long y,
|
|
|
|
unsigned long width, unsigned long height,
|
2004-02-25 18:12:58 +03:00
|
|
|
long clip_x0, long clip_y0, long clip_x1, long clip_y1,
|
|
|
|
float scale)
|
2003-09-11 02:46:56 +04:00
|
|
|
{
|
|
|
|
unsigned int size;
|
2003-12-27 03:11:57 +03:00
|
|
|
osspriteop_area *area = (osspriteop_area*)c->data.sprite.data;
|
2003-09-11 02:46:56 +04:00
|
|
|
osspriteop_trans_tab *table;
|
|
|
|
os_factors factors;
|
|
|
|
|
|
|
|
xcolourtrans_generate_table_for_sprite(
|
2003-09-12 23:51:17 +04:00
|
|
|
area,
|
2003-12-27 03:11:57 +03:00
|
|
|
(osspriteop_id)((char*)(c->data.sprite.data) +
|
|
|
|
area->first),
|
2003-09-11 02:46:56 +04:00
|
|
|
colourtrans_CURRENT_MODE, colourtrans_CURRENT_PALETTE,
|
|
|
|
0, colourtrans_GIVEN_SPRITE, 0, 0, &size);
|
|
|
|
table = xcalloc(size, 1);
|
|
|
|
xcolourtrans_generate_table_for_sprite(
|
2003-09-12 23:51:17 +04:00
|
|
|
area,
|
2003-12-27 03:11:57 +03:00
|
|
|
(osspriteop_id)((char*)(c->data.sprite.data) +
|
|
|
|
area->first),
|
2003-09-11 02:46:56 +04:00
|
|
|
colourtrans_CURRENT_MODE, colourtrans_CURRENT_PALETTE,
|
|
|
|
table, colourtrans_GIVEN_SPRITE, 0, 0, 0);
|
|
|
|
|
|
|
|
factors.xmul = width;
|
|
|
|
factors.ymul = height;
|
|
|
|
factors.xdiv = c->width * 2;
|
|
|
|
factors.ydiv = c->height * 2;
|
|
|
|
|
2003-09-11 22:37:25 +04:00
|
|
|
xosspriteop_put_sprite_scaled(osspriteop_PTR,
|
2003-09-12 23:51:17 +04:00
|
|
|
area,
|
2003-12-27 03:11:57 +03:00
|
|
|
(osspriteop_id)((char*)(c->data.sprite.data) +
|
|
|
|
area->first),
|
|
|
|
x, (int)(y - height),
|
2003-09-11 02:46:56 +04:00
|
|
|
osspriteop_USE_MASK | osspriteop_USE_PALETTE, &factors, table);
|
|
|
|
|
|
|
|
xfree(table);
|
|
|
|
}
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|