Previous 199869 Revisions Next

r32339 Wednesday 24th September, 2014 at 02:58:30 UTC by David Haywood
move some legacy code in preparation for refactoring (and hopefully fixing) it (nw)
[src/mame/drivers]legionna.c
[src/mame/machine]raiden2cop.c raiden2cop.h seicop.c seicop.h

trunk/src/mame/drivers/legionna.c
r32338r32339
9797   AM_RANGE(0x100412, 0x100413) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_sprite_dma_src_hi_w) // grainbow
9898   AM_RANGE(0x100414, 0x100415) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_sprite_dma_src_lo_w) // grainbow
9999
100//   AM_RANGE(0x10041c, 0x10041d) AM_WRITE(cop_angle_target_w) // angle target (for 0x6200 COP macro) // ADD ME
101//   AM_RANGE(0x10041e, 0x10041f) AM_WRITE(cop_angle_step_w)   // angle step   (for 0x6200 COP macro) // ADD ME
102   AM_RANGE(0x10041c, 0x10041d) AM_DEVWRITE("raiden2cop", raiden2cop_device, LEGACY_cop_angle_compare_w) // angle target (for 0x6200 COP macro) // REMOVE ME
103   AM_RANGE(0x10041e, 0x10041f) AM_DEVWRITE("raiden2cop", raiden2cop_device, LEGACY_cop_angle_mod_val_w)   // angle step   (for 0x6200 COP macro) // REMOVE ME
100104
101//   AM_RANGE(0x10041c, 0x10041d) AM_WRITE(cop_angle_target_w) // angle target (for 0x6200 COP macro)
102//   AM_RANGE(0x10041e, 0x10041f) AM_WRITE(cop_angle_step_w)   // angle step   (for 0x6200 COP macro)
103105   AM_RANGE(0x100420, 0x100421) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_itoa_low_w)
104106   AM_RANGE(0x100422, 0x100423) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_itoa_high_w)
105107   AM_RANGE(0x100424, 0x100425) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_itoa_digit_count_w)
106108   AM_RANGE(0x100428, 0x100429) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_dma_v1_w)
107109   AM_RANGE(0x10042a, 0x10042b) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_dma_v2_w)
108110   AM_RANGE(0x10042c, 0x10042d) AM_DEVREADWRITE("raiden2cop", raiden2cop_device, cop_prng_maxvalue_r, cop_prng_maxvalue_w)
111   
109112   AM_RANGE(0x100432, 0x100433) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_pgm_data_w)
110113   AM_RANGE(0x100434, 0x100435) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_pgm_addr_w)
111114//   AM_RANGE(0x100436, 0x100437) AM_WRITE(cop_hitbox_baseadr_w)
112115   AM_RANGE(0x100438, 0x100439) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_pgm_value_w)
113116   AM_RANGE(0x10043a, 0x10043b) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_pgm_mask_w)
114117   AM_RANGE(0x10043c, 0x10043d) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_pgm_trigger_w)
118   //AM_RANGE(0x10043e, 0x10043f) AM_DEVWRITE("raiden2cop", raiden2cop_device,)   /*   0 in all 68k based games,    0xffff in raiden2 / raidendx,    0x2000 in zeroteam / xsedae , it's always set up just before the 0x474 register */
119
115120   AM_RANGE(0x100444, 0x100445) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_scale_w)
121   AM_RANGE(0x100446, 0x100447) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_rom_addr_unk_w) // 68k
122   AM_RANGE(0x100448, 0x100449) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_rom_addr_lo_w) // 68k
123   AM_RANGE(0x10044a, 0x10044b) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_rom_addr_hi_w) // 68k
124   
116125   AM_RANGE(0x100450, 0x100451) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_sort_ram_addr_hi_w)
117126   AM_RANGE(0x100452, 0x100453) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_sort_ram_addr_lo_w)
118127   AM_RANGE(0x100454, 0x100455) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_sort_lookup_hi_w)
r32338r32339
120129   AM_RANGE(0x100458, 0x100459) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_sort_param_w)
121130   AM_RANGE(0x10045a, 0x10045b) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_pal_brightness_val_w) //palette DMA brightness val, used by X Se Dae / Zero Team
122131   AM_RANGE(0x10045c, 0x10045d) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_pal_brightness_mode_w)  //palette DMA brightness mode, used by X Se Dae / Zero Team (sets to 5)
132
123133//   AM_RANGE(0x100470, 0x100471) AM_READWRITE(cop_tile_bank_2_r,cop_tile_bank_2_w)
124
134//   AM_RANGE(0x100474, 0x100475) AM_DEVWRITE("raiden2cop", raiden2cop_device,) // this gets set to a pointer to spriteram (relative to start of ram) on all games excecpt raiden 2, where it isn't set
125135   AM_RANGE(0x100476, 0x100477) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_dma_adr_rel_w)
126136   AM_RANGE(0x100478, 0x100479) AM_DEVWRITE("raiden2cop", raiden2cop_device,cop_dma_src_w)
127137   AM_RANGE(0x10047a, 0x10047b) AM_DEVWRITE("raiden2cop", raiden2cop_device,cop_dma_size_w)
128138   AM_RANGE(0x10047c, 0x10047d) AM_DEVWRITE("raiden2cop", raiden2cop_device,cop_dma_dst_w)
129139   AM_RANGE(0x10047e, 0x10047f) AM_DEVREADWRITE("raiden2cop", raiden2cop_device, cop_dma_mode_r, cop_dma_mode_w)
140
141   AM_RANGE(0x10048c, 0x10048d) AM_DEVWRITE("raiden2cop", raiden2cop_device,cop_sprite_dma_abs_y_w) // 68k
142   AM_RANGE(0x10048e, 0x10048f) AM_DEVWRITE("raiden2cop", raiden2cop_device,cop_sprite_dma_abs_x_w) // 68k
143
130144   AM_RANGE(0x1004a0, 0x1004ad) AM_DEVREADWRITE("raiden2cop", raiden2cop_device, cop_reg_high_r, cop_reg_high_w)
131145   AM_RANGE(0x1004c0, 0x1004cd) AM_DEVREADWRITE("raiden2cop", raiden2cop_device, cop_reg_low_r, cop_reg_low_w)
132//   AM_RANGE(0x100500, 0x100505) AM_WRITE(cop_cmd_w)
146
147//   AM_RANGE(0x100500, 0x100505) AM_WRITE(cop_cmd_w) // ADD ME
148   AM_RANGE(0x100500, 0x100505) AM_DEVWRITE("raiden2cop", raiden2cop_device,LEGACY_cop_cmd_w) // REMOVE ME
149
133150   AM_RANGE(0x100580, 0x100581) AM_DEVREAD("raiden2cop", raiden2cop_device, cop_collision_status_r)
134//   AM_RANGE(0x100582, 0x100587) AM_READ(cop_collision_status_val_r)
151//   AM_RANGE(0x100582, 0x100587) AM_READ(cop_collision_status_val_r) // ADD ME
152   AM_RANGE(0x100582, 0x100587) AM_DEVREAD("raiden2cop", raiden2cop_device, LEGACY_cop_collision_status_val_r) // REMOVE ME
153
154
135155   AM_RANGE(0x100588, 0x100589) AM_DEVREAD("raiden2cop", raiden2cop_device, cop_collision_status_stat_r)
136156   AM_RANGE(0x100590, 0x100599) AM_DEVREAD("raiden2cop", raiden2cop_device, cop_itoa_digits_r)
137157
r32338r32339
156176   AM_RANGE(0x100744, 0x100745) AM_READ_PORT("PLAYERS12")
157177   AM_RANGE(0x100748, 0x100749) AM_READ_PORT("PLAYERS34")
158178   AM_RANGE(0x10074c, 0x10074d) AM_READ_PORT("SYSTEM")
159   AM_RANGE(0x100400, 0x1007ff) AM_DEVREADWRITE("seibucop", seibu_cop_legacy_device, generic_cop_r, generic_cop_w) AM_SHARE("cop_mcu_ram")    /* COP mcu */
160179   AM_RANGE(0x101000, 0x1017ff) AM_RAM // _WRITE(legionna_background_w) AM_SHARE("back_data")
161180   AM_RANGE(0x101800, 0x101fff) AM_RAM // _WRITE(legionna_foreground_w) AM_SHARE("fore_data")
162181   AM_RANGE(0x102000, 0x1027ff) AM_RAM // _WRITE(legionna_midground_w) AM_SHARE("mid_data")
r32338r32339
179198   AM_RANGE(0x100748, 0x100749) AM_READ_PORT("PLAYERS34")
180199   AM_RANGE(0x10074c, 0x10074d) AM_READ_PORT("SYSTEM")
181200   AM_RANGE(0x1007c0, 0x1007df) AM_READWRITE(sound_comms_r,sound_comms_w)
182   AM_RANGE(0x100400, 0x1007ff) AM_DEVREADWRITE("seibucop", seibu_cop_legacy_device, generic_cop_r, generic_cop_w) AM_SHARE("cop_mcu_ram")  /* COP mcu */
183201   AM_RANGE(0x100800, 0x100fff) AM_RAM // _WRITE(legionna_background_w) AM_SHARE("back_data")
184202   AM_RANGE(0x101000, 0x1017ff) AM_RAM // _WRITE(legionna_foreground_w) AM_SHARE("fore_data")
185203   AM_RANGE(0x101800, 0x101fff) AM_RAM // _WRITE(legionna_midground_w) AM_SHARE("mid_data")
r32338r32339
200218   AM_RANGE(0x100744, 0x100745) AM_READ_PORT("PLAYERS12")
201219   AM_RANGE(0x100748, 0x100749) AM_READ_PORT("PLAYERS34")
202220   AM_RANGE(0x10074c, 0x10074d) AM_READ_PORT("SYSTEM")
203   AM_RANGE(0x100400, 0x1007ff) AM_DEVREADWRITE("seibucop", seibu_cop_legacy_device, generic_cop_r, generic_cop_w) AM_SHARE("cop_mcu_ram")    /* COP mcu */
204221   AM_RANGE(0x100800, 0x100fff) AM_RAM
205222   AM_RANGE(0x101000, 0x1017ff) AM_RAM // _WRITE(legionna_background_w) AM_SHARE("back_data")
206223   AM_RANGE(0x101800, 0x101fff) AM_RAM // _WRITE(legionna_foreground_w) AM_SHARE("fore_data")
r32338r32339
236253   AM_RANGE(0x100748, 0x100749) AM_READ_PORT("PLAYERS34")
237254   AM_RANGE(0x10074c, 0x10074d) AM_READ_PORT("SYSTEM")
238255   AM_RANGE(0x10075c, 0x10075d) AM_READ_PORT("DSW2")
239   AM_RANGE(0x100400, 0x1007ff) AM_DEVREADWRITE("seibucop", seibu_cop_legacy_device, generic_cop_r, generic_cop_w) AM_SHARE("cop_mcu_ram")    /* COP mcu */
240256   AM_RANGE(0x100800, 0x100fff) AM_RAM
241257   AM_RANGE(0x101000, 0x1017ff) AM_RAM // _WRITE(legionna_background_w) AM_SHARE("back_data")
242258   AM_RANGE(0x101800, 0x101fff) AM_RAM // _WRITE(legionna_foreground_w) AM_SHARE("fore_data")
r32338r32339
261277   AM_RANGE(0x100748, 0x100749) AM_READ_PORT("PLAYERS34")
262278   AM_RANGE(0x10074c, 0x10074d) AM_READ_PORT("SYSTEM")
263279   AM_RANGE(0x10075c, 0x10075d) AM_READ_PORT("DSW2")
264   AM_RANGE(0x100400, 0x1007ff) AM_DEVREADWRITE("seibucop", seibu_cop_legacy_device, generic_cop_r, generic_cop_w) AM_SHARE("cop_mcu_ram")    /* COP mcu */
265280   AM_RANGE(0x100800, 0x100fff) AM_RAM // _WRITE(legionna_background_w) AM_SHARE("back_data")
266281   AM_RANGE(0x101000, 0x1017ff) AM_RAM // _WRITE(legionna_foreground_w) AM_SHARE("fore_data")
267282   AM_RANGE(0x101800, 0x101fff) AM_RAM // _WRITE(legionna_midground_w) AM_SHARE("mid_data")
r32338r32339
285300   AM_RANGE(0x100748, 0x100749) AM_READ_PORT("PLAYERS34")
286301   AM_RANGE(0x10074c, 0x10074d) AM_READ_PORT("SYSTEM")
287302   AM_RANGE(0x10075c, 0x10075d) AM_READ_PORT("DSW2")
288   AM_RANGE(0x100400, 0x1007ff) AM_DEVREADWRITE("seibucop", seibu_cop_legacy_device, generic_cop_r,generic_cop_w) AM_SHARE("cop_mcu_ram")
289303   AM_RANGE(0x100800, 0x100fff) AM_RAM // _WRITE(legionna_background_w) AM_SHARE("back_data")
290304   AM_RANGE(0x101000, 0x1017ff) AM_RAM // _WRITE(legionna_foreground_w) AM_SHARE("fore_data")
291305   AM_RANGE(0x101800, 0x101fff) AM_RAM // _WRITE(legionna_midground_w) AM_SHARE("mid_data")
r32338r32339
313327   AM_RANGE(0x10070c, 0x10070d) AM_READ_PORT("SYSTEM")
314328   AM_RANGE(0x10071c, 0x10071d) AM_READ_PORT("DSW2")
315329   AM_RANGE(0x100740, 0x10075f) AM_READWRITE(sound_comms_r,sound_comms_w)
316   AM_RANGE(0x100400, 0x1007ff) AM_DEVREADWRITE("seibucop", seibu_cop_legacy_device, generic_cop_r,generic_cop_w) AM_SHARE("cop_mcu_ram")
317330   AM_RANGE(0x100800, 0x100fff) AM_RAM // _WRITE(legionna_background_w) AM_SHARE("back_data")
318331   AM_RANGE(0x101000, 0x1017ff) AM_RAM // _WRITE(legionna_foreground_w) AM_SHARE("fore_data")
319332   AM_RANGE(0x101800, 0x101fff) AM_RAM // _WRITE(legionna_midground_w) AM_SHARE("mid_data")
r32338r32339
339352   AM_RANGE(0x100704, 0x100705) AM_READ_PORT("PLAYERS12")
340353   AM_RANGE(0x100708, 0x100709) AM_READ_PORT("PLAYERS34")
341354   AM_RANGE(0x10070c, 0x10070d) AM_READ_PORT("SYSTEM")
342   AM_RANGE(0x100000, 0x1007ff) AM_DEVREADWRITE("seibucop", seibu_cop_legacy_device, copdxbl_0_r,copdxbl_0_w) AM_SHARE("cop_mcu_ram")
355   AM_RANGE(0x100000, 0x1007ff) AM_DEVREADWRITE("seibucop_boot", seibu_cop_bootleg_device, copdxbl_0_r,copdxbl_0_w) AM_SHARE("cop_mcu_ram")
343356   AM_RANGE(0x100800, 0x100fff) AM_RAM // _WRITE(legionna_background_w) AM_SHARE("back_data")
344357   AM_RANGE(0x101000, 0x1017ff) AM_RAM // _WRITE(legionna_foreground_w) AM_SHARE("fore_data")
345358   AM_RANGE(0x101800, 0x101fff) AM_RAM // _WRITE(legionna_midground_w) AM_SHARE("mid_data")
r32338r32339
11991212
12001213   SEIBU_SOUND_SYSTEM_CPU(14318180/4)
12011214
1202   MCFG_SEIBU_COP_ADD("seibucop")
12031215   MCFG_RAIDEN2COP_ADD("raiden2cop")
12041216   MCFG_RAIDEN2COP_VIDEORAM_OUT_CB(WRITE16(legionna_state, videowrite_cb_w))
12051217
r32338r32339
12361248
12371249   SEIBU_SOUND_SYSTEM_CPU(14318180/4)
12381250
1239   MCFG_SEIBU_COP_ADD("seibucop")
12401251   MCFG_RAIDEN2COP_ADD("raiden2cop")
12411252   MCFG_RAIDEN2COP_VIDEORAM_OUT_CB(WRITE16(legionna_state, videowrite_cb_w))
12421253
r32338r32339
12741285
12751286   SEIBU2_SOUND_SYSTEM_CPU(14318180/4)
12761287
1277   MCFG_SEIBU_COP_ADD("seibucop")
12781288   MCFG_RAIDEN2COP_ADD("raiden2cop")
12791289   MCFG_RAIDEN2COP_VIDEORAM_OUT_CB(WRITE16(legionna_state, videowrite_cb_w))
12801290
r32338r32339
13131323
13141324   SEIBU2_SOUND_SYSTEM_CPU(14318180/4)
13151325
1316   MCFG_SEIBU_COP_ADD("seibucop")
13171326   MCFG_RAIDEN2COP_ADD("raiden2cop")
13181327   MCFG_RAIDEN2COP_VIDEORAM_OUT_CB(WRITE16(legionna_state, videowrite_cb_w))
13191328
r32338r32339
13511360
13521361   SEIBU2_SOUND_SYSTEM_CPU(14318180/4)
13531362
1354   MCFG_SEIBU_COP_ADD("seibucop")
13551363   MCFG_RAIDEN2COP_ADD("raiden2cop")
13561364   MCFG_RAIDEN2COP_VIDEORAM_OUT_CB(WRITE16(legionna_state, videowrite_cb_w))
13571365
r32338r32339
13901398
13911399   SEIBU_SOUND_SYSTEM_CPU(14318180/4)
13921400
1393   MCFG_SEIBU_COP_ADD("seibucop")
13941401   MCFG_RAIDEN2COP_ADD("raiden2cop")
13951402   MCFG_RAIDEN2COP_VIDEORAM_OUT_CB(WRITE16(legionna_state, videowrite_cb_w))
13961403
r32338r32339
14311438   MCFG_CPU_PROGRAM_MAP(cupsocbl_mem)
14321439   MCFG_CPU_VBLANK_INT_DRIVER("screen", legionna_state,  irq4_line_hold) /* VBL */
14331440
1434   MCFG_SEIBU_COP_ADD("seibucop")
1441   MCFG_SEIBU_COP_ADD("seibucop_boot")
14351442   MCFG_RAIDEN2COP_ADD("raiden2cop")
14361443   MCFG_RAIDEN2COP_VIDEORAM_OUT_CB(WRITE16(legionna_state, videowrite_cb_w))
14371444
trunk/src/mame/machine/raiden2cop.c
r32338r32339
33 Seibu Cop (Co-Processor) emulation
44  (new implementation, based on Raiden 2 code)
55
6  (should write new notes to replace those that were in seicop.c)
7
68***************************************************************************/
79
810#include "emu.h"
r32338r32339
4749   m_cop_sprite_dma_src(0),
4850   m_cop_sprite_dma_size(0),
4951
52   m_cop_rom_addr_lo(0),
53   m_cop_rom_addr_hi(0),
54   m_cop_rom_addr_unk(0),
5055
56   m_cop_sprite_dma_abs_x(0),
57   m_cop_sprite_dma_abs_y(0),
58
59   m_LEGACY_cop_angle_compare(0),
60   m_LEGACY_cop_angle_mod_val(0),
61   m_LEGACY_cop_hit_val_x(0),
62   m_LEGACY_cop_hit_val_y(0),
63   m_LEGACY_m_cop_hit_val_z(0),
64   m_LEGACY_r0(0),
65   m_LEGACY_r1(0),
66
5167   m_videoramout_cb(*this),
5268   m_palette(*this, ":palette")
5369{
r32338r32339
139155   save_item(NAME(m_cop_sprite_dma_size));
140156   save_item(NAME(m_cop_sprite_dma_src));
141157
158   save_item(NAME(m_cop_rom_addr_lo));
159   save_item(NAME(m_cop_rom_addr_hi));
160   save_item(NAME(m_cop_rom_addr_unk));
142161
162   save_item(NAME(m_cop_sprite_dma_abs_x));
163   save_item(NAME(m_cop_sprite_dma_abs_y));
164
165   // legacy
166   save_item(NAME(m_LEGACY_cop_angle_compare));
167   save_item(NAME(m_LEGACY_cop_angle_mod_val));
168   save_item(NAME(m_LEGACY_cop_hit_val_x));
169   save_item(NAME(m_LEGACY_cop_hit_val_y));
170   save_item(NAME(m_LEGACY_m_cop_hit_val_z));
171   save_item(NAME(m_LEGACY_r0));
172   save_item(NAME(m_LEGACY_r1));
173
143174   m_videoramout_cb.resolve_safe();
144175
145176   cop_itoa_digit_count = 4; //TODO: Raiden 2 never inits the BCD register, value here is a guess (8 digits, as WR is 10.000.000 + a)
r32338r32339
11391170         cop_status |= 2;
11401171   }
11411172}
1173
1174// more misc
1175
1176WRITE16_MEMBER( raiden2cop_device::cop_rom_addr_unk_w)
1177{
1178   COMBINE_DATA(&m_cop_rom_addr_unk);
1179}
1180
1181WRITE16_MEMBER( raiden2cop_device::cop_rom_addr_lo_w)
1182{
1183   COMBINE_DATA(&m_cop_rom_addr_lo);
1184}
1185
1186WRITE16_MEMBER( raiden2cop_device::cop_rom_addr_hi_w)
1187{
1188   COMBINE_DATA(&m_cop_rom_addr_hi);
1189}
1190
1191WRITE16_MEMBER(raiden2cop_device::cop_sprite_dma_abs_y_w)
1192{
1193   m_cop_sprite_dma_abs_y = data;
1194}
1195
1196WRITE16_MEMBER(raiden2cop_device::cop_sprite_dma_abs_x_w)
1197{
1198   m_cop_sprite_dma_abs_x = data;
1199}
1200
1201/*------------------------------------------------------------------------------------------------------------------------------------------------*/
1202/* LEGACY CODE -----------------------------------------------------------------------------------------------------------------------------------*/
1203/* this is all old code that hasn't been refactored yet, it will go away                                                                          */
1204/*------------------------------------------------------------------------------------------------------------------------------------------------*/
1205/*------------------------------------------------------------------------------------------------------------------------------------------------*/
1206/*------------------------------------------------------------------------------------------------------------------------------------------------*/
1207
1208
1209WRITE16_MEMBER(raiden2cop_device::LEGACY_cop_angle_compare_w)
1210{
1211   m_LEGACY_cop_angle_compare = UINT16(data);
1212}
1213
1214WRITE16_MEMBER(raiden2cop_device::LEGACY_cop_angle_mod_val_w)
1215{
1216   m_LEGACY_cop_angle_mod_val = UINT16(data);
1217}
1218
1219READ16_MEMBER( raiden2cop_device::LEGACY_cop_collision_status_val_r)
1220{
1221   /* these two controls facing direction in Godzilla opponents (only vs.) - x value compare? */
1222   if (offset==0) return (m_LEGACY_cop_hit_val_y);
1223   else if (offset==1) return (m_LEGACY_cop_hit_val_x);
1224   else return (m_LEGACY_m_cop_hit_val_z);
1225}
1226
1227
1228/*
1229Godzilla 0x12c0 X = 0x21ed Y = 0x57da
1230Megaron  0x12d0 X = 0x1ef1 Y = 0x55db
1231King Ghidorah 0x12c8 X = 0x26eb Y = 0x55dc
1232Mecha Ghidorah 0x12dc X = 0x24ec Y = 0x55dc
1233Mecha Godzilla 0x12d4 X = 0x1cf1 Y = 0x52dc
1234Gigan 0x12cc X = 0x23e8 Y = 0x55db
1235
1236(DC.W $1020, $F0C0, $0000, $0000)
1237X = collides at the same spot
1238Y = collides between 0xd0 and 0x20
12390x588 bits 2 & 3 = 0
1240(DC.W $F0C0, $1020, $0000, $0000)
1241X = collides between 0xb0 and 0x50 (inclusive)
1242Y = collides between 0xd0 and 0x30 (not inclusive)
12430x588 bits 2 & 3 = 0x580 bits 0 & 1
1244*/
1245void raiden2cop_device::LEGACY_cop_take_hit_box_params(UINT8 offs)
1246{
1247   INT16 start_x,start_y,height,width;
1248
1249   {
1250      height = UINT8(m_LEGACY_cop_collision_info[offs].hitbox_y >> 8);
1251      start_y = INT8(m_LEGACY_cop_collision_info[offs].hitbox_y);
1252      width = UINT8(m_LEGACY_cop_collision_info[offs].hitbox_x >> 8);
1253      start_x = INT8(m_LEGACY_cop_collision_info[offs].hitbox_x);
1254   }
1255
1256   m_LEGACY_cop_collision_info[offs].min_x = (m_LEGACY_cop_collision_info[offs].x >> 16) + start_x;
1257   m_LEGACY_cop_collision_info[offs].max_x = m_LEGACY_cop_collision_info[offs].min_x + width;
1258   m_LEGACY_cop_collision_info[offs].min_y = (m_LEGACY_cop_collision_info[offs].y >> 16) + start_y;
1259   m_LEGACY_cop_collision_info[offs].max_y = m_LEGACY_cop_collision_info[offs].min_y + height;
1260}
1261
1262
1263UINT8 raiden2cop_device::LEGACY_cop_calculate_collsion_detection()
1264{
1265   static UINT8 res;
1266
1267   res = 3;
1268
1269   /* outbound X check */
1270   if(m_LEGACY_cop_collision_info[0].max_x >= m_LEGACY_cop_collision_info[1].min_x && m_LEGACY_cop_collision_info[0].min_x <= m_LEGACY_cop_collision_info[1].max_x)
1271      res &= ~2;
1272
1273   if(m_LEGACY_cop_collision_info[1].max_x >= m_LEGACY_cop_collision_info[0].min_x && m_LEGACY_cop_collision_info[1].min_x <= m_LEGACY_cop_collision_info[0].max_x)
1274      res &= ~2;
1275
1276   /* outbound Y check */
1277   if(m_LEGACY_cop_collision_info[0].max_y >= m_LEGACY_cop_collision_info[1].min_y && m_LEGACY_cop_collision_info[0].min_y <= m_LEGACY_cop_collision_info[1].max_y)
1278      res &= ~1;
1279
1280   if(m_LEGACY_cop_collision_info[1].max_y >= m_LEGACY_cop_collision_info[0].min_y && m_LEGACY_cop_collision_info[1].min_y <= m_LEGACY_cop_collision_info[0].max_y)
1281      res &= ~1;
1282
1283   m_LEGACY_cop_hit_val_x = (m_LEGACY_cop_collision_info[0].x - m_LEGACY_cop_collision_info[1].x) >> 16;
1284   m_LEGACY_cop_hit_val_y = (m_LEGACY_cop_collision_info[0].y - m_LEGACY_cop_collision_info[1].y) >> 16;
1285   m_LEGACY_m_cop_hit_val_z = 1;
1286   cop_hit_val_stat = res; // TODO: there's also bit 2 and 3 triggered in the tests, no known meaning
1287
1288   //popmessage("%d %d %04x %04x %04x %04x",m_LEGACY_cop_hit_val_x,m_LEGACY_cop_hit_val_y,m_LEGACY_cop_collision_info[0].hitbox_x,m_LEGACY_cop_collision_info[0].hitbox_y,m_LEGACY_cop_collision_info[1].hitbox_x,m_LEGACY_cop_collision_info[1].hitbox_y);
1289
1290   //if(res == 0)
1291   //popmessage("0:%08x %08x %08x 1:%08x %08x %08x\n",m_LEGACY_cop_collision_info[0].x,m_LEGACY_cop_collision_info[0].y,m_LEGACY_cop_collision_info[0].hitbox,m_LEGACY_cop_collision_info[1].x,m_LEGACY_cop_collision_info[1].y,m_LEGACY_cop_collision_info[1].hitbox);
1292//  popmessage("0:%08x %08x %08x %08x 1:%08x %08x %08x %08x\n",m_LEGACY_cop_collision_info[0].min_x,m_LEGACY_cop_collision_info[0].max_x,m_LEGACY_cop_collision_info[0].min_y, m_LEGACY_cop_collision_info[0].max_y,
1293//                                                   m_LEGACY_cop_collision_info[1].min_x,m_LEGACY_cop_collision_info[1].max_x,m_LEGACY_cop_collision_info[1].min_y, m_LEGACY_cop_collision_info[1].max_y);
1294
1295   return res;
1296}
1297
1298
1299WRITE16_MEMBER(raiden2cop_device::LEGACY_cop_cmd_w)
1300{
1301   int command;
1302
1303
1304   logerror("%06x: COPX execute table macro command %04x | regs %08x %08x %08x %08x %08x\n", space.device().safe_pc(), data,  cop_regs[0], cop_regs[1], cop_regs[2], cop_regs[3], cop_regs[4]);
1305
1306
1307   command = find_trigger_match(data, 0xff00);
1308
1309
1310   if (command == -1)
1311   {
1312      return;
1313   }
1314   UINT16 funcval, funcmask;
1315   // this is pointless.. all we use it for is comparing against the same value
1316   funcval = get_func_value(command);
1317   funcmask = get_func_mask(command);
1318   //printf("%04x %04x %04x\n",m_cop_mcu_ram[offset],funcval,funcmask);
1319
1320   /*
1321   Macro notes:
1322   - endianess changes from/to Raiden 2:
1323   dword ^= 0
1324   word ^= 2
1325   byte ^= 3
1326   - some macro commands here have a commented algorithm, it's how Seibu Cup Bootleg version handles maths inside the 14/15 roms.
1327   The ROMs map tables in the following arrangement:
1328   0x00000 - 0x1ffff Sine math results
1329   0x20000 - 0x3ffff Cosine math results
1330   0x40000 - 0x7ffff Division math results
1331   0x80000 - 0xfffff Pythagorean theorem, hypotenuse length math results
1332   Surprisingly atan maths are nowhere to be found from the roms.
1333   */
1334
1335   int executed = 0;
1336
1337   /* "automatic" movement, 0205 */
1338   if (check_command_matches(command, 0x188, 0x282, 0x082, 0xb8e, 0x98e, 0x000, 0x000, 0x000, 6, 0xffeb))
1339   {
1340      executed = 1;
1341      UINT8 offs;
1342
1343      offs = (offset & 3) * 4;
1344      int ppos = space.read_dword(cop_regs[0] + 4 + offs);
1345      int npos = ppos + space.read_dword(cop_regs[0] + 0x10 + offs);
1346      int delta = (npos >> 16) - (ppos >> 16);
1347
1348      space.write_dword(cop_regs[0] + 4 + offs, npos);
1349      space.write_word(cop_regs[0] + 0x1c + offs, space.read_word(cop_regs[0] + 0x1c + offs) + delta);
1350      return;
1351   }
1352
1353   /* "automatic" movement, for arcs in Legionnaire / Zero Team (expression adjustment) 0905 */
1354   if (check_command_matches(command, 0x194, 0x288, 0x088, 0x000, 0x000, 0x000, 0x000, 0x000, 6, 0xfbfb))
1355   {
1356      executed = 1;
1357      UINT8 offs;
1358
1359      offs = (offset & 3) * 4;
1360
1361      /* read 0x28 + offs */
1362      /* add 0x10 + offs */
1363      /* write 0x10 + offs */
1364
1365      space.write_dword(cop_regs[0] + 0x10 + offs, space.read_dword(cop_regs[0] + 0x10 + offs) + space.read_dword(cop_regs[0] + 0x28 + offs));
1366      return;
1367   }
1368
1369   /* SINE math - 0x8100 */
1370   /*
1371         00000-0ffff:
1372         amp = x/256
1373         ang = x & 255
1374         s = sin(ang*2*pi/256)
1375         val = trunc(s*amp)
1376         if(s<0)
1377         val--
1378         if(s == 192)
1379         val = -2*amp
1380         */
1381   if (check_command_matches(command, 0xb9a, 0xb88, 0x888, 0x000, 0x000, 0x000, 0x000, 0x000, 7, 0xfdfb))
1382   {
1383      executed = 1;
1384      int raw_angle = (space.read_word(cop_regs[0] + (0x34 ^ 2)) & 0xff);
1385      double angle = raw_angle * M_PI / 128;
1386      double amp = (65536 >> 5)*(space.read_word(cop_regs[0] + (0x36 ^ 2)) & 0xff);
1387      int res;
1388
1389      /* TODO: up direction, why? */
1390      if (raw_angle == 0xc0)
1391         amp *= 2;
1392
1393      res = int(amp*sin(angle)) << cop_scale;
1394
1395      space.write_dword(cop_regs[0] + 0x10, res);
1396      return;
1397   }
1398
1399   /* COSINE math - 0x8900 */
1400   /*
1401      10000-1ffff:
1402      amp = x/256
1403      ang = x & 255
1404      s = cos(ang*2*pi/256)
1405      val = trunc(s*amp)
1406      if(s<0)
1407      val--
1408      if(s == 128)
1409      val = -2*amp
1410      */
1411   if (check_command_matches(command, 0xb9a, 0xb8a, 0x88a, 0x000, 0x000, 0x000, 0x000, 0x000, 7, 0xfdfb))
1412   {
1413      executed = 1;
1414      int raw_angle = (space.read_word(cop_regs[0] + (0x34 ^ 2)) & 0xff);
1415      double angle = raw_angle * M_PI / 128;
1416      double amp = (65536 >> 5)*(space.read_word(cop_regs[0] + (0x36 ^ 2)) & 0xff);
1417      int res;
1418
1419      /* TODO: left direction, why? */
1420      if (raw_angle == 0x80)
1421         amp *= 2;
1422
1423      res = int(amp*cos(angle)) << cop_scale;
1424
1425      space.write_dword(cop_regs[0] + 20, res);
1426      return;
1427   }
1428
1429   /* 0x130e / 0x138e */
1430   if (check_command_matches(command, 0x984, 0xaa4, 0xd82, 0xaa2, 0x39b, 0xb9a, 0xb9a, 0xa9a, 5, 0xbf7f))
1431   {
1432      executed = 1;
1433      int dy = space.read_dword(cop_regs[1] + 4) - space.read_dword(cop_regs[0] + 4);
1434      int dx = space.read_dword(cop_regs[1] + 8) - space.read_dword(cop_regs[0] + 8);
1435
1436      cop_status = 7;
1437      if (!dx) {
1438         cop_status |= 0x8000;
1439         cop_angle = 0;
1440      }
1441      else {
1442         cop_angle = atan(double(dy) / double(dx)) * 128.0 / M_PI;
1443         if (dx < 0)
1444            cop_angle += 0x80;
1445      }
1446
1447      m_LEGACY_r0 = dy;
1448      m_LEGACY_r1 = dx;
1449
1450      //printf("%d %d %f %04x\n",dx,dy,atan(double(dy)/double(dx)) * 128 / M_PI,cop_angle);
1451
1452      if (data & 0x80)
1453         space.write_word(cop_regs[0] + (0x34 ^ 2), cop_angle);
1454      return;
1455   }
1456
1457   /* Pythagorean theorem, hypotenuse direction - 130e / 138e */
1458   //(heatbrl)  | 5 | bf7f | 138e | 984 aa4 d82 aa2 39b b9a b9a b9a
1459   if (check_command_matches(command, 0x984, 0xaa4, 0xd82, 0xaa2, 0x39b, 0xb9a, 0xb9a, 0xb9a, 5, 0xbf7f))
1460   {
1461      executed = 1;
1462      int dy = space.read_dword(cop_regs[1] + 4) - space.read_dword(cop_regs[0] + 4);
1463      int dx = space.read_dword(cop_regs[1] + 8) - space.read_dword(cop_regs[0] + 8);
1464
1465      cop_status = 7;
1466      if (!dx) {
1467         cop_status |= 0x8000;
1468         cop_angle = 0;
1469      }
1470      else {
1471         cop_angle = atan(double(dy) / double(dx)) * 128.0 / M_PI;
1472         if (dx < 0)
1473            cop_angle += 0x80;
1474      }
1475
1476      cop_angle -= 0x80;
1477      m_LEGACY_r0 = dy;
1478      m_LEGACY_r1 = dx;
1479
1480      if (data & 0x80)
1481         space.write_word(cop_regs[0] + (0x34 ^ 2), cop_angle);
1482      return;
1483   }
1484
1485   /* Pythagorean theorem, hypotenuse length - 0x3bb0 */
1486   //(grainbow) | 4 | 007f | 3bb0 | f9c b9c b9c b9c b9c b9c b9c 99c
1487   /*
1488      40000-7ffff:
1489      v1 = (x / 32768)*64
1490      v2 = (x & 255)*32767/255
1491      val = sqrt(v1*v1+v2*v2) (unsigned)
1492      */
1493   if (check_command_matches(command, 0xf9c, 0xb9c, 0xb9c, 0xb9c, 0xb9c, 0xb9c, 0xb9c, 0x99c, 4, 0x007f))
1494   {
1495      executed = 1;
1496      int dy = m_LEGACY_r0;
1497      int dx = m_LEGACY_r1;
1498
1499      dx >>= 16;
1500      dy >>= 16;
1501      cop_dist = sqrt((double)(dx*dx + dy*dy));
1502
1503      if (data & 0x80)
1504         space.write_word(cop_regs[0] + (0x38), cop_dist);
1505      return;
1506   }
1507
1508   /* Division - 0x42c2 */
1509   /*
1510      20000-2ffff:
1511      v1 = x / 1024
1512      v2 = x & 1023
1513      val = !v1 ? 32767 : trunc(v2/v1+0.5)
1514      30000-3ffff:
1515      v1 = x / 1024
1516      v2 = (x & 1023)*32
1517      val = !v1 ? 32767 : trunc(v2/v1+0.5)
1518      */
1519   if (check_command_matches(command, 0xf9a, 0xb9a, 0xb9c, 0xb9c, 0xb9c, 0x29c, 0x000, 0x000, 5, 0xfcdd))
1520   {
1521      executed = 1;
1522      int dy = m_LEGACY_r0;
1523      int dx = m_LEGACY_r1;
1524      int div = space.read_word(cop_regs[0] + (0x36 ^ 2));
1525      int res;
1526      int cop_dist_raw;
1527
1528      if (!div)
1529      {
1530         printf("divide by zero?\n");
1531         div = 1;
1532      }
1533
1534      /* TODO: calculation of this one should occur at 0x3b30/0x3bb0 I *think* */
1535      /* TODO: recheck if cop_scale still masks at 3 with this command */
1536      dx >>= 11 + cop_scale;
1537      dy >>= 11 + cop_scale;
1538      cop_dist_raw = sqrt((double)(dx*dx + dy*dy));
1539
1540      res = cop_dist_raw;
1541      res /= div;
1542
1543      cop_dist = (1 << (5 - cop_scale)) / div;
1544
1545      /* TODO: bits 5-6-15 */
1546      cop_status = 7;
1547
1548      space.write_word(cop_regs[0] + (0x38 ^ 2), res);
1549      return;
1550   }
1551
1552   /*
1553      collision detection:
1554
1555      int dy_0 = space.read_dword(cop_regs[0]+4);
1556      int dx_0 = space.read_dword(cop_regs[0]+8);
1557      int dy_1 = space.read_dword(cop_regs[1]+4);
1558      int dx_1 = space.read_dword(cop_regs[1]+8);
1559      int hitbox_param1 = space.read_dword(cop_regs[2]);
1560      int hitbox_param2 = space.read_dword(cop_regs[3]);
1561
1562      TODO: we are ignoring the funcval / funcmask params for now
1563      */
1564
1565   if (check_command_matches(command, 0xb80, 0xb82, 0xb84, 0xb86, 0x000, 0x000, 0x000, 0x000, funcval, funcmask))
1566   {
1567      executed = 1;
1568      m_LEGACY_cop_collision_info[0].y = (space.read_dword(cop_regs[0] + 4));
1569      m_LEGACY_cop_collision_info[0].x = (space.read_dword(cop_regs[0] + 8));
1570      return;
1571   }
1572
1573   //(heatbrl)  | 9 | ffff | b080 | b40 bc0 bc2
1574   if (check_command_matches(command, 0xb40, 0xbc0, 0xbc2, 0x000, 0x000, 0x000, 0x000, 0x000, funcval, funcmask))
1575   {
1576      executed = 1;
1577      m_LEGACY_cop_collision_info[0].hitbox = space.read_word(cop_regs[2]);
1578      m_LEGACY_cop_collision_info[0].hitbox_y = space.read_word((cop_regs[2] & 0xffff0000) | (m_LEGACY_cop_collision_info[0].hitbox));
1579      m_LEGACY_cop_collision_info[0].hitbox_x = space.read_word(((cop_regs[2] & 0xffff0000) | (m_LEGACY_cop_collision_info[0].hitbox)) + 2);
1580
1581      /* do the math */
1582      LEGACY_cop_take_hit_box_params(0);
1583      cop_hit_status = LEGACY_cop_calculate_collsion_detection();
1584
1585      return;
1586   }
1587
1588   if (check_command_matches(command, 0xba0, 0xba2, 0xba4, 0xba6, 0x000, 0x000, 0x000, 0x000, funcval, funcmask))
1589   {
1590      executed = 1;
1591      m_LEGACY_cop_collision_info[1].y = (space.read_dword(cop_regs[1] + 4));
1592      m_LEGACY_cop_collision_info[1].x = (space.read_dword(cop_regs[1] + 8));
1593      return;
1594   }
1595
1596   //(heatbrl)  | 6 | ffff | b880 | b60 be0 be2
1597   if (check_command_matches(command, 0xb60, 0xbe0, 0xbe2, 0x000, 0x000, 0x000, 0x000, 0x000, funcval, funcmask))
1598   {
1599      executed = 1;
1600      m_LEGACY_cop_collision_info[1].hitbox = space.read_word(cop_regs[3]);
1601      m_LEGACY_cop_collision_info[1].hitbox_y = space.read_word((cop_regs[3] & 0xffff0000) | (m_LEGACY_cop_collision_info[1].hitbox));
1602      m_LEGACY_cop_collision_info[1].hitbox_x = space.read_word(((cop_regs[3] & 0xffff0000) | (m_LEGACY_cop_collision_info[1].hitbox)) + 2);
1603
1604      /* do the math */
1605      LEGACY_cop_take_hit_box_params(1);
1606      cop_hit_status = LEGACY_cop_calculate_collsion_detection();
1607      return;
1608   }
1609
1610   // grainbow 0d | a | fff3 | 6980 | b80 ba0
1611   if (check_command_matches(command, 0xb80, 0xba0, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 10, 0xfff3))
1612   {
1613      executed = 1;
1614      UINT8 offs;
1615      int abs_x, abs_y, rel_xy;
1616
1617      offs = (offset & 3) * 4;
1618
1619      /* TODO: I really suspect that following two are actually taken from the 0xa180 macro command then internally loaded */
1620      abs_x = space.read_word(cop_regs[0] + 8) - m_cop_sprite_dma_abs_x;
1621      abs_y = space.read_word(cop_regs[0] + 4) - m_cop_sprite_dma_abs_y;
1622      rel_xy = space.read_word(m_cop_sprite_dma_src + 4 + offs);
1623
1624      //if(rel_xy & 0x0706)
1625      //  printf("sprite rel_xy = %04x\n",rel_xy);
1626
1627      if (rel_xy & 1)
1628         space.write_word(cop_regs[4] + offs + 4, 0xc0 + abs_x - (rel_xy & 0xf8));
1629      else
1630         space.write_word(cop_regs[4] + offs + 4, (((rel_xy & 0x78) + (abs_x)-((rel_xy & 0x80) ? 0x80 : 0))));
1631
1632      space.write_word(cop_regs[4] + offs + 6, (((rel_xy & 0x7800) >> 8) + (abs_y)-((rel_xy & 0x8000) ? 0x80 : 0)));
1633      return;
1634   }
1635
1636   // grainbow 18 | a | ff00 | c480 | 080 882
1637   if (check_command_matches(command, 0x080, 0x882, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 10, 0xff00))
1638   {
1639      executed = 1;
1640      UINT8 offs;
1641
1642      offs = (offset & 3) * 4;
1643
1644      space.write_word(cop_regs[4] + offs + 0, space.read_word(m_cop_sprite_dma_src + offs) + (m_cop_sprite_dma_param & 0x3f));
1645      //space.write_word(cop_regs[4] + offs + 2,space.read_word(m_cop_sprite_dma_src+2 + offs));
1646      return;
1647   }
1648
1649   // cupsoc 1b | 5 | 7ff7 | dde5 | f80 aa2 984 0c2
1650   /* radar x/y positions */
1651   /* FIXME: x/ys are offsetted */
1652   /* FIXME: uses 0x10044a for something */
1653   if (check_command_matches(command, 0xf80, 0xaa2, 0x984, 0x0c2, 0x000, 0x000, 0x000, 0x000, 5, 0x7ff7))
1654   {
1655      executed = 1;
1656      UINT8 offs;
1657      int div;
1658      INT16 dir_offset;
1659      //              INT16 offs_val;
1660
1661      /* TODO: [4-7] could be mirrors of [0-3] (this is the only command so far that uses 4-7 actually)*/
1662      /* ? 0 + [4] */
1663      /* sub32 4 + [5] */
1664      /* write16h 8 + [4] */
1665      /* addmem16 4 + [6] */
1666
1667      // these two are obvious ...
1668      // 0xf x 16 = 240
1669      // 0x14 x 16 = 320
1670      // what are these two instead? scale factor? offsets? (edit: offsets to apply from the initial sprite data)
1671      // 0xfc69 ?
1672      // 0x7f4 ?
1673      //printf("%08x %08x %08x %08x %08x %08x %08x\n",cop_regs[0],cop_regs[1],cop_regs[2],cop_regs[3],cop_regs[4],cop_regs[5],cop_regs[6]);
1674
1675      offs = (offset & 3) * 4;
1676
1677      div = space.read_word(cop_regs[4] + offs);
1678      dir_offset = space.read_word(cop_regs[4] + offs + 8);
1679      //              offs_val = space.read_word(cop_regs[3] + offs);
1680      //420 / 180 = 500 : 400 = 30 / 50 = 98 / 18
1681
1682      /* TODO: this probably trips a cop status flag */
1683      if (div == 0) { div = 1; }
1684
1685
1686      space.write_word((cop_regs[6] + offs + 4), ((space.read_word(cop_regs[5] + offs + 4) + dir_offset) / div));
1687      return;
1688   }
1689
1690   //(cupsoc)   | 8 | f3e7 | 6200 | 3a0 3a6 380 aa0 2a6
1691   if (check_command_matches(command, 0x3a0, 0x3a6, 0x380, 0xaa0, 0x2a6, 0x000, 0x000, 0x000, 8, 0xf3e7))
1692   {
1693      executed = 1;
1694      UINT8 cur_angle;
1695      UINT16 flags;
1696
1697      /* 0 [1] */
1698      /* 0xc [1] */
1699      /* 0 [0] */
1700      /* 0 [1] */
1701      /* 0xc [1] */
1702
1703      cur_angle = space.read_byte(cop_regs[1] + (0xc ^ 3));
1704      flags = space.read_word(cop_regs[1]);
1705      //space.write_byte(cop_regs[1] + (0^3),space.read_byte(cop_regs[1] + (0^3)) & 0xfb); //correct?
1706
1707      m_LEGACY_cop_angle_compare &= 0xff;
1708      m_LEGACY_cop_angle_mod_val &= 0xff;
1709      flags &= ~0x0004;
1710
1711      int delta = cur_angle - m_LEGACY_cop_angle_compare;
1712      if (delta >= 128)
1713         delta -= 256;
1714      else if (delta < -128)
1715         delta += 256;
1716      if (delta < 0)
1717      {
1718         if (delta >= -m_LEGACY_cop_angle_mod_val)
1719         {
1720            cur_angle = m_LEGACY_cop_angle_compare;
1721            flags |= 0x0004;
1722         }
1723         else
1724            cur_angle += m_LEGACY_cop_angle_mod_val;
1725      }
1726      else
1727      {
1728         if (delta <= m_LEGACY_cop_angle_mod_val)
1729         {
1730            cur_angle = m_LEGACY_cop_angle_compare;
1731            flags |= 0x0004;
1732         }
1733         else
1734            cur_angle -= m_LEGACY_cop_angle_mod_val;
1735      }
1736
1737      space.write_byte(cop_regs[1] + (0 ^ 2), flags);
1738      space.write_byte(cop_regs[1] + (0xc ^ 3), cur_angle);
1739      return;
1740   }
1741
1742   //(grainbow) | 8 | f3e7 | 6200 | 380 39a 380 a80 29a
1743   /* search direction, used on SD Gundam homing weapon */
1744   /* FIXME: still doesn't work ... */
1745   if (check_command_matches(command, 0x380, 0x39a, 0x380, 0xa80, 0x29a, 0x000, 0x000, 0x000, 8, 0xf3e7))
1746   {
1747      executed = 1;
1748      UINT8 cur_angle;
1749      UINT16 flags;
1750
1751      cur_angle = space.read_byte(cop_regs[0] + (0x34 ^ 3));
1752      flags = space.read_word(cop_regs[0] + (0 ^ 2));
1753      //space.write_byte(cop_regs[1] + (0^3),space.read_byte(cop_regs[1] + (0^3)) & 0xfb); //correct?
1754
1755      m_LEGACY_cop_angle_compare &= 0xff;
1756      m_LEGACY_cop_angle_mod_val &= 0xff;
1757      flags &= ~0x0004;
1758
1759      int delta = cur_angle - m_LEGACY_cop_angle_compare;
1760      if (delta >= 128)
1761         delta -= 256;
1762      else if (delta < -128)
1763         delta += 256;
1764      if (delta < 0)
1765      {
1766         if (delta >= -m_LEGACY_cop_angle_mod_val)
1767         {
1768            cur_angle = m_LEGACY_cop_angle_compare;
1769            flags |= 0x0004;
1770         }
1771         else
1772            cur_angle += m_LEGACY_cop_angle_mod_val;
1773      }
1774      else
1775      {
1776         if (delta <= m_LEGACY_cop_angle_mod_val)
1777         {
1778            cur_angle = m_LEGACY_cop_angle_compare;
1779            flags |= 0x0004;
1780         }
1781         else
1782            cur_angle -= m_LEGACY_cop_angle_mod_val;
1783      }
1784
1785      space.write_byte(cop_regs[0] + (0 ^ 3), flags);
1786      space.write_word(cop_regs[0] + (0x34 ^ 3), cur_angle);
1787      return;
1788   }
1789
1790   //(cupsoc) 1c | 5 | b07f | e38e | 984 ac4 d82 ac2 39b b9a b9a a9a
1791   if (check_command_matches(command, 0x984, 0xac4, 0xd82, 0xac2, 0x39b, 0xb9a, 0xb9a, 0xa9a, 5, 0xb07f))
1792   {
1793      executed = 1;
1794      int dy = space.read_dword(cop_regs[2] + 4) - space.read_dword(cop_regs[0] + 4);
1795      int dx = space.read_dword(cop_regs[2] + 8) - space.read_dword(cop_regs[0] + 8);
1796
1797      cop_status = 7;
1798      if (!dx) {
1799         cop_status |= 0x8000;
1800         cop_angle = 0;
1801      }
1802      else {
1803         cop_angle = atan(double(dy) / double(dx)) * 128.0 / M_PI;
1804         if (dx < 0)
1805            cop_angle += 0x80;
1806      }
1807
1808      m_LEGACY_r0 = dy;
1809      m_LEGACY_r1 = dx;
1810
1811      //printf("%d %d %f %04x\n",dx,dy,atan(double(dy)/double(dx)) * 128 / M_PI,cop_angle);
1812
1813      if (data & 0x80)
1814         space.write_word(cop_regs[0] + (0x34 ^ 2), cop_angle);
1815      return;
1816   }
1817
1818   //(cupsoc) 1a | 5 | fffb | d104 | ac2 9e0 0a2
1819   /* controls player vs. player collision detection, 0xf105 controls player vs. ball */
1820   if (check_command_matches(command, 0xac2, 0x9e0, 0x0a2, 0x000, 0x000, 0x000, 0x000, 0x000, 5, 0xfffb))
1821   {
1822      executed = 1;
1823      UINT8 *ROM = space.machine().root_device().memregion("maincpu")->base();
1824      UINT32 rom_addr = (m_cop_rom_addr_hi << 16 | m_cop_rom_addr_lo) & ~1;
1825      UINT16 rom_data = (ROM[rom_addr + 0]) | (ROM[rom_addr + 1] << 8);
1826
1827      /* writes to some unemulated COP registers, then puts the result in here, adding a parameter taken from ROM */
1828      //space.write_word(cop_regs[0]+(0x44 + offset * 4), rom_data);
1829
1830      printf("%04x%04x %04x %04x\n", m_cop_rom_addr_hi, m_cop_rom_addr_lo, m_cop_rom_addr_unk, rom_data);
1831      return;
1832   }
1833
1834   if (executed == 0) printf("did not execute %04x\n", data);
1835}
1836
1837
1838
1839
trunk/src/mame/machine/raiden2cop.h
r32338r32339
166166   DECLARE_WRITE16_MEMBER(cop_sprite_dma_inc_w);
167167   int m_cop_sprite_dma_size;
168168
169   // misc 68k
170   UINT16 m_cop_rom_addr_lo,m_cop_rom_addr_hi,m_cop_rom_addr_unk;
171   DECLARE_WRITE16_MEMBER(cop_rom_addr_unk_w);
172   DECLARE_WRITE16_MEMBER(cop_rom_addr_lo_w);
173   DECLARE_WRITE16_MEMBER(cop_rom_addr_hi_w);
174
175   int m_cop_sprite_dma_abs_x,m_cop_sprite_dma_abs_y;
176   DECLARE_WRITE16_MEMBER(cop_sprite_dma_abs_y_w);
177   DECLARE_WRITE16_MEMBER(cop_sprite_dma_abs_x_w);
178
179   // legacy code, to be removed / refactored into above
180   INT8 m_LEGACY_cop_angle_compare;
181   INT8 m_LEGACY_cop_angle_mod_val;
182   DECLARE_WRITE16_MEMBER(LEGACY_cop_angle_compare_w);
183   DECLARE_WRITE16_MEMBER(LEGACY_cop_angle_mod_val_w);
184   INT16 m_LEGACY_cop_hit_val_x,m_LEGACY_cop_hit_val_y,m_LEGACY_m_cop_hit_val_z;
185   int m_LEGACY_r0, m_LEGACY_r1;
186   DECLARE_READ16_MEMBER(LEGACY_cop_collision_status_val_r);
187   DECLARE_WRITE16_MEMBER(LEGACY_cop_cmd_w);
188
189   struct LEGACY_collision_info
190   {
191      LEGACY_collision_info():
192      x(0),
193      y(0),
194      min_x(0),
195      min_y(0),
196      max_x(0),
197      max_y(0),
198      hitbox(0),
199      hitbox_x(0),
200      hitbox_y(0) {}
201
202      int x,y;
203      INT16 min_x,min_y,max_x,max_y;
204      UINT16 hitbox;
205      UINT16 hitbox_x,hitbox_y;
206   };
207
208   struct LEGACY_collision_info m_LEGACY_cop_collision_info[2];
209   void LEGACY_cop_take_hit_box_params(UINT8 offs);
210   UINT8 LEGACY_cop_calculate_collsion_detection();
211
212
169213protected:
170214   // device-level overrides
171215   virtual void device_start();
trunk/src/mame/machine/seicop.c
r32338r32339
11
2/* Seibu 'COP' (co-processor)  protection
2/*
3  OLD Seibu Cop simulation code.
34
4  there appear to be 3 revisions of this protection (based on the external rom)
5  this is currently only used by the Seibu Cup Soccer BOOTLEG
6 
7*/
58
6  COPX-D1 - Seibu Cup Soccer / Olympic Soccer '92
7          - Legionnaire
8  COPX-D2 - Heated Barrel
9          - Godzilla
10          - SD Gundam Sangokushi Rainbow Tairiku Senki
11          - Denjin Makai
12          - Raiden 2
13          - Raiden DX
14          - Zero Team
15  COPX-D3 - Raiden 2/DX New (V33 PCB version)
16          - New Zero Team
9/********************************************************************************************
1710
18  COPX / COPX-D2 based games appear to function in a similar way to each other
19  while the games using COPX-D3 appears to access the protection device very
20  differently to the others.
11  COPX bootleg simulation
12    - Seibu Cup Soccer (bootleg)
2113
22  As this is only the external rom it isn't confirmed that the actual protection
23  devices are identical even where the external rom matches.
14 *******************************************************************************************/
2415
25  Protection features include BCD math protection, 'command sequences', DMA.
26  memory clearing etc.
27
28  it is not confirmed which custom Seibu chip contains the actual co-processor,
29  nor if the co-processor is a real MCU with internal code, or a custom designed
30  'blitter' like device.
31
32  I suspect that for the earlier games it's part of the COP300 or COP1000 chips,
33  for the COPX-D3 based games it's probably inside the system controller SEI333
34
35  the external COP rom is probably used as a lookup for maths operations.
36
37  there should probably only be a single cop2_r / cop2_w function, the chip
38  looks to be configurable via the table uploaded to
39  0x432 / 0x434 / 0x438 / 0x43a / 0x43c, with 'macro' commands triggered via
40  writes to 0x500.
41
42  this simulation is incomplete
43
44  COP TODO list:
45  - collision detection, hitbox parameter is a complete mystery;
46  - collision detection, unknown usage of reads at 0x582-0x588;
47  - The RNG relies on the master CPU clock cycles, but without accurate waitstate support is
48    basically impossible to have a 1:1 matchup. Seibu Cup Soccer Selection for instance should show the
49    first match as Germany vs. USA at twilight, right now is Spain vs. Brazil at sunset.
50  - (MANY other things that needs to be listed here)
51
52  Protection information
53
54ALL games using COPX-D/D2 upload a series of command tables, using the following upload pattern.
55This happens ONCE at startup.
56
57Each table is 8 words long, and the table upload offsets aren't always in sequential order, as
58you can see from this example (cupsocs) it uploads in the following order
59
6000 - 07, 08 - 0f, 10 - 17, 18 - 1f, 28 - 2f, 60 - 67, 80 - 87, 88 - 8f
6190 - 97, 98 - 9f, 20 - 27, 30 - 37, 38 - 3f, 40 - 47, 48 - 4f, 68 - 6f
62c0 - c7, a0 - a7, a8 - af, b0 - b7, b8 - bf, c8 - cf, d0 - d7, d8 - df
63e0 - e7, e8 - ef, 50 - 57, 58 - 5f, 78 - 7f, f0 - f7
64
65table data is never overwritten, and in this case no data is uploaded
66in the 70-77 or f8 - ff region.
67
68It is assumed that the data written before each part of the table is associated
69with that table.
70
71000620:  write data 0205 at offset 003c <- 'trigger' associated with this table
72000624:  write data 0006 at offset 0038 <- 'unknown1 (4-bit)'
73000628:  write data ffeb at offset 003a <- 'unknown2'
74
75000632:  write data 0000 at offset 0034 <- 'table offset'
76000638:  write data 0188 at offset 0032 <- '12-bit data' for this offset
77000632:  write data 0001 at offset 0034
78000638:  write data 0282 at offset 0032
79000632:  write data 0002 at offset 0034
80000638:  write data 0082 at offset 0032
81000632:  write data 0003 at offset 0034
82000638:  write data 0b8e at offset 0032
83000632:  write data 0004 at offset 0034
84000638:  write data 098e at offset 0032
85000632:  write data 0005 at offset 0034
86000638:  write data 0000 at offset 0032
87000632:  write data 0006 at offset 0034
88000638:  write data 0000 at offset 0032
89000632:  write data 0007 at offset 0034
90000638:  write data 0000 at offset 0032
91--------------------------------------------
92000620:  write data 0905 at offset 003c
93000624:  write data 0006 at offset 0038
94000628:  write data fbfb at offset 003a
95
96000632:  write data 0008 at offset 0034
97000638:  write data 0194 at offset 0032
98000632:  write data 0009 at offset 0034
99000638:  write data 0288 at offset 0032
100000632:  write data 000a at offset 0034
101000638:  write data 0088 at offset 0032
102000632:  write data 000b at offset 0034
103000638:  write data 0000 at offset 0032
104000632:  write data 000c at offset 0034
105000638:  write data 0000 at offset 0032
106000632:  write data 000d at offset 0034
107000638:  write data 0000 at offset 0032
108000632:  write data 000e at offset 0034
109000638:  write data 0000 at offset 0032
110000632:  write data 000f at offset 0034
111000638:  write data 0000 at offset 0032
112--------------------------------------------
113000620:  write data 138e at offset 003c
114000624:  write data 0005 at offset 0038
115000628:  write data bf7f at offset 003a
116
117000632:  write data 0010 at offset 0034
118000638:  write data 0984 at offset 0032
119000632:  write data 0011 at offset 0034
120000638:  write data 0aa4 at offset 0032
121000632:  write data 0012 at offset 0034
122000638:  write data 0d82 at offset 0032
123000632:  write data 0013 at offset 0034
124000638:  write data 0aa2 at offset 0032
125000632:  write data 0014 at offset 0034
126000638:  write data 039b at offset 0032
127000632:  write data 0015 at offset 0034
128000638:  write data 0b9a at offset 0032
129000632:  write data 0016 at offset 0034
130000638:  write data 0b9a at offset 0032
131000632:  write data 0017 at offset 0034
132000638:  write data 0a9a at offset 0032
133--------------------------------------------
134000620:  write data 1905 at offset 003c
135000624:  write data 0006 at offset 0038
136000628:  write data fbfb at offset 003a
137
138000632:  write data 0018 at offset 0034
139000638:  write data 0994 at offset 0032
140000632:  write data 0019 at offset 0034
141000638:  write data 0a88 at offset 0032
142000632:  write data 001a at offset 0034
143000638:  write data 0088 at offset 0032
144000632:  write data 001b at offset 0034
145000638:  write data 0000 at offset 0032
146000632:  write data 001c at offset 0034
147000638:  write data 0000 at offset 0032
148000632:  write data 001d at offset 0034
149000638:  write data 0000 at offset 0032
150000632:  write data 001e at offset 0034
151000638:  write data 0000 at offset 0032
152000632:  write data 001f at offset 0034
153000638:  write data 0000 at offset 0032
154--------------------------------------------
155000620:  write data 2a05 at offset 003c
156000624:  write data 0006 at offset 0038
157000628:  write data ebeb at offset 003a
158
159000632:  write data 0028 at offset 0034
160000638:  write data 09af at offset 0032
161000632:  write data 0029 at offset 0034
162000638:  write data 0a82 at offset 0032
163000632:  write data 002a at offset 0034
164000638:  write data 0082 at offset 0032
165000632:  write data 002b at offset 0034
166000638:  write data 0a8f at offset 0032
167000632:  write data 002c at offset 0034
168000638:  write data 018e at offset 0032
169000632:  write data 002d at offset 0034
170000638:  write data 0000 at offset 0032
171000632:  write data 002e at offset 0034
172000638:  write data 0000 at offset 0032
173000632:  write data 002f at offset 0034
174000638:  write data 0000 at offset 0032
175--------------------------------------------
176000620:  write data 6200 at offset 003c
177000624:  write data 0008 at offset 0038
178000628:  write data f3e7 at offset 003a
179
180000632:  write data 0060 at offset 0034
181000638:  write data 03a0 at offset 0032
182000632:  write data 0061 at offset 0034
183000638:  write data 03a6 at offset 0032
184000632:  write data 0062 at offset 0034
185000638:  write data 0380 at offset 0032
186000632:  write data 0063 at offset 0034
187000638:  write data 0aa0 at offset 0032
188000632:  write data 0064 at offset 0034
189000638:  write data 02a6 at offset 0032
190000632:  write data 0065 at offset 0034
191000638:  write data 0000 at offset 0032
192000632:  write data 0066 at offset 0034
193000638:  write data 0000 at offset 0032
194000632:  write data 0067 at offset 0034
195000638:  write data 0000 at offset 0032
196--------------------------------------------
197000620:  write data 8100 at offset 003c
198000624:  write data 0007 at offset 0038
199000628:  write data fdfb at offset 003a
200
201000632:  write data 0080 at offset 0034
202000638:  write data 0b9a at offset 0032
203000632:  write data 0081 at offset 0034
204000638:  write data 0b88 at offset 0032
205000632:  write data 0082 at offset 0034
206000638:  write data 0888 at offset 0032
207000632:  write data 0083 at offset 0034
208000638:  write data 0000 at offset 0032
209000632:  write data 0084 at offset 0034
210000638:  write data 0000 at offset 0032
211000632:  write data 0085 at offset 0034
212000638:  write data 0000 at offset 0032
213000632:  write data 0086 at offset 0034
214000638:  write data 0000 at offset 0032
215000632:  write data 0087 at offset 0034
216000638:  write data 0000 at offset 0032
217--------------------------------------------
218000620:  write data 8900 at offset 003c
219000624:  write data 0007 at offset 0038
220000628:  write data fdfb at offset 003a
221
222000632:  write data 0088 at offset 0034
223000638:  write data 0b9a at offset 0032
224000632:  write data 0089 at offset 0034
225000638:  write data 0b8a at offset 0032
226000632:  write data 008a at offset 0034
227000638:  write data 088a at offset 0032
228000632:  write data 008b at offset 0034
229000638:  write data 0000 at offset 0032
230000632:  write data 008c at offset 0034
231000638:  write data 0000 at offset 0032
232000632:  write data 008d at offset 0034
233000638:  write data 0000 at offset 0032
234000632:  write data 008e at offset 0034
235000638:  write data 0000 at offset 0032
236000632:  write data 008f at offset 0034
237000638:  write data 0000 at offset 0032
238--------------------------------------------
239000620:  write data 9180 at offset 003c
240000624:  write data 0007 at offset 0038
241000628:  write data f8f7 at offset 003a
242
243000632:  write data 0090 at offset 0034
244000638:  write data 0b80 at offset 0032
245000632:  write data 0091 at offset 0034
246000638:  write data 0b94 at offset 0032
247000632:  write data 0092 at offset 0034
248000638:  write data 0b94 at offset 0032
249000632:  write data 0093 at offset 0034
250000638:  write data 0894 at offset 0032
251000632:  write data 0094 at offset 0034
252000638:  write data 0000 at offset 0032
253000632:  write data 0095 at offset 0034
254000638:  write data 0000 at offset 0032
255000632:  write data 0096 at offset 0034
256000638:  write data 0000 at offset 0032
257000632:  write data 0097 at offset 0034
258000638:  write data 0000 at offset 0032
259--------------------------------------------
260000620:  write data 9980 at offset 003c
261000624:  write data 0007 at offset 0038
262000628:  write data f8f7 at offset 003a
263
264000632:  write data 0098 at offset 0034
265000638:  write data 0b80 at offset 0032
266000632:  write data 0099 at offset 0034
267000638:  write data 0b94 at offset 0032
268000632:  write data 009a at offset 0034
269000638:  write data 0b94 at offset 0032
270000632:  write data 009b at offset 0034
271000638:  write data 0896 at offset 0032
272000632:  write data 009c at offset 0034
273000638:  write data 0000 at offset 0032
274000632:  write data 009d at offset 0034
275000638:  write data 0000 at offset 0032
276000632:  write data 009e at offset 0034
277000638:  write data 0000 at offset 0032
278000632:  write data 009f at offset 0034
279000638:  write data 0000 at offset 0032
280--------------------------------------------
281000620:  write data 2288 at offset 003c
282000624:  write data 0005 at offset 0038
283000628:  write data f5df at offset 003a
284
285000632:  write data 0020 at offset 0034
286000638:  write data 0f8a at offset 0032
287000632:  write data 0021 at offset 0034
288000638:  write data 0b8a at offset 0032
289000632:  write data 0022 at offset 0034
290000638:  write data 0388 at offset 0032
291000632:  write data 0023 at offset 0034
292000638:  write data 0b9a at offset 0032
293000632:  write data 0024 at offset 0034
294000638:  write data 0b9a at offset 0032
295000632:  write data 0025 at offset 0034
296000638:  write data 0a9a at offset 0032
297000632:  write data 0026 at offset 0034
298000638:  write data 0000 at offset 0032
299000632:  write data 0027 at offset 0034
300000638:  write data 0000 at offset 0032
301--------------------------------------------
302000620:  write data 338e at offset 003c
303000624:  write data 0005 at offset 0038
304000628:  write data bf7f at offset 003a
305
306000632:  write data 0030 at offset 0034
307000638:  write data 0984 at offset 0032
308000632:  write data 0031 at offset 0034
309000638:  write data 0aa4 at offset 0032
310000632:  write data 0032 at offset 0034
311000638:  write data 0d82 at offset 0032
312000632:  write data 0033 at offset 0034
313000638:  write data 0aa2 at offset 0032
314000632:  write data 0034 at offset 0034
315000638:  write data 039c at offset 0032
316000632:  write data 0035 at offset 0034
317000638:  write data 0b9c at offset 0032
318000632:  write data 0036 at offset 0034
319000638:  write data 0b9c at offset 0032
320000632:  write data 0037 at offset 0034
321000638:  write data 0a9a at offset 0032
322--------------------------------------------
323000620:  write data 3bb0 at offset 003c
324000624:  write data 0004 at offset 0038
325000628:  write data 007f at offset 003a
326
327000632:  write data 0038 at offset 0034
328000638:  write data 0f9c at offset 0032
329000632:  write data 0039 at offset 0034
330000638:  write data 0b9c at offset 0032
331000632:  write data 003a at offset 0034
332000638:  write data 0b9c at offset 0032
333000632:  write data 003b at offset 0034
334000638:  write data 0b9c at offset 0032
335000632:  write data 003c at offset 0034
336000638:  write data 0b9c at offset 0032
337000632:  write data 003d at offset 0034
338000638:  write data 0b9c at offset 0032
339000632:  write data 003e at offset 0034
340000638:  write data 0b9c at offset 0032
341000632:  write data 003f at offset 0034
342000638:  write data 099c at offset 0032
343--------------------------------------------
344000620:  write data 42c2 at offset 003c
345000624:  write data 0005 at offset 0038
346000628:  write data fcdd at offset 003a
347
348000632:  write data 0040 at offset 0034
349000638:  write data 0f9a at offset 0032
350000632:  write data 0041 at offset 0034
351000638:  write data 0b9a at offset 0032
352000632:  write data 0042 at offset 0034
353000638:  write data 0b9c at offset 0032
354000632:  write data 0043 at offset 0034
355000638:  write data 0b9c at offset 0032
356000632:  write data 0044 at offset 0034
357000638:  write data 0b9c at offset 0032
358000632:  write data 0045 at offset 0034
359000638:  write data 029c at offset 0032
360000632:  write data 0046 at offset 0034
361000638:  write data 0000 at offset 0032
362000632:  write data 0047 at offset 0034
363000638:  write data 0000 at offset 0032
364--------------------------------------------
365000620:  write data 4aa0 at offset 003c
366000624:  write data 0005 at offset 0038
367000628:  write data fcdd at offset 003a
368
369000632:  write data 0048 at offset 0034
370000638:  write data 0f9a at offset 0032
371000632:  write data 0049 at offset 0034
372000638:  write data 0b9a at offset 0032
373000632:  write data 004a at offset 0034
374000638:  write data 0b9c at offset 0032
375000632:  write data 004b at offset 0034
376000638:  write data 0b9c at offset 0032
377000632:  write data 004c at offset 0034
378000638:  write data 0b9c at offset 0032
379000632:  write data 004d at offset 0034
380000638:  write data 099b at offset 0032
381000632:  write data 004e at offset 0034
382000638:  write data 0000 at offset 0032
383000632:  write data 004f at offset 0034
384000638:  write data 0000 at offset 0032
385--------------------------------------------
386000620:  write data 6880 at offset 003c
387000624:  write data 000a at offset 0038
388000628:  write data fff3 at offset 003a
389
390000632:  write data 0068 at offset 0034
391000638:  write data 0b80 at offset 0032
392000632:  write data 0069 at offset 0034
393000638:  write data 0ba0 at offset 0032
394000632:  write data 006a at offset 0034
395000638:  write data 0000 at offset 0032
396000632:  write data 006b at offset 0034
397000638:  write data 0000 at offset 0032
398000632:  write data 006c at offset 0034
399000638:  write data 0000 at offset 0032
400000632:  write data 006d at offset 0034
401000638:  write data 0000 at offset 0032
402000632:  write data 006e at offset 0034
403000638:  write data 0000 at offset 0032
404000632:  write data 006f at offset 0034
405000638:  write data 0000 at offset 0032
406--------------------------------------------
407000620:  write data c480 at offset 003c
408000624:  write data 000a at offset 0038
409000628:  write data ff00 at offset 003a
410
411000632:  write data 00c0 at offset 0034
412000638:  write data 0080 at offset 0032
413000632:  write data 00c1 at offset 0034
414000638:  write data 0882 at offset 0032
415000632:  write data 00c2 at offset 0034
416000638:  write data 0000 at offset 0032
417000632:  write data 00c3 at offset 0034
418000638:  write data 0000 at offset 0032
419000632:  write data 00c4 at offset 0034
420000638:  write data 0000 at offset 0032
421000632:  write data 00c5 at offset 0034
422000638:  write data 0000 at offset 0032
423000632:  write data 00c6 at offset 0034
424000638:  write data 0000 at offset 0032
425000632:  write data 00c7 at offset 0034
426000638:  write data 0000 at offset 0032
427--------------------------------------------
428000620:  write data a180 at offset 003c
429000624:  write data 0000 at offset 0038
430000628:  write data ffff at offset 003a
431
432000632:  write data 00a0 at offset 0034
433000638:  write data 0b80 at offset 0032
434000632:  write data 00a1 at offset 0034
435000638:  write data 0b82 at offset 0032
436000632:  write data 00a2 at offset 0034
437000638:  write data 0b84 at offset 0032
438000632:  write data 00a3 at offset 0034
439000638:  write data 0b86 at offset 0032
440000632:  write data 00a4 at offset 0034
441000638:  write data 0000 at offset 0032
442000632:  write data 00a5 at offset 0034
443000638:  write data 0000 at offset 0032
444000632:  write data 00a6 at offset 0034
445000638:  write data 0000 at offset 0032
446000632:  write data 00a7 at offset 0034
447000638:  write data 0000 at offset 0032
448--------------------------------------------
449000620:  write data a980 at offset 003c
450000624:  write data 000f at offset 0038
451000628:  write data ffff at offset 003a
452
453000632:  write data 00a8 at offset 0034
454000638:  write data 0ba0 at offset 0032
455000632:  write data 00a9 at offset 0034
456000638:  write data 0ba2 at offset 0032
457000632:  write data 00aa at offset 0034
458000638:  write data 0ba4 at offset 0032
459000632:  write data 00ab at offset 0034
460000638:  write data 0ba6 at offset 0032
461000632:  write data 00ac at offset 0034
462000638:  write data 0000 at offset 0032
463000632:  write data 00ad at offset 0034
464000638:  write data 0000 at offset 0032
465000632:  write data 00ae at offset 0034
466000638:  write data 0000 at offset 0032
467000632:  write data 00af at offset 0034
468000638:  write data 0000 at offset 0032
469--------------------------------------------
470000620:  write data b100 at offset 003c
471000624:  write data 0009 at offset 0038
472000628:  write data ffff at offset 003a
473
474000632:  write data 00b0 at offset 0034
475000638:  write data 0b40 at offset 0032
476000632:  write data 00b1 at offset 0034
477000638:  write data 0bc0 at offset 0032
478000632:  write data 00b2 at offset 0034
479000638:  write data 0bc2 at offset 0032
480000632:  write data 00b3 at offset 0034
481000638:  write data 0000 at offset 0032
482000632:  write data 00b4 at offset 0034
483000638:  write data 0000 at offset 0032
484000632:  write data 00b5 at offset 0034
485000638:  write data 0000 at offset 0032
486000632:  write data 00b6 at offset 0034
487000638:  write data 0000 at offset 0032
488000632:  write data 00b7 at offset 0034
489000638:  write data 0000 at offset 0032
490--------------------------------------------
491000620:  write data b900 at offset 003c
492000624:  write data 0006 at offset 0038
493000628:  write data ffff at offset 003a
494
495000632:  write data 00b8 at offset 0034
496000638:  write data 0b60 at offset 0032
497000632:  write data 00b9 at offset 0034
498000638:  write data 0be0 at offset 0032
499000632:  write data 00ba at offset 0034
500000638:  write data 0be2 at offset 0032
501000632:  write data 00bb at offset 0034
502000638:  write data 0000 at offset 0032
503000632:  write data 00bc at offset 0034
504000638:  write data 0000 at offset 0032
505000632:  write data 00bd at offset 0034
506000638:  write data 0000 at offset 0032
507000632:  write data 00be at offset 0034
508000638:  write data 0000 at offset 0032
509000632:  write data 00bf at offset 0034
510000638:  write data 0000 at offset 0032
511--------------------------------------------
512000620:  write data cb8f at offset 003c
513000624:  write data 0005 at offset 0038
514000628:  write data bf7f at offset 003a
515
516000632:  write data 00c8 at offset 0034
517000638:  write data 0984 at offset 0032
518000632:  write data 00c9 at offset 0034
519000638:  write data 0aa4 at offset 0032
520000632:  write data 00ca at offset 0034
521000638:  write data 0d82 at offset 0032
522000632:  write data 00cb at offset 0034
523000638:  write data 0aa2 at offset 0032
524000632:  write data 00cc at offset 0034
525000638:  write data 039b at offset 0032
526000632:  write data 00cd at offset 0034
527000638:  write data 0b9a at offset 0032
528000632:  write data 00ce at offset 0034
529000638:  write data 0b9a at offset 0032
530000632:  write data 00cf at offset 0034
531000638:  write data 0a9f at offset 0032
532--------------------------------------------
533000620:  write data d104 at offset 003c
534000624:  write data 0005 at offset 0038
535000628:  write data fffb at offset 003a
536
537000632:  write data 00d0 at offset 0034
538000638:  write data 0ac2 at offset 0032
539000632:  write data 00d1 at offset 0034
540000638:  write data 09e0 at offset 0032
541000632:  write data 00d2 at offset 0034
542000638:  write data 00a2 at offset 0032
543000632:  write data 00d3 at offset 0034
544000638:  write data 0000 at offset 0032
545000632:  write data 00d4 at offset 0034
546000638:  write data 0000 at offset 0032
547000632:  write data 00d5 at offset 0034
548000638:  write data 0000 at offset 0032
549000632:  write data 00d6 at offset 0034
550000638:  write data 0000 at offset 0032
551000632:  write data 00d7 at offset 0034
552000638:  write data 0000 at offset 0032
553--------------------------------------------
554000620:  write data dde5 at offset 003c
555000624:  write data 0005 at offset 0038
556000628:  write data 7ff7 at offset 003a
557
558000632:  write data 00d8 at offset 0034
559000638:  write data 0f80 at offset 0032
560000632:  write data 00d9 at offset 0034
561000638:  write data 0aa2 at offset 0032
562000632:  write data 00da at offset 0034
563000638:  write data 0984 at offset 0032
564000632:  write data 00db at offset 0034
565000638:  write data 00c2 at offset 0032
566000632:  write data 00dc at offset 0034
567000638:  write data 0000 at offset 0032
568000632:  write data 00dd at offset 0034
569000638:  write data 0000 at offset 0032
570000632:  write data 00de at offset 0034
571000638:  write data 0000 at offset 0032
572000632:  write data 00df at offset 0034
573000638:  write data 0000 at offset 0032
574--------------------------------------------
575000620:  write data e38e at offset 003c
576000624:  write data 0005 at offset 0038
577000628:  write data b07f at offset 003a
578
579000632:  write data 00e0 at offset 0034
580000638:  write data 0984 at offset 0032
581000632:  write data 00e1 at offset 0034
582000638:  write data 0ac4 at offset 0032
583000632:  write data 00e2 at offset 0034
584000638:  write data 0d82 at offset 0032
585000632:  write data 00e3 at offset 0034
586000638:  write data 0ac2 at offset 0032
587000632:  write data 00e4 at offset 0034
588000638:  write data 039b at offset 0032
589000632:  write data 00e5 at offset 0034
590000638:  write data 0b9a at offset 0032
591000632:  write data 00e6 at offset 0034
592000638:  write data 0b9a at offset 0032
593000632:  write data 00e7 at offset 0034
594000638:  write data 0a9a at offset 0032
595--------------------------------------------
596000620:  write data eb8e at offset 003c
597000624:  write data 0005 at offset 0038
598000628:  write data b07f at offset 003a
599
600000632:  write data 00e8 at offset 0034
601000638:  write data 0984 at offset 0032
602000632:  write data 00e9 at offset 0034
603000638:  write data 0ac4 at offset 0032
604000632:  write data 00ea at offset 0034
605000638:  write data 0d82 at offset 0032
606000632:  write data 00eb at offset 0034
607000638:  write data 0ac2 at offset 0032
608000632:  write data 00ec at offset 0034
609000638:  write data 039b at offset 0032
610000632:  write data 00ed at offset 0034
611000638:  write data 0b9a at offset 0032
612000632:  write data 00ee at offset 0034
613000638:  write data 0b9a at offset 0032
614000632:  write data 00ef at offset 0034
615000638:  write data 0a9f at offset 0032
616--------------------------------------------
617000620:  write data 5105 at offset 003c
618000624:  write data 0005 at offset 0038
619000628:  write data fefb at offset 003a
620
621000632:  write data 0050 at offset 0034
622000638:  write data 0a80 at offset 0032
623000632:  write data 0051 at offset 0034
624000638:  write data 0984 at offset 0032
625000632:  write data 0052 at offset 0034
626000638:  write data 0082 at offset 0032
627000632:  write data 0053 at offset 0034
628000638:  write data 0000 at offset 0032
629000632:  write data 0054 at offset 0034
630000638:  write data 0000 at offset 0032
631000632:  write data 0055 at offset 0034
632000638:  write data 0000 at offset 0032
633000632:  write data 0056 at offset 0034
634000638:  write data 0000 at offset 0032
635000632:  write data 0057 at offset 0034
636000638:  write data 0000 at offset 0032
637--------------------------------------------
638000620:  write data 5905 at offset 003c
639000624:  write data 0005 at offset 0038
640000628:  write data fffb at offset 003a
641
642000632:  write data 0058 at offset 0034
643000638:  write data 09c8 at offset 0032
644000632:  write data 0059 at offset 0034
645000638:  write data 0a84 at offset 0032
646000632:  write data 005a at offset 0034
647000638:  write data 00a2 at offset 0032
648000632:  write data 005b at offset 0034
649000638:  write data 0000 at offset 0032
650000632:  write data 005c at offset 0034
651000638:  write data 0000 at offset 0032
652000632:  write data 005d at offset 0034
653000638:  write data 0000 at offset 0032
654000632:  write data 005e at offset 0034
655000638:  write data 0000 at offset 0032
656000632:  write data 005f at offset 0034
657000638:  write data 0000 at offset 0032
658--------------------------------------------
659000620:  write data 7905 at offset 003c
660000624:  write data 0006 at offset 0038
661000628:  write data fffb at offset 003a
662
663000632:  write data 0078 at offset 0034
664000638:  write data 01a2 at offset 0032
665000632:  write data 0079 at offset 0034
666000638:  write data 02c2 at offset 0032
667000632:  write data 007a at offset 0034
668000638:  write data 00a2 at offset 0032
669000632:  write data 007b at offset 0034
670000638:  write data 0000 at offset 0032
671000632:  write data 007c at offset 0034
672000638:  write data 0000 at offset 0032
673000632:  write data 007d at offset 0034
674000638:  write data 0000 at offset 0032
675000632:  write data 007e at offset 0034
676000638:  write data 0000 at offset 0032
677000632:  write data 007f at offset 0034
678000638:  write data 0000 at offset 0032
679--------------------------------------------
680000620:  write data f105 at offset 003c
681000624:  write data 0005 at offset 0038
682000628:  write data fefb at offset 003a
683
684000632:  write data 00f0 at offset 0034
685000638:  write data 0a88 at offset 0032
686000632:  write data 00f1 at offset 0034
687000638:  write data 0994 at offset 0032
688000632:  write data 00f2 at offset 0034
689000638:  write data 0088 at offset 0032
690000632:  write data 00f3 at offset 0034
691000638:  write data 0000 at offset 0032
692000632:  write data 00f4 at offset 0034
693000638:  write data 0000 at offset 0032
694000632:  write data 00f5 at offset 0034
695000638:  write data 0000 at offset 0032
696000632:  write data 00f6 at offset 0034
697000638:  write data 0000 at offset 0032
698000632:  write data 00f7 at offset 0034
699000638:  write data 0000 at offset 0032
700
701These uploads appear to form the basis of one part of the protection; command lists.
702
703The games upload these tables
704
705cupsoc, cupsoca, cupsocs, cupsocs2, olysoc92
706t    u1  u2     trg    tbl
70700 | 6 | ffeb | 0205 | 188 282 082 b8e 98e
70801 | 6 | fbfb | 0905 | 194 288 088
70902 | 5 | bf7f | 138e | 984 aa4 d82 aa2 39b b9a b9a a9a
71003 | 6 | fbfb | 1905 | 994 a88 088
71104 | 5 | f5df | 2288 | f8a b8a 388 b9a b9a a9a
71205 | 6 | ebeb | 2a05 | 9af a82 082 a8f 18e
71306 | 5 | bf7f | 338e | 984 aa4 d82 aa2 39c b9c b9c a9a
71407 | 4 | 007f | 3bb0 | f9c b9c b9c b9c b9c b9c b9c 99c
71508 | 5 | fcdd | 42c2 | f9a b9a b9c b9c b9c 29c
71609 | 5 | fcdd | 4aa0 | f9a b9a b9c b9c b9c 99b
7170a | 5 | fefb | 5105 | a80 984 082
7180b | 5 | fffb | 5905 | 9c8 a84 0a2
7190c | 8 | f3e7 | 6200 | 3a0 3a6 380 aa0 2a6
7200d | a | fff3 | 6880 | b80 ba0
7210e | 0 | 0000 | 0000 |
7220f | 6 | fffb | 7905 | 1a2 2c2 0a2
72310 | 7 | fdfb | 8100 | b9a b88 888
72411 | 7 | fdfb | 8900 | b9a b8a 88a
72512 | 7 | f8f7 | 9180 | b80 b94 b94 894
72613 | 7 | f8f7 | 9980 | b80 b94 b94 896
72714 | 0 | ffff | a180 | b80 b82 b84 b86
72815 | f | ffff | a980 | ba0 ba2 ba4 ba6
72916 | 9 | ffff | b100 | b40 bc0 bc2
73017 | 6 | ffff | b900 | b60 be0 be2
73118 | a | ff00 | c480 | 080 882
73219 | 5 | bf7f | cb8f | 984 aa4 d82 aa2 39b b9a b9a a9f
7331a | 5 | fffb | d104 | ac2 9e0 0a2
7341b | 5 | 7ff7 | dde5 | f80 aa2 984 0c2
7351c | 5 | b07f | e38e | 984 ac4 d82 ac2 39b b9a b9a a9a
7361d | 5 | b07f | eb8e | 984 ac4 d82 ac2 39b b9a b9a a9f
7371e | 5 | fefb | f105 | a88 994 088
7381f | 0 | 0000 | 0000 |
739
740heatbrl, heatbrl2, heatbrlo, heatbrlu
741t    u1  u2     trg    tbl
74200 | 6 | ffeb | 0205 | 188 282 082 b8e 98e
74301 | 6 | fbfb | 0905 | 194 288 088
74402 | 5 | bf7f | 138e | 984 aa4 d82 aa2 39b b9a b9a b9a
74503 | 6 | fbfb | 1905 | 994 a88 088
74604 | 5 | f5df | 2288 | f8a b8a 388 b9c b9a a9a
74705 | 6 | ebeb | 2a05 | 9af a82 082 a8f 18e
74806 | 5 | bf7f | 338e | 984 aa4 d82 aa2 39c b9c b9c a9a
74907 | 4 | 007f | 3bb0 | f9c b9c b9c b9c b9c b9c b9c 99c
75008 | 5 | fcdd | 42c2 | f9a b9a b9c b9c b9c 29c
75109 | 5 | fcdd | 4aa0 | f9a b9a b9c b9c b9c 99b
7520a | 0 | 0000 | 0000 |
7530b | 0 | 0000 | 0000 |
7540c | 8 | f3e7 | 6200 | 380 39a 380 a80 29a
7550d | a | fff3 | 6880 | b80 ba0
7560e | 0 | 0000 | 0000 |
7570f | 0 | 0000 | 0000 |
75810 | 7 | fdfb | 8100 | b9a b88 888
75911 | 7 | fdfb | 8900 | b9a b8a 88a
76012 | 7 | f8f7 | 9180 | b80 b94 b94 894
76113 | 7 | f8f7 | 9980 | b80 b96 b96 896
76214 | 0 | ffff | a100 | b80 b82 b84 b86
76315 | f | ffff | a900 | ba0 ba2 ba4 ba6
76416 | 9 | ffff | b080 | b40 bc0 bc2
76517 | 6 | ffff | b880 | b60 be0 be2
76618 | a | ff00 | c480 | 080 882
76719 | 0 | 0000 | 0000 |
7681a | 0 | 0000 | 0000 |
7691b | 0 | 0000 | 0000 |
7701c | 0 | 0000 | 0000 |
7711d | 0 | 0000 | 0000 |
7721e | 0 | 0000 | 0000 |
7731f | 0 | 0000 | 0000 |
774
775legionna, legionnau (commands are the same as heatbrl, triggers are different)
776t    u1  u2     trg    tbl
77700 | 6 | ffeb | 0205 | 188 282 082 b8e 98e
77801 | 6 | fbfb | 0905 | 194 288 088
77902 | 5 | bf7f | 138e | 984 aa4 d82 aa2 39b b9a b9a b9a
78003 | 6 | fbfb | 1905 | 994 a88 088
78104 | 5 | f5df | 2288 | f8a b8a 388 b9c b9a a9a
78205 | 6 | ebeb | 2a05 | 9af a82 082 a8f 18e
78306 | 5 | bf7f | 338e | 984 aa4 d82 aa2 39c b9c b9c a9a
78407 | 4 | 007f | 3bb0 | f9c b9c b9c b9c b9c b9c b9c 99c
78508 | 5 | fcdd | 42c2 | f9a b9a b9c b9c b9c 29c
78609 | 5 | fcdd | 4aa0 | f9a b9a b9c b9c b9c 99b
7870a | 0 | 0000 | 0000 |
7880b | 0 | 0000 | 0000 |
7890c | 8 | f3e7 | 6200 | 380 39a 380 a80 29a
7900d | a | fff3 | 6880 | b80 ba0
7910e | 0 | 0000 | 0000 |
7920f | 0 | 0000 | 0000 |
79310 | 7 | fdfb | 8100 | b9a b88 888
79411 | 7 | fdfb | 8900 | b9a b8a 88a
79512 | 7 | f8f7 | 9180 | b80 b94 b94 894
79613 | 7 | f8f7 | 9980 | b80 b96 b96 896
79714 | 0 | ffff | a180 | b80 b82 b84 b86
79815 | f | ffff | a980 | ba0 ba2 ba4 ba6
79916 | 9 | ffff | b100 | b40 bc0 bc2
80017 | 6 | ffff | b900 | b60 be0 be2
80118 | a | ff00 | c480 | 080 882
80219 | 0 | 0000 | 0000 |
8031a | 0 | 0000 | 0000 |
8041b | 0 | 0000 | 0000 |
8051c | 0 | 0000 | 0000 |
8061d | 0 | 0000 | 0000 |
8071e | 0 | 0000 | 0000 |
8081f | 0 | 0000 | 0000 |
809
810godzilla, denjinmk
811(denjinmk doesn't actually make use of the table, it never writes to the execute trigger)
812t    u1  u2     trg    tbl
81300 | 6 | ffeb | 0205 | 188 282 082 b8e 98e
81401 | 6 | fbfb | 0905 | 194 288 088
81502 | 5 | bf7f | 138e | 984 aa4 d82 aa2 39b b9a b9a a9a
81603 | 6 | fbfb | 1905 | 994 a88 088
81704 | 5 | f5df | 2288 | f8a b8a 388 b9a b9a a9a
81805 | 6 | ebeb | 2a05 | 9af a82 082 a8f 18e
81906 | 5 | bf7f | 338e | 984 aa4 d82 aa2 39c b9c b9c a9a
82007 | 4 | 007f | 3bb0 | f9c b9c b9c b9c b9c b9c b9c 99c
82108 | 5 | fcdd | 42c2 | f9a b9a b9c b9c b9c 29c
82209 | 5 | fcdd | 4aa0 | f9a b9a b9c b9c b9c 99b
8230a | 0 | 0000 | 0000 |
8240b | 0 | 0000 | 0000 |
8250c | 8 | f3e7 | 6200 | 380 39a 380 a80 29a
8260d | a | fff3 | 6880 | b80 ba0
8270e | 0 | 0000 | 0000 |
8280f | 0 | 0000 | 0000 |
82910 | 7 | fdfb | 8100 | b9a b88 888
83011 | 7 | fdfb | 8900 | b9a b8a 88a
83112 | 7 | f8f7 | 9180 | b80 b94 b94 894
83213 | 7 | f8f7 | 9980 | b80 b94 b94 896
83314 | 0 | ffff | a180 | b80 b82 b84 b86
83415 | f | ffff | a980 | ba0 ba2 ba4 ba6
83516 | 9 | ffff | b100 | b40 bc0 bc2
83617 | 6 | ffff | b900 | b60 be0 be2
83718 | a | ff00 | c480 | 080 882
83819 | 0 | 0000 | 0000 |
8391a | 0 | 0000 | 0000 |
8401b | 0 | 0000 | 0000 |
8411c | 0 | 0000 | 0000 |
8421d | 0 | 0000 | 0000 |
8431e | 0 | 0000 | 0000 |
8441f | 0 | 0000 | 0000 |
845
846grainbow
847t    u1  u2     trg    tbl
84800 | 6 | ffeb | 0205 | 188 282 082 b8e 98e
84901 | 6 | fbfb | 0905 | 194 288 088
85002 | 5 | bf7f | 138e | 984 aa4 d82 aa2 39b b9a b9a a9a
85103 | 6 | fbfb | 1905 | 994 a88 088
85204 | 5 | f5df | 2288 | f8a b8a 388 b9a b9a a9a
85305 | 6 | ebeb | 2a05 | 9af a82 082 a8f 18e
85406 | 5 | bf7f | 338e | 984 aa4 d82 aa2 39c b9c b9c a9a
85507 | 4 | 007f | 3bb0 | f9c b9c b9c b9c b9c b9c b9c 99c
85608 | 5 | fcdd | 42c2 | f9a b9a b9c b9c b9c 29c
85709 | 5 | fcdd | 4aa0 | f9a b9a b9c b9c b9c 99b
8580a | 5 | fefb | 5105 | a80 984 082
8590b | 5 | fffb | 5905 | 9c8 a84 0a2
8600c | 8 | f3e7 | 6200 | 380 39a 380 a80 29a
8610d | a | fff3 | 6980 | b80 ba0
8620e | 0 | 0000 | 0000 |
8630f | 6 | fffb | 7905 | 1a2 2c2 0a2
86410 | 7 | fdfb | 8100 | b9a b88 888
86511 | 7 | fdfb | 8900 | b9a b8a 88a
86612 | 7 | f8f7 | 9180 | b80 b94 b94 894
86713 | 7 | f8f7 | 9980 | b80 b94 b94 896
86814 | 0 | 02ff | a180 | b80 b82 b84 b86
86915 | f | 02ff | a980 | ba0 ba2 ba4 ba6
87016 | 9 | ffff | b100 | b40 bc0 bc2
87117 | 6 | ffff | b900 | b60 be0 be2
87218 | a | ff00 | c480 | 080 882
87319 | 5 | bf7f | cb8f | 984 aa4 d82 aa2 39b b9a b9a a9f
8741a | 5 | fffb | d104 | ac2 9e0 0a2
8751b | 5 | 7ff7 | dde5 | f80 aa2 984 0c2
8761c | 5 | b07f | e38e | 984 ac4 d82 ac2 39b b9a b9a a9a
8771d | 5 | b07f | eb8e | 984 ac4 d82 ac2 39b b9a b9a a9f
8781e | 5 | fefb | f105 | a88 994 088
8791f | 0 | 0000 | 0000 |
880
881raiden2, raiden2a, raiden2b, raiden2c, raiden2d, raiden2e, raiden2f
882t    u1  u2     trg    tbl
88300 | 6 | ffeb | 0205 | 188 282 082 b8e 98e
88401 | 6 | fbfb | 0905 | 194 288 088
88502 | 5 | bf7f | 130e | 984 aa4 d82 aa2 39b b9a b9a a9a
88603 | 6 | fbfb | 1905 | 994 a88 088
88704 | 5 | f5df | 2208 | f8a b8a 388 b9a b9a a9a
88805 | 6 | ebeb | 2a05 | 9af a82 082 a8f 18e
88906 | 5 | bf7f | 338e | 984 aa4 d82 aa2 39c b9c b9c a9a
89007 | 4 | 007f | 3bb0 | f9c b9c b9c b9c b9c b9c b9c 99c
89108 | 5 | fcdd | 42c2 | f9a b9a b9c b9c b9c 29c
89209 | 5 | fcdd | 4aa0 | f9a b9a b9c b9c b9c 99b
8930a | 6 | fff7 | 5205 | 180 2e0 3a0 0a0 3a0
8940b | 6 | fff7 | 5a05 | 180 2e0 3a0 0a0 3a0
8950c | 8 | f3e7 | 6200 | 380 39a 380 a80 29a
8960d | 0 | 0000 | 0000 |
8970e | 0 | 0000 | 0000 |
8980f | 0 | 0000 | 0000 |
89910 | 7 | fdfb | 8100 | b9a b88 888
90011 | 7 | fdfb | 8900 | b9a b8a 88a
90112 | 7 | fefb | 9100 | b80 b94 894
90213 | 7 | fefb | 9900 | b80 b94 896
90314 | 0 | 00ff | a100 | b80 b82 b84 b86
90415 | f | 00ff | a900 | ba0 ba2 ba4 ba6
90516 | 9 | ffff | b100 | b40 bc0 bc2
90617 | 6 | ffff | b900 | b60 be0 be2
90718 | 0 | 0000 | 0000 |
90819 | 0 | 0000 | 0000 |
9091a | 0 | 0000 | 0000 |
9101b | 0 | 0000 | 0000 |
9111c | 0 | 0000 | 0000 |
9121d | 0 | 0000 | 0000 |
9131e | 6 | fff7 | f205 | 182 2e0 3c0 0c0 3c0
9141f | 0 | 0000 | 0000 |
915
916raidndx, raidndxj, raidndxm, raidndxt
917(the same as raiden2, but adds an extra command with trigger 7e05)
918t    u1  u2     trg    tbl
91900 | 6 | ffeb | 0205 | 188 282 082 b8e 98e
92001 | 6 | fbfb | 0905 | 194 288 088
92102 | 5 | bf7f | 130e | 984 aa4 d82 aa2 39b b9a b9a a9a
92203 | 6 | fbfb | 1905 | 994 a88 088
92304 | 5 | f5df | 2208 | f8a b8a 388 b9a b9a a9a
92405 | 6 | ebeb | 2a05 | 9af a82 082 a8f 18e
92506 | 5 | bf7f | 338e | 984 aa4 d82 aa2 39c b9c b9c a9a
92607 | 4 | 007f | 3bb0 | f9c b9c b9c b9c b9c b9c b9c 99c
92708 | 5 | fcdd | 42c2 | f9a b9a b9c b9c b9c 29c
92809 | 5 | fcdd | 4aa0 | f9a b9a b9c b9c b9c 99b
9290a | 6 | fff7 | 5205 | 180 2e0 3a0 0a0 3a0
9300b | 6 | fff7 | 5a05 | 180 2e0 3a0 0a0 3a0
9310c | 8 | f3e7 | 6200 | 380 39a 380 a80 29a
9320d | 0 | 0000 | 0000 |
9330e | 0 | 0000 | 0000 |
9340f | 6 | fffb | 7e05 | 180 282 080 180 282
93510 | 7 | fdfb | 8100 | b9a b88 888
93611 | 7 | fdfb | 8900 | b9a b8a 88a
93712 | 7 | fefb | 9100 | b80 b94 894
93813 | 7 | fefb | 9900 | b80 b94 896
93914 | 0 | 00ff | a100 | b80 b82 b84 b86
94015 | f | 00ff | a900 | ba0 ba2 ba4 ba6
94116 | 9 | ffff | b100 | b40 bc0 bc2
94217 | 6 | ffff | b900 | b60 be0 be2
94318 | 0 | 0000 | 0000 |
94419 | 0 | 0000 | 0000 |
9451a | 0 | 0000 | 0000 |
9461b | 0 | 0000 | 0000 |
9471c | 0 | 0000 | 0000 |
9481d | 0 | 0000 | 0000 |
9491e | 6 | fff7 | f205 | 182 2e0 3c0 0c0 3c0
9501f | 0 | 0000 | 0000 |
951
952
953zeroteam, zeroteama, zeroteamb, zeroteamc, zeroteams, xsedae
954t    u1  u2     trg    tbl
95500 | 6 | ffeb | 0205 | 188 282 082 b8e 98e
95601 | 6 | fbfb | 0905 | 194 288 088
95702 | 5 | bf7f | 130e | 984 aa4 d82 aa2 39b b9a b9a a9a
95803 | 6 | fbfb | 1905 | 994 a88 088
95904 | 5 | f5df | 2208 | f8a b8a 388 b9a b9a a9a
96005 | 6 | ebeb | 2a05 | 9af a82 082 a8f 18e
96106 | 5 | bf7f | 330e | 984 aa4 d82 aa2 39c b9c b9c a9a
96207 | 4 | 007f | 3b30 | f9c b9c b9c b9c b9c b9c b9c 99c
96308 | 5 | fcdd | 42c2 | f9a b9a b9c b9c b9c 29c
96409 | 5 | fcdd | 4aa0 | f9a b9a b9c b9c b9c 99b
9650a | 6 | fffb | 5105 | 180 2e0 0a0
9660b | 6 | ffdb | 5a85 | 180 2e0 0a0 182 2e0 0c0 3c0
9670c | 8 | f3e7 | 6200 | 380 39a 380 a80 29a
9680d | a | fff3 | 6980 | b80 ba0
9690e | 8 | fdfd | 7100 | b80 a80 b80
9700f | 0 | 0000 | 0000 |
97110 | 7 | fdfb | 8100 | b9a b88 888
97211 | 7 | fdfb | 8900 | b9a b8a 88a
97312 | 7 | f8f7 | 9100 | b80 b94 b94 894
97413 | 7 | f8f7 | 9900 | b80 b94 b94 896
97514 | 0 | ffff | a100 | b80 b82 b84 b86
97615 | f | ffff | a900 | ba0 ba2 ba4 ba6
97716 | 9 | ffff | b100 | b40 bc0 bc2
97817 | 6 | ffff | b900 | b60 be0 be2
97918 | a | ff00 | 7c80 | 080 882
98019 | 0 | 0000 | 0000 |
9811a | 0 | 0000 | 0000 |
9821b | 0 | 0000 | 0000 |
9831c | 5 | 06fb | e105 | a88 994 088
9841d | 5 | 05f7 | ede5 | f88 a84 986 08a
9851e | 4 | 00ff | f790 | f80 b84 b84 b84 b84 b84 b84 b84
9861f | 6 | 00ff | fc84 | 182 280
987
988as you can see, there are a lot of command 'command lists' between the games.
989(todo, comment ones which seem to have a known function)
990
991executing these seems to cause various operations to occur, be it memory transfer, collision checking, or movement checking.
992
993each 12-bit entry in the tables is probably some kind of 'opcode' which runs and processes data placed in registers / memory.
994
995If we rearrange these tables a bit, so that we can see which are common between games we get the following, take note of
996the ones with slight changes, these could be important to figuring out how this works!
997
998
999Game       |u1 |u2    | trig | macrolist
1000
1001Table 00 - Same on All games
1002(grainbow) | 6 | ffeb | 0205 | 188 282 082 b8e 98e
1003(cupsoc)   | 6 | ffeb | 0205 | 188 282 082 b8e 98e
1004(legionna) | 6 | ffeb | 0205 | 188 282 082 b8e 98e
1005(godzilla) | 6 | ffeb | 0205 | 188 282 082 b8e 98e
1006(heatbrl)  | 6 | ffeb | 0205 | 188 282 082 b8e 98e
1007(zeroteam) | 6 | ffeb | 0205 | 188 282 082 b8e 98e
1008(raiden2)  | 6 | ffeb | 0205 | 188 282 082 b8e 98e
1009(raidndx)  | 6 | ffeb | 0205 | 188 282 082 b8e 98e
1010
1011Table 01 - Same on All games
1012(grainbow) | 6 | fbfb | 0905 | 194 288 088
1013(cupsoc)   | 6 | fbfb | 0905 | 194 288 088
1014(legionna) | 6 | fbfb | 0905 | 194 288 088
1015(godzilla) | 6 | fbfb | 0905 | 194 288 088
1016(heatbrl)  | 6 | fbfb | 0905 | 194 288 088
1017(zeroteam) | 6 | fbfb | 0905 | 194 288 088
1018(raiden2)  | 6 | fbfb | 0905 | 194 288 088
1019(raidndx)  | 6 | fbfb | 0905 | 194 288 088
1020
1021Table 02 - grainbow and heatbrl have different last entry.  triggers differ on v30 hw
1022(grainbow) | 5 | bf7f | 138e | 984 aa4 d82 aa2 39b b9a b9a b9a
1023(cupsoc)   | 5 | bf7f | 138e | 984 aa4 d82 aa2 39b b9a b9a a9a
1024(legionna) | 5 | bf7f | 138e | 984 aa4 d82 aa2 39b b9a b9a a9a
1025(godzilla) | 5 | bf7f | 138e | 984 aa4 d82 aa2 39b b9a b9a a9a
1026(heatbrl)  | 5 | bf7f | 138e | 984 aa4 d82 aa2 39b b9a b9a b9a
1027(zeroteam) | 5 | bf7f | 130e | 984 aa4 d82 aa2 39b b9a b9a a9a
1028(raiden2)  | 5 | bf7f | 130e | 984 aa4 d82 aa2 39b b9a b9a a9a
1029(raidndx)  | 5 | bf7f | 130e | 984 aa4 d82 aa2 39b b9a b9a a9a
1030
1031Table 03 - Same on All games
1032(grainbow) | 6 | fbfb | 1905 | 994 a88 088
1033(cupsoc)   | 6 | fbfb | 1905 | 994 a88 088
1034(legionna) | 6 | fbfb | 1905 | 994 a88 088
1035(godzilla) | 6 | fbfb | 1905 | 994 a88 088
1036(heatbrl)  | 6 | fbfb | 1905 | 994 a88 088
1037(zeroteam) | 6 | fbfb | 1905 | 994 a88 088
1038(raiden2)  | 6 | fbfb | 1905 | 994 a88 088
1039(raidndx)  | 6 | fbfb | 1905 | 994 a88 088
1040
1041Table 04 - grainbow and heatbrl have a b9c in the 4th slot, triggers differ on v30 hw
1042(grainbow) | 5 | f5df | 2288 | f8a b8a 388 b9c b9a a9a
1043(cupsoc)   | 5 | f5df | 2288 | f8a b8a 388 b9a b9a a9a
1044(legionna) | 5 | f5df | 2288 | f8a b8a 388 b9a b9a a9a
1045(godzilla) | 5 | f5df | 2288 | f8a b8a 388 b9a b9a a9a
1046(heatbrl)  | 5 | f5df | 2288 | f8a b8a 388 b9c b9a a9a
1047(zeroteam) | 5 | f5df | 2208 | f8a b8a 388 b9a b9a a9a
1048(raiden2)  | 5 | f5df | 2208 | f8a b8a 388 b9a b9a a9a
1049(raidndx)  | 5 | f5df | 2208 | f8a b8a 388 b9a b9a a9a
1050
1051Table 05 - Same on All games
1052(grainbow) | 6 | ebeb | 2a05 | 9af a82 082 a8f 18e
1053(cupsoc)   | 6 | ebeb | 2a05 | 9af a82 082 a8f 18e
1054(legionna) | 6 | ebeb | 2a05 | 9af a82 082 a8f 18e
1055(godzilla) | 6 | ebeb | 2a05 | 9af a82 082 a8f 18e
1056(heatbrl)  | 6 | ebeb | 2a05 | 9af a82 082 a8f 18e
1057(zeroteam) | 6 | ebeb | 2a05 | 9af a82 082 a8f 18e
1058(raiden2)  | 6 | ebeb | 2a05 | 9af a82 082 a8f 18e
1059(raidndx)  | 6 | ebeb | 2a05 | 9af a82 082 a8f 18e
1060
1061Table 06 - different trigger on zeroteam (330e)
1062(grainbow) | 5 | bf7f | 338e | 984 aa4 d82 aa2 39c b9c b9c a9a
1063(cupsoc)   | 5 | bf7f | 338e | 984 aa4 d82 aa2 39c b9c b9c a9a
1064(legionna) | 5 | bf7f | 338e | 984 aa4 d82 aa2 39c b9c b9c a9a
1065(godzilla) | 5 | bf7f | 338e | 984 aa4 d82 aa2 39c b9c b9c a9a
1066(heatbrl)  | 5 | bf7f | 338e | 984 aa4 d82 aa2 39c b9c b9c a9a
1067(zeroteam) | 5 | bf7f | 330e | 984 aa4 d82 aa2 39c b9c b9c a9a
1068(raiden2)  | 5 | bf7f | 338e | 984 aa4 d82 aa2 39c b9c b9c a9a
1069(raidndx)  | 5 | bf7f | 338e | 984 aa4 d82 aa2 39c b9c b9c a9a
1070
1071Table 07 - different trigger on zeroteam (3b30)
1072(grainbow) | 4 | 007f | 3bb0 | f9c b9c b9c b9c b9c b9c b9c 99c
1073(cupsoc)   | 4 | 007f | 3bb0 | f9c b9c b9c b9c b9c b9c b9c 99c
1074(legionna) | 4 | 007f | 3bb0 | f9c b9c b9c b9c b9c b9c b9c 99c
1075(godzilla) | 4 | 007f | 3bb0 | f9c b9c b9c b9c b9c b9c b9c 99c
1076(heatbrl)  | 4 | 007f | 3bb0 | f9c b9c b9c b9c b9c b9c b9c 99c
1077(zeroteam) | 4 | 007f | 3b30 | f9c b9c b9c b9c b9c b9c b9c 99c
1078(raiden2)  | 4 | 007f | 3bb0 | f9c b9c b9c b9c b9c b9c b9c 99c
1079(raidndx)  | 4 | 007f | 3bb0 | f9c b9c b9c b9c b9c b9c b9c 99c
1080
1081Table 08 - Same on All games
1082(grainbow) | 5 | fcdd | 42c2 | f9a b9a b9c b9c b9c 29c
1083(cupsoc)   | 5 | fcdd | 42c2 | f9a b9a b9c b9c b9c 29c
1084(legionna) | 5 | fcdd | 42c2 | f9a b9a b9c b9c b9c 29c
1085(godzilla) | 5 | fcdd | 42c2 | f9a b9a b9c b9c b9c 29c
1086(heatbrl)  | 5 | fcdd | 42c2 | f9a b9a b9c b9c b9c 29c
1087(zeroteam) | 5 | fcdd | 42c2 | f9a b9a b9c b9c b9c 29c
1088(raiden2)  | 5 | fcdd | 42c2 | f9a b9a b9c b9c b9c 29c
1089(raidndx)  | 5 | fcdd | 42c2 | f9a b9a b9c b9c b9c 29c
1090
1091Table 09 - Same on All games
1092(grainbow) | 5 | fcdd | 4aa0 | f9a b9a b9c b9c b9c 99b
1093(cupsoc)   | 5 | fcdd | 4aa0 | f9a b9a b9c b9c b9c 99b
1094(legionna) | 5 | fcdd | 4aa0 | f9a b9a b9c b9c b9c 99b
1095(godzilla) | 5 | fcdd | 4aa0 | f9a b9a b9c b9c b9c 99b
1096(heatbrl)  | 5 | fcdd | 4aa0 | f9a b9a b9c b9c b9c 99b
1097(zeroteam) | 5 | fcdd | 4aa0 | f9a b9a b9c b9c b9c 99b
1098(raiden2)  | 5 | fcdd | 4aa0 | f9a b9a b9c b9c b9c 99b
1099(raidndx)  | 5 | fcdd | 4aa0 | f9a b9a b9c b9c b9c 99b
1100
1101Table 0a - Game specific
1102(grainbow) | 5 | fefb | 5105 | a80 984 082
1103(cupsoc)   | 5 | fefb | 5105 | a80 984 082
1104(legionna) | 0 | 0000 | 0000 |
1105(godzilla) | 0 | 0000 | 0000 |
1106(heatbrl)  | 0 | 0000 | 0000 |
1107(zeroteam) | 6 | fffb | 5105 | 180 2e0 0a0
1108(raiden2)  | 6 | fff7 | 5205 | 180 2e0 3a0 0a0 3a0
1109(raidndx)  | 6 | fff7 | 5205 | 180 2e0 3a0 0a0 3a0
1110
1111Table 0b - Game specific
1112(grainbow) | 5 | fffb | 5905 | 9c8 a84 0a2
1113(cupsoc)   | 5 | fffb | 5905 | 9c8 a84 0a2
1114(legionna) | 0 | 0000 | 0000 |
1115(godzilla) | 0 | 0000 | 0000 |
1116(heatbrl)  | 0 | 0000 | 0000 |
1117(zeroteam) | 6 | ffdb | 5a85 | 180 2e0 0a0 182 2e0 0c0 3c0
1118(raiden2)  | 6 | fff7 | 5a05 | 180 2e0 3a0 0a0 3a0
1119(raidndx)  | 6 | fff7 | 5a05 | 180 2e0 3a0 0a0 3a0
1120
1121Table 0c - cupsoc has various modifications
1122notice how *80 is replaced by *a0 and *9a is replaced with *a6, maybe it has the same function, but on different registers?
1123(grainbow) | 8 | f3e7 | 6200 | 380 39a 380 a80 29a
1124(cupsoc)   | 8 | f3e7 | 6200 | 3a0 3a6 380 aa0 2a6
1125(legionna) | 8 | f3e7 | 6200 | 380 39a 380 a80 29a
1126(godzilla) | 8 | f3e7 | 6200 | 380 39a 380 a80 29a
1127(heatbrl)  | 8 | f3e7 | 6200 | 380 39a 380 a80 29a
1128(zeroteam) | 8 | f3e7 | 6200 | 380 39a 380 a80 29a
1129(raiden2)  | 8 | f3e7 | 6200 | 380 39a 380 a80 29a
1130(raidndx)  | 8 | f3e7 | 6200 | 380 39a 380 a80 29a
1131
1132Table 0d - Zero team uses different trigger, doesn't exist on raiden2/dx
1133(grainbow) | a | fff3 | 6980 | b80 ba0
1134(cupsoc)   | a | fff3 | 6880 | b80 ba0
1135(legionna) | a | fff3 | 6880 | b80 ba0
1136(godzilla) | a | fff3 | 6880 | b80 ba0
1137(heatbrl)  | a | fff3 | 6880 | b80 ba0
1138(zeroteam) | a | fff3 | 6980 | b80 ba0
1139(raiden2)  | 0 | 0000 | 0000 |
1140(raidndx)  | 0 | 0000 | 0000 |
1141
1142Table 0e - Zero Team only
1143(grainbow) | 0 | 0000 | 0000 |
1144(cupsoc)   | 0 | 0000 | 0000 |
1145(legionna) | 0 | 0000 | 0000 |
1146(godzilla) | 0 | 0000 | 0000 |
1147(heatbrl)  | 0 | 0000 | 0000 |
1148(zeroteam) | 8 | fdfd | 7100 | b80 a80 b80
1149(raiden2)  | 0 | 0000 | 0000 |
1150(raidndx)  | 0 | 0000 | 0000 |
1151
1152Table 0f - Same on grainbow/cupsoc, different on raidndx (added compared to raiden2)
1153(grainbow) | 6 | fffb | 7905 | 1a2 2c2 0a2
1154(cupsoc)   | 6 | fffb | 7905 | 1a2 2c2 0a2
1155(legionna) | 0 | 0000 | 0000 |
1156(godzilla) | 0 | 0000 | 0000 |
1157(heatbrl)  | 0 | 0000 | 0000 |
1158(zeroteam) | 0 | 0000 | 0000 |
1159(raiden2)  | 0 | 0000 | 0000 |
1160(raidndx)  | 6 | fffb | 7e05 | 180 282 080 180 282
1161
1162Table 10 - Same on all games
1163(grainbow) | 7 | fdfb | 8100 | b9a b88 888
1164(cupsoc)   | 7 | fdfb | 8100 | b9a b88 888
1165(legionna) | 7 | fdfb | 8100 | b9a b88 888
1166(godzilla) | 7 | fdfb | 8100 | b9a b88 888
1167(heatbrl)  | 7 | fdfb | 8100 | b9a b88 888
1168(zeroteam) | 7 | fdfb | 8100 | b9a b88 888
1169(raiden2)  | 7 | fdfb | 8100 | b9a b88 888
1170(raidndx)  | 7 | fdfb | 8100 | b9a b88 888
1171
1172Table 11 - Same on all games
1173(grainbow) | 7 | fdfb | 8900 | b9a b8a 88a
1174(cupsoc)   | 7 | fdfb | 8900 | b9a b8a 88a
1175(legionna) | 7 | fdfb | 8900 | b9a b8a 88a
1176(godzilla) | 7 | fdfb | 8900 | b9a b8a 88a
1177(heatbrl)  | 7 | fdfb | 8900 | b9a b8a 88a
1178(zeroteam) | 7 | fdfb | 8900 | b9a b8a 88a
1179(raiden2)  | 7 | fdfb | 8900 | b9a b8a 88a
1180(raidndx)  | 7 | fdfb | 8900 | b9a b8a 88a
1181
1182Table 12 - Raiden2/DX differ from others (list and trigger)
1183(grainbow) | 7 | f8f7 | 9180 | b80 b94 b94 894
1184(cupsoc)   | 7 | f8f7 | 9180 | b80 b94 b94 894
1185(legionna) | 7 | f8f7 | 9180 | b80 b94 b94 894
1186(godzilla) | 7 | f8f7 | 9180 | b80 b94 b94 894
1187(heatbrl)  | 7 | f8f7 | 9180 | b80 b94 b94 894
1188(zeroteam) | 7 | f8f7 | 9100 | b80 b94 b94 894
1189(raiden2)  | 7 | fefb | 9100 | b80 b94 894
1190(raidndx)  | 7 | fefb | 9100 | b80 b94 894
1191
1192Table 13 - Raiden2/DX differ from others , slight changes on legionna and hearbrl too
1193           (*94 replaced with *96, to operate on a different register?)
1194(grainbow) | 7 | f8f7 | 9980 | b80 b94 b94 896
1195(cupsoc)   | 7 | f8f7 | 9980 | b80 b94 b94 896
1196(legionna) | 7 | f8f7 | 9980 | b80 b96 b96 896
1197(godzilla) | 7 | f8f7 | 9980 | b80 b94 b94 896
1198(heatbrl)  | 7 | f8f7 | 9980 | b80 b96 b96 896
1199(zeroteam) | 7 | f8f7 | 9900 | b80 b94 b94 896
1200(raiden2)  | 7 | fefb | 9900 | b80 b94 896
1201(raidndx)  | 7 | fefb | 9900 | b80 b94 896
1202
1203Table 14 - Trigger differs on heatbrl + v30 games, unknown param differs on grainbow + v30 games
1204(grainbow) | 0 | 02ff | a180 | b80 b82 b84 b86
1205(cupsoc)   | 0 | ffff | a180 | b80 b82 b84 b86
1206(legionna) | 0 | ffff | a180 | b80 b82 b84 b86
1207(godzilla) | 0 | ffff | a180 | b80 b82 b84 b86
1208(heatbrl)  | 0 | ffff | a100 | b80 b82 b84 b86
1209(zeroteam) | 0 | ffff | a100 | b80 b82 b84 b86
1210(raiden2)  | 0 | 00ff | a100 | b80 b82 b84 b86
1211(raidndx)  | 0 | 00ff | a100 | b80 b82 b84 b86
1212
1213Table 15 - Trigger differs on heatbrl + v30 games, unknown param differs on grainbow + v30 games
1214(grainbow) | f | 02ff | a980 | ba0 ba2 ba4 ba6
1215(cupsoc)   | f | ffff | a980 | ba0 ba2 ba4 ba6
1216(legionna) | f | ffff | a980 | ba0 ba2 ba4 ba6
1217(godzilla) | f | ffff | a980 | ba0 ba2 ba4 ba6
1218(heatbrl)  | f | ffff | a900 | ba0 ba2 ba4 ba6
1219(zeroteam) | f | ffff | a900 | ba0 ba2 ba4 ba6
1220(raiden2)  | f | 00ff | a900 | ba0 ba2 ba4 ba6
1221(raidndx)  | f | 00ff | a900 | ba0 ba2 ba4 ba6
1222
1223Table 16 - Trigger differs on heatbrl
1224(grainbow) | 9 | ffff | b100 | b40 bc0 bc2
1225(cupsoc)   | 9 | ffff | b100 | b40 bc0 bc2
1226(legionna) | 9 | ffff | b100 | b40 bc0 bc2
1227(godzilla) | 9 | ffff | b100 | b40 bc0 bc2
1228(heatbrl)  | 9 | ffff | b080 | b40 bc0 bc2
1229(zeroteam) | 9 | ffff | b100 | b40 bc0 bc2
1230(raiden2)  | 9 | ffff | b100 | b40 bc0 bc2
1231(raidndx)  | 9 | ffff | b100 | b40 bc0 bc2
1232
1233Table 17 - Trigger differs on heatbrl
1234(grainbow) | 6 | ffff | b900 | b60 be0 be2
1235(cupsoc)   | 6 | ffff | b900 | b60 be0 be2
1236(legionna) | 6 | ffff | b900 | b60 be0 be2
1237(godzilla) | 6 | ffff | b900 | b60 be0 be2
1238(heatbrl)  | 6 | ffff | b880 | b60 be0 be2
1239(zeroteam) | 6 | ffff | b900 | b60 be0 be2
1240(raiden2)  | 6 | ffff | b900 | b60 be0 be2
1241(raidndx)  | 6 | ffff | b900 | b60 be0 be2
1242
1243Table 18 - Same for all 68k games, zero team has different trigger, not on Raiden2/DX
1244(grainbow) | a | ff00 | c480 | 080 882
1245(cupsoc)   | a | ff00 | c480 | 080 882
1246(legionna) | a | ff00 | c480 | 080 882
1247(godzilla) | a | ff00 | c480 | 080 882
1248(heatbrl)  | a | ff00 | c480 | 080 882
1249(zeroteam) | a | ff00 | 7c80 | 080 882
1250(raiden2)  | 0 | 0000 | 0000 |
1251(raidndx)  | 0 | 0000 | 0000 |
1252
1253Table 19 - grainbow / cupsoc only
1254(grainbow) | 5 | bf7f | cb8f | 984 aa4 d82 aa2 39b b9a b9a a9f
1255(cupsoc)   | 5 | bf7f | cb8f | 984 aa4 d82 aa2 39b b9a b9a a9f
1256(legionna) | 0 | 0000 | 0000 |
1257(godzilla) | 0 | 0000 | 0000 |
1258(heatbrl)  | 0 | 0000 | 0000 |
1259(zeroteam) | 0 | 0000 | 0000 |
1260(raiden2)  | 0 | 0000 | 0000 |
1261(raidndx)  | 0 | 0000 | 0000 |
1262
1263Table 1a - grainbow / cupsoc only
1264(grainbow) | 5 | fffb | d104 | ac2 9e0 0a2
1265(cupsoc)   | 5 | fffb | d104 | ac2 9e0 0a2
1266(legionna) | 0 | 0000 | 0000 |
1267(godzilla) | 0 | 0000 | 0000 |
1268(heatbrl)  | 0 | 0000 | 0000 |
1269(zeroteam) | 0 | 0000 | 0000 |
1270(raiden2)  | 0 | 0000 | 0000 |
1271(raidndx)  | 0 | 0000 | 0000 |
1272
1273Table 1b - grainbow / cupsoc only
1274(grainbow) | 5 | 7ff7 | dde5 | f80 aa2 984 0c2
1275(cupsoc)   | 5 | 7ff7 | dde5 | f80 aa2 984 0c2
1276(legionna) | 0 | 0000 | 0000 |
1277(godzilla) | 0 | 0000 | 0000 |
1278(heatbrl)  | 0 | 0000 | 0000 |
1279(zeroteam) | 0 | 0000 | 0000 |
1280(raiden2)  | 0 | 0000 | 0000 |
1281(raidndx)  | 0 | 0000 | 0000 |
1282
1283Table 1c - grainbow / cupsoc are the same, different on zero team
1284(grainbow) | 5 | b07f | e38e | 984 ac4 d82 ac2 39b b9a b9a a9a
1285(cupsoc)   | 5 | b07f | e38e | 984 ac4 d82 ac2 39b b9a b9a a9a
1286(legionna) | 0 | 0000 | 0000 |
1287(godzilla) | 0 | 0000 | 0000 |
1288(heatbrl)  | 0 | 0000 | 0000 |
1289(zeroteam) | 5 | 06fb | e105 | a88 994 088
1290(raiden2)  | 0 | 0000 | 0000 |
1291(raidndx)  | 0 | 0000 | 0000 |
1292
1293Table 1d - grainbow / cupsoc are the same, different on zero team
1294(grainbow) | 5 | b07f | eb8e | 984 ac4 d82 ac2 39b b9a b9a a9f
1295(cupsoc)   | 5 | b07f | eb8e | 984 ac4 d82 ac2 39b b9a b9a a9f
1296(legionna) | 0 | 0000 | 0000 |
1297(godzilla) | 0 | 0000 | 0000 |
1298(heatbrl)  | 0 | 0000 | 0000 |
1299(zeroteam) | 5 | 05f7 | ede5 | f88 a84 986 08a
1300(raiden2)  | 0 | 0000 | 0000 |
1301(raidndx)  | 0 | 0000 | 0000 |
1302
1303Table 1e - grainbow / cupsoc are the same, different on zero team, different on raiden2/dx
1304(grainbow) | 5 | fefb | f105 | a88 994 088
1305(cupsoc)   | 5 | fefb | f105 | a88 994 088
1306(legionna) | 0 | 0000 | 0000 |
1307(godzilla) | 0 | 0000 | 0000 |
1308(heatbrl)  | 0 | 0000 | 0000 |
1309(zeroteam) | 4 | 00ff | f790 | f80 b84 b84 b84 b84 b84 b84 b84
1310(raiden2)  | 6 | fff7 | f205 | 182 2e0 3c0 0c0 3c0
1311(raidndx)  | 6 | fff7 | f205 | 182 2e0 3c0 0c0 3c0
1312
1313Table 1f - zeroteam specific
1314(grainbow) | 0 | 0000 | 0000 |
1315(cupsoc)   | 0 | 0000 | 0000 |
1316(legionna) | 0 | 0000 | 0000 |
1317(godzilla) | 0 | 0000 | 0000 |
1318(heatbrl)  | 0 | 0000 | 0000 |
1319(zeroteam) | 6 | 00ff | fc84 | 182 280
1320(raiden2)  | 0 | 0000 | 0000 |
1321(raidndx)  | 0 | 0000 | 0000 |
1322
1323
1324
1325typically the games write data for use with the commands at MCUBASE+0xa0 - 0xaf  and MCUBASE+0xc0 - 0xcf before triggering
1326the operation by writing to MCUBASE+0x100 (or MCUBASE+0x102) with the trigger value.  I believe the commands can change
1327both COP registers and system memory.
1328
1329(MCUBASE typically being 0x100400 in the 68k games, and 0x400 in the v30 games)
1330
1331Seibu Cup Soccer sometimes attempts to use a trigger value which wasn't defined in the table, I don't know what should
1332happen in that case!
1333
1334----
1335
1336Protection Part 2: BCD Maths
1337
1338some additional registers serve as a math box type device, converting numbers + other functions.  Godzilla seems to use
1339this for a protection check, other games (Denjin Makai, Raiden 2) use it for scoring:
1340
1341----
1342
1343Protection Part 3: Private Buffer DMA + RAM Clear
1344(todo, expand on this)
1345
1346address ranges can be specified which allows DMA Fill / Clear operations to be performed, as well as transfering
1347tilemap+palette data to private buffers for rendering.  If you don't use these nothing gets updated on the real
1348hardware!.  These don't currently make much sense because the hardware specifies ranges which aren't mapped, or
1349contain nothing.  It's possible the original hardware has mirroring which this function relies on.
1350
1351the DMA to private buffer operations are currently ignored due to
1352if ((cop_dma_trigger==0x14) || (cop_dma_trigger==0x15)) return;
1353
1354----
1355
1356Other Protections?
1357
1358Denjin Makai seems to rely on a byteswapped mirror to write the palette.
1359Various other ports go through the COP area, and get mapped to inputs / sounds / video registers, this adds to
1360the confusion and makes it less clear what is / isn't protection related
1361
1362=================================================================================================================
1363Seibu COP memory map
1364
1365DMA mode partial documentation:
13660x476
1367???? ???? ???? ???? SRC table value used for palette DMAs, val << 10
1368
13690x478
1370xxxx xxxx xxxx xxxx SRC address register, val << 6
1371
13720x47a
1373xxxx xxxx xxxx xxxx length register, val << 5
1374
13750x47c
1376xxxx xxxx xxxx xxxx DST address register, val << 6
1377
13780x47e
1379---- ---x ---x ---- DMA mode (00: DMA, work RAM to work RAM 01: DMA, work RAM to private buffers / 10 <unknown> / 11: fill work RAM)
1380---- ---- x--- ---- palette DMA mode (used for brightness effects)
1381---- ---- ---- x--- Transfer type (0: word 1:dword)
1382---- ---- ---- -xxx Channel #
1383
1384- channels 0x4 and 0x5 are always used to transfer respectively the VRAM and the palette data to the private buffers.
1385  It isn't know at current stage if it's just a design choice or they are dedicated DMAs.
1386
1387- Some games (Heated Barrel start-up menu, Olympic Soccer '92 OBJ test) sets up the layer clearance in the midst of the
1388  frame interval. It might indicate that it delays those DMAs inside the buffers at vblank time.
1389
1390- Raiden 2 / Raiden DX sets 0x14 with DST = 0xfffe and size as a sprite limit behaviour. The former is probably used to change the
1391  order of the loaded tables (they are the only known cases where spriteram is smallest address-wise).
1392
1393- Reading here is probably used for DMA status of the individual channels or just for read-back of the register, but nothing seems to rely
1394  on it so far so nothing is really known about it.
1395
13960x6fc
1397???? ???? ???? ???? triggers DMA loaded in registers, value looks meaningless
1398
1399Miscellaneous registers:
14000x470
1401???? ???? ???? ???? External pin register, used by some games for prg/gfx banking (per-game specific)
1402
1403
1404---
1405
1406commands 0x8100/0x8900:
1407
1408status always 0x8007 (doesn't seem to care)
1409raw | amp | scale | sin       | cos      |
1410------------------------------------------
1411y     0x00     x    0x00000000 0x00000000 (i.e. if amp is 0 then sin/cos are zero too)
14120     0x40     0    0x00000000 0x00020000
14130     0x40     1    0x00000000 0x00040000
14140     0x40     2    0x00000000 0x00080000
14150     0x40     3    0x00000000 0x00100000
14160x40  0x40     0    0x00020000 0x00000000
14170x40  0x40     1    0x00040000 0x00000000
14180x40  0x40     2    0x00080000 0x00000000
14190x40  0x40     3    0x00100000 0x00000000
14200x80  0x40     0    0x00000000 0xfffc0000
14210x80  0x40     1    0x00000000 0xfff80000
14220x80  0x40     2    0x00000000 0xfff00000
14230x80  0x40     3    0x00000000 0xffe00000
14240xc0  0x40     0    0xfffc0000 0x00000000
14250xc0  0x40     1    0xfff80000 0x00000000
14260xc0  0x40     2    0xfff00000 0x00000000
14270xc0  0x40     3    0xffe00000 0x00000000
14280     0x80     0    0x00000000 0x00040000
14290     0x80     1    0x00000000 0x00080000
14300     0x80     2    0x00000000 0x00100000
14310     0x80     3    0x00000000 0x00200000
14320x40  0x80     0    0x00040000 0x00000000
14330x40  0x80     1    0x00080000 0x00000000
14340x40  0x80     2    0x00100000 0x00000000
14350x40  0x80     3    0x00200000 0x00000000
14360x80  0x80     0    0x00000000 0xfff80000
14370x80  0x80     1    0x00000000 0xfff00000
14380x80  0x80     2    0x00000000 0xffe00000
14390x80  0x80     3    0x00000000 0xffc00000
14400xc0  0x80     0    0xfff80000 0x00000000
14410xc0  0x80     1    0xfff00000 0x00000000
14420xc0  0x80     2    0xffe00000 0x00000000
14430xc0  0x80     3    0xffc00000 0x00000000
14440     0xc0     0    0x00000000 0x00060000
14450     0xc0     1    0x00000000 0x000c0000
14460     0xc0     2    0x00000000 0x00180000
14470     0xc0     3    0x00000000 0x00300000
14480x40  0xc0     0    0x00060000 0x00000000
14490x40  0xc0     1    0x000c0000 0x00000000
14500x40  0xc0     2    0x00180000 0x00000000
14510x40  0xc0     3    0x00300000 0x00000000
14520x80  0xc0     0    0x00000000 0xfff40000
14530x80  0xc0     1    0x00000000 0xffe80000
14540x80  0xc0     2    0x00000000 0xffd00000
14550x80  0xc0     3    0x00000000 0xffa00000
14560xc0  0xc0     0    0xfff40000 0x00000000
14570xc0  0xc0     1    0xffe80000 0x00000000
14580xc0  0xc0     2    0xffd00000 0x00000000
14590xc0  0xc0     3    0xffa00000 0x00000000
1460
1461commands 0x130e/0x138e: (dx dy 2 fixed point 0x80)
1462dx     dy      angle
1463---------------------
14640x00   0x00    0x20
14650x20   0x00    0x25 (0x26 in test)
14660x40   0x00    0x2d (0x2b in test)
14670x60   0x00    0x36
14680x80   0x00    0x00 cop status 0x8007
14690xa0   0x00    0x4a
14700xc0   0x00    0x53
14710xe0   0x00    0x5b (0x5a)
14720x100  0x00    0x60
14730x120  0x00    0x65
14740x140  0x00    0x69 (0x68)
14750x160  0x00    0x6b
14760x180  0x00    0x6e (0x6d)
14770x1a0  0x00    0x6f
14780x1c0  0x00    0x71
14790x1e0  0x00    0x72
1480
1481
1482command 0x3bb0
1483dx    dy   | dist
1484-----------|-----
14850x00  0x00 | 0xb5
14860x20  0x00 | 0xa0
14870x40  0x00 | 0x8f
14880x60  0x00 | 0x83
14890x80  0x00 | 0x80
14900xa0  0x00 | 0x83
14910xc0  0x00 | 0x8f
14920xe0  0x00 | 0xa0
1493
1494command 0x42c2
1495dx    dy   | stat   dist angle scale  r34(r) r36     r38*  r3a
1496-----------|-----------------------------------------------------
14970x00  0x00 | 0x0067 0x20 0x20  0x0000 0x0001 0x0020  0xb5 0x16a0
14980x20  0x00 | 0x0027 0x20 0x26  0x0000 0x0001 0x0026  0xa0 0x1400
14990x40  0x00 | 0x0067 0x20 0x2d  0x0000 0x0001 0x002d  0x8f 0x11e3
15000x60  0x00 | 0x0067 0x20 0x36  0x0000 0x0001 0x0036  0x83 0x107e
15010x80  0x00 | 0x0027 0x20 0x00  0x0000 0x0001 0x0000  0x80 0x1000
15020xa0  0x00 | 0x0067 0x20 0x4a  0x0000 0x0001 0x004a  0x83 0x107e
15030xc0  0x00 | 0x0067 0x20 0x53  0x0000 0x0001 0x0053  0x8f 0x11e3
15040xe0  0x00 | 0x0027 0x20 0x5a  0x0000 0x0001 0x005a  0xa0 0x1400
1505
15060x00  0x00 | ****** 0x10 0x20  0x0000 0x0002 0x0020  0xb5 0x0b50
15070x20  0x00 | ****** 0x10 0x26  0x0000 0x0002 0x0026  0xa0 0x0a00
15080x40  0x00 | ****** 0x10 0x2d  0x0000 0x0002 0x002d  0x8f 0x08f1
15090x60  0x00 | ****** 0x10 0x36  0x0000 0x0002 0x0036  0x83 0x083f
15100x80  0x00 | ****** 0x10 0x00  0x0000 0x0002 0x0000  0x80 0x0800
15110xa0  0x00 | ****** 0x10 0x4a  0x0000 0x0002 0x004a  0x83 0x083f
15120xc0  0x00 | ****** 0x10 0x53  0x0000 0x0002 0x0053  0x8f 0x08f1
15130xe0  0x00 | ****** 0x10 0x5a  0x0000 0x0002 0x005a  0xa0 0x0a00
1514
15150x00  0x00 | ****** 0x08 0x20  0x0000 0x0004 0x0020  0xb5 0x05a8
15160x20  0x00 | ****** 0x08 0x26  0x0000 0x0004 0x0026  0xa0 0x0500
1517
15180x20  0x00 | ****** 0x02 0x26  0x0000 0x0010 0x0026  0xa0 0x0140
1519
15200xc0  0x00 | 0x0047 0x01 0x53  0x0000 0x0020 0x0053  0x8f 0x008f
1521
15220x60  0x00 | 0x0047 0x00 0x36  0x0000 0x0040 0x0036  0x83 0x0041
1523
15240x40  0x00 | 0x0047 0x00 0x2d  0x0000 0x0080 0x002d  0x8f 0x0023
1525
15260x40  0x00 | 0x8007 0x00 0x2d  0x0000 0x0400 0x008f  0x8f 0x0000
1527
15280x00  0x00 | 0x0067 0x10 0x2d  0x0000 0x0001 0x0020  0xb5 0x0b50
1529
1530*same as 0x3bb0
1531
1532command 0x6200
1533raw angle|angle compare|angle mod value| res |
1534---------|-------------|---------------|-----|
15350x00      ****          0x00            0x00
15360x00      0x00          0x20            0x00
15370x00      0x20          0x20            0x20
15380x00      0x40          0x20            0x20
15390x00      0x60          0x20            0x20
15400x00      0x80          0x20            0xe0
15410x00      0xa0          0x20            0xe0
15420x00      0xc0          0x20            0xe0
15430x00      0xe0          0x20            0xe0
15440x00      0x00          0x40            0x00
15450x00      0x20          0x40            0x20
15460x00      0x40          0x40            0x40
15470x00      0x60          0x40            0x40
15480x00      0x80          0x40            0xc0
15490x00      0xa0          0x40            0xc0
15500x00      0xc0          0x40            0xc0
15510x00      0xe0          0x40            0xe0
15520x00      0x00          0x60            0x00
15530x00      0x20          0x60            0x20
15540x00      0x40          0x60            0x60 *
15550x00      0x60          0x60            0x60
15560x00      0x80          0x60            0xa0
15570x00      0xa0          0x60            0xa0
15580x00      0xc0          0x60            0xc0
15590x00      0xe0          0x60            0xe0
15600x00      0x00          0x80            0x00
15610x00      0x20          0x80            0x80 *
15620x00      0x40          0x80            0x80 *
15630x00      0x60          0x80            0x80 *
15640x00      0x80          0x80            0x80 *
15650x00      0xa0          0x80            0x80
15660x00      0xc0          0x80            0x80
15670x00      0xe0          0x80            0x80
15680x00      0x00          0xa0            0x00
15690x00      0x20          0xa0            0x20
15700x00      0x40          0xa0            0xa0
15710x00      0x60          0xa0            0xa0
15720x00      0x80          0xa0            0x60
15730x00      0xa0          0xa0            0x60
15740x00      0xc0          0xa0            0x60
15750x00      0xe0          0xa0            0xe0
15760x00      0x00          0xc0            0x00
15770x00      0x20          0xc0            0x20
15780x00      0x40          0xc0            0xc0
15790x00      0x60          0xc0            ****
15800x00      0x80          0xc0            0x40
15810x00      0xa0          0xc0            ****
15820x00      0xc0          0xc0            0xc0
15830x00      0xe0          0xc0            0xe0
15840x00      0x00          0xe0            0x00
15850x00      0x20          0xe0            0x20
15860x00      0x40          0xe0            0xe0
15870x00      0x60          0xe0            0xe0
15880x00      0x80          0xe0            0x20
15890x00      0xa0          0xe0            0x20
15900x00      0xc0          0xe0            0xc0
15910x00      0xe0          0xe0            0xe0
1592*/
1593
159416#include "emu.h"
17#include "seicop.h"
159518#include "includes/legionna.h"
1596#include "machine/seicop.h"
159719
159820
1599const device_type SEIBU_COP_LEGACY = &device_creator<seibu_cop_legacy_device>;
21const device_type SEIBU_COP_BOOTLEG = &device_creator<seibu_cop_bootleg_device>;
160022
1601seibu_cop_legacy_device::seibu_cop_legacy_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
1602   : device_t(mconfig, SEIBU_COP_LEGACY, "Seibu COP Legacy", tag, owner, clock, "seibu_cop_legacy", __FILE__),
23seibu_cop_bootleg_device::seibu_cop_bootleg_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
24   : device_t(mconfig, SEIBU_COP_BOOTLEG, "Seibu COP Bootleg", tag, owner, clock, "seibu_cop_boot", __FILE__),
160325   m_cop_mcu_ram(NULL),
1604   m_cop_hit_val_x(0),
1605   m_cop_hit_val_y(0),
1606   m_cop_hit_val_z(0),
1607   m_legacycop_angle_compare(0),
1608   m_legacycop_angle_mod_val(0),
1609   m_r0(0),
1610   m_r1(0),
1611   m_cop_rom_addr_lo(0),
1612   m_cop_rom_addr_hi(0),
1613   m_cop_rom_addr_unk(0),
1614   m_cop_sprite_dma_abs_x(0),
1615   m_cop_sprite_dma_abs_y(0),
161626   m_raiden2cop(*this, ":raiden2cop")
161727{
161828
r32338r32339
162737//  complete
162838//-------------------------------------------------
162939
1630void seibu_cop_legacy_device::device_config_complete()
40void seibu_cop_bootleg_device::device_config_complete()
163141{
163242}
163343
r32338r32339
163545//  device_start - device-specific startup
163646//-------------------------------------------------
163747
1638void seibu_cop_legacy_device::device_start()
48void seibu_cop_bootleg_device::device_start()
163949{
164050   m_cop_mcu_ram = reinterpret_cast<UINT16 *>(machine().root_device().memshare("cop_mcu_ram")->ptr());
164151
1642
1643   save_item(NAME(m_cop_hit_val_x));
1644   save_item(NAME(m_cop_hit_val_y));
1645   save_item(NAME(m_cop_hit_val_z));
1646   save_item(NAME(m_legacycop_angle_compare));
1647   save_item(NAME(m_legacycop_angle_mod_val));
1648   save_item(NAME(m_r0));
1649   save_item(NAME(m_r1));
1650   save_item(NAME(m_cop_rom_addr_lo));
1651   save_item(NAME(m_cop_rom_addr_hi));
1652   save_item(NAME(m_cop_rom_addr_unk));
1653   save_item(NAME(m_cop_sprite_dma_abs_x));
1654   save_item(NAME(m_cop_sprite_dma_abs_y));
165552}
165653
165754//-------------------------------------------------
1658//  device_
1659//  device-specific startup
55//  device_reset
166056//-------------------------------------------------
166157
1662void seibu_cop_legacy_device::device_reset()
58void seibu_cop_bootleg_device::device_reset()
166359{
166460}
166561
166662
166763
1668/*
1669"The area of ASM snippets"
1670
1671player-1 priorities list:
16721086d8: show this sprite (bit 15)
16731086dc: lives (BCD,bits 3,2,1,0)
16741086de: energy bar (upper byte)
16751086e0: walk animation (lower byte)
16761086ec: "death" status (bit 15)
16771086f4: sprite y axis
16781086f0: sprite x axis
1679
1680Sprite DMA TODO:
1681- various bits not yet understood in the sprite src tables and in the 0x400/0x402 sprite param;
1682
1683spriteram DMA [1]
1684001DE4: 3086                     move.w  D6, (A0) ;$100400,color + other stuff
1685001DE6: 2440                     movea.l D0, A2
1686001DE8: 0269 0004 0002           andi.w  #$4, ($2,A1)
1687001DEE: 3152 000C                move.w  (A2), ($c,A0) ;DMA size
1688001DF2: 3145 0002                move.w  D5, ($2,A0)
1689001DF6: 0245 0040                andi.w  #$40, D5
1690001DFA: 2009                     move.l  A1, D0
1691001DFC: 3140 00C0                move.w  D0, ($c0,A0) ;RAM -> $1004c0 (work ram index?)
1692001E00: 4840                     swap    D0
1693001E02: 3140 00A0                move.w  D0, ($a0,A0) ;RAM -> $1004a0
1694001E06: 200A                     move.l  A2, D0
1695001E08: 3140 0014                move.w  D0, ($14,A0) ;$ROM lo -> $100414 src
1696001E0C: 4840                     swap    D0
1697001E0E: 3140 0012                move.w  D0, ($12,A0) ;$ROM hi -> $100412
1698001E12: 2679 0010 8116           movea.l $108116.l, A3 ;points to dst spriteram
1699001E18: 3839 0010 810A           move.w  $10810a.l, D4 ;spriteram index
1700001E1E: 260B                     move.l  A3, D3
1701001E20: 3143 00C8                move.w  D3, ($c8,A0) ;sets the dst spriteram
1702001E24: 4843                     swap    D3
1703001E26: 3143 00A8                move.w  D3, ($a8,A0)
1704001E2A: 45EA 0004                lea     ($4,A2), A2
1705//at this point we're ready for DMAing
1706001E2E: 317C A180 0100           move.w  #$a180, ($100,A0) ;<-get x/y from sprite
1707001E34: 317C 6980 0102           move.w  #$6980, ($102,A0) ;<-adjust sprite x/y
1708001E3A: 317C C480 0102           move.w  #$c480, ($102,A0) ;<-load sprite offset
1709001E40: 317C 0000 0010           move.w  #$0, ($10,A0)     ;<-do the job?
1710001E46: 302A 0002                move.w  ($2,A2), D0
1711001E4A: 816B 0006                or.w    D0, ($6,A3)
1712001E4E: 45EA 0006                lea     ($6,A2), A2
1713001E52: 302B 0008                move.w  ($8,A3), D0
1714001E56: B079 0010 8112           cmp.w   $108112.l, D0
1715001E5C: 6E00 0054                bgt     $1eb2
1716001E60: B079 0010 8110           cmp.w   $108110.l, D0
1717001E66: 6D00 004A                blt     $1eb2
1718001E6A: 026B 7FFF 000A           andi.w  #$7fff, ($a,A3)
1719001E70: 8B6B 0004                or.w    D5, ($4,A3)
1720001E74: 47EB 0008                lea     ($8,A3), A3
1721001E78: 260B                     move.l  A3, D3
1722001E7A: 3143 00C8                move.w  D3, ($c8,A0)
1723001E7E: 4843                     swap    D3
1724001E80: 3143 00A8                move.w  D3, ($a8,A0)
1725001E84: 5244                     addq.w  #1, D4
1726001E86: B879 0010 8114           cmp.w   $108114.l, D4
1727001E8C: 6500 000C                bcs     $1e9a
1728001E90: 0069 0002 0002           ori.w   #$2, ($2,A1)
1729001E96: 6000 000C                bra     $1ea4
1730001E9A: 3028 01B0                move.w  ($1b0,A0), D0 ;bit 1 = DMA job finished
1731001E9E: 0240 0002                andi.w  #$2, D0
1732001EA2: 6790                     beq     $1e34
1733001EA4: 33C4 0010 810A           move.w  D4, $10810a.l
1734001EAA: 23CB 0010 8116           move.l  A3, $108116.l
1735001EB0: 4E75                     rts
1736
1737x/y check [2]
1738002030: E58D                     lsl.l   #2, D5
1739002032: 0685 0003 0000           addi.l  #$30000, D5
1740002038: 33C5 0010 04C4           move.w  D5, $1004c4.l
174100203E: 4845                     swap    D5
1742002040: 33C5 0010 04A4           move.w  D5, $1004a4.l
1743002046: E58E                     lsl.l   #2, D6
1744002048: 0686 0003 0000           addi.l  #$30000, D6
174500204E: 33C6 0010 04C6           move.w  D6, $1004c6.l
1746002054: 4846                     swap    D6
1747002056: 33C6 0010 04A6           move.w  D6, $1004a6.l
174800205C: 33FC A180 0010 0500      move.w  #$a180, $100500.l
1749002064: 33FC B100 0010 0500      move.w  #$b100, $100500.l
175000206C: 33FC A980 0010 0500      move.w  #$a980, $100500.l
1751002074: 33FC B900 0010 0500      move.w  #$b900, $100500.l
175200207C: 4E75                     rts
1753[...]
1754//then reads at $580
1755
1756sine cosine has a weird math problem, it needs that the amp is multiplied by two when the direction is TOTALLY left or TOTALLY up.
1757No known explanation to this so far ...
1758
1759003306: move.w  #$8100, ($100,A0)
176000330C: move.w  #$8900, ($100,A0)
1761003312: cmpi.w  #$80, ($36,A1) ;checks if angle is equal to 0x80 (left direction of objects)
1762003318: bne     $332a
176300331C: move.l  ($14,A1), D0 ;divide by two if so
1764003320: asr.l   #1, D0
1765003322: move.l  D0, ($14,A1)
1766003326: bra     $333e
176700332A: cmpi.w  #$c0, ($36,A1) ;checks if angle is equal to 0xc0 (up direction of objects)
1768003330: bne     $333e
1769003334: move.l  ($10,A1), D0 ;divide by two if so
1770003338: asr.l   #1, D0
177100333A: move.l  D0, ($10,A1)
177200333E: movem.l (A7)+, D0/A0-A1
1773003342: rts
1774
1775*/
1776
1777/********************************************************************************************
1778
1779  COPX bootleg simulation
1780    - Seibu Cup Soccer (bootleg)
1781
1782 *******************************************************************************************/
1783
1784
1785READ16_MEMBER( seibu_cop_legacy_device::copdxbl_0_r )
64READ16_MEMBER( seibu_cop_bootleg_device::copdxbl_0_r )
178665{
178766   UINT16 retvalue = m_cop_mcu_ram[offset];
178867
r32338r32339
180988   }
181089}
181190
1812WRITE16_MEMBER( seibu_cop_legacy_device::copdxbl_0_w )
91WRITE16_MEMBER( seibu_cop_bootleg_device::copdxbl_0_w )
181392{
181493   legionna_state *state = space.machine().driver_data<legionna_state>();
181594   COMBINE_DATA(&m_cop_mcu_ram[offset]);
r32338r32339
1892171                     m_raiden2cop->cop_angle += 0x80;
1893172               }
1894173
1895               m_r0 = dy;
1896               m_r1 = dx;
174               m_raiden2cop->m_LEGACY_r0 = dy;
175               m_raiden2cop->m_LEGACY_r1 = dx;
1897176
1898177               if(m_cop_mcu_ram[offset] & 0x80)
1899178                  space.write_word(m_raiden2cop->cop_regs[0]+(0x34^2), m_raiden2cop->cop_angle);
r32338r32339
1903182            case 0x3b30:
1904183            case 0x3bb0:
1905184            {
1906               int dy = m_r0;
1907               int dx = m_r1;
185               int dy = m_raiden2cop->m_LEGACY_r0;
186               int dx = m_raiden2cop->m_LEGACY_r1;
1908187
1909188               dx >>= 16;
1910189               dy >>= 16;
r32338r32339
1940219   }
1941220}
1942221
1943/* Generic COP functions
1944  -- the game specific handlers fall through to these if there
1945     isn't a specific case for them.  these implement behavior
1946     which seems common to all the games
1947*/
1948222
1949
1950
1951
1952
1953/*
1954_
1955*/
1956
1957/*
1958Godzilla 0x12c0 X = 0x21ed Y = 0x57da
1959Megaron  0x12d0 X = 0x1ef1 Y = 0x55db
1960King Ghidorah 0x12c8 X = 0x26eb Y = 0x55dc
1961Mecha Ghidorah 0x12dc X = 0x24ec Y = 0x55dc
1962Mecha Godzilla 0x12d4 X = 0x1cf1 Y = 0x52dc
1963Gigan 0x12cc X = 0x23e8 Y = 0x55db
1964
1965(DC.W $1020, $F0C0, $0000, $0000)
1966X = collides at the same spot
1967Y = collides between 0xd0 and 0x20
19680x588 bits 2 & 3 = 0
1969(DC.W $F0C0, $1020, $0000, $0000)
1970X = collides between 0xb0 and 0x50 (inclusive)
1971Y = collides between 0xd0 and 0x30 (not inclusive)
19720x588 bits 2 & 3 = 0x580 bits 0 & 1
1973*/
1974void seibu_cop_legacy_device::cop_take_hit_box_params(UINT8 offs)
1975{
1976   INT16 start_x,start_y,height,width;
1977
1978   {
1979      height = UINT8(m_cop_collision_info[offs].hitbox_y >> 8);
1980      start_y = INT8(m_cop_collision_info[offs].hitbox_y);
1981      width = UINT8(m_cop_collision_info[offs].hitbox_x >> 8);
1982      start_x = INT8(m_cop_collision_info[offs].hitbox_x);
1983   }
1984
1985   m_cop_collision_info[offs].min_x = (m_cop_collision_info[offs].x >> 16) + start_x;
1986   m_cop_collision_info[offs].max_x = m_cop_collision_info[offs].min_x + width;
1987   m_cop_collision_info[offs].min_y = (m_cop_collision_info[offs].y >> 16) + start_y;
1988   m_cop_collision_info[offs].max_y = m_cop_collision_info[offs].min_y + height;
1989}
1990
1991
1992UINT8 seibu_cop_legacy_device::cop_calculate_collsion_detection()
1993{
1994   static UINT8 res;
1995
1996   res = 3;
1997
1998   /* outbound X check */
1999   if(m_cop_collision_info[0].max_x >= m_cop_collision_info[1].min_x && m_cop_collision_info[0].min_x <= m_cop_collision_info[1].max_x)
2000      res &= ~2;
2001
2002   if(m_cop_collision_info[1].max_x >= m_cop_collision_info[0].min_x && m_cop_collision_info[1].min_x <= m_cop_collision_info[0].max_x)
2003      res &= ~2;
2004
2005   /* outbound Y check */
2006   if(m_cop_collision_info[0].max_y >= m_cop_collision_info[1].min_y && m_cop_collision_info[0].min_y <= m_cop_collision_info[1].max_y)
2007      res &= ~1;
2008
2009   if(m_cop_collision_info[1].max_y >= m_cop_collision_info[0].min_y && m_cop_collision_info[1].min_y <= m_cop_collision_info[0].max_y)
2010      res &= ~1;
2011
2012   m_cop_hit_val_x = (m_cop_collision_info[0].x - m_cop_collision_info[1].x) >> 16;
2013   m_cop_hit_val_y = (m_cop_collision_info[0].y - m_cop_collision_info[1].y) >> 16;
2014   m_cop_hit_val_z = 1;
2015   m_raiden2cop->cop_hit_val_stat = res; // TODO: there's also bit 2 and 3 triggered in the tests, no known meaning
2016
2017   //popmessage("%d %d %04x %04x %04x %04x",m_cop_hit_val_x,m_cop_hit_val_y,m_cop_collision_info[0].hitbox_x,m_cop_collision_info[0].hitbox_y,m_cop_collision_info[1].hitbox_x,m_cop_collision_info[1].hitbox_y);
2018
2019   //if(res == 0)
2020   //popmessage("0:%08x %08x %08x 1:%08x %08x %08x\n",m_cop_collision_info[0].x,m_cop_collision_info[0].y,m_cop_collision_info[0].hitbox,m_cop_collision_info[1].x,m_cop_collision_info[1].y,m_cop_collision_info[1].hitbox);
2021//  popmessage("0:%08x %08x %08x %08x 1:%08x %08x %08x %08x\n",m_cop_collision_info[0].min_x,m_cop_collision_info[0].max_x,m_cop_collision_info[0].min_y, m_cop_collision_info[0].max_y,
2022//                                                   m_cop_collision_info[1].min_x,m_cop_collision_info[1].max_x,m_cop_collision_info[1].min_y, m_cop_collision_info[1].max_y);
2023
2024   return res;
2025}
2026
2027READ16_MEMBER( seibu_cop_legacy_device::generic_cop_r )
2028{
2029   UINT16 retvalue;
2030   retvalue = m_cop_mcu_ram[offset];
2031
2032
2033   switch (offset)
2034   {
2035
2036      /* these two controls facing direction in Godzilla opponents (only vs.) - x value compare? */
2037      case 0x182/2:
2038         return (m_cop_hit_val_y);
2039
2040      case 0x184/2:
2041         return (m_cop_hit_val_x);
2042
2043      /* Legionnaire only - z value compare? */
2044      case 0x186/2:
2045         return (m_cop_hit_val_z);
2046
2047
2048
2049
2050
2051      default:
2052         seibu_cop_log("%06x: COPX unhandled read returning %04x from offset %04x\n", space.device().safe_pc(), retvalue, offset*2);
2053         return retvalue;
2054   }
2055}
2056
2057WRITE16_MEMBER( seibu_cop_legacy_device::generic_cop_w )
2058{
2059   COMBINE_DATA(&m_cop_mcu_ram[offset]);
2060
2061   switch (offset)
2062   {
2063      default:
2064         seibu_cop_log("%06x: COPX unhandled write data %04x at offset %04x\n", space.device().safe_pc(), data, offset*2);
2065         break;
2066
2067
2068
2069   
2070
2071
2072
2073      /* triggered before 0x6200 in Seibu Cup, looks like an angle value ... */
2074      case (0x01c/2): m_legacycop_angle_compare = UINT16(m_cop_mcu_ram[0x1c/2]);  break;
2075      case (0x01e/2): m_legacycop_angle_mod_val = UINT16(m_cop_mcu_ram[0x1e/2]); break;
2076
2077
2078
2079
2080         
2081         
2082
2083     
2084      case (0x03e/2):
2085         /*
2086         0 in all 68k based games
2087         0xffff in raiden2 / raidendx
2088         0x2000 in zeroteam / xsedae
2089         it's always setted up just before the 0x474 register
2090         */
2091         break;
2092
2093      case (0x046/2): { m_cop_rom_addr_unk = data & 0xffff; break; }
2094      case (0x048/2): { m_cop_rom_addr_lo = data & 0xffff; break; }
2095      case (0x04a/2): { m_cop_rom_addr_hi = data & 0xffff; break; }
2096
2097   
2098      /* DMA / layer clearing section */
2099      case (0x074/2):
2100         /*
2101         This sets up a DMA mode of some sort
2102             0x0e00: grainbow, cupsoc
2103             0x0a00: legionna, godzilla, denjinmk
2104             0x0600: heatbrl
2105             0x1e00: zeroteam, xsedae
2106         raiden2 and raidendx doesn't set this up, this could indicate that this is related to the non-private buffer DMAs
2107         (both only uses 0x14 and 0x15 as DMAs)
2108         */
2109         break;
2110
2111     
2112
2113
2114
2115
2116
2117
2118
2119
2120      case (0x08c/2): m_cop_sprite_dma_abs_y = (m_cop_mcu_ram[0x08c/2]); break;
2121      case (0x08e/2): m_cop_sprite_dma_abs_x = (m_cop_mcu_ram[0x08e/2]); break;
2122
2123   
2124
2125      case (0x100/2):
2126      case (0x102/2):
2127      case (0x104/2):
2128      {
2129         int command;
2130
2131
2132         logerror("%06x: COPX execute table macro command %04x %04x | regs %08x %08x %08x %08x %08x\n", space.device().safe_pc(), data, m_cop_mcu_ram[offset], m_raiden2cop->cop_regs[0], m_raiden2cop->cop_regs[1], m_raiden2cop->cop_regs[2], m_raiden2cop->cop_regs[3], m_raiden2cop->cop_regs[4]);
2133
2134
2135         command = m_raiden2cop->find_trigger_match(m_cop_mcu_ram[offset], 0xff00);
2136
2137
2138         if (command==-1)
2139         {
2140            return;
2141         }
2142         UINT16 funcval,funcmask;
2143         // this is pointless.. all we use it for is comparing against the same value
2144         funcval = m_raiden2cop->get_func_value(command);
2145         funcmask = m_raiden2cop->get_func_mask(command);
2146         //printf("%04x %04x %04x\n",m_cop_mcu_ram[offset],funcval,funcmask);
2147
2148         /*
2149         Macro notes:
2150         - endianess changes from/to Raiden 2:
2151           dword ^= 0
2152           word ^= 2
2153           byte ^= 3
2154         - some macro commands here have a commented algorithm, it's how Seibu Cup Bootleg version handles maths inside the 14/15 roms.
2155           The ROMs map tables in the following arrangement:
2156           0x00000 - 0x1ffff Sine math results
2157           0x20000 - 0x3ffff Cosine math results
2158           0x40000 - 0x7ffff Division math results
2159           0x80000 - 0xfffff Pythagorean theorem, hypotenuse length math results
2160           Surprisingly atan maths are nowhere to be found from the roms.
2161         */
2162
2163         int executed = 0;
2164
2165         /* "automatic" movement, 0205 */
2166         if(m_raiden2cop->check_command_matches(command, 0x188,0x282,0x082,0xb8e,0x98e,0x000,0x000,0x000,6,0xffeb))
2167         {
2168            executed = 1;
2169            UINT8 offs;
2170
2171            offs = (offset & 3) * 4;
2172            int ppos = space.read_dword(m_raiden2cop->cop_regs[0] + 4 + offs);
2173            int npos = ppos + space.read_dword(m_raiden2cop->cop_regs[0] + 0x10 + offs);
2174            int delta = (npos >> 16) - (ppos >> 16);
2175
2176            space.write_dword(m_raiden2cop->cop_regs[0] + 4 + offs, npos);
2177            space.write_word(m_raiden2cop->cop_regs[0] + 0x1c + offs, space.read_word(m_raiden2cop->cop_regs[0] + 0x1c + offs) + delta);
2178            return;
2179         }
2180
2181         /* "automatic" movement, for arcs in Legionnaire / Zero Team (expression adjustment) 0905 */
2182         if(m_raiden2cop->check_command_matches(command, 0x194,0x288,0x088,0x000,0x000,0x000,0x000,0x000,6,0xfbfb))
2183         {
2184            executed = 1;
2185            UINT8 offs;
2186
2187            offs = (offset & 3) * 4;
2188
2189            /* read 0x28 + offs */
2190            /* add 0x10 + offs */
2191            /* write 0x10 + offs */
2192
2193            space.write_dword(m_raiden2cop->cop_regs[0] + 0x10 + offs, space.read_dword(m_raiden2cop->cop_regs[0] + 0x10 + offs) + space.read_dword(m_raiden2cop->cop_regs[0] + 0x28 + offs));
2194            return;
2195         }
2196
2197         /* SINE math - 0x8100 */
2198         /*
2199              00000-0ffff:
2200                amp = x/256
2201                ang = x & 255
2202                s = sin(ang*2*pi/256)
2203                val = trunc(s*amp)
2204                if(s<0)
2205                  val--
2206                if(s == 192)
2207                  val = -2*amp
2208         */
2209         if(m_raiden2cop->check_command_matches(command, 0xb9a,0xb88,0x888,0x000,0x000,0x000,0x000,0x000,7,0xfdfb))
2210         {
2211            executed = 1;
2212            int raw_angle = (space.read_word(m_raiden2cop->cop_regs[0]+(0x34^2)) & 0xff);
2213            double angle = raw_angle * M_PI / 128;
2214            double amp = (65536 >> 5)*(space.read_word(m_raiden2cop->cop_regs[0]+(0x36^2)) & 0xff);
2215            int res;
2216
2217            /* TODO: up direction, why? */
2218            if(raw_angle == 0xc0)
2219               amp*=2;
2220
2221            res = int(amp*sin(angle)) << m_raiden2cop->cop_scale;
2222
2223            space.write_dword(m_raiden2cop->cop_regs[0] + 0x10, res);
2224            return;
2225         }
2226
2227         /* COSINE math - 0x8900 */
2228         /*
2229          10000-1ffff:
2230            amp = x/256
2231            ang = x & 255
2232            s = cos(ang*2*pi/256)
2233            val = trunc(s*amp)
2234            if(s<0)
2235              val--
2236            if(s == 128)
2237              val = -2*amp
2238         */
2239         if(m_raiden2cop->check_command_matches(command, 0xb9a,0xb8a,0x88a,0x000,0x000,0x000,0x000,0x000,7,0xfdfb))
2240         {
2241            executed = 1;
2242            int raw_angle = (space.read_word(m_raiden2cop->cop_regs[0]+(0x34^2)) & 0xff);
2243            double angle = raw_angle * M_PI / 128;
2244            double amp = (65536 >> 5)*(space.read_word(m_raiden2cop->cop_regs[0]+(0x36^2)) & 0xff);
2245            int res;
2246
2247            /* TODO: left direction, why? */
2248            if(raw_angle == 0x80)
2249               amp*=2;
2250
2251            res = int(amp*cos(angle)) << m_raiden2cop->cop_scale;
2252
2253            space.write_dword(m_raiden2cop->cop_regs[0] + 20, res);
2254            return;
2255         }
2256
2257         /* 0x130e / 0x138e */
2258         if(m_raiden2cop->check_command_matches(command, 0x984,0xaa4,0xd82,0xaa2,0x39b,0xb9a,0xb9a,0xa9a,5,0xbf7f))
2259         {
2260            executed = 1;
2261            int dy = space.read_dword(m_raiden2cop->cop_regs[1]+4) - space.read_dword(m_raiden2cop->cop_regs[0]+4);
2262            int dx = space.read_dword(m_raiden2cop->cop_regs[1]+8) - space.read_dword(m_raiden2cop->cop_regs[0]+8);
2263
2264            m_raiden2cop->cop_status = 7;
2265            if(!dx) {
2266               m_raiden2cop->cop_status |= 0x8000;
2267               m_raiden2cop->cop_angle = 0;
2268            } else {
2269               m_raiden2cop->cop_angle = atan(double(dy)/double(dx)) * 128.0 / M_PI;
2270               if(dx<0)
2271                  m_raiden2cop->cop_angle += 0x80;
2272            }
2273
2274            m_r0 = dy;
2275            m_r1 = dx;
2276
2277            //printf("%d %d %f %04x\n",dx,dy,atan(double(dy)/double(dx)) * 128 / M_PI,m_raiden2cop->cop_angle);
2278
2279            if(m_cop_mcu_ram[offset] & 0x80)
2280               space.write_word(m_raiden2cop->cop_regs[0]+(0x34^2), m_raiden2cop->cop_angle);
2281            return;
2282         }
2283
2284         /* Pythagorean theorem, hypotenuse direction - 130e / 138e */
2285         //(heatbrl)  | 5 | bf7f | 138e | 984 aa4 d82 aa2 39b b9a b9a b9a
2286         if(m_raiden2cop->check_command_matches(command, 0x984,0xaa4,0xd82,0xaa2,0x39b,0xb9a,0xb9a,0xb9a,5,0xbf7f))
2287         {
2288            executed = 1;
2289            int dy = space.read_dword(m_raiden2cop->cop_regs[1]+4) - space.read_dword(m_raiden2cop->cop_regs[0]+4);
2290            int dx = space.read_dword(m_raiden2cop->cop_regs[1]+8) - space.read_dword(m_raiden2cop->cop_regs[0]+8);
2291
2292            m_raiden2cop->cop_status = 7;
2293            if(!dx) {
2294               m_raiden2cop->cop_status |= 0x8000;
2295               m_raiden2cop->cop_angle = 0;
2296            } else {
2297               m_raiden2cop->cop_angle = atan(double(dy)/double(dx)) * 128.0 / M_PI;
2298               if(dx<0)
2299                  m_raiden2cop->cop_angle += 0x80;
2300            }
2301
2302            m_raiden2cop->cop_angle-=0x80;
2303            m_r0 = dy;
2304            m_r1 = dx;
2305
2306            if(m_cop_mcu_ram[offset] & 0x80)
2307               space.write_word(m_raiden2cop->cop_regs[0]+(0x34^2), m_raiden2cop->cop_angle);
2308            return;
2309         }
2310
2311         /* Pythagorean theorem, hypotenuse length - 0x3bb0 */
2312         //(grainbow) | 4 | 007f | 3bb0 | f9c b9c b9c b9c b9c b9c b9c 99c
2313         /*
2314          40000-7ffff:
2315            v1 = (x / 32768)*64
2316            v2 = (x & 255)*32767/255
2317            val = sqrt(v1*v1+v2*v2) (unsigned)
2318         */
2319         if(m_raiden2cop->check_command_matches(command, 0xf9c,0xb9c,0xb9c,0xb9c,0xb9c,0xb9c,0xb9c,0x99c,4,0x007f))
2320         {
2321            executed = 1;
2322            int dy = m_r0;
2323            int dx = m_r1;
2324
2325            dx >>= 16;
2326            dy >>= 16;
2327            m_raiden2cop->cop_dist = sqrt((double)(dx*dx+dy*dy));
2328
2329            if(m_cop_mcu_ram[offset] & 0x80)
2330               space.write_word(m_raiden2cop->cop_regs[0]+(0x38), m_raiden2cop->cop_dist);
2331            return;
2332         }
2333
2334         /* Division - 0x42c2 */
2335         /*
2336          20000-2ffff:
2337            v1 = x / 1024
2338            v2 = x & 1023
2339            val = !v1 ? 32767 : trunc(v2/v1+0.5)
2340          30000-3ffff:
2341            v1 = x / 1024
2342            v2 = (x & 1023)*32
2343            val = !v1 ? 32767 : trunc(v2/v1+0.5)
2344         */
2345         if(m_raiden2cop->check_command_matches(command, 0xf9a,0xb9a,0xb9c,0xb9c,0xb9c,0x29c,0x000,0x000,5,0xfcdd))
2346         {
2347            executed = 1;
2348            int dy = m_r0;
2349            int dx = m_r1;
2350            int div = space.read_word(m_raiden2cop->cop_regs[0]+(0x36^2));
2351            int res;
2352            int cop_dist_raw;
2353
2354            if(!div)
2355            {
2356               printf("divide by zero?\n");
2357               div = 1;
2358            }
2359
2360            /* TODO: calculation of this one should occur at 0x3b30/0x3bb0 I *think* */
2361            /* TODO: recheck if m_raiden2cop->cop_scale still masks at 3 with this command */
2362            dx >>= 11 + m_raiden2cop->cop_scale;
2363            dy >>= 11 + m_raiden2cop->cop_scale;
2364            cop_dist_raw = sqrt((double)(dx*dx+dy*dy));
2365
2366            res = cop_dist_raw;
2367            res /= div;
2368
2369            m_raiden2cop->cop_dist = (1 << (5 - m_raiden2cop->cop_scale)) / div;
2370
2371            /* TODO: bits 5-6-15 */
2372            m_raiden2cop->cop_status = 7;
2373
2374            space.write_word(m_raiden2cop->cop_regs[0]+(0x38^2), res);
2375            return;
2376         }
2377
2378         /*
2379             collision detection:
2380
2381             int dy_0 = space.read_dword(m_raiden2cop->cop_regs[0]+4);
2382             int dx_0 = space.read_dword(m_raiden2cop->cop_regs[0]+8);
2383             int dy_1 = space.read_dword(m_raiden2cop->cop_regs[1]+4);
2384             int dx_1 = space.read_dword(m_raiden2cop->cop_regs[1]+8);
2385             int hitbox_param1 = space.read_dword(m_raiden2cop->cop_regs[2]);
2386             int hitbox_param2 = space.read_dword(m_raiden2cop->cop_regs[3]);
2387
2388             TODO: we are ignoring the funcval / funcmask params for now
2389         */
2390
2391         if(m_raiden2cop->check_command_matches(command, 0xb80,0xb82,0xb84,0xb86,0x000,0x000,0x000,0x000,funcval,funcmask))
2392         {
2393            executed = 1;
2394            m_cop_collision_info[0].y = (space.read_dword(m_raiden2cop->cop_regs[0]+4));
2395            m_cop_collision_info[0].x = (space.read_dword(m_raiden2cop->cop_regs[0]+8));
2396            return;
2397         }
2398
2399         //(heatbrl)  | 9 | ffff | b080 | b40 bc0 bc2
2400         if(m_raiden2cop->check_command_matches(command, 0xb40,0xbc0,0xbc2,0x000,0x000,0x000,0x000,0x000,funcval,funcmask))
2401         {
2402            executed = 1;
2403            m_cop_collision_info[0].hitbox = space.read_word(m_raiden2cop->cop_regs[2]);
2404            m_cop_collision_info[0].hitbox_y = space.read_word((m_raiden2cop->cop_regs[2]&0xffff0000)|(m_cop_collision_info[0].hitbox));
2405            m_cop_collision_info[0].hitbox_x = space.read_word(((m_raiden2cop->cop_regs[2]&0xffff0000)|(m_cop_collision_info[0].hitbox))+2);
2406
2407            /* do the math */
2408            cop_take_hit_box_params(0);
2409            m_raiden2cop->cop_hit_status = cop_calculate_collsion_detection();
2410
2411            return;
2412         }
2413
2414         if(m_raiden2cop->check_command_matches(command, 0xba0,0xba2,0xba4,0xba6,0x000,0x000,0x000,0x000,funcval,funcmask))
2415         {
2416            executed = 1;
2417            m_cop_collision_info[1].y = (space.read_dword(m_raiden2cop->cop_regs[1]+4));
2418            m_cop_collision_info[1].x = (space.read_dword(m_raiden2cop->cop_regs[1]+8));
2419            return;
2420         }
2421
2422         //(heatbrl)  | 6 | ffff | b880 | b60 be0 be2
2423         if(m_raiden2cop->check_command_matches(command, 0xb60,0xbe0,0xbe2,0x000,0x000,0x000,0x000,0x000,funcval,funcmask))
2424         {
2425            executed = 1;
2426            m_cop_collision_info[1].hitbox = space.read_word(m_raiden2cop->cop_regs[3]);
2427            m_cop_collision_info[1].hitbox_y = space.read_word((m_raiden2cop->cop_regs[3]&0xffff0000)|(m_cop_collision_info[1].hitbox));
2428            m_cop_collision_info[1].hitbox_x = space.read_word(((m_raiden2cop->cop_regs[3]&0xffff0000)|(m_cop_collision_info[1].hitbox))+2);
2429
2430            /* do the math */
2431            cop_take_hit_box_params(1);
2432            m_raiden2cop->cop_hit_status = cop_calculate_collsion_detection();
2433            return;
2434         }
2435
2436         // grainbow 0d | a | fff3 | 6980 | b80 ba0
2437         if(m_raiden2cop->check_command_matches(command, 0xb80,0xba0,0x000,0x000,0x000,0x000,0x000,0x000,10,0xfff3))
2438         {
2439            executed = 1;
2440            UINT8 offs;
2441            int abs_x,abs_y,rel_xy;
2442
2443            offs = (offset & 3) * 4;
2444
2445            /* TODO: I really suspect that following two are actually taken from the 0xa180 macro command then internally loaded */
2446            abs_x = space.read_word(m_raiden2cop->cop_regs[0] + 8) - m_cop_sprite_dma_abs_x;
2447            abs_y = space.read_word(m_raiden2cop->cop_regs[0] + 4) - m_cop_sprite_dma_abs_y;
2448            rel_xy = space.read_word(m_raiden2cop->m_cop_sprite_dma_src + 4 + offs);
2449
2450            //if(rel_xy & 0x0706)
2451            //  printf("sprite rel_xy = %04x\n",rel_xy);
2452
2453            if(rel_xy & 1)
2454               space.write_word(m_raiden2cop->cop_regs[4] + offs + 4,0xc0 + abs_x - (rel_xy & 0xf8));
2455            else
2456               space.write_word(m_raiden2cop->cop_regs[4] + offs + 4,(((rel_xy & 0x78) + (abs_x) - ((rel_xy & 0x80) ? 0x80 : 0))));
2457
2458            space.write_word(m_raiden2cop->cop_regs[4] + offs + 6,(((rel_xy & 0x7800) >> 8) + (abs_y) - ((rel_xy & 0x8000) ? 0x80 : 0)));
2459            return;
2460         }
2461
2462         // grainbow 18 | a | ff00 | c480 | 080 882
2463         if(m_raiden2cop->check_command_matches(command, 0x080,0x882,0x000,0x000,0x000,0x000,0x000,0x000,10,0xff00))
2464         {
2465            executed = 1;
2466            UINT8 offs;
2467
2468            offs = (offset & 3) * 4;
2469
2470            space.write_word(m_raiden2cop->cop_regs[4] + offs + 0,space.read_word(m_raiden2cop->m_cop_sprite_dma_src + offs) + (m_raiden2cop->m_cop_sprite_dma_param & 0x3f));
2471            //space.write_word(m_raiden2cop->cop_regs[4] + offs + 2,space.read_word(m_raiden2cop->m_cop_sprite_dma_src+2 + offs));
2472            return;
2473         }
2474
2475         // cupsoc 1b | 5 | 7ff7 | dde5 | f80 aa2 984 0c2
2476         /* radar x/y positions */
2477         /* FIXME: x/ys are offsetted */
2478         /* FIXME: uses 0x10044a for something */
2479         if(m_raiden2cop->check_command_matches(command, 0xf80,0xaa2,0x984,0x0c2,0x000,0x000,0x000,0x000,5,0x7ff7))
2480         {
2481            executed = 1;
2482            UINT8 offs;
2483            int div;
2484            INT16 dir_offset;
2485//              INT16 offs_val;
2486
2487            /* TODO: [4-7] could be mirrors of [0-3] (this is the only command so far that uses 4-7 actually)*/
2488            /* ? 0 + [4] */
2489            /* sub32 4 + [5] */
2490            /* write16h 8 + [4] */
2491            /* addmem16 4 + [6] */
2492
2493            // these two are obvious ...
2494            // 0xf x 16 = 240
2495            // 0x14 x 16 = 320
2496            // what are these two instead? scale factor? offsets? (edit: offsets to apply from the initial sprite data)
2497            // 0xfc69 ?
2498            // 0x7f4 ?
2499            //printf("%08x %08x %08x %08x %08x %08x %08x\n",m_raiden2cop->cop_regs[0],m_raiden2cop->cop_regs[1],m_raiden2cop->cop_regs[2],m_raiden2cop->cop_regs[3],m_raiden2cop->cop_regs[4],m_raiden2cop->cop_regs[5],m_raiden2cop->cop_regs[6]);
2500
2501            offs = (offset & 3) * 4;
2502
2503            div = space.read_word(m_raiden2cop->cop_regs[4] + offs);
2504            dir_offset = space.read_word(m_raiden2cop->cop_regs[4] + offs + 8);
2505//              offs_val = space.read_word(m_raiden2cop->cop_regs[3] + offs);
2506            //420 / 180 = 500 : 400 = 30 / 50 = 98 / 18
2507           
2508            /* TODO: this probably trips a cop status flag */
2509            if(div == 0) { div = 1; }
2510           
2511           
2512            space.write_word((m_raiden2cop->cop_regs[6] + offs + 4), ((space.read_word(m_raiden2cop->cop_regs[5] + offs + 4) + dir_offset) / div));
2513            return;
2514         }
2515
2516         //(cupsoc)   | 8 | f3e7 | 6200 | 3a0 3a6 380 aa0 2a6
2517         if(m_raiden2cop->check_command_matches(command, 0x3a0,0x3a6,0x380,0xaa0,0x2a6,0x000,0x000,0x000,8,0xf3e7))
2518         {
2519            executed = 1;
2520            UINT8 cur_angle;
2521            UINT16 flags;
2522           
2523            /* 0 [1] */
2524            /* 0xc [1] */
2525            /* 0 [0] */
2526            /* 0 [1] */
2527            /* 0xc [1] */
2528
2529            cur_angle = space.read_byte(m_raiden2cop->cop_regs[1] + (0xc ^ 3));
2530            flags = space.read_word(m_raiden2cop->cop_regs[1]);
2531            //space.write_byte(m_raiden2cop->cop_regs[1] + (0^3),space.read_byte(m_raiden2cop->cop_regs[1] + (0^3)) & 0xfb); //correct?
2532
2533            m_legacycop_angle_compare &= 0xff;
2534            m_legacycop_angle_mod_val &= 0xff;
2535            flags &= ~0x0004;
2536           
2537            int delta = cur_angle - m_legacycop_angle_compare;
2538            if(delta >= 128)
2539               delta -= 256;
2540            else if(delta < -128)
2541               delta += 256;
2542            if(delta < 0)
2543            {
2544               if(delta >= -m_legacycop_angle_mod_val)
2545               {
2546                  cur_angle = m_legacycop_angle_compare;
2547                  flags |= 0x0004;
2548               }
2549               else
2550                  cur_angle += m_legacycop_angle_mod_val;
2551            }
2552            else
2553            {
2554               if(delta <= m_legacycop_angle_mod_val)
2555               {
2556                  cur_angle = m_legacycop_angle_compare;
2557                  flags |= 0x0004;
2558               }
2559               else
2560                  cur_angle -= m_legacycop_angle_mod_val;
2561            }
2562
2563            space.write_byte(m_raiden2cop->cop_regs[1] + (0 ^ 2),flags);
2564            space.write_byte(m_raiden2cop->cop_regs[1] + (0xc ^ 3),cur_angle);
2565            return;
2566         }
2567
2568         //(grainbow) | 8 | f3e7 | 6200 | 380 39a 380 a80 29a
2569         /* search direction, used on SD Gundam homing weapon */
2570         /* FIXME: still doesn't work ... */
2571         if(m_raiden2cop->check_command_matches(command, 0x380,0x39a,0x380,0xa80,0x29a,0x000,0x000,0x000,8,0xf3e7))
2572         {
2573            executed = 1;
2574            UINT8 cur_angle;
2575            UINT16 flags;
2576           
2577            cur_angle = space.read_byte(m_raiden2cop->cop_regs[0] + (0x34 ^ 3));
2578            flags = space.read_word(m_raiden2cop->cop_regs[0] + (0 ^ 2));
2579            //space.write_byte(m_raiden2cop->cop_regs[1] + (0^3),space.read_byte(m_raiden2cop->cop_regs[1] + (0^3)) & 0xfb); //correct?
2580
2581            m_legacycop_angle_compare &= 0xff;
2582            m_legacycop_angle_mod_val &= 0xff;
2583            flags &= ~0x0004;
2584           
2585            int delta = cur_angle - m_legacycop_angle_compare;
2586            if(delta >= 128)
2587               delta -= 256;
2588            else if(delta < -128)
2589               delta += 256;
2590            if(delta < 0)
2591            {
2592               if(delta >= -m_legacycop_angle_mod_val)
2593               {
2594                  cur_angle = m_legacycop_angle_compare;
2595                  flags |= 0x0004;
2596               }
2597               else
2598                  cur_angle += m_legacycop_angle_mod_val;
2599            }
2600            else
2601            {
2602               if(delta <= m_legacycop_angle_mod_val)
2603               {
2604                  cur_angle = m_legacycop_angle_compare;
2605                  flags |= 0x0004;
2606               }
2607               else
2608                  cur_angle -= m_legacycop_angle_mod_val;
2609            }
2610
2611            space.write_byte(m_raiden2cop->cop_regs[0] + (0 ^ 3),flags);
2612            space.write_word(m_raiden2cop->cop_regs[0] + (0x34 ^ 3),cur_angle);
2613            return;
2614         }
2615
2616         //(cupsoc) 1c | 5 | b07f | e38e | 984 ac4 d82 ac2 39b b9a b9a a9a
2617         if(m_raiden2cop->check_command_matches(command, 0x984,0xac4,0xd82,0xac2,0x39b,0xb9a,0xb9a,0xa9a,5,0xb07f))
2618         {
2619            executed = 1;
2620            int dy = space.read_dword(m_raiden2cop->cop_regs[2]+4) - space.read_dword(m_raiden2cop->cop_regs[0]+4);
2621            int dx = space.read_dword(m_raiden2cop->cop_regs[2]+8) - space.read_dword(m_raiden2cop->cop_regs[0]+8);
2622
2623            m_raiden2cop->cop_status = 7;
2624            if(!dx) {
2625               m_raiden2cop->cop_status |= 0x8000;
2626               m_raiden2cop->cop_angle = 0;
2627            } else {
2628               m_raiden2cop->cop_angle = atan(double(dy)/double(dx)) * 128.0 / M_PI;
2629               if(dx<0)
2630                  m_raiden2cop->cop_angle += 0x80;
2631            }
2632
2633            m_r0 = dy;
2634            m_r1 = dx;
2635
2636            //printf("%d %d %f %04x\n",dx,dy,atan(double(dy)/double(dx)) * 128 / M_PI,m_raiden2cop->cop_angle);
2637
2638            if(m_cop_mcu_ram[offset] & 0x80)
2639               space.write_word(m_raiden2cop->cop_regs[0]+(0x34^2), m_raiden2cop->cop_angle);
2640            return;
2641         }
2642
2643         //(cupsoc) 1a | 5 | fffb | d104 | ac2 9e0 0a2
2644         /* controls player vs. player collision detection, 0xf105 controls player vs. ball */
2645         if(m_raiden2cop->check_command_matches(command, 0xac2,0x9e0,0x0a2,0x000,0x000,0x000,0x000,0x000,5,0xfffb))
2646         {
2647            executed = 1;
2648            UINT8 *ROM = space.machine().root_device().memregion("maincpu")->base();
2649            UINT32 rom_addr = (m_cop_rom_addr_hi << 16 | m_cop_rom_addr_lo) & ~1;
2650            UINT16 rom_data = (ROM[rom_addr + 0]) | (ROM[rom_addr + 1]<<8);
2651
2652            /* writes to some unemulated COP registers, then puts the result in here, adding a parameter taken from ROM */
2653            //space.write_word(m_raiden2cop->cop_regs[0]+(0x44 + offset * 4), rom_data);
2654
2655            printf("%04x%04x %04x %04x\n",m_cop_rom_addr_hi,m_cop_rom_addr_lo,m_cop_rom_addr_unk,rom_data);
2656            return;
2657         }
2658
2659         if (executed==0) printf("did not execute %04x\n",m_cop_mcu_ram[offset]);
2660         break;
2661      }
2662
2663
2664
2665
2666
2667   }
2668}
trunk/src/mame/machine/seicop.h
r32338r32339
11
22#include "raiden2cop.h"
33
4struct collision_info
5{
6      collision_info():
7      x(0),
8      y(0),
9      min_x(0),
10      min_y(0),
11      max_x(0),
12      max_y(0),
13      hitbox(0),
14      hitbox_x(0),
15      hitbox_y(0) {}
164
17   int x,y;
18   INT16 min_x,min_y,max_x,max_y;
19   UINT16 hitbox;
20   UINT16 hitbox_x,hitbox_y;
21};
225
23
24class seibu_cop_legacy_device : public device_t
6class seibu_cop_bootleg_device : public device_t
257{
268public:
27seibu_cop_legacy_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
9seibu_cop_bootleg_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
2810
2911   DECLARE_READ16_MEMBER( copdxbl_0_r );
3012   DECLARE_WRITE16_MEMBER( copdxbl_0_w );
31
32   DECLARE_READ16_MEMBER( generic_cop_r );
33   DECLARE_WRITE16_MEMBER( generic_cop_w );
3413protected:
3514   // device-level overrides
3615   virtual void device_config_complete();
r32338r32339
4221
4322
4423
45   INT16 m_cop_hit_val_x,m_cop_hit_val_y,m_cop_hit_val_z;
46   INT8 m_legacycop_angle_compare;
47   INT8 m_legacycop_angle_mod_val;
48   struct collision_info m_cop_collision_info[2];
49   int m_r0, m_r1;
50   UINT16 m_cop_rom_addr_lo,m_cop_rom_addr_hi,m_cop_rom_addr_unk;
5124
52   int m_cop_sprite_dma_abs_x,m_cop_sprite_dma_abs_y;
53
54
55   void cop_take_hit_box_params(UINT8 offs);
56   UINT8 cop_calculate_collsion_detection();
57
58
5925   required_device<raiden2cop_device> m_raiden2cop;
6026
6127};
6228
63extern const device_type SEIBU_COP_LEGACY;
29extern const device_type SEIBU_COP_BOOTLEG;
6430
6531#define MCFG_SEIBU_COP_ADD(_tag) \
66   MCFG_DEVICE_ADD(_tag, SEIBU_COP_LEGACY, 0)
32   MCFG_DEVICE_ADD(_tag, SEIBU_COP_BOOTLEG, 0)
6733

Previous 199869 Revisions Next


© 1997-2024 The MAME Team