src/mess/video/cpschngr.c
| r4407 | r4408 | |
| 1 | | /***************************************************************************
|
| 2 | | |
| 3 | | CPS Changer
|
| 4 | | |
| 5 | | ***************************************************************************/
|
| 6 | | |
| 7 | | #include "driver.h"
|
| 8 | | #include "cps1.h"
|
| 9 | | |
| 10 | | /********************************************************************
|
| 11 | | |
| 12 | | Configuration table:
|
| 13 | | |
| 14 | | ********************************************************************/
|
| 15 | | |
| 16 | | /* Game specific data */
|
| 17 | | |
| 18 | | #define GFXTYPE_SPRITES (1<<0)
|
| 19 | | #define GFXTYPE_SCROLL1 (1<<1)
|
| 20 | | #define GFXTYPE_SCROLL2 (1<<2)
|
| 21 | | #define GFXTYPE_SCROLL3 (1<<3)
|
| 22 | | #define GFXTYPE_STARS (1<<4)
|
| 23 | | |
| 24 | | |
| 25 | | struct gfx_range
|
| 26 | | {
|
| 27 | | // start and end are as passed by the game (shift adjusted to be all
|
| 28 | | // in the same scale a 8x8 tiles): they don't necessarily match the
|
| 29 | | // position in ROM.
|
| 30 | | int type;
|
| 31 | | int start;
|
| 32 | | int end;
|
| 33 | | int bank;
|
| 34 | | };
|
| 35 | | |
| 36 | | struct CPS1config
|
| 37 | | {
|
| 38 | | const char *name; /* game driver name */
|
| 39 | | |
| 40 | | /* Some games interrogate a couple of registers on bootup. */
|
| 41 | | /* These are CPS1 board B self test checks. They wander from game to */
|
| 42 | | /* game. */
|
| 43 | | int cpsb_addr; /* CPS board B test register address */
|
| 44 | | int cpsb_value; /* CPS board B test register expected value */
|
| 45 | | |
| 46 | | /* some games use as a protection check the ability to do 16-bit multiplies */
|
| 47 | | /* with a 32-bit result, by writing the factors to two ports and reading the */
|
| 48 | | /* result from two other ports. */
|
| 49 | | /* It looks like this feature was introduced with 3wonders (CPSB ID = 08xx) */
|
| 50 | | int mult_factor1;
|
| 51 | | int mult_factor2;
|
| 52 | | int mult_result_lo;
|
| 53 | | int mult_result_hi;
|
| 54 | | |
| 55 | | /* unknown registers which might be related to the multiply protection */
|
| 56 | | int unknown1;
|
| 57 | | int unknown2;
|
| 58 | | int unknown3;
|
| 59 | | |
| 60 | | int layer_control;
|
| 61 | | int priority[4];
|
| 62 | | int palette_control;
|
| 63 | | |
| 64 | | /* ideally, the layer enable masks should consist of only one bit, */
|
| 65 | | /* but in many cases it is unknown which bit is which. */
|
| 66 | | int layer_enable_mask[5];
|
| 67 | | |
| 68 | | /* these depend on the B-board model and PAL */
|
| 69 | | int bank_sizes[4];
|
| 70 | | const struct gfx_range *bank_mapper;
|
| 71 | | |
| 72 | | /* some C-boards have additional I/O for extra buttons/extra players */
|
| 73 | | int in2_addr;
|
| 74 | | int in3_addr;
|
| 75 | | int out2_addr;
|
| 76 | | |
| 77 | | int bootleg_kludge;
|
| 78 | | };
|
| 79 | | |
| 80 | | static const struct CPS1config *cps1_game_config;
|
| 81 | | |
| 82 | | |
| 83 | | #define __not_applicable__ -1,-1,-1,-1,-1,-1,-1
|
| 84 | | |
| 85 | | /* CPSB ID multiply protection unknown ctrl priority masks palctrl layer enable masks */
|
| 86 | | #define CPS_B_21_DEF 0x32, -1, 0x00,0x02,0x04,0x06, 0x08, -1, -1, 0x26,{0x28,0x2a,0x2c,0x2e},0x30, {0x02,0x04,0x08,0x30,0x30} // pang3 sets layer enable to 0x26 on startup
|
| 87 | | |
| 88 | | #define mapper_sfzch { 0x20000, 0, 0, 0 }, mapper_sfzch_table
|
| 89 | | static const struct gfx_range mapper_sfzch_table[] =
|
| 90 | | {
|
| 91 | | /* type start end bank */
|
| 92 | | { GFXTYPE_SPRITES | GFXTYPE_SCROLL1 | GFXTYPE_SCROLL2 | GFXTYPE_SCROLL3, 0x00000, 0x1ffff, 0 },
|
| 93 | | { 0 }
|
| 94 | | };
|
| 95 | | |
| 96 | | static const struct CPS1config cps1_config_table[]=
|
| 97 | | {
|
| 98 | | /* name CPSB gfx mapper in2 in3 out2 kludge */
|
| 99 | | {"sfach", CPS_B_21_DEF, mapper_sfzch },
|
| 100 | | {"sfzbch", CPS_B_21_DEF, mapper_sfzch },
|
| 101 | | {"sfzch", CPS_B_21_DEF, mapper_sfzch },
|
| 102 | | {"wofch", CPS_B_21_DEF, mapper_sfzch },
|
| 103 | | {0} /* End of table */
|
| 104 | | };
|
| 105 | | |
| 106 | | |
| 107 | | |
| 108 | | /* Public variables */
|
| 109 | | UINT16 *cps1_gfxram;
|
| 110 | | UINT16 *cps1_cps_a_regs;
|
| 111 | | UINT16 *cps1_cps_b_regs;
|
| 112 | | |
| 113 | | size_t cps1_gfxram_size;
|
| 114 | | |
| 115 | | /* Offset of each palette entry */
|
| 116 | | #define cps1_palette_entries (32*6) /* Number colour schemes in palette */
|
| 117 | | |
| 118 | | static const int cps1_scroll_size =0x4000; /* scroll1, scroll2, scroll3 */
|
| 119 | | static const int cps1_obj_size =0x0800;
|
| 120 | | static const int cps1_other_size =0x0800;
|
| 121 | | static const int cps1_palette_align=0x0400; /* minimum alignment is a single palette page (512 colors). Verified on pcb. */
|
| 122 | | static const int cps1_palette_size=cps1_palette_entries*32; /* Size of palette RAM */
|
| 123 | | |
| 124 | | static UINT16 *cps1_scroll1;
|
| 125 | | static UINT16 *cps1_scroll2;
|
| 126 | | static UINT16 *cps1_scroll3;
|
| 127 | | static UINT16 *cps1_obj;
|
| 128 | | static UINT16 *cps1_buffered_obj;
|
| 129 | | static UINT16 *cps1_other;
|
| 130 | | |
| 131 | | /* Working variables */
|
| 132 | | static int cps1_last_sprite_offset; /* Offset of the last sprite */
|
| 133 | | static int cps1_stars_enabled[2]; /* Layer enabled [Y/N] */
|
| 134 | | |
| 135 | | static tilemap *cps1_bg_tilemap[3];
|
| 136 | | |
| 137 | | |
| 138 | | static int cps1_scroll1x, cps1_scroll1y;
|
| 139 | | static int cps1_scroll2x, cps1_scroll2y;
|
| 140 | | static int cps1_scroll3x, cps1_scroll3y;
|
| 141 | | static int stars1x, stars1y, stars2x, stars2y;
|
| 142 | | |
| 143 | | |
| 144 | | /* CPS-A registers */
|
| 145 | | #define CPS1_OBJ_BASE (0x00/2) /* Base address of objects */
|
| 146 | | #define CPS1_SCROLL1_BASE (0x02/2) /* Base address of scroll 1 */
|
| 147 | | #define CPS1_SCROLL2_BASE (0x04/2) /* Base address of scroll 2 */
|
| 148 | | #define CPS1_SCROLL3_BASE (0x06/2) /* Base address of scroll 3 */
|
| 149 | | #define CPS1_OTHER_BASE (0x08/2) /* Base address of other video */
|
| 150 | | #define CPS1_PALETTE_BASE (0x0a/2) /* Base address of palette */
|
| 151 | | #define CPS1_SCROLL1_SCROLLX (0x0c/2) /* Scroll 1 X */
|
| 152 | | #define CPS1_SCROLL1_SCROLLY (0x0e/2) /* Scroll 1 Y */
|
| 153 | | #define CPS1_SCROLL2_SCROLLX (0x10/2) /* Scroll 2 X */
|
| 154 | | #define CPS1_SCROLL2_SCROLLY (0x12/2) /* Scroll 2 Y */
|
| 155 | | #define CPS1_SCROLL3_SCROLLX (0x14/2) /* Scroll 3 X */
|
| 156 | | #define CPS1_SCROLL3_SCROLLY (0x16/2) /* Scroll 3 Y */
|
| 157 | | #define CPS1_STARS1_SCROLLX (0x18/2) /* Stars 1 X */
|
| 158 | | #define CPS1_STARS1_SCROLLY (0x1a/2) /* Stars 1 Y */
|
| 159 | | #define CPS1_STARS2_SCROLLX (0x1c/2) /* Stars 2 X */
|
| 160 | | #define CPS1_STARS2_SCROLLY (0x1e/2) /* Stars 2 Y */
|
| 161 | | #define CPS1_ROWSCROLL_OFFS (0x20/2) /* base of row scroll offsets in other RAM */
|
| 162 | | #define CPS1_VIDEOCONTROL (0x22/2) /* flip screen, rowscroll enable */
|
| 163 | | |
| 164 | | |
| 165 | | /* first 0x4000 of gfx ROM are used, but 0x0000-0x1fff is == 0x2000-0x3fff */
|
| 166 | | static const int stars_rom_size = 0x2000;
|
| 167 | | |
| 168 | | static void cps1_build_palette(running_machine *machine, const UINT16* const palette_base);
|
| 169 | | |
| 170 | | |
| 171 | | static MACHINE_RESET( cps )
|
| 172 | | {
|
| 173 | | const char *gamename = machine->gamedrv->name;
|
| 174 | | const struct CPS1config *pCFG=&cps1_config_table[0];
|
| 175 | | |
| 176 | | while(pCFG->name)
|
| 177 | | {
|
| 178 | | if (strcmp(pCFG->name, gamename) == 0)
|
| 179 | | {
|
| 180 | | break;
|
| 181 | | }
|
| 182 | | pCFG++;
|
| 183 | | }
|
| 184 | | cps1_game_config=pCFG;
|
| 185 | | }
|
| 186 | | |
| 187 | | |
| 188 | | INLINE UINT16 *cps1_base(int offset,int boundary)
|
| 189 | | {
|
| 190 | | int base = cps1_cps_a_regs[offset]*256;
|
| 191 | | base &= ~(boundary-1);
|
| 192 | | return &cps1_gfxram[(base&0x3ffff)/2];
|
| 193 | | }
|
| 194 | | |
| 195 | | |
| 196 | | |
| 197 | | WRITE16_HANDLER( cps1_cps_a_w )
|
| 198 | | {
|
| 199 | | data = COMBINE_DATA(&cps1_cps_a_regs[offset]);
|
| 200 | | |
| 201 | | if (offset == CPS1_PALETTE_BASE)
|
| 202 | | cps1_build_palette(space->machine, cps1_base(CPS1_PALETTE_BASE,cps1_palette_align));
|
| 203 | | }
|
| 204 | | |
| 205 | | |
| 206 | | READ16_HANDLER( cps1_cps_b_r )
|
| 207 | | {
|
| 208 | | /* Some games interrogate a couple of registers on bootup. */
|
| 209 | | /* These are CPS1 board B self test checks. They wander from game to */
|
| 210 | | /* game. */
|
| 211 | | if (offset == cps1_game_config->cpsb_addr/2)
|
| 212 | | return cps1_game_config->cpsb_value;
|
| 213 | | |
| 214 | | /* some games use as a protection check the ability to do 16-bit multiplications */
|
| 215 | | /* with a 32-bit result, by writing the factors to two ports and reading the */
|
| 216 | | /* result from two other ports. */
|
| 217 | | if (offset == cps1_game_config->mult_result_lo/2)
|
| 218 | | return (cps1_cps_b_regs[cps1_game_config->mult_factor1/2] *
|
| 219 | | cps1_cps_b_regs[cps1_game_config->mult_factor2/2]) & 0xffff;
|
| 220 | | if (offset == cps1_game_config->mult_result_hi/2)
|
| 221 | | return (cps1_cps_b_regs[cps1_game_config->mult_factor1/2] *
|
| 222 | | cps1_cps_b_regs[cps1_game_config->mult_factor2/2]) >> 16;
|
| 223 | | |
| 224 | | if (offset == cps1_game_config->in2_addr/2) /* Extra input ports (on C-board) */
|
| 225 | | return input_port_read(space->machine, "IN2");
|
| 226 | | |
| 227 | | if (offset == cps1_game_config->in3_addr/2) /* Player 4 controls (on C-board) ("Captain Commando") */
|
| 228 | | return input_port_read(space->machine, "IN3");
|
| 229 | | |
| 230 | | return 0xffff;
|
| 231 | | }
|
| 232 | | |
| 233 | | |
| 234 | | WRITE16_HANDLER( cps1_cps_b_w )
|
| 235 | | {
|
| 236 | | data = COMBINE_DATA(&cps1_cps_b_regs[offset]);
|
| 237 | | |
| 238 | | // additional outputs on C-board
|
| 239 | | if (offset == cps1_game_config->out2_addr/2)
|
| 240 | | {
|
| 241 | | if (ACCESSING_BITS_0_7)
|
| 242 | | {
|
| 243 | | if (cps1_game_config->cpsb_value == 0x0402) // Mercs (CN2 connector)
|
| 244 | | {
|
| 245 | | coin_lockout_w(2,~data & 0x01);
|
| 246 | | set_led_status(0,data & 0x02);
|
| 247 | | set_led_status(1,data & 0x04);
|
| 248 | | set_led_status(2,data & 0x08);
|
| 249 | | }
|
| 250 | | else // kod, captcomm, knights
|
| 251 | | {
|
| 252 | | coin_lockout_w(2,~data & 0x02);
|
| 253 | | coin_lockout_w(3,~data & 0x08);
|
| 254 | | }
|
| 255 | | }
|
| 256 | | }
|
| 257 | | }
|
| 258 | | |
| 259 | | |
| 260 | | |
| 261 | | static void cps1_gfx_decode(running_machine *machine)
|
| 262 | | {
|
| 263 | | int size=memory_region_length(machine, "gfx");
|
| 264 | | int i,j,gfxsize;
|
| 265 | | UINT8 *cps1_gfx = memory_region(machine, "gfx");
|
| 266 | | |
| 267 | | |
| 268 | | gfxsize=size/4;
|
| 269 | | |
| 270 | | for (i = 0;i < gfxsize;i++)
|
| 271 | | {
|
| 272 | | UINT32 src = cps1_gfx[4*i] + (cps1_gfx[4*i+1]<<8) + (cps1_gfx[4*i+2]<<16) + (cps1_gfx[4*i+3]<<24);
|
| 273 | | UINT32 dwval = 0;
|
| 274 | | |
| 275 | | for (j = 0;j < 8;j++)
|
| 276 | | {
|
| 277 | | int n = 0;
|
| 278 | | UINT32 mask = (0x80808080 >> j) & src;
|
| 279 | | |
| 280 | | if (mask & 0x000000ff) n |= 1;
|
| 281 | | if (mask & 0x0000ff00) n |= 2;
|
| 282 | | if (mask & 0x00ff0000) n |= 4;
|
| 283 | | if (mask & 0xff000000) n |= 8;
|
| 284 | | |
| 285 | | dwval |= n << (j * 4);
|
| 286 | | }
|
| 287 | | cps1_gfx[4*i ] = dwval>>0;
|
| 288 | | cps1_gfx[4*i+1] = dwval>>8;
|
| 289 | | cps1_gfx[4*i+2] = dwval>>16;
|
| 290 | | cps1_gfx[4*i+3] = dwval>>24;
|
| 291 | | }
|
| 292 | | }
|
| 293 | | |
| 294 | | static void unshuffle(UINT64 *buf,int len)
|
| 295 | | {
|
| 296 | | int i;
|
| 297 | | UINT64 t;
|
| 298 | | |
| 299 | | if (len == 2) return;
|
| 300 | | |
| 301 | | assert(len % 4 == 0); /* must not happen */
|
| 302 | | |
| 303 | | len /= 2;
|
| 304 | | |
| 305 | | unshuffle(buf,len);
|
| 306 | | unshuffle(buf + len,len);
|
| 307 | | |
| 308 | | for (i = 0;i < len/2;i++)
|
| 309 | | {
|
| 310 | | t = buf[len/2 + i];
|
| 311 | | buf[len/2 + i] = buf[len + i];
|
| 312 | | buf[len + i] = t;
|
| 313 | | }
|
| 314 | | }
|
| 315 | | |
| 316 | | |
| 317 | | DRIVER_INIT( cps1 )
|
| 318 | | {
|
| 319 | | cps1_gfx_decode(machine);
|
| 320 | | }
|
| 321 | | |
| 322 | | |
| 323 | | static void cps1_get_video_base(void )
|
| 324 | | {
|
| 325 | | int layercontrol, videocontrol, scroll1xoff, scroll2xoff, scroll3xoff;
|
| 326 | | |
| 327 | | /* Re-calculate the VIDEO RAM base */
|
| 328 | | if (cps1_scroll1 != cps1_base(CPS1_SCROLL1_BASE,cps1_scroll_size))
|
| 329 | | {
|
| 330 | | cps1_scroll1 = cps1_base(CPS1_SCROLL1_BASE,cps1_scroll_size);
|
| 331 | | tilemap_mark_all_tiles_dirty(cps1_bg_tilemap[0]);
|
| 332 | | }
|
| 333 | | if (cps1_scroll2 != cps1_base(CPS1_SCROLL2_BASE,cps1_scroll_size))
|
| 334 | | {
|
| 335 | | cps1_scroll2 = cps1_base(CPS1_SCROLL2_BASE,cps1_scroll_size);
|
| 336 | | tilemap_mark_all_tiles_dirty(cps1_bg_tilemap[1]);
|
| 337 | | }
|
| 338 | | if (cps1_scroll3 != cps1_base(CPS1_SCROLL3_BASE,cps1_scroll_size))
|
| 339 | | {
|
| 340 | | cps1_scroll3 = cps1_base(CPS1_SCROLL3_BASE,cps1_scroll_size);
|
| 341 | | tilemap_mark_all_tiles_dirty(cps1_bg_tilemap[2]);
|
| 342 | | }
|
| 343 | | |
| 344 | | /* Some of the sf2 hacks use only sprite port 0x9100 and the scroll layers are offset */
|
| 345 | | if (cps1_game_config->bootleg_kludge == 1)
|
| 346 | | {
|
| 347 | | cps1_cps_a_regs[CPS1_OBJ_BASE] = 0x9100;
|
| 348 | | cps1_obj = cps1_base(CPS1_OBJ_BASE, cps1_obj_size);
|
| 349 | | scroll1xoff = -0x0c;
|
| 350 | | scroll2xoff = -0x0e;
|
| 351 | | scroll3xoff = -0x10;
|
| 352 | | }
|
| 353 | | else
|
| 354 | | {
|
| 355 | | cps1_obj = cps1_base(CPS1_OBJ_BASE, cps1_obj_size);
|
| 356 | | scroll1xoff = 0;
|
| 357 | | scroll2xoff = 0;
|
| 358 | | scroll3xoff = 0;
|
| 359 | | }
|
| 360 | | cps1_other = cps1_base(CPS1_OTHER_BASE,cps1_other_size);
|
| 361 | | |
| 362 | | /* Get scroll values */
|
| 363 | | cps1_scroll1x = cps1_cps_a_regs[CPS1_SCROLL1_SCROLLX] + scroll1xoff;
|
| 364 | | cps1_scroll1y = cps1_cps_a_regs[CPS1_SCROLL1_SCROLLY];
|
| 365 | | cps1_scroll2x = cps1_cps_a_regs[CPS1_SCROLL2_SCROLLX] + scroll2xoff;
|
| 366 | | cps1_scroll2y = cps1_cps_a_regs[CPS1_SCROLL2_SCROLLY];
|
| 367 | | cps1_scroll3x = cps1_cps_a_regs[CPS1_SCROLL3_SCROLLX] + scroll3xoff;
|
| 368 | | cps1_scroll3y = cps1_cps_a_regs[CPS1_SCROLL3_SCROLLY];
|
| 369 | | stars1x = cps1_cps_a_regs[CPS1_STARS1_SCROLLX];
|
| 370 | | stars1y = cps1_cps_a_regs[CPS1_STARS1_SCROLLY];
|
| 371 | | stars2x = cps1_cps_a_regs[CPS1_STARS2_SCROLLX];
|
| 372 | | stars2y = cps1_cps_a_regs[CPS1_STARS2_SCROLLY];
|
| 373 | | |
| 374 | | /* Get layer enable bits */
|
| 375 | | layercontrol = cps1_cps_b_regs[cps1_game_config->layer_control/2];
|
| 376 | | videocontrol = cps1_cps_a_regs[CPS1_VIDEOCONTROL];
|
| 377 | | tilemap_set_enable(cps1_bg_tilemap[0],layercontrol & cps1_game_config->layer_enable_mask[0]);
|
| 378 | | tilemap_set_enable(cps1_bg_tilemap[1],(layercontrol & cps1_game_config->layer_enable_mask[1]) && (videocontrol & 4));
|
| 379 | | tilemap_set_enable(cps1_bg_tilemap[2],(layercontrol & cps1_game_config->layer_enable_mask[2]) && (videocontrol & 8));
|
| 380 | | cps1_stars_enabled[0] = layercontrol & cps1_game_config->layer_enable_mask[3];
|
| 381 | | cps1_stars_enabled[1] = layercontrol & cps1_game_config->layer_enable_mask[4];
|
| 382 | | }
|
| 383 | | |
| 384 | | |
| 385 | | WRITE16_HANDLER( cps1_gfxram_w )
|
| 386 | | {
|
| 387 | | int page = (offset >> 7) & 0x3c0;
|
| 388 | | COMBINE_DATA(&cps1_gfxram[offset]);
|
| 389 | | |
| 390 | | if (page == (cps1_cps_a_regs[CPS1_SCROLL1_BASE] & 0x3c0))
|
| 391 | | tilemap_mark_tile_dirty(cps1_bg_tilemap[0],offset/2 & 0x0fff);
|
| 392 | | if (page == (cps1_cps_a_regs[CPS1_SCROLL2_BASE] & 0x3c0))
|
| 393 | | tilemap_mark_tile_dirty(cps1_bg_tilemap[1],offset/2 & 0x0fff);
|
| 394 | | if (page == (cps1_cps_a_regs[CPS1_SCROLL3_BASE] & 0x3c0))
|
| 395 | | tilemap_mark_tile_dirty(cps1_bg_tilemap[2],offset/2 & 0x0fff);
|
| 396 | | }
|
| 397 | | |
| 398 | | |
| 399 | | |
| 400 | | static int gfxrom_bank_mapper(running_machine *machine, int type, int code)
|
| 401 | | {
|
| 402 | | const struct gfx_range *range = cps1_game_config->bank_mapper;
|
| 403 | | int shift = 0;
|
| 404 | | |
| 405 | | assert(range);
|
| 406 | | |
| 407 | | switch (type)
|
| 408 | | {
|
| 409 | | case GFXTYPE_SPRITES: shift = 1; break;
|
| 410 | | case GFXTYPE_SCROLL1: shift = 0; break;
|
| 411 | | case GFXTYPE_SCROLL2: shift = 1; break;
|
| 412 | | case GFXTYPE_SCROLL3: shift = 3; break;
|
| 413 | | }
|
| 414 | | |
| 415 | | code <<= shift;
|
| 416 | | |
| 417 | | while (range->type)
|
| 418 | | {
|
| 419 | | if (code >= range->start && code <= range->end)
|
| 420 | | {
|
| 421 | | if (range->type & type)
|
| 422 | | {
|
| 423 | | int base = 0;
|
| 424 | | int i;
|
| 425 | | |
| 426 | | for (i = 0; i < range->bank; ++i)
|
| 427 | | base += cps1_game_config->bank_sizes[i];
|
| 428 | | |
| 429 | | return (base + (code & (cps1_game_config->bank_sizes[range->bank] - 1))) >> shift;
|
| 430 | | }
|
| 431 | | }
|
| 432 | | |
| 433 | | ++range;
|
| 434 | | }
|
| 435 | | |
| 436 | | return -1;
|
| 437 | | }
|
| 438 | | |
| 439 | | |
| 440 | | /***************************************************************************
|
| 441 | | |
| 442 | | Start the video hardware emulation.
|
| 443 | | |
| 444 | | ***************************************************************************/
|
| 445 | | |
| 446 | | static TILEMAP_MAPPER( tilemap0_scan )
|
| 447 | | {
|
| 448 | | /* logical (col,row) -> memory offset */
|
| 449 | | return (row & 0x1f) + ((col & 0x3f) << 5) + ((row & 0x20) << 6);
|
| 450 | | }
|
| 451 | | |
| 452 | | static TILEMAP_MAPPER( tilemap1_scan )
|
| 453 | | {
|
| 454 | | /* logical (col,row) -> memory offset */
|
| 455 | | return (row & 0x0f) + ((col & 0x3f) << 4) + ((row & 0x30) << 6);
|
| 456 | | }
|
| 457 | | |
| 458 | | static TILEMAP_MAPPER( tilemap2_scan )
|
| 459 | | {
|
| 460 | | /* logical (col,row) -> memory offset */
|
| 461 | | return (row & 0x07) + ((col & 0x3f) << 3) + ((row & 0x38) << 6);
|
| 462 | | }
|
| 463 | | |
| 464 | | static UINT8 empty_tile8x8[8*8];
|
| 465 | | static UINT8 empty_tile[32*32/2];
|
| 466 | | |
| 467 | | static TILE_GET_INFO( get_tile0_info )
|
| 468 | | {
|
| 469 | | int code = cps1_scroll1[2*tile_index];
|
| 470 | | int attr = cps1_scroll1[2*tile_index+1];
|
| 471 | | int gfxset;
|
| 472 | | |
| 473 | | code = gfxrom_bank_mapper(machine, GFXTYPE_SCROLL1, code);
|
| 474 | | |
| 475 | | /* allows us to reproduce a problem seen with a ffight board where USA and Japanese
|
| 476 | | roms have been mixed to be reproduced (ffightua) -- it looks like each column
|
| 477 | | should alternate between the left and right side of the 16x16 tiles */
|
| 478 | | gfxset = (tile_index & 0x20) >> 5;
|
| 479 | | |
| 480 | | SET_TILE_INFO(
|
| 481 | | gfxset,
|
| 482 | | code,
|
| 483 | | (attr & 0x1f) + 0x20,
|
| 484 | | TILE_FLIPYX((attr & 0x60) >> 5));
|
| 485 | | tileinfo->group = (attr & 0x0180) >> 7;
|
| 486 | | |
| 487 | | // for out of range tiles, switch to fully transparent data
|
| 488 | | // (but still call SET_TILE_INFO, otherwise problems might occur on boot e.g. unsquad)
|
| 489 | | if (code == -1)
|
| 490 | | tileinfo->pen_data = empty_tile8x8;
|
| 491 | | }
|
| 492 | | |
| 493 | | static TILE_GET_INFO( get_tile1_info )
|
| 494 | | {
|
| 495 | | int code = cps1_scroll2[2*tile_index];
|
| 496 | | int attr = cps1_scroll2[2*tile_index+1];
|
| 497 | | |
| 498 | | code = gfxrom_bank_mapper(machine, GFXTYPE_SCROLL2, code);
|
| 499 | | |
| 500 | | SET_TILE_INFO(
|
| 501 | | 2,
|
| 502 | | code,
|
| 503 | | (attr & 0x1f) + 0x40,
|
| 504 | | TILE_FLIPYX((attr & 0x60) >> 5));
|
| 505 | | tileinfo->group = (attr & 0x0180) >> 7;
|
| 506 | | |
| 507 | | // for out of range tiles, switch to fully transparent data
|
| 508 | | if (code == -1)
|
| 509 | | tileinfo->pen_data = empty_tile;
|
| 510 | | }
|
| 511 | | |
| 512 | | static TILE_GET_INFO( get_tile2_info )
|
| 513 | | {
|
| 514 | | int code = cps1_scroll3[2*tile_index] & 0x3fff;
|
| 515 | | int attr = cps1_scroll3[2*tile_index+1];
|
| 516 | | |
| 517 | | code = gfxrom_bank_mapper(machine, GFXTYPE_SCROLL3, code);
|
| 518 | | |
| 519 | | SET_TILE_INFO(
|
| 520 | | 3,
|
| 521 | | code,
|
| 522 | | (attr & 0x1f) + 0x60,
|
| 523 | | TILE_FLIPYX((attr & 0x60) >> 5));
|
| 524 | | tileinfo->group = (attr & 0x0180) >> 7;
|
| 525 | | |
| 526 | | // for out of range tiles, switch to fully transparent data
|
| 527 | | // (but still call SET_TILE_INFO, otherwise problems might occur on boot e.g. unsquad)
|
| 528 | | if (code == -1)
|
| 529 | | tileinfo->pen_data = empty_tile;
|
| 530 | | }
|
| 531 | | |
| 532 | | |
| 533 | | |
| 534 | | static void cps1_update_transmasks(void)
|
| 535 | | {
|
| 536 | | int i;
|
| 537 | | |
| 538 | | for (i = 0;i < 4;i++)
|
| 539 | | {
|
| 540 | | int mask;
|
| 541 | | |
| 542 | | /* Get transparency registers */
|
| 543 | | if (cps1_game_config->priority[i] != -1)
|
| 544 | | mask = cps1_cps_b_regs[cps1_game_config->priority[i]/2] ^ 0xffff;
|
| 545 | | else mask = 0xffff; /* completely transparent if priority masks not defined (qad) */
|
| 546 | | |
| 547 | | tilemap_set_transmask(cps1_bg_tilemap[0],i,mask,0x8000);
|
| 548 | | tilemap_set_transmask(cps1_bg_tilemap[1],i,mask,0x8000);
|
| 549 | | tilemap_set_transmask(cps1_bg_tilemap[2],i,mask,0x8000);
|
| 550 | | }
|
| 551 | | }
|
| 552 | | |
| 553 | | VIDEO_START( cps1 )
|
| 554 | | {
|
| 555 | | int i;
|
| 556 | | |
| 557 | | MACHINE_RESET_CALL(cps);
|
| 558 | | |
| 559 | | cps1_bg_tilemap[0] = tilemap_create(machine, get_tile0_info,tilemap0_scan, 8, 8,64,64);
|
| 560 | | cps1_bg_tilemap[1] = tilemap_create(machine, get_tile1_info,tilemap1_scan,16,16,64,64);
|
| 561 | | cps1_bg_tilemap[2] = tilemap_create(machine, get_tile2_info,tilemap2_scan,32,32,64,64);
|
| 562 | | |
| 563 | | /* front masks will change at runtime to handle sprite occluding */
|
| 564 | | cps1_update_transmasks();
|
| 565 | | |
| 566 | | memset(empty_tile8x8,0x0f,sizeof(empty_tile8x8));
|
| 567 | | memset(empty_tile,0xff,sizeof(empty_tile)); // 16x16 and 32x32 use packed graphics, 8x8 does not
|
| 568 | | |
| 569 | | for (i = 0;i < cps1_palette_entries*16;i++)
|
| 570 | | {
|
| 571 | | palette_set_color(machine,i,MAKE_RGB(0,0,0));
|
| 572 | | }
|
| 573 | | |
| 574 | | cps1_buffered_obj = auto_malloc (cps1_obj_size);
|
| 575 | | memset(cps1_buffered_obj, 0x00, cps1_obj_size);
|
| 576 | | |
| 577 | | memset(cps1_gfxram, 0, cps1_gfxram_size); /* Clear GFX RAM */
|
| 578 | | memset(cps1_cps_a_regs, 0, 0x40); /* Clear CPS-A registers */
|
| 579 | | memset(cps1_cps_b_regs, 0, 0x40); /* Clear CPS-B registers */
|
| 580 | | |
| 581 | | /* Put in some defaults */
|
| 582 | | cps1_cps_a_regs[CPS1_OBJ_BASE] = 0x9200;
|
| 583 | | cps1_cps_a_regs[CPS1_SCROLL1_BASE] = 0x9000;
|
| 584 | | cps1_cps_a_regs[CPS1_SCROLL2_BASE] = 0x9040;
|
| 585 | | cps1_cps_a_regs[CPS1_SCROLL3_BASE] = 0x9080;
|
| 586 | | cps1_cps_a_regs[CPS1_OTHER_BASE] = 0x9100;
|
| 587 | | |
| 588 | | assert_always(cps1_game_config, "cps1_game_config hasn't been set up yet");
|
| 589 | | |
| 590 | | /* Set up old base */
|
| 591 | | cps1_get_video_base(); /* Calculate base pointers */
|
| 592 | | cps1_get_video_base(); /* Calculate old base pointers */
|
| 593 | | }
|
| 594 | | |
| 595 | | |
| 596 | | |
| 597 | | /***************************************************************************
|
| 598 | | |
| 599 | | Build palette from palette RAM
|
| 600 | | |
| 601 | | 12 bit RGB with a 4 bit brightness value.
|
| 602 | | |
| 603 | | ***************************************************************************/
|
| 604 | | |
| 605 | | static void cps1_build_palette(running_machine *machine, const UINT16* const palette_base)
|
| 606 | | {
|
| 607 | | int offset, page;
|
| 608 | | const UINT16 *palette_ram = palette_base;
|
| 609 | | |
| 610 | | int ctrl = cps1_cps_b_regs[cps1_game_config->palette_control/2];
|
| 611 | | |
| 612 | | for (page = 0; page < 6; ++page)
|
| 613 | | {
|
| 614 | | if (BIT(ctrl,page))
|
| 615 | | {
|
| 616 | | for (offset = 0; offset < 0x200; ++offset)
|
| 617 | | {
|
| 618 | | int palette = *(palette_ram++);
|
| 619 | | int r, g, b, bright;
|
| 620 | | |
| 621 | | // from my understanding of the schematics, when the 'brightness'
|
| 622 | | // component is set to 0 it should reduce brightness to 1/3
|
| 623 | | |
| 624 | | bright = 0x0f + ((palette>>12)<<1);
|
| 625 | | |
| 626 | | r = ((palette>>8)&0x0f) * 0x11 * bright / 0x2d;
|
| 627 | | g = ((palette>>4)&0x0f) * 0x11 * bright / 0x2d;
|
| 628 | | b = ((palette>>0)&0x0f) * 0x11 * bright / 0x2d;
|
| 629 | | |
| 630 | | palette_set_color (machine, 0x200*page + offset, MAKE_RGB(r, g, b));
|
| 631 | | }
|
| 632 | | }
|
| 633 | | else
|
| 634 | | {
|
| 635 | | // skip page in gfxram, but only if we have already copied at least one page
|
| 636 | | if (palette_ram != palette_base)
|
| 637 | | palette_ram += 0x200;
|
| 638 | | }
|
| 639 | | }
|
| 640 | | }
|
| 641 | | |
| 642 | | static void cps1_find_last_sprite(void) /* Find the offset of last sprite */
|
| 643 | | {
|
| 644 | | int offset=0;
|
| 645 | | /* Locate the end of table marker */
|
| 646 | | while (offset < cps1_obj_size/2)
|
| 647 | | {
|
| 648 | | int colour=cps1_buffered_obj[offset+3];
|
| 649 | | if ((colour & 0xff00) == 0xff00)
|
| 650 | | {
|
| 651 | | /* Marker found. This is the last sprite. */
|
| 652 | | cps1_last_sprite_offset=offset-4;
|
| 653 | | return;
|
| 654 | | }
|
| 655 | | offset+=4;
|
| 656 | | }
|
| 657 | | /* Sprites must use full sprite RAM */
|
| 658 | | cps1_last_sprite_offset=cps1_obj_size/2-4;
|
| 659 | | }
|
| 660 | | |
| 661 | | |
| 662 | | static void cps1_render_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
|
| 663 | | {
|
| 664 | | #define DRAWSPRITE(CODE,COLOR,FLIPX,FLIPY,SX,SY) \
|
| 665 | | { \
|
| 666 | | if (flip_screen_get(machine)) \
|
| 667 | | pdrawgfx(bitmap,machine->gfx[2], \
|
| 668 | | CODE, \
|
| 669 | | COLOR, \
|
| 670 | | !(FLIPX),!(FLIPY), \
|
| 671 | | 511-16-(SX),255-16-(SY), \
|
| 672 | | cliprect,TRANSPARENCY_PEN,15,0x02); \
|
| 673 | | else \
|
| 674 | | pdrawgfx(bitmap,machine->gfx[2], \
|
| 675 | | CODE, \
|
| 676 | | COLOR, \
|
| 677 | | FLIPX,FLIPY, \
|
| 678 | | SX,SY, \
|
| 679 | | cliprect,TRANSPARENCY_PEN,15,0x02); \
|
| 680 | | }
|
| 681 | | |
| 682 | | |
| 683 | | int i, baseadd;
|
| 684 | | UINT16 *base=cps1_buffered_obj;
|
| 685 | | |
| 686 | | /* some sf2 hacks draw the sprites in reverse order */
|
| 687 | | if (cps1_game_config->bootleg_kludge == 1)
|
| 688 | | {
|
| 689 | | base += cps1_last_sprite_offset;
|
| 690 | | baseadd = -4;
|
| 691 | | }
|
| 692 | | else
|
| 693 | | {
|
| 694 | | baseadd = 4;
|
| 695 | | }
|
| 696 | | |
| 697 | | for (i=cps1_last_sprite_offset; i>=0; i-=4)
|
| 698 | | {
|
| 699 | | int x=*(base+0);
|
| 700 | | int y=*(base+1);
|
| 701 | | int code =*(base+2);
|
| 702 | | int colour=*(base+3);
|
| 703 | | int col=colour&0x1f;
|
| 704 | | |
| 705 | | code = gfxrom_bank_mapper(machine, GFXTYPE_SPRITES, code);
|
| 706 | | |
| 707 | | if (code != -1)
|
| 708 | | {
|
| 709 | | if (colour & 0xff00 )
|
| 710 | | {
|
| 711 | | /* handle blocked sprites */
|
| 712 | | int nx=(colour & 0x0f00) >> 8;
|
| 713 | | int ny=(colour & 0xf000) >> 12;
|
| 714 | | int nxs,nys,sx,sy;
|
| 715 | | nx++;
|
| 716 | | ny++;
|
| 717 | | |
| 718 | | if (colour & 0x40)
|
| 719 | | {
|
| 720 | | /* Y flip */
|
| 721 | | if (colour &0x20)
|
| 722 | | {
|
| 723 | | for (nys=0; nys<ny; nys++)
|
| 724 | | {
|
| 725 | | for (nxs=0; nxs<nx; nxs++)
|
| 726 | | {
|
| 727 | | sx = (x+nxs*16) & 0x1ff;
|
| 728 | | sy = (y+nys*16) & 0x1ff;
|
| 729 | | |
| 730 | | DRAWSPRITE(
|
| 731 | | (code & ~0xf) + ((code + (nx-1) - nxs) & 0xf) + 0x10*(ny-1-nys),
|
| 732 | | (col&0x1f),
|
| 733 | | 1,1,
|
| 734 | | sx,sy);
|
| 735 | | }
|
| 736 | | }
|
| 737 | | }
|
| 738 | | else
|
| 739 | | {
|
| 740 | | for (nys=0; nys<ny; nys++)
|
| 741 | | {
|
| 742 | | for (nxs=0; nxs<nx; nxs++)
|
| 743 | | {
|
| 744 | | sx = (x+nxs*16) & 0x1ff;
|
| 745 | | sy = (y+nys*16) & 0x1ff;
|
| 746 | | |
| 747 | | DRAWSPRITE(
|
| 748 | | (code & ~0xf) + ((code + nxs) & 0xf) + 0x10*(ny-1-nys),
|
| 749 | | (col&0x1f),
|
| 750 | | 0,1,
|
| 751 | | sx,sy);
|
| 752 | | }
|
| 753 | | }
|
| 754 | | }
|
| 755 | | }
|
| 756 | | else
|
| 757 | | {
|
| 758 | | if (colour &0x20)
|
| 759 | | {
|
| 760 | | for (nys=0; nys<ny; nys++)
|
| 761 | | {
|
| 762 | | for (nxs=0; nxs<nx; nxs++)
|
| 763 | | {
|
| 764 | | sx = (x+nxs*16) & 0x1ff;
|
| 765 | | sy = (y+nys*16) & 0x1ff;
|
| 766 | | |
| 767 | | DRAWSPRITE(
|
| 768 | | (code & ~0xf) + ((code + (nx-1) - nxs) & 0xf) + 0x10*nys,
|
| 769 | | (col&0x1f),
|
| 770 | | 1,0,
|
| 771 | | sx,sy);
|
| 772 | | }
|
| 773 | | }
|
| 774 | | }
|
| 775 | | else
|
| 776 | | {
|
| 777 | | for (nys=0; nys<ny; nys++)
|
| 778 | | {
|
| 779 | | for (nxs=0; nxs<nx; nxs++)
|
| 780 | | {
|
| 781 | | sx = (x+nxs*16) & 0x1ff;
|
| 782 | | sy = (y+nys*16) & 0x1ff;
|
| 783 | | |
| 784 | | DRAWSPRITE(
|
| 785 | | (code & ~0xf) + ((code + nxs) & 0xf) + 0x10*nys, // fix 00406: qadj: When playing as the ninja, there is one broekn frame in his animation loop when walking.
|
| 786 | | (col&0x1f),
|
| 787 | | 0,0,
|
| 788 | | sx,sy);
|
| 789 | | }
|
| 790 | | }
|
| 791 | | }
|
| 792 | | }
|
| 793 | | }
|
| 794 | | else
|
| 795 | | {
|
| 796 | | /* Simple case... 1 sprite */
|
| 797 | | DRAWSPRITE(
|
| 798 | | code,
|
| 799 | | (col&0x1f),
|
| 800 | | colour&0x20,colour&0x40,
|
| 801 | | x & 0x1ff,y & 0x1ff);
|
| 802 | | }
|
| 803 | | }
|
| 804 | | base += baseadd;
|
| 805 | | }
|
| 806 | | #undef DRAWSPRITE
|
| 807 | | }
|
| 808 | | |
| 809 | | |
| 810 | | static void cps1_render_stars(const device_config *screen, bitmap_t *bitmap,const rectangle *cliprect)
|
| 811 | | {
|
| 812 | | int offs;
|
| 813 | | UINT8 *stars_rom = memory_region(screen->machine, "stars");
|
| 814 | | |
| 815 | | if (!stars_rom && (cps1_stars_enabled[0] || cps1_stars_enabled[1]))
|
| 816 | | {
|
| 817 | | return;
|
| 818 | | }
|
| 819 | | |
| 820 | | if (cps1_stars_enabled[0])
|
| 821 | | {
|
| 822 | | for (offs = 0;offs < stars_rom_size/2;offs++)
|
| 823 | | {
|
| 824 | | int col = stars_rom[8*offs+4];
|
| 825 | | if (col != 0x0f)
|
| 826 | | {
|
| 827 | | int sx = (offs / 256) * 32;
|
| 828 | | int sy = (offs % 256);
|
| 829 | | sx = (sx - stars2x + (col & 0x1f)) & 0x1ff;
|
| 830 | | sy = (sy - stars2y) & 0xff;
|
| 831 | | if (flip_screen_get(screen->machine))
|
| 832 | | {
|
| 833 | | sx = 511 - sx;
|
| 834 | | sy = 255 - sy;
|
| 835 | | }
|
| 836 | | |
| 837 | | col = ((col & 0xe0) >> 1) + (video_screen_get_frame_number(screen)/16 & 0x0f);
|
| 838 | | |
| 839 | | if (sx >= cliprect->min_x && sx <= cliprect->max_x &&
|
| 840 | | sy >= cliprect->min_y && sy <= cliprect->max_y)
|
| 841 | | *BITMAP_ADDR16(bitmap, sy, sx) = 0xa00 + col;
|
| 842 | | }
|
| 843 | | }
|
| 844 | | }
|
| 845 | | |
| 846 | | if (cps1_stars_enabled[1])
|
| 847 | | {
|
| 848 | | for (offs = 0;offs < stars_rom_size/2;offs++)
|
| 849 | | {
|
| 850 | | int col = stars_rom[8*offs];
|
| 851 | | if (col != 0x0f)
|
| 852 | | {
|
| 853 | | int sx = (offs / 256) * 32;
|
| 854 | | int sy = (offs % 256);
|
| 855 | | sx = (sx - stars1x + (col & 0x1f)) & 0x1ff;
|
| 856 | | sy = (sy - stars1y) & 0xff;
|
| 857 | | if (flip_screen_get(screen->machine))
|
| 858 | | {
|
| 859 | | sx = 511 - sx;
|
| 860 | | sy = 255 - sy;
|
| 861 | | }
|
| 862 | | |
| 863 | | col = ((col & 0xe0) >> 1) + (video_screen_get_frame_number(screen)/16 & 0x0f);
|
| 864 | | |
| 865 | | if (sx >= cliprect->min_x && sx <= cliprect->max_x &&
|
| 866 | | sy >= cliprect->min_y && sy <= cliprect->max_y)
|
| 867 | | *BITMAP_ADDR16(bitmap, sy, sx) = 0x800 + col;
|
| 868 | | }
|
| 869 | | }
|
| 870 | | }
|
| 871 | | }
|
| 872 | | |
| 873 | | |
| 874 | | static void cps1_render_layer(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,int layer,int primask)
|
| 875 | | {
|
| 876 | | switch (layer)
|
| 877 | | {
|
| 878 | | case 0:
|
| 879 | | cps1_render_sprites(machine,bitmap,cliprect);
|
| 880 | | break;
|
| 881 | | case 1:
|
| 882 | | case 2:
|
| 883 | | case 3:
|
| 884 | | tilemap_draw(bitmap,cliprect,cps1_bg_tilemap[layer-1],TILEMAP_DRAW_LAYER1,primask);
|
| 885 | | break;
|
| 886 | | }
|
| 887 | | }
|
| 888 | | |
| 889 | | static void cps1_render_high_layer(bitmap_t *bitmap, const rectangle *cliprect, int layer)
|
| 890 | | {
|
| 891 | | switch (layer)
|
| 892 | | {
|
| 893 | | case 0:
|
| 894 | | /* there are no high priority sprites */
|
| 895 | | break;
|
| 896 | | case 1:
|
| 897 | | case 2:
|
| 898 | | case 3:
|
| 899 | | tilemap_draw(NULL,cliprect,cps1_bg_tilemap[layer-1],TILEMAP_DRAW_LAYER0,1);
|
| 900 | | break;
|
| 901 | | }
|
| 902 | | }
|
| 903 | | |
| 904 | | |
| 905 | | /***************************************************************************
|
| 906 | | |
| 907 | | Refresh screen
|
| 908 | | |
| 909 | | ***************************************************************************/
|
| 910 | | |
| 911 | | VIDEO_UPDATE( cps1 )
|
| 912 | | {
|
| 913 | | int layercontrol,l0,l1,l2,l3;
|
| 914 | | int videocontrol = cps1_cps_a_regs[CPS1_VIDEOCONTROL];
|
| 915 | | |
| 916 | | |
| 917 | | flip_screen_set(screen->machine, videocontrol & 0x8000);
|
| 918 | | |
| 919 | | layercontrol = cps1_cps_b_regs[cps1_game_config->layer_control/2];
|
| 920 | | |
| 921 | | /* Get video memory base registers */
|
| 922 | | cps1_get_video_base();
|
| 923 | | |
| 924 | | /* Find the offset of the last sprite in the sprite table */
|
| 925 | | cps1_find_last_sprite();
|
| 926 | | cps1_update_transmasks();
|
| 927 | | |
| 928 | | tilemap_set_scrollx(cps1_bg_tilemap[0],0,cps1_scroll1x);
|
| 929 | | tilemap_set_scrolly(cps1_bg_tilemap[0],0,cps1_scroll1y);
|
| 930 | | if (videocontrol & 0x01) /* linescroll enable */
|
| 931 | | {
|
| 932 | | int scrly=-cps1_scroll2y;
|
| 933 | | int i;
|
| 934 | | int otheroffs;
|
| 935 | | |
| 936 | | tilemap_set_scroll_rows(cps1_bg_tilemap[1],1024);
|
| 937 | | |
| 938 | | otheroffs = cps1_cps_a_regs[CPS1_ROWSCROLL_OFFS];
|
| 939 | | |
| 940 | | for (i = 0;i < 256;i++)
|
| 941 | | tilemap_set_scrollx(cps1_bg_tilemap[1],(i - scrly) & 0x3ff,cps1_scroll2x + cps1_other[(i + otheroffs) & 0x3ff]);
|
| 942 | | }
|
| 943 | | else
|
| 944 | | {
|
| 945 | | tilemap_set_scroll_rows(cps1_bg_tilemap[1],1);
|
| 946 | | tilemap_set_scrollx(cps1_bg_tilemap[1],0,cps1_scroll2x);
|
| 947 | | }
|
| 948 | | tilemap_set_scrolly(cps1_bg_tilemap[1],0,cps1_scroll2y);
|
| 949 | | tilemap_set_scrollx(cps1_bg_tilemap[2],0,cps1_scroll3x);
|
| 950 | | tilemap_set_scrolly(cps1_bg_tilemap[2],0,cps1_scroll3y);
|
| 951 | | |
| 952 | | |
| 953 | | /* Blank screen */
|
| 954 | | bitmap_fill(bitmap,cliprect,0xbff);
|
| 955 | | |
| 956 | | cps1_render_stars(screen, bitmap,cliprect);
|
| 957 | | |
| 958 | | /* Draw layers (0 = sprites, 1-3 = tilemaps) */
|
| 959 | | l0 = (layercontrol >> 0x06) & 03;
|
| 960 | | l1 = (layercontrol >> 0x08) & 03;
|
| 961 | | l2 = (layercontrol >> 0x0a) & 03;
|
| 962 | | l3 = (layercontrol >> 0x0c) & 03;
|
| 963 | | bitmap_fill(priority_bitmap,cliprect,0);
|
| 964 | | |
| 965 | | cps1_render_layer(screen->machine,bitmap,cliprect,l0,0);
|
| 966 | | if (l1 == 0) cps1_render_high_layer(bitmap,cliprect,l0); /* prepare mask for sprites */
|
| 967 | | cps1_render_layer(screen->machine,bitmap,cliprect,l1,0);
|
| 968 | | if (l2 == 0) cps1_render_high_layer(bitmap,cliprect,l1); /* prepare mask for sprites */
|
| 969 | | cps1_render_layer(screen->machine,bitmap,cliprect,l2,0);
|
| 970 | | if (l3 == 0) cps1_render_high_layer(bitmap,cliprect,l2); /* prepare mask for sprites */
|
| 971 | | cps1_render_layer(screen->machine,bitmap,cliprect,l3,0);
|
| 972 | | |
| 973 | | return 0;
|
| 974 | | }
|
| 975 | | |
| 976 | | VIDEO_EOF( cps1 )
|
| 977 | | {
|
| 978 | | /* Get video memory base registers */
|
| 979 | | cps1_get_video_base();
|
| 980 | | |
| 981 | | /* CPS1 sprites have to be delayed one frame */
|
| 982 | | memcpy(cps1_buffered_obj, cps1_obj, cps1_obj_size);
|
| 983 | | }
|
| 1 | /*************************************************************************** |
| 2 | |
| 3 | CPS Changer |
| 4 | |
| 5 | ***************************************************************************/ |
| 6 | |
| 7 | #include "driver.h" |
| 8 | #include "cps1.h" |
| 9 | |
| 10 | /******************************************************************** |
| 11 | |
| 12 | Configuration table: |
| 13 | |
| 14 | ********************************************************************/ |
| 15 | |
| 16 | /* Game specific data */ |
| 17 | |
| 18 | #define GFXTYPE_SPRITES (1<<0) |
| 19 | #define GFXTYPE_SCROLL1 (1<<1) |
| 20 | #define GFXTYPE_SCROLL2 (1<<2) |
| 21 | #define GFXTYPE_SCROLL3 (1<<3) |
| 22 | #define GFXTYPE_STARS (1<<4) |
| 23 | |
| 24 | |
| 25 | struct gfx_range |
| 26 | { |
| 27 | // start and end are as passed by the game (shift adjusted to be all |
| 28 | // in the same scale a 8x8 tiles): they don't necessarily match the |
| 29 | // position in ROM. |
| 30 | int type; |
| 31 | int start; |
| 32 | int end; |
| 33 | int bank; |
| 34 | }; |
| 35 | |
| 36 | struct CPS1config |
| 37 | { |
| 38 | const char *name; /* game driver name */ |
| 39 | |
| 40 | /* Some games interrogate a couple of registers on bootup. */ |
| 41 | /* These are CPS1 board B self test checks. They wander from game to */ |
| 42 | /* game. */ |
| 43 | int cpsb_addr; /* CPS board B test register address */ |
| 44 | int cpsb_value; /* CPS board B test register expected value */ |
| 45 | |
| 46 | /* some games use as a protection check the ability to do 16-bit multiplies */ |
| 47 | /* with a 32-bit result, by writing the factors to two ports and reading the */ |
| 48 | /* result from two other ports. */ |
| 49 | /* It looks like this feature was introduced with 3wonders (CPSB ID = 08xx) */ |
| 50 | int mult_factor1; |
| 51 | int mult_factor2; |
| 52 | int mult_result_lo; |
| 53 | int mult_result_hi; |
| 54 | |
| 55 | /* unknown registers which might be related to the multiply protection */ |
| 56 | int unknown1; |
| 57 | int unknown2; |
| 58 | int unknown3; |
| 59 | |
| 60 | int layer_control; |
| 61 | int priority[4]; |
| 62 | int palette_control; |
| 63 | |
| 64 | /* ideally, the layer enable masks should consist of only one bit, */ |
| 65 | /* but in many cases it is unknown which bit is which. */ |
| 66 | int layer_enable_mask[5]; |
| 67 | |
| 68 | /* these depend on the B-board model and PAL */ |
| 69 | int bank_sizes[4]; |
| 70 | const struct gfx_range *bank_mapper; |
| 71 | |
| 72 | /* some C-boards have additional I/O for extra buttons/extra players */ |
| 73 | int in2_addr; |
| 74 | int in3_addr; |
| 75 | int out2_addr; |
| 76 | |
| 77 | int bootleg_kludge; |
| 78 | }; |
| 79 | |
| 80 | static const struct CPS1config *cps1_game_config; |
| 81 | |
| 82 | |
| 83 | #define __not_applicable__ -1,-1,-1,-1,-1,-1,-1 |
| 84 | |
| 85 | /* CPSB ID multiply protection unknown ctrl priority masks palctrl layer enable masks */ |
| 86 | #define CPS_B_21_DEF 0x32, -1, 0x00,0x02,0x04,0x06, 0x08, -1, -1, 0x26,{0x28,0x2a,0x2c,0x2e},0x30, {0x02,0x04,0x08,0x30,0x30} // pang3 sets layer enable to 0x26 on startup |
| 87 | |
| 88 | #define mapper_sfzch { 0x20000, 0, 0, 0 }, mapper_sfzch_table |
| 89 | static const struct gfx_range mapper_sfzch_table[] = |
| 90 | { |
| 91 | /* type start end bank */ |
| 92 | { GFXTYPE_SPRITES | GFXTYPE_SCROLL1 | GFXTYPE_SCROLL2 | GFXTYPE_SCROLL3, 0x00000, 0x1ffff, 0 }, |
| 93 | { 0 } |
| 94 | }; |
| 95 | |
| 96 | static const struct CPS1config cps1_config_table[]= |
| 97 | { |
| 98 | /* name CPSB gfx mapper in2 in3 out2 kludge */ |
| 99 | {"sfach", CPS_B_21_DEF, mapper_sfzch }, |
| 100 | {"sfzbch", CPS_B_21_DEF, mapper_sfzch }, |
| 101 | {"sfzch", CPS_B_21_DEF, mapper_sfzch }, |
| 102 | {"wofch", CPS_B_21_DEF, mapper_sfzch }, |
| 103 | {0} /* End of table */ |
| 104 | }; |
| 105 | |
| 106 | |
| 107 | |
| 108 | /* Public variables */ |
| 109 | UINT16 *cps1_gfxram; |
| 110 | UINT16 *cps1_cps_a_regs; |
| 111 | UINT16 *cps1_cps_b_regs; |
| 112 | |
| 113 | size_t cps1_gfxram_size; |
| 114 | |
| 115 | /* Offset of each palette entry */ |
| 116 | #define cps1_palette_entries (32*6) /* Number colour schemes in palette */ |
| 117 | |
| 118 | static const int cps1_scroll_size =0x4000; /* scroll1, scroll2, scroll3 */ |
| 119 | static const int cps1_obj_size =0x0800; |
| 120 | static const int cps1_other_size =0x0800; |
| 121 | static const int cps1_palette_align=0x0400; /* minimum alignment is a single palette page (512 colors). Verified on pcb. */ |
| 122 | static const int cps1_palette_size=cps1_palette_entries*32; /* Size of palette RAM */ |
| 123 | |
| 124 | static UINT16 *cps1_scroll1; |
| 125 | static UINT16 *cps1_scroll2; |
| 126 | static UINT16 *cps1_scroll3; |
| 127 | static UINT16 *cps1_obj; |
| 128 | static UINT16 *cps1_buffered_obj; |
| 129 | static UINT16 *cps1_other; |
| 130 | |
| 131 | /* Working variables */ |
| 132 | static int cps1_last_sprite_offset; /* Offset of the last sprite */ |
| 133 | static int cps1_stars_enabled[2]; /* Layer enabled [Y/N] */ |
| 134 | |
| 135 | static tilemap *cps1_bg_tilemap[3]; |
| 136 | |
| 137 | |
| 138 | static int cps1_scroll1x, cps1_scroll1y; |
| 139 | static int cps1_scroll2x, cps1_scroll2y; |
| 140 | static int cps1_scroll3x, cps1_scroll3y; |
| 141 | static int stars1x, stars1y, stars2x, stars2y; |
| 142 | |
| 143 | |
| 144 | /* CPS-A registers */ |
| 145 | #define CPS1_OBJ_BASE (0x00/2) /* Base address of objects */ |
| 146 | #define CPS1_SCROLL1_BASE (0x02/2) /* Base address of scroll 1 */ |
| 147 | #define CPS1_SCROLL2_BASE (0x04/2) /* Base address of scroll 2 */ |
| 148 | #define CPS1_SCROLL3_BASE (0x06/2) /* Base address of scroll 3 */ |
| 149 | #define CPS1_OTHER_BASE (0x08/2) /* Base address of other video */ |
| 150 | #define CPS1_PALETTE_BASE (0x0a/2) /* Base address of palette */ |
| 151 | #define CPS1_SCROLL1_SCROLLX (0x0c/2) /* Scroll 1 X */ |
| 152 | #define CPS1_SCROLL1_SCROLLY (0x0e/2) /* Scroll 1 Y */ |
| 153 | #define CPS1_SCROLL2_SCROLLX (0x10/2) /* Scroll 2 X */ |
| 154 | #define CPS1_SCROLL2_SCROLLY (0x12/2) /* Scroll 2 Y */ |
| 155 | #define CPS1_SCROLL3_SCROLLX (0x14/2) /* Scroll 3 X */ |
| 156 | #define CPS1_SCROLL3_SCROLLY (0x16/2) /* Scroll 3 Y */ |
| 157 | #define CPS1_STARS1_SCROLLX (0x18/2) /* Stars 1 X */ |
| 158 | #define CPS1_STARS1_SCROLLY (0x1a/2) /* Stars 1 Y */ |
| 159 | #define CPS1_STARS2_SCROLLX (0x1c/2) /* Stars 2 X */ |
| 160 | #define CPS1_STARS2_SCROLLY (0x1e/2) /* Stars 2 Y */ |
| 161 | #define CPS1_ROWSCROLL_OFFS (0x20/2) /* base of row scroll offsets in other RAM */ |
| 162 | #define CPS1_VIDEOCONTROL (0x22/2) /* flip screen, rowscroll enable */ |
| 163 | |
| 164 | |
| 165 | /* first 0x4000 of gfx ROM are used, but 0x0000-0x1fff is == 0x2000-0x3fff */ |
| 166 | static const int stars_rom_size = 0x2000; |
| 167 | |
| 168 | static void cps1_build_palette(running_machine *machine, const UINT16* const palette_base); |
| 169 | |
| 170 | |
| 171 | static MACHINE_RESET( cps ) |
| 172 | { |
| 173 | const char *gamename = machine->gamedrv->name; |
| 174 | const struct CPS1config *pCFG=&cps1_config_table[0]; |
| 175 | |
| 176 | while(pCFG->name) |
| 177 | { |
| 178 | if (strcmp(pCFG->name, gamename) == 0) |
| 179 | { |
| 180 | break; |
| 181 | } |
| 182 | pCFG++; |
| 183 | } |
| 184 | cps1_game_config=pCFG; |
| 185 | } |
| 186 | |
| 187 | |
| 188 | INLINE UINT16 *cps1_base(int offset,int boundary) |
| 189 | { |
| 190 | int base = cps1_cps_a_regs[offset]*256; |
| 191 | base &= ~(boundary-1); |
| 192 | return &cps1_gfxram[(base&0x3ffff)/2]; |
| 193 | } |
| 194 | |
| 195 | |
| 196 | |
| 197 | WRITE16_HANDLER( cps1_cps_a_w ) |
| 198 | { |
| 199 | data = COMBINE_DATA(&cps1_cps_a_regs[offset]); |
| 200 | |
| 201 | if (offset == CPS1_PALETTE_BASE) |
| 202 | cps1_build_palette(space->machine, cps1_base(CPS1_PALETTE_BASE,cps1_palette_align)); |
| 203 | } |
| 204 | |
| 205 | |
| 206 | READ16_HANDLER( cps1_cps_b_r ) |
| 207 | { |
| 208 | /* Some games interrogate a couple of registers on bootup. */ |
| 209 | /* These are CPS1 board B self test checks. They wander from game to */ |
| 210 | /* game. */ |
| 211 | if (offset == cps1_game_config->cpsb_addr/2) |
| 212 | return cps1_game_config->cpsb_value; |
| 213 | |
| 214 | /* some games use as a protection check the ability to do 16-bit multiplications */ |
| 215 | /* with a 32-bit result, by writing the factors to two ports and reading the */ |
| 216 | /* result from two other ports. */ |
| 217 | if (offset == cps1_game_config->mult_result_lo/2) |
| 218 | return (cps1_cps_b_regs[cps1_game_config->mult_factor1/2] * |
| 219 | cps1_cps_b_regs[cps1_game_config->mult_factor2/2]) & 0xffff; |
| 220 | if (offset == cps1_game_config->mult_result_hi/2) |
| 221 | return (cps1_cps_b_regs[cps1_game_config->mult_factor1/2] * |
| 222 | cps1_cps_b_regs[cps1_game_config->mult_factor2/2]) >> 16; |
| 223 | |
| 224 | if (offset == cps1_game_config->in2_addr/2) /* Extra input ports (on C-board) */ |
| 225 | return input_port_read(space->machine, "IN2"); |
| 226 | |
| 227 | if (offset == cps1_game_config->in3_addr/2) /* Player 4 controls (on C-board) ("Captain Commando") */ |
| 228 | return input_port_read(space->machine, "IN3"); |
| 229 | |
| 230 | return 0xffff; |
| 231 | } |
| 232 | |
| 233 | |
| 234 | WRITE16_HANDLER( cps1_cps_b_w ) |
| 235 | { |
| 236 | data = COMBINE_DATA(&cps1_cps_b_regs[offset]); |
| 237 | |
| 238 | // additional outputs on C-board |
| 239 | if (offset == cps1_game_config->out2_addr/2) |
| 240 | { |
| 241 | if (ACCESSING_BITS_0_7) |
| 242 | { |
| 243 | if (cps1_game_config->cpsb_value == 0x0402) // Mercs (CN2 connector) |
| 244 | { |
| 245 | coin_lockout_w(2,~data & 0x01); |
| 246 | set_led_status(0,data & 0x02); |
| 247 | set_led_status(1,data & 0x04); |
| 248 | set_led_status(2,data & 0x08); |
| 249 | } |
| 250 | else // kod, captcomm, knights |
| 251 | { |
| 252 | coin_lockout_w(2,~data & 0x02); |
| 253 | coin_lockout_w(3,~data & 0x08); |
| 254 | } |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | |
| 260 | |
| 261 | static void cps1_gfx_decode(running_machine *machine) |
| 262 | { |
| 263 | int size=memory_region_length(machine, "gfx"); |
| 264 | int i,j,gfxsize; |
| 265 | UINT8 *cps1_gfx = memory_region(machine, "gfx"); |
| 266 | |
| 267 | |
| 268 | gfxsize=size/4; |
| 269 | |
| 270 | for (i = 0;i < gfxsize;i++) |
| 271 | { |
| 272 | UINT32 src = cps1_gfx[4*i] + (cps1_gfx[4*i+1]<<8) + (cps1_gfx[4*i+2]<<16) + (cps1_gfx[4*i+3]<<24); |
| 273 | UINT32 dwval = 0; |
| 274 | |
| 275 | for (j = 0;j < 8;j++) |
| 276 | { |
| 277 | int n = 0; |
| 278 | UINT32 mask = (0x80808080 >> j) & src; |
| 279 | |
| 280 | if (mask & 0x000000ff) n |= 1; |
| 281 | if (mask & 0x0000ff00) n |= 2; |
| 282 | if (mask & 0x00ff0000) n |= 4; |
| 283 | if (mask & 0xff000000) n |= 8; |
| 284 | |
| 285 | dwval |= n << (j * 4); |
| 286 | } |
| 287 | cps1_gfx[4*i ] = dwval>>0; |
| 288 | cps1_gfx[4*i+1] = dwval>>8; |
| 289 | cps1_gfx[4*i+2] = dwval>>16; |
| 290 | cps1_gfx[4*i+3] = dwval>>24; |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | #ifdef UNUSED_FUNCTION |
| 295 | static void unshuffle(UINT64 *buf,int len) |
| 296 | { |
| 297 | int i; |
| 298 | UINT64 t; |
| 299 | |
| 300 | if (len == 2) return; |
| 301 | |
| 302 | assert(len % 4 == 0); /* must not happen */ |
| 303 | |
| 304 | len /= 2; |
| 305 | |
| 306 | unshuffle(buf,len); |
| 307 | unshuffle(buf + len,len); |
| 308 | |
| 309 | for (i = 0;i < len/2;i++) |
| 310 | { |
| 311 | t = buf[len/2 + i]; |
| 312 | buf[len/2 + i] = buf[len + i]; |
| 313 | buf[len + i] = t; |
| 314 | } |
| 315 | } |
| 316 | #endif |
| 317 | |
| 318 | |
| 319 | DRIVER_INIT( cps1 ) |
| 320 | { |
| 321 | cps1_gfx_decode(machine); |
| 322 | } |
| 323 | |
| 324 | |
| 325 | static void cps1_get_video_base(void ) |
| 326 | { |
| 327 | int layercontrol, videocontrol, scroll1xoff, scroll2xoff, scroll3xoff; |
| 328 | |
| 329 | /* Re-calculate the VIDEO RAM base */ |
| 330 | if (cps1_scroll1 != cps1_base(CPS1_SCROLL1_BASE,cps1_scroll_size)) |
| 331 | { |
| 332 | cps1_scroll1 = cps1_base(CPS1_SCROLL1_BASE,cps1_scroll_size); |
| 333 | tilemap_mark_all_tiles_dirty(cps1_bg_tilemap[0]); |
| 334 | } |
| 335 | if (cps1_scroll2 != cps1_base(CPS1_SCROLL2_BASE,cps1_scroll_size)) |
| 336 | { |
| 337 | cps1_scroll2 = cps1_base(CPS1_SCROLL2_BASE,cps1_scroll_size); |
| 338 | tilemap_mark_all_tiles_dirty(cps1_bg_tilemap[1]); |
| 339 | } |
| 340 | if (cps1_scroll3 != cps1_base(CPS1_SCROLL3_BASE,cps1_scroll_size)) |
| 341 | { |
| 342 | cps1_scroll3 = cps1_base(CPS1_SCROLL3_BASE,cps1_scroll_size); |
| 343 | tilemap_mark_all_tiles_dirty(cps1_bg_tilemap[2]); |
| 344 | } |
| 345 | |
| 346 | /* Some of the sf2 hacks use only sprite port 0x9100 and the scroll layers are offset */ |
| 347 | if (cps1_game_config->bootleg_kludge == 1) |
| 348 | { |
| 349 | cps1_cps_a_regs[CPS1_OBJ_BASE] = 0x9100; |
| 350 | cps1_obj = cps1_base(CPS1_OBJ_BASE, cps1_obj_size); |
| 351 | scroll1xoff = -0x0c; |
| 352 | scroll2xoff = -0x0e; |
| 353 | scroll3xoff = -0x10; |
| 354 | } |
| 355 | else |
| 356 | { |
| 357 | cps1_obj = cps1_base(CPS1_OBJ_BASE, cps1_obj_size); |
| 358 | scroll1xoff = 0; |
| 359 | scroll2xoff = 0; |
| 360 | scroll3xoff = 0; |
| 361 | } |
| 362 | cps1_other = cps1_base(CPS1_OTHER_BASE,cps1_other_size); |
| 363 | |
| 364 | /* Get scroll values */ |
| 365 | cps1_scroll1x = cps1_cps_a_regs[CPS1_SCROLL1_SCROLLX] + scroll1xoff; |
| 366 | cps1_scroll1y = cps1_cps_a_regs[CPS1_SCROLL1_SCROLLY]; |
| 367 | cps1_scroll2x = cps1_cps_a_regs[CPS1_SCROLL2_SCROLLX] + scroll2xoff; |
| 368 | cps1_scroll2y = cps1_cps_a_regs[CPS1_SCROLL2_SCROLLY]; |
| 369 | cps1_scroll3x = cps1_cps_a_regs[CPS1_SCROLL3_SCROLLX] + scroll3xoff; |
| 370 | cps1_scroll3y = cps1_cps_a_regs[CPS1_SCROLL3_SCROLLY]; |
| 371 | stars1x = cps1_cps_a_regs[CPS1_STARS1_SCROLLX]; |
| 372 | stars1y = cps1_cps_a_regs[CPS1_STARS1_SCROLLY]; |
| 373 | stars2x = cps1_cps_a_regs[CPS1_STARS2_SCROLLX]; |
| 374 | stars2y = cps1_cps_a_regs[CPS1_STARS2_SCROLLY]; |
| 375 | |
| 376 | /* Get layer enable bits */ |
| 377 | layercontrol = cps1_cps_b_regs[cps1_game_config->layer_control/2]; |
| 378 | videocontrol = cps1_cps_a_regs[CPS1_VIDEOCONTROL]; |
| 379 | tilemap_set_enable(cps1_bg_tilemap[0],layercontrol & cps1_game_config->layer_enable_mask[0]); |
| 380 | tilemap_set_enable(cps1_bg_tilemap[1],(layercontrol & cps1_game_config->layer_enable_mask[1]) && (videocontrol & 4)); |
| 381 | tilemap_set_enable(cps1_bg_tilemap[2],(layercontrol & cps1_game_config->layer_enable_mask[2]) && (videocontrol & 8)); |
| 382 | cps1_stars_enabled[0] = layercontrol & cps1_game_config->layer_enable_mask[3]; |
| 383 | cps1_stars_enabled[1] = layercontrol & cps1_game_config->layer_enable_mask[4]; |
| 384 | } |
| 385 | |
| 386 | |
| 387 | WRITE16_HANDLER( cps1_gfxram_w ) |
| 388 | { |
| 389 | int page = (offset >> 7) & 0x3c0; |
| 390 | COMBINE_DATA(&cps1_gfxram[offset]); |
| 391 | |
| 392 | if (page == (cps1_cps_a_regs[CPS1_SCROLL1_BASE] & 0x3c0)) |
| 393 | tilemap_mark_tile_dirty(cps1_bg_tilemap[0],offset/2 & 0x0fff); |
| 394 | if (page == (cps1_cps_a_regs[CPS1_SCROLL2_BASE] & 0x3c0)) |
| 395 | tilemap_mark_tile_dirty(cps1_bg_tilemap[1],offset/2 & 0x0fff); |
| 396 | if (page == (cps1_cps_a_regs[CPS1_SCROLL3_BASE] & 0x3c0)) |
| 397 | tilemap_mark_tile_dirty(cps1_bg_tilemap[2],offset/2 & 0x0fff); |
| 398 | } |
| 399 | |
| 400 | |
| 401 | |
| 402 | static int gfxrom_bank_mapper(running_machine *machine, int type, int code) |
| 403 | { |
| 404 | const struct gfx_range *range = cps1_game_config->bank_mapper; |
| 405 | int shift = 0; |
| 406 | |
| 407 | assert(range); |
| 408 | |
| 409 | switch (type) |
| 410 | { |
| 411 | case GFXTYPE_SPRITES: shift = 1; break; |
| 412 | case GFXTYPE_SCROLL1: shift = 0; break; |
| 413 | case GFXTYPE_SCROLL2: shift = 1; break; |
| 414 | case GFXTYPE_SCROLL3: shift = 3; break; |
| 415 | } |
| 416 | |
| 417 | code <<= shift; |
| 418 | |
| 419 | while (range->type) |
| 420 | { |
| 421 | if (code >= range->start && code <= range->end) |
| 422 | { |
| 423 | if (range->type & type) |
| 424 | { |
| 425 | int base = 0; |
| 426 | int i; |
| 427 | |
| 428 | for (i = 0; i < range->bank; ++i) |
| 429 | base += cps1_game_config->bank_sizes[i]; |
| 430 | |
| 431 | return (base + (code & (cps1_game_config->bank_sizes[range->bank] - 1))) >> shift; |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | ++range; |
| 436 | } |
| 437 | |
| 438 | return -1; |
| 439 | } |
| 440 | |
| 441 | |
| 442 | /*************************************************************************** |
| 443 | |
| 444 | Start the video hardware emulation. |
| 445 | |
| 446 | ***************************************************************************/ |
| 447 | |
| 448 | static TILEMAP_MAPPER( tilemap0_scan ) |
| 449 | { |
| 450 | /* logical (col,row) -> memory offset */ |
| 451 | return (row & 0x1f) + ((col & 0x3f) << 5) + ((row & 0x20) << 6); |
| 452 | } |
| 453 | |
| 454 | static TILEMAP_MAPPER( tilemap1_scan ) |
| 455 | { |
| 456 | /* logical (col,row) -> memory offset */ |
| 457 | return (row & 0x0f) + ((col & 0x3f) << 4) + ((row & 0x30) << 6); |
| 458 | } |
| 459 | |
| 460 | static TILEMAP_MAPPER( tilemap2_scan ) |
| 461 | { |
| 462 | /* logical (col,row) -> memory offset */ |
| 463 | return (row & 0x07) + ((col & 0x3f) << 3) + ((row & 0x38) << 6); |
| 464 | } |
| 465 | |
| 466 | static UINT8 empty_tile8x8[8*8]; |
| 467 | static UINT8 empty_tile[32*32/2]; |
| 468 | |
| 469 | static TILE_GET_INFO( get_tile0_info ) |
| 470 | { |
| 471 | int code = cps1_scroll1[2*tile_index]; |
| 472 | int attr = cps1_scroll1[2*tile_index+1]; |
| 473 | int gfxset; |
| 474 | |
| 475 | code = gfxrom_bank_mapper(machine, GFXTYPE_SCROLL1, code); |
| 476 | |
| 477 | /* allows us to reproduce a problem seen with a ffight board where USA and Japanese |
| 478 | roms have been mixed to be reproduced (ffightua) -- it looks like each column |
| 479 | should alternate between the left and right side of the 16x16 tiles */ |
| 480 | gfxset = (tile_index & 0x20) >> 5; |
| 481 | |
| 482 | SET_TILE_INFO( |
| 483 | gfxset, |
| 484 | code, |
| 485 | (attr & 0x1f) + 0x20, |
| 486 | TILE_FLIPYX((attr & 0x60) >> 5)); |
| 487 | tileinfo->group = (attr & 0x0180) >> 7; |
| 488 | |
| 489 | // for out of range tiles, switch to fully transparent data |
| 490 | // (but still call SET_TILE_INFO, otherwise problems might occur on boot e.g. unsquad) |
| 491 | if (code == -1) |
| 492 | tileinfo->pen_data = empty_tile8x8; |
| 493 | } |
| 494 | |
| 495 | static TILE_GET_INFO( get_tile1_info ) |
| 496 | { |
| 497 | int code = cps1_scroll2[2*tile_index]; |
| 498 | int attr = cps1_scroll2[2*tile_index+1]; |
| 499 | |
| 500 | code = gfxrom_bank_mapper(machine, GFXTYPE_SCROLL2, code); |
| 501 | |
| 502 | SET_TILE_INFO( |
| 503 | 2, |
| 504 | code, |
| 505 | (attr & 0x1f) + 0x40, |
| 506 | TILE_FLIPYX((attr & 0x60) >> 5)); |
| 507 | tileinfo->group = (attr & 0x0180) >> 7; |
| 508 | |
| 509 | // for out of range tiles, switch to fully transparent data |
| 510 | if (code == -1) |
| 511 | tileinfo->pen_data = empty_tile; |
| 512 | } |
| 513 | |
| 514 | static TILE_GET_INFO( get_tile2_info ) |
| 515 | { |
| 516 | int code = cps1_scroll3[2*tile_index] & 0x3fff; |
| 517 | int attr = cps1_scroll3[2*tile_index+1]; |
| 518 | |
| 519 | code = gfxrom_bank_mapper(machine, GFXTYPE_SCROLL3, code); |
| 520 | |
| 521 | SET_TILE_INFO( |
| 522 | 3, |
| 523 | code, |
| 524 | (attr & 0x1f) + 0x60, |
| 525 | TILE_FLIPYX((attr & 0x60) >> 5)); |
| 526 | tileinfo->group = (attr & 0x0180) >> 7; |
| 527 | |
| 528 | // for out of range tiles, switch to fully transparent data |
| 529 | // (but still call SET_TILE_INFO, otherwise problems might occur on boot e.g. unsquad) |
| 530 | if (code == -1) |
| 531 | tileinfo->pen_data = empty_tile; |
| 532 | } |
| 533 | |
| 534 | |
| 535 | |
| 536 | static void cps1_update_transmasks(void) |
| 537 | { |
| 538 | int i; |
| 539 | |
| 540 | for (i = 0;i < 4;i++) |
| 541 | { |
| 542 | int mask; |
| 543 | |
| 544 | /* Get transparency registers */ |
| 545 | if (cps1_game_config->priority[i] != -1) |
| 546 | mask = cps1_cps_b_regs[cps1_game_config->priority[i]/2] ^ 0xffff; |
| 547 | else mask = 0xffff; /* completely transparent if priority masks not defined (qad) */ |
| 548 | |
| 549 | tilemap_set_transmask(cps1_bg_tilemap[0],i,mask,0x8000); |
| 550 | tilemap_set_transmask(cps1_bg_tilemap[1],i,mask,0x8000); |
| 551 | tilemap_set_transmask(cps1_bg_tilemap[2],i,mask,0x8000); |
| 552 | } |
| 553 | } |
| 554 | |
| 555 | VIDEO_START( cps1 ) |
| 556 | { |
| 557 | int i; |
| 558 | |
| 559 | MACHINE_RESET_CALL(cps); |
| 560 | |
| 561 | cps1_bg_tilemap[0] = tilemap_create(machine, get_tile0_info,tilemap0_scan, 8, 8,64,64); |
| 562 | cps1_bg_tilemap[1] = tilemap_create(machine, get_tile1_info,tilemap1_scan,16,16,64,64); |
| 563 | cps1_bg_tilemap[2] = tilemap_create(machine, get_tile2_info,tilemap2_scan,32,32,64,64); |
| 564 | |
| 565 | /* front masks will change at runtime to handle sprite occluding */ |
| 566 | cps1_update_transmasks(); |
| 567 | |
| 568 | memset(empty_tile8x8,0x0f,sizeof(empty_tile8x8)); |
| 569 | memset(empty_tile,0xff,sizeof(empty_tile)); // 16x16 and 32x32 use packed graphics, 8x8 does not |
| 570 | |
| 571 | for (i = 0;i < cps1_palette_entries*16;i++) |
| 572 | { |
| 573 | palette_set_color(machine,i,MAKE_RGB(0,0,0)); |
| 574 | } |
| 575 | |
| 576 | cps1_buffered_obj = auto_malloc (cps1_obj_size); |
| 577 | memset(cps1_buffered_obj, 0x00, cps1_obj_size); |
| 578 | |
| 579 | memset(cps1_gfxram, 0, cps1_gfxram_size); /* Clear GFX RAM */ |
| 580 | memset(cps1_cps_a_regs, 0, 0x40); /* Clear CPS-A registers */ |
| 581 | memset(cps1_cps_b_regs, 0, 0x40); /* Clear CPS-B registers */ |
| 582 | |
| 583 | /* Put in some defaults */ |
| 584 | cps1_cps_a_regs[CPS1_OBJ_BASE] = 0x9200; |
| 585 | cps1_cps_a_regs[CPS1_SCROLL1_BASE] = 0x9000; |
| 586 | cps1_cps_a_regs[CPS1_SCROLL2_BASE] = 0x9040; |
| 587 | cps1_cps_a_regs[CPS1_SCROLL3_BASE] = 0x9080; |
| 588 | cps1_cps_a_regs[CPS1_OTHER_BASE] = 0x9100; |
| 589 | |
| 590 | assert_always(cps1_game_config, "cps1_game_config hasn't been set up yet"); |
| 591 | |
| 592 | /* Set up old base */ |
| 593 | cps1_get_video_base(); /* Calculate base pointers */ |
| 594 | cps1_get_video_base(); /* Calculate old base pointers */ |
| 595 | } |
| 596 | |
| 597 | |
| 598 | |
| 599 | /*************************************************************************** |
| 600 | |
| 601 | Build palette from palette RAM |
| 602 | |
| 603 | 12 bit RGB with a 4 bit brightness value. |
| 604 | |
| 605 | ***************************************************************************/ |
| 606 | |
| 607 | static void cps1_build_palette(running_machine *machine, const UINT16* const palette_base) |
| 608 | { |
| 609 | int offset, page; |
| 610 | const UINT16 *palette_ram = palette_base; |
| 611 | |
| 612 | int ctrl = cps1_cps_b_regs[cps1_game_config->palette_control/2]; |
| 613 | |
| 614 | for (page = 0; page < 6; ++page) |
| 615 | { |
| 616 | if (BIT(ctrl,page)) |
| 617 | { |
| 618 | for (offset = 0; offset < 0x200; ++offset) |
| 619 | { |
| 620 | int palette = *(palette_ram++); |
| 621 | int r, g, b, bright; |
| 622 | |
| 623 | // from my understanding of the schematics, when the 'brightness' |
| 624 | // component is set to 0 it should reduce brightness to 1/3 |
| 625 | |
| 626 | bright = 0x0f + ((palette>>12)<<1); |
| 627 | |
| 628 | r = ((palette>>8)&0x0f) * 0x11 * bright / 0x2d; |
| 629 | g = ((palette>>4)&0x0f) * 0x11 * bright / 0x2d; |
| 630 | b = ((palette>>0)&0x0f) * 0x11 * bright / 0x2d; |
| 631 | |
| 632 | palette_set_color (machine, 0x200*page + offset, MAKE_RGB(r, g, b)); |
| 633 | } |
| 634 | } |
| 635 | else |
| 636 | { |
| 637 | // skip page in gfxram, but only if we have already copied at least one page |
| 638 | if (palette_ram != palette_base) |
| 639 | palette_ram += 0x200; |
| 640 | } |
| 641 | } |
| 642 | } |
| 643 | |
| 644 | static void cps1_find_last_sprite(void) /* Find the offset of last sprite */ |
| 645 | { |
| 646 | int offset=0; |
| 647 | /* Locate the end of table marker */ |
| 648 | while (offset < cps1_obj_size/2) |
| 649 | { |
| 650 | int colour=cps1_buffered_obj[offset+3]; |
| 651 | if ((colour & 0xff00) == 0xff00) |
| 652 | { |
| 653 | /* Marker found. This is the last sprite. */ |
| 654 | cps1_last_sprite_offset=offset-4; |
| 655 | return; |
| 656 | } |
| 657 | offset+=4; |
| 658 | } |
| 659 | /* Sprites must use full sprite RAM */ |
| 660 | cps1_last_sprite_offset=cps1_obj_size/2-4; |
| 661 | } |
| 662 | |
| 663 | |
| 664 | static void cps1_render_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) |
| 665 | { |
| 666 | #define DRAWSPRITE(CODE,COLOR,FLIPX,FLIPY,SX,SY) \ |
| 667 | { \ |
| 668 | if (flip_screen_get(machine)) \ |
| 669 | pdrawgfx(bitmap,machine->gfx[2], \ |
| 670 | CODE, \ |
| 671 | COLOR, \ |
| 672 | !(FLIPX),!(FLIPY), \ |
| 673 | 511-16-(SX),255-16-(SY), \ |
| 674 | cliprect,TRANSPARENCY_PEN,15,0x02); \ |
| 675 | else \ |
| 676 | pdrawgfx(bitmap,machine->gfx[2], \ |
| 677 | CODE, \ |
| 678 | COLOR, \ |
| 679 | FLIPX,FLIPY, \ |
| 680 | SX,SY, \ |
| 681 | cliprect,TRANSPARENCY_PEN,15,0x02); \ |
| 682 | } |
| 683 | |
| 684 | |
| 685 | int i, baseadd; |
| 686 | UINT16 *base=cps1_buffered_obj; |
| 687 | |
| 688 | /* some sf2 hacks draw the sprites in reverse order */ |
| 689 | if (cps1_game_config->bootleg_kludge == 1) |
| 690 | { |
| 691 | base += cps1_last_sprite_offset; |
| 692 | baseadd = -4; |
| 693 | } |
| 694 | else |
| 695 | { |
| 696 | baseadd = 4; |
| 697 | } |
| 698 | |
| 699 | for (i=cps1_last_sprite_offset; i>=0; i-=4) |
| 700 | { |
| 701 | int x=*(base+0); |
| 702 | int y=*(base+1); |
| 703 | int code =*(base+2); |
| 704 | int colour=*(base+3); |
| 705 | int col=colour&0x1f; |
| 706 | |
| 707 | code = gfxrom_bank_mapper(machine, GFXTYPE_SPRITES, code); |
| 708 | |
| 709 | if (code != -1) |
| 710 | { |
| 711 | if (colour & 0xff00 ) |
| 712 | { |
| 713 | /* handle blocked sprites */ |
| 714 | int nx=(colour & 0x0f00) >> 8; |
| 715 | int ny=(colour & 0xf000) >> 12; |
| 716 | int nxs,nys,sx,sy; |
| 717 | nx++; |
| 718 | ny++; |
| 719 | |
| 720 | if (colour & 0x40) |
| 721 | { |
| 722 | /* Y flip */ |
| 723 | if (colour &0x20) |
| 724 | { |
| 725 | for (nys=0; nys<ny; nys++) |
| 726 | { |
| 727 | for (nxs=0; nxs<nx; nxs++) |
| 728 | { |
| 729 | sx = (x+nxs*16) & 0x1ff; |
| 730 | sy = (y+nys*16) & 0x1ff; |
| 731 | |
| 732 | DRAWSPRITE( |
| 733 | (code & ~0xf) + ((code + (nx-1) - nxs) & 0xf) + 0x10*(ny-1-nys), |
| 734 | (col&0x1f), |
| 735 | 1,1, |
| 736 | sx,sy); |
| 737 | } |
| 738 | } |
| 739 | } |
| 740 | else |
| 741 | { |
| 742 | for (nys=0; nys<ny; nys++) |
| 743 | { |
| 744 | for (nxs=0; nxs<nx; nxs++) |
| 745 | { |
| 746 | sx = (x+nxs*16) & 0x1ff; |
| 747 | sy = (y+nys*16) & 0x1ff; |
| 748 | |
| 749 | DRAWSPRITE( |
| 750 | (code & ~0xf) + ((code + nxs) & 0xf) + 0x10*(ny-1-nys), |
| 751 | (col&0x1f), |
| 752 | 0,1, |
| 753 | sx,sy); |
| 754 | } |
| 755 | } |
| 756 | } |
| 757 | } |
| 758 | else |
| 759 | { |
| 760 | if (colour &0x20) |
| 761 | { |
| 762 | for (nys=0; nys<ny; nys++) |
| 763 | { |
| 764 | for (nxs=0; nxs<nx; nxs++) |
| 765 | { |
| 766 | sx = (x+nxs*16) & 0x1ff; |
| 767 | sy = (y+nys*16) & 0x1ff; |
| 768 | |
| 769 | DRAWSPRITE( |
| 770 | (code & ~0xf) + ((code + (nx-1) - nxs) & 0xf) + 0x10*nys, |
| 771 | (col&0x1f), |
| 772 | 1,0, |
| 773 | sx,sy); |
| 774 | } |
| 775 | } |
| 776 | } |
| 777 | else |
| 778 | { |
| 779 | for (nys=0; nys<ny; nys++) |
| 780 | { |
| 781 | for (nxs=0; nxs<nx; nxs++) |
| 782 | { |
| 783 | sx = (x+nxs*16) & 0x1ff; |
| 784 | sy = (y+nys*16) & 0x1ff; |
| 785 | |
| 786 | DRAWSPRITE( |
| 787 | (code & ~0xf) + ((code + nxs) & 0xf) + 0x10*nys, // fix 00406: qadj: When playing as the ninja, there is one broekn frame in his animation loop when walking. |
| 788 | (col&0x1f), |
| 789 | 0,0, |
| 790 | sx,sy); |
| 791 | } |
| 792 | } |
| 793 | } |
| 794 | } |
| 795 | } |
| 796 | else |
| 797 | { |
| 798 | /* Simple case... 1 sprite */ |
| 799 | DRAWSPRITE( |
| 800 | code, |
| 801 | (col&0x1f), |
| 802 | colour&0x20,colour&0x40, |
| 803 | x & 0x1ff,y & 0x1ff); |
| 804 | } |
| 805 | } |
| 806 | base += baseadd; |
| 807 | } |
| 808 | #undef DRAWSPRITE |
| 809 | } |
| 810 | |
| 811 | |
| 812 | static void cps1_render_stars(const device_config *screen, bitmap_t *bitmap,const rectangle *cliprect) |
| 813 | { |
| 814 | int offs; |
| 815 | UINT8 *stars_rom = memory_region(screen->machine, "stars"); |
| 816 | |
| 817 | if (!stars_rom && (cps1_stars_enabled[0] || cps1_stars_enabled[1])) |
| 818 | { |
| 819 | return; |
| 820 | } |
| 821 | |
| 822 | if (cps1_stars_enabled[0]) |
| 823 | { |
| 824 | for (offs = 0;offs < stars_rom_size/2;offs++) |
| 825 | { |
| 826 | int col = stars_rom[8*offs+4]; |
| 827 | if (col != 0x0f) |
| 828 | { |
| 829 | int sx = (offs / 256) * 32; |
| 830 | int sy = (offs % 256); |
| 831 | sx = (sx - stars2x + (col & 0x1f)) & 0x1ff; |
| 832 | sy = (sy - stars2y) & 0xff; |
| 833 | if (flip_screen_get(screen->machine)) |
| 834 | { |
| 835 | sx = 511 - sx; |
| 836 | sy = 255 - sy; |
| 837 | } |
| 838 | |
| 839 | col = ((col & 0xe0) >> 1) + (video_screen_get_frame_number(screen)/16 & 0x0f); |
| 840 | |
| 841 | if (sx >= cliprect->min_x && sx <= cliprect->max_x && |
| 842 | sy >= cliprect->min_y && sy <= cliprect->max_y) |
| 843 | *BITMAP_ADDR16(bitmap, sy, sx) = 0xa00 + col; |
| 844 | } |
| 845 | } |
| 846 | } |
| 847 | |
| 848 | if (cps1_stars_enabled[1]) |
| 849 | { |
| 850 | for (offs = 0;offs < stars_rom_size/2;offs++) |
| 851 | { |
| 852 | int col = stars_rom[8*offs]; |
| 853 | if (col != 0x0f) |
| 854 | { |
| 855 | int sx = (offs / 256) * 32; |
| 856 | int sy = (offs % 256); |
| 857 | sx = (sx - stars1x + (col & 0x1f)) & 0x1ff; |
| 858 | sy = (sy - stars1y) & 0xff; |
| 859 | if (flip_screen_get(screen->machine)) |
| 860 | { |
| 861 | sx = 511 - sx; |
| 862 | sy = 255 - sy; |
| 863 | } |
| 864 | |
| 865 | col = ((col & 0xe0) >> 1) + (video_screen_get_frame_number(screen)/16 & 0x0f); |
| 866 | |
| 867 | if (sx >= cliprect->min_x && sx <= cliprect->max_x && |
| 868 | sy >= cliprect->min_y && sy <= cliprect->max_y) |
| 869 | *BITMAP_ADDR16(bitmap, sy, sx) = 0x800 + col; |
| 870 | } |
| 871 | } |
| 872 | } |
| 873 | } |
| 874 | |
| 875 | |
| 876 | static void cps1_render_layer(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,int layer,int primask) |
| 877 | { |
| 878 | switch (layer) |
| 879 | { |
| 880 | case 0: |
| 881 | cps1_render_sprites(machine,bitmap,cliprect); |
| 882 | break; |
| 883 | case 1: |
| 884 | case 2: |
| 885 | case 3: |
| 886 | tilemap_draw(bitmap,cliprect,cps1_bg_tilemap[layer-1],TILEMAP_DRAW_LAYER1,primask); |
| 887 | break; |
| 888 | } |
| 889 | } |
| 890 | |
| 891 | static void cps1_render_high_layer(bitmap_t *bitmap, const rectangle *cliprect, int layer) |
| 892 | { |
| 893 | switch (layer) |
| 894 | { |
| 895 | case 0: |
| 896 | /* there are no high priority sprites */ |
| 897 | break; |
| 898 | case 1: |
| 899 | case 2: |
| 900 | case 3: |
| 901 | tilemap_draw(NULL,cliprect,cps1_bg_tilemap[layer-1],TILEMAP_DRAW_LAYER0,1); |
| 902 | break; |
| 903 | } |
| 904 | } |
| 905 | |
| 906 | |
| 907 | /*************************************************************************** |
| 908 | |
| 909 | Refresh screen |
| 910 | |
| 911 | ***************************************************************************/ |
| 912 | |
| 913 | VIDEO_UPDATE( cps1 ) |
| 914 | { |
| 915 | int layercontrol,l0,l1,l2,l3; |
| 916 | int videocontrol = cps1_cps_a_regs[CPS1_VIDEOCONTROL]; |
| 917 | |
| 918 | |
| 919 | flip_screen_set(screen->machine, videocontrol & 0x8000); |
| 920 | |
| 921 | layercontrol = cps1_cps_b_regs[cps1_game_config->layer_control/2]; |
| 922 | |
| 923 | /* Get video memory base registers */ |
| 924 | cps1_get_video_base(); |
| 925 | |
| 926 | /* Find the offset of the last sprite in the sprite table */ |
| 927 | cps1_find_last_sprite(); |
| 928 | cps1_update_transmasks(); |
| 929 | |
| 930 | tilemap_set_scrollx(cps1_bg_tilemap[0],0,cps1_scroll1x); |
| 931 | tilemap_set_scrolly(cps1_bg_tilemap[0],0,cps1_scroll1y); |
| 932 | if (videocontrol & 0x01) /* linescroll enable */ |
| 933 | { |
| 934 | int scrly=-cps1_scroll2y; |
| 935 | int i; |
| 936 | int otheroffs; |
| 937 | |
| 938 | tilemap_set_scroll_rows(cps1_bg_tilemap[1],1024); |
| 939 | |
| 940 | otheroffs = cps1_cps_a_regs[CPS1_ROWSCROLL_OFFS]; |
| 941 | |
| 942 | for (i = 0;i < 256;i++) |
| 943 | tilemap_set_scrollx(cps1_bg_tilemap[1],(i - scrly) & 0x3ff,cps1_scroll2x + cps1_other[(i + otheroffs) & 0x3ff]); |
| 944 | } |
| 945 | else |
| 946 | { |
| 947 | tilemap_set_scroll_rows(cps1_bg_tilemap[1],1); |
| 948 | tilemap_set_scrollx(cps1_bg_tilemap[1],0,cps1_scroll2x); |
| 949 | } |
| 950 | tilemap_set_scrolly(cps1_bg_tilemap[1],0,cps1_scroll2y); |
| 951 | tilemap_set_scrollx(cps1_bg_tilemap[2],0,cps1_scroll3x); |
| 952 | tilemap_set_scrolly(cps1_bg_tilemap[2],0,cps1_scroll3y); |
| 953 | |
| 954 | |
| 955 | /* Blank screen */ |
| 956 | bitmap_fill(bitmap,cliprect,0xbff); |
| 957 | |
| 958 | cps1_render_stars(screen, bitmap,cliprect); |
| 959 | |
| 960 | /* Draw layers (0 = sprites, 1-3 = tilemaps) */ |
| 961 | l0 = (layercontrol >> 0x06) & 03; |
| 962 | l1 = (layercontrol >> 0x08) & 03; |
| 963 | l2 = (layercontrol >> 0x0a) & 03; |
| 964 | l3 = (layercontrol >> 0x0c) & 03; |
| 965 | bitmap_fill(priority_bitmap,cliprect,0); |
| 966 | |
| 967 | cps1_render_layer(screen->machine,bitmap,cliprect,l0,0); |
| 968 | if (l1 == 0) cps1_render_high_layer(bitmap,cliprect,l0); /* prepare mask for sprites */ |
| 969 | cps1_render_layer(screen->machine,bitmap,cliprect,l1,0); |
| 970 | if (l2 == 0) cps1_render_high_layer(bitmap,cliprect,l1); /* prepare mask for sprites */ |
| 971 | cps1_render_layer(screen->machine,bitmap,cliprect,l2,0); |
| 972 | if (l3 == 0) cps1_render_high_layer(bitmap,cliprect,l2); /* prepare mask for sprites */ |
| 973 | cps1_render_layer(screen->machine,bitmap,cliprect,l3,0); |
| 974 | |
| 975 | return 0; |
| 976 | } |
| 977 | |
| 978 | VIDEO_EOF( cps1 ) |
| 979 | { |
| 980 | /* Get video memory base registers */ |
| 981 | cps1_get_video_base(); |
| 982 | |
| 983 | /* CPS1 sprites have to be delayed one frame */ |
| 984 | memcpy(cps1_buffered_obj, cps1_obj, cps1_obj_size); |
| 985 | } |
src/mess/drivers/pdp1.c
| r4407 | r4408 | |
| 81 | 81 | #endif |
| 82 | 82 | ADDRESS_MAP_END |
| 83 | 83 | |
| 84 | | static DRIVER_INIT( pdp1 ) |
| 85 | | { |
| 86 | | UINT8 *dst; |
| 87 | | |
| 88 | | static const unsigned char fontdata6x8[pdp1_fontdata_size] = |
| 89 | | { /* ASCII characters */ |
| 90 | | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00, |
| 91 | | 0x50,0x50,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0xf8,0x50,0xf8,0x50,0x00,0x00, |
| 92 | | 0x20,0x70,0xc0,0x70,0x18,0xf0,0x20,0x00,0x40,0xa4,0x48,0x10,0x20,0x48,0x94,0x08, |
| 93 | | 0x60,0x90,0xa0,0x40,0xa8,0x90,0x68,0x00,0x10,0x20,0x40,0x00,0x00,0x00,0x00,0x00, |
| 94 | | 0x20,0x40,0x40,0x40,0x40,0x40,0x20,0x00,0x10,0x08,0x08,0x08,0x08,0x08,0x10,0x00, |
| 95 | | 0x20,0xa8,0x70,0xf8,0x70,0xa8,0x20,0x00,0x00,0x20,0x20,0xf8,0x20,0x20,0x00,0x00, |
| 96 | | 0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x60,0x00,0x00,0x00,0xf8,0x00,0x00,0x00,0x00, |
| 97 | | 0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00, |
| 98 | | 0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x00,0x10,0x30,0x10,0x10,0x10,0x10,0x10,0x00, |
| 99 | | 0x70,0x88,0x08,0x10,0x20,0x40,0xf8,0x00,0x70,0x88,0x08,0x30,0x08,0x88,0x70,0x00, |
| 100 | | 0x10,0x30,0x50,0x90,0xf8,0x10,0x10,0x00,0xf8,0x80,0xf0,0x08,0x08,0x88,0x70,0x00, |
| 101 | | 0x70,0x80,0xf0,0x88,0x88,0x88,0x70,0x00,0xf8,0x08,0x08,0x10,0x20,0x20,0x20,0x00, |
| 102 | | 0x70,0x88,0x88,0x70,0x88,0x88,0x70,0x00,0x70,0x88,0x88,0x88,0x78,0x08,0x70,0x00, |
| 103 | | 0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x00,0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x60, |
| 104 | | 0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x00,0x00,0x00,0xf8,0x00,0xf8,0x00,0x00,0x00, |
| 105 | | 0x40,0x20,0x10,0x08,0x10,0x20,0x40,0x00,0x70,0x88,0x08,0x10,0x20,0x00,0x20,0x00, |
| 106 | | 0x70,0x88,0xb8,0xa8,0xb8,0x80,0x70,0x00,0x70,0x88,0x88,0xf8,0x88,0x88,0x88,0x00, |
| 107 | | 0xf0,0x88,0x88,0xf0,0x88,0x88,0xf0,0x00,0x70,0x88,0x80,0x80,0x80,0x88,0x70,0x00, |
| 108 | | 0xf0,0x88,0x88,0x88,0x88,0x88,0xf0,0x00,0xf8,0x80,0x80,0xf0,0x80,0x80,0xf8,0x00, |
| 109 | | 0xf8,0x80,0x80,0xf0,0x80,0x80,0x80,0x00,0x70,0x88,0x80,0x98,0x88,0x88,0x70,0x00, |
| 110 | | 0x88,0x88,0x88,0xf8,0x88,0x88,0x88,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00, |
| 111 | | 0x08,0x08,0x08,0x08,0x88,0x88,0x70,0x00,0x88,0x90,0xa0,0xc0,0xa0,0x90,0x88,0x00, |
| 112 | | 0x80,0x80,0x80,0x80,0x80,0x80,0xf8,0x00,0x88,0xd8,0xa8,0x88,0x88,0x88,0x88,0x00, |
| 113 | | 0x88,0xc8,0xa8,0x98,0x88,0x88,0x88,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x00, |
| 114 | | 0xf0,0x88,0x88,0xf0,0x80,0x80,0x80,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x08, |
| 115 | | 0xf0,0x88,0x88,0xf0,0x88,0x88,0x88,0x00,0x70,0x88,0x80,0x70,0x08,0x88,0x70,0x00, |
| 116 | | 0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00, |
| 117 | | 0x88,0x88,0x88,0x88,0x88,0x50,0x20,0x00,0x88,0x88,0x88,0x88,0xa8,0xd8,0x88,0x00, |
| 118 | | 0x88,0x50,0x20,0x20,0x20,0x50,0x88,0x00,0x88,0x88,0x88,0x50,0x20,0x20,0x20,0x00, |
| 119 | | 0xf8,0x08,0x10,0x20,0x40,0x80,0xf8,0x00,0x30,0x20,0x20,0x20,0x20,0x20,0x30,0x00, |
| 120 | | 0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x30,0x10,0x10,0x10,0x10,0x10,0x30,0x00, |
| 121 | | 0x20,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc, |
| 122 | | 0x40,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x08,0x78,0x88,0x78,0x00, |
| 123 | | 0x80,0x80,0xf0,0x88,0x88,0x88,0xf0,0x00,0x00,0x00,0x70,0x88,0x80,0x80,0x78,0x00, |
| 124 | | 0x08,0x08,0x78,0x88,0x88,0x88,0x78,0x00,0x00,0x00,0x70,0x88,0xf8,0x80,0x78,0x00, |
| 125 | | 0x18,0x20,0x70,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x78,0x88,0x88,0x78,0x08,0x70, |
| 126 | | 0x80,0x80,0xf0,0x88,0x88,0x88,0x88,0x00,0x20,0x00,0x20,0x20,0x20,0x20,0x20,0x00, |
| 127 | | 0x20,0x00,0x20,0x20,0x20,0x20,0x20,0xc0,0x80,0x80,0x90,0xa0,0xe0,0x90,0x88,0x00, |
| 128 | | 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0xf0,0xa8,0xa8,0xa8,0xa8,0x00, |
| 129 | | 0x00,0x00,0xb0,0xc8,0x88,0x88,0x88,0x00,0x00,0x00,0x70,0x88,0x88,0x88,0x70,0x00, |
| 130 | | 0x00,0x00,0xf0,0x88,0x88,0xf0,0x80,0x80,0x00,0x00,0x78,0x88,0x88,0x78,0x08,0x08, |
| 131 | | 0x00,0x00,0xb0,0xc8,0x80,0x80,0x80,0x00,0x00,0x00,0x78,0x80,0x70,0x08,0xf0,0x00, |
| 132 | | 0x20,0x20,0x70,0x20,0x20,0x20,0x18,0x00,0x00,0x00,0x88,0x88,0x88,0x98,0x68,0x00, |
| 133 | | 0x00,0x00,0x88,0x88,0x88,0x50,0x20,0x00,0x00,0x00,0xa8,0xa8,0xa8,0xa8,0x50,0x00, |
| 134 | | 0x00,0x00,0x88,0x50,0x20,0x50,0x88,0x00,0x00,0x00,0x88,0x88,0x88,0x78,0x08,0x70, |
| 135 | | 0x00,0x00,0xf8,0x10,0x20,0x40,0xf8,0x00,0x08,0x10,0x10,0x20,0x10,0x10,0x08,0x00, |
| 136 | | 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x40,0x20,0x20,0x10,0x20,0x20,0x40,0x00, |
| 137 | | 0x00,0x68,0xb0,0x00,0x00,0x00,0x00,0x00,0x20,0x50,0x20,0x50,0xa8,0x50,0x00,0x00, |
| 138 | | }; |
| 139 | | |
| 140 | | /* set up our font */ |
| 141 | | dst = memory_region(machine, "gfx1"); |
| 142 | | |
| 143 | | memcpy(dst, fontdata6x8, pdp1_fontdata_size); |
| 144 | | } |
| 145 | | |
| 146 | | |
| 147 | 84 | static INPUT_PORTS_START( pdp1 ) |
| 148 | 85 | |
| 149 | 86 | PORT_START("SPACEWAR") /* 0: spacewar controllers */ |
| r4407 | r4408 | |
| 581 | 518 | ***************************************************************************/ |
| 582 | 519 | |
| 583 | 520 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME */ |
| 584 | | COMP( 1961, pdp1, 0, 0, pdp1, pdp1, pdp1, pdp1, "Digital Equipment Corporation", "PDP-1" , 0) |
| 521 | COMP( 1961, pdp1, 0, 0, pdp1, pdp1, 0, pdp1, "Digital Equipment Corporation", "PDP-1" , 0) |