Previous 15994 Revisions Next

r14483 Thursday 16th February, 2012 at 16:17:52 UTC by Miodrag Milanović
Fixed mess tools compile (nw)
[src/mess/tools/imgtool]imghd.c imgtool.mak
[src/mess/tools/imgtool/windows]wimgtool.mak

src/mess/tools/imgtool/imgtool.mak
r14482r14483
9191# rules to build the imgtool executable
9292#-------------------------------------------------
9393
94$(IMGTOOL): $(IMGTOOL_OBJS) $(LIBIMGTOOL) $(FORMATS_LIB) $(LIBEMU) $(LIBUTIL) $(EXPAT) $(ZLIB) $(FLAC_LIB) $(LIBOCORE)
94$(IMGTOOL): $(IMGTOOL_OBJS) $(LIBIMGTOOL) $(FORMATS_LIB) $(LIBEMU) $(LIBUTIL) $(EXPAT) $(ZLIB) $(FLAC_LIB) $(7Z_LIB) $(LIBOCORE)
9595   @echo Linking $@...
9696   $(LD) $(LDFLAGS) $^ $(LIBS) -o $@
src/mess/tools/imgtool/windows/wimgtool.mak
r14482r14483
5757   @echo Compiling resources $<...
5858   $(RC) $(RCDEFS) $(RCFLAGS) --include-dir $(WIMGTOOLSRC) -o $@ -i $<
5959
60$(WIMGTOOL): $(VERSIONOBJ) $(WIMGTOOL_OBJS) $(LIBIMGTOOL) $(FORMATS_LIB) $(LIBEMU) $(LIBUTIL) $(EXPAT) $(ZLIB) $(FLAC_LIB) $(LIBOCORE_NOMAIN)
60$(WIMGTOOL): $(VERSIONOBJ) $(WIMGTOOL_OBJS) $(LIBIMGTOOL) $(FORMATS_LIB) $(LIBEMU) $(LIBUTIL) $(EXPAT) $(ZLIB) $(FLAC_LIB) $(7Z_LIB) $(LIBOCORE_NOMAIN)
6161   @echo Linking $@...
6262   $(LD) $(LDFLAGS_WIN) -municode -mwindows $^ $(LIBS_WIN) -o $@
src/mess/tools/imgtool/imghd.c
r14482r14483
4848{
4949   imgtoolerr_t err = IMGTOOLERR_SUCCESS;
5050   UINT8 *cache = NULL;
51   chd_file *chd = NULL;
51   chd_file chd;
5252   chd_error rc;
5353   UINT64 logicalbytes;
5454   int hunknum, totalhunks;
55   char metadata[256];
55   astring metadata;
56   chd_codec_type compression[4] = { CHD_CODEC_NONE };
5657
5758   /* sanity check args */
5859   if (hunksize >= 2048)
r14482r14483
7475   logicalbytes = (UINT64)cylinders * heads * sectors * seclen;
7576
7677   /* create the new hard drive */
77   rc = chd_create_file(stream_core_file(stream), logicalbytes, hunksize, CHDCOMPRESSION_NONE, NULL);
78   rc = chd.create(*stream_core_file(stream), logicalbytes, hunksize, seclen, compression);
7879   if (rc != CHDERR_NONE)
7980   {
8081      err = map_chd_error(rc);
r14482r14483
8283   }
8384
8485   /* open the new hard drive */
85   rc = chd_open_file(stream_core_file(stream), CHD_OPEN_READWRITE, NULL, &chd);
86   rc = chd.open(*stream_core_file(stream));
87
8688   if (rc != CHDERR_NONE)
8789   {
8890      err = map_chd_error(rc);
r14482r14483
9092   }
9193
9294   /* write the metadata */
93   sprintf(metadata, HARD_DISK_METADATA_FORMAT, cylinders, heads, sectors, seclen);
94   err = (imgtoolerr_t)chd_set_metadata(chd, HARD_DISK_METADATA_TAG, 0, metadata, strlen(metadata) + 1, 0);
95   metadata.format(HARD_DISK_METADATA_FORMAT, cylinders, heads, sectors, seclen);
96   err = (imgtoolerr_t)chd.write_metadata(HARD_DISK_METADATA_TAG, 0, metadata);
9597   if (rc != CHDERR_NONE)
9698   {
9799      err = map_chd_error(rc);
r14482r14483
111113   totalhunks = (logicalbytes + hunksize - 1) / hunksize;
112114   for (hunknum = 0; hunknum < totalhunks; hunknum++)
113115   {
114      rc = chd_write(chd, hunknum, cache);
116      rc = chd.write_units(hunknum, cache);
115117      if (rc)
116118      {
117119         err = IMGTOOLERR_WRITEERROR;
r14482r14483
123125done:
124126   if (cache)
125127      free(cache);
126   if (chd)
127      chd_close(chd);
128128   return err;
129129}
130130
r14482r14483
143143   hard_disk->hard_disk = NULL;
144144   hard_disk->chd = NULL;
145145
146   chderr = chd_open_file(stream_core_file(stream), stream_isreadonly(stream) ? CHD_OPEN_READ : CHD_OPEN_READWRITE, NULL, &hard_disk->chd);
146   chderr = hard_disk->chd->open(*stream_core_file(stream), stream_isreadonly(stream));
147147   if (chderr)
148148   {
149149      err = map_chd_error(chderr);
r14482r14483
178178      hard_disk_close(disk->hard_disk);
179179      disk->hard_disk = NULL;
180180   }
181   if (disk->chd)
182   {
183      chd_close(disk->chd);
184      disk->chd = NULL;
185   }
186181   if (disk->stream)
187182      stream_close(disk->stream);
188183}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team