diff --git a/sega/dreamcast/MemoryMap.java b/sega/dreamcast/MemoryMap.java new file mode 100644 index 0000000..125984b --- /dev/null +++ b/sega/dreamcast/MemoryMap.java @@ -0,0 +1,31 @@ +package sega.dreamcast; + +public class MemoryMap { + public static final int system_boot_rom = -1610612736; // 0xa0000000 + public static final int system = -1604360192; // 0xa05f6800 + public static final int maple_if = -1604359168; // 0xa05f6c00 + public static final int gdrom_if = -1604358144; // 0xa05f7000 + public static final int g1_if = -1604357120; // 0xa05f7400 + public static final int g2_if = -1604356096; // 0xa05f7800 + public static final int pvr_if = -1604355072; // 0xa05f7c00 + public static final int holly = -1604354048; // 0xa05f8000 + public static final int modem = -1604321280; // 0xa0600000 + public static final int aica_sound = -1603272704; // 0xa0700000 + public static final int aica_rtc = -1603207168; // 0xa0710000 + public static final int aica_wave_memory = -1602224128; // 0xa0800000 + public static final int texture_memory64 = -1543503872; // 0xa4000000 + public static final int texture_memory32 = -1526726656; // 0xa5000000 + public static final int system_memory = -1409286144; // 0xac000000 + public static final int ta_fifo_polygon_converter = 268435456; // 0x10000000 + public static final int ta_fifo_yuv_converter = 276824064; // 0x10800000 + public static final int ta_fifo_texture_memory = 285212672; // 0x11000000 + public static final int ta_fifo_polygon_converter_mirror = 301989888; // 0x12000000 + public static final int ta_fifo_yuv_converter_mirror = 310378496; // 0x12800000 + public static final int ta_fifo_texture_memory_mirror = 318767104; // 0x13000000 + public static final int store_queue = -536870912; // 0xe0000000 + public static final int sh7091_ic_a = -268435456; // 0xf0000000 + public static final int sh7091_ic_d = -251658240; // 0xf1000000 + public static final int sh7091_oc_a = -201326592; // 0xf4000000 + public static final int sh7091_oc_d = -184549376; // 0xf5000000 + public static final int sh7091 = -16777216; // 0xff000000 +} diff --git a/sega/dreamcast/holly/Background.java b/sega/dreamcast/holly/Background.java new file mode 100644 index 0000000..253a532 --- /dev/null +++ b/sega/dreamcast/holly/Background.java @@ -0,0 +1,44 @@ +package sega.dreamcast.holly; + +import sega.dreamcast.MemoryMap; +import sega.dreamcast.holly.ISPTSP; +import java.misc.Memory; + +public class Background { + private Background() { + } + + public static void background(int background_start, + int base_color) + { + int isp_tsp_instruction_word = + ISPTSP.isp_tsp_instruction_word__depth_compare_mode__always + | ISPTSP.isp_tsp_instruction_word__culling_mode__no_culling; + + int tsp_instruction_word = + ISPTSP.tsp_instruction_word__src_alpha_instr__one + | ISPTSP.tsp_instruction_word__dst_alpha_instr__zero + | ISPTSP.tsp_instruction_word__fog_control__no_fog; + + int texture_control_word = 0; + + int vertex_x = 0; + int vertex_y = 0; + int vertex_z = 0x37c00000; // 0.00002 + + int parameter = MemoryMap.texture_memory32 + background_start; + + Memory.putU4(parameter + 0, isp_tsp_instruction_word); + Memory.putU4(parameter + 4, tsp_instruction_word); + Memory.putU4(parameter + 8, texture_control_word); + + int vertex = parameter + 12; + for (int i = 0; i < 3; i++) { + Memory.putU4(vertex + 0, vertex_x); + Memory.putU4(vertex + 4, vertex_y); + Memory.putU4(vertex + 8, vertex_z); + Memory.putU4(vertex + 12, base_color); + vertex += 16; + } + } +} diff --git a/sega/dreamcast/holly/Core.java b/sega/dreamcast/holly/Core.java new file mode 100644 index 0000000..85a5266 --- /dev/null +++ b/sega/dreamcast/holly/Core.java @@ -0,0 +1,79 @@ +package sega.dreamcast.holly; + +import sega.dreamcast.holly.Holly; +import sega.dreamcast.holly.CoreBits; +import java.misc.Memory; + +public class Core { + private Core() { + } + + public static void init() { + int fb_w_ctrl = CoreBits.fb_w_ctrl__fb_dither + | CoreBits.fb_w_ctrl__fb_packmode__565_rgb_16bit; + + int fpu_cull_val = 0x3f800000; // 1.0f + + int fpu_perp_val = 0; // 0.0f + + int fpu_param_cfg = CoreBits.fpu_param_cfg__region_header_type__type_2 + | CoreBits.fpu_param_cfg__tsp_parameter_burst_threshold(31) + | CoreBits.fpu_param_cfg__isp_parameter_burst_threshold(31) + | CoreBits.fpu_param_cfg__pointer_burst_size(15) + | CoreBits.fpu_param_cfg__pointer_first_burst_size(7); + + int half_offset = CoreBits.half_offset__tsp_texel_sampling_position__center + | CoreBits.half_offset__tsp_pixel_sampling_position__center + | CoreBits.half_offset__fpu_pixel_sampling_position__center; + + int isp_feed_cfg = CoreBits.isp_feed_cfg__cache_size_for_translucency(0x200) + | CoreBits.isp_feed_cfg__punch_through_chunk_size(0x040); + + int span_sort_cfg = CoreBits.span_sort_cfg__span_sort_enable + | CoreBits.span_sort_cfg__offset_sort_enable; + + int softreset = CoreBits.softreset__pipeline_soft_reset + | CoreBits.softreset__ta_soft_reset; + + Memory.putU4(Holly.FB_W_CTRL, fb_w_ctrl); + Memory.putU4(Holly.FPU_CULL_VAL, fpu_cull_val); + Memory.putU4(Holly.FPU_PERP_VAL, fpu_perp_val); + Memory.putU4(Holly.FPU_PARAM_CFG, fpu_param_cfg); + Memory.putU4(Holly.HALF_OFFSET, half_offset); + Memory.putU4(Holly.ISP_FEED_CFG, isp_feed_cfg); + Memory.putU4(Holly.SPAN_SORT_CFG, span_sort_cfg); + + Memory.putU4(Holly.SOFTRESET, softreset); + Memory.putU4(Holly.SOFTRESET, 0); + } + + public static void start_render(int region_array_start, + int isp_tsp_parameters_start, + int background_start, + int frame_address, // in pixels + int frame_width // in pixels + ) + { + int background_offset = background_start - isp_tsp_parameters_start; + + int isp_backgnd_t = CoreBits.isp_backgnd_t__tag_address(background_offset / 4) + | CoreBits.isp_backgnd_t__tag_offset(0) + | CoreBits.isp_backgnd_t__skip(1); + + int isp_backgnd_d = 0x37c00000; // 0.00002 + + int bytes_per_pixel = 2; + int fb_w_linestride = (frame_width * bytes_per_pixel) >> 3; + + Memory.putU4(Holly.ISP_BACKGND_T, isp_backgnd_t); + Memory.putU4(Holly.ISP_BACKGND_D, isp_backgnd_d); + + Memory.putU4(Holly.REGION_BASE, region_array_start); + Memory.putU4(Holly.PARAM_BASE, isp_tsp_parameters_start); + + Memory.putU4(Holly.FB_W_LINESTRIDE, fb_w_linestride); + Memory.putU4(Holly.FB_W_SOF1, frame_address); + + Memory.putU4(Holly.STARTRENDER, 1); + } +} diff --git a/sega/dreamcast/holly/CoreBits.java b/sega/dreamcast/holly/CoreBits.java index 0b1b08f..fd2714f 100644 --- a/sega/dreamcast/holly/CoreBits.java +++ b/sega/dreamcast/holly/CoreBits.java @@ -41,9 +41,7 @@ public class CoreBits { public static int vo_border_col__blue(int n) { return (n & 255) << 0; } - public static int fb_r_ctrl__vclk_div__pclk_vclk_2(int n) { - return (n >> 23) & 1; - } + public static final int fb_r_ctrl__vclk_div__pclk_vclk_2 = 0 << 23; public static final int fb_r_ctrl__vclk_div__pclk_vclk_1 = 1 << 23; public static final int fb_r_ctrl__fb_strip_buf_en = 1 << 22; public static int fb_r_ctrl__fb_stripsize(int n) { @@ -57,9 +55,7 @@ public class CoreBits { } public static final int fb_r_ctrl__fb_line_double = 1 << 1; public static final int fb_r_ctrl__fb_enable = 1 << 0; - public static int fb_r_ctrl__fb_depth__0555_rgb_16bit(int n) { - return (n >> 2) & 3; - } + public static final int fb_r_ctrl__fb_depth__0555_rgb_16bit = 0 << 2; public static final int fb_r_ctrl__fb_depth__565_rgb_16bit = 1 << 2; public static final int fb_r_ctrl__fb_depth__888_rgb_24bit_packed = 2 << 2; public static final int fb_r_ctrl__fb_depth__0888_rgb_32bit = 3 << 2; @@ -70,9 +66,7 @@ public class CoreBits { return (n & 255) << 8; } public static final int fb_w_ctrl__fb_dither = 1 << 3; - public static int fb_w_ctrl__fb_packmode__0555_krgb_16bit(int n) { - return (n >> 0) & 7; - } + public static final int fb_w_ctrl__fb_packmode__0555_krgb_16bit = 0 << 0; public static final int fb_w_ctrl__fb_packmode__565_rgb_16bit = 1 << 0; public static final int fb_w_ctrl__fb_packmode__4444_argb_16bit = 2 << 0; public static final int fb_w_ctrl__fb_packmode__1555_argb_16bit = 3 << 0; @@ -115,9 +109,7 @@ public class CoreBits { public static int fb_y_clip__fb_y_clip_min(int n) { return (n & 1023) << 0; } - public static int fpu_shad_scale__simple_shadow_enable__parameter_selection_volume_mode(int n) { - return (n >> 8) & 1; - } + public static final int fpu_shad_scale__simple_shadow_enable__parameter_selection_volume_mode = 0 << 8; public static final int fpu_shad_scale__simple_shadow_enable__intensity_volume_mode = 1 << 8; public static int fpu_shad_scale__scale_factor_for_shadows(int n) { return (n & 255) << 0; @@ -125,9 +117,7 @@ public class CoreBits { public static int fpu_cull_val__culling_comparison_value(int n) { return (n & 2147483647) << 0; } - public static int fpu_param_cfg__region_header_type__type_1(int n) { - return (n >> 21) & 1; - } + public static final int fpu_param_cfg__region_header_type__type_1 = 0 << 21; public static final int fpu_param_cfg__region_header_type__type_2 = 1 << 21; public static int fpu_param_cfg__tsp_parameter_burst_threshold(int n) { return (n & 63) << 14; @@ -175,9 +165,7 @@ public class CoreBits { public static int sdram_refresh__refresh_counter_value(int n) { return (n & 255) << 0; } - public static int sdram_arb_cfg__override_value__priority_only(int n) { - return (n >> 18) & 15; - } + public static final int sdram_arb_cfg__override_value__priority_only = 0 << 18; public static final int sdram_arb_cfg__override_value__rendered_data = 1 << 18; public static final int sdram_arb_cfg__override_value__texture_vq_index = 2 << 18; public static final int sdram_arb_cfg__override_value__texture_normal_data_and_vq_codebook = 3 << 18; @@ -189,9 +177,7 @@ public class CoreBits { public static final int sdram_arb_cfg__override_value__isp_pointer_data = 9 << 18; public static final int sdram_arb_cfg__override_value__isp_parameters = 10 << 18; public static final int sdram_arb_cfg__override_value__crt_controller = 11 << 18; - public static int sdram_arb_cfg__arbiter_priority_control__priority_arbitration_only(int n) { - return (n >> 16) & 3; - } + public static final int sdram_arb_cfg__arbiter_priority_control__priority_arbitration_only = 0 << 16; public static final int sdram_arb_cfg__arbiter_priority_control__override_value_field = 1 << 16; public static final int sdram_arb_cfg__arbiter_priority_control__round_robin_counter = 2 << 16; public static int sdram_arb_cfg__arbiter_crt_page_break_latency_count_value(int n) { @@ -290,9 +276,7 @@ public class CoreBits { public static int spg_hblank_int__line_comp_val(int n) { return (n & 1023) << 0; } - public static int spg_hblank_int__hblank_int_mode__output_equal_line_comp_val(int n) { - return (n >> 12) & 3; - } + public static final int spg_hblank_int__hblank_int_mode__output_equal_line_comp_val = 0 << 12; public static final int spg_hblank_int__hblank_int_mode__output_every_line_comp_val = 1 << 12; public static final int spg_hblank_int__hblank_int_mode__output_every_line = 2 << 12; public static int spg_vblank_int__vblank_out_interrupt_line_number(int n) { @@ -301,30 +285,20 @@ public class CoreBits { public static int spg_vblank_int__vblank_in_interrupt_line_number(int n) { return (n & 1023) << 0; } - public static int spg_control__csync_on_h__hsync(int n) { - return (n >> 9) & 1; - } + public static final int spg_control__csync_on_h__hsync = 0 << 9; public static final int spg_control__csync_on_h__csync = 1 << 9; - public static int spg_control__sync_direction__input(int n) { - return (n >> 8) & 1; - } + public static final int spg_control__sync_direction__input = 0 << 8; public static final int spg_control__sync_direction__output = 1 << 8; public static final int spg_control__pal = 1 << 7; public static final int spg_control__ntsc = 1 << 6; public static final int spg_control__force_field2 = 1 << 5; public static final int spg_control__interlace = 1 << 4; public static final int spg_control__spg_lock = 1 << 3; - public static int spg_control__mcsync_pol__active_low(int n) { - return (n >> 2) & 1; - } + public static final int spg_control__mcsync_pol__active_low = 0 << 2; public static final int spg_control__mcsync_pol__active_high = 1 << 2; - public static int spg_control__mvsync_pol__active_low(int n) { - return (n >> 1) & 1; - } + public static final int spg_control__mvsync_pol__active_low = 0 << 1; public static final int spg_control__mvsync_pol__active_high = 1 << 1; - public static int spg_control__mhsync_pol__active_low(int n) { - return (n >> 0) & 1; - } + public static final int spg_control__mhsync_pol__active_low = 0 << 0; public static final int spg_control__mhsync_pol__active_high = 1 << 0; public static int spg_hblank__hbend(int n) { return (n & 1023) << 16; @@ -356,13 +330,9 @@ public class CoreBits { public static int spg_width__hswidth(int n) { return (n & 127) << 0; } - public static int text_control__code_book_endian__little_endian(int n) { - return (n >> 17) & 1; - } + public static final int text_control__code_book_endian__little_endian = 0 << 17; public static final int text_control__code_book_endian__big_endian = 1 << 17; - public static int text_control__index_endian__little_endian(int n) { - return (n >> 16) & 1; - } + public static final int text_control__index_endian__little_endian = 0 << 16; public static final int text_control__index_endian__big_endian = 1 << 16; public static int text_control__bank_bit(int n) { return (n & 31) << 8; @@ -376,9 +346,7 @@ public class CoreBits { } public static final int vo_control__pixel_double = 1 << 8; public static final int vo_control__blank_video = 1 << 3; - public static int vo_control__field_mode__use_field_flag_from_spg(int n) { - return (n >> 4) & 15; - } + public static final int vo_control__field_mode__use_field_flag_from_spg = 0 << 4; public static final int vo_control__field_mode__use_inverse_of_field_flag_from_spg = 1 << 4; public static final int vo_control__field_mode__field_1_fixed = 2 << 4; public static final int vo_control__field_mode__field_2_fixed = 3 << 4; @@ -387,17 +355,11 @@ public class CoreBits { public static final int vo_control__field_mode__field_1_when_hsync_becomes_active_in_the_middle_of_the_vsync_active_edge = 6 << 4; public static final int vo_control__field_mode__field_2_when_hsync_becomes_active_in_the_middle_of_the_vsync_active_edge = 7 << 4; public static final int vo_control__field_mode__inverted_at_the_active_edge_of_vsync = 8 << 4; - public static int vo_control__blank_pol__active_low(int n) { - return (n >> 2) & 1; - } + public static final int vo_control__blank_pol__active_low = 0 << 2; public static final int vo_control__blank_pol__active_high = 1 << 2; - public static int vo_control__vsync_pol__active_low(int n) { - return (n >> 1) & 1; - } + public static final int vo_control__vsync_pol__active_low = 0 << 1; public static final int vo_control__vsync_pol__active_high = 1 << 1; - public static int vo_control__hsync_pol__active_low(int n) { - return (n >> 0) & 1; - } + public static final int vo_control__hsync_pol__active_low = 0 << 0; public static final int vo_control__hsync_pol__active_high = 1 << 0; public static int vo_startx__horizontal_start_position(int n) { return (n & 1023) << 0; @@ -408,18 +370,14 @@ public class CoreBits { public static int vo_starty__vertical_start_position_on_field_1(int n) { return (n & 1023) << 0; } - public static int scaler_ctl__field_select__field_1(int n) { - return (n >> 18) & 1; - } + public static final int scaler_ctl__field_select__field_1 = 0 << 18; public static final int scaler_ctl__field_select__field_2 = 1 << 18; public static final int scaler_ctl__interlace = 1 << 17; public static final int scaler_ctl__horizontal_scaling_enable = 1 << 16; public static int scaler_ctl__vertical_scale_factor(int n) { return (n & 65535) << 0; } - public static int pal_ram_ctrl__pixel_format__argb1555(int n) { - return (n >> 0) & 3; - } + public static final int pal_ram_ctrl__pixel_format__argb1555 = 0 << 0; public static final int pal_ram_ctrl__pixel_format__rgb565 = 1 << 0; public static final int pal_ram_ctrl__pixel_format__argb4444 = 2 << 0; public static final int pal_ram_ctrl__pixel_format__argb8888 = 3 << 0; diff --git a/sega/dreamcast/holly/HollyBits.java b/sega/dreamcast/holly/HollyBits.java deleted file mode 100644 index 0b1b08f..0000000 --- a/sega/dreamcast/holly/HollyBits.java +++ /dev/null @@ -1,468 +0,0 @@ -package sega.dreamcast.holly; - -public class CoreBits { - public static int id__device_id(int n) { - return (n >> 16) & 65535; - } - public static int id__vendor_id(int n) { - return (n >> 0) & 65535; - } - public static int revision__chip_revision(int n) { - return (n >> 0) & 65535; - } - public static final int softreset__sdram_if_soft_reset = 1 << 2; - public static final int softreset__pipeline_soft_reset = 1 << 1; - public static final int softreset__ta_soft_reset = 1 << 0; - public static final int startrender__start_render = 1 << 0; - public static int test_select__diagdb_data(int n) { - return (n >> 5) & 31; - } - public static int test_select__diagda_data(int n) { - return (n >> 0) & 31; - } - public static int param_base__base_address(int n) { - return (n & 15728640) << 0; - } - public static int region_base__base_address(int n) { - return (n & 16777212) << 0; - } - public static final int span_sort_cfg__cache_bypass = 1 << 16; - public static final int span_sort_cfg__offset_sort_enable = 1 << 8; - public static final int span_sort_cfg__span_sort_enable = 1 << 0; - public static int vo_border_col__chroma(int n) { - return (n & 1) << 24; - } - public static int vo_border_col__red(int n) { - return (n & 255) << 16; - } - public static int vo_border_col__green(int n) { - return (n & 255) << 8; - } - public static int vo_border_col__blue(int n) { - return (n & 255) << 0; - } - public static int fb_r_ctrl__vclk_div__pclk_vclk_2(int n) { - return (n >> 23) & 1; - } - public static final int fb_r_ctrl__vclk_div__pclk_vclk_1 = 1 << 23; - public static final int fb_r_ctrl__fb_strip_buf_en = 1 << 22; - public static int fb_r_ctrl__fb_stripsize(int n) { - return (n & 62) << 16; - } - public static int fb_r_ctrl__fb_chroma_threshold(int n) { - return (n & 255) << 8; - } - public static int fb_r_ctrl__fb_concat(int n) { - return (n & 3) << 4; - } - public static final int fb_r_ctrl__fb_line_double = 1 << 1; - public static final int fb_r_ctrl__fb_enable = 1 << 0; - public static int fb_r_ctrl__fb_depth__0555_rgb_16bit(int n) { - return (n >> 2) & 3; - } - public static final int fb_r_ctrl__fb_depth__565_rgb_16bit = 1 << 2; - public static final int fb_r_ctrl__fb_depth__888_rgb_24bit_packed = 2 << 2; - public static final int fb_r_ctrl__fb_depth__0888_rgb_32bit = 3 << 2; - public static int fb_w_ctrl__fb_alpha_threshold(int n) { - return (n & 255) << 16; - } - public static int fb_w_ctrl__fb_kval(int n) { - return (n & 255) << 8; - } - public static final int fb_w_ctrl__fb_dither = 1 << 3; - public static int fb_w_ctrl__fb_packmode__0555_krgb_16bit(int n) { - return (n >> 0) & 7; - } - public static final int fb_w_ctrl__fb_packmode__565_rgb_16bit = 1 << 0; - public static final int fb_w_ctrl__fb_packmode__4444_argb_16bit = 2 << 0; - public static final int fb_w_ctrl__fb_packmode__1555_argb_16bit = 3 << 0; - public static final int fb_w_ctrl__fb_packmode__888_rgb_24bit_packed = 4 << 0; - public static final int fb_w_ctrl__fb_packmode__0888_krgb_32bit = 5 << 0; - public static final int fb_w_ctrl__fb_packmode__8888_argb_32bit = 6 << 0; - public static int fb_w_linestride__fb_line_stride(int n) { - return (n & 255) << 0; - } - public static int fb_r_sof1__frame_buffer_read_address_frame_1(int n) { - return (n & 16777212) << 0; - } - public static int fb_r_sof2__frame_buffer_read_address_frame_2(int n) { - return (n & 16777212) << 0; - } - public static int fb_r_size__fb_modulus(int n) { - return (n & 1023) << 20; - } - public static int fb_r_size__fb_y_size(int n) { - return (n & 1023) << 10; - } - public static int fb_r_size__fb_x_size(int n) { - return (n & 1023) << 0; - } - public static int fb_w_sof1__frame_buffer_write_address_frame_1(int n) { - return (n & 33554428) << 0; - } - public static int fb_w_sof2__frame_buffer_write_address_frame_2(int n) { - return (n & 33554428) << 0; - } - public static int fb_x_clip__fb_x_clip_max(int n) { - return (n & 2047) << 16; - } - public static int fb_x_clip__fb_x_clip_min(int n) { - return (n & 2047) << 0; - } - public static int fb_y_clip__fb_y_clip_max(int n) { - return (n & 1023) << 16; - } - public static int fb_y_clip__fb_y_clip_min(int n) { - return (n & 1023) << 0; - } - public static int fpu_shad_scale__simple_shadow_enable__parameter_selection_volume_mode(int n) { - return (n >> 8) & 1; - } - public static final int fpu_shad_scale__simple_shadow_enable__intensity_volume_mode = 1 << 8; - public static int fpu_shad_scale__scale_factor_for_shadows(int n) { - return (n & 255) << 0; - } - public static int fpu_cull_val__culling_comparison_value(int n) { - return (n & 2147483647) << 0; - } - public static int fpu_param_cfg__region_header_type__type_1(int n) { - return (n >> 21) & 1; - } - public static final int fpu_param_cfg__region_header_type__type_2 = 1 << 21; - public static int fpu_param_cfg__tsp_parameter_burst_threshold(int n) { - return (n & 63) << 14; - } - public static int fpu_param_cfg__isp_parameter_burst_threshold(int n) { - return (n & 63) << 8; - } - public static int fpu_param_cfg__pointer_burst_size(int n) { - return (n & 15) << 4; - } - public static int fpu_param_cfg__pointer_first_burst_size(int n) { - return (n & 15) << 0; - } - public static final int half_offset__tsp_texel_sampling_position__top_left = 1 << 2; - public static final int half_offset__tsp_texel_sampling_position__center = 1 << 2; - public static final int half_offset__tsp_pixel_sampling_position__top_left = 1 << 1; - public static final int half_offset__tsp_pixel_sampling_position__center = 1 << 1; - public static final int half_offset__fpu_pixel_sampling_position__top_left = 1 << 0; - public static final int half_offset__fpu_pixel_sampling_position__center = 1 << 0; - public static int fpu_perp_val__perpendicular_triangle_compare(int n) { - return (n & 2147483647) << 0; - } - public static int isp_backgnd_d__background_plane_depth(int n) { - return (n & 268435455) << 4; - } - public static final int isp_backgnd_t__cache_bypass = 1 << 28; - public static final int isp_backgnd_t__shadow = 1 << 27; - public static int isp_backgnd_t__skip(int n) { - return (n & 7) << 24; - } - public static int isp_backgnd_t__tag_address(int n) { - return (n & 2097151) << 3; - } - public static int isp_backgnd_t__tag_offset(int n) { - return (n & 7) << 0; - } - public static int isp_feed_cfg__cache_size_for_translucency(int n) { - return (n & 1023) << 14; - } - public static int isp_feed_cfg__punch_through_chunk_size(int n) { - return (n & 1023) << 4; - } - public static final int isp_feed_cfg__discard_mode = 1 << 3; - public static final int isp_feed_cfg__pre_sort_mode = 1 << 0; - public static int sdram_refresh__refresh_counter_value(int n) { - return (n & 255) << 0; - } - public static int sdram_arb_cfg__override_value__priority_only(int n) { - return (n >> 18) & 15; - } - public static final int sdram_arb_cfg__override_value__rendered_data = 1 << 18; - public static final int sdram_arb_cfg__override_value__texture_vq_index = 2 << 18; - public static final int sdram_arb_cfg__override_value__texture_normal_data_and_vq_codebook = 3 << 18; - public static final int sdram_arb_cfg__override_value__tile_accelerator_isp_tsp_data = 4 << 18; - public static final int sdram_arb_cfg__override_value__tile_accelerator_pointers = 5 << 18; - public static final int sdram_arb_cfg__override_value__sh4 = 6 << 18; - public static final int sdram_arb_cfg__override_value__tsp_parameters = 7 << 18; - public static final int sdram_arb_cfg__override_value__tsp_region_data = 8 << 18; - public static final int sdram_arb_cfg__override_value__isp_pointer_data = 9 << 18; - public static final int sdram_arb_cfg__override_value__isp_parameters = 10 << 18; - public static final int sdram_arb_cfg__override_value__crt_controller = 11 << 18; - public static int sdram_arb_cfg__arbiter_priority_control__priority_arbitration_only(int n) { - return (n >> 16) & 3; - } - public static final int sdram_arb_cfg__arbiter_priority_control__override_value_field = 1 << 16; - public static final int sdram_arb_cfg__arbiter_priority_control__round_robin_counter = 2 << 16; - public static int sdram_arb_cfg__arbiter_crt_page_break_latency_count_value(int n) { - return (n & 255) << 8; - } - public static int sdram_arb_cfg__arbiter_page_break_latency_count_value(int n) { - return (n & 255) << 0; - } - public static int sdram_cfg__read_command_to_returned_data_delay(int n) { - return (n & 7) << 26; - } - public static int sdram_cfg__cas_latency_value(int n) { - return (n & 7) << 23; - } - public static int sdram_cfg__activate_to_activate_period(int n) { - return (n & 3) << 21; - } - public static int sdram_cfg__read_to_write_period(int n) { - return (n & 7) << 18; - } - public static int sdram_cfg__refresh_to_activate_period(int n) { - return (n & 15) << 14; - } - public static int sdram_cfg__pre_charge_to_activate_period(int n) { - return (n & 3) << 10; - } - public static int sdram_cfg__activate_to_pre_charge_period(int n) { - return (n & 15) << 6; - } - public static int sdram_cfg__activate_to_read_write_command_period(int n) { - return (n & 3) << 4; - } - public static int sdram_cfg__write_to_pre_charge_period(int n) { - return (n & 3) << 2; - } - public static int sdram_cfg__read_to_pre_charge_period(int n) { - return (n & 3) << 0; - } - public static int fog_col_ram__red(int n) { - return (n & 255) << 16; - } - public static int fog_col_ram__green(int n) { - return (n & 255) << 8; - } - public static int fog_col_ram__blue(int n) { - return (n & 255) << 0; - } - public static int fog_col_vert__red(int n) { - return (n & 255) << 16; - } - public static int fog_col_vert__green(int n) { - return (n & 255) << 8; - } - public static int fog_col_vert__blue(int n) { - return (n & 255) << 0; - } - public static int fog_density__fog_scale_mantissa(int n) { - return (n & 255) << 8; - } - public static int fog_density__fog_scale_exponent(int n) { - return (n & 255) << 0; - } - public static int fog_clamp_max__alpha(int n) { - return (n & 255) << 24; - } - public static int fog_clamp_max__red(int n) { - return (n & 255) << 16; - } - public static int fog_clamp_max__green(int n) { - return (n & 255) << 8; - } - public static int fog_clamp_max__blue(int n) { - return (n & 255) << 0; - } - public static int fog_clamp_min__alpha(int n) { - return (n & 255) << 24; - } - public static int fog_clamp_min__red(int n) { - return (n & 255) << 16; - } - public static int fog_clamp_min__green(int n) { - return (n & 255) << 8; - } - public static int fog_clamp_min__blue(int n) { - return (n & 255) << 0; - } - public static int spg_trigger_pos__trigger_v_count(int n) { - return (n >> 16) & 1023; - } - public static int spg_trigger_pos__trigger_h_count(int n) { - return (n >> 0) & 1023; - } - public static int spg_hblank_int__hblank_in_interrupt(int n) { - return (n >> 16) & 1023; - } - public static int spg_hblank_int__line_comp_val(int n) { - return (n & 1023) << 0; - } - public static int spg_hblank_int__hblank_int_mode__output_equal_line_comp_val(int n) { - return (n >> 12) & 3; - } - public static final int spg_hblank_int__hblank_int_mode__output_every_line_comp_val = 1 << 12; - public static final int spg_hblank_int__hblank_int_mode__output_every_line = 2 << 12; - public static int spg_vblank_int__vblank_out_interrupt_line_number(int n) { - return (n & 1023) << 16; - } - public static int spg_vblank_int__vblank_in_interrupt_line_number(int n) { - return (n & 1023) << 0; - } - public static int spg_control__csync_on_h__hsync(int n) { - return (n >> 9) & 1; - } - public static final int spg_control__csync_on_h__csync = 1 << 9; - public static int spg_control__sync_direction__input(int n) { - return (n >> 8) & 1; - } - public static final int spg_control__sync_direction__output = 1 << 8; - public static final int spg_control__pal = 1 << 7; - public static final int spg_control__ntsc = 1 << 6; - public static final int spg_control__force_field2 = 1 << 5; - public static final int spg_control__interlace = 1 << 4; - public static final int spg_control__spg_lock = 1 << 3; - public static int spg_control__mcsync_pol__active_low(int n) { - return (n >> 2) & 1; - } - public static final int spg_control__mcsync_pol__active_high = 1 << 2; - public static int spg_control__mvsync_pol__active_low(int n) { - return (n >> 1) & 1; - } - public static final int spg_control__mvsync_pol__active_high = 1 << 1; - public static int spg_control__mhsync_pol__active_low(int n) { - return (n >> 0) & 1; - } - public static final int spg_control__mhsync_pol__active_high = 1 << 0; - public static int spg_hblank__hbend(int n) { - return (n & 1023) << 16; - } - public static int spg_hblank__hbstart(int n) { - return (n & 1023) << 0; - } - public static int spg_load__vcount(int n) { - return (n & 1023) << 16; - } - public static int spg_load__hcount(int n) { - return (n & 1023) << 0; - } - public static int spg_vblank__vbend(int n) { - return (n & 1023) << 16; - } - public static int spg_vblank__vbstart(int n) { - return (n & 1023) << 0; - } - public static int spg_width__eqwidth(int n) { - return (n & 1023) << 22; - } - public static int spg_width__bpwidth(int n) { - return (n & 1023) << 12; - } - public static int spg_width__vswidth(int n) { - return (n & 15) << 8; - } - public static int spg_width__hswidth(int n) { - return (n & 127) << 0; - } - public static int text_control__code_book_endian__little_endian(int n) { - return (n >> 17) & 1; - } - public static final int text_control__code_book_endian__big_endian = 1 << 17; - public static int text_control__index_endian__little_endian(int n) { - return (n >> 16) & 1; - } - public static final int text_control__index_endian__big_endian = 1 << 16; - public static int text_control__bank_bit(int n) { - return (n & 31) << 8; - } - public static int text_control__stride(int n) { - return (n & 31) << 0; - } - public static final int vo_control__pclk_delay_reset = 1 << 21; - public static int vo_control__pclk_delay(int n) { - return (n & 31) << 16; - } - public static final int vo_control__pixel_double = 1 << 8; - public static final int vo_control__blank_video = 1 << 3; - public static int vo_control__field_mode__use_field_flag_from_spg(int n) { - return (n >> 4) & 15; - } - public static final int vo_control__field_mode__use_inverse_of_field_flag_from_spg = 1 << 4; - public static final int vo_control__field_mode__field_1_fixed = 2 << 4; - public static final int vo_control__field_mode__field_2_fixed = 3 << 4; - public static final int vo_control__field_mode__field_1_when_the_active_edges_of_hsync_and_vsync_match = 4 << 4; - public static final int vo_control__field_mode__field_2_when_the_active_edges_of_hsync_and_vsync_match = 5 << 4; - public static final int vo_control__field_mode__field_1_when_hsync_becomes_active_in_the_middle_of_the_vsync_active_edge = 6 << 4; - public static final int vo_control__field_mode__field_2_when_hsync_becomes_active_in_the_middle_of_the_vsync_active_edge = 7 << 4; - public static final int vo_control__field_mode__inverted_at_the_active_edge_of_vsync = 8 << 4; - public static int vo_control__blank_pol__active_low(int n) { - return (n >> 2) & 1; - } - public static final int vo_control__blank_pol__active_high = 1 << 2; - public static int vo_control__vsync_pol__active_low(int n) { - return (n >> 1) & 1; - } - public static final int vo_control__vsync_pol__active_high = 1 << 1; - public static int vo_control__hsync_pol__active_low(int n) { - return (n >> 0) & 1; - } - public static final int vo_control__hsync_pol__active_high = 1 << 0; - public static int vo_startx__horizontal_start_position(int n) { - return (n & 1023) << 0; - } - public static int vo_starty__vertical_start_position_on_field_2(int n) { - return (n & 1023) << 16; - } - public static int vo_starty__vertical_start_position_on_field_1(int n) { - return (n & 1023) << 0; - } - public static int scaler_ctl__field_select__field_1(int n) { - return (n >> 18) & 1; - } - public static final int scaler_ctl__field_select__field_2 = 1 << 18; - public static final int scaler_ctl__interlace = 1 << 17; - public static final int scaler_ctl__horizontal_scaling_enable = 1 << 16; - public static int scaler_ctl__vertical_scale_factor(int n) { - return (n & 65535) << 0; - } - public static int pal_ram_ctrl__pixel_format__argb1555(int n) { - return (n >> 0) & 3; - } - public static final int pal_ram_ctrl__pixel_format__rgb565 = 1 << 0; - public static final int pal_ram_ctrl__pixel_format__argb4444 = 2 << 0; - public static final int pal_ram_ctrl__pixel_format__argb8888 = 3 << 0; - public static int spg_status__vsync(int n) { - return (n >> 13) & 1; - } - public static int spg_status__hsync(int n) { - return (n >> 12) & 1; - } - public static int spg_status__blank(int n) { - return (n >> 11) & 1; - } - public static int spg_status__fieldnum(int n) { - return (n >> 10) & 1; - } - public static int spg_status__scanline(int n) { - return (n >> 0) & 1023; - } - public static int fb_burstctrl__wr_burst(int n) { - return (n & 15) << 16; - } - public static int fb_burstctrl__vid_lat(int n) { - return (n & 127) << 8; - } - public static int fb_burstctrl__vid_burst(int n) { - return (n & 63) << 0; - } - public static int fb_c_sof__frame_buffer_current_read_address(int n) { - return (n >> 0) & 16777215; - } - public static int y_coeff__coefficient_1(int n) { - return (n & 255) << 8; - } - public static int y_coeff__coefficient_0_2(int n) { - return (n & 255) << 0; - } - public static int pt_alpha_ref__alpha_reference_for_punch_through(int n) { - return (n & 255) << 0; - } - public static int fog_table__fog_table_data(int n) { - return (n & 65535) << 0; - } - public static int palette_ram__palette_data(int n) { - return (n & -1) << 0; - } -} diff --git a/sega/dreamcast/holly/ISPTSP.java b/sega/dreamcast/holly/ISPTSP.java index cba21fe..106a576 100644 --- a/sega/dreamcast/holly/ISPTSP.java +++ b/sega/dreamcast/holly/ISPTSP.java @@ -1,9 +1,7 @@ package sega.dreamcast.holly; public class ISPTSP { - public static int isp_tsp_instruction_word__depth_compare_mode__never(int n) { - return (n >> 29) & 7; - } + public static final int isp_tsp_instruction_word__depth_compare_mode__never = 0 << 29; public static final int isp_tsp_instruction_word__depth_compare_mode__less = 1 << 29; public static final int isp_tsp_instruction_word__depth_compare_mode__equal = 2 << 29; public static final int isp_tsp_instruction_word__depth_compare_mode__less_or_equal = 3 << 29; @@ -11,14 +9,10 @@ public class ISPTSP { public static final int isp_tsp_instruction_word__depth_compare_mode__greater_or_equal = 5 << 29; public static final int isp_tsp_instruction_word__depth_compare_mode__not_equal = 6 << 29; public static final int isp_tsp_instruction_word__depth_compare_mode__always = 7 << 29; - public static int isp_tsp_instruction_word__volume_instruction__normal_polygon(int n) { - return (n >> 29) & 7; - } + public static final int isp_tsp_instruction_word__volume_instruction__normal_polygon = 0 << 29; public static final int isp_tsp_instruction_word__volume_instruction__inside_last_polygon = 1 << 29; public static final int isp_tsp_instruction_word__volume_instruction__outside_last_polygon = 2 << 29; - public static int isp_tsp_instruction_word__culling_mode__no_culling(int n) { - return (n >> 27) & 3; - } + public static final int isp_tsp_instruction_word__culling_mode__no_culling = 0 << 27; public static final int isp_tsp_instruction_word__culling_mode__cull_if_small = 1 << 27; public static final int isp_tsp_instruction_word__culling_mode__cull_if_negative = 2 << 27; public static final int isp_tsp_instruction_word__culling_mode__cull_if_positive = 3 << 27; @@ -29,9 +23,7 @@ public class ISPTSP { public static final int isp_tsp_instruction_word__16bit_uv = 1 << 22; public static final int isp_tsp_instruction_word__cache_bypass = 1 << 21; public static final int isp_tsp_instruction_word__dcalc_ctrl = 1 << 20; - public static int tsp_instruction_word__src_alpha_instr__zero(int n) { - return (n >> 29) & 7; - } + public static final int tsp_instruction_word__src_alpha_instr__zero = 0 << 29; public static final int tsp_instruction_word__src_alpha_instr__one = 1 << 29; public static final int tsp_instruction_word__src_alpha_instr__other_color = 2 << 29; public static final int tsp_instruction_word__src_alpha_instr__inverse_other_color = 3 << 29; @@ -39,9 +31,7 @@ public class ISPTSP { public static final int tsp_instruction_word__src_alpha_instr__inverse_src_alpha = 5 << 29; public static final int tsp_instruction_word__src_alpha_instr__dst_alpha = 6 << 29; public static final int tsp_instruction_word__src_alpha_instr__inverse_dst_alpha = 7 << 29; - public static int tsp_instruction_word__dst_alpha_instr__zero(int n) { - return (n >> 26) & 7; - } + public static final int tsp_instruction_word__dst_alpha_instr__zero = 0 << 26; public static final int tsp_instruction_word__dst_alpha_instr__one = 1 << 26; public static final int tsp_instruction_word__dst_alpha_instr__other_color = 2 << 26; public static final int tsp_instruction_word__dst_alpha_instr__inverse_other_color = 3 << 26; @@ -49,17 +39,11 @@ public class ISPTSP { public static final int tsp_instruction_word__dst_alpha_instr__inverse_src_alpha = 5 << 26; public static final int tsp_instruction_word__dst_alpha_instr__dst_alpha = 6 << 26; public static final int tsp_instruction_word__dst_alpha_instr__inverse_dst_alpha = 7 << 26; - public static int tsp_instruction_word__src_select__primary_accumulation_buffer(int n) { - return (n >> 25) & 1; - } + public static final int tsp_instruction_word__src_select__primary_accumulation_buffer = 0 << 25; public static final int tsp_instruction_word__src_select__secondary_accumulation_buffer = 1 << 25; - public static int tsp_instruction_word__dst_select__primary_accumulation_buffer(int n) { - return (n >> 24) & 1; - } + public static final int tsp_instruction_word__dst_select__primary_accumulation_buffer = 0 << 24; public static final int tsp_instruction_word__dst_select__secondary_accumulation_buffer = 1 << 24; - public static int tsp_instruction_word__fog_control__look_up_table(int n) { - return (n >> 22) & 3; - } + public static final int tsp_instruction_word__fog_control__look_up_table = 0 << 22; public static final int tsp_instruction_word__fog_control__per_vertex = 1 << 22; public static final int tsp_instruction_word__fog_control__no_fog = 2 << 22; public static final int tsp_instruction_word__fog_control__look_up_table_mode_2 = 3 << 22; @@ -82,33 +66,23 @@ public class ISPTSP { public static int tsp_instruction_word__texture_address(int n) { return (n & 2097151) << 0; } - public static int tsp_instruction_word__flip_uv__none(int n) { - return (n >> 17) & 3; - } + public static final int tsp_instruction_word__flip_uv__none = 0 << 17; public static final int tsp_instruction_word__flip_uv__v = 1 << 17; public static final int tsp_instruction_word__flip_uv__u = 2 << 17; public static final int tsp_instruction_word__flip_uv__uv = 3 << 17; - public static int tsp_instruction_word__clamp_uv__none(int n) { - return (n >> 15) & 3; - } + public static final int tsp_instruction_word__clamp_uv__none = 0 << 15; public static final int tsp_instruction_word__clamp_uv__v = 1 << 15; public static final int tsp_instruction_word__clamp_uv__u = 2 << 15; public static final int tsp_instruction_word__clamp_uv__uv = 3 << 15; - public static int tsp_instruction_word__filter_mode__point_sampled(int n) { - return (n >> 13) & 3; - } + public static final int tsp_instruction_word__filter_mode__point_sampled = 0 << 13; public static final int tsp_instruction_word__filter_mode__bilinear_filter = 1 << 13; public static final int tsp_instruction_word__filter_mode__trilinear_pass_a = 2 << 13; public static final int tsp_instruction_word__filter_mode__trilinear_pass_b = 3 << 13; - public static int tsp_instruction_word__texture_shading_instruction__decal(int n) { - return (n >> 6) & 3; - } + public static final int tsp_instruction_word__texture_shading_instruction__decal = 0 << 6; public static final int tsp_instruction_word__texture_shading_instruction__modulate = 1 << 6; public static final int tsp_instruction_word__texture_shading_instruction__decal_alpha = 2 << 6; public static final int tsp_instruction_word__texture_shading_instruction__modulate_alpha = 3 << 6; - public static int tsp_instruction_word__texture_u_size__8(int n) { - return (n >> 3) & 7; - } + public static final int tsp_instruction_word__texture_u_size__8 = 0 << 3; public static final int tsp_instruction_word__texture_u_size__16 = 1 << 3; public static final int tsp_instruction_word__texture_u_size__32 = 2 << 3; public static final int tsp_instruction_word__texture_u_size__64 = 3 << 3; @@ -116,9 +90,7 @@ public class ISPTSP { public static final int tsp_instruction_word__texture_u_size__256 = 5 << 3; public static final int tsp_instruction_word__texture_u_size__512 = 6 << 3; public static final int tsp_instruction_word__texture_u_size__1024 = 7 << 3; - public static int tsp_instruction_word__texture_v_size__8(int n) { - return (n >> 0) & 7; - } + public static final int tsp_instruction_word__texture_v_size__8 = 0 << 0; public static final int tsp_instruction_word__texture_v_size__16 = 1 << 0; public static final int tsp_instruction_word__texture_v_size__32 = 2 << 0; public static final int tsp_instruction_word__texture_v_size__64 = 3 << 0; @@ -126,18 +98,14 @@ public class ISPTSP { public static final int tsp_instruction_word__texture_v_size__256 = 5 << 0; public static final int tsp_instruction_word__texture_v_size__512 = 6 << 0; public static final int tsp_instruction_word__texture_v_size__1024 = 7 << 0; - public static int tsp_instruction_word__pixel_format__1555(int n) { - return (n >> 27) & 7; - } + public static final int tsp_instruction_word__pixel_format__1555 = 0 << 27; public static final int tsp_instruction_word__pixel_format__565 = 1 << 27; public static final int tsp_instruction_word__pixel_format__4444 = 2 << 27; public static final int tsp_instruction_word__pixel_format__yuv422 = 3 << 27; public static final int tsp_instruction_word__pixel_format__bump_map = 4 << 27; public static final int tsp_instruction_word__pixel_format__4bpp_palette = 5 << 27; public static final int tsp_instruction_word__pixel_format__8bpp_palette = 6 << 27; - public static int tsp_instruction_word__scan_order__twiddled(int n) { - return (n >> 26) & 1; - } + public static final int tsp_instruction_word__scan_order__twiddled = 0 << 26; public static final int tsp_instruction_word__scan_order__non_twiddled = 1 << 26; public static final int texture_control_word__mip_mapped = 1 << 31; public static final int texture_control_word__vq_compressed = 1 << 30; diff --git a/sega/dreamcast/holly/RegionArray.java b/sega/dreamcast/holly/RegionArray.java new file mode 100644 index 0000000..0ddb56f --- /dev/null +++ b/sega/dreamcast/holly/RegionArray.java @@ -0,0 +1,137 @@ +package sega.dreamcast.holly; + +import sega.dreamcast.MemoryMap; +import java.misc.Memory; + +// this is for a "type 2" region array. +// region header type is specified in FPU_PARAM_CFG +public class RegionArray { + private RegionArray() { + } + + public static final int TILE = 0 * 4; + public static final int OPAQUE_LIST_POINTER = 1 * 4; + public static final int OPAQUE_MODIFIER_VOLUME_LIST_POINTER = 2 * 4; + public static final int TRANSLUCENT_LIST_POINTER = 3 * 4; + public static final int TRANSLUCENT_MODIFIER_VOLUME_LIST_POINTER = 4 * 4; + public static final int PUNCH_THROUGH_LIST_POINTER = 5 * 4; + + public static final int ENTRY_SIZE = 6 * 4; + + public static final int TILE__LAST_REGION = (1 << 31); + public static final int TILE__Z_CLEAR = (1 << 30); + public static final int TILE__PRE_SORT = (1 << 29); + public static final int TILE__FLUSH_ACCUMULATE = (1 << 28); + public static int TILE__Y_POSITION(int n) { + return ((n) & 0X3F) << 8; + } + public static int TILE__X_POSITION(int n) { + return ((n) & 0X3F) << 2; + } + public static final int LIST_POINTER__EMPTY = (1 << 31); + + public static class OPBSize { + int opaque; + int opaque_modifier_volume; + int translucent; + int translucent_modifier_volume; + int punch_through; + + public OPBSize(int opaque, + int opaque_modifier_volume, + int translucent, + int translucent_modifier_volume, + int punch_through) + { + this.opaque = opaque; + this.opaque_modifier_volume = opaque_modifier_volume; + this.translucent = translucent; + this.translucent_modifier_volume = translucent_modifier_volume; + this.punch_through = punch_through; + } + + public int total() + { + return opaque + + opaque_modifier_volume + + translucent + + translucent_modifier_volume + + punch_through; + } + } + + public static void region_array(int width, // in tile units (1 tile unit = 32 pixels) + int height, // in tile units (1 tile unit = 32 pixels) + OPBSize[] opb_size, + int num_render_passes, + int region_array_start, + int object_list_start) { + int region_array = MemoryMap.texture_memory32 + region_array_start; + + int num_tiles = width * height; + int[] ol_base = new int[num_render_passes]; + + ol_base[0] = object_list_start; + for (int pass = 1; pass < num_render_passes; pass++) { + ol_base[pass] = ol_base[pass - 1] + num_tiles * opb_size[pass - 1].total(); + } + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + for (int pass = 0; pass < num_render_passes; pass++) { + int tile_value = TILE__Y_POSITION(y) + | TILE__X_POSITION(x); + + if (pass == (num_render_passes - 1) && y == (height - 1) && x == (width - 1)) + tile_value |= TILE__LAST_REGION; + if (pass != (num_render_passes - 1)) + tile_value |= TILE__FLUSH_ACCUMULATE; + if (pass > 0) + tile_value |= TILE__Z_CLEAR; + + int tile_index = y * width + x; + + int opaque_list_pointer_value = + (opb_size[pass].opaque == 0) ? LIST_POINTER__EMPTY : + (ol_base[pass] + num_tiles * ( 0 ) + + (opb_size[pass].opaque * tile_index)); + + int opaque_modifier_volume_list_pointer_value = + (opb_size[pass].opaque_modifier_volume == 0) ? LIST_POINTER__EMPTY : + (ol_base[pass] + num_tiles * ( opb_size[pass].opaque ) + + (opb_size[pass].opaque_modifier_volume * tile_index)); + + int translucent_list_pointer_value = + (opb_size[pass].translucent == 0) ? LIST_POINTER__EMPTY : + (ol_base[pass] + num_tiles * ( opb_size[pass].opaque + + opb_size[pass].opaque_modifier_volume ) + + (opb_size[pass].translucent * tile_index)); + + int translucent_modifier_volume_list_pointer_value = + (opb_size[pass].translucent_modifier_volume == 0) ? LIST_POINTER__EMPTY : + (ol_base[pass] + num_tiles * ( opb_size[pass].opaque + + opb_size[pass].opaque_modifier_volume + + opb_size[pass].translucent ) + + (opb_size[pass].translucent_modifier_volume * tile_index)); + + int punch_through_list_pointer_value = + (opb_size[pass].punch_through == 0) ? LIST_POINTER__EMPTY : + (ol_base[pass] + num_tiles * ( opb_size[pass].opaque + + opb_size[pass].opaque_modifier_volume + + opb_size[pass].translucent + + opb_size[pass].translucent_modifier_volume ) + + (opb_size[pass].punch_through * tile_index)); + + Memory.putU4(region_array + TILE, tile_value); + Memory.putU4(region_array + OPAQUE_LIST_POINTER, opaque_list_pointer_value); + Memory.putU4(region_array + OPAQUE_MODIFIER_VOLUME_LIST_POINTER, opaque_modifier_volume_list_pointer_value); + Memory.putU4(region_array + TRANSLUCENT_LIST_POINTER, translucent_list_pointer_value); + Memory.putU4(region_array + TRANSLUCENT_MODIFIER_VOLUME_LIST_POINTER, translucent_modifier_volume_list_pointer_value); + Memory.putU4(region_array + PUNCH_THROUGH_LIST_POINTER, punch_through_list_pointer_value); + + region_array += ENTRY_SIZE; + } + } + } + } +} diff --git a/sega/dreamcast/holly/TABits.java b/sega/dreamcast/holly/TABits.java index 478aaa2..6a99d01 100644 --- a/sega/dreamcast/holly/TABits.java +++ b/sega/dreamcast/holly/TABits.java @@ -25,37 +25,25 @@ public class TABits { public static int ta_glob_tile_clip__tile_x_num(int n) { return (n & 31) << 0; } - public static int ta_alloc_ctrl__opb_mode__increasing_addresses(int n) { - return (n >> 20) & 1; - } + public static final int ta_alloc_ctrl__opb_mode__increasing_addresses = 0 << 20; public static final int ta_alloc_ctrl__opb_mode__decreasing_addresses = 1 << 20; - public static int ta_alloc_ctrl__pt_opb__no_list(int n) { - return (n >> 16) & 3; - } + public static final int ta_alloc_ctrl__pt_opb__no_list = 0 << 16; public static final int ta_alloc_ctrl__pt_opb__8x4byte = 1 << 16; public static final int ta_alloc_ctrl__pt_opb__16x4byte = 2 << 16; public static final int ta_alloc_ctrl__pt_opb__32x4byte = 3 << 16; - public static int ta_alloc_ctrl__tm_opb__no_list(int n) { - return (n >> 12) & 3; - } + public static final int ta_alloc_ctrl__tm_opb__no_list = 0 << 12; public static final int ta_alloc_ctrl__tm_opb__8x4byte = 1 << 12; public static final int ta_alloc_ctrl__tm_opb__16x4byte = 2 << 12; public static final int ta_alloc_ctrl__tm_opb__32x4byte = 3 << 12; - public static int ta_alloc_ctrl__t_opb__no_list(int n) { - return (n >> 8) & 3; - } + public static final int ta_alloc_ctrl__t_opb__no_list = 0 << 8; public static final int ta_alloc_ctrl__t_opb__8x4byte = 1 << 8; public static final int ta_alloc_ctrl__t_opb__16x4byte = 2 << 8; public static final int ta_alloc_ctrl__t_opb__32x4byte = 3 << 8; - public static int ta_alloc_ctrl__om_opb__no_list(int n) { - return (n >> 4) & 3; - } + public static final int ta_alloc_ctrl__om_opb__no_list = 0 << 4; public static final int ta_alloc_ctrl__om_opb__8x4byte = 1 << 4; public static final int ta_alloc_ctrl__om_opb__16x4byte = 2 << 4; public static final int ta_alloc_ctrl__om_opb__32x4byte = 3 << 4; - public static int ta_alloc_ctrl__o_opb__no_list(int n) { - return (n >> 0) & 3; - } + public static final int ta_alloc_ctrl__o_opb__no_list = 0 << 0; public static final int ta_alloc_ctrl__o_opb__8x4byte = 1 << 0; public static final int ta_alloc_ctrl__o_opb__16x4byte = 2 << 0; public static final int ta_alloc_ctrl__o_opb__32x4byte = 3 << 0; @@ -63,13 +51,9 @@ public class TABits { public static int ta_yuv_tex_base__base_address(int n) { return (n & 16777208) << 0; } - public static int ta_yuv_tex_ctrl__yuv_form__yuv420(int n) { - return (n >> 24) & 1; - } + public static final int ta_yuv_tex_ctrl__yuv_form__yuv420 = 0 << 24; public static final int ta_yuv_tex_ctrl__yuv_form__yuv422 = 1 << 24; - public static int ta_yuv_tex_ctrl__yuv_tex__one_texture(int n) { - return (n >> 16) & 1; - } + public static final int ta_yuv_tex_ctrl__yuv_tex__one_texture = 0 << 16; public static final int ta_yuv_tex_ctrl__yuv_tex__multiple_textures = 1 << 16; public static int ta_yuv_tex_ctrl__yuv_v_size(int n) { return (n & 63) << 8; diff --git a/sega/dreamcast/holly/TAFIFOPolygonConverter.java b/sega/dreamcast/holly/TAFIFOPolygonConverter.java new file mode 100644 index 0000000..46a3204 --- /dev/null +++ b/sega/dreamcast/holly/TAFIFOPolygonConverter.java @@ -0,0 +1,58 @@ +package sega.dreamcast.holly; + +import sega.dreamcast.holly.Holly; +import sega.dreamcast.holly.CoreBits; +import sega.dreamcast.holly.TABits; +import java.misc.Memory; + +public class TAFIFOPolygonConverter { + private TAFIFOPolygonConverter() { + } + + public static void init(int isp_tsp_parameters_start, + int isp_tsp_parameters_end, + int object_list_start, + int object_list_end, + int opb_total_size, + int ta_alloc, + int tile_width, // in tile units + int tile_height) // in tile units + { + // opb_size is the total size of all OPBs for all passes + int ta_next_opb_offset = opb_total_size * tile_width * tile_height; + + int ta_glob_tile_clip = TABits.ta_glob_tile_clip__tile_y_num(tile_height - 1) + | TABits.ta_glob_tile_clip__tile_x_num(tile_width - 1); + + Memory.putU4(Holly.SOFTRESET, CoreBits.softreset__ta_soft_reset); + Memory.putU4(Holly.SOFTRESET, 0); + + Memory.putU4(Holly.TA_GLOB_TILE_CLIP, ta_glob_tile_clip); + + Memory.putU4(Holly.TA_ALLOC_CTRL, ta_alloc); + + Memory.putU4(Holly.TA_ISP_BASE, isp_tsp_parameters_start); + Memory.putU4(Holly.TA_ISP_LIMIT, isp_tsp_parameters_end); // the end of isp_tsp_parameters + Memory.putU4(Holly.TA_OL_BASE, object_list_start); + Memory.putU4(Holly.TA_OL_LIMIT, object_list_end); // the end of the object_list + Memory.putU4(Holly.TA_NEXT_OPB_INIT, object_list_start + ta_next_opb_offset); + + Memory.putU4(Holly.TA_LIST_INIT, TABits.ta_list_init__list_init); + + // dummy read + Memory.getU4(Holly.TA_LIST_INIT); + } + + public static void wait_opaque_list() + { + //while ((system.ISTNRM & istnrm::end_of_transferring_opaque_list) == 0) { + //}; + //system.ISTNRM = istnrm::end_of_transferring_opaque_list; + while (true) { + int istnrm = Memory.getU4(0xa05f6900); + if ((istnrm & (1 << 7)) != 0) + break; + } + Memory.putU4(0xa05f6900, (1 << 7)); + } +} diff --git a/sega/dreamcast/holly/TAParameter.java b/sega/dreamcast/holly/TAParameter.java new file mode 100644 index 0000000..21eda1c --- /dev/null +++ b/sega/dreamcast/holly/TAParameter.java @@ -0,0 +1,35 @@ +package sega.dreamcast.holly; + +public class TAParameter { + public static final int para_control__para_type__end_of_list = 0 << 29; + public static final int para_control__para_type__user_tile_clip = 1 << 29; + public static final int para_control__para_type__object_list_set = 2 << 29; + public static final int para_control__para_type__polygon_or_modifier_volume = 4 << 29; + public static final int para_control__para_type__sprite = 5 << 29; + public static final int para_control__para_type__vertex_parameter = 7 << 29; + public static final int para_control__end_of_strip = 1 << 28; + public static final int para_control__list_type__opaque = 0 << 24; + public static final int para_control__list_type__opaque_modifier_volume = 1 << 24; + public static final int para_control__list_type__translucent = 2 << 24; + public static final int para_control__list_type__translucent_modifier_volume = 3 << 24; + public static final int para_control__list_type__punch_through = 4 << 24; + public static final int group_control__group_en__group_en = 1 << 23; + public static final int group_control__strip_len__1_strip = 0 << 18; + public static final int group_control__strip_len__2_strip = 1 << 18; + public static final int group_control__strip_len__4_strip = 2 << 18; + public static final int group_control__strip_len__6_strip = 3 << 18; + public static final int group_control__user_clip__disabled = 0 << 16; + public static final int group_control__user_clip__inside_enable = 2 << 16; + public static final int group_control__user_clip__outside_enable = 3 << 16; + public static final int obj_control__shadow = 1 << 7; + public static final int obj_control__texture = 1 << 3; + public static final int obj_control__offset = 1 << 2; + public static final int obj_control__gouraud = 1 << 1; + public static final int obj_control__16bit_uv = 1 << 0; + public static final int obj_control__volume__with_two_volumes = 1 << 6; + public static final int obj_control__volume__last_in_volume = 1 << 6; + public static final int obj_control__col_type__packed_color = 1 << 4; + public static final int obj_control__col_type__floating_color = 1 << 4; + public static final int obj_control__col_type__intensity_mode_1 = 1 << 4; + public static final int obj_control__col_type__intensity_mode_2 = 1 << 4; +} diff --git a/sega/dreamcast/holly/TextureMemoryAllocation.java b/sega/dreamcast/holly/TextureMemoryAllocation.java new file mode 100644 index 0000000..a890278 --- /dev/null +++ b/sega/dreamcast/holly/TextureMemoryAllocation.java @@ -0,0 +1,21 @@ +package sega.dreamcast.holly; + +public class TextureMemoryAllocation { + /* frame A frame B */ + public static final int[] isp_tsp_parameters_start = { 0x000000, 0x080000 }; + public static final int[] isp_tsp_parameters_end = { 0x07ffc0, 0x0fffc0 }; + public static final int[] background_start = { 0x07ffc0, 0x0fffc0 }; + public static final int[] background_end = { 0x080000, 0x100000 }; + public static final int[] object_list_start = { 0x100000, 0x180000 }; + public static final int[] object_list_end = { 0x17ffe0, 0x1fffe0 }; + public static final int[] region_array_start = { 0x200000, 0x210000 }; + public static final int[] region_array_end = { 0x210000, 0x220000 }; + public static final int[] framebuffer_start = { 0x220000, 0x2c8c00 }; // 720 x 480 @ 16bpp + public static final int[] framebuffer_end = { 0x2c8c00, 0x371800 }; // 720 x 480 @ 16bpp + + public static final int[][] texture_regions = { + /* start end */ + { 0x200000, 0x400000 }, + { 0x600000, 0x800000 }, + }; +}