Subversion Repositories SvarDOS

Rev

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

Rev 392 Rev 396
Line 1... Line 1...
1
/*
1
/*
2
 * a variety of helper functions
2
 * a variety of helper functions
3
 * Copyright (C) 2021 Mateusz Viste
3
 * Copyright (C) 2021 Mateusz Viste
4
 */
4
 */
5
 
5
 
-
 
6
#include <i86.h>    /* MK_FP() */
-
 
7
 
6
#include "helpers.h"
8
#include "helpers.h"
7
 
9
 
8
/* case-insensitive comparison of strings, returns non-zero on equality */
10
/* case-insensitive comparison of strings, returns non-zero on equality */
9
int imatch(const char *s1, const char *s2) {
11
int imatch(const char *s1, const char *s2) {
10
  for (;;) {
12
  for (;;) {
Line 167... Line 169...
167
    mov [res], cx
169
    mov [res], cx
168
    DONE:
170
    DONE:
169
  }
171
  }
170
  return(res);
172
  return(res);
171
}
173
}
-
 
174
 
-
 
175
 
-
 
176
/* returns screen's width (in columns) */
-
 
177
unsigned short screen_getwidth(void) {
-
 
178
  /* BIOS 0040:004A = word containing screen width in text columns */
-
 
179
  unsigned short far *scrw = MK_FP(0x40, 0x4a);
-
 
180
  return(*scrw);
-
 
181
}
-
 
182
 
-
 
183
 
-
 
184
/* returns screen's height (in rows) */
-
 
185
unsigned short screen_getheight(void) {
-
 
186
  /* BIOS 0040:0084 = byte containing maximum valid row value (EGA ONLY) */
-
 
187
  unsigned char far *scrh = MK_FP(0x40, 0x84);
-
 
188
  if (*scrh == 0) return(25);  /* pre-EGA adapter */
-
 
189
  return(*scrh + 1);
-
 
190
}
-
 
191
 
-
 
192
 
-
 
193
/* displays the "Press any key to continue" msg and waits for a keypress */
-
 
194
void press_any_key(void) {
-
 
195
  output("Press any key to continue...");
-
 
196
  _asm {
-
 
197
    mov ah, 0x08  /* no echo console input */
-
 
198
    int 0x21      /* pressed key in AL now (0 for extended keys) */
-
 
199
    test al, al
-
 
200
    jnz DONE
-
 
201
    int 0x21      /* executed ah=8 again to read the rest of extended key */
-
 
202
    DONE:
-
 
203
    /* output CR/LF */
-
 
204
    mov ah, 0x02
-
 
205
    mov dl, 0x0D
-
 
206
    int 0x21
-
 
207
    mov dl, 0x0A
-
 
208
    int 0x21
-
 
209
  }
-
 
210
}