Skip to content

Commit

Permalink
leftovers, NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
toxieainc committed Feb 15, 2024
1 parent 4a2a21c commit 0656042
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 43 deletions.
27 changes: 13 additions & 14 deletions src/wpc/capcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@
Milestones:
09/19/03-09/21/03 - U16 Test successfully bypassed, dmd and lamps working quite well
09/21/03-09/24/03 - DMD working 100% incuding 256x64 size, switches, solenoids working on most games except kp, and ff
09/21/03-09/24/03 - DMD working 100% including 256x64 size, switches, solenoids working on most games except kp, and ff
09/25/03 - First time game booted without any errors.. (Even though in reality, the U16 would still fail if not hacked around)
11/03/03 - First time sound was working almost fully (although still some glitches and much work left to do)
11/09/03 - 50V Line finally reports a voltage & KP,FF fire hi-volt solenoids
11/10/03 - Seem to have found decent IRQ4 freq. to allow KP & FF to fire sols 1 & 2 properly
11/15/03 - 68306 optimized & true address mappings implemented, major speed improvements!
Hacks & Issues that need to be looked into:
#1) Why do we need to adjust the CPU Speed to get the animations to display at correct speed? U16 related bug?
#2) U16 Needs to be better understood and emulated more accurately (should fix IRQ4 timing problems)
#3) IRQ4 appears to somehow control timing for 50V solenoids & Lamps in FF&KP, unknown effect in other games
#4) Handle opto switches internally? Is this needed?
Expand All @@ -55,20 +54,20 @@
The PowerMeter in King Pin works that way. The lower the power is on the display the lower the strength the flippers is applied.
Also see https://m.facebook.com/story.php?story_fbid=2088173937889558&id=1034214746618821
-> suggestion: Find mem location (as it's only one machine/ROM version after all!) and use that directly instead of trying to track/map it?
#11) Flippers are not implemented. VPinMame appears to pass flipper switches through to flipper solenoids (always on). Actual flipper solenoids
#11) Flippers are not implemented. VPinMAME appears to pass flipper switches through to flipper solenoids (always on). Actual flipper solenoids
seem to give one very latent pulse instead of staying on.
[VB 02/01/2024]
After diving into the schematics and some 68000 disassembler, some changes:
- Added PWM with physical model outputs (really needed, since the hardware uses this almost everywhere)
- Replaced diagnostic leds by PWM output in an addtional lamp column (they were wrong before, and Capcom use PWM to report ok state)
- Replaced diagnostic leds by PWM output in an additional lamp column (they were wrong before, and Capcom use PWM to report ok state)
- Moved back to 'normal' frequencies: CPU at 16MHz from the schematics, 120Hz for zero cross since these are things we can be sure of
- Removed locals.driverboard read/write: from the schematics, this is an hardcoded value read from U55 (sheet 9 of driver board schematics, checked for Airborne, Breakshot,...)
- Adjusted Line_5/Line_V to be read as expected (RC filter with comparator, the CPU measure how long it takes to pass the comparator threshold)
- Fixed 68306 DUART counter which was counting 2 times too slow. 5V/50V measure is now right (it is used to measure Pulse/Charge/Discharge lengths and likely adjust solenoid PWM to get consistent solenoid strength accross voltage levels)
- Removed locals.blanking since it is in fact the lamp matrix VSET1/2 which enable/disable lamp matrices (not solenoid). There is also a Blank signal from U16 which is unknown so far
- Returns the lamp/solenoid state when read since the schematics shows that the read value is the latched one, including overcurrent reset (used in diagnostics section of DMD)
- Zero cross (IRQ2) is now latched and manually reseted by the CPU as the schematics shows
- Zero cross (IRQ2) is now latched and manually resetted by the CPU as the schematics shows
- Cleaned up a little bit of memory mapping between Breakshot and other games
- Implemented U16 programmable interrupt controller. Startup tests are now passing.
- Adjusted (hacked) IRQ1 timings to fulfill zero cross measurements (in audit, in ROM code, also impacts how IRQ4 line 1 is setup by game code)
Expand Down Expand Up @@ -264,7 +263,7 @@ static WRITE16_HANDLER(cc_porta_w) {
// Cabinet switch voltage level comparator (either comparator from +5V with 2.2k/1.2k =>1.76V or 2.2k/3.9k => 3.20V), not sure why
locals.vset = (data>>6) & 1;

//Manually reset the sound board on 1->0 transition (but don't do it the very first time, ie, when both cpu's first boot up)
// Manually reset the sound board on 1->0 transition (but don't do it the very first time, ie, when both cpu's first boot up)
reset = (data >> 7) & 1;
if (locals.greset && !reset) {
if(!locals.first_sound_reset)
Expand Down Expand Up @@ -340,8 +339,8 @@ static WRITE16_HANDLER(cc_portb_w) {
// measured by game code (during gameplay). The only identified difference being the way the IRQ is acknowledge (delay flag ? something unspot yet ?).
// . CBA is IRQ4 line enable, bit C is inverted:
// C is a fixed frequency interrupt generator, likely corresponding to DMD VBlank since it is 45.9Hz for FF (64 lines), 91.8Hz for others (32 lines), maybe this flag is DMD steobe on/off
// B use frequency defined by writting at 40C00404
// A use frequency defined by writting at 40C00402
// B use frequency defined by writing at 40C00404
// A use frequency defined by writing at 40C00402
// . ??? are unknown. Breakshot, Flipper Football & KingPin always set them to 011, except if an auxiliary board is present, then it is set to 111
// $40C00402 u16IRQ4line1f is IRQ4 line 1 frequency (0x1000 - (data & 0x0FFF)) * 88.6489 CPU cycles
// $40C00404 u16IRQ4line2f is IRQ4 line 2 frequency (0x1000 - (data & 0x0FFF)) * 88.6489 CPU cycles
Expand Down Expand Up @@ -450,7 +449,7 @@ static WRITE16_HANDLER(u16_w) {
//LOG_U16(("PC %08x - U16w IRQ ACK %02x [data@%03x=%04x] (%04x)\n", activecpu_get_pc(), (~data) & 0x17, offset, data, mem_mask));
locals.u16IRQState &= data;
u16UpdateIRQ();
// FIXME this is clearly a hack but we do not know what actually drives IRQ1 and the ROM code expects frequency around 4KHz when acknowledgeded with 0xFFE7 (during play) while it expects a 2.96KHz frequency when acked with 0xFFEF (during startup), so...
// FIXME this is clearly a hack but we do not know what actually drives IRQ1 and the ROM code expects frequency around 4KHz when acknowledged with 0xFFE7 (during play) while it expects a 2.96KHz frequency when acked with 0xFFEF (during startup), so...
if (((data & 0x10) == 0) && (locals.u16IRQ1Adjust == (data & 0x08))) {
locals.u16IRQ1Adjust = (~data) & 0x08;
timer_adjust(locals.u16IRQ1timer, locals.u16IRQ1Adjust ? (locals.u16IRQ1Period * 120.0 / 165.0) : locals.u16IRQ1Period, 0, locals.u16IRQ1Adjust ? (locals.u16IRQ1Period * 120.0 / 165.0) : locals.u16IRQ1Period);
Expand Down Expand Up @@ -901,8 +900,8 @@ MEMORY_END

static MEMORY_WRITE16_START(cc_writemem)
{ 0x00000000, 0x0007ffff, MWA16_RAM, &ramptr }, /* DRAM */
{ 0x10000000, 0x10ffffff, MWA16_ROM, &rom_base }, /* ROMS */
{ 0x30000000, 0x3001ffff, MWA16_RAM, &CMOS }, /* NVRAM */
{ 0x10000000, 0x10ffffff, MWA16_ROM, &rom_base }, /* ROMS */
{ 0x30000000, 0x3001ffff, MWA16_RAM, &CMOS } /* NVRAM */
{ 0x40000000, 0x40bfffff, io_w }, /* I/O */
{ 0x40c00000, 0x40c007ff, u16_w }, /* U16 (A10,A2,A1)*/
MEMORY_END
Expand Down Expand Up @@ -958,7 +957,7 @@ PINMAME_VIDEO_UPDATE(cc_dmd128x32) {
UINT16 intens1 = RAM[0];
for(jj=0;jj<8;jj++) {
*line++ = (intens1&0xc000)>>14;
intens1 = intens1<<2;
intens1 <<= 2;
}
RAM+=1;
}
Expand Down Expand Up @@ -986,9 +985,9 @@ PINMAME_VIDEO_UPDATE(cc_dmd256x64) {
UINT16 intensr = RAM[0x10];
for(jj=0;jj<8;jj++) {
*linel++ = (intensl&0xc000)>>14;
intensl = intensl<<2;
intensl <<= 2;
*liner++ = (intensr&0xc000)>>14;
intensr = intensr<<2;
intensr <<= 2;
}
RAM+=1;
}
Expand Down
49 changes: 20 additions & 29 deletions src/wpc/mrgame.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,11 +655,7 @@ static const struct rectangle screen_visible_area =
//Video Update - Generation #1
PINMAME_VIDEO_UPDATE(mrgame_update_g1) {
size_t offs;
int color;
int colorindex = 0;
int tile;
int flipx;
int flipy;

#ifdef MAME_DEBUG

Expand Down Expand Up @@ -697,11 +693,11 @@ PINMAME_VIDEO_UPDATE(mrgame_update_g1) {

colorindex = (colorindex+2);
if(sx==0) colorindex=1;
color = mrgame_objectram[colorindex];
unsigned int color = mrgame_objectram[colorindex];
locals.scrollers[sx] = -mrgame_objectram[colorindex-1];

tile = mrgame_videoram[offs]+
(locals.vid_a11<<8)+(locals.vid_a12<<9)+(locals.vid_a13<<10)+(locals.vid_a14<<11);
unsigned int tile = mrgame_videoram[offs]+
(locals.vid_a11<<8) + (locals.vid_a12<<9) + (locals.vid_a13<<10) + (locals.vid_a14<<11);

drawgfx(tmpbitmap,Machine->gfx[0],
tile,
Expand All @@ -711,19 +707,19 @@ PINMAME_VIDEO_UPDATE(mrgame_update_g1) {
0,TRANSPARENCY_NONE,0);
}
}
/* copy the temporary bitmap to the screen with scolling */
/* copy the temporary bitmap to the screen with scrolling */
copyscrollbitmap(tmpbitmap2,tmpbitmap,0,0,32, locals.scrollers,&screen_all_area,TRANSPARENCY_NONE,0);

/* Draw Sprites - Not sure of total size here (this memory size allows 8 sprites on screen at once ) */
for (offs = 0x40; offs < 0x60; offs += 4)
{
unsigned int sx = mrgame_objectram[offs + 3] + 1;
unsigned int sy = 240 - mrgame_objectram[offs];
flipx = mrgame_objectram[offs + 1] & 0x40;
flipy = mrgame_objectram[offs + 1] & 0x80;
tile = (mrgame_objectram[offs + 1] & 0x3f) +
(locals.vid_a11<<6) + (locals.vid_a12<<7) + (locals.vid_a13<<8);
color = mrgame_objectram[offs + 2]; //Note: This byte may have upper bits also used for other things, but no idea what if/any!
unsigned int flipx = mrgame_objectram[offs + 1] & 0x40;
unsigned int flipy = mrgame_objectram[offs + 1] & 0x80;
unsigned int tile = (mrgame_objectram[offs + 1] & 0x3f) +
(locals.vid_a11<<6) + (locals.vid_a12<<7) + (locals.vid_a13<<8);
unsigned int color = mrgame_objectram[offs + 2]; //Note: This byte may have upper bits also used for other things, but no idea what if/any!
drawgfx(tmpbitmap2,Machine->gfx[1],
tile,
color+2, //+2 to offset from PinMAME palette entries
Expand All @@ -739,11 +735,6 @@ PINMAME_VIDEO_UPDATE(mrgame_update_g1) {
PINMAME_VIDEO_UPDATE(mrgame_update_g2) {
size_t offs;
int colorindex = 0;
int tile;
int flipx;
int flipy;
int sx;
int sy;

if (locals.pout2) return 0;

Expand All @@ -755,15 +746,15 @@ PINMAME_VIDEO_UPDATE(mrgame_update_g2) {
{
// dirtybuffer[offs] = 0;

sx = (int)(offs % 32);
sy = (int)(offs / 32);
unsigned int sx = (unsigned int)(offs % 32);
unsigned int sy = (unsigned int)(offs / 32);

colorindex = (colorindex+2);
if(sx==0) colorindex=1;
locals.scrollers[sx] = -mrgame_objectram[colorindex-1];

tile = mrgame_videoram[offs]+
(locals.vid_a11<<8)+(locals.vid_a12<<9)+(locals.vid_a13<<10)+(locals.vid_a14<<11);
unsigned int tile = mrgame_videoram[offs]+
(locals.vid_a11<<8) + (locals.vid_a12<<9) + (locals.vid_a13<<10) + (locals.vid_a14<<11);
drawgfx(tmpbitmap,Machine->gfx[0],
tile,
0, //Always color 0 because there's no color data used
Expand All @@ -772,20 +763,20 @@ PINMAME_VIDEO_UPDATE(mrgame_update_g2) {
0,TRANSPARENCY_NONE,0);
}
}
/* copy the temporary bitmap to the screen with scolling */
/* copy the temporary bitmap to the screen with scrolling */
copyscrollbitmap(tmpbitmap2,tmpbitmap,0,0,32, locals.scrollers,&screen_all_area,TRANSPARENCY_NONE,0);


/* Draw Sprites - Not sure of total size here (this memory size allows 8 sprites on screen at once ) */
/* NOTE: We loop backwards in sprite memory so that we draw the last sprites first so overlapping priority is correct */
for (offs = 0x5f; offs > 0x3F; offs -= 4)
{
sx = mrgame_objectram[offs] + 1;
sy = 240 - mrgame_objectram[offs-3];
flipx = mrgame_objectram[offs - 2] & 0x40;
flipy = mrgame_objectram[offs - 2] & 0x80;
tile = (mrgame_objectram[offs - 2] & 0x3f) +
(locals.vid_a11<<6) + (locals.vid_a12<<7) + (locals.vid_a13<<8) + (locals.vid_a14<<9);
unsigned int sx = mrgame_objectram[offs] + 1;
unsigned int sy = 240 - mrgame_objectram[offs-3];
unsigned int flipx = mrgame_objectram[offs - 2] & 0x40;
unsigned int flipy = mrgame_objectram[offs - 2] & 0x80;
unsigned int tile = (mrgame_objectram[offs - 2] & 0x3f) +
(locals.vid_a11<<6) + (locals.vid_a12<<7) + (locals.vid_a13<<8) + (locals.vid_a14<<9);
//Draw it
if (sx != 1) // seems like sprites rendered at an X offset of 1 should not be rendered?!
drawgfx(tmpbitmap2,Machine->gfx[1],
Expand Down

0 comments on commit 0656042

Please sign in to comment.