int namcos3d_Init( int width, int height, void *pTilemapROM, void *pTextureROM ) { int i; if( !gUseOpenGL ) { namco_zbuffer = auto_malloc( width*height*sizeof(*namco_zbuffer) ); } if( pTilemapROM && pTextureROM ) { /* following setup is Namco System 22 specific */ const UINT8 *pPackedTileAttr = 0x200000 + (UINT8 *)pTilemapROM; UINT8 *pUnpackedTileAttr = auto_malloc(0x080000*2); InitXYAttrToPixel(); mpTextureTileMapAttr = pUnpackedTileAttr; for( i=0; i<0x80000; i++ ) { *pUnpackedTileAttr++ = (*pPackedTileAttr)>>4; *pUnpackedTileAttr++ = (*pPackedTileAttr)&0xf; pPackedTileAttr++; } mpTextureTileMap16 = pTilemapROM; mpTextureTileData = pTextureROM; PatchTexture(); /* HACK! */ } return 0; }
static int bitbanger_init(mess_image *img) { int id = image_index_in_device(img); struct bitbanger_info *bi; const struct bitbanger_config *config; config = (const struct bitbanger_config *) device_find(Machine->devices, IO_BITBANGER)->user1; bi = (struct bitbanger_info *) auto_malloc(sizeof(struct bitbanger_info)); if (!bi) return INIT_FAIL; bi->pulses = (double *) auto_malloc(config->maximum_pulses * sizeof(double)); if (!bi->pulses) return INIT_FAIL; bi->factored_pulses = (int *) auto_malloc(config->maximum_pulses * sizeof(int)); if (!bi->factored_pulses) return INIT_FAIL; bi->config = config; bi->last_pulse_time = 0.0; bi->recorded_pulses = 0; bi->value = config->initial_value; bi->timeout_timer = timer_alloc(bitbanger_overthreshhold); bi->over_threshhold = 1; bitbangers[id] = bi; return INIT_PASS; }
ROM_END /***************************************************************************/ static DRIVER_INIT( apache3 ) { UINT8 *dst = memory_region(REGION_GFX1); UINT8 *src1 = memory_region(REGION_GFX2); UINT8 *src2 = memory_region(REGION_GFX3); int i; cpunum_set_input_line(3, INPUT_LINE_HALT, ASSERT_LINE); /* ? */ for (i=0; i<0x100000; i+=32) { memcpy(dst,src1,32); src1+=32; dst+=32; memcpy(dst,src2,32); dst+=32; src2+=32; } /* Copy sprite & palette data out of GFX rom area */ tatsumi_rom_sprite_lookup1=auto_malloc(0x4000); tatsumi_rom_sprite_lookup2=auto_malloc(0x4000); tatsumi_rom_clut0=auto_malloc(0x1000); tatsumi_rom_clut1=auto_malloc(0x1000); memcpy(tatsumi_rom_sprite_lookup1, memory_region(REGION_GFX2),0x4000); memcpy(tatsumi_rom_sprite_lookup2, memory_region(REGION_GFX3),0x4000); memcpy(tatsumi_rom_clut0, memory_region(REGION_GFX2)+0x100000-0x800,0x800); memcpy(tatsumi_rom_clut1, memory_region(REGION_GFX3)+0x100000-0x800,0x800); tatsumi_reset(); }
static void init_buffered_spriteram(void) { assert_always(spriteram_size != 0, "Video buffers spriteram but spriteram_size is 0"); /* allocate memory for the back buffer */ buffered_spriteram = auto_malloc(spriteram_size); /* register for saving it */ state_save_register_global_pointer(buffered_spriteram, spriteram_size); /* do the same for the secon back buffer, if present */ if (spriteram_2_size) { /* allocate memory */ buffered_spriteram_2 = auto_malloc(spriteram_2_size); /* register for saving it */ state_save_register_global_pointer(buffered_spriteram_2, spriteram_2_size); } /* make 16-bit and 32-bit pointer variants */ buffered_spriteram16 = (UINT16 *)buffered_spriteram; buffered_spriteram32 = (UINT32 *)buffered_spriteram; buffered_spriteram16_2 = (UINT16 *)buffered_spriteram_2; buffered_spriteram32_2 = (UINT32 *)buffered_spriteram_2; }
static DRIVER_INIT( roundup5 ) { UINT8 *dst = memory_region(REGION_GFX1); UINT8 *src1 = memory_region(REGION_GFX2); UINT8 *src2 = memory_region(REGION_GFX3); int i; for (i=0; i<0xc0000; i+=32) { memcpy(dst,src1,32); src1+=32; dst+=32; memcpy(dst,src2,32); dst+=32; src2+=32; } /* Copy sprite & palette data out of GFX rom area */ tatsumi_rom_sprite_lookup1=auto_malloc(0x4000); tatsumi_rom_sprite_lookup2=auto_malloc(0x4000); tatsumi_rom_clut0=auto_malloc(0x800); tatsumi_rom_clut1=auto_malloc(0x800); memcpy(tatsumi_rom_sprite_lookup1, memory_region(REGION_GFX2),0x4000); memcpy(tatsumi_rom_sprite_lookup2, memory_region(REGION_GFX3),0x4000); memcpy(tatsumi_rom_clut0, memory_region(REGION_GFX2)+0xc0000-0x800,0x800); memcpy(tatsumi_rom_clut1, memory_region(REGION_GFX3)+0xc0000-0x800,0x800); tatsumi_reset(); }
static DRIVER_INIT( cyclwarr ) { UINT8 *dst = memory_region(REGION_GFX1); UINT8 *src1 = memory_region(REGION_GFX2); UINT8 *src2 = memory_region(REGION_GFX3); int i; for (i=0; i<0x100000; i+=32) { memcpy(dst,src1,32); src1+=32; dst+=32; memcpy(dst,src2,32); dst+=32; src2+=32; } dst = memory_region(REGION_CPU1); memcpy(cyclwarr_cpua_ram,dst+0x100000,8); memory_set_bankptr(1, memory_region(REGION_CPU1) + 0x100000); dst = memory_region(REGION_CPU2); memcpy(cyclwarr_cpub_ram,dst+0x100000,8); memory_set_bankptr(2, memory_region(REGION_CPU2) + 0x100000); /* Copy sprite & palette data out of GFX rom area */ tatsumi_rom_sprite_lookup1=auto_malloc(0x4000); tatsumi_rom_sprite_lookup2=auto_malloc(0x4000); tatsumi_rom_clut0=auto_malloc(0x1000); tatsumi_rom_clut1=auto_malloc(0x1000); memcpy(tatsumi_rom_sprite_lookup1, memory_region(REGION_GFX2),0x4000); memcpy(tatsumi_rom_sprite_lookup2, memory_region(REGION_GFX3),0x4000); memcpy(tatsumi_rom_clut0, memory_region(REGION_GFX2)+0x100000-0x1000,0x1000); memcpy(tatsumi_rom_clut1, memory_region(REGION_GFX3)+0x100000-0x1000,0x1000); tatsumi_reset(); }
int ninjakd2_init_samples(const struct MachineSound *msound) { int i,n; unsigned char *source = memory_region(REGION_SOUND1); struct GameSamples *samples; int sample_info [9][2] = { {0x0000,0x0A00},{0x0A00,0x1D00},{0x2700,0x1700}, {0x3E00,0x1500},{0x5300,0x0B00},{0x5E00,0x0A00},{0x6800,0x0E00},{0x7600,0x1E00},{0xF000,0x0400} }; if ((Machine->samples = auto_malloc(sizeof(struct GameSamples) + 9 * sizeof(struct GameSample *))) == NULL) return 1; samples = Machine->samples; samples->total = 8; for (i=0;i<8;i++) { if ((samples->sample[i] = auto_malloc(sizeof(struct GameSample) + (sample_info[i][1]))) == NULL) return 1; samples->sample[i]->length = sample_info[i][1]; samples->sample[i]->smpfreq = 16000; /* 16 kHz */ samples->sample[i]->resolution = 8; for (n=0; n<sample_info[i][1]; n++) samples->sample[i]->data[n] = source[sample_info[i][0]+n] ^ 0x80; } /* The samples are now ready to be used. They are a 8 bit, 16 kHz samples. */ return 0; }
static int init_buffered_spriteram(void) { /* make sure we have a valid size */ if (spriteram_size == 0) { logerror("video_init(): Video buffers spriteram but spriteram_size is 0\n"); return 0; } /* allocate memory for the back buffer */ buffered_spriteram = auto_malloc(spriteram_size); /* register for saving it */ state_save_register_global_pointer(buffered_spriteram, spriteram_size); /* do the same for the secon back buffer, if present */ if (spriteram_2_size) { /* allocate memory */ buffered_spriteram_2 = auto_malloc(spriteram_2_size); /* register for saving it */ state_save_register_global_pointer(buffered_spriteram_2, spriteram_2_size); } /* make 16-bit and 32-bit pointer variants */ buffered_spriteram16 = (UINT16 *)buffered_spriteram; buffered_spriteram32 = (UINT32 *)buffered_spriteram; buffered_spriteram16_2 = (UINT16 *)buffered_spriteram_2; buffered_spriteram32_2 = (UINT32 *)buffered_spriteram_2; return 0; }
void at28c16_init( int chip, UINT8 *data, UINT8 *id ) { struct at28c16_chip *c; if( chip >= MAX_AT28C16_CHIPS ) { logerror( "at28c16_init: invalid chip %d\n", chip ); return; } c = &at28c16[ chip ]; c->a9_12v = 0; if( data == NULL ) { data = auto_malloc( SIZE_DATA ); } if( id == NULL ) { id = auto_malloc( SIZE_ID ); } c->data = data; c->id = id; state_save_register_item_pointer( "at28c16", chip, c->data, SIZE_DATA ); state_save_register_item_pointer( "at28c16", chip, c->id, SIZE_ID ); state_save_register_item( "at28c16", chip, c->a9_12v ); }
/* video_start_crt video init */ int video_start_crt(int num_levels, int offset_x, int offset_y, int width, int height) { int i; num_intensity_levels = num_levels; window_offset_x = offset_x; window_offset_y = offset_y; window_width = width; window_height = height; /* alloc the arrays */ list = auto_malloc(window_width * window_height * sizeof(point)); if (!list) return 1; list_head = auto_malloc(window_height * sizeof(int)); if (!list_head) return 1; /* fill with black and set up list as empty */ for (i=0; i<(window_width * window_height); i++) { list[i].intensity = intensity_pixel_not_in_list; } for (i=0; i<window_height; i++) list_head[i] = -1; decay_counter = 0; return 0; }
int jagobj_init(void) { int i; /* allocate memory for tables */ blend_y = auto_malloc(256 * 256); blend_cc = auto_malloc(256 * 256); /* fill tables */ for (i = 0; i < 256 * 256; i++) { int y = (i >> 8) & 0xff; int dy = (INT8)i; int c1 = (i >> 8) & 0x0f; int dc1 = (INT8)(i << 4) >> 4; int c2 = (i >> 12) & 0x0f; int dc2 = (INT8)(i & 0xf0) >> 4; y += dy; if (y < 0) y = 0; else if (y > 0xff) y = 0xff; blend_y[i] = y; c1 += dc1; if (c1 < 0) c1 = 0; else if (c1 > 0x0f) c1 = 0x0f; c2 += dc2; if (c2 < 0) c2 = 0; else if (c2 > 0x0f) c2 = 0x0f; blend_cc[i] = (c2 << 4) | c1; } return 0; }
int sound_init(running_machine *machine) { /* handle -nosound */ nosound_mode = (Machine->sample_rate == 0); if (nosound_mode) Machine->sample_rate = 11025; /* count the speakers */ for (totalspeakers = 0; Machine->drv->speaker[totalspeakers].tag; totalspeakers++) ; VPRINTF(("total speakers = %d\n", totalspeakers)); /* initialize the OSD layer */ VPRINTF(("osd_start_audio_stream\n")); samples_this_frame = osd_start_audio_stream(1); if (!samples_this_frame) return 1; /* allocate memory for mix buffers */ leftmix = auto_malloc(Machine->sample_rate * sizeof(*leftmix)); rightmix = auto_malloc(Machine->sample_rate * sizeof(*rightmix)); finalmix = auto_malloc(Machine->sample_rate * sizeof(*finalmix)); /* allocate a global timer for sound timing */ sound_update_timer = mame_timer_alloc(NULL); /* initialize the streams engine */ VPRINTF(("streams_init\n")); streams_init(); /* now start up the sound chips and tag their streams */ VPRINTF(("start_sound_chips\n")); if (start_sound_chips()) return 1; /* then create all the speakers */ VPRINTF(("start_speakers\n")); if (start_speakers()) return 1; /* finally, do all the routing */ VPRINTF(("route_sound\n")); if (route_sound()) return 1; if (MAKE_WAVS) wavfile = wav_open("finalmix.wav", Machine->sample_rate, 2); /* enable sound by default */ global_sound_enabled = TRUE; /* register callbacks */ config_register("mixer", sound_load, sound_save); add_pause_callback(machine, sound_pause); add_reset_callback(machine, sound_reset); add_exit_callback(machine, sound_exit); return 0; }
void filterTableInit(void) { UINT16 uk; /* Parameter calculation has not been moved to a separate function */ /* by purpose. */ const float filterRefFreq = 44100.0; float yMax = 1.0; float yMin = 0.01; float yAdd; float yTmp, rk, rk2; float resDyMax; float resDyMin; float resDy; filterTable = auto_malloc(sizeof(*filterTable) * 0x800); bandPassParam = auto_malloc(sizeof(*bandPassParam) * 0x800); uk = 0; for ( rk = 0; rk < 0x800; rk++ ) { filterTable[uk] = (((exp(rk/0x800*log(400.0))/60.0)+0.05) *filterRefFreq) / Machine->sample_rate; if ( filterTable[uk] < yMin ) filterTable[uk] = yMin; if ( filterTable[uk] > yMax ) filterTable[uk] = yMax; uk++; } /*extern float bandPassParam[0x800]; */ yMax = 0.22; yMin = 0.05; /* less for some R1/R4 chips */ yAdd = (yMax-yMin)/2048.0; yTmp = yMin; uk = 0; /* Some C++ compilers still have non-local scope! */ for ( rk2 = 0; rk2 < 0x800; rk2++ ) { bandPassParam[uk] = (yTmp*filterRefFreq) / Machine->sample_rate; yTmp += yAdd; uk++; } /*extern float filterResTable[16]; */ resDyMax = 1.0; resDyMin = 2.0; resDy = resDyMin; for ( uk = 0; uk < 16; uk++ ) { filterResTable[uk] = resDy; resDy -= (( resDyMin - resDyMax ) / 15 ); } filterResTable[0] = resDyMin; filterResTable[15] = resDyMax; }
void palette_init(running_machine *machine) { palette_private *palette = auto_malloc(sizeof(*palette)); /* request cleanup */ machine->palette_data = palette; add_exit_callback(machine, palette_exit); /* reset all our data */ memset(palette, 0, sizeof(*palette)); palette->format = machine->screen[0].format; /* determine the color mode */ switch (palette->format) { case BITMAP_FORMAT_INDEXED16: /* indexed modes are fine for everything */ break; case BITMAP_FORMAT_RGB15: case BITMAP_FORMAT_RGB32: /* RGB modes can't use color tables */ assert(machine->drv->color_table_len == 0); break; case BITMAP_FORMAT_INVALID: /* invalid format means no palette - or at least it should */ assert(machine->drv->total_colors == 0); assert(machine->drv->color_table_len == 0); return; default: fatalerror("Unsupported screen bitmap format!"); break; } /* allocate all the data structures */ if (machine->drv->total_colors > 0) { int numcolors; allocate_palette(machine, palette); allocate_color_tables(machine, palette); allocate_shadow_tables(machine, palette); /* set up save/restore of the palette */ numcolors = palette_get_num_colors(machine->palette); palette->save_pen = auto_malloc(sizeof(*palette->save_pen) * numcolors); palette->save_bright = auto_malloc(sizeof(*palette->save_bright) * numcolors); state_save_register_global_pointer(palette->save_pen, numcolors); state_save_register_global_pointer(palette->save_bright, numcolors); state_save_register_func_presave(palette_presave); state_save_register_func_postload(palette_postload); } }
void sound_init(running_machine *machine) { attotime update_frequency = SOUND_UPDATE_FREQUENCY; const char *filename; /* handle -nosound */ nosound_mode = !options_get_bool(mame_options(), OPTION_SOUND); if (nosound_mode) Machine->sample_rate = 11025; /* count the speakers */ for (totalspeakers = 0; Machine->drv->speaker[totalspeakers].tag; totalspeakers++) ; VPRINTF(("total speakers = %d\n", totalspeakers)); /* allocate memory for mix buffers */ leftmix = auto_malloc(Machine->sample_rate * sizeof(*leftmix)); rightmix = auto_malloc(Machine->sample_rate * sizeof(*rightmix)); finalmix = auto_malloc(Machine->sample_rate * sizeof(*finalmix)); /* allocate a global timer for sound timing */ sound_update_timer = timer_alloc(sound_update, NULL); timer_adjust(sound_update_timer, update_frequency, 0, update_frequency); /* initialize the streams engine */ VPRINTF(("streams_init\n")); streams_init(machine, update_frequency.attoseconds); /* now start up the sound chips and tag their streams */ VPRINTF(("start_sound_chips\n")); start_sound_chips(); /* then create all the speakers */ VPRINTF(("start_speakers\n")); start_speakers(); /* finally, do all the routing */ VPRINTF(("route_sound\n")); route_sound(); /* open the output WAV file if specified */ filename = options_get_string(mame_options(), OPTION_WAVWRITE); if (filename[0] != 0) wavfile = wav_open(filename, machine->sample_rate, 2); /* enable sound by default */ global_sound_enabled = TRUE; sound_muted = FALSE; sound_set_attenuation(options_get_int(mame_options(), OPTION_VOLUME)); /* register callbacks */ config_register("mixer", sound_load, sound_save); add_pause_callback(machine, sound_pause); add_reset_callback(machine, sound_reset); add_exit_callback(machine, sound_exit); }
static void imgtool_library_add_class(imgtool_library *library, const imgtool_class *imgclass) { imgtool_module *module; char *s1, *s2; size_t len; /* allocate the module and place it in the chain */ module = auto_malloc(sizeof(*module)); memset(module, 0, sizeof(*module)); module->previous = library->last; if (library->last) library->last->next = module; else library->first = module; library->last = module; /* extensions have a weird format */ s1 = imgtool_get_info_string(imgclass, IMGTOOLINFO_STR_FILE_EXTENSIONS); len = strlen(s1);; s2 = auto_malloc(len + 2); strcpy(s2, s1); s2[len + 1] = '\0'; while((s1 = strchr(s2, ',')) != NULL) *s1 = '\0'; module->extensions = s2; module->imgclass = *imgclass; module->name = auto_strdup(imgtool_get_info_string(imgclass, IMGTOOLINFO_STR_NAME)); module->description = auto_strdup(imgtool_get_info_string(imgclass, IMGTOOLINFO_STR_DESCRIPTION)); module->eoln = auto_strdup_allow_null(imgtool_get_info_string(imgclass, IMGTOOLINFO_STR_EOLN)); module->initial_path_separator = imgtool_get_info_int(imgclass, IMGTOOLINFO_INT_INITIAL_PATH_SEPARATOR) ? 1 : 0; module->open_is_strict = imgtool_get_info_int(imgclass, IMGTOOLINFO_INT_OPEN_IS_STRICT) ? 1 : 0; module->tracks_are_called_cylinders = imgtool_get_info_int(imgclass, IMGTOOLINFO_INT_TRACKS_ARE_CALLED_CYLINDERS) ? 1 : 0; module->writing_untested = imgtool_get_info_int(imgclass, IMGTOOLINFO_INT_WRITING_UNTESTED) ? 1 : 0; module->creation_untested = imgtool_get_info_int(imgclass, IMGTOOLINFO_INT_CREATION_UNTESTED) ? 1 : 0; module->open = (imgtoolerr_t (*)(imgtool_image *, imgtool_stream *)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_OPEN); module->create = (imgtoolerr_t (*)(imgtool_image *, imgtool_stream *, option_resolution *)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_CREATE); module->close = (void (*)(imgtool_image *)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_CLOSE); module->info = (void (*)(imgtool_image *, char *, size_t)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_INFO); module->read_sector = (imgtoolerr_t (*)(imgtool_image *, UINT32, UINT32, UINT32, void *, size_t)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_READ_SECTOR); module->write_sector = (imgtoolerr_t (*)(imgtool_image *, UINT32, UINT32, UINT32, const void *, size_t)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_WRITE_SECTOR); module->get_geometry = (imgtoolerr_t (*)(imgtool_image *, UINT32 *, UINT32 *, UINT32 *))imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_GET_GEOMETRY); module->get_sector_size = (imgtoolerr_t (*)(imgtool_image *, UINT32, UINT32, UINT32, UINT32 *))imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_GET_SECTOR_SIZE); module->read_block = (imgtoolerr_t (*)(imgtool_image *, void *, UINT64)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_READ_BLOCK); module->write_block = (imgtoolerr_t (*)(imgtool_image *, const void *, UINT64)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_WRITE_BLOCK); module->list_partitions = (imgtoolerr_t (*)(imgtool_image *, imgtool_partition_info *, size_t)) imgtool_get_info_fct(imgclass, IMGTOOLINFO_PTR_LIST_PARTITIONS); module->block_size = imgtool_get_info_int(imgclass, IMGTOOLINFO_INT_BLOCK_SIZE); module->createimage_optguide = (const struct OptionGuide *) imgtool_get_info_ptr(imgclass, IMGTOOLINFO_PTR_CREATEIMAGE_OPTGUIDE); module->createimage_optspec = auto_strdup_allow_null(imgtool_get_info_ptr(imgclass, IMGTOOLINFO_STR_CREATEIMAGE_OPTSPEC)); module->image_extra_bytes += imgtool_get_info_int(imgclass, IMGTOOLINFO_INT_IMAGE_EXTRA_BYTES); }
void *attckufo_custom_start(int clock, const struct CustomSound_interface *config) { int i; channel = stream_create(0, 1, OUTPUT_RATE, 0, attckufo_update); /* buffer for fastest played sample for 5 second * so we have enough data for min 5 second */ noisesize = NOISE_FREQUENCY_MAX * NOISE_BUFFER_SIZE_SEC; noise = (INT8*) auto_malloc (noisesize * sizeof (noise[0])); { int noiseshift = 0x7ffff8; char data; for (i = 0; i < noisesize; i++) { data = 0; if (noiseshift & 0x400000) data |= 0x80; if (noiseshift & 0x100000) data |= 0x40; if (noiseshift & 0x010000) data |= 0x20; if (noiseshift & 0x002000) data |= 0x10; if (noiseshift & 0x000800) data |= 0x08; if (noiseshift & 0x000080) data |= 0x04; if (noiseshift & 0x000010) data |= 0x02; if (noiseshift & 0x000004) data |= 0x01; noise[i] = data; if (((noiseshift & 0x400000) == 0) != ((noiseshift & 0x002000) == 0)) noiseshift = (noiseshift << 1) | 1; else noiseshift <<= 1; } } tonesize = OUTPUT_RATE / TONE_FREQUENCY_MIN; tone = (INT16*) auto_malloc (tonesize * sizeof (tone[0])); for (i = 0; i < tonesize; i++) { tone[i] = (INT16)(sin (2 * M_PI * i / tonesize) * 127 + 0.5); } return (void *) ~0; }
static void toaplan1_vram_alloc(void) { pf1_tilevram16 = auto_malloc(TOAPLAN1_TILEVRAM_SIZE); memset(pf1_tilevram16,0,TOAPLAN1_TILEVRAM_SIZE); pf2_tilevram16 = auto_malloc(TOAPLAN1_TILEVRAM_SIZE); memset(pf2_tilevram16,0,TOAPLAN1_TILEVRAM_SIZE); pf3_tilevram16 = auto_malloc(TOAPLAN1_TILEVRAM_SIZE); memset(pf3_tilevram16,0,TOAPLAN1_TILEVRAM_SIZE); pf4_tilevram16 = auto_malloc(TOAPLAN1_TILEVRAM_SIZE); memset(pf4_tilevram16,0,TOAPLAN1_TILEVRAM_SIZE); }
int exidy440_sh_start(const struct MachineSound *msound) { const char *names[] = { "Exidy 440 sound left", "Exidy 440 sound right" }; int i, length; int vol[2]; /* reset the system */ exidy440_sound_command = 0; exidy440_sound_command_ack = 1; /* reset the 6844 */ for (i = 0; i < 4; i++) { m6844_channel[i].active = 0; m6844_channel[i].control = 0x00; } m6844_priority = 0x00; m6844_interrupt = 0x00; m6844_chain = 0x00; /* get stream channels */ vol[0] = MIXER(100, MIXER_PAN_LEFT); vol[1] = MIXER(100, MIXER_PAN_RIGHT); sound_stream = stream_init_multi(2, names, vol, SAMPLE_RATE_FAST, 0, channel_update); /* allocate the sample cache */ length = memory_region_length(REGION_SOUND1) * 16 + MAX_CACHE_ENTRIES * sizeof(sound_cache_entry); sound_cache = auto_malloc(length); if (!sound_cache) return 1; /* determine the hard end of the cache and reset */ sound_cache_max = (sound_cache_entry *)((UINT8 *)sound_cache + length); reset_sound_cache(); /* allocate the mixer buffer */ mixer_buffer_left = auto_malloc(2 * SAMPLE_RATE_FAST * sizeof(INT32)); if (!mixer_buffer_left) return 1; mixer_buffer_right = mixer_buffer_left + SAMPLE_RATE_FAST; if (SOUND_LOG) debuglog = fopen("sound.log", "w"); return 0; }
void *exidy440_sh_start(int clock, const struct CustomSound_interface *config) { int i, length; /* reset the system */ exidy440_sound_command = 0; exidy440_sound_command_ack = 1; state_save_register_global(exidy440_sound_command); state_save_register_global(exidy440_sound_command_ack); /* reset the 6844 */ for (i = 0; i < 4; i++) { m6844_channel[i].active = 0; m6844_channel[i].control = 0x00; } m6844_priority = 0x00; m6844_interrupt = 0x00; m6844_chain = 0x00; state_save_register_int("m6844", 0, "priority", &m6844_priority); state_save_register_int("m6844", 0, "interrupt", &m6844_interrupt); state_save_register_int("m6844", 0, "chain", &m6844_chain); channel_frequency[0] = clock; /* channels 0 and 1 are run by FCLK */ channel_frequency[1] = clock; channel_frequency[2] = clock/2; /* channels 2 and 3 are run by SCLK */ channel_frequency[3] = clock/2; /* get stream channels */ stream = stream_create(0, 2, clock, NULL, channel_update); /* allocate the sample cache */ length = memory_region_length(REGION_SOUND1) * 16 + MAX_CACHE_ENTRIES * sizeof(sound_cache_entry); sound_cache = auto_malloc(length); /* determine the hard end of the cache and reset */ sound_cache_max = (sound_cache_entry *)((UINT8 *)sound_cache + length); reset_sound_cache(); /* allocate the mixer buffer */ mixer_buffer_left = auto_malloc(2 * clock * sizeof(INT32)); mixer_buffer_right = mixer_buffer_left + clock; if (SOUND_LOG) debuglog = fopen("sound.log", "w"); return auto_malloc(1); }
int stv_vdp1_start ( void ) { stv_vdp1_regs = auto_malloc ( 0x040000 ); stv_vdp1_vram = auto_malloc ( 0x100000 ); memset(stv_vdp1_regs, 0, 0x040000); memset(stv_vdp1_vram, 0, 0x100000); stv_framebuffer = auto_malloc( 1024 * 256 * sizeof(UINT16) * 2 ); /* *2 is for double interlace */ stv_framebuffer_lines = auto_malloc( 512 * sizeof(UINT16*) ); stv_framebuffer_width = stv_framebuffer_height = 0; stv_framebuffer_mode = -1; stv_framebuffer_double_interlace = -1; return 0; }
static void toaplan1_spritevram_alloc(void) { spriteram16 = auto_malloc(TOAPLAN1_SPRITERAM_SIZE); memset(spriteram16,0,TOAPLAN1_SPRITERAM_SIZE); buffered_spriteram16 = auto_malloc(TOAPLAN1_SPRITERAM_SIZE); memset(buffered_spriteram16,0,TOAPLAN1_SPRITERAM_SIZE); toaplan1_spritesizeram16 = auto_malloc(TOAPLAN1_SPRITESIZERAM_SIZE); memset(toaplan1_spritesizeram16,0,TOAPLAN1_SPRITESIZERAM_SIZE); toaplan1_buffered_spritesizeram16 = auto_malloc(TOAPLAN1_SPRITESIZERAM_SIZE); memset(toaplan1_buffered_spritesizeram16,0,TOAPLAN1_SPRITESIZERAM_SIZE); spriteram_size = TOAPLAN1_SPRITERAM_SIZE; }
static void *ym2203_start(int sndindex, int clock, const void *config) { static const struct YM2203interface generic_2203 = { 0 }; const struct YM2203interface *intf = config ? config : &generic_2203; struct ym2203_info *info; info = auto_malloc(sizeof(*info)); memset(info, 0, sizeof(*info)); info->intf = intf; info->psg = ay8910_start_ym(SOUND_YM2203, sndindex, clock, 3, intf->portAread, intf->portBread, intf->portAwrite, intf->portBwrite); if (!info->psg) return NULL; /* Timer Handler set */ info->timer[0] = timer_alloc_ptr(timer_callback_2203_0, info); info->timer[1] = timer_alloc_ptr(timer_callback_2203_1, info); /* stream system initialize */ info->stream = stream_create(0,1,Machine->sample_rate,info,ym2203_stream_update); /* Initialize FM emurator */ info->chip = YM2203Init(info,sndindex,clock,Machine->sample_rate,TimerHandler,IRQHandler,&psgintf); state_save_register_func_postload_ptr(ym2203_postload, info); if (info->chip) return info; /* error */ /* stream close */ return NULL; }
static int toaplan1_paletteram_alloc(void) { if ((paletteram16 = (data16_t *)auto_malloc(toaplan1_colorram1_size + toaplan1_colorram2_size)) == 0) return 1; return 0; }
void init_konami_cgboard(int board_id, int type) { dsp_comm_ppc[board_id][0] = 0x00; dsp_shared_ram[board_id] = auto_malloc(0x20000); dsp_shared_ram_bank[board_id] = 0; cgboard_type = type; }
ADDRESS_MAP_END VIDEO_START(twins) { twins_pal = auto_malloc(0x100*2); return 0; }
void hdsnd_init(void) { rombase = (UINT8 *)memory_region(REGION_SOUND1); romsize = memory_region_length(REGION_SOUND1); comram = (UINT16 *)auto_malloc(0x400); last_bio_cycles = 0; }
static VIDEO_START( ninjaw_core ) { int chips; spritelist = auto_malloc(0x1000 * sizeof(*spritelist)); chips = number_of_TC0100SCN(); if (chips <= 0) /* we have an erroneous TC0100SCN configuration */ return 1; if (TC0100SCN_vh_start(chips,TC0100SCN_GFX_NUM,taito_hide_pixels,0,0,0,0,0,0)) return 1; if (has_TC0110PCR()) if (TC0110PCR_vh_start()) return 1; if (has_second_TC0110PCR()) if (TC0110PCR_1_vh_start()) return 1; if (has_third_TC0110PCR()) if (TC0110PCR_2_vh_start()) return 1; /* Ensure palette from correct TC0110PCR used for each screen */ TC0100SCN_set_chip_colbanks(0x0,0x100,0x200); return 0; }
static void *ym3812_start(int sndindex, int clock, const void *config) { static const struct YM3812interface dummy = { 0 }; int rate = Machine->sample_rate; struct ym3812_info *info; info = auto_malloc(sizeof(*info)); memset(info, 0, sizeof(*info)); info->intf = config ? config : &dummy; rate = clock/72; /* stream system initialize */ info->chip = YM3812Init(sndindex,clock,rate); if (!info->chip) return NULL; info->stream = stream_create(0,1,rate,info,ym3812_stream_update); /* YM3812 setup */ YM3812SetTimerHandler (info->chip, TimerHandler_3812, info); YM3812SetIRQHandler (info->chip, IRQHandler_3812, info); YM3812SetUpdateHandler(info->chip, _stream_update_3812, info); info->timer[0] = timer_alloc_ptr(timer_callback_3812_0, info); info->timer[1] = timer_alloc_ptr(timer_callback_3812_1, info); return info; }
struct crtc6845 *crtc6845_init(const struct crtc6845_config *config) { struct crtc6845 *crtc; int idx; crtc = auto_malloc(sizeof(struct crtc6845)); memset(crtc, 0, sizeof(*crtc)); crtc->cursor_time = timer_get_time(); crtc->config = *config; crtc6845 = crtc; /* Hardwire the values which can't be changed in the PC1512 version */ if (config->personality == M6845_PERSONALITY_PC1512) { for (idx = 0; idx < sizeof(pc1512_defaults); idx++) { crtc->reg[idx] = pc1512_defaults[idx]; } } state_save_register_item_array("crtc6845", 0, crtc->reg); state_save_register_item("crtc6845", 0, crtc->idx); state_save_register_func_postload(crtc6845_state_postload); return crtc; }