Subversion Repositories SvarDOS

Rev

Rev 402 | Rev 410 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 402 Rev 405
Line 13... Line 13...
13
 *
13
 *
14
 * if not found:
14
 * if not found:
15
 *   installs it by creating a new PSP, set int 22 vector to the routine, set my "parent PSP" to the routine
15
 *   installs it by creating a new PSP, set int 22 vector to the routine, set my "parent PSP" to the routine
16
 *   and quit.
16
 *   and quit.
17
 *
17
 *
18
 *
-
 
19
 *
-
 
20
 * good lecture about PSP and allocating memory
-
 
21
 * https://retrocomputing.stackexchange.com/questions/20001/how-much-of-the-program-segment-prefix-area-can-be-reused-by-programs-with-impun/20006#20006
-
 
22
 *
-
 
23
 * PSP structure
18
 * PSP structure
24
 * http://www.piclist.com/techref/dos/psps.htm
19
 * http://www.piclist.com/techref/dos/psps.htm
25
 *
20
 *
26
 *
21
 *
27
 *
22
 *
Line 281... Line 276...
281
    printf("rmod_inpbuff at %04X:%04X, env_seg at %04X:0000 (env_size = %u bytes)\r\n", rmod_seg, RMOD_OFFSET_INPBUFF, *rmod_envseg, envsiz);
276
    printf("rmod_inpbuff at %04X:%04X, env_seg at %04X:0000 (env_size = %u bytes)\r\n", rmod_seg, RMOD_OFFSET_INPBUFF, *rmod_envseg, envsiz);
282
  }*/
277
  }*/
283
 
278
 
284
  for (;;) {
279
  for (;;) {
285
    char far *cmdline = MK_FP(rmod_seg, RMOD_OFFSET_INPBUFF + 2);
280
    char far *cmdline = MK_FP(rmod_seg, RMOD_OFFSET_INPBUFF + 2);
-
 
281
    unsigned char far *echostatus = MK_FP(rmod_seg, RMOD_OFFSET_ECHOFLAG);
286
 
282
 
287
    /* revert input history terminator to \r */
283
    if (*echostatus != 0) outputnl(""); /* terminate the previous command with a CR/LF */
288
    if (cmdline[-1] != 0) {
-
 
289
      cmdline[(unsigned short)(cmdline[-1])] = '\r';
-
 
290
    }
-
 
291
 
284
 
292
    {
285
    SKIP_NEWLINE:
-
 
286
 
293
      /* print shell prompt */
287
    /* print shell prompt (only if ECHO is enabled) */
-
 
288
    if (*echostatus != 0) {
294
      char *promptptr = BUFFER;
289
      char *promptptr = BUFFER;
295
      buildprompt(promptptr, *rmod_envseg);
290
      buildprompt(promptptr, *rmod_envseg);
296
      _asm {
291
      _asm {
297
        push ax
292
        push ax
298
        push dx
293
        push dx
Line 302... Line 297...
302
        pop dx
297
        pop dx
303
        pop ax
298
        pop ax
304
      }
299
      }
305
    }
300
    }
306
 
301
 
-
 
302
    /* revert input history terminator to \r */
-
 
303
    if (cmdline[-1] != 0) {
-
 
304
      cmdline[(unsigned short)(cmdline[-1])] = '\r';
-
 
305
    }
-
 
306
 
307
    /* wait for user input */
307
    /* wait for user input */
308
    _asm {
308
    _asm {
309
      push ax
309
      push ax
310
      push bx
310
      push bx
311
      push cx
311
      push cx
Line 334... Line 334...
334
      DOSKEY:
334
      DOSKEY:
335
      mov ax, 0x4810
335
      mov ax, 0x4810
336
      int 0x2f
336
      int 0x2f
337
 
337
 
338
      DONE:
338
      DONE:
-
 
339
      /* terminate command with a CR/LF */
-
 
340
      mov ah, 0x02 /* display character in dl */
-
 
341
      mov dl, 0x0d
-
 
342
      int 0x21
-
 
343
      mov dl, 0x0a
-
 
344
      int 0x21
-
 
345
 
339
      pop ds
346
      pop ds
340
      pop dx
347
      pop dx
341
      pop cx
348
      pop cx
342
      pop bx
349
      pop bx
343
      pop ax
350
      pop ax
344
    }
351
    }
345
    outputnl("");
-
 
346
 
352
 
347
    /* if nothing entered, loop again */
353
    /* if nothing entered, loop again (but without appending an extra CR/LF) */
348
    if (cmdline[-1] == 0) continue;
354
    if (cmdline[-1] == 0) goto SKIP_NEWLINE;
349
 
355
 
350
    /* replace \r by a zero terminator */
356
    /* replace \r by a zero terminator */
351
    cmdline[(unsigned char)(cmdline[-1])] = 0;
357
    cmdline[(unsigned char)(cmdline[-1])] = 0;
352
 
358
 
353
    /* move pointer forward to skip over any leading spaces */
359
    /* move pointer forward to skip over any leading spaces */
Line 362... Line 368...
362
      continue;
368
      continue;
363
    }
369
    }
364
 
370
 
365
    /* try matching (and executing) an internal command */
371
    /* try matching (and executing) an internal command */
366
    {
372
    {
367
      int ecode = cmd_process(*rmod_envseg, cmdline, BUFFER);
373
      int ecode = cmd_process(rmod_seg, *rmod_envseg, cmdline, BUFFER);
368
      if (ecode >= 0) *lastexitcode = ecode;
374
      if (ecode >= 0) *lastexitcode = ecode;
369
      if (ecode >= -1) { /* internal command executed */
375
      if (ecode >= -1) { /* internal command executed */
370
        redir_revert(); /* revert stdout (in case it was redirected) */
376
        redir_revert(); /* revert stdout (in case it was redirected) */
371
        outputnl("");
-
 
372
        continue;
377
        continue;
373
      }
378
      }
374
    }
379
    }
375
 
380
 
376
    /* if here, then this was not an internal command */
381
    /* if here, then this was not an internal command */