<html>
<body>
  <div id="body" style="background-color:#ffffff;" >
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head" style="border-bottom-width:1px;border-bottom-style:solid;" ><td class="headtd" style="padding:0;padding-top:.2em;" colspan="4">Commit in <b><tt>lxdream/src</tt></b></td></tr>
<tr><td><tt><a href="#file1">Makefile.am</a></tt></td><td id="added" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ddffdd;" align="right">+1</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-2</td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">00dd49743974 -> 45674791c6ad</td></tr>
<tr class="alt" style=";" ><td><tt><a href="#file2">Makefile.in</a></tt></td><td id="addedalt" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ccf7cc;" align="right">+12</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-12</td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">00dd49743974 -> 45674791c6ad</td></tr>
<tr><td><tt>pvr2/<a href="#file3">glrender.c</a></tt></td><td id="added" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ddffdd;" align="right">+68</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-132</td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">00dd49743974 -> 45674791c6ad</td></tr>
<tr class="alt" style=";" ><td><tt>    /<a href="#file4">pvr2.h</a></tt></td><td id="addedalt" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ccf7cc;" align="right">+5</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-1</td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">00dd49743974 -> 45674791c6ad</td></tr>
<tr><td><tt>    /<a href="#file5">tacore.c</a></tt></td><td></td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-4</td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">00dd49743974 -> 45674791c6ad</td></tr>
<tr class="alt" style=";" ><td><tt>    /<a href="#file6"><span id="addedalt" style="background-color:#ccf7cc;" >tileiter.h</span></a></tt></td><td id="addedalt" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ccf7cc;" align="right">+197</td><td></td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" align="right" nowrap="nowrap">added 45674791c6ad</td></tr>
<tr><td></td><td id="added" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ddffdd;" align="right">+283</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-151</td><td></td></tr>
</table>
<small id="info" style="color: #888888;" >1 added + 5 modified, total 6 files</small><br />
<pre class="comment" style="white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;white-space:pre-wrap;word-wrap:break-word;padding:4px;border:1px dashed #000000;background-color:#ffffdd;" >
Introduce tile iterators to simplify processing of the tile lists
</pre>
<hr /><a name="file1" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>Makefile.am</b></big> <small id="info" style="color: #888888;" >00dd49743974 -> 45674791c6ad</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/Makefile.am
+++ lxdream/src/Makefile.am
@@ -56,10 +56,9 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >         aica/armcore.c aica/armcore.h aica/armdasm.c aica/armdasm.h aica/armmem.c \
         aica/aica.c aica/aica.h aica/audio.c aica/audio.h \
        pvr2/pvr2.c pvr2/pvr2.h pvr2/pvr2mem.c pvr2/pvr2mmio.h \
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-   pvr2/tacore.c pvr2/rendsort.c \
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+     pvr2/tacore.c pvr2/rendsort.c pvr2/tileiter.h pvr2/shaders.glsl \
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >    pvr2/texcache.c pvr2/yuv.c pvr2/rendsave.c pvr2/scene.c pvr2/scene.h \
        pvr2/gl_sl.c pvr2/shaders.h pvr2/shaders.def pvr2/glutil.c pvr2/glutil.h pvr2/glrender.c \
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-   pvr2/vertex.glsl pvr2/fragment.glsl \
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >         maple/maple.c maple/maple.h \
         maple/controller.c maple/kbd.c maple/mouse.c maple/lightgun.c maple/vmu.c \
         loader.c loader.h elf.h bootstrap.c bootstrap.h util.c gdlist.c gdlist.h \
