void* SelfDestructBehaveInit(void* bhdata,STRATEGYBLOCK* sbptr) { SELF_DESTRUCT_BEHAV_BLOCK* sd_bhv; SELF_DESTRUCT_TOOLS_TEMPLATE* sd_tt; GLOBALASSERT(sbptr); GLOBALASSERT(bhdata); sd_bhv=(SELF_DESTRUCT_BEHAV_BLOCK*)AllocateMem(sizeof(SELF_DESTRUCT_BEHAV_BLOCK)); if(!sd_bhv) { memoryInitialisationFailure = 1; return 0; } sd_bhv->bhvr_type=I_BehaviourSelfDestruct; sd_tt=(SELF_DESTRUCT_TOOLS_TEMPLATE*)bhdata; //copy stuff from tools template COPY_NAME(sbptr->SBname, sd_tt->nameID); sd_bhv->timer=sd_tt->timer; sd_bhv->active=FALSE; return (void*)sd_bhv; }
void* PowerCableBehaveInit(void* bhdata,STRATEGYBLOCK* sbptr) { POWER_CABLE_BEHAV_BLOCK* pc_bhv; POWER_CABLE_TOOLS_TEMPLATE* pc_tt; GLOBALASSERT(sbptr); GLOBALASSERT(bhdata); pc_bhv=(POWER_CABLE_BEHAV_BLOCK*)AllocateMem(sizeof(POWER_CABLE_BEHAV_BLOCK)); if(!pc_bhv) { memoryInitialisationFailure = 1; return 0; } pc_bhv->bhvr_type=I_BehaviourPowerCable; pc_tt=(POWER_CABLE_TOOLS_TEMPLATE*)bhdata; //copy stuff from tools template COPY_NAME(sbptr->SBname, pc_tt->nameID); pc_bhv->position = pc_tt->position; pc_bhv->max_charge = pc_tt->max_charge; pc_bhv->current_charge = pc_tt->current_charge; pc_bhv->recharge_rate = pc_tt->recharge_rate; pc_bhv->position.vy+=10; //temporarily move cable down in case rounding errors have put cable just outside of module sbptr->containingModule=ModuleFromPosition(&(pc_bhv->position),0); pc_bhv->position.vy-=10; GLOBALASSERT(sbptr->containingModule); return (void*)pc_bhv; }
void* DeathVolumeBehaveInit(void* bhdata,STRATEGYBLOCK* sbptr) { DEATH_VOLUME_BEHAV_BLOCK* dv_bhv; DEATH_VOLUME_TOOLS_TEMPLATE* dv_tt; GLOBALASSERT(sbptr); GLOBALASSERT(bhdata); dv_bhv=(DEATH_VOLUME_BEHAV_BLOCK*)AllocateMem(sizeof(DEATH_VOLUME_BEHAV_BLOCK)); if(!dv_bhv) { memoryInitialisationFailure = 1; return 0; } dv_bhv->bhvr_type=I_BehaviourDeathVolume; dv_tt=(DEATH_VOLUME_TOOLS_TEMPLATE*)bhdata; //copy stuff from tools template COPY_NAME(sbptr->SBname, dv_tt->nameID); dv_bhv->volume_min=dv_tt->volume_min; dv_bhv->volume_max=dv_tt->volume_max; dv_bhv->damage_per_second=dv_tt->damage_per_second; dv_bhv->active=dv_tt->active; dv_bhv->collision_required=dv_tt->collision_required; return (void*)dv_bhv; }
void LoadDatabaseMessage() { char filename[DATABASE_MESSAGE_NAME_LENGTH] = {"\000"}; FILE* message_fp; struct _stat filestatus; int filesize; GetMessageName(filename); message_fp = fopen(filename, "rb"); GLOBALASSERT(message_fp); _stat(filename, &filestatus); filesize = filestatus.st_size;//filestatus.off_t; MessageString = AllocateMem(filesize + 1); if (!MessageString) { memoryInitialisationFailure = 1; return; } fread(MessageString, 1, filesize, message_fp); // add the terminator *((char*)MessageString + filesize) = 0; }
void* PlacedHierarchyBehaveInit(void* bhdata,STRATEGYBLOCK* sbptr) { PLACED_HIERARCHY_BEHAV_BLOCK* ph_bhv; PLACED_HIERARCHY_TOOLS_TEMPLATE* ph_tt; SECTION *root_section; SECTION_DATA* sound_section_data; GLOBALASSERT(sbptr); GLOBALASSERT(bhdata); ph_bhv=(PLACED_HIERARCHY_BEHAV_BLOCK*)AllocateMem(sizeof(PLACED_HIERARCHY_BEHAV_BLOCK)); if(!ph_bhv) { memoryInitialisationFailure = 1; return ((void *)NULL); } ph_bhv->bhvr_type=I_BehaviourPlacedHierarchy; ph_tt=(PLACED_HIERARCHY_TOOLS_TEMPLATE*)bhdata; sbptr->shapeIndex=0; COPY_NAME(sbptr->SBname, ph_tt->nameID); sbptr->DynPtr->Position = sbptr->DynPtr->PrevPosition = ph_tt->position; sbptr->DynPtr->OrientEuler = ph_tt->orientation; CreateEulerMatrix(&sbptr->DynPtr->OrientEuler, &sbptr->DynPtr->OrientMat); TransposeMatrixCH(&sbptr->DynPtr->OrientMat); ph_bhv->num_sequences=ph_tt->num_sequences; ph_bhv->sequences=ph_tt->sequences; ph_bhv->num_sounds=ph_tt->num_sounds; ph_bhv->sounds=ph_tt->sounds; ph_bhv->num_special_track_points=ph_tt->num_special_track_points; ph_bhv->special_track_points=ph_tt->special_track_points; root_section=GetNamedHierarchyFromLibrary(ph_tt->file_name,ph_tt->hier_name); GLOBALASSERT(root_section); Create_HModel(&ph_bhv->HModelController,root_section); ph_bhv->current_seq=ph_tt->first_sequence; InitHModelSequence(&ph_bhv->HModelController,ph_bhv->current_seq->sequence_no,ph_bhv->current_seq->sub_sequence_no,ph_bhv->current_seq->time); ph_bhv->HModelController.Playing=ph_tt->playing; ph_bhv->HModelController.Looped=ph_bhv->current_seq->loop; //find the hierarchy section that sound should be produced from sound_section_data=GetThisSectionData(ph_bhv->HModelController.section_data,"SoundSource"); if(!sound_section_data) { //if there isn't a SoundSource object , sound can come from the root section sound_section_data=ph_bhv->HModelController.section_data; } ph_bhv->sound_location=&sound_section_data->World_Offset; return ((void*)ph_bhv); }
void SortTable::Insert(string k, Polinom* p) { if (currpos == tabsize) { AllocateMem(); } AddSort(k, p); }
static void load_mofflott(void) { romset=1; RAMSize=0x38000; if(!(RAM=AllocateMem(RAMSize))) return; /*-----[Sound Setup]-----*/ Z80ROM=RAM+0x28000; memcpy(Z80ROM,load_region[REGION_CPU2],0x10000); AddTaitoYM2151(0x01C0, 0x01AB, 0x10000, (UINT8 *) Maze_of_Flott_M5205_W, NULL); /*-----------------------*/ memset(RAM+0x00000,0x00,0x28000); RAM_VIDEO = RAM+0x08000; RAM_SCROLL = RAM+0x1B000; RAM_OBJECT = RAM+0x18000; RAM_INPUT = RAM+0x1A000; tc0110pcr_init(RAM+0x1C000, 1); set_colour_mapper(&col_map_xbbb_bbgg_gggr_rrrr); InitPaletteMap(RAM+0x1C000, 0x100, 0x10, 0x8000); GFX_FG0 = RAM+0x20000; // Speed Hack // ---------- WriteLong68k(&ROM[0x005CA],0x13FC0000); WriteLong68k(&ROM[0x005CE],0x00AA0000); WriteLong68k(&ROM[0x0368C],0x13FC0000); WriteLong68k(&ROM[0x03690],0x00AA0000); // Fix ROM Checksum // ---------------- WriteLong68k(&ROM[0x030F6],0x4E714E71); // Fix Bad Writes // -------------- WriteLong68k(&ROM[0x14C6A],0x4E714E71); WriteLong68k(&ROM[0x14C7A],0x4E714E71); AddEarthJoker68k(); }
void DelayPlugin::OnDelayTime(wxScrollEvent &WXUNUSED(e)) { DelayMutex.Lock(); // DelayTime = TimeFader->GetValue(); AllocateMem(); DelayMutex.Unlock(); // cout << "Time: " << DelayTime << endl; }
void DelayPlugin::Init() { DelayMutex.Lock(); DelayTime = 1000; // Feedback = 0.5f; // DryLevel = 0.5f; // WetLevel = 0.5f; Feedback = 50; DryLevel = 50; WetLevel = 50; AllocateMem(); DelayMutex.Unlock(); }
static void load_earthjkr(void) { romset=0; RAMSize=0x38000; if(!(RAM=AllocateMem(RAMSize))) return; GFX_FG0 = RAM+0x20000; /*-----[Sound Setup]-----*/ Z80ROM=RAM+0x28000; memcpy(Z80ROM,load_region[REGION_CPU2],0x10000); AddTaitoYM2151(0x01AF, 0x0143, 0x10000, NULL, NULL); /*-----------------------*/ memset(RAM+0x00000,0x00,0x28000); RAM_VIDEO = RAM+0x08000; RAM_SCROLL = RAM+0x1B000; RAM_OBJECT = RAM+0x18000; RAM_INPUT = RAM+0x1A000; tc0110pcr_init(RAM+0x1C000, 1); set_colour_mapper(&col_map_xbbb_bbgg_gggr_rrrr); InitPaletteMap(RAM+0x1C000, 0x100, 0x10, 0x8000); // Speed Hack // ---------- WriteLong68k(&ROM[0x004D8],0x13FC0000); WriteLong68k(&ROM[0x004DC],0x00AA0000); // Fix ROM Checksum // ---------------- WriteLong68k(&ROM[0x00B36],0x4E714E71); AddEarthJoker68k(); }
static void load_eto(void) { romset=3; RAMSize=0x38000; if(!(RAM=AllocateMem(RAMSize))) return; /*-----[Sound Setup]-----*/ Z80ROM=RAM+0x28000; memcpy(Z80ROM,load_region[REGION_CPU2],0x10000); AddTaitoYM2151(0x01CF, 0x01AB, 0x10000, NULL, NULL); // 100% not sure /*-----------------------*/ memset(RAM+0x00000,0x00,0x28000); RAM_VIDEO = RAM+0x08000; RAM_SCROLL = RAM+0x1B000; RAM_OBJECT = RAM+0x18000; RAM_INPUT = RAM+0x1A000; tc0110pcr_init(RAM+0x1C000, 1); set_colour_mapper(&col_map_xbbb_bbgg_gggr_rrrr); InitPaletteMap(RAM+0x1C000, 0x100, 0x10, 0x8000); GFX_FG0 = RAM+0x20000; // Speed Hack // ---------- // ... AddEarthJoker68k(); }
void* PoolAllocateMem(unsigned int amount) { char* retval; GLOBALASSERT(amount<=MEMORY_BLOCK_SIZE) if(amount>MemoryLeft) { CurrentMemoryBlock++; GLOBALASSERT(CurrentMemoryBlock<MAX_NUM_MEMORY_BLOCK); MemoryBlocks[CurrentMemoryBlock]=AllocateMem(MEMORY_BLOCK_SIZE); GLOBALASSERT(MemoryBlocks[CurrentMemoryBlock]); MemoryLeft=MEMORY_BLOCK_SIZE; MemoryPoolPtr=MemoryBlocks[CurrentMemoryBlock]; } retval=MemoryPoolPtr; MemoryLeft-=amount; MemoryPoolPtr+=amount; return (void*)retval; }
static void load_ninjaw(void) { int ta,tb,tc,td; UINT8 *TMP; setup_z80_frame(CPU_Z80_0,CPU_FRAME_MHz(4.5,60)); romset = 0; if(!(TMP=AllocateMem(0x80000))) return; if(!(GFX=AllocateMem(0x600000))) return; GFX_BG0 = GFX+0x000000; GFX_SPR = GFX+0x200000; tb=0; if(!load_rom("b31-01.23", TMP, 0x80000)) return; // 8x8 BACKGROUND TILES for(ta=0;ta<0x80000;ta+=2){ GFX[tb+1]=TMP[ta+1]&15; GFX[tb+0]=TMP[ta+1]>>4; GFX[tb+3]=TMP[ta+0]&15; GFX[tb+2]=TMP[ta+0]>>4; tb+=4; } if(!load_rom("b31-02.24", TMP, 0x80000)) return; for(ta=0;ta<0x80000;ta+=2){ GFX[tb+1]=TMP[ta+1]&15; GFX[tb+0]=TMP[ta+1]>>4; GFX[tb+3]=TMP[ta+0]&15; GFX[tb+2]=TMP[ta+0]>>4; tb+=4; } if(!load_rom("b31-07.176", TMP, 0x80000)) return; // 16x16 SPRITES for(ta=0;ta<0x80000;ta+=0){ for(td=0;td<2;td++){ tc=TMP[ta++]; GFX[tb+3]=(((tc&0x80)>>7)<<1); GFX[tb+2]=(((tc&0x40)>>6)<<1); GFX[tb+1]=(((tc&0x20)>>5)<<1); GFX[tb+0]=(((tc&0x10)>>4)<<1); GFX[tb+3]|=(((tc&0x08)>>3)<<0); GFX[tb+2]|=(((tc&0x04)>>2)<<0); GFX[tb+1]|=(((tc&0x02)>>1)<<0); GFX[tb+0]|=(((tc&0x01)>>0)<<0); tc=TMP[ta++]; GFX[tb+3]|=(((tc&0x80)>>7)<<3); GFX[tb+2]|=(((tc&0x40)>>6)<<3); GFX[tb+1]|=(((tc&0x20)>>5)<<3); GFX[tb+0]|=(((tc&0x10)>>4)<<3); GFX[tb+3]|=(((tc&0x08)>>3)<<2); GFX[tb+2]|=(((tc&0x04)>>2)<<2); GFX[tb+1]|=(((tc&0x02)>>1)<<2); GFX[tb+0]|=(((tc&0x01)>>0)<<2); tb+=4; } tb+=8; if((tb&0x7F)==0){tb-=0x78;} else{if((tb&0x7F)==8){tb-=8;}} } if(!load_rom("b31-06.175", TMP, 0x80000)) return; // 16x16 SPRITES for(ta=0;ta<0x80000;ta+=0){ for(td=0;td<2;td++){ tc=TMP[ta++]; GFX[tb+3]=(((tc&0x80)>>7)<<1); GFX[tb+2]=(((tc&0x40)>>6)<<1); GFX[tb+1]=(((tc&0x20)>>5)<<1); GFX[tb+0]=(((tc&0x10)>>4)<<1); GFX[tb+3]|=(((tc&0x08)>>3)<<0); GFX[tb+2]|=(((tc&0x04)>>2)<<0); GFX[tb+1]|=(((tc&0x02)>>1)<<0); GFX[tb+0]|=(((tc&0x01)>>0)<<0); tc=TMP[ta++]; GFX[tb+3]|=(((tc&0x80)>>7)<<3); GFX[tb+2]|=(((tc&0x40)>>6)<<3); GFX[tb+1]|=(((tc&0x20)>>5)<<3); GFX[tb+0]|=(((tc&0x10)>>4)<<3); GFX[tb+3]|=(((tc&0x08)>>3)<<2); GFX[tb+2]|=(((tc&0x04)>>2)<<2); GFX[tb+1]|=(((tc&0x02)>>1)<<2); GFX[tb+0]|=(((tc&0x01)>>0)<<2); tb+=4; } tb+=8; if((tb&0x7F)==0){tb-=0x78;} else{if((tb&0x7F)==8){tb-=8;}} } if(!load_rom("b31-05.174", TMP, 0x80000)) return; // 16x16 SPRITES for(ta=0;ta<0x80000;ta+=0){ for(td=0;td<2;td++){ tc=TMP[ta++]; GFX[tb+3]=(((tc&0x80)>>7)<<1); GFX[tb+2]=(((tc&0x40)>>6)<<1); GFX[tb+1]=(((tc&0x20)>>5)<<1); GFX[tb+0]=(((tc&0x10)>>4)<<1); GFX[tb+3]|=(((tc&0x08)>>3)<<0); GFX[tb+2]|=(((tc&0x04)>>2)<<0); GFX[tb+1]|=(((tc&0x02)>>1)<<0); GFX[tb+0]|=(((tc&0x01)>>0)<<0); tc=TMP[ta++]; GFX[tb+3]|=(((tc&0x80)>>7)<<3); GFX[tb+2]|=(((tc&0x40)>>6)<<3); GFX[tb+1]|=(((tc&0x20)>>5)<<3); GFX[tb+0]|=(((tc&0x10)>>4)<<3); GFX[tb+3]|=(((tc&0x08)>>3)<<2); GFX[tb+2]|=(((tc&0x04)>>2)<<2); GFX[tb+1]|=(((tc&0x02)>>1)<<2); GFX[tb+0]|=(((tc&0x01)>>0)<<2); tb+=4; } tb+=8; if((tb&0x7F)==0){tb-=0x78;} else{if((tb&0x7F)==8){tb-=8;}} } if(!load_rom("b31-04.173", TMP, 0x80000)) return; // 16x16 SPRITES for(ta=0;ta<0x80000;ta+=0){ for(td=0;td<2;td++){ tc=TMP[ta++]; GFX[tb+3]=(((tc&0x80)>>7)<<1); GFX[tb+2]=(((tc&0x40)>>6)<<1); GFX[tb+1]=(((tc&0x20)>>5)<<1); GFX[tb+0]=(((tc&0x10)>>4)<<1); GFX[tb+3]|=(((tc&0x08)>>3)<<0); GFX[tb+2]|=(((tc&0x04)>>2)<<0); GFX[tb+1]|=(((tc&0x02)>>1)<<0); GFX[tb+0]|=(((tc&0x01)>>0)<<0); tc=TMP[ta++]; GFX[tb+3]|=(((tc&0x80)>>7)<<3); GFX[tb+2]|=(((tc&0x40)>>6)<<3); GFX[tb+1]|=(((tc&0x20)>>5)<<3); GFX[tb+0]|=(((tc&0x10)>>4)<<3); GFX[tb+3]|=(((tc&0x08)>>3)<<2); GFX[tb+2]|=(((tc&0x04)>>2)<<2); GFX[tb+1]|=(((tc&0x02)>>1)<<2); GFX[tb+0]|=(((tc&0x01)>>0)<<2); tb+=4; } tb+=8; if((tb&0x7F)==0){tb-=0x78;} else{if((tb&0x7F)==8){tb-=8;}} } FreeMem(TMP); RAMSize=0xA0000; if(!(ROM=AllocateMem(0x120000))) return; if(!(RAM=AllocateMem(RAMSize))) return; RAM2=RAM+0x40000; if(!load_rom_index(13, RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta]=RAM[ta]; } if(!load_rom_index(14, RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta+1]=RAM[ta]; } if(!load_rom("b31_29.34", RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta+0x20000]=RAM[ta]; } if(!load_rom("b31_27.31", RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta+0x20001]=RAM[ta]; } if(!load_rom("b31_41.5", RAM, 0x20000)) return; for(ta=0;ta<0x20000;ta++){ ROM[ta+ta+0x40000]=RAM[ta]; } if(!load_rom("b31_39.2", RAM, 0x20000)) return; for(ta=0;ta<0x20000;ta++){ ROM[ta+ta+0x40001]=RAM[ta]; } if(!load_rom("b31_40.6", RAM, 0x20000)) return; for(ta=0;ta<0x20000;ta++){ ROM[ta+ta+0x80000]=RAM[ta]; } if(!load_rom("b31_38.3", RAM, 0x20000)) return; for(ta=0;ta<0x20000;ta++){ ROM[ta+ta+0x80001]=RAM[ta]; } if(!load_rom("b31_33.87", RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta+0xC0000]=RAM[ta]; } if(!load_rom("b31_36.97", RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta+0xC0001]=RAM[ta]; } if(!load_rom("b31_32.86", RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta+0xE0000]=RAM[ta]; } if(!load_rom("b31_35.96", RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta+0xE0001]=RAM[ta]; } if(!load_rom("b31_31.85", RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta+0x100000]=RAM[ta]; } if(!load_rom("b31_34.95", RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta+0x100001]=RAM[ta]; } /*-----[Sound Setup]-----*/ Z80ROM=RAM+0x80000; if(!load_rom("b31_37.11", Z80ROM, 0x20000)) return; // Z80 SOUND ROM AddTaitoYM2610(0x0345, 0x02B7, 0x20000); /*-----------------------*/ // This one avoids to send an explicit start command to the 2nd 68k (cpua_w) // this is used only at start of the game, so it's easier to just disable it ROM[0x199C]=0x4E; // Fix small 68000 communication problem ROM[0x199D]=0x71; ROM[0x07BA]=0x13; // move.b #$00,$AA0000 ROM[0x07BB]=0xFC; // Speed Hack ROM[0x07BC]=0x00; ROM[0x07BD]=0x00; ROM[0x07BE]=0x00; ROM[0x07BF]=0xAA; ROM[0x07C0]=0x00; ROM[0x07C1]=0x00; ROM[0x07C2]=0x60; ROM[0x07C3]=0xE2; ROM[0xC07A6]=0x13; // move.b #$00,$AA0000 ROM[0xC07A7]=0xFC; // Speed Hack ROM[0xC07A8]=0x00; ROM[0xC07A9]=0x00; ROM[0xC07AA]=0x00; ROM[0xC07AB]=0xAA; ROM[0xC07AC]=0x00; ROM[0xC07AD]=0x00; ROM[0xC07AE]=0x60; ROM[0xC07AF]=0xEE; // WriteWord68k(&ROM[0xc0ad4],0x4e71); // fast start, don't wait for the other memset(RAM+0x00000,0x00,0x80000); GFX_FG0 = RAM+0x64000; RAM_INPUT = RAM+0x3B000; tc0100scn[0].RAM = RAM+0x21000-0x6000; tc0100scn[0].GFX_FG0 = GFX_FG0; init_tc0100scn(0); tc0100scn_0_copy_gfx_fg0(ROM+0x22000, 0x1000); GFX_BG0_SOLID = make_solid_mask_8x8 (GFX_BG0, 0x8000); init_tile_cachex4(); GFX_SPR_SOLID = make_solid_mask_16x16(GFX_SPR, 0x4000); tc0110pcr_init_typeb(RAM+0x38000, 1, 0); tc0110pcr_init_typeb_2(RAM+0x39000, 1, 0); tc0110pcr_init_typeb_3(RAM+0x3A000, 1, 0); set_colour_mapper(&col_map_xbbb_bbgg_gggr_rrrr); InitPaletteMap(RAM+0x38000, 0x100, 0x10, 0x8000); // Init tc0220ioc emulation // ------------------------ tc0220ioc.RAM = RAM_INPUT; tc0220ioc.ctrl = 0; //TC0220_STOPCPU; reset_tc0220ioc(); memset(RAM_INPUT,0x00,0x20); /* * StarScream Stuff follows */ ByteSwap(ROM,0x120000); ByteSwap(RAM,0x50000); AddMemFetch(0x000000, 0x0BFFFF, ROM+0x000000-0x000000); // 68000 ROM AddMemFetch(-1, -1, NULL); AddReadByte(0x000000, 0x0BFFFF, NULL, ROM+0x000000); // 68000 ROM AddReadByte(0x0C0000, 0x0CFFFF, NULL, RAM+0x000000); // MAIN RAM AddReadByte(0x240000, 0x24FFFF, NULL, RAM+0x024000); // COMMON RAM AddReadByte(0x260000, 0x263FFF, NULL, RAM+0x034000); // OBJECT RAM AddReadByte(0x280000, 0x293FFF, NULL, RAM+0x010000); // SCREEN RAM AddReadByte(0x200000, 0x200003, tc0220ioc_rb_port, NULL); // INPUT AddReadByte(0x000000, 0xFFFFFF, DefBadReadByte, NULL); // <Bad Reads> AddReadByte(-1, -1, NULL, NULL); AddReadWord(0x000000, 0x0BFFFF, NULL, ROM+0x000000); // 68000 ROM AddReadWord(0x0C0000, 0x0CFFFF, NULL, RAM+0x000000); // MAIN RAM AddReadWord(0x240000, 0x24FFFF, NULL, RAM+0x024000); // COMMON RAM AddReadWord(0x260000, 0x263FFF, NULL, RAM+0x034000); // OBJECT RAM AddReadWord(0x280000, 0x293FFF, NULL, RAM+0x010000); // SCREEN RAM AddReadWord(0x340000, 0x340007, tc0110pcr_rw, NULL); // COLOR RAM SCREEN A AddReadWord(0x350000, 0x350007, tc0110pcr_rw_2, NULL); // COLOR RAM SCREEN B AddReadWord(0x360000, 0x360007, tc0110pcr_rw_3, NULL); // COLOR RAM SCREEN C AddReadWord(0x200000, 0x200003, tc0220ioc_rw_port, NULL); // INPUT AddReadWord(0x220000, 0x220003, tc0140syt_read_main_68k, NULL); // SOUND COMM AddReadWord(0x000000, 0xFFFFFF, DefBadReadWord, NULL); // <Bad Reads> AddReadWord(-1, -1, NULL, NULL); AddWriteByte(0x0C0000, 0x0CFFFF, NULL, RAM+0x000000); // MAIN RAM AddWriteByte(0x240000, 0x24FFFF, NULL, RAM+0x024000); // COMMON RAM AddWriteByte(0x260000, 0x263FFF, NULL, RAM+0x034000); // OBJECT RAM AddWriteByte(0x280000, 0x293FFF, NULL, RAM+0x010000); // SCREEN RAM AddWriteByte(0x200000, 0x200003, tc0220ioc_wb_port, NULL); // INPUT AddWriteByte(0xAA0000, 0xAA0001, Stop68000, NULL); // Trap Idle 68000 AddWriteByte(0x000000, 0xFFFFFF, DefBadWriteByte, NULL); // <Bad Writes> AddWriteByte(-1, -1, NULL, NULL); AddWriteWord(0x0C0000, 0x0CFFFF, NULL, RAM+0x000000); // MAIN RAM AddWriteWord(0x240000, 0x24FFFF, NULL, RAM+0x024000); // COMMON RAM AddWriteWord(0x260000, 0x263FFF, NULL, RAM+0x034000); // OBJECT RAM AddWriteWord(0x280000, 0x293FFF, NULL, RAM+0x010000); // SCREEN RAM AddWriteWord(0x340000, 0x340007, tc0110pcr_ww, NULL); // COLOR RAM SCREEN A AddWriteWord(0x350000, 0x350007, tc0110pcr_ww_2, NULL); // COLOR RAM SCREEN B AddWriteWord(0x360000, 0x360007, tc0110pcr_ww_3, NULL); // COLOR RAM SCREEN C AddWriteWord(0x200000, 0x200003, tc0220ioc_ww_port, NULL); // INPUT AddWriteWord(0x2A0000, 0x2A000F, NULL, RAM+0x03B100); // SCROLL A AddWriteWord(0x2E0000, 0x2E000F, NULL, RAM+0x03B200); // SCROLL B AddWriteWord(0x320000, 0x32000F, NULL, RAM+0x03B300); // SCROLL C AddWriteWord(0x220000, 0x220003, tc0140syt_write_main_68k, NULL); // SOUND COMM AddWriteWord(0x000000, 0xFFFFFF, DefBadWriteWord, NULL); // <Bad Writes> AddWriteWord(-1, -1, NULL, NULL); AddInitMemory(); // Set Starscream mem pointers... AddMemFetchMC68000B(0x000000, 0x05FFFF, ROM+0x0C0000-0x000000); // 68000 ROM AddMemFetchMC68000B(-1, -1, NULL); AddReadByteMC68000B(0x000000, 0x05FFFF, NULL, ROM+0x0C0000); // 68000 ROM AddReadByteMC68000B(0x080000, 0x08FFFF, NULL, RAM2+0x000000); // SUB LOCAL RAM AddReadByteMC68000B(0x240000, 0x24FFFF, NULL, RAM+0x024000); // COMMON RAM AddReadByteMC68000B(0x260000, 0x263FFF, NULL, RAM+0x034000); // OBJECT RAM AddReadByteMC68000B(0x280000, 0x293FFF, NULL, RAM+0x010000); // SCREEN RAM AddReadByteMC68000B(0x200000, 0x200003, tc0220ioc_rb_port, NULL); // INPUT AddReadByteMC68000B(0x000000, 0xFFFFFF, DefBadReadByte, NULL); // <Bad Reads> AddReadByteMC68000B(-1, -1, NULL, NULL); AddReadWordMC68000B(0x000000, 0x05FFFF, NULL, ROM+0x0C0000); // 68000 ROM AddReadWordMC68000B(0x080000, 0x08FFFF, NULL, RAM2+0x000000); // SUB LOCAL RAM AddReadWordMC68000B(0x240000, 0x24FFFF, NULL, RAM+0x024000); // COMMON RAM AddReadWordMC68000B(0x260000, 0x263FFF, NULL, RAM+0x034000); // OBJECT RAM AddReadWordMC68000B(0x280000, 0x293FFF, NULL, RAM+0x010000); // SCREEN RAM AddReadWordMC68000B(0x340000, 0x340007, tc0110pcr_rw, NULL); // COLOR RAM SCREEN A AddReadWordMC68000B(0x350000, 0x350007, tc0110pcr_rw_2, NULL); // COLOR RAM SCREEN B AddReadWordMC68000B(0x360000, 0x360007, tc0110pcr_rw_3, NULL); // COLOR RAM SCREEN C AddReadWordMC68000B(0x200000, 0x200003, tc0220ioc_rw_port, NULL); // INPUT AddReadWordMC68000B(0x000000, 0xFFFFFF, DefBadReadWord, NULL); // <Bad Reads> AddReadWordMC68000B(-1, -1, NULL, NULL); AddWriteByteMC68000B(0x080000, 0x08FFFF, NULL, RAM2+0x000000); // SUB LOCAL RAM AddWriteByteMC68000B(0x240000, 0x24FFFF, NULL, RAM+0x024000); // COMMON RAM AddWriteByteMC68000B(0x260000, 0x263FFF, NULL, RAM+0x034000); // OBJECT RAM AddWriteByteMC68000B(0x280000, 0x293FFF, NULL, RAM+0x010000); // SCREEN RAM AddWriteByteMC68000B(0x200000, 0x200003, tc0220ioc_wb_port, NULL); // INPUT AddWriteByteMC68000B(0xAA0000, 0xAA0001, Stop68000, NULL); // Trap Idle 68000 AddWriteByteMC68000B(0x000000, 0xFFFFFF, DefBadWriteByte, NULL); // <Bad Writes> AddWriteByteMC68000B(-1, -1, NULL, NULL); AddWriteWordMC68000B(0x080000, 0x08FFFF, NULL, RAM2+0x000000); // SUB LOCAL RAM AddWriteWordMC68000B(0x240000, 0x24FFFF, NULL, RAM+0x024000); // COMMON RAM AddWriteWordMC68000B(0x260000, 0x263FFF, NULL, RAM+0x034000); // OBJECT RAM AddWriteWordMC68000B(0x280000, 0x293FFF, NULL, RAM+0x010000); // SCREEN RAM AddWriteWordMC68000B(0x340000, 0x340007, tc0110pcr_ww, NULL); // COLOR RAM SCREEN A AddWriteWordMC68000B(0x350000, 0x350007, tc0110pcr_ww_2, NULL); // COLOR RAM SCREEN B AddWriteWordMC68000B(0x360000, 0x360007, tc0110pcr_ww_3, NULL); // COLOR RAM SCREEN C AddWriteWordMC68000B(0x200000, 0x200003, tc0220ioc_ww_port, NULL); // INPUT AddWriteWordMC68000B(0x000000, 0xFFFFFF, DefBadWriteWord, NULL); // <Bad Writes> AddWriteWordMC68000B(-1, -1, NULL, NULL); AddInitMemoryMC68000B(); // Set Starscream mem pointers... }
void InitPredAlBehaviour(void* bhdata, STRATEGYBLOCK *sbPtr) { TOOLS_DATA_PAQ *toolsData; int i; LOCALASSERT(sbPtr); LOCALASSERT(bhdata); toolsData = (TOOLS_DATA_PAQ *)bhdata; /* check we're not in a net game */ if(AvP.Network != I_No_Network) { RemoveBehaviourStrategy(sbPtr); return; } /* make the assumption that the loader has initialised the strategy block sensibly... so just set the shapeIndex from the tools data & copy the name id*/ sbPtr->shapeIndex = toolsData->shapeIndex; for(i=0;i<SB_NAME_LENGTH;i++) sbPtr->SBname[i] = toolsData->nameID[i]; /* create, initialise and attach a dynamics block */ sbPtr->DynPtr = AllocateDynamicsBlock(DYNAMICS_TEMPLATE_SPRITE_NPC); if(sbPtr->DynPtr) { EULER zeroEuler = {0,0,0}; DYNAMICSBLOCK *dynPtr = sbPtr->DynPtr; dynPtr->PrevPosition = dynPtr->Position = toolsData->position; dynPtr->OrientEuler = zeroEuler; CreateEulerMatrix(&dynPtr->OrientEuler, &dynPtr->OrientMat); TransposeMatrixCH(&dynPtr->OrientMat); /* zero linear velocity in dynamics block */ dynPtr->LinVelocity.vx = 0; dynPtr->LinVelocity.vy = 0; dynPtr->LinVelocity.vz = 0; } else { RemoveBehaviourStrategy(sbPtr); return; } /* Initialise alien's stats */ { NPC_DATA *NpcData; NpcData=GetThisNpcData(I_NPC_PredatorAlien); LOCALASSERT(NpcData); sbPtr->SBDamageBlock.Health=NpcData->StartingStats.Health<<ONE_FIXED_SHIFT; sbPtr->SBDamageBlock.Armour=NpcData->StartingStats.Armour<<ONE_FIXED_SHIFT; sbPtr->SBDamageBlock.SB_H_flags=NpcData->StartingStats.SB_H_flags; } /* create, initialise and attach a predator-alien/queen data block */ sbPtr->SBdataptr = (void *)AllocateMem(sizeof(PAQ_STATUS_BLOCK)); if(sbPtr->SBdataptr) { PAQ_STATUS_BLOCK *paqStatus = (PAQ_STATUS_BLOCK *)sbPtr->SBdataptr; NPC_InitMovementData(&(paqStatus->moveData)); NPC_InitWanderData(&(paqStatus->wanderData)); paqStatus->health = PRAL_STARTING_HEALTH; paqStatus->nearSpeed = PRAL_NEAR_SPEED; paqStatus->damageInflicted = PRAL_NEAR_DAMAGE; sbPtr->integrity = paqStatus->health; paqStatus->FarBehaviourState = PAQFS_Wait; paqStatus->NearBehaviourState = PAQNS_Wait; paqStatus->stateTimer = 0; InitShapeAnimationController(&paqStatus->ShpAnimCtrl, GetShapeData(sbPtr->shapeIndex)); } else { RemoveBehaviourStrategy(sbPtr); return; } }
int main(int argc,char *argv[]) { int i=0,t1,t2,k; FILE *fsft1,*fsft2; size_t ecode; /* Reads command line arguments into the CommandLineArgs struct. In the absence of command line arguments it sets some defaults */ if (ReadCommandLine(argc,argv,&CommandLineArgs)) return 1; /* Sets global variables and sticks them into the GlobalVariables struct */ if (CreateFileList(CommandLineArgs)) return 2; if (AllocateMem(CommandLineArgs)) return 3; while(i<filenumber) { fsft1=fopen(filelist[i],"r"); /* read in the header from the file */ ecode=fread((void*)&header,sizeof(header),1,fsft1); if (ecode!=1) { fprintf(stderr,"No header in data file %s\n",filelist[i]); return 1; } /* check that data is correct endian order */ if (header.endian!=1.0) { fprintf(stderr,"First object in file %s is not (double)1.0!\n",filelist[i]); fprintf(stderr,"It could be a file format error (big/little\n"); fprintf(stderr,"endian) or the file might be corrupted\n\n"); return 2; } fclose(fsft1); t1=header.gps_sec; timestamps.gpsSeconds=header.gps_sec; timestamps.gpsNanoSeconds=header.gps_nsec; fsft2=fopen(filelist[i+CommandLineArgs.number-1],"r"); /* read in the header from the file */ ecode=fread((void*)&header,sizeof(header),1,fsft2); if (ecode!=1) { fprintf(stderr,"No header in data file %s\n",filelist[i]); return 1; } /* check that data is correct endian order */ if (header.endian!=1.0) { fprintf(stderr,"First object in file %s is not (double)1.0!\n",filelist[i]); fprintf(stderr,"It could be a file format error (big/little\n"); fprintf(stderr,"endian) or the file might be corrupted\n\n"); return 2; } fclose(fsft2); t2=header.gps_sec+sTsft; /* if( (int)((t2-t1)/lTsft +0.5) == 1) */ /* { */ fprintf(stdout,"Combining SFTs %d thru %d\n",i,i+CommandLineArgs.number-1); /* Have CommandLineArgs.number consecutive SFTs */ if (ReadSFTs(CommandLineArgs,i)) return 3; if (CSFTs(CommandLineArgs)) return 4; i += CommandLineArgs.number; /* } */ /* else i++; */ } /* Free the SFT data */ for (k=0;k<CommandLineArgs.number;k++) { LALFree(SFTData[k]->fft->data->data); LALFree(SFTData[k]->fft->data); LALFree(SFTData[k]->fft); LALFree(SFTData[k]); } LALFree(SFTData); LALFree(sinVal); LALFree(cosVal); LALCheckMemoryLeaks(); return 0; }
static void load_puchicar(void) { int ta,tb,tc; RAMSize=0x80000; if(!(RAM=AllocateMem(0x80000))) return; if(!(ROM=AllocateMem(0x200000))) return; if(!(GFX=AllocateMem(0xF17A00+0x3F0800))) return; GFX_BG0 = GFX+0xF17A00; GFX_SPR = GFX+0x000000; tb=0; if(!load_rom("e46.06", ROM, 0x200000)) return; // 16x16 SPRITES ($8000) for(ta=0;ta<0x200000;ta++,tb+=4){ WriteWord(&GFX_SPR[tb],((ROM[ta])|(ROM[ta]<<4))&0x0F0F); } tb=2; if(!load_rom("e46.04", ROM, 0x200000)) return; // 16x16 SPRITES for(ta=0;ta<0x200000;ta++,tb+=4){ WriteWord(&GFX_SPR[tb],((ROM[ta])|(ROM[ta]<<4))&0x0F0F); } tb=0; if(!load_rom("e46.02", ROM, 0x200000)) return; // 16x16 SPRITES (MASK) for(ta=0;ta<0x200000;ta++){ tc=ROM[ta]; GFX[tb+3]|=((tc&0x40)>>6)<<4; GFX[tb+2]|=((tc&0x10)>>4)<<4; GFX[tb+1]|=((tc&0x04)>>2)<<4; GFX[tb+0]|=((tc&0x01)>>0)<<4; tb+=4; } tb=0x800000; if(!load_rom("e46.05", ROM, 0x1C5E80)) return; // 16x16 SPRITES ($717A) for(ta=0;ta<0x1C5E80;ta++,tb+=4){ WriteWord(&GFX_SPR[tb],((ROM[ta])|(ROM[ta]<<4))&0x0F0F); } tb=0x800002; if(!load_rom("e46.03", ROM, 0x1C5E80)) return; // 16x16 SPRITES for(ta=0;ta<0x1C5E80;ta++,tb+=4){ WriteWord(&GFX_SPR[tb],((ROM[ta])|(ROM[ta]<<4))&0x0F0F); } tb=0x800000; if(!load_rom("e46.01", ROM, 0x1C5E80)) return; // 16x16 SPRITES (MASK) for(ta=0;ta<0x1C5E80;ta++){ tc=ROM[ta]; GFX[tb+3]|=((tc&0x40)>>6)<<4; GFX[tb+2]|=((tc&0x10)>>4)<<4; GFX[tb+1]|=((tc&0x04)>>2)<<4; GFX[tb+0]|=((tc&0x01)>>0)<<4; tb+=4; } tb=0; if(!load_rom("e46.12", ROM, 0xFC200)) return; // 16x16 TILES ($3F08) for(ta=0;ta<0xFC200;ta+=2,tb+=8){ WriteWord(&GFX_BG0[tb+0],((ROM[ta+0])|(ROM[ta+0]<<4))&0x0F0F); WriteWord(&GFX_BG0[tb+2],((ROM[ta+1])|(ROM[ta+1]<<4))&0x0F0F); } tb=4; if(!load_rom("e46.11", ROM, 0xFC200)) return; // 16x16 TILES for(ta=0;ta<0xFC200;ta+=2,tb+=8){ WriteWord(&GFX_BG0[tb+0],((ROM[ta+0])|(ROM[ta+0]<<4))&0x0F0F); WriteWord(&GFX_BG0[tb+2],((ROM[ta+1])|(ROM[ta+1]<<4))&0x0F0F); } tb=0; if(!load_rom("e46.10", ROM, 0xFC200)) return; // 16x16 TILES (MASK) for(ta=0;ta<0xFC200;ta+=2){ tc=ROM[ta]; GFX_BG0[tb+7]|=((tc&0x80)>>7)<<4; GFX_BG0[tb+6]|=((tc&0x40)>>6)<<4; GFX_BG0[tb+5]|=((tc&0x20)>>5)<<4; GFX_BG0[tb+4]|=((tc&0x10)>>4)<<4; GFX_BG0[tb+3]|=((tc&0x08)>>3)<<4; GFX_BG0[tb+2]|=((tc&0x04)>>2)<<4; GFX_BG0[tb+1]|=((tc&0x02)>>1)<<4; GFX_BG0[tb+0]|=((tc&0x01)>>0)<<4; tc=ROM[ta+1]; GFX_BG0[tb+7]|=((tc&0x80)>>7)<<5; GFX_BG0[tb+6]|=((tc&0x40)>>6)<<5; GFX_BG0[tb+5]|=((tc&0x20)>>5)<<5; GFX_BG0[tb+4]|=((tc&0x10)>>4)<<5; GFX_BG0[tb+3]|=((tc&0x08)>>3)<<5; GFX_BG0[tb+2]|=((tc&0x04)>>2)<<5; GFX_BG0[tb+1]|=((tc&0x02)>>1)<<5; GFX_BG0[tb+0]|=((tc&0x01)>>0)<<5; tb+=8; } GFX_BG0_SOLID = MakeSolidTileMap16x16(GFX_BG0, 0x3F08); GFX_SPR_SOLID = make_solid_mask_16x16(GFX_SPR, 0xF17A); FreeMem(ROM); ROM = load_region[REGION_CPU1]; // Setup 68020 Memory Map // ---------------------- AddF3MemoryMap(0x100000); RAM_BG0=RAM+0x30000; RAM_BG1=RAM+0x32000; RAM_BG2=RAM+0x34000; RAM_BG3=RAM+0x36000; RAM_SCR0=RAM+0x6A000; RAM_SCR1=RAM+0x6A002; RAM_SCR2=RAM+0x6A004; RAM_SCR3=RAM+0x6A006; SCR0_XOFS=0xF600; SCR1_XOFS=0xF700; SCR2_XOFS=0xF800; SCR3_XOFS=0xF900; SCR0_YOFS=0xFF80; SCR1_YOFS=0xFF80; SCR2_YOFS=0xFF80; SCR3_YOFS=0xFF80; // 68000 code M68000ROM = load_region[REGION_ROM2]; if(!(PCMROM=AllocateMem(0xe00004))) return; load_be("e46.09",PCMROM,0x200000); load_be("e46.08",PCMROM+0x400000,0x200000); load_be("e46.07",PCMROM+0x800000,0x200000); max_banks_this_game=6; //=memory_region_length(REGION_SOUND1)/0x400000; memset(PCMROM+0xc00000,0x0,0x200003); memset(RAM+0x00000,0x00,0x80000); memset(RAM+0x69000,0xFF,0x01000); // EEPROM HACKS // ------------ WriteWord68k(&ROM[0x0019C4],0x7F00); // raine #$00 <read/write eeprom> WriteWord68k(&ROM[0x0019C6],0x4ED6); // jmp (a6) // SPEED HACK#1 // ------------ // WriteWord68k(&ROM[0x009DC],0x7F02); // raine #$02 <stop cpu> WriteWord68k(&ROM[0x009A4],0x7F02); // raine #$02 <stop cpu> WriteWord68k(&ROM[0x009A6],0x4E71); // nop WriteWord68k(&ROM[0x009A8],0x4E71); // nop WriteWord68k(&ROM[0x009AA],0x4E71); // nop F3SystemEEPROMAccess=&F3SysEEPROMAccessMode2; set_colour_mapper(&col_map_xxxx_xxxx_rrrr_rrrr_gggg_gggg_bbbb_bbbb); InitPaletteMap(RAM+0x60000, 0x200, 0x40, 0x8000); // Init tc0003vcu emulation // ------------------------ tc0003vcu.RAM = RAM+0x20000; // Mapper disabled tc0003vcu.bmp_x = 64; tc0003vcu.bmp_y = 64; tc0003vcu.bmp_w = 320; tc0003vcu.bmp_h = 232; tc0003vcu.scr_x = 0; tc0003vcu.scr_y = 0; // Init tc0200obj emulation // ------------------------ tc0200obj.RAM = RAM+0x20000; tc0200obj.RAM_B = RAM+0x28000; tc0200obj.GFX = GFX_SPR; tc0200obj.MASK = GFX_SPR_SOLID; tc0200obj.bmp_x = 64; tc0200obj.bmp_y = 64; tc0200obj.bmp_w = 320; tc0200obj.bmp_h = 232; // Mapper disabled tc0200obj.tile_mask = 0xFFFF; tc0200obj.ofs_x = 0-0x2E; tc0200obj.ofs_y = 0-0x18; tc0200obj.cols = 32; init_tc0200obj(); init_f3_system_ioc(F3_IOC_2P_3BUTTON | F3_IOC_TRACKBALL); init_m68k(); setup_sound_68000(); }
static void load_drius2do(void) { int ta,tb; UINT8 *TMP; if(!(GFX=AllocateMem(0x400000))) return; if(!(TMP=AllocateMem(0x080000))) return; GFX_BG0 = GFX+0x000000; GFX_SPR = GFX+0x200000; tb=0; if(!load_rom("c07-03.12", TMP, 0x80000)) return; // 8x8 BG0 for(ta=0;ta<0x80000;ta+=2){ GFX_BG0[tb+1]=TMP[ta+1]&15; GFX_BG0[tb+0]=TMP[ta+1]>>4; GFX_BG0[tb+3]=TMP[ta+0]&15; GFX_BG0[tb+2]=TMP[ta+0]>>4; tb+=4; } if(!load_rom("c07-04.11", TMP, 0x80000)) return; for(ta=0;ta<0x80000;ta+=2){ GFX_BG0[tb+1]=TMP[ta+1]&15; GFX_BG0[tb+0]=TMP[ta+1]>>4; GFX_BG0[tb+3]=TMP[ta+0]&15; GFX_BG0[tb+2]=TMP[ta+0]>>4; tb+=4; } if(!load_rom("c07-05.24", TMP, 0x40000)) return; // 16x16 OBJ tb=0; for(ta=0;ta<0x40000;ta+=2){ GFX_SPR[tb+0]=TMP[ta+0]&15; GFX_SPR[tb+1]=TMP[ta+0]>>4; GFX_SPR[tb+2]=TMP[ta+1]&15; GFX_SPR[tb+3]=TMP[ta+1]>>4; tb+=16; } if(!load_rom("c07-06.27", TMP, 0x40000)) return; // 16x16 OBJ tb=4; for(ta=0;ta<0x40000;ta+=2){ GFX_SPR[tb+0]=TMP[ta+0]&15; GFX_SPR[tb+1]=TMP[ta+0]>>4; GFX_SPR[tb+2]=TMP[ta+1]&15; GFX_SPR[tb+3]=TMP[ta+1]>>4; tb+=16; } if(!load_rom("c07-07.26", TMP, 0x40000)) return; // 16x16 OBJ tb=8; for(ta=0;ta<0x40000;ta+=2){ GFX_SPR[tb+0]=TMP[ta+0]&15; GFX_SPR[tb+1]=TMP[ta+0]>>4; GFX_SPR[tb+2]=TMP[ta+1]&15; GFX_SPR[tb+3]=TMP[ta+1]>>4; tb+=16; } if(!load_rom("c07-08.25", TMP, 0x40000)) return; // 16x16 OBJ tb=12; for(ta=0;ta<0x40000;ta+=2){ GFX_SPR[tb+0]=TMP[ta+0]&15; GFX_SPR[tb+1]=TMP[ta+0]>>4; GFX_SPR[tb+2]=TMP[ta+1]&15; GFX_SPR[tb+3]=TMP[ta+1]>>4; tb+=16; } FreeMem(TMP); RAMSize=0xA0000+0x20000; if(!(ROM=AllocateMem(0x100000))) return; if(!(RAM=AllocateMem(RAMSize))) return; if(!load_rom("c07_20-1.74", RAM+0x00000, 0x20000)) return; if(!load_rom("c07_21-1.76", RAM+0x20000, 0x20000)) return; for(ta=0;ta<0x40000;ta++){ ROM[ta+ta]=RAM[ta]; } if(!load_rom("c07_19-1.73", RAM+0x00000, 0x20000)) return; if(!load_rom("c07_18-1.71", RAM+0x20000, 0x20000)) return; for(ta=0;ta<0x40000;ta++){ ROM[ta+ta+1]=RAM[ta]; } if(!load_rom("c07-09.75", ROM+0x80000, 0x80000)) return; /*-----[Sound Setup]-----*/ Z80ROM=RAM+0xA0000; if(!load_rom("c07-17.69", Z80ROM, 0x20000)) return; // Z80 SOUND ROM if(!(PCMROM=AllocateMem(0x180000))) return; if(!load_rom("c07-12.107",PCMROM+0x000000,0x80000)) return; // ADPCM A rom if(!load_rom("c07-10.95",PCMROM+0x080000,0x80000)) return; // ADPCM B rom 1/2 if(!load_rom("c07-11.96",PCMROM+0x100000,0x80000)) return; // ADPCM B rom 2/2 YM2610SetBuffers(PCMROM, PCMROM+0x080000, 0x080000, 0x100000); AddTaitoYM2610(0x0247, 0x01C7, 0x20000); /*-----------------------*/ /// Checksum Fix WriteWord68k(&ROM[0x012BE],0x4E71); // nop /// Allow Rom Versions WriteLong68k(&ROM[0x01280],0x4E714E71); // nop // 68000 Speed Hack WriteLong68k(&ROM[0x012A4],0x13FC0000); // move.b #$00,$AA0000 WriteLong68k(&ROM[0x012A8],0x00AA0000); WriteWord68k(&ROM[0x012AC],0x6100-16); // bra.s <loop> memset(RAM+0x00000,0x00,0xA0000); GFX_FG0 = RAM+0x64000; RAM_INPUT = RAM+0x3B000; tc0100scn[0].RAM = RAM+0x21000-0x6000; tc0100scn[0].GFX_FG0 = GFX_FG0; init_tc0100scn(0); GFX_BG0_SOLID = make_solid_mask_8x8 (GFX_BG0, 0x8000); GFX_SPR_SOLID = make_solid_mask_16x16(GFX_SPR, 0x2000); tc0110pcr_init_typeb(RAM+0x38000, 1, 0); tc0110pcr_init_typeb_2(RAM+0x39000, 1, 0); set_colour_mapper(&col_map_xbbb_bbgg_gggr_rrrr); InitPaletteMap(RAM+0x38000, 0x80, 0x10, 0x8000); // Init tc0220ioc emulation // ------------------------ tc0220ioc.RAM = RAM_INPUT; tc0220ioc.ctrl = 0; //TC0220_STOPCPU; reset_tc0220ioc(); memset(RAM_INPUT,0x00,0x20); /* * StarScream Stuff follows */ ByteSwap(ROM,0x80000); ByteSwap(RAM,0x60000); AddMemFetch(0x000000, 0x0FFFFF, ROM+0x000000-0x000000); // 68000 ROM AddMemFetch(-1, -1, NULL); AddReadByte(0x000000, 0x0FFFFF, NULL, ROM+0x000000); // 68000 ROM AddReadByte(0x100000, 0x10FFFF, NULL, RAM+0x000000); // MAIN RAM AddReadByte(0x600000, 0x603FFF, NULL, RAM+0x034000); // OBJECT RAM AddReadByte(0x200000, 0x213FFF, NULL, RAM+0x010000); // SCREEN RAM AddReadByte(0x800000, 0x80001F, tc0220ioc_rb, NULL); // INPUT AddReadByte(0x000000, 0xFFFFFF, DefBadReadByte, NULL); // <Bad Reads> AddReadByte(-1, -1, NULL, NULL); AddReadWord(0x000000, 0x0FFFFF, NULL, ROM+0x000000); // 68000 ROM AddReadWord(0x100000, 0x10FFFF, NULL, RAM+0x000000); // MAIN RAM AddReadWord(0x600000, 0x603FFF, NULL, RAM+0x034000); // OBJECT RAM AddReadWord(0x200000, 0x213FFF, NULL, RAM+0x010000); // SCREEN RAM AddReadWord(0x240000, 0x253FFF, NULL, RAM+0x050000); // SCREEN B AddReadWord(0x400000, 0x400007, tc0110pcr_rw, NULL); // COLOR RAM SCREEN A AddReadWord(0x420000, 0x420007, tc0110pcr_rw_2, NULL); // COLOR RAM SCREEN B AddReadWord(0x800000, 0x80001F, tc0220ioc_rw, NULL); // INPUT AddReadWord(0x830000, 0x830003, tc0140syt_read_main_68k, NULL); // SOUND AddReadWord(0x000000, 0xFFFFFF, DefBadReadWord, NULL); // <Bad Reads> AddReadWord(-1, -1, NULL, NULL); AddWriteByte(0x100000, 0x10FFFF, NULL, RAM+0x000000); // MAIN RAM AddWriteByte(0x600000, 0x603FFF, NULL, RAM+0x034000); // OBJECT RAM AddWriteByte(0x200000, 0x210FFF, NULL, RAM+0x010000); // SCREEN RAM AddWriteByte(0x211000, 0x211FFF, tc0100scn_0_gfx_fg0_wb, NULL); // FG0 GFX RAM AddWriteByte(0x212000, 0x213FFF, NULL, RAM+0x022000); // FG0 RAM AddWriteByte(0x800000, 0x80001F, tc0220ioc_wb, NULL); // INPUT AddWriteByte(0xAA0000, 0xAA0001, Stop68000, NULL); // Trap Idle 68000 AddWriteByte(0x000000, 0xFFFFFF, DefBadWriteByte, NULL); // <Bad Writes> AddWriteByte(-1, -1, NULL, NULL); AddWriteWord(0x100000, 0x10FFFF, NULL, RAM+0x000000); // MAIN RAM AddWriteWord(0x600000, 0x603FFF, NULL, RAM+0x034000); // OBJECT RAM AddWriteWord(0x200000, 0x210FFF, NULL, RAM+0x010000); // SCREEN RAM AddWriteWord(0x211000, 0x211FFF, tc0100scn_0_gfx_fg0_ww, NULL); // FG0 GFX RAM AddWriteWord(0x212000, 0x213FFF, NULL, RAM+0x022000); // FG0 RAM AddWriteWord(0x240000, 0x253FFF, NULL, RAM+0x050000); // SCREEN B AddWriteWord(0x400000, 0x400007, tc0110pcr_ww, NULL); // COLOR RAM SCREEN A AddWriteWord(0x420000, 0x420007, tc0110pcr_ww_2, NULL); // COLOR RAM SCREEN B AddWriteWord(0x800000, 0x80001F, tc0220ioc_ww, NULL); // INPUT AddWriteWord(0x220000, 0x22000F, NULL, RAM+0x03B100); // SCROLL A AddWriteWord(0x260000, 0x26000F, NULL, RAM+0x03B200); // SCROLL B AddWriteWord(0x830000, 0x830003, tc0140syt_write_main_68k, NULL); // SOUND AddWriteWord(0x000000, 0xFFFFFF, DefBadWriteWord, NULL); // <Bad Writes> AddWriteWord(-1, -1, NULL, NULL); AddInitMemory(); // Set Starscream mem pointers... }
/*----------------------Patrick 12/11/96--------------------------- Initialises pheromone systems -------------------------------------------------------------------*/ void InitPheromoneSystem(void) { int i; #if 1 /* allocate the pheromone buffers */ Pher_Player1 = (unsigned int *)AllocateMem((AIModuleArraySize+1)*sizeof(unsigned int)); if(!Pher_Player1) { memoryInitialisationFailure = 1; return; } Pher_Player2 = (unsigned int *)AllocateMem((AIModuleArraySize+1)*sizeof(unsigned int)); if(!Pher_Player2) { memoryInitialisationFailure = 1; return; } Pher_Ai1 = (unsigned char *)AllocateMem((AIModuleArraySize+1)*sizeof(unsigned char)); if(!Pher_Ai1) { memoryInitialisationFailure = 1; return; } #endif #if SUPER_PHEROMONE_SYSTEM Pher_Aliens1 = (unsigned int *)AllocateMem((AIModuleArraySize+1)*sizeof(unsigned int)); if(!Pher_Aliens1) { memoryInitialisationFailure = 1; return; } Pher_Aliens2 = (unsigned int *)AllocateMem((AIModuleArraySize+1)*sizeof(unsigned int)); if(!Pher_Aliens2) { memoryInitialisationFailure = 1; return; } Pher_Marines1 = (unsigned int *)AllocateMem((AIModuleArraySize+1)*sizeof(unsigned int)); if(!Pher_Marines1) { memoryInitialisationFailure = 1; return; } Pher_Marines2 = (unsigned int *)AllocateMem((AIModuleArraySize+1)*sizeof(unsigned int)); if(!Pher_Marines2) { memoryInitialisationFailure = 1; return; } #endif /* init the player phermone system */ for(i=0;i<AIModuleArraySize;i++) { Pher_Player1[i] = 1; Pher_Player2[i] = 1; } PherPl_ReadBuf = &Pher_Player1[0]; PherPl_WriteBuf = &Pher_Player2[0]; PlayerSmell = 3; playerPherModule = (MODULE *)0; /* init the ai pheromone system */ for(i=0;i<AIModuleArraySize;i++) { Pher_Ai1[i] = 0; } PherAi_Buf = &Pher_Ai1[0]; #if SUPER_PHEROMONE_SYSTEM for(i=0;i<AIModuleArraySize;i++) { Pher_Aliens1[i] = 0; Pher_Aliens2[i] = 0; } PherAls_ReadBuf = &Pher_Aliens1[0]; PherAls_WriteBuf = &Pher_Aliens2[0]; AlienPheromoneScale=1; for(i=0;i<AIModuleArraySize;i++) { Pher_Marines1[i] = 0; Pher_Marines2[i] = 0; } PherMars_ReadBuf = &Pher_Marines1[0]; PherMars_WriteBuf = &Pher_Marines2[0]; #endif #if logPheromoneDiagnostics printModAdj = 1; #endif }
static void load_ninjak(void) { int ta,tb; if(!(RAM=AllocateMem(0x100000))) return; if(!(GFX=AllocateMem(0x500000))) return; GFX_BG0 = GFX+0x000000; GFX_SPR = GFX+0x100000; tb=0; if(!load_rom("c85-03.10", RAM, 0x80000)) return; // 8x8 TILES for(ta=0;ta<0x80000;ta+=2){ GFX[tb+0]=RAM[ta+1]>>4; GFX[tb+1]=RAM[ta+1]&15; GFX[tb+2]=RAM[ta+0]>>4; GFX[tb+3]=RAM[ta+0]&15; tb+=4; } if(!load_rom("c85-01.16", RAM, 0x100000)) return; // 16x16 SPRITES for(ta=0;ta<0x100000;ta++){ GFX[tb++]=RAM[ta]&15; GFX[tb++]=RAM[ta]>>4; } if(!load_rom("c85-02.15", RAM, 0x100000)) return; for(ta=0;ta<0x100000;ta++){ GFX[tb++]=RAM[ta]&15; GFX[tb++]=RAM[ta]>>4; } RAMSize=0x50000; if(!(RAM=AllocateMem(RAMSize))) return; if(!(ROM=AllocateMem(0x80000))) return; if(!load_rom("c85_10x.19", RAM, 0x20000)) return; for(ta=0;ta<0x20000;ta++){ ROM[ta+ta]=RAM[ta]; } if(!load_rom("c85_xx.5", RAM, 0x20000)) return; for(ta=0;ta<0x20000;ta++){ ROM[ta+ta+1]=RAM[ta]; } if(!load_rom("c85_07.18", RAM, 0x20000)) return; for(ta=0;ta<0x20000;ta++){ ROM[ta+ta+0x40000]=RAM[ta]; } if(!load_rom("c85_06.4", RAM, 0x20000)) return; for(ta=0;ta<0x20000;ta++){ ROM[ta+ta+0x40001]=RAM[ta]; } /*-----[Sound Setup]-----*/ Z80ROM=RAM+0x40000; if(!load_rom("c85-14.6", Z80ROM, 0x10000)) return; // Z80 SOUND ROM if(!(PCMROM=AllocateMem(0x100000))) return; if(!load_rom("c85-05.11",PCMROM+0x00000,0x80000)) return; // ADPCM A rom if(!load_rom("c85-04.1",PCMROM+0x80000,0x80000)) return; // ADPCM B rom YM2610SetBuffers(PCMROM, PCMROM+0x80000, 0x80000, 0x80000); AddTaitoYM2610(0x01BB, 0x015B, 0x10000); /*-----------------------*/ memset(RAM+0x00000,0x00,0x40000); memset(RAM+0x25100,0xFF,0x01000); RAM_VIDEO = RAM+0x04000; RAM_OBJECT = RAM+0x14000; RAM_SCROLL = RAM+0x25000; GFX_FG0 = RAM+0x30000; set_colour_mapper(&col_map_rrrr_gggg_bbbb_xxxx); InitPaletteMap(RAM+0x24000, 0x100, 0x10, 0x1000); GFX_BG0_SOLID = make_solid_mask_8x8 (GFX_BG0, 0x4000); GFX_SPR_SOLID = make_solid_mask_16x16(GFX_SPR, 0x4000); ROM[0x3F32]=0x4E; // SKIP OLD CODE (NO ROOM FOR HACK) ROM[0x3F33]=0xF9; // (JMP $7FF00) ROM[0x3F34]=0x00; ROM[0x3F35]=0x07; ROM[0x3F36]=0xFF; ROM[0x3F37]=0x00; ROM[0x7FF00]=0x46; // MOVE #$2000,SR ROM[0x7FF01]=0xFC; ROM[0x7FF02]=0x20; ROM[0x7FF03]=0x00; ROM[0x7FF04]=0x13; // move.b #$00,$AA0000 ROM[0x7FF05]=0xFC; // (Speed Hack) ROM[0x7FF06]=0x00; ROM[0x7FF07]=0x00; ROM[0x7FF08]=0x00; ROM[0x7FF09]=0xAA; ROM[0x7FF0A]=0x00; ROM[0x7FF0B]=0x00; ROM[0x7FF0C]=0x60; // Loop ROM[0x7FF0D]=0x100-0x0A; // Init tc0100scn emulation // ------------------------ tc0100scn[0].layer[0].RAM =RAM_VIDEO+0x0000; tc0100scn[0].layer[0].GFX =GFX_BG0; tc0100scn[0].layer[0].MASK =GFX_BG0_SOLID; tc0100scn[0].layer[0].SCR =RAM_SCROLL+0; tc0100scn[0].layer[0].type =0; tc0100scn[0].layer[0].bmp_x =32; tc0100scn[0].layer[0].bmp_y =32; tc0100scn[0].layer[0].bmp_w =320; tc0100scn[0].layer[0].bmp_h =224; // Mapper disabled tc0100scn[0].layer[0].tile_mask=0x3FFF; tc0100scn[0].layer[0].scr_x =16; tc0100scn[0].layer[0].scr_y =8; tc0100scn[0].layer[1].RAM =RAM_VIDEO+0x8000; tc0100scn[0].layer[1].GFX =GFX_BG0; tc0100scn[0].layer[1].MASK =GFX_BG0_SOLID; tc0100scn[0].layer[1].SCR =RAM_SCROLL+2; tc0100scn[0].layer[1].type =0; tc0100scn[0].layer[1].bmp_x =32; tc0100scn[0].layer[1].bmp_y =32; tc0100scn[0].layer[1].bmp_w =320; tc0100scn[0].layer[1].bmp_h =224; // Mapper disabled tc0100scn[0].layer[1].tile_mask=0x3FFF; tc0100scn[0].layer[1].scr_x =16; tc0100scn[0].layer[1].scr_y =8; tc0100scn[0].layer[2].RAM =RAM_VIDEO+0x4000; tc0100scn[0].layer[2].GFX =GFX_FG0; tc0100scn[0].layer[2].SCR =RAM_SCROLL+4; tc0100scn[0].layer[2].type =3; tc0100scn[0].layer[2].bmp_x =32; tc0100scn[0].layer[2].bmp_y =32; tc0100scn[0].layer[2].bmp_w =320; tc0100scn[0].layer[2].bmp_h =224; // Mapper disabled tc0100scn[0].layer[2].scr_x =16; tc0100scn[0].layer[2].scr_y =8; tc0100scn[0].RAM = RAM_VIDEO; tc0100scn[0].GFX_FG0 = GFX_FG0; init_tc0100scn(0); // Init tc0200obj emulation // ------------------------ tc0200obj.RAM = RAM_OBJECT+0x0000; tc0200obj.RAM_B = RAM_OBJECT+0x8000; tc0200obj.GFX = GFX_SPR; tc0200obj.MASK = GFX_SPR_SOLID; tc0200obj.bmp_x = 32; tc0200obj.bmp_y = 32; tc0200obj.bmp_w = 320; tc0200obj.bmp_h = 224; // Mapper disabled tc0200obj.tile_mask = 0x3FFF; tc0200obj.ofs_x = 0 - 0x13; tc0200obj.ofs_y = 0 - 0x60; init_tc0200obj(); /* * StarScream Stuff follows */ ByteSwap(ROM,0x80000); ByteSwap(RAM,0x2C000); AddMemFetch(0x000000, 0x07FFFF, ROM+0x000000-0x000000); // 68000 ROM AddMemFetch(-1, -1, NULL); AddReadByte(0x000000, 0x07FFFF, NULL, ROM+0x000000); // 68000 ROM AddReadByte(0x100000, 0x103FFF, NULL, RAM+0x000000); // 68000 RAM AddReadByte(0x800000, 0x80FFFF, NULL, RAM_VIDEO); // SCREEN RAM AddReadByte(0x900000, 0x90FFFF, NULL, RAM_OBJECT); // OBJECT RAM AddReadByte(0x300000, 0x30000F, NULL, RAM+0x025100); // INPUT AddReadByte(0x400000, 0x400003, tc0140syt_read_main_68k, NULL); // SOUND COMM AddReadByte(0x000000, 0xFFFFFF, DefBadReadByte, NULL); // <Bad Reads> AddReadByte(-1, -1, NULL, NULL); AddReadWord(0x000000, 0x07FFFF, NULL, ROM+0x000000); // 68000 ROM AddReadWord(0x100000, 0x103FFF, NULL, RAM+0x000000); // 68000 RAM AddReadWord(0x800000, 0x80FFFF, NULL, RAM_VIDEO); // SCREEN RAM AddReadWord(0x900000, 0x90FFFF, NULL, RAM_OBJECT); // OBJECT RAM AddReadWord(0x200000, 0x200FFF, NULL, RAM+0x024000); // COLOR RAM AddReadWord(0x000000, 0xFFFFFF, BadReadWord, NULL); // <Bad Reads> AddReadWord(-1, -1, NULL, NULL); AddWriteByte(0x100000, 0x103FFF, NULL, RAM+0x000000); // 68000 RAM AddWriteByte(0x806000, 0x806FFF, tc0100scn_0_gfx_fg0_wb, NULL); // FG0 GFX RAM AddWriteByte(0x800000, 0x80FFFF, NULL, RAM_VIDEO); // SCREEN RAM AddWriteByte(0x900000, 0x90FFFF, NULL, RAM_OBJECT); // OBJECT RAM AddWriteByte(0x400000, 0x400003, tc0140syt_write_main_68k, NULL); // SOUND COMM AddWriteByte(0xAA0000, 0xAA0001, Stop68000, NULL); // Trap Idle 68000 AddWriteByte(0x000000, 0xFFFFFF, DefBadWriteByte, NULL); // <Bad Writes> AddWriteByte(-1, -1, NULL, NULL); AddWriteWord(0x100000, 0x103FFF, NULL, RAM+0x000000); // 68000 RAM AddWriteWord(0x806000, 0x806FFF, tc0100scn_0_gfx_fg0_ww, NULL); // FG0 GFX RAM AddWriteWord(0x800000, 0x80FFFF, NULL, RAM_VIDEO); // SCREEN RAM AddWriteWord(0x900000, 0x90FFFF, NULL, RAM_OBJECT); // OBJECT RAM AddWriteWord(0x200000, 0x200FFF, NULL, RAM+0x024000); // COLOR RAM AddWriteWord(0x820000, 0x82000F, NULL, RAM_SCROLL); // SCROLL RAM AddWriteWord(0x380000, 0x38000F, NULL, RAM+0x025180); // ??? AddWriteWord(0x600000, 0x60000F, NULL, RAM+0x025280); // SPRITE BANK AddWriteWord(0xB00000, 0xB0001F, NULL, RAM+0x025300); // ? AddWriteWord(0x000000, 0xFFFFFF, DefBadWriteWord, NULL); // <Bad Writes> AddWriteWord(-1, -1, NULL, NULL); AddInitMemory(); // Set Starscream mem pointers... }
static void load_masterw(void) { int ta,tb,tc; RAMSize=0x38000; if(!(RAM=AllocateMem(0x80000))) return; if(!(GFX=AllocateMem(0x240000))) return; GFX_BG0 = GFX+0x000000; GFX_BG2 = GFX+0x200000; if(!load_rom("mow-m01.rom", RAM, 0x80000)) return; tb=0x200000; for(ta=0;ta<0x10000;ta+=2){ tc=RAM[ta+1]; GFX[tb+0]=((tc&0x80)>>7)<<0; GFX[tb+1]=((tc&0x40)>>6)<<0; GFX[tb+2]=((tc&0x20)>>5)<<0; GFX[tb+3]=((tc&0x10)>>4)<<0; GFX[tb+4]=((tc&0x08)>>3)<<0; GFX[tb+5]=((tc&0x04)>>2)<<0; GFX[tb+6]=((tc&0x02)>>1)<<0; GFX[tb+7]=((tc&0x01)>>0)<<0; tc=RAM[ta]; GFX[tb+0]|=((tc&0x80)>>7)<<1; GFX[tb+1]|=((tc&0x40)>>6)<<1; GFX[tb+2]|=((tc&0x20)>>5)<<1; GFX[tb+3]|=((tc&0x10)>>4)<<1; GFX[tb+4]|=((tc&0x08)>>3)<<1; GFX[tb+5]|=((tc&0x04)>>2)<<1; GFX[tb+6]|=((tc&0x02)>>1)<<1; GFX[tb+7]|=((tc&0x01)>>0)<<1; tb+=8; } tb=0; for(ta=0;ta<0x80000;ta+=2){ tc=RAM[ta+1]; GFX[tb+0]=((tc&0x80)>>7)<<0; GFX[tb+1]=((tc&0x40)>>6)<<0; GFX[tb+2]=((tc&0x20)>>5)<<0; GFX[tb+3]=((tc&0x10)>>4)<<0; GFX[tb+4]=((tc&0x08)>>3)<<0; GFX[tb+5]=((tc&0x04)>>2)<<0; GFX[tb+6]=((tc&0x02)>>1)<<0; GFX[tb+7]=((tc&0x01)>>0)<<0; tc=RAM[ta]; GFX[tb+0]|=((tc&0x80)>>7)<<1; GFX[tb+1]|=((tc&0x40)>>6)<<1; GFX[tb+2]|=((tc&0x20)>>5)<<1; GFX[tb+3]|=((tc&0x10)>>4)<<1; GFX[tb+4]|=((tc&0x08)>>3)<<1; GFX[tb+5]|=((tc&0x04)>>2)<<1; GFX[tb+6]|=((tc&0x02)>>1)<<1; GFX[tb+7]|=((tc&0x01)>>0)<<1; tb+=16; if((tb&0x7F)==0){tb-=0x78;} else{if((tb&0x7F)==8){tb-=0x08;}} } if(!load_rom("mow-m02.rom", RAM, 0x80000)) return; tb=0x200000; for(ta=0;ta<0x10000;ta+=2){ tc=RAM[ta+1]; GFX[tb+0]|=((tc&0x80)>>7)<<2; GFX[tb+1]|=((tc&0x40)>>6)<<2; GFX[tb+2]|=((tc&0x20)>>5)<<2; GFX[tb+3]|=((tc&0x10)>>4)<<2; GFX[tb+4]|=((tc&0x08)>>3)<<2; GFX[tb+5]|=((tc&0x04)>>2)<<2; GFX[tb+6]|=((tc&0x02)>>1)<<2; GFX[tb+7]|=((tc&0x01)>>0)<<2; tc=RAM[ta]; GFX[tb+0]|=((tc&0x80)>>7)<<3; GFX[tb+1]|=((tc&0x40)>>6)<<3; GFX[tb+2]|=((tc&0x20)>>5)<<3; GFX[tb+3]|=((tc&0x10)>>4)<<3; GFX[tb+4]|=((tc&0x08)>>3)<<3; GFX[tb+5]|=((tc&0x04)>>2)<<3; GFX[tb+6]|=((tc&0x02)>>1)<<3; GFX[tb+7]|=((tc&0x01)>>0)<<3; tb+=8; } tb=0; for(ta=0;ta<0x80000;ta+=2){ tc=RAM[ta+1]; GFX[tb+0]|=((tc&0x80)>>7)<<2; GFX[tb+1]|=((tc&0x40)>>6)<<2; GFX[tb+2]|=((tc&0x20)>>5)<<2; GFX[tb+3]|=((tc&0x10)>>4)<<2; GFX[tb+4]|=((tc&0x08)>>3)<<2; GFX[tb+5]|=((tc&0x04)>>2)<<2; GFX[tb+6]|=((tc&0x02)>>1)<<2; GFX[tb+7]|=((tc&0x01)>>0)<<2; tc=RAM[ta]; GFX[tb+0]|=((tc&0x80)>>7)<<3; GFX[tb+1]|=((tc&0x40)>>6)<<3; GFX[tb+2]|=((tc&0x20)>>5)<<3; GFX[tb+3]|=((tc&0x10)>>4)<<3; GFX[tb+4]|=((tc&0x08)>>3)<<3; GFX[tb+5]|=((tc&0x04)>>2)<<3; GFX[tb+6]|=((tc&0x02)>>1)<<3; GFX[tb+7]|=((tc&0x01)>>0)<<3; tb+=16; if((tb&0x7F)==0){tb-=0x78;} else{if((tb&0x7F)==8){tb-=0x08;}} } Rotate16x16(GFX_BG0,0x2000); Flip16x16_X(GFX_BG0,0x2000); Rotate8x8 (GFX_BG2,0x1000); Flip8x8_X (GFX_BG2,0x1000); /*-----[Sound Setup]-----*/ Z80ROM=RAM+0x28000; if(!load_rom("b72-07.rom", Z80ROM, 0x10000)) return; // Z80 SOUND ROM AddTaitoYM2203(0x02CB, 0x025C, 0x10000, NULL, 0x00000); /*-----------------------*/ memset(RAM+0x00000,0x00,0x28000); RAM_INPUT = RAM+0x25100; RAM_VIDEO = RAM+0x04000; RAM_COLOUR = RAM+0x24000; GFX_BG0_SOLID = make_solid_mask_16x16(GFX_BG0, 0x2000); GFX_BG2_SOLID = make_solid_mask_8x8 (GFX_BG2, 0x1000); InitPaletteMap(RAM_COLOUR, 0x40, 0x10, 0x1000); set_colour_mapper(&col_map_rrrr_gggg_bbbb_xxxx); WriteLong68k(&ROM[0x0742],0x13FC0000); // move.b #$00,$AA0000 WriteLong68k(&ROM[0x0746],0x00AA0000); WriteWord68k(&ROM[0x074A],0x4E71); // nop // Init tc0220ioc emulation // ------------------------ tc0220ioc.RAM = input_buffer; tc0220ioc.ctrl = 0; //TC0220_STOPCPU; reset_tc0220ioc(); // Init tc0180vcu emulation // ------------------------ tc0180vcu.RAM = RAM_VIDEO; tc0180vcu.RAM_2 = RAM_VIDEO+0x18000; tc0180vcu.GFX_BG0 = GFX_BG0; tc0180vcu.GFX_BG0_MSK= GFX_BG0_SOLID; tc0180vcu.GFX_BG2 = GFX_BG2; tc0180vcu.GFX_BG2_MSK= GFX_BG2_SOLID; tc0180vcu.tile_mask = 0x1FFF; tc0180vcu.bmp_x = 32; tc0180vcu.bmp_y = 32; tc0180vcu.bmp_w = 224; tc0180vcu.bmp_h = 320; tc0180vcu.scr_x = 16; tc0180vcu.scr_y = 0; vcu_make_col_bankmap(0x10,0x30,0x20,0x10,0x00); /* * StarScream Stuff follows */ ByteSwap(ROM,0x80000); ByteSwap(RAM,0x25000); AddMemFetch(0x000000, 0x07FFFF, ROM+0x000000-0x000000); // 68000 ROM AddMemFetch(-1, -1, NULL); AddReadByte(0x000000, 0x07FFFF, NULL, ROM+0x000000); // 68000 ROM AddReadByte(0x200000, 0x203FFF, NULL, RAM+0x000000); // 68000 RAM AddReadByte(0x400000, 0x41FFFF, NULL, RAM_VIDEO); // SCREEN RAM AddReadByte(0x600000, 0x600FFF, NULL, RAM_COLOUR); // COLOR RAM AddReadByte(0x800000, 0x800003, tc0220ioc_rb_port, NULL); // INPUT AddReadByte(0xA00000, 0xA00003, tc0140syt_read_main_68k, NULL); // SOUND AddReadByte(0x000000, 0xFFFFFF, DefBadReadByte, NULL); // <Bad Reads> AddReadByte(-1, -1, NULL, NULL); AddReadWord(0x000000, 0x07FFFF, NULL, ROM+0x000000); // 68000 ROM AddReadWord(0x200000, 0x203FFF, NULL, RAM+0x000000); // 68000 RAM AddReadWord(0x400000, 0x41FFFF, NULL, RAM_VIDEO); // SCREEN RAM AddReadWord(0x600000, 0x600FFF, NULL, RAM_COLOUR); // COLOR RAM AddReadWord(0x800000, 0x800003, tc0220ioc_rw_port, NULL); // INPUT AddReadWord(0x000000, 0xFFFFFF, DefBadReadWord, NULL); // <Bad Reads> AddReadWord(-1, -1,NULL, NULL); AddWriteByte(0x200000, 0x203FFF, NULL, RAM+0x000000); // 68000 RAM AddWriteByte(0x400000, 0x41FFFF, NULL, RAM_VIDEO); // SCREEN RAM AddWriteByte(0x600000, 0x600FFF, NULL, RAM_COLOUR); // COLOR RAM AddWriteByte(0x800000, 0x800003, tc0220ioc_wb_port, NULL); // INPUT AddWriteByte(0xA00000, 0xA00003, tc0140syt_write_main_68k, NULL); // SOUND AddWriteByte(0xAA0000, 0xAA0001, Stop68000, NULL); // Trap Idle 68000 AddWriteByte(0x000000, 0xFFFFFF, DefBadWriteByte, NULL); // <Bad Writes> AddWriteByte(-1, -1, NULL, NULL); AddWriteWord(0x200000, 0x203FFF, NULL, RAM+0x000000); // 68000 RAM AddWriteWord(0x400000, 0x41FFFF, NULL, RAM_VIDEO); // SCREEN RAM AddWriteWord(0x600000, 0x600FFF, NULL, RAM_COLOUR); // COLOR RAM AddWriteWord(0x800000, 0x800003, tc0220ioc_ww_port, NULL); // INPUT AddWriteWord(0x000000, 0xFFFFFF, DefBadWriteWord, NULL); // <Bad Writes> AddWriteWord(-1, -1, NULL, NULL); AddInitMemory(); // Set Starscream mem pointers... }
void* LiftDoorBehaveInit(void* bhdata, STRATEGYBLOCK* sbptr) { LIFT_DOOR_BEHAV_BLOCK *doorbhv; LIFT_DOOR_TOOLS_TEMPLATE *doortt; MORPHCTRL* morphctrl; MORPHHEADER* morphheader; MORPHFRAME* morphframe; MODULE * my_mod; doorbhv = (LIFT_DOOR_BEHAV_BLOCK*)AllocateMem(sizeof(LIFT_DOOR_BEHAV_BLOCK)); if (!doorbhv) { memoryInitialisationFailure = 1; return ((void *)NULL); } doorbhv->bhvr_type = I_BehaviourLiftDoor; // from loaders doortt = (LIFT_DOOR_TOOLS_TEMPLATE*)bhdata; // Set up a new Morph Control morphctrl = (MORPHCTRL*)AllocateMem(sizeof(MORPHCTRL)); if (!morphctrl) { memoryInitialisationFailure = 1; return ((void *)NULL); } morphheader = (MORPHHEADER*)AllocateMem(sizeof(MORPHHEADER)); if (!morphheader) { memoryInitialisationFailure = 1; return ((void *)NULL); } morphframe = (MORPHFRAME*)AllocateMem(sizeof(MORPHFRAME)); if (!morphframe) { memoryInitialisationFailure = 1; return ((void *)NULL); } morphframe->mf_shape1 = doortt->shape_open; morphframe->mf_shape2 = doortt->shape_closed; morphheader->mph_numframes = 1; morphheader->mph_maxframes = ONE_FIXED; morphheader->mph_frames = morphframe; morphctrl->ObMorphCurrFrame = 0; morphctrl->ObMorphFlags = 0; morphctrl->ObMorphSpeed = 0; morphctrl->ObMorphHeader = morphheader; // Copy the name over COPY_NAME (sbptr->SBname, doortt->nameID); // Setup module ref { MREF mref=doortt->my_module; ConvertModuleNameToPointer (&mref, MainSceneArray[0]->sm_marray); my_mod = mref.mref_ptr; } GLOBALASSERT (my_mod); my_mod->m_sbptr = sbptr; sbptr->SBmoptr = my_mod; sbptr->SBmomptr = my_mod->m_mapptr; sbptr->SBflags.no_displayblock = 1; doorbhv->door_state = doortt->state; doorbhv->PDmctrl = morphctrl; doorbhv->door_closing_speed=doortt->door_closing_speed; doorbhv->door_opening_speed=doortt->door_opening_speed; // all lift doors have a closed starting state except the // one where the lift is - fill in other data sbptr->SBmorphctrl = doorbhv->PDmctrl; if(doorbhv->door_state == I_door_open) { sbptr->SBmorphctrl->ObMorphCurrFrame = 0; OpenDoor(sbptr->SBmorphctrl, DOOR_OPENFASTSPEED); } else { GLOBALASSERT(doorbhv->door_state == I_door_closed); sbptr->SBmorphctrl->ObMorphCurrFrame = 1; CloseDoor(sbptr->SBmorphctrl, DOOR_CLOSEFASTSPEED); } doorbhv->request_state = doorbhv->door_state; // copy data into relevant structures sbptr->SBmorphctrl = doorbhv->PDmctrl; if(sbptr->SBmoptr) { sbptr->SBmoptr->m_flags |= m_flag_open; } if(sbptr->SBmomptr) { sbptr->SBmomptr->MapMorphHeader = sbptr->SBmorphctrl->ObMorphHeader; } doorbhv->SoundHandle=SOUND_NOACTIVEINDEX; return((void*)doorbhv); }
static void load_opwolf(void) { UINT8 *TMP; int ta,tb; if (is_current_game("opwolf")) romset = 0; else if (is_current_game("opwolfb")) romset = 1; RAMSize=0x60000; set_reset_function(clear_ram); if(!(RAM=AllocateMem(0x80000))) return; if(!(ROM=AllocateMem(0x40000))) return; if(!(GFX=AllocateMem(0x200000))) return; GFX_SPR = GFX+0x100000; Z80ROM2=RAM+0x50000; // C-CHIP ROM/RAM if(romset==1){ // BOOTLEG tb=0; if(!load_rom("opwlfb.08", RAM+0x00000, 0x10000)) return; // 8x8 TILES if(!load_rom("opwlfb.06", RAM+0x10000, 0x10000)) return; // 8x8 TILES if(!load_rom("opwlfb.07", RAM+0x20000, 0x10000)) return; // 8x8 TILES if(!load_rom("opwlfb.05", RAM+0x30000, 0x10000)) return; // 8x8 TILES if(!load_rom("opwlfb.04", RAM+0x40000, 0x10000)) return; // 8x8 TILES if(!load_rom("opwlfb.02", RAM+0x50000, 0x10000)) return; // 8x8 TILES if(!load_rom("opwlfb.03", RAM+0x60000, 0x10000)) return; // 8x8 TILES if(!load_rom("opwlfb.01", RAM+0x70000, 0x10000)) return; // 8x8 TILES for(ta=0;ta<0x40000;ta++,tb+=4){ GFX[tb+0]=RAM[ta+0x00000]>>4; GFX[tb+1]=RAM[ta+0x00000]&15; GFX[tb+2]=RAM[ta+0x40000]>>4; GFX[tb+3]=RAM[ta+0x40000]&15; } if(!load_rom("opwlfb.14", RAM+0x00000, 0x10000)) return; // 16x16 TILES if(!load_rom("opwlfb.15", RAM+0x10000, 0x10000)) return; // 16x16 TILES if(!load_rom("opwlfb.16", RAM+0x20000, 0x10000)) return; // 16x16 TILES if(!load_rom("opwlfb.17", RAM+0x30000, 0x10000)) return; // 16x16 TILES if(!load_rom("opwlfb.18", RAM+0x40000, 0x10000)) return; // 16x16 TILES if(!load_rom("opwlfb.19", RAM+0x50000, 0x10000)) return; // 16x16 TILES if(!load_rom("opwlfb.20", RAM+0x60000, 0x10000)) return; // 16x16 TILES if(!load_rom("opwlfb.21", RAM+0x70000, 0x10000)) return; // 16x16 TILES for(ta=0;ta<0x40000;ta++,tb+=4){ GFX[tb+0]=RAM[ta+0x00000]>>4; GFX[tb+1]=RAM[ta+0x00000]&15; GFX[tb+2]=RAM[ta+0x40000]>>4; GFX[tb+3]=RAM[ta+0x40000]&15; } if(!load_rom("opwlfb.12", RAM, 0x10000)) return; // 68000 ROM for(ta=0;ta<0x10000;ta++){ ROM[ta+ta]=RAM[ta]; } if(!load_rom("opwlfb.10", RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta+1]=RAM[ta]; } if(!load_rom("opwlfb.13", RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta+0x20000]=RAM[ta]; } if(!load_rom("opwlfb.11", RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta+0x20001]=RAM[ta]; } if(!load_rom("opwlfb.09", Z80ROM2, 0x8000)) return; // Z80 C-CHIP ROM }
extern void CreateFlamingDebris(VECTORCH *positionPtr, VECTORCH *dirPtr) { STRATEGYBLOCK* sbPtr; /* create and initialise a strategy block */ sbPtr = CreateActiveStrategyBlock(); if(!sbPtr) return; /* failure */ InitialiseSBValues(sbPtr); sbPtr->I_SBtype = I_BehaviourFragment; AssignNewSBName(sbPtr); sbPtr->SBdataptr = (void*)AllocateMem(sizeof(ONE_SHOT_BEHAV_BLOCK)); if (sbPtr->SBdataptr == 0) { // Failed to allocate a strategy block data pointer RemoveBehaviourStrategy(sbPtr); return; } ((ONE_SHOT_BEHAV_BLOCK * ) sbPtr->SBdataptr)->counter = ((FastRandom()&32768)<<2) + 65535*2; /* create, initialise and attach a dynamics block */ sbPtr->DynPtr = AllocateDynamicsBlock(DYNAMICS_TEMPLATE_ALIEN_DEBRIS); if(sbPtr->DynPtr) { DYNAMICSBLOCK *dynPtr = sbPtr->DynPtr; dynPtr->PrevPosition = dynPtr->Position = *positionPtr; dynPtr->OrientEuler.EulerX = 0; dynPtr->OrientEuler.EulerY = FastRandom()&4095; dynPtr->OrientEuler.EulerZ = 0; CreateEulerMatrix(&dynPtr->OrientEuler, &dynPtr->OrientMat); TransposeMatrixCH(&dynPtr->OrientMat); dynPtr->LinImpulse.vx = dirPtr->vx/4; dynPtr->LinImpulse.vy = dirPtr->vy/4; if (dynPtr->LinImpulse.vy>0) dynPtr->LinImpulse.vy=-dynPtr->LinImpulse.vy; dynPtr->LinImpulse.vy += -4000; dynPtr->LinImpulse.vz = dirPtr->vz/4; dynPtr->AngVelocity.EulerX = (((FastRandom()&2047)-1023))<<2; dynPtr->AngVelocity.EulerY = (((FastRandom()&2047)-1023))<<2; dynPtr->AngVelocity.EulerZ = (((FastRandom()&2047)-1023))<<2; dynPtr->Elasticity = ONE_FIXED/4; } else { /* dynamics block allocation failed... */ RemoveBehaviourStrategy(sbPtr); return; } sbPtr->shapeIndex = GetLoadedShapeMSL("Shell"); sbPtr->maintainVisibility = 0; sbPtr->containingModule = ModuleFromPosition(&(sbPtr->DynPtr->Position), 0); LOCALASSERT(sbPtr->containingModule); if(!(sbPtr->containingModule)) { /* no containing module can be found... abort*/ RemoveBehaviourStrategy(sbPtr); return; } { MODULE tempModule; DISPLAYBLOCK *dPtr; DYNAMICSBLOCK *dynPtr = sbPtr->DynPtr; VisibilityDefaultObjectMap.MapShape = sbPtr->shapeIndex; tempModule.m_mapptr = &VisibilityDefaultObjectMap; tempModule.m_sbptr = (STRATEGYBLOCK*)NULL; tempModule.m_numlights = 0; tempModule.m_lightarray = (struct lightblock *)0; tempModule.m_extraitemdata = (struct extraitemdata *)0; tempModule.m_dptr = NULL; /* this is important */ tempModule.name = NULL; /* this is important */ AllocateModuleObject(&tempModule); dPtr = tempModule.m_dptr; if(dPtr==NULL) { RemoveBehaviourStrategy(sbPtr); return; } sbPtr->SBdptr = dPtr; dPtr->ObStrategyBlock = sbPtr; dPtr->ObMyModule = NULL; dPtr->ObWorld = dynPtr->Position; dPtr->ObEuler = dynPtr->OrientEuler; dPtr->ObMat = dynPtr->OrientMat; /* make displayblock a dynamic module object */ dPtr->ObFlags3 |= ObFlag3_DynamicModuleObject; sbPtr->SBDamageBlock.IsOnFire=1; } }
static void load_metalb(void) { int ta,tb; if(!(GFX=AllocateMem(0x400000))) return; if(!(RAM=AllocateMem(0x100000))) return; GFX_BG0 = GFX+0x000000; GFX_SPR = GFX+0x200000; tb=0; if(!load_rom_index(0, RAM, 0x100000)) return; // 16x16 SPRITES ($2000) for(ta=0;ta<0x100000;ta++,tb+=2){ GFX_SPR[tb+0]=RAM[ta]&15; GFX_SPR[tb+1]=RAM[ta]>>4; } tb=0; if(!load_rom_index(2, RAM, 0x80000)) return; // 16x16 TILES ($2000) for(ta=0;ta<0x80000;ta+=2,tb+=8){ GFX_BG0[tb+0]=RAM[ta]&15; GFX_BG0[tb+1]=RAM[ta]>>4; GFX_BG0[tb+2]=RAM[ta+1]&15; GFX_BG0[tb+3]=RAM[ta+1]>>4; } tb=4; if(!load_rom_index(3, RAM, 0x80000)) return; // 16x16 TILES for(ta=0;ta<0x80000;ta+=2,tb+=8){ GFX_BG0[tb+0]=RAM[ta]&15; GFX_BG0[tb+1]=RAM[ta]>>4; GFX_BG0[tb+2]=RAM[ta+1]&15; GFX_BG0[tb+3]=RAM[ta+1]>>4; } FreeMem(RAM); memset(GFX_SPR+0x000F00,0x00,0x100); // Mask Sprite memset(GFX_SPR+0x168C00,0x00,0x100); // Sun Sprite RAMSize=0x40000+0x20000; if(!(RAM=AllocateMem(RAMSize))) return; if(!(ROM=AllocateMem(0xC0000))) return; if(!load_rom_index(8, RAM, 0x40000)) return; for(ta=0;ta<0x40000;ta++){ ROM[ta+ta]=RAM[ta]; } if(!load_rom_index(7, RAM, 0x40000)) return; for(ta=0;ta<0x40000;ta++){ ROM[ta+ta+1]=RAM[ta]; } if(!load_rom_index(6, RAM, 0x20000)) return; for(ta=0;ta<0x20000;ta++){ ROM[ta+ta+0x80000]=RAM[ta]; } if(!load_rom_index(5, RAM, 0x20000)) return; for(ta=0;ta<0x20000;ta++){ ROM[ta+ta+0x80001]=RAM[ta]; } /*-----[Sound Setup]-----*/ Z80ROM=RAM+0x40000; if(!load_rom_index(9, Z80ROM, 0x20000)) return; // Z80 SOUND ROM if(!(PCMROM=AllocateMem(0x180000))) return; if(!load_rom_index(4,PCMROM+0x00000,0x080000)) return; // ADPCM A rom if(!load_rom_index(1,PCMROM+0x80000,0x100000)) return; // ADPCM B rom YM2610SetBuffers(PCMROM, PCMROM+0x80000, 0x080000, 0x100000); AddTaitoYM2610(0x0217, 0x0180, 0x20000); /*-----------------------*/ memset(RAM+0x00000,0x00,0x40000); memset(RAM+0x34100,0xFF,0x00020); if(is_current_game("metalb")){ WriteWord68k(&ROM[0x0248E],0x4EF9); // jmp $300 WriteLong68k(&ROM[0x02490],0x00000300); WriteLong68k(&ROM[0x00300],0x4EB820DE); // jsr <random gen> WriteLong68k(&ROM[0x00304],0x13FC0000); // move.b #$00,$AA0000 WriteLong68k(&ROM[0x00308],0x00AA0000); WriteWord68k(&ROM[0x0030C],0x6100-14); // bra.s <loop> } else{ WriteWord68k(&ROM[0x024BA],0x4EF9); // jmp $300 WriteLong68k(&ROM[0x024BC],0x00000300); WriteLong68k(&ROM[0x00300],0x4EB8210A); // jsr <random gen> WriteLong68k(&ROM[0x00304],0x13FC0000); // move.b #$00,$AA0000 WriteLong68k(&ROM[0x00308],0x00AA0000); WriteWord68k(&ROM[0x0030C],0x6100-14); // bra.s <loop> } RAM_OBJECT = RAM+0x10000; RAM_INPUT = RAM+0x34100; GFX_BG0_SOLID = make_solid_mask_16x16(GFX_BG0, 0x2000); GFX_SPR_SOLID = make_solid_mask_16x16(GFX_SPR, 0x2000); InitPaletteMap(RAM+0x30000, 0x200, 0x10, 0x1000); set_colour_mapper(&col_map_rrrr_gggg_bbbb_xxxx); RAM_BG0=RAM+0x23000; RAM_BG1=RAM+0x22000; RAM_BG2=RAM+0x21000; RAM_BG3=RAM+0x20000; RAM_SCR0=RAM+0x34006; RAM_SCR1=RAM+0x34004; RAM_SCR2=RAM+0x34002; RAM_SCR3=RAM+0x34000; RAM_SCR4=RAM+0x34018; SCR0_XOFS=0x0036; SCR1_XOFS=0x0032; SCR2_XOFS=0x002E; SCR3_XOFS=0x002A; SCR4_XOFS=0x0039; SCR0_YOFS=0x0014; SCR1_YOFS=0x0014; SCR2_YOFS=0x0014; SCR3_YOFS=0x0014; SCR4_YOFS=0x0014; // Init tc0006vcu emulation // ------------------------ if(!(tc0006vcu.GFX_FG = AllocateMem(0x4000))) return; tc0006vcu.RAM = RAM+0x20000; tc0006vcu.RAM_SCR = RAM+0x34000; tc0006vcu.GFX_BG = GFX_BG0; tc0006vcu.GFX_BG_MASK= GFX_BG0_SOLID; tc0006vcu.tile_mask = 0x1FFF; tc0006vcu.mapper = &Map_12bit_RGBx; tc0006vcu.pal_ofs = 0x100; tc0006vcu.bmp_x = 48; tc0006vcu.bmp_y = 48; tc0006vcu.bmp_w = 320; tc0006vcu.bmp_h = 224; tc0006vcu.scr_x[0] = SCR0_XOFS; tc0006vcu.scr_x[1] = SCR1_XOFS; tc0006vcu.scr_x[2] = SCR2_XOFS; tc0006vcu.scr_x[3] = SCR3_XOFS; tc0006vcu.scr_x[4] = SCR4_XOFS; tc0006vcu.scr_y[0] = SCR0_YOFS; tc0006vcu.scr_y[1] = SCR1_YOFS; tc0006vcu.scr_y[2] = SCR2_YOFS; tc0006vcu.scr_y[3] = SCR3_YOFS; tc0006vcu.scr_y[4] = SCR4_YOFS; init_tc0006vcu(); // Init tc0200obj emulation // ------------------------ tc0200obj.RAM = RAM_OBJECT+0x0000; tc0200obj.RAM_B = RAM_OBJECT+0x8000; tc0200obj.GFX = GFX_SPR; tc0200obj.MASK = GFX_SPR_SOLID; tc0200obj.bmp_x = 48; tc0200obj.bmp_y = 48; tc0200obj.bmp_w = 320; tc0200obj.bmp_h = 224; tc0200obj.mapper = &Map_12bit_RGBx; tc0200obj.tile_mask = 0x1FFF; tc0200obj.ofs_x = 0; tc0200obj.ofs_y = 0; tc0200obj.cols = 16; init_tc0200obj(); // Init tc0220ioc emulation // ------------------------ tc0220ioc.RAM = input_buffer; tc0220ioc.ctrl = 0; //TC0220_STOPCPU; reset_tc0220ioc(); /* * StarScream Stuff follows */ ByteSwap(ROM,0xC0000); ByteSwap(RAM,0x40000); AddMemFetch(0x000000, 0x0BFFFF, ROM+0x000000-0x000000); // 68000 ROM AddMemFetch(-1, -1, NULL); AddReadByte(0x000000, 0x0BFFFF, NULL, ROM+0x000000); // 68000 ROM AddReadByte(0x100000, 0x10FFFF, NULL, RAM+0x000000); // 68000 RAM AddReadByte(0x300000, 0x30FFFF, NULL, RAM_OBJECT); // OBJECT RAM AddReadByte(0x500000, 0x50FFFF, NULL, RAM+0x020000); // SCREEN RAM AddReadByte(0x700000, 0x703FFF, NULL, RAM+0x030000); // COLOR RAM AddReadByte(0x800000, 0x80000F, tc0220ioc_rb_bswap, NULL); // INPUT AddReadByte(0x900000, 0x900003, tc0140syt_read_main_68k, NULL); // SOUND COMM AddReadByte(0x000000, 0xFFFFFF, DefBadReadByte, NULL); // <Bad Reads> AddReadByte(-1, -1, NULL, NULL); AddReadWord(0x000000, 0x0BFFFF, NULL, ROM+0x000000); // 68000 ROM AddReadWord(0x100000, 0x10FFFF, NULL, RAM+0x000000); // 68000 RAM AddReadWord(0x300000, 0x30FFFF, NULL, RAM_OBJECT); // OBJECT RAM AddReadWord(0x500000, 0x50FFFF, NULL, RAM+0x020000); // SCREEN RAM AddReadWord(0x700000, 0x703FFF, NULL, RAM+0x030000); // COLOR RAM AddReadWord(0x800000, 0x80000F, tc0220ioc_rw_bswap, NULL); // INPUT AddReadWord(0x000000, 0xFFFFFF, DefBadReadWord, NULL); // <Bad Reads> AddReadWord(-1, -1,NULL, NULL); AddWriteByte(0x100000, 0x10FFFF, NULL, RAM+0x000000); // 68000 RAM AddWriteByte(0x300000, 0x30FFFF, NULL, RAM_OBJECT); // OBJECT RAM AddWriteByte(0x500000, 0x50DFFF, NULL, RAM+0x020000); // SCREEN RAM AddWriteByte(0x50E000, 0x50FFFF, tc0006vcu_gfx_fg0_wb, NULL); // FG0 GFX RAM AddWriteByte(0x700000, 0x703FFF, NULL, RAM+0x030000); // COLOR RAM AddWriteByte(0x900000, 0x900003, tc0140syt_write_main_68k, NULL); // SOUND COMM AddWriteByte(0x800000, 0x80000F, tc0220ioc_wb_bswap, NULL); // INPUT AddWriteByte(0xAA0000, 0xAA0001, Stop68000, NULL); // Trap Idle 68000 AddWriteByte(0x000000, 0xFFFFFF, DefBadWriteByte, NULL); // <Bad Writes> AddWriteByte(-1, -1, NULL, NULL); AddWriteWord(0x100000, 0x10FFFF, NULL, RAM+0x000000); // 68000 RAM AddWriteWord(0x300000, 0x30FFFF, NULL, RAM_OBJECT); // OBJECT RAM AddWriteWord(0x500000, 0x50DFFF, NULL, RAM+0x020000); // SCREEN RAM AddWriteWord(0x50E000, 0x50FFFF, tc0006vcu_gfx_fg0_ww, NULL); // FG0 GFX RAM AddWriteWord(0x700000, 0x703FFF, NULL, RAM+0x030000); // COLOR RAM AddWriteWord(0x530000, 0x5300FF, NULL, RAM+0x034000); // SCROLL AddWriteWord(0x800000, 0x80000F, tc0220ioc_ww_bswap, NULL); // INPUT AddWriteWord(0x000000, 0xFFFFFF, BadWriteWord, NULL); // <Bad Writes> AddWriteWord(-1, -1, NULL, NULL); AddInitMemory(); // Set Starscream mem pointers... }
static void load_pbobbl2x(void) { int ta,tb,tc; RAMSize=0x80000; if(!(RAM=AllocateMem(0x80000))) return; if(!(ROM=AllocateMem(0x100000))) return; if(!(GFX=AllocateMem(0x3F5D00+0x3EC700))) return; GFX_BG0 = GFX+0x3F5D00; GFX_SPR = GFX+0x000000; tb=0; if(!load_rom("e10-02.rom", ROM, 0xFD740)) return; // 16x16 SPRITES ($3F5D) for(ta=0;ta<0xFD740;ta++){ GFX[tb++]=ROM[ta]&15; GFX[tb++]=ROM[ta]>>4; tb+=2; } tb=2; if(!load_rom("e10-01.rom", ROM, 0xFD740)) return; // 16x16 SPRITES for(ta=0;ta<0xFD740;ta++){ GFX[tb++]=ROM[ta]&15; GFX[tb++]=ROM[ta]>>4; tb+=2; } tb=0; if(!load_rom("e10-07.rom", ROM, 0xFB1C0)) return; // 16x16 TILES ($3EC7) for(ta=0;ta<0xFB1C0;ta+=2){ GFX_BG0[tb++]=ROM[ta]&15; GFX_BG0[tb++]=ROM[ta]>>4; GFX_BG0[tb++]=ROM[ta+1]&15; GFX_BG0[tb++]=ROM[ta+1]>>4; tb+=4; } tb=4; if(!load_rom("e10-06.rom", ROM, 0xFB1C0)) return; // 16x16 TILES for(ta=0;ta<0xFB1C0;ta+=2){ GFX_BG0[tb++]=ROM[ta]&15; GFX_BG0[tb++]=ROM[ta]>>4; GFX_BG0[tb++]=ROM[ta+1]&15; GFX_BG0[tb++]=ROM[ta+1]>>4; tb+=4; } tb=0; if(!load_rom("e10-05.rom", ROM, 0xFB1C0)) return; // 16x16 TILES (MASK) for(ta=0;ta<0xFB1C0;ta+=2){ tc=ROM[ta]; GFX_BG0[tb+7]|=((tc&0x80)>>7)<<4; GFX_BG0[tb+6]|=((tc&0x40)>>6)<<4; GFX_BG0[tb+5]|=((tc&0x20)>>5)<<4; GFX_BG0[tb+4]|=((tc&0x10)>>4)<<4; GFX_BG0[tb+3]|=((tc&0x08)>>3)<<4; GFX_BG0[tb+2]|=((tc&0x04)>>2)<<4; GFX_BG0[tb+1]|=((tc&0x02)>>1)<<4; GFX_BG0[tb+0]|=((tc&0x01)>>0)<<4; tc=ROM[ta+1]; GFX_BG0[tb+7]|=((tc&0x80)>>7)<<5; GFX_BG0[tb+6]|=((tc&0x40)>>6)<<5; GFX_BG0[tb+5]|=((tc&0x20)>>5)<<5; GFX_BG0[tb+4]|=((tc&0x10)>>4)<<5; GFX_BG0[tb+3]|=((tc&0x08)>>3)<<5; GFX_BG0[tb+2]|=((tc&0x04)>>2)<<5; GFX_BG0[tb+1]|=((tc&0x02)>>1)<<5; GFX_BG0[tb+0]|=((tc&0x01)>>0)<<5; tb+=8; } GFX_BG0_SOLID = make_solid_mask_16x16(GFX_BG0, 0x3EC7); GFX_SPR_SOLID = make_solid_mask_16x16(GFX_SPR, 0x3F5D); GFX_BG0_PENS = make_colour_count_16x16(GFX_BG0, 0x3EC7); // Setup 68020 Memory Map // ---------------------- AddF3MemoryMap(0x100000); RAM_BG0=RAM+0x33000; RAM_BG1=RAM+0x32000; RAM_BG2=RAM+0x31000; RAM_BG3=RAM+0x30000; RAM_SCR0=RAM+0x6A006; RAM_SCR1=RAM+0x6A004; RAM_SCR2=RAM+0x6A002; RAM_SCR3=RAM+0x6A000; SCR3_XOFS=0xF640; SCR2_XOFS=0xF740; SCR1_XOFS=0xF840; SCR0_XOFS=0xF940; SCR3_YOFS=0xF400; SCR2_YOFS=0xF400; SCR1_YOFS=0xF400; SCR0_YOFS=0xF400; if(!load_rom("e10.29", RAM, 0x40000)) return; for(ta=0;ta<0x40000;ta++){ ROM[(ta<<2)+0]=RAM[ta]; } if(!load_rom("e10.28", RAM, 0x40000)) return; for(ta=0;ta<0x40000;ta++){ ROM[(ta<<2)+1]=RAM[ta]; } if(!load_rom("e10.27", RAM, 0x40000)) return; for(ta=0;ta<0x40000;ta++){ ROM[(ta<<2)+2]=RAM[ta]; } if(!load_rom("e10.26", RAM, 0x40000)) return; for(ta=0;ta<0x40000;ta++){ ROM[(ta<<2)+3]=RAM[ta]; } // 68000 code M68000ROM = load_region[REGION_ROM2]; if(!(PCMROM=AllocateMem(0x800000))) return; load_be("e10-03.rom",PCMROM,0x200000); load_be("e10-04.rom",PCMROM+0x400000,0x200000); max_banks_this_game=3; //=memory_region_length(REGION_SOUND1)/0x400000; memset(RAM+0x00000,0x00,0x80000); memset(RAM+0x69000,0xFF,0x01000); // EEPROM ACCESS // ------------- WriteWord68k(&ROM[0x0044D2],0x7F00); // raine #$00 <eeprom access> WriteWord68k(&ROM[0x0044D4],0x4ED6); // jmp (a6) // SPEED HACK // ---------- WriteWord68k(&ROM[0x031D4],0x4EF9); // jmp $F8000 WriteLong68k(&ROM[0x031D6],0x000F8000); WriteWord68k(&ROM[0xF8000],0x4EB9); // jsr $0291C <random gen> WriteLong68k(&ROM[0xF8002],0x0000291C); WriteWord68k(&ROM[0xF8006],0x7F02); // raine #$02 <stop cpu> WriteWord68k(&ROM[0xF8008],0x6100-10); // bra.s <loop> F3SystemEEPROMAccess=&F3SysEEPROMAccessMode2; set_colour_mapper(&col_map_xxxx_xxxx_rrrr_rrrr_gggg_gggg_bbbb_bbbb); InitPaletteMap(RAM+0x60000, 0x200, 0x40, 0x8000); // Init tc0003vcu emulation // ------------------------ tc0003vcu.RAM = RAM+0x20000; tc0003vcu.mapper = &Map_24bit_xRGB; tc0003vcu.bmp_x = 64; tc0003vcu.bmp_y = 64; tc0003vcu.bmp_w = 320; tc0003vcu.bmp_h = 232; tc0003vcu.scr_x = 0; tc0003vcu.scr_y = 0; // Init tc0200obj emulation // ------------------------ tc0200obj.RAM = RAM+0x20000; tc0200obj.RAM_B = RAM+0x28000; tc0200obj.GFX = GFX_SPR; tc0200obj.MASK = GFX_SPR_SOLID; tc0200obj.bmp_x = 64; tc0200obj.bmp_y = 64; tc0200obj.bmp_w = 320; tc0200obj.bmp_h = 232; tc0200obj.mapper = &Map_24bit_xRGB; tc0200obj.tile_mask = 0x3FFF; tc0200obj.ofs_x = 0-0x2E; tc0200obj.ofs_y = 0-0x18; tc0200obj.cols = 16; init_tc0200obj(); init_f3_system_ioc(F3_IOC_2P_3BUTTON); init_m68k(); setup_sound_68000(); }
void* LinkSwitchBehaveInit(void* bhdata, STRATEGYBLOCK* sbptr) { LINK_SWITCH_BEHAV_BLOCK *ls_bhv; LINK_SWITCH_TOOLS_TEMPLATE *ls_tt; int i; GLOBALASSERT(sbptr); ls_bhv = (LINK_SWITCH_BEHAV_BLOCK*)AllocateMem(sizeof(LINK_SWITCH_BEHAV_BLOCK)); if(!ls_bhv) { memoryInitialisationFailure = 1; return ((void *)NULL); } ls_bhv->bhvr_type = I_BehaviourLinkSwitch; // from loaders // 1 rest_state - on or off // 2 mode // 3 timer switch - time for reset // 4 security clerance to operate // 5 copy the target name ls_tt = (LINK_SWITCH_TOOLS_TEMPLATE*)bhdata; sbptr->shapeIndex = ls_tt->shape_num; COPY_NAME(sbptr->SBname, ls_tt->nameID); if (ls_tt->mode == I_lswitch_SELFDESTRUCT) { ls_bhv->ls_mode = I_lswitch_timer; ls_bhv->IS_SELF_DESTRUCT = Yes; } else { ls_bhv->ls_mode = ls_tt->mode; ls_bhv->IS_SELF_DESTRUCT = No; } ls_bhv->num_targets=ls_tt->num_targets; if(ls_bhv->num_targets) { ls_bhv->ls_targets = (LINK_SWITCH_TARGET*)AllocateMem(sizeof(LINK_SWITCH_TARGET) * ls_tt->num_targets); if (!ls_bhv->ls_targets) { memoryInitialisationFailure = 1; return ((void *)NULL); } } else { ls_bhv->ls_targets=0; } for (i=0; i<ls_tt->num_targets; i++) { ls_bhv->ls_targets[i]=ls_tt->targets[i]; ls_bhv->ls_targets[i].sbptr = 0; } ls_bhv->time_for_reset = ls_tt->time_for_reset; ls_bhv->security_clerance = ls_tt->security_clearance; ls_bhv->switch_flags=ls_tt->switch_flags; ls_bhv->trigger_volume_min=ls_tt->trigger_volume_min; ls_bhv->trigger_volume_max=ls_tt->trigger_volume_max; ls_bhv->switch_always_on = ls_tt->switch_always_on; ls_bhv->switch_off_message_same=ls_tt->switch_off_message_same; ls_bhv->switch_off_message_none=ls_tt->switch_off_message_none; if(sbptr->DynPtr) //there may be no shape { sbptr->DynPtr->Position = sbptr->DynPtr->PrevPosition = ls_tt->position; sbptr->DynPtr->OrientEuler = ls_tt->orientation; CreateEulerMatrix(&sbptr->DynPtr->OrientEuler, &sbptr->DynPtr->OrientMat); TransposeMatrixCH(&sbptr->DynPtr->OrientMat); } // set up the animation control if(sbptr->shapeIndex!=-1) { int item_num; TXACTRLBLK **pptxactrlblk; int shape_num = ls_tt->shape_num; SHAPEHEADER *shptr = GetShapeData(shape_num); SetupPolygonFlagAccessForShape(shptr); pptxactrlblk = &ls_bhv->ls_tac; for(item_num = 0; item_num < shptr->numitems; item_num ++) { POLYHEADER *poly = (POLYHEADER*)(shptr->items[item_num]); LOCALASSERT(poly); if((Request_PolyFlags((void *)poly)) & iflag_txanim) { TXACTRLBLK *pnew_txactrlblk; int num_seq = 0; pnew_txactrlblk = AllocateMem(sizeof(TXACTRLBLK)); if (pnew_txactrlblk) { pnew_txactrlblk->tac_flags = 0; pnew_txactrlblk->tac_item = item_num; pnew_txactrlblk->tac_sequence = ls_tt->rest_state; pnew_txactrlblk->tac_node = 0; pnew_txactrlblk->tac_txarray = GetTxAnimArrayZ(shape_num, item_num); pnew_txactrlblk->tac_txah_s = GetTxAnimHeaderFromShape(pnew_txactrlblk, shape_num); while(pnew_txactrlblk->tac_txarray[num_seq+1])num_seq++; // Assert does not work at this point so GLOBALASSERT(num_seq==2); /* set the flags in the animation header */ // we only ever have one frame of animation per sequence - // nb this can change talk to richard - one sequence with two frames // or mutliple sequences??? //Now two sequences with an arbitrary number of frames - Richard pnew_txactrlblk->tac_txah.txa_flags |= txa_flag_play; /* change the value held in pptxactrlblk which point to the previous structures "next" pointer*/ *pptxactrlblk = pnew_txactrlblk; pptxactrlblk = &pnew_txactrlblk->tac_next; } else { memoryInitialisationFailure = 1; } } } *pptxactrlblk=0; } else { //no shape - so there won't be any animation ls_bhv->ls_tac=0; } ls_bhv->ls_dtype = linkswitch_no_display; if (ls_bhv->ls_tac) { ls_bhv->ls_dtype = linkswitch_animate_me; } ls_bhv->ls_track=ls_tt->track; if (ls_bhv->ls_track) { ls_bhv->ls_track->sbptr=sbptr; if (ls_bhv->ls_dtype == linkswitch_animate_me) { ls_bhv->ls_dtype = linkswitch_animate_and_move_me; } else { ls_bhv->ls_dtype = linkswitch_move_me; } } // fill in the rest ourselves ls_bhv->request = 0; ls_bhv->state = ls_tt->rest_state; ls_bhv->timer = 0; ls_bhv->system_state = 0; ls_bhv->soundHandle = SOUND_NOACTIVEINDEX; ls_bhv->num_linked_switches=ls_tt->num_linked_switches; if(ls_tt->num_linked_switches) ls_bhv->lswitch_list=(LSWITCH_ITEM*)AllocateMem(sizeof(LSWITCH_ITEM)*ls_bhv->num_linked_switches); else ls_bhv->lswitch_list=0; for (i=0; i<ls_tt->num_linked_switches; i++) { COPY_NAME (ls_bhv->lswitch_list[i].bs_name, ls_tt->switchIDs[i].name); } if(ls_bhv->state) { ls_bhv->timer=ls_bhv->time_for_reset; if(ls_bhv->ls_track) { //set the track to the end position ls_bhv->ls_track->current_section=(ls_bhv->ls_track->num_sections-1); ls_bhv->ls_track->timer=ls_bhv->ls_track->sections[ls_bhv->ls_track->current_section].time_for_section; ls_bhv->ls_track->playing=1; Update_Track_Position(ls_bhv->ls_track); } } ls_bhv->TimeUntilNetSynchAllowed=0; return((void*)ls_bhv); }
static void load_darius2(void) { int ta,tb,tc,td; UINT8 *TMP; setup_z80_frame(CPU_Z80_0,CPU_FRAME_MHz(8,60)); romset = 1; if(!(TMP=AllocateMem(0x80000))) return; if(!(GFX=AllocateMem(0x400000))) return; GFX_BG0 = GFX+0x000000; GFX_SPR = GFX+0x200000; tb=0; if(!load_rom("c07-03.12", TMP, 0x80000)) return; // 8x8 BACKGROUND TILES for(ta=0;ta<0x80000;ta+=2){ GFX[tb+1]=TMP[ta+1]&15; GFX[tb+0]=TMP[ta+1]>>4; GFX[tb+3]=TMP[ta+0]&15; GFX[tb+2]=TMP[ta+0]>>4; tb+=4; } if(!load_rom("c07-04.11", TMP, 0x80000)) return; for(ta=0;ta<0x80000;ta+=2){ GFX[tb+1]=TMP[ta+1]&15; GFX[tb+0]=TMP[ta+1]>>4; GFX[tb+3]=TMP[ta+0]&15; GFX[tb+2]=TMP[ta+0]>>4; tb+=4; } if(!load_rom("c07-01", TMP, 0x80000)) return; // 16x16 SPRITES for(ta=0;ta<0x80000;ta+=0){ for(td=0;td<2;td++){ tc=TMP[ta++]; GFX[tb+3]=(((tc&0x80)>>7)<<1); GFX[tb+2]=(((tc&0x40)>>6)<<1); GFX[tb+1]=(((tc&0x20)>>5)<<1); GFX[tb+0]=(((tc&0x10)>>4)<<1); GFX[tb+3]|=(((tc&0x08)>>3)<<0); GFX[tb+2]|=(((tc&0x04)>>2)<<0); GFX[tb+1]|=(((tc&0x02)>>1)<<0); GFX[tb+0]|=(((tc&0x01)>>0)<<0); tc=TMP[ta++]; GFX[tb+3]|=(((tc&0x80)>>7)<<3); GFX[tb+2]|=(((tc&0x40)>>6)<<3); GFX[tb+1]|=(((tc&0x20)>>5)<<3); GFX[tb+0]|=(((tc&0x10)>>4)<<3); GFX[tb+3]|=(((tc&0x08)>>3)<<2); GFX[tb+2]|=(((tc&0x04)>>2)<<2); GFX[tb+1]|=(((tc&0x02)>>1)<<2); GFX[tb+0]|=(((tc&0x01)>>0)<<2); tb+=4; } tb+=8; if((tb&0x7F)==0){tb-=0x78;} else{if((tb&0x7F)==8){tb-=8;}} } if(!load_rom("c07-02", TMP, 0x80000)) return; // 16x16 SPRITES for(ta=0;ta<0x80000;ta+=0){ for(td=0;td<2;td++){ tc=TMP[ta++]; GFX[tb+3]=(((tc&0x80)>>7)<<1); GFX[tb+2]=(((tc&0x40)>>6)<<1); GFX[tb+1]=(((tc&0x20)>>5)<<1); GFX[tb+0]=(((tc&0x10)>>4)<<1); GFX[tb+3]|=(((tc&0x08)>>3)<<0); GFX[tb+2]|=(((tc&0x04)>>2)<<0); GFX[tb+1]|=(((tc&0x02)>>1)<<0); GFX[tb+0]|=(((tc&0x01)>>0)<<0); tc=TMP[ta++]; GFX[tb+3]|=(((tc&0x80)>>7)<<3); GFX[tb+2]|=(((tc&0x40)>>6)<<3); GFX[tb+1]|=(((tc&0x20)>>5)<<3); GFX[tb+0]|=(((tc&0x10)>>4)<<3); GFX[tb+3]|=(((tc&0x08)>>3)<<2); GFX[tb+2]|=(((tc&0x04)>>2)<<2); GFX[tb+1]|=(((tc&0x02)>>1)<<2); GFX[tb+0]|=(((tc&0x01)>>0)<<2); tb+=4; } tb+=8; if((tb&0x7F)==0){tb-=0x78;} else{if((tb&0x7F)==8){tb-=8;}} } FreeMem(TMP); RAMSize=0xA0000+0x20000; if(!(ROM=AllocateMem(0x120000))) return; if(!(RAM=AllocateMem(RAMSize))) return; if(!load_rom("c07-32-1", RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta]=RAM[ta]; } if(!load_rom("c07-29-1", RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta+1]=RAM[ta]; } if(!load_rom("c07-31-1", RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta+0x20000]=RAM[ta]; } if(!load_rom("c07-30-1", RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta+0x20001]=RAM[ta]; } //if(!load_rom("c07-09.bin", ROM+0x40000, 0x80000)) return; //ByteSwap(ROM+0x40000,0x80000); if(!load_rom("c07-27", RAM, 0x20000)) return; for(ta=0;ta<0x20000;ta++){ ROM[ta+ta+0x40000]=RAM[ta]; } if(!load_rom("c07-25", RAM, 0x20000)) return; for(ta=0;ta<0x20000;ta++){ ROM[ta+ta+0x40001]=RAM[ta]; } if(!load_rom("c07-26", RAM, 0x20000)) return; for(ta=0;ta<0x20000;ta++){ ROM[ta+ta+0x80000]=RAM[ta]; } if(!load_rom("c07-24", RAM, 0x20000)) return; for(ta=0;ta<0x20000;ta++){ ROM[ta+ta+0x80001]=RAM[ta]; } if(!load_rom("c07-35-1", RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta+0xC0000]=RAM[ta]; } if(!load_rom("c07-38-1", RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta+0xC0001]=RAM[ta]; } if(!load_rom("c07-34-1", RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta+0xE0000]=RAM[ta]; } if(!load_rom("c07-37-1", RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta+0xE0001]=RAM[ta]; } if(!load_rom("c07-33-1", RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta+0x100000]=RAM[ta]; } if(!load_rom("c07-36-1", RAM, 0x10000)) return; for(ta=0;ta<0x10000;ta++){ ROM[ta+ta+0x100001]=RAM[ta]; } /*-----[Sound Setup]-----*/ Z80ROM=RAM+0xA0000; if(!load_rom("c07-28", Z80ROM, 0x20000)) return; // Z80 SOUND ROM AddTaitoYM2610(0x0247, 0x01C7, 0x20000); /*-----------------------*/ ROM[0x10F4]=0x60; // Fix Main Checksum ROM[0x1172]=0x60; // Fix Sub Checksum/communication problem ROM[0x11E4]=0x4E; // jmp $300 ROM[0x11E5]=0xF9; ROM[0x11E6]=0x00; ROM[0x11E7]=0x00; ROM[0x11E8]=0x03; ROM[0x11E9]=0x00; ROM[0x0300]=0x52; // addq #1,$C10A0 ROM[0x0301]=0x79; ROM[0x0302]=0x00; ROM[0x0303]=0x0C; ROM[0x0304]=0x10; ROM[0x0305]=0xA0; ROM[0x0306]=0x13; // move.b #$00,$AA0000 ROM[0x0307]=0xFC; // Speed Hack ROM[0x0308]=0x00; ROM[0x0309]=0x00; ROM[0x030A]=0x00; ROM[0x030B]=0xAA; ROM[0x030C]=0x00; ROM[0x030D]=0x00; ROM[0x030E]=0x60; ROM[0x030F]=0x100-16; ROM[0xC0932]=0x60; // Fix Sub Checksum ROM[0xC097E]=0x4E; // jmp $300 ROM[0xC097F]=0xF9; ROM[0xC0980]=0x00; ROM[0xC0981]=0x00; ROM[0xC0982]=0x03; ROM[0xC0983]=0x00; ROM[0xC0300]=0x52; // addq #1,$C10A0 ROM[0xC0301]=0x79; ROM[0xC0302]=0x00; ROM[0xC0303]=0x08; ROM[0xC0304]=0x0C; ROM[0xC0305]=0x94; ROM[0xC0306]=0x13; // move.b #$00,$AA0000 ROM[0xC0307]=0xFC; // Speed Hack ROM[0xC0308]=0x00; ROM[0xC0309]=0x00; ROM[0xC030A]=0x00; ROM[0xC030B]=0xAA; ROM[0xC030C]=0x00; ROM[0xC030D]=0x00; ROM[0xC030E]=0x60; ROM[0xC030F]=0x100-16; memset(RAM+0x00000,0x00,0xA0000); GFX_FG0 = RAM+0x64000; RAM_INPUT = RAM+0x3B000; tc0100scn[0].RAM = RAM+0x21000-0x6000; tc0100scn[0].GFX_FG0 = GFX_FG0; init_tc0100scn(0); GFX_BG0_SOLID = make_solid_mask_8x8 (GFX_BG0, 0x8000); init_tile_cachex4(); GFX_SPR_SOLID = make_solid_mask_16x16(GFX_SPR, 0x2000); tc0110pcr_init_typeb(RAM+0x38000, 1, 0); tc0110pcr_init_typeb_2(RAM+0x39000, 1, 0); tc0110pcr_init_typeb_3(RAM+0x3A000, 1, 0); set_colour_mapper(&col_map_xbbb_bbgg_gggr_rrrr); InitPaletteMap(RAM+0x38000, 0x80, 0x10, 0x8000); // Init tc0220ioc emulation // ------------------------ tc0220ioc.RAM = RAM_INPUT; tc0220ioc.ctrl = 0; //TC0220_STOPCPU; reset_tc0220ioc(); memset(RAM_INPUT,0x00,0x20); /* * StarScream Stuff follows */ ByteSwap(ROM,0x120000); ByteSwap(RAM,0x60000); AddMemFetch(0x000000, 0x0BFFFF, ROM+0x000000-0x000000); // 68000 ROM AddMemFetch(-1, -1, NULL); AddReadByte(0x000000, 0x0BFFFF, NULL, ROM+0x000000); // 68000 ROM AddReadByte(0x0C0000, 0x0CFFFF, NULL, RAM+0x000000); // MAIN RAM AddReadByte(0x240000, 0x24FFFF, NULL, RAM+0x024000); // COMMON RAM AddReadByte(0x260000, 0x263FFF, NULL, RAM+0x034000); // OBJECT RAM AddReadByte(0x280000, 0x293FFF, NULL, RAM+0x010000); // SCREEN RAM AddReadByte(0x200000, 0x200003, tc0220ioc_rb_port, NULL); // INPUT AddReadByte(0x000000, 0xFFFFFF, DefBadReadByte, NULL); // <Bad Reads> AddReadByte(-1, -1, NULL, NULL); AddReadWord(0x000000, 0x0BFFFF, NULL, ROM+0x000000); // 68000 ROM AddReadWord(0x0C0000, 0x0CFFFF, NULL, RAM+0x000000); // MAIN RAM AddReadWord(0x240000, 0x24FFFF, NULL, RAM+0x024000); // COMMON RAM AddReadWord(0x260000, 0x263FFF, NULL, RAM+0x034000); // OBJECT RAM AddReadWord(0x280000, 0x293FFF, NULL, RAM+0x010000); // SCREEN RAM AddReadWord(0x340000, 0x340007, tc0110pcr_rw, NULL); // COLOR RAM SCREEN A AddReadWord(0x350000, 0x350007, tc0110pcr_rw_2, NULL); // COLOR RAM SCREEN B AddReadWord(0x360000, 0x360007, tc0110pcr_rw_3, NULL); // COLOR RAM SCREEN C AddReadWord(0x200000, 0x200003, tc0220ioc_rw_port, NULL); // INPUT AddReadWord(0x2C0000, 0x2D3FFF, NULL, RAM+0x050000); // CUSTOM2 AddReadWord(0x300000, 0x313FFF, NULL, RAM+0x064000); // CUSTOM3 AddReadWord(0x220000, 0x220003, tc0140syt_read_main_68k, NULL); // SOUND AddReadWord(0x000000, 0xFFFFFF, DefBadReadWord, NULL); // <Bad Reads> AddReadWord(-1, -1, NULL, NULL); AddWriteByte(0x0C0000, 0x0CFFFF, NULL, RAM+0x000000); // MAIN RAM AddWriteByte(0x240000, 0x24FFFF, NULL, RAM+0x024000); // COMMON RAM AddWriteByte(0x260000, 0x263FFF, NULL, RAM+0x034000); // OBJECT RAM AddWriteByte(0x280000, 0x290FFF, NULL, RAM+0x010000); // SCREEN RAM AddWriteByte(0x291000, 0x291FFF, tc0100scn_0_gfx_fg0_wb, NULL); // FG0 GFX RAM AddWriteByte(0x292000, 0x293FFF, NULL, RAM+0x022000); // FG0 RAM AddWriteByte(0x200000, 0x200003, tc0220ioc_wb_port, NULL); // INPUT AddWriteByte(0xAA0000, 0xAA0001, Stop68000, NULL); // Trap Idle 68000 AddWriteByte(0x000000, 0xFFFFFF, DefBadWriteByte, NULL); // <Bad Writes> AddWriteByte(-1, -1, NULL, NULL); AddWriteWord(0x0C0000, 0x0CFFFF, NULL, RAM+0x000000); // MAIN RAM AddWriteWord(0x240000, 0x24FFFF, NULL, RAM+0x024000); // COMMON RAM AddWriteWord(0x260000, 0x263FFF, NULL, RAM+0x034000); // OBJECT RAM AddWriteWord(0x280000, 0x290FFF, NULL, RAM+0x010000); // SCREEN RAM AddWriteWord(0x291000, 0x291FFF, tc0100scn_0_gfx_fg0_ww, NULL); // FG0 GFX RAM AddWriteWord(0x292000, 0x293FFF, NULL, RAM+0x022000); // FG0 RAM AddWriteWord(0x340000, 0x340007, tc0110pcr_ww, NULL); // COLOR RAM SCREEN A AddWriteWord(0x350000, 0x350007, tc0110pcr_ww_2, NULL); // COLOR RAM SCREEN B AddWriteWord(0x360000, 0x360007, tc0110pcr_ww_3, NULL); // COLOR RAM SCREEN C AddWriteWord(0x200000, 0x200003, tc0220ioc_ww_port, NULL); // INPUT AddWriteWord(0x2A0000, 0x2A000F, NULL, RAM+0x03B100); // SCROLL A AddWriteWord(0x2E0000, 0x2E000F, NULL, RAM+0x03B200); // SCROLL B AddWriteWord(0x320000, 0x32000F, NULL, RAM+0x03B300); // SCROLL C AddWriteWord(0x2C0000, 0x2D3FFF, NULL, RAM+0x050000); // CUSTOM2 AddWriteWord(0x300000, 0x313FFF, NULL, RAM+0x064000); // CUSTOM3 AddWriteWord(0x220000, 0x220003, tc0140syt_write_main_68k, NULL); // SOUND AddWriteWord(0x000000, 0xFFFFFF, DefBadWriteWord, NULL); // <Bad Writes> AddWriteWord(-1, -1, NULL, NULL); AddInitMemory(); // Set Starscream mem pointers... AddMemFetchMC68000B(0x000000, 0x05FFFF, ROM+0x0C0000-0x000000); // 68000 ROM AddMemFetchMC68000B(-1, -1, NULL); AddReadByteMC68000B(0x000000, 0x05FFFF, NULL, ROM+0x0C0000); // 68000 ROM AddReadByteMC68000B(0x080000, 0x08FFFF, NULL, RAM+0x040000); // SUB LOCAL RAM AddReadByteMC68000B(0x240000, 0x24FFFF, NULL, RAM+0x024000); // COMMON RAM AddReadByteMC68000B(0x260000, 0x263FFF, NULL, RAM+0x034000); // OBJECT RAM AddReadByteMC68000B(0x280000, 0x293FFF, NULL, RAM+0x010000); // SCREEN RAM AddReadByteMC68000B(0x200000, 0x200003, tc0220ioc_rb_port, NULL); // INPUT AddReadByteMC68000B(0x000000, 0xFFFFFF, DefBadReadByte, NULL); // <Bad Reads> AddReadByteMC68000B(-1, -1, NULL, NULL); AddReadWordMC68000B(0x000000, 0x05FFFF, NULL, ROM+0x0C0000); // 68000 ROM AddReadWordMC68000B(0x080000, 0x08FFFF, NULL, RAM+0x040000); // SUB LOCAL RAM AddReadWordMC68000B(0x240000, 0x24FFFF, NULL, RAM+0x024000); // COMMON RAM AddReadWordMC68000B(0x260000, 0x263FFF, NULL, RAM+0x034000); // OBJECT RAM AddReadWordMC68000B(0x280000, 0x293FFF, NULL, RAM+0x010000); // SCREEN RAM AddReadWordMC68000B(0x340000, 0x340007, tc0110pcr_rw, NULL); // COLOR RAM SCREEN A AddReadWordMC68000B(0x350000, 0x350007, tc0110pcr_rw_2, NULL); // COLOR RAM SCREEN B AddReadWordMC68000B(0x360000, 0x360007, tc0110pcr_rw_3, NULL); // COLOR RAM SCREEN C AddReadWordMC68000B(0x200000, 0x200003, tc0220ioc_rw_port, NULL); // INPUT AddReadWordMC68000B(0x000000, 0xFFFFFF, DefBadReadWord, NULL); // <Bad Reads> AddReadWordMC68000B(-1, -1, NULL, NULL); AddWriteByteMC68000B(0x080000, 0x08FFFF, NULL, RAM+0x040000); // SUB LOCAL RAM AddWriteByteMC68000B(0x240000, 0x24FFFF, NULL, RAM+0x024000); // COMMON RAM AddWriteByteMC68000B(0x260000, 0x263FFF, NULL, RAM+0x034000); // OBJECT RAM AddWriteByteMC68000B(0x280000, 0x290FFF, NULL, RAM+0x010000); // SCREEN RAM AddWriteByteMC68000B(0x291000, 0x291FFF, tc0100scn_0_gfx_fg0_wb, NULL); // FG0 GFX RAM AddWriteByteMC68000B(0x292000, 0x293FFF, NULL, RAM+0x022000); // FG0 RAM AddWriteByteMC68000B(0x200000, 0x200003, tc0220ioc_wb_port, NULL); // INPUT AddWriteByteMC68000B(0xAA0000, 0xAA0001, Stop68000, NULL); // Trap Idle 68000 AddWriteByteMC68000B(0x000000, 0xFFFFFF, DefBadWriteByte, NULL); // <Bad Writes> AddWriteByteMC68000B(-1, -1, NULL, NULL); AddWriteWordMC68000B(0x080000, 0x08FFFF, NULL, RAM+0x040000); // SUB LOCAL RAM AddWriteWordMC68000B(0x240000, 0x24FFFF, NULL, RAM+0x024000); // COMMON RAM AddWriteWordMC68000B(0x260000, 0x263FFF, NULL, RAM+0x034000); // OBJECT RAM AddWriteWordMC68000B(0x280000, 0x290FFF, NULL, RAM+0x010000); // SCREEN RAM AddWriteWordMC68000B(0x291000, 0x291FFF, tc0100scn_0_gfx_fg0_ww, NULL); // FG0 GFX RAM AddWriteWordMC68000B(0x292000, 0x293FFF, NULL, RAM+0x022000); // FG0 RAM AddWriteWordMC68000B(0x340000, 0x340007, tc0110pcr_ww, NULL); // COLOR RAM SCREEN A AddWriteWordMC68000B(0x350000, 0x350007, tc0110pcr_ww_2, NULL); // COLOR RAM SCREEN B AddWriteWordMC68000B(0x360000, 0x360007, tc0110pcr_ww_3, NULL); // COLOR RAM SCREEN C AddWriteWordMC68000B(0x200000, 0x200003, tc0220ioc_ww_port, NULL); // INPUT AddWriteWordMC68000B(0x000000, 0xFFFFFF, DefBadWriteWord, NULL); // <Bad Writes> AddWriteWordMC68000B(-1, -1, NULL, NULL); AddInitMemoryMC68000B(); // Set Starscream mem pointers... }
void* InitPlacedLight(void* bhdata,STRATEGYBLOCK *sbPtr) { TOOLS_DATA_PLACEDLIGHT *toolsData = (TOOLS_DATA_PLACEDLIGHT *)bhdata; PLACED_LIGHT_BEHAV_BLOCK* pl_bhv; int i; LOCALASSERT(sbPtr->I_SBtype == I_BehaviourPlacedLight); LOCALASSERT(toolsData); /* create, initialise and attach a data block */ pl_bhv = (void *)AllocateMem(sizeof(PLACED_LIGHT_BEHAV_BLOCK)); if(!pl_bhv) { memoryInitialisationFailure = 1; return ((void *)NULL); } pl_bhv->bhvr_type=I_BehaviourPlacedLight; sbPtr->SBdataptr = pl_bhv; /* these should be loaded */ /* set default indestructibility */ pl_bhv->Indestructable = No; /* Initialise object's stats */ { NPC_DATA *NpcData; NpcData=GetThisNpcData(I_NPC_DefaultInanimate); LOCALASSERT(NpcData); sbPtr->SBDamageBlock.Health=NpcData->StartingStats.Health<<ONE_FIXED_SHIFT; sbPtr->SBDamageBlock.Armour=NpcData->StartingStats.Armour<<ONE_FIXED_SHIFT; sbPtr->SBDamageBlock.SB_H_flags=NpcData->StartingStats.SB_H_flags; } pl_bhv->destruct_target_request=toolsData->destruct_target_request; for(i=0;i<SB_NAME_LENGTH;i++) { pl_bhv->destruct_target_ID[i]=toolsData->destruct_target_ID[i]; } pl_bhv->destruct_target_sbptr=0; pl_bhv->sequence=toolsData->sequence; pl_bhv->colour_red=toolsData->colour_red; pl_bhv->colour_green=toolsData->colour_green; pl_bhv->colour_blue=toolsData->colour_blue; pl_bhv->colour_diff_red=toolsData->colour_diff_red; pl_bhv->colour_diff_green=toolsData->colour_diff_green; pl_bhv->colour_diff_blue=toolsData->colour_diff_blue; pl_bhv->fade_up_time=toolsData->fade_up_time; pl_bhv->fade_down_time=toolsData->fade_down_time; pl_bhv->up_time=toolsData->up_time; pl_bhv->down_time=toolsData->down_time; pl_bhv->timer=toolsData->timer; pl_bhv->flicker_timer=0; pl_bhv->type=toolsData->type; pl_bhv->on_off_type=toolsData->on_off_type; pl_bhv->state=toolsData->state; pl_bhv->on_off_state=toolsData->on_off_state; pl_bhv->swap_colour_and_brightness_alterations=toolsData->swap_colour_and_brightness_alterations; pl_bhv->on_off_timer=0; sbPtr->SBDamageBlock.Health*=toolsData->integrity; if(toolsData->static_light) { sbPtr->DynPtr = AllocateDynamicsBlock(DYNAMICS_TEMPLATE_STATIC); } else { sbPtr->DynPtr = AllocateDynamicsBlock(DYNAMICS_TEMPLATE_INANIMATE); } if(!sbPtr->DynPtr) { RemoveBehaviourStrategy(sbPtr); return 0; } sbPtr->DynPtr->Mass = toolsData->mass; if (toolsData->integrity > 20) { pl_bhv->Indestructable = Yes; sbPtr->integrity = DEFAULT_OBJECT_INTEGRITY; } else if (toolsData->integrity < 1) { sbPtr->integrity = 1; // die immediately } else { sbPtr->integrity = (DEFAULT_OBJECT_INTEGRITY)*(toolsData->integrity); } pl_bhv->has_broken_sequence=1; pl_bhv->has_corona=0; /*check to see if object is animated.*/ /*also check for corona flag at the same time*/ { TXACTRLBLK **pptxactrlblk; int item_num; int shape_num = toolsData->shapeIndex; SHAPEHEADER *shptr = GetShapeData(shape_num); pptxactrlblk = &pl_bhv->inan_tac; for(item_num = 0; item_num < shptr->numitems; item_num ++) { POLYHEADER *poly = (POLYHEADER*)(shptr->items[item_num]); LOCALASSERT(poly); SetupPolygonFlagAccessForShape(shptr); if((Request_PolyFlags((void *)poly)) & iflag_txanim) { TXACTRLBLK *pnew_txactrlblk; pnew_txactrlblk = AllocateMem(sizeof(TXACTRLBLK)); if(pnew_txactrlblk) { pnew_txactrlblk->tac_flags = 0; pnew_txactrlblk->tac_item = item_num; pnew_txactrlblk->tac_sequence = 0; pnew_txactrlblk->tac_node = 0; pnew_txactrlblk->tac_txarray = GetTxAnimArrayZ(shape_num, item_num); pnew_txactrlblk->tac_txah_s = GetTxAnimHeaderFromShape(pnew_txactrlblk, shape_num); *pptxactrlblk = pnew_txactrlblk; pptxactrlblk = &pnew_txactrlblk->tac_next; { //see how many sequences there are int num_seq=0; while(pnew_txactrlblk->tac_txarray[num_seq+1])num_seq++; if(num_seq<3) pl_bhv->has_broken_sequence=0; GLOBALASSERT(num_seq>=2); } } else *pptxactrlblk = NULL; } if((Request_PolyFlags((void *)poly)) & iflag_light_corona) { int* vertexptr= &poly->Poly1stPt; int num_verts=0; pl_bhv->has_corona=1; pl_bhv->corona_location.vx=0; pl_bhv->corona_location.vy=0; pl_bhv->corona_location.vz=0; //take the average of all the points in the polygon while(*vertexptr!=-1) { num_verts++; AddVector((VECTORCH*)&shptr->points[0][(*vertexptr)*3],&pl_bhv->corona_location); vertexptr++; } pl_bhv->corona_location.vx/=num_verts; pl_bhv->corona_location.vy/=num_verts; pl_bhv->corona_location.vz/=num_verts; } } *pptxactrlblk=0; pl_bhv->light=toolsData->light; GLOBALASSERT(pl_bhv->light); pl_bhv->light->RedScale=pl_bhv->colour_red; pl_bhv->light->GreenScale=pl_bhv->colour_green; pl_bhv->light->BlueScale=pl_bhv->colour_blue; } if(!pl_bhv->inan_tac) { pl_bhv->has_broken_sequence=0; } SetTextureAnimationSequence(sbPtr->shapeIndex,pl_bhv->inan_tac,pl_bhv->sequence); /* Initialise the dynamics block */ { DYNAMICSBLOCK *dynPtr = sbPtr->DynPtr; GLOBALASSERT(dynPtr); dynPtr->PrevPosition = dynPtr->Position = toolsData->position; dynPtr->OrientEuler = toolsData->orientation; CreateEulerMatrix(&dynPtr->OrientEuler, &dynPtr->OrientMat); TransposeMatrixCH(&dynPtr->OrientMat); } /* strategy block initialisation */ sbPtr->shapeIndex = toolsData->shapeIndex; for(i=0;i<SB_NAME_LENGTH;i++) sbPtr->SBname[i] = toolsData->nameID[i]; UpdatePlacedLightState(pl_bhv,sbPtr); /* these must be initialised for respawning objects in multiplayer game */ pl_bhv->startingHealth = sbPtr->SBDamageBlock.Health; pl_bhv->startingArmour = sbPtr->SBDamageBlock.Armour; return((void*)pl_bhv); }
static void load_rastan(void) { RAMSize=0x20000+0x10000; if(!(RAM=AllocateMem(RAMSize))) return; /*-----[Sound Setup]-----*/ Z80ROM=RAM+0x20000; if(!(PCMROM=AllocateMem(0x10000))) return; if(!load_rom("ic49_19.bin", Z80ROM, 0x10000)) return; // Z80 SOUND ROM if(!load_rom("ic76_20.bin", PCMROM, 0x10000)) return; AddTaitoYM2151(0x01C0, 0x01AB, 0x10000, (UINT8 *) Rastan_M5205_W, NULL); msm5205_interface.rom[0] = PCMROM; msm5205_interface.romsize[0] = 0x10000; msm5205_interface.updatemode = MSM5205_MONO; /*-----------------------*/ memset(RAM+0x00000,0x00,0x20000); RAM[0x1A007]=0x9F; // !! Vital !! RAM_VIDEO = RAM+0x08000; RAM_SCROLL = RAM+0x1B080; RAM_OBJECT = RAM+0x18000; set_colour_mapper(&col_map_xbbb_bbgg_gggr_rrrr); InitPaletteMap(RAM+0x4000, 0x100, 0x10, 0x8000); // 68000 Speed Hack // ---------------- if(is_current_game("rastan")) { WriteLong68k(&ROM[0x00146],0x4E714E71); // nop WriteLong68k(&ROM[0x3B08C],0x13FC0000); // move.b #$00,$AA0000 WriteLong68k(&ROM[0x3B090],0x00AA0000); // WriteWord68k(&ROM[0x3B094],0x4E71); // nop } if(is_current_game("rastsaga")) { WriteLong68k(&ROM[0x3B088],0x13FC0000); // move.b #$00,$AA0000 WriteLong68k(&ROM[0x3B08C],0x00AA0000); // WriteWord68k(&ROM[0x3B090],0x4E71); // nop } // Init tc0100scn emulation // ------------------------ tc0100scn[0].layer[0].RAM =RAM_VIDEO+0x0000; tc0100scn[0].layer[0].SCR =RAM_SCROLL+0; tc0100scn[0].layer[0].type =0; tc0100scn[0].layer[0].bmp_x =32; tc0100scn[0].layer[0].bmp_y =32; tc0100scn[0].layer[0].bmp_w =320; tc0100scn[0].layer[0].bmp_h =240; // Mapper disabled tc0100scn[0].layer[0].tile_mask=0x3FFF; tc0100scn[0].layer[0].scr_x =16; tc0100scn[0].layer[0].scr_y =8; tc0100scn[0].layer[1].RAM =RAM_VIDEO+0x8000; tc0100scn[0].layer[1].SCR =RAM_SCROLL+2; tc0100scn[0].layer[1].type =0; tc0100scn[0].layer[1].bmp_x =32; tc0100scn[0].layer[1].bmp_y =32; tc0100scn[0].layer[1].bmp_w =320; tc0100scn[0].layer[1].bmp_h =240; // Mapper disabled tc0100scn[0].layer[1].tile_mask=0x3FFF; tc0100scn[0].layer[1].scr_x =16; tc0100scn[0].layer[1].scr_y =8; tc0100scn[0].RAM = RAM_VIDEO; init_tc0100scn(0); // Init tc0002obj emulation // ------------------------ tc0002obj.RAM = RAM_OBJECT; tc0002obj.GFX = NULL; tc0002obj.bmp_x = 32; tc0002obj.bmp_y = 32; tc0002obj.bmp_w = 320; tc0002obj.bmp_h = 240; // Mapper disabled tc0002obj.tile_mask = 0x0FFF; tc0002obj.ofs_x = 0; tc0002obj.ofs_y = -8; /* * StarScream Stuff follows */ ByteSwap(ROM,0x60000); ByteSwap(RAM,0x1B100); AddMemFetch(0x000000, 0x05FFFF, ROM+0x000000-0x000000); // 68000 ROM AddMemFetch(-1, -1, NULL); AddReadByte(0x000000, 0x05FFFF, NULL, ROM+0x000000); // 68000 ROM AddReadByte(0x10C000, 0x10FFFF, NULL, RAM+0x000000); // 68000 RAM AddReadByte(0xC00000, 0xC0FFFF, NULL, RAM_VIDEO); AddReadByte(0xD00000, 0xD01FFF, NULL, RAM+0x018000); AddReadByte(0x200000, 0x203FFF, NULL, RAM+0x004000); AddReadByte(0x390000, 0x390FFF, NULL, RAM+0x01A000); // INPUT AddReadByte(0x350000, 0x35000F, NULL, RAM+0x01B010); AddReadByte(0x380000, 0x380001, NULL, RAM+0x01B00A); AddReadByte(0x3C0000, 0x3C0001, NULL, RAM+0x01B020); AddReadByte(0x3E0000, 0x3E0003, tc0140syt_read_main_68k, NULL); AddReadByte(-1, -1, NULL, NULL); AddReadWord(0x000000, 0x05FFFF, NULL, ROM+0x000000); // 68000 ROM AddReadWord(0x10C000, 0x10FFFF, NULL, RAM+0x000000); // 68000 RAM AddReadWord(0xC00000, 0xC0FFFF, NULL, RAM_VIDEO); AddReadWord(0xD00000, 0xD01FFF, NULL, RAM+0x018000); AddReadWord(0x200000, 0x203FFF, NULL, RAM+0x004000); AddReadWord(0x390000, 0x390FFF, NULL, RAM+0x01A000); // INPUT AddReadWord(0x350000, 0x35000F, NULL, RAM+0x01B010); AddReadWord(0x380000, 0x380001, NULL, RAM+0x01B00A); AddReadWord(0x3C0000, 0x3C0001, NULL, RAM+0x01B020); AddReadWord(0x3E0000, 0x3E0003, NULL, RAM+0x01B00C); AddReadWord(-1, -1, NULL, NULL); AddWriteByte(0x10C000, 0x10FFFF, NULL, RAM+0x000000); // 68000 RAM AddWriteByte(0xC00000, 0xC0FFFF, NULL, RAM_VIDEO); AddWriteByte(0xD00000, 0xD01FFF, NULL, RAM+0x018000); AddWriteByte(0x200000, 0x203FFF, NULL, RAM+0x004000); AddWriteByte(0xC20000, 0xC20003, NULL, RAM_SCROLL+6); // SCROLL Y AddWriteByte(0xC40000, 0xC40003, NULL, RAM_SCROLL+0); // SCROLL X AddWriteByte(0xC50000, 0xC50001, NULL, RAM_SCROLL+14); // CTRL AddWriteByte(0x350000, 0x35000F, NULL, RAM+0x01B010); AddWriteByte(0x380000, 0x380001, NULL, RAM+0x01B00A); AddWriteByte(0x390000, 0x390FFF, NULL, RAM+0x01A000); // INPUT AddWriteByte(0x3C0000, 0x3C0001, NULL, RAM+0x01B020); AddWriteByte(0x3E0000, 0x3E0003, tc0140syt_write_main_68k, NULL); AddWriteByte(0xAA0000, 0xAA0001, Stop68000, NULL); // Trap Idle 68000 AddWriteByte(-1, -1, NULL, NULL); AddWriteWord(0x10C000, 0x10FFFF, NULL, RAM+0x000000); // 68000 RAM AddWriteWord(0xC00000, 0xC0FFFF, NULL, RAM_VIDEO); AddWriteWord(0xD00000, 0xD01FFF, NULL, RAM+0x018000); AddWriteWord(0x200000, 0x203FFF, NULL, RAM+0x004000); AddWriteWord(0xC20000, 0xC20003, NULL, RAM_SCROLL+6); // SCROLL Y AddWriteWord(0xC40000, 0xC40003, NULL, RAM_SCROLL+0); // SCROLL X AddWriteWord(0xC50000, 0xC50001, NULL, RAM_SCROLL+14); // CTRL AddWriteWord(0x350000, 0x35000F, NULL, RAM+0x01B010); AddWriteWord(0x380000, 0x380001, NULL, RAM+0x01B00A); AddWriteWord(0x390000, 0x390FFF, NULL, RAM+0x01A000); // INPUT AddWriteWord(0x3C0000, 0x3C0001, NULL, RAM+0x01B020); AddWriteWord(0x3E0000, 0x3E0003, NULL, RAM+0x01B00C); AddWriteWord(-1, -1, NULL, NULL); AddInitMemory(); // Set Starscream mem pointers... }
void read_dx_file() { int i,err; char buff[80]; unzFile dat; UINT8 *buffer; unz_file_info file_info; /* int start,end; */ /* short *src; */ if (!dx_file[0]) return; if (raine_nb_samples && emudx_samples && sample_data) { return; } dat = unzOpen(dx_file); if (!dat) return; for (raine_nb_samples=1; raine_nb_samples<32; raine_nb_samples++) { sprintf(buff,"%d.wav",raine_nb_samples); err = unzLocateFile(dat,buff,2); if (err != UNZ_OK) break; } raine_nb_samples--; emudx_samples = (struct wave_spec*)AllocateMem((raine_nb_samples+1) * sizeof(struct wave_spec)); AddSaveData(ASCII_ID('S','A','M','P'), (UINT8*)emudx_samples, (raine_nb_samples+1) * sizeof(struct wave_spec)); sample_data = (struct private_data*)AllocateMem((raine_nb_samples+1)*sizeof(struct private_data)); for (i=1; i<=raine_nb_samples; i++) { sprintf(buff,"%d.wav",i); unzLocateFile(dat,buff,2); err = unzOpenCurrentFile(dat); unzGetCurrentFileInfo(dat,&file_info,NULL,0,NULL,0,NULL,0); buffer = malloc(file_info.uncompressed_size); unzReadCurrentFile(dat,buffer,file_info.uncompressed_size); emudx_samples[i].pos = emudx_samples[i].playing = 0; #ifdef SDL SDL_RWops *rw; unsigned int len_in_bytes; SDL_AudioCVT wav_cvt; SDL_AudioSpec wave; UINT8 *wav_buffer; extern SDL_AudioSpec gotspec; if (!gotspec.freq) { /* Now read_dx_file is called before the soundcard init, so we * must put sensible default values here... */ gotspec.freq = audio_sample_rate; gotspec.channels = 2; gotspec.format = AUDIO_S16; } rw = SDL_RWFromMem(buffer, file_info.uncompressed_size); if (!SDL_LoadWAV_RW(rw,1,&wave,&wav_buffer,&len_in_bytes)) { printf("couldn't load sample %d: %s\n",i,SDL_GetError()); exit(1); } unzCloseCurrentFile(dat); // Is this needed when open failed? if (SDL_BuildAudioCVT(&wav_cvt, wave.format, wave.channels, wave.freq, gotspec.format, gotspec.channels,gotspec.freq) == -1) { printf("can't build converter\n"); exit(1); } wav_cvt.buf = sample_data[i].data = AllocateMem(len_in_bytes*wav_cvt.len_mult); sample_data[i].len =len_in_bytes*wav_cvt.len_ratio; wav_cvt.len = len_in_bytes; memcpy(sample_data[i].data, wav_buffer, len_in_bytes); SDL_FreeWAV(wav_buffer); SDL_ConvertAudio(&wav_cvt); #else convert_wav((char*)buffer,file_info.uncompressed_size, (char**)&sample_data[i].data,&sample_data[i].len); #endif free(buffer); } unzClose(dat); }