Could Knight Lore have been (a lot) faster?
- 5MinuteRetro
- Manic Miner
- Posts: 767
- Joined: Mon Nov 13, 2017 12:21 pm
- Location: UK
- Contact:
Could Knight Lore have been (a lot) faster?
I’ve always respected the technological achievement that Knight Lore represented but damn if it wasn’t slow when there was a lot going on in a room.
So, I wonder… using modern techniques / new understandings, could Knight Lore be rewritten to run much faster on original hardware. Sure, I know there were later isometric games that ran faster/better, and so perhaps that’s the answer, right there. But perhaps not. Perhaps those games just used fewer objects and/or something else that otherwise wasn’t quite as good as Knight Lore?
My question, then, to you clever types, is could Knight Lore be redone on an original ZX Spectrum to present *exactly the same game* but only running faster -- and preferably much faster? And, kinda related, could the frame rate be locked so that it never appeared to slow down? (Obviously I know that might mean locking it at the lowest-possible FPS, but if that lowest-possible FPS was still better than the original Knight Lore then so what?)
Does all that make sense? It does to me, but then I’ve had a few drinks!
So, I wonder… using modern techniques / new understandings, could Knight Lore be rewritten to run much faster on original hardware. Sure, I know there were later isometric games that ran faster/better, and so perhaps that’s the answer, right there. But perhaps not. Perhaps those games just used fewer objects and/or something else that otherwise wasn’t quite as good as Knight Lore?
My question, then, to you clever types, is could Knight Lore be redone on an original ZX Spectrum to present *exactly the same game* but only running faster -- and preferably much faster? And, kinda related, could the frame rate be locked so that it never appeared to slow down? (Obviously I know that might mean locking it at the lowest-possible FPS, but if that lowest-possible FPS was still better than the original Knight Lore then so what?)
Does all that make sense? It does to me, but then I’ve had a few drinks!
Retro stuff, real quick
YouTube: http://bit.ly/5MinuteRetro
Twitter: https://twitter.com/5MinuteRetro
YouTube: http://bit.ly/5MinuteRetro
Twitter: https://twitter.com/5MinuteRetro
Re: Could Knight Lore have been (a lot) faster?
Yes, probably it could be faster. Hard to say how much however, without getting deep into it. I suppose it wouldn't be an easy job. it cannot be done with one or two pokes and would require a serious rewrite.
But I guess that with very good programming it could run at similar speed as Batman or Head over Heels.
It's an early game and there is a general truth that early games weren't optimal as people were still learning coding tricks. It applies also to impressive classics like Knight Lore.
But I guess that with very good programming it could run at similar speed as Batman or Head over Heels.
It's an early game and there is a general truth that early games weren't optimal as people were still learning coding tricks. It applies also to impressive classics like Knight Lore.
Re: Could Knight Lore have been (a lot) faster?
Yeah, there's no reason it couldn't run more like HoH. Dunno about frame rate locking, that's good in action games but when you're already running at pretty low frame rates it might not be entirely desirable.
- 5MinuteRetro
- Manic Miner
- Posts: 767
- Joined: Mon Nov 13, 2017 12:21 pm
- Location: UK
- Contact:
Re: Could Knight Lore have been (a lot) faster?
Not sure I agree. Consider Manic Miner: perhaps it could've run faster on some screens, or slower on others. Who knows? But would that have been desireable? For me, that's a resounding no. So far as I recall, Manic Miner's speed was its speed, screen through screen. I think in terms of 'experience management' there's a lot to be said of lockng a frame rate.
Retro stuff, real quick
YouTube: http://bit.ly/5MinuteRetro
Twitter: https://twitter.com/5MinuteRetro
YouTube: http://bit.ly/5MinuteRetro
Twitter: https://twitter.com/5MinuteRetro
Re: Could Knight Lore have been (a lot) faster?
It's a tricky thing. Capping the max frame rate can definitely help a game, it's better than the speed constantly changing.5MinuteRetro wrote: ↑Fri Mar 01, 2024 10:37 pm Not sure I agree. Consider Manic Miner: perhaps it could've run faster on some screens, or slower on others. Who knows? But would that have been desireable? For me, that's a resounding no. So far as I recall, Manic Miner's speed was its speed, screen through screen. I think in terms of 'experience management' there's a lot to be said of lockng a frame rate.
But sometimes it's better to just let the game suffer minor slowdown in the worst case scenarios, than to force everything to act like those worse case scenarios. If you can get a solid 25fps most of the time and then just occasionally have it drop to 17fps, that might be a better experience than the entire game at 17fps, particularly if it's not a particularly action oriented game.
- PROSM
- Manic Miner
- Posts: 476
- Joined: Fri Nov 17, 2017 7:18 pm
- Location: Sunderland, England
- Contact:
Re: Could Knight Lore have been (a lot) faster?
It probably could have been faster, with the benefit of hindsight. There were some insightful posts recently in the "Ultimate Filmation Maths" thread, written by @what_the_wasabi and quoted below:
what_the_wasabi wrote: ↑Tue Feb 06, 2024 12:12 pm Apologies for resurrecting this thread but it came up when searching for Filmation. I've been looking at how the Knightlore 3D engine works and found a few interesting things that might explain why it slows down so much.
1. It renders internally to a back buffer, arranged as a linear buffer. Same size as the main screen, taking 6K of space
2. Objects are not stored in depth order, it sorts the objects every time it needs to render something
3. When an object moves it finds all the objects that could potentially overlap the sprite, sorts them and draws them all in depth order to the back buffer. It then just blits the area of the sprite bounding box to the actual screen.
I modified Knightlore to blit the whole back buffer to see which objects are rendered as the player moves around. Below is a video with the modified version running (at 28Mhz!)
The sorting and drawing of so many objects seems to be the main cause of slowdown. There has been some attempt at making the object rendering code run fast. It uses a 3.5K look up table for pre-computed shifted values and the stack pointer to read the source data.
what_the_wasabi wrote: ↑Tue Feb 06, 2024 3:05 pm The main difference is Knightlore (and Alien8) draws all objects completely that are overlapping the moving object, into the back buffer.
Where as HoH has a much smaller 256 byte buffer, which is arranged to be 6 bytes x height of object. Everything gets shifted, clipped and drawn into this small buffer. So the calculations are more complicated but the actual drawing is much less.
HoH drawing routines are optimised for a set of fixed sizes, Knightlore as very general routines that can handle different sprite width and heights.
9K is used by Knightlore for back buffer and shifting tables, so less space for unrolling loops etc.. HoH has lots of similar routines optimised for specific use cases.
Also, I think HoH keeps everything in a sorted linked list and re-arranges it when objects move. So it doesn't have to do much sorting as the game plays. Knightlore keeps objects in a table and generates a temporary sorted list every time it has to draw an object.
All software to-date
Working on something, as always.
Working on something, as always.
Re: Could Knight Lore have been (a lot) faster?
Thanks, very interesting!PROSM wrote: ↑Fri Mar 01, 2024 11:30 pm There were some insightful posts recently in the "Ultimate Filmation Maths" thread, written by @what_the_wasabi and quoted below:
Re: Could Knight Lore have been (a lot) faster?
Fascinating! I love such deep dives into game code.PROSM wrote: ↑Fri Mar 01, 2024 11:30 pm It probably could have been faster, with the benefit of hindsight. There were some insightful posts recently in the "Ultimate Filmation Maths" thread, written by @what_the_wasabi and quoted below:
- arkannoyed
- Manic Miner
- Posts: 438
- Joined: Mon Feb 05, 2018 9:56 am
- Location: Northamptonshire
Re: Could Knight Lore have been (a lot) faster?
The conversion of Melkiors Mansion that Bob Smith is working on is being optimised for speed and seems to have managed to overcome some of the annoyances of the game becoming slow. Though it doesn’t contain the same array of moveable objects that Knight Lore does I guess
Re: Could Knight Lore have been (a lot) faster?
... that 'chuck..chuck...chuck' noise when it's going real slow!!!
Re: Could Knight Lore have been (a lot) faster?
The speed of play in my conversion of Melkhior's was, and still is, very much on my mind, as it needs to be as fluid as possible. Indeed, it got me down for quite a while thinking that it simply wasn't, and never would be, fast enough to be playable - especially when compared to the ultra-fluid PC version. The issues I have to overcome are different to both Knight Lore and Head Over Heals though, and are mostly dictated by available memory - as I'd argue it is more graphically rich, and larger, than both those games. I do have a sorted list of objects, and I don't have a full-screen buffer. I have at most 5 moving objects - of various sizes - active at any one time, along with the opening and closing of the doors & trapdoor, any collectable objects & food, and finally static objects such as tables. It can get slow, but hopefully never slow enough to become annoying. If I ever finish it (!) I'm sure people will let me know if I achieved that.arkannoyed wrote: ↑Sat Mar 02, 2024 10:57 am The conversion of Melkiors Mansion that Bob Smith is working on is being optimised for speed and seems to have managed to overcome some of the annoyances of the game becoming slow. Though it doesn’t contain the same array of moveable objects that Knight Lore does I guess
I just flipped my emulator back to 48K mode to have a play of HoH and I'd say that my game is faster, although there are less objects in the playing area, which will make a difference. All in all it's probably very similar if faced with similar content.
Back to the original question though - I'm pretty sure Knight Lore could be faster, but not "a lot" faster. There are various discussions above regarding methods which could be employed to improve it, and all are valid, but I don't think the end result would be dramatically quicker. Personally if anybody was going to invest the time to make a faster 3D engine, I'd rather they made a new original game using it.