News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_ervin

Chunky Pixel Collision

Started by ervin, 15:35, 15 December 10

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

ervin

Hi redbox.

I'm glad it's giving you some ideas - that's really cool.
I've actually thought of some more little optimisations, and it is now running a bit faster.

I'm (ab)using the stack pointer in the routine that processes sprite data now, and that routine has sped up by about 15%, which is handy. I've tried several ideas to make that routine faster, but the stack pointer idea was the only one that really provided any benefit over what I already had.

Hopefully I'll have the final version of the sprite processing and screen display routines for a demo shortly.
It's just amazing how many ways there are to skin a cat, so to speak!

ervin

#51
Well, I'm done with the sprite processing and screen display routines.  :)
I just can't think of any more ways to make them faster.
I've tried several different algorithms and data storage techiques, and I've delved into all sorts of machine code black magic, but this is the best I'm capable of at the moment.
I'm sure some of the ace programmers around these parts could do better, but what I've been able to figure out will have to suffice.

Okay, I've attached the final "engine prototype" to this post.
In it you'll find Savage being harassed by 9 reasonably large Miner Willy sprites.

Savage can be moved around with the arrow keys, while the Willy sprites just move up and down.

All the sprites have transparency, and all of them get clipped when they reach the screen edges.
When the Savage sprite is virtually filling the screen, it's not the fastest thing around, but it is running full-screen, so I'm really happy with it.
When he goes partially off-screen, it speeds up and gets accordingly smoother.

In any case, it's fine for my game design, and now I'll finally be able to start concentrating on that.

This phase of optimisation is now OVER!
8)

Ygdrazil

This is great!

/ygdrazil

Quote from: ervin on 01:23, 17 January 11
Well, I'm done with the sprite processing and screen display routines.  :)
I just can't think of any more ways to make them faster.
I've tried several different algorithms and data storage techiques, and I've delved into all sorts of machine code black magic, but this is the best I'm capable of at the moment.
I'm sure some of the ace programmers around these parts could do better, but what I've been able to figure out will have to suffice.

Okay, I've attached the final "engine prototype" to this post.
In it you'll find Savage being harassed by 9 reasonably large Miner Willy sprites.

Savage can be moved around with the arrow keys, while the Willy sprites just move up and down.

All the sprites have transparency, and all of them get clipped when they reach the screen edges.
When the Savage sprite is virtually filling the screen, it's not the fastest thing around, but it is running full-screen, so I'm really happy with it.
When he goes partially off-screen, it speeds up and gets accordingly smoother.

In any case, it's fine for my game design, and now I'll finally be able to start concentrating on that.

This phase of optimisation is now OVER!
8)

redbox

Quote from: ervin on 01:23, 17 January 11
In any case, it's fine for my game design, and now I'll finally be able to start concentrating on that.

Really cool, liking what you're doing.  :)

Moves along at an impressive speed given how much data you're shifting.

ervin

Thanks guys.

Now I'm trying to figure out how to dynamically create and destroy sprite entities at runtime.
???

I can do it in something like Blitz3D on the PC with my arms tied behind my back, but for the cpc, it's a very different kettle of fish!

ervin

#55
Never let it be said that the IX and IY registers are useless in high speed games!

For the last couple of weeks, while working on other parts of my game, the screen rendering routine has been nagging away at the back of my brain. I just knew that it could be made faster, but I couldn't figure out how.

Well, after staring at the routine for literally hours, I decided to try changing the way the registers in that routine are used.

I shuffled them around, gave them different tasks etc. And I found a combination that used the IX and IY registers in such a way as to free up the BC and DE register pairs and allow them to be used more effectively.

For example, IX is pointing to the start of a block of memory that determines whether or not a particular part of the screen should be rendered in a screen refresh, and I can do this:

srl (ix+n),a
rra
jr nc,NEXT_CELL

That, along with a couple of other changes using the IY register and a few other little things, has led to the screen refresh routine becoming over 10% faster!

VERY CHUFFED I AM!

redbox

Quote from: ervin on 03:06, 03 February 11
Never let it be said that the IX and IY registers are useless in high speed games!

I have found this too, although I do not use them of my first choice because of their speed.  But you're right, they can be very effectively used to speed something up!

Well done with your optimisation.  :)

Axelay

Quote from: ervin on 03:06, 03 February 11
Never let it be said that the IX and IY registers are useless in high speed games!



Heh, well OK not useless, but they're certainly a last resort in my mind!  ;)


