diff options
Diffstat (limited to 'src/mame/video/turbo.cpp')
-rw-r--r-- | src/mame/video/turbo.cpp | 161 |
1 files changed, 76 insertions, 85 deletions
diff --git a/src/mame/video/turbo.cpp b/src/mame/video/turbo.cpp index d52f2d9fdfa..723aa15054e 100644 --- a/src/mame/video/turbo.cpp +++ b/src/mame/video/turbo.cpp @@ -352,22 +352,21 @@ uint32_t turbo_state::turbo_get_sprite_bits(uint8_t road, sprite_info *sprinfo) uint32_t turbo_state::screen_update_turbo(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { bitmap_ind16 &fgpixmap = m_fg_tilemap->pixmap(); - const uint8_t *pr1114 = &m_proms[0x000]; - const uint8_t *pr1115 = &m_proms[0x020]; - const uint8_t *pr1116 = &m_proms[0x040]; - const uint8_t *pr1117 = &m_proms[0x060]; - const uint8_t *pr1118 = &m_proms[0x100]; - const uint8_t *pr1121 = &m_proms[0x600]; - const uint8_t *pr1122 = &m_proms[0x800]; - const uint8_t *pr1123 = &m_proms[0xc00]; - int x, y; + uint8_t const *const pr1114 = &m_proms[0x000]; + uint8_t const *const pr1115 = &m_proms[0x020]; + uint8_t const *const pr1116 = &m_proms[0x040]; + uint8_t const *const pr1117 = &m_proms[0x060]; + uint8_t const *const pr1118 = &m_proms[0x100]; + uint8_t const *const pr1121 = &m_proms[0x600]; + uint8_t const *const pr1122 = &m_proms[0x800]; + uint8_t const *const pr1123 = &m_proms[0xc00]; /* loop over rows */ - for (y = cliprect.min_y; y <= cliprect.max_y; y++) + for (int y = cliprect.min_y; y <= cliprect.max_y; y++) { - const uint16_t *fore = &fgpixmap.pix16(y); - uint16_t *dest = &bitmap.pix16(y); - int sel, coch, babit, slipar_acciar, area, offs, areatmp, road = 0; + uint16_t const *const fore = &fgpixmap.pix(y); + uint16_t *const dest = &bitmap.pix(y); + int road = 0; sprite_info sprinfo; /* compute the Y sum between opa and the current scanline (p. 141) */ @@ -382,25 +381,22 @@ uint32_t turbo_state::screen_update_turbo(screen_device &screen, bitmap_ind16 &b turbo_prepare_sprites(y, &sprinfo); /* loop over columns */ - for (x = 0; x <= cliprect.max_x; x += TURBO_X_SCALE) + for (int x = 0; x <= cliprect.max_x; x += TURBO_X_SCALE) { - int bacol, red, grn, blu, priority, foreraw, forebits, mx, ix; int xx = x / TURBO_X_SCALE; - uint8_t carry; - uint32_t sprbits; - uint16_t he; /* load the bitmask from the sprite position for both halves of the sprites (p. 139) */ - he = m_sprite_position[xx] | (m_sprite_position[xx + 0x100] << 8); + uint16_t he = m_sprite_position[xx] | (m_sprite_position[xx + 0x100] << 8); /* the AND of the line enable and horizontal enable is clocked and held in LST0-7 (p. 143) */ he &= sprinfo.ve; sprinfo.lst |= he | (he >> 8); /* compute the X sum between opb and the current column; only the carry matters (p. 141) */ - carry = (xx + m_turbo_opb) >> 8; + uint8_t carry = (xx + m_turbo_opb) >> 8; /* the carry selects which inputs to use (p. 141) */ + int sel, coch; if (carry) { sel = m_turbo_ipb; @@ -413,6 +409,7 @@ uint32_t turbo_state::screen_update_turbo(screen_device &screen, bitmap_ind16 &b } /* look up AREA1 and AREA2 (p. 142) */ + int area, offs, areatmp; offs = va | /* A0- A7 = VA0-VA7 */ ((sel & 0x0f) << 8); /* A8-A11 = SEL0-3 */ @@ -447,27 +444,27 @@ uint32_t turbo_state::screen_update_turbo(screen_device &screen, bitmap_ind16 &b /* compute the final area value and look it up in IC18/PR1115 (p. 144) */ /* note: SLIPAR is 0 on the road surface only */ /* ACCIAR is 0 on the road surface and the striped edges only */ - babit = pr1115[area]; - slipar_acciar = babit & 0x30; + int babit = pr1115[area]; + int slipar_acciar = babit & 0x30; if (!road && (slipar_acciar & 0x20)) road = 1; /* also use the coch value to look up color info in IC13/PR1114 and IC21/PR1117 (p. 144) */ offs = (coch & 0x0f) | /* A0-A3: CONT0-3 = COCH0-3 */ ((m_turbo_fbcol & 0x01) << 4); /* A4: COL0 */ - bacol = pr1114[offs] | (pr1117[offs] << 8); + int bacol = pr1114[offs] | (pr1117[offs] << 8); /* at this point, do the character lookup; due to the shift register loading in */ /* the sync PROM, we latch character 0 during pixel 6 and start clocking in pixel */ /* 8, effectively shifting the display by 8; at pixel 0x108, the color latch is */ /* forced clear and isn't touched until the next shift register load */ - foreraw = (xx < 8 || xx >= 0x108) ? 0 : fore[xx - 8]; + int foreraw = (xx < 8 || xx >= 0x108) ? 0 : fore[xx - 8]; /* perform the foreground color table lookup in IC99/PR1118 (p. 137) */ - forebits = pr1118[foreraw]; + int forebits = pr1118[foreraw]; /* now that we have done all the per-5MHz pixel work, mix the sprites at the scale factor */ - for (ix = 0; ix < TURBO_X_SCALE; ix++) + for (int ix = 0; ix < TURBO_X_SCALE; ix++) { /* iterate over live sprites and update them */ /* the final 32-bit value is: */ @@ -475,18 +472,18 @@ uint32_t turbo_state::screen_update_turbo(screen_device &screen, bitmap_ind16 &b /* CDG0-7 = D8 -D15 */ /* CDR0-7 = D16-D23 */ /* PLB0-7 = D24-D31 */ - sprbits = turbo_get_sprite_bits(road, &sprinfo); + uint32_t sprbits = turbo_get_sprite_bits(road, &sprinfo); /* perform collision detection here via lookup in IC20/PR1116 (p. 144) */ m_turbo_collision |= pr1116[((sprbits >> 24) & 7) | (slipar_acciar >> 1)]; /* look up the sprite priority in IC11/PR1122 (p. 144) */ - priority = ((sprbits & 0xfe000000) >> 25) | /* A0-A6: PLB1-7 */ + int priority = ((sprbits & 0xfe000000) >> 25) | /* A0-A6: PLB1-7 */ ((m_turbo_fbpla & 0x07) << 7); /* A7-A9: PLA0-2 */ priority = pr1122[priority]; /* use that to look up the overall priority in IC12/PR1123 (p. 144) */ - mx = (priority & 7) | /* A0-A2: PR-1122 output, bits 0-2 */ + int mx = (priority & 7) | /* A0-A2: PR-1122 output, bits 0-2 */ ((sprbits & 0x01000000) >> 21) | /* A3: PLB0 */ ((foreraw & 0x80) >> 3) | /* A4: PLBE */ ((forebits & 0x08) << 2) | /* A5: PLBF */ @@ -496,19 +493,19 @@ uint32_t turbo_state::screen_update_turbo(screen_device &screen, bitmap_ind16 &b /* the MX output selects one of 16 inputs; build up a 16-bit pattern to match */ /* these in red, green, and blue (p. 144) */ - red = ((sprbits & 0x0000ff) >> 0) | /* D0- D7: CDR0-CDR7 */ + int red = ((sprbits & 0x0000ff) >> 0) | /* D0- D7: CDR0-CDR7 */ ((forebits & 0x01) << 8) | /* D8: CDRF */ ((bacol & 0x001f) << 9) | /* D9-D13: BAR0-BAR4 */ (1 << 14) | /* D14: 1 */ (0 << 15); /* D15: 0 */ - grn = ((sprbits & 0x00ff00) >> 8) | /* D0- D7: CDG0-CDG7 */ + int grn = ((sprbits & 0x00ff00) >> 8) | /* D0- D7: CDG0-CDG7 */ ((forebits & 0x02) << 7) | /* D8: CDGF */ ((bacol & 0x03e0) << 4) | /* D9-D13: BAG0-BAG4 */ (1 << 14) | /* D14: 1 */ (0 << 15); /* D15: 0 */ - blu = ((sprbits & 0xff0000) >> 16) | /* D0- D7: CDB0-CDB7 */ + int blu = ((sprbits & 0xff0000) >> 16) | /* D0- D7: CDB0-CDB7 */ ((forebits & 0x04) << 6) | /* D8: CDBF */ ((bacol & 0x7c00) >> 1) | /* D9-D13: BAB0-BAB4 */ (1 << 14) | /* D14: 1 */ @@ -703,17 +700,16 @@ uint32_t turbo_state::subroc3d_get_sprite_bits(sprite_info *sprinfo, uint8_t *pl uint32_t turbo_state::screen_update_subroc3d(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { bitmap_ind16 &fgpixmap = m_fg_tilemap->pixmap(); - const uint8_t *pr1419 = &m_proms[0x000]; - const uint8_t *pr1620 = &m_proms[0x200]; - const uint8_t *pr1450 = &m_proms[0x500]; - const uint8_t *pr1454 = &m_proms[0x920]; - int x, y; + uint8_t const *const pr1419 = &m_proms[0x000]; + uint8_t const *const pr1620 = &m_proms[0x200]; + uint8_t const *const pr1450 = &m_proms[0x500]; + uint8_t const *const pr1454 = &m_proms[0x920]; /* loop over rows */ - for (y = cliprect.min_y; y <= cliprect.max_y; y++) + for (int y = cliprect.min_y; y <= cliprect.max_y; y++) { - const uint16_t *fore = &fgpixmap.pix16(y); - uint16_t *dest = &bitmap.pix16(y); + uint16_t const *const fore = &fgpixmap.pix(y); + uint16_t *const dest = &bitmap.pix(y); sprite_info sprinfo; /* compute the sprite information; we use y-1 since this info was computed during HBLANK */ @@ -721,47 +717,48 @@ uint32_t turbo_state::screen_update_subroc3d(screen_device &screen, bitmap_ind16 subroc3d_prepare_sprites(y, &sprinfo); /* loop over columns */ - for (x = 0; x <= cliprect.max_x; x += TURBO_X_SCALE) + for (int x = 0; x <= cliprect.max_x; x += TURBO_X_SCALE) { - int offs, finalbits, ix; uint8_t xx = x / TURBO_X_SCALE; - uint8_t foreraw, forebits, mux, cd, plb, mplb; - uint16_t he; - uint32_t sprbits; /* load the bitmask from the sprite position for both halves of the sprites (p. 143) */ - he = m_sprite_position[xx * 2] | (m_sprite_position[xx * 2 + 1] << 8); + uint16_t he = m_sprite_position[xx * 2] | (m_sprite_position[xx * 2 + 1] << 8); /* the AND of the line enable and horizontal enable is clocked and held in LST0-7 (p. 143) */ he &= sprinfo.ve; sprinfo.lst |= he | (he >> 8); /* at this point, do the character lookup */ + uint8_t foreraw; if (!m_subroc3d_flip) foreraw = fore[xx]; else foreraw = fore[(pr1454[(xx >> 3) & 0x1f] << 3) | (xx & 0x07)]; /* perform the foreground color table lookup in IC62/PR1620 (p. 141) */ - forebits = pr1620[foreraw]; + uint8_t forebits = pr1620[foreraw]; /* MPLB is set based on the high bit of the raw foreground data, as an OR over the output */ /* of the foreground color PROM */ - mplb = (foreraw & 0x80) || ((forebits & 0x0f) == 0); + uint8_t mplb = (foreraw & 0x80) || ((forebits & 0x0f) == 0); /* now that we have done all the per-5MHz pixel work, mix the sprites at the scale factor */ - for (ix = 0; ix < TURBO_X_SCALE; ix++) + for (int ix = 0; ix < TURBO_X_SCALE; ix++) { + int offs; + /* iterate over live sprites and update them */ /* the final 32-bit value is: */ /* CDA0-7 = D0 -D7 */ /* CDB0-7 = D8 -D15 */ /* CDC0-7 = D16-D23 */ /* CDD0-7 = D24-D31 */ - sprbits = subroc3d_get_sprite_bits(&sprinfo, &plb); + uint8_t plb; + uint32_t sprbits = subroc3d_get_sprite_bits(&sprinfo, &plb); /* MUX0-3 is selected by PLY0-3 and the sprite enable bits, and is the output */ /* of IC21/PR1450 (p. 141), unless MPLB = 0, in which case the values are grounded (p. 141) */ + uint8_t mux; if (mplb) { offs = (plb ^ 0xff) | /* A0-A7: /PLB0-7 */ @@ -773,9 +770,10 @@ uint32_t turbo_state::screen_update_subroc3d(screen_device &screen, bitmap_ind16 /* CD0-3 are selected from the sprite bits and MUX0-2 (p. 141) */ sprbits = (sprbits >> (mux & 0x07)) & 0x01010101; - cd = (sprbits >> (24-3)) | (sprbits >> (16-2)) | (sprbits >> (8-1)) | sprbits; + uint8_t cd = (sprbits >> (24-3)) | (sprbits >> (16-2)) | (sprbits >> (8-1)) | sprbits; /* MUX3 selects either CD0-3 or the foreground output (p. 141) */ + int finalbits; if (mux & 0x08) finalbits = cd; else @@ -802,26 +800,23 @@ uint32_t turbo_state::screen_update_subroc3d(screen_device &screen, bitmap_ind16 void turbo_state::buckrog_prepare_sprites(uint8_t y, sprite_info *info) { - const uint8_t *pr5196 = &m_proms[0x100]; - int sprnum; + uint8_t const *const pr5196 = &m_proms[0x100]; /* initialize the line enable signals to 0 */ info->ve = 0; info->lst = 0; /* compute the sprite information, which was done on the previous scanline during HBLANK */ - for (sprnum = 0; sprnum < 16; sprnum++) + for (int sprnum = 0; sprnum < 16; sprnum++) { - uint8_t *rambase = &m_spriteram[sprnum * 8]; + uint8_t *const rambase = &m_spriteram[sprnum * 8]; int level = sprnum & 7; - uint8_t clo, chi; - uint32_t sum; /* perform the first ALU to see if we are within the scanline */ - sum = y + (rambase[0]/* ^ 0xff*/); - clo = (sum >> 8) & 1; + uint32_t sum = y + (rambase[0]/* ^ 0xff*/); + uint8_t clo = (sum >> 8) & 1; sum += (y << 8) + ((rambase[1]/* ^ 0xff*/) << 8); - chi = (sum >> 16) & 1; + uint8_t chi = (sum >> 16) & 1; /* the AND of the low carry and the inverse of the high carry clocks an enable bit */ /* for this sprite; note that the logic in the Turbo schematics is reversed here */ @@ -830,7 +825,6 @@ void turbo_state::buckrog_prepare_sprites(uint8_t y, sprite_info *info) int xscale = rambase[2] ^ 0xff; int yscale = rambase[3];// ^ 0xff; uint16_t offset = rambase[6] + (rambase[7] << 8); - int offs; /* mark this entry enabled */ info->ve |= 1 << sprnum; @@ -838,7 +832,7 @@ void turbo_state::buckrog_prepare_sprites(uint8_t y, sprite_info *info) /* look up the low byte of the sum plus the yscale value in */ /* IC50/PR1119 to determine if we write back the sum of the */ /* offset and the rowbytes this scanline (p. 138) */ - offs = (sum & 0xff) | /* A0-A7 = AL0-AL7 */ + int offs = (sum & 0xff) | /* A0-A7 = AL0-AL7 */ ((yscale & 0x08) << 5); /* A8-A9 = /RO11-/RO12 */ /* one of the bits is selected based on the low 7 bits of yscale */ @@ -870,12 +864,11 @@ uint32_t turbo_state::buckrog_get_sprite_bits(sprite_info *sprinfo, uint8_t *plb */ static const uint8_t plb_end[16] = { 0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,2 }; uint32_t sprdata = 0; - int level; *plb = 0; /* loop over all live levels */ - for (level = 0; level < 8; level++) + for (int level = 0; level < 8; level++) if (sprinfo->lst & (1 << level)) { /* latch the data and advance the offset */ @@ -887,12 +880,11 @@ uint32_t turbo_state::buckrog_get_sprite_bits(sprite_info *sprinfo, uint8_t *plb while (sprinfo->frac[level] >= 0x800000) { uint32_t offs = sprinfo->offset[level]; - uint8_t pixdata; /* bit 0 controls which half of the byte to use */ /* bits 1-13 go to address lines */ /* bit 14 selects which of the two ROMs to read from */ - pixdata = m_spriteroms[(level << 15) | ((offs >> 1) & 0x7fff)] >> ((~offs & 1) * 4); + uint8_t pixdata = m_spriteroms[(level << 15) | ((offs >> 1) & 0x7fff)] >> ((~offs & 1) * 4); sprinfo->latched[level] = sprite_expand[pixdata & 0x0f] << level; sprinfo->plb[level] = (plb_end[pixdata & 0x0f] & 1) << level; @@ -920,16 +912,15 @@ uint32_t turbo_state::buckrog_get_sprite_bits(sprite_info *sprinfo, uint8_t *plb uint32_t turbo_state::screen_update_buckrog(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { bitmap_ind16 &fgpixmap = m_fg_tilemap->pixmap(); - const uint8_t *pr5194 = &m_proms[0x000]; - const uint8_t *pr5198 = &m_proms[0x500]; - const uint8_t *pr5199 = &m_proms[0x700]; - int x, y; + uint8_t const *const pr5194 = &m_proms[0x000]; + uint8_t const *const pr5198 = &m_proms[0x500]; + uint8_t const *const pr5199 = &m_proms[0x700]; /* loop over rows */ - for (y = cliprect.min_y; y <= cliprect.max_y; y++) + for (int y = cliprect.min_y; y <= cliprect.max_y; y++) { - const uint16_t *fore = &fgpixmap.pix16(y); - uint16_t *dest = &bitmap.pix16(y); + uint16_t const *const fore = &fgpixmap.pix(y); + uint16_t *const dest = &bitmap.pix(y); sprite_info sprinfo; /* compute the sprite information; we use y-1 since this info was computed during HBLANK */ @@ -937,33 +928,30 @@ uint32_t turbo_state::screen_update_buckrog(screen_device &screen, bitmap_ind16 buckrog_prepare_sprites(y, &sprinfo); /* loop over columns */ - for (x = 0; x <= cliprect.max_x; x += TURBO_X_SCALE) + for (int x = 0; x <= cliprect.max_x; x += TURBO_X_SCALE) { - uint8_t foreraw, forebits, cd, plb, star, mux; uint8_t xx = x / TURBO_X_SCALE; - uint16_t he; - uint32_t sprbits; - int palbits, offs, ix; + int offs; /* load the bitmask from the sprite position for both halves of the sprites (p. 143) */ - he = m_sprite_position[xx * 2] | (m_sprite_position[xx * 2 + 1] << 8); + uint16_t he = m_sprite_position[xx * 2] | (m_sprite_position[xx * 2 + 1] << 8); /* the AND of the line enable and horizontal enable is clocked and held in LST0-7 (p. 143) */ he &= sprinfo.ve; sprinfo.lst |= he | (he >> 8); /* at this point, do the character lookup and the foreground color table lookup in IC93/PR1598 (SH 5/5)*/ - foreraw = fore[(pr5194[((xx >> 3) - 1) & 0x1f] << 3) | (xx & 0x07)]; + uint8_t foreraw = fore[(pr5194[((xx >> 3) - 1) & 0x1f] << 3) | (xx & 0x07)]; offs = ((foreraw & 0x03) << 0) | /* A0-A1: BIT0-1 */ ((foreraw & 0xf8) >> 1) | /* A2-A6: BANK3-7 */ ((m_buckrog_fchg & 0x03) << 7); /* A7-A9: FCHG0-2 */ - forebits = pr5198[offs]; + uint8_t forebits = pr5198[offs]; /* fetch the STAR bit */ - star = m_buckrog_bitmap_ram[y * 256 + xx]; + uint8_t star = m_buckrog_bitmap_ram[y * 256 + xx]; /* now that we have done all the per-5MHz pixel work, mix the sprites at the scale factor */ - for (ix = 0; ix < TURBO_X_SCALE; ix++) + for (int ix = 0; ix < TURBO_X_SCALE; ix++) { /* iterate over live sprites and update them */ /* the final 32-bit value is: */ @@ -971,9 +959,11 @@ uint32_t turbo_state::screen_update_buckrog(screen_device &screen, bitmap_ind16 /* CDB0-7 = D8 -D15 */ /* CDC0-7 = D16-D23 */ /* CDD0-7 = D24-D31 */ - sprbits = buckrog_get_sprite_bits(&sprinfo, &plb); + uint8_t plb; + uint32_t sprbits = buckrog_get_sprite_bits(&sprinfo, &plb); /* the PLB bits go into an LS148 8-to-1 decoder and become MUX0-3 (PROM board SH 2/10) */ + uint8_t mux; if (plb == 0) mux = 8; else @@ -988,11 +978,12 @@ uint32_t turbo_state::screen_update_buckrog(screen_device &screen, bitmap_ind16 /* MUX then selects one of the sprites and selects CD0-3 */ sprbits = (sprbits >> (mux & 0x07)) & 0x01010101; - cd = (sprbits >> (24-3)) | (sprbits >> (16-2)) | (sprbits >> (8-1)) | sprbits; + uint8_t cd = (sprbits >> (24-3)) | (sprbits >> (16-2)) | (sprbits >> (8-1)) | sprbits; /* this info goes into an LS148 8-to-3 decoder to determine the priorities (SH 5/5) */ /* priority 7 is if bit 0x80 of the foreground color is 0; CHNG = 0 */ + int palbits; if (!(forebits & 0x80)) { palbits = ((forebits & 0x3c) << 2) | |