Horizontal Scrolling :0-
Horizontal Scrolling :0-
Does anyone have any idea how its done in Ghosts n' Goblins?
It seems quite impressive.
I imagine each tile has 4 copies at 4 different horizontal positions and the screen scrolls 2 pixels at a time, at a total guess?
It seems quite impressive.
I imagine each tile has 4 copies at 4 different horizontal positions and the screen scrolls 2 pixels at a time, at a total guess?
- MustardTiger
- Microbot
- Posts: 122
- Joined: Tue May 02, 2023 8:05 pm
Re: Horizontal Scrolling :0-
There's an old thread about stack tricks here viewtopic.php?t=3995 which has some Ghost and Goblins info.
The stack trick sounds really interesting and i'd like to give it a try sometime.
The stack trick sounds really interesting and i'd like to give it a try sometime.
Re: Horizontal Scrolling :0-
It's explained in good detail here: http://www.emix8.org/ggdisasm/
Re: Horizontal Scrolling :0-
ah i see thanks if there are 8 tiles ahead they would be rotated the same, so thats just a case of drawing 8 tiles at the same rotation across the screen, I can see how thats fast.
loads of empty space and repeating tiles ftw
loads of empty space and repeating tiles ftw
- Lee Bee
- Dynamite Dan
- Posts: 1297
- Joined: Sat Nov 16, 2019 11:01 pm
- Location: Devon, England
- Contact:
Re: Horizontal Scrolling :0-
I have no idea about the technicalities of this, but visually the scrolling looks the same to me as Agent X 2.
Re: Horizontal Scrolling :0-
There are as many different ways of scrolling the screen as there are Speccy games!
You can try and redraw the screen really fast and get the sprites up before the TV refresh comes round again.
Or you can copy the scenery into a buffer, add the sprites, then copy the buffer to the screen (or swap the visible screen over on a 128K).
R-Type has an ingenious method of just pixel-shifting the character cells on the screen that contain scenery, whilst making sure that sprites are never drawn over those character cells.
You can pixel-shift scenes in memory, filling-in more scenery at the edges, before copying to the screen (Green Beret, Hysteria), or you can repaint the whole play area every time from pre-shifted tiles (e.g. a small number of pre-shifted tiles in 2-pixel steps like Cobra). Or repaint strips pattern with special treatment for the ends (as in that Ghosts'n'Goblins breakdown). Or you can move things around in whole character squares (Gauntlet) if the game runs a bit slower or the graphics and sprites are pretty big.
You can try and redraw the screen really fast and get the sprites up before the TV refresh comes round again.
Or you can copy the scenery into a buffer, add the sprites, then copy the buffer to the screen (or swap the visible screen over on a 128K).
R-Type has an ingenious method of just pixel-shifting the character cells on the screen that contain scenery, whilst making sure that sprites are never drawn over those character cells.
You can pixel-shift scenes in memory, filling-in more scenery at the edges, before copying to the screen (Green Beret, Hysteria), or you can repaint the whole play area every time from pre-shifted tiles (e.g. a small number of pre-shifted tiles in 2-pixel steps like Cobra). Or repaint strips pattern with special treatment for the ends (as in that Ghosts'n'Goblins breakdown). Or you can move things around in whole character squares (Gauntlet) if the game runs a bit slower or the graphics and sprites are pretty big.
Re: Horizontal Scrolling :0-
For me it's not impressive. Ghosts'n'Goblins has actually a very ugly, messy code with different routines for everything. I made some research into it oneDoes anyone have any idea how its done in Ghosts n' Goblins?
It seems quite impressive.
day and my conclusions were the same as given at the link:
It's not even an engine. An engine for me is something reusable that you can use with any graphics. Here we have everything hardcoded with different code for player, demons, zombies, graves, ladders etc.Most of the optimizations are done using specialization. A lot of cycles are saved by writing specific routines for every case that would otherwise require expensive testing for various conditions. This does increase the code size: at least 35 different routines are used in combination to fill the screen.
Yes, the result is smooth. But look at the graphics - tiny sprites and very few simplistic background tiles.
But well, maybe I should have started from saying that I really don't like GNG on Spectrum that much
Re: Horizontal Scrolling :0-
I made a Little game with pixel shifting done right on the screen. It works beautifully as there are z80 commands which can be used to put the bit that is shifted off onto the next byte ,so it works perfectly for scrolling.
I think a flag is set if the bit destroyed by a shift is a one. So then you add one to the previous byte on screen.
It only had one line of tiles. Imagine the floor to a Mario game.
It was fast but any more tiles would have been slow.
I think a flag is set if the bit destroyed by a shift is a one. So then you add one to the previous byte on screen.
It only had one line of tiles. Imagine the floor to a Mario game.
It was fast but any more tiles would have been slow.
Re: Horizontal Scrolling :0-
This code (128K only) can repaint the whole screen from pixel-shifted tiles at 50 frames per second. Unfortunately it's limited to only one type of tile (brickwork or platform) on each row, and that's made up of four tiles (background, left-end, right-end and mid-platform). At least the background tile is a parallax scrolling pattern.
https://spectrumcomputing.co.uk/entry/3 ... um/50Hurts
It's almost unheard of for horizontal scrolling Speccy games to run at 50fps though. Sidewize does, but not many others. Most of the fastest ones run at 25fps, but are limited in screen area and number of sprites on-screen. Green Beret, Hysteria and Ghosts'n'Goblins are the best examples. But Ghosts'n'Goblins, for all its technical trickery, does have some ugly graphics in it.
https://spectrumcomputing.co.uk/entry/3 ... um/50Hurts
It's almost unheard of for horizontal scrolling Speccy games to run at 50fps though. Sidewize does, but not many others. Most of the fastest ones run at 25fps, but are limited in screen area and number of sprites on-screen. Green Beret, Hysteria and Ghosts'n'Goblins are the best examples. But Ghosts'n'Goblins, for all its technical trickery, does have some ugly graphics in it.
Re: Horizontal Scrolling :0-
I hope that one day we will see this game:
I don't know what's the framerate there but it's really, really fast with support of big masked sprites, possible paralax scrolling and background without any limitation.
I'm not sure if it is flickering a bit while scrolling or it is some artifact of Youtube.
Still it could be the best ever done on Speccy when completed.
I don't know what's the framerate there but it's really, really fast with support of big masked sprites, possible paralax scrolling and background without any limitation.
I'm not sure if it is flickering a bit while scrolling or it is some artifact of Youtube.
Still it could be the best ever done on Speccy when completed.
Re: Horizontal Scrolling :0-
Goncharov nice
Very similar to robocop.
I'll check out that 128k code
Very similar to robocop.
I'll check out that 128k code
Re: Horizontal Scrolling :0-
Yes, Goncharov looks basically like Robocop on steroids
Re: Horizontal Scrolling :0-
Metal Man moves the foreground in whole character squares. Goncharov is using 4-pixel steps. Robocop scrolls two pixels at a time.
The step size is just as important as the frame rate.
The step size is just as important as the frame rate.
Re: Horizontal Scrolling :0-
I wasn't quite sure about it from the video but it explains a bit why it's so fast.Goncharov is using 4-pixel steps
Robocop first game was a bit sluggish but it surprisingly fits well becase the real Robocop from the movie was also a bit
sluggish and akward, similar to a heavy armour tank. I never like Robocop adaptations on other platforms where he is faster and can even jump (see 64 version for example).
Re: Horizontal Scrolling :0-
4 pixel scrolling looks great.
I saw the video without knowing any of the technical details. It just felt like a 'real game' unlike the 8 pixel scrolling games.
I saw the video without knowing any of the technical details. It just felt like a 'real game' unlike the 8 pixel scrolling games.
Re: Horizontal Scrolling :0-
When it comes to pixel scrolling, you can call RL (HL) or RR (HL) to rotate a byte in memory by one bit, filling in the empty bit at one end from the carry flag, and catching the bit that falls out the other end in the new setting of the carry flag. So you call it on a series of bytes and the whole lot shift along one bit (or one pixel). But there's no equivalent way to shift by two pixels (which would be really handy).
However, when it comes to four pixels, there's a pair of rarely-used instructions in Z80 called RLD and RRD. These shift the byte in memory that HL points to, by four pixels right or left, and use the bottom half of the A register as the 'carry' or 'overflow'. So what's in the bottom four bits of A gets pushed into one end of a byte in memory, and what falls out the other end goes back into A. In that way, you can shift a screen buffer along by four pixels, and it only takes a fraction longer (18 cycles compared to 15) than the 1-pixel equivalent.
But when it comes to four-pixel scrolling, you could instead have two back-buffers, one permanently shifted four pixels over relative to the other, then you can shift each one by whole bytes for 8-pixel movement, and and just swap between them for four pixel movement. It uses more memory, but it's much faster, and a bit more versatile.
However, when it comes to four pixels, there's a pair of rarely-used instructions in Z80 called RLD and RRD. These shift the byte in memory that HL points to, by four pixels right or left, and use the bottom half of the A register as the 'carry' or 'overflow'. So what's in the bottom four bits of A gets pushed into one end of a byte in memory, and what falls out the other end goes back into A. In that way, you can shift a screen buffer along by four pixels, and it only takes a fraction longer (18 cycles compared to 15) than the 1-pixel equivalent.
But when it comes to four-pixel scrolling, you could instead have two back-buffers, one permanently shifted four pixels over relative to the other, then you can shift each one by whole bytes for 8-pixel movement, and and just swap between them for four pixel movement. It uses more memory, but it's much faster, and a bit more versatile.
-
- Microbot
- Posts: 134
- Joined: Tue Jun 09, 2020 6:14 am
- Contact:
Re: Horizontal Scrolling :0-
Scrolling is just a way of showing a bigger map in a small window. Chances are you don't even need that for your game idea. If you don't, that's a big plus on such a platform.
Otherwise just use Unity/Godot really. Only downside is it's not Spectrum anymore, everything else is a plus, you aren't in pain (not to that extent anyway) and your game isn't crippled by 25fps, bad graphics and all that
Otherwise just use Unity/Godot really. Only downside is it's not Spectrum anymore, everything else is a plus, you aren't in pain (not to that extent anyway) and your game isn't crippled by 25fps, bad graphics and all that
Re: Horizontal Scrolling :0-
Seems a bit harsh What does it matter how he achieved a 25 FPS almost full-screen scroller (and in no doubt written to a tight deadline), or whether it used re-usable/”engine” code? I don’t think the end result could have been bettered on the ol' 48K machine.Ralf wrote: ↑Sat May 27, 2023 12:51 pm For me it's not impressive. Ghosts'n'Goblins has actually a very ugly, messy code with different routines for everything. I made some research into it one
day and my conclusions were the same as given at the link:
It's not even an engine. An engine for me is something reusable that you can use with any graphics. Here we have everything hardcoded with different code for player, demons, zombies, graves, ladders etc.
Yes, the result is smooth. But look at the graphics - tiny sprites and very few simplistic background tiles.
But well, maybe I should have started from saying that I really don't like GNG on Spectrum that much
Also you could accuse most push scrollers of the same – lots of repeated code, just variations on a theme. Or even non-push-scrollers like Commando which also has a lot of custom blitting code for the scenery. Just curious as to what GnG in particular has done to offend you
Re: Horizontal Scrolling :0-
using rotate right on an onscreen byte is one way of doing it.
But wouldnt it be faster to just repaint everything every frame?
But wouldnt it be faster to just repaint everything every frame?
Re: Horizontal Scrolling :0-
Depends entirely on how complicated the scene is. Storing tiles pre-shifted into different scroll positions so the scene can be repainted in any position is memory-consuming, so it's only viable when the scene consists of a very limited number of repeated patterns and structures - as with Ghosts'n'Goblins and Cobra, for example.
- Lethargeek
- Manic Miner
- Posts: 743
- Joined: Wed Dec 11, 2019 6:47 am
Re: Horizontal Scrolling :0-
for caves, rotate edges, skip empty and solid tiles
with limited numbers you may not even need preshiftedJoefish wrote: ↑Wed Jun 21, 2023 6:23 pm Depends entirely on how complicated the scene is. Storing tiles pre-shifted into different scroll positions so the scene can be repainted in any position is memory-consuming, so it's only viable when the scene consists of a very limited number of repeated patterns and structures - as with Ghosts'n'Goblins and Cobra, for example.
shift every used pattern once, then copy