SCMedia.java
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17: package xeij;
18:
19: import java.lang.*;
20: import java.util.*;
21:
22: public class SCMedia extends HumanMedia {
23:
24: public int scmBytesShiftRecord;
25: public int scmBytesPerRecord;
26: public int scmDiskEndRecord;
27: public int scmPartitionStartSector;
28: public int scmDiskEndSector;
29:
30: public SCMedia (int bytesPerRecord, int diskEndRecord) {
31: super (1024,
32: -1,
33: 2,
34: 1,
35: 512,
36: 0xf7,
37: 0xf7,
38: -1,
39: (long) bytesPerRecord * diskEndRecord,
40: 32768L,
41: (long) bytesPerRecord * diskEndRecord);
42: scmBytesShiftRecord = Integer.numberOfTrailingZeros (bytesPerRecord);
43: scmBytesPerRecord = 1 << scmBytesShiftRecord;
44: scmDiskEndRecord = diskEndRecord;
45: scmPartitionStartSector = (int) (humPartitionStartByte >> humBytesShiftSector);
46: scmDiskEndSector = (int) (humDiskEndByte >> humBytesShiftSector);
47: }
48:
49:
50:
51: public boolean scmMakeFormatData (byte[] bb, boolean partitioningOn, boolean copyHumanSysOn, boolean copyCommandXOn) {
52: Arrays.fill (bb, (byte) 0);
53:
54: System.arraycopy (SPC.SPC_DISK_ID_1, 0, bb, 0x00000000, SPC.SPC_DISK_ID_1.length);
55: ByteArray.byaWw (bb, 0x00000008, scmBytesPerRecord);
56: ByteArray.byaWl (bb, 0x0000000a, scmDiskEndRecord);
57: ByteArray.byaWw (bb, 0x0000000e, 0x0100);
58: System.arraycopy (SPC.SPC_DISK_ID_2, 0, bb, 0x00000010, SPC.SPC_DISK_ID_2.length);
59:
60: System.arraycopy (SPC.SPC_DISK_IPL, 0, bb, 0x00000400, SPC.SPC_DISK_IPL.length);
61:
62: ByteArray.byaWl (bb, 0x00000800, 'X' << 24 | '6' << 16 | '8' << 8 | 'K');
63: if (partitioningOn) {
64: ByteArray.byaWl (bb, 0x00000804, scmDiskEndSector);
65: } else {
66: ByteArray.byaWl (bb, 0x00000804, scmPartitionStartSector);
67: }
68: ByteArray.byaWl (bb, 0x00000808, scmDiskEndSector);
69: ByteArray.byaWl (bb, 0x0000080c, scmDiskEndSector);
70: if (partitioningOn) {
71: ByteArray.byaWl (bb, 0x00000810, 'H' << 24 | 'u' << 16 | 'm' << 8 | 'a');
72: ByteArray.byaWl (bb, 0x00000814, 'n' << 24 | '6' << 16 | '8' << 8 | 'k');
73: ByteArray.byaWl (bb, 0x00000818, scmPartitionStartSector);
74: ByteArray.byaWl (bb, 0x0000081c, humPartitionSectors);
75: }
76:
77: System.arraycopy (SPC.SPC_DEVICE_DRIVER, 0, bb, 0x00000c00, SPC.SPC_DEVICE_DRIVER.length);
78: if (partitioningOn) {
79:
80: System.arraycopy (SPC.SPC_PARTITION_IPL, 0, bb, (int) humPartitionStartByte, SPC.SPC_PARTITION_IPL.length);
81:
82: ByteArray.byaWw (bb, (int) humPartitionStartByte + 0x12, humBytesPerSector);
83: ByteArray.byaWb (bb, (int) humPartitionStartByte + 0x14, humSectorsPerCluster);
84: ByteArray.byaWb (bb, (int) humPartitionStartByte + 0x15, humFatCount);
85: ByteArray.byaWw (bb, (int) humPartitionStartByte + 0x16, humReservedSectors);
86: ByteArray.byaWw (bb, (int) humPartitionStartByte + 0x18, humRootEntries);
87: ByteArray.byaWw (bb, (int) humPartitionStartByte + 0x1a, 0);
88: ByteArray.byaWb (bb, (int) humPartitionStartByte + 0x1c, humFatID);
89: ByteArray.byaWb (bb, (int) humPartitionStartByte + 0x1d, humFatSectors);
90: ByteArray.byaWl (bb, (int) humPartitionStartByte + 0x1e, humPartitionSectors);
91: ByteArray.byaWl (bb, (int) humPartitionStartByte + 0x22, scmPartitionStartSector);
92:
93: humWriteFatMarker (bb);
94:
95:
96:
97:
98:
99:
100:
101: if (copyHumanSysOn) {
102: if (!humCopyHumanSys (bb)) {
103: return false;
104: }
105: if (copyCommandXOn) {
106: if (!humCopyCommandX (bb)) {
107: return false;
108: }
109: }
110: }
111: if (false) {
112: humDumpFat (bb);
113: }
114: }
115: return true;
116: }
117:
118: }
119:
120:
121: