psx_gpu: some argument checks
authorExophase <exophase@gmail.com>
Fri, 23 Dec 2011 16:51:42 +0000 (18:51 +0200)
committernotaz <notasas@gmail.com>
Fri, 23 Dec 2011 16:51:42 +0000 (18:51 +0200)
plugins/gpu_neon/psx_gpu/psx_gpu.c
plugins/gpu_neon/psx_gpu/psx_gpu_parse.c

index 5c49b22..49e8c8b 100644 (file)
@@ -3767,7 +3767,7 @@ void render_sprite(psx_gpu_struct *psx_gpu, s32 x, s32 y, u32 u, u32 v,
    RENDER_FLAGS_TEXTURE_MAP);
   render_state |=
    (psx_gpu->render_state_base & ~RENDER_STATE_DITHER);
    RENDER_FLAGS_TEXTURE_MAP);
   render_state |=
    (psx_gpu->render_state_base & ~RENDER_STATE_DITHER);
-  
+
   if((psx_gpu->render_state != render_state) ||
    (psx_gpu->primitive_type != PRIMITIVE_TYPE_SPRITE))
   {
   if((psx_gpu->render_state != render_state) ||
    (psx_gpu->primitive_type != PRIMITIVE_TYPE_SPRITE))
   {
@@ -4316,6 +4316,9 @@ void render_line(psx_gpu_struct *psx_gpu, vertex_struct *vertexes, u32 flags,
 void render_block_fill(psx_gpu_struct *psx_gpu, u32 color, u32 x, u32 y,
  u32 width, u32 height)
 {
 void render_block_fill(psx_gpu_struct *psx_gpu, u32 color, u32 x, u32 y,
  u32 width, u32 height)
 {
+  if((width == 0) || (height == 0))
+    return;
+
   invalidate_texture_cache_region(psx_gpu, x, y, x + width - 1, y + height - 1);
 
 #ifndef NEON_BUILD
   invalidate_texture_cache_region(psx_gpu, x, y, x + width - 1, y + height - 1);
 
 #ifndef NEON_BUILD
@@ -4350,6 +4353,9 @@ void render_block_copy(psx_gpu_struct *psx_gpu, u16 *source, u32 x, u32 y,
   u16 *vram_ptr = psx_gpu->vram_ptr + x + (y * 1024);
   u32 draw_x, draw_y;
 
   u16 *vram_ptr = psx_gpu->vram_ptr + x + (y * 1024);
   u32 draw_x, draw_y;
 
+  if((width == 0) || (height == 0))
+    return;
+
   invalidate_texture_cache_region(psx_gpu, x, y, x + width - 1, y + height - 1);
 
   for(draw_y = 0; draw_y < height; draw_y++)
   invalidate_texture_cache_region(psx_gpu, x, y, x + width - 1, y + height - 1);
 
   for(draw_y = 0; draw_y < height; draw_y++)
index dc7a6c1..32895e1 100644 (file)
@@ -210,8 +210,8 @@ void gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size)
                        break;
   
                case 0x02:
                        break;
   
                case 0x02:
-        render_block_fill(psx_gpu, list[0] & 0xFFFFFF, list_s16[2], list_s16[3],
-         list_s16[4] & 0x3FF, list_s16[5] & 0x3FF);
+        render_block_fill(psx_gpu, list[0] & 0xFFFFFF, list_s16[2] & 0x3FF,
+         list_s16[3] & 0x1FF, list_s16[4] & 0x3FF, list_s16[5] & 0x1FF);
                        break;
   
                case 0x20 ... 0x23:
                        break;
   
                case 0x20 ... 0x23:
@@ -532,10 +532,10 @@ void gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size)
   
                case 0xA0:          //  sys -> vid
       {
   
                case 0xA0:          //  sys -> vid
       {
-        u32 load_x = list_s16[2];
-        u32 load_y = list_s16[3];
-        u32 load_width = list_s16[4];
-        u32 load_height = list_s16[5];
+        u32 load_x = list_s16[2] & 0x3FF;
+        u32 load_y = list_s16[3] & 0x1FF;
+        u32 load_width = list_s16[4] & 0x3FF;
+        u32 load_height = list_s16[5] & 0x1FF;
         u32 load_size = load_width * load_height;
   
         command_length += load_size / 2;
         u32 load_size = load_width * load_height;
   
         command_length += load_size / 2;