SeaGtGruff Posted March 29, 2007 Share Posted March 29, 2007 Shake shake shake, Shake shake shake, Shake the screeeen, Shake the screeeen! Okay, I've seen something called "shakescreen" buried in the code for bB's standard kernel (it isn't in the other kernels), but I couldn't find any information about it in the bB documentation or manual, so I had to figure out by myself what it does and how to use it. I'll leave it to each of you to decide if this could ever be useful in one of your games, but first I'll explain what I've figured out about it. "shakescreen" is an interesting little feature that batari seems to have snuck into the standard kernel beginning with bB version 0.99c (Fred, correct me if I'm wrong). What it does is move the screen up and down by 1 scan line-- the playfield, the players, the missiles, and the ball, but *not* the score. However, to do that you must set the shakescreen variable to a value of 128 or higher (i.e., bit 7 must be on). So if you alternate the value of shakescreen between, say, 128 and 0, you can make everything on the screen shake up and down. The speed of the shaking will depend on how often you change the shakescreen variable-- i.e., every frame, or every 2 frames, every 3 frames, etc. The effect seems to work best if you change shakescreen every 3 or 4 frames, otherwise the shaking is too fast and looks like it might just be a jittery "bug" in the program. Why would you want to do this? Well, one possibility might be if there are big explosions in the game, and you want the screen to shake for a second or two whenever there's an explosion. Or perhaps you want to draw big blocks falling from the sky, and whenever a block crashes into the "ground" you want the screen to shake for a second. If you want to experiment with this hidden feature, the first thing you need to know is that there is actually no shakescreen variable set up in bB's memory, so you need to define it by dimming it to one of the user variables (a through z), as follows: dim shakescreen = a Once you've done that, you can set shakescreen to 128 (or 128 to 255) to move the screen up by 1 scan line, or set shakescreen to 0 (or 0 to 127) to move the screen back down by 1 scan line. Note that if you just set shakescreen to, say, 128 and leave it at that value, the screen won't shake, since it will move up 1 scan line and then stay there. So to shake the screen, you need to keep changing shakescreen between, say, 128 and 0-- and you'll want to control how often shakescreen gets set to a new value, to control the speed of the shaking. There are different ways you could do this, such as by counting frames, or else by adding some value to shakescreen, as follows: dim shakescreen = a dim frame = b loop if frame > 3 then shakescreen = 128 else shakescreen = 0 drawscreen frame = frame + 1 if frame = 8 then frame = 0 goto loop dim shakescreen = a loop shakescreen = shakescreen + 32 drawscreen goto loop The first example counts frames and sets shakescreen to 0 or 128 depending on the frame number-- it will be set to 0 if the frame number is 0, 1, 2, or 3, or it will be set to 128 if the frame number is 4, 5, 6, or 7, therefore the screen will shake once every 4 frames. The second example accomplishes the same thing but without using a frame counter, and with fewer lines of code. Assuming shakescreen starts out with a value of 0, it will cycle through values of 0, 32, 64, 96, 128, 160, 192, 224, then back to 0 again. (Remember, values of 128 or more-- where bit 7 is set to a 1-- make the screen move up 1 scan line, and values of 127 or less-- where bit 7 is set to a 0-- make the screen move back down 1 scan line.) The number that you add to shakescreen will determine the speed of the shaking: shakescreen = shakescreen + 1 would be once every 128 frames shakescreen = shakescreen + 2 would be once every 64 frames shakescreen = shakescreen + 4 would be once every 32 frames shakescreen = shakescreen + 8 would be once every 16 frames shakescreen = shakescreen + 16 would be once every 8 frames shakescreen = shakescreen + 32 would be once every 4 frames shakescreen = shakescreen + 64 would be once every 2 frames shakescreen = shakescreen + 128 would be once every frame Here's a very pointless little example that makes the screen shake whenever the left joystick's fire button is pressed, and makes the screen stop shaking when the fire button is released. I just drew a line of playfield pixels, the ball, the two players, and the two missiles, to show that everything (other than the score) will shake up and down. Michael test_shakescreen.bas test_shakescreen.bas.bin 3 Quote Link to comment Share on other sites More sharing options...
+batari Posted March 29, 2007 Share Posted March 29, 2007 Shake shake shake, Shake shake shake, Shake the screeeen, Shake the screeeen! Okay, I've seen something called "shakescreen" buried in the code for bB's standard kernel (it isn't in the other kernels), but I couldn't find any information about it in the bB documentation or manual, so I had to figure out by myself what it does and how to use it. I'll leave it to each of you to decide if this could ever be useful in one of your games, but first I'll explain what I've figured out about it. I completely forgot to document that. You are correct, in that was intended for an earthquake-like effect for explosions, crashes and the like. It could also be used for a finer-grained vertical scroll, though I haven't tried this. Quote Link to comment Share on other sites More sharing options...
abaudrand Posted April 18, 2011 Share Posted April 18, 2011 Hi, just to say that I've tried to use it with the classic kernel plus the pfcolors and pfheights in RAM by SeaGtGruff tip to change the background colors with supercartridge. It didn't shake at all but turns randomly on/off colors on the screen. funny but I wasn't loking for that . Quote Link to comment Share on other sites More sharing options...
KevKelley Posted December 12, 2019 Share Posted December 12, 2019 I was curious but is this feature only in the standard kernel? I had tried using it in DPC+ to see if it would work and nothing. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted December 12, 2019 Share Posted December 12, 2019 8 hours ago, KevKelley said: I was curious but is this feature only in the standard kernel? I had tried using it in DPC+ to see if it would work and nothing. "'shakescreen' is an interesting little feature that batari seems to have snuck into the standard kernel . . ." Quote Link to comment Share on other sites More sharing options...
KevKelley Posted December 12, 2019 Share Posted December 12, 2019 I had seen that and had assumed as much. Is there an easy way to try and implement such a feature in other kernels? I like the effect but didn't know if it would be worth it to explore. Even trying to understand just how it works. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted December 12, 2019 Share Posted December 12, 2019 1 hour ago, KevKelley said: I had seen that and had assumed as much. Is there an easy way to try and implement such a feature in other kernels? I like the effect but didn't know if it would be worth it to explore. Even trying to understand just how it works. Maybe someone who knows about the guts of the DPC+ kernel can figure it out when they're not busy. Quote Link to comment Share on other sites More sharing options...
+Gemintronic Posted December 12, 2019 Share Posted December 12, 2019 For the kernels that support pfscroll you could make a routine that pfscroll's up or down determined by a counter variable that increments at the top of the main program loop. For more fine grained shaking you could play around with playfieldpos With help from bogax I created a 4 way scrolling demo that uses playfieldpos. https://atariage.com/forums/topic/218190-smooth-vertical-scrolling-from-data-want-4-way/ 1 Quote Link to comment Share on other sites More sharing options...
KevKelley Posted December 12, 2019 Share Posted December 12, 2019 Thanks. I will definitely look into the things that you mention. I had used the shakescreen command in my 1st attempt at my game and had some thoughts of how I could use it with the DPC+ version but didn't know if it was something can be easily implemented. This will give me some reading homework! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.