PoP1 SEGA Genesis format documentation

Discuss other PoP1 related things here.

Moderator: English Moderator Team

User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 2939
Joined: April 9th, 2009, 10:58 pm
Contact:

Re: PoP1 SEGA Genesis format documentation

Postby Norbert » December 5th, 2016, 6:15 pm

If I place a sword object, it doesn't show a sword in-game. Plus, it can be picked up endlessly.
This made me think the sword also has its own object table.
There's only one sword and it's in level 1.
This means, in theory, the table should have 00 01, <4 byte offset>, and then 16 times 00 00 00 00 00 00.
With the <4 byte offset> pointing to the location after the last set of zeros.
However, the attached program that loops through the EU file to find the object table for the sword(s) fails.

Also, the most likely bytes for the sword's Y (6) and X (3) are...
01 40 00 40, with Y = 320 pixels and X = 64 pixels
or
01 7F 00 40, with Y = 383 pixels and X = 64 pixels
...but this too does not give me a hit. There's only one place with these first bytes, and two places with these second bytes, and modifying all these does not impact the appearance/location of the sword.
Attachments
sword.c
(1.6 KiB) Downloaded 5 times

User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 2939
Joined: April 9th, 2009, 10:58 pm
Contact:

Re: PoP1 SEGA Genesis format documentation

Postby Norbert » December 9th, 2016, 2:26 am

Norbert wrote:To make sure it's not a complete surprise when it arrives, I am actually working on an editor for this port.


Here's an update. I'm about halfway done. :mrgreen:
I've worked on it, not full-time, for almost 4 weeks; since November 13th.
So, first release in the beginning of January, it looks like.
However, part of me wants to get a release out in 2016, but I don't know if I'll make that.
Maybe a beta release late December. We'll see.

The tiles screen will be (is already) somewhat different from the other editors I've created. I'm using tabs for both the object and the graphics selection, to allow users to create all object+graphics combos possible. As a bonus this tabbed grouping makes it easy to quickly find, for example, all graphics that contain gate slots. Oh, and the tiles screen has a (full-size, 3-tile) preview that updates when hovering over graphics. The rooms screen - "room links" in the other editors - contains, in addition to rescale options, a miniature overview of the level. The enumerate screen - "events" in the other editors - contains an overview of object and room totals, and their (save) statuses. Most of the work for this port is related to properly removing and adding object attributes, because these are stored separately. For legbop I started from scratch while glancing at apoplexy source code, for the new editor (lemdop) I've done nothing but modify and complement legbop's code.

David
The Prince of Persia
The Prince of Persia
Posts: 1333
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: PoP1 SEGA Genesis format documentation

Postby David » December 10th, 2016, 1:59 pm

Norbert wrote:If I place a sword object, it doesn't show a sword in-game. Plus, it can be picked up endlessly.
This made me think the sword also has its own object table.
There's only one sword and it's in level 1.
This means, in theory, the table should have 00 01, <4 byte offset>, and then 16 times 00 00 00 00 00 00.
With the <4 byte offset> pointing to the location after the last set of zeros.
However, the attached program that loops through the EU file to find the object table for the sword(s) fails.


I was trying to find it some days ago, too, with the same (non-)results.
Although not because added swords are invisible, but because all other objects have an object table, so I felt the sword should also have one.

Now I checked again, and got some interesting results.

The original sword is still displayed even if I remove it from the level. (change 0x0B to 0x02)
I also figured out that room Y-pos must be exactly 0xC0 and room X-pos must be exactly 0x00.
If I change the starting room's coordinates to slightly different values, then the sword won't appear.

I searched for CMP involving 0xC0 and 0x00 and I found one part that affects the sword:

Code: Select all

