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 09: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[117062]
2D Rotated Rectangles Collision Detection[88988]
Keyboard Hook[77329]
UDP[65880]
HTTP Proxy[41218]

::Top 5 Samples::
2D ColDet Rotated Rectangles[11561]
PS2 Mouse Driver[6959]
Wave Format Player[5792]
Reading FAT12[5620]
CodeGuru[5360]


All rights reserved to RageStorm © 2009