</pre></div>
<hr /><a name="file2" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>Makefile.in</b></big> <small id="info" style="color: #888888;" >00dd49743974 -> 45674791c6ad</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/Makefile.in
+++ lxdream/src/Makefile.in
@@ -156,10 +156,10 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >      aica/armcore.h aica/armdasm.c aica/armdasm.h aica/armmem.c \
        aica/aica.c aica/aica.h aica/audio.c aica/audio.h pvr2/pvr2.c \
        pvr2/pvr2.h pvr2/pvr2mem.c pvr2/pvr2mmio.h pvr2/tacore.c \
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-   pvr2/rendsort.c pvr2/texcache.c pvr2/yuv.c pvr2/rendsave.c \
-       pvr2/scene.c pvr2/scene.h pvr2/gl_sl.c pvr2/shaders.h \
-       pvr2/shaders.def pvr2/glutil.c pvr2/glutil.h pvr2/glrender.c \
-       pvr2/vertex.glsl pvr2/fragment.glsl maple/maple.c \
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+     pvr2/rendsort.c pvr2/tileiter.h pvr2/shaders.glsl \
+       pvr2/texcache.c pvr2/yuv.c pvr2/rendsave.c pvr2/scene.c \
+       pvr2/scene.h pvr2/gl_sl.c pvr2/shaders.h pvr2/shaders.def \
+       pvr2/glutil.c pvr2/glutil.h pvr2/glrender.c maple/maple.c \
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >    maple/maple.h maple/controller.c maple/kbd.c maple/mouse.c \
        maple/lightgun.c maple/vmu.c loader.c loader.h elf.h \
        bootstrap.c bootstrap.h util.c gdlist.c gdlist.h vmu/vmuvol.c \
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -576,14 +576,14 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >      aica/armdasm.h aica/armmem.c aica/aica.c aica/aica.h \
        aica/audio.c aica/audio.h pvr2/pvr2.c pvr2/pvr2.h \
        pvr2/pvr2mem.c pvr2/pvr2mmio.h pvr2/tacore.c pvr2/rendsort.c \
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-   pvr2/texcache.c pvr2/yuv.c pvr2/rendsave.c pvr2/scene.c \
-       pvr2/scene.h pvr2/gl_sl.c pvr2/shaders.h pvr2/shaders.def \
-       pvr2/glutil.c pvr2/glutil.h pvr2/glrender.c pvr2/vertex.glsl \
-       pvr2/fragment.glsl maple/maple.c maple/maple.h \
-       maple/controller.c maple/kbd.c maple/mouse.c maple/lightgun.c \
-       maple/vmu.c loader.c loader.h elf.h bootstrap.c bootstrap.h \
-       util.c gdlist.c gdlist.h vmu/vmuvol.c vmu/vmuvol.h \
-       vmu/vmulist.c vmu/vmulist.h display.c display.h dckeysyms.h \
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+     pvr2/tileiter.h pvr2/shaders.glsl pvr2/texcache.c pvr2/yuv.c \
+       pvr2/rendsave.c pvr2/scene.c pvr2/scene.h pvr2/gl_sl.c \
+       pvr2/shaders.h pvr2/shaders.def pvr2/glutil.c pvr2/glutil.h \
+       pvr2/glrender.c maple/maple.c maple/maple.h maple/controller.c \
+       maple/kbd.c maple/mouse.c maple/lightgun.c maple/vmu.c \
+       loader.c loader.h elf.h bootstrap.c bootstrap.h util.c \
+       gdlist.c gdlist.h vmu/vmuvol.c vmu/vmuvol.h vmu/vmulist.c \
+       vmu/vmulist.h display.c display.h dckeysyms.h \
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >    drivers/audio_null.c drivers/video_null.c drivers/video_gl.c \
        drivers/video_gl.h drivers/gl_fbo.c drivers/serial_unix.c \
        drivers/cdrom/cdrom.h drivers/cdrom/cdrom.c \
