// Add room state to active room. private bool ForceAddRoomState(StateType type) { if (ActiveRoom == null) { return(false); } RoomStateHeader newHeader = new RoomStateHeader(); newHeader.SetDefault(); newHeader.HeaderType = type; var newState = new RoomState(); var newLevelData = new LevelData(RoomWidthInScreens, RoomHeightInScreens); var newPlmSet = new PlmSet(); var newEnemySet = new EnemySet(); var newEnemyGfx = new EnemyGfx(); var newFx = new Fx(); newState.SetDefault(); newLevelData.SetDefault(); newPlmSet.SetDefault(); newEnemySet.SetDefault(); newEnemyGfx.SetDefault(); newFx.SetDefault(); newState.SetLevelData(newLevelData, out var ignore1); newState.SetScrollSet(null, out var ignore2); newState.SetPlmSet(newPlmSet, out var ignore3); newState.SetEnemySet(newEnemySet, out var ignore4); newState.SetEnemyGfx(newEnemyGfx, out var ignore5); newState.SetFx(newFx, out var ignore6); newState.SetBackground(null, out var ignore7); newState.SetSetupAsm(null, out var ignore8); newState.SetMainAsm(null, out var ignore9); ActiveRoom.RoomStateHeaders.Insert(0, newHeader); ActiveRoom.RoomStates.Insert(0, newState); LevelDatas.Add(newState.MyLevelData); PlmSets.Add(newState.MyPlmSet); EnemySets.Add(newState.MyEnemySet); EnemyGfxs.Add(newState.MyEnemyGfx); Fxs.Add(newState.MyFx); ChangesMade = true; return(true); }
public ActiveItems(Project p) { ActiveArea = p.AreaIndex; ActiveRoom = p.ActiveRoom; ActiveRoomState = p.ActiveRoomState; ActiveTileSet = p.ActiveTileSet; ActiveDoor = p.ActiveDoor; ActiveLevelData = p.ActiveLevelData; ActivePlm = p.ActivePlm; ActivePlmType = p.ActivePlmType; ActiveEnemy = p.ActiveEnemy; ActiveEnemyGfx = p.ActiveEnemyGfx; ActiveEnemyType = p.ActiveEnemyType; ActiveScrollData = p.ActiveScrollData; ActiveScrollColor = p.ActiveScrollColor; ActiveFx = p.ActiveFx; ActiveFxData = p.ActiveFxData; ActiveBackground = p.ActiveBackground; }
private void ForceSelectRoomState(int index) { if (ActiveRoom != null && index >= 0 && index < ActiveRoom.RoomStates.Count) { RoomStateIndex = index; ActiveRoomState = ActiveRoom.RoomStates [RoomStateIndex]; ForceSelectScrollData(-1); ForceSelectPlm(0); ForceSelectEnemy(0); ForceSelectEnemyGfx(-1); ForceSelectFxData(ActiveFx.FxDataCount - 1); } else { RoomStateIndex = IndexNone; ActiveRoomState = null; ForceSelectScrollData(IndexNone); ForceSelectPlm(IndexNone); ForceSelectEnemy(IndexNone); ForceSelectEnemyGfx(IndexNone); ForceSelectFxData(IndexNone); } }
// Read data from ROM at given PC address. public override bool ReadFromROM(Rom rom, int addressPC) { int sAddressPC = addressPC; byte [] b = new byte [HeaderSize]; rom.Seek(addressPC); if (!rom.Read(b, 0, HeaderSize)) { return(false); } RoomIndex = b [0]; Area = b [1]; MapX = b [2]; MapY = b [3]; Width = b [4]; Height = b [5]; UpScroller = b [6]; DownScroller = b [7]; SpecialGfxBitflag = b [8]; DoorsPtr = Tools.ConcatBytes(b [9], b [10], 0x8F); // read room state headers addressPC += HeaderSize; int i = 0; RoomStateHeaders.Add(new RoomStateHeader()); if (!RoomStateHeaders [i].ReadFromROM(rom, addressPC)) { return(false); } addressPC += RoomStateHeaders [i].Size; while (RoomStateHeaders [i].HeaderType != StateType.Standard) { i++; RoomStateHeaders.Add(new RoomStateHeader()); if (!RoomStateHeaders [i].ReadFromROM(rom, addressPC)) { return(false); } addressPC += RoomStateHeaders [i].Size; } // read room states int StateCount = RoomStateHeaders.Count; for (int j = 0; j < StateCount; j++) { RoomStates.Add(null); } for (int j = 0; j < StateCount; j++) { RoomStates [j] = new RoomState(); addressPC = Tools.LRtoPC(RoomStateHeaders [j].RoomStatePtr); if (!RoomStates [j].ReadFromROM(rom, addressPC)) { return(false); } } startAddressPC = sAddressPC; return(true); }