Those values at the end of those last 16 lines look like RGB0, so I an going to see if you've documented the conversion algorithm somewhere as you don't just multiply everything by 4, like for TFX.
What I don't see are obvious XYZ coordinates, for things like the sun position, so it may be done with angles.
What I don't see either is a compass in the game, so can't say the sun is at a particular heading.
Yeah, running the game would be good, but I haven't investigated at all if the game can be run extracted, or if everything has to be put back into an .iso.
Regarding emulators, I can only comment that pcsx-redux looks like a good option for Windows at least. It built perfectly after I downloaded the VS2022 community edition....and it seems to run AC3 OK. I haven't actually tried playing the game though, and all my experience is watching the demo sequence and people flying missions on YT. https://github.com/grumpycoders/pcsx-redux
Re: Ace Combat levels
Posted: 2023-Sep-04, 15:45
by Krishty
mikew wrote: ↑2023-Sep-04, 07:28So, I've only just formatted my output to take into account some of your previous findings.
Almost all unknowns before 0800080008000… are 16-bit signed integers; most likely Y coordinates. E.g. 5f6d in your example is 27,999 (accounted for Little-Endian).
Those values at the end of those last 16 lines look like RGB0, so I an going to see if you've documented the conversion algorithm somewhere as you don't just multiply everything by 4, like for TFX.
No algorithm, you just take the bytes as they come. The PSX has a very special gamma curve though, that I wasn’t able to replicate yet.
What I don't see are obvious XYZ coordinates, for things like the sun position, so it may be done with angles.
What I don't see either is a compass in the game, so can't say the sun is at a particular heading.
See the cues circled in yellow here:
image.png (144.09 KiB) Viewed 2356 times
Your overview is very interesting because it seems like Project Aces took all snapshots in direction of the sun?! Its height above the horizon differs, but most often all mission thumbnails have it in a similar place.
————
I also wanted to report on something I found out yesterday. The Y coordinates of ships and some enemies seem a bit off; e.g. ships submerge or hover. I fired up the game and … it’s identical there. You just don’t notice in the original game because there is no Z buffering, so the polygons are never occluded by ground or sea.
M28 Dilemma displays for me with the ships several meters submerged; you can only see the bridge:
image.png (185.08 KiB) Viewed 2356 times
image.png (284.15 KiB) Viewed 2356 times
M14 Pawns in the Game has an AA gun floating above a building, and a power plant sunken into the ground. Again, that’s hidden by the game’s low resolution and incorrect depth buffering. (You can see the dark windows on the TGT in the game, but not in TFXplorer.)
image.png (183.54 KiB) Viewed 2356 times
image.png (635.9 KiB) Viewed 2356 times
I will ignore these errors for buildings, but I will have to find a solution for ships as the problem is really obvious there. It might get worse once we add shadows to the mix …
Re: Ace Combat levels
Posted: 2023-Sep-14, 20:35
by Krishty
mikew wrote: ↑2023-Sep-04, 07:28Unfortunately, I haven't been able to give this my undivided attention
If you ever get back to it, could you have a look at 7.dat from this post? With the placement of objects in missions?
I’m wrapping up the API and I will soon reach a point where targets like SAM / AA guns could become interactive. But for this to work, I would need to know how to differentiate between SAM, AA gun, and other targets like factories or radar sites. Also allegiance so I know if an object is hostile or friendly.
I’m also trying to find a way to supply you with a working prototype of my AC3 extension. The thing is, you can view the levels – but you still need to manually find and count individual objects in them, as I don’t have a way of saying “LOOK! There’s an interactive object over there!” …
Re: Ace Combat levels
Posted: 2023-Sep-14, 21:42
by mikew
Last time I looked at this, I was wondering why the object block of eg Mission 1 was empty even though there's a city in it.
I'm probably making a counting mistake though, so plenty to check with my parser...
Re: Ace Combat levels
Posted: 2023-Sep-14, 22:10
by Krishty
Does not seem like a counting bug! The city does not contain any targets you could destroy. (Skyscrapers etc. are entirely contained in the terrain, and not placed by the mission.) M02 does have lots of ground targets, though.
Re: Ace Combat levels
Posted: 2023-Sep-15, 08:47
by mikew
Aha.
By the way, the number of elements in that object block (what I'm calling block 9 for now) is given by 'numberofDDD'.
numberofAAA, numberofBBB, and numberofCCC are the corresponding element sizes of Blocks 1,2 &3 so a bit of a departure.
This is an example how I'm splitting things right now:
mikew wrote: ↑2023-Sep-15, 08:47This is an example how I'm splitting things right now:
Great! Mostly identical to my analysis 👍 My 5 ct:
Block 2
The last four bytes are always zero.
The first four bytes are unknown.
But the twelve bytes in-between seem to correspond to six 16-bit numbers. Bounding boxes?
Block 3
The last byte is always FFh. Seems to be a marker for “unused” data.
Block 9
I hope you didn’t overlook:
Krishty wrote: ↑2023-Aug-20, 01:10The section denoted by wordsToObjects is an array of the following structure (length can be computed from the offset to the following section):
// Types of objects in missions.
enum class MissionObjectType : uint8_t {
static_ = 0, // bridges, carrier decks, …
gndTgt = 1, // ground targets
ship = 2, // ships, submarines, …
airdrop = 3, // airdrop in “Enter Dision”
train = 4, // train in “One-Way Ticket”
sam = 5, // surface-to-air missiles in “Damage Control” (friendly ones?)
heli = 6, // can move a bit vertically and turn towards the player
debris = 7, // building debris in “The Orientation” after they collapsed with an animation
antlion = 8 // air-dropped Antlion tanks in “Reaching for Stars”
};
// Objects in mission files.
// • no AI; may move but only along simple, pre-defined paths
struct MissionObject {
uint8_t unknownA;
uint8_t unknownB;
uint8_t indexOrFF; // semantics depend on type
MissionObjectType type;
int32_t x; // meters × 16384
int32_t y; // meters × 16384
int32_t z; // meters × 16384
uint8_t unknownD[12];
uint8_t unknownE;
uint8_t unknownF;
uint8_t unknownG;
uint8_t unknownH;
uint8_t unknownI; // some kind of index?
uint8_t unknownJ; // some kind of index? “0xFF” if unused
uint8_t unknownK; // some kind of index?
uint8_t unknownL; // some kind of index? “0xFF” if unused
};
Maybe we can correlate a few bytes to the number of objects/planes in a mission. E.g. data/34/3 is the pack with all rotatable models for M28 Dilemma, and there are 128 of them. I can’t extract all of them and I need to find out why (could be as simple as them being empty) …
image.png (144.81 KiB) Viewed 2308 times
Most of the models we see above are individual parts of the Sphyrna airship seen at the end of the gameplay video here:
So models 28–35 and also 40–45 and 127 make up the Sphyrna, and the game displays all of them always in the same place. Is there some kind of grouping going on?
Index 36 seems to denote the most detailed LOD of a helicopter. Maybe this number appears prominently somewhere in the data? Helicopters have mission object type 6 in block 9, according to my code above.
Speaking of LODs: Most objects seem to have three LODs, but I’m not sure yet. They are not always at consecutive indices either. This, too, needs to be somewhere in that file …
Re: Ace Combat levels
Posted: 2023-Sep-15, 10:58
by mikew
No, I didn't overlook your breakdown of Block9, but I wanted to sort out the basic structure 'my way' first. I probably need to duplicate what you've done somewhat to gain familiarity.
Anyway, I'm relying on this site for the gameplay aspects: https://acecombat.fandom.com/wiki/Awakening
...and from that, we can see that Block3 looks like it contains the enemy plane info plus 5 elements at the start which I haven't correlated with anything yet.
FYI: That wiki recently moved, because Fandom has become a horrible nightmare of advertisement and tracking. The new version is at https://acecombat.wiki.gg/wiki/Awakening but it will take some time for Google to pick up the site rank.
...and from that, we can see that Block3 looks like it contains the enemy plane info plus 5 elements at the start which I haven't correlated with anything yet.
m01_b3.PNG
Where 0x28 is the R-501 etc
FANTASTIC!
That site does not list friendly planes, which would be You + Erich + Fiona + Rena according to this gameplay video. So, only one unknown entry left?
Re: Ace Combat levels
Posted: 2023-Sep-15, 22:15
by mikew
The first byte of each Block3 element is either 0 or 1, with 1 meaning enemy. I'm not quite sure how to interpret the 0 elements.
There are always 2 lines starting with 00ff, so they may relate to the player's plane.
Regarding the plane codes in the second byte of each Block3 element, here's a rough list cross referenced from that wiki site.
Note that helicopters (R-701?)or the V22 don't seem to live in Block3
mikew wrote: ↑2023-Sep-15, 22:15Note that helicopters (R-701?)or the V22 don't seem to live in Block3
Helicopters live in block 9 (with ships, trains, AA guns etc). Not sure about the V-22, but I think I have once seen an AA gun in its place during my experiments, so I assume that it too lives in block 9.
I assume that in block 3, the bytes 6/7, 10/11, and 14/15 form 16-bit signed integers, respectively. The correlation is pretty high, and M01 shows very clear numbers like 2500, -2200, and -4500. These can’t occur by coincidence alone.
Re: Ace Combat levels
Posted: 2023-Sep-16, 10:34
by mikew
Hard to say. Those 'plane codes' from my last post may in fact be 4 bytes long.
For M01, that seems to be the case, but right now I'm just 'looking' at the block to see what is worth scanning all the files for.
There's a bit/byte which marks whether the plane is marked with a TGT symbol, and also some differences if a plane appears in the 'main mission' or some extension after an event.
Those bytes could be grouped as you say, but almost look like 24 bit signed integers with a zero padding.
Here's M01's Block3 cut up with some comments. Anything here which stands out?
No time for this over the last couple of days, but some comments regarding the files I've been analyzing.
For now, I've only been considering files that are part of the missions used in the game. For the 'sky' 0.dat files, these are all exactly the same length, but are shorter for the 'extra' missions.
For the 52 mission 7/ directories, all but 4 contain 5 files (0.dat to 4.dat), so have only included these 48 in the recent analysis.
So, making an attempt to include these missing missions, I see that M06 and M08 each have 3 sets of 0.dat to 4.dat files for some reason. My parser has some problems with these, but I do see that the first byte in Block3 can be 0x02 for both of these missions.
M12 and M37 have their 0.dat files in an extra directory (/7/0/0.dat instead of 7/0.dat), and my parser completely chokes on these for now.
Anyway, I should probably try to understand why these 4 missions are different before doing anything else.
Re: Ace Combat levels
Posted: 2023-Sep-20, 07:37
by Krishty
mikew wrote: ↑2023-Sep-18, 09:59For now, I've only been considering files that are part of the missions used in the game. For the 'sky' 0.dat files, these are all exactly the same length, but are shorter for the 'extra' missions.
Correct 👍
mikew wrote: ↑2023-Sep-18, 09:59
For the 52 mission 7/ directories, all but 4 contain 5 files (0.dat to 4.dat), so have only included these 48 in the recent analysis.
So, making an attempt to include these missing missions, I see that M06 and M08 each have 3 sets of 0.dat to 4.dat files for some reason. My parser has some problems with these, but I do see that the first byte in Block3 can be 0x02 for both of these missions.
Both M06 and M08 are randomized missions. In M06, you fly through a canyon and the target can be found in one of several places; it’s different whenever you start the mission. In M08, you protect an airship that may take one of several different paths.
If I look at M06 in TFXplorer, which ignores all but 0.dat, the final target (whose position should be randomized) is missing completely from the level.
So I presume that these additional files store randomized targets and the engine picks a set at random when the game starts.
Note: The doors in M51 Tunnel Vision look randomized on first sight too, but speedruns suggest that they are in fact based on the player’s heading. E.g. in this video at 0:50 the player seems to point the nose towards a door for an instant to make it close.
mikew wrote: ↑2023-Sep-18, 09:59M12 and M37 have their 0.dat files in an extra directory (/7/0/0.dat instead of 7/0.dat), and my parser completely chokes on these for now.
So does mine. I had to hard-code that 😔
mikew wrote: ↑2023-Sep-18, 09:59Anyway, I should probably try to understand why these 4 missions are different before doing anything else.
This is where I kindly disagree – there is so much undiscovered stuff. Missions being divided into stages, with events being triggered dynamically. How does the engine designate ships as two or three targets (bridge + AA gun + SAM) when there is no such information in the model file. Etc pp
We should get an overview first, and pick the low-hanging fruits. When the easy stuff is solved and only the difficult problems remain, they automatically become easy by principle of exclusion … or so I hope 😆
Re: Ace Combat levels
Posted: 2023-Sep-20, 19:14
by mikew
Yes, since I wrote that, I'm now including one set from M06 and M08 in my 7/ analysis. I'll worry about M12 and M37 later.
M06 and M08 are also different in that they both have a large 'Block14' that takes up most of the 0.dat file.
There's a pointer to it at the start of the file, which works for M06 and M08, but some files have invalid values. Something else to sort out...
EDIT: I meant M03 (not M08) and M06 with the large 'Block14'. These missions both have a chase element, so may be something to do with that.
Re: Ace Combat levels
Posted: 2024-Jan-20, 21:50
by Krishty
mikew wrote: ↑2023-Sep-16, 10:34Those bytes could be grouped as you say, but almost look like 24 bit signed integers with a zero padding.
I finally checked and you are completely right. These are the X, Y, Z position multiplied by 25,600 (centimeters×256), stored as 24-bit numbers.
Mapping it to the overview places everything exactly where the player, allies, and enemies spawn:
image.png (55.91 KiB) Viewed 1520 times
Will implement this and then check if it applies to other maps. I don’t have enemies yet so I will only spawn the player, who is hopefully always at the first position.
Best to test the tunnel level as it requires placement accurate to 100 m or you’ll spawn outside of the tunnel …
Re: Ace Combat levels
Posted: 2024-Jan-20, 22:43
by Krishty
Correction: It’s *not* multiplied by 25,600, it’s full 32-bit numbers multiplied by 32,768. But it looks like 24-bit numbers because if you divide by 256, they are all evenly divisable by 1000. It’s very odd.
What got me on the wrong track is the altitude. I compared my Y coordinate with the altimeter in AC3, but for some reason it is off by factor ~0.81. E.g. the Stratosphere mission spawns you at 45,480 ft according to the data, but AC3 displays 37,301. I am pretty perplexed?!
Anyway. Here is Stratosphere:
image.png (1.96 MiB) Viewed 1513 times
And Tunnel Vision:
image.png (4.6 MiB) Viewed 1513 times
Resistance starts on the runway, but sadly the game spawns you 50 ft above it. Pretty sure they had to do this to avoid clipping problems with the PSX renderer. That’s a bit sad, because if it were 10 ft then UAW would automatically place the plane on the ground, with gear extended, parked like in the game. Maybe I’ll just subtract 40 ft everywhere …
image.png (1.48 MiB) Viewed 1513 times
So, coordinate system is the same as for static models (meters ×32,768) and spawn points work, but altitude is displayed differently in AC3.
Note that planes now face the wrong direction. It would be great to find out where the game stores the heading for each unit! I haven’t identified angles in the data files so far, so it could be degrees, rad, full circles divided by 4096 (popular on PSX for some reason) or anything else.
Edit: The game does not seem to be able to spawn with arbitrary headings. It seems to be limited to N/E/S/W and to NE/NW/SE/SW. So the heading could be hidden in a 3-bit number!
Here’s the player heading from what I’ve seen in playthroughs:
M01 Awakening NE
M24 Stratosphere E
M48 Resistance N
M51 Tunnel Vision N
Re: Ace Combat levels
Posted: 2024-Jan-20, 23:23
by Krishty
Solved. The 24th byte is 8 for Awakening (NE), 16 for Stratosphere (E), and 0 for Tunnel Vision (N).
So the heading in degrees can simply be computed from this byte via × 360 / 64. Checked it with a few other missions and works nicely.
It is well possible that the bytes immediately before or after it are pitch and roll angles; I haven’t checked. M24 Stratosphere starts with you pitching up IIRC, so this is where we could investigate it.
As of today, TFXplorer does not support roll/pitch for spawning, so we couldn’t use this data. But it may come in handy later, when the engine supports actual waypoints.
Re: Ace Combat levels
Posted: 2024-Jan-20, 23:26
by mikew
Heh, I kind of regretted that '24 bit integer' comment, as while they indeed looked like 24 bit integers, it would be unusual if they were used like that.
I should revisit my AC3 parser.
Re: Ace Combat levels
Posted: 2024-Jan-21, 00:05
by Krishty
mikew wrote: ↑2024-Jan-20, 23:26I should revisit my AC3 parser.
Didn’t want to distract you; I just had this code in my hands while finishing up the terrain API docs 🙂
The heading thing has an important implication: If AC3 stores angles in 0…63 range there, it may do the same for the sun. We should revisit the sky files and check for two bytes in 0…63 range that could denote sun angle.
That’s pretty important as I currently have to set the sun angles manually for all 60 missions, which I won’t do for obvious reasons – but then the sky looks shitty in most of them.