| version 1.1, 2003/05/11 18:50:17 |
version 1.2, 2003/05/18 22:40:51 |
|
|
| * |
* |
| */ |
*/ |
| |
|
| /* $Platon$ */ |
/* $Platon: games/_shared/dos2linux.c,v 1.1.1.1 2003/05/11 18:50:17 nepto Exp $ */ |
| |
|
| #include <string.h> |
#include <string.h> |
| #include <stdlib.h> |
#include <stdlib.h> |
| |
#include <time.h> |
| #include <typedef.h> |
#include <typedef.h> |
| #include <vga.h> |
#include <vga.h> |
| |
|
| Line 31 int kbhit(void) /* {{{ */ |
|
| Line 32 int kbhit(void) /* {{{ */ |
|
| return ret > 0 ? 1 : 0; |
return ret > 0 ? 1 : 0; |
| } /* }}} */ |
} /* }}} */ |
| |
|
| |
static int getch_next_ret = 0; |
| |
|
| |
int getch(void) /* {{{ */ |
| |
{ |
| |
register int ret; |
| |
if (getch_next_ret != 0) { |
| |
ret = getch_next_ret; |
| |
getch_next_ret = 0; |
| |
} else { |
| |
ret = vga_getch(); |
| |
if (ret == 27 && kbhit() && (ret = vga_getch()) == 91 && kbhit()) { |
| |
switch (ret = vga_getch()) { |
| |
case 65: getch_next_ret = SUP; break; |
| |
case 66: getch_next_ret = SDOWN; break; |
| |
case 67: getch_next_ret = SRIGHT; break; |
| |
case 68: getch_next_ret = SLEFT; break; |
| |
case 49: getch_next_ret = HOME; break; |
| |
case 50: getch_next_ret = INSERT; break; |
| |
case 51: getch_next_ret = DELETE; break; |
| |
case 52: getch_next_ret = END; break; |
| |
case 53: getch_next_ret = PGUP; break; |
| |
case 54: getch_next_ret = PGDOWN; break; |
| |
} |
| |
if (ret >= 49 && ret <= 54 && kbhit()) |
| |
ret = vga_getch(); /* == 126 */ |
| |
if (getch_next_ret != 0) |
| |
ret = NUL; |
| |
} else if (ret == LF) { |
| |
ret = EOL; |
| |
} else if (ret == 127) { |
| |
ret = BS; |
| |
} |
| |
} |
| |
fprintf(stderr, "getch(): ret = %d\n", ret); |
| |
return ret; |
| |
} /* }}} */ |
| |
|
| |
void getdate(struct date *datep) /* {{{ */ |
| |
{ |
| |
time_t secs; |
| |
struct tm *t; |
| |
time(&secs); |
| |
t = gmtime(&secs); |
| |
datep->da_year = (short) t->tm_year + 1900; |
| |
datep->da_mon = (char) t->tm_mon + 1; |
| |
datep->da_day = (char) t->tm_mday; |
| |
} /* }}} */ |
| |
|
| /* Modeline for ViM {{{ |
/* Modeline for ViM {{{ |
| * vim: set ts=4: |
* vim: set ts=4: |
| * vim600: fdm=marker fdl=0 fdc=0: |
* vim600: fdm=marker fdl=0 fdc=0: |