static void kabuki_decode(_BytePtr src, _BytePtr dest_op, _BytePtr dest_data, int base_addr, int length, int swap_key1, int swap_key2, int addr_key, int xor_key) { for (int A = 0; A < length; A++) { /* decode opcodes */ int select = (A + base_addr) + addr_key; dest_op[A] = (byte)bytedecode(src[A], swap_key1, swap_key2, xor_key, select); /* decode data */ select = ((A + base_addr) ^ 0x1fc0) + addr_key + 1; dest_data[A] = (byte)bytedecode(src[A], swap_key1, swap_key2, xor_key, select); } }
int SEGAPCMInit(Mame.MachineSound msound, int banksize, int mode, _BytePtr inpcm, int volume) { int i; int rate = Mame.Machine.sample_rate; buffer_len = (int)(rate / Mame.Machine.drv.frames_per_second); emulation_rate = (int)(buffer_len * Mame.Machine.drv.frames_per_second); sample_rate = SEGAPCM_samples[mode][0]; sample_shift = SEGAPCM_samples[mode][1]; pcm_rom = inpcm; //printf( "segaPCM in\n" ); /**** interface init ****/ spcm.bankshift = banksize & 0xffffff; if ((banksize >> 16) == 0x00) { spcm.bankmask = (BANK_MASK7 >> 16) & 0x00ff; /* default */ } else { spcm.bankmask = (banksize >> 16) & 0x00ff; } for (i = 0; i < SEGAPCM_MAX; i++) { spcm.gain[i, L_PAN] = spcm.gain[i, R_PAN] = 0; spcm.vol[i, L_PAN] = spcm.vol[i, R_PAN] = 0; spcm.addr_l[i] = 0; spcm.addr_h[i] = 0; spcm.bank[i] = 0; spcm.end_h[i] = 0; spcm.delta_t[i] = 0x80; spcm.flag[i] = 1; spcm.add_addr[i] = 0; spcm.step[i] = (uint)(((float)sample_rate / (float)emulation_rate) * (float)(0x80 << 5)); spcm.pcmd[i] = 0; } //printf( "segaPCM work init end\n" ); { string[] name = new string[LR_PAN]; int[] vol = new int[2]; name[0] = Mame.sprintf("%s L", Mame.sound_name(msound)); name[1] = Mame.sprintf("%s R", Mame.sound_name(msound)); vol[0] = (Mame.MIXER_PAN_LEFT << 8) | (volume & 0xff); vol[1] = (Mame.MIXER_PAN_RIGHT << 8) | (volume & 0xff); stream = Mame.stream_init_multi(LR_PAN, name, vol, rate, 0, SEGAPCMUpdate); } //printf( "segaPCM end\n" ); return 0; }
public static void overlay_draw(osd_bitmap dest, artwork overlay) { int i, j; int height, width; osd_bitmap o = null; int black; o = overlay._artwork; height = overlay._artwork.height; width = overlay._artwork.width; black = Machine.pens[0]; if (dest.depth == 8) { _BytePtr dst, ovr; for (j = 0; j < height; j++) { dst = new _BytePtr(dest.line[j]); ovr = new _BytePtr(o.line[j]); for (i = 0; i < width; i++) { if (dst[0] != black) dst[0] = ovr[0]; dst.offset++; ovr.offset++; } } } else { _ShortPtr dst, ovr; for (j = 0; j < height; j++) { dst = new _ShortPtr(dest.line[j]); ovr = new _ShortPtr(o.line[j]); for (i = 0; i < width; i++) { if (dst.read16(0) != black) dst.write16(0, ovr.read16(0)); dst.offset += 2; ovr.offset += 2; } } } }
public static void sprite_init() { rectangle clip = Machine.drv.visible_area; int left = clip.min_x; int top = clip.min_y; int right = clip.max_x + 1; int bottom = clip.max_y + 1; osd_bitmap bitmap = Machine.scrbitmap; screen_baseaddr = bitmap.line[0]; screen_line_offset = (int)(bitmap.line[1].offset - bitmap.line[0].offset); orientation = Machine.orientation; screen_width = Machine.scrbitmap.width; screen_height = Machine.scrbitmap.height; if ((orientation & ORIENTATION_SWAP_XY) != 0) { { int t = left; left = top; top = t; } { int t = right; right = bottom; bottom = t; } } if ((orientation & ORIENTATION_FLIP_X) != 0) { { int t = left; left = right; right = t; } left = screen_width - left; right = screen_width - right; } if ((orientation & ORIENTATION_FLIP_Y) != 0) { { int t = top; top = bottom; bottom = t; } top = screen_height - top; bottom = screen_height - bottom; } screen_clip_left = left; screen_clip_right = right; screen_clip_top = top; screen_clip_bottom = bottom; }
static int avgdvg_init(int vgType) { int i; if (Vector.vectorram_size[0] == 0) { Mame.printf("Error: vectorram_size not initialized\n"); return 1; } /* ASG 971210 -- initialize the pages */ for (i = 0; i < NUM_BANKS; i++) vectorbank[i] = new _BytePtr(Vector.vectorram, (i << BANK_BITS)); if (vgType == USE_AVG_MHAVOC) vectorbank[1] = new _BytePtr(Mame.memory_region(Mame.REGION_CPU1), 0x18000); vectorEngine = vgType; if ((vectorEngine < AVGDVG_MIN) || (vectorEngine > AVGDVG_MAX)) { Mame.printf("Error: unknown Atari Vector Game Type\n"); return 1; } if (vectorEngine == USE_AVG_SWARS) flipword = 1; #if !WINDOWS else if (vectorEngine==USE_AVG_QUANTUM) flipword=1; #endif else flipword = 0; vg_step = 0; busy = false; xmin = Mame.Machine.drv.visible_area.min_x; ymin = Mame.Machine.drv.visible_area.min_y; xmax = Mame.Machine.drv.visible_area.max_x; ymax = Mame.Machine.drv.visible_area.max_y; width = xmax - xmin; height = ymax - ymin; xcenter = ((xmax + xmin) / 2) << VEC_SHIFT; /*.ac JAN2498 */ ycenter = ((ymax + ymin) / 2) << VEC_SHIFT; /*.ac JAN2498 */ Vector.vector_set_shift(VEC_SHIFT); if (Vector.vector_vh_start() != 0) return 1; return 0; }
static void avg_generate_vector_list() { int pc; int sp; int[] stack = new int[MAXSTACK]; int scale; int statz = 0; int sparkle = 0; int xflip = 0; int color = 0; int bz_col = -1; /* Battle Zone color selection */ int ywindow = -1; /* Major Havoc Y-Window */ int currentx, currenty; bool done = false; int firstwd, secondwd; int opcode; int x, y, z = 0, b, l, d, a; int deltax, deltay; pc = 0; sp = 0; statz = 0; color = 0; if (flipword != 0) { firstwd = memrdwd_flip(map_addr(pc)); secondwd = memrdwd_flip(map_addr(pc + 1)); } else { firstwd = memrdwd(map_addr(pc)); secondwd = memrdwd(map_addr(pc + 1)); } if ((firstwd == 0) && (secondwd == 0)) { Mame.printf("VGO with zeroed vector memory\n"); return; } /* kludge to bypass Major Havoc's empty frames. BW 980216 */ if (vectorEngine == USE_AVG_MHAVOC && firstwd == 0xafe2) return; scale = 0; /* ASG 080497 */ currentx = xcenter; /* ASG 080497 */ /*.ac JAN2498 */ currenty = ycenter; /* ASG 080497 */ /*.ac JAN2498 */ Vector.vector_clear_list(); while (!done) { #if VG_DEBUG if (vg_step) getchar(); #endif if (flipword != 0) firstwd = memrdwd_flip(map_addr(pc)); else firstwd = memrdwd(map_addr(pc)); opcode = firstwd >> 13; #if VG_DEBUG if (errorlog) fprintf (errorlog,"%4x: %4x ", map_addr (pc), firstwd); #endif pc++; if (opcode == VCTR) { if (flipword != 0) secondwd = memrdwd_flip(map_addr(pc)); else secondwd = memrdwd(map_addr(pc)); pc++; #if VG_DEBUG if (errorlog) fprintf (errorlog,"%4x ", secondwd); #endif } #if VG_DEBUG else if (errorlog) fprintf (errorlog," "); #endif if ((opcode == STAT) && ((firstwd & 0x1000) != 0)) opcode = SCAL; #if VG_DEBUG if (errorlog) fprintf (errorlog,"%s ", avg_mnem [opcode]); #endif switch (opcode) { case VCTR: if (vectorEngine == USE_AVG_QUANTUM) { x = twos_comp_val(secondwd, 12); y = twos_comp_val(firstwd, 12); } else { /* These work for all other games. */ x = twos_comp_val(secondwd, 13); y = twos_comp_val(firstwd, 13); } z = (secondwd >> 12) & ~0x01; /* z is the maximum DAC output, and */ /* the 8 bit value from STAT does some */ /* fine tuning. STATs of 128 should give */ /* highest intensity. */ if (vectorEngine == USE_AVG_SWARS) { if (Vector.translucency != 0) z = (statz * z) / 12; else z = (statz * z) >> 3; if (z > 0xff) z = 0xff; } else { if (z == 2) z = statz; if (Vector.translucency != 0) z = z * BRIGHTNESS; else if (z != 0) z = (z << 4) | 0x1f; } deltax = x * scale; if (xflip != 0) deltax = -deltax; deltay = y * scale; currentx += deltax; currenty -= deltay; vector_timer(deltax, deltay); if (sparkle != 0) { color = Mame.rand() & 0x07; } if ((vectorEngine == USE_AVG_BZONE) && (bz_col != 0)) { if (currenty < (BZONE_TOP << 16)) color = 4; else color = 2; } Vector.vector_add_point(currentx, currenty, colorram[color], z); #if VG_DEBUG if (errorlog) fprintf (errorlog,"VCTR x:%d y:%d z:%d statz:%d", x, y, z, statz); #endif break; case SVEC: x = twos_comp_val(firstwd, 5) << 1; y = twos_comp_val(firstwd >> 8, 5) << 1; z = ((firstwd >> 4) & 0x0e); if (vectorEngine == USE_AVG_SWARS) { if (Vector.translucency != 0) z = (statz * z) / 12; else z = (statz * z) >> 3; if (z > 0xff) z = 0xff; } else { if (z == 2) z = statz; if (Vector.translucency != 0) z = z * BRIGHTNESS; else if (z != 0) z = (z << 4) | 0x1f; } deltax = x * scale; if (xflip != 0) deltax = -deltax; deltay = y * scale; currentx += deltax; currenty -= deltay; vector_timer(deltax, deltay); if (sparkle != 0) { color = Mame.rand() & 0x07; } Vector.vector_add_point(currentx, currenty, colorram[color], z); #if VG_DEBUG if (errorlog) fprintf (errorlog,"SVEC x:%d y:%d z:%d statz:%d", x, y, z, statz); #endif break; case STAT: if (vectorEngine == USE_AVG_SWARS) { /* color code 0-7 stored in top 3 bits of `color' */ color = (char)((firstwd & 0x0700) >> 8); statz = (firstwd) & 0xff; } else { color = (firstwd) & 0x000f; statz = (firstwd >> 4) & 0x000f; if (vectorEngine == USE_AVG_TEMPEST) sparkle = (firstwd & 0x0800) == 0 ? 1 : 0; if (vectorEngine == USE_AVG_MHAVOC) { sparkle = (firstwd & 0x0800); xflip = firstwd & 0x0400; /* Bank switch the vector ROM for Major Havoc */ vectorbank[1] = new _BytePtr(Mame.memory_region(Mame.REGION_CPU1), 0x18000 + ((firstwd & 0x300) >> 8) * 0x2000); } if (vectorEngine == USE_AVG_BZONE) { bz_col = color; if (color == 0) { Vector.vector_add_clip(xmin << VEC_SHIFT, BZONE_TOP << VEC_SHIFT, xmax << VEC_SHIFT, ymax << VEC_SHIFT); color = 2; } else { Vector.vector_add_clip(xmin << VEC_SHIFT, ymin << VEC_SHIFT, xmax << VEC_SHIFT, ymax << VEC_SHIFT); } } } #if VG_DEBUG if (errorlog) { fprintf (errorlog,"STAT: statz: %d color: %d", statz, color); if (xflip || sparkle) fprintf (errorlog, "xflip: %02x sparkle: %02x\n", xflip, sparkle); } #endif break; case SCAL: b = ((firstwd >> 8) & 0x07) + 8; l = (~firstwd) & 0xff; scale = (l << VEC_SHIFT) >> b; /* ASG 080497 */ /* Y-Window toggle for Major Havoc BW 980318 */ if (vectorEngine == USE_AVG_MHAVOC) { if ((firstwd & 0x0800) != 0) { Mame.printf("CLIP %d\n", firstwd & 0x0800); if (ywindow == 0) { ywindow = 1; Vector.vector_add_clip(xmin << VEC_SHIFT, MHAVOC_YWINDOW << VEC_SHIFT, xmax << VEC_SHIFT, ymax << VEC_SHIFT); } else { ywindow = 0; Vector.vector_add_clip(xmin << VEC_SHIFT, ymin << VEC_SHIFT, xmax << VEC_SHIFT, ymax << VEC_SHIFT); } } } #if VG_DEBUG if (errorlog) { fprintf (errorlog,"bin: %d, lin: ", b); if (l > 0x80) fprintf (errorlog,"(%d?)", l); else fprintf (errorlog,"%d", l); fprintf (errorlog," scale: %f", (scale/(float)(1<<VEC_SHIFT))); } #endif break; case CNTR: d = firstwd & 0xff; #if VG_DEBUG if (errorlog && (d != 0x40)) fprintf (errorlog,"%d", d); #endif currentx = xcenter; /* ASG 080497 */ /*.ac JAN2498 */ currenty = ycenter; /* ASG 080497 */ /*.ac JAN2498 */ Vector.vector_add_point(currentx, currenty, 0, 0); break; case RTSL: #if VG_DEBUG if (errorlog && ((firstwd & 0x1fff) != 0)) fprintf (errorlog,"(%d?)", firstwd & 0x1fff); #endif if (sp == 0) { Mame.printf("\n*** Vector generator stack underflow! ***\n"); done = true; sp = MAXSTACK - 1; } else sp--; pc = stack[sp]; break; case HALT: #if VG_DEBUG if (errorlog && ((firstwd & 0x1fff) != 0)) fprintf (errorlog,"(%d?)", firstwd & 0x1fff); #endif done = true; break; case JMPL: a = firstwd & 0x1fff; #if VG_DEBUG if (errorlog) fprintf (errorlog,"%4x", map_addr(a)); #endif /* if a = 0x0000, treat as HALT */ if (a == 0x0000) done = true; else pc = a; break; case JSRL: a = firstwd & 0x1fff; #if VG_DEBUG if (errorlog) fprintf (errorlog,"%4x", map_addr(a)); #endif /* if a = 0x0000, treat as HALT */ if (a == 0x0000) done = true; else { stack[sp] = pc; if (sp == (MAXSTACK - 1)) { Mame.printf("\n*** Vector generator stack overflow! ***\n"); done = true; sp = 0; } else sp++; pc = a; } break; default: Mame.printf("internal error\n"); break; } #if VG_DEBUG if (errorlog) fprintf (errorlog,"\n"); #endif } }
static void blockmove_pen_table_flipx16(_BytePtr srcdata, int srcwidth, int srcheight, int srcmodulo, _ShortPtr dstdata, int dstmodulo, UShortSubArray paldata, int transcolor) { throw new Exception(); }
static void blockmove_opaque_flipx16(_BytePtr srcdata, int srcwidth, int srcheight, int srcmodulo, _ShortPtr dstdata, int dstmodulo, UShortSubArray paldata) { throw new Exception(); }
static void drawgfx_core16(osd_bitmap dest, GfxElement gfx, uint code, uint color, bool flipx, bool flipy, int sx, int sy, rectangle clip, int transparency, int transparent_color) { int ox; int oy; int ex; int ey; /* check bounds */ ox = sx; oy = sy; ex = sx + gfx.width - 1; if (sx < 0) sx = 0; if (clip != null && sx < clip.min_x) sx = clip.min_x; if (ex >= dest.width) ex = dest.width - 1; if (clip != null && ex > clip.max_x) ex = clip.max_x; if (sx > ex) return; ey = sy + gfx.height - 1; if (sy < 0) sy = 0; if (clip != null && sy < clip.min_y) sy = clip.min_y; if (ey >= dest.height) ey = dest.height - 1; if (clip != null && ey > clip.max_y) ey = clip.max_y; if (sy > ey) return; osd_mark_dirty(sx, sy, ex, ey, 0); /* ASG 971011 */ { _BytePtr sd = new _BytePtr(gfx.gfxdata, (int)(code * gfx.char_modulo)); /* source data */ int sw = ex - sx + 1; /* source width */ int sh = ey - sy + 1; /* source height */ int sm = gfx.line_modulo; /* source modulo */ _ShortPtr dd = new _ShortPtr(dest.line[sy], sx); /* dest data */ int dm = dest.line[1].offset - dest.line[0].offset; /* dest modulo */ UShortSubArray paldata = new UShortSubArray(gfx.colortable, (int)((gfx.color_granularity * color))); if (flipx) { sd.offset += gfx.width - 1 - (sx - ox); } else sd.offset += (sx - ox); if (flipy) { sd.offset += sm * (gfx.height - 1 - (sy - oy)); sm = -sm; } else sd.offset += sm * (sy - oy); switch (transparency) { case TRANSPARENCY_NONE: if (flipx) blockmove_opaque_flipx16(sd, sw, sh, sm, dd, dm, paldata); else blockmove_opaque16(sd, sw, sh, sm, dd, dm, paldata); break; case TRANSPARENCY_PEN: if (flipx) blockmove_transpen_flipx16(sd, sw, sh, sm, dd, dm, paldata, transparent_color); else blockmove_transpen16(sd, sw, sh, sm, dd, dm, paldata, transparent_color); break; case TRANSPARENCY_PENS: if (flipx) blockmove_transmask_flipx16(sd, sw, sh, sm, dd, dm, paldata, transparent_color); else blockmove_transmask16(sd, sw, sh, sm, dd, dm, paldata, transparent_color); break; case TRANSPARENCY_COLOR: if (flipx) blockmove_transcolor_flipx16(sd, sw, sh, sm, dd, dm, paldata, transparent_color); else blockmove_transcolor16(sd, sw, sh, sm, dd, dm, paldata, transparent_color); break; case TRANSPARENCY_THROUGH: if (flipx) blockmove_transthrough_flipx16(sd, sw, sh, sm, dd, dm, paldata, transparent_color); else blockmove_transthrough16(sd, sw, sh, sm, dd, dm, paldata, transparent_color); break; case TRANSPARENCY_PEN_TABLE: if (flipx) blockmove_pen_table_flipx16(sd, sw, sh, sm, dd, dm, paldata, transparent_color); else blockmove_pen_table16(sd, sw, sh, sm, dd, dm, paldata, transparent_color); break; } } }
static void blockmove_transcolor_flipx8(_BytePtr srcdata, int srcwidth, int srcheight, int srcmodulo, _BytePtr dstdata, int dstmodulo, UShortSubArray paldata, int transcolor) { FuncDict["blockmove_transcolor_flipx8"] = "blockmove_transcolor_flipx8"; int end; int offset = paldata.offset; int length = Machine.game_colortable.Length - offset; ArraySegment<ushort> lookupdata = new ArraySegment<ushort>(Machine.game_colortable, offset, length); srcmodulo += srcwidth; dstmodulo -= srcwidth; //srcdata += srcwidth-1; while (srcheight != 0) { end = (int)(dstdata.offset + srcwidth); while (dstdata.offset < end) { if (lookupdata.Array[lookupdata.Offset+srcdata.buffer[srcdata.offset]] != transcolor) dstdata.buffer[dstdata.offset] = (byte)paldata[srcdata.buffer[srcdata.offset]]; srcdata.offset--; dstdata.offset++; } srcdata.offset += srcmodulo; dstdata.offset += dstmodulo; srcheight--; } }
static void write_dword(_BytePtr address, int data) { if ((address.offset & 3) != 0) { #if WINDOWS address[0] = (byte)data; address[1] = (byte)(data >> 8); address[2] = (byte)(data >> 16); address[3] = (byte)(data >> 24); #else *((unsigned char *)address+3) = data; *((unsigned char *)address+2) = (data >> 8); *((unsigned char *)address+1) = (data >> 16); *((unsigned char *)address) = (data >> 24); #endif return; } else address.write32(0, (uint)data); }
static void blockmove_opaque_noremap_flipx8(_BytePtr srcdata, int srcwidth, int srcheight, int srcmodulo, _BytePtr dstdata, int dstmodulo) { FuncDict["blockmove_opaque_noremap_flipx8"] = "blockmove_opaque_noremap_flipx8"; uint end; srcmodulo += srcwidth; dstmodulo -= srcwidth; //srcdata += srcwidth-1; while (srcheight != 0) { end = (uint)(dstdata.offset + srcwidth); while (dstdata.offset <= end - 8) { srcdata.offset -= 8; dstdata[0] = srcdata[8]; dstdata[1] = srcdata[7]; dstdata[2] = srcdata[6]; dstdata[3] = srcdata[5]; dstdata[4] = srcdata[4]; dstdata[5] = srcdata[3]; dstdata[6] = srcdata[2]; dstdata[7] = srcdata[1]; dstdata.offset += 8; } while (dstdata.offset < end) { dstdata[0] = srcdata[0]; dstdata.offset++; srcdata.offset--; } srcdata.offset += srcmodulo; dstdata.offset += dstmodulo; srcheight--; } }
static void blockmove_opaque_noremap8(_BytePtr srcdata, int srcwidth, int srcheight, int srcmodulo, _BytePtr dstdata, int dstmodulo) { FuncDict["blockmove_opaque_noremap8"] = "blockmove_opaque_noremap8"; while (srcheight != 0) { Buffer.BlockCopy(srcdata.buffer, (int)srcdata.offset, dstdata.buffer, (int)dstdata.offset, srcwidth); //memcpy(dstdata,srcdata,srcwidth * sizeof(UINT8)); srcdata.offset += srcmodulo; dstdata.offset += dstmodulo; srcheight--; } }
static void copybitmap_core8(osd_bitmap dest, osd_bitmap src, bool flipx, bool flipy, int sx, int sy, rectangle clip, int transparency, int transparent_color) { FuncDict["copybitmap_core8"] = "copybitmap_core8"; int ox; int oy; int ex; int ey; /* check bounds */ ox = sx; oy = sy; ex = sx + src.width - 1; if (sx < 0) sx = 0; if (clip != null && sx < clip.min_x) sx = clip.min_x; if (ex >= dest.width) ex = dest.width - 1; if (clip != null && ex > clip.max_x) ex = clip.max_x; if (sx > ex) return; ey = sy + src.height - 1; if (sy < 0) sy = 0; if (clip != null && sy < clip.min_y) sy = clip.min_y; if (ey >= dest.height) ey = dest.height - 1; if (clip != null && ey > clip.max_y) ey = clip.max_y; if (sy > ey) return; _BytePtr sd = new _BytePtr(src.line[0]); /* source data */ int sw = ex - sx + 1; /* source width */ int sh = ey - sy + 1; /* source height */ int sm = (int)(src.line[1].offset - src.line[0].offset); /* source modulo */ _BytePtr dd = new _BytePtr(dest.line[sy], sx); /* dest data */ int dm = (int)(dest.line[1].offset - dest.line[0].offset); /* dest modulo */ if (flipx) { sd.offset += src.width - 1 - (sx - ox); } else sd.offset += (sx - ox); if (flipy) { sd.offset += sm * (src.height - 1 - (sy - oy)); sm = -sm; } else sd.offset += (sm * (sy - oy)); switch (transparency) { case TRANSPARENCY_NONE: if (flipx) blockmove_opaque_noremap_flipx8(sd, sw, sh, sm, dd, dm); else blockmove_opaque_noremap8(sd, sw, sh, sm, dd, dm); break; case TRANSPARENCY_PEN: case TRANSPARENCY_COLOR: if (flipx) blockmove_transpen_noremap_flipx8(sd, sw, sh, sm, dd, dm, transparent_color); else blockmove_transpen_noremap8(sd, sw, sh, sm, dd, dm, transparent_color); break; case TRANSPARENCY_THROUGH: if (flipx) blockmove_transthrough_noremap_flipx8(sd, sw, sh, sm, dd, dm, transparent_color); else blockmove_transthrough_noremap8(sd, sw, sh, sm, dd, dm, transparent_color); break; } }
public uint color_table_len; /* length in shorts of the color lookup table */ public abstract void vh_init_palette(byte[] palette, ushort[] colortable, _BytePtr color_prom);
static void blockmove_transpen_flipx8(_BytePtr srcdata, int srcwidth, int srcheight, int srcmodulo, _BytePtr dstdata, int dstmodulo, UShortSubArray paldata, int transpen) { FuncDict["blockmove_transpen_flipx8"] = "blockmove_transpen_flipx8"; int end; _IntPtr sd4 = new _IntPtr(srcdata); srcmodulo += srcwidth; dstmodulo -= srcwidth; srcdata.offset -= 3; int trans4 = transpen * 0x01010101; while (srcheight != 0) { end = dstdata.offset + srcwidth; while ((srcdata.offset & 3) != 0 && dstdata.offset < end) /* longword align */ { int col = srcdata[3]; srcdata.offset--; if (col != transpen) dstdata[0] = (byte)paldata[col]; dstdata.offset++; } sd4.offset = srcdata.offset; while (dstdata.offset <= end - 4) { uint col4; if ((col4 = sd4.read32(0)) != trans4) { uint xod4 = (uint)(col4 ^ trans4); if ((xod4 & 0xff000000) != 0) dstdata[BL0] = (byte)paldata[(int)col4 >> 24]; if ((xod4 & 0x00ff0000) != 0) dstdata[BL1] = (byte)paldata[(int)(col4 >> 16) & 0xff]; if ((xod4 & 0x0000ff00) != 0) dstdata[BL2] = (byte)paldata[(int)(col4 >> 8) & 0xff]; if ((xod4 & 0x000000ff) != 0) dstdata[BL3] = (byte)paldata[((int)col4 & 0xff)]; } sd4.offset -= 4; dstdata.offset += 4; } srcdata.offset = sd4.offset; while (dstdata.offset < end) { int col = srcdata[3]; srcdata.offset--; if (col != transpen) dstdata[0] = (byte)paldata[col]; dstdata.offset++; } srcdata.offset += srcmodulo; dstdata.offset += dstmodulo; srcheight--; } }
static void blockmove_transmask8(_BytePtr srcdata, int srcwidth, int srcheight, int srcmodulo, _BytePtr dstdata, int dstmodulo, UShortSubArray paldata, int transmask) { int end; _IntPtr sd4; srcmodulo -= srcwidth; dstmodulo -= srcwidth; while (srcheight != 0) { end = dstdata.offset + srcwidth; while (((long)srcdata.offset & 3) != 0 && dstdata.offset < end) /* longword align */ { int col; col = srcdata[0]; srcdata.offset++; if (((1 << col) & transmask) == 0) dstdata[0] = (byte)paldata[col]; dstdata.offset++; } sd4 = new _IntPtr(srcdata); while (dstdata.offset <= end - 4) { int col; uint col4; col4 = sd4.read32(0); sd4.offset += 4; col = (int)((col4 >> 0) & 0xff); if (((1 << col) & transmask) == 0) dstdata[BL0] = (byte)paldata[col]; col = (int)((col4 >> 8) & 0xff); if (((1 << col) & transmask) == 0) dstdata[BL1] = (byte)paldata[col]; col = (int)((col4 >> 16) & 0xff); if (((1 << col) & transmask) == 0) dstdata[BL2] = (byte)paldata[col]; col = (int)((col4 >> 24) & 0xff); if (((1 << col) & transmask) == 0) dstdata[BL3] = (byte)paldata[col]; dstdata.offset += 4; } srcdata = new _BytePtr(sd4); while (dstdata.offset < end) { int col; col = srcdata[0]; srcdata.offset++; if (((1 << col) & transmask) == 0) dstdata[0] = (byte)paldata[col]; dstdata.offset++; } srcdata.offset += srcmodulo; dstdata.offset += dstmodulo; srcheight--; } }
static void blockmove_transpen_noremap8(_BytePtr srcdata, int srcwidth, int srcheight, int srcmodulo, _BytePtr dstdata, int dstmodulo, int transpen) { FuncDict["blockmove_transpen_noremap8"] = "blockmove_transpen_noremap8"; int end; int trans4; _IntPtr sd4; srcmodulo -= srcwidth; dstmodulo -= srcwidth; trans4 = transpen * 0x01010101; while (srcheight != 0) { end = dstdata.offset + srcwidth; while ((srcdata.offset & 3) != 0 && dstdata.offset < end) /* longword align */ { int col = srcdata[0]; srcdata.offset++; if (col != transpen) dstdata[0] = (byte)col; dstdata.offset++; } sd4 = new _IntPtr(srcdata); while (dstdata.offset <= end - 4) { uint col4; if ((col4 = sd4.read32(0)) != trans4) { uint xod4; xod4 = (uint)(col4 ^ trans4); if ((xod4 & 0x000000ff) != 0 && (xod4 & 0x0000ff00) != 0 && (xod4 & 0x00ff0000) != 0 && (xod4 & 0xff000000) != 0) { //dstdata.write32(0, col4); write_dword(dstdata, (int)col4); } else { if ((xod4 & 0xff000000) != 0) dstdata[BL3] = (byte)(col4 >> 24); if ((xod4 & 0x00ff0000) != 0) dstdata[BL2] = (byte)(col4 >> 16); if ((xod4 & 0x0000ff00) != 0) dstdata[BL1] = (byte)(col4 >> 8); if ((xod4 & 0x000000ff) != 0) dstdata[BL0] = (byte)(col4); } } sd4.offset += 4; dstdata.offset += 4; } srcdata = new _BytePtr(sd4); while (dstdata.offset < end) { int col = srcdata[0]; srcdata.offset++; if (col != transpen) dstdata[0] = (byte)col; dstdata.offset++; } srcdata.offset += srcmodulo; dstdata.offset += dstmodulo; srcheight--; } }
static void blockmove_transthrough_flipx8(_BytePtr srcdata, int srcwidth, int srcheight, int srcmodulo, _BytePtr dstdata, int dstmodulo, UShortSubArray paldata, int transcolor) { FuncDict["blockmove_transthrough_flipx8"] = "blockmove_transthrough_flipx8"; int end; srcmodulo += srcwidth; dstmodulo -= srcwidth; //srcdata += srcwidth-1; while (srcheight != 0) { end = dstdata.offset + srcwidth; while (dstdata.offset < end) { if (dstdata[0] == transcolor) dstdata[0] = (byte)paldata[srcdata[0]]; srcdata.offset--; dstdata.offset++; } srcdata.offset += srcmodulo; dstdata.offset += dstmodulo; srcheight--; } }
static void blockmove_transthrough_noremap_flipx8(_BytePtr srcdata, int srcwidth, int srcheight, int srcmodulo, _BytePtr dstdata, int dstmodulo, int transthrough) { throw new Exception(); }
static void blockmove_opaque16(_BytePtr srcdata, int srcwidth, int srcheight, int srcmodulo, _ShortPtr dstdata, int dstmodulo, UShortSubArray paldata) { //blockmove_opaque8(srcdata, srcwidth, srcheight, srcmodulo, (_BytePtr)dstdata, dstmodulo, paldata); //return; int end; srcmodulo -= srcwidth; dstmodulo -= srcwidth; while (srcheight != 0) { end = dstdata.offset + srcwidth; while (dstdata.offset <= end - 8) { dstdata.write16(0, paldata[srcdata[0]]); dstdata.write16(1, paldata[srcdata[1]]); dstdata.write16(2, paldata[srcdata[2]]); dstdata.write16(3, paldata[srcdata[3]]); dstdata.write16(4, paldata[srcdata[4]]); dstdata.write16(5, paldata[srcdata[5]]); dstdata.write16(6, paldata[srcdata[6]]); dstdata.write16(7, paldata[srcdata[7]]); dstdata.offset += 8 * 2; srcdata.offset++; } while (dstdata.offset < end) { dstdata.write16(0, paldata[srcdata[0]]); srcdata.offset++; dstdata.offset += 2; } srcdata.inc(srcmodulo); dstdata.inc(dstmodulo); srcheight--; } }
public static void drawgfxzoom(osd_bitmap dest_bmp, GfxElement gfx, uint code, uint color, bool flipx, bool flipy, int sx, int sy, rectangle clip, int transparency, int transparent_color, int scalex, int scaley) { FuncDict["drawgfxzoom"] = "drawgfxzoom"; rectangle myclip = new rectangle(); /* only support TRANSPARENCY_PEN and TRANSPARENCY_COLOR */ if (transparency != TRANSPARENCY_PEN && transparency != TRANSPARENCY_COLOR) return; if (transparency == TRANSPARENCY_COLOR) transparent_color = Machine.pens[transparent_color]; /* scalex and scaley are 16.16 fixed point numbers 1<<15 : shrink to 50% 1<<16 : uniform scale 1<<17 : double to 200% */ if ((Machine.orientation & ORIENTATION_SWAP_XY) != 0) { int temp; temp = sx; sx = sy; sy = temp; var tempb = flipx; flipx = flipy; flipy = tempb; temp = scalex; scalex = scaley; scaley = temp; if (clip != null) { /* clip and myclip might be the same, so we need a temporary storage */ temp = clip.min_x; myclip.min_x = clip.min_y; myclip.min_y = temp; temp = clip.max_x; myclip.max_x = clip.max_y; myclip.max_y = temp; clip = myclip; } } if ((Machine.orientation & ORIENTATION_FLIP_X) != 0) { sx = dest_bmp.width - ((gfx.width * scalex + 0x7fff) >> 16) - sx; if (clip != null) { int temp; /* clip and myclip might be the same, so we need a temporary storage */ temp = clip.min_x; myclip.min_x = dest_bmp.width - 1 - clip.max_x; myclip.max_x = dest_bmp.width - 1 - temp; myclip.min_y = clip.min_y; myclip.max_y = clip.max_y; clip = myclip; } #if !PREROTATE_GFX flipx = !flipx; #endif } if ((Machine.orientation & ORIENTATION_FLIP_Y) != 0) { sy = dest_bmp.height - ((gfx.height * scaley + 0x7fff) >> 16) - sy; if (clip != null) { int temp; myclip.min_x = clip.min_x; myclip.max_x = clip.max_x; /* clip and myclip might be the same, so we need a temporary storage */ temp = clip.min_y; myclip.min_y = dest_bmp.height - 1 - clip.max_y; myclip.max_y = dest_bmp.height - 1 - temp; clip = myclip; } #if !PREROTATE_GFX flipy = !flipy; #endif } /* KW 991012 -- Added code to force clip to bitmap boundary */ if (clip != null) { myclip.min_x = clip.min_x; myclip.max_x = clip.max_x; myclip.min_y = clip.min_y; myclip.max_y = clip.max_y; if (myclip.min_x < 0) myclip.min_x = 0; if (myclip.max_x >= dest_bmp.width) myclip.max_x = dest_bmp.width - 1; if (myclip.min_y < 0) myclip.min_y = 0; if (myclip.max_y >= dest_bmp.height) myclip.max_y = dest_bmp.height - 1; clip = myclip; } /* ASG 980209 -- added 16-bit version */ if (dest_bmp.depth != 16) { if (gfx != null && gfx.colortable != null) { UShortSubArray pal = new UShortSubArray(gfx.colortable, (int)(gfx.color_granularity * (color % gfx.total_colors))); /* ASG 980209 */ int source_base = (int)((code % gfx.total_elements) * gfx.height); int sprite_screen_height = (scaley * gfx.height + 0x8000) >> 16; int sprite_screen_width = (scalex * gfx.width + 0x8000) >> 16; /* compute sprite increment per screen pixel */ int dx = (gfx.width << 16) / sprite_screen_width; int dy = (gfx.height << 16) / sprite_screen_height; int ex = sx + sprite_screen_width; int ey = sy + sprite_screen_height; int x_index_base; int y_index; if (flipx) { x_index_base = (sprite_screen_width - 1) * dx; dx = -dx; } else { x_index_base = 0; } if (flipy) { y_index = (sprite_screen_height - 1) * dy; dy = -dy; } else { y_index = 0; } if (clip != null) { if (sx < clip.min_x) { /* clip left */ int pixels = clip.min_x - sx; sx += pixels; x_index_base += pixels * dx; } if (sy < clip.min_y) { /* clip top */ int pixels = clip.min_y - sy; sy += pixels; y_index += pixels * dy; } /* NS 980211 - fixed incorrect clipping */ if (ex > clip.max_x + 1) { /* clip right */ int pixels = ex - clip.max_x - 1; ex -= pixels; } if (ey > clip.max_y + 1) { /* clip bottom */ int pixels = ey - clip.max_y - 1; ey -= pixels; } } if (ex > sx) { /* skip if inner loop doesn't draw anything */ int y; /* case 1: TRANSPARENCY_PEN */ if (transparency == TRANSPARENCY_PEN) { for (y = sy; y < ey; y++) { _BytePtr source = new _BytePtr(gfx.gfxdata, (source_base + (y_index >> 16)) * gfx.line_modulo); _BytePtr dest = dest_bmp.line[y]; int x, x_index = x_index_base; for (x = sx; x < ex; x++) { int c = source[x_index >> 16]; if (c != transparent_color) dest[x] = (byte)pal[c]; x_index += dx; } y_index += dy; } } /* case 2: TRANSPARENCY_COLOR */ else if (transparency == TRANSPARENCY_COLOR) { for (y = sy; y < ey; y++) { _BytePtr source = new _BytePtr(gfx.gfxdata, (source_base + (y_index >> 16)) * gfx.line_modulo); _BytePtr dest = dest_bmp.line[y]; int x, x_index = x_index_base; for (x = sx; x < ex; x++) { int c = pal[source[x_index >> 16]]; if (c != transparent_color) dest[x] = (byte)c; x_index += dx; } y_index += dy; } } } } } /* ASG 980209 -- new 16-bit part */ else { if (gfx != null && gfx.colortable != null) { UShortSubArray pal = new UShortSubArray(gfx.colortable, (int)(gfx.color_granularity * (color % gfx.total_colors))); /* ASG 980209 */ int source_base = (int)((code % gfx.total_elements) * gfx.height); int sprite_screen_height = (scaley * gfx.height + 0x8000) >> 16; int sprite_screen_width = (scalex * gfx.width + 0x8000) >> 16; /* compute sprite increment per screen pixel */ int dx = (gfx.width << 16) / sprite_screen_width; int dy = (gfx.height << 16) / sprite_screen_height; int ex = sx + sprite_screen_width; int ey = sy + sprite_screen_height; int x_index_base; int y_index; if (flipx) { x_index_base = (sprite_screen_width - 1) * dx; dx = -dx; } else { x_index_base = 0; } if (flipy) { y_index = (sprite_screen_height - 1) * dy; dy = -dy; } else { y_index = 0; } if (clip != null) { if (sx < clip.min_x) { /* clip left */ int pixels = clip.min_x - sx; sx += pixels; x_index_base += pixels * dx; } if (sy < clip.min_y) { /* clip top */ int pixels = clip.min_y - sy; sy += pixels; y_index += pixels * dy; } /* NS 980211 - fixed incorrect clipping */ if (ex > clip.max_x + 1) { /* clip right */ int pixels = ex - clip.max_x - 1; ex -= pixels; } if (ey > clip.max_y + 1) { /* clip bottom */ int pixels = ey - clip.max_y - 1; ey -= pixels; } } if (ex > sx) { /* skip if inner loop doesn't draw anything */ int y; /* case 1: TRANSPARENCY_PEN */ if (transparency == TRANSPARENCY_PEN) { for (y = sy; y < ey; y++) { _BytePtr source = new _BytePtr(gfx.gfxdata, (source_base + (y_index >> 16)) * gfx.line_modulo); _ShortPtr dest = new _ShortPtr(dest_bmp.line[y]); int x, x_index = x_index_base; for (x = sx; x < ex; x++) { int c = source[x_index >> 16]; if (c != transparent_color) dest[x] = (byte)pal[c]; x_index += dx; } y_index += dy; } } /* case 2: TRANSPARENCY_COLOR */ else if (transparency == TRANSPARENCY_COLOR) { for (y = sy; y < ey; y++) { _BytePtr source = new _BytePtr(gfx.gfxdata, (source_base + (y_index >> 16)) * gfx.line_modulo); _ShortPtr dest = new _ShortPtr(dest_bmp.line[y]); int x, x_index = x_index_base; for (x = sx; x < ex; x++) { int c = pal[source[x_index >> 16]]; if (c != transparent_color) dest.write16(x, (ushort)c); x_index += dx; } y_index += dy; } } } } } }
static void blockmove_transmask16(_BytePtr srcdata, int srcwidth, int srcheight, int srcmodulo, _ShortPtr dstdata, int dstmodulo, UShortSubArray paldata, int transmask) { throw new Exception(); }
static int readbit(_BytePtr src, int bitnum) { return (src[bitnum / 8] >> (7 - bitnum % 8)) & 1; }
public static void avg_init_palette_white(byte[] palette, ushort[] colortable, _BytePtr color_prom) { avg_init_palette(VEC_PAL_WHITE, palette, colortable, color_prom); }
public static void decodechar(GfxElement gfx, int num, _BytePtr src, GfxLayout gl) { int plane, x, y; _BytePtr dp; int offs; offs = num * gl.charincrement; dp = new _BytePtr(gfx.gfxdata, (num * gfx.char_modulo)); for (y = 0; y < gfx.height; y++) { int yoffs; yoffs = y; #if PREROTATE_GFX if ((Machine.orientation & ORIENTATION_FLIP_Y)!=0) yoffs = gfx.height-1 - yoffs; #endif for (x = 0; x < gfx.width; x++) { int xoffs; xoffs = x; #if PREROTATE_GFX if ((Machine.orientation & ORIENTATION_FLIP_X)!=0) xoffs = gfx.width-1 - xoffs; #endif dp[x] = 0; if ((Machine.orientation & ORIENTATION_SWAP_XY) != 0) { for (plane = 0; plane < gl.planes; plane++) { if (readbit(src, (int)(offs + gl.planeoffset[plane] + gl.yoffset[xoffs] + gl.xoffset[yoffs])) != 0) dp[x] |= (byte)((1 << (gl.planes - 1 - plane))); } } else { for (plane = 0; plane < gl.planes; plane++) { if (readbit(src, (int)(offs + gl.planeoffset[plane] + gl.yoffset[yoffs] + gl.xoffset[xoffs])) != 0) dp[x] |= (byte)(1 << (gl.planes - 1 - plane)); } } } dp.offset += gfx.line_modulo; } if (gfx.pen_usage != null) { /* fill the pen_usage array with info on the used pens */ gfx.pen_usage[num] = 0; dp = new _BytePtr(gfx.gfxdata, (num * gfx.char_modulo)); for (y = 0; y < gfx.height; y++) { for (x = 0; x < gfx.width; x++) { gfx.pen_usage[num] = (uint)(gfx.pen_usage[num] | (1 << dp[x])); } dp.offset += gfx.line_modulo; } } }
public static void avg_init_palette(int paltype, byte[] palette, ushort[] colortable, _BytePtr color_prom) { int i, j, k; int[] trcl1 = { 0, 0, 2, 2, 1, 1 }; int[] trcl2 = { 1, 2, 0, 1, 0, 2 }; int[] trcl3 = { 2, 1, 1, 0, 2, 0 }; /* initialize the first 8 colors with the basic colors */ /* Only these are selected by writes to the colorram. */ for (i = 0; i < 8; i++) { palette[3 * i] = (byte)((i & RED) != 0 ? 0xff : 0); palette[3 * i + 1] = (byte)((i & GREEN) != 0 ? 0xff : 0); palette[3 * i + 2] = (byte)((i & BLUE) != 0 ? 0xff : 0); } /* initialize the colorram */ for (i = 0; i < 16; i++) colorram[i] = i & 0x07; /* fill the rest of the 256 color entries depending on the game */ switch (paltype) { /* Black and White vector colors (Asteroids,Omega Race) .ac JAN2498 */ case VEC_PAL_WHITE: shade_fill(palette, RED | GREEN | BLUE, 8, 128 + 8, 0, 255); colorram[1] = 7; /* BW games use only color 1 (== white) */ break; /* Monochrome Aqua colors (Asteroids Deluxe,Red Baron) .ac JAN2498 */ case VEC_PAL_ASTDELUX: /* Use backdrop if present MLR OCT0598 */ if ((backdrop = Mame.artwork_load("astdelux.png", 32, (int)(Mame.Machine.drv.total_colors - 32))) != null) { shade_fill(palette, GREEN | BLUE, 8, 23, 1, 254); /* Some more anti-aliasing colors. */ shade_fill(palette, GREEN | BLUE, 24, 31, 1, 254); for (i = 0; i < 8; i++) palette[(24 + i) * 3] = 80; for (i = 0; i < 3 * backdrop.num_pens_used; i++) palette[i + 3 * backdrop.start_pen] = backdrop.orig_palette[i]; //memcpy (palette+3*backdrop.start_pen, backdrop.orig_palette,3*backdrop.num_pens_used); } else shade_fill(palette, GREEN | BLUE, 8, 128 + 8, 1, 254); colorram[1] = 3; /* for Asteroids */ break; case VEC_PAL_AQUA: shade_fill(palette, GREEN | BLUE, 8, 128 + 8, 1, 254); colorram[0] = 3; /* for Red Baron */ break; /* Monochrome Green/Red vector colors (Battlezone) .ac JAN2498 */ case VEC_PAL_BZONE: shade_fill(palette, RED, 8, 23, 1, 254); shade_fill(palette, GREEN, 24, 31, 1, 254); shade_fill(palette, WHITE, 32, 47, 1, 254); /* Use backdrop if present MLR OCT0598 */ if ((backdrop = Mame.artwork_load("bzone.png", 48, (int)(Mame.Machine.drv.total_colors - 48))) != null) for (i = 0; i < 3 * backdrop.num_pens_used; i++) palette[3 * backdrop.start_pen + i] = backdrop.orig_palette[i]; //memcpy (palette+3*backdrop.start_pen, backdrop.orig_palette, 3*backdrop.num_pens_used); break; /* Colored games (Major Havoc, Star Wars, Tempest) .ac JAN2498 */ case VEC_PAL_MULTI: case VEC_PAL_SWARS: /* put in 40 shades for red, blue and magenta */ shade_fill(palette, RED, 8, 47, 10, 250); shade_fill(palette, BLUE, 48, 87, 10, 250); shade_fill(palette, RED | BLUE, 88, 127, 10, 250); /* put in 20 shades for yellow and green */ shade_fill(palette, GREEN, 128, 147, 10, 250); shade_fill(palette, RED | GREEN, 148, 167, 10, 250); /* and 14 shades for cyan and white */ shade_fill(palette, BLUE | GREEN, 168, 181, 10, 250); shade_fill(palette, WHITE, 182, 194, 10, 250); /* Fill in unused gaps with more anti-aliasing colors. */ /* There are 60 slots available. .ac JAN2498 */ i = 195; for (j = 0; j < 6; j++) { for (k = 7; k <= 16; k++) { palette[3 * i + trcl1[j]] = (byte)(((256 * k) / 16) - 1); palette[3 * i + trcl2[j]] = (byte)(((128 * k) / 16) - 1); palette[3 * i + trcl3[j]] = 0; i++; } } break; default: Mame.printf("Wrong palette type in avgdvg.c"); break; } }
public static GfxElement decodegfx(_BytePtr src, GfxLayout gl) { int c; GfxElement gfx; if ((gfx = new GfxElement()) == null) return null; if ((Machine.orientation & ORIENTATION_SWAP_XY) != 0) { gfx.width = gl.height; gfx.height = gl.width; } else { gfx.width = gl.width; gfx.height = gl.height; } gfx.line_modulo = gfx.width; gfx.char_modulo = gfx.line_modulo * gfx.height; if ((gfx.gfxdata = new byte[gl.total * gfx.char_modulo]) == null) { gfx = null; return null; } gfx.total_elements = gl.total; gfx.color_granularity = 1 << gl.planes; gfx.pen_usage = null; /* need to make sure this is NULL if the next test fails) */ if (gfx.color_granularity <= 32) /* can't handle more than 32 pens */ gfx.pen_usage = new uint[gfx.total_elements]; /* no need to check for failure, the code can work without pen_usage */ for (c = 0; c < gl.total; c++) decodechar(gfx, c, src, gl); return gfx; }
public static int pacman_vh_convert_color_prom(byte[] palette, ushort[] colortable, _BytePtr color_prom) { int i; //#define TOTAL_COLORS(gfxn) (Machine.gfx[gfxn].total_colors * Machine.gfx[gfxn].color_granularity) //#define COLOR(gfxn,offs) (colortable[Machine.drv.gfxdecodeinfo[gfxn].color_codes_start + offs]) int cpi = 0; int pi = 0; for (i = 0; i < Mame.Machine.drv.total_colors; i++) { /* red component */ int bit0 = (color_prom[cpi] >> 0) & 0x01; int bit1 = (color_prom[cpi] >> 1) & 0x01; int bit2 = (color_prom[cpi] >> 2) & 0x01; palette[pi++] = (byte)(0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2); /* green component */ bit0 = (color_prom[cpi] >> 3) & 0x01; bit1 = (color_prom[cpi] >> 4) & 0x01; bit2 = (color_prom[cpi] >> 5) & 0x01; palette[pi++] =(byte)( 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2); /* blue component */ bit0 = 0; bit1 = (color_prom[cpi] >> 6) & 0x01; bit2 = (color_prom[cpi] >> 7) & 0x01; palette[pi++] = (byte)(0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2); cpi++; } cpi += 0x10; /* color_prom now points to the beginning of the lookup table */ /* character lookup table */ /* sprites use the same color lookup table as characters */ for (i = 0; i < Mame.Machine.gfx[0].total_colors * Mame.Machine.gfx[0].color_granularity; i++) colortable[Mame.Machine.drv.gfxdecodeinfo[0].color_codes_start + i]=(ushort)((color_prom[cpi++]) & 0x0f); return 0; }
static void blockmove_opaque_flipx8(_BytePtr srcdata, int srcwidth, int srcheight, int srcmodulo, _BytePtr dstdata, int dstmodulo, UShortSubArray paldata) { FuncDict["blockmove_opaque_flipx8"] = "blockmove_opaque_flipx8"; int end; srcmodulo += srcwidth; dstmodulo -= srcwidth; //srcdata += srcwidth-1; while (srcheight != 0) { end = (int)(dstdata.offset + srcwidth); while (dstdata.offset <= end - 8) { srcdata.offset = ((int)srcdata.offset - 8); dstdata.buffer[dstdata.offset] = (byte)paldata[srcdata.buffer[srcdata.offset + 8]]; dstdata.buffer[dstdata.offset + 1] = (byte)paldata[srcdata.buffer[srcdata.offset + 7]]; dstdata.buffer[dstdata.offset + 2] = (byte)paldata[srcdata.buffer[srcdata.offset + 6]]; dstdata.buffer[dstdata.offset + 3] = (byte)paldata[srcdata.buffer[srcdata.offset + 5]]; dstdata.buffer[dstdata.offset + 4] = (byte)paldata[srcdata.buffer[srcdata.offset + 4]]; dstdata.buffer[dstdata.offset + 5] = (byte)paldata[srcdata.buffer[srcdata.offset + 3]]; dstdata.buffer[dstdata.offset + 6] = (byte)paldata[srcdata.buffer[srcdata.offset + 2]]; dstdata.buffer[dstdata.offset + 7] = (byte)paldata[srcdata.buffer[srcdata.offset + 1]]; dstdata.offset += 8; } while (dstdata.offset < end) { dstdata.buffer[dstdata.offset] = (byte)paldata[srcdata.buffer[srcdata.offset]]; dstdata.offset++; srcdata.offset--; } srcdata.offset += srcmodulo; dstdata.offset += dstmodulo; srcheight--; } }