Home
Tutorials
Code Snippets
Code Samples
Downloads
Links

The Blog
Our Projects
About
Contact

::Add RageStorm to Favorites!::

The Blog | Our Projects | Guest Book | About | Contact

 
Code Snippet - Toggling Lights
Author:Arkon
Category:DOS Stuff
File Size:~ 1.06 KB
Uploaded at:13-Dec-02 04:04:28 am
Description:
  This piece of code shows how to turn on/off drive's led, turn on/off keyboard leds, manipulating cursor in text mode and turn on/off monitor(not by power).
  
// Unfortunately, these two functions work just in real DOS mode.
#define drive_a 0
#define drive_b 1
void lightdrvon(unsigned char drive)
{
 outport(0x3f2, 12 +drive +1 << (4 +drive));
}
void lightdrvoff(unsigned char drive)
{
 outport(0x3f2, 12 +drive);
}

// Keyboard Leds
void scroll_lockon()
{
 pokeb(0x40, 0x17, peekb(0x40, 0x17) | 0x10);
}
void scroll_lockoff()
{
 pokeb(0x40, 0x17, peekb(0x40, 0x17) & 0xef);
}

void num_lockon()
{
 pokeb(0x40, 0x17, peekb(0x40, 0x17) | 0x20);
}
void num_lockoff()
{
 pokeb(0x40, 0x17, peekb(0x40, 0x17) & 0xdf);
}

void caps_lockon()
{
 pokeb(0x40, 0x17, peekb(0x40, 0x17) | 0x40);
}
void caps_lockoff()
{
 pokeb(0x40, 0x17, peekb(0x40, 0x17) & 0xbf);
}

// text mode Cursor
void showcursor()
{
 asm{
  mov ax, 0x100
  mov cx, 0x506
  int 0x10
 }
}
void hidecursor()
{
 asm{
  mov ax, 0x100
  mov cx, 0x2607
  int 0x10
 }
}

// monitor
void screenon()
{
 outport(0x3c4, 1);
 outport(0x3c5, 0x00);
}
void screenoff()
{
 outport(0x3c4, 1);
 outport(0x3c5, inport(0x3c5) | 0x20);
}
NOTE:
Comments that will hurt anyone in any way will be deleted.
Don't ask for features, advertise or curse.
If you want to leave a message to the author use the contacts,
if you have any question in relation to your comments please use the forum.
Comments which violate any of these requests will be deleted without further
notice. Use the comment system decently.

Post your comment:
Name:
email:
Comment:
::Top 5 Tutorials::
Embedded Python[106775]
2D Rotated Rectangles Collision Detection[79918]
Keyboard Hook[69063]
UDP[53058]
HTTP Proxy[36303]

::Top 5 Samples::
2D ColDet Rotated Rectangles[10638]
PS2 Mouse Driver[6122]
Wave Format Player[5005]
Reading FAT12[4893]
CodeGuru[4579]


All rights reserved to RageStorm © 2009