public bool saveRoomsHeaders() { //long?? int headerPointer = (ROM.DATA[Constants.room_header_pointer + 2] << 16) + (ROM.DATA[Constants.room_header_pointer + 1] << 8) + (ROM.DATA[Constants.room_header_pointer]); headerPointer = Addresses.snestopc(headerPointer); //headerPointer = 04F1E2 topc -> 0271E2 if (Constants.Rando) { //24 ROM.DATA[Constants.room_header_pointers_bank] = 0x24; for (int i = 0; i < 296; i++) { ROM.DATA[headerPointer + (i * 2)] = (byte)((Addresses.pctosnes(newHeaderPos + (i * 14)) & 0xFF)); ROM.DATA[headerPointer + (i * 2) + 1] = (byte)((Addresses.pctosnes(newHeaderPos + (i * 14)) >> 8) & 0xFF); saveHeader(newHeaderPos, i); //savetext //(short)((ROM.DATA[Constants.messages_id_dungeon + (index * 2) + 1] << 8) + ROM.DATA[Constants.messages_id_dungeon + (index * 2)]) ROM.DATA[Constants.messages_id_dungeon + (i * 2)] = (byte)(all_rooms[i].messageid & 0xFF); ROM.DATA[Constants.messages_id_dungeon + (i * 2) + 1] = (byte)((all_rooms[i].messageid >> 8) & 0xFF); } } else { ROM.DATA[Constants.room_header_pointers_bank] = 0x22; for (int i = 0; i < 296; i++) { ROM.DATA[headerPointer + (i * 2)] = (byte)((Addresses.pctosnes(0x110000 + (i * 14)) & 0xFF)); ROM.DATA[headerPointer + (i * 2) + 1] = (byte)((Addresses.pctosnes(0x110000 + (i * 14)) >> 8) & 0xFF); saveHeader(0x110000, i); } } return(false); // False = no error }
public bool saveRoomsHeaders() { //long?? int headerPointer = getLongPointerSnestoPc(ConstantsJP.room_header_pointer); if (headerPointer < 0x100000) { MovePointer mp = new MovePointer(); mp.ShowDialog(); headerPointer = mp.address; int addr = Addresses.pctosnes(mp.address); ROM.DATA[ConstantsJP.room_header_pointer] = (byte)(addr & 0xFF); ROM.DATA[ConstantsJP.room_header_pointer + 1] = (byte)((addr >> 8) & 0xFF); ROM.DATA[ConstantsJP.room_header_pointer + 2] = (byte)((addr >> 16) & 0xFF); } ROM.DATA[ConstantsJP.room_header_pointers_bank] = ROM.DATA[ConstantsJP.room_header_pointer + 2]; for (int i = 0; i < 296; i++) { ROM.DATA[(headerPointer) + (i * 2)] = (byte)((Addresses.pctosnes((headerPointer + 640) + (i * 14)) & 0xFF)); ROM.DATA[(headerPointer) + (i * 2) + 1] = (byte)((Addresses.pctosnes((headerPointer + 640) + (i * 14)) >> 8) & 0xFF); saveHeader((headerPointer + 640), i); ROM.DATA[ConstantsJP.messages_id_dungeon + (i * 2) + 1] = (byte)((all_rooms[i].Messageid << 8) & 0xFF); ROM.DATA[ConstantsJP.messages_id_dungeon + (i * 2)] = (byte)((all_rooms[i].Messageid) & 0xFF);; } return(false); // False = no error }
public void savemapstorom() { int pos = 0x110000; for (int i = 0; i < 160; i++) { int npos = 0; byte[] singlemap1 = new byte[256], singlemap2 = new byte[256]; for (int y = 0; y < 16; y++) { for (int x = 0; x < 16; x++) { singlemap1[npos] = (byte)(t32[npos + (i * 256)] & 0xFF); singlemap2[npos] = (byte)((t32[npos + (i * 256)] >> 8) & 0xFF); npos++; } } int snesPos = Addresses.pctosnes(pos); ROM.DATA[(Constants.compressedAllMap32PointersHigh) + 0 + (int)(3 * i)] = (byte)(snesPos & 0xFF); ROM.DATA[(Constants.compressedAllMap32PointersHigh) + 1 + (int)(3 * i)] = (byte)((snesPos >> 8) & 0xFF); ROM.DATA[(Constants.compressedAllMap32PointersHigh) + 2 + (int)(3 * i)] = (byte)((snesPos >> 16) & 0xFF); ROM.DATA[pos] = 0xE0; ROM.DATA[pos + 1] = 0xFF; pos += 2; for (int j = 0; j < 256; j++) { ROM.DATA[pos] = singlemap2[j]; pos += 1; } ROM.DATA[pos] = 0xFF; pos += 1; snesPos = Addresses.pctosnes(pos); ROM.DATA[(Constants.compressedAllMap32PointersLow) + 0 + (int)(3 * i)] = (byte)((snesPos >> 00) & 0xFF); ROM.DATA[(Constants.compressedAllMap32PointersLow) + 1 + (int)(3 * i)] = (byte)((snesPos >> 08) & 0xFF); ROM.DATA[(Constants.compressedAllMap32PointersLow) + 2 + (int)(3 * i)] = (byte)((snesPos >> 16) & 0xFF); ROM.DATA[pos] = 0xE0; ROM.DATA[pos + 1] = 0xFF; pos += 2; for (int j = 0; j < 256; j++) { ROM.DATA[pos] = singlemap1[j]; pos += 1; } ROM.DATA[pos] = 0xFF; pos += 1; } //Console.WriteLine(); //Save32Tiles(); }
public bool saveallPots() { int pos = Constants.items_data_start + 2; //skip 2 FF FF that are empty pointer for (int i = 0; i < 296; i++) { if (all_rooms[i].pot_items.Count == 0) { ROM.DATA[Constants.room_items_pointers + (i * 2)] = (byte)((Addresses.pctosnes(Constants.items_data_start) & 0xFF)); ROM.DATA[Constants.room_items_pointers + (i * 2) + 1] = (byte)((Addresses.pctosnes(Constants.items_data_start) >> 8) & 0xFF); continue; } //pointer ROM.DATA[Constants.room_items_pointers + (i * 2)] = (byte)((Addresses.pctosnes(pos) & 0xFF)); ROM.DATA[Constants.room_items_pointers + (i * 2) + 1] = (byte)((Addresses.pctosnes(pos) >> 8) & 0xFF); for (int j = 0; j < all_rooms[i].pot_items.Count; j++) { if (all_rooms[i].pot_items[j].layer == 0) { all_rooms[i].pot_items[j].bg2 = false; } else { all_rooms[i].pot_items[j].bg2 = true; } int xy = (((all_rooms[i].pot_items[j].y * 64) + all_rooms[i].pot_items[j].x) << 1); ROM.DATA[pos] = (byte)(xy & 0xFF); pos++; ROM.DATA[pos] = (byte)(((xy >> 8) & 0xFF) + (all_rooms[i].pot_items[j].bg2 == true ? 0x20 : 0x00)); pos++; ROM.DATA[pos] = all_rooms[i].pot_items[j].id; pos++; } ROM.DATA[pos] = 0xFF; pos++; ROM.DATA[pos] = 0xFF; pos++; if (pos > Constants.items_data_end) { return(true); } } return(false); // False = no error }
void saveObjectBytes(int roomId, int position, byte[] bytes, int doorOffset) { int objectPointer = (ROM.DATA[Constants.room_object_pointer + 2] << 16) + (ROM.DATA[Constants.room_object_pointer + 1] << 8) + (ROM.DATA[Constants.room_object_pointer]); objectPointer = Addresses.snestopc(objectPointer); saddr = Addresses.pctosnes(position); int daddr = Addresses.pctosnes(position + doorOffset); // update the index ROM.DATA[objectPointer + (roomId * 3)] = (byte)(saddr & 0xFF); ROM.DATA[objectPointer + (roomId * 3) + 1] = (byte)((saddr >> 8) & 0xFF); ROM.DATA[objectPointer + (roomId * 3) + 2] = (byte)((saddr >> 16) & 0xFF); ROM.DATA[Constants.doorPointers + (roomId * 3)] = (byte)(daddr & 0xFF); ROM.DATA[Constants.doorPointers + (roomId * 3) + 1] = (byte)((daddr >> 8) & 0xFF); ROM.DATA[Constants.doorPointers + (roomId * 3) + 2] = (byte)((daddr >> 16) & 0xFF); Array.Copy(bytes, 0, ROM.DATA, position, bytes.Length); }
public bool saveallSprites() { byte[] sprites_buffer = new byte[0x1670]; //empty room data = 0x250 //start of data = 0x252 try { int pos = 0x252; //set empty room sprites_buffer[0x250] = 0x00; sprites_buffer[0x251] = 0xFF; for (int i = 0; i < 296; i++) { if (all_rooms[i].sprites.Count <= 0) { sprites_buffer[(i * 2)] = (byte)((Addresses.pctosnes(Constants.sprites_data_empty_room) & 0xFF)); sprites_buffer[(i * 2) + 1] = (byte)((Addresses.pctosnes(Constants.sprites_data_empty_room) >> 8) & 0xFF); } else { //pointer : sprites_buffer[(i * 2)] = (byte)((Addresses.pctosnes(Constants.sprites_data + (pos - 0x252)) & 0xFF)); sprites_buffer[(i * 2) + 1] = (byte)((Addresses.pctosnes(Constants.sprites_data + (pos - 0x252)) >> 8) & 0xFF); //ROM.DATA[sprite_address] == 1 ? true : false; sprites_buffer[pos] = (byte)(all_rooms[i].sortSprites == true ? 0x01 : 0x00); //Unknown byte?? pos++; foreach (Sprite spr in all_rooms[i].sprites) //3bytes { byte b1 = (byte)((spr.layer << 7) + (spr.subtype << 5) + spr.y); byte b2 = (byte)((spr.overlord << 5) + spr.x); byte b3 = (byte)((spr.id)); sprites_buffer[pos] = b1; pos++; sprites_buffer[pos] = b2; pos++; sprites_buffer[pos] = b3; pos++; //if current sprite hold a key then save it before if (spr.keyDrop == 1) { byte bb1 = (byte)(0xFE); byte bb2 = (byte)(0x00); byte bb3 = (byte)(0xE4); sprites_buffer[pos] = bb1; pos++; sprites_buffer[pos] = bb2; pos++; sprites_buffer[pos] = bb3; pos++; } if (spr.keyDrop == 2) { byte bb1 = (byte)(0xFD); byte bb2 = (byte)(0x00); byte bb3 = (byte)(0xE4); sprites_buffer[pos] = bb1; pos++; sprites_buffer[pos] = bb2; pos++; sprites_buffer[pos] = bb3; pos++; } } sprites_buffer[pos] = 0xFF;//End of sprites pos++; } } int spritePointer = (04 << 16) + (ROM.DATA[Constants.rooms_sprite_pointer + 1] << 8) + (ROM.DATA[Constants.rooms_sprite_pointer]); sprites_buffer.CopyTo(ROM.DATA, spritePointer); } catch (Exception e) { return(true); } return(false); // False = no error }