The Ur-Quan Masters Home Page Welcome, Guest. Please login or register.
Did you miss your activation email?
October 15, 2024, 06:14:08 am
Home Help Search Login Register
News: Celebrating 30 years of Star Control 2 - The Ur-Quan Masters

+  The Ur-Quan Masters Discussion Forum
|-+  The Ur-Quan Masters Re-Release
| |-+  Technical Issues (Moderator: Death 999)
| | |-+  Velocity problems with hi-res experiment
« previous next »
Pages: [1] Print
Author Topic: Velocity problems with hi-res experiment  (Read 2128 times)
superbutcherx
*Many bubbles*
***
Offline Offline

Posts: 116



View Profile
Velocity problems with hi-res experiment
« on: May 17, 2010, 11:25:59 pm »

Hi!

I've been able to get the "real 640x480" project going pretty nicely: I've got the interplanetary graphics all updated now plus the melee icons, border and interface drawing etc.

In most places it's been easy enough to multiply the defined constants that have something to do with graphics with 2 so that they correspond to the doubled resolution.

I ran into a vexing problem with the ship velocities though. Now that the resolution is doubled, the ships move at half their original speed at hyperspace. (Also melee, but I'm not going there yet). I tried to introduce the resolution factor to the WORLD_TO_VELOCITY and VELOCITY_TO_WORLD defines in velocity.h.

They were basically
WORLD_TO_VELOCITY (s) = s<<5
VELOCITY_TO_WORLD (s) = s>>5

Trying either
WORLD_TO_VELOCITY (s) = s<<(5+1)
or
VELOCITY_TO_WORLD (s) = s>>(5-1)
(the same as multiplying by 2 basically...)
did double the ship speed in interplanetary but kind of messed up the ship handling there and totally wrecked the ship behavior in hyperspace so I think this is not the way to do it here.

I could multiply by 2 many things in the functions in velocity.c, but if you can think of a more elegant way, please let me know.
Logged
Angelfish
Enlightened
*****
Offline Offline

Posts: 568



View Profile
Re: Velocity problems with hi-res experiment
« Reply #1 on: May 18, 2010, 09:40:39 am »

I don't really know how to help you since I'm not that familiar with the UQM source, but it's good to see that you've made progress Smiley.
One question: How exactly is the ship behaviour wrecked? Is the ship too fast, too sluggish or just not manoeverable?
It seems that you're creating a universe double the size, in pixels, so wouldn't it be better to just increase the ship's max speed and accelleration stats by 2?
« Last Edit: May 18, 2010, 09:45:15 am by Angelfish » Logged
superbutcherx
*Many bubbles*
***
Offline Offline

Posts: 116



View Profile
Re: Velocity problems with hi-res experiment
« Reply #2 on: May 18, 2010, 07:08:45 pm »

The ship starts moving quite sluggishly, then suddenly zaps into an incredible hyperspeed, moves sideways and finally disappears from the screen!

Yes, just doubling the speeds would be a clear-cut way of doing the thing. It wouldn't be too hard to introduce the *2 factor to every ship.
It's just that I'm becoming the kind of coding elitist who's always looking for the most elegant way of doing things Wink

Making the graphics is time-consuming, but has been easy enough once I found an OK batch resizer for OSX and also realized that I can reuse the existing graphics to a large extent. That way I only have to make the largest scale graphics anew.

It's only the melee graphics that pose a problem: I'm not sure if I know how to make that lighting/shading thing look as cool as in the original graphics.
Logged
Angelfish
Enlightened
*****
Offline Offline

Posts: 568



View Profile
Re: Velocity problems with hi-res experiment
« Reply #3 on: May 18, 2010, 07:15:04 pm »

For the melee graphics you could just use the timewarp graphics. As to the most elegant way of solving this, I don't know, but the way the ship behaves I think you've got something terribly wrong Wink.
Logged
meep-eep
Forum Admin
Enlightened
*****
Offline Offline

Posts: 2847



View Profile
Re: Velocity problems with hi-res experiment
« Reply #4 on: May 18, 2010, 10:42:38 pm »

In most places it's been easy enough to multiply the defined constants that have something to do with graphics with 2 so that they correspond to the doubled resolution.

I ran into a vexing problem with the ship velocities though. Now that the resolution is doubled, the ships move at half their original speed at hyperspace. (Also melee, but I'm not going there yet). I tried to introduce the resolution factor to the WORLD_TO_VELOCITY and VELOCITY_TO_WORLD defines in velocity.h.
There are several coordinate systems — at least 3, I think — used in the game. I would think that you'd only want to scale the display coordinates — the ones which are actually used to position things on the screen.
I don't recall what system VELOCITY coordinates are part of, and I can't check right now.

Quote
They were basically
WORLD_TO_VELOCITY (s) = s<<5
VELOCITY_TO_WORLD (s) = s>>5

Trying either
WORLD_TO_VELOCITY (s) = s<<(5+1)
or
VELOCITY_TO_WORLD (s) = s>>(5-1)
(the same as multiplying by 2 basically...)
did double the ship speed in interplanetary but kind of messed up the ship handling there and totally wrecked the ship behavior in hyperspace so I think this is not the way to do it here.
WORLD_TO_VELOCITY and VELOCITY_TO_WORLD are supposed to be each other's inverse, so if you change the shift to some number, you need to change it for the other as well.
Also, what might be a problem is that you could be overflowing the integer types used. But if you only scale the display coordinates, you should not have that problem.

Logged

“When Juffo-Wup is complete
when at last there is no Void, no Non
when the Creators return
then we can finally rest.”
superbutcherx
*Many bubbles*
***
Offline Offline

Posts: 116



View Profile
Re: Velocity problems with hi-res experiment
« Reply #5 on: May 23, 2010, 09:39:51 pm »

Yep, I had a meek hope that I would achieve the effect of multiplying by two by just changing one of the WORLD_TO_VELOCITY thingies since when I changed both, it did basically nothing.

But as Angelfish suggested, doubling the flagship speed did the trick nicely in hyperspace and seems to work for other races as well! So that's the direction I'm taking.

Ship speeds in melee might be more problematic though since the ship speed stats are initialized in ship structs with constant numbers.
Variables cannot be used for initializing so I must cram that *resolution_factor somewhere else than in those structures.
Logged
superbutcherx
*Many bubbles*
***
Offline Offline

Posts: 116



View Profile
Re: Velocity problems with hi-res experiment
« Reply #6 on: May 25, 2010, 11:39:04 am »

Ah, I partied too early...

Flying in hyperspace still has some quirks:
When I go right or down at full speed and release thrust, the ship doesn't slow down nicely, but bounces backwards before stopping, as if punched back by a giant fist :-p.

Going up or left at full blast everything is OK.
Maybe some int if overflowing somewhere afterall?
Logged
Angelfish
Enlightened
*****
Offline Offline

Posts: 568



View Profile
Re: Velocity problems with hi-res experiment
« Reply #7 on: May 25, 2010, 04:23:21 pm »

Did you double both the max speed and accelleration as I suggested?
Logged
superbutcherx
*Many bubbles*
***
Offline Offline

Posts: 116



View Profile
Re: Velocity problems with hi-res experiment
« Reply #8 on: May 25, 2010, 06:14:30 pm »

Yep, I doubled them both.

Ship works OK in 320 x 240, but does that bouncy stop in 640 x 480.  Huh
Logged
Alvarin
Enlightened
*****
Offline Offline

Gender: Male
Posts: 799



View Profile
Re: Velocity problems with hi-res experiment
« Reply #9 on: May 25, 2010, 06:54:24 pm »

You might want to change option "ArmBrake=1" to "ArmBrake=0"


Good luck!
Logged
meep-eep
Forum Admin
Enlightened
*****
Offline Offline

Posts: 2847



View Profile
Re: Velocity problems with hi-res experiment
« Reply #10 on: May 25, 2010, 07:20:19 pm »

To Arms!... wait a minute! Don't HAVE any arms!
AIEE!! MY ARMS!! MY ARMS!! WHO HAS STOLEN MY ARMS!!! AIEEE!! ARM THIEF!!!
Har! Har! Har!... Never HAD any arms! Har! Har! Har!
Logged

“When Juffo-Wup is complete
when at last there is no Void, no Non
when the Creators return
then we can finally rest.”
superbutcherx
*Many bubbles*
***
Offline Offline

Posts: 116



View Profile
Re: Velocity problems with hi-res experiment
« Reply #11 on: May 25, 2010, 07:48:02 pm »

YES! That's it! Grin

I should've considered using the infamous ArmBrake variable months ago...
Logged
Angelfish
Enlightened
*****
Offline Offline

Posts: 568



View Profile
Re: Velocity problems with hi-res experiment
« Reply #12 on: May 25, 2010, 11:34:59 pm »

omg what's the armbrake Cheesy
Logged
superbutcherx
*Many bubbles*
***
Offline Offline

Posts: 116



View Profile
Re: Velocity problems with hi-res experiment
« Reply #13 on: June 02, 2010, 08:12:08 pm »

YEAAH!

The ArmBrake was cleverly disguised, but after rigorous search, I found it hiding cowardly in sis_ship.c and dealt it swift justice.
The overflowing integers were SIZES dx, dy, udx and udy in the preprocessing function.

It just happened so, that with the upgraded speed to match the 640x480 resolution, the main ship's max speed with all thrusters was 32768.
Now, too bad, SIZE is a signed 16-bit word, so the max value it can hold is 32767.

Thus 32768 was wrapped around to -32768 creating an ugly bounce when decelerating.  This only happened when letting go of thrust instead of instantly hitting the top speed since the faulty part of the code was only ran when the state of control buttons changed, I guess.

      ORIGINAL:
         udx = dx << 4;
         udy = dy << 4;

      MODDED:
         dtempx = (SDWORD)dx;
         dtempy = (SDWORD)dy;
         if((dtempx << 4) > 32767)
            udx = 32767;
         else
            udx = dtempx;
         if((dtempy << 4) > 32767)
            udy = 32767;
         else
            udy = dtempy;

geeky fun  Cheesy
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!