Fast scrolling game howto, anyone?

Want to talks about games you like, would like to see developed on the Oric, it's here.
Antiriad2097
Flying Officer
Posts: 158
Joined: Tue May 09, 2006 9:42 pm
Location: Aberdeen, UK
Contact:

Re: Fast scrolling game howto, anyone?

Post by Antiriad2097 »

With a Mario style game, you can do as many Speccy games do and have your parallax bits so they're not actually part of the action, so you can have a fast scroll of a foreground 'ground' object that only uses a couple of characters to make a basic dirt/block effect. That looks convincing running faster than the play area which runs just above it. Just a couple of tiles with that can be redefined on the fly to give say a 1.5 character scroll compared to the main play area 1 char scroll.

You can have sky objects that are again out of range of the player running at a pixel scroll to give a deeper parallax effect. Typically this will also include some horizon objects like hills or mountains. As long as the player sprite doesn't go high enough up the screen to overlap that area it looks good and gives the impression of depth and a larger play area.

The foreground objects are simple to move fast as you're just redefining a repeating pattern across the screen.

The sky/horizon objects don't have to move every frame as they're meant to be slow, so you can focus more time on game logic perhaps in the intervening time.

fwiw, as mentioned in the WoS threads I much prefer a large bottom of screen display panel for score etc to a top one, it just seems to work better visually.
User avatar
Dbug
Site Admin
Posts: 4459
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Fast scrolling game howto, anyone?

Post by Dbug »

Antiriad2097 wrote:fwiw, as mentioned in the WoS threads I much prefer a large bottom of screen display panel for score etc to a top one, it just seems to work better visually.
I guess on the Oric by playing with a subtle HIRES switch at the right place you could force the three last lines of the screen to be using the two other sets of characters, so you can display the whole game and the scores with different character sets.

Personally I like to have the scores at the top in HIRES and then use the 4 sets of characters for the game itself, like using the three last lines of text to do some fancy parallax foreground effect (Like in Shadow of the Beast for example).
User avatar
ibisum
Wing Commander
Posts: 1652
Joined: Fri Apr 03, 2009 8:56 am
Location: Vienna, Austria
Contact:

Re: Fast scrolling game howto, anyone?

Post by ibisum »

Wish I had the chops to do this in C on OSDK right now .. someone else got some C code to do some of these things, yet?
User avatar
Dbug
Site Admin
Posts: 4459
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Fast scrolling game howto, anyone?

Post by Dbug »

ibisum wrote:Wish I had the chops to do this in C on OSDK right now .. someone else got some C code to do some of these things, yet?
It's just a matter of writing characters in the TEXT area (from 0xBB80 to 0xBBE0), and then change the values in the redefined characters area (from 0xB400 to 0xB7FF for STD charset, from 0xB800 for ALT charset).

So if you do that:

Code: Select all

char Data[]={0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7};
printf("ABABABABABABABABABABA");
memset((char*)(0xB400+8*65),Data,8*2);
You will display a bunch of AB characters that get replaced by whatever is in 'Data'.
If you do a loop to change the Data it will animate the AB characters :)
User avatar
Chema
Game master
Posts: 3019
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Fast scrolling game howto, anyone?

Post by Chema »

How interesting...

Just one thing. Am I wrong, or it is not possible to scroll using dynamic redefinition? I mean, the masked sprites on top would show glitches in the background parts which are visible.

That is why I told about alternating std and alt charsets at each frame, to keep everything drawn with double buffer.

More later...
User avatar
Dbug
Site Admin
Posts: 4459
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Fast scrolling game howto, anyone?

Post by Dbug »

Added a quick hack test to show the concept of character redefinition:
http://miniserve.defence-force.org/svn/ ... allaxTest/
(Use left and right keys to change the direction)
User avatar
Chema
Game master
Posts: 3019
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Fast scrolling game howto, anyone?

Post by Chema »

