Thread: KeyBoard Interrupt ScreenSvr (stucked)

  1. #1
    Registered User
    Join Date
    May 2016
    Posts
    7

    KeyBoard Interrupt ScreenSvr (stucked)

    Write a TSR program in C that will clear all the contents of the screen and print your VU ID and Name (BC0000000-Name) at the center of the video text memory available at 0xB8000000 whenever Alt+Ctrl+D combination is pressed from keyboard.
    Note that you have to take the backup of the contents of video text memory before clearing the screen. And, whenever Alt+Ctrl+R combination is pressed from the keyboard, all the contents of video text memory should be restored.


    I Am trying this code but still need to check keys.
    Code:
    #include<DOS.H>
    #include<stdio.h>
    void interrupt (*oldint)();
    void interrupt getContents();
    unsigned char far *scr = (unsigned char far*)0xb8000680;
    unsigned char far *src = (unsigned char far*)0xb8000000;
    unsigned char far *sch = (unsigned char far*)0x00400017;
    int i;
    char charsrc[4000];
    
    
    void interrupt getContents(){
    
    
    //saving contents
        for(i=0; i < 4000; i++)
        charsrc[i] = *(src+i);
    //getContentsing Screen
        for(i=0; i < 4000; i+=2)
        {
            *(src + i) = 0x20;
            *(src + i + 1) = 0x07;
        }
        echoChar();
    }
    //Prints RollNo and Name at Center of Graphics Text Memory
    void echoChar(){
         *scr = 0x6D;
        *(scr+1) = 0x70;
        *(scr+2) = 0x63;
        *(scr+3) = 0x07;
        *(scr+4) = 0x31;
        *(scr+5) = 0x07;
        *(scr+6) = 0x34;
        *(scr+7) = 0x07;
        *(scr+8) = 0x30;
        *(scr+9) = 0x07;
        *(scr+10) = 0x34;
        *(scr+11) = 0x07;
        *(scr+12) = 0x30;
        *(scr+13) = 0x07;
        *(scr+14) = 0x32;
        *(scr+15) = 0x07;
        *(scr+16) = 0x32;
        *(scr+17) = 0x07;
        *(scr+18) = 0x39;
        *(scr+19) = 0x07;
        *(scr+20) = 0x37;
        *(scr+159) = 0x07;
        *(scr+160) = 0x53;
        *(scr+161) = 0x07;
        *(scr+162) = 0x61;
        *(scr+163) = 0x07;
        *(scr+164) = 0x6C;
        *(scr+165) = 0x07;
        *(scr+166) = 0x6D;
        *(scr+167) = 0x07;
        *(scr+168) = 0x61;
        *(scr+169) = 0x07;
        *(scr+170) = 0x6E;
        *(scr+171) = 0x07;
        *(scr+172) = 0x20;
        *(scr+173) = 0x07;
        *(scr+174) = 0x48;
        *(scr+175) = 0x07;
        *(scr+176) = 0x61;
        *(scr+177) = 0x07;
        *(scr+178) = 0x69;
        *(scr+179) = 0x07;
        *(scr+180) = 0x64;
        *(scr+181) = 0x07;
        *(scr+182) = 0x65;
        *(scr+183) = 0x07;
        *(scr+184) = 0x72;
    }
    void restoreContents(){
        for(i=0; i < 4000; i++)
            *(src + i) = charsrc[i];
    }
    void main(){
        oldint = getvect(0x09);
        setvect(0x09,getContents);
        keep(0,1000);
        restoreContents();
    
    
    }

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    On any modern operating system, this program is all but certain to crash. This might be valid on an old dos system, or maybe even running inside an emulator like dosbox, but the entire exercise that you're performing here is obsolete.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  3. #3
    Registered User
    Join Date
    May 2016
    Posts
    7
    This is a TSR program which invokes int9 when ctrl+alt+L key pressed and then clear the screen get the backup of text screen and then prints the characters on screen
    Second when ctrl+alt+R key pressed then it restored the contents on the screen.
    it can work as a screen saver

  4. #4
    Registered User
    Join Date
    Jun 2015
    Posts
    1,640
    We know what it is. What kind of system are you trying to run it on?

  5. #5
    Registered User
    Join Date
    May 2016
    Posts
    7
    64 Bit OS-Windows it works over my system using Emulator (DOSBOX 16 bit) but here in this code i didnt putt the code of keyboard invocation in AL register or so what ?
    Can you please insert the code into it for the keys pressing

  6. #6
    Registered User
    Join Date
    May 2016
    Posts
    7
    @Elkvis suggest me the code to call the interrupt 9 only when ctrl+alt+L key pressed

  7. #7
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Writing code like this is literally a waste of time. There is absolutely no market, and no legitimate purpose to learn how to write directly to the screen in DOS. DOS is obsolete and learning to code for it will not help you in any way. Get a modern book on C programming, and get a real development environment, such as Code::Blocks or Eclipse, which are both free, or CLion, which is a commercial product, but if you're a student, you may be able to get a free license.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  8. #8
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by devilShadow View Post
    @Elkvis suggest me the code to call the interrupt 9 only when ctrl+alt+L key pressed
    No. I won't. You're wasting your time with this garbage.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  9. #9
    Registered User
    Join Date
    May 2016
    Posts
    7
    Quote Originally Posted by Elkvis View Post
    Writing code like this is literally a waste of time. There is absolutely no market, and no legitimate purpose to learn how to write directly to the screen in DOS. DOS is obsolete and learning to code for it will not help you in any way. Get a modern book on C programming, and get a real development environment, such as Code::Blocks or Eclipse, which are both free, or CLion, which is a commercial product, but if you're a student, you may be able to get a free license.
    This is a part of my assingment today is the last date of university i have to submit it.

  10. #10
    Registered User
    Join Date
    Jun 2015
    Posts
    1,640
    Quote Originally Posted by devilShadow View Post
    This is a part of my assingment today is the last date of university i have to submit it.
    Then you shouldn't have left it to the last minute.

    You could maybe experiment with conio.h's _getch function, but people aren't much interested in this antiquated style of programming around here. Maybe there's a DOS-lovers site somewhere you could try. E.g., DOS Programming, Undocumented DOS, and DOS Secrets

  11. #11
    Registered User
    Join Date
    May 2016
    Posts
    7
    Quote Originally Posted by algorism View Post
    Then you shouldn't have left it to the last minute.

    You could maybe experiment with conio.h's _getch function, but people aren't much interested in this antiquated style of programming around here. Maybe there's a DOS-lovers site somewhere you could try. E.g., DOS Programming, Undocumented DOS, and DOS Secrets
    Will you suggest me the code as you are an expert ?

  12. #12

  13. #13
    Registered User
    Join Date
    Jun 2015
    Posts
    1,640
    Quote Originally Posted by devilShadow View Post
    Will you suggest me the code as you are an expert ?
    I have no interest in it and am certainly not an expert! You're the one running a DOS emulator on a windows machine, not me. Experiment with _getch and see what values it spews back when you hit your desired key combo.

  14. #14
    Registered User
    Join Date
    May 2016
    Posts
    7
    Quote Originally Posted by Codeplug View Post
    What is this "D.O.S" you speak of?

    gg
    I need the code for ctrl+alt+L key pressing to call int9

  15. #15
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Save off the original int9 interupt function, install your own interrupt function in its place, and see what the scan codes are when pressing ctrl+alt+L.

    Or - if it's not too late - drop out of the class and ask for your money back.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Get Keyboard Character via BIOS Interrupt
    By proggerboy in forum C Programming
    Replies: 20
    Last Post: 05-15-2013, 11:52 AM
  2. Stucked in Linked List --> Last step
    By YannB in forum C Programming
    Replies: 13
    Last Post: 02-06-2013, 06:28 AM
  3. Stucked! Identification Quiz Program..
    By Jimboynoob in forum C Programming
    Replies: 2
    Last Post: 08-20-2012, 10:06 AM
  4. series problem stucked in the last step
    By ramim121 in forum C Programming
    Replies: 3
    Last Post: 07-03-2010, 03:52 PM
  5. Fake a Keyboard Interrupt.
    By nicka in forum Networking/Device Communication
    Replies: 0
    Last Post: 09-04-2009, 03:19 AM

Tags for this Thread