(USA version)
00026D7C   4a79 00ff 1ec4                   TST.W     A_00ff1ec4 ; got sword
00026D82   6600 0092                        BNE.L     B_26e16
00026D86   0c79 0000 00ff 0f48              CMP.W     #0x0,A_00ff0f48 ; level number - 1
00026D8E   6600 0158                        BNE.L     B_26ee8
00026D92   0c79 00c0 00ff 0002              CMP.W     #0xc0,A_00ff0002 ; Y coord of room's top edge
00026D9A   6600 014c                        BNE.L     B_26ee8
00026D9E   0c79 0000 00ff 0004              CMP.W     #0x0,A_00ff0004 ; X coord of room's left edge
00026DA6   6600 0140                        BNE.L     B_26ee8
00026DAA   30bc 0009                        MOVE.W    #0x0009,(A0) ; no difference?
00026DAE   317c 0002 0002                   MOVE.W    #0x0002,(D_0002,A0) ; no difference?
00026DB4   317c 0177 0004                   MOVE.W    #0x0177,(D_0004,A0) ; Y coord within level
00026DBA   317c 0059 0006                   MOVE.W    #0x0059,(D_0006,A0) ; X coord within level
00026DC0   317c 4000 0008                   MOVE.W    #0x4000,(D_0008,A0) ; sprite flags: palette, flip
00026DC6   317c 0000 000a                   MOVE.W    #0x0000,(D_000a,A0) ; if not 0 then sword is gone

This is only for *displaying* the sword: The prince can still pick it up at the location determined by the level data.
Now the only thing left is that he should not be able to pick it up after he already did that.

The sword is removed here:

Code: Select all

000222FC   4a79 00ff 3dd4                   TST.W     A_00ff3dd4
00022302   6600 0004                        BNE.L     B_22308
00022306   4e75                             RTS
00022308   13fc 0002 00ff 15f7              MOVE.B    #0x0002,A_00ff15f7 ; change a specific location to floor
00022310   41f9 0000 4680                   LEA       A_00004680,A0
00022316   4eb9 0000 4486                   JSR       A_00004486
0002231C   4e75                             RTS

Great, more hardcoded stuff...
Address = 0xFF15E0 + Xpos * levelheight + Ypos
In this case, Xpos=2, levelheight=9, Ypos=5: 0xFF15F7 = 0xFF15E0 + 2 * 9 + 5

Additionally, you can make it so that the sword leaves an empty space behind, so the prince will fall through the floor... :)
(Change the 0002 to 0000 for this one.)

So it seems that the sword is a "special event" in this version?

User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 2939
Joined: April 9th, 2009, 10:58 pm
Contact:

Re: PoP1 SEGA Genesis format documentation

Postby Norbert » December 10th, 2016, 7:34 pm

Hm, it's interesting, all the differences between the various ports.

User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 2939
Joined: April 9th, 2009, 10:58 pm
Contact:

Re: PoP1 SEGA Genesis format documentation

Postby Norbert » December 12th, 2016, 8:05 pm

Here's the same sword stuff, but for the EU version:

Code: Select all

(EU version)
00057576   4A79 00FF 1F7A
0005757C   6600 0092
00057580   0C79 0000 00FF 0FE0
00057588   6600 0158
0005758C   0C79 00C0 00FF 0002
00057594   6600 014C
00057598   0C79 0000 00FF 0004
000575A0   6600 0140
000575A4   30BC 0009
000575A8   317C 0002 0002
000575AE   317C 0177 0004
000575B4   317C 0059 0006

===

000526DC   4A79 00FF 3EB0
000526E2   6600 0004
000526E6   4E75
000526E8   13FC 0002 00FF 1691
000526F0   41F9 0000 4BCC
000526F6   4EB9 0000 49D2
000526FC   4E75

User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 2939
Joined: April 9th, 2009, 10:58 pm
Contact:

Re: PoP1 SEGA Genesis format documentation

Postby Norbert » December 12th, 2016, 10:33 pm

David, are you sure the 0000 is the level number - 1?
Using your findings, I can successfully change the location of the sword and it can also only be picked up once, but all this only works for level 1.
When I try to change the level, the sword does not show up.

User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 2939
Joined: April 9th, 2009, 10:58 pm
Contact:

Re: PoP1 SEGA Genesis format documentation

Postby Norbert » December 15th, 2016, 5:40 pm

Norbert wrote:Maybe a beta release late December. We'll see.


