MCPcopy Create free account
hub / github.com/badvision/jace / prodosMLI

Method prodosMLI

src/main/java/jace/hardware/ProdosDriver.java:80–128  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

78 }
79
80 private MLI_RETURN prodosMLI() {
81 return Emulator.withMemory(memory -> {
82 try {
83 int cmd = memory.readRaw(MLI_COMMAND);
84 MLI_COMMAND_TYPE command = MLI_COMMAND_TYPE.fromInt(cmd);
85 int unit = (memory.readWordRaw(MLI_UNITNUMBER) & 0x080) > 0 ? 1 : 0;
86 if (changeUnit(unit) == false) {
87 return MLI_RETURN.NO_DEVICE;
88 }
89 int block = memory.readWordRaw(MLI_BLOCK_NUMBER);
90 int bufferAddress = memory.readWordRaw(MLI_BUFFER_ADDRESS);
91 // System.out.println(getOwner().getName()+" MLI Call "+command+", unit "+unit+" Block "+block+" --> "+Integer.toHexString(bufferAddress));
92 if (command == null) {
93 System.out.println(getOwner().getName()+" Mass storage given bogus command (" + Integer.toHexString(cmd) + "), returning I/O error");
94 return MLI_RETURN.IO_ERROR;
95 }
96 switch (command) {
97 case STATUS:
98 int blocks = getSize();
99 Emulator.withComputer(computer -> {
100 MOS65C02 cpu = (MOS65C02) computer.getCpu();
101 cpu.X = blocks & 0x0ff;
102 cpu.Y = (blocks >> 8) & 0x0ff;
103 });
104 if (isWriteProtected()) {
105 return MLI_RETURN.WRITE_PROTECTED;
106 }
107 break;
108 case FORMAT:
109 mliFormat();
110 case READ:
111 mliRead(block, bufferAddress);
112 break;
113 case WRITE:
114 mliWrite(block, bufferAddress);
115 break;
116 default:
117 System.out.println(getOwner().getName()+" MLI given bogus command (" + Integer.toHexString(cmd) + " = " + command.name() + "), returning I/O error");
118 return MLI_RETURN.IO_ERROR;
119 }
120 return MLI_RETURN.NO_ERROR;
121 } catch (UnsupportedOperationException ex) {
122 return MLI_RETURN.WRITE_PROTECTED;
123 } catch (IOException ex) {
124 System.out.println(getOwner().getName()+" Encountered IO Error, returning error: " + ex.getMessage());
125 return MLI_RETURN.IO_ERROR;
126 }
127 }, MLI_RETURN.NO_ERROR);
128 }
129}

Callers 1

handleMLIMethod · 0.95

Calls 15

withMemoryMethod · 0.95
fromIntMethod · 0.95
changeUnitMethod · 0.95
getOwnerMethod · 0.95
getSizeMethod · 0.95
withComputerMethod · 0.95
isWriteProtectedMethod · 0.95
mliFormatMethod · 0.95
mliReadMethod · 0.95
mliWriteMethod · 0.95
readRawMethod · 0.80
readWordRawMethod · 0.80

Tested by

no test coverage detected