psx_gpu: add a tool to generate asm offsets
authornotaz <notasas@gmail.com>
Sat, 11 Aug 2012 15:34:13 +0000 (18:34 +0300)
committernotaz <notasas@gmail.com>
Thu, 11 Oct 2012 21:05:07 +0000 (00:05 +0300)
plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.S
plugins/gpu_neon/psx_gpu/psx_gpu_offsets.h [new file with mode: 0644]
plugins/gpu_neon/psx_gpu/psx_gpu_offsets_update.c [new file with mode: 0644]

index 3331d5d..79d5466 100644 (file)
 #define MAX_BLOCKS                                        64
 #define MAX_BLOCKS_PER_ROW                                128
 
-#define psx_gpu_test_mask_offset                          0
-#define psx_gpu_uvrg_offset                               16
-#define psx_gpu_uvrg_dx_offset                            32
-#define psx_gpu_uvrg_dy_offset                            48
-#define psx_gpu_u_block_span_offset                       64
-#define psx_gpu_v_block_span_offset                       80
-#define psx_gpu_r_block_span_offset                       96
-#define psx_gpu_g_block_span_offset                       112
-#define psx_gpu_b_block_span_offset                       128
-
-#define psx_gpu_b_dx_offset                               132
-
-#define psx_gpu_b_offset                                  144
-#define psx_gpu_b_dy_offset                               148
-#define psx_gpu_triangle_area_offset                      152
-#define psx_gpu_texture_window_settings_offset            156
-#define psx_gpu_current_texture_mask_offset               160
-#define psx_gpu_viewport_mask_offset                      164
-#define psx_gpu_dirty_textures_4bpp_mask_offset           168
-#define psx_gpu_dirty_textures_8bpp_mask_offset           172
-#define psx_gpu_dirty_textures_8bpp_alternate_mask_offset 176
-#define psx_gpu_triangle_color_offset                     180
-#define psx_gpu_dither_table_offset                       184
-#define psx_gpu_render_block_handler_offset               200
-#define psx_gpu_texture_page_ptr_offset                   204
-#define psx_gpu_texture_page_base_offset                  208
-#define psx_gpu_clut_ptr_offset                           212
-#define psx_gpu_vram_ptr_offset                           216
-
-#define psx_gpu_render_state_base_offset                  220
-#define psx_gpu_render_state_offset                       222
-#define psx_gpu_num_spans_offset                          224
-#define psx_gpu_num_blocks_offset                         226
-#define psx_gpu_offset_x_offset                           228
-#define psx_gpu_offset_y_offset                           230
-#define psx_gpu_clut_settings_offset                      232
-#define psx_gpu_texture_settings_offset                   234
-#define psx_gpu_viewport_start_x_offset                   236
-#define psx_gpu_viewport_start_y_offset                   238
-#define psx_gpu_viewport_end_x_offset                     240
-#define psx_gpu_viewport_end_y_offset                     242
-#define psx_gpu_mask_msb_offset                           244
-                                                          
-#define psx_gpu_triangle_winding_offset                   246
-#define psx_gpu_display_area_draw_enable_offset           247
-#define psx_gpu_current_texture_page_offset               248
-#define psx_gpu_last_8bpp_texture_page_offset             249
-#define psx_gpu_texture_mask_width_offset                 250
-#define psx_gpu_texture_mask_height_offset                251
-#define psx_gpu_texture_window_x_offset                   252
-#define psx_gpu_texture_window_y_offset                   253
-#define psx_gpu_primitive_type_offset                     254
-
-#define psx_gpu_reserved_a_offset                         255
-
-#define psx_gpu_blocks_offset                             0x0100
-#define psx_gpu_span_uvrg_offset_offset                   0x2100
-#define psx_gpu_span_edge_data_offset                     0x4100
-#define psx_gpu_span_b_offset_offset                      0x5100
+#include "psx_gpu_offsets.h"
+
+#define psx_gpu_b_dx_offset (psx_gpu_b_block_span_offset + 4)
 
 #define edge_data_left_x_offset                           0
 #define edge_data_num_blocks_offset                       2