Mid-December. Download links for the beta release:
viewtopic.php?f=63&t=3927

salvadorc17
Calif
Calif
Posts: 461
Joined: August 27th, 2011, 2:04 am

Re: PoP1 SEGA Genesis format documentation

Postby salvadorc17 » December 16th, 2016, 11:14 pm

Norbert wrote:
Norbert wrote:Maybe a beta release late December. We'll see.


Mid-December. Download links for the beta release:
viewtopic.php?f=63&t=3927


Have tested it and seems really, promising, it comes with Eu version, is also possible to edit Us?? Also seems hard to use for menus considering that it does handle levels more similar to snes (background/foreground separated) than Dos..

User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 2939
Joined: April 9th, 2009, 10:58 pm
Contact:

Re: PoP1 SEGA Genesis format documentation

Postby Norbert » December 17th, 2016, 1:13 am

salvadorc17 wrote:it comes with Eu version, is also possible to edit Us??


Yes, simply empty the rom/ directory and then put the US ROM file into that directory.

David
The Prince of Persia
The Prince of Persia
Posts: 1333
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: PoP1 SEGA Genesis format documentation

Postby David » December 17th, 2016, 12:58 pm

Norbert wrote:Here's the same sword stuff, but for the EU version:

Note that the RAM address is calculated a bit differently:
Instead of 0xFF15F7-(2*9+5) = 0xFF15E0, the base address is 0xFF1691-(2*9+5) = 0xFF167A.

Oh, I see in the editor's source that you already figured that out.

Norbert wrote:David, are you sure the 0000 is the level number - 1?
Using your findings, I can successfully change the location of the sword and it can also only be picked up once, but all this only works for level 1.
When I try to change the level, the sword does not show up.


It's related to starting level 1 without the sword. (see below)
You see, there is a check before displaying the sword (TST.W A_00ff1ec4, here) that skips the whole thing if the prince already has the sword.
I still don't get why doesn't the code just check the objects map to decide when and where to display the sword.

Code: Select all

Prince starts without sword on level 1.

(USA)
000200B4   0c79 0000 00ff 0f48              CMP.W     #0x0,A_00ff0f48 ; level number - 1
000200BC   6700 000a                        BEQ.L     B_200c8
000200C0   33fc 0001 00ff 1ec4              MOVE.W    #0x0001,A_00ff1ec4 ; got sword

(Europe)
00050400   33fc 0001 00ff 1f7a              MOVE.W    #0x0001,A_00ff1f7a ; got sword
00050408   0c79 0000 00ff 0fe0              CMP.W     #0x0,A_00ff0fe0 ; level number - 1
00050410   6600 0028                        BNE.L     B_5043a
00050414   237c 0005 4768 0008              MOVE      #0x00054768,(D_0008,A1) ; falling entry?
0005041C   337c 004f 0006                   MOVE.W    #0x004f,(D_0006,A1)
00050422   33fc 0002 00ff 1f64              MOVE.W    #0x0002,A_00ff1f64
0005042A   33fc 000c 00ff 1f6c              MOVE.W    #0x000c,A_00ff1f6c
00050432   33fc 0000 00ff 1f7a              MOVE.W    #0x0000,A_00ff1f7a ; got sword


TODO: Add these to the docs.
Question: Should I show the disassemblies there as well, or just the offsets and their meanings?
(Maybe the disassemblies would show something like "I know what I'm doing, I'm not just shooting randomly"? :) )

I made the disassemblies with dasm68, by the way. I originally downloaded it to use on PoP1 for the Mac...
It's a "straight and stupid" disassembler, which means that it disassembles even those parts that are not executable code.
As a result, before I pasted the disassembly into my posts, I sometimes had to fix those instructions that are directly after data areas. At 0x00026D7C for example.

User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 2939
Joined: April 9th, 2009, 10:58 pm
Contact:

Re: PoP1 SEGA Genesis format documentation

Postby Norbert » December 17th, 2016, 5:20 pm

David wrote:there is a check before displaying the sword


Can an easy hex edit disable this check?

David wrote:Question: Should I show the disassemblies there as well, or just the offsets and their meanings?


