Click here to Skip to main content
15,880,405 members
Articles / Containers / Virtual Machine
Article

Windows Virtual Machine screen saver

Rate me:
Please Sign up or sign in to vote.
3.38/5 (17 votes)
20 Jan 20043 min read 148K   3.2K   43   25
A Windows version of a cool Linux screen saver.

Screenshot

Introduction

I once saw a really cool Linux screen saver while working in the Linux labs at school. It had a bunch of colored numbers and letters all over the screen which periodically pulsed and changed. I could tell it was some kind of program interpreter and that the cycling pulses were running code, but beyond that I didn't have a clue.

Some time later (and not too long ago), I had the urge to write a similar screen saver. My friend shot down my ideas one by one and then suggested I do a port of the original Linux screen saver. That's precisely what I've done.

The Windows Virtual Machine (WVM) screen saver is distributed under the GNU General Public License (GPL). It requires at least Windows NT 4.0 and DirectX 8.0 to run. The source code is provided in Visual C++ 6.0 format. The original screen saver was written by Artur Rataj and is called KVM.

Getting Started

If you want to get the screen saver up and running, extract wvm.scr to your system directory (probably C:\WINDOWS\SYSTEM32). Then right-click on the Desktop, select Properties, and click on the Screen Saver tab. Select the Virtual Machine screen saver from the list. You can now click Settings to change the simulation parameters, click Test to see the screen saver, and click OK to set this as your screen saver.

For details on what the screen saver actually does, click on Help in the Settings dialog. There's a rather exhaustive explanation from the user's perspective there. What follows is an overview from the programmer's perspective.

Framework

The screen saver is divided into four main modules:

  • Display.cpp / Display.h
  • ScreenSaver.cpp / ScreenSaver.h
  • Settings.cpp / Settings.h
  • Simulator.cpp / Simulator.h

ScreenSaver

This is the entry point module. Screen savers that link with scrnsave.lib are required to implement the ScreenSaverProc function. This function is called when the screen saver is started and terminated. Because the screen saver needs to enter a constantly running loop to function, this function starts a thread which handles the rest of the screen saver and returns immediately. Upon termination, it destroys the thread and ends the screen saver.

The thread creates an instance of the ScreenSaver class, which is a singleton (only one instance can exist at a time). It then calls the Heartbeat function, which is the screen saver's main loop, on that instance. This loop continually updates the virtual machine by calling Behave on it and then requesting a screen paint.

Settings

The settings dialog and registry reading and writing is handled by this module. ScreenSaverConfigureDialog, another required screen saver function, is augmented by a static Settings object. This module could probably use a little tidying up but it does the job well.

Display

Nearly all of the DirectX code is contained in this module. The item of interest is the singleton Display class. The code is very minimal because screen savers don't have to deal with losing the device. The constructor initializes Direct3D and the device, the Paint function prepares the device for painting, and the Blt function does a nicely versatile job of painting 2D sprites.

Simulator

This module is the core of the screen saver. Much of the code was taken directly from the Linux original. If you want to really understand it, you'll have to get into the code. I'll point out major landmarks though. Behave is called each time the main loop repeats. It in turn calls DoCycle which updates the state of the virtual machine. It also updates all the effects.

Effects are an addition I made to the screen saver that are not found in the original. In essence, the effects are a linked list of Effect structs. They are updated separately from the virtual machine itself and are painted on top of it.

Conclusion

<P>So that's an overview of the Windows Virtual Machine screen saver. You'll get the most benefit from it by rummaging through the code yourself. Feel free to ask any specific questions and I will go into greater detail.</P>
<P>Happy coding!</P>

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionUpdated the code. Pin
treytomes24-May-16 9:56
treytomes24-May-16 9:56 
QuestionAny Updates? Pin
Bill96031-Jun-11 15:04
Bill96031-Jun-11 15:04 
GeneralThank you for sharing such a beautiful screensaver Pin
yoco31528-Apr-07 21:46
yoco31528-Apr-07 21:46 
I really like this screensaver.

The first time I saw it is on my co-worker's computer, impressing! my co-worker had copied this screensaver to me, but one day my system crashed, and I forget to backup this screensaver, and I forget the name of the screensaver, moreover, I had leaved that company, so I don't know how to get this screen, sad.

About one year later, it comes to me, the screensaver is so beautiful, I use google, and search "artificial life screensaver".

Thanks god, and thank you, I find it.
QuestionMicrosoft Visual C++ Runtime Library Pin
InsomniacXx27-Feb-07 16:10
InsomniacXx27-Feb-07 16:10 
GeneralNice Screensaver! Pin
bneacetp22-Jun-04 21:17
bneacetp22-Jun-04 21:17 
GeneralHere are changes for multi-monitor Pin
DaveMGrant13-Apr-04 5:46
DaveMGrant13-Apr-04 5:46 
GeneralThanks alot ! Pin
Kochise15-Apr-04 22:29
Kochise15-Apr-04 22:29 
GeneralRe: Here are changes for multi-monitor Pin
Ryan Beesley23-Feb-05 13:03
Ryan Beesley23-Feb-05 13:03 
GeneralCPU 100% when ScreenSaver is running Pin
Hans Wieser13-Feb-04 9:02
Hans Wieser13-Feb-04 9:02 
GeneralRe: CPU 100% when ScreenSaver is running Pin
DaveMGrant13-Apr-04 5:49
DaveMGrant13-Apr-04 5:49 
GeneralRe: CPU 100% when ScreenSaver is running Pin
Hans Wieser15-Apr-04 23:23
Hans Wieser15-Apr-04 23:23 
GeneralRe: CPU 100% when ScreenSaver is running Pin
DaveMGrant16-Apr-04 3:05
DaveMGrant16-Apr-04 3:05 
GeneralDual Monitors Pin
smelton4-Feb-04 8:46
smelton4-Feb-04 8:46 
GeneralCould not get it to compile. Pin
WREY22-Jan-04 4:39
WREY22-Jan-04 4:39 
GeneralRe: Could not get it to compile. Pin
Squirrel Twirler22-Jan-04 10:17
Squirrel Twirler22-Jan-04 10:17 
GeneralRe: Could not get it to compile. Pin
DaveMGrant13-Apr-04 5:48
DaveMGrant13-Apr-04 5:48 
QuestionMissing a point ? Pin
MarcosEdu22-Jan-04 0:07
MarcosEdu22-Jan-04 0:07 
AnswerBecause this is a BeFreak interpreter emulator ! Pin
Kochise22-Jan-04 2:31
Kochise22-Jan-04 2:31 
GeneralTierra - Artificial Life in computer Pin
Kochise13-Feb-04 3:15
Kochise13-Feb-04 3:15 
GeneralLimitations :( Pin
Kochise20-Jan-04 6:15
Kochise20-Jan-04 6:15 
GeneralVC++ 7 Pin
Squirrel Twirler20-Jan-04 11:34
Squirrel Twirler20-Jan-04 11:34 
GeneralVC++ 7 to VC++6 Pin
Kochise20-Jan-04 19:49
Kochise20-Jan-04 19:49 
GeneralMulti screen display Pin
nalpec20-Jan-04 5:32
nalpec20-Jan-04 5:32 
GeneralRe: Multi screen display Pin
paste0x7815-Nov-07 7:06
paste0x7815-Nov-07 7:06 
GeneralNice Job Pin
Domenic20-Jan-04 2:34
Domenic20-Jan-04 2:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.