Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by wero ( 3 years ago )
#include <iostream.h>
#include <dos.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
//----------------------------------------------------------------------------
unsigned char value = 0;
unsigned int mode = 0; // 0: standard mode, 1: enhanced mode
void interrupt (*OldHandler08H)(...);
void interrupt (*OldHandler09H)(...);
//----------------------------------------------------------------------------
void itoa(unsigned int value, char* str, int base)
{
char* p = str;
char* p1, * p2;
unsigned int digits = 0;
do {
unsigned int remainder = value % base;
*p++ = (remainder < 10) ? '0' + remainder : 'A' + remainder - 10;
digits++;
value /= base;
} while (value != 0);
*p = '\0';
// Reverse the string
p1 = str;
p2 = p - 1;
while (p1 < p2) {
char tmp = *p1;
*p1 = *p2;
*p2 = tmp;
p1++;
p2--;
}
}
//----------------------------------------------------------------------------
void interrupt NewHandler08H(...)
{
char text[16];
int i;
for (i = 0; i < 15; i++)
text[i] = ' ';
text[15] = 0;
if (mode == 0) {
struct dostime_t tm;
_dos_gettime(&tm);
itoa(tm.hour, text, 10);
strcat(text, ":");
itoa(tm.minute, text + strlen(text), 10);
strcat(text, ":");
itoa(tm.second, text + strlen(text), 10);
} else {
itoa(value, text, 10);
}
text[strlen(text)] = ' ';
for (i = 0; i < strlen(text); i++)
pokeb(0xB800, 12 * 160 + (40 + i) * 2, text[i]);
value++;
outp(0x20, 0x20);
if (kbhit() && getch() == 27) // Check for Esc key press
exit(0);
}
//----------------------------------------------------------------------------
void interrupt NewHandler09H(...)
{
asm sti
int i;
if (inp(0x60) == 0x58) // Check for F12 key press
{
mode = 1 - mode; // Toggle mode between standard and enhanced
clrscr();
}
OldHandler09H();
}
//----------------------------------------------------------------------------
int main()
{
textcolor(LIGHTGRAY);
textbackground(BLACK);
_setcursortype(_NOCURSOR);
clrscr();
OldHandler08H = getvect(0x08);
OldHandler09H = getvect(0x09);
setvect(0x08, NewHandler08H);
setvect(0x09, NewHandler09H);
while (kbhit())
getch();
getch();
setvect(0x08, OldHandler08H);
setvect(0x09, OldHandler09H);
_setcursortype(_NORMALCURSOR);
clrscr();
return 0;
}
Revise this Paste