</pre></div>
<hr /><a name="file3" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src/pvr2</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>glrender.c</b></big> <small id="info" style="color: #888888;" >00dd49743974 -> 45674791c6ad</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/pvr2/glrender.c
+++ lxdream/src/pvr2/glrender.c
@@ -21,8 +21,9 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > #include "display.h"
 #include "pvr2/pvr2.h"
 #include "pvr2/pvr2mmio.h"
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+#include "pvr2/glutil.h"
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > #include "pvr2/scene.h"
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-#include "pvr2/<span id="removedchars" style="background-color:#ff9999;font-weight:bolder;" >glutil</span>.h"
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+#include "pvr2/<span id="addedchars" style="background-color:#99ff99;font-weight:bolder;" >tileiter</span>.h"
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
 #define IS_EMPTY_TILE_LIST(p) ((*((uint32_t *)(pvr2_main_ram+(p))) >> 28) == 0x0F)
 
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -59,6 +60,16 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     return tile[0] < tile[1] && tile[2] < tile[3];
 }
 
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+static void drawrect2d( uint32_t tile_bounds[], float z )
+{
+    glBegin( GL_QUADS );
+    glVertex3f( tile_bounds[0], tile_bounds[2], z );
+    glVertex3f( tile_bounds[1], tile_bounds[2], z );
+    glVertex3f( tile_bounds[1], tile_bounds[3], z );
+    glVertex3f( tile_bounds[0], tile_bounds[3], z );
+    glEnd();
+}
+
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > void pvr2_scene_load_textures()
 {
     int i;
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -239,107 +250,8 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     }
 }
 
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-static void gl_render_bkgnd( struct polygon_struct *poly )
-{
-    glBindTexture(GL_TEXTURE_2D, poly->tex_id);
-    render_set_tsp_context( poly->context[0], poly->context[1] );
-    glDisable( GL_DEPTH_TEST );
-    glBlendFunc( GL_ONE, GL_ZERO );
-    gl_draw_vertexes(poly);
-    glEnable( GL_DEPTH_TEST );
-}
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-void gl_render_tilelist( pvraddr_t tile_entry, gboolean set_depth )
-{
-    uint32_t *tile_list = (uint32_t *)(pvr2_main_ram+tile_entry);
-    int strip_count;
-    struct polygon_struct *poly;
-
-    if( !IS_TILE_PTR(tile_entry) )
-        return;
-
-    while(1) {
-        uint32_t entry = *tile_list++;
-        switch( entry >> 28 ) {
-        case 0x0F:
-            return; // End-of-list
-        case 0x0E:
-            tile_list = (uint32_t *)(pvr2_main_ram + (entry&0x007FFFFF));
-            break;
-        case 0x08: case 0x09: case 0x0A: case 0x0B:
-            strip_count = ((entry >> 25) & 0x0F)+1;
-            poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];
-            while( strip_count > 0 ) {
-                assert( poly != NULL );
-                gl_render_poly( poly, set_depth );
-                poly = poly->next;
-                strip_count--;
-            }
-            break;
-        default:
-            if( entry & 0x7E000000 ) {
-                poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];
-                gl_render_poly( poly, set_depth );
-            }
-        }
-    }       
-}
-
-/**
- * Render the tilelist with depthbuffer updates only. 
- */
-void gl_render_tilelist_depthonly( pvraddr_t tile_entry )
-{
-    uint32_t *tile_list = (uint32_t *)(pvr2_main_ram+tile_entry);
-    int strip_count;
-    struct polygon_struct *poly;
-    
-    if( !IS_TILE_PTR(tile_entry) )
-        return;
-
-    while(1) {
-        uint32_t entry = *tile_list++;
-        switch( entry >> 28 ) {
-        case 0x0F:
-            return; // End-of-list
-        case 0x0E:
-            tile_list = (uint32_t *)(pvr2_main_ram + (entry&0x007FFFFF));
-            break;
-        case 0x08: case 0x09: case 0x0A: case 0x0B:
-            strip_count = ((entry >> 25) & 0x0F)+1;
-            poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];
-            while( strip_count > 0 ) {
-                if( poly->vertex_count != 0 ) {
-                    render_set_base_context(poly->context[0],TRUE);
-                    gl_draw_vertexes(poly);
-                }
-                poly = poly->next;
-                strip_count--;
-            }
-            break;
-        default:
-            if( entry & 0x7E000000 ) {
-                poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];
-                if( poly->vertex_count != 0 ) {
-                    render_set_base_context(poly->context[0],TRUE);
-                    gl_draw_vertexes(poly);
-                }
-            }
-        }
-    }           
-}
-
-static void drawrect2d( uint32_t tile_bounds[], float z )
-{
-    glBegin( GL_QUADS );
-    glVertex3f( tile_bounds[0], tile_bounds[2], z );
-    glVertex3f( tile_bounds[1], tile_bounds[2], z );
-    glVertex3f( tile_bounds[1], tile_bounds[3], z );
-    glVertex3f( tile_bounds[0], tile_bounds[3], z );
-    glEnd();
-}
-
-void gl_render_modifier_polygon( struct polygon_struct *poly, uint32_t tile_bounds[] )
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+static void gl_render_modifier_polygon( struct polygon_struct *poly, uint32_t tile_bounds[] )
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > {
     /* A bit of explanation:
      * In theory it works like this: generate a 1-bit stencil for each polygon
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -405,55 +317,79 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     }
 }
 
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-void gl_render_modifier_tilelist( pvraddr_t tile_entry, uint32_t tile_bounds[] )
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+static void gl_render_bkgnd( struct polygon_struct *poly )
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > {
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-    uint32_t *tile_list = (uint32_t *)(pvr2_main_ram+tile_entry);
-    int strip_count;
-    struct polygon_struct *poly;
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    glBindTexture(GL_TEXTURE_2D, poly->tex_id);
+    render_set_tsp_context( poly->context[0], poly->context[1] );
+    glDisable( GL_DEPTH_TEST );
+    glBlendFunc( GL_ONE, GL_ZERO );
+    gl_draw_vertexes(poly);
+    glEnable( GL_DEPTH_TEST );
+}
+
+void gl_render_tilelist( pvraddr_t tile_entry, gboolean set_depth )
+{
+    tileentryiter list;
+
+    FOREACH_TILEENTRY(list, tile_entry) {
+        struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[TILEENTRYITER_POLYADDR(list)];
+        if( poly != NULL ) {
+            do {
+                gl_render_poly(poly, set_depth);
+                poly = poly->next;
+            } while( list.strip_count-- > 0 );
+        }
+    }
+}
+
+/**
+ * Render the tilelist with depthbuffer updates only.
+ */
+static void gl_render_tilelist_depthonly( pvraddr_t tile_entry )
+{
+    tileentryiter list;
+
+    FOREACH_TILEENTRY(list, tile_entry) {
+        struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[TILEENTRYITER_POLYADDR(list)];
+        if( poly != NULL ) {
+            do {
+                render_set_base_context(poly->context[0],TRUE);
+                gl_draw_vertexes(poly);
+                poly = poly->next;
+            } while( list.strip_count-- > 0 );
+        }
+    }
+}
+
+static void gl_render_modifier_tilelist( pvraddr_t tile_entry, uint32_t tile_bounds[] )
+{
+    tileentryiter list;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
     if( !IS_TILE_PTR(tile_entry) )
         return;
 
     glEnable( GL_STENCIL_TEST );
     glEnable( GL_DEPTH_TEST );
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-    glDepthFunc( GL_LEQUAL );
-    
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     glStencilFunc( GL_ALWAYS, 0, 1 );
     glStencilOp( GL_KEEP,GL_INVERT, GL_KEEP ); 
     glStencilMask( 0x01 );
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    glDepthFunc( GL_LEQUAL );
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     glDepthMask( GL_FALSE );
     
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-    while(1) {
-        uint32_t entry = *tile_list++;
-        switch( entry >> 28 ) {
-        case 0x0F:
-            glDepthMask( GL_TRUE );
-            glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
-            glDisable( GL_STENCIL_TEST );
-            return; // End-of-list
-        case 0x0E:
-            tile_list = (uint32_t *)(pvr2_main_ram + (entry&0x007FFFFF));
-            break;
-        case 0x08: case 0x09: case 0x0A: case 0x0B:
-            strip_count = ((entry >> 25) & 0x0F)+1;
-            poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];
-            while( strip_count > 0 ) {
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    FOREACH_TILEENTRY(list, tile_entry ) {
+        struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[TILEENTRYITER_POLYADDR(list)];
+        if( poly != NULL ) {
+            do {
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >                 gl_render_modifier_polygon( poly, tile_bounds );
                 poly = poly->next;
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-                strip_count--;
-            }
-            break;
-        default:
-            if( entry & 0x7E000000 ) {
-                poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];
-                gl_render_modifier_polygon( poly, tile_bounds );
-            }
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+            } while( list.strip_count-- > 0 );
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >         }
     }
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-    
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    glDepthMask( GL_TRUE );
+    glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
+    glDisable( GL_STENCIL_TEST );
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > }
 
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > /**
  * Render the currently defined scene in pvr2_scene
  */
</pre></div>
<hr /><a name="file4" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src/pvr2</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>pvr2.h</b></big> <small id="info" style="color: #888888;" >00dd49743974 -> 45674791c6ad</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/pvr2/pvr2.h
+++ lxdream/src/pvr2/pvr2.h
@@ -21,7 +21,6 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
 #include <stdio.h>
 #include "lxdream.h"
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-#include "mem.h"
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > #include "display.h"
 
 #ifdef __cplusplus
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -431,6 +430,11 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     pvraddr_t punchout_ptr;
 };
 
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+
+struct tile_bounds {
+    int32_t x1, y1, x2, y2;
+};
+
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > #ifdef __cplusplus
 }
 #endif
