summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/kaneko16.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/machine/kaneko16.c')
-rw-r--r--src/mame/machine/kaneko16.c218
1 files changed, 109 insertions, 109 deletions
diff --git a/src/mame/machine/kaneko16.c b/src/mame/machine/kaneko16.c
index cbd86660bf6..224b21913c6 100644
--- a/src/mame/machine/kaneko16.c
+++ b/src/mame/machine/kaneko16.c
@@ -244,8 +244,8 @@ READ16_HANDLER(bloodwar_calc_r)
}
/*
- B Rap Boys
- Shogun Warriors
+ B Rap Boys
+ Shogun Warriors
*/
@@ -253,21 +253,21 @@ READ16_HANDLER(bloodwar_calc_r)
static struct {
int x1p, y1p, z1p, x1s, y1s, z1s;
int x2p, y2p, z2p, x2s, y2s, z2s;
-
+
int x1po, y1po, z1po, x1so, y1so, z1so;
int x2po, y2po, z2po, x2so, y2so, z2so;
int x12, y12, z12, x21, y21, z21;
-
+
int x_coll, y_coll, z_coll;
-
+
int x1tox2, y1toy2, z1toz2;
UINT16 mult_a, mult_b;
-
+
UINT16 flags;
UINT16 mode;
-
+
} shogwarr_hit;
@@ -276,32 +276,32 @@ static struct {
static int shogwarr_calc_compute(int x1, int w1, int x2, int w2)
{
int dist;
-
+
if(x2>=x1 && x2+w2<=(x1+w1))
{
//x2 inside x1
- dist=w2;
+ dist=w2;
}
else
{
if(x1>=x2 && x1+w1<=(x2+w2))
{
//x1 inside x2
- dist=w1;
+ dist=w1;
}
else
{
if(x2<x1)
{
- //swap
+ //swap
int tmp=x1;
x1=x2;
x2=tmp;
tmp=w1;
w1=w2;
w2=tmp;
- }
- dist=x1+w1-x2;
+ }
+ dist=x1+w1-x2;
}
}
return dist;
@@ -318,42 +318,42 @@ static void shogwarr_calc_org(int mode, int x0, int s0, int* x1, int* s1)
case 2: *x1=x0-s0; *s1=s0; break;
case 3: *x1=x0-s0; *s1=2*s0; break;
}
- //x1 is the left most coord, s1 = width
+ //x1 is the left most coord, s1 = width
}
static void shogwarr_recalc_collisions(void)
{
//calculate positions and sizes
-
+
int mode=shogwarr_hit.mode;
-
+
shogwarr_hit.flags=0;
-
+
shogwarr_calc_org(mode&3, shogwarr_hit.x1po, shogwarr_hit.x1so, &shogwarr_hit.x1p, &shogwarr_hit.x1s);
mode>>=2;
shogwarr_calc_org(mode&3, shogwarr_hit.y1po, shogwarr_hit.y1so, &shogwarr_hit.y1p, &shogwarr_hit.y1s);
mode>>=2;
shogwarr_calc_org(mode&3, shogwarr_hit.z1po, shogwarr_hit.z1so, &shogwarr_hit.z1p, &shogwarr_hit.z1s);
-
+
mode>>=4;
-
+
shogwarr_calc_org(mode&3, shogwarr_hit.x2po, shogwarr_hit.x2so, &shogwarr_hit.x2p, &shogwarr_hit.x2s);
mode>>=2;
shogwarr_calc_org(mode&3, shogwarr_hit.y2po, shogwarr_hit.y2so, &shogwarr_hit.y2p, &shogwarr_hit.y2s);
mode>>=2;
shogwarr_calc_org(mode&3, shogwarr_hit.z2po, shogwarr_hit.z2so, &shogwarr_hit.z2p, &shogwarr_hit.z2s);
-
+
shogwarr_hit.x1tox2=abs(shogwarr_hit.x2po-shogwarr_hit.x1po);
shogwarr_hit.y1toy2=abs(shogwarr_hit.y2po-shogwarr_hit.y1po);
shogwarr_hit.z1toz2=abs(shogwarr_hit.z2po-shogwarr_hit.z1po);
-
-
+
+
shogwarr_hit.x_coll = shogwarr_calc_compute(shogwarr_hit.x1p, shogwarr_hit.x1s, shogwarr_hit.x2p, shogwarr_hit.x2s);
shogwarr_hit.y_coll = shogwarr_calc_compute(shogwarr_hit.y1p, shogwarr_hit.y1s, shogwarr_hit.y2p, shogwarr_hit.y2s);
shogwarr_hit.z_coll = shogwarr_calc_compute(shogwarr_hit.z1p, shogwarr_hit.z1s, shogwarr_hit.z2p, shogwarr_hit.z2s);
-
-
+
+
// 4th nibble: Y Absolute Collision -> possible values = 9,8,4,3,2
if (shogwarr_hit.y1p > shogwarr_hit.y2p) shogwarr_hit.flags |= 0x2000;
else if (shogwarr_hit.y1p == shogwarr_hit.y2p) shogwarr_hit.flags |= 0x4000;
@@ -372,7 +372,7 @@ static void shogwarr_recalc_collisions(void)
else if (shogwarr_hit.z1p < shogwarr_hit.z2p) shogwarr_hit.flags |= 0x0080;
if (shogwarr_hit.z_coll<0) shogwarr_hit.flags |= 0x0010;
- // 1st nibble: XYZ Overlap Collision
+ // 1st nibble: XYZ Overlap Collision
if ((shogwarr_hit.x_coll>=0)&&(shogwarr_hit.y_coll>=0)&&(shogwarr_hit.z_coll>=0)) shogwarr_hit.flags |= 0x0008;
if ((shogwarr_hit.x_coll>=0)&&(shogwarr_hit.z_coll>=0)) shogwarr_hit.flags |= 0x0004;
if ((shogwarr_hit.y_coll>=0)&&(shogwarr_hit.z_coll>=0)) shogwarr_hit.flags |= 0x0002;
@@ -388,66 +388,66 @@ WRITE16_HANDLER(shogwarr_calc_w)
// p is position, s is size
case 0x00:
case 0x28:
-
+
shogwarr_hit.x1po = data; break;
-
+
case 0x04:
case 0x2c:
shogwarr_hit.x1so = data; break;
-
- case 0x08:
+
+ case 0x08:
case 0x30:
shogwarr_hit.y1po = data; break;
-
- case 0x0c:
+
+ case 0x0c:
case 0x34:
shogwarr_hit.y1so = data; break;
- case 0x10:
+ case 0x10:
case 0x58:
shogwarr_hit.x2po = data; break;
-
- case 0x14:
+
+ case 0x14:
case 0x5c:
shogwarr_hit.x2so = data; break;
-
- case 0x18:
+
+ case 0x18:
case 0x60:
shogwarr_hit.y2po = data; break;
-
- case 0x1c:
+
+ case 0x1c:
case 0x64:
shogwarr_hit.y2so = data; break;
-
+
case 0x38:
case 0x50:
shogwarr_hit.z1po = data; break;
- case 0x3c:
+ case 0x3c:
case 0x54:
shogwarr_hit.z1so = data; break;
-
- case 0x20:
+
+ case 0x20:
case 0x68:
shogwarr_hit.z2po = data; break;
-
- case 0x24:
+
+ case 0x24:
case 0x6c:
shogwarr_hit.z2so = data; break;
-
+
case 0x70:
shogwarr_hit.mode=data;break;
-
+
default:
logerror("CPU #0 PC %06x: warning - write unmapped hit address %06x [ %06x] = %06x\n",cpu_get_pc(space->cpu),offset<<1, idx, data);
}
-
+
shogwarr_recalc_collisions();
}
READ16_HANDLER(shogwarr_calc_r)
{
-
+
int idx=offset*4;
switch (idx)
@@ -459,11 +459,11 @@ READ16_HANDLER(shogwarr_calc_r)
case 0x04: // Y distance
case 0x14:
return shogwarr_hit.y_coll;
-
+
case 0x18: // Z distance
return shogwarr_hit.z_coll;
- case 0x08:
+ case 0x08:
case 0x1c:
return shogwarr_hit.flags;
@@ -484,7 +484,7 @@ READ16_HANDLER(shogwarr_calc_r)
case 0x64: return shogwarr_hit.y2so;
case 0x68: return shogwarr_hit.z2po;
case 0x6c: return shogwarr_hit.z2so;
-
+
case 0x80: return shogwarr_hit.x1tox2;
case 0x84: return shogwarr_hit.y1toy2;
case 0x88: return shogwarr_hit.z1toz2;
@@ -724,7 +724,7 @@ static UINT8 calc3_key04[64] = {
0x9c,0x8e,0x45,0xe8,0x5b,0xe1,0xdd,0xaf,0x99,0xa8,0x47,0x79,0x67,0x00,0x38,0xf4,
0x43,0xbe,0x47,0x32,0x8f,0x0e,0xfd,0x64,0x42,0x59,0x2b,0xe5,0xde,0x6d,0x80,0x7a,
};
-
+
static UINT8 calc3_key05[64] = {
0x5e,0xd8,0xa6,0xd7,0x00,0x94,0x23,0x66,0xaf,0xea,0xbe,0x45,0x38,0x90,0x8e,0x8d,
0x5b,0x14,0x2c,0xda,0x55,0x7e,0x9d,0x08,0x2d,0x31,0xfd,0x3a,0xbe,0x13,0xeb,0x21,
@@ -830,7 +830,7 @@ static UINT8 calc3_keybc[64] = {
0xd5,0xf9,0x42,0x57,0x7a,0xf8,0x30,0x2e,0xea,0x49,0xe5,0xd5,0x34,0x6a,0xcd,0x5b,
0xfa,0x8e,0x71,0x32,0xfa,0x42,0x69,0xec,0x5d,0x50,0x02,0x42,0xc2,0xe4,0xae,0x5a,
};
-
+
static UINT8 calc3_keybf[64] = {
0x9a,0x8e,0xcf,0x66,0xe0,0xd8,0xd4,0x2a,0x0f,0x4d,0xad,0x64,0x8c,0x6d,0xcb,0x37,
0x2e,0x0e,0x9f,0xc4,0xca,0xff,0x85,0xf1,0x7f,0xec,0x71,0x69,0xc2,0x81,0x5c,0xe4,
@@ -868,7 +868,7 @@ static UINT8 shift_bits(UINT8 dat, int bits)
if (bits==5) return BITSWAP8(dat, 2,1,0,7,6,5,4,3);
if (bits==6) return BITSWAP8(dat, 1,0,7,6,5,4,3,2);
if (bits==7) return BITSWAP8(dat, 0,7,6,5,4,3,2,1);
-
+
return dat;
}
@@ -902,7 +902,7 @@ int calc3_decompress_table(running_machine* machine, int tabnum, UINT8* dstram,
length = rom[offset+0] | (rom[offset+1]<<8);
offset+=length+2;
}
-
+
// we're at the start of the block, get the info about it
{
UINT16 inline_table_base = 0;
@@ -927,7 +927,7 @@ int calc3_decompress_table(running_machine* machine, int tabnum, UINT8* dstram,
offset+= calc3_blocksize_offset+1;
length = rom[offset+0] | (rom[offset+1]<<8);
offset+=2;
-
+
#if CALC3_VERBOSE_OUTPUT
if (inline_table_size)
{
@@ -948,16 +948,16 @@ int calc3_decompress_table(running_machine* machine, int tabnum, UINT8* dstram,
// shogwarr does this with 'mode' as 0x08, which probably has some special meaning
//printf("CALC3: requested 0 length table!\n");
// -- seems to be 'reset stack' to default for the protection table writes
-
- // except this will break shogun going into game, must be specific conditions for
+
+ // except this will break shogun going into game, must be specific conditions for
// this, or it can remember addresses and restore those
-
- // hack, set it to a known address instead of trying to restore to anywhere specific..
+
+ // hack, set it to a known address instead of trying to restore to anywhere specific..
// might break at some point tho, eg if it doesn't write command 06 often enough because it trys to use another one like 07...
// need to understand the meaning of this (test hw?)
-
+
// !dstram is used because we don't want to process these during our initial table scan, only when the game asks!
-
+
if (calc3_mode==0x06)
{
calc3_writeaddress_current = 0x202000;
@@ -965,7 +965,7 @@ int calc3_decompress_table(running_machine* machine, int tabnum, UINT8* dstram,
else if (calc3_mode==0x07)
{
// also calls empty table with Mode? 07
- // maybe they reset to different points?
+ // maybe they reset to different points?
}
else if (calc3_mode==0x08 && !dstram)
{
@@ -976,12 +976,12 @@ int calc3_decompress_table(running_machine* machine, int tabnum, UINT8* dstram,
UINT8 *dat;
dat = (UINT8 *)eeprom_get_data_pointer(&length, &size);
-
+
for (i=0;i<0x80;i++)
{
dat[i] = memory_read_byte(space, calc3_eeprom_addr+0x200000+i);
- }
-
+ }
+
}
}
@@ -989,7 +989,7 @@ int calc3_decompress_table(running_machine* machine, int tabnum, UINT8* dstram,
{
printf("unknown blank table command\n");
}
-
+
return 0;
}
@@ -998,14 +998,14 @@ int calc3_decompress_table(running_machine* machine, int tabnum, UINT8* dstram,
// these should be derived from the inline table somehow, probably just a +/- swap like the normal stuff.. maybe
UINT8 extra[] = { 0x14,0xf0,0xf8,0xd2,0xbe,0xfc,0xac,0x86,0x64,0x08,0x0c,0x74,0xd6,0x6a,0x24,0x12,0x1a,0x72,0xba,0x48,0x76,0x66,0x4a,0x7c,0x5c,0x82,0x0a,0x86,0x82,0x02,0xe6 };
UINT8 extra2[] = { 0x2f,0x04,0xd1,0x69,0xad,0xeb,0x10,0x95,0xb0,0x2f,0x0a,0x83,0x7d,0x4e,0x2a,0x07,0x89,0x52,0xca,0x41,0xf1,0x4f,0xaf,0x1c,0x01,0xe9,0x89,0xd2,0xaf,0xcd };
-
-
+
+
for (i=0;i<length;i++)
{
UINT8 dat=0;
int extrasign = -1;
-
-
+
+
if (
(tabnum==0x11 && isbrap) ||
(tabnum==0x1a && isbrap) ||
@@ -1015,12 +1015,12 @@ int calc3_decompress_table(running_machine* machine, int tabnum, UINT8* dstram,
/*(tabnum==0x40 && !isbrap)*/
)
extrasign = 0;
-
+
if ((tabnum==0x25 && isbrap))
extrasign = 1;
-
-
-
+
+
+
if (extrasign !=-1)
{
if ( ((i / inline_table_size)&1)==0)
@@ -1034,10 +1034,10 @@ int calc3_decompress_table(running_machine* machine, int tabnum, UINT8* dstram,
}
else
{
-
+
UINT8 inlinet = rom[inline_table_base + (i%inline_table_size)];
dat = rom[offset+i];
-
+
if (extrasign==0)
{
dat -= inlinet;
@@ -1046,9 +1046,9 @@ int calc3_decompress_table(running_machine* machine, int tabnum, UINT8* dstram,
else
{
dat += inlinet;
- dat += extra[(i%inline_table_size)>>1];
+ dat += extra[(i%inline_table_size)>>1];
}
-
+
dat = shift_bits(dat, 8-calc3_shift);
}
}
@@ -1059,12 +1059,12 @@ int calc3_decompress_table(running_machine* machine, int tabnum, UINT8* dstram,
UINT8 inlinet = rom[inline_table_base + (i%inline_table_size)];
dat = rom[offset+i];
dat -= inlinet;
- dat = shift_bits(dat, calc3_shift);
+ dat = shift_bits(dat, calc3_shift);
}
else
{
dat = rom[offset+i];
-
+
if (extrasign==0)
{
dat -= extra2[(i%inline_table_size)>>1];
@@ -1075,7 +1075,7 @@ int calc3_decompress_table(running_machine* machine, int tabnum, UINT8* dstram,
}
dat = shift_bits(dat, 8-calc3_shift);
}
- }
+ }
}
// the above rule doesn't work for this case... hmm ..
else if (tabnum==0x40 && !isbrap) // fjbuster / shogun warriors japanese character select (what enables this extra?)
@@ -1096,7 +1096,7 @@ int calc3_decompress_table(running_machine* machine, int tabnum, UINT8* dstram,
{
if (i==1)
printf("unhandled inline case\n");
-
+
}
if(local_counter>1)
@@ -1105,7 +1105,7 @@ int calc3_decompress_table(running_machine* machine, int tabnum, UINT8* dstram,
{
memory_write_byte(space, dstoffset+i, dat);
}
-
+
// debug, used to output tables at the start
if (dstram)
{
@@ -1114,7 +1114,7 @@ int calc3_decompress_table(running_machine* machine, int tabnum, UINT8* dstram,
}
else
data_header[local_counter]=dat;
-
+
++local_counter;
}
}
@@ -1128,7 +1128,7 @@ int calc3_decompress_table(running_machine* machine, int tabnum, UINT8* dstram,
// each key seems to relate directly to a 0x40 byte decryption table, only these ones handled so far
if (calc3_decryption_key_byte == 0x01) key = calc3_key01;
if (calc3_decryption_key_byte == 0x04) key = calc3_key04;
- if (calc3_decryption_key_byte == 0x05) key = calc3_key05;
+ if (calc3_decryption_key_byte == 0x05) key = calc3_key05;
if (calc3_decryption_key_byte == 0x15) key = calc3_key15;
if (calc3_decryption_key_byte == 0x17) key = calc3_key17;
if (calc3_decryption_key_byte == 0x19) key = calc3_key19;
@@ -1136,7 +1136,7 @@ int calc3_decompress_table(running_machine* machine, int tabnum, UINT8* dstram,
if (calc3_decryption_key_byte == 0x24) key = calc3_key24;
if (calc3_decryption_key_byte == 0x31) key = calc3_key31;
if (calc3_decryption_key_byte == 0x39) key = calc3_key39;
- if (calc3_decryption_key_byte == 0x3f) key = calc3_key3f;
+ if (calc3_decryption_key_byte == 0x3f) key = calc3_key3f;
if (calc3_decryption_key_byte == 0x80) key = calc3_key80;
if (calc3_decryption_key_byte == 0x89) key = calc3_key89;
if (calc3_decryption_key_byte == 0xa1) key = calc3_keya1;
@@ -1194,9 +1194,9 @@ int calc3_decompress_table(running_machine* machine, int tabnum, UINT8* dstram,
// note we've already seen this table, but like many others, it's + instead of - on some bytes..
if ((i&1)==1) dat += key[i&0x3f];
else dat -= key[i&0x3f];
-
+
if ((i&1)==0) dat = shift_bits(dat, 8-calc3_shift);
- else dat = shift_bits(dat, calc3_shift);
+ else dat = shift_bits(dat, calc3_shift);
}
else if (tabnum==0x12 && isbrap)
{
@@ -1216,7 +1216,7 @@ int calc3_decompress_table(running_machine* machine, int tabnum, UINT8* dstram,
{
memory_write_byte(space, dstoffset+i, dat);
}
-
+
// debug, used to output tables at the start
if (dstram)
{
@@ -1225,7 +1225,7 @@ int calc3_decompress_table(running_machine* machine, int tabnum, UINT8* dstram,
}
else
data_header[local_counter]=dat;
-
+
++local_counter;
//dstram[(dstoffset+i)^1] = dat;
@@ -1302,7 +1302,7 @@ DRIVER_INIT(calc3_scantables)
// to that extra block of data
// dump out the 0x1000 sized block at the end
-#if CALC3_VERBOSE_OUTPUT
+#if CALC3_VERBOSE_OUTPUT
{
FILE *fp;
char filename[256];
@@ -1334,7 +1334,7 @@ void calc3_mcu_run(running_machine *machine)
if (calc3_dsw_addr) memory_write_byte(space, calc3_dsw_addr+0x200000, ( ~input_port_read(machine, "DSW1"))&0xff); // // DSW // dsw actually updates in realtime - mcu reads+writes it every frame
-
+
//calc3_mcu_status = 0;
mcu_command = kaneko16_mcu_ram[calc3_mcu_command_offset/2 + 0];
@@ -1362,7 +1362,7 @@ void calc3_mcu_run(running_machine *machine)
cakc3_checkumaddress = kaneko16_mcu_ram[(0>>1) + 5];
calc3_writeaddress = (kaneko16_mcu_ram[(0>>1) + 6] << 16) |
(kaneko16_mcu_ram[(0>>1) + 7]);
-
+
// set our current write / stack pointer to the address specified
calc3_writeaddress_current = calc3_writeaddress;
#if CALC3_VERBOSE_OUTPUT
@@ -1373,30 +1373,30 @@ void calc3_mcu_run(running_machine *machine)
printf("Calc 3 Init Command - %04x ROM Checksum Address\n", cakc3_checkumaddress);
printf("Calc 3 Init Command - %08x Data Write Address\n", calc3_writeaddress);
#endif
- // memory_write_byte(space, calc3_dsw_addr+0x200000, ( ~input_port_read(machine, "DSW1"))&0xff); // // DSW // dsw actually updates in realtime - mcu reads+writes it every frame
-
+ // memory_write_byte(space, calc3_dsw_addr+0x200000, ( ~input_port_read(machine, "DSW1"))&0xff); // // DSW // dsw actually updates in realtime - mcu reads+writes it every frame
+
kaneko16_mcu_ram[cakc3_checkumaddress / 2] = calc3_mcu_crc; // MCU Rom Checksum!
/*
- for (i=0;i<0x40;i++)
- {
- kaneko16_mcu_ram[(calc3_eeprom_addr / 2)+i] = kaneko16_eeprom_data[i];//((eepromData[i]&0xff00)>>8) | ((eepromData[i]&0x00ff)<<8);
- }
- */
+ for (i=0;i<0x40;i++)
+ {
+ kaneko16_mcu_ram[(calc3_eeprom_addr / 2)+i] = kaneko16_eeprom_data[i];//((eepromData[i]&0xff00)>>8) | ((eepromData[i]&0x00ff)<<8);
+ }
+ */
{
UINT32 length, size;
UINT8 *dat;
dat = (UINT8 *)eeprom_get_data_pointer(&length, &size);
-
+
for (i=0;i<0x80;i++)
{
memory_write_byte(space, calc3_eeprom_addr+0x200000+i, dat[i]);
- }
-
+ }
+
}
-
+
}
/* otherwise the command number is the number of transfer operations to perform */
else
@@ -1421,15 +1421,15 @@ void calc3_mcu_run(running_machine *machine)
#endif
{
int length;
-
+
length = calc3_decompress_table(machine, commandtabl, 0, calc3_writeaddress_current-2);
-
+
if (length)
{
int write=commandaddr;
-#if CALC3_VERBOSE_OUTPUT
+#if CALC3_VERBOSE_OUTPUT
printf("writing back address %08x to %08x %08x\n", calc3_writeaddress_current, commandaddr,write);
-#endif
+#endif
//memory_write_byte(space,write+0x200001, data_header[0]); // maybe not.. check first boss brapboysj
memory_write_byte(space,write+0x200001, data_header[1]);