1. Falling Speckles Exercise
- Posted by Matt Sephton <u5ms at CSC.LIV.AC.UK> Apr 25, 1997
- 1064 views
I've made a small falling speckles demo, which look sort of like snow. The speckles fall down the screen and build up on any text or whatever. I think that it would be a good exercise for those on the mailing list to see who can come up with the best attempt at putting some sort of speed limitation into the program. My P166 can manage a huge number of speckles but lesser computers cannot. So, how about it? What is required is a small procedure that will add a delay into each pass, so that the algorithm runs at the same speed on all PCs (with a lowest common denominator number of stars). FILE: http://www.csc.liv.ac.uk/~u5ms/Euphoria/falling.zip PS: Is there any program out there which will slow a computer down to a crawl so I can test my Euphoria programs on a '486' or whatever? My turbo button just doesn't do the job. Regards, Matt Sephton -- u5ms at csc.liv.ac.uk http://www.csc.liv.ac.uk/~u5ms/
2. Re: Falling Speckles Exercise
- Posted by Michael Packard <lgp at EXO.COM> Apr 25, 1997
- 1036 views
On Fri, 25 Apr 1997, Matt Sephton wrote: > > So, how about it? What is required is a small procedure that will add a > delay into each pass, so that the algorithm runs at the same speed on > all PCs (with a lowest common denominator number of stars). Here's what I do, which works great: atom frameclock At the beginning of each animation frame: frameclock=time() : : do whatever you do : : while time()-frameclock<.05 do end while This will throttle the speed to 20 fps. You'll need to set tick_rate(100) or more as the default time increment is 1/18 of a second or so. Michael Packard Lord Generic Productions lgp at exo.com http://exo.com/~lgp A Crash Course in Game Design and Production http://exo.com/~lgp/euphoria
3. Re: Falling Speckles Exercise
- Posted by James Powell <Wizard at DJO.COM> Apr 25, 1997
- 1035 views
--=====================_861989419==_ >---------------------- Information from the mail header ----------------------- >Sender: Euphoria Programming for MS-DOS <EUPHORIA at >MIAMIU.ACS.MUOHIO.EDU> >Poster: Matt Sephton <u5ms at CSC.LIV.AC.UK> >Subject: Falling Speckles Exercise >------------------------------------------------------------------------------- > >I've made a small falling speckles demo, which look sort of like snow. >The speckles fall down the screen and build up on any text or whatever. > >I think that it would be a good exercise for those on the mailing list >to see who can come up with the best attempt at putting some sort of >speed limitation into the program. My P166 can manage a huge number of >speckles but lesser computers cannot. > snip >Matt Sephton >-- Actually, i wanted to speed it up :). I had the bright idea of using a virtual screen to perform all the operations on, and then mem_copy it to the VGA. And it works, sort of. The problem is, its slower (currently), and a bit buggy (the snow falls THROUGH things rather than building up!). However, those problems can be fixed. The REAL problem, however, is that it runs fine for 10 only seconds or so. Within that 10 seconds, if the user hits any key, the program exits. Good, thats the way its programmed. BUT, if it is allowed to run longer than that, everything still LOOKS normal, ie. the snow falls (eating as it goes) until a key is pressed. As soon as the key is pressed, the program terminates abnormally, generating a Causeway protection fault (or similar)!! I cant figure out why, so im sending the code and a CS.ERR file. Hopefully someone can spot the bad section of code. James Powell --=====================_861989419==_ x-mac-type="705A4950"; x-mac-creator="705A4950"
4. Re: Falling Speckles Exercise
- Posted by Robert Craig <robert_craig at COMPUSERVE.COM> Apr 25, 1997
- 1044 views
- Last edited Apr 26, 1997
James Powell writes: > runs fine for 10 only seconds or so. Within that 10 seconds, if the user > hits any key, the program exits. Good, thats the way its programmed. > BUT, if it is allowed to run longer than that, everything still LOOKS > normal, ie. the snow falls (eating as it goes) until a key is pressed. As > soon as the key is pressed, > the program terminates abnormally, generating a Causeway protection fault I tried fall.ex in a win95 DOS window and there was no problem. However when I rebooted in (pure) MS-DOS 7.0 mode and ran it, I was able to duplicate the problem exactly as described. I'm not sure yet if it's due to a bug in Euphoria, the Causeway extender, or your program, but I would like to warn other people not to run this program because after it crashed, SCANDISK detected and corrected a minor disk error. I wouldn't want other people to risk damaging their file systems. I'll report back to this list once I figure out what's going wrong here. Thanks for reporting the problem. Regards, Rob Craig Rapid Deployment Software
5. Re: Falling Speckles Exercise
- Posted by Michael Bolin <michaeltom at GEOCITIES.COM> Apr 25, 1997
- 1034 views
- Last edited Apr 26, 1997
* This message contains the file 'snow.zip', which has been * uuencoded. If you are using Pegasus Mail, then you can use * the browser's eXtract function to lift the original contents * out to a file, otherwise you will have to extract the message * and uudecode it manually.
6. Re: Falling Speckles Exercise
- Posted by Michael Bolin <michaeltom at GEOCITIES.COM> Apr 25, 1997
- 1045 views
- Last edited Apr 26, 1997
> The problem is, its slower (currently), and a bit buggy (the snow falls > THROUGH things rather than building up!). > However, those problems can be fixed. The REAL problem, however, is that it > runs fine for 10 only seconds or so. Within that 10 seconds, if the user > hits any key, the program exits. Good, thats the way its programmed. > BUT, if it is allowed to run longer than that, everything still LOOKS > normal, ie. the snow falls (eating as it goes) until a key is pressed. As > soon as the key is pressed, > the program terminates abnormally, generating a Causeway protection fault > (or similar)!! > > I cant figure out why, so im sending the code and a CS.ERR file. Hopefully > someone can spot the bad section of code. > James Powell Here's the corrected source. I've added comments to show where the bugs were, and how I fixed them. I'm pretty sure that the Causeway error came from the snow falling off the bottom line of the screen. I've shown why in the code. Regards, Michael Bolin
7. Re: Falling Speckles Exercise
- Posted by James Powell <Wizard at DJO.COM> Apr 26, 1997
- 1029 views
> >Here's the corrected source. I've added comments to show where the >bugs were, and how I fixed them. > >I'm pretty sure that the Causeway error came from the snow falling >off the bottom line of the screen. I've shown why in the code. > >Regards, > Michael Bolin > Thanks! I looked at the comments you made and I realize what was going on with the snow eating the text etc. But I still dont see how writing to just below the visible screen area would cause the program to fail. I have never experienced a problem like this before (of course, I have never written off the screen in protected mode before either). It seems to me that if writing to memory off the display screen causes the problem, it should have manifested itself while the program was running, not right after a key was pressed. The way the program is written, a check is made for a key press. If there was no key pressed, it goes on to calculate the new screen using the virtual one. Once that is done, it copies the virtual screen to the VGA, and then performs another keypress check/update/copy, ad infinum. if a key was pressed, the program exits the loop, without calculating another screen, and without another VGA write. I am not sure what part of memory is at the 201 line that i was writing to, but I thought it was still part of the display memory (since 64000 * 4 = 320 * 200 * 4 = 256000 which is less than the 512k on my card). However, seeing as it DOES cause problems, I will try to avoid doing so again. Anyway, thanks for the information. >I tried fall.ex in a win95 DOS window and there was no problem. However >when I rebooted in (pure) MS-DOS 7.0 mode and ran it, I was able to >duplicate the problem exactly as described. I'm not sure yet if it's due to >a bug in Euphoria, the Causeway extender, or your program, but I would like >to warn other people not to run this program because after it crashed, >SCANDISK detected and corrected a minor disk error. I wouldn't want other >people to risk damaging their file systems. > >I'll report back to this list once I figure out >what's going wrong here. > >Thanks for reporting the problem. > >Regards, > Rob Craig > Rapid Deployment Software Wow! Can the disk error be traced back to fall.ex? Again, I have very little experience dealing with programming in protected mode, but i thought that VGA memory was VGA memory. I will have to be much more carefull in the future. Also, if you find out exactly what was happening with the Causeway extender when I was writing off the screen, I am sure everyone would like to hear what it was, so that similar mistakes can be avoided. Again, Thanks. James Powell PS. Here's a little tip for other programmers. ; ) There are 2 ways to write bug free code, and only the 3rd way works!
8. Re: Falling Speckles Exercise
- Posted by Robert Craig <robert_craig at COMPUSERVE.COM> Apr 26, 1997
- 1033 views
Michael Bolin writes, > Here's the corrected source. I've added comments to show where the > bugs were, and how I fixed them. > I'm pretty sure that the Causeway error came from the snow falling > off the bottom line of the screen. I've shown why in the code. Thanks Michael for fixing fall.ex. You corrected some bugs, but there is still a bug, even in your improved version. I added some code to check the 2 poke statements, and I found that in James' version and in yours there are instances where the program pokes outside the 64000-byte block of allocated memory. I put an if-statement around the 2 pokes to make sure that no poke would be allowed if it was out of bounds. After this, the "Causeway" error was finally silenced. Conclusion: the bug was due to poking outside the bounds of allocated memory. It was not a Causeway or Euphoria bug. Maybe James or someone can figure out how to completely fix fall.ex. I have to go to bed! Regards, Rob Craig Rapid Deployment Software
9. Re: Falling Speckles Exercise
- Posted by The Reaper <reaper at LOKI.ATCON.COM> Apr 26, 1997
- 1043 views
- Last edited Apr 27, 1997
At 01:57 AM 4/26/97 -0500, you wrote: >Wow! Can the disk error be traced back to fall.ex? Again, I have very >little experience dealing with programming in protected mode, but i thought >that VGA memory was VGA memory. I will have to be much more carefull in >the future. >Also, if you find out exactly what was happening with the Causeway extender >when I was writing off the screen, I am sure everyone would like to hear >what it was, so that similar mistakes can be avoided. Good god, man! Don't mess around with those memory errors! If you're going to write to memory, make SURE you get get right the first time!!!! During my early days of trying memory copies, I poked over the 64000 limit, and not only did my program crash, but EMM386 halted my computer saying that I wrote over sensitive parts of memory! SCANDISK found a few errors, but (thank god) I was able to fix them (hopefully). Now, I always quad-check my code so that I never have to worry about that happening again! You're lucky all you got was a CauseWay Error! =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= The Reaper (J. Lays) http://www.geocities.com/TimesSquare/Alley/4444/ reaper at auracom.com Check out my Euphoria Games page at: -= http://www.geocities.com/TimesSquare/Alley/4444/eugames.html ........................ . .. -||..........__...... "There are those who spend their life . / ||......../-- \\.:::: Dreaming of their desire; . ..| ||...... / | |.::: You can either live to make it happen, .| _-||.......|| / /.:::: Or burn in misery's fire." ..| |..||...... -\_- \ |\-.::: .| |.[< \ .../ \.:: .||.|||\|\ | - - . \.:::: ...|.\|| | \ | | |.:::. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
10. Re: Falling Speckles Exercise
- Posted by Robert Craig <robert_craig at COMPUSERVE.COM> Apr 26, 1997
- 1028 views
- Last edited Apr 27, 1997
James Powell writes: > Also, if you find out exactly what was happening with the Causeway extender > when I was writing off the screen, I am sure everyone would like to hear > what it was, so that similar mistakes can be avoided. I found that fall.ex was not writing off the screen, but it was sometimes poking just beyond the 64000-byte area of memory that was allocated using allocate(). You might have to run it for several seconds before enough damage would be done to cause a crash when you hit a key. I don't know what may have been stored in the area of memory beyond your allocated area. Perhaps you were trashing some other block of memory containing data structures needed by Euphoria or Causeway. > Wow! Can the disk error be traced back to fall.ex? I'm not sure now. I think I crashed some other (non-Euphoria) program before I started playing around with fall.ex. When a program (written in Euphoria or any other language) terminates badly, there is some potential for file system damage. Being paranoid, I usually run scandisk immediately to check for and repair any damage. If a bad crash happens when your Euphoria program is doing a lot of swapping, the swap file might have to be cleaned up by scandisk. By running scandisk and correcting problems right away, you avoid getting into more severe file system problems later on. Euphoria normally protects you by catching subscript out-of-bound errors and so on, and you should rarely see a Causeway error. However when you use poke(), mem_copy(), dos_interrupt() etc. Euphoria does not protect you, and you have to be extra careful to avoid nasty problems. Regards, Rob Craig Rapid Deployment Software