Previous 199869 Revisions Next

r32460 Monday 29th September, 2014 at 15:03:08 UTC by David Haywood
refactor (nw)
[src/mame/machine]raiden2cop.c raiden2cop.h

trunk/src/mame/machine/raiden2cop.c
r32459r32460
201201   else space.write_word(address, data);
202202}
203203
204void raiden2cop_device::cop_write_byte(address_space &space, int address, UINT8 data)
205{
206   if (m_cpu_is_68k) space.write_byte(address ^ 3, data);
207   else space.write_byte(address, data);
208}
204209
210
205211/*** Command Table uploads ***/
206212
207213
r32459r32460
11921198*/
11931199void raiden2cop_device::execute_6200(address_space &space, int offset, UINT16 data)
11941200{
1195   UINT8 angle = cop_read_byte(space, cop_regs[0] + 0x34);
1196   UINT16 flags = cop_read_word(space, cop_regs[0]);
1201   int primary_reg = 0;
1202   int primary_offset = 0x34;
1203
1204   UINT8 angle = cop_read_byte(space, cop_regs[primary_reg] + primary_offset);
1205   UINT16 flags = cop_read_word(space, cop_regs[primary_reg]);
11971206   cop_angle_target &= 0xff;
11981207   cop_angle_step &= 0xff;
11991208   flags &= ~0x0004;
r32459r32460
12181227      else
12191228         angle -= cop_angle_step;
12201229   }
1221   space.write_word(cop_regs[0], flags);
1222   space.write_byte(cop_regs[0] + 0x34, angle);
1223}
1230   
1231   cop_write_word(space, cop_regs[primary_reg], flags);
12241232
1233   if (!m_cpu_is_68k)
1234      cop_write_byte(space, cop_regs[primary_reg] + primary_offset, angle);
1235   else // angle is a byte, but grainbow (cave mid-boss) is only happy with write-word, could be more endian weirdness, or it always writes a word?
1236      cop_write_word(space, cop_regs[primary_reg] + primary_offset, angle);
12251237
1226void raiden2cop_device::LEGACY_execute_6200_grainbow(address_space &space, int offset, UINT16 data)
1227{
1228   UINT8 cur_angle;
1229   UINT16 flags;
1230
1231   cur_angle = cop_read_byte(space,cop_regs[0] + 0x34);
1232   flags = cop_read_word(space, cop_regs[0]);
1233   //space.write_byte(cop_regs[1] + (0^3),space.read_byte(cop_regs[1] + (0^3)) & 0xfb); //correct?
1234
1235   INT8 tempangle_compare = (INT8)cop_angle_target;
1236   INT8 tempangle_mod_val = (INT8)cop_angle_step;
1237
1238   tempangle_compare &= 0xff;
1239   tempangle_mod_val &= 0xff;
1240
1241   cop_angle_target = tempangle_compare;
1242   cop_angle_step = tempangle_mod_val;
1243
1244
1245   flags &= ~0x0004;
1246
1247   int delta = cur_angle - tempangle_compare;
1248   if (delta >= 128)
1249      delta -= 256;
1250   else if (delta < -128)
1251      delta += 256;
1252   if (delta < 0)
1253   {
1254      if (delta >= -tempangle_mod_val)
1255      {
1256         cur_angle = tempangle_compare;
1257         flags |= 0x0004;
1258      }
1259      else
1260         cur_angle += tempangle_mod_val;
1261   }
1262   else
1263   {
1264      if (delta <= tempangle_mod_val)
1265      {
1266         cur_angle = tempangle_compare;
1267         flags |= 0x0004;
1268      }
1269      else
1270         cur_angle -= tempangle_mod_val;
1271   }
1272
1273   space.write_byte(cop_regs[0] + (0 ^ 3), flags); // this is a word in the avoce
1274   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
12751238}
12761239
12771240
12781241void raiden2cop_device::LEGACY_execute_6200(address_space &space, int offset, UINT16 data) // this is for cupsoc, different sequence, works on different registers
12791242{
1280   UINT8 cur_angle;
1281   UINT16 flags;
1243   int primary_reg = 1;
1244   int primary_offset = 0xc;
12821245
1283   /* 0 [1] */
1284   /* 0xc [1] */
1285   /* 0 [0] */
1286   /* 0 [1] */
1287   /* 0xc [1] */
1288
1289   cur_angle = space.read_byte(cop_regs[1] + (0xc ^ 3));
1290   flags = space.read_word(cop_regs[1]);
1291   //space.write_byte(cop_regs[1] + (0^3),space.read_byte(cop_regs[1] + (0^3)) & 0xfb); //correct?
1292
1293   INT8 tempangle_compare = (INT8)cop_angle_target;
1294   INT8 tempangle_mod_val = (INT8)cop_angle_step;
1295
1296   tempangle_compare &= 0xff;
1297   tempangle_mod_val &= 0xff;
1298
1299   cop_angle_target = tempangle_compare;
1300   cop_angle_step = tempangle_mod_val;
1301
1246   UINT8 angle = cop_read_byte(space, cop_regs[primary_reg] + primary_offset);
1247   UINT16 flags = cop_read_word(space, cop_regs[primary_reg]);
1248   cop_angle_target &= 0xff;
1249   cop_angle_step &= 0xff;
13021250   flags &= ~0x0004;
1303
1304   int delta = cur_angle - tempangle_compare;
1251   int delta = angle - cop_angle_target;
13051252   if (delta >= 128)
13061253      delta -= 256;
13071254   else if (delta < -128)
13081255      delta += 256;
1309   if (delta < 0)
1310   {
1311      if (delta >= -tempangle_mod_val)
1312      {
1313         cur_angle = tempangle_compare;
1256   if (delta < 0) {
1257      if (delta >= -cop_angle_step) {
1258         angle = cop_angle_target;
13141259         flags |= 0x0004;
13151260      }
13161261      else
1317         cur_angle += tempangle_mod_val;
1262         angle += cop_angle_step;
13181263   }
1319   else
1320   {
1321      if (delta <= tempangle_mod_val)
1322      {
1323         cur_angle = tempangle_compare;
1264   else {
1265      if (delta <= cop_angle_step) {
1266         angle = cop_angle_target;
13241267         flags |= 0x0004;
13251268      }
13261269      else
1327         cur_angle -= tempangle_mod_val;
1270         angle -= cop_angle_step;
13281271   }
1272   
1273   cop_write_word(space, cop_regs[primary_reg], flags);
13291274
1330   space.write_byte(cop_regs[1] + (0 ^ 2), flags);
1331   space.write_byte(cop_regs[1] + (0xc ^ 3), cur_angle);
1275   if (!m_cpu_is_68k)
1276      cop_write_byte(space, cop_regs[primary_reg] + primary_offset, angle);
1277   else // angle is a byte, but grainbow (cave mid-boss) is only happy with write-word, could be more endian weirdness, or it always writes a word?
1278      cop_write_word(space, cop_regs[primary_reg] + primary_offset, angle);
13321279}
13331280
13341281/*
r32459r32460
23052252   if (check_command_matches(command, 0x380, 0x39a, 0x380, 0xa80, 0x29a, 0x000, 0x000, 0x000, 8, 0xf3e7))
23062253   {
23072254      executed = 1;
2308      LEGACY_execute_6200_grainbow(space, offset, data);   
2255      execute_6200(space, offset, data);   
23092256      return;
23102257   }
23112258
trunk/src/mame/machine/raiden2cop.h
r32459r32460
193193   void LEGACY_execute_42c2(address_space &space, int offset, UINT16 data);
194194   void LEGACY_execute_e30e(address_space &space, int offset, UINT16 data);
195195   void LEGACY_execute_6200(address_space &space, int offset, UINT16 data);
196   void LEGACY_execute_6200_grainbow(address_space &space, int offset, UINT16 data);
197196   void LEGACY_execute_dde5(address_space &space, int offset, UINT16 data);
198197   void LEGACY_execute_d104(address_space &space, int offset, UINT16 data);
199198   void LEGACY_execute_6980(address_space &space, int offset, UINT16 data);
r32459r32460
252251   UINT16 cop_read_word(address_space &space, int address);
253252   UINT8 cop_read_byte(address_space &space, int address);
254253   void cop_write_word(address_space &space, int address, UINT16 data);
254   void cop_write_byte(address_space &space, int address, UINT8 data);
255255
256256   // DEBUG
257257   void dump_table();

Previous 199869 Revisions Next


© 1997-2024 The MAME Team