protected void refreshPointer3Bytes() { for (int i = 0; i < primaryPointer_address.Length; i++) { primaryPointer_address[i] = PointerRead.LongRead_LoHiBank(primaryPointer_location[i]); } }
internal indoor_damagepits() { POINTER_LOCATION = ConstantsReader.GetAddress("pit_pointer"); DATALENGTH_VALUE_LOCATION = ConstantsReader.GetAddress("pit_count"); dataAddress = PointerRead.LongRead_LoHiBank(POINTER_LOCATION); maxLength = Conversion.toUShort(ROM.DATA[DATALENGTH_VALUE_LOCATION + 1], ROM.DATA[DATALENGTH_VALUE_LOCATION + 0]) + embedded2; readData(); }
private void readSecondaryPointers() { secondayPointers = new int[numberOfRooms]; for (int i = 0; i < numberOfRooms; i++) { secondayPointers[i] = PointerRead.ShortRead_LoHi(primaryPointer_val + (i * bytesPerRoomEntry)); } }
public void movePointers(int newAddress) { if (ROM.IsEmpty(newAddress, sizeOfPointerTable)) { PointerRead.CheckAddressWithinRangeOf3Byte(newAddress); ROM.Swap(primaryPointer_val, newAddress, sizeOfPointerTable); byte[] b = PointerRead.GeneratePointer3(newAddress); ROM.Write(primaryPointer_location, b.Length, b); ROM.Write(primaryPointer_location + primaryPointer_length - 1, b[b.Length - 1]); } }
/// <summary> /// Reads the pointer, which is byte swapped /// </summary> private void getPointers() { secondayPointers = new int[numberOfRooms]; byte[] rawData = new byte[pointerSize]; Array.Copy(ROM.DATA, primaryPointer_address[1], rawData, 0, pointerSize); updatePointer(rawData, ref secondayPointers, rawData.Length); layoutPointers = new int[numberOfLayouts]; for (int i = 0; i < numberOfLayouts; i++) { layoutPointers[i] = PointerRead.LongRead_LoHiBank(layoutPointersLocation + (i * 3)); } }
private void updatePointers() { bool match = true; byte[] b = new byte[originalCode.Length]; Array.Copy(ROM.DATA, codePointer, b, 0, originalCode.Length); for (int i = 0; i < originalCode.Length; i++) { if (originalCode[i] != b[i]) { match = false; break; } } if (match) { secondaryPointer = PointerRead.ShortRead_LoHi(primaryPointer); } else if (b[0] == specialPatchByte) { int Codeaddress = PointerRead.LongRead_LoHiBank(codePointer + 1); byte[] patch = new byte[patchByConn.Length]; Array.Copy(ROM.DATA, Codeaddress, patch, 0, patchByConn.Length); for (int i = 0; i < patchByConn.Length; i++) { if (patchByConn[i] != patch[i] && i != connPointerByteNo && i != connPointerByteNo + 1) { throw new Exception(patchError); } } secondaryPointer = PointerRead.ShortRead_LoHi(codePointer + connPointerByteNo); } else { throw new Exception(patchError); } roomPointers = new int[size / bytesPerRoomEntry]; for (int i = 0; i < size / bytesPerRoomEntry; i++) { roomPointers[i] = PointerRead.ShortRead_LoHi(secondaryPointer + (i * bytesPerRoomEntry)); } isConnPatched = !match; }
public Layout() { int primaryPointer_location; switch (RegionId.myRegion) { case ((int)RegionId.Region.USA): primaryPointer_location = 0x26F2F; break; case ((int)RegionId.Region.Japan): primaryPointer_location = 0x26C0F; break; default: throw new NotImplementedException(); } int location = PointerRead.LongRead_LoHiBank(primaryPointer_location); }
public void movePointers(int newAddress) { if (ROM.IsEmpty(newAddress, pointerSize)) { PointerRead.CheckAddressWithinRangeOf3Byte(newAddress); ROM.Swap(primaryPointer_address[1], newAddress, pointerSize); byte[] b = PointerRead.GeneratePointer3(newAddress); for (int i = 0; i < primaryPointer_location.Length; i++) { b[0] += (byte)((i % 2 == 0) ? 1 : -1); //works if the first byte is ($actualPointer + 1) ROM.Write(primaryPointer_location[i], 3, b); } updatePrimaryPointers(); } else { throw new Exception(TextAndTranslationManager.GetString(Dungeon.moveError)); } }
public void DecompressAllMapTiles() { //locat functions int genPointer(int address, int i) => PointerRead.LongRead_LoHiBank(address + i * 3); byte[] Decomp(int pointer, ref int compressedSize) => Decompress.ALTTPDecompressOverworld(ROM.DATA, pointer, 1000, ref compressedSize); int npos = 0; for (int i = 0; i < 160; i++) { int p1 = genPointer(ConstantsReader.GetAddress("compressedAllMap32PointersHigh"), i), p2 = genPointer(ConstantsReader.GetAddress("compressedAllMap32PointersLow"), i); int ttpos = 0, compressedSize1 = 0, compressedSize2 = 0; byte[] bytes = Decomp(p2, ref compressedSize1), bytes2 = Decomp(p1, ref compressedSize2); for (int y = 0; y < 16; y++) { for (int x = 0, tpos; x < 16; x++, npos++, ttpos++) { tpos = (ushort)((bytes2[ttpos] << 8) + bytes[ttpos]); if (tpos < tiles32.Count) { map16tiles[npos] = new Tile32(tiles32[tpos].tile0, tiles32[tpos].tile1, tiles32[tpos].tile2, tiles32[tpos].tile3); } else { Console.WriteLine("Found 0,0,0,0"); map16tiles[npos] = new Tile32(0, 0, 0, 0); } } } } }
private void readPointer() { if (ROM.Read(primaryPointer + bankOffset1) != ROM.Read(primaryPointer + bankOffset2)) { throw new Exception(); } secondaryPointer = PointerRead.LongRead_LoHiBank(primaryPointer); secondaryPointer = PointerRead.LongRead_LoHiBank(primaryPointer, primaryPointer + 1, pointer_bank); roomHeaderPointers = new int[numberOfHeaders]; for (int i = 0; i < numberOfHeaders; i++) { int temp = secondaryPointer + i * 2; roomHeaderPointers[i] = AddressLoROM.SnesToPc( ROM.Read(temp + 0), ROM.Read(temp + 1), AddressLoROM.PcToSnes_Bank(secondaryPointer)); roomHeaders[i] = new i_roomHeader(ROM.Read(roomHeaderPointers[i], sizeOfEachHeader)); } }
public void movePointers(uint pointerNo, int newAddress) { if (!(pointerNo <= getNumberOfPointers())) { throw new ArgumentOutOfRangeException(); } int size = dataSize[pointerNo]; if (ROM.IsEmpty(newAddress, size)) { PointerRead.CheckAddressWithinRangeOf3Byte(newAddress); ROM.Swap(primaryPointer_address[pointerNo], newAddress, size); byte[] newPointer = PointerRead.GeneratePointer3(newAddress); ROM.Write(primaryPointer_location[pointerNo], newPointer.Length, newPointer); refreshPointer3Bytes(); } else { throw new Exception(TextAndTranslationManager.GetString(Dungeon.moveError)); } }
private void readPrimaryPointers() { primaryPointer_val = PointerRead.LongRead_LoHiBank(primaryPointer_location); }