felixrieseberg / felixrieseberg/windows95
Export HDA into img file
- Dominant language
- TypeScript
- Stars
- 24.2k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
It is definitely necessary to be able to export files out from this emulator.
Currently windows95.img works one way only and state-v3.bin is not readable to extract files.
We need a function that will update the img file or understand why this is problematic.
My current attempts:
```
/**
* Save the emulator's modified disk image to disk.
*/
private async saveDiskImage(): Promise {
const { emulator } = this.state;
const imgPath = (await getStatePath()).replace('.bin', '.img');
console.log(`saveDiskImage into:` + imgPath);
if (!emulator || !emulator.disk_images || !emulator.disk_images.hda) {
console.log(`saveDiskImage: No disk image present`);
return;
}
try {
// Convert SyncBuffer to a Uint8Array
const diskBuffer = new Uint8Array(emulator.disk_images.hda);
// Save the raw buffer as an .img file
await fs.outputFile(imgPath, Buffer.from(diskBuffer));
console.log(`Disk image saved to ${imgPath}`);
} catch (error) {
console.warn(`saveDiskImage: Could not save disk image`, error);
fs.appendFileSync('log.txt', `saveDiskImage: Could not save disk image: ${error.message}\n${error.stack}\n`);
}
}
```
As I understand this won't work, having blocks, we could:
```
// Apply modified blocks
const blockSize = 0x200;
for (const { sector, data } of writtenBlocks) {
const offset = sector * blockSize;
if (offset + data.length <= diskBuffer.length) {
data.copy(diskBuffer, offset);
} else {
console.warn(`saveDiskImage: Block at sector ${sector} exceeds disk size`);
}
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start from the proposed saveDiskImage method and inspect how getStatePath, emulator.disk_images.hda, SyncBuffer, and writtenBlocks are represented and persisted. Determine how modified blocks map to the disk image, then verify that exporting produces an .img file from which files can be extracted and that existing emulator state remains usable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- desktop
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100