| 46 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 47 |  | procedure TForm_TxmpReplace.SelectFile(fileinfo: TFileInfo); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 48 |  | var | 
 
 
 
 
 
 
 
 
 | 49 | – | Data: TByteData; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 49 |  | mem:  TMemoryStream; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 50 |  | fadingbyte, depthbyte, storebyte: Byte; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 51 |  | begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 52 |  | fileid := fileinfo.ID; | 
 
 
 
 
 
 
 
 
 
 
 | 53 | < | Connection.LoadDatFilePart(fileid, $88, SizeOf(fadingbyte), @fadingbyte); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 54 | < | Connection.LoadDatFilePart(fileid, $89, SizeOf(depthbyte), @depthbyte); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 55 | < | Connection.LoadDatFilePart(fileid, $90, SizeOf(storebyte), @storebyte); | 
 
 
 
 
 
 
 
 
 | 53 | > | ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $88, SizeOf(fadingbyte), @fadingbyte); | 
 
 
 
 
 | 54 | > | ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $89, SizeOf(depthbyte), @depthbyte); | 
 
 
 
 
 | 55 | > | ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $90, SizeOf(storebyte), @storebyte); | 
 
 
 
 
 
 
 
 
 
 
 | 56 |  | check_fading.Checked := (fadingbyte and $01) > 0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 57 |  | check_transparency.Checked := (depthbyte and $04) > 0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 58 |  |  | 
 
 
 
 
 
 
 
 
 
 
 | 59 | < | OniImage_Old.LoadFromTXMP(connection, fileid); | 
 
 
 
 
 
 
 
 
 | 59 | > | OniImage_Old.LoadFromTXMP(ConnectionID, fileid); | 
 
 
 
 
 
 
 
 
 
 
 | 60 |  | old_size := OniImage_Old.GetImageDataSize((fadingbyte and $01) > 0); | 
 
 
 
 
 
 
 
 
 | 62 | – | Data := OniImage_Old.GetAsBMP; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 61 |  | mem  := TMemoryStream.Create; | 
 
 
 
 
 
 
 
 
 
 
 | 62 | < | mem.Write(Data[0], Length(Data)); | 
 
 
 
 
 
 
 
 
 | 62 | > | OniImage_Old.GetAsBMP(TStream(mem)); | 
 
 
 
 
 
 
 
 
 
 
 | 63 |  | mem.Seek(0, soFromBeginning); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 64 |  | image_txmppreview.Picture.Bitmap.LoadFromStream(mem); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 65 |  | mem.Free; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 71 |  | procedure TForm_TxmpReplace.btn_loadClick(Sender: TObject); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 72 |  | var | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 73 |  | mem:   TMemoryStream; | 
 
 
 
 
 
 
 
 
 | 76 | – | tempd: Tdata; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 74 |  | begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 75 |  | if opend.Execute then | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 76 |  | begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 77 |  | OniImage_New.LoadFromBMP(opend.FileName); | 
 
 
 
 
 
 
 
 
 | 81 | – | tempd := OniImage_New.GetAsBMP; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 78 |  | mem   := TMemoryStream.Create; | 
 
 
 
 
 
 
 
 
 
 
 | 79 | < | mem.Write(tempd[0], Length(tempd)); | 
 
 
 
 
 
 
 
 
 | 79 | > | OniImage_New.GetAsBMP(TStream(mem)); | 
 
 
 
 
 
 
 
 
 
 
 | 80 |  | mem.Seek(0, soFromBeginning); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 81 |  | image_bmppreview.Picture.Bitmap.LoadFromStream(mem); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 82 |  | mem.Free; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 92 |  | newsize: LongWord; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 93 |  | old_rawaddr, new_rawaddr: LongWord; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 94 |  | oldfading: Byte; | 
 
 
 
 
 
 
 
 
 | 99 | – | tempd:     Tdata; | 
 
 
 
 
 
 
 
 
 | 100 | – |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 95 |  | datbyte: Word; | 
 
 
 
 
 
 
 
 | 96 | + | mem: TMemoryStream; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 97 |  | begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 98 |  | if filelist.ItemIndex >= 0 then | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 99 |  | begin | 
 
 
 
 
 
 
 
 
 
 
 | 100 | < | Connection.LoadDatFilePart(fileid, $88, 1, @oldfading); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 101 | < | if Connection.OSisMac then | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 102 | < | Connection.UpdateDatFilePart(fileid, $A0, 4, @old_rawaddr) | 
 
 
 
 
 
 
 
 
 | 100 | > | ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $88, 1, @oldfading); | 
 
 
 
 
 | 101 | > | if not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN) then | 
 
 
 
 
 | 102 | > | ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $A0, 4, @old_rawaddr) | 
 
 
 
 
 
 
 
 
 
 
 | 103 |  | else | 
 
 
 
 
 
 
 
 
 
 
 | 104 | < | Connection.LoadDatFilePart(fileid, $9C, 4, @old_rawaddr); | 
 
 
 
 
 
 
 
 
 | 104 | > | ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $9C, 4, @old_rawaddr); | 
 
 
 
 
 
 
 
 
 
 
 | 105 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 106 |  | if (OniImage_Old.Width <> OniImage_New.Width) or | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 107 |  | (OniImage_Old.Height <> OniImage_New.Height) then | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 108 |  | begin | 
 
 
 
 
 
 
 
 
 
 
 | 109 | < | if MessageBox(Self.Handle, PChar( | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 110 | < | 'Current image and new image have different size' + CrLf + | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 111 | < | '(Current: ' + IntToStr(OniImage_Old.Width) + | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 112 | < | 'x' + IntToStr(OniImage_Old.Height) + ' - New: ' + | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 113 | < | IntToStr(OniImage_New.Width) + 'x' + IntToStr(OniImage_New.Height) + ')' + CrLf + | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 114 | < | 'Replace anyways?'), | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 115 | < | PChar(filelist.Items.Strings[filelist.ItemIndex]), | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 116 | < | MB_YESNO) = idNo then | 
 
 
 
 
 
 
 
 
 | 109 | > | if MessageBox(Self.Handle, | 
 
 
 
 
 | 110 | > | PChar( | 
 
 
 
 
 | 111 | > | 'Current image and new image have different size' + CrLf + | 
 
 
 
 
 | 112 | > | '(Current: ' + IntToStr(OniImage_Old.Width) + 'x' + | 
 
 
 
 
 | 113 | > | IntToStr(OniImage_Old.Height) + ' - New: ' + | 
 
 
 
 
 | 114 | > | IntToStr(OniImage_New.Width) + 'x' + IntToStr(OniImage_New.Height) + | 
 
 
 
 
 | 115 | > | ')' + CrLf + 'Replace anyway?'), | 
 
 
 
 
 | 116 | > | PChar(filelist.Items.Strings[filelist.ItemIndex]), MB_YESNO) = idNo then | 
 
 
 
 
 
 
 
 
 
 
 | 117 |  | Exit; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 118 |  | end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 119 |  |  | 
 
 
 
 
 
 
 
 | 120 | + | mem := TMemoryStream.Create; | 
 
 
 
 
 
 
 
 | 121 | + |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 122 |  | if check_fading.Checked then | 
 
 
 
 
 
 
 
 
 
 
 | 123 | < | if not OniImage_New.GetMipMappedImage(tempd) then | 
 
 
 
 
 
 
 
 
 | 123 | > | if not OniImage_New.GetMipMappedImage(TStream(mem)) then | 
 
 
 
 
 
 
 
 
 
 
 | 124 |  | if MessageBox(Self.Handle, | 
 
 
 
 
 
 
 
 
 
 
 | 125 | < | PChar('Can not create a MipMapped-image (probably because of a wrong dimension).' + | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 126 | < | #13 + #10 + 'Do you want to continue without MipMapping?'), PChar('Warning'), | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 127 | < | MB_YESNO) = ID_YES then | 
 
 
 
 
 
 
 
 
 | 125 | > | PChar('Can not create a MipMapped-image (probably because of a wrong dimension).' + | 
 
 
 
 
 | 126 | > | #13 + #10 + 'Do you want to continue without MipMapping?'), PChar('Warning'), | 
 
 
 
 
 | 127 | > | MB_YESNO) = ID_YES then | 
 
 
 
 
 
 
 
 
 
 
 | 128 |  | check_fading.Checked := False | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 129 |  | else | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 130 |  | Exit; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 131 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 132 |  | if not check_fading.Checked then | 
 
 
 
 
 
 
 
 
 
 
 | 133 | < | tempd := OniImage_New.GetAsData; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 133 | > | begin | 
 
 
 
 
 | 134 | > | mem.Clear; | 
 
 
 
 
 | 135 | > | OniImage_New.GetAsData(TStream(mem)); | 
 
 
 
 
 | 136 | > | end; | 
 
 
 
 
 
 
 
 
 
 
 | 137 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 138 |  | newsize := OniImage_New.GetImageDataSize(check_fading.Checked); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 139 |  |  | 
 
 
 
 
 
 
 
 
 
 
 | 140 | < | if (newsize > old_size) and (Connection.Backend = ODB_Dat) then | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 141 | < | new_rawaddr := Connection.AppendRawFile( | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 142 | < | Connection.OSisMac, Length(tempd), tempd) | 
 
 
 
 
 
 
 
 
 | 140 | > | if (newsize > old_size) and (ConManager.Connection[ConnectionID].Backend = DB_ONI) then | 
 
 
 
 
 | 141 | > | new_rawaddr := ConManager.Connection[ConnectionID].AppendRawFile( | 
 
 
 
 
 | 142 | > | not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN), mem.Size, mem) | 
 
 
 
 
 
 
 
 
 
 
 | 143 |  | else | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 144 |  | begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 145 |  | new_rawaddr := old_rawaddr; | 
 
 
 
 
 
 
 
 
 
 
 | 146 | < | Connection.UpdateRawFile(fileid, $9C, Length(tempd), tempd); | 
 
 
 
 
 
 
 
 
 | 146 | > | ConManager.Connection[ConnectionID].UpdateRawFile(fileid, $9C, mem); | 
 
 
 
 
 
 
 
 
 
 
 | 147 |  | end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 148 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 149 |  | datbyte := $00; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 150 |  | if check_fading.Checked then | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 151 |  | datbyte := datbyte or $01; | 
 
 
 
 
 
 
 
 
 
 
 | 152 | < | Connection.UpdateDatFilePart(fileid, $88, 1, @datbyte); | 
 
 
 
 
 
 
 
 
 | 152 | > | ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $88, 1, @datbyte); | 
 
 
 
 
 
 
 
 
 
 
 | 153 |  | datbyte := $10; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 154 |  | if check_transparency.Checked then | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 155 |  | datbyte := datbyte or $04; | 
 
 
 
 
 
 
 
 
 
 
 | 156 | < | Connection.UpdateDatFilePart(fileid, $89, 1, @datbyte); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 157 | < | Connection.UpdateDatFilePart(fileid, $8C, 2, @OniImage_New.Width); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 158 | < | Connection.UpdateDatFilePart(fileid, $8E, 2, @OniImage_New.Height); | 
 
 
 
 
 
 
 
 
 | 156 | > | ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $89, 1, @datbyte); | 
 
 
 
 
 | 157 | > | ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $8C, 2, @OniImage_New.Width); | 
 
 
 
 
 | 158 | > | ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $8E, 2, @OniImage_New.Height); | 
 
 
 
 
 
 
 
 
 
 
 | 159 |  | datbyte := $08; | 
 
 
 
 
 
 
 
 
 
 
 | 160 | < | Connection.UpdateDatFilePart(fileid, $90, 1, @datbyte); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 161 | < | if Connection.OSisMac then | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 162 | < | Connection.UpdateDatFilePart(fileid, $A0, 4, @new_rawaddr) | 
 
 
 
 
 
 
 
 
 | 160 | > | ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $90, 1, @datbyte); | 
 
 
 
 
 | 161 | > | if not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN) then | 
 
 
 
 
 | 162 | > | ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $A0, 4, @new_rawaddr) | 
 
 
 
 
 
 
 
 
 
 
 | 163 |  | else | 
 
 
 
 
 
 
 
 
 
 
 | 164 | < | Connection.UpdateDatFilePart(fileid, $9C, 4, @new_rawaddr); | 
 
 
 
 
 
 
 
 
 | 164 | > | ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $9C, 4, @new_rawaddr); | 
 
 
 
 
 
 
 
 
 
 
 | 165 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 166 |  | ShowMessage('TXMP-image replaced'); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 167 |  | end; |