src/mess/video/jaguar.c
| r0 | r5099 | |
| 1 | /***************************************************************************
|
| 2 | |
| 3 | Atari Jaguar hardware
|
| 4 | |
| 5 | ****************************************************************************
|
| 6 | |
| 7 | ------------------------------------------------------------
|
| 8 | TOM REGISTERS
|
| 9 | ------------------------------------------------------------
|
| 10 | F00000-F0FFFF R/W xxxxxxxx xxxxxxxx Internal Registers
|
| 11 | F00000 R/W -x-xx--- xxxxxxxx MEMCON1 - memory config reg 1
|
| 12 | -x------ -------- (CPU32 - is the CPU 32bits?)
|
| 13 | ---xx--- -------- (IOSPEED - external I/O clock cycles)
|
| 14 | -------- x------- (FASTROM - reduces ROM clock cycles)
|
| 15 | -------- -xx----- (DRAMSPEED - sets RAM clock cycles)
|
| 16 | -------- ---xx--- (ROMSPEED - sets ROM clock cycles)
|
| 17 | -------- -----xx- (ROMWIDTH - sets width of ROM: 8,16,32,64 bits)
|
| 18 | -------- -------x (ROMHI - controls ROM mapping)
|
| 19 | F00002 R/W --xxxxxx xxxxxxxx MEMCON2 - memory config reg 2
|
| 20 | --x----- -------- (HILO - image display bit order)
|
| 21 | ---x---- -------- (BIGEND - big endian addressing?)
|
| 22 | ----xxxx -------- (REFRATE - DRAM refresh rate)
|
| 23 | -------- xx------ (DWIDTH1 - DRAM1 width: 8,16,32,64 bits)
|
| 24 | -------- --xx---- (COLS1 - DRAM1 columns: 256,512,1024,2048)
|
| 25 | -------- ----xx-- (DWIDTH0 - DRAM0 width: 8,16,32,64 bits)
|
| 26 | -------- ------xx (COLS0 - DRAM0 columns: 256,512,1024,2048)
|
| 27 | F00004 R/W -----xxx xxxxxxxx HC - horizontal count
|
| 28 | -----x-- -------- (which half of the display)
|
| 29 | ------xx xxxxxxxx (10-bit counter)
|
| 30 | F00006 R/W ----xxxx xxxxxxxx VC - vertical count
|
| 31 | ----x--- -------- (which field is being generated)
|
| 32 | -----xxx xxxxxxxx (11-bit counter)
|
| 33 | F00008 R -----xxx xxxxxxxx LPH - light pen horizontal position
|
| 34 | F0000A R -----xxx xxxxxxxx LPV - light pen vertical position
|
| 35 | F00010-F00017 R xxxxxxxx xxxxxxxx OB - current object code from the graphics processor
|
| 36 | F00020-F00023 W xxxxxxxx xxxxxxxx OLP - start of the object list
|
| 37 | F00026 W -------- -------x OBF - object processor flag
|
| 38 | F00028 W ----xxxx xxxxxxxx VMODE - video mode
|
| 39 | W ----xxx- -------- (PWIDTH1-8 - width of pixel in video clock cycles)
|
| 40 | W -------x -------- (VARMOD - enable variable color resolution)
|
| 41 | W -------- x------- (BGEN - clear line buffere to BG color)
|
| 42 | W -------- -x------ (CSYNC - enable composite sync on VSYNC)
|
| 43 | W -------- --x----- (BINC - local border color if INCEN)
|
| 44 | W -------- ---x---- (INCEN - encrustation enable)
|
| 45 | W -------- ----x--- (GENLOCK - enable genlock)
|
| 46 | W -------- -----xx- (MODE - CRY16,RGB24,DIRECT16,RGB16)
|
| 47 | W -------- -------x (VIDEN - enables video)
|
| 48 | F0002A W xxxxxxxx xxxxxxxx BORD1 - border color (red/green)
|
| 49 | F0002C W -------- xxxxxxxx BORD2 - border color (blue)
|
| 50 | F0002E W ------xx xxxxxxxx HP - horizontal period
|
| 51 | F00030 W -----xxx xxxxxxxx HBB - horizontal blanking begin
|
| 52 | F00032 W -----xxx xxxxxxxx HBE - horizontal blanking end
|
| 53 | F00034 W -----xxx xxxxxxxx HSYNC - horizontal sync
|
| 54 | F00036 W ------xx xxxxxxxx HVS - horizontal vertical sync
|
| 55 | F00038 W -----xxx xxxxxxxx HDB1 - horizontal display begin 1
|
| 56 | F0003A W -----xxx xxxxxxxx HDB2 - horizontal display begin 2
|
| 57 | F0003C W -----xxx xxxxxxxx HDE - horizontal display end
|
| 58 | F0003E W -----xxx xxxxxxxx VP - vertical period
|
| 59 | F00040 W -----xxx xxxxxxxx VBB - vertical blanking begin
|
| 60 | F00042 W -----xxx xxxxxxxx VBE - vertical blanking end
|
| 61 | F00044 W -----xxx xxxxxxxx VS - vertical sync
|
| 62 | F00046 W -----xxx xxxxxxxx VDB - vertical display begin
|
| 63 | F00048 W -----xxx xxxxxxxx VDE - vertical display end
|
| 64 | F0004A W -----xxx xxxxxxxx VEB - vertical equalization begin
|
| 65 | F0004C W -----xxx xxxxxxxx VEE - vertical equalization end
|
| 66 | F0004E W -----xxx xxxxxxxx VI - vertical interrupt
|
| 67 | F00050 W xxxxxxxx xxxxxxxx PIT0 - programmable interrupt timer 0
|
| 68 | F00052 W xxxxxxxx xxxxxxxx PIT1 - programmable interrupt timer 1
|
| 69 | F00054 W ------xx xxxxxxxx HEQ - horizontal equalization end
|
| 70 | F00058 W xxxxxxxx xxxxxxxx BG - background color
|
| 71 | F000E0 R/W ---xxxxx ---xxxxx INT1 - CPU interrupt control register
|
| 72 | ---x---- -------- (C_JERCLR - clear pending Jerry ints)
|
| 73 | ----x--- -------- (C_PITCLR - clear pending PIT ints)
|
| 74 | -----x-- -------- (C_OPCLR - clear pending object processor ints)
|
| 75 | ------x- -------- (C_GPUCLR - clear pending graphics processor ints)
|
| 76 | -------x -------- (C_VIDCLR - clear pending video timebase ints)
|
| 77 | -------- ---x---- (C_JERENA - enable Jerry ints)
|
| 78 | -------- ----x--- (C_PITENA - enable PIT ints)
|
| 79 | -------- -----x-- (C_OPENA - enable object processor ints)
|
| 80 | -------- ------x- (C_GPUENA - enable graphics processor ints)
|
| 81 | -------- -------x (C_VIDENA - enable video timebase ints)
|
| 82 | F000E2 W -------- -------- INT2 - CPU interrupt resume register
|
| 83 | F00400-F005FF R/W xxxxxxxx xxxxxxxx CLUT - color lookup table A
|
| 84 | F00600-F007FF R/W xxxxxxxx xxxxxxxx CLUT - color lookup table B
|
| 85 | F00800-F00D9F R/W xxxxxxxx xxxxxxxx LBUF - line buffer A
|
| 86 | F01000-F0159F R/W xxxxxxxx xxxxxxxx LBUF - line buffer B
|
| 87 | F01800-F01D9F R/W xxxxxxxx xxxxxxxx LBUF - line buffer currently selected
|
| 88 | ------------------------------------------------------------
|
| 89 | F02000-F021FF R/W xxxxxxxx xxxxxxxx GPU control registers
|
| 90 | F02100 R/W xxxxxxxx xxxxxxxx G_FLAGS - GPU flags register
|
| 91 | R/W x------- -------- (DMAEN - DMA enable)
|
| 92 | R/W -x------ -------- (REGPAGE - register page)
|
| 93 | W --x----- -------- (G_BLITCLR - clear blitter interrupt)
|
| 94 | W ---x---- -------- (G_OPCLR - clear object processor int)
|
| 95 | W ----x--- -------- (G_PITCLR - clear PIT interrupt)
|
| 96 | W -----x-- -------- (G_JERCLR - clear Jerry interrupt)
|
| 97 | W ------x- -------- (G_CPUCLR - clear CPU interrupt)
|
| 98 | R/W -------x -------- (G_BLITENA - enable blitter interrupt)
|
| 99 | R/W -------- x------- (G_OPENA - enable object processor int)
|
| 100 | R/W -------- -x------ (G_PITENA - enable PIT interrupt)
|
| 101 | R/W -------- --x----- (G_JERENA - enable Jerry interrupt)
|
| 102 | R/W -------- ---x---- (G_CPUENA - enable CPU interrupt)
|
| 103 | R/W -------- ----x--- (IMASK - interrupt mask)
|
| 104 | R/W -------- -----x-- (NEGA_FLAG - ALU negative)
|
| 105 | R/W -------- ------x- (CARRY_FLAG - ALU carry)
|
| 106 | R/W -------- -------x (ZERO_FLAG - ALU zero)
|
| 107 | F02104 W -------- ----xxxx G_MTXC - matrix control register
|
| 108 | W -------- ----x--- (MATCOL - column/row major)
|
| 109 | W -------- -----xxx (MATRIX3-15 - matrix width)
|
| 110 | F02108 W ----xxxx xxxxxx-- G_MTXA - matrix address register
|
| 111 | F0210C W -------- -----xxx G_END - data organization register
|
| 112 | W -------- -----x-- (BIG_INST - big endian instruction fetch)
|
| 113 | W -------- ------x- (BIG_PIX - big endian pixels)
|
| 114 | W -------- -------x (BIG_IO - big endian I/O)
|
| 115 | F02110 R/W xxxxxxxx xxxxxxxx G_PC - GPU program counter
|
| 116 | F02114 R/W xxxxxxxx xx-xxxxx G_CTRL - GPU control/status register
|
| 117 | R xxxx---- -------- (VERSION - GPU version code)
|
| 118 | R/W ----x--- -------- (BUS_HOG - hog the bus!)
|
| 119 | R/W -----x-- -------- (G_BLITLAT - blitter interrupt latch)
|
| 120 | R/W ------x- -------- (G_OPLAT - object processor int latch)
|
| 121 | R/W -------x -------- (G_PITLAT - PIT interrupt latch)
|
| 122 | R/W -------- x------- (G_JERLAT - Jerry interrupt latch)
|
| 123 | R/W -------- -x------ (G_CPULAT - CPU interrupt latch)
|
| 124 | R/W -------- ---x---- (SINGLE_GO - single step one instruction)
|
| 125 | R/W -------- ----x--- (SINGLE_STEP - single step mode)
|
| 126 | R/W -------- -----x-- (FORCEINT0 - cause interrupt 0 on GPU)
|
| 127 | R/W -------- ------x- (CPUINT - send GPU interrupt to CPU)
|
| 128 | R/W -------- -------x (GPUGO - enable GPU execution)
|
| 129 | F02118-F0211B R/W xxxxxxxx xxxxxxxx G_HIDATA - high data register
|
| 130 | F0211C-F0211F R xxxxxxxx xxxxxxxx G_REMAIN - divide unit remainder
|
| 131 | F0211C W -------- -------x G_DIVCTRL - divide unit control
|
| 132 | W -------- -------x (DIV_OFFSET - 1=16.16 divide, 0=32-bit divide)
|
| 133 | ------------------------------------------------------------
|
| 134 | |
| 135 | ****************************************************************************/
|
| 136 | |
| 137 | #include "driver.h"
|
| 138 | #include "memconv.h"
|
| 139 | #include "profiler.h"
|
| 140 | #include "machine/atarigen.h"
|
| 141 | #include "cpu/mips/r3000.h"
|
| 142 | #include "cpu/m68000/m68000.h"
|
| 143 | #include "includes/jaguar.h"
|
| 144 | #include "jagblit.h"
|
| 145 | |
| 146 | |
| 147 | #define ENABLE_BORDERS 0
|
| 148 | |
| 149 | #define LOG_BLITS 0
|
| 150 | #define LOG_BAD_BLITS 0
|
| 151 | #define LOG_BLITTER_STATS 0
|
| 152 | #define LOG_BLITTER_WRITE 0
|
| 153 | #define LOG_UNHANDLED_BLITS 0
|
| 154 | |
| 155 | |
| 156 | // interrupts to main CPU:
|
| 157 | // 0 = video (on the VI scanline)
|
| 158 | // 1 = GPU (write from GPU coprocessor)
|
| 159 | // 2 = object (stop object interrupt in display list)
|
| 160 | // 3 = timer (from the PIT)
|
| 161 | // 4 = jerry
|
| 162 | |
| 163 | |
| 164 | /* GPU registers */
|
| 165 | enum
|
| 166 | {
|
| 167 | MEMCON1, MEMCON2, HC, VC,
|
| 168 | LPH, LPV, GPU0, GPU1,
|
| 169 | OB_HH, OB_HL, OB_LH, OB_LL,
|
| 170 | GPU2, GPU3, GPU4, GPU5,
|
| 171 | OLP_L, OLP_H, GPU6, OBF,
|
| 172 | VMODE, BORD1, BORD2, HP,
|
| 173 | HBB, HBE, HSYNC, HVS,
|
| 174 | HDB1, HDB2, HDE, VP,
|
| 175 | VBB, VBE, VS, VDB,
|
| 176 | VDE, VEB, VEE, VI,
|
| 177 | PIT0, PIT1, HEQ, GPU7,
|
| 178 | BG,
|
| 179 | INT1 = 0xe0/2,
|
| 180 | INT2,
|
| 181 | GPU_REGS
|
| 182 | };
|
| 183 | |
| 184 | |
| 185 | |
| 186 | /*************************************
|
| 187 | *
|
| 188 | * Local variables
|
| 189 | *
|
| 190 | *************************************/
|
| 191 | |
| 192 | /* blitter variables */
|
| 193 | static UINT32 blitter_regs[BLITTER_REGS];
|
| 194 | static UINT16 gpu_regs[GPU_REGS];
|
| 195 | |
| 196 | static emu_timer *object_timer;
|
| 197 | static UINT8 cpu_irq_state;
|
| 198 | |
| 199 | static bitmap_t *screen_bitmap;
|
| 200 | |
| 201 | static pen_t *pen_table;
|
| 202 | |
| 203 | |
| 204 | |
| 205 | /*************************************
|
| 206 | *
|
| 207 | * Prototypes
|
| 208 | *
|
| 209 | *************************************/
|
| 210 | |
| 211 | /* from jagobj.c */
|
| 212 | static void jagobj_init(running_machine *machine);
|
| 213 | static void process_object_list(running_machine *machine, int vc, UINT16 *_scanline);
|
| 214 | |
| 215 | /* from jagblit.c */
|
| 216 | static void generic_blitter(running_machine *machine, UINT32 command, UINT32 a1flags, UINT32 a2flags);
|
| 217 | static void blitter_09800001_010020_010020(running_machine *machine, UINT32 command, UINT32 a1flags, UINT32 a2flags);
|
| 218 | static void blitter_09800009_000020_000020(running_machine *machine, UINT32 command, UINT32 a1flags, UINT32 a2flags);
|
| 219 | static void blitter_01800009_000028_000028(running_machine *machine, UINT32 command, UINT32 a1flags, UINT32 a2flags);
|
| 220 | static void blitter_01800001_000018_000018(running_machine *machine, UINT32 command, UINT32 a1flags, UINT32 a2flags);
|
| 221 | static void blitter_01c00001_000018_000018(running_machine *machine, UINT32 command, UINT32 a1flags, UINT32 a2flags);
|
| 222 | |
| 223 | #ifdef MESS
|
| 224 | static void blitter_00010000_xxxxxx_xxxxxx(running_machine *machine, UINT32 command, UINT32 a1flags, UINT32 a2flags);
|
| 225 | static void blitter_01800001_xxxxxx_xxxxxx(running_machine *machine, UINT32 command, UINT32 a1flags, UINT32 a2flags);
|
| 226 | static void blitter_x1800x01_xxxxxx_xxxxxx(running_machine *machine, UINT32 command, UINT32 a1flags, UINT32 a2flags);
|
| 227 | #endif
|
| 228 | |
| 229 | |
| 230 | |
| 231 | /*************************************
|
| 232 | *
|
| 233 | * Compute X/Y coordinates
|
| 234 | *
|
| 235 | *************************************/
|
| 236 | |
| 237 | INLINE void get_crosshair_xy(running_machine *machine, int player, int *x, int *y)
|
| 238 | {
|
| 239 | const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen);
|
| 240 | |
| 241 | int width = visarea->max_x + 1 - visarea->min_x;
|
| 242 | int height = visarea->max_y + 1 - visarea->min_y;
|
| 243 | /* only 2 lightguns are connected */
|
| 244 | *x = visarea->min_x + (((input_port_read(machine, player ? "FAKE2_X" : "FAKE1_X") & 0xff) * width) >> 8);
|
| 245 | *y = visarea->min_y + (((input_port_read(machine, player ? "FAKE2_Y" : "FAKE1_Y") & 0xff) * height) >> 8);
|
| 246 | }
|
| 247 | |
| 248 | |
| 249 | |
| 250 | /*************************************
|
| 251 | *
|
| 252 | * Horizontal display values
|
| 253 | *
|
| 254 | *************************************/
|
| 255 | |
| 256 | INLINE int effective_hvalue(int value)
|
| 257 | {
|
| 258 | if (!(value & 0x400))
|
| 259 | return value & 0x3ff;
|
| 260 | else
|
| 261 | return (value & 0x3ff) + (gpu_regs[HP] & 0x3ff) + 1;
|
| 262 | }
|
| 263 | |
| 264 | |
| 265 | |
| 266 | /*************************************
|
| 267 | *
|
| 268 | * Object processor timer
|
| 269 | *
|
| 270 | *************************************/
|
| 271 | |
| 272 | INLINE int adjust_object_timer(running_machine *machine, int vc)
|
| 273 | {
|
| 274 | int hdbpix[2];
|
| 275 | int hdb = 0;
|
| 276 | |
| 277 | /* extract the display begin registers */
|
| 278 | hdbpix[0] = (gpu_regs[HDB1] & 0x7ff) / 2;
|
| 279 | hdbpix[1] = (gpu_regs[HDB2] & 0x7ff) / 2;
|
| 280 | |
| 281 | /* sort */
|
| 282 | if (hdbpix[0] > hdbpix[1])
|
| 283 | {
|
| 284 | int temp = hdbpix[0];
|
| 285 | hdbpix[0] = hdbpix[1];
|
| 286 | hdbpix[1] = temp;
|
| 287 | }
|
| 288 | |
| 289 | /* select the target one */
|
| 290 | hdb = hdbpix[vc % 2];
|
| 291 | |
| 292 | /* if setting the second one in a line, make sure we will ever actually hit it */
|
| 293 | if (vc % 2 == 1 && (hdbpix[1] == hdbpix[0] || hdbpix[1] >= video_screen_get_width(machine->primary_screen)))
|
| 294 | return FALSE;
|
| 295 | |
| 296 | /* adjust the timer */
|
| 297 | timer_adjust_oneshot(object_timer, video_screen_get_time_until_pos(machine->primary_screen, vc / 2, hdb), vc | (hdb << 16));
|
| 298 | return TRUE;
|
| 299 | }
|
| 300 | |
| 301 | |
| 302 | |
| 303 | /*************************************
|
| 304 | *
|
| 305 | * GPU optimization control
|
| 306 | *
|
| 307 | *************************************/
|
| 308 | |
| 309 | void jaguar_gpu_suspend(running_machine *machine)
|
| 310 | {
|
| 311 | cputag_suspend(machine, "gpu", SUSPEND_REASON_SPIN, 1);
|
| 312 | }
|
| 313 | |
| 314 | |
| 315 | void jaguar_gpu_resume(running_machine *machine)
|
| 316 | {
|
| 317 | cputag_resume(machine, "gpu", SUSPEND_REASON_SPIN);
|
| 318 | }
|
| 319 | |
| 320 | |
| 321 | |
| 322 | /*************************************
|
| 323 | *
|
| 324 | * Main CPU interrupts
|
| 325 | *
|
| 326 | *************************************/
|
| 327 | |
| 328 | static void update_cpu_irq(running_machine *machine)
|
| 329 | {
|
| 330 | if (cpu_irq_state & gpu_regs[INT1] & 0x1f)
|
| 331 | cputag_set_input_line(machine, "maincpu", cojag_is_r3000 ? R3000_IRQ4 : M68K_IRQ_6, ASSERT_LINE);
|
| 332 | else
|
| 333 | cputag_set_input_line(machine, "maincpu", cojag_is_r3000 ? R3000_IRQ4 : M68K_IRQ_6, CLEAR_LINE);
|
| 334 | }
|
| 335 | |
| 336 | |
| 337 | void jaguar_gpu_cpu_int(const device_config *device)
|
| 338 | {
|
| 339 | cpu_irq_state |= 2;
|
| 340 | update_cpu_irq(device->machine);
|
| 341 | }
|
| 342 | |
| 343 | |
| 344 | void jaguar_dsp_cpu_int(const device_config *device)
|
| 345 | {
|
| 346 | cpu_irq_state |= 16;
|
| 347 | update_cpu_irq(device->machine);
|
| 348 | }
|
| 349 | |
| 350 | |
| 351 | |
| 352 | /*************************************
|
| 353 | *
|
| 354 | * Palette init
|
| 355 | *
|
| 356 | *************************************/
|
| 357 | |
| 358 | static void jaguar_set_palette(UINT16 vmode)
|
| 359 | {
|
| 360 | static const UINT8 red_lookup[256] =
|
| 361 | {
|
| 362 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
| 363 | 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 19, 0,
|
| 364 | 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 64, 43, 21, 0,
|
| 365 | 102,102,102,102,102,102,102,102,102,102,102, 95, 71, 47, 23, 0,
|
| 366 | 135,135,135,135,135,135,135,135,135,135,130,104, 78, 52, 26, 0,
|
| 367 | 169,169,169,169,169,169,169,169,169,170,141,113, 85, 56, 28, 0,
|
| 368 | 203,203,203,203,203,203,203,203,203,183,153,122, 91, 61, 30, 0,
|
| 369 | 237,237,237,237,237,237,237,237,230,197,164,131, 98, 65, 32, 0,
|
| 370 | 255,255,255,255,255,255,255,255,247,214,181,148,115, 82, 49, 17,
|
| 371 | 255,255,255,255,255,255,255,255,255,235,204,173,143,112, 81, 51,
|
| 372 | 255,255,255,255,255,255,255,255,255,255,227,198,170,141,113, 85,
|
| 373 | 255,255,255,255,255,255,255,255,255,255,249,223,197,171,145,119,
|
| 374 | 255,255,255,255,255,255,255,255,255,255,255,248,224,200,177,153,
|
| 375 | 255,255,255,255,255,255,255,255,255,255,255,255,252,230,208,187,
|
| 376 | 255,255,255,255,255,255,255,255,255,255,255,255,255,255,240,221,
|
| 377 | 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
|
| 378 | };
|
| 379 | |
| 380 | static const UINT8 grn_lookup[256] =
|
| 381 | {
|
| 382 | 0, 17, 34, 51, 68, 85,102,119,136,153,170,187,204,221,238,255,
|
| 383 | 0, 19, 38, 57, 77, 96,115,134,154,173,182,211,231,250,255,255,
|
| 384 | 0, 21, 43, 64, 86,107,129,150,172,193,215,236,255,255,255,255,
|
| 385 | 0, 23, 47, 71, 96,119,142,166,190,214,238,255,255,255,255,255,
|
| 386 | 0, 26, 52, 78,104,130,156,182,208,234,255,255,255,255,255,255,
|
| 387 | 0, 28, 56, 85,113,141,170,198,226,255,255,255,255,255,255,255,
|
| 388 | 0, 30, 61, 91,122,153,183,214,244,255,255,255,255,255,255,255,
|
| 389 | 0, 32, 65, 98,131,164,197,230,255,255,255,255,255,255,255,255,
|
| 390 | 0, 32, 65, 98,131,164,197,230,255,255,255,255,255,255,255,255,
|
| 391 | 0, 30, 61, 91,122,153,183,214,244,255,255,255,255,255,255,255,
|
| 392 | 0, 28, 56, 85,113,141,170,198,226,255,255,255,255,255,255,255,
|
| 393 | 0, 26, 52, 78,104,130,156,182,208,234,255,255,255,255,255,255,
|
| 394 | 0, 23, 47, 71, 96,119,142,166,190,214,238,255,255,255,255,255,
|
| 395 | 0, 21, 43, 64, 86,107,129,150,172,193,215,236,255,255,255,255,
|
| 396 | 0, 19, 38, 57, 77, 96,115,134,154,173,182,211,231,250,255,255,
|
| 397 | 0, 17, 34, 51, 68, 85,102,119,136,153,170,187,204,221,238,255
|
| 398 | };
|
| 399 | |
| 400 | static const UINT8 blu_lookup[256] =
|
| 401 | {
|
| 402 | 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
| 403 | 255,255,255,255,255,255,255,255,255,255,255,255,255,255,240,221,
|
| 404 | 255,255,255,255,255,255,255,255,255,255,255,255,252,230,208,187,
|
| 405 | 255,255,255,255,255,255,255,255,255,255,255,248,224,200,177,153,
|
| 406 | 255,255,255,255,255,255,255,255,255,255,249,223,197,171,145,119,
|
| 407 | 255,255,255,255,255,255,255,255,255,255,227,198,170,141,113, 85,
|
| 408 | 255,255,255,255,255,255,255,255,255,235,204,173,143,112, 81, 51,
|
| 409 | 255,255,255,255,255,255,255,255,247,214,181,148,115, 82, 49, 17,
|
| 410 | 237,237,237,237,237,237,237,237,230,197,164,131, 98, 65, 32, 0,
|
| 411 | 203,203,203,203,203,203,203,203,203,183,153,122, 91, 61, 30, 0,
|
| 412 | 169,169,169,169,169,169,169,169,169,170,141,113, 85, 56, 28, 0,
|
| 413 | 135,135,135,135,135,135,135,135,135,135,130,104, 78, 52, 26, 0,
|
| 414 | 102,102,102,102,102,102,102,102,102,102,102, 95, 71, 47, 23, 0,
|
| 415 | 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 64, 43, 21, 0,
|
| 416 | 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 19, 0,
|
| 417 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
| 418 | };
|
| 419 | |
| 420 | int i;
|
| 421 | |
| 422 | /* switch off the mode */
|
| 423 | switch (vmode & 0x106)
|
| 424 | {
|
| 425 | /* YCC full */
|
| 426 | case 0x000: // CRY16, varmod off
|
| 427 | for (i = 0; i < 65536; i++)
|
| 428 | {
|
| 429 | UINT8 r = (red_lookup[i >> 8] * (i & 0xff)) >> 8;
|
| 430 | UINT8 g = (grn_lookup[i >> 8] * (i & 0xff)) >> 8;
|
| 431 | UINT8 b = (blu_lookup[i >> 8] * (i & 0xff)) >> 8;
|
| 432 | pen_table[i] = MAKE_RGB(r, g, b);
|
| 433 | }
|
| 434 | break;
|
| 435 | |
| 436 | /* YCC/RGB VARMOD */
|
| 437 | case 0x100: // CRY16, varmod on
|
| 438 | case 0x106: // RGB16, varmod on
|
| 439 | for (i = 0; i < 65536; i++)
|
| 440 | {
|
| 441 | UINT8 r = (red_lookup[i >> 8] * (i & 0xff)) >> 8;
|
| 442 | UINT8 g = (grn_lookup[i >> 8] * (i & 0xff)) >> 8;
|
| 443 | UINT8 b = (blu_lookup[i >> 8] * (i & 0xff)) >> 8;
|
| 444 | |
| 445 | /* if the low bit is set, treat it as 5-5-5 RGB instead */
|
| 446 | if (i & 1)
|
| 447 | {
|
| 448 | r = (i >> 11) & 31;
|
| 449 | g = (i >> 1) & 31;
|
| 450 | b = (i >> 6) & 31;
|
| 451 | r = (r << 3) | (r >> 2);
|
| 452 | g = (g << 3) | (g >> 2);
|
| 453 | b = (b << 3) | (b >> 2);
|
| 454 | }
|
| 455 | pen_table[i] = MAKE_RGB(r, g, b);
|
| 456 | }
|
| 457 | break;
|
| 458 | |
| 459 | /* RGB full */
|
| 460 | case 0x006: // RGB16, varmod off
|
| 461 | for (i = 0; i < 65536; i++)
|
| 462 | pen_table[i] = MAKE_RGB(pal5bit(i >> 11), pal6bit(i >> 0), pal5bit(i >> 6));
|
| 463 | break;
|
| 464 | |
| 465 | /* others */
|
| 466 | default: // RGB24, DIRECT16
|
| 467 | logerror("Can't handle mode %X\n", vmode);
|
| 468 | break;
|
| 469 | }
|
| 470 | }
|
| 471 | |
| 472 | |
| 473 | |
| 474 | /*************************************
|
| 475 | *
|
| 476 | * Fast memory accessors
|
| 477 | *
|
| 478 | *************************************/
|
| 479 | |
| 480 | static UINT8 *get_jaguar_memory(running_machine *machine, UINT32 offset)
|
| 481 | {
|
| 482 | const address_space *space = cputag_get_address_space(machine, "gpu", ADDRESS_SPACE_PROGRAM);
|
| 483 | return (UINT8 *)memory_get_read_ptr(space, offset);
|
| 484 | }
|
| 485 | |
| 486 | |
| 487 | |
| 488 | /*************************************
|
| 489 | *
|
| 490 | * 32-bit access to the blitter
|
| 491 | *
|
| 492 | *************************************/
|
| 493 | |
| 494 | static void blitter_run(running_machine *machine)
|
| 495 | {
|
| 496 | UINT32 command = blitter_regs[B_CMD] & STATIC_COMMAND_MASK;
|
| 497 | UINT32 a1flags = blitter_regs[A1_FLAGS] & STATIC_FLAGS_MASK;
|
| 498 | UINT32 a2flags = blitter_regs[A2_FLAGS] & STATIC_FLAGS_MASK;
|
| 499 | |
| 500 | // profiler_mark(PROFILER_USER1);
|
| 501 | |
| 502 | if (a1flags == a2flags)
|
| 503 | {
|
| 504 | if (command == 0x09800001 && a1flags == 0x010020)
|
| 505 | {
|
| 506 | blitter_09800001_010020_010020(machine, blitter_regs[B_CMD], blitter_regs[A1_FLAGS], blitter_regs[A2_FLAGS]);
|
| 507 | return;
|
| 508 | }
|
| 509 | if (command == 0x09800009 && a1flags == 0x000020)
|
| 510 | {
|
| 511 | blitter_09800009_000020_000020(machine, blitter_regs[B_CMD], blitter_regs[A1_FLAGS], blitter_regs[A2_FLAGS]);
|
| 512 | return;
|
| 513 | }
|
| 514 | if (command == 0x01800009 && a1flags == 0x000028)
|
| 515 | {
|
| 516 | blitter_01800009_000028_000028(machine, blitter_regs[B_CMD], blitter_regs[A1_FLAGS], blitter_regs[A2_FLAGS]);
|
| 517 | return;
|
| 518 | }
|
| 519 | |
| 520 | if (command == 0x01800001 && a1flags == 0x000018)
|
| 521 | {
|
| 522 | blitter_01800001_000018_000018(machine, blitter_regs[B_CMD], blitter_regs[A1_FLAGS], blitter_regs[A2_FLAGS]);
|
| 523 | return;
|
| 524 | }
|
| 525 | |
| 526 | if (command == 0x01c00001 && a1flags == 0x000018)
|
| 527 | {
|
| 528 | blitter_01c00001_000018_000018(machine, blitter_regs[B_CMD], blitter_regs[A1_FLAGS], blitter_regs[A2_FLAGS]);
|
| 529 | return;
|
| 530 | }
|
| 531 | }
|
| 532 | |
| 533 | #ifdef MESS
|
| 534 | if (command == 0x00010000)
|
| 535 | {
|
| 536 | blitter_00010000_xxxxxx_xxxxxx(machine, blitter_regs[B_CMD], blitter_regs[A1_FLAGS], blitter_regs[A2_FLAGS]);
|
| 537 | return;
|
| 538 | }
|
| 539 | |
| 540 | if (command == 0x01800001)
|
| 541 | {
|
| 542 | blitter_01800001_xxxxxx_xxxxxx(machine, blitter_regs[B_CMD], blitter_regs[A1_FLAGS], blitter_regs[A2_FLAGS]);
|
| 543 | return;
|
| 544 | }
|
| 545 | |
| 546 | if ((command & 0x0ffff0ff) == 0x01800001)
|
| 547 | {
|
| 548 | blitter_x1800x01_xxxxxx_xxxxxx(machine, blitter_regs[B_CMD], blitter_regs[A1_FLAGS], blitter_regs[A2_FLAGS]);
|
| 549 | return;
|
| 550 | }
|
| 551 | #endif
|
| 552 | |
| 553 | |
| 554 | if (LOG_BLITTER_STATS)
|
| 555 | {
|
| 556 | static UINT32 blitter_stats[1000][4];
|
| 557 | static UINT64 blitter_pixels[1000];
|
| 558 | static int blitter_count = 0;
|
| 559 | static int reps = 0;
|
| 560 | int i;
|
| 561 | for (i = 0; i < blitter_count; i++)
|
| 562 | if (blitter_stats[i][0] == (blitter_regs[B_CMD] & STATIC_COMMAND_MASK) &&
|
| 563 | blitter_stats[i][1] == (blitter_regs[A1_FLAGS] & STATIC_FLAGS_MASK) &&
|
| 564 | blitter_stats[i][2] == (blitter_regs[A2_FLAGS] & STATIC_FLAGS_MASK))
|
| 565 | break;
|
| 566 | if (i == blitter_count)
|
| 567 | {
|
| 568 | blitter_stats[i][0] = blitter_regs[B_CMD] & STATIC_COMMAND_MASK;
|
| 569 | blitter_stats[i][1] = blitter_regs[A1_FLAGS] & STATIC_FLAGS_MASK;
|
| 570 | blitter_stats[i][2] = blitter_regs[A2_FLAGS] & STATIC_FLAGS_MASK;
|
| 571 | blitter_stats[i][3] = 0;
|
| 572 | blitter_pixels[i] = 0;
|
| 573 | blitter_count++;
|
| 574 | }
|
| 575 | blitter_stats[i][3]++;
|
| 576 | blitter_pixels[i] += (blitter_regs[B_COUNT] & 0xffff) * (blitter_regs[B_COUNT] >> 16);
|
| 577 | if (++reps % 100 == 99)
|
| 578 | {
|
| 579 | mame_printf_debug("---\nBlitter stats:\n");
|
| 580 | for (i = 0; i < blitter_count; i++)
|
| 581 | mame_printf_debug(" CMD=%08X A1=%08X A2=%08X %6d times, %08X%08X pixels\n",
|
| 582 | blitter_stats[i][0], blitter_stats[i][1], blitter_stats[i][2],
|
| 583 | blitter_stats[i][3], (UINT32)(blitter_pixels[i] >> 32), (UINT32)(blitter_pixels[i]));
|
| 584 | mame_printf_debug("---\n");
|
| 585 | }
|
| 586 | }
|
| 587 | |
| 588 | generic_blitter(machine, blitter_regs[B_CMD], blitter_regs[A1_FLAGS], blitter_regs[A2_FLAGS]);
|
| 589 | // profiler_mark(PROFILER_END);
|
| 590 | }
|
| 591 | |
| 592 | |
| 593 | READ32_HANDLER( jaguar_blitter_r )
|
| 594 | {
|
| 595 | switch (offset)
|
| 596 | {
|
| 597 | case B_CMD: /* B_CMD */
|
| 598 | return 1;
|
| 599 | |
| 600 | default:
|
| 601 | logerror("%08X:Blitter read register @ F022%02X\n", cpu_get_previouspc(space->cpu), offset * 4);
|
| 602 | return 0;
|
| 603 | }
|
| 604 | }
|
| 605 | |
| 606 | |
| 607 | WRITE32_HANDLER( jaguar_blitter_w )
|
| 608 | {
|
| 609 | COMBINE_DATA(&blitter_regs[offset]);
|
| 610 | if (offset == B_CMD)
|
| 611 | blitter_run(space->machine);
|
| 612 | |
| 613 | if (LOG_BLITTER_WRITE)
|
| 614 | logerror("%08X:Blitter write register @ F022%02X = %08X\n", cpu_get_previouspc(space->cpu), offset * 4, data);
|
| 615 | }
|
| 616 | |
| 617 | |
| 618 | |
| 619 | /*************************************
|
| 620 | *
|
| 621 | * 16-bit TOM register access
|
| 622 | *
|
| 623 | *************************************/
|
| 624 | |
| 625 | READ16_HANDLER( jaguar_tom_regs_r )
|
| 626 | {
|
| 627 | if (offset != INT1 && offset != INT2 && offset != HC && offset != VC)
|
| 628 | logerror("%08X:TOM read register @ F00%03X\n", cpu_get_previouspc(space->cpu), offset * 2);
|
| 629 | |
| 630 | switch (offset)
|
| 631 | {
|
| 632 | case INT1:
|
| 633 | return cpu_irq_state;
|
| 634 | |
| 635 | case HC:
|
| 636 | return video_screen_get_hpos(space->machine->primary_screen) % (video_screen_get_width(space->machine->primary_screen) / 2);
|
| 637 | |
| 638 | case VC:
|
| 639 | return video_screen_get_vpos(space->machine->primary_screen) * 2 + gpu_regs[VBE];
|
| 640 | |
| 641 | }
|
| 642 | |
| 643 | return gpu_regs[offset];
|
| 644 | }
|
| 645 | |
| 646 | |
| 647 | WRITE16_HANDLER( jaguar_tom_regs_w )
|
| 648 | {
|
| 649 | if (offset < GPU_REGS)
|
| 650 | {
|
| 651 | COMBINE_DATA(&gpu_regs[offset]);
|
| 652 | |
| 653 | switch (offset)
|
| 654 | {
|
| 655 | case INT1:
|
| 656 | cpu_irq_state &= ~(gpu_regs[INT1] >> 8);
|
| 657 | update_cpu_irq(space->machine);
|
| 658 | break;
|
| 659 | |
| 660 | case VMODE:
|
| 661 | jaguar_set_palette(gpu_regs[VMODE]);
|
| 662 | break;
|
| 663 | |
| 664 | case HP:
|
| 665 | case HBB:
|
| 666 | case HBE:
|
| 667 | case HDB1:
|
| 668 | case HDB2:
|
| 669 | case HDE:
|
| 670 | case VP:
|
| 671 | case VBB:
|
| 672 | case VBE:
|
| 673 | case VDB:
|
| 674 | case VDE:
|
| 675 | {
|
| 676 | #if 0
|
| 677 | int hperiod = 2 * ((gpu_regs[HP] & 0x3ff) + 1);
|
| 678 | int hbend = effective_hvalue(ENABLE_BORDERS ? gpu_regs[HBE] : MIN(gpu_regs[HDB1], gpu_regs[HDB2]));
|
| 679 | int hbstart = effective_hvalue(gpu_regs[ENABLE_BORDERS ? HBB : HDE]);
|
| 680 | int vperiod = (gpu_regs[VP] & 0x7ff) + 1;
|
| 681 | int vbend = gpu_regs[VBE] & 0x7ff;
|
| 682 | int vbstart = gpu_regs[VBB] & 0x7ff;
|
| 683 | |
| 684 | /* adjust for the half-lines */
|
| 685 | if (hperiod != 0 && vperiod != 0 && hbend < hbstart && vbend < vbstart && hbstart < hperiod)
|
| 686 | {
|
| 687 | rectangle visarea;
|
| 688 | visarea.min_x = hbend / 2;
|
| 689 | visarea.max_x = hbstart / 2 - 1;
|
| 690 | visarea.min_y = vbend / 2;
|
| 691 | visarea.max_y = vbstart / 2 - 1;
|
| 692 | #endif
|
| 693 | int hperiod = ((gpu_regs[HP] & 0x3ff) + 1)<<1;
|
| 694 | int hbend = MAX(gpu_regs[HDB1], gpu_regs[HBE]);
|
| 695 | int hbstart = gpu_regs[HP] & 0x3ff;
|
| 696 | int vperiod = (gpu_regs[VP] & 0x7ff) + 1;
|
| 697 | int vbend = MAX(gpu_regs[VBE], gpu_regs[VDB]) & 0x1ff;
|
| 698 | int vbstart = MIN(gpu_regs[VBB], gpu_regs[VDE]) & 0x1ff;
|
| 699 | |
| 700 | /* adjust for the half-lines */
|
| 701 | if (hperiod != 0 && vperiod != 0 && hbend < hbstart && vbend < vbstart && hbstart < hperiod)
|
| 702 | {
|
| 703 | rectangle visarea;
|
| 704 | visarea.min_x = hbend >> 1;
|
| 705 | visarea.max_x = hbstart >> 1;
|
| 706 | visarea.min_y = vbend >> 1;
|
| 707 | visarea.max_y = vbstart >> 1;
|
| 708 | video_screen_configure(space->machine->primary_screen, hperiod >> 1, vperiod >> 1, &visarea, HZ_TO_ATTOSECONDS((double)COJAG_PIXEL_CLOCK * 2 / hperiod / vperiod));
|
| 709 | }
|
| 710 | break;
|
| 711 | }
|
| 712 | }
|
| 713 | }
|
| 714 | |
| 715 | if (offset != INT2 && offset != VI)
|
| 716 | logerror("%08X:TOM write register @ F00%03X = %04X\n", cpu_get_previouspc(space->cpu), offset * 2, data);
|
| 717 | }
|
| 718 | |
| 719 | |
| 720 | |
| 721 | /*************************************
|
| 722 | *
|
| 723 | * 32-bit TOM register access
|
| 724 | *
|
| 725 | *************************************/
|
| 726 | |
| 727 | READ32_HANDLER( jaguar_tom_regs32_r )
|
| 728 | {
|
| 729 | return read32be_with_16be_handler(jaguar_tom_regs_r, space, offset, mem_mask);
|
| 730 | }
|
| 731 | |
| 732 | |
| 733 | WRITE32_HANDLER( jaguar_tom_regs32_w )
|
| 734 | {
|
| 735 | write32be_with_16be_handler(jaguar_tom_regs_w, space, offset, data, mem_mask);
|
| 736 | }
|
| 737 | |
| 738 | |
| 739 | |
| 740 | /*************************************
|
| 741 | *
|
| 742 | * Gun input
|
| 743 | *
|
| 744 | *************************************/
|
| 745 | |
| 746 | READ32_HANDLER( cojag_gun_input_r )
|
| 747 | {
|
| 748 | int beamx, beamy;
|
| 749 | |
| 750 | switch (offset)
|
| 751 | {
|
| 752 | case 0:
|
| 753 | get_crosshair_xy(space->machine, 1, &beamx, &beamy);
|
| 754 | return (beamy << 16) | (beamx ^ 0x1ff);
|
| 755 | |
| 756 | case 1:
|
| 757 | get_crosshair_xy(space->machine, 0, &beamx, &beamy);
|
| 758 | return (beamy << 16) | (beamx ^ 0x1ff);
|
| 759 | |
| 760 | case 2:
|
| 761 | return input_port_read(space->machine, "IN3");
|
| 762 | }
|
| 763 | return 0;
|
| 764 | }
|
| 765 | |
| 766 | |
| 767 | |
| 768 | /*************************************
|
| 769 | *
|
| 770 | * Video system start
|
| 771 | *
|
| 772 | *************************************/
|
| 773 | |
| 774 | static TIMER_CALLBACK( cojag_scanline_update )
|
| 775 | {
|
| 776 | int vc = param & 0xffff;
|
| 777 | int hdb = param >> 16;
|
| 778 | const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen);
|
| 779 | |
| 780 | /* only run if video is enabled and we are past the "display begin" */
|
| 781 | if ((gpu_regs[VMODE] & 1) && vc >= (gpu_regs[VDB] & 0x7ff))
|
| 782 | {
|
| 783 | UINT32 *dest = BITMAP_ADDR32(screen_bitmap, vc / 2, 0);
|
| 784 | int maxx = visarea->max_x;
|
| 785 | int hde = effective_hvalue(gpu_regs[HDE]) / 2;
|
| 786 | UINT16 scanline[360];
|
| 787 | int x;
|
| 788 | |
| 789 | /* if we are first on this scanline, clear to the border color */
|
| 790 | if (ENABLE_BORDERS && vc % 2 == 0)
|
| 791 | {
|
| 792 | rgb_t border = MAKE_RGB(gpu_regs[BORD1] & 0xff, gpu_regs[BORD1] >> 8, gpu_regs[BORD2] & 0xff);
|
| 793 | for (x = visarea->min_x; x <= visarea->max_x; x++)
|
| 794 | dest[x] = border;
|
| 795 | }
|
| 796 | |
| 797 | /* process the object list for this counter value */
|
| 798 | process_object_list(machine, vc, scanline);
|
| 799 | |
| 800 | /* copy the data to the target, clipping */
|
| 801 | for (x = 0; x < 360 && hdb <= maxx && hdb < hde; x++, hdb++)
|
| 802 | dest[hdb] = pen_table[scanline[x]];
|
| 803 | }
|
| 804 | |
| 805 | /* adjust the timer in a loop, to handle missed cases */
|
| 806 | do
|
| 807 | {
|
| 808 | /* handle vertical interrupts */
|
| 809 | if (vc == gpu_regs[VI])
|
| 810 | {
|
| 811 | cpu_irq_state |= 1;
|
| 812 | update_cpu_irq(machine);
|
| 813 | }
|
| 814 | |
| 815 | /* point to the next counter value */
|
| 816 | if (++vc / 2 >= video_screen_get_height(machine->primary_screen))
|
| 817 | vc = 0;
|
| 818 | |
| 819 | } while (!adjust_object_timer(machine, vc));
|
| 820 | }
|
| 821 | |
| 822 | static STATE_POSTLOAD( cojag_postload )
|
| 823 | {
|
| 824 | update_cpu_irq(machine);
|
| 825 | }
|
| 826 | |
| 827 | VIDEO_START( cojag )
|
| 828 | {
|
| 829 | memset(&blitter_regs, 0, sizeof(blitter_regs));
|
| 830 | memset(&gpu_regs, 0, sizeof(gpu_regs));
|
| 831 | cpu_irq_state = 0;
|
| 832 | |
| 833 | object_timer = timer_alloc(machine, cojag_scanline_update, NULL);
|
| 834 | adjust_object_timer(machine, 0);
|
| 835 | |
| 836 | screen_bitmap = auto_bitmap_alloc(machine, 720, 512, BITMAP_FORMAT_RGB32);
|
| 837 | |
| 838 | jagobj_init(machine);
|
| 839 | |
| 840 | pen_table = auto_alloc_array(machine, pen_t, 65536);
|
| 841 | |
| 842 | state_save_register_global_pointer(machine, pen_table, 65536);
|
| 843 | state_save_register_global_array(machine, blitter_regs);
|
| 844 | state_save_register_global_array(machine, gpu_regs);
|
| 845 | state_save_register_global(machine, cpu_irq_state);
|
| 846 | state_save_register_postload(machine, cojag_postload, NULL);
|
| 847 | }
|
| 848 | |
| 849 | |
| 850 | |
| 851 | /*************************************
|
| 852 | *
|
| 853 | * Main refresh
|
| 854 | *
|
| 855 | *************************************/
|
| 856 | |
| 857 | VIDEO_UPDATE( cojag )
|
| 858 | {
|
| 859 | /* if not enabled, just blank */
|
| 860 | if (!(gpu_regs[VMODE] & 1))
|
| 861 | {
|
| 862 | bitmap_fill(bitmap, cliprect, 0);
|
| 863 | return 0;
|
| 864 | }
|
| 865 | |
| 866 | /* render the object list */
|
| 867 | copybitmap(bitmap, screen_bitmap, 0, 0, 0, 0, cliprect);
|
| 868 | return 0;
|
| 869 | }
|
| 870 | |
| 871 | |
| 872 | |
| 873 | /*************************************
|
| 874 | *
|
| 875 | * Object processor
|
| 876 | *
|
| 877 | *************************************/
|
| 878 | |
| 879 | #define INCLUDE_OBJECT_PROCESSOR
|
| 880 | #include "jagobj.c"
|
| 881 | |
| 882 | |
| 883 | |
| 884 | /*************************************
|
| 885 | *
|
| 886 | * Blitter macros
|
| 887 | *
|
| 888 | *************************************/
|
| 889 | |
| 890 | /* generic blitters */
|
| 891 | #define FUNCNAME generic_blitter
|
| 892 | #define COMMAND command
|
| 893 | #define A1FIXED a1flags
|
| 894 | #define A2FIXED a2flags
|
| 895 | #include "jagblit.c"
|
| 896 | #undef A2FIXED
|
| 897 | #undef A1FIXED
|
| 898 | #undef COMMAND
|
| 899 | #undef FUNCNAME
|
| 900 | |
| 901 | /* optimized common blitters */
|
| 902 | #define FUNCNAME blitter_09800001_010020_010020
|
| 903 | #define COMMAND 0x09800001
|
| 904 | #define A1FIXED 0x010020
|
| 905 | #define A2FIXED 0x010020
|
| 906 | #include "jagblit.c"
|
| 907 | #undef A2FIXED
|
| 908 | #undef A1FIXED
|
| 909 | #undef COMMAND
|
| 910 | #undef FUNCNAME
|
| 911 | |
| 912 | #define FUNCNAME blitter_09800009_000020_000020
|
| 913 | #define COMMAND 0x09800009
|
| 914 | #define A1FIXED 0x000020
|
| 915 | #define A2FIXED 0x000020
|
| 916 | #include "jagblit.c"
|
| 917 | #undef A2FIXED
|
| 918 | #undef A1FIXED
|
| 919 | #undef COMMAND
|
| 920 | #undef FUNCNAME
|
| 921 | |
| 922 | #define FUNCNAME blitter_01800009_000028_000028
|
| 923 | #define COMMAND 0x01800009
|
| 924 | #define A1FIXED 0x000028
|
| 925 | #define A2FIXED 0x000028
|
| 926 | #include "jagblit.c"
|
| 927 | #undef A2FIXED
|
| 928 | #undef A1FIXED
|
| 929 | #undef COMMAND
|
| 930 | #undef FUNCNAME
|
| 931 | |
| 932 | #define FUNCNAME blitter_01800001_000018_000018
|
| 933 | #define COMMAND 0x01800001
|
| 934 | #define A1FIXED 0x000018
|
| 935 | #define A2FIXED 0x000018
|
| 936 | #include "jagblit.c"
|
| 937 | #undef A2FIXED
|
| 938 | #undef A1FIXED
|
| 939 | #undef COMMAND
|
| 940 | #undef FUNCNAME
|
| 941 | |
| 942 | #define FUNCNAME blitter_01c00001_000018_000018
|
| 943 | #define COMMAND 0x01c00001
|
| 944 | #define A1FIXED 0x000018
|
| 945 | #define A2FIXED 0x000018
|
| 946 | #include "jagblit.c"
|
| 947 | #undef A2FIXED
|
| 948 | #undef A1FIXED
|
| 949 | #undef COMMAND
|
| 950 | #undef FUNCNAME
|
| 951 | |
| 952 | #ifdef MESS
|
| 953 | |
| 954 | #define FUNCNAME blitter_00010000_xxxxxx_xxxxxx
|
| 955 | #define COMMAND 0x00010000
|
| 956 | #define A1FIXED a1flags
|
| 957 | #define A2FIXED a2flags
|
| 958 | #include "jagblit.c"
|
| 959 | #undef A2FIXED
|
| 960 | #undef A1FIXED
|
| 961 | #undef COMMAND
|
| 962 | #undef FUNCNAME
|
| 963 | |
| 964 | #define FUNCNAME blitter_01800001_xxxxxx_xxxxxx
|
| 965 | #define COMMAND 0x01800001
|
| 966 | #define A1FIXED a1flags
|
| 967 | #define A2FIXED a2flags
|
| 968 | #include "jagblit.c"
|
| 969 | #undef A2FIXED
|
| 970 | #undef A1FIXED
|
| 971 | #undef COMMAND
|
| 972 | #undef FUNCNAME
|
| 973 | |
| 974 | #define FUNCNAME blitter_x1800x01_xxxxxx_xxxxxx
|
| 975 | #define COMMAND ((command & 0xf0000f00) | 0x01800001)
|
| 976 | #define A1FIXED a1flags
|
| 977 | #define A2FIXED a2flags
|
| 978 | #include "jagblit.c"
|
| 979 | #undef A2FIXED
|
| 980 | #undef A1FIXED
|
| 981 | #undef COMMAND
|
| 982 | #undef FUNCNAME
|
| 983 | |
| 984 | #endif /* MESS */
|
src/mess/video/jagobj.c
| r0 | r5099 | |
| 1 | /***************************************************************************
|
| 2 | |
| 3 | Atari Jaguar object processor
|
| 4 | |
| 5 | ****************************************************************************/
|
| 6 | |
| 7 | #ifndef INCLUDE_OBJECT_PROCESSOR
|
| 8 | #error jagobj.c is not directly compilable!
|
| 9 | #endif
|
| 10 | |
| 11 | |
| 12 | #define LOG_OBJECTS 0
|
| 13 | |
| 14 | |
| 15 | static UINT16 *scanline;
|
| 16 | static UINT16 *clutbase;
|
| 17 | static UINT8 *blend_y, *blend_cc;
|
| 18 | |
| 19 | |
| 20 | |
| 21 | /*************************************
|
| 22 | *
|
| 23 | * Object processor init
|
| 24 | *
|
| 25 | *************************************/
|
| 26 | |
| 27 | void jagobj_init(running_machine *machine)
|
| 28 | {
|
| 29 | int i;
|
| 30 | |
| 31 | /* allocate memory for tables */
|
| 32 | blend_y = auto_alloc_array(machine, UINT8, 256 * 256);
|
| 33 | blend_cc = auto_alloc_array(machine, UINT8, 256 * 256);
|
| 34 | |
| 35 | /* fill tables */
|
| 36 | for (i = 0; i < 256 * 256; i++)
|
| 37 | {
|
| 38 | int y = (i >> 8) & 0xff;
|
| 39 | int dy = (INT8)i;
|
| 40 | int c1 = (i >> 8) & 0x0f;
|
| 41 | int dc1 = (INT8)(i << 4) >> 4;
|
| 42 | int c2 = (i >> 12) & 0x0f;
|
| 43 | int dc2 = (INT8)(i & 0xf0) >> 4;
|
| 44 | |
| 45 | y += dy;
|
| 46 | if (y < 0) y = 0;
|
| 47 | else if (y > 0xff) y = 0xff;
|
| 48 | blend_y[i] = y;
|
| 49 | |
| 50 | c1 += dc1;
|
| 51 | if (c1 < 0) c1 = 0;
|
| 52 | else if (c1 > 0x0f) c1 = 0x0f;
|
| 53 | c2 += dc2;
|
| 54 | if (c2 < 0) c2 = 0;
|
| 55 | else if (c2 > 0x0f) c2 = 0x0f;
|
| 56 | blend_cc[i] = (c2 << 4) | c1;
|
| 57 | }
|
| 58 | }
|
| 59 | |
| 60 | |
| 61 | |
| 62 | /*************************************
|
| 63 | *
|
| 64 | * Blending function
|
| 65 | *
|
| 66 | *************************************/
|
| 67 | |
| 68 | #define BLEND(dst, src) \
|
| 69 | (dst) = (blend_cc[((dst) & 0xff00) | (((src) >> 8) & 0xff)] << 8) | blend_y[(((dst) & 0xff) << 8) | ((src) & 0xff)];
|
| 70 | |
| 71 | |
| 72 | |
| 73 | /*************************************
|
| 74 | *
|
| 75 | * 4bpp bitmap renderers
|
| 76 | *
|
| 77 | *************************************/
|
| 78 | |
| 79 | INLINE void bitmap_4_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos)
|
| 80 | {
|
| 81 | if (firstpix & 7)
|
| 82 | {
|
| 83 | UINT32 pixsrc = src[firstpix / 8];
|
| 84 | while (firstpix & 7)
|
| 85 | {
|
| 86 | int pix = (pixsrc >> (4 * (~firstpix & 7))) & 0x0f;
|
| 87 | if ((!(flags & 4) || pix) && (UINT32)xpos < 360)
|
| 88 | {
|
| 89 | if (!(flags & 2))
|
| 90 | scanline[xpos] = clutbase[BYTE_XOR_BE(pix)];
|
| 91 | else
|
| 92 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE(pix)]);
|
| 93 | }
|
| 94 | xpos += dxpos;
|
| 95 | firstpix++;
|
| 96 | }
|
| 97 | }
|
| 98 | |
| 99 | firstpix /= 8;
|
| 100 | iwidth /= 8;
|
| 101 | iwidth -= firstpix;
|
| 102 | |
| 103 | while (iwidth-- > 0)
|
| 104 | {
|
| 105 | UINT32 pix = src[firstpix++];
|
| 106 | if (!(flags & 4) || pix)
|
| 107 | {
|
| 108 | if ((!(flags & 4) || (pix & 0xf0000000)) && (UINT32)xpos < 360)
|
| 109 | {
|
| 110 | if (!(flags & 2))
|
| 111 | scanline[xpos] = clutbase[BYTE_XOR_BE(pix >> 28)];
|
| 112 | else
|
| 113 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE(pix >> 28)]);
|
| 114 | }
|
| 115 | xpos += dxpos;
|
| 116 | |
| 117 | if ((!(flags & 4) || (pix & 0x0f000000)) && (UINT32)xpos < 360)
|
| 118 | {
|
| 119 | if (!(flags & 2))
|
| 120 | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 24) & 0x0f)];
|
| 121 | else
|
| 122 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 24) & 0x0f)]);
|
| 123 | }
|
| 124 | xpos += dxpos;
|
| 125 | |
| 126 | if ((!(flags & 4) || (pix & 0x00f00000)) && (UINT32)xpos < 360)
|
| 127 | {
|
| 128 | if (!(flags & 2))
|
| 129 | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 20) & 0x0f)];
|
| 130 | else
|
| 131 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 20) & 0x0f)]);
|
| 132 | }
|
| 133 | xpos += dxpos;
|
| 134 | |
| 135 | if ((!(flags & 4) || (pix & 0x000f0000)) && (UINT32)xpos < 360)
|
| 136 | {
|
| 137 | if (!(flags & 2))
|
| 138 | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 16) & 0x0f)];
|
| 139 | else
|
| 140 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 16) & 0x0f)]);
|
| 141 | }
|
| 142 | xpos += dxpos;
|
| 143 | |
| 144 | if ((!(flags & 4) || (pix & 0x0000f000)) && (UINT32)xpos < 360)
|
| 145 | {
|
| 146 | if (!(flags & 2))
|
| 147 | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 12) & 0x0f)];
|
| 148 | else
|
| 149 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 12) & 0x0f)]);
|
| 150 | }
|
| 151 | xpos += dxpos;
|
| 152 | |
| 153 | if ((!(flags & 4) || (pix & 0x00000f00)) && (UINT32)xpos < 360)
|
| 154 | {
|
| 155 | if (!(flags & 2))
|
| 156 | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 8) & 0x0f)];
|
| 157 | else
|
| 158 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 8) & 0x0f)]);
|
| 159 | }
|
| 160 | xpos += dxpos;
|
| 161 | |
| 162 | if ((!(flags & 4) || (pix & 0x000000f0)) && (UINT32)xpos < 360)
|
| 163 | {
|
| 164 | if (!(flags & 2))
|
| 165 | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 4) & 0x0f)];
|
| 166 | else
|
| 167 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 4) & 0x0f)]);
|
| 168 | }
|
| 169 | xpos += dxpos;
|
| 170 | |
| 171 | if ((!(flags & 4) || (pix & 0x0000000f)) && (UINT32)xpos < 360)
|
| 172 | {
|
| 173 | if (!(flags & 2))
|
| 174 | scanline[xpos] = clutbase[BYTE_XOR_BE(pix & 0x0f)];
|
| 175 | else
|
| 176 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE(pix & 0x0f)]);
|
| 177 | }
|
| 178 | xpos += dxpos;
|
| 179 | }
|
| 180 | else
|
| 181 | xpos += 8 * dxpos;
|
| 182 | }
|
| 183 | }
|
| 184 | |
| 185 | static void bitmap_4_0(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 186 | {
|
| 187 | bitmap_4_draw(firstpix, iwidth, src, xpos, 0, 1);
|
| 188 | }
|
| 189 | |
| 190 | static void bitmap_4_1(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 191 | {
|
| 192 | bitmap_4_draw(firstpix, iwidth, src, xpos, 1, -1);
|
| 193 | }
|
| 194 | |
| 195 | static void bitmap_4_2(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 196 | {
|
| 197 | bitmap_4_draw(firstpix, iwidth, src, xpos, 2, 1);
|
| 198 | }
|
| 199 | |
| 200 | static void bitmap_4_3(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 201 | {
|
| 202 | bitmap_4_draw(firstpix, iwidth, src, xpos, 3, -1);
|
| 203 | }
|
| 204 | |
| 205 | static void bitmap_4_4(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 206 | {
|
| 207 | bitmap_4_draw(firstpix, iwidth, src, xpos, 4, 1);
|
| 208 | }
|
| 209 | |
| 210 | static void bitmap_4_5(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 211 | {
|
| 212 | bitmap_4_draw(firstpix, iwidth, src, xpos, 5, -1);
|
| 213 | }
|
| 214 | |
| 215 | static void bitmap_4_6(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 216 | {
|
| 217 | bitmap_4_draw(firstpix, iwidth, src, xpos, 6, 1);
|
| 218 | }
|
| 219 | |
| 220 | static void bitmap_4_7(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 221 | {
|
| 222 | bitmap_4_draw(firstpix, iwidth, src, xpos, 7, -1);
|
| 223 | }
|
| 224 | |
| 225 | static void (*const bitmap4[8])(INT32, INT32, UINT32 *, INT32) =
|
| 226 | {
|
| 227 | bitmap_4_0,
|
| 228 | bitmap_4_1,
|
| 229 | bitmap_4_2,
|
| 230 | bitmap_4_3,
|
| 231 | bitmap_4_4,
|
| 232 | bitmap_4_5,
|
| 233 | bitmap_4_6,
|
| 234 | bitmap_4_7
|
| 235 | };
|
| 236 | |
| 237 | |
| 238 | |
| 239 | /*************************************
|
| 240 | *
|
| 241 | * 8bpp bitmap renderers
|
| 242 | *
|
| 243 | *************************************/
|
| 244 | |
| 245 | INLINE void bitmap_8_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos)
|
| 246 | {
|
| 247 | if (firstpix & 3)
|
| 248 | {
|
| 249 | UINT32 pixsrc = src[firstpix / 4];
|
| 250 | while (firstpix & 3)
|
| 251 | {
|
| 252 | UINT8 pix = pixsrc >> (8 * (~firstpix & 3));
|
| 253 | if ((!(flags & 4) || pix) && (UINT32)xpos < 360)
|
| 254 | {
|
| 255 | if (!(flags & 2))
|
| 256 | scanline[xpos] = clutbase[BYTE_XOR_BE(pix)];
|
| 257 | else
|
| 258 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE(pix)]);
|
| 259 | }
|
| 260 | xpos += dxpos;
|
| 261 | firstpix++;
|
| 262 | }
|
| 263 | }
|
| 264 | |
| 265 | firstpix /= 4;
|
| 266 | iwidth /= 4;
|
| 267 | iwidth -= firstpix;
|
| 268 | |
| 269 | while (iwidth-- > 0)
|
| 270 | {
|
| 271 | UINT32 pix = src[firstpix++];
|
| 272 | if (!(flags & 4) || pix)
|
| 273 | {
|
| 274 | if ((!(flags & 4) || (pix & 0xff000000)) && (UINT32)xpos < 360)
|
| 275 | {
|
| 276 | if (!(flags & 2))
|
| 277 | scanline[xpos] = clutbase[BYTE_XOR_BE(pix >> 24)];
|
| 278 | else
|
| 279 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE(pix >> 24)]);
|
| 280 | }
|
| 281 | xpos += dxpos;
|
| 282 | |
| 283 | if ((!(flags & 4) || (pix & 0x00ff0000)) && (UINT32)xpos < 360)
|
| 284 | {
|
| 285 | if (!(flags & 2))
|
| 286 | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 16) & 0xff)];
|
| 287 | else
|
| 288 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 16) & 0xff)]);
|
| 289 | }
|
| 290 | xpos += dxpos;
|
| 291 | |
| 292 | if ((!(flags & 4) || (pix & 0x0000ff00)) && (UINT32)xpos < 360)
|
| 293 | {
|
| 294 | if (!(flags & 2))
|
| 295 | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 8) & 0xff)];
|
| 296 | else
|
| 297 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 8) & 0xff)]);
|
| 298 | }
|
| 299 | xpos += dxpos;
|
| 300 | |
| 301 | if ((!(flags & 4) || (pix & 0x000000ff)) && (UINT32)xpos < 360)
|
| 302 | {
|
| 303 | if (!(flags & 2))
|
| 304 | scanline[xpos] = clutbase[BYTE_XOR_BE(pix & 0xff)];
|
| 305 | else
|
| 306 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE(pix & 0xff)]);
|
| 307 | }
|
| 308 | xpos += dxpos;
|
| 309 | }
|
| 310 | else
|
| 311 | xpos += 4 * dxpos;
|
| 312 | }
|
| 313 | }
|
| 314 | |
| 315 | static void bitmap_8_0(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 316 | {
|
| 317 | bitmap_8_draw(firstpix, iwidth, src, xpos, 0, 1);
|
| 318 | }
|
| 319 | |
| 320 | static void bitmap_8_1(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 321 | {
|
| 322 | bitmap_8_draw(firstpix, iwidth, src, xpos, 1, -1);
|
| 323 | }
|
| 324 | |
| 325 | static void bitmap_8_2(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 326 | {
|
| 327 | bitmap_8_draw(firstpix, iwidth, src, xpos, 2, 1);
|
| 328 | }
|
| 329 | |
| 330 | static void bitmap_8_3(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 331 | {
|
| 332 | bitmap_8_draw(firstpix, iwidth, src, xpos, 3, -1);
|
| 333 | }
|
| 334 | |
| 335 | static void bitmap_8_4(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 336 | {
|
| 337 | bitmap_8_draw(firstpix, iwidth, src, xpos, 4, 1);
|
| 338 | }
|
| 339 | |
| 340 | static void bitmap_8_5(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 341 | {
|
| 342 | bitmap_8_draw(firstpix, iwidth, src, xpos, 5, -1);
|
| 343 | }
|
| 344 | |
| 345 | static void bitmap_8_6(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 346 | {
|
| 347 | bitmap_8_draw(firstpix, iwidth, src, xpos, 6, 1);
|
| 348 | }
|
| 349 | |
| 350 | static void bitmap_8_7(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 351 | {
|
| 352 | bitmap_8_draw(firstpix, iwidth, src, xpos, 7, -1);
|
| 353 | }
|
| 354 | |
| 355 | static void (*const bitmap8[8])(INT32, INT32, UINT32 *, INT32) =
|
| 356 | {
|
| 357 | bitmap_8_0,
|
| 358 | bitmap_8_1,
|
| 359 | bitmap_8_2,
|
| 360 | bitmap_8_3,
|
| 361 | bitmap_8_4,
|
| 362 | bitmap_8_5,
|
| 363 | bitmap_8_6,
|
| 364 | bitmap_8_7
|
| 365 | };
|
| 366 | |
| 367 | |
| 368 | |
| 369 | /*************************************
|
| 370 | *
|
| 371 | * 16bpp bitmap renderers
|
| 372 | *
|
| 373 | *************************************/
|
| 374 | |
| 375 | INLINE void bitmap_16_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos)
|
| 376 | {
|
| 377 | if (firstpix & 1)
|
| 378 | {
|
| 379 | UINT16 pix = src[firstpix / 2];
|
| 380 | if ((!(flags & 4) || pix) && (UINT32)xpos < 360)
|
| 381 | {
|
| 382 | if (!(flags & 2))
|
| 383 | scanline[xpos] = pix;
|
| 384 | else
|
| 385 | BLEND(scanline[xpos], pix);
|
| 386 | }
|
| 387 | xpos += dxpos;
|
| 388 | }
|
| 389 | |
| 390 | firstpix /= 2;
|
| 391 | iwidth /= 2;
|
| 392 | iwidth -= firstpix;
|
| 393 | |
| 394 | while (iwidth-- > 0)
|
| 395 | {
|
| 396 | UINT32 pix = src[firstpix++];
|
| 397 | if (!(flags & 4) || pix)
|
| 398 | {
|
| 399 | if ((!(flags & 4) || (pix >> 16)) && (UINT32)xpos < 360)
|
| 400 | {
|
| 401 | if (!(flags & 2))
|
| 402 | scanline[xpos] = pix >> 16;
|
| 403 | else
|
| 404 | BLEND(scanline[xpos], pix >> 16);
|
| 405 | }
|
| 406 | xpos += dxpos;
|
| 407 | |
| 408 | if ((!(flags & 4) || (pix & 0xffff)) && (UINT32)xpos < 360)
|
| 409 | {
|
| 410 | if (!(flags & 2))
|
| 411 | scanline[xpos] = pix;
|
| 412 | else
|
| 413 | BLEND(scanline[xpos], pix);
|
| 414 | }
|
| 415 | xpos += dxpos;
|
| 416 | }
|
| 417 | else
|
| 418 | xpos += 2 * dxpos;
|
| 419 | }
|
| 420 | }
|
| 421 | |
| 422 | static void bitmap_16_0(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 423 | {
|
| 424 | bitmap_16_draw(firstpix, iwidth, src, xpos, 0, 1);
|
| 425 | }
|
| 426 | |
| 427 | static void bitmap_16_1(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 428 | {
|
| 429 | bitmap_16_draw(firstpix, iwidth, src, xpos, 1, -1);
|
| 430 | }
|
| 431 | |
| 432 | static void bitmap_16_2(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 433 | {
|
| 434 | bitmap_16_draw(firstpix, iwidth, src, xpos, 2, 1);
|
| 435 | }
|
| 436 | |
| 437 | static void bitmap_16_3(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 438 | {
|
| 439 | bitmap_16_draw(firstpix, iwidth, src, xpos, 3, -1);
|
| 440 | }
|
| 441 | |
| 442 | static void bitmap_16_4(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 443 | {
|
| 444 | bitmap_16_draw(firstpix, iwidth, src, xpos, 4, 1);
|
| 445 | }
|
| 446 | |
| 447 | static void bitmap_16_5(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 448 | {
|
| 449 | bitmap_16_draw(firstpix, iwidth, src, xpos, 5, -1);
|
| 450 | }
|
| 451 | |
| 452 | static void bitmap_16_6(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 453 | {
|
| 454 | bitmap_16_draw(firstpix, iwidth, src, xpos, 6, 1);
|
| 455 | }
|
| 456 | |
| 457 | static void bitmap_16_7(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 458 | {
|
| 459 | bitmap_16_draw(firstpix, iwidth, src, xpos, 7, -1);
|
| 460 | }
|
| 461 | |
| 462 | static void (*const bitmap16[8])(INT32, INT32, UINT32 *, INT32) =
|
| 463 | {
|
| 464 | bitmap_16_0,
|
| 465 | bitmap_16_1,
|
| 466 | bitmap_16_2,
|
| 467 | bitmap_16_3,
|
| 468 | bitmap_16_4,
|
| 469 | bitmap_16_5,
|
| 470 | bitmap_16_6,
|
| 471 | bitmap_16_7
|
| 472 | };
|
| 473 | |
| 474 | |
| 475 | |
| 476 | INLINE UINT8 lookup_pixel(const UINT32 *src, int i, int pitch, int depth)
|
| 477 | {
|
| 478 | int ppl = 32 / depth;
|
| 479 | UINT32 data = src[((i & ppl) / ppl) + ((i / (ppl*2)) * 2 * pitch)];
|
| 480 | UINT8 pix = (data >> ((~i & (ppl-1)) * depth)) & ((1 << depth) - 1);
|
| 481 | return pix;
|
| 482 | }
|
| 483 | |
| 484 | |
| 485 | |
| 486 | /*************************************
|
| 487 | *
|
| 488 | * Standard bitmap processor
|
| 489 | *
|
| 490 | *************************************/
|
| 491 | |
| 492 | static UINT32 *process_bitmap(running_machine *machine, UINT32 *objdata, int vc, int logit)
|
| 493 | {
|
| 494 | /* extract minimal data */
|
| 495 | UINT32 upper = objdata[0];
|
| 496 | UINT32 lower = objdata[1];
|
| 497 | UINT32 ypos = (lower >> 3) & 0x7ff;
|
| 498 | UINT32 height = (lower >> 14) & 0x3ff;
|
| 499 | UINT32 link = (lower >> 24) | ((upper & 0x7ff) << 8);
|
| 500 | UINT32 data = (upper >> 11);
|
| 501 | UINT32 *src = (UINT32 *)get_jaguar_memory(machine, data << 3);
|
| 502 | |
| 503 | if (logit)
|
| 504 | {
|
| 505 | /* second phrase */
|
| 506 | UINT32 upper2 = objdata[2];
|
| 507 | UINT32 lower2 = objdata[3];
|
| 508 | |
| 509 | /* extract data */
|
| 510 | INT32 xpos = (INT32)(lower2 << 20) >> 20;
|
| 511 | UINT8 depth = 1 << ((lower2 >> 12) & 7);
|
| 512 | UINT8 pitch = (lower2 >> 15) & 7;
|
| 513 | UINT32 dwidth = (lower2 >> 18) & 0x3ff;
|
| 514 | INT32 iwidth = (lower2 >> 28) | ((upper2 & 0x3f) << 4);
|
| 515 | UINT8 _index = (upper2 >> 6) & 0x3f;
|
| 516 | UINT8 flags = (upper2 >> 13) & 0x0f;
|
| 517 | UINT8 firstpix = (upper2 >> 17) & 0x3f;
|
| 518 | |
| 519 | logerror(" ypos=%X height=%X link=%06X data=%06X\n", ypos, height, link << 3, data << 3);
|
| 520 | logerror(" xpos=%X depth=%X pitch=%X dwidth=%X iwidth=%X index=%X flags=%X firstpix=%X\n", xpos, depth, pitch, dwidth, iwidth, _index, flags, firstpix);
|
| 521 | }
|
| 522 | |
| 523 | /* only render if valid */
|
| 524 | if (vc >= ypos && height > 0 && src)
|
| 525 | {
|
| 526 | /* second phrase */
|
| 527 | UINT32 upper2 = objdata[2];
|
| 528 | UINT32 lower2 = objdata[3];
|
| 529 | |
| 530 | /* extract data */
|
| 531 | INT32 xpos = (INT32)(lower2 << 20) >> 20;
|
| 532 | UINT8 depthlog = (lower2 >> 12) & 7;
|
| 533 | UINT8 pitch = (lower2 >> 15) & 7;
|
| 534 | UINT32 dwidth = (lower2 >> 18) & 0x3ff;
|
| 535 | UINT32 iwidth = ((lower2 >> 28) | ((upper2 & 0x3f) << 4)) << (6 - depthlog);
|
| 536 | UINT8 _index = (upper2 >> 5) & 0xfe;
|
| 537 | UINT8 flags = (upper2 >> 13) & 0x0f;
|
| 538 | UINT8 firstpix = ((upper2 >> 17) & 0x1f) >> depthlog;
|
| 539 | int i, dxpos = (flags & 1) ? -1 : 1;
|
| 540 | |
| 541 | /* preadjust for firstpix */
|
| 542 | xpos += firstpix * dxpos;
|
| 543 | |
| 544 | /* switch off the depth */
|
| 545 | switch (depthlog)
|
| 546 | {
|
| 547 | /* 1bpp case */
|
| 548 | case 0:
|
| 549 | {
|
| 550 | UINT16 *clut = (UINT16 *)jaguar_gpu_clut;
|
| 551 | clut += _index & 0xfe;
|
| 552 | |
| 553 | /* non-blending */
|
| 554 | if (!(flags & 2))
|
| 555 | {
|
| 556 | for (i = firstpix; i < iwidth; i++)
|
| 557 | {
|
| 558 | UINT8 pix = lookup_pixel(src, i, pitch, 1);
|
| 559 | |
| 560 | if (xpos >= 0 && xpos < 360 && (pix || !(flags & 4)))
|
| 561 | scanline[xpos] = clut[BYTE_XOR_BE(pix)];
|
| 562 | xpos += dxpos;
|
| 563 | }
|
| 564 | }
|
| 565 | |
| 566 | /* blending */
|
| 567 | else
|
| 568 | {
|
| 569 | for (i = firstpix; i < iwidth; i++)
|
| 570 | {
|
| 571 | UINT8 pix = lookup_pixel(src, i, pitch, 1);
|
| 572 | |
| 573 | if (xpos >= 0 && xpos < 360 && (pix || !(flags & 4)))
|
| 574 | BLEND(scanline[xpos], clut[BYTE_XOR_BE(pix)]);
|
| 575 | xpos += dxpos;
|
| 576 | }
|
| 577 | }
|
| 578 | break;
|
| 579 | }
|
| 580 | |
| 581 | /* 2bpp case */
|
| 582 | case 1:
|
| 583 | {
|
| 584 | UINT16 *clut = (UINT16 *)jaguar_gpu_clut;
|
| 585 | clut += _index & 0xfc;
|
| 586 | |
| 587 | /* non-blending */
|
| 588 | if (!(flags & 2))
|
| 589 | {
|
| 590 | for (i = firstpix; i < iwidth; i++)
|
| 591 | {
|
| 592 | UINT8 pix = lookup_pixel(src, i, pitch, 2);
|
| 593 | |
| 594 | if (xpos >= 0 && xpos < 360 && (pix || !(flags & 4)))
|
| 595 | scanline[xpos] = clut[BYTE_XOR_BE(pix)];
|
| 596 | xpos += dxpos;
|
| 597 | }
|
| 598 | }
|
| 599 | |
| 600 | /* blending */
|
| 601 | else
|
| 602 | {
|
| 603 | for (i = firstpix; i < iwidth; i++)
|
| 604 | {
|
| 605 | UINT8 pix = lookup_pixel(src, i, pitch, 2);
|
| 606 | |
| 607 | if (xpos >= 0 && xpos < 360 && (pix || !(flags & 4)))
|
| 608 | BLEND(scanline[xpos], clut[BYTE_XOR_BE(pix)]);
|
| 609 | xpos += dxpos;
|
| 610 | }
|
| 611 | }
|
| 612 | break;
|
| 613 | }
|
| 614 | |
| 615 | /* 4bpp case */
|
| 616 | case 2:
|
| 617 | /* only handle pitch=1 for now */
|
| 618 | if (pitch != 1)
|
| 619 | logerror("Unhandled pitch = %d\n", pitch);
|
| 620 | |
| 621 | clutbase = (UINT16 *)jaguar_gpu_clut + (_index & 0xf0);
|
| 622 | (*bitmap4[flags & 7])(firstpix, iwidth, src, xpos);
|
| 623 | break;
|
| 624 | |
| 625 | /* 8bpp case */
|
| 626 | case 3:
|
| 627 | /* only handle pitch=1 for now */
|
| 628 | if (pitch != 1)
|
| 629 | logerror("Unhandled pitch = %d\n", pitch);
|
| 630 | |
| 631 | clutbase = (UINT16 *)jaguar_gpu_clut;
|
| 632 | (*bitmap8[flags & 7])(firstpix, iwidth, src, xpos);
|
| 633 | break;
|
| 634 | |
| 635 | /* 16bpp case */
|
| 636 | case 4:
|
| 637 | /* only handle pitch=1 for now */
|
| 638 | if (pitch != 1)
|
| 639 | logerror("Unhandled pitch = %d\n", pitch);
|
| 640 | |
| 641 | (*bitmap16[flags & 7])(firstpix, iwidth, src, xpos);
|
| 642 | break;
|
| 643 | |
| 644 | default:
|
| 645 | fprintf(stderr, "Unhandled bitmap source depth = %d\n", depthlog);
|
| 646 | break;
|
| 647 | }
|
| 648 | |
| 649 | /* decrement the height and add to the source data offset */
|
| 650 | objdata[0] = upper + (dwidth << 11);
|
| 651 | objdata[1] = lower - (1 << 14);
|
| 652 | }
|
| 653 | |
| 654 | return (UINT32 *)get_jaguar_memory(machine, link << 3);
|
| 655 | }
|
| 656 | |
| 657 | |
| 658 | |
| 659 | /*************************************
|
| 660 | *
|
| 661 | * Scaled bitmap object processor
|
| 662 | *
|
| 663 | *************************************/
|
| 664 | |
| 665 | static UINT32 *process_scaled_bitmap(running_machine *machine, UINT32 *objdata, int vc, int logit)
|
| 666 | {
|
| 667 | /* extract data */
|
| 668 | UINT32 upper = objdata[0];
|
| 669 | UINT32 lower = objdata[1];
|
| 670 | UINT32 ypos = (lower >> 3) & 0x7ff;
|
| 671 | UINT32 height = (lower >> 14) & 0x3ff;
|
| 672 | UINT32 link = (lower >> 24) | ((upper & 0x7ff) << 8);
|
| 673 | UINT32 data = (upper >> 11);
|
| 674 | UINT32 *src = (UINT32 *)get_jaguar_memory(machine, data << 3);
|
| 675 | |
| 676 | /* third phrase */
|
| 677 | UINT32 lower3 = objdata[5];
|
| 678 | INT32 remainder = (lower3 >> 16) & 0xff;
|
| 679 | |
| 680 | if (logit)
|
| 681 | {
|
| 682 | /* second phrase */
|
| 683 | UINT32 upper2 = objdata[2];
|
| 684 | UINT32 lower2 = objdata[3];
|
| 685 | |
| 686 | /* extract data */
|
| 687 | INT32 xpos = (INT32)(lower2 << 20) >> 20;
|
| 688 | UINT8 depth = 1 << ((lower2 >> 12) & 7);
|
| 689 | UINT8 pitch = (lower2 >> 15) & 7;
|
| 690 | UINT32 dwidth = (lower2 >> 18) & 0x3ff;
|
| 691 | INT32 iwidth = (lower2 >> 28) | ((upper2 & 0x3f) << 4);
|
| 692 | UINT8 _index = (upper2 >> 6) & 0x3f;
|
| 693 | UINT8 flags = (upper2 >> 13) & 0x0f;
|
| 694 | UINT8 firstpix = (upper2 >> 17) & 0x3f;
|
| 695 | |
| 696 | INT32 hscale = lower3 & 0xff;
|
| 697 | INT32 vscale = (lower3 >> 8) & 0xff;
|
| 698 | |
| 699 | logerror(" ypos=%X height=%X link=%06X data=%06X\n", ypos, height, link << 3, data << 3);
|
| 700 | logerror(" xpos=%X depth=%X pitch=%X dwidth=%X iwidth=%X index=%X flags=%X firstpix=%X\n", xpos, depth, pitch, dwidth, iwidth, _index, flags, firstpix);
|
| 701 | logerror(" hscale=%X vscale=%X remainder=%X\n", hscale, vscale, remainder);
|
| 702 | }
|
| 703 | |
| 704 | /* only render if valid */
|
| 705 | if (vc >= ypos && (height > 0 || remainder > 0) && src)
|
| 706 | {
|
| 707 | /* second phrase */
|
| 708 | UINT32 upper2 = objdata[2];
|
| 709 | UINT32 lower2 = objdata[3];
|
| 710 | |
| 711 | /* extract data */
|
| 712 | INT32 xpos = (INT32)(lower2 << 20) >> 20;
|
| 713 | UINT8 depthlog = (lower2 >> 12) & 7;
|
| 714 | UINT8 pitch = (lower2 >> 15) & 7;
|
| 715 | UINT32 dwidth = (lower2 >> 18) & 0x3ff;
|
| 716 | INT32 iwidth = ((lower2 >> 28) | ((upper2 & 0x3f) << 4)) << (6 - depthlog);
|
| 717 | UINT8 _index = (upper2 >> 5) & 0xfe;
|
| 718 | UINT8 flags = (upper2 >> 13) & 0x0f;
|
| 719 | UINT8 firstpix = ((upper2 >> 17) & 0x1f) >> depthlog;
|
| 720 | |
| 721 | INT32 hscale = lower3 & 0xff;
|
| 722 | INT32 vscale = (lower3 >> 8) & 0xff;
|
| 723 | INT32 xleft = hscale;
|
| 724 | int dxpos = (flags & 1) ? -1 : 1;
|
| 725 | int xpix = firstpix, yinc;
|
| 726 | |
| 727 | /* only handle pitch=0 for now */
|
| 728 | if (pitch != 1)
|
| 729 | logerror("Unhandled pitch = %d\n", pitch);
|
| 730 | if (flags & 2)
|
| 731 | {
|
| 732 | mame_printf_debug("Unhandled blend mode in scaled bitmap case\n");
|
| 733 | logerror("Unhandled blend mode in scaled bitmap case\n");
|
| 734 | }
|
| 735 | |
| 736 | /* preadjust for firstpix */
|
| 737 | xpos += firstpix * dxpos;
|
| 738 | |
| 739 | /* ignore hscale = 0 */
|
| 740 | if (hscale != 0)
|
| 741 | {
|
| 742 | /* switch off the depth */
|
| 743 | switch (depthlog)
|
| 744 | {
|
| 745 | case 2:
|
| 746 | {
|
| 747 | UINT16 *clut = (UINT16 *)jaguar_gpu_clut;
|
| 748 | clut += _index & 0xf0;
|
| 749 | |
| 750 | /* render in phrases */
|
| 751 | while (xpix < iwidth)
|
| 752 | {
|
| 753 | UINT16 pix = (src[xpix / 8] >> ((~xpix & 7) * 4)) & 0x0f;
|
| 754 | |
| 755 | while (xleft > 0)
|
| 756 | {
|
| 757 | if (xpos >= 0 && xpos < 360 && (pix || !(flags & 4)))
|
| 758 | scanline[xpos] = clut[BYTE_XOR_BE(pix)];
|
| 759 | xpos += dxpos;
|
| 760 | xleft -= 0x20;
|
| 761 | }
|
| 762 | while (xleft <= 0)
|
| 763 | xleft += hscale, xpix++;
|
| 764 | }
|
| 765 | break;
|
| 766 | }
|
| 767 | |
| 768 | case 3:
|
| 769 | {
|
| 770 | UINT16 *clut = (UINT16 *)jaguar_gpu_clut;
|
| 771 | |
| 772 | /* render in phrases */
|
| 773 | while (xpix < iwidth)
|
| 774 | {
|
| 775 | UINT16 pix = (src[xpix / 4] >> ((~xpix & 3) * 8)) & 0xff;
|
| 776 | |
| 777 | while (xleft > 0)
|
| 778 | {
|
| 779 | if (xpos >= 0 && xpos < 360 && (pix || !(flags & 4)))
|
| 780 | scanline[xpos] = clut[BYTE_XOR_BE(pix)];
|
| 781 | xpos += dxpos;
|
| 782 | xleft -= 0x20;
|
| 783 | }
|
| 784 | while (xleft <= 0)
|
| 785 | xleft += hscale, xpix++;
|
| 786 | }
|
| 787 | break;
|
| 788 | }
|
| 789 | |
| 790 | case 4:
|
| 791 | while (xpix < iwidth)
|
| 792 | {
|
| 793 | UINT16 pix = src[xpix / 2] >> ((~xpix & 1) * 16);
|
| 794 | |
| 795 | while (xleft > 0)
|
| 796 | {
|
| 797 | if (xpos >= 0 && xpos < 360 && (pix || !(flags & 4)))
|
| 798 | scanline[xpos] = pix;
|
| 799 | xpos += dxpos;
|
| 800 | xleft -= 0x20;
|
| 801 | }
|
| 802 | while (xleft <= 0)
|
| 803 | xleft += hscale, xpix++;
|
| 804 | }
|
| 805 | break;
|
| 806 | |
| 807 | default:
|
| 808 | fprintf(stderr, "Unhandled scaled bitmap source depth = %d\n", depthlog);
|
| 809 | break;
|
| 810 | }
|
| 811 | }
|
| 812 | |
| 813 | /* handle Y scale */
|
| 814 | remainder -= 0x20;
|
| 815 | yinc = 0;
|
| 816 | while (remainder <= 0 && vscale != 0)
|
| 817 | remainder += vscale, yinc++;
|
| 818 | if (yinc > height)
|
| 819 | yinc = height, remainder = 0;
|
| 820 | |
| 821 | /* decrement the height and add to the source data offset */
|
| 822 | objdata[0] = upper + yinc * (dwidth << 11);
|
| 823 | objdata[1] = lower - yinc * (1 << 14);
|
| 824 | objdata[5] = (lower3 & ~0xff0000) | ((remainder & 0xff) << 16);
|
| 825 | }
|
| 826 | |
| 827 | return (UINT32 *)get_jaguar_memory(machine, link << 3);
|
| 828 | }
|
| 829 | |
| 830 | |
| 831 | |
| 832 | /*************************************
|
| 833 | *
|
| 834 | * Brach object processor
|
| 835 | *
|
| 836 | *************************************/
|
| 837 | |
| 838 | static UINT32 *process_branch(running_machine *machine, UINT32 *objdata, int vc, int logit)
|
| 839 | {
|
| 840 | UINT32 upper = objdata[0];
|
| 841 | UINT32 lower = objdata[1];
|
| 842 | UINT32 ypos = (lower >> 3) & 0x7ff;
|
| 843 | UINT32 cc = (lower >> 14) & 7;
|
| 844 | UINT32 link = (lower >> 24) | ((upper & 0x7ff) << 8);
|
| 845 | int taken = 0;
|
| 846 | |
| 847 | #ifndef MESS
|
| 848 | if ((ypos & 1) && ypos != 0x7ff)
|
| 849 | fprintf(stderr, " branch cc=%d ypos=%X link=%06X - \n", cc, ypos, link << 3);
|
| 850 | #endif
|
| 851 | |
| 852 | switch (cc)
|
| 853 | {
|
| 854 | /* 0: branch if ypos == vc or ypos == 0x7ff */
|
| 855 | case 0:
|
| 856 | if (logit) logerror(" branch if %X == vc or %X == 0x7ff to %06X\n", ypos, ypos, link << 3);
|
| 857 | taken = (ypos == vc) || (ypos == 0x7ff);
|
| 858 | break;
|
| 859 | |
| 860 | /* 1: branch if ypos > vc */
|
| 861 | case 1:
|
| 862 | if (logit) logerror(" branch if %X > vc to %06X\n", ypos, link << 3);
|
| 863 | taken = (ypos > vc);
|
| 864 | break;
|
| 865 | |
| 866 | /* 2: branch if ypos < vc */
|
| 867 | case 2:
|
| 868 | if (logit) logerror(" branch if %X < vc to %06X\n", ypos, link << 3);
|
| 869 | taken = (ypos < vc);
|
| 870 | break;
|
| 871 | |
| 872 | /* 3: branch if object processor flag is set */
|
| 873 | case 3:
|
| 874 | if (logit) logerror(" branch if object flag set to %06X\n", link << 3);
|
| 875 | fprintf(stderr, "Unhandled branch!\n");
|
| 876 | link = 0, taken = 1;
|
| 877 | break;
|
| 878 | |
| 879 | /* 4: branch on second half of display line */
|
| 880 | case 4:
|
| 881 | if (logit) logerror(" branch if second half of line to %06X\n", link << 3);
|
| 882 | taken = (vc & 1);
|
| 883 | break;
|
| 884 | |
| 885 | default:
|
| 886 | fprintf(stderr, "Invalid branch!\n");
|
| 887 | link = 0, taken = 1;
|
| 888 | break;
|
| 889 | }
|
| 890 | |
| 891 | /* handle the branch */
|
| 892 | return taken ? (UINT32 *)get_jaguar_memory(machine, link << 3) : (objdata + 2);
|
| 893 | }
|
| 894 | |
| 895 | |
| 896 | |
| 897 | /*************************************
|
| 898 | *
|
| 899 | * Process object list
|
| 900 | *
|
| 901 | *************************************/
|
| 902 | |
| 903 | static void process_object_list(running_machine *machine, int vc, UINT16 *_scanline)
|
| 904 | {
|
| 905 | int done = 0, count = 0;
|
| 906 | UINT32 *objdata;
|
| 907 | int logit;
|
| 908 | int x;
|
| 909 | |
| 910 | /* erase the scanline first */
|
| 911 | scanline = _scanline;
|
| 912 | for (x = 0; x < 336; x++)
|
| 913 | scanline[x] = gpu_regs[BG];
|
| 914 | |
| 915 | logit = LOG_OBJECTS;
|
| 916 | |
| 917 | /* fetch the object pointer */
|
| 918 | objdata = (UINT32 *)get_jaguar_memory(machine, (gpu_regs[OLP_H] << 16) | gpu_regs[OLP_L]);
|
| 919 | while (!done && objdata && count++ < 100)
|
| 920 | {
|
| 921 | /* the low 3 bits determine the command */
|
| 922 | switch (objdata[1] & 7)
|
| 923 | {
|
| 924 | /* bitmap object */
|
| 925 | case 0:
|
| 926 | if (logit)
|
| 927 | logerror("bitmap = %08X-%08X %08X-%08X\n", objdata[0], objdata[1], objdata[2], objdata[3]);
|
| 928 | objdata = process_bitmap(machine, objdata, vc, logit);
|
| 929 | break;
|
| 930 | |
| 931 | /* scaled bitmap object */
|
| 932 | case 1:
|
| 933 | if (logit)
|
| 934 | logerror("scaled = %08X-%08X %08X-%08X %08X-%08X\n", objdata[0], objdata[1], objdata[2], objdata[3], objdata[4], objdata[5]);
|
| 935 | objdata = process_scaled_bitmap(machine, objdata, vc, logit);
|
| 936 | break;
|
| 937 | |
| 938 | /* branch */
|
| 939 | case 3:
|
| 940 | if (logit)
|
| 941 | logerror("branch = %08X-%08X\n", objdata[0], objdata[1]);
|
| 942 | objdata = process_branch(machine, objdata, vc, logit);
|
| 943 | break;
|
| 944 | |
| 945 | /* stop */
|
| 946 | case 4:
|
| 947 | {
|
| 948 | int interrupt = (objdata[1] >> 3) & 1;
|
| 949 | done = 1;
|
| 950 | |
| 951 | if (logit)
|
| 952 | logerror("stop = %08X-%08X\n", objdata[0], objdata[1]);
|
| 953 | if (interrupt)
|
| 954 | {
|
| 955 | #ifndef MESS
|
| 956 | fprintf(stderr, "stop int=%d\n", interrupt);
|
| 957 | #endif
|
| 958 | cpu_irq_state |= 4;
|
| 959 | update_cpu_irq(machine);
|
| 960 | }
|
| 961 | break;
|
| 962 | }
|
| 963 | |
| 964 | default:
|
| 965 | fprintf(stderr, "%08X %08X\n", objdata[0], objdata[1]);
|
| 966 | done = 1;
|
| 967 | break;
|
| 968 | }
|
| 969 | }
|
| 970 | }
|
src/mess/video/jagblit.c
| r0 | r5099 | |
| 1 | /***************************************************************************
|
| 2 | |
| 3 | Atari Jaguar blitter
|
| 4 | |
| 5 | ****************************************************************************
|
| 6 | |
| 7 | How to use this module:
|
| 8 | |
| 9 | #define FUNCNAME -- name of the function to be generated
|
| 10 | #define COMMAND -- blitter command bits for blitter
|
| 11 | #define A1FIXED -- fixed A1 flag bits for blitter
|
| 12 | #define A2FIXED -- fixed A2 flag bits for blitter
|
| 13 | #include "jagblit.c"
|
| 14 | |
| 15 | ****************************************************************************/
|
| 16 | |
| 17 | |
| 18 | #ifndef FUNCNAME
|
| 19 | #error jagblit.c -- requires FUNCNAME to be predefined
|
| 20 | #endif
|
| 21 | |
| 22 | #ifndef COMMAND
|
| 23 | #error jagblit.c -- requires COMMAND to be predefined
|
| 24 | #endif
|
| 25 | |
| 26 | #ifndef A1FIXED
|
| 27 | #error jagblit.c -- requires A1FIXED to be predefined
|
| 28 | #endif
|
| 29 | |
| 30 | #ifndef A2FIXED
|
| 31 | #error jagblit.c -- requires A2FIXED to be predefined
|
| 32 | #endif
|
| 33 | |
| 34 | #ifndef PIXEL_SHIFT_1
|
| 35 | #define PIXEL_SHIFT_1(a) ((~a##_x >> 16) & 7)
|
| 36 | #define PIXEL_OFFSET_1(a) BYTE4_XOR_BE(((UINT32)a##_y >> 16) * a##_width / 8 + (((UINT32)a##_x >> 19) & ~7) * (1 + a##_pitch) + (((UINT32)a##_x >> 19) & 7))
|
| 37 | #define ZDATA_OFFSET_1(a) 0 /* huh? */
|
| 38 | #define READ_RDATA_1(r,a,p) ((p) ? (((((UINT8 *)&blitter_regs[r])[BYTE4_XOR_BE(((UINT32)a##_x >> 19) & 7)]) >> PIXEL_SHIFT_1(a)) & 0x01) : (blitter_regs[r] & 0x01))
|
| 39 | #define READ_PIXEL_1(a) (((((UINT8 *)a##_base_mem)[PIXEL_OFFSET_1(a)]) >> PIXEL_SHIFT_1(a)) & 0x01)
|
| 40 | #define READ_ZDATA_1(a) 0 /* huh? */
|
| 41 | #define WRITE_PIXEL_1(a,d) do { UINT8 *pix = &((UINT8 *)a##_base_mem)[PIXEL_OFFSET_1(a)]; *pix = (*pix & ~(0x01 << PIXEL_SHIFT_1(a))) | ((d) << PIXEL_SHIFT_1(a)); } while (0)
|
| 42 | #define WRITE_ZDATA_1(a,d) /* huh? */
|
| 43 | |
| 44 | #define PIXEL_SHIFT_2(a) ((~a##_x >> 15) & 6)
|
| 45 | #define PIXEL_OFFSET_2(a) BYTE4_XOR_BE(((UINT32)a##_y >> 16) * a##_width / 4 + (((UINT32)a##_x >> 18) & ~7) * (1 + a##_pitch) + (((UINT32)a##_x >> 18) & 7))
|
| 46 | #define ZDATA_OFFSET_2(a) 0 /* huh? */
|
| 47 | #define READ_RDATA_2(r,a,p) ((p) ? (((((UINT8 *)&blitter_regs[r])[BYTE4_XOR_BE(((UINT32)a##_x >> 18) & 7)]) >> PIXEL_SHIFT_2(a)) & 0x03) : (blitter_regs[r] & 0x03))
|
| 48 | #define READ_PIXEL_2(a) (((((UINT8 *)a##_base_mem)[PIXEL_OFFSET_2(a)]) >> PIXEL_SHIFT_2(a)) & 0x03)
|
| 49 | #define READ_ZDATA_2(a) 0 /* huh? */
|
| 50 | #define WRITE_PIXEL_2(a,d) do { UINT8 *pix = &((UINT8 *)a##_base_mem)[PIXEL_OFFSET_2(a)]; *pix = (*pix & ~(0x03 << PIXEL_SHIFT_2(a))) | ((d) << PIXEL_SHIFT_2(a)); } while (0)
|
| 51 | #define WRITE_ZDATA_2(a,d) /* huh? */
|
| 52 | |
| 53 | #define PIXEL_SHIFT_4(a) ((~a##_x >> 14) & 4)
|
| 54 | #define PIXEL_OFFSET_4(a) BYTE4_XOR_BE(((UINT32)a##_y >> 16) * a##_width / 2 + (((UINT32)a##_x >> 17) & ~7) * (1 + a##_pitch) + (((UINT32)a##_x >> 17) & 7))
|
| 55 | #define ZDATA_OFFSET_4(a) 0 /* huh? */
|
| 56 | #define READ_RDATA_4(r,a,p) ((p) ? (((((UINT8 *)&blitter_regs[r])[BYTE4_XOR_BE(((UINT32)a##_x >> 17) & 7)]) >> PIXEL_SHIFT_4(a)) & 0x0f) : (blitter_regs[r] & 0x0f))
|
| 57 | #define READ_PIXEL_4(a) (((((UINT8 *)a##_base_mem)[PIXEL_OFFSET_4(a)]) >> PIXEL_SHIFT_4(a)) & 0x0f)
|
| 58 | #define READ_ZDATA_4(a) 0 /* huh? */
|
| 59 | #define WRITE_PIXEL_4(a,d) do { UINT8 *pix = &((UINT8 *)a##_base_mem)[PIXEL_OFFSET_4(a)]; *pix = (*pix & ~(0x0f << PIXEL_SHIFT_4(a))) | ((d) << PIXEL_SHIFT_4(a)); } while (0)
|
| 60 | #define WRITE_ZDATA_4(a,d) /* huh? */
|
| 61 | |
| 62 | #define PIXEL_OFFSET_8(a) BYTE4_XOR_BE(((UINT32)a##_y >> 16) * a##_width + (((UINT32)a##_x >> 16) & ~7) * (1 + a##_pitch) + (((UINT32)a##_x >> 16) & 7))
|
| 63 | #define ZDATA_OFFSET_8(a) (PIXEL_OFFSET_8(a) + a##_zoffs * 8)
|
| 64 | #define READ_RDATA_8(r,a,p) ((p) ? (((UINT8 *)&blitter_regs[r])[BYTE4_XOR_BE(((UINT32)a##_x >> 16) & 7)]) : (blitter_regs[r] & 0xff))
|
| 65 | #define READ_PIXEL_8(a) (((UINT8 *)a##_base_mem)[PIXEL_OFFSET_8(a)])
|
| 66 | #define READ_ZDATA_8(a) (((UINT8 *)a##_base_mem)[ZDATA_OFFSET_8(a)])
|
| 67 | #define WRITE_PIXEL_8(a,d) do { ((UINT8 *)a##_base_mem)[PIXEL_OFFSET_8(a)] = (d); } while (0)
|
| 68 | #define WRITE_ZDATA_8(a,d) do { ((UINT8 *)a##_base_mem)[ZDATA_OFFSET_8(a)] = (d); } while (0)
|
| 69 | |
| 70 | #define PIXEL_OFFSET_16(a) BYTE_XOR_BE(((UINT32)a##_y >> 16) * a##_width + (((UINT32)a##_x >> 16) & ~3) * (1 + a##_pitch) + (((UINT32)a##_x >> 16) & 3))
|
| 71 | #define ZDATA_OFFSET_16(a) (PIXEL_OFFSET_16(a) + a##_zoffs * 4)
|
| 72 | #define READ_RDATA_16(r,a,p) ((p) ? (((UINT16 *)&blitter_regs[r])[BYTE_XOR_BE(((UINT32)a##_x >> 16) & 3)]) : (blitter_regs[r] & 0xffff))
|
| 73 | #define READ_PIXEL_16(a) (((UINT16 *)a##_base_mem)[PIXEL_OFFSET_16(a)])
|
| 74 | #define READ_ZDATA_16(a) (((UINT16 *)a##_base_mem)[ZDATA_OFFSET_16(a)])
|
| 75 | #define WRITE_PIXEL_16(a,d) do { ((UINT16 *)a##_base_mem)[PIXEL_OFFSET_16(a)] = (d); } while (0)
|
| 76 | #define WRITE_ZDATA_16(a,d) do { ((UINT16 *)a##_base_mem)[ZDATA_OFFSET_16(a)] = (d); } while (0)
|
| 77 | |
| 78 | #define PIXEL_OFFSET_32(a) (((UINT32)a##_y >> 16) * a##_width + (((UINT32)a##_x >> 16) & ~1) * (1 + a##_pitch) + (((UINT32)a##_x >> 16) & 1))
|
| 79 | #define ZDATA_OFFSET_32(a) (PIXEL_OFFSET_32(a) + a##_zoffs * 2)
|
| 80 | #define READ_RDATA_32(r,a,p) ((p) ? (blitter_regs[r + (((UINT32)a##_x >> 16) & 1)]) : blitter_regs[r])
|
| 81 | #define READ_PIXEL_32(a) (((UINT32 *)a##_base_mem)[PIXEL_OFFSET_32(a)])
|
| 82 | #define READ_ZDATA_32(a) (((UINT32 *)a##_base_mem)[ZDATA_OFFSET_32(a)])
|
| 83 | #define WRITE_PIXEL_32(a,d) do { ((UINT32 *)a##_base_mem)[PIXEL_OFFSET_32(a)] = (d); } while (0)
|
| 84 | #define WRITE_ZDATA_32(a,d) do { ((UINT32 *)a##_base_mem)[ZDATA_OFFSET_32(a)] = (d); } while (0)
|
| 85 | |
| 86 | #define READ_RDATA(r,a,f,p) \
|
| 87 | ((((f) & 0x38) == (0 << 3)) ? (READ_RDATA_1(r,a,p)) : \
|
| 88 | (((f) & 0x38) == (1 << 3)) ? (READ_RDATA_2(r,a,p)) : \
|
| 89 | (((f) & 0x38) == (2 << 3)) ? (READ_RDATA_4(r,a,p)) : \
|
| 90 | (((f) & 0x38) == (3 << 3)) ? (READ_RDATA_8(r,a,p)) : \
|
| 91 | (((f) & 0x38) == (4 << 3)) ? (READ_RDATA_16(r,a,p)) : \
|
| 92 | (((f) & 0x38) == (5 << 3)) ? (READ_RDATA_32(r,a,p)) : 0)
|
| 93 | |
| 94 | #define READ_PIXEL(a,f) \
|
| 95 | ((((f) & 0x38) == (0 << 3)) ? (READ_PIXEL_1(a)) : \
|
| 96 | (((f) & 0x38) == (1 << 3)) ? (READ_PIXEL_2(a)) : \
|
| 97 | (((f) & 0x38) == (2 << 3)) ? (READ_PIXEL_4(a)) : \
|
| 98 | (((f) & 0x38) == (3 << 3)) ? (READ_PIXEL_8(a)) : \
|
| 99 | (((f) & 0x38) == (4 << 3)) ? (READ_PIXEL_16(a)) : \
|
| 100 | (((f) & 0x38) == (5 << 3)) ? (READ_PIXEL_32(a)) : 0)
|
| 101 | |
| 102 | #define READ_ZDATA(a,f) \
|
| 103 | ((((f) & 0x38) == (0 << 3)) ? (READ_ZDATA_1(a)) : \
|
| 104 | (((f) & 0x38) == (1 << 3)) ? (READ_ZDATA_2(a)) : \
|
| 105 | (((f) & 0x38) == (2 << 3)) ? (READ_ZDATA_4(a)) : \
|
| 106 | (((f) & 0x38) == (3 << 3)) ? (READ_ZDATA_8(a)) : \
|
| 107 | (((f) & 0x38) == (4 << 3)) ? (READ_ZDATA_16(a)) : \
|
| 108 | (((f) & 0x38) == (5 << 3)) ? (READ_ZDATA_32(a)) : 0)
|
| 109 | |
| 110 | #define WRITE_PIXEL(a,f,d) \
|
| 111 | do \
|
| 112 | { \
|
| 113 | if (((f) & 0x38) == (0 << 3)) WRITE_PIXEL_1(a,d); \
|
| 114 | else if (((f) & 0x38) == (1 << 3)) WRITE_PIXEL_2(a,d); \
|
| 115 | else if (((f) & 0x38) == (2 << 3)) WRITE_PIXEL_4(a,d); \
|
| 116 | else if (((f) & 0x38) == (3 << 3)) WRITE_PIXEL_8(a,d); \
|
| 117 | else if (((f) & 0x38) == (4 << 3)) WRITE_PIXEL_16(a,d); \
|
| 118 | else if (((f) & 0x38) == (5 << 3)) WRITE_PIXEL_32(a,d); \
|
| 119 | } while (0)
|
| 120 | |
| 121 | #define WRITE_ZDATA(a,f,d) \
|
| 122 | do \
|
| 123 | { \
|
| 124 | if (((f) & 0x38) == (0 << 3)) WRITE_ZDATA_1(a,d); \
|
| 125 | else if (((f) & 0x38) == (1 << 3)) WRITE_ZDATA_2(a,d); \
|
| 126 | else if (((f) & 0x38) == (2 << 3)) WRITE_ZDATA_4(a,d); \
|
| 127 | else if (((f) & 0x38) == (3 << 3)) WRITE_ZDATA_8(a,d); \
|
| 128 | else if (((f) & 0x38) == (4 << 3)) WRITE_ZDATA_16(a,d); \
|
| 129 | else if (((f) & 0x38) == (5 << 3)) WRITE_ZDATA_32(a,d); \
|
| 130 | } while (0)
|
| 131 | #endif
|
| 132 | |
| 133 | static void FUNCNAME(running_machine *machine, UINT32 command, UINT32 a1flags, UINT32 a2flags)
|
| 134 | {
|
| 135 | UINT32 a1_base = blitter_regs[A1_BASE];
|
| 136 | INT32 a1_pitch = (A1FIXED & 3) ^ ((A1FIXED & 2) >> 1);
|
| 137 | INT32 a1_zoffs = (A1FIXED >> 6) & 7;
|
| 138 | INT32 a1_width = ((4 | ((a1flags >> 9) & 3)) << ((a1flags >> 11) & 15)) >> 2;
|
| 139 | INT32 a1_xadd = (A1FIXED >> 16) & 0x03;
|
| 140 | INT32 a1_yadd = (A1FIXED >> 18) & 0x01;
|
| 141 | INT32 a1_x = (blitter_regs[A1_PIXEL] << 16) | (blitter_regs[A1_FPIXEL] & 0xffff);
|
| 142 | INT32 a1_y = (blitter_regs[A1_PIXEL] & 0xffff0000) | (blitter_regs[A1_FPIXEL] >> 16);
|
| 143 | INT32 a1_xstep = 0;
|
| 144 | INT32 a1_ystep = 0;
|
| 145 | UINT32 a1_xmask = 0xffffffff;
|
| 146 | UINT32 a1_ymask = 0xffffffff;
|
| 147 | |
| 148 | UINT32 a2_base = blitter_regs[A2_BASE];
|
| 149 | INT32 a2_pitch = (A2FIXED & 3) ^ ((A2FIXED & 2) >> 1);
|
| 150 | INT32 a2_zoffs = (A2FIXED >> 6) & 7;
|
| 151 | INT32 a2_width = ((4 | ((a2flags >> 9) & 3)) << ((a2flags >> 11) & 15)) >> 2;
|
| 152 | INT32 a2_xadd = (A2FIXED >> 16) & 0x03;
|
| 153 | INT32 a2_yadd = (A2FIXED >> 18) & 0x01;
|
| 154 | INT32 a2_x = (blitter_regs[A2_PIXEL] << 16);
|
| 155 | INT32 a2_y = (blitter_regs[A2_PIXEL] & 0xffff0000);
|
| 156 | INT32 a2_xstep = 0;
|
| 157 | INT32 a2_ystep = 0;
|
| 158 | UINT32 a2_xmask = 0xffffffff;
|
| 159 | UINT32 a2_ymask = 0xffffffff;
|
| 160 | |
| 161 | int inner_count = blitter_regs[B_COUNT] & 0xffff;
|
| 162 | int outer_count = blitter_regs[B_COUNT] >> 16;
|
| 163 | int inner, outer;
|
| 164 | |
| 165 | UINT8 a1_phrase_mode = 0;
|
| 166 | UINT8 a2_phrase_mode = 0;
|
| 167 | |
| 168 | void *a1_base_mem = get_jaguar_memory(machine, a1_base);
|
| 169 | void *a2_base_mem = get_jaguar_memory(machine, a2_base);
|
| 170 | |
| 171 | void *asrc_base_mem = (COMMAND & 0x00000800) ? a1_base_mem : a2_base_mem;
|
| 172 | UINT32 asrcflags = (COMMAND & 0x00000800) ? A1FIXED : A2FIXED;
|
| 173 | INT32 asrc_x = (COMMAND & 0x00000800) ? a1_x : a2_x;
|
| 174 | INT32 asrc_y = (COMMAND & 0x00000800) ? a1_y : a2_y;
|
| 175 | INT32 asrc_width = (COMMAND & 0x00000800) ? a1_width : a2_width;
|
| 176 | INT32 asrc_pitch = (COMMAND & 0x00000800) ? a1_pitch : a2_pitch;
|
| 177 | INT32 asrc_zoffs = (COMMAND & 0x00000800) ? a1_zoffs : a2_zoffs;
|
| 178 | UINT8 asrc_phrase_mode;
|
| 179 | INT32 asrc_xadd, asrc_xstep, asrc_yadd, asrc_ystep;
|
| 180 | UINT32 asrc_xmask, asrc_ymask;
|
| 181 | |
| 182 | void *adest_base_mem = (COMMAND & 0x00000800) ? a2_base_mem : a1_base_mem;
|
| 183 | UINT32 adestflags = (COMMAND & 0x00000800) ? A2FIXED : A1FIXED;
|
| 184 | INT32 adest_x = (COMMAND & 0x00000800) ? a2_x : a1_x;
|
| 185 | INT32 adest_y = (COMMAND & 0x00000800) ? a2_y : a1_y;
|
| 186 | INT32 adest_width = (COMMAND & 0x00000800) ? a2_width : a1_width;
|
| 187 | INT32 adest_pitch = (COMMAND & 0x00000800) ? a2_pitch : a1_pitch;
|
| 188 | INT32 adest_zoffs = (COMMAND & 0x00000800) ? a2_zoffs : a1_zoffs;
|
| 189 | UINT8 adest_phrase_mode;
|
| 190 | INT32 adest_xadd, adest_xstep, adest_yadd, adest_ystep;
|
| 191 | UINT32 adest_xmask, adest_ymask;
|
| 192 | |
| 193 | /* don't blit if pointer bad */
|
| 194 | if (!a1_base_mem || !a2_base_mem)
|
| 195 | {
|
| 196 | if (LOG_BAD_BLITS)
|
| 197 | {
|
| 198 | logerror("%s:Blit!\n", cpuexec_describe_context(machine));
|
| 199 | logerror(" a1_base = %08X\n", a1_base);
|
| 200 | logerror(" a2_base = %08X\n", a2_base);
|
| 201 | }
|
| 202 | return;
|
| 203 | }
|
| 204 | |
| 205 | /* determine actual xadd/yadd for A1 */
|
| 206 | a1_yadd <<= 16;
|
| 207 | if (A1FIXED & 0x00100000)
|
| 208 | a1_yadd = -a1_yadd;
|
| 209 | |
| 210 | a1_phrase_mode = (a1_xadd == 0);
|
| 211 | if (a1_xadd == 3)
|
| 212 | {
|
| 213 | a1_xadd = (blitter_regs[A1_INC] << 16) | (blitter_regs[A1_FINC] & 0xffff);
|
| 214 | a1_yadd = (blitter_regs[A1_INC] & 0xffff0000) | (blitter_regs[A1_FINC] >> 16);
|
| 215 | }
|
| 216 | else if (a1_xadd == 2)
|
| 217 | a1_xadd = 0;
|
| 218 | else
|
| 219 | a1_xadd = 1 << 16;
|
| 220 | if (A1FIXED & 0x00080000)
|
| 221 | a1_xadd = -a1_xadd;
|
| 222 | |
| 223 | /* determine actual xadd/yadd for A2 */
|
| 224 | a2_yadd <<= 16;
|
| 225 | if (A2FIXED & 0x00100000)
|
| 226 | a2_yadd = -a2_yadd;
|
| 227 | |
| 228 | a2_phrase_mode = (a2_xadd == 0);
|
| 229 | if (a2_xadd == 2)
|
| 230 | a2_xadd = 0;
|
| 231 | else
|
| 232 | a2_xadd = 1 << 16;
|
| 233 | if (A2FIXED & 0x00080000)
|
| 234 | a2_xadd = -a2_xadd;
|
| 235 | |
| 236 | /* set up the A2 mask */
|
| 237 | if (A2FIXED & 0x00008000)
|
| 238 | {
|
| 239 | a2_xmask = (blitter_regs[A2_MASK] << 16) | 0xffff;
|
| 240 | a2_ymask = (blitter_regs[A2_MASK] & 0xffff) | 0xffff;
|
| 241 | }
|
| 242 | |
| 243 | /* modify outer loop steps based on command */
|
| 244 | if (command & 0x00000100)
|
| 245 | {
|
| 246 | a1_xstep = blitter_regs[A1_FSTEP] & 0xffff;
|
| 247 | a1_ystep = blitter_regs[A1_FSTEP] >> 16;
|
| 248 | }
|
| 249 | if (command & 0x00000200)
|
| 250 | {
|
| 251 | a1_xstep += blitter_regs[A1_STEP] << 16;
|
| 252 | a1_ystep += blitter_regs[A1_STEP] & 0xffff0000;
|
| 253 | }
|
| 254 | if (command & 0x00000400)
|
| 255 | {
|
| 256 | a2_xstep = blitter_regs[A2_STEP] << 16;
|
| 257 | a2_ystep = blitter_regs[A2_STEP] & 0xffff0000;
|
| 258 | }
|
| 259 | |
| 260 | asrc_phrase_mode = (COMMAND & 0x00000800) ? a1_phrase_mode : a2_phrase_mode;
|
| 261 | asrc_xstep = (COMMAND & 0x00000800) ? a1_xstep : a2_xstep;
|
| 262 | asrc_ystep = (COMMAND & 0x00000800) ? a1_ystep : a2_ystep;
|
| 263 | asrc_xadd = (COMMAND & 0x00000800) ? a1_xadd : a2_xadd;
|
| 264 | asrc_yadd = (COMMAND & 0x00000800) ? a1_yadd : a2_yadd;
|
| 265 | asrc_xmask = (COMMAND & 0x00000800) ? a1_xmask : a2_xmask;
|
| 266 | asrc_ymask = (COMMAND & 0x00000800) ? a1_ymask : a2_ymask;
|
| 267 | |
| 268 | adest_phrase_mode = (COMMAND & 0x00000800) ? a2_phrase_mode : a1_phrase_mode;
|
| 269 | adest_xstep = (COMMAND & 0x00000800) ? a2_xstep : a1_xstep;
|
| 270 | adest_ystep = (COMMAND & 0x00000800) ? a2_ystep : a1_ystep;
|
| 271 | adest_xadd = (COMMAND & 0x00000800) ? a2_xadd : a1_xadd;
|
| 272 | adest_yadd = (COMMAND & 0x00000800) ? a2_yadd : a1_yadd;
|
| 273 | adest_xmask = (COMMAND & 0x00000800) ? a2_xmask : a1_xmask;
|
| 274 | adest_ymask = (COMMAND & 0x00000800) ? a2_ymask : a1_ymask;
|
| 275 | |
| 276 | if (LOG_BLITS)
|
| 277 | {
|
| 278 | logerror("%s:Blit!\n", cpuexec_describe_context(machine));
|
| 279 | logerror(" a1_base = %08X\n", a1_base);
|
| 280 | logerror(" a1_pitch = %d\n", a1_pitch);
|
| 281 | logerror(" a1_psize = %d\n", 1 << ((A1FIXED >> 3) & 7));
|
| 282 | logerror(" a1_width = %d\n", a1_width);
|
| 283 | logerror(" a1_xadd = %f (phrase=%d)\n", (float)a1_xadd / 65536.0, a1_phrase_mode);
|
| 284 | logerror(" a1_yadd = %f\n", (float)a1_yadd / 65536.0);
|
| 285 | logerror(" a1_xstep = %f\n", (float)a1_xstep / 65536.0);
|
| 286 | logerror(" a1_ystep = %f\n", (float)a1_ystep / 65536.0);
|
| 287 | logerror(" a1_x = %f\n", (float)a1_x / 65536.0);
|
| 288 | logerror(" a1_y = %f\n", (float)a1_y / 65536.0);
|
| 289 | |
| 290 | logerror(" a2_base = %08X\n", a2_base);
|
| 291 | logerror(" a2_pitch = %d\n", a2_pitch);
|
| 292 | logerror(" a2_psize = %d\n", 1 << ((A2FIXED >> 3) & 7));
|
| 293 | logerror(" a2_width = %d\n", a2_width);
|
| 294 | logerror(" a2_xadd = %f (phrase=%d)\n", (float)a2_xadd / 65536.0, a2_phrase_mode);
|
| 295 | logerror(" a2_yadd = %f\n", (float)a2_yadd / 65536.0);
|
| 296 | logerror(" a2_xstep = %f\n", (float)a2_xstep / 65536.0);
|
| 297 | logerror(" a2_ystep = %f\n", (float)a2_ystep / 65536.0);
|
| 298 | logerror(" a2_x = %f\n", (float)a2_x / 65536.0);
|
| 299 | logerror(" a2_y = %f\n", (float)a2_y / 65536.0);
|
| 300 | |
| 301 | logerror(" count = %d x %d\n", inner_count, outer_count);
|
| 302 | logerror(" command = %08X\n", COMMAND);
|
| 303 | }
|
| 304 | |
| 305 | /* check for unhandled command bits */
|
| 306 | if (LOG_UNHANDLED_BLITS && (COMMAND & 0x24003000))
|
| 307 | logerror("Blitter unhandled: these command bits: %08X\n", COMMAND & 0x24003000);
|
| 308 | |
| 309 | /* top of the outer loop */
|
| 310 | outer = outer_count;
|
| 311 | while (outer--)
|
| 312 | {
|
| 313 | /* top of the inner loop */
|
| 314 | inner = inner_count;
|
| 315 | while (inner--)
|
| 316 | {
|
| 317 | UINT32 srcdata;
|
| 318 | UINT32 srczdata = 0;
|
| 319 | UINT32 dstdata;
|
| 320 | UINT32 dstzdata = 0;
|
| 321 | UINT32 writedata = 0;
|
| 322 | int inhibit = 0;
|
| 323 | |
| 324 | /* load src data and Z */
|
| 325 | if (COMMAND & 0x00000001)
|
| 326 | {
|
| 327 | srcdata = READ_PIXEL(asrc, asrcflags);
|
| 328 | if (COMMAND & 0x00000002)
|
| 329 | srczdata = READ_ZDATA(asrc, asrcflags);
|
| 330 | else if (COMMAND & 0x001c020)
|
| 331 | srczdata = READ_RDATA(B_SRCZ1_H, asrc, asrcflags, asrc_phrase_mode);
|
| 332 | }
|
| 333 | else
|
| 334 | {
|
| 335 | srcdata = READ_RDATA(B_SRCD_H, asrc, asrcflags, asrc_phrase_mode);
|
| 336 | if (COMMAND & 0x001c020)
|
| 337 | srczdata = READ_RDATA(B_SRCZ1_H, asrc, asrcflags, asrc_phrase_mode);
|
| 338 | }
|
| 339 | |
| 340 | /* load dst data and Z */
|
| 341 | if (COMMAND & 0x00000008)
|
| 342 | {
|
| 343 | dstdata = READ_PIXEL(adest, adestflags);
|
| 344 | if (COMMAND & 0x00000010)
|
| 345 | dstzdata = READ_ZDATA(adest, adestflags);
|
| 346 | else
|
| 347 | dstzdata = READ_RDATA(B_DSTZ_H, adest, adestflags, adest_phrase_mode);
|
| 348 | }
|
| 349 | else
|
| 350 | {
|
| 351 | dstdata = READ_RDATA(B_DSTD_H, adest, adestflags, adest_phrase_mode);
|
| 352 | if (COMMAND & 0x00000010)
|
| 353 | dstzdata = READ_RDATA(B_DSTZ_H, adest, adestflags, adest_phrase_mode);
|
| 354 | }
|
| 355 | |
| 356 | /* handle clipping */
|
| 357 | if (COMMAND & 0x00000040)
|
| 358 | {
|
| 359 | if (adest_x < 0 || adest_y < 0 ||
|
| 360 | (adest_x >> 16) >= (blitter_regs[A1_CLIP] & 0x7fff) ||
|
| 361 | (adest_y >> 16) >= ((blitter_regs[A1_CLIP] >> 16) & 0x7fff))
|
| 362 | inhibit = 1;
|
| 363 | }
|
| 364 | |
| 365 | /* apply Z comparator */
|
| 366 | if (COMMAND & 0x00040000)
|
| 367 | if (srczdata < dstzdata) inhibit = 1;
|
| 368 | if (COMMAND & 0x00080000)
|
| 369 | if (srczdata == dstzdata) inhibit = 1;
|
| 370 | if (COMMAND & 0x00100000)
|
| 371 | if (srczdata > dstzdata) inhibit = 1;
|
| 372 | |
| 373 | /* apply data comparator */
|
| 374 | if (COMMAND & 0x08000000)
|
| 375 | {
|
| 376 | if (!(COMMAND & 0x02000000))
|
| 377 | {
|
| 378 | if (srcdata == READ_RDATA(B_PATD_H, asrc, asrcflags, asrc_phrase_mode))
|
| 379 | inhibit = 1;
|
| 380 | }
|
| 381 | else
|
| 382 | {
|
| 383 | if (dstdata == READ_RDATA(B_PATD_H, adest, adestflags, adest_phrase_mode))
|
| 384 | inhibit = 1;
|
| 385 | }
|
| 386 | }
|
| 387 | |
| 388 | /* compute the write data and store */
|
| 389 | if (!inhibit)
|
| 390 | {
|
| 391 | /* handle patterns/additive/LFU */
|
| 392 | if (COMMAND & 0x00010000)
|
| 393 | writedata = READ_RDATA(B_PATD_H, adest, adestflags, adest_phrase_mode);
|
| 394 | else if (COMMAND & 0x00020000)
|
| 395 | {
|
| 396 | writedata = (srcdata & 0xff) + (dstdata & 0xff);
|
| 397 | if (!(COMMAND & 0x00004000) && writedata > 0xff)
|
| 398 | writedata = 0xff;
|
| 399 | writedata |= (srcdata & 0xf00) + (dstdata & 0xf00);
|
| 400 | if (!(COMMAND & 0x00008000) && writedata > 0xfff)
|
| 401 | writedata = 0xfff;
|
| 402 | writedata |= (srcdata & 0xf000) + (dstdata & 0xf000);
|
| 403 | }
|
| 404 | else
|
| 405 | {
|
| 406 | if (COMMAND & 0x00200000)
|
| 407 | writedata |= ~srcdata & ~dstdata;
|
| 408 | if (COMMAND & 0x00400000)
|
| 409 | writedata |= ~srcdata & dstdata;
|
| 410 | if (COMMAND & 0x00800000)
|
| 411 | writedata |= srcdata & ~dstdata;
|
| 412 | if (COMMAND & 0x01000000)
|
| 413 | writedata |= srcdata & dstdata;
|
| 414 | }
|
| 415 | |
| 416 | /* handle source shading */
|
| 417 | if (COMMAND & 0x40000000)
|
| 418 | {
|
| 419 | int intensity = srcdata & 0x00ff;
|
| 420 | intensity += (INT8) (blitter_regs[B_Z3] >> 16);
|
| 421 | if (intensity < 0)
|
| 422 | intensity = 0;
|
| 423 | else if (intensity > 0xff)
|
| 424 | intensity = 0xff;
|
| 425 | writedata = (srcdata & 0xff00) | intensity;
|
| 426 | }
|
| 427 | }
|
| 428 | else
|
| 429 | writedata = dstdata;
|
| 430 | |
| 431 | if (adest_phrase_mode || (command & 0x10000000) || !inhibit)
|
| 432 | {
|
| 433 | /* write to the destination */
|
| 434 | WRITE_PIXEL(adest, adestflags, writedata);
|
| 435 | if (COMMAND & 0x00000020)
|
| 436 | WRITE_ZDATA(adest, adestflags, srczdata);
|
| 437 | }
|
| 438 | |
| 439 | /* update X/Y */
|
| 440 | asrc_x = (asrc_x + asrc_xadd) & asrc_xmask;
|
| 441 | asrc_y = (asrc_y + asrc_yadd) & asrc_ymask;
|
| 442 | adest_x = (adest_x + adest_xadd) & adest_xmask;
|
| 443 | adest_y = (adest_y + adest_yadd) & adest_ymask;
|
| 444 | }
|
| 445 | |
| 446 | /* adjust for phrase mode */
|
| 447 | if (asrc_phrase_mode)
|
| 448 | {
|
| 449 | if (asrc_xadd > 0)
|
| 450 | asrc_x += 3 << 16;
|
| 451 | else
|
| 452 | asrc_x -= 3 << 16;
|
| 453 | asrc_x &= ~(3 << 16);
|
| 454 | }
|
| 455 | if (adest_phrase_mode)
|
| 456 | {
|
| 457 | if (adest_xadd > 0)
|
| 458 | adest_x += 3 << 16;
|
| 459 | else
|
| 460 | adest_x -= 3 << 16;
|
| 461 | adest_x &= ~(3 << 16);
|
| 462 | }
|
| 463 | |
| 464 | /* update for outer loop */
|
| 465 | asrc_x += asrc_xstep;
|
| 466 | asrc_y += asrc_ystep;
|
| 467 | adest_x += adest_xstep;
|
| 468 | adest_y += adest_ystep;
|
| 469 | }
|
| 470 | |
| 471 | /* write values back to registers */
|
| 472 | a1_x = (COMMAND & 0x00000800) ? asrc_x : adest_x;
|
| 473 | a1_y = (COMMAND & 0x00000800) ? asrc_y : adest_y;
|
| 474 | a2_x = (COMMAND & 0x00000800) ? adest_x : asrc_x;
|
| 475 | a2_y = (COMMAND & 0x00000800) ? adest_y : asrc_y;
|
| 476 | |
| 477 | blitter_regs[A1_PIXEL] = (a1_y & 0xffff0000) | ((a1_x >> 16) & 0xffff);
|
| 478 | blitter_regs[A1_FPIXEL] = (a1_y << 16) | (a1_x & 0xffff);
|
| 479 | blitter_regs[A2_PIXEL] = (a2_y & 0xffff0000) | ((a2_x >> 16) & 0xffff);
|
| 480 | }
|