</pre></div>
<hr /><a name="file5" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src/pvr2</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>tacore.c</b></big> <small id="info" style="color: #888888;" >00dd49743974 -> 45674791c6ad</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/pvr2/tacore.c
+++ lxdream/src/pvr2/tacore.c
@@ -126,10 +126,6 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     uint32_t detail[8]; /* 0-8 detail words */
 };
 
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-struct tile_bounds {
-    int32_t x1, y1, x2, y2;
-};
-
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > struct pvr2_ta_status {
     int32_t state;
     int32_t width, height; /* Tile resolution, ie 20x15 */
</pre></div>
<hr /><a name="file6" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span id="added" class="pathname" style="font-family:monospace; float:right; background-color:#ddffdd;" >lxdream/src/pvr2</span><br />
<div id="added" class="fileheader" style="margin-bottom:.5em; background-color:#ddffdd;" ><big><b>tileiter.h</b></big> <small id="info" style="color: #888888;" >added at 45674791c6ad</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/pvr2/tileiter.h
+++ lxdream/src/pvr2/tileiter.h
@@ -0,0 +1,197 @@
</small></pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+/**
+ * $Id$
+ *
+ * Tile iterator ADT. Defines an iterator that can be used to iterate through
+ * a PVR2 tile list a polygon at a time.
+ *
+ * Note: The iterator functions are defined here to allow the compiler to
+ * inline them if it wants to, but it's not always beneficial to do so
+ * (hence we don't force them to be inlined)
+ *
+ * Copyright (c) 2010 Nathan Keynes.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef lxdream_tileiter_H
+#define lxdream_tileiter_H 1
+
+#include <assert.h>
+#include "pvr2/pvr2.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * tileiter: iterator over individual polygons in a tile list.
+ */
+typedef struct tileiter {
+    uint32_t *ptr;
+    unsigned strip_count;
+    unsigned poly_size;
+    uint32_t poly_addr;
+} tileiter;
+
+
+#define TILEITER_IS_MODIFIED(it) ((*(it).ptr) & 0x01000000)
+#define TILEITER_IS_TRIANGLE(it) (((*(it).ptr) >> 29) == 4)
+#define TILEITER_IS_QUAD(it) (((*(it).ptr) >> 29) == 5)
+#define TILEITER_IS_POLY(it) (((*(it).ptr) >> 31) == 0)
+
+#define TILEITER_POLYADDR(it) ((it).poly_addr)
+#define TILEITER_STRIPCOUNT(it) ((it).strip_count)
+#define TILEITER_DONE(it) ((it).ptr == 0)
+#define TILEITER_BEGIN(it, tileent) (tileiter_init(&it, tileent))
+#define TILEITER_NEXT(it) (tileiter_next(&it))
+#define FOREACH_TILE(it, seg) for( TILEITER_BEGIN(it, seg); !TILEITER_DONE(it); TILEITER_NEXT(it) )
+
+
+/**
+ * tileentryiter: iterator over entries in the tile list, where each entry is
+ * a polygon, triangle set, or quad set.
+ */
+typedef struct tileentryiter {
+    uint32_t *ptr;
+    unsigned strip_count;
+} tileentryiter;
+
+#define TILEENTRYITER_POLYADDR(it) ((*((it).ptr)) & 0x001FFFFF)
+#define TILEENTRYITER_STRIPCOUNT(it) ((it).strip_count)
+#define TILEENTRYITER_DONE(it) ((it).ptr == 0)
+#define TILEENTRYITER_BEGIN(it, tileent) (tileentryiter_init(&(it),tileent))
+#define TILEENTRYITER_NEXT(it) (tileentryiter_next(&(it)))
+#define FOREACH_TILEENTRY(it,seg) for( TILEENTRYITER_BEGIN(it,seg); !TILEENTRYITER_DONE(it); TILEENTRYITER_NEXT(it) )
+
+/**************************** tileiter functions ****************************/
+
+/**
+ * Read the entry pointed to by it->ptr into the tileiter structure. If the
+ * entry if a list pointer or invalid entry, the pointer will first be
+ * updated to the next real entry. On end-of-list, sets ptr to NULL
+ */
+static void tileiter_read( tileiter *it )
+{
+    for(;;){
+        uint32_t entry = *it->ptr;
+        uint32_t tag = entry >> 29;
+        if( tag == 0x07 ) {
+            if( tag & 0x10000000 ) {
+                it->ptr = NULL;
+                return;
+            } else {
+                it->ptr = (uint32_t *)(pvr2_main_ram + (entry&0x007FFFFF));
+                it->poly_addr = -1;
+                entry = *it->ptr;
+            }
+        } else if( tag == 6 ) {
+            /* Illegal? Skip */
+            it->ptr++;
+        } else if( tag & 0x04 ) {
+            int vertex_count = tag-1; /* 4 == tri, 5 == quad */
+            int vertex_length = (entry >> 21) & 0x07;
+            if( (entry & 0x01000000) && (pvr2_scene.shadow_mode == SHADOW_FULL) ) {
+                it->poly_size = 5 + (vertex_length<<1) * vertex_count;
+            } else {
+                it->poly_size = 3 + vertex_length * vertex_count;
+            }
+            it->strip_count = ((entry >> 25) & 0x0F);
+            it->poly_addr = entry & 0x001FFFFF;
+            return;
+        } else {
+            /* Other polygon */
+            it->strip_count = 0;
+            it->poly_addr = entry & 0x001FFFFF;
+            return;
+        }
+    }
+}
+
+static void tileiter_init( tileiter *it, uint32_t segptr )
+{
+    if( IS_TILE_PTR(segptr) ) {
+        it->ptr = (uint32_t *)(pvr2_main_ram + (segptr & 0x007FFFFF));
+        tileiter_read(it);
+    } else {
+        it->ptr = 0;
+    }
+}
+
+static inline void tileiter_next( tileiter *it )
+{
+    assert( it->ptr != NULL );
+    if( it->strip_count > 0 ) {
+        it->strip_count--;
+        it->poly_addr += it->poly_size;
+    } else {
+        it->ptr++;
+        tileiter_read(it);
+    }
+}
+
+
+/************************* tileentryiter functions **************************/
+
+/**
+ * Read the entry pointed to by it->ptr, updating the pointer to point
+ * to the next real element if the current value is not a polygon entry.
+ */
+static void tileentryiter_read( tileentryiter *it )
+{
+    for(;;){
+        uint32_t entry = *it->ptr;
+        uint32_t tag = entry >> 28;
+        if( tag < 0x0C ) {
+            if( tag & 0x08 ) {
+                it->strip_count = ((entry >> 25) & 0x0F);
+            } else {
+                it->strip_count = 0;
+            }
+            return;
+        } else {
+            if( tag == 0x0F ) {
+                it->ptr = NULL;
+                return;
+            } else if( tag == 0x0E ) {
+                it->ptr = (uint32_t *)(pvr2_main_ram + (entry&0x007FFFFF));
+                entry = *it->ptr;
+            } else {
+                /* Illegal? Skip */
+                it->ptr++;
+            }
+        }
+    }
+}
+
+
+static void tileentryiter_init( tileentryiter *it, uint32_t segptr )
+{
+    if( IS_TILE_PTR(segptr) ) {
+        it->ptr = (uint32_t *)(pvr2_main_ram + (segptr & 0x007FFFFF));
+        tileentryiter_read(it);
+    } else {
+        it->ptr = 0;
+    }
+}
+
+static void inline tileentryiter_next( tileentryiter *it )
+{
+    it->ptr++;
+    tileentryiter_read(it);
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !lxdream_tileiter_H */
</pre></div>
<center><small>Chaos Theory</small></center>
</div></body></html>