Author [EN] [PL] [ES] [PT] [IT] [DE] [FR] [NL] [TR] [SR] [AR] [RU] [ID] Topic: Figured out Bionic Commando's grapple mechanic  (Read 2355 times)

0 Members and 1 Guest are viewing this topic.

Offline TheouAegis

  • Amateur Auteur of GMvania
  • Master Hunter
  • *****
  • Posts: 1860
  • Gender: Male
  • Awards The Retro Gamer: Has a heated passion for the oldschool VG Titles. The Great Defender will always defend the object of his or her fandom. Hack Master makes creations out of CV parts. (S)he makes Dr. Frankenstein proud.
    • GMvania Developer's Blog
    • Awards
  • Likes:
Figured out Bionic Commando's grapple mechanic
« on: January 01, 2015, 12:40:03 PM »
+2
Just woke up one morning, looked at the data in the pRAM, then had a sudden epiphany.

If you're programming your own game with grappling, like in Super Metroid or CV4, by all means use math to calculate the swing position. This is just an info blog. NES programmers usually just stored all the values in the ROM data rather than using math, especially since they rarely even cared about precision since it was an 8-bit system meant for gaming.

All the data for Bionic Commando's swinging is stored in a series of arrays. The primary array defines Rad's positioning and regulates what values to use from the secondary array, which handles the grappling hook's motion. The grappling hook is thus comprised of three parts: the hook itself, the chain parts, and Rad('s arm).

1CF40908
2CF40906
3CF40905
4D020D05
5D060D04
6E0C0906
7E0C0908
7C0C0918
6C0C0916
5C0C0914
4DFE0D14
3DFA0D16
2EF40918
1EF40918

1FF40915
2FF40915
3FF40914
4D020D04
5D060D03
600C0915
700C0915
7F0C0905
6F0C0905
5F0C0903
4DFE0D13
3DFA0D15
20F40905
10F40905

These are the two primary arrays. The first one is for when Rad is just swinging normally, the second is for when he's swinging himself up. You may notice a couple patterns in the values and for good reason. The two arrays are of the format 1-2-33-44-5-6 defined as follows:

  • Period
  • Sprite
  • Y-offset from arm
  • X-offset from arm
  • Direction
  • Speed

Speed is how long it takes to switch between indices. The direction is a simple binary value, 0 for right and 1 for left (same as in Castlevania games). The x and y offsets are relative to the last chain's position (if any). The sprite is Rad's sprite at each step. The period affects the chain and positioning. It determines which index to use in the secondary array:

7E 80 80 80 7F 80 80 80 7E
81 85 83 84 82 84 83 85 81
00 04 08 08 08 08 08 04 00
F8 F8 F8 FC 00 04 08 08 08

The first row is the sprite for the hook, the second is for the chain. The fourth row is the y-offset of each chain from the hook or previous chain, and the last row is the x-offset. The formula for positioning the hook is thus:

xn = x0 - 4 + n * offsetperiod

The swing cycle is over 56 steps. If the I/O state is either left or right, it checks if the cycle is at the proper step (0 or 24) and then sends Rad flying away. For down, it breaks off at any point I think, but I haven't delved into the break-off mechanics just yet.
Been too busy working and planning for moving in with my latest girlfriend so I can get out of my parents' house (was a rough year....). I'll look into the break-off mechanics this weekend when I get settled into my new place.
« Last Edit: January 01, 2015, 12:41:36 PM by TheouAegis »
Your mom has had more floppies put in her than a Commodore 64!


Follow my lack of progress on my game at my blog:
http://gmvania.blogspot.com

Offline Gunlord

  • Wandering Mendicant
  • Global Moderator
  • Master Hunter
  • *****
  • Posts: 2724
  • Gender: Male
  • Meow.
  • Awards Capable of resolving arguments/fights peacefully without mod/admin intervention. Permanent Resident: Seems to always be around to post/reply. Master Debater: Gracefully argues 'til the cows come home about topics.
    • My blog
    • Awards
  • Favorite Game: Castlevania: Symphony of the Night (PS1/SS)
  • Likes:
Re: Figured out Bionic Commando's grapple mechanic
« Reply #1 on: January 03, 2015, 02:13:14 AM »
0
That's some cool coding research, my friend :o

Check me out at gunlord500.wordpress.com!
https://www.youtube.com/watch?v=phhCrFZek44

Tags:
 

anything