#include #include #include #define INTR 0x1C #define KINTR 0x9 #ifdef __cplusplus #define __CPPARGS ... #else #define __CPPARGS #endif void interrupt (*old)(__CPPARGS); int time = 0; int stop = 0; char halt = 'f'; void interrupt control(__CPPARGS) { if (!stop) ++time; old(); return; } void kbd() { char key, pressed = 0; asm{ mov ah,01h int 16h jz OK mov key,al mov pressed,1 } OK:; if (pressed) { stop = (key == 27); if (stop) printf("proces zastaven\n"); } } void main(void) { int last = -1; int state, laststop; old = getvect(INTR); setvect(INTR, control); do { kbd(); if (time < 20) state = 1; else if (time < 30) state = 2; else if (time < 40) state = 3; else if (time < 50) state = 4; else if (time < 60) state = 5; else if (time < 90) state = 6; else state = 7; if (last != state) { switch (state){ case 1: printf("napoustim vodu\n"); break; case 2: printf(">\n"); break; case 3: printf("<\n"); break; case 4: printf(">\n"); break; case 5: printf("<\n"); break; case 6: printf("vypoustim vodu\n"); break; case 7: printf("konec\n"); halt = 't'; break; } } last = state; } while((halt != 't')); setvect(INTR, old); getchar(); return; }