diff --git a/src/mame/drivers/model1.c b/src/mame/drivers/model1.c index 750cdacdfdc..c12e2077413 100644 --- a/src/mame/drivers/model1.c +++ b/src/mame/drivers/model1.c @@ -747,7 +747,7 @@ MACHINE_RESET_MEMBER(model1_state,model1) { membank("bank1")->set_base(memregion("maincpu")->base() + 0x1000000); irq_init(); - model1_tgp_reset(machine(), !strcmp(machine().system().name, "swa") || !strcmp(machine().system().name, "wingwar") || !strcmp(machine().system().name, "wingwaru") || !strcmp(machine().system().name, "wingwarj")); + tgp_reset(!strcmp(machine().system().name, "swa") || !strcmp(machine().system().name, "wingwar") || !strcmp(machine().system().name, "wingwaru") || !strcmp(machine().system().name, "wingwarj")); if (!strcmp(machine().system().name, "swa")) { m_sound_irq = 0; @@ -762,7 +762,7 @@ MACHINE_RESET_MEMBER(model1_state,model1_vr) { membank("bank1")->set_base(memregion("maincpu")->base() + 0x1000000); irq_init(); - model1_vr_tgp_reset(machine()); + vr_tgp_reset(); m_sound_irq = 3; } diff --git a/src/mame/includes/model1.h b/src/mame/includes/model1.h index 4adfbdfb395..7249adfc1a5 100644 --- a/src/mame/includes/model1.h +++ b/src/mame/includes/model1.h @@ -2,7 +2,7 @@ #include "audio/segam1audio.h" #include "cpu/v60/v60.h" -typedef void (*tgp_func)(running_machine &machine); +#define DECLARE_TGP_FUNCTION(name) void name() enum {FIFO_SIZE = 256}; enum {MAT_STACK_SIZE = 32}; @@ -16,6 +16,7 @@ public: m_m1audio(*this, "m1audio"), m_dsbz80(*this, DSBZ80_TAG), m_tgp(*this, "tgp"), + m_screen(*this, "screen"), m_mr2(*this, "mr2"), m_mr(*this, "mr"), m_display_list0(*this, "display_list0"), @@ -28,13 +29,14 @@ public: required_device m_m1audio; // Model 1 standard sound board optional_device m_dsbz80; // Digital Sound Board optional_device m_tgp; + required_device m_screen; required_shared_ptr m_mr2; required_shared_ptr m_mr; required_shared_ptr m_display_list0; required_shared_ptr m_display_list1; required_shared_ptr m_color_xlat; - + struct view *m_view; struct point *m_pointdb; struct point *m_pointpt; @@ -52,7 +54,15 @@ public: UINT32 m_fifoin_data[FIFO_SIZE]; int m_swa; int m_fifoin_cbcount; + typedef void (model1_state::*tgp_func)(); tgp_func m_fifoin_cb; + struct function + { + tgp_func cb; + int count; + }; + static const struct function ftab_vf[]; + static const struct function ftab_swa[]; INT32 m_fifoout_rpos; INT32 m_fifoout_wpos; UINT32 m_fifoout_data[FIFO_SIZE]; @@ -151,12 +161,133 @@ public: DECLARE_READ_LINE_MEMBER(copro_fifoin_pop_ok); DECLARE_READ32_MEMBER(copro_fifoin_pop); DECLARE_WRITE32_MEMBER(copro_fifoout_push); + void vr_tgp_reset(); + void tgp_reset(int swa); + void next_fn(); + UINT32 fifoout_pop(); + void fifoout_push(UINT32 data); + void fifoout_push_f(float data); + UINT32 fifoin_pop(); + void fifoin_push(UINT32 data); + float fifoin_pop_f(); + UINT16 ram_get_i(); + float ram_get_f(); + DECLARE_TGP_FUNCTION( fadd ); + DECLARE_TGP_FUNCTION( fsub ); + DECLARE_TGP_FUNCTION( fmul ); + DECLARE_TGP_FUNCTION( fdiv ); + DECLARE_TGP_FUNCTION( matrix_push ); + DECLARE_TGP_FUNCTION( matrix_pop ); + DECLARE_TGP_FUNCTION( matrix_write ); + DECLARE_TGP_FUNCTION( clear_stack ); + DECLARE_TGP_FUNCTION( matrix_mul ); + DECLARE_TGP_FUNCTION( anglev ); + DECLARE_TGP_FUNCTION( f11 ); + DECLARE_TGP_FUNCTION( normalize ); + DECLARE_TGP_FUNCTION( acc_seti ); + DECLARE_TGP_FUNCTION( track_select ); + DECLARE_TGP_FUNCTION( f14 ); + DECLARE_TGP_FUNCTION( f15_swa ); + DECLARE_TGP_FUNCTION( anglep ); + DECLARE_TGP_FUNCTION( matrix_ident ); + DECLARE_TGP_FUNCTION( matrix_read ); + DECLARE_TGP_FUNCTION( matrix_trans ); + DECLARE_TGP_FUNCTION( matrix_scale ); + DECLARE_TGP_FUNCTION( matrix_rotx ); + DECLARE_TGP_FUNCTION( matrix_roty ); + DECLARE_TGP_FUNCTION( matrix_rotz ); + DECLARE_TGP_FUNCTION( track_read_quad ); + DECLARE_TGP_FUNCTION( f24_swa ); + DECLARE_TGP_FUNCTION( transform_point ); + DECLARE_TGP_FUNCTION( fcos_m1 ); + DECLARE_TGP_FUNCTION( fsin_m1 ); + DECLARE_TGP_FUNCTION( fcosm_m1 ); + DECLARE_TGP_FUNCTION( fsinm_m1 ); + DECLARE_TGP_FUNCTION( distance3 ); + DECLARE_TGP_FUNCTION( ftoi ); + DECLARE_TGP_FUNCTION( itof ); + DECLARE_TGP_FUNCTION( acc_set ); + DECLARE_TGP_FUNCTION( acc_get ); + DECLARE_TGP_FUNCTION( acc_add ); + DECLARE_TGP_FUNCTION( acc_sub ); + DECLARE_TGP_FUNCTION( acc_mul ); + DECLARE_TGP_FUNCTION( acc_div ); + DECLARE_TGP_FUNCTION( f42 ); + DECLARE_TGP_FUNCTION( xyz2rqf ); + DECLARE_TGP_FUNCTION( f43 ); + DECLARE_TGP_FUNCTION( f43_swa ); + DECLARE_TGP_FUNCTION( f44 ); + DECLARE_TGP_FUNCTION( matrix_sdir ); + DECLARE_TGP_FUNCTION( f45 ); + DECLARE_TGP_FUNCTION( vlength ); + DECLARE_TGP_FUNCTION( f47 ); + DECLARE_TGP_FUNCTION( track_read_info ); + DECLARE_TGP_FUNCTION( colbox_set ); + DECLARE_TGP_FUNCTION( colbox_test ); + DECLARE_TGP_FUNCTION( f49_swa ); + DECLARE_TGP_FUNCTION( f50_swa ); + DECLARE_TGP_FUNCTION( f52 ); + DECLARE_TGP_FUNCTION( matrix_rdir ); + DECLARE_TGP_FUNCTION( track_lookup ); + DECLARE_TGP_FUNCTION( f56 ); + DECLARE_TGP_FUNCTION( f57 ); + DECLARE_TGP_FUNCTION( matrix_readt ); + DECLARE_TGP_FUNCTION( acc_geti ); + DECLARE_TGP_FUNCTION( f60 ); + DECLARE_TGP_FUNCTION( col_setcirc ); + DECLARE_TGP_FUNCTION( col_testpt ); + DECLARE_TGP_FUNCTION( push_and_ident ); + DECLARE_TGP_FUNCTION( catmull_rom ); + DECLARE_TGP_FUNCTION( distance ); + DECLARE_TGP_FUNCTION( car_move ); + DECLARE_TGP_FUNCTION( cpa ); + DECLARE_TGP_FUNCTION( vmat_store ); + DECLARE_TGP_FUNCTION( vmat_restore ); + DECLARE_TGP_FUNCTION( vmat_mul ); + DECLARE_TGP_FUNCTION( vmat_read ); + DECLARE_TGP_FUNCTION( matrix_rtrans ); + DECLARE_TGP_FUNCTION( matrix_unrot ); + DECLARE_TGP_FUNCTION( f80 ); + DECLARE_TGP_FUNCTION( vmat_save ); + DECLARE_TGP_FUNCTION( vmat_load ); + DECLARE_TGP_FUNCTION( ram_setadr ); + DECLARE_TGP_FUNCTION( groundbox_test ); + DECLARE_TGP_FUNCTION( f89 ); + DECLARE_TGP_FUNCTION( f92 ); + DECLARE_TGP_FUNCTION( f93 ); + DECLARE_TGP_FUNCTION( f94 ); + DECLARE_TGP_FUNCTION( vmat_flatten ); + DECLARE_TGP_FUNCTION( vmat_load1 ); + DECLARE_TGP_FUNCTION( ram_trans ); + DECLARE_TGP_FUNCTION( f98_load ); + DECLARE_TGP_FUNCTION( f98 ); + DECLARE_TGP_FUNCTION( f99 ); + DECLARE_TGP_FUNCTION( f100 ); + DECLARE_TGP_FUNCTION( groundbox_set ); + DECLARE_TGP_FUNCTION( f102 ); + DECLARE_TGP_FUNCTION( f103 ); + DECLARE_TGP_FUNCTION( dump ); + DECLARE_TGP_FUNCTION( function_get_vf ); + DECLARE_TGP_FUNCTION( function_get_swa ); + void copro_fifoin_push(UINT32 data); + UINT32 copro_fifoout_pop(); + void sort_quads(); + void unsort_quads(); + void draw_quads(bitmap_rgb32 &bitmap, const rectangle &cliprect); + void fclip_push_quad_next(int level, struct quad_m1 *q, struct point *p1, struct point *p2, struct point *p3, struct point *p4); + void fclip_push_quad(int level, struct quad_m1 *q); + void push_object(UINT32 tex_adr, UINT32 poly_adr, UINT32 size); + UINT16 *push_direct(UINT16 *list); + void draw_objects(bitmap_rgb32 &bitmap, const rectangle &cliprect); + UINT16 *draw_direct(bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT16 *list); + UINT16 *get_list(); + int get_list_number(); + void end_frame(); + void tgp_render(bitmap_rgb32 &bitmap, const rectangle &cliprect); + void tgp_scan(); }; /*----------- defined in machine/model1.c -----------*/ ADDRESS_MAP_EXTERN( model1_vr_tgp_map, 32 ); - -void model1_vr_tgp_reset( running_machine &machine ); -void model1_tgp_reset(running_machine &machine, int swa); diff --git a/src/mame/machine/model1.c b/src/mame/machine/model1.c index 10f565f533f..1b26ea2584b 100644 --- a/src/mame/machine/model1.c +++ b/src/mame/machine/model1.c @@ -8,81 +8,74 @@ #include "cpu/v60/v60.h" #include "includes/model1.h" -#define TGP_FUNCTION(name) void name(running_machine &machine) +#define TGP_FUNCTION(name) void name() -static UINT32 fifoout_pop(address_space &space) +UINT32 model1_state::fifoout_pop() { - model1_state *state = space.machine().driver_data(); - UINT32 v; - if(state->m_fifoout_wpos == state->m_fifoout_rpos) { - fatalerror("TGP FIFOOUT underflow (%x)\n", space.device().safe_pc()); + if(m_fifoout_wpos == m_fifoout_rpos) { + fatalerror("TGP FIFOOUT underflow (%x)\n", safe_pc()); } - v = state->m_fifoout_data[state->m_fifoout_rpos++]; - if(state->m_fifoout_rpos == FIFO_SIZE) - state->m_fifoout_rpos = 0; + UINT32 v = m_fifoout_data[m_fifoout_rpos++]; + if(m_fifoout_rpos == FIFO_SIZE) + m_fifoout_rpos = 0; return v; } -static void fifoout_push(model1_state *state, UINT32 data) +void model1_state::fifoout_push(UINT32 data) { - if(!state->m_puuu) + if(!m_puuu) logerror("TGP: Push %d\n", data); else - state->m_puuu = 0; - state->m_fifoout_data[state->m_fifoout_wpos++] = data; - if(state->m_fifoout_wpos == FIFO_SIZE) - state->m_fifoout_wpos = 0; - if(state->m_fifoout_wpos == state->m_fifoout_rpos) + m_puuu = 0; + m_fifoout_data[m_fifoout_wpos++] = data; + if(m_fifoout_wpos == FIFO_SIZE) + m_fifoout_wpos = 0; + if(m_fifoout_wpos == m_fifoout_rpos) logerror("TGP FIFOOUT overflow\n"); } -static void fifoout_push_f(model1_state *state, float data) +void model1_state::fifoout_push_f(float data) { - state->m_puuu = 1; + m_puuu = 1; logerror("TGP: Push %f\n", data); - fifoout_push(state, f2u(data)); + fifoout_push(f2u(data)); } -static UINT32 fifoin_pop(model1_state *state) +UINT32 model1_state::fifoin_pop() { - UINT32 v; - if(state->m_fifoin_wpos == state->m_fifoin_rpos) + if(m_fifoin_wpos == m_fifoin_rpos) logerror("TGP FIFOIN underflow\n"); - v = state->m_fifoin_data[state->m_fifoin_rpos++]; - if(state->m_fifoin_rpos == FIFO_SIZE) - state->m_fifoin_rpos = 0; + UINT32 v = m_fifoin_data[m_fifoin_rpos++]; + if(m_fifoin_rpos == FIFO_SIZE) + m_fifoin_rpos = 0; return v; } -static void fifoin_push(address_space &space, UINT32 data) +void model1_state::fifoin_push(UINT32 data) { - model1_state *state = space.machine().driver_data(); - // logerror("TGP FIFOIN write %08x (%x)\n", data, space.device().safe_pc()); - state->m_fifoin_data[state->m_fifoin_wpos++] = data; - if(state->m_fifoin_wpos == FIFO_SIZE) - state->m_fifoin_wpos = 0; - if(state->m_fifoin_wpos == state->m_fifoin_rpos) + // logerror("TGP FIFOIN write %08x (%x)\n", data, safe_pc()); + m_fifoin_data[m_fifoin_wpos++] = data; + if(m_fifoin_wpos == FIFO_SIZE) + m_fifoin_wpos = 0; + if(m_fifoin_wpos == m_fifoin_rpos) logerror("TGP FIFOIN overflow\n"); - state->m_fifoin_cbcount--; - if(!state->m_fifoin_cbcount) - state->m_fifoin_cb(space.machine()); + m_fifoin_cbcount--; + if(!m_fifoin_cbcount) + (this->*m_fifoin_cb)(); } -static float fifoin_pop_f(model1_state *state) +float model1_state::fifoin_pop_f() { - return u2f(fifoin_pop(state)); + return u2f(fifoin_pop()); } -static TGP_FUNCTION( function_get_vf ); -static TGP_FUNCTION( function_get_swa ); - -static void next_fn(model1_state *state) +void model1_state::next_fn() { - state->m_fifoin_cbcount = 1; - state->m_fifoin_cb = state->m_swa ? function_get_swa : function_get_vf; + m_fifoin_cbcount = 1; + m_fifoin_cb = m_swa ? &model1_state::function_get_swa : &model1_state::function_get_vf; } static float tcos(INT16 a) @@ -109,171 +102,160 @@ static float tsin(INT16 a) return sin(a*(2*M_PI/65536.0)); } -static UINT16 ram_get_i(model1_state *state) +UINT16 model1_state::ram_get_i() { - return state->m_ram_data[state->m_ram_scanadr++]; + return m_ram_data[m_ram_scanadr++]; } -static float ram_get_f(model1_state *state) +float model1_state::ram_get_f() { - return u2f(state->m_ram_data[state->m_ram_scanadr++]); + return u2f(m_ram_data[m_ram_scanadr++]); } -static TGP_FUNCTION( fadd ) +TGP_FUNCTION( model1_state::fadd ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); float r = a+b; - logerror("TGP fadd %f+%f=%f (%x)\n", a, b, r, state->m_pushpc); - fifoout_push_f(state, r); - next_fn(state); + logerror("TGP fadd %f+%f=%f (%x)\n", a, b, r, m_pushpc); + fifoout_push_f(r); + next_fn(); } -static TGP_FUNCTION( fsub ) +TGP_FUNCTION( model1_state::fsub ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); float r = a-b; - state->m_dump = 1; - logerror("TGP fsub %f-%f=%f (%x)\n", a, b, r, state->m_pushpc); - fifoout_push_f(state, r); - next_fn(state); + m_dump = 1; + logerror("TGP fsub %f-%f=%f (%x)\n", a, b, r, m_pushpc); + fifoout_push_f(r); + next_fn(); } -static TGP_FUNCTION( fmul ) +TGP_FUNCTION( model1_state::fmul ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); float r = a*b; - logerror("TGP fmul %f*%f=%f (%x)\n", a, b, r, state->m_pushpc); - fifoout_push_f(state, r); - next_fn(state); + logerror("TGP fmul %f*%f=%f (%x)\n", a, b, r, m_pushpc); + fifoout_push_f(r); + next_fn(); } -static TGP_FUNCTION( fdiv ) +TGP_FUNCTION( model1_state::fdiv ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); // float r = !b ? 1e39 : a/b; float r = !b ? 0 : a * (1/b); - logerror("TGP fdiv %f/%f=%f (%x)\n", a, b, r, state->m_pushpc); - fifoout_push_f(state, r); - next_fn(state); + logerror("TGP fdiv %f/%f=%f (%x)\n", a, b, r, m_pushpc); + fifoout_push_f(r); + next_fn(); } -static TGP_FUNCTION( matrix_push ) +TGP_FUNCTION( model1_state::matrix_push ) { - model1_state *state = machine.driver_data(); - if(state->m_mat_stack_pos != MAT_STACK_SIZE) { - memcpy(state->m_mat_stack[state->m_mat_stack_pos], state->m_cmat, sizeof(state->m_cmat)); - state->m_mat_stack_pos++; + if(m_mat_stack_pos != MAT_STACK_SIZE) { + memcpy(m_mat_stack[m_mat_stack_pos], m_cmat, sizeof(m_cmat)); + m_mat_stack_pos++; } - logerror("TGP matrix_push (depth=%d, pc=%x)\n", state->m_mat_stack_pos, state->m_pushpc); - next_fn(state); + logerror("TGP matrix_push (depth=%d, pc=%x)\n", m_mat_stack_pos, m_pushpc); + next_fn(); } -static TGP_FUNCTION( matrix_pop ) +TGP_FUNCTION( model1_state::matrix_pop ) { - model1_state *state = machine.driver_data(); - if(state->m_mat_stack_pos) { - state->m_mat_stack_pos--; - memcpy(state->m_cmat, state->m_mat_stack[state->m_mat_stack_pos], sizeof(state->m_cmat)); + if(m_mat_stack_pos) { + m_mat_stack_pos--; + memcpy(m_cmat, m_mat_stack[m_mat_stack_pos], sizeof(m_cmat)); } - logerror("TGP matrix_pop (depth=%d, pc=%x)\n", state->m_mat_stack_pos, state->m_pushpc); - next_fn(state); + logerror("TGP matrix_pop (depth=%d, pc=%x)\n", m_mat_stack_pos, m_pushpc); + next_fn(); } -static TGP_FUNCTION( matrix_write ) +TGP_FUNCTION( model1_state::matrix_write ) { - model1_state *state = machine.driver_data(); int i; for(i=0; i<12; i++) - state->m_cmat[i] = fifoin_pop_f(state); + m_cmat[i] = fifoin_pop_f(); logerror("TGP matrix_write %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f) (%x)\n", - state->m_cmat[0], state->m_cmat[1], state->m_cmat[2], state->m_cmat[3], state->m_cmat[4], state->m_cmat[5], state->m_cmat[6], state->m_cmat[7], state->m_cmat[8], state->m_cmat[9], state->m_cmat[10], state->m_cmat[11], - state->m_pushpc); - next_fn(state); + m_cmat[0], m_cmat[1], m_cmat[2], m_cmat[3], m_cmat[4], m_cmat[5], m_cmat[6], m_cmat[7], m_cmat[8], m_cmat[9], m_cmat[10], m_cmat[11], + m_pushpc); + next_fn(); } -static TGP_FUNCTION( clear_stack ) +TGP_FUNCTION( model1_state::clear_stack ) { - model1_state *state = machine.driver_data(); - logerror("TGP clear_stack (%x)\n", state->m_pushpc); - state->m_mat_stack_pos = 0; - next_fn(state); + logerror("TGP clear_stack (%x)\n", m_pushpc); + m_mat_stack_pos = 0; + next_fn(); } -static TGP_FUNCTION( matrix_mul ) +TGP_FUNCTION( model1_state::matrix_mul ) { - model1_state *state = machine.driver_data(); float m[12]; - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); - float d = fifoin_pop_f(state); - float e = fifoin_pop_f(state); - float f = fifoin_pop_f(state); - float g = fifoin_pop_f(state); - float h = fifoin_pop_f(state); - float i = fifoin_pop_f(state); - float j = fifoin_pop_f(state); - float k = fifoin_pop_f(state); - float l = fifoin_pop_f(state); - logerror("TGP matrix_mul %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f (%x)\n", a, b, c, d, e, f, g, h, i, j, k, l, state->m_pushpc); - m[0] = a*state->m_cmat[0] + b*state->m_cmat[3] + c*state->m_cmat[6]; - m[1] = a*state->m_cmat[1] + b*state->m_cmat[4] + c*state->m_cmat[7]; - m[2] = a*state->m_cmat[2] + b*state->m_cmat[5] + c*state->m_cmat[8]; - m[3] = d*state->m_cmat[0] + e*state->m_cmat[3] + f*state->m_cmat[6]; - m[4] = d*state->m_cmat[1] + e*state->m_cmat[4] + f*state->m_cmat[7]; - m[5] = d*state->m_cmat[2] + e*state->m_cmat[5] + f*state->m_cmat[8]; - m[6] = g*state->m_cmat[0] + h*state->m_cmat[3] + i*state->m_cmat[6]; - m[7] = g*state->m_cmat[1] + h*state->m_cmat[4] + i*state->m_cmat[7]; - m[8] = g*state->m_cmat[2] + h*state->m_cmat[5] + i*state->m_cmat[8]; - m[9] = j*state->m_cmat[0] + k*state->m_cmat[3] + l*state->m_cmat[6] + state->m_cmat[9]; - m[10] = j*state->m_cmat[1] + k*state->m_cmat[4] + l*state->m_cmat[7] + state->m_cmat[10]; - m[11] = j*state->m_cmat[2] + k*state->m_cmat[5] + l*state->m_cmat[8] + state->m_cmat[11]; + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); + float d = fifoin_pop_f(); + float e = fifoin_pop_f(); + float f = fifoin_pop_f(); + float g = fifoin_pop_f(); + float h = fifoin_pop_f(); + float i = fifoin_pop_f(); + float j = fifoin_pop_f(); + float k = fifoin_pop_f(); + float l = fifoin_pop_f(); + logerror("TGP matrix_mul %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f (%x)\n", a, b, c, d, e, f, g, h, i, j, k, l, m_pushpc); + m[0] = a*m_cmat[0] + b*m_cmat[3] + c*m_cmat[6]; + m[1] = a*m_cmat[1] + b*m_cmat[4] + c*m_cmat[7]; + m[2] = a*m_cmat[2] + b*m_cmat[5] + c*m_cmat[8]; + m[3] = d*m_cmat[0] + e*m_cmat[3] + f*m_cmat[6]; + m[4] = d*m_cmat[1] + e*m_cmat[4] + f*m_cmat[7]; + m[5] = d*m_cmat[2] + e*m_cmat[5] + f*m_cmat[8]; + m[6] = g*m_cmat[0] + h*m_cmat[3] + i*m_cmat[6]; + m[7] = g*m_cmat[1] + h*m_cmat[4] + i*m_cmat[7]; + m[8] = g*m_cmat[2] + h*m_cmat[5] + i*m_cmat[8]; + m[9] = j*m_cmat[0] + k*m_cmat[3] + l*m_cmat[6] + m_cmat[9]; + m[10] = j*m_cmat[1] + k*m_cmat[4] + l*m_cmat[7] + m_cmat[10]; + m[11] = j*m_cmat[2] + k*m_cmat[5] + l*m_cmat[8] + m_cmat[11]; - memcpy(state->m_cmat, m, sizeof(m)); - next_fn(state); + memcpy(m_cmat, m, sizeof(m)); + next_fn(); } -static TGP_FUNCTION( anglev ) +TGP_FUNCTION( model1_state::anglev ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - logerror("TGP anglev %f, %f (%x)\n", a, b, state->m_pushpc); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + logerror("TGP anglev %f, %f (%x)\n", a, b, m_pushpc); if(!b) { if(a>=0) - fifoout_push(state, 0); + fifoout_push(0); else - fifoout_push(state, (UINT32)-32768); + fifoout_push((UINT32)-32768); } else if(!a) { if(b>=0) - fifoout_push(state, 16384); + fifoout_push(16384); else - fifoout_push(state, (UINT32)-16384); + fifoout_push((UINT32)-16384); } else - fifoout_push(state, (INT16)(atan2(b, a)*32768/M_PI)); - next_fn(state); + fifoout_push((INT16)(atan2(b, a)*32768/M_PI)); + next_fn(); } -static TGP_FUNCTION( f11 ) +TGP_FUNCTION( model1_state::f11 ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); - float d = fifoin_pop_f(state); - float e = fifoin_pop_f(state); - float f = fifoin_pop_f(state); - float g = fifoin_pop_f(state); - float h = fifoin_pop_f(state); - float i = fifoin_pop_f(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); + float d = fifoin_pop_f(); + float e = fifoin_pop_f(); + float f = fifoin_pop_f(); + float g = fifoin_pop_f(); + float h = fifoin_pop_f(); + float i = fifoin_pop_f(); (void)a; (void)b; (void)c; @@ -283,250 +265,235 @@ static TGP_FUNCTION( f11 ) (void)g; (void)h; (void)i; - logerror("TGP f11 %f, %f, %f, %f, %f, %f, %f, %f, %f (%x)\n", a, b, c, d, e, f, g, h, i, state->m_pushpc); - fifoout_push_f(state, 0); - fifoout_push_f(state, 0); - fifoout_push_f(state, 0); - next_fn(state); + logerror("TGP f11 %f, %f, %f, %f, %f, %f, %f, %f, %f (%x)\n", a, b, c, d, e, f, g, h, i, m_pushpc); + fifoout_push_f(0); + fifoout_push_f(0); + fifoout_push_f(0); + next_fn(); } -static TGP_FUNCTION( normalize ) +TGP_FUNCTION( model1_state::normalize ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); float n = (a*a+b*b+c*c) / sqrt(a*a+b*b+c*c); - logerror("TGP normalize %f, %f, %f (%x)\n", a, b, c, state->m_pushpc); - fifoout_push_f(state, a/n); - fifoout_push_f(state, b/n); - fifoout_push_f(state, c/n); - next_fn(state); + logerror("TGP normalize %f, %f, %f (%x)\n", a, b, c, m_pushpc); + fifoout_push_f(a/n); + fifoout_push_f(b/n); + fifoout_push_f(c/n); + next_fn(); } -static TGP_FUNCTION( acc_seti ) +TGP_FUNCTION( model1_state::acc_seti ) { - model1_state *state = machine.driver_data(); - INT32 a = fifoin_pop(state); - state->m_dump = 1; - logerror("TGP acc_seti %d (%x)\n", a, state->m_pushpc); - state->m_acc = a; - next_fn(state); + INT32 a = fifoin_pop(); + m_dump = 1; + logerror("TGP acc_seti %d (%x)\n", a, m_pushpc); + m_acc = a; + next_fn(); } -static TGP_FUNCTION( track_select ) +TGP_FUNCTION( model1_state::track_select ) { - model1_state *state = machine.driver_data(); - INT32 a = fifoin_pop(state); - logerror("TGP track_select %d (%x)\n", a, state->m_pushpc); - state->m_tgp_vr_select = a; - next_fn(state); + INT32 a = fifoin_pop(); + logerror("TGP track_select %d (%x)\n", a, m_pushpc); + m_tgp_vr_select = a; + next_fn(); } -static TGP_FUNCTION( f14 ) +TGP_FUNCTION( model1_state::f14 ) { - model1_state *state = machine.driver_data(); - state->m_tgp_vr_base[0] = fifoin_pop_f(state); - state->m_tgp_vr_base[1] = fifoin_pop_f(state); - state->m_tgp_vr_base[2] = fifoin_pop_f(state); - state->m_tgp_vr_base[3] = fifoin_pop_f(state); + m_tgp_vr_base[0] = fifoin_pop_f(); + m_tgp_vr_base[1] = fifoin_pop_f(); + m_tgp_vr_base[2] = fifoin_pop_f(); + m_tgp_vr_base[3] = fifoin_pop_f(); - next_fn(state); + next_fn(); } -static TGP_FUNCTION( f15_swa ) +TGP_FUNCTION( model1_state::f15_swa ) { - model1_state *state = machine.driver_data(); - logerror("TGP f15_swa (%x)\n", state->m_pushpc); + logerror("TGP f15_swa (%x)\n", m_pushpc); - next_fn(state); + next_fn(); } -static TGP_FUNCTION( anglep ) +TGP_FUNCTION( model1_state::anglep ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); - float d = fifoin_pop_f(state); - logerror("TGP anglep %f, %f, %f, %f (%x)\n", a, b, c, d, state->m_pushpc); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); + float d = fifoin_pop_f(); + logerror("TGP anglep %f, %f, %f, %f (%x)\n", a, b, c, d, m_pushpc); c = a - c; d = b - d; if(!d) { if(c>=0) - fifoout_push(state, 0); + fifoout_push(0); else - fifoout_push(state, (UINT32)-32768); + fifoout_push((UINT32)-32768); } else if(!c) { if(d>=0) - fifoout_push(state, 16384); + fifoout_push(16384); else - fifoout_push(state, (UINT32)-16384); + fifoout_push((UINT32)-16384); } else - fifoout_push(state, (INT16)(atan2(d, c)*32768/M_PI)); - next_fn(state); + fifoout_push((INT16)(atan2(d, c)*32768/M_PI)); + next_fn(); } -static TGP_FUNCTION( matrix_ident ) +TGP_FUNCTION( model1_state::matrix_ident ) { - model1_state *state = machine.driver_data(); - logerror("TGP matrix_ident (%x)\n", state->m_pushpc); - memset(state->m_cmat, 0, sizeof(state->m_cmat)); - state->m_cmat[0] = 1.0; - state->m_cmat[4] = 1.0; - state->m_cmat[8] = 1.0; - next_fn(state); + logerror("TGP matrix_ident (%x)\n", m_pushpc); + memset(m_cmat, 0, sizeof(m_cmat)); + m_cmat[0] = 1.0; + m_cmat[4] = 1.0; + m_cmat[8] = 1.0; + next_fn(); } -static TGP_FUNCTION( matrix_read ) +TGP_FUNCTION( model1_state::matrix_read ) { - model1_state *state = machine.driver_data(); int i; logerror("TGP matrix_read (%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f) (%x)\n", - state->m_cmat[0], state->m_cmat[1], state->m_cmat[2], state->m_cmat[3], state->m_cmat[4], state->m_cmat[5], state->m_cmat[6], state->m_cmat[7], state->m_cmat[8], state->m_cmat[9], state->m_cmat[10], state->m_cmat[11], state->m_pushpc); + m_cmat[0], m_cmat[1], m_cmat[2], m_cmat[3], m_cmat[4], m_cmat[5], m_cmat[6], m_cmat[7], m_cmat[8], m_cmat[9], m_cmat[10], m_cmat[11], m_pushpc); for(i=0; i<12; i++) - fifoout_push_f(state, state->m_cmat[i]); - next_fn(state); + fifoout_push_f(m_cmat[i]); + next_fn(); } -static TGP_FUNCTION( matrix_trans ) +TGP_FUNCTION( model1_state::matrix_trans ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); - state->m_cmat[ 9] += state->m_cmat[0]*a+state->m_cmat[3]*b+state->m_cmat[6]*c; - state->m_cmat[10] += state->m_cmat[1]*a+state->m_cmat[4]*b+state->m_cmat[7]*c; - state->m_cmat[11] += state->m_cmat[2]*a+state->m_cmat[5]*b+state->m_cmat[8]*c; - next_fn(state); + m_cmat[ 9] += m_cmat[0]*a+m_cmat[3]*b+m_cmat[6]*c; + m_cmat[10] += m_cmat[1]*a+m_cmat[4]*b+m_cmat[7]*c; + m_cmat[11] += m_cmat[2]*a+m_cmat[5]*b+m_cmat[8]*c; + next_fn(); } -static TGP_FUNCTION( matrix_scale ) +TGP_FUNCTION( model1_state::matrix_scale ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); - logerror("TGP matrix_scale %f, %f, %f (%x)\n", a, b, c, state->m_pushpc); - state->m_cmat[0] *= a; - state->m_cmat[1] *= a; - state->m_cmat[2] *= a; - state->m_cmat[3] *= b; - state->m_cmat[4] *= b; - state->m_cmat[5] *= b; - state->m_cmat[6] *= c; - state->m_cmat[7] *= c; - state->m_cmat[8] *= c; - next_fn(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); + logerror("TGP matrix_scale %f, %f, %f (%x)\n", a, b, c, m_pushpc); + m_cmat[0] *= a; + m_cmat[1] *= a; + m_cmat[2] *= a; + m_cmat[3] *= b; + m_cmat[4] *= b; + m_cmat[5] *= b; + m_cmat[6] *= c; + m_cmat[7] *= c; + m_cmat[8] *= c; + next_fn(); } -static TGP_FUNCTION( matrix_rotx ) +TGP_FUNCTION( model1_state::matrix_rotx ) { - model1_state *state = machine.driver_data(); - INT16 a = fifoin_pop(state); + INT16 a = fifoin_pop(); float s = tsin(a); float c = tcos(a); float t1, t2; - logerror("TGP matrix_rotx %d (%x)\n", a, state->m_pushpc); - t1 = state->m_cmat[3]; - t2 = state->m_cmat[6]; - state->m_cmat[3] = c*t1-s*t2; - state->m_cmat[6] = s*t1+c*t2; - t1 = state->m_cmat[4]; - t2 = state->m_cmat[7]; - state->m_cmat[4] = c*t1-s*t2; - state->m_cmat[7] = s*t1+c*t2; - t1 = state->m_cmat[5]; - t2 = state->m_cmat[8]; - state->m_cmat[5] = c*t1-s*t2; - state->m_cmat[8] = s*t1+c*t2; - next_fn(state); + logerror("TGP matrix_rotx %d (%x)\n", a, m_pushpc); + t1 = m_cmat[3]; + t2 = m_cmat[6]; + m_cmat[3] = c*t1-s*t2; + m_cmat[6] = s*t1+c*t2; + t1 = m_cmat[4]; + t2 = m_cmat[7]; + m_cmat[4] = c*t1-s*t2; + m_cmat[7] = s*t1+c*t2; + t1 = m_cmat[5]; + t2 = m_cmat[8]; + m_cmat[5] = c*t1-s*t2; + m_cmat[8] = s*t1+c*t2; + next_fn(); } -static TGP_FUNCTION( matrix_roty ) +TGP_FUNCTION( model1_state::matrix_roty ) { - model1_state *state = machine.driver_data(); - INT16 a = fifoin_pop(state); + INT16 a = fifoin_pop(); float s = tsin(a); float c = tcos(a); float t1, t2; - logerror("TGP matrix_roty %d (%x)\n", a, state->m_pushpc); - t1 = state->m_cmat[6]; - t2 = state->m_cmat[0]; - state->m_cmat[6] = c*t1-s*t2; - state->m_cmat[0] = s*t1+c*t2; - t1 = state->m_cmat[7]; - t2 = state->m_cmat[1]; - state->m_cmat[7] = c*t1-s*t2; - state->m_cmat[1] = s*t1+c*t2; - t1 = state->m_cmat[8]; - t2 = state->m_cmat[2]; - state->m_cmat[8] = c*t1-s*t2; - state->m_cmat[2] = s*t1+c*t2; - next_fn(state); + logerror("TGP matrix_roty %d (%x)\n", a, m_pushpc); + t1 = m_cmat[6]; + t2 = m_cmat[0]; + m_cmat[6] = c*t1-s*t2; + m_cmat[0] = s*t1+c*t2; + t1 = m_cmat[7]; + t2 = m_cmat[1]; + m_cmat[7] = c*t1-s*t2; + m_cmat[1] = s*t1+c*t2; + t1 = m_cmat[8]; + t2 = m_cmat[2]; + m_cmat[8] = c*t1-s*t2; + m_cmat[2] = s*t1+c*t2; + next_fn(); } -static TGP_FUNCTION( matrix_rotz ) +TGP_FUNCTION( model1_state::matrix_rotz ) { - model1_state *state = machine.driver_data(); - INT16 a = fifoin_pop(state); + INT16 a = fifoin_pop(); float s = tsin(a); float c = tcos(a); float t1, t2; - logerror("TGP matrix_rotz %d (%x)\n", a, state->m_pushpc); - t1 = state->m_cmat[0]; - t2 = state->m_cmat[3]; - state->m_cmat[0] = c*t1-s*t2; - state->m_cmat[3] = s*t1+c*t2; - t1 = state->m_cmat[1]; - t2 = state->m_cmat[4]; - state->m_cmat[1] = c*t1-s*t2; - state->m_cmat[4] = s*t1+c*t2; - t1 = state->m_cmat[2]; - t2 = state->m_cmat[5]; - state->m_cmat[2] = c*t1-s*t2; - state->m_cmat[5] = s*t1+c*t2; - next_fn(state); + logerror("TGP matrix_rotz %d (%x)\n", a, m_pushpc); + t1 = m_cmat[0]; + t2 = m_cmat[3]; + m_cmat[0] = c*t1-s*t2; + m_cmat[3] = s*t1+c*t2; + t1 = m_cmat[1]; + t2 = m_cmat[4]; + m_cmat[1] = c*t1-s*t2; + m_cmat[4] = s*t1+c*t2; + t1 = m_cmat[2]; + t2 = m_cmat[5]; + m_cmat[2] = c*t1-s*t2; + m_cmat[5] = s*t1+c*t2; + next_fn(); } -static TGP_FUNCTION( track_read_quad ) +TGP_FUNCTION( model1_state::track_read_quad ) { - model1_state *state = machine.driver_data(); - const UINT32 *tgp_data = (const UINT32 *)state->memregion("user2")->base(); - UINT32 a = fifoin_pop(state); + const UINT32 *tgp_data = (const UINT32 *)memregion("user2")->base(); + UINT32 a = fifoin_pop(); int offd; - logerror("TGP track_read_quad %d (%x)\n", a, state->m_pushpc); + logerror("TGP track_read_quad %d (%x)\n", a, m_pushpc); - offd = tgp_data[0x20+state->m_tgp_vr_select] + 16*a; - fifoout_push(state, tgp_data[offd]); - fifoout_push(state, tgp_data[offd+1]); - fifoout_push(state, tgp_data[offd+2]); - fifoout_push(state, tgp_data[offd+3]); - fifoout_push(state, tgp_data[offd+4]); - fifoout_push(state, tgp_data[offd+5]); - fifoout_push(state, tgp_data[offd+6]); - fifoout_push(state, tgp_data[offd+7]); - fifoout_push(state, tgp_data[offd+8]); - fifoout_push(state, tgp_data[offd+9]); - fifoout_push(state, tgp_data[offd+10]); - fifoout_push(state, tgp_data[offd+11]); - next_fn(state); + offd = tgp_data[0x20+m_tgp_vr_select] + 16*a; + fifoout_push(tgp_data[offd]); + fifoout_push(tgp_data[offd+1]); + fifoout_push(tgp_data[offd+2]); + fifoout_push(tgp_data[offd+3]); + fifoout_push(tgp_data[offd+4]); + fifoout_push(tgp_data[offd+5]); + fifoout_push(tgp_data[offd+6]); + fifoout_push(tgp_data[offd+7]); + fifoout_push(tgp_data[offd+8]); + fifoout_push(tgp_data[offd+9]); + fifoout_push(tgp_data[offd+10]); + fifoout_push(tgp_data[offd+11]); + next_fn(); } -static TGP_FUNCTION( f24_swa ) +TGP_FUNCTION( model1_state::f24_swa ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); - float d = fifoin_pop_f(state); - float e = fifoin_pop_f(state); - float f = fifoin_pop_f(state); - UINT32 g = fifoin_pop(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); + float d = fifoin_pop_f(); + float e = fifoin_pop_f(); + float f = fifoin_pop_f(); + UINT32 g = fifoin_pop(); (void)a; (void)b; (void)c; @@ -534,274 +501,254 @@ static TGP_FUNCTION( f24_swa ) (void)e; (void)f; (void)g; - logerror("TGP f24_swa %f, %f, %f, %f, %f, %f, %x (%x)\n", a, b, c, d, e, f, g, state->m_pushpc); - fifoout_push_f(state, 0); - next_fn(state); + logerror("TGP f24_swa %f, %f, %f, %f, %f, %f, %x (%x)\n", a, b, c, d, e, f, g, m_pushpc); + fifoout_push_f(0); + next_fn(); } -static TGP_FUNCTION( transform_point ) +TGP_FUNCTION( model1_state::transform_point ) { - model1_state *state = machine.driver_data(); - float x = fifoin_pop_f(state); - float y = fifoin_pop_f(state); - float z = fifoin_pop_f(state); - logerror("TGP transform_point %f, %f, %f (%x)\n", x, y, z, state->m_pushpc); + float x = fifoin_pop_f(); + float y = fifoin_pop_f(); + float z = fifoin_pop_f(); + logerror("TGP transform_point %f, %f, %f (%x)\n", x, y, z, m_pushpc); - fifoout_push_f(state, state->m_cmat[0]*x+state->m_cmat[3]*y+state->m_cmat[6]*z+state->m_cmat[9]); - fifoout_push_f(state, state->m_cmat[1]*x+state->m_cmat[4]*y+state->m_cmat[7]*z+state->m_cmat[10]); - fifoout_push_f(state, state->m_cmat[2]*x+state->m_cmat[5]*y+state->m_cmat[8]*z+state->m_cmat[11]); - next_fn(state); + fifoout_push_f(m_cmat[0]*x+m_cmat[3]*y+m_cmat[6]*z+m_cmat[9]); + fifoout_push_f(m_cmat[1]*x+m_cmat[4]*y+m_cmat[7]*z+m_cmat[10]); + fifoout_push_f(m_cmat[2]*x+m_cmat[5]*y+m_cmat[8]*z+m_cmat[11]); + next_fn(); } -static TGP_FUNCTION( fcos_m1 ) +TGP_FUNCTION( model1_state::fcos_m1 ) { - model1_state *state = machine.driver_data(); - INT16 a = fifoin_pop(state); - logerror("TGP fcos %d (%x)\n", a, state->m_pushpc); - fifoout_push_f(state, tcos(a)); - next_fn(state); + INT16 a = fifoin_pop(); + logerror("TGP fcos %d (%x)\n", a, m_pushpc); + fifoout_push_f(tcos(a)); + next_fn(); } -static TGP_FUNCTION( fsin_m1 ) +TGP_FUNCTION( model1_state::fsin_m1 ) { - model1_state *state = machine.driver_data(); - INT16 a = fifoin_pop(state); - logerror("TGP fsin %d (%x)\n", a, state->m_pushpc); - fifoout_push_f(state, tsin(a)); - next_fn(state); + INT16 a = fifoin_pop(); + logerror("TGP fsin %d (%x)\n", a, m_pushpc); + fifoout_push_f(tsin(a)); + next_fn(); } -static TGP_FUNCTION( fcosm_m1 ) +TGP_FUNCTION( model1_state::fcosm_m1 ) { - model1_state *state = machine.driver_data(); - INT16 a = fifoin_pop(state); - float b = fifoin_pop_f(state); - logerror("TGP fcosm %d, %f (%x)\n", a, b, state->m_pushpc); - fifoout_push_f(state, b*tcos(a)); - next_fn(state); + INT16 a = fifoin_pop(); + float b = fifoin_pop_f(); + logerror("TGP fcosm %d, %f (%x)\n", a, b, m_pushpc); + fifoout_push_f(b*tcos(a)); + next_fn(); } -static TGP_FUNCTION( fsinm_m1 ) +TGP_FUNCTION( model1_state::fsinm_m1 ) { - model1_state *state = machine.driver_data(); - INT16 a = fifoin_pop(state); - float b = fifoin_pop_f(state); - state->m_dump = 1; - logerror("TGP fsinm %d, %f (%x)\n", a, b, state->m_pushpc); - fifoout_push_f(state, b*tsin(a)); - next_fn(state); + INT16 a = fifoin_pop(); + float b = fifoin_pop_f(); + m_dump = 1; + logerror("TGP fsinm %d, %f (%x)\n", a, b, m_pushpc); + fifoout_push_f(b*tsin(a)); + next_fn(); } -static TGP_FUNCTION( distance3 ) +TGP_FUNCTION( model1_state::distance3 ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); - float d = fifoin_pop_f(state); - float e = fifoin_pop_f(state); - float f = fifoin_pop_f(state); - logerror("TGP distance3 (%f, %f, %f), (%f, %f, %f) (%x)\n", a, b, c, d, e, f, state->m_pushpc); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); + float d = fifoin_pop_f(); + float e = fifoin_pop_f(); + float f = fifoin_pop_f(); + logerror("TGP distance3 (%f, %f, %f), (%f, %f, %f) (%x)\n", a, b, c, d, e, f, m_pushpc); a -= d; b -= e; c -= f; - fifoout_push_f(state, (a*a+b*b+c*c)/sqrt(a*a+b*b+c*c)); - next_fn(state); + fifoout_push_f((a*a+b*b+c*c)/sqrt(a*a+b*b+c*c)); + next_fn(); } -static TGP_FUNCTION( ftoi ) +TGP_FUNCTION( model1_state::ftoi ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - logerror("TGP ftoi %f (%x)\n", a, state->m_pushpc); - fifoout_push(state, (int)a); - next_fn(state); + float a = fifoin_pop_f(); + logerror("TGP ftoi %f (%x)\n", a, m_pushpc); + fifoout_push((int)a); + next_fn(); } -static TGP_FUNCTION( itof ) +TGP_FUNCTION( model1_state::itof ) { - model1_state *state = machine.driver_data(); - INT32 a = fifoin_pop(state); - logerror("TGP itof %d (%x)\n", a, state->m_pushpc); - fifoout_push_f(state, a); - next_fn(state); + INT32 a = fifoin_pop(); + logerror("TGP itof %d (%x)\n", a, m_pushpc); + fifoout_push_f(a); + next_fn(); } -static TGP_FUNCTION( acc_set ) +TGP_FUNCTION( model1_state::acc_set ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - logerror("TGP acc_set %f (%x)\n", a, state->m_pushpc); - state->m_acc = a; - next_fn(state); + float a = fifoin_pop_f(); + logerror("TGP acc_set %f (%x)\n", a, m_pushpc); + m_acc = a; + next_fn(); } -static TGP_FUNCTION( acc_get ) +TGP_FUNCTION( model1_state::acc_get ) { - model1_state *state = machine.driver_data(); - logerror("TGP acc_get (%x)\n", state->m_pushpc); - fifoout_push_f(state, state->m_acc); - next_fn(state); + logerror("TGP acc_get (%x)\n", m_pushpc); + fifoout_push_f(m_acc); + next_fn(); } -static TGP_FUNCTION( acc_add ) +TGP_FUNCTION( model1_state::acc_add ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - logerror("TGP acc_add %f (%x)\n", a, state->m_pushpc); - state->m_acc += a; - next_fn(state); + float a = fifoin_pop_f(); + logerror("TGP acc_add %f (%x)\n", a, m_pushpc); + m_acc += a; + next_fn(); } -static TGP_FUNCTION( acc_sub ) +TGP_FUNCTION( model1_state::acc_sub ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - logerror("TGP acc_sub %f (%x)\n", a, state->m_pushpc); - state->m_acc -= a; - next_fn(state); + float a = fifoin_pop_f(); + logerror("TGP acc_sub %f (%x)\n", a, m_pushpc); + m_acc -= a; + next_fn(); } -static TGP_FUNCTION( acc_mul ) +TGP_FUNCTION( model1_state::acc_mul ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - logerror("TGP acc_mul %f (%x)\n", a, state->m_pushpc); - state->m_acc *= a; - next_fn(state); + float a = fifoin_pop_f(); + logerror("TGP acc_mul %f (%x)\n", a, m_pushpc); + m_acc *= a; + next_fn(); } -static TGP_FUNCTION( acc_div ) +TGP_FUNCTION( model1_state::acc_div ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - logerror("TGP acc_div %f (%x)\n", a, state->m_pushpc); - state->m_acc /= a; - next_fn(state); + float a = fifoin_pop_f(); + logerror("TGP acc_div %f (%x)\n", a, m_pushpc); + m_acc /= a; + next_fn(); } -static TGP_FUNCTION( f42 ) +TGP_FUNCTION( model1_state::f42 ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); (void)a; (void)b; (void)c; - logerror("TGP f42 %f, %f, %f (%x)\n", a, b, c, state->m_pushpc); - // fifoout_push_f((machine.rand() % 1000) - 500); - fifoout_push_f(state, 0); - fifoout_push_f(state, 0); - fifoout_push_f(state, 0); - fifoout_push_f(state, 0); - fifoout_push_f(state, 0); - fifoout_push_f(state, 0); - next_fn(state); + logerror("TGP f42 %f, %f, %f (%x)\n", a, b, c, m_pushpc); + // fifoout_push_f((machine().rand() % 1000) - 500); + fifoout_push_f(0); + fifoout_push_f(0); + fifoout_push_f(0); + fifoout_push_f(0); + fifoout_push_f(0); + fifoout_push_f(0); + next_fn(); } // r = (x2 + y2 + z2)1/2, f = tan-1(y/(x2+z2)1/2), q = tan-1(z/x) -static TGP_FUNCTION( xyz2rqf ) +TGP_FUNCTION( model1_state::xyz2rqf ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); float norm; (void)a; (void)b; (void)c; - logerror("TGP xyz2rqf %f, %f, %f (%x)\n", a, b, c, state->m_pushpc); - fifoout_push_f(state, (a*a+b*b+c*c)/sqrt(a*a+b*b+c*c)); + logerror("TGP xyz2rqf %f, %f, %f (%x)\n", a, b, c, m_pushpc); + fifoout_push_f((a*a+b*b+c*c)/sqrt(a*a+b*b+c*c)); norm = sqrt(a*a+c*c); if(!c) { if(a>=0) - fifoout_push(state, 0); + fifoout_push(0); else - fifoout_push(state, (UINT32)-32768); + fifoout_push((UINT32)-32768); } else if(!a) { if(c>=0) - fifoout_push(state, 16384); + fifoout_push(16384); else - fifoout_push(state, (UINT32)-16384); + fifoout_push((UINT32)-16384); } else - fifoout_push(state, (INT16)(atan2(c, a)*32768/M_PI)); + fifoout_push((INT16)(atan2(c, a)*32768/M_PI)); if(!b) - fifoout_push(state, 0); + fifoout_push(0); else if(!norm) { if(b>=0) - fifoout_push(state, 16384); + fifoout_push(16384); else - fifoout_push(state, (UINT32)-16384); + fifoout_push((UINT32)-16384); } else - fifoout_push(state, (INT16)(atan2(b, norm)*32768/M_PI)); + fifoout_push((INT16)(atan2(b, norm)*32768/M_PI)); - next_fn(state); + next_fn(); } -static TGP_FUNCTION( f43 ) +TGP_FUNCTION( model1_state::f43 ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); - float d = fifoin_pop_f(state); - float e = fifoin_pop_f(state); - float f = fifoin_pop_f(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); + float d = fifoin_pop_f(); + float e = fifoin_pop_f(); + float f = fifoin_pop_f(); (void)a; (void)b; (void)c; (void)d; (void)e; (void)f; - logerror("TGP f43 %f, %f, %f, %f, %f, %f (%x)\n", a, b, c, d, e, f, state->m_pushpc); - fifoout_push_f(state, 0); - fifoout_push_f(state, 0); - fifoout_push_f(state, 0); - fifoout_push_f(state, 0); - next_fn(state); + logerror("TGP f43 %f, %f, %f, %f, %f, %f (%x)\n", a, b, c, d, e, f, m_pushpc); + fifoout_push_f(0); + fifoout_push_f(0); + fifoout_push_f(0); + fifoout_push_f(0); + next_fn(); } -static TGP_FUNCTION( f43_swa ) +TGP_FUNCTION( model1_state::f43_swa ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - int b = fifoin_pop(state); - int c = fifoin_pop(state); + float a = fifoin_pop_f(); + int b = fifoin_pop(); + int c = fifoin_pop(); (void)a; (void)b; (void)c; - logerror("TGP f43_swa %f, %d, %d (%x)\n", a, b, c, state->m_pushpc); - fifoout_push_f(state, 0); - fifoout_push_f(state, 0); - fifoout_push_f(state, 0); - next_fn(state); + logerror("TGP f43_swa %f, %d, %d (%x)\n", a, b, c, m_pushpc); + fifoout_push_f(0); + fifoout_push_f(0); + fifoout_push_f(0); + next_fn(); } -static TGP_FUNCTION( f44 ) +TGP_FUNCTION( model1_state::f44 ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); + float a = fifoin_pop_f(); (void)a; - logerror("TGP f44 %f (%x)\n", a, state->m_pushpc); - fifoout_push_f(state, 0); - fifoout_push_f(state, 0); - fifoout_push_f(state, 0); - next_fn(state); + logerror("TGP f44 %f (%x)\n", a, m_pushpc); + fifoout_push_f(0); + fifoout_push_f(0); + fifoout_push_f(0); + next_fn(); } -static TGP_FUNCTION( matrix_sdir ) +TGP_FUNCTION( model1_state::matrix_sdir ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); float norm = sqrt(a*a+b*b+c*c); float t[9], m[9]; - logerror("TGP matrix_sdir %f, %f, %f (%x)\n", a, b, c, state->m_pushpc); + logerror("TGP matrix_sdir %f, %f, %f (%x)\n", a, b, c, m_pushpc); memset(t, 0, sizeof(t)); @@ -829,174 +776,164 @@ static TGP_FUNCTION( matrix_sdir ) t[5] /= norm; } - m[0] = t[0]*state->m_cmat[0] + t[1]*state->m_cmat[3] + t[2]*state->m_cmat[6]; - m[1] = t[0]*state->m_cmat[1] + t[1]*state->m_cmat[4] + t[2]*state->m_cmat[7]; - m[2] = t[0]*state->m_cmat[2] + t[1]*state->m_cmat[5] + t[2]*state->m_cmat[8]; - m[3] = t[3]*state->m_cmat[0] + t[4]*state->m_cmat[3] + t[5]*state->m_cmat[6]; - m[4] = t[3]*state->m_cmat[1] + t[4]*state->m_cmat[4] + t[5]*state->m_cmat[7]; - m[5] = t[3]*state->m_cmat[2] + t[4]*state->m_cmat[5] + t[5]*state->m_cmat[8]; - m[6] = t[6]*state->m_cmat[0] + t[7]*state->m_cmat[3] + t[8]*state->m_cmat[6]; - m[7] = t[6]*state->m_cmat[1] + t[7]*state->m_cmat[4] + t[8]*state->m_cmat[7]; - m[8] = t[6]*state->m_cmat[2] + t[7]*state->m_cmat[5] + t[8]*state->m_cmat[8]; + m[0] = t[0]*m_cmat[0] + t[1]*m_cmat[3] + t[2]*m_cmat[6]; + m[1] = t[0]*m_cmat[1] + t[1]*m_cmat[4] + t[2]*m_cmat[7]; + m[2] = t[0]*m_cmat[2] + t[1]*m_cmat[5] + t[2]*m_cmat[8]; + m[3] = t[3]*m_cmat[0] + t[4]*m_cmat[3] + t[5]*m_cmat[6]; + m[4] = t[3]*m_cmat[1] + t[4]*m_cmat[4] + t[5]*m_cmat[7]; + m[5] = t[3]*m_cmat[2] + t[4]*m_cmat[5] + t[5]*m_cmat[8]; + m[6] = t[6]*m_cmat[0] + t[7]*m_cmat[3] + t[8]*m_cmat[6]; + m[7] = t[6]*m_cmat[1] + t[7]*m_cmat[4] + t[8]*m_cmat[7]; + m[8] = t[6]*m_cmat[2] + t[7]*m_cmat[5] + t[8]*m_cmat[8]; - memcpy(state->m_cmat, m, sizeof(m)); + memcpy(m_cmat, m, sizeof(m)); - next_fn(state); + next_fn(); } -static TGP_FUNCTION( f45 ) +TGP_FUNCTION( model1_state::f45 ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); + float a = fifoin_pop_f(); (void)a; - logerror("TGP f45 %f (%x)\n", a, state->m_pushpc); - fifoout_push_f(state, 0); - next_fn(state); + logerror("TGP f45 %f (%x)\n", a, m_pushpc); + fifoout_push_f(0); + next_fn(); } -static TGP_FUNCTION( vlength ) +TGP_FUNCTION( model1_state::vlength ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state) - state->m_tgp_vr_base[0]; - float b = fifoin_pop_f(state) - state->m_tgp_vr_base[1]; - float c = fifoin_pop_f(state) - state->m_tgp_vr_base[2]; - logerror("TGP vlength %f, %f, %f (%x)\n", a, b, c, state->m_pushpc); + float a = fifoin_pop_f() - m_tgp_vr_base[0]; + float b = fifoin_pop_f() - m_tgp_vr_base[1]; + float c = fifoin_pop_f() - m_tgp_vr_base[2]; + logerror("TGP vlength %f, %f, %f (%x)\n", a, b, c, m_pushpc); a = (a*a+b*b+c*c); b = 1/sqrt(a); c = a * b; - c -= state->m_tgp_vr_base[3]; - fifoout_push_f(state, c); - next_fn(state); + c -= m_tgp_vr_base[3]; + fifoout_push_f(c); + next_fn(); } -static TGP_FUNCTION( f47 ) +TGP_FUNCTION( model1_state::f47 ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); - logerror("TGP f47 %f, %f, %f (%x)\n", a, b, c, state->m_pushpc); - fifoout_push_f(state, a+c); - fifoout_push_f(state, b+c); - next_fn(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); + logerror("TGP f47 %f, %f, %f (%x)\n", a, b, c, m_pushpc); + fifoout_push_f(a+c); + fifoout_push_f(b+c); + next_fn(); } -static TGP_FUNCTION( track_read_info ) +TGP_FUNCTION( model1_state::track_read_info ) { - model1_state *state = machine.driver_data(); - const UINT32 *tgp_data = (const UINT32 *)state->memregion("user2")->base(); - UINT16 a = fifoin_pop(state); + const UINT32 *tgp_data = (const UINT32 *)memregion("user2")->base(); + UINT16 a = fifoin_pop(); int offd; - logerror("TGP track_read_info %d (%x)\n", a, state->m_pushpc); + logerror("TGP track_read_info %d (%x)\n", a, m_pushpc); - offd = tgp_data[0x20+state->m_tgp_vr_select] + 16*a; - fifoout_push(state, tgp_data[offd+15]); - next_fn(state); + offd = tgp_data[0x20+m_tgp_vr_select] + 16*a; + fifoout_push(tgp_data[offd+15]); + next_fn(); } -static TGP_FUNCTION( colbox_set ) +TGP_FUNCTION( model1_state::colbox_set ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); - float d = fifoin_pop_f(state); - float e = fifoin_pop_f(state); - float f = fifoin_pop_f(state); - float g = fifoin_pop_f(state); - float h = fifoin_pop_f(state); - float i = fifoin_pop_f(state); - float j = fifoin_pop_f(state); - float k = fifoin_pop_f(state); - float l = fifoin_pop_f(state); - logerror("TGP colbox_set %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f (%x)\n", a, b, c, d, e, f, g, h, i, j, k, l, state->m_pushpc); - state->m_tgp_vr_cbox[ 0] = a; - state->m_tgp_vr_cbox[ 1] = b; - state->m_tgp_vr_cbox[ 2] = c; - state->m_tgp_vr_cbox[ 3] = d; - state->m_tgp_vr_cbox[ 4] = e; - state->m_tgp_vr_cbox[ 5] = f; - state->m_tgp_vr_cbox[ 6] = g; - state->m_tgp_vr_cbox[ 7] = h; - state->m_tgp_vr_cbox[ 8] = i; - state->m_tgp_vr_cbox[ 9] = j; - state->m_tgp_vr_cbox[10] = k; - state->m_tgp_vr_cbox[11] = l; - next_fn(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); + float d = fifoin_pop_f(); + float e = fifoin_pop_f(); + float f = fifoin_pop_f(); + float g = fifoin_pop_f(); + float h = fifoin_pop_f(); + float i = fifoin_pop_f(); + float j = fifoin_pop_f(); + float k = fifoin_pop_f(); + float l = fifoin_pop_f(); + logerror("TGP colbox_set %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f (%x)\n", a, b, c, d, e, f, g, h, i, j, k, l, m_pushpc); + m_tgp_vr_cbox[ 0] = a; + m_tgp_vr_cbox[ 1] = b; + m_tgp_vr_cbox[ 2] = c; + m_tgp_vr_cbox[ 3] = d; + m_tgp_vr_cbox[ 4] = e; + m_tgp_vr_cbox[ 5] = f; + m_tgp_vr_cbox[ 6] = g; + m_tgp_vr_cbox[ 7] = h; + m_tgp_vr_cbox[ 8] = i; + m_tgp_vr_cbox[ 9] = j; + m_tgp_vr_cbox[10] = k; + m_tgp_vr_cbox[11] = l; + next_fn(); } -static TGP_FUNCTION( colbox_test ) +TGP_FUNCTION( model1_state::colbox_test ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); (void)a; (void)b; (void)c; - logerror("TGP colbox_test %f, %f, %f (%x)\n", a, b, c, state->m_pushpc); + logerror("TGP colbox_test %f, %f, %f (%x)\n", a, b, c, m_pushpc); // #### Wrong, need to check with the tgp_vr_cbox coordinates // Game only test sign, negative = collision - fifoout_push_f(state, -1); - next_fn(state); + fifoout_push_f(-1); + next_fn(); } -static TGP_FUNCTION( f49_swa ) +TGP_FUNCTION( model1_state::f49_swa ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); - float d = fifoin_pop_f(state); - float e = fifoin_pop_f(state); - float f = fifoin_pop_f(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); + float d = fifoin_pop_f(); + float e = fifoin_pop_f(); + float f = fifoin_pop_f(); (void)a; (void)b; (void)c; (void)d; (void)e; (void)f; - logerror("TGP f49_swa %f, %f, %f, %f, %f, %f (%x)\n", a, b, c, d, e, f, state->m_pushpc); - next_fn(state); + logerror("TGP f49_swa %f, %f, %f, %f, %f, %f (%x)\n", a, b, c, d, e, f, m_pushpc); + next_fn(); } -static TGP_FUNCTION( f50_swa ) +TGP_FUNCTION( model1_state::f50_swa ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); - float d = fifoin_pop_f(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); + float d = fifoin_pop_f(); (void)a; (void)b; (void)c; (void)d; - logerror("TGP f50_swa %f, %f, %f, %f (%x)\n", a, b, c, d, state->m_pushpc); - fifoout_push_f(state, d); - next_fn(state); + logerror("TGP f50_swa %f, %f, %f, %f (%x)\n", a, b, c, d, m_pushpc); + fifoout_push_f(d); + next_fn(); } -static TGP_FUNCTION( f52 ) +TGP_FUNCTION( model1_state::f52 ) { - model1_state *state = machine.driver_data(); - logerror("TGP f52 (%x)\n", state->m_pushpc); - next_fn(state); + logerror("TGP f52 (%x)\n", m_pushpc); + next_fn(); } -static TGP_FUNCTION( matrix_rdir ) +TGP_FUNCTION( model1_state::matrix_rdir ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); float norm = sqrt(a*a+c*c); float t1, t2; (void)b; - logerror("TGP matrix_rdir %f, %f, %f (%x)\n", a, b, c, state->m_pushpc); + logerror("TGP matrix_rdir %f, %f, %f (%x)\n", a, b, c, m_pushpc); if(!norm) { c = 1; @@ -1006,19 +943,19 @@ static TGP_FUNCTION( matrix_rdir ) a /= norm; } - t1 = state->m_cmat[6]; - t2 = state->m_cmat[0]; - state->m_cmat[6] = c*t1-a*t2; - state->m_cmat[0] = a*t1+c*t2; - t1 = state->m_cmat[7]; - t2 = state->m_cmat[1]; - state->m_cmat[7] = c*t1-a*t2; - state->m_cmat[1] = a*t1+c*t2; - t1 = state->m_cmat[8]; - t2 = state->m_cmat[2]; - state->m_cmat[8] = c*t1-a*t2; - state->m_cmat[2] = a*t1+c*t2; - next_fn(state); + t1 = m_cmat[6]; + t2 = m_cmat[0]; + m_cmat[6] = c*t1-a*t2; + m_cmat[0] = a*t1+c*t2; + t1 = m_cmat[7]; + t2 = m_cmat[1]; + m_cmat[7] = c*t1-a*t2; + m_cmat[1] = a*t1+c*t2; + t1 = m_cmat[8]; + t2 = m_cmat[2]; + m_cmat[8] = c*t1-a*t2; + m_cmat[2] = a*t1+c*t2; + next_fn(); } // A+(B-A)*t1 + (C-A)*t2 = P @@ -1036,24 +973,23 @@ static void tri_calc_pq(float ax, float ay, float bx, float by, float cx, float *t2 = (bx*py-by*px)/d; } -static TGP_FUNCTION( track_lookup ) +TGP_FUNCTION( model1_state::track_lookup ) { - model1_state *state = machine.driver_data(); - const UINT32 *tgp_data = (const UINT32 *)state->memregion("user2")->base(); - float a = fifoin_pop_f(state); - UINT32 b = fifoin_pop(state); - float c = fifoin_pop_f(state); - float d = fifoin_pop_f(state); + const UINT32 *tgp_data = (const UINT32 *)memregion("user2")->base(); + float a = fifoin_pop_f(); + UINT32 b = fifoin_pop(); + float c = fifoin_pop_f(); + float d = fifoin_pop_f(); int offi, offd, len; float dist; int i; UINT32 entry; float height; - logerror("TGP track_lookup %f, 0x%x, %f, %f (%x)\n", a, b, c, d, state->m_pushpc); + logerror("TGP track_lookup %f, 0x%x, %f, %f (%x)\n", a, b, c, d, m_pushpc); - offi = tgp_data[0x10+state->m_tgp_vr_select] + b; - offd = tgp_data[0x20+state->m_tgp_vr_select]; + offi = tgp_data[0x10+m_tgp_vr_select] + b; + offd = tgp_data[0x20+m_tgp_vr_select]; len = tgp_data[offi++]; @@ -1088,23 +1024,22 @@ static TGP_FUNCTION( track_lookup ) } } - state->m_ram_data[0x0000] = 0; // non zero = still computing - state->m_ram_data[0x8001] = f2u(height); - state->m_ram_data[0x8002] = entry; + m_ram_data[0x0000] = 0; // non zero = still computing + m_ram_data[0x8001] = f2u(height); + m_ram_data[0x8002] = entry; - next_fn(state); + next_fn(); } -static TGP_FUNCTION( f56 ) +TGP_FUNCTION( model1_state::f56 ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); - float d = fifoin_pop_f(state); - float e = fifoin_pop_f(state); - float f = fifoin_pop_f(state); - UINT32 g = fifoin_pop(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); + float d = fifoin_pop_f(); + float e = fifoin_pop_f(); + float f = fifoin_pop_f(); + UINT32 g = fifoin_pop(); (void)a; (void)b; (void)c; @@ -1113,110 +1048,102 @@ static TGP_FUNCTION( f56 ) (void)f; (void)g; - logerror("TGP f56 %f, %f, %f, %f, %f, %f, %d (%x)\n", a, b, c, d, e, f, g, state->m_pushpc); - fifoout_push(state, 0); - next_fn(state); + logerror("TGP f56 %f, %f, %f, %f, %f, %f, %d (%x)\n", a, b, c, d, e, f, g, m_pushpc); + fifoout_push(0); + next_fn(); } -static TGP_FUNCTION( f57 ) +TGP_FUNCTION( model1_state::f57 ) { - model1_state *state = machine.driver_data(); - logerror("TGP f57 (%x)\n", state->m_pushpc); - fifoout_push_f(state, 0); - fifoout_push_f(state, 0); - fifoout_push_f(state, 0); - next_fn(state); + logerror("TGP f57 (%x)\n", m_pushpc); + fifoout_push_f(0); + fifoout_push_f(0); + fifoout_push_f(0); + next_fn(); } -static TGP_FUNCTION( matrix_readt ) +TGP_FUNCTION( model1_state::matrix_readt ) { - model1_state *state = machine.driver_data(); - logerror("TGP matrix_readt (%x)\n", state->m_pushpc); - fifoout_push_f(state, state->m_cmat[9]); - fifoout_push_f(state, state->m_cmat[10]); - fifoout_push_f(state, state->m_cmat[11]); - next_fn(state); + logerror("TGP matrix_readt (%x)\n", m_pushpc); + fifoout_push_f(m_cmat[9]); + fifoout_push_f(m_cmat[10]); + fifoout_push_f(m_cmat[11]); + next_fn(); } -static TGP_FUNCTION( acc_geti ) +TGP_FUNCTION( model1_state::acc_geti ) { - model1_state *state = machine.driver_data(); - logerror("TGP acc_geti (%x)\n", state->m_pushpc); - fifoout_push(state, (int)state->m_acc); - next_fn(state); + logerror("TGP acc_geti (%x)\n", m_pushpc); + fifoout_push((int)m_acc); + next_fn(); } -static TGP_FUNCTION( f60 ) +TGP_FUNCTION( model1_state::f60 ) { - model1_state *state = machine.driver_data(); - logerror("TGP f60 (%x)\n", state->m_pushpc); - fifoout_push_f(state, 0); - fifoout_push_f(state, 0); - fifoout_push_f(state, 0); - next_fn(state); + logerror("TGP f60 (%x)\n", m_pushpc); + fifoout_push_f(0); + fifoout_push_f(0); + fifoout_push_f(0); + next_fn(); } -static TGP_FUNCTION( col_setcirc ) +TGP_FUNCTION( model1_state::col_setcirc ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); - logerror("TGP col_setcirc %f, %f, %f (%x)\n", a, b, c, state->m_pushpc); - state->m_tgp_vr_circx = a; - state->m_tgp_vr_circy = b; - state->m_tgp_vr_circrad = c; - next_fn(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); + logerror("TGP col_setcirc %f, %f, %f (%x)\n", a, b, c, m_pushpc); + m_tgp_vr_circx = a; + m_tgp_vr_circy = b; + m_tgp_vr_circrad = c; + next_fn(); } -static TGP_FUNCTION( col_testpt ) +TGP_FUNCTION( model1_state::col_testpt ) { - model1_state *state = machine.driver_data(); float x, y; - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - logerror("TGP col_testpt %f, %f (%x)\n", a, b, state->m_pushpc); - x = a - state->m_tgp_vr_circx; - y = b - state->m_tgp_vr_circy; - fifoout_push_f(state, ((x*x+y*y)/sqrt(x*x+y*y)) - state->m_tgp_vr_circrad); - next_fn(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + logerror("TGP col_testpt %f, %f (%x)\n", a, b, m_pushpc); + x = a - m_tgp_vr_circx; + y = b - m_tgp_vr_circy; + fifoout_push_f(((x*x+y*y)/sqrt(x*x+y*y)) - m_tgp_vr_circrad); + next_fn(); } -static TGP_FUNCTION( push_and_ident ) +TGP_FUNCTION( model1_state::push_and_ident ) { - model1_state *state = machine.driver_data(); - if(state->m_mat_stack_pos != MAT_STACK_SIZE) { - memcpy(state->m_mat_stack[state->m_mat_stack_pos], state->m_cmat, sizeof(state->m_cmat)); - state->m_mat_stack_pos++; + if(m_mat_stack_pos != MAT_STACK_SIZE) { + memcpy(m_mat_stack[m_mat_stack_pos], m_cmat, sizeof(m_cmat)); + m_mat_stack_pos++; } - logerror("TGP push_and_ident (depth=%d, pc=%x)\n", state->m_mat_stack_pos, state->m_pushpc); - memset(state->m_cmat, 0, sizeof(state->m_cmat)); - state->m_cmat[0] = 1.0; - state->m_cmat[4] = 1.0; - state->m_cmat[8] = 1.0; - next_fn(state); + logerror("TGP push_and_ident (depth=%d, pc=%x)\n", m_mat_stack_pos, m_pushpc); + memset(m_cmat, 0, sizeof(m_cmat)); + m_cmat[0] = 1.0; + m_cmat[4] = 1.0; + m_cmat[8] = 1.0; + next_fn(); } -static TGP_FUNCTION( catmull_rom ) +TGP_FUNCTION( model1_state::catmull_rom ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); - float d = fifoin_pop_f(state); - float e = fifoin_pop_f(state); - float f = fifoin_pop_f(state); - float g = fifoin_pop_f(state); - float h = fifoin_pop_f(state); - float i = fifoin_pop_f(state); - float j = fifoin_pop_f(state); - float k = fifoin_pop_f(state); - float l = fifoin_pop_f(state); - float m = fifoin_pop_f(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); + float d = fifoin_pop_f(); + float e = fifoin_pop_f(); + float f = fifoin_pop_f(); + float g = fifoin_pop_f(); + float h = fifoin_pop_f(); + float i = fifoin_pop_f(); + float j = fifoin_pop_f(); + float k = fifoin_pop_f(); + float l = fifoin_pop_f(); + float m = fifoin_pop_f(); float m2, m3; float w1, w2, w3, w4; - logerror("TGP catmull_rom %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f (%x)\n", a, b, c, d, e, f, g, h, i, j, k, l, m, state->m_pushpc); + logerror("TGP catmull_rom %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f (%x)\n", a, b, c, d, e, f, g, h, i, j, k, l, m, m_pushpc); m2 = m*m; m3 = m*m*m; @@ -1226,64 +1153,61 @@ static TGP_FUNCTION( catmull_rom ) w3 = 0.5*(-3*m3+4*m2+m); w4 = 0.5*(m3-m2); - fifoout_push_f(state, a*w1+d*w2+g*w3+j*w4); - fifoout_push_f(state, b*w1+e*w2+h*w3+k*w4); - fifoout_push_f(state, c*w1+f*w2+i*w3+l*w4); - next_fn(state); + fifoout_push_f(a*w1+d*w2+g*w3+j*w4); + fifoout_push_f(b*w1+e*w2+h*w3+k*w4); + fifoout_push_f(c*w1+f*w2+i*w3+l*w4); + next_fn(); } -static TGP_FUNCTION( distance ) +TGP_FUNCTION( model1_state::distance ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); - float d = fifoin_pop_f(state); - logerror("TGP distance (%f, %f), (%f, %f) (%x)\n", a, b, c, d, state->m_pushpc); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); + float d = fifoin_pop_f(); + logerror("TGP distance (%f, %f), (%f, %f) (%x)\n", a, b, c, d, m_pushpc); c -= a; d -= b; - fifoout_push_f(state, (c*c+d*d)/sqrt(c*c+d*d)); - next_fn(state); + fifoout_push_f((c*c+d*d)/sqrt(c*c+d*d)); + next_fn(); } -static TGP_FUNCTION( car_move ) +TGP_FUNCTION( model1_state::car_move ) { - model1_state *state = machine.driver_data(); - INT16 a = fifoin_pop(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); - float d = fifoin_pop_f(state); + INT16 a = fifoin_pop(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); + float d = fifoin_pop_f(); float dx, dy; - logerror("TGP car_move (%d, %f), (%f, %f) (%x)\n", a, b, c, d, state->m_pushpc); + logerror("TGP car_move (%d, %f), (%f, %f) (%x)\n", a, b, c, d, m_pushpc); dx = b*tsin(a); dy = b*tcos(a); - fifoout_push_f(state, dx); - fifoout_push_f(state, dy); - fifoout_push_f(state, c+dx); - fifoout_push_f(state, d+dy); - next_fn(state); + fifoout_push_f(dx); + fifoout_push_f(dy); + fifoout_push_f(c+dx); + fifoout_push_f(d+dy); + next_fn(); } -static TGP_FUNCTION( cpa ) +TGP_FUNCTION( model1_state::cpa ) { - model1_state *state = machine.driver_data(); float dv_x, dv_y, dv_z, dv2, dw_x, dw_y, dw_z, dt; - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); - float d = fifoin_pop_f(state); - float e = fifoin_pop_f(state); - float f = fifoin_pop_f(state); - float g = fifoin_pop_f(state); - float h = fifoin_pop_f(state); - float i = fifoin_pop_f(state); - float j = fifoin_pop_f(state); - float k = fifoin_pop_f(state); - float l = fifoin_pop_f(state); - logerror("TGP cpa %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f (%x)\n", a, b, c, d, e, f, g, h, i, j, k, l, state->m_pushpc); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); + float d = fifoin_pop_f(); + float e = fifoin_pop_f(); + float f = fifoin_pop_f(); + float g = fifoin_pop_f(); + float h = fifoin_pop_f(); + float i = fifoin_pop_f(); + float j = fifoin_pop_f(); + float k = fifoin_pop_f(); + float l = fifoin_pop_f(); + logerror("TGP cpa %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f (%x)\n", a, b, c, d, e, f, g, h, i, j, k, l, m_pushpc); dv_x = (b-a) - (d-c); dv_y = (f-e) - (h-g); @@ -1307,495 +1231,465 @@ static TGP_FUNCTION( cpa ) dv_z = (i-k)*(1-dt) + (j-l)*dt; dv2 = dv_x*dv_x + dv_y*dv_y + dv_z*dv_z; - fifoout_push_f(state, sqrt(dv2)); - next_fn(state); + fifoout_push_f(sqrt(dv2)); + next_fn(); } -static TGP_FUNCTION( vmat_store ) +TGP_FUNCTION( model1_state::vmat_store ) { - model1_state *state = machine.driver_data(); - UINT32 a = fifoin_pop(state); + UINT32 a = fifoin_pop(); if(a<21) - memcpy(state->m_mat_vector[a], state->m_cmat, sizeof(state->m_cmat)); + memcpy(m_mat_vector[a], m_cmat, sizeof(m_cmat)); else logerror("TGP ERROR bad vector index\n"); - logerror("TGP vmat_store %d (%x)\n", a, state->m_pushpc); - next_fn(state); + logerror("TGP vmat_store %d (%x)\n", a, m_pushpc); + next_fn(); } -static TGP_FUNCTION( vmat_restore ) +TGP_FUNCTION( model1_state::vmat_restore ) { - model1_state *state = machine.driver_data(); - UINT32 a = fifoin_pop(state); + UINT32 a = fifoin_pop(); if(a<21) - memcpy(state->m_cmat, state->m_mat_vector[a], sizeof(state->m_cmat)); + memcpy(m_cmat, m_mat_vector[a], sizeof(m_cmat)); else logerror("TGP ERROR bad vector index\n"); - logerror("TGP vmat_restore %d (%x)\n", a, state->m_pushpc); - next_fn(state); + logerror("TGP vmat_restore %d (%x)\n", a, m_pushpc); + next_fn(); } -static TGP_FUNCTION( vmat_mul ) +TGP_FUNCTION( model1_state::vmat_mul ) { - model1_state *state = machine.driver_data(); - UINT32 a = fifoin_pop(state); - UINT32 b = fifoin_pop(state); + UINT32 a = fifoin_pop(); + UINT32 b = fifoin_pop(); if(a<21 && b<21) { - state->m_mat_vector[b][0] = state->m_mat_vector[a][ 0]*state->m_cmat[0] + state->m_mat_vector[a][ 1]*state->m_cmat[3] + state->m_mat_vector[a][ 2]*state->m_cmat[6]; - state->m_mat_vector[b][1] = state->m_mat_vector[a][ 0]*state->m_cmat[1] + state->m_mat_vector[a][ 1]*state->m_cmat[4] + state->m_mat_vector[a][ 2]*state->m_cmat[7]; - state->m_mat_vector[b][2] = state->m_mat_vector[a][ 0]*state->m_cmat[2] + state->m_mat_vector[a][ 1]*state->m_cmat[5] + state->m_mat_vector[a][ 2]*state->m_cmat[8]; - state->m_mat_vector[b][3] = state->m_mat_vector[a][ 3]*state->m_cmat[0] + state->m_mat_vector[a][ 4]*state->m_cmat[3] + state->m_mat_vector[a][ 5]*state->m_cmat[6]; - state->m_mat_vector[b][4] = state->m_mat_vector[a][ 3]*state->m_cmat[1] + state->m_mat_vector[a][ 4]*state->m_cmat[4] + state->m_mat_vector[a][ 5]*state->m_cmat[7]; - state->m_mat_vector[b][5] = state->m_mat_vector[a][ 3]*state->m_cmat[2] + state->m_mat_vector[a][ 4]*state->m_cmat[5] + state->m_mat_vector[a][ 5]*state->m_cmat[8]; - state->m_mat_vector[b][6] = state->m_mat_vector[a][ 6]*state->m_cmat[0] + state->m_mat_vector[a][ 7]*state->m_cmat[3] + state->m_mat_vector[a][ 8]*state->m_cmat[6]; - state->m_mat_vector[b][7] = state->m_mat_vector[a][ 6]*state->m_cmat[1] + state->m_mat_vector[a][ 7]*state->m_cmat[4] + state->m_mat_vector[a][ 8]*state->m_cmat[7]; - state->m_mat_vector[b][8] = state->m_mat_vector[a][ 6]*state->m_cmat[2] + state->m_mat_vector[a][ 7]*state->m_cmat[5] + state->m_mat_vector[a][ 8]*state->m_cmat[8]; - state->m_mat_vector[b][9] = state->m_mat_vector[a][ 9]*state->m_cmat[0] + state->m_mat_vector[a][10]*state->m_cmat[3] + state->m_mat_vector[a][11]*state->m_cmat[6] + state->m_cmat[9]; - state->m_mat_vector[b][10] = state->m_mat_vector[a][ 9]*state->m_cmat[1] + state->m_mat_vector[a][10]*state->m_cmat[4] + state->m_mat_vector[a][11]*state->m_cmat[7] + state->m_cmat[10]; - state->m_mat_vector[b][11] = state->m_mat_vector[a][ 9]*state->m_cmat[2] + state->m_mat_vector[a][10]*state->m_cmat[5] + state->m_mat_vector[a][11]*state->m_cmat[8] + state->m_cmat[11]; + m_mat_vector[b][0] = m_mat_vector[a][ 0]*m_cmat[0] + m_mat_vector[a][ 1]*m_cmat[3] + m_mat_vector[a][ 2]*m_cmat[6]; + m_mat_vector[b][1] = m_mat_vector[a][ 0]*m_cmat[1] + m_mat_vector[a][ 1]*m_cmat[4] + m_mat_vector[a][ 2]*m_cmat[7]; + m_mat_vector[b][2] = m_mat_vector[a][ 0]*m_cmat[2] + m_mat_vector[a][ 1]*m_cmat[5] + m_mat_vector[a][ 2]*m_cmat[8]; + m_mat_vector[b][3] = m_mat_vector[a][ 3]*m_cmat[0] + m_mat_vector[a][ 4]*m_cmat[3] + m_mat_vector[a][ 5]*m_cmat[6]; + m_mat_vector[b][4] = m_mat_vector[a][ 3]*m_cmat[1] + m_mat_vector[a][ 4]*m_cmat[4] + m_mat_vector[a][ 5]*m_cmat[7]; + m_mat_vector[b][5] = m_mat_vector[a][ 3]*m_cmat[2] + m_mat_vector[a][ 4]*m_cmat[5] + m_mat_vector[a][ 5]*m_cmat[8]; + m_mat_vector[b][6] = m_mat_vector[a][ 6]*m_cmat[0] + m_mat_vector[a][ 7]*m_cmat[3] + m_mat_vector[a][ 8]*m_cmat[6]; + m_mat_vector[b][7] = m_mat_vector[a][ 6]*m_cmat[1] + m_mat_vector[a][ 7]*m_cmat[4] + m_mat_vector[a][ 8]*m_cmat[7]; + m_mat_vector[b][8] = m_mat_vector[a][ 6]*m_cmat[2] + m_mat_vector[a][ 7]*m_cmat[5] + m_mat_vector[a][ 8]*m_cmat[8]; + m_mat_vector[b][9] = m_mat_vector[a][ 9]*m_cmat[0] + m_mat_vector[a][10]*m_cmat[3] + m_mat_vector[a][11]*m_cmat[6] + m_cmat[9]; + m_mat_vector[b][10] = m_mat_vector[a][ 9]*m_cmat[1] + m_mat_vector[a][10]*m_cmat[4] + m_mat_vector[a][11]*m_cmat[7] + m_cmat[10]; + m_mat_vector[b][11] = m_mat_vector[a][ 9]*m_cmat[2] + m_mat_vector[a][10]*m_cmat[5] + m_mat_vector[a][11]*m_cmat[8] + m_cmat[11]; } else logerror("TGP ERROR bad vector index\n"); - logerror("TGP vmat_mul %d, %d (%x)\n", a, b, state->m_pushpc); - next_fn(state); + logerror("TGP vmat_mul %d, %d (%x)\n", a, b, m_pushpc); + next_fn(); } -static TGP_FUNCTION( vmat_read ) +TGP_FUNCTION( model1_state::vmat_read ) { - model1_state *state = machine.driver_data(); - UINT32 a = fifoin_pop(state); - logerror("TGP vmat_read %d (%x)\n", a, state->m_pushpc); + UINT32 a = fifoin_pop(); + logerror("TGP vmat_read %d (%x)\n", a, m_pushpc); if(a<21) { int i; for(i=0; i<12; i++) - fifoout_push_f(state, state->m_mat_vector[a][i]); + fifoout_push_f(m_mat_vector[a][i]); } else { int i; logerror("TGP ERROR bad vector index\n"); for(i=0; i<12; i++) - fifoout_push_f(state, 0); + fifoout_push_f(0); } - next_fn(state); + next_fn(); } -static TGP_FUNCTION( matrix_rtrans ) +TGP_FUNCTION( model1_state::matrix_rtrans ) { - model1_state *state = machine.driver_data(); - logerror("TGP matrix_rtrans (%x)\n", state->m_pushpc); - fifoout_push_f(state, state->m_cmat[ 9]); - fifoout_push_f(state, state->m_cmat[10]); - fifoout_push_f(state, state->m_cmat[11]); - next_fn(state); + logerror("TGP matrix_rtrans (%x)\n", m_pushpc); + fifoout_push_f(m_cmat[ 9]); + fifoout_push_f(m_cmat[10]); + fifoout_push_f(m_cmat[11]); + next_fn(); } -static TGP_FUNCTION( matrix_unrot ) +TGP_FUNCTION( model1_state::matrix_unrot ) { - model1_state *state = machine.driver_data(); - logerror("TGP matrix_unrot (%x)\n", state->m_pushpc); - memset(state->m_cmat, 0, 9*sizeof(state->m_cmat[0])); - state->m_cmat[0] = 1.0; - state->m_cmat[4] = 1.0; - state->m_cmat[8] = 1.0; - next_fn(state); + logerror("TGP matrix_unrot (%x)\n", m_pushpc); + memset(m_cmat, 0, 9*sizeof(m_cmat[0])); + m_cmat[0] = 1.0; + m_cmat[4] = 1.0; + m_cmat[8] = 1.0; + next_fn(); } -static TGP_FUNCTION( f80 ) +TGP_FUNCTION( model1_state::f80 ) { - model1_state *state = machine.driver_data(); - logerror("TGP f80 (%x)\n", state->m_pushpc); - // state->m_cmat[9] = state->m_cmat[10] = state->m_cmat[11] = 0; - next_fn(state); + logerror("TGP f80 (%x)\n", m_pushpc); + // m_cmat[9] = m_cmat[10] = m_cmat[11] = 0; + next_fn(); } -static TGP_FUNCTION( vmat_save ) +TGP_FUNCTION( model1_state::vmat_save ) { - model1_state *state = machine.driver_data(); - UINT32 a = fifoin_pop(state); + UINT32 a = fifoin_pop(); int i; - logerror("TGP vmat_save 0x%x (%x)\n", a, state->m_pushpc); + logerror("TGP vmat_save 0x%x (%x)\n", a, m_pushpc); for(i=0; i<16; i++) - memcpy(state->m_ram_data+a+0x10*i, state->m_mat_vector[i], sizeof(state->m_cmat)); - next_fn(state); + memcpy(m_ram_data+a+0x10*i, m_mat_vector[i], sizeof(m_cmat)); + next_fn(); } -static TGP_FUNCTION( vmat_load ) +TGP_FUNCTION( model1_state::vmat_load ) { - model1_state *state = machine.driver_data(); - UINT32 a = fifoin_pop(state); + UINT32 a = fifoin_pop(); int i; - logerror("TGP vmat_load 0x%x (%x)\n", a, state->m_pushpc); + logerror("TGP vmat_load 0x%x (%x)\n", a, m_pushpc); for(i=0; i<16; i++) - memcpy(state->m_mat_vector[i], state->m_ram_data+a+0x10*i, sizeof(state->m_cmat)); - next_fn(state); + memcpy(m_mat_vector[i], m_ram_data+a+0x10*i, sizeof(m_cmat)); + next_fn(); } -static TGP_FUNCTION( ram_setadr ) +TGP_FUNCTION( model1_state::ram_setadr ) { - model1_state *state = machine.driver_data(); - state->m_ram_scanadr = fifoin_pop(state) - 0x8000; - logerror("TGP f0 ram_setadr 0x%x (%x)\n", state->m_ram_scanadr+0x8000, state->m_pushpc); - next_fn(state); + m_ram_scanadr = fifoin_pop() - 0x8000; + logerror("TGP f0 ram_setadr 0x%x (%x)\n", m_ram_scanadr+0x8000, m_pushpc); + next_fn(); } -static TGP_FUNCTION( groundbox_test ) +TGP_FUNCTION( model1_state::groundbox_test ) { - model1_state *state = machine.driver_data(); int out_x, out_y, out_z; float x, /*y,*/ z; - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); - logerror("TGP groundbox_test %f, %f, %f (%x)\n", a, b, c, state->m_pushpc); - x = state->m_cmat[0]*a+state->m_cmat[3]*b+state->m_cmat[6]*c+state->m_cmat[9]; - //y = state->m_cmat[1]*a+state->m_cmat[4]*b+state->m_cmat[7]*c+state->m_cmat[10]; - z = state->m_cmat[2]*a+state->m_cmat[5]*b+state->m_cmat[8]*c+state->m_cmat[11]; + logerror("TGP groundbox_test %f, %f, %f (%x)\n", a, b, c, m_pushpc); + x = m_cmat[0]*a+m_cmat[3]*b+m_cmat[6]*c+m_cmat[9]; + //y = m_cmat[1]*a+m_cmat[4]*b+m_cmat[7]*c+m_cmat[10]; + z = m_cmat[2]*a+m_cmat[5]*b+m_cmat[8]*c+m_cmat[11]; - out_x = x < state->m_tgp_vf_xmin || x > state->m_tgp_vf_xmax; - out_z = z < state->m_tgp_vf_zmin || z > state->m_tgp_vf_zmax; + out_x = x < m_tgp_vf_xmin || x > m_tgp_vf_xmax; + out_z = z < m_tgp_vf_zmin || z > m_tgp_vf_zmax; out_y = 1; // Wrong, but untestable it seems. - fifoout_push(state, out_x); - fifoout_push(state, out_y); - fifoout_push(state, out_z); - next_fn(state); + fifoout_push(out_x); + fifoout_push(out_y); + fifoout_push(out_z); + next_fn(); } -static TGP_FUNCTION( f89 ) +TGP_FUNCTION( model1_state::f89 ) { - model1_state *state = machine.driver_data(); - UINT32 a = fifoin_pop(state); - UINT32 b = fifoin_pop(state); - UINT32 c = fifoin_pop(state); - UINT32 d = fifoin_pop(state); + UINT32 a = fifoin_pop(); + UINT32 b = fifoin_pop(); + UINT32 c = fifoin_pop(); + UINT32 d = fifoin_pop(); (void)a; (void)b; (void)c; - logerror("TGP list set base 0x%x, 0x%x, %d, length=%d (%x)\n", a, b, c, d, state->m_pushpc); - state->m_list_length = d; - next_fn(state); + logerror("TGP list set base 0x%x, 0x%x, %d, length=%d (%x)\n", a, b, c, d, m_pushpc); + m_list_length = d; + next_fn(); } -static TGP_FUNCTION( f92 ) +TGP_FUNCTION( model1_state::f92 ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); - float d = fifoin_pop_f(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); + float d = fifoin_pop_f(); (void)a; (void)b; (void)c; (void)d; - logerror("TGP f92 %f, %f, %f, %f (%x)\n", a, b, c, d, state->m_pushpc); - next_fn(state); + logerror("TGP f92 %f, %f, %f, %f (%x)\n", a, b, c, d, m_pushpc); + next_fn(); } -static TGP_FUNCTION( f93 ) +TGP_FUNCTION( model1_state::f93 ) { - model1_state *state = machine.driver_data(); - float a = fifoin_pop_f(state); + float a = fifoin_pop_f(); (void)a; - logerror("TGP f93 %f (%x)\n", a, state->m_pushpc); - next_fn(state); + logerror("TGP f93 %f (%x)\n", a, m_pushpc); + next_fn(); } -static TGP_FUNCTION( f94 ) +TGP_FUNCTION( model1_state::f94 ) { - model1_state *state = machine.driver_data(); - UINT32 a = fifoin_pop(state); + UINT32 a = fifoin_pop(); (void)a; - logerror("TGP f94 %d (%x)\n", a, state->m_pushpc); - next_fn(state); + logerror("TGP f94 %d (%x)\n", a, m_pushpc); + next_fn(); } -static TGP_FUNCTION( vmat_flatten ) +TGP_FUNCTION( model1_state::vmat_flatten ) { - model1_state *state = machine.driver_data(); int i; float m[12]; - logerror("TGP vmat_flatten (%x)\n", state->m_pushpc); + logerror("TGP vmat_flatten (%x)\n", m_pushpc); for(i=0; i<16; i++) { - memcpy(m, state->m_mat_vector[i], sizeof(state->m_cmat)); + memcpy(m, m_mat_vector[i], sizeof(m_cmat)); m[1] = m[4] = m[7] = m[10] = 0; - state->m_mat_vector[i][0] = m[ 0]*state->m_cmat[0] + m[ 1]*state->m_cmat[3] + m[ 2]*state->m_cmat[6]; - state->m_mat_vector[i][1] = m[ 0]*state->m_cmat[1] + m[ 1]*state->m_cmat[4] + m[ 2]*state->m_cmat[7]; - state->m_mat_vector[i][2] = m[ 0]*state->m_cmat[2] + m[ 1]*state->m_cmat[5] + m[ 2]*state->m_cmat[8]; - state->m_mat_vector[i][3] = m[ 3]*state->m_cmat[0] + m[ 4]*state->m_cmat[3] + m[ 5]*state->m_cmat[6]; - state->m_mat_vector[i][4] = m[ 3]*state->m_cmat[1] + m[ 4]*state->m_cmat[4] + m[ 5]*state->m_cmat[7]; - state->m_mat_vector[i][5] = m[ 3]*state->m_cmat[2] + m[ 4]*state->m_cmat[5] + m[ 5]*state->m_cmat[8]; - state->m_mat_vector[i][6] = m[ 6]*state->m_cmat[0] + m[ 7]*state->m_cmat[3] + m[ 8]*state->m_cmat[6]; - state->m_mat_vector[i][7] = m[ 6]*state->m_cmat[1] + m[ 7]*state->m_cmat[4] + m[ 8]*state->m_cmat[7]; - state->m_mat_vector[i][8] = m[ 6]*state->m_cmat[2] + m[ 7]*state->m_cmat[5] + m[ 8]*state->m_cmat[8]; - state->m_mat_vector[i][9] = m[ 9]*state->m_cmat[0] + m[10]*state->m_cmat[3] + m[11]*state->m_cmat[6] + state->m_cmat[9]; - state->m_mat_vector[i][10] = m[ 9]*state->m_cmat[1] + m[10]*state->m_cmat[4] + m[11]*state->m_cmat[7] + state->m_cmat[10]; - state->m_mat_vector[i][11] = m[ 9]*state->m_cmat[2] + m[10]*state->m_cmat[5] + m[11]*state->m_cmat[8] + state->m_cmat[11]; + m_mat_vector[i][0] = m[ 0]*m_cmat[0] + m[ 1]*m_cmat[3] + m[ 2]*m_cmat[6]; + m_mat_vector[i][1] = m[ 0]*m_cmat[1] + m[ 1]*m_cmat[4] + m[ 2]*m_cmat[7]; + m_mat_vector[i][2] = m[ 0]*m_cmat[2] + m[ 1]*m_cmat[5] + m[ 2]*m_cmat[8]; + m_mat_vector[i][3] = m[ 3]*m_cmat[0] + m[ 4]*m_cmat[3] + m[ 5]*m_cmat[6]; + m_mat_vector[i][4] = m[ 3]*m_cmat[1] + m[ 4]*m_cmat[4] + m[ 5]*m_cmat[7]; + m_mat_vector[i][5] = m[ 3]*m_cmat[2] + m[ 4]*m_cmat[5] + m[ 5]*m_cmat[8]; + m_mat_vector[i][6] = m[ 6]*m_cmat[0] + m[ 7]*m_cmat[3] + m[ 8]*m_cmat[6]; + m_mat_vector[i][7] = m[ 6]*m_cmat[1] + m[ 7]*m_cmat[4] + m[ 8]*m_cmat[7]; + m_mat_vector[i][8] = m[ 6]*m_cmat[2] + m[ 7]*m_cmat[5] + m[ 8]*m_cmat[8]; + m_mat_vector[i][9] = m[ 9]*m_cmat[0] + m[10]*m_cmat[3] + m[11]*m_cmat[6] + m_cmat[9]; + m_mat_vector[i][10] = m[ 9]*m_cmat[1] + m[10]*m_cmat[4] + m[11]*m_cmat[7] + m_cmat[10]; + m_mat_vector[i][11] = m[ 9]*m_cmat[2] + m[10]*m_cmat[5] + m[11]*m_cmat[8] + m_cmat[11]; } - next_fn(state); + next_fn(); } -static TGP_FUNCTION( vmat_load1 ) +TGP_FUNCTION( model1_state::vmat_load1 ) { - model1_state *state = machine.driver_data(); - UINT32 a = fifoin_pop(state); - logerror("TGP vmat_load1 0x%x (%x)\n", a, state->m_pushpc); - memcpy(state->m_cmat, state->m_ram_data+a, sizeof(state->m_cmat)); - next_fn(state); + UINT32 a = fifoin_pop(); + logerror("TGP vmat_load1 0x%x (%x)\n", a, m_pushpc); + memcpy(m_cmat, m_ram_data+a, sizeof(m_cmat)); + next_fn(); } -static TGP_FUNCTION( ram_trans ) +TGP_FUNCTION( model1_state::ram_trans ) { - model1_state *state = machine.driver_data(); - float a = ram_get_f(state); - float b = ram_get_f(state); - float c = ram_get_f(state); - logerror("TGP ram_trans (%x)\n", state->m_pushpc); - state->m_cmat[ 9] += state->m_cmat[0]*a+state->m_cmat[3]*b+state->m_cmat[6]*c; - state->m_cmat[10] += state->m_cmat[1]*a+state->m_cmat[4]*b+state->m_cmat[7]*c; - state->m_cmat[11] += state->m_cmat[2]*a+state->m_cmat[5]*b+state->m_cmat[8]*c; - next_fn(state); + float a = ram_get_f(); + float b = ram_get_f(); + float c = ram_get_f(); + logerror("TGP ram_trans (%x)\n", m_pushpc); + m_cmat[ 9] += m_cmat[0]*a+m_cmat[3]*b+m_cmat[6]*c; + m_cmat[10] += m_cmat[1]*a+m_cmat[4]*b+m_cmat[7]*c; + m_cmat[11] += m_cmat[2]*a+m_cmat[5]*b+m_cmat[8]*c; + next_fn(); } -static TGP_FUNCTION( f98_load ) +TGP_FUNCTION( model1_state::f98_load ) { - model1_state *state = machine.driver_data(); int i; - for(i=0; im_list_length; i++) { - float f = fifoin_pop_f(state); + for(i=0; im_list_length, f, state->m_pushpc); + logerror("TGP load list (%2d/%2d) %f (%x)\n", i, m_list_length, f, m_pushpc); } - next_fn(state); + next_fn(); } -static TGP_FUNCTION( f98 ) +TGP_FUNCTION( model1_state::f98 ) { - model1_state *state = machine.driver_data(); - UINT32 a = fifoin_pop(state); + UINT32 a = fifoin_pop(); (void)a; - logerror("TGP load list start %d (%x)\n", a, state->m_pushpc); - state->m_fifoin_cbcount = state->m_list_length; - state->m_fifoin_cb = f98_load; + logerror("TGP load list start %d (%x)\n", a, m_pushpc); + m_fifoin_cbcount = m_list_length; + m_fifoin_cb = &model1_state::f98_load; } -static TGP_FUNCTION( f99 ) +TGP_FUNCTION( model1_state::f99 ) { - model1_state *state = machine.driver_data(); - logerror("TGP f99 (%x)\n", state->m_pushpc); - next_fn(state); + logerror("TGP f99 (%x)\n", m_pushpc); + next_fn(); } -static TGP_FUNCTION( f100 ) +TGP_FUNCTION( model1_state::f100 ) { - model1_state *state = machine.driver_data(); int i; - logerror("TGP f100 get list (%x)\n", state->m_pushpc); - for(i=0; im_list_length; i++) - fifoout_push_f(state, (machine.rand() % 1000)/100.0); - next_fn(state); + logerror("TGP f100 get list (%x)\n", m_pushpc); + for(i=0; i(); - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); - float d = fifoin_pop_f(state); - float e = fifoin_pop_f(state); - float f = fifoin_pop_f(state); - float g = fifoin_pop_f(state); - logerror("TGP groundbox_set %f, %f, %f, %f, %f, %f, %f (%x)\n", a, b, c, d, e, f, g, state->m_pushpc); - state->m_tgp_vf_xmin = e; - state->m_tgp_vf_xmax = d; - state->m_tgp_vf_zmin = g; - state->m_tgp_vf_zmax = f; - state->m_tgp_vf_ygnd = b; - state->m_tgp_vf_yflr = a; - state->m_tgp_vf_yjmp = c; + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); + float d = fifoin_pop_f(); + float e = fifoin_pop_f(); + float f = fifoin_pop_f(); + float g = fifoin_pop_f(); + logerror("TGP groundbox_set %f, %f, %f, %f, %f, %f, %f (%x)\n", a, b, c, d, e, f, g, m_pushpc); + m_tgp_vf_xmin = e; + m_tgp_vf_xmax = d; + m_tgp_vf_zmin = g; + m_tgp_vf_zmax = f; + m_tgp_vf_ygnd = b; + m_tgp_vf_yflr = a; + m_tgp_vf_yjmp = c; - next_fn(state); + next_fn(); } -static TGP_FUNCTION( f102 ) +TGP_FUNCTION( model1_state::f102 ) { - model1_state *state = machine.driver_data(); float px, py, pz; - float a = fifoin_pop_f(state); - float b = fifoin_pop_f(state); - float c = fifoin_pop_f(state); - float d = fifoin_pop_f(state); - float e = fifoin_pop_f(state); - UINT32 f = fifoin_pop(state); - UINT32 g = fifoin_pop(state); - UINT32 h = fifoin_pop(state); + float a = fifoin_pop_f(); + float b = fifoin_pop_f(); + float c = fifoin_pop_f(); + float d = fifoin_pop_f(); + float e = fifoin_pop_f(); + UINT32 f = fifoin_pop(); + UINT32 g = fifoin_pop(); + UINT32 h = fifoin_pop(); - state->m_ccount++; + m_ccount++; - logerror("TGP f0 mve_calc %f, %f, %f, %f, %f, %d, %d, %d (%d) (%x)\n", a, b, c, d, e, f, g, h, state->m_ccount, state->m_pushpc); + logerror("TGP f0 mve_calc %f, %f, %f, %f, %f, %d, %d, %d (%d) (%x)\n", a, b, c, d, e, f, g, h, m_ccount, m_pushpc); - px = u2f(state->m_ram_data[state->m_ram_scanadr+0x16]); - py = u2f(state->m_ram_data[state->m_ram_scanadr+0x17]); - pz = u2f(state->m_ram_data[state->m_ram_scanadr+0x18]); + px = u2f(m_ram_data[m_ram_scanadr+0x16]); + py = u2f(m_ram_data[m_ram_scanadr+0x17]); + pz = u2f(m_ram_data[m_ram_scanadr+0x18]); - // memset(state->m_cmat, 0, sizeof(state->m_cmat)); - // state->m_cmat[0] = 1.0; - // state->m_cmat[4] = 1.0; - // state->m_cmat[8] = 1.0; + // memset(m_cmat, 0, sizeof(m_cmat)); + // m_cmat[0] = 1.0; + // m_cmat[4] = 1.0; + // m_cmat[8] = 1.0; px = c; py = d; pz = e; #if 1 - state->m_cmat[ 9] += state->m_cmat[0]*a+state->m_cmat[3]*b+state->m_cmat[6]*c; - state->m_cmat[10] += state->m_cmat[1]*a+state->m_cmat[4]*b+state->m_cmat[7]*c; - state->m_cmat[11] += state->m_cmat[2]*a+state->m_cmat[5]*b+state->m_cmat[8]*c; + m_cmat[ 9] += m_cmat[0]*a+m_cmat[3]*b+m_cmat[6]*c; + m_cmat[10] += m_cmat[1]*a+m_cmat[4]*b+m_cmat[7]*c; + m_cmat[11] += m_cmat[2]*a+m_cmat[5]*b+m_cmat[8]*c; #else - state->m_cmat[ 9] += px; - state->m_cmat[10] += py; - state->m_cmat[11] += pz; + m_cmat[ 9] += px; + m_cmat[10] += py; + m_cmat[11] += pz; #endif logerror(" f0 mve_calc %f, %f, %f\n", px, py, pz); - fifoout_push_f(state, c); - fifoout_push_f(state, d); - fifoout_push_f(state, e); - fifoout_push(state, f); - fifoout_push(state, g); - fifoout_push(state, h); + fifoout_push_f(c); + fifoout_push_f(d); + fifoout_push_f(e); + fifoout_push(f); + fifoout_push(g); + fifoout_push(h); - next_fn(state); + next_fn(); } -static TGP_FUNCTION( f103 ) +TGP_FUNCTION( model1_state::f103 ) { - model1_state *state = machine.driver_data(); - state->m_ram_scanadr = fifoin_pop(state) - 0x8000; - logerror("TGP f0 mve_setadr 0x%x (%x)\n", state->m_ram_scanadr, state->m_pushpc); - ram_get_i(state); - next_fn(state); + m_ram_scanadr = fifoin_pop() - 0x8000; + logerror("TGP f0 mve_setadr 0x%x (%x)\n", m_ram_scanadr, m_pushpc); + ram_get_i(); + next_fn(); } -struct function { - tgp_func cb; - int count; -}; +const struct model1_state::function model1_state::ftab_vf[] = { + { &model1_state::fadd, 2 }, /* 0x00 */ + { &model1_state::fsub, 2 }, + { &model1_state::fmul, 2 }, + { &model1_state::fdiv, 2 }, + { NULL, 0 }, + { &model1_state::matrix_push, 0 }, + { &model1_state::matrix_pop, 0 }, + { &model1_state::matrix_write, 12 }, + { &model1_state::clear_stack, 0 }, + { NULL, 0 }, + { &model1_state::anglev, 2 }, + { NULL, 0 }, + { NULL, 0 }, + { &model1_state::track_select, 1 }, + { &model1_state::f14, 4 }, + { &model1_state::anglep, 4 }, -static const struct function ftab_vf[] = { - { fadd, 2 }, /* 0x00 */ - { fsub, 2 }, - { fmul, 2 }, - { fdiv, 2 }, - { NULL, 0 }, - { matrix_push, 0 }, - { matrix_pop, 0 }, - { matrix_write, 12 }, - { clear_stack, 0 }, - { NULL, 0 }, - { anglev, 2 }, - { NULL, 0 }, - { NULL, 0 }, - { track_select, 1 }, - { f14, 4 }, - { anglep, 4 }, + { &model1_state::matrix_ident, 0 }, /* 0x10 */ + { &model1_state::matrix_read, 0 }, + { &model1_state::matrix_trans, 3 }, + { &model1_state::matrix_scale, 3 }, + { &model1_state::matrix_rotx, 1 }, + { &model1_state::matrix_roty, 1 }, + { &model1_state::matrix_rotz, 1 }, + { NULL, 0 }, + { &model1_state::track_read_quad, 1 }, + { NULL, 0 }, + { &model1_state::transform_point, 3 }, + { &model1_state::fsin_m1, 1 }, + { &model1_state::fcos_m1, 1 }, + { &model1_state::fsinm_m1, 2 }, + { &model1_state::fcosm_m1, 2 }, + { &model1_state::distance3, 6 }, - { matrix_ident, 0 }, /* 0x10 */ - { matrix_read, 0 }, - { matrix_trans, 3 }, - { matrix_scale, 3 }, - { matrix_rotx, 1 }, - { matrix_roty, 1 }, - { matrix_rotz, 1 }, - { NULL, 0 }, - { track_read_quad, 1 }, - { NULL, 0 }, - { transform_point, 3 }, - { fsin_m1, 1 }, - { fcos_m1, 1 }, - { fsinm_m1, 2 }, - { fcosm_m1, 2 }, - { distance3, 6 }, + { NULL, 0 }, /* 0x20 */ + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { &model1_state::acc_set, 1 }, + { &model1_state::acc_get, 0 }, + { &model1_state::acc_add, 1 }, + { &model1_state::acc_sub, 1 }, + { &model1_state::acc_mul, 1 }, + { &model1_state::acc_div, 1 }, // not used ? + { &model1_state::f42, 3 }, + { &model1_state::f43, 6 }, + { &model1_state::f44, 1 }, + { &model1_state::f45, 1 }, + { &model1_state::vlength, 3 }, + { NULL, 0 }, - { NULL, 0 }, /* 0x20 */ - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { acc_set, 1 }, - { acc_get, 0 }, - { acc_add, 1 }, - { acc_sub, 1 }, - { acc_mul, 1 }, - { acc_div, 1 }, // not used ? - { f42, 3 }, - { f43, 6 }, - { f44, 1 }, - { f45, 1 }, - { vlength, 3 }, - { NULL, 0 }, + { &model1_state::track_read_info, 1 }, /* 0x30 */ + { &model1_state::colbox_set, 12 }, + { &model1_state::colbox_test, 3 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { &model1_state::track_lookup, 4 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, - { track_read_info, 1 }, /* 0x30 */ - { colbox_set, 12 }, - { colbox_test, 3 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { track_lookup, 4 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, + { &model1_state::col_setcirc, 3 }, /* 0x40 */ + { &model1_state::col_testpt, 2 }, + { NULL, 0 }, + { &model1_state::distance, 4 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { &model1_state::car_move, 4 }, + { &model1_state::cpa, 12 }, + { NULL, 0 }, + { &model1_state::vmat_store, 1 }, + { &model1_state::vmat_restore, 1 }, + { NULL, 0 }, + { &model1_state::vmat_mul, 2 }, + { &model1_state::vmat_read, 1 }, + { &model1_state::matrix_unrot, 0 }, - { col_setcirc, 3 }, /* 0x40 */ - { col_testpt, 2 }, - { NULL, 0 }, - { distance, 4 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { car_move, 4 }, - { cpa, 12 }, - { NULL, 0 }, - { vmat_store, 1 }, - { vmat_restore, 1 }, - { NULL, 0 }, - { vmat_mul, 2 }, - { vmat_read, 1 }, - { matrix_unrot, 0 }, + { &model1_state::f80, 0 }, /* 0x50 */ + { NULL, 0 }, + { &model1_state::matrix_rtrans, 0 }, + { NULL, 0 }, + { &model1_state::vmat_save, 1 }, + { &model1_state::vmat_load, 1 }, + { &model1_state::ram_setadr, 1 }, + { &model1_state::groundbox_test, 3 }, + { NULL, 0 }, + { &model1_state::f89, 4 }, + { NULL, 0 }, + { NULL, 0 }, + { &model1_state::f92, 4 }, + { &model1_state::f93, 1 }, + { &model1_state::f94, 1 }, + { &model1_state::vmat_flatten, 0 }, - { f80, 0 }, /* 0x50 */ - { NULL, 0 }, - { matrix_rtrans, 0 }, - { NULL, 0 }, - { vmat_save, 1 }, - { vmat_load, 1 }, - { ram_setadr, 1 }, - { groundbox_test, 3 }, - { NULL, 0 }, - { f89, 4 }, - { NULL, 0 }, - { NULL, 0 }, - { f92, 4 }, - { f93, 1 }, - { f94, 1 }, - { vmat_flatten, 0 }, - - { vmat_load1, 1 }, /* 0x60 */ - { ram_trans, 0 }, - { f98, 1 }, - { f99, 0 }, - { f100, 0 }, - { groundbox_set, 7 }, - { f102, 8 }, - { f103, 1 } + { &model1_state::vmat_load1, 1 }, /* 0x60 */ + { &model1_state::ram_trans, 0 }, + { &model1_state::f98, 1 }, + { &model1_state::f99, 0 }, + { &model1_state::f100, 0 }, + { &model1_state::groundbox_set, 7 }, + { &model1_state::f102, 8 }, + { &model1_state::f103, 1 } }; // Used in swa scene 1 and unemulated: @@ -1803,142 +1697,139 @@ static const struct function ftab_vf[] = { // f49_swa // f15_swa -static const struct function ftab_swa[] = { - { fadd, 2 }, /* 0x00 */ - { fsub, 2 }, - { fmul, 2 }, - { fdiv, 2 }, - { NULL, 0 }, - { matrix_push, 0 }, - { matrix_pop, 0 }, - { matrix_write, 12 }, - { clear_stack, 0 }, - { matrix_mul, 12 }, - { anglev, 2 }, - { f11, 9 }, - { normalize, 3 }, - { acc_seti, 1 }, - { f14, 4 }, - { f15_swa, 0 }, +const struct model1_state::function model1_state::ftab_swa[] = { + { &model1_state::fadd, 2 }, /* 0x00 */ + { &model1_state::fsub, 2 }, + { &model1_state::fmul, 2 }, + { &model1_state::fdiv, 2 }, + { NULL, 0 }, + { &model1_state::matrix_push, 0 }, + { &model1_state::matrix_pop, 0 }, + { &model1_state::matrix_write, 12 }, + { &model1_state::clear_stack, 0 }, + { &model1_state::matrix_mul, 12 }, + { &model1_state::anglev, 2 }, + { &model1_state::f11, 9 }, + { &model1_state::normalize, 3 }, + { &model1_state::acc_seti, 1 }, + { &model1_state::f14, 4 }, + { &model1_state::f15_swa, 0 }, - { matrix_ident, 0 }, /* 0x10 */ - { matrix_read, 0 }, - { matrix_trans, 3 }, - { matrix_scale, 3 }, - { matrix_rotx, 1 }, - { matrix_roty, 1 }, - { matrix_rotz, 1 }, - { NULL, 0 }, - { f24_swa, 7 }, - { NULL, 0 }, - { transform_point, 3 }, - { fsin_m1, 1 }, - { fcos_m1, 1 }, - { fsinm_m1, 2 }, - { fcosm_m1, 2 }, - { distance3, 6 }, + { &model1_state::matrix_ident, 0 }, /* 0x10 */ + { &model1_state::matrix_read, 0 }, + { &model1_state::matrix_trans, 3 }, + { &model1_state::matrix_scale, 3 }, + { &model1_state::matrix_rotx, 1 }, + { &model1_state::matrix_roty, 1 }, + { &model1_state::matrix_rotz, 1 }, + { NULL, 0 }, + { &model1_state::f24_swa, 7 }, + { NULL, 0 }, + { &model1_state::transform_point, 3 }, + { &model1_state::fsin_m1, 1 }, + { &model1_state::fcos_m1, 1 }, + { &model1_state::fsinm_m1, 2 }, + { &model1_state::fcosm_m1, 2 }, + { &model1_state::distance3, 6 }, - { NULL, 0 }, /* 0x20 */ - { NULL, 0 }, - { ftoi, 1 }, - { itof, 1 }, - { acc_set, 1 }, - { acc_get, 0 }, - { acc_add, 1 }, - { acc_sub, 1 }, - { acc_mul, 1 }, - { acc_div, 1 }, // not used ? - { xyz2rqf, 3 }, - { f43_swa, 3 }, - { matrix_sdir, 3 }, - { f45, 1 }, - { vlength, 3 }, - { f47, 3 }, + { NULL, 0 }, /* 0x20 */ + { NULL, 0 }, + { &model1_state::ftoi, 1 }, + { &model1_state::itof, 1 }, + { &model1_state::acc_set, 1 }, + { &model1_state::acc_get, 0 }, + { &model1_state::acc_add, 1 }, + { &model1_state::acc_sub, 1 }, + { &model1_state::acc_mul, 1 }, + { &model1_state::acc_div, 1 }, // not used ? + { &model1_state::xyz2rqf, 3 }, + { &model1_state::f43_swa, 3 }, + { &model1_state::matrix_sdir, 3 }, + { &model1_state::f45, 1 }, + { &model1_state::vlength, 3 }, + { &model1_state::f47, 3 }, - { NULL, 0 }, /* 0x30 */ - { f49_swa, 6 }, - { f50_swa, 4 }, - { NULL, 0 }, - { f52, 0 }, - { matrix_rdir, 3 }, - { NULL, 0 }, - { NULL, 0 }, - { f56, 7 }, - { f57, 0 }, - { matrix_readt, 0 }, - { acc_geti, 0 }, - { f60, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, + { NULL, 0 }, /* 0x30 */ + { &model1_state::f49_swa, 6 }, + { &model1_state::f50_swa, 4 }, + { NULL, 0 }, + { &model1_state::f52, 0 }, + { &model1_state::matrix_rdir, 3 }, + { NULL, 0 }, + { NULL, 0 }, + { &model1_state::f56, 7 }, + { &model1_state::f57, 0 }, + { &model1_state::matrix_readt, 0 }, + { &model1_state::acc_geti, 0 }, + { &model1_state::f60, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, + { NULL, 0 }, - { push_and_ident, 0 }, /* 0x40 */ - { NULL, 0 }, - { catmull_rom, 13 } + { &model1_state::push_and_ident, 0 }, /* 0x40 */ + { NULL, 0 }, + { &model1_state::catmull_rom, 13 } }; -static TGP_FUNCTION( dump ) +TGP_FUNCTION( model1_state::dump ) { - model1_state *state = machine.driver_data(); - logerror("TGP FIFOIN write %08x (%x)\n", fifoin_pop(state), state->m_pushpc); - state->m_fifoin_cbcount = 1; - state->m_fifoin_cb = dump; + logerror("TGP FIFOIN write %08x (%x)\n", fifoin_pop(), m_pushpc); + m_fifoin_cbcount = 1; + m_fifoin_cb = &model1_state::dump; } -static TGP_FUNCTION( function_get_vf ) +TGP_FUNCTION( model1_state::function_get_vf ) { - model1_state *state = machine.driver_data(); - UINT32 f = fifoin_pop(state) >> 23; + UINT32 f = fifoin_pop() >> 23; - if(state->m_fifoout_rpos != state->m_fifoout_wpos) { - int count = state->m_fifoout_wpos - state->m_fifoout_rpos; + if(m_fifoout_rpos != m_fifoout_wpos) { + int count = m_fifoout_wpos - m_fifoout_rpos; if(count < 0) count += FIFO_SIZE; logerror("TGP function called with sizeout = %d\n", count); } if(ARRAY_LENGTH(ftab_vf) > f && NULL != ftab_vf[f].cb) { - state->m_fifoin_cbcount = ftab_vf[f].count; - state->m_fifoin_cb = ftab_vf[f].cb; - // logerror("TGP function %d request, %d parameters\n", f, state->m_fifoin_cbcount); - if(!state->m_fifoin_cbcount) - state->m_fifoin_cb(machine); + m_fifoin_cbcount = ftab_vf[f].count; + m_fifoin_cb = model1_state::ftab_vf[f].cb; + // logerror("TGP function %d request, %d parameters\n", f, m_fifoin_cbcount); + if(!m_fifoin_cbcount) + (this->*m_fifoin_cb)(); } else { - logerror("TGP function %d unimplemented (%x)\n", f, state->m_pushpc); - state->m_fifoin_cbcount = 1; - state->m_fifoin_cb = dump; + logerror("TGP function %d unimplemented (%x)\n", f, m_pushpc); + m_fifoin_cbcount = 1; + m_fifoin_cb = &model1_state::dump; } } -static TGP_FUNCTION( function_get_swa ) +TGP_FUNCTION( model1_state::function_get_swa ) { - model1_state *state = machine.driver_data(); - UINT32 f = fifoin_pop(state); + UINT32 f = fifoin_pop(); - if(state->m_fifoout_rpos != state->m_fifoout_wpos) { - int count = state->m_fifoout_wpos - state->m_fifoout_rpos; + if(m_fifoout_rpos != m_fifoout_wpos) { + int count = m_fifoout_wpos - m_fifoout_rpos; if(count < 0) count += FIFO_SIZE; logerror("TGP function called with sizeout = %d\n", count); } if(ARRAY_LENGTH(ftab_swa) > f && NULL != ftab_swa[f].cb) { - state->m_fifoin_cbcount = ftab_swa[f].count; - state->m_fifoin_cb = ftab_swa[f].cb; - // logerror("TGP function %d request, %d parameters\n", f, state->m_fifoin_cbcount); - if(!state->m_fifoin_cbcount) - state->m_fifoin_cb(machine); + m_fifoin_cbcount = ftab_swa[f].count; + m_fifoin_cb = model1_state::ftab_swa[f].cb; + // logerror("TGP function %d request, %d parameters\n", f, m_fifoin_cbcount); + if(!m_fifoin_cbcount) + (this->*m_fifoin_cb)(); } else { - logerror("TGP function %d unimplemented (%x)\n", f, state->m_pushpc); - state->m_fifoin_cbcount = 1; - state->m_fifoin_cb = dump; + logerror("TGP function %d unimplemented (%x)\n", f, m_pushpc); + m_fifoin_cbcount = 1; + m_fifoin_cb = &model1_state::dump; } } READ16_MEMBER(model1_state::model1_tgp_copro_r) { if(!offset) { - m_copro_r = fifoout_pop(space); + m_copro_r = fifoout_pop(); return m_copro_r; } else return m_copro_r >> 16; @@ -1949,7 +1840,7 @@ WRITE16_MEMBER(model1_state::model1_tgp_copro_w) if(offset) { m_copro_w = (m_copro_w & 0x0000ffff) | (data << 16); m_pushpc = space.device().safe_pc(); - fifoin_push(space, m_copro_w); + fifoin_push(m_copro_w); } else m_copro_w = (m_copro_w & 0xffff0000) | data; } @@ -2006,44 +1897,42 @@ MACHINE_START_MEMBER(model1_state,model1) save_item(NAME(m_list_length)); } -void model1_tgp_reset(running_machine &machine, int swa) +void model1_state::tgp_reset(int swa) { - model1_state *state = machine.driver_data(); - state->m_ram_adr = 0; - memset(state->m_ram_data, 0, 0x10000*4); + m_ram_adr = 0; + memset(m_ram_data, 0, 0x10000*4); - state->m_fifoout_rpos = 0; - state->m_fifoout_wpos = 0; - state->m_fifoin_rpos = 0; - state->m_fifoin_wpos = 0; + m_fifoout_rpos = 0; + m_fifoout_wpos = 0; + m_fifoin_rpos = 0; + m_fifoin_wpos = 0; - state->m_acc = 0; - state->m_mat_stack_pos = 0; - memset(state->m_cmat, 0, sizeof(state->m_cmat)); - state->m_cmat[0] = 1.0; - state->m_cmat[4] = 1.0; - state->m_cmat[8] = 1.0; + m_acc = 0; + m_mat_stack_pos = 0; + memset(m_cmat, 0, sizeof(m_cmat)); + m_cmat[0] = 1.0; + m_cmat[4] = 1.0; + m_cmat[8] = 1.0; - state->m_dump = 0; - state->m_swa = swa; - next_fn(state); + m_dump = 0; + m_swa = swa; + next_fn(); } /*********************************** Virtua Racing ***********************************/ -void model1_vr_tgp_reset( running_machine &machine ) +void model1_state::vr_tgp_reset() { - model1_state *state = machine.driver_data(); - state->m_ram_adr = 0; - memset(state->m_ram_data, 0, 0x8000*4); + m_ram_adr = 0; + memset(m_ram_data, 0, 0x8000*4); - state->m_copro_fifoout_rpos = 0; - state->m_copro_fifoout_wpos = 0; - state->m_copro_fifoout_num = 0; - state->m_copro_fifoin_rpos = 0; - state->m_copro_fifoin_wpos = 0; - state->m_copro_fifoin_num = 0; + m_copro_fifoout_rpos = 0; + m_copro_fifoout_wpos = 0; + m_copro_fifoout_num = 0; + m_copro_fifoin_rpos = 0; + m_copro_fifoin_wpos = 0; + m_copro_fifoin_num = 0; } /* FIFO */ @@ -2072,47 +1961,43 @@ READ32_MEMBER(model1_state::copro_fifoin_pop) } -static void copro_fifoin_push(address_space &space, UINT32 data) +void model1_state::copro_fifoin_push(UINT32 data) { - model1_state *state = space.machine().driver_data(); - if (state->m_copro_fifoin_num == FIFO_SIZE) + if (m_copro_fifoin_num == FIFO_SIZE) { - fatalerror("Copro FIFOIN overflow (at %08X)\n", space.device().safe_pc()); + fatalerror("Copro FIFOIN overflow (at %08X)\n", safe_pc()); } - state->m_copro_fifoin_data[state->m_copro_fifoin_wpos++] = data; + m_copro_fifoin_data[m_copro_fifoin_wpos++] = data; - if (state->m_copro_fifoin_wpos == FIFO_SIZE) + if (m_copro_fifoin_wpos == FIFO_SIZE) { - state->m_copro_fifoin_wpos = 0; + m_copro_fifoin_wpos = 0; } - state->m_copro_fifoin_num++; + m_copro_fifoin_num++; } -static UINT32 copro_fifoout_pop(address_space &space) +UINT32 model1_state::copro_fifoout_pop() { - model1_state *state = space.machine().driver_data(); - UINT32 r; - - if (state->m_copro_fifoout_num == 0) + if (m_copro_fifoout_num == 0) { // Reading from empty FIFO causes the v60 to enter wait state - state->m_maincpu->stall(); + m_maincpu->stall(); - space.machine().scheduler().synchronize(); + machine().scheduler().synchronize(); return 0; } - r = state->m_copro_fifoout_data[state->m_copro_fifoout_rpos++]; + UINT32 r = m_copro_fifoout_data[m_copro_fifoout_rpos++]; - if (state->m_copro_fifoout_rpos == FIFO_SIZE) + if (m_copro_fifoout_rpos == FIFO_SIZE) { - state->m_copro_fifoout_rpos = 0; + m_copro_fifoout_rpos = 0; } - state->m_copro_fifoout_num--; + m_copro_fifoout_num--; return r; } @@ -2202,7 +2087,7 @@ READ16_MEMBER(model1_state::model1_vr_tgp_r) { if (!offset) { - m_vr_r = copro_fifoout_pop(space); + m_vr_r = copro_fifoout_pop(); return m_vr_r; } else @@ -2214,7 +2099,7 @@ WRITE16_MEMBER(model1_state::model1_vr_tgp_w) if (offset) { m_vr_w = (m_vr_w & 0x0000ffff) | (data << 16); - copro_fifoin_push(space, m_vr_w); + copro_fifoin_push(m_vr_w); } else m_vr_w = (m_vr_w & 0xffff0000) | data; diff --git a/src/mame/video/model1.c b/src/mame/video/model1.c index b78fd0f0e6f..e6ebe084c37 100644 --- a/src/mame/video/model1.c +++ b/src/mame/video/model1.c @@ -69,7 +69,7 @@ static float readf(const UINT16 *adr) return u2f(readi(adr)); } -static void transform_point(struct view *view, struct point *p) +static void _transform_point(struct view *view, struct point *p) { struct point q = *p; float *trans = view->trans_mat; @@ -415,28 +415,28 @@ static int comp_quads(const void *q1, const void *q2) return +1; } -static void sort_quads(model1_state *state) +void model1_state::sort_quads() { - int count = state->m_quadpt - state->m_quaddb; + int count = m_quadpt - m_quaddb; int i; for(i=0; im_quadind[i] = state->m_quaddb+i; - qsort(state->m_quadind, count, sizeof(struct quad_m1 *), comp_quads); + m_quadind[i] = m_quaddb+i; + qsort(m_quadind, count, sizeof(struct quad_m1 *), comp_quads); } -static void unsort_quads(model1_state *state) +void model1_state::unsort_quads() { - int count = state->m_quadpt - state->m_quaddb; + int count = m_quadpt - m_quaddb; int i; for(i=0; im_quadind[i] = state->m_quaddb+i; + m_quadind[i] = m_quaddb+i; } -static void draw_quads(model1_state *state, bitmap_rgb32 &bitmap, const rectangle &cliprect) +void model1_state::draw_quads(bitmap_rgb32 &bitmap, const rectangle &cliprect) { - struct view *view = state->m_view; - int count = state->m_quadpt - state->m_quaddb; + struct view *view = m_view; + int count = m_quadpt - m_quaddb; int i; /* clip to the cliprect */ @@ -450,7 +450,7 @@ static void draw_quads(model1_state *state, bitmap_rgb32 &bitmap, const rectangl view->y2 = MIN(view->y2, cliprect.max_y); for(i=0; im_quadind[i]; + struct quad_m1 *q = m_quadind[i]; fill_quad(bitmap, view, q); #if 0 @@ -566,9 +566,7 @@ static const struct { { fclip_isc_right, fclip_clip_right }, }; -static void fclip_push_quad(model1_state *state, int level, struct quad_m1 *q); - -static void fclip_push_quad_next(model1_state *state, int level, struct quad_m1 *q, +void model1_state::fclip_push_quad_next(int level, struct quad_m1 *q, struct point *p1, struct point *p2, struct point *p3, struct point *p4) { struct quad_m1 q2; @@ -579,12 +577,12 @@ static void fclip_push_quad_next(model1_state *state, int level, struct quad_m1 q2.p[2] = p3; q2.p[3] = p4; - fclip_push_quad(state, level+1, &q2); + fclip_push_quad(level+1, &q2); } -static void fclip_push_quad(model1_state *state, int level, struct quad_m1 *q) +void model1_state::fclip_push_quad(int level, struct quad_m1 *q) { - struct view *view = state->m_view; + struct view *view = m_view; int i, j; struct point *pt[4], *pi1, *pi2; int is_out[4], is_out2[4]; @@ -595,8 +593,8 @@ static void fclip_push_quad(model1_state *state, int level, struct quad_m1 *q) for(i=0; i<4; i++) LOG_TGP((" (%f, %f, %f)", q->p[i]->x, q->p[i]->y, q->p[i]->z)); LOG_TGP(("\n")); - *state->m_quadpt = *q; - state->m_quadpt++; + *m_quadpt = *q; + m_quadpt++; return; } @@ -610,7 +608,7 @@ static void fclip_push_quad(model1_state *state, int level, struct quad_m1 *q) // No clipping if(!is_out[0] && !is_out[1] && !is_out[2] && !is_out[3]) { - fclip_push_quad(state, level+1, q); + fclip_push_quad(level+1, q); return; } @@ -634,40 +632,40 @@ static void fclip_push_quad(model1_state *state, int level, struct quad_m1 *q) if(is_out2[1]) if(is_out2[2]) { // pt 0,1,2 clipped out, one triangle left - fclip_point(view, state->m_pointpt, pt[2], pt[3]); - pi1 = state->m_pointpt++; - fclip_point(view, state->m_pointpt, pt[3], pt[0]); - pi2 = state->m_pointpt++; - fclip_push_quad_next(state, level, q, pi1, pt[3], pi2, pi2); + fclip_point(view, m_pointpt, pt[2], pt[3]); + pi1 = m_pointpt++; + fclip_point(view, m_pointpt, pt[3], pt[0]); + pi2 = m_pointpt++; + fclip_push_quad_next(level, q, pi1, pt[3], pi2, pi2); } else { // pt 0,1 clipped out, one quad left - fclip_point(view, state->m_pointpt, pt[1], pt[2]); - pi1 = state->m_pointpt++; - fclip_point(view, state->m_pointpt, pt[3], pt[0]); - pi2 = state->m_pointpt++; - fclip_push_quad_next(state, level, q, pi1, pt[2], pt[3], pi2); + fclip_point(view, m_pointpt, pt[1], pt[2]); + pi1 = m_pointpt++; + fclip_point(view, m_pointpt, pt[3], pt[0]); + pi2 = m_pointpt++; + fclip_push_quad_next(level, q, pi1, pt[2], pt[3], pi2); } else if(is_out2[2]) { // pt 0,2 clipped out, shouldn't happen, two triangles - fclip_point(view, state->m_pointpt, pt[0], pt[1]); - pi1 = state->m_pointpt++; - fclip_point(view, state->m_pointpt, pt[1], pt[2]); - pi2 = state->m_pointpt++; - fclip_push_quad_next(state, level, q, pi1, pt[1], pi2, pi2); - fclip_point(view, state->m_pointpt, pt[2], pt[3]); - pi1 = state->m_pointpt++; - fclip_point(view, state->m_pointpt, pt[3], pt[0]); - pi2 = state->m_pointpt++; - fclip_push_quad_next(state, level, q, pi1, pt[3], pi2, pi2); + fclip_point(view, m_pointpt, pt[0], pt[1]); + pi1 = m_pointpt++; + fclip_point(view, m_pointpt, pt[1], pt[2]); + pi2 = m_pointpt++; + fclip_push_quad_next(level, q, pi1, pt[1], pi2, pi2); + fclip_point(view, m_pointpt, pt[2], pt[3]); + pi1 = m_pointpt++; + fclip_point(view, m_pointpt, pt[3], pt[0]); + pi2 = m_pointpt++; + fclip_push_quad_next(level, q, pi1, pt[3], pi2, pi2); } else { // pt 0 clipped out, one decagon left, split in quad+tri - fclip_point(view, state->m_pointpt, pt[0], pt[1]); - pi1 = state->m_pointpt++; - fclip_point(view, state->m_pointpt, pt[3], pt[0]); - pi2 = state->m_pointpt++; - fclip_push_quad_next(state, level, q, pi1, pt[1], pt[2], pt[3]); - fclip_push_quad_next(state, level, q, pt[3], pi2, pi1, pi1); + fclip_point(view, m_pointpt, pt[0], pt[1]); + pi1 = m_pointpt++; + fclip_point(view, m_pointpt, pt[3], pt[0]); + pi2 = m_pointpt++; + fclip_push_quad_next(level, q, pi1, pt[1], pt[2], pt[3]); + fclip_push_quad_next(level, q, pt[3], pi2, pi1, pi1); } } @@ -724,10 +722,9 @@ static float compute_specular(struct vector *normal, struct vector *light,float return 0; } -static void push_object(running_machine &machine, UINT32 tex_adr, UINT32 poly_adr, UINT32 size) +void model1_state::push_object(UINT32 tex_adr, UINT32 poly_adr, UINT32 size) { - model1_state *state = machine.driver_data(); - struct view *view = state->m_view; + struct view *view = m_view; int i; UINT32 flags; struct point *old_p0, *old_p1, *p0, *p1; @@ -742,9 +739,9 @@ static void push_object(running_machine &machine, UINT32 tex_adr, UINT32 poly_ad float *poly_data; if(poly_adr & 0x800000) - poly_data=(float *) state->m_poly_ram; + poly_data=(float *) m_poly_ram; else - poly_data=(float *) state->m_poly_rom; + poly_data=(float *) m_poly_rom; poly_adr &= 0x7fffff; #if 0 @@ -773,8 +770,8 @@ static void push_object(running_machine &machine, UINT32 tex_adr, UINT32 poly_ad if(!size) size = 0xffffffff; - old_p0 = state->m_pointpt++; - old_p1 = state->m_pointpt++; + old_p0 = m_pointpt++; + old_p1 = m_pointpt++; old_p0->x = poly_data[poly_adr+0]; old_p0->y = poly_data[poly_adr+1]; @@ -782,8 +779,8 @@ static void push_object(running_machine &machine, UINT32 tex_adr, UINT32 poly_ad old_p1->x = poly_data[poly_adr+3]; old_p1->y = poly_data[poly_adr+4]; old_p1->z = poly_data[poly_adr+5]; - transform_point(view, old_p0); - transform_point(view, old_p1); + _transform_point(view, old_p0); + _transform_point(view, old_p1); if(old_p0->z > 0) project_point(view, old_p0); else @@ -815,8 +812,8 @@ static void push_object(running_machine &machine, UINT32 tex_adr, UINT32 poly_ad tex_adr ++; lightmode=(flags>>17)&15; - p0 = state->m_pointpt++; - p1 = state->m_pointpt++; + p0 = m_pointpt++; + p1 = m_pointpt++; vn.x = poly_data[poly_adr+1]; vn.y = poly_data[poly_adr+2]; @@ -832,8 +829,8 @@ static void push_object(running_machine &machine, UINT32 tex_adr, UINT32 poly_ad transform_vector(view, &vn); - transform_point(view, p0); - transform_point(view, p1); + _transform_point(view, p0); + _transform_point(view, p1); if(p0->z > 0) project_point(view, p0); else @@ -896,30 +893,30 @@ static void push_object(running_machine &machine, UINT32 tex_adr, UINT32 poly_ad #if 0 float dif=mult_vector(&vn, &view->light); float ln=view->lightparams[lightmode].a + view->lightparams[lightmode].d*MAX(0.0,dif); - cquad.col = scale_color(machine.pens[0x1000|(state->m_tgp_ram[tex_adr-0x40000] & 0x3ff)], MIN(1.0,ln)); - cquad.col = scale_color(machine.pens[0x1000|(state->m_tgp_ram[tex_adr-0x40000] & 0x3ff)], MIN(1.0,ln)); + cquad.col = scale_color(machine().pens[0x1000|(m_tgp_ram[tex_adr-0x40000] & 0x3ff)], MIN(1.0,ln)); + cquad.col = scale_color(machine().pens[0x1000|(m_tgp_ram[tex_adr-0x40000] & 0x3ff)], MIN(1.0,ln)); #endif float dif=mult_vector(&vn, &view->light); float spec=compute_specular(&vn,&view->light,dif,lightmode); float ln=view->lightparams[lightmode].a + view->lightparams[lightmode].d*MAX(0.0,dif) + spec; int lumval=255.0*MIN(1.0,ln); - int color=state->m_paletteram16[0x1000|(state->m_tgp_ram[tex_adr-0x40000] & 0x3ff)]; + int color=m_paletteram16[0x1000|(m_tgp_ram[tex_adr-0x40000] & 0x3ff)]; int r=(color>>0x0)&0x1f; int g=(color>>0x5)&0x1f; int b=(color>>0xA)&0x1f; lumval>>=2; //there must be a luma translation table somewhere if(lumval>0x3f) lumval=0x3f; else if(lumval<0) lumval=0; - r=(state->m_color_xlat[(r<<8)|lumval|0x0]>>3)&0x1f; - g=(state->m_color_xlat[(g<<8)|lumval|0x2000]>>3)&0x1f; - b=(state->m_color_xlat[(b<<8)|lumval|0x4000]>>3)&0x1f; + r=(m_color_xlat[(r<<8)|lumval|0x0]>>3)&0x1f; + g=(m_color_xlat[(g<<8)|lumval|0x2000]>>3)&0x1f; + b=(m_color_xlat[(b<<8)|lumval|0x4000]>>3)&0x1f; cquad.col=(pal5bit(r)<<16)|(pal5bit(g)<<8)|(pal5bit(b)<<0); } if(flags & 0x00002000) cquad.col |= MOIRE; - fclip_push_quad(state, 0, &cquad); + fclip_push_quad(0, &cquad); next: poly_adr += 10; @@ -939,9 +936,9 @@ static void push_object(running_machine &machine, UINT32 tex_adr, UINT32 poly_ad } } -static UINT16 *push_direct(model1_state *state, UINT16 *list) +UINT16 *model1_state::push_direct(UINT16 *list) { - struct view *view = state->m_view; + struct view *view = m_view; UINT32 flags; UINT32 tex_adr, lum; //, v1, v2; struct point *old_p0, *old_p1, *p0, *p1; @@ -953,8 +950,8 @@ static UINT16 *push_direct(model1_state *state, UINT16 *list) // v1 = readi(list+2); // v2 = readi(list+10); - old_p0 = state->m_pointpt++; - old_p1 = state->m_pointpt++; + old_p0 = m_pointpt++; + old_p1 = m_pointpt++; old_p0->x = readf(list+4); old_p0->y = readf(list+6); @@ -968,8 +965,8 @@ static UINT16 *push_direct(model1_state *state, UINT16 *list) old_p0->x, old_p0->y, old_p0->z, old_p1->x, old_p1->y, old_p1->z)); - //transform_point(view, old_p0); - //transform_point(view, old_p1); + //_transform_point(view, old_p0); + //_transform_point(view, old_p1); if(old_p0->z > 0) project_point_direct(view, old_p0); else @@ -995,8 +992,8 @@ static UINT16 *push_direct(model1_state *state, UINT16 *list) // list+4 is 0? // list+12 is z? - p0 = state->m_pointpt++; - p1 = state->m_pointpt++; + p0 = m_pointpt++; + p1 = m_pointpt++; lum = readi(list+2); // v1 = readi(list+4); @@ -1028,8 +1025,8 @@ static UINT16 *push_direct(model1_state *state, UINT16 *list) link = (flags >> 8) & 3; - //transform_point(view, p0); - //transform_point(view, p1); + //_transform_point(view, p0); + //_transform_point(view, p1); if(p0->z > 0) project_point_direct(view, p0); if(p1->z > 0) @@ -1061,23 +1058,23 @@ static UINT16 *push_direct(model1_state *state, UINT16 *list) cquad.z = z; { int lumval=((float) (lum>>24)) * 2.0; - int color=state->m_paletteram16[0x1000|(state->m_tgp_ram[tex_adr-0x40000] & 0x3ff)]; + int color=m_paletteram16[0x1000|(m_tgp_ram[tex_adr-0x40000] & 0x3ff)]; int r=(color>>0x0)&0x1f; int g=(color>>0x5)&0x1f; int b=(color>>0xA)&0x1f; lumval>>=2; //there must be a luma translation table somewhere if(lumval>0x3f) lumval=0x3f; else if(lumval<0) lumval=0; - r=(state->m_color_xlat[(r<<8)|lumval|0x0]>>3)&0x1f; - g=(state->m_color_xlat[(g<<8)|lumval|0x2000]>>3)&0x1f; - b=(state->m_color_xlat[(b<<8)|lumval|0x4000]>>3)&0x1f; + r=(m_color_xlat[(r<<8)|lumval|0x0]>>3)&0x1f; + g=(m_color_xlat[(g<<8)|lumval|0x2000]>>3)&0x1f; + b=(m_color_xlat[(b<<8)|lumval|0x4000]>>3)&0x1f; cquad.col=(pal5bit(r)<<16)|(pal5bit(g)<<8)|(pal5bit(b)<<0); } - //cquad.col = scale_color(machine.pens[0x1000|(state->m_tgp_ram[tex_adr-0x40000] & 0x3ff)],((float) (lum>>24)) / 128.0); + //cquad.col = scale_color(machine().pens[0x1000|(m_tgp_ram[tex_adr-0x40000] & 0x3ff)],((float) (lum>>24)) / 128.0); if(flags & 0x00002000) cquad.col |= MOIRE; - fclip_push_quad(state, 0, &cquad); + fclip_push_quad(0, &cquad); next: switch(link) { @@ -1119,53 +1116,52 @@ static UINT16 *skip_direct(UINT16 *list) return list+2; } -static void draw_objects(model1_state *state, bitmap_rgb32 &bitmap, const rectangle &cliprect) +void model1_state::draw_objects(bitmap_rgb32 &bitmap, const rectangle &cliprect) { - if(state->m_quadpt != state->m_quaddb) { + if(m_quadpt != m_quaddb) { LOG_TGP(("VIDEO: sort&draw\n")); - sort_quads(state); - draw_quads(state, bitmap, cliprect); + sort_quads(); + draw_quads(bitmap, cliprect); } - state->m_quadpt = state->m_quaddb; - state->m_pointpt = state->m_pointdb; + m_quadpt = m_quaddb; + m_pointpt = m_pointdb; } -static UINT16 *draw_direct(model1_state *state, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT16 *list) +UINT16 *model1_state::draw_direct(bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT16 *list) { UINT16 *res; LOG_TGP(("VIDEO: draw direct %x\n", readi(list))); - draw_objects(state, bitmap, cliprect); - res = push_direct(state, list); - unsort_quads(state); - draw_quads(state, bitmap, cliprect); + draw_objects(bitmap, cliprect); + res = push_direct(list); + unsort_quads(); + draw_quads(bitmap, cliprect); - state->m_quadpt = state->m_quaddb; - state->m_pointpt = state->m_pointdb; + m_quadpt = m_quaddb; + m_pointpt = m_pointdb; return res; } -static UINT16 *get_list(model1_state *state) +UINT16 *model1_state::get_list() { - if(!(state->m_listctl[0] & 4)) - state->m_listctl[0] = (state->m_listctl[0] & ~0x40) | (state->m_listctl[0] & 8 ? 0x40 : 0); - return state->m_listctl[0] & 0x40 ? state->m_display_list1 : state->m_display_list0; + if(!(m_listctl[0] & 4)) + m_listctl[0] = (m_listctl[0] & ~0x40) | (m_listctl[0] & 8 ? 0x40 : 0); + return m_listctl[0] & 0x40 ? m_display_list1 : m_display_list0; } -static int get_list_number(model1_state *state) +int model1_state::get_list_number() { - if(!(state->m_listctl[0] & 4)) - state->m_listctl[0] = (state->m_listctl[0] & ~0x40) | (state->m_listctl[0] & 8 ? 0x40 : 0); - return state->m_listctl[0] & 0x40 ? 0 : 1; + if(!(m_listctl[0] & 4)) + m_listctl[0] = (m_listctl[0] & ~0x40) | (m_listctl[0] & 8 ? 0x40 : 0); + return m_listctl[0] & 0x40 ? 0 : 1; } -static void end_frame(running_machine &machine) +void model1_state::end_frame() { - model1_state *state = machine.driver_data(); - if((state->m_listctl[0] & 4) && (machine.first_screen()->frame_number() & 1)) - state->m_listctl[0] ^= 0x40; + if((m_listctl[0] & 4) && (m_screen->frame_number() & 1)) + m_listctl[0] ^= 0x40; } READ16_MEMBER(model1_state::model1_listctl_r) @@ -1182,15 +1178,14 @@ WRITE16_MEMBER(model1_state::model1_listctl_w) LOG_TGP(("VIDEO: control=%08x\n", (m_listctl[1]<<16)|m_listctl[0])); } -static void tgp_render(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect) +void model1_state::tgp_render(bitmap_rgb32 &bitmap, const rectangle &cliprect) { - model1_state *state = machine.driver_data(); - struct view *view = state->m_view; - state->m_render_done = 1; - if((state->m_listctl[1] & 0x1f) == 0x1f) { - UINT16 *list = get_list(state); + struct view *view = m_view; + m_render_done = 1; + if((m_listctl[1] & 0x1f) == 0x1f) { + UINT16 *list = get_list(); int zz = 0; - LOG_TGP(("VIDEO: render list %d\n", get_list_number(state))); + LOG_TGP(("VIDEO: render list %d\n", get_list_number())); memset(view->trans_mat, 0, sizeof(view->trans_mat)); view->trans_mat[0] = 1.0; @@ -1199,7 +1194,7 @@ static void tgp_render(running_machine &machine, bitmap_rgb32 &bitmap, const rec for(;;) { int type = (list[1]<<16)|list[0]; - state->m_glist=list; + m_glist=list; switch(type & 15) { case 0: list += 2; @@ -1213,11 +1208,11 @@ static void tgp_render(running_machine &machine, bitmap_rgb32 &bitmap, const rec // 6 = ?? draw object (57bd4, 387460, 2ad) if(1 || zz >= 666) - push_object(machine, readi(list+2), readi(list+4), readi(list+6)); + push_object(readi(list+2), readi(list+4), readi(list+6)); list += 8; break; case 2: - list = draw_direct(state, bitmap, cliprect, list+2); + list = draw_direct(bitmap, cliprect, list+2); break; case 3: LOG_TGP(("VIDEO: viewport (%d, %d, %d, %d, %d, %d, %d)\n", @@ -1225,7 +1220,7 @@ static void tgp_render(running_machine &machine, bitmap_rgb32 &bitmap, const rec readi16(list+4), readi16(list+6), readi16(list+8), readi16(list+10), readi16(list+12), readi16(list+14))); - draw_objects(state, bitmap, cliprect); + draw_objects(bitmap, cliprect); view->xc = readi16(list+4); view->yc = 383-(readi16(list+6)-39); @@ -1244,7 +1239,7 @@ static void tgp_render(running_machine &machine, bitmap_rgb32 &bitmap, const rec int i; LOG_TGP(("ZVIDEO: color write, adr=%x, len=%x\n", adr, len)); for(i=0; im_tgp_ram[adr-0x40000+i] = list[6+2*i]; + m_tgp_ram[adr-0x40000+i] = list[6+2*i]; list += 6+len*2; break; } @@ -1255,7 +1250,7 @@ static void tgp_render(running_machine &machine, bitmap_rgb32 &bitmap, const rec int i; for(i=0;im_poly_ram[adr-0x800000+i]=readi(list+2*i+6); + m_poly_ram[adr-0x800000+i]=readi(list+2*i+6); } list+=6+len*2; } @@ -1332,31 +1327,30 @@ static void tgp_render(running_machine &machine, bitmap_rgb32 &bitmap, const rec } } end: - draw_objects(state, bitmap, cliprect); + draw_objects(bitmap, cliprect); } } -static void tgp_scan(running_machine &machine) +void model1_state::tgp_scan() { - model1_state *state = machine.driver_data(); - struct view *view = state->m_view; + struct view *view = m_view; #if 0 - if (machine.input().code_pressed_once(KEYCODE_F)) + if (machine().input().code_pressed_once(KEYCODE_F)) { FILE *fp; fp=fopen("tgp-ram.bin", "w+b"); if (fp) { - fwrite(state->m_tgp_ram, (0x100000-0x40000)*2, 1, fp); + fwrite(m_tgp_ram, (0x100000-0x40000)*2, 1, fp); fclose(fp); } exit(0); } #endif - if(!state->m_render_done && (state->m_listctl[1] & 0x1f) == 0x1f) { - UINT16 *list = get_list(state); + if(!m_render_done && (m_listctl[1] & 0x1f) == 0x1f) { + UINT16 *list = get_list(); // Skip everything but the data uploads - LOG_TGP(("VIDEO: scan list %d\n", get_list_number(state))); + LOG_TGP(("VIDEO: scan list %d\n", get_list_number())); for(;;) { int type = (list[1]<<16)|list[0]; switch(type) { @@ -1378,7 +1372,7 @@ static void tgp_scan(running_machine &machine) int i; LOG_TGP(("ZVIDEO: scan color write, adr=%x, len=%x\n", adr, len)); for(i=0; im_tgp_ram[adr-0x40000+i] = list[6+2*i]; + m_tgp_ram[adr-0x40000+i] = list[6+2*i]; list += 6+len*2; break; } @@ -1389,7 +1383,7 @@ static void tgp_scan(running_machine &machine) int i; for(i=0;im_poly_ram[adr-0x800000+i]=readi(list+2*i+6); + m_poly_ram[adr-0x800000+i]=readi(list+2*i+6); } list+=6+len*2; } @@ -1440,7 +1434,7 @@ static void tgp_scan(running_machine &machine) end: ; } - state->m_render_done = 0; + m_render_done = 0; } VIDEO_START_MEMBER(model1_state,model1) @@ -1521,7 +1515,7 @@ UINT32 model1_state::screen_update_model1(screen_device &screen, bitmap_rgb32 &b tile->draw(screen, bitmap, cliprect, 2, 0, 0); tile->draw(screen, bitmap, cliprect, 0, 0, 0); - tgp_render(machine(), bitmap, cliprect); + tgp_render(bitmap, cliprect); tile->draw(screen, bitmap, cliprect, 7, 0, 0); tile->draw(screen, bitmap, cliprect, 5, 0, 0); @@ -1536,8 +1530,8 @@ void model1_state::screen_eof_model1(screen_device &screen, bool state) // on rising edge if (state) { - tgp_scan(machine()); - end_frame(machine()); + tgp_scan(); + end_frame(); LOG_TGP(("TGP: vsync\n")); } }