Subversion Repositories SvarDOS

Rev

Rev 1877 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1877 Rev 1954
Line 190... Line 190...
190
 
190
 
191
    /* do we have an original environment? if yes copy it (envsize is a number of paragraphs) */
191
    /* do we have an original environment? if yes copy it (envsize is a number of paragraphs) */
192
    if (origenvseg != 0) _fmemcpy(owner, MK_FP(origenvseg, 0), envsize * 16);
192
    if (origenvseg != 0) _fmemcpy(owner, MK_FP(origenvseg, 0), envsize * 16);
193
  }
193
  }
194
 
194
 
195
  /* set CTRL+BREAK and CRITERR handlers to rmod */
-
 
196
  _asm {
195
  _asm {
197
    push ax
196
    push ax
-
 
197
    push bx
198
    push dx
198
    push dx
199
    push ds
199
    push ds
200
 
200
 
-
 
201
    /* preset DS with RMOD's seg since I will work on RMOD fields */
201
    mov ds, rmodseg
202
    mov ds, rmodseg
202
 
203
 
-
 
204
    /***********************************************
-
 
205
     * set CTRL+BREAK and CRITERR handlers to rmod *
-
 
206
     ***********************************************/
203
    mov ax, 0x2523
207
    mov ax, 0x2523
204
    mov dx, RMOD_OFFSET_BRKHANDLER
208
    mov dx, RMOD_OFFSET_BRKHANDLER
205
    int 0x21
209
    int 0x21
206
 
210
 
207
    mov ax, 0x2524
211
    mov ax, 0x2524
208
    mov dx, RMOD_OFFSET_CRITHANDLER
212
    mov dx, RMOD_OFFSET_CRITHANDLER
209
    int 0x21
213
    int 0x21
210
 
214
 
211
    pop ds
-
 
212
    pop dx
-
 
213
    pop ax
-
 
214
  }
-
 
215
 
-
 
216
  /* mark the input buffer as empty */
-
 
217
  myptr = MK_FP(rmodseg, RMOD_OFFSET_INPUTBUF);
-
 
218
  myptr[0] = 128;  /* max acceptable length */
-
 
219
  myptr[1] = 0;    /* len of currently stored history string */
-
 
220
  myptr[2] = '\r'; /* string terminator */
-
 
221
  myptr[3] = 0xCA; /* signature to detect stack overflow damaging the buffer */
-
 
222
  myptr[4] = 0xFE; /* 2nd byte of the signature */
-
 
223
 
-
 
224
  /* prepare result (rmod props) */
-
 
225
  res = MK_FP(rmodseg, 0x100 + rmodcore_len);
-
 
226
  _fmemset(res, 0, sizeof(*res));  /* zero out */
215
    /***********************************************
227
  res->rmodseg = rmodseg;          /* rmod segment */
-
 
228
 
-
 
229
  /* write env segment to rmod's PSP */
216
     * write boot drive to RMOD's bootdrive field  *
230
  owner = MK_FP(rmodseg, RMOD_OFFSET_ENVSEG);
-
 
231
  *owner = envseg;
-
 
232
 
-
 
233
  /* write boot drive to rmod bootdrive field */
217
     ***********************************************/
234
  _asm {
-
 
235
    push ax
-
 
236
    push bx
-
 
237
    push dx
-
 
238
    push ds
-
 
239
    mov ax, 0x3305 /* DOS 4.0+ - GET BOOT DRIVE */
218
    mov ax, 0x3305 /* DOS 4.0+ - GET BOOT DRIVE */
240
    int 0x21 /* boot drive is in DL now (1=A:, 2=B:, etc) */
219
    int 0x21       /* boot drive is in DL now (1=A:, 2=B:, etc) */
241
    add dl, 'A'-1 /* convert to a proper ASCII letter */
220
    add dl, '@'    /* convert to a proper ASCII letter */
242
    /* set DS to rmodseg */
-
 
243
    mov ax, rmodseg
-
 
244
    mov ds, ax
-
 
245
    /* write boot drive to rmod bootdrive field */
221
    /* write boot drive to rmod bootdrive field */
246
    mov bx, RMOD_OFFSET_BOOTDRIVE
222
    mov bx, RMOD_OFFSET_BOOTDRIVE
247
    mov [bx], dl
223
    mov [bx], dl
-
 
224
 
-
 
225
    /***********************************************
-
 
226
     * mark command-line history buffer as empty   *
-
 
227
     ***********************************************/
-
 
228
    mov bx, RMOD_OFFSET_INPUTBUF
-
 
229
    mov byte ptr [bx+0], 128     /* max acceptable length */
-
 
230
    mov byte ptr [bx+1], 0       /* len of currently stored history string */
-
 
231
    mov byte ptr [bx+2], 0x0D    /* string terminator */
-
 
232
    mov word ptr [bx+3], 0xFECA  /* signature to detect stack overflow damaging the buffer */
-
 
233
 
-
 
234
    /***********************************************
-
 
235
     * write env segment to RMOD's PSP             *
-
 
236
     ***********************************************/
-
 
237
    mov bx, RMOD_OFFSET_ENVSEG
-
 
238
    mov ax, envseg
-
 
239
    mov [bx], ax
-
 
240
 
248
    pop ds
241
    pop ds
249
    pop dx
242
    pop dx
250
    pop bx
243
    pop bx
251
    pop ax
244
    pop ax
252
  }
245
  }
253
 
246
 
-
 
247
  /* prepare result (rmod props) */
-
 
248
  res = MK_FP(rmodseg, 0x100 + rmodcore_len);
-
 
249
  _fmemset(res, 0, sizeof(*res));  /* zero out */
-
 
250
  res->rmodseg = rmodseg;          /* rmod segment */
-
 
251
 
254
  /* save my original int22h handler and parent in rmod's memory */
252
  /* save my original int22h handler and parent in rmod's memory */
255
  res->origint22 = *((unsigned long *)0x0a); /* original int22h handler seg:off is at 0x0a of my PSP */
253
  res->origint22 = *((unsigned long *)0x0a); /* original int22h handler seg:off is at 0x0a of my PSP */
256
  res->origparent = *((unsigned short *)0x16); /* PSP segment of my parent is at 0x16 of my PSP */
254
  res->origparent = *((unsigned short *)0x16); /* PSP segment of my parent is at 0x16 of my PSP */
257
 
255
 
258
  /* set the int22 handler in my PSP to rmod so DOS jumps to rmod after I
256
  /* set the int22 handler in my PSP to rmod so DOS jumps to rmod after I