diff --git a/src/components/DiskInfo.vue b/src/components/DiskInfo.vue new file mode 100644 index 0000000..ace4d88 --- /dev/null +++ b/src/components/DiskInfo.vue @@ -0,0 +1,19 @@ + + + + + diff --git a/src/components/HomeView.vue b/src/components/HomeView.vue index fa2cb70..e7887ff 100644 --- a/src/components/HomeView.vue +++ b/src/components/HomeView.vue @@ -1,10 +1,8 @@ - + diff --git a/src/components/PlaygroundView.vue b/src/components/PlaygroundView.vue index fd30c63..4ae3c1c 100644 --- a/src/components/PlaygroundView.vue +++ b/src/components/PlaygroundView.vue @@ -2,6 +2,7 @@ import { ref } from 'vue' import DiskReader from '@/components/DiskReader.vue' import HexDump from '@/components/HexDump.vue' +import DiskInfo from '@/components/DiskInfo.vue' type DiskReadyState = 'empty' | 'read-started' | 'read-success' | 'read-failed' @@ -45,39 +46,41 @@ function onReadProgress(read: number, total: number) { +

Playground

+

This is my playground for testing out my code.

+

+ WARNING!!! Use at your own risk! +

-

Playground

-

This is my playground for testing out my code.

-

- WARNING!!! Use at your own risk! -

-
-

Disk Read

-
- -
- {{ diskName }} reading - - {{ ((diskReadBytes / diskTotalBytes) * 100.0).toFixed(2) }} % - +

Disk Read

+
+ +
+ {{ diskName }} reading + {{ ((diskReadBytes / diskTotalBytes) * 100.0).toFixed(2) }} % -
-
{{ diskName }} loaded
-
- error reading disk: {{ diskReadError }} -
-
No disk loaded
+ + {{ ((diskReadBytes / diskTotalBytes) * 100.0).toFixed(2) }} %
-
-
-

Disk Hex Dump

- -
+
{{ diskName }} loaded
+
+ error reading disk: {{ diskReadError }} +
+
No disk loaded
+ +
+
+

Disk Hex Dump

+ +
+
+

Disk Info

+
diff --git a/src/floppy/disk.ts b/src/floppy/disk.ts new file mode 100644 index 0000000..f110c4a --- /dev/null +++ b/src/floppy/disk.ts @@ -0,0 +1,61 @@ +export interface BiosParameterBlock { + oemId: string + bytesPerSector: number + sectorsPerCluster: number + numReservedSectors: number + numFATs: number + numRootDirEntries: number + totalSectors: number + mediaTypeDescriptor: number + sectorsPerFAT: number + sectorsPerTrack: number + numHeads: number + bootSignature: number + volumeId: number + volumeLabel: string + fileSystemId: string +} + +export function getBiosParameterBlock(buffer: ArrayBuffer): BiosParameterBlock | null { + if (buffer.byteLength < 64) { + return null + } + + const data = new DataView(buffer) + + const asciiDecoder = new TextDecoder('ascii') + + const oemId = asciiDecoder.decode(buffer.slice(3, 11)) + const bytesPerSector = data.getUint16(11, true) + const sectorsPerCluster = data.getUint8(13) + const numReservedSectors = data.getUint16(14, true) + const numFATs = data.getUint8(16) + const numRootDirEntries = data.getUint16(17, true) + const totalSectors = data.getUint16(19, true) + const mediaTypeDescriptor = data.getUint8(21) + const sectorsPerFAT = data.getUint16(22, true) + const sectorsPerTrack = data.getUint16(24, true) + const numHeads = data.getUint16(26, true) + const bootSignature = data.getUint8(38) + const volumeId = data.getUint32(39, true) + const volumeLabel = asciiDecoder.decode(buffer.slice(43, 54)) + const fileSystemId = asciiDecoder.decode(buffer.slice(54, 62)) + + return { + oemId, + bytesPerSector, + sectorsPerCluster, + numReservedSectors, + numFATs, + numRootDirEntries, + totalSectors, + mediaTypeDescriptor, + sectorsPerFAT, + sectorsPerTrack, + numHeads, + bootSignature, + volumeId, + volumeLabel, + fileSystemId, + } +}