Subversion Repositories SvarDOS

Rev

Rev 1775 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1775 Rev 1776
Line 114... Line 114...
114
"xor ax, ax" \
114
"xor ax, ax" \
115
"done:" \
115
"done:" \
116
parm [es] \
116
parm [es] \
117
value [ax];
117
value [ax];
118
 
118
 
-
 
119
/* mode 0x3C = create or truncate file ; model 0x3D = open for read
-
 
120
 * returns 0 on failure, file handle otherwise */
-
 
121
unsigned short dos_fopen(const char *fname, unsigned char mode);
-
 
122
 
-
 
123
#pragma aux dos_fopen = \
-
 
124
"xor al, al" \
-
 
125
"xor cx, cx" \
-
 
126
"int 0x21" \
-
 
127
"jnc DONE" \
-
 
128
"xor ax, ax" \
-
 
129
"DONE:" \
-
 
130
parm [dx] [ah] \
-
 
131
modify [cx] \
-
 
132
value [ax];
119
 
133
 
120
unsigned short dos_fclose(unsigned short handle);
134
unsigned short dos_fclose(unsigned short handle);
121
 
135
 
122
#pragma aux dos_fclose = \
136
#pragma aux dos_fclose = \
123
"mov ah,0x3e" \
137
"mov ah,0x3e" \
Line 168... Line 182...
168
"jc done" \
182
"jc done" \
169
"mov [di], ax" \
183
"mov [di], ax" \
170
"xor ax, ax" \
184
"xor ax, ax" \
171
"done:" \
185
"done:" \
172
parm [bx] [cx] [di] \
186
parm [bx] [cx] [di] \
-
 
187
modify [dx] \
173
value [ax]
188
value [ax]
174
 
189
 
175
 
190
 
176
/*****************************************************************************
191
/*****************************************************************************
177
 * functions                                                                 *
192
 * functions                                                                 *
Line 350... Line 365...
350
  int errflag = 0;
365
  int errflag = 0;
351
 
366
 
352
  /* if filename not overloaded then use the fname in db */
367
  /* if filename not overloaded then use the fname in db */
353
  if (saveas == NULL) saveas = db->fname;
368
  if (saveas == NULL) saveas = db->fname;
354
 
369
 
355
  _asm {
-
 
356
    push cx
-
 
357
    push dx
-
 
358
 
-
 
359
    mov ah, 0x3C    /* create or truncate file */
370
  fd = dos_fopen(saveas, 0x3C /* create or truncate file */);
360
    xor cx, cx      /* file attributes */
-
 
361
    mov dx, saveas  /* works only in SMALL/TINY mode */
-
 
362
    int 0x21
-
 
363
    jnc DONE
-
 
364
    mov errflag, ax
-
 
365
    DONE:
-
 
366
    mov fd, ax
-
 
367
 
-
 
368
    pop dx
-
 
369
    pop cx
-
 
370
  }
-
 
371
 
-
 
372
  if (errflag != 0) return(-1);
371
  if (fd == 0) return(-1);
373
 
372
 
374
  l = db->cursor;
373
  l = db->cursor;
375
  while (l->prev) l = l->prev;
374
  while (l->prev) l = l->prev;
376
 
375
 
377
  /* preset line terminators */
376
  /* preset line terminators */
Line 781... Line 780...
781
 
780
 
782
  /* make the filename canonical (DOS 3+ only, on earlier versions it just copies the filename) */
781
  /* make the filename canonical (DOS 3+ only, on earlier versions it just copies the filename) */
783
  mdr_dos_truename(db->fname, fname);
782
  mdr_dos_truename(db->fname, fname);
784
 
783
 
785
  /* fopen file */
784
  /* fopen file */
786
  fd = 0;
-
 
787
  _asm {
-
 
788
    push cx
-
 
789
    push dx
-
 
790
 
-
 
791
    mov ax, 0x3d00
-
 
792
    mov dx, fname   // works only in SMALL memory model!
785
  fd = dos_fopen(fname, 0x3D /* open for read */);
793
    xor cl, cl
-
 
794
    int 0x21
-
 
795
    mov fd, ax
-
 
796
    jnc done
-
 
797
    mov err, al
786
  if (fd == 0) err = LOADFILE_FILENOTFOUND;
798
    done:
-
 
799
 
-
 
800
    pop dx
-
 
801
    pop cx
-
 
802
  }
-
 
803
 
787
 
804
  if (err != 0) goto SKIPLOADING;
788
  if (err != 0) goto SKIPLOADING;
805
 
789
 
806
  db->lfonly = 1;
790
  db->lfonly = 1;
807
 
791