Sonic and Sega Retro Message Board: Megadrive First Person Effect in Toy Story Video Game - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
  • 2 Pages +
  • 1
  • 2
    Locked
    Locked Forum

Megadrive First Person Effect in Toy Story Video Game

#1 User is offline Ethan 

Posted 13 September 2017 - 02:46 AM

  • Posts: 1
  • Joined: 04-June 17
  • Gender:Male
Not sure if this is the right thread. The channel GameHut has brought us some footage of early Sonic R and Sonic 3D Blast footage. Not too long ago, an explanation of how the first person effect in the Megadrive Toy Story game was released after another video where he shows various effects intended for Mickey Mania 2.

https://youtu.be/IhMMK3QLxSM

Assembly Code is beyond me at the moment :rolleyes:/> ... but it was still interesting to see.
This post has been edited by Ethan: 13 September 2017 - 02:47 AM

#2 User is offline MarkeyJester 

Posted 13 September 2017 - 06:17 AM

  • The architect of the universe, didn't build a stairway, leading nowhere.
  • Posts: 1842
  • Joined: 22-July 08
  • Gender:Male
  • Location:Japan
  • Wiki edits:16
There's something dodgy about this...

At 3:06 in the video and beyond, he referenced assembly code of the rendering process, but, has made some obvious optimisation mistakes, some clear ones that a professional game programmer would never have made on the 68k. For example:

loop:
	move.b	(a1),(a0)
	add.l	#1,a0
	add.l	#1,a1

He could've used auto increment on a1 and a0, resulting in:

loop:
	move.b	(a1)+,(a0)+

Additionally, situations where he couldn't have used auto increment (like skipping a pixel or more), e.g:

loop:
	move.b	(a1),(a0)
	add.l	#1,a0
	add.l	#2,a1

Could've been condensed to:

loop:
	move.b	(a1),(a0)+
	add.w	#2,a1

Where a0 has auto increment, and a1 has word added rather than long, since it sign extends...

At around 5:05 there's a series of indexing, now the source of a1 is understandable, but the destination of a0 is not, it's always in order from 1 to 34. They could've used auto increment for all of those and save don both CPU time and space.

Don't get me wrong, it was nice to have a good insight into the professional world, I'm not one to argue with an old aged programmer, I wouldn't expect them to remember how to program in the language by any means, but if he's referencing old code written back in the day, then these mistakes were made at the time, thus, something just doesn't add up. I really cannot stress how odd this is, I'm surprised no other programmers working with him at the time even pointed this out.

#3 User is offline ICEknight 

Posted 13 September 2017 - 11:07 AM

  • Posts: 10792
  • Joined: 11-January 03
  • Gender:Male
  • Location:Spain
  • Wiki edits:18
Maybe you could tell him about it in the comments? Perhaps he had a reason for that.
This post has been edited by ICEknight: 13 September 2017 - 11:07 AM

#4 User is offline Covarr 

Posted 13 September 2017 - 11:14 AM

  • Sentient Cash Register
  • Posts: 4135
  • Joined: 05-February 07
  • Gender:Male
  • Location:The desert of nowhere, USA
  • Wiki edits:1
I would assume it was more about explaining the idea in a way that's as clear as possible to people who may not know any ASM, such as myself.

#5 User is offline Black Squirrel 

Posted 13 September 2017 - 11:48 AM

  • maybe she's born with it
  • Posts: 4150
  • Joined: 27-December 03
  • Gender:Male
  • Location:Northumberland, England
  • Project:maybe it's maybelline
  • Wiki edits:20,569

View PostMarkeyJester, on 13 September 2017 - 06:17 AM, said:

I really cannot stress how odd this is, I'm surprised no other programmers working with him at the time even pointed this out.

The objective is to make it work - to make it work well is secondary, and is dictated by how much time you have left (or knowledge).

Not everyone can work your magic!

#6 User is offline MarkeyJester 