diff --git a/plugins/gpu_neon/psx_gpu/psx_gpu_offsets.h b/plugins/gpu_neon/psx_gpu/psx_gpu_offsets.h
new file mode 100644 (file)
index 0000000..a47d965
--- /dev/null
@@ -0,0 +1,55 @@
+#define psx_gpu_test_mask_offset                          0x0
+#define psx_gpu_uvrg_offset                               0x10
+#define psx_gpu_uvrg_dx_offset                            0x20
+#define psx_gpu_uvrg_dy_offset                            0x30
+#define psx_gpu_u_block_span_offset                       0x40
+#define psx_gpu_v_block_span_offset                       0x50
+#define psx_gpu_r_block_span_offset                       0x60
+#define psx_gpu_g_block_span_offset                       0x70
+#define psx_gpu_b_block_span_offset                       0x80
+#define psx_gpu_b_offset                                  0x90
+#define psx_gpu_b_dy_offset                               0x94
+#define psx_gpu_triangle_area_offset                      0x98
+#define psx_gpu_texture_window_settings_offset            0x9c
+#define psx_gpu_current_texture_mask_offset               0xa0
+#define psx_gpu_viewport_mask_offset                      0xa4
+#define psx_gpu_dirty_textures_4bpp_mask_offset           0xa8
+#define psx_gpu_dirty_textures_8bpp_mask_offset           0xac
+#define psx_gpu_dirty_textures_8bpp_alternate_mask_offset 0xb0
+#define psx_gpu_triangle_color_offset                     0xb4
+#define psx_gpu_dither_table_offset                       0xb8
+#define psx_gpu_render_block_handler_offset               0xc8
+#define psx_gpu_texture_page_ptr_offset                   0xcc
+#define psx_gpu_texture_page_base_offset                  0xd0
+#define psx_gpu_clut_ptr_offset                           0xd4
+#define psx_gpu_vram_ptr_offset                           0xd8
+#define psx_gpu_render_state_base_offset                  0xdc
+#define psx_gpu_render_state_offset                       0xde
+#define psx_gpu_num_spans_offset                          0xe0
+#define psx_gpu_num_blocks_offset                         0xe2
+#define psx_gpu_offset_x_offset                           0xe4
+#define psx_gpu_offset_y_offset                           0xe6
+#define psx_gpu_clut_settings_offset                      0xe8
+#define psx_gpu_texture_settings_offset                   0xea
+#define psx_gpu_viewport_start_x_offset                   0xec
+#define psx_gpu_viewport_start_y_offset                   0xee
+#define psx_gpu_viewport_end_x_offset                     0xf0
+#define psx_gpu_viewport_end_y_offset                     0xf2
+#define psx_gpu_mask_msb_offset                           0xf4
+#define psx_gpu_triangle_winding_offset                   0xf6
+#define psx_gpu_display_area_draw_enable_offset           0xf7
+#define psx_gpu_current_texture_page_offset               0xf8
+#define psx_gpu_last_8bpp_texture_page_offset             0xf9
+#define psx_gpu_texture_mask_width_offset                 0xfa
+#define psx_gpu_texture_mask_height_offset                0xfb
+#define psx_gpu_texture_window_x_offset                   0xfc
+#define psx_gpu_texture_window_y_offset                   0xfd
+#define psx_gpu_primitive_type_offset                     0xfe
+#define psx_gpu_interlace_mode_offset                     0xff
+#define psx_gpu_blocks_offset                             0x100
+#define psx_gpu_span_uvrg_offset_offset                   0x2100
+#define psx_gpu_span_edge_data_offset                     0x4100
+#define psx_gpu_span_b_offset_offset                      0x5100
+#define psx_gpu_texture_4bpp_cache_offset                 0x5900
+#define psx_gpu_texture_8bpp_even_cache_offset            0x205900
+#define psx_gpu_texture_8bpp_odd_cache_offset             0x305900
diff --git a/plugins/gpu_neon/psx_gpu/psx_gpu_offsets_update.c b/plugins/gpu_neon/psx_gpu/psx_gpu_offsets_update.c
new file mode 100644 (file)
index 0000000..2275f59
--- /dev/null
@@ -0,0 +1,84 @@
+#include <stdio.h>
+#include <stddef.h>
+
+#include "common.h"
+
+#define WRITE_OFFSET(f, member) \
+       fprintf(f, "#define %-50s0x%x\n", \
+               "psx_gpu_" #member "_offset", \
+               offsetof(psx_gpu_struct, member));
+
+int main()
+{
+       FILE *f;
+
+       if (sizeof(f) != 4) {
+               fprintf(stderr, "bad pointer size\n");
+               return 1;
+       }
+
+       f = fopen("psx_gpu_offsets.h", "w");
+       if (f == NULL) {
+               perror("fopen");
+               return 1;
+       }
+
+       WRITE_OFFSET(f, test_mask);
+       WRITE_OFFSET(f, uvrg);
+       WRITE_OFFSET(f, uvrg_dx);
+       WRITE_OFFSET(f, uvrg_dy);
+       WRITE_OFFSET(f, u_block_span);
+       WRITE_OFFSET(f, v_block_span);
+       WRITE_OFFSET(f, r_block_span);
+       WRITE_OFFSET(f, g_block_span);
+       WRITE_OFFSET(f, b_block_span);
+       WRITE_OFFSET(f, b);
+       WRITE_OFFSET(f, b_dy);
+       WRITE_OFFSET(f, triangle_area);
+       WRITE_OFFSET(f, texture_window_settings);
+       WRITE_OFFSET(f, current_texture_mask);
+       WRITE_OFFSET(f, viewport_mask);
+       WRITE_OFFSET(f, dirty_textures_4bpp_mask);
+       WRITE_OFFSET(f, dirty_textures_8bpp_mask);
+       WRITE_OFFSET(f, dirty_textures_8bpp_alternate_mask);
+       WRITE_OFFSET(f, triangle_color);
+       WRITE_OFFSET(f, dither_table);
+       WRITE_OFFSET(f, render_block_handler);
+       WRITE_OFFSET(f, texture_page_ptr);
+       WRITE_OFFSET(f, texture_page_base);
+       WRITE_OFFSET(f, clut_ptr);
+       WRITE_OFFSET(f, vram_ptr);
+       WRITE_OFFSET(f, render_state_base);
+       WRITE_OFFSET(f, render_state);
+       WRITE_OFFSET(f, num_spans);
+       WRITE_OFFSET(f, num_blocks);
+       WRITE_OFFSET(f, offset_x);
+       WRITE_OFFSET(f, offset_y);
+       WRITE_OFFSET(f, clut_settings);
+       WRITE_OFFSET(f, texture_settings);
+       WRITE_OFFSET(f, viewport_start_x);
+       WRITE_OFFSET(f, viewport_start_y);
+       WRITE_OFFSET(f, viewport_end_x);
+       WRITE_OFFSET(f, viewport_end_y);
+       WRITE_OFFSET(f, mask_msb);
+       WRITE_OFFSET(f, triangle_winding);
+       WRITE_OFFSET(f, display_area_draw_enable);
+       WRITE_OFFSET(f, current_texture_page);
+       WRITE_OFFSET(f, last_8bpp_texture_page);
+       WRITE_OFFSET(f, texture_mask_width);
+       WRITE_OFFSET(f, texture_mask_height);
+       WRITE_OFFSET(f, texture_window_x);
+       WRITE_OFFSET(f, texture_window_y);
+       WRITE_OFFSET(f, primitive_type);
+       WRITE_OFFSET(f, interlace_mode);
+       WRITE_OFFSET(f, blocks);
+       WRITE_OFFSET(f, span_uvrg_offset);
+       WRITE_OFFSET(f, span_edge_data);
+       WRITE_OFFSET(f, span_b_offset);
+       WRITE_OFFSET(f, texture_4bpp_cache);
+       WRITE_OFFSET(f, texture_8bpp_even_cache);
+       WRITE_OFFSET(f, texture_8bpp_odd_cache);
+       fclose(f);
+
+       return 0;
+}