Author Topic: Chunky Pixel Collision  (Read 23650 times)

0 Members and 1 Guest are viewing this topic.

Offline ervin

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.418
  • Country: au
    • index.php?action=treasury
  • Liked: 1115
  • Likes Given: 1327
Re: Chunky Pixel Collision
« Reply #50 on: 11:11, 15 January 11 »
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!
My (cancelled) entry for the CPCRetroDev 2017 Competition http://www.cpcwiki.eu/forum/programming/my-cpcretrodev-2017-entry/
FAST line drawing in CPCtelera http://www.cpcwiki.eu/forum/programming/drawing-lines-with-cpctelera-sdcc/
RUNCPC My entry for the CPCRetroDev 2015 Competition http://www.cpc-power.com/index.php?page=detail&num=12494

Offline ervin

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.418
  • Country: au
    • index.php?action=treasury
  • Liked: 1115
  • Likes Given: 1327
Re: Chunky Pixel Collision
« Reply #51 on: 02: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)
« Last Edit: 07:14, 17 January 11 by ervin »
My (cancelled) entry for the CPCRetroDev 2017 Competition http://www.cpcwiki.eu/forum/programming/my-cpcretrodev-2017-entry/
FAST line drawing in CPCtelera http://www.cpcwiki.eu/forum/programming/drawing-lines-with-cpctelera-sdcc/
RUNCPC My entry for the CPCRetroDev 2015 Competition http://www.cpc-power.com/index.php?page=detail&num=12494

Offline Ygdrazil

  • Global Moderator
  • 464 Plus
  • *****
  • Posts: 497
  • Country: dk
  • Liked: 50
  • Likes Given: 266
Re: Chunky Pixel Collision
« Reply #52 on: 10:37, 17 January 11 »
This is great!

/ygdrazil

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)

Offline redbox

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.767
  • Country: gb
    • redbox
  • Liked: 369
  • Likes Given: 273
Re: Chunky Pixel Collision
« Reply #53 on: 12:20, 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.

Offline ervin

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.418
  • Country: au
    • index.php?action=treasury
  • Liked: 1115
  • Likes Given: 1327
Re: Chunky Pixel Collision
« Reply #54 on: 13:06, 17 January 11 »
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!
My (cancelled) entry for the CPCRetroDev 2017 Competition http://www.cpcwiki.eu/forum/programming/my-cpcretrodev-2017-entry/
FAST line drawing in CPCtelera http://www.cpcwiki.eu/forum/programming/drawing-lines-with-cpctelera-sdcc/
RUNCPC My entry for the CPCRetroDev 2015 Competition http://www.cpc-power.com/index.php?page=detail&num=12494

Offline ervin

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.418
  • Country: au
    • index.php?action=treasury
  • Liked: 1115
  • Likes Given: 1327
Re: Chunky Pixel Collision
« Reply #55 on: 04:06, 03 February 11 »
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!
« Last Edit: 04:09, 03 February 11 by ervin »
My (cancelled) entry for the CPCRetroDev 2017 Competition http://www.cpcwiki.eu/forum/programming/my-cpcretrodev-2017-entry/
FAST line drawing in CPCtelera http://www.cpcwiki.eu/forum/programming/drawing-lines-with-cpctelera-sdcc/
RUNCPC My entry for the CPCRetroDev 2015 Competition http://www.cpc-power.com/index.php?page=detail&num=12494

Offline redbox

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.767
  • Country: gb
    • redbox
  • Liked: 369
  • Likes Given: 273
Re: Chunky Pixel Collision
« Reply #56 on: 09:46, 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.  :)

Offline Axelay

  • 6128 Plus
  • ******
  • Posts: 589
  • Country: au
  • Liked: 385
  • Likes Given: 89
Re: Chunky Pixel Collision
« Reply #57 on: 13:23, 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

Offline ervin

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.418
  • Country: au
    • index.php?action=treasury
  • Liked: 1115
  • Likes Given: 1327
Re: Chunky Pixel Collision
« Reply #58 on: 13:52, 03 February 11 »
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)
My (cancelled) entry for the CPCRetroDev 2017 Competition http://www.cpcwiki.eu/forum/programming/my-cpcretrodev-2017-entry/
FAST line drawing in CPCtelera http://www.cpcwiki.eu/forum/programming/drawing-lines-with-cpctelera-sdcc/
RUNCPC My entry for the CPCRetroDev 2015 Competition http://www.cpc-power.com/index.php?page=detail&num=12494

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 16.582
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3812
  • Likes Given: 6829
Re: Chunky Pixel Collision
« Reply #59 on: 13:08, 06 February 11 »
I don't understand a bit about the above, but GREAT JOB! :D Let's see it put in use...