Maybe a link to this thread?

I want to comment on the wiki in general. It's too much a single point of failure, in my opinion. I hope you're making local backups of articles you post and update. (I personally see lemdop as a semi backup of your findings.) I do mention your documentation in lemdop's docs/README.txt, but decided not to link to the wiki. Maybe I'm overly cautious, but the Princed website has been hacked in the past - for weeks, without anyone taking action - because WordPress was outdated, and like this forum the wiki is in a fragile position, because nobody is looking after it. It's probably already impossible for new users to register. I'm not going to look into it, I've done enough Princed admin stuff, and you (David) shouldn't have to either, given all your PoP contributions over the years. Plus you are super busy. I think you're mostly just dropping by on Saturday mornings these days. If poirot will allow this forum to eventually go off-line, for whatever reason, maybe we'll all just move back to popuw.com. Who knows. Of course, that probably wouldn't be ideal either. But the wiki, maybe occasionally release PDF documents of content, to allow for easy backups on other websites (popot.org, popuw.com)? Then again, I think you backup 'everything', you still have things from a decade ago.

David
The Prince of Persia
The Prince of Persia
Posts: 1333
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: PoP1 SEGA Genesis format documentation

Postby David » December 18th, 2016, 11:44 am

Norbert wrote:Can an easy hex edit disable this check?

Er, that's possible, but then the sword remains visible after pickup.
(USA) At 0x26D82: change 66 00 00 92 to 4E 71 4E 71.
(Europe) At 0x5757C: change 66 00 00 92 to 4E 71 4E 71.

A better option is to change the level where the prince starts without sword, as I wrote above.
But then, does it make sense to put this anywhere other than level 1?

EDIT: Updated the wiki: http://www.princed.org/wiki/SEGA_Genesis_format

David
The Prince of Persia
The Prince of Persia
Posts: 1333
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: PoP1 SEGA Genesis format documentation

Postby David » December 18th, 2016, 1:22 pm

(Separate post because it's a different topic. I might even move this elsewhere.)

Norbert wrote:I hope you're making local backups of articles you post and update.

Yes, I do have a backup of all three format-related wiki articles. (SNES, SEGA Genesis, Game Boy Color)
I also make a backup of all my (and sometimes others') longer posts (and PMs), especially the technical ones.
Or rather, I first write them into a text file, and then copy-paste them into the wiki or the forum.

Norbert wrote:Plus you are super busy. I think you're mostly just dropping by on Saturday mornings these days.

*sigh*

Norbert wrote:If poirot will allow this forum to eventually go off-line, for whatever reason, maybe we'll all just move back to popuw.com.

Will Jalal ever re-enable the PoPUW forum? He didn't even post the archive yet...

Norbert wrote:Then again, I think you backup 'everything', you still have things from a decade ago.

Exactly...
And I still regret those few things that were interesting (in hindsight?) yet I did not save them.

Norbert wrote:Maybe I'm overly cautious, but the Princed website has been hacked in the past

I have seen various forms of data loss, too...
HDD crashes, broken floppy disks and CDs, disappearing (or just completely redesigned) websites, people removing/closing their accounts...

User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 2939
Joined: April 9th, 2009, 10:58 pm
Contact:

Re: PoP1 SEGA Genesis format documentation

Postby Norbert » February 16th, 2017, 3:52 pm

David wrote:A better option is to change the level where the prince starts without sword, as I wrote above.


Right.
I noticed that, for the EU version, changing this also changes where the prince has a falling start animation.
Setting it to, for example, level 2 makes the prince semi-fall even though he starts on a tile.

David
The Prince of Persia
The Prince of Persia
Posts: 1333
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: PoP1 SEGA Genesis format documentation

Postby David » March 25th, 2017, 6:17 pm

Norbert wrote:Speaking of names of levels, the four extra levels of the EU version, how will we name them?

Apoplexy does not display level names for PoP2 DOS and PoP1 SNES, only the names of level types.
Why was it important for the Genesis version?


Return to “Prince of Persia 1 - Other”

Who is online

Users browsing this forum: No registered users and 1 guest