@@ -190,6 +190,27 @@ func BiosSysCallReserved1(cpm *CPM) error {
190
190
c := cpm .CPU .States .BC .Lo
191
191
de := cpm .CPU .States .DE .U16 ()
192
192
193
+ //
194
+ // Helper to read a null/space terminated string from
195
+ // memory.
196
+ //
197
+ // Here because our custom syscalls read a string when
198
+ // setting both CCP and DisplayDriver.
199
+ //
200
+ getStringFromMemory := func (addr uint16 ) string {
201
+ str := ""
202
+ c := cpm .Memory .Get (addr )
203
+ for c != ' ' && c != 0x00 {
204
+ str += string (c )
205
+ addr ++
206
+ c = cpm .Memory .Get (addr )
207
+ }
208
+
209
+ // Useful when the CCP has passed a string, because
210
+ // that uppercases all input
211
+ return strings .ToLower (str )
212
+ }
213
+
193
214
switch hl {
194
215
case 0x0000 :
195
216
// Magic values in the registers
@@ -209,6 +230,7 @@ func BiosSysCallReserved1(cpm *CPM) error {
209
230
end --
210
231
}
211
232
233
+ // now populate with our name/version/information
212
234
for i , c := range vers {
213
235
cpm .Memory .Set (addr + uint16 (i ), uint8 (c ))
214
236
}
@@ -220,17 +242,10 @@ func BiosSysCallReserved1(cpm *CPM) error {
220
242
} else {
221
243
cpm .input .SetInterruptCount (int (c ))
222
244
}
223
- case 0x0002 :
224
- str := ""
225
-
226
- c := cpm .Memory .Get (de )
227
- for c != ' ' && c != 0x00 {
228
- str += string (c )
229
- de ++
230
- c = cpm .Memory .Get (de )
231
- }
232
245
233
- str = strings .ToLower (str )
246
+ case 0x0002 :
247
+ // Get the string pointed to by DE
248
+ str := getStringFromMemory (de )
234
249
235
250
// Output driver needs to be created
236
251
driver , err := consoleout .New (str )
@@ -243,41 +258,46 @@ func BiosSysCallReserved1(cpm *CPM) error {
243
258
}
244
259
245
260
old := cpm .output .GetName ()
261
+ cpm .output = driver
262
+
263
+ // when running quietly don't show any output
264
+ if cpm .quiet {
265
+ return nil
266
+ }
267
+
246
268
if old != str {
247
269
fmt .Printf ("Console driver changed from %s to %s.\n " , cpm .output .GetName (), driver .GetName ())
248
- cpm .output = driver
249
270
} else {
250
271
fmt .Printf ("console driver is already %s, making no change.\n " , str )
251
272
}
252
- case 0x0003 :
253
- str := ""
254
273
255
- c := cpm .Memory .Get (de )
256
- for c != ' ' && c != 0x00 {
257
- str += string (c )
258
- de ++
259
- c = cpm .Memory .Get (de )
260
- }
274
+ case 0x0003 :
261
275
262
- // CP/M will upper-case command-lines (and therefor their arguments)
263
- str = strings . ToLower ( str )
276
+ // Get the string pointed to by DE
277
+ str := getStringFromMemory ( de )
264
278
265
279
// See if the CCP exists
266
- _ , err := ccp .Get (str )
280
+ entry , err := ccp .Get (str )
267
281
if err != nil {
268
282
fmt .Printf ("Invalid CCP name %s\n " , str )
269
283
return nil
270
284
}
271
285
272
286
// old value
273
287
old := cpm .ccp
288
+ cpm .ccp = str
289
+
290
+ // when running quietly don't show any output
291
+ if cpm .quiet {
292
+ return nil
293
+ }
274
294
275
295
if old != str {
276
- fmt .Printf ("CCP changed from %s to %s.\n " , old , str )
277
- cpm .ccp = str
296
+ fmt .Printf ("CCP changed to %s [%s] Size:0x%04X Entry-Point:0x%04X\n " , str , entry .Description , len (entry .Bytes ), entry .Start )
278
297
} else {
279
298
fmt .Printf ("CCP is already %s, making no change.\n " , str )
280
299
}
300
+
281
301
case 0x0004 :
282
302
if c == 0x00 {
283
303
cpm .quiet = true
0 commit comments