[Scummvm-cvs-logs] SF.net SVN: scummvm: [22488] residual/trunk
aquadran at users.sourceforge.net
aquadran at users.sourceforge.net
Tue May 16 04:14:57 CEST 2006
Revision: 22488
Author: aquadran
Date: 2006-05-16 03:02:27 -0700 (Tue, 16 May 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=22488&view=rev
Log Message:
-----------
removed indexed colors code and formating code
Modified Paths:
--------------
residual/trunk/driver_tinygl.cpp
residual/trunk/tinygl/zbuffer.cpp
residual/trunk/tinygl/zbuffer.h
Modified: residual/trunk/driver_tinygl.cpp
===================================================================
--- residual/trunk/driver_tinygl.cpp 2006-05-16 09:29:40 UTC (rev 22487)
+++ residual/trunk/driver_tinygl.cpp 2006-05-16 10:02:27 UTC (rev 22488)
@@ -110,7 +110,7 @@
SDL_WM_SetCaption("Residual: Software 3D Renderer", "Residual");
- _zb = ZB_open(screenW, screenH, ZB_MODE_5R6G5B, 0, NULL, NULL, _screen->pixels);
+ _zb = ZB_open(screenW, screenH, ZB_MODE_5R6G5B, _screen->pixels);
tglInit(_zb);
_storedDisplay = new byte[640 * 480 * 2];
Modified: residual/trunk/tinygl/zbuffer.cpp
===================================================================
--- residual/trunk/tinygl/zbuffer.cpp 2006-05-16 09:29:40 UTC (rev 22487)
+++ residual/trunk/tinygl/zbuffer.cpp 2006-05-16 10:02:27 UTC (rev 22488)
@@ -1,215 +1,194 @@
-/*
- * Z buffer: 16 bits Z / 16 bits color
- *
- */
+// Z buffer: 16,32 bits Z / 16 bits color
+
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include "tinygl/zbuffer.h"
-ZBuffer *ZB_open(int xsize, int ysize, int mode,
- int nb_colors,
- unsigned char *color_indexes,
- int *color_table,
- void *frame_buffer)
-{
- ZBuffer *zb;
- int size;
+ZBuffer *ZB_open(int xsize, int ysize, int mode, void *frame_buffer) {
+ ZBuffer *zb;
+ int size;
- zb = (ZBuffer *)gl_malloc(sizeof(ZBuffer));
- if (zb == NULL)
+ zb = (ZBuffer *)gl_malloc(sizeof(ZBuffer));
+ if (zb == NULL)
return NULL;
- zb->xsize = xsize;
- zb->ysize = ysize;
- zb->mode = mode;
- zb->linesize = (xsize * PSZB + 3) & ~3;
+ zb->xsize = xsize;
+ zb->ysize = ysize;
+ zb->mode = mode;
+ zb->linesize = (xsize * PSZB + 3) & ~3;
- switch (mode) {
+ switch (mode) {
case ZB_MODE_5R6G5B:
- zb->nb_colors = 0;
break;
- default:
+ default:
goto error;
- }
+ }
- size = zb->xsize * zb->ysize * sizeof(unsigned short);
+ size = zb->xsize * zb->ysize * sizeof(unsigned short);
- zb->zbuf = (unsigned short *)gl_malloc(size);
- if (zb->zbuf == NULL)
- goto error;
+ zb->zbuf = (unsigned short *)gl_malloc(size);
+ if (zb->zbuf == NULL)
+ goto error;
- size = zb->xsize * zb->ysize * sizeof(unsigned long);
+ size = zb->xsize * zb->ysize * sizeof(unsigned long);
- zb->zbuf2 = (unsigned long *)gl_malloc(size);
+ zb->zbuf2 = (unsigned long *)gl_malloc(size);
if (zb->zbuf2 == NULL) {
- gl_free(zb->zbuf);
+ gl_free(zb->zbuf);
goto error;
}
if (frame_buffer == NULL) {
- zb->pbuf = (PIXEL *)gl_malloc(zb->ysize * zb->linesize);
- if (zb->pbuf == NULL) {
- gl_free(zb->zbuf);
- gl_free(zb->zbuf2);
- goto error;
+ zb->pbuf = (PIXEL *)gl_malloc(zb->ysize * zb->linesize);
+ if (zb->pbuf == NULL) {
+ gl_free(zb->zbuf);
+ gl_free(zb->zbuf2);
+ goto error;
+ }
+ zb->frame_buffer_allocated = 1;
+ } else {
+ zb->frame_buffer_allocated = 0;
+ zb->pbuf = (PIXEL *)frame_buffer;
}
- zb->frame_buffer_allocated = 1;
- } else {
- zb->frame_buffer_allocated = 0;
- zb->pbuf = (PIXEL *)frame_buffer;
- }
- zb->current_texture = NULL;
+ zb->current_texture = NULL;
- return zb;
- error:
- gl_free(zb);
- return NULL;
+ return zb;
+error:
+ gl_free(zb);
+ return NULL;
}
-void ZB_close(ZBuffer * zb)
-{
+void ZB_close(ZBuffer *zb) {
if (zb->frame_buffer_allocated)
- gl_free(zb->pbuf);
+ gl_free(zb->pbuf);
gl_free(zb->zbuf);
gl_free(zb->zbuf2);
gl_free(zb);
}
-void ZB_resize(ZBuffer * zb, void *frame_buffer, int xsize, int ysize)
-{
- int size;
+void ZB_resize(ZBuffer *zb, void *frame_buffer, int xsize, int ysize) {
+ int size;
- /* xsize must be a multiple of 4 */
- xsize = xsize & ~3;
+ // xsize must be a multiple of 4
+ xsize = xsize & ~3;
- zb->xsize = xsize;
- zb->ysize = ysize;
- zb->linesize = (xsize * PSZB + 3) & ~3;
+ zb->xsize = xsize;
+ zb->ysize = ysize;
+ zb->linesize = (xsize * PSZB + 3) & ~3;
- size = zb->xsize * zb->ysize * sizeof(unsigned short);
+ size = zb->xsize * zb->ysize * sizeof(unsigned short);
- gl_free(zb->zbuf);
- zb->zbuf = (unsigned short *)gl_malloc(size);
+ gl_free(zb->zbuf);
+ zb->zbuf = (unsigned short *)gl_malloc(size);
- size = zb->xsize * zb->ysize * sizeof(unsigned long);
+ size = zb->xsize * zb->ysize * sizeof(unsigned long);
gl_free(zb->zbuf2);
- zb->zbuf2 = (unsigned long *)gl_malloc(size);
+ zb->zbuf2 = (unsigned long *)gl_malloc(size);
if (zb->frame_buffer_allocated)
- gl_free(zb->pbuf);
+ gl_free(zb->pbuf);
- if (frame_buffer == NULL) {
- zb->pbuf = (PIXEL *)gl_malloc(zb->ysize * zb->linesize);
- zb->frame_buffer_allocated = 1;
- } else {
- zb->pbuf = (PIXEL *)frame_buffer;
- zb->frame_buffer_allocated = 0;
- }
+ if (frame_buffer == NULL) {
+ zb->pbuf = (PIXEL *)gl_malloc(zb->ysize * zb->linesize);
+ zb->frame_buffer_allocated = 1;
+ } else {
+ zb->pbuf = (PIXEL *)frame_buffer;
+ zb->frame_buffer_allocated = 0;
+ }
}
-static void ZB_copyBuffer(ZBuffer * zb,
- void *buf,
- int linesize)
-{
- unsigned char *p1;
- PIXEL *q;
- int y, n;
+static void ZB_copyBuffer(ZBuffer *zb, void *buf, int linesize) {
+ unsigned char *p1;
+ PIXEL *q;
+ int y, n;
- q = zb->pbuf;
- p1 =(unsigned char *) buf;
- n = zb->xsize * PSZB;
- for (y = 0; y < zb->ysize; y++) {
- memcpy(p1, q, n);
- p1 += linesize;
- q = (PIXEL *) ((char *) q + zb->linesize);
- }
+ q = zb->pbuf;
+ p1 = (unsigned char *)buf;
+ n = zb->xsize * PSZB;
+ for (y = 0; y < zb->ysize; y++) {
+ memcpy(p1, q, n);
+ p1 += linesize;
+ q = (PIXEL *)((char *) q + zb->linesize);
+ }
}
-void ZB_copyFrameBuffer(ZBuffer * zb, void *buf,
- int linesize)
-{
+void ZB_copyFrameBuffer(ZBuffer *zb, void *buf, int linesize) {
switch (zb->mode) {
case ZB_MODE_5R6G5B:
ZB_copyBuffer(zb, buf, linesize);
break;
default:
assert(0);
- }
+ }
}
+// adr must be aligned on an 'int'
+void memset_s(void *adr, int val, int count) {
+ int i, n, v;
+ unsigned int *p;
+ unsigned short *q;
-/*
- * adr must be aligned on an 'int'
- */
-void memset_s(void *adr, int val, int count)
-{
- int i, n, v;
- unsigned int *p;
- unsigned short *q;
+ p = (unsigned int *)adr;
+ v = val | (val << 16);
- p = (unsigned int *)adr;
- v = val | (val << 16);
+ n = count >> 3;
+ for (i = 0; i < n; i++) {
+ p[0] = v;
+ p[1] = v;
+ p[2] = v;
+ p[3] = v;
+ p += 4;
+ }
- n = count >> 3;
- for (i = 0; i < n; i++) {
- p[0] = v;
- p[1] = v;
- p[2] = v;
- p[3] = v;
- p += 4;
- }
-
- q = (unsigned short *) p;
- n = count & 7;
- for (i = 0; i < n; i++)
- *q++ = val;
+ q = (unsigned short *) p;
+ n = count & 7;
+ for (i = 0; i < n; i++)
+ *q++ = val;
}
-void memset_l(void *adr, int val, int count)
-{
- int i, n, v;
- unsigned int *p;
+void memset_l(void *adr, int val, int count) {
+ int i, n, v;
+ unsigned int *p;
- p = (unsigned int *)adr;
- v = val;
- n = count >> 2;
- for (i = 0; i < n; i++) {
- p[0] = v;
- p[1] = v;
- p[2] = v;
- p[3] = v;
- p += 4;
- }
+ p = (unsigned int *)adr;
+ v = val;
+ n = count >> 2;
+ for (i = 0; i < n; i++) {
+ p[0] = v;
+ p[1] = v;
+ p[2] = v;
+ p[3] = v;
+ p += 4;
+ }
n = count & 3;
for (i = 0; i < n; i++)
*p++ = val;
}
-void ZB_clear(ZBuffer * zb, int clear_z, int z,
- int clear_color, int r, int g, int b)
-{
- int color;
- int y;
- PIXEL *pp;
+void ZB_clear(ZBuffer *zb, int clear_z, int z,
+ int clear_color, int r, int g, int b) {
+ int color;
+ int y;
+ PIXEL *pp;
- if (clear_z) {
+ if (clear_z) {
memset_s(zb->zbuf, z, zb->xsize * zb->ysize);
- }
- if (clear_z) {
+ }
+ if (clear_z) {
memset_l(zb->zbuf, z, zb->xsize * zb->ysize);
- }
- if (clear_color) {
+ }
+ if (clear_color) {
pp = zb->pbuf;
for (y = 0; y < zb->ysize; y++) {
color = RGB_TO_PIXEL(r, g, b);
memset_s(pp, color, zb->xsize);
- pp = (PIXEL *) ((char *) pp + zb->linesize);
+ pp = (PIXEL *)((char *)pp + zb->linesize);
}
- }
+ }
}
Modified: residual/trunk/tinygl/zbuffer.h
===================================================================
--- residual/trunk/tinygl/zbuffer.h 2006-05-16 09:29:40 UTC (rev 22487)
+++ residual/trunk/tinygl/zbuffer.h 2006-05-16 10:02:27 UTC (rev 22488)
@@ -1,114 +1,88 @@
#ifndef _tgl_zbuffer_h_
#define _tgl_zbuffer_h_
-/*
- * Z buffer
- */
+// Z buffer
#define ZB_Z_BITS 16
#define ZB_POINT_Z_FRAC_BITS 14
-#define ZB_POINT_S_MIN ( (1<<13) )
-#define ZB_POINT_S_MAX ( (1<<22)-(1<<13) )
-#define ZB_POINT_T_MIN ( (1<<21) )
-#define ZB_POINT_T_MAX ( (1<<30)-(1<<21) )
+#define ZB_POINT_S_MIN ( (1 << 13) )
+#define ZB_POINT_S_MAX ( (1 << 22) - (1 << 13) )
+#define ZB_POINT_T_MIN ( (1 << 21) )
+#define ZB_POINT_T_MAX ( (1 << 30) - (1 << 21) )
-#define ZB_POINT_RED_MIN ( (1<<10) )
-#define ZB_POINT_RED_MAX ( (1<<16)-(1<<10) )
-#define ZB_POINT_GREEN_MIN ( (1<<9) )
-#define ZB_POINT_GREEN_MAX ( (1<<16)-(1<<9) )
-#define ZB_POINT_BLUE_MIN ( (1<<10) )
-#define ZB_POINT_BLUE_MAX ( (1<<16)-(1<<10) )
+#define ZB_POINT_RED_MIN ( (1 << 10) )
+#define ZB_POINT_RED_MAX ( (1 << 16) - (1 << 10) )
+#define ZB_POINT_GREEN_MIN ( (1 << 9) )
+#define ZB_POINT_GREEN_MAX ( (1 << 16) - (1 << 9) )
+#define ZB_POINT_BLUE_MIN ( (1 << 10) )
+#define ZB_POINT_BLUE_MAX ( (1 << 16) - (1 << 10) )
-/* display modes */
-#define ZB_MODE_5R6G5B 1 /* true color 16 bits */
+// display modes
+#define ZB_MODE_5R6G5B 1 // true color 16 bits
-/* 16 bit mode */
-#define RGB_TO_PIXEL(r,g,b) \
- (((r) & 0xF800) | (((g) >> 5) & 0x07E0) | ((b) >> 11))
+// 16 bit mode
+#define RGB_TO_PIXEL(r,g,b) (((r) & 0xF800) | (((g) >> 5) & 0x07E0) | ((b) >> 11))
typedef unsigned short PIXEL;
#define PSZB 2
#define PSZSH 4
typedef struct {
- int xsize,ysize;
- int linesize; /* line size, in bytes */
- int mode;
-
- unsigned short *zbuf;
- unsigned long *zbuf2;
- PIXEL *pbuf;
- int frame_buffer_allocated;
-
- int nb_colors;
- unsigned char *dctable;
- int *ctable;
- PIXEL *current_texture;
+ int xsize,ysize;
+ int linesize; // line size, in bytes
+ int mode;
+
+ unsigned short *zbuf;
+ unsigned long *zbuf2;
+ PIXEL *pbuf;
+ int frame_buffer_allocated;
+
+ unsigned char *dctable;
+ int *ctable;
+ PIXEL *current_texture;
} ZBuffer;
typedef struct {
- int x,y,z; /* integer coordinates in the zbuffer */
- int s,t; /* coordinates for the mapping */
- int r,g,b; /* color indexes */
+ int x,y,z; // integer coordinates in the zbuffer
+ int s,t; // coordinates for the mapping
+ int r,g,b; // color indexes
- float sz,tz; /* temporary coordinates for mapping */
+ float sz,tz; // temporary coordinates for mapping
} ZBufferPoint;
-/* zbuffer.c */
+// zbuffer.c
-ZBuffer *ZB_open(int xsize,int ysize,int mode,
- int nb_colors,
- unsigned char *color_indexes,
- int *color_table,
- void *frame_buffer);
-
-
+ZBuffer *ZB_open(int xsize, int ysize, int mode, void *frame_buffer);
void ZB_close(ZBuffer *zb);
+void ZB_resize(ZBuffer *zb, void *frame_buffer, int xsize, int ysize);
+void ZB_clear(ZBuffer *zb, int clear_z, int z, int clear_color, int r, int g, int b);
+// linesize is in BYTES
+void ZB_copyFrameBuffer(ZBuffer *zb, void *buf, int linesize);
-void ZB_resize(ZBuffer *zb,void *frame_buffer,int xsize,int ysize);
-void ZB_clear(ZBuffer *zb,int clear_z,int z,
- int clear_color,int r,int g,int b);
-/* linesize is in BYTES */
-void ZB_copyFrameBuffer(ZBuffer *zb,void *buf,int linesize);
+// zline.c
-/* zdither.c */
-
-void ZB_initDither(ZBuffer *zb,int nb_colors,
- unsigned char *color_indexes,int *color_table);
-void ZB_closeDither(ZBuffer *zb);
-void ZB_ditherFrameBuffer(ZBuffer *zb,unsigned char *dest,
- int linesize);
-
-/* zline.c */
-
void ZB_plot(ZBuffer *zb,ZBufferPoint *p);
void ZB_line(ZBuffer *zb,ZBufferPoint *p1,ZBufferPoint *p2);
void ZB_line_z(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2);
-/* ztriangle.c */
+// ztriangle.c */
void ZB_setTexture(ZBuffer *zb, PIXEL *texture);
+void ZB_fillTriangleFlat(ZBuffer *zb, ZBufferPoint *p1,
+ ZBufferPoint *p2, ZBufferPoint *p3);
+void ZB_fillTriangleSmooth(ZBuffer *zb, ZBufferPoint *p1,
+ ZBufferPoint *p2, ZBufferPoint *p3);
+void ZB_fillTriangleMapping(ZBuffer *zb, ZBufferPoint *p1,
+ ZBufferPoint *p2, ZBufferPoint *p3);
+void ZB_fillTriangleMappingPerspective(ZBuffer *zb, ZBufferPoint *p0,
+ ZBufferPoint *p1, ZBufferPoint *p2);
+typedef void (*ZB_fillTriangleFunc)(ZBuffer *, ZBufferPoint *,
+ ZBufferPoint *, ZBufferPoint *);
-void ZB_fillTriangleFlat(ZBuffer *zb,
- ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
-
-void ZB_fillTriangleSmooth(ZBuffer *zb,
- ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
-
-void ZB_fillTriangleMapping(ZBuffer *zb,
- ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
-
-void ZB_fillTriangleMappingPerspective(ZBuffer *zb,
- ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
-
-
-typedef void (*ZB_fillTriangleFunc)(ZBuffer *,
- ZBufferPoint *,ZBufferPoint *,ZBufferPoint *);
-
-/* memory.c */
+// memory.c
void gl_free(void *p);
void *gl_malloc(int size);
void *gl_zalloc(int size);
-#endif /* _tgl_zbuffer_h_ */
+#endif // _tgl_zbuffer_h_
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list