|
Subject: [stella] Object handler organisation From: Manuel Polik <cybergoth@xxxxxxxx> Date: Thu, 07 Nov 2002 10:05:42 +0100 |
Hi there!
Once again more coding advice is needed.
Well, since I slowly started loosing control over all my
objects behaviour, I started reorganizing it in some OOP
like manner. I've now one giant loop, calling the
required subroutines for every object. It looks like
this:
;-------------------------------------------------------
;INTELLIGENT MOVE AND HANDLE ALL SPACE OBJECTS
;-------------------------------------------------------
LDX #MAXOBJECTS-1
MoveNextSprite
LDA sprtsizetype,X
CMP #$28
BMI NoShipSprite
JSR GeneralMovement ; General Movement
JSR JoystickMovement ; Move according to Joystick
JSR CollisionDetection ; Handle Collision with shot
JSR ZMovement ; Move along the z axxis
JSR HandleShip ; Special ship handling
JMP Spritedone ; Done
NoShipSprite
CMP #$20
BMI NoMeteorSprite
JSR GeneralMovement ; General Movement
JSR JoystickMovement ; Move according to Joystick
JSR CollisionDetection ; Handle Collision with shot
JSR ZMovement ; Move along the z axxis
JSR HandleMeteor ; Special meteor handling
JMP Spritedone ; Done
NoMeteorSprite
CMP #$18
BMI NoShotSprite
JSR JoystickMovement ; Move according to Joystick
JSR CollisionDetection ; Handle Collision with shot
JSR ZMovement ; Move along the z axxis
JSR HandleShot ; Special shot handling
JMP Spritedone ; Done
NoShotSprite
CMP #$10
BMI NoExplosionSprite
JSR HandleExplosion ; Special Explosion Handling
JSR JoystickMovement ; Move according to Joystick
JMP Spritedone ; Done
NoExplosionSprite
CMP #$0F
BMI NoVoidObject
LDA xpos,X ; Simplified void object handling
ORA #%10000000
STA xpos,X
BMI Spritedone ; Done
NoVoidObject
CMP #$0C
BMI NoMothership
JSR JoystickMovement ; Move according to Joystick
JSR GeneralMovement ; General Movement
JSR CollisionDetection ; Handle Collision with shot
JMP Spritedone ; Done
NoMothership
JSR HandleLaser ; Special Laser Handling
JSR GeneralMovement ; General Movement
Spritedone
DEX
BPL MoveNextSprite
RTS
;-------------------------------------------------------
Well, now most of my objects are either Meteors or
Ships...
Assuming I have 10 meteors onscreen, I'd do this 10
times:
JSR GeneralMovement ; General Movement
JSR JoystickMovement ; Move according to Joystick
JSR CollisionDetection ; Handle Collision with shot
JSR ZMovement ; Move along the z axxis
JSR HandleShip ; Special ship handling
So, the JSRs alone cost me 600 extra cycles!
Aaargh!
Though I already started optimizing that for speed, any
ideas for quicker solutions are highly appreciated...
:-)
Here's a few from me:
- One idea from is duplicating the loop, having one
optimized for the meteors scene and one for the normal
combat scene.
- One other is to duplicate
JSR JoystickMovement ; Move according to Joystick
JSR CollisionDetection ; Handle Collision with shot
JSR ZMovement ; Move along the z axxis
Into one single sub, to speed up the ship & meteor
handling. But at the moment I can't grant that those
three subs won't later need any object specific
specialization...
Both of these would also eat huge ROM heaps.
- Next idea was to write a status byte first.
I could then chain the subs and let them start with
something like
LSR executeThisPart
BCC NextPart
But this is still 8-9 cycles per part, too + plus
overhead. Plus there'll most likely be more than 8
different subs - I think they already are.
Hm... well... :-)
Greetings,
Manuel
----------------------------------------------------------------------------------------------
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [stella] incoming: the 1 player ver, Ben Larson | Thread | Re: [stella] Object handler organis, Thomas Jentzsch |
| Re: [stella] [POLL]What is everybod, Manuel Polik | Date | Re: [stella] Object handler organis, Thomas Jentzsch |
| Month |