I will have a look at this as soon as I can. Currently with an ipad, and no OSDK nor Oric emulator :(

But I think I got the idea. Smart.

BTW, slice it just remembered me about the routine which let the use calibrate the timers to get an irq in sync with the vertical retrace. It appeared in the old Oric pages. Anyone has experienced with it?
User avatar
Xeron
Emulation expert
Posts: 426
Joined: Sat Mar 07, 2009 5:18 pm
Contact:

Re: Fast scrolling game howto, anyone?

Post by Xeron »

Is there a floating input somewhere on the Oric where you might see the vsync in the interference? I doubt it, but you never know. It seems the Oric has quite noisy busses etc.
User avatar
Dbug
Site Admin
Posts: 4459
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Fast scrolling game howto, anyone?

Post by Dbug »

Xeron wrote:Is there a floating input somewhere on the Oric where you might see the vsync in the interference? I doubt it, but you never know. It seems the Oric has quite noisy busses etc.
I tried in the past to see if we could read something in page 3, values changing etc... but without much success.
User avatar
Chema
Game master
Posts: 3019
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Fast scrolling game howto, anyone?

Post by Chema »

I tested your program Dbug, and I must say the results are quite interesting. Even written in C it is quite fast (asm would give a 5x or even a 10x speed?).

I wonder if my points about restrictions using these kind of trick are still valid. You have some restrictions about the overall design of the map, but that can be handled, I think, depending on the kind of game.

Also, if you redefine the charset which is visible onscreen I am not sure how to manage masked sprites. The only way of doing it with no glitches could be synchronizing with the vertical retrace and doing all the redefinitions before the screen is redrawn. Also I think a double buffer would still be needed if sprites may overlap.

The other option is use two charsets, redefine the one that is not visible and change it once everything has been done. That would keep double buffering, but dramatically reduce the number of usable tiles. This is quite important. A game such as Cobra (spectrum version), or skooldaze uses 24x32 pixel sprites, so 4x4 tiles. If you have 5 sprites onscreen at the same time you need 80 characters. And you'd probably need more. That is why I am using both charsets at odd/even rows (and using much smaller sprites).

These are just thoughts, so, please, correct me if I am wrong.

Anyway I may try to, for example, add this effect in a simple way (just for testing) in my demo, making the stars scroll at a much slower pace. If I make them just one pixel, I can have them scroll by one pixel at each frame. Then see how it looks like.

I could also try to borrow some tiles from Cobra (for instance), which are quite repetitive patterns and see if with much less tile usage, a smoother scroll can be made using this method.

On the matter of sync with the vertical retrace, has anybody used the old program which wrote a band of paper and let the user calibrate the timer by moving it up/down in the screen? Could some kind of calibration make a 50Hz IRQ trigger at the correct moment?

Maybe it is too cumbersome for a game anyway... just wondering.
User avatar
Symoon
Archivist
Posts: 2310
Joined: Sat Jan 14, 2006 12:44 am
Location: Paris, France

Re: Fast scrolling game howto, anyone?

Post by Symoon »

Seems I can't upload anoymore on the DF FTP, but just for the record, I made an animation with char redefinition long ago.
Get it there:
http://dl.free.fr/qzCp9JjoW
Just in case it gives some ideas !
User avatar
Dbug
Site Admin
Posts: 4459
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Fast scrolling game howto, anyone?

Post by Dbug »

Simon: Very nice animation, apparently takes 3x4 characters.

Chema: Ideally the way I would do it is to have a compositing buffer and then flip it to the screen:
- Initialize the buffer with the semi static elements, like mountains, forest and other parallax looking effects
- Write over all the platform blocks
- Add the moving sprites

A way to avoid the problem of flickering is to use the STD and ALT charsets to avoid the problems:
- One frame is drawn in STD, the other frame is drawn in ALT
- From one frame to the other one has to keep the same character allocation for the same type of elements (ie: keep the same range of characters for mountains, blocks, forest, sprites)
- When flipping the screen if there is a delay between the reading of the STD/ALT attribute and the data at worse it will result in some small pixels issues (previous/next frame)

Any unique sprite can be fully masked: It's just a matter of redefining the characters of the sprite by using whatever graphic data is present in the background at this location and then mask out the sprite data itself.

Now the question is how many characters would that use, but that's always going to be an issue anyway :)
User avatar
Silicebit.
Flight Lieutenant
Posts: 313
Joined: Thu Jan 12, 2006 10:18 pm
Location: Madrid, Spain
Contact:

Re: Fast scrolling game howto, anyone?

Post by Silicebit. »

Dbug wrote:I guess on the Oric by playing with a subtle HIRES switch at the right place you could force the three last lines of the screen to be using the two other sets of characters, so you can display the whole game and the scores with different character sets.
Yes, You can do it in this way
Attachments
Alternative characters set.png
Alternative characters set.png (11 KiB) Viewed 13352 times
Oric user since 1984. YouTube
User avatar
Chema
Game master
Posts: 3019
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Fast scrolling game howto, anyone?

Post by Chema »

Dbug: yeah, that is what I thought.

Slicebit, Dbug, does that mean that the three last lines are using the charaet area of hires? So they are usable for a socrpanel, though in text mode... That is very interesting, because I had no idea about how to add information below the play area..

Great! Need to add that to my test... I just need time :)
User avatar
Dbug
Site Admin
Posts: 4459
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Fast scrolling game howto, anyone?

Post by Dbug »

Chema: Yes. Basically if an HIRES attribute is active, the last three lines will use the secondary redefinition area, that's why I said you can use 4 sets of redefined characters and why it's a good idea to do the panel in hires on the top :)
Post Reply