Still, faster code is always satisfying to work out, and I'd have to admit there's been times when I've found the gymnastics required to use alternate registers or faff about with things on the stack turns out to be slower than using those accursedly slow index registers!  ;D

ervin

Indeed, I usually leave them as a last resort as well.

I'm actually surprised at how effective they have been in this case!
8)

Gryzor

I don't understand a bit about the above, but GREAT JOB! :D Let's see it put in use...

ervin

I hope to have something cool to show off soon, once I figure out how to do a 3D road!
(It's not a racing game, by the way).

Gryzor

It's got a road, it's a racer, no matter if you use a supersized bunny shooting up Dobkeratopses! :D

ervin

Heck, that's an idea worth thinking about!
:laugh:

Gryzor

If only I could program...

ervin

Give it a go. You might really like it.
Even creating something simple to start with can be really satisfying.

Programming is a difficult hobby, but also very rewarding.  8)

Only problem is that it is also very time-consuming!

AMSDOS

Gryzor wrote:

If only I could program...

Never too late to learn if one is interested! Or even if the family want to have a go!  :)

The problem is sourcing out good programming examples, and sometimes finding the right programming language also matters, so BASIC isn't necessarily a computer language for everyone. I thought I read from someone somewhere how they hated BASIC and couldn't understand it and then turn around and talked about how they Loved their "C" based language!  :-[  BASIC has the problem of being too restricted to what a Magazine publisher demands which would be along the lines of Spaghetti Programming. You can write good structured code in BASIC and I just saw an example of a game in one of my magazines the other day clearly high lighting how the program works!  ;D  Shoot the "GOTO" man!  >:(
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Gryzor

Yeah... thanks for the encouraging words mates, but not gonna happen :( Over the years I've tried learning some stuff and have even put together a few small programs to help me with my work, but learning to program requires dedication and time - and I don't have the time to give it the dedication it needs! Too many hobbies to pick up such a serious one :( Oh well, back to knitting...

redbox

Quote from: ervin on 10:06, 07 February 11
Programming is a difficult hobby, but also very rewarding.  8)

Especially with the Z80.  :D

But optimising a routine down to something mega quick (which is pretty much essential with only 4Mhz of love) is totally what it's all about.  :)

ervin

#68
Quote from: redbox on 19:26, 07 February 11
optimising a routine down to something mega quick (which is pretty much essential with only 4Mhz of love) is totally what it's all about.  :)

Amen, brother!
You're absolutely right - squeezing that extra frame per second is quite the challenge, and a damn satisfying one!

arnoldemu

Quote from: Gryzor on 19:02, 07 February 11
Yeah... thanks for the encouraging words mates, but not gonna happen :( Over the years I've tried learning some stuff and have even put together a few small programs to help me with my work, but learning to program requires dedication and time - and I don't have the time to give it the dedication it needs! Too many hobbies to pick up such a serious one :( Oh well, back to knitting...
Well I am sure you have the skills in other ways? game design? pixelling? music?
level design?
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

sigh

Quote from: arnoldemu on 10:33, 08 February 11
Well I am sure you have the skills in other ways? game design? pixelling? music?
level design?

Exactly! Loading/splash screens, tiles etc. There are lots of little bits out there. I always wanted to be able to program but decided that it's better for me to work on other areas and leave those "Input error in line 10" to someone else ;D

AMSDOS

Gryzor wrote:

"Too many hobbies to pick up such a serious one" :(

Too right, nothing compares it to generating some Sprites and Music eh Maestro?  ;)
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Gryzor

Quote from: arnoldemu on 10:33, 08 February 11
Well I am sure you have the skills in other ways? game design? pixelling? music?
level design?


Ahhh no. I'm not the creative guy, I'm afraid. I'm good at my job (marketing) because I can manage things and supervise the creative processes, but I'm no good in them myself (even if, in the past, I have been known to produce some gfx to replace crappy 'professional' ones for online campaigns. But that was the designer's fault :D ).

AMSDOS

You could be like the 21st Century guy representing AMSOFT, marketing CPC Software and flogging off Amstrad Emulators!  ;)

464 Posts!  :-[
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

arnoldemu

Quote from: Gryzor on 09:46, 11 February 11
Ahhh no. I'm not the creative guy, I'm afraid. I'm good at my job (marketing) because I can manage things and supervise the creative processes, but I'm no good in them myself (even if, in the past, I have been known to produce some gfx to replace crappy 'professional' ones for online campaigns. But that was the designer's fault :D ).
market the wiki, or perhaps market the new cpc games?
;)
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Powered by SMFPacks Menu Editor Mod