Offline ervin

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.418
  • Country: au
    • index.php?action=treasury
  • Liked: 1115
  • Likes Given: 1327
Re: Chunky Pixel Collision
« Reply #60 on: 14:24, 06 February 11 »
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).
My (cancelled) entry for the CPCRetroDev 2017 Competition http://www.cpcwiki.eu/forum/programming/my-cpcretrodev-2017-entry/
FAST line drawing in CPCtelera http://www.cpcwiki.eu/forum/programming/drawing-lines-with-cpctelera-sdcc/
RUNCPC My entry for the CPCRetroDev 2015 Competition http://www.cpc-power.com/index.php?page=detail&num=12494

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 16.582
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3812
  • Likes Given: 6829
Re: Chunky Pixel Collision
« Reply #61 on: 18:42, 06 February 11 »
It's got a road, it's a racer, no matter if you use a supersized bunny shooting up Dobkeratopses! :D

Offline ervin

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.418
  • Country: au
    • index.php?action=treasury
  • Liked: 1115
  • Likes Given: 1327
Re: Chunky Pixel Collision
« Reply #62 on: 22:22, 06 February 11 »
Heck, that's an idea worth thinking about!
 :laugh:
My (cancelled) entry for the CPCRetroDev 2017 Competition http://www.cpcwiki.eu/forum/programming/my-cpcretrodev-2017-entry/
FAST line drawing in CPCtelera http://www.cpcwiki.eu/forum/programming/drawing-lines-with-cpctelera-sdcc/
RUNCPC My entry for the CPCRetroDev 2015 Competition http://www.cpc-power.com/index.php?page=detail&num=12494

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 16.582
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3812
  • Likes Given: 6829
Re: Chunky Pixel Collision
« Reply #63 on: 10:40, 07 February 11 »
If only I could program...

Offline ervin

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.418
  • Country: au
    • index.php?action=treasury
  • Liked: 1115
  • Likes Given: 1327
Re: Chunky Pixel Collision
« Reply #64 on: 11:06, 07 February 11 »
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!
My (cancelled) entry for the CPCRetroDev 2017 Competition http://www.cpcwiki.eu/forum/programming/my-cpcretrodev-2017-entry/
FAST line drawing in CPCtelera http://www.cpcwiki.eu/forum/programming/drawing-lines-with-cpctelera-sdcc/
RUNCPC My entry for the CPCRetroDev 2015 Competition http://www.cpc-power.com/index.php?page=detail&num=12494

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.939
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1157
  • Likes Given: 1924
Learning to Program
« Reply #65 on: 12:41, 07 February 11 »
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

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 16.582
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3812
  • Likes Given: 6829
Re: Chunky Pixel Collision
« Reply #66 on: 20: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...

Offline redbox

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.767
  • Country: gb
    • redbox
  • Liked: 369
  • Likes Given: 273
Re: Chunky Pixel Collision
« Reply #67 on: 20:26, 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.  :)

Offline ervin

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.418
  • Country: au
    • index.php?action=treasury
  • Liked: 1115
  • Likes Given: 1327
Re: Chunky Pixel Collision
« Reply #68 on: 23:07, 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!
« Last Edit: 23:08, 07 February 11 by ervin »
My (cancelled) entry for the CPCRetroDev 2017 Competition http://www.cpcwiki.eu/forum/programming/my-cpcretrodev-2017-entry/
FAST line drawing in CPCtelera http://www.cpcwiki.eu/forum/programming/drawing-lines-with-cpctelera-sdcc/
RUNCPC My entry for the CPCRetroDev 2015 Competition http://www.cpc-power.com/index.php?page=detail&num=12494

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.336
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2278
  • Likes Given: 3478
Re: Chunky Pixel Collision
« Reply #69 on: 11:33, 08 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

Offline sigh

  • 6128 Plus
  • ******
  • Posts: 1.302
  • Liked: 614
  • Likes Given: 62
Re: Chunky Pixel Collision
« Reply #70 on: 13:05, 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

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.939
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1157
  • Likes Given: 1924
Re: Chunky Pixel Collision
« Reply #71 on: 11:10, 09 February 11 »
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

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 16.582
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3812
  • Likes Given: 6829
Re: Chunky Pixel Collision
« Reply #72 on: 10:46, 11 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 ).

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.939
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1157
  • Likes Given: 1924
Re: Chunky Pixel Collision
« Reply #73 on: 11:00, 11 February 11 »
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

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.336
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2278
  • Likes Given: 3478
Re: Chunky Pixel Collision
« Reply #74 on: 11:33, 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