Previous 199869 Revisions Next

r32364 Wednesday 24th September, 2014 at 22:10:23 UTC by David Haywood
some code reduction (nw)
[src/mame/machine]raiden2cop.c raiden2cop.h

trunk/src/mame/machine/raiden2cop.c
r32363r32364
178178   else return space.read_word(address);
179179}
180180
181UINT8 raiden2cop_device::cop_read_byte(address_space &space, int address)
182{
183   if (m_cpu_is_68k) return space.read_byte(address ^ 3);
184   else return space.read_byte(address);
185}
186
187
181188/*** Command Table uploads ***/
182189
183190
r32363r32364
783790*/
784791
785792// triggered with 0904 0905
786/* X Se Dae and Zero Team uses this variant */
793
787794void raiden2cop_device::execute_0904(address_space &space, int offset, UINT16 data)
788795{
789   space.write_dword(cop_regs[0] + 16 + offset * 4, space.read_dword(cop_regs[0] + 16 + offset * 4) - space.read_dword(cop_regs[0] + 0x28 + offset * 4));
796   if (data&0x0001)
797      space.write_dword(cop_regs[0] + 16 + offset * 4, space.read_dword(cop_regs[0] + 16 + offset * 4) + space.read_dword(cop_regs[0] + 0x28 + offset * 4));
798   else /* X Se Dae and Zero Team uses this variant */
799      space.write_dword(cop_regs[0] + 16 + offset * 4, space.read_dword(cop_regs[0] + 16 + offset * 4) - space.read_dword(cop_regs[0] + 0x28 + offset * 4));
790800}
791801
792void raiden2cop_device::execute_0905(address_space &space, int offset, UINT16 data)
793{
794   space.write_dword(cop_regs[0] + 16 + offset * 4, space.read_dword(cop_regs[0] + 16 + offset * 4) + space.read_dword(cop_regs[0] + 0x28 + offset * 4));
795}
796802
797void raiden2cop_device::LEGACY_execute_0905(address_space &space, int offset, UINT16 data)
798{
799   UINT8 offs;
800803
801   offs = (offset & 3) * 4;
802804
803   /* read 0x28 + offs */
804   /* add 0x10 + offs */
805   /* write 0x10 + offs */
806
807   space.write_dword(cop_regs[0] + 0x10 + offs, space.read_dword(cop_regs[0] + 0x10 + offs) + space.read_dword(cop_regs[0] + 0x28 + offs));
808
809}
810
811805/*
81280602 - 138e (130e  ) :  (984, aa4, d82, aa2, 39b, b9a, b9a, b9a)  5     bf7f   (heatbrl, legionna)
81380702 - 138e (130e  ) :  (984, aa4, d82, aa2, 39b, b9a, b9a, a9a)  5     bf7f   (cupsoc, godzilla, grainbow, denjinmk)
r32363r32364
10601054*/
10611055void raiden2cop_device::execute_6200(address_space &space, int offset, UINT16 data)
10621056{
1063   UINT8 angle = space.read_byte(cop_regs[0] + 0x34);
1064   UINT16 flags = space.read_word(cop_regs[0]);
1057   UINT8 angle = cop_read_byte(space, cop_regs[0] + 0x34);
1058   UINT16 flags = cop_read_word(space, cop_regs[0]);
10651059   cop_angle_target &= 0xff;
10661060   cop_angle_step &= 0xff;
10671061   flags &= ~0x0004;
r32363r32364
10901084   space.write_byte(cop_regs[0] + 0x34, angle);
10911085}
10921086
1093void raiden2cop_device::LEGACY_execute_6200(address_space &space, int offset, UINT16 data)
1087
1088void raiden2cop_device::LEGACY_execute_6200_grainbow(address_space &space, int offset, UINT16 data)
10941089{
10951090   UINT8 cur_angle;
10961091   UINT16 flags;
10971092
1098   /* 0 [1] */
1099   /* 0xc [1] */
1100   /* 0 [0] */
1101   /* 0 [1] */
1102   /* 0xc [1] */
1103
1104   cur_angle = space.read_byte(cop_regs[1] + (0xc ^ 3));
1105   flags = space.read_word(cop_regs[1]);
1093   cur_angle = cop_read_byte(space,cop_regs[0] + 0x34);
1094   flags = cop_read_word(space, cop_regs[0]);
11061095   //space.write_byte(cop_regs[1] + (0^3),space.read_byte(cop_regs[1] + (0^3)) & 0xfb); //correct?
11071096
11081097   INT8 tempangle_compare = (INT8)cop_angle_target;
r32363r32364
11141103   cop_angle_target = tempangle_compare;
11151104   cop_angle_step = tempangle_mod_val;
11161105
1106
11171107   flags &= ~0x0004;
11181108
11191109   int delta = cur_angle - tempangle_compare;
r32363r32364
11421132         cur_angle -= tempangle_mod_val;
11431133   }
11441134
1145   space.write_byte(cop_regs[1] + (0 ^ 2), flags);
1146   space.write_byte(cop_regs[1] + (0xc ^ 3), cur_angle);
1135   space.write_byte(cop_regs[0] + (0 ^ 3), flags); // this is a word in the avoce
1136   space.write_word(cop_regs[0] + (0x34 ^ 3), cur_angle); // why ^3 on a word? should it be a byte, it is in the above
11471137}
11481138
1149void raiden2cop_device::LEGACY_execute_6200_grainbow(address_space &space, int offset, UINT16 data)
1139
1140void raiden2cop_device::LEGACY_execute_6200(address_space &space, int offset, UINT16 data) // this is for cupsoc, different sequence, works on different registers
11501141{
11511142   UINT8 cur_angle;
11521143   UINT16 flags;
11531144
1154   cur_angle = space.read_byte(cop_regs[0] + (0x34 ^ 3));
1155   flags = space.read_word(cop_regs[0] + (0 ^ 2));
1145   /* 0 [1] */
1146   /* 0xc [1] */
1147   /* 0 [0] */
1148   /* 0 [1] */
1149   /* 0xc [1] */
1150
1151   cur_angle = space.read_byte(cop_regs[1] + (0xc ^ 3));
1152   flags = space.read_word(cop_regs[1]);
11561153   //space.write_byte(cop_regs[1] + (0^3),space.read_byte(cop_regs[1] + (0^3)) & 0xfb); //correct?
11571154
11581155   INT8 tempangle_compare = (INT8)cop_angle_target;
r32363r32364
11641161   cop_angle_target = tempangle_compare;
11651162   cop_angle_step = tempangle_mod_val;
11661163
1167
11681164   flags &= ~0x0004;
11691165
11701166   int delta = cur_angle - tempangle_compare;
r32363r32364
11931189         cur_angle -= tempangle_mod_val;
11941190   }
11951191
1196   space.write_byte(cop_regs[0] + (0 ^ 3), flags);
1197   space.write_word(cop_regs[0] + (0x34 ^ 3), cur_angle);
1192   space.write_byte(cop_regs[1] + (0 ^ 2), flags);
1193   space.write_byte(cop_regs[1] + (0xc ^ 3), cur_angle);
11981194}
11991195
12001196/*
r32363r32364
15841580   }
15851581
15861582   case 0x0904: /* X Se Dae and Zero Team uses this variant */
1583   case 0x0905: //  0905 0006 fbfb 0008 - 0194 0288 0088 0000 0000 0000 0000 0000
15871584      execute_0904(space, offset, data);
15881585      break;
1589   
1590   case 0x0905: //  0905 0006 fbfb 0008 - 0194 0288 0088 0000 0000 0000 0000 0000
1591      execute_0905(space, offset, data);
1592      break;
15931586
15941587   case 0x130e:   // 130e 0005 bf7f 0010 - 0984 0aa4 0d82 0aa2 039b 0b9a 0b9a 0a9a
15951588   case 0x138e:
r32363r32364
20041997   if (check_command_matches(command, 0x194, 0x288, 0x088, 0x000, 0x000, 0x000, 0x000, 0x000, 6, 0xfbfb))
20051998   {
20061999      executed = 1;
2007      LEGACY_execute_0905(space, offset, data);
2000      execute_0904(space, offset, data);
20082001      return;
20092002   }
20102003
trunk/src/mame/machine/raiden2cop.h
r32363r32364
159159   void execute_3b30(address_space &space, int offset, UINT16 data);
160160   void execute_130e(address_space &space, int offset, UINT16 data);
161161   void execute_0904(address_space &space, int offset, UINT16 data);
162   void execute_0905(address_space &space, int offset, UINT16 data);
163162   void execute_2a05(address_space &space, int offset, UINT16 data);
164163   void execute_7e05(address_space &space, int offset, UINT16 data);
165164   void execute_5205(address_space &space, int offset, UINT16 data);
r32363r32364
180179   void LEGACY_execute_b900(address_space &space, int offset, UINT16 data);
181180   void LEGACY_execute_0205(address_space &space, int offset, UINT16 data);
182181   void LEGACY_execute_42c2(address_space &space, int offset, UINT16 data);
183   void LEGACY_execute_0905(address_space &space, int offset, UINT16 data);
184182   void LEGACY_execute_e30e(address_space &space, int offset, UINT16 data);
185183   void LEGACY_execute_6200(address_space &space, int offset, UINT16 data);
186184   void LEGACY_execute_6200_grainbow(address_space &space, int offset, UINT16 data);
r32363r32364
260258   int m_cpu_is_68k;
261259   static void set_cpu_is_68k(device_t &device, int value) { downcast<raiden2cop_device &>(device).m_cpu_is_68k = value; }
262260   UINT16 cop_read_word(address_space &space, int address);
261   UINT8 cop_read_byte(address_space &space, int address);
263262
264263   // DEBUG
265264   void dump_table();

Previous 199869 Revisions Next


© 1997-2024 The MAME Team