Posted 13 September 2017 - 12:07 PM

  • The architect of the universe, didn't build a stairway, leading nowhere.
  • Posts: 1842
  • Joined: 22-July 08
  • Gender:Male
  • Location:Japan
  • Wiki edits:16
I'm sorry, it appears I've (once again) given the wrong impression. Wrong choice of words, and certainly wrong way of expression, a mistake on my part (and probably one that I'll make again without realising).

I didn't mean to offend anyone, nor imply that "they're shit, I'm better than them", or anything like that. I was just taken off guard. This type of lack of optimisation, is not one of those "strict" type of optimisations, where you'd have to very heavily think about the way you're going about it. It's one of those "common and obvious" types of optimisation, that's what it's taken me off guard. I would not have expected a professional team of developers to make quite the modest of mistakes. Being honest, I thought the effect was brilliant, and quite well laid out for what it was.

If I've offended any of you, my apologies entirely. I am just speculating what they could've added to it, if they had free'd up CPU time from optimising.

View PostCovarr, on 13 September 2017 - 11:14 AM, said:

I would assume it was more about explaining the idea in a way that's as clear as possible to people who may not know any ASM, such as myself.

Natsumi suggested the same, and encouraged me to disassembly Toy Story. Unfortunately, this is not the case, at least, not in aspect that I was addressing with the auto-increment, but it doesn't matter. I realise I could've worded it better.
This post has been edited by MarkeyJester: 13 September 2017 - 12:13 PM

#7 User is offline HedgeHayes 

Posted 13 September 2017 - 02:16 PM

  • Chaos Emeralds, Alola form
  • Posts: 324
  • Joined: 01-June 17
  • Gender:Male
  • Location:Bilbao, Spain
  • Project:Too many of them
I think you worded it perfectly, there's no arrogance in what you said, and you shouldn't be ashamed on being good at what you do, even if you haven't worked professionally in mega Drive games, becuase, let's face it, you'd need a time machine to try get that job. I'll probably would have said the same if I knew as much as you do, and probably with a worse choice of words. It's true, however, people used to do things in the best way possible hardly find that kind of mistakes as something possible coming from a professional, but I can assure you there's a lot of "professional" people doing sub-optimal work and getting away with it, so, as long as the only fault in their code is forgetting the auto-increment, everything's quite fine. :v:

Byt the way, I've always seen you as the most polite person in this forum; I guess thinking you're easily offending someone has something to do with that, but you're truly a respectful and respectable man, don't forget it. :thumbsup:

#8 User is offline Flygon 

Posted 13 September 2017 - 08:48 PM

  • Dem Melons
  • Posts: 3030
  • Joined: 10-February 06
  • Gender:Not Telling
  • Location:Victoria, Australia
  • Project:SMS RPG script
  • Wiki edits:10
Not having seen the video, it's worth remembering that Travelers Tales often suffered severely short development times for the projects they outputted. I understand that Toy Story only got around 6-7 months from very beginning to release.

Even with a game that pulls the crazy stuff it does, and with the incredibly skilled work crew behind it, all sorts of small stuff will fall through the cracks.

Just look at any movie that's been given carte blanche with the budget in particular areas, but also been given a very strict timeline. Throwing enough money at a problem won't fix it if nobody notices the mistakes made into the final cut on time.

#9 User is offline flamewing 

Posted 13 September 2017 - 11:35 PM

  • Emerald Hunter
  • Posts: 1135
  • Joined: 11-October 10
  • Gender:Male
  • Location:🇫🇷 France
  • Project:Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
  • Wiki edits:12

View PostMarkeyJester, on 13 September 2017 - 06:17 AM, said:

loop:
	move.b	(a1),(a0)
	add.l	#1,a0
	add.l	#1,a1

He could've used auto increment on a1 and a0, resulting in:

loop:
	move.b	(a1)+,(a0)+

Additionally, situations where he couldn't have used auto increment (like skipping a pixel or more), e.g:

loop:
	move.b	(a1),(a0)
	add.l	#1,a0
	add.l	#2,a1

Could've been condensed to:

loop:
	move.b	(a1),(a0)+
	add.w	#2,a1

Where a0 has auto increment, and a1 has word added rather than long, since it sign extends...

At around 5:05 there's a series of indexing, now the source of a1 is understandable, but the destination of a0 is not, it's always in order from 1 to 34. They could've used auto increment for all of those and save don both CPU time and space.

I was thinking about that when I watched the video to. But then, when he described what the engine was supposed to be doing, I realized that these initial parts had to be code he reconstructed from memory.

Think about it: tiles are rows of pixels. He needs to skip 3 bytes every write in order to write columns as he describes.

But what is perhaps most relevant is that he does not talk about VDP bandwidth. Drawing half of H32 mode and reflecting vertically means 32x14 tiles, or 32x32x14 = 14,336 bytes.


This takes almost all bandwidth of the VDP for 1 full frame and for almost all of vblank on the next frame, meaning you have very little left for everything else. This on top of the time needed to tender the frame.

So there is something else missing in the description, some other trick they used. Probably line doubling (using hblank to change scroll every other line to double each line), which would halve the number of tiles needed.

#10 User is offline Clownacy 

Posted 14 September 2017 - 04:28 AM

  • Layin' the Wax and Spinnin' the Sounds
  • Posts: 696
  • Joined: 06-July 13
  • Gender:Not Telling
I can't help but find this idea that you have to be on par with Markey to know about something as simple as post-increment a little... insulting, I guess is the word? It's basic 68k. Sure, not everyone knows about the 'self-additions are faster than small left-shifts' trick, but increments? They're not just some obscure optimisation. The only explanation I can think of is the dev getting too used to Z80 ASM, where you actually do need to write code like that, unless you want to resort to gimmicky instructions like 'ldi'. And even then, I don't expect that from a company that's been working with the Mega Drive for four years. It's simply not a mistake you should even make in the first place, let alone miss during cleanup and revision.

View Postflamewing, on 13 September 2017 - 11:35 PM, said:

I was thinking about that when I watched the video to. But then, when he described what the engine was supposed to be doing, I realized that these initial parts had to be code he reconstructed from memory.

Quote

Natsumi suggested the same, and encouraged me to disassembly Toy Story. Unfortunately, this is not the case, at least, not in aspect that I was addressing with the auto-increment, but it doesn't matter. I realise I could've worded it better.

I would have assumed the above quote meant that the code isn't reconstructed, and is actually in the game.
This post has been edited by Clownacy: 14 September 2017 - 04:29 AM

#11 User is offline HCKTROX 

Posted 14 September 2017 - 11:41 AM

  • Nah. Fuck it.
  • Posts: 30
  • Joined: 04-August 10
  • Gender:Not Telling
  • Location:Chile
  • Project:Tails Into Dreams, Tails in Alphaomega
  • Wiki edits:4
Professionally, not only the workflow, but also the environment itself are also very different than a lone and calm room at home. There's a short timeline, have to constantly deal with good and bad people, write a bunch of different and complicated code, yet everything needs to work and play, at least in a good enough way depending the capability and how overall presentation should be. If there's not much time left, and the code got to work, it's time to move on; can't stay stuck around checking and perfecting everything over and over again. Not to mention any extra charges within the team. Distractions and pression, especially if programmer is nervous or anxious person, ARE a true handicap (to what I learnt from college in the most part).

Overall Sonic 3 & Knuckles has useful engine reorganization, but certain objects are still written like shit, some say. For instance, the way Perform_DPLC is called could have been grouped into a macro and avoid reading an array from ROM, so addresses get set using inmediate values instead
To date, most if not every game's source code I have seen has weird oddities at times as well, including but not limited to hacks and commercial games. It seems rare to see cycle-perfect code.


I'm talking for myself here, but who knows if other "programmers" have a similar mindset to this?:
Spoiler

This post has been edited by HCKTROX: 14 September 2017 - 11:49 AM

#12 User is offline Black Squirrel 

Posted 14 September 2017 - 01:31 PM

  • maybe she's born with it
  • Posts: 4150
  • Joined: 27-December 03
  • Gender:Male
  • Location:Northumberland, England
  • Project:maybe it's maybelline
  • Wiki edits:20,569

View PostClownacy, on 14 September 2017 - 04:28 AM, said:

I can't help but find this idea that you have to be on par with Markey to know about something as simple as post-increment a little... insulting, I guess is the word? It's basic 68k.

I'm a C++ programmer by trade. We're not allowed to use the standard library for reasons unknown to man - that standard feature of the language that's quite literally part the second line of code most people write when starting C++ from scratch. My boss probably doesn't know how most of the library works.

Our products keep planes in the sky and let Lewis Hamilton win trophies. This codebase has been actively worked on since 2002 (and parts of it since the 90s) and is used to produce world-class software.


But internally, it sucks.
This post has been edited by Black Squirrel: 14 September 2017 - 01:32 PM

#13 User is offline MarkeyJester 

Posted 14 September 2017 - 01:50 PM

  • The architect of the universe, didn't build a stairway, leading nowhere.
  • Posts: 1842
  • Joined: 22-July 08
  • Gender:Male
  • Location:Japan
  • Wiki edits:16
Auto-increment for the 68k is nothing to do with a standard library of code/routines. Your argument would work if the discussion was about accusing them of not using routines supplied by SEGA, but that is not the issue.

The issue is about a benefitially supplied functionality of the CPU. If you were to say, that your company forbid you to use auto-increment with your C/C++ pointers, as in:

	*ptr1++ = *ptr2++;

And you HAD to do it this way:

	*ptr1 = *ptr2;
	ptr1 += 1;
	ptr2 += 2;

Then fair enough, you'd have a point. But I highly doubt that, and I highly (...no, I 100% extremely) doubt their company forbid them to use auto-increment in their code, no matter how pathetically stupid their management may or may not have been. I think you might be misunderstanding the situation.

Edit: Furthermore, auto-increment was used in various other placed in the game's code, just not in this place where it equally really matters.

--- --- --- --- --- --- --- ---

Anyways, GameHut responded to my comment, claims the code was generated by a macro, hence the lack of increment. While it's not impossible for a macro to use auto-increment, at least this makes sense, and I see it as a fair enough point. When you make a macro, you often don't see the code result, thus, you generally don't think about optimising it, even a standard auto-increment. So, mystery solved?
This post has been edited by MarkeyJester: 14 September 2017 - 01:55 PM

#14 User is offline Black Squirrel 

Posted 14 September 2017 - 02:45 PM

  • maybe she's born with it
  • Posts: 4150
  • Joined: 27-December 03
  • Gender:Male
  • Location:Northumberland, England
  • Project:maybe it's maybelline
  • Wiki edits:20,569
The point was what you consider to be common knowledge is not always the case for others. I didn't know you could get so far in life without knowing how an std::vector works but here we are.



Okay simpler example:

*ptr1++;

maybe you came from a Python background and didn't know "++" was a thing, so you wrote all your code like

*ptr1 += 1;

it's not outside the realms of possibility.

#15 User is offline Clownacy 

Posted 14 September 2017 - 05:41 PM

  • Layin' the Wax and Spinnin' the Sounds
  • Posts: 696
  • Joined: 06-July 13
  • Gender:Not Telling
That's where I was going with my 'they might have been thinking of Z80' point. But like I said back then, four years is a long time to figure that out (assuming they've always had the same programmer, anyway). The macro thing definitely clears it up for me, though. It wasn't until after I'd already made my post that I thought about the code possibly being copy-pasted from elsewhere and then edited by hand, explaining how it came to be in the first place, but a macro makes even more sense.

  • 2 Pages +
  • 1
  • 2
    Locked
    Locked Forum

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users