makipl / openviii-monogame Goto Github PK
View Code? Open in Web Editor NEWOpen source Final Fantasy VIII engine implementation in C# working on Windows and Linux (Android and iOS planned too!) [Monogame]
License: MIT License
Open source Final Fantasy VIII engine implementation in C# working on Windows and Linux (Android and iOS planned too!) [Monogame]
License: MIT License
If you cycle threw videos and watch memory usage in Visual Studio you can see the spikes going up when it loads something new. And it not come back down all the way. A new instance is created every time a new video is played. So the old one is leaving something behind.
For tracking progess on load/saving support.
Also right now can only Load games.
NewGame
There menus get complex and with complexity comes slowdowns. It's really obvious on linux. And I can't just skip the draw call because some screens have animation. Like blinking arrows and such.
Though just getting the menus done first I think is important. We can go back over them with hacks to decrease draw calls and calculations.
Linux readme is wrong about apt-get install mono. It should be mono-devel and mono-complete
MonoGame/XNA doesn't know what BGRA is and treats bgra5551 as rgba5551- looks like I may need to swap RGB<>BGR manually
Weapons for Zell (id=1) and Kiros (id=9) require skeleton data from character file
This repo is missing a "how to get started" kind of file or a new section in the main readme file.
How can ppl get this running to contribute code? What does one need to install to contribute?
It being in Mono/C#, can ppl dev under Linux?
Some monsters like c0m002.dat are not rendered correctly. Looks like it's somewhat related to entities that act like 'fluid' and also entities with extremely different skeleton like Odin
Some special characters are 2 parts. so when we draw with monospace they show in two pieces instead of one. Not sure where the font widths would be. maybe in the EXE?
https://user-images.githubusercontent.com/1035905/56608044-e5d7a600-65d7-11e9-86e3-12e6cc6a2467.png
related issue: #54
DirectX 6 DirectMusic not natively supported with Unix. What now?
EDIT: I talk about DirectMusic .DTS and .SGT files.
Currently I'm wrapping real DX6 component. Linux may probably require pre-converted OGG sounds.
EDIT:
*Pulse per note = tick per note; milliseconds = 60 000 / (BMP * PPQ). Now: 120 * 2000 ?
https://github.com/MaKiPL/OpenVIII/blob/cfdb4e3b045298107601b31212089b1f1bda0b83/FF8/module_battle_Debug.cs#L243
texture index is always zero and not corresponding to real texture pointer
this is an enhancement of battle .DAT monster file:
currently the animation is set to be valid through FPS and a timer:
float fpsVariable = 1000.0f / 15f;
frameperFPS += Memory.gameTime.ElapsedGameTime.Milliseconds;
if (frameperFPS > fpsVariable)
{
frameperFPS = 0.0f;
for (int x = 0; x < frame.Length; x++)
frame[x]++;
}
by increasing the FPS, we would be able to add Nth animation frame, that is Lerp of:
start: frame[n], last: frame[n+1], step: x
where x is the distance between first and next frame. Therefore:
and etc... dynamically calculating
I'm putting this one as a remainder.
I was going to add pausing to movie player this morning. But I could not get the audio to pause. Maybe it's how I set stuff up. I could pause the video. But the audio would start gliching instead of stopping. I maybe able to make a function to calculate where in the byte[] the audio position is and restart playback from that.
check timings
Currently the renderer is set to show only the constant specified monsters (three). Change that so the monsters are actually grabbed from encounter data; utilize monsterPos array from Memory.Encounter
I am going to start tracking my progress here:
Parts are coded because they are the same as load screen.
I may redo the save/load parts a bit as I had remade the main ingame menu screen into a class. I had originally copied and pasted the code from the save/load screen. But It was a mess. And it didn't scale well. And I was making a new set of the same variables for each screen. O.o So yeah the save/load and Splash screen and debug menus will probably be recoded with the new class.
When I exit while a video is playing the game doesn't quit. I pushed pause on the debugger and it was in the thread. since audio isn't playing the number of samples never changes so the loop goes on forever. I think to fix I might need to move the thread to ffcc class. So on dispose it kills the thread. Or I need to just kill the thread when I quit the game.
I think dispose is the better method. Though I was surprised it didn't throw an exception. :P
I'll put a fix in before my next pull request.
world needs further optimilizations based on camera rotation.
example of Ifrit's cave shows animated lava.
Question is - how? (from the file view, not implementation)
I checked the documentation for stage files and:
Managed Debugging Assistant 'CallbackOnCollectedDelegate'
Message=Managed Debugging Assistant 'CallbackOnCollectedDelegate' : 'A callback was made on a garbage collected delegate of type 'FFmpeg.AutoGen!FFmpeg.AutoGen.avio_alloc_context_read_packet::Invoke'. This may cause application crashes, corruption and data loss. When passing delegates to unmanaged code, they must be kept alive by the managed application until it is guaranteed that they will never be called.'
I am unsure why but after a sound is done playing I guess the delegate is being called by avio. It doesn't happen all the time. I have seen it twice today.
I added lock around the code in the fixed statement. This should prevent any dispose from being called before the code is done executing.
The system will not let me ffmpeg.avio_context_free(&Decoder._format->pb);
It causes a CTD when ever I try.
I hope the lock helps. The error is so rare.
The only reason I am using avio_read_content. Is that it is the only way I found to read ADPCM sounds out of memory.
I am having trouble with TEX. When i try to receive the highres icon textures pallet>0.
I am pretty sure the issue is in TEX.GetTexture()
I fed it the icon.tex and my code worked. When I gave it iconfl00.tex-iconfl03.tex it returns a corrupt texture.
It's possible texture handler is doing something wrong but it seems to be working.
The working ones
All the rest of them come up like this.
There is an image here ^ it's just blank.
I'll keep debugging maybe have to ref Vincent Tim some more.
Find another way to play pre-converted sounds from NAudio adpcm to WavPCM
there's currently no animation system (they are all playing at constant animation index=0).
Frame[n] holds current frames for every entity, we should implement an animation index change system with animation blending available (new feature)
EDIT: Fix frame[n] for monster and characters due to recent change in instance system
BS_PARSER_PRE_OBJECTSECTION: Main geometry section has no 6 pointers at: 4340
Encounters example:
195; 136
Could be probably some stupid. It's not a major issue (I mean it is, but there are more critical things to fix that one non-working stage).
Currently we have at the moment two classes that provide the text encoding/decoding. No need for redundancy. I'd go with FF8.Encoding as it supports different chartables, has encoding capabilities and already have support for tags.
Audio is working but not the video. I posted a question. I gotta work tomorrow but will fiddle with it tomorrow night.
looks like the UV formula is valid for monsters only; Both characters and their weapons have invalid UVs
Currently : U (0-128)/128; V (0-128)/128 (if V>128 -> (V-128)/128
where 128 is constant currently. Looks like it corresponds to TIM texture resolution.
Either characters use -1 coordinates (1 is up, 0 is down) or they need dynamic dividor based on TIM resolution; To reverse...
Music will play and loop but it will not loop from marked loop point.
MonoGame issue 5186
MonoGame pull 6607
Looks like this user has an open pull request for a fix. I had trouble finding his code to test.
So if his change gets approved this issue should go away.
I might be able to do a correct loop in naudio for windows only. I was reading about it someone using a custom class to wrap around the wavestream or something like that.
Some kinds of licenses make the product dirty.
For example, the GNU GPLv3 lets people do almost anything they want with your project, except to distribute closed source versions.
At the same time, there are ready-made solutions, the use of which code can simplify life.
Is there a limit to the kinds of licenses that we can use during development?
I have some basic file structure support right now. For files that had filenames this works 80%. Some pallets aren't detected correctly. Because for tonberry the filename doesn't matter as long as the hash is right. At least I think so.
Some mods have to use the hashmap to find out what texture and pallet to replace. So we would need to port the hash code from tonberry to c#. It's in the GlobalContext.cpp.
Maybe it would be better to use a standard hash. Since they seem to want a new hash. Once we have mapped out all the textures we can run multiple hashes on all of them. Track the time and collision rate. Then we could suggest that be added to tonberry enhanced. Though tonberry doesn't check the entire texture so we could come up with tests like every other pixel and keep going till we get maximum speed and 0 collisions. https://softwareengineering.stackexchange.com/questions/49550/which-hashing-algorithm-is-best-for-uniqueness-and-speed
I am gonna put this on the back burner for now I wanted to put this here as a remember to come back to this.
LordUrQuan Today at 11:08 PM
ok... that was unexpected
got distracted so the overture ran through to the end. final graphic has psychedlic color corruption
https://media.discordapp.net/attachments/552838120895283210/580593042021679125/overture_complete.jpg?width=1241&height=703
Selecting> OpenVIII debug tools>Play overture
doesn't play overture but get's back to main menu
vfr = new VideoFileReader();
I decided to check to make sure everything was working on linux still before I kept going. When I selected the movie player on the debug menu it just exited. So I debugged line by line till I got to this line.
If there is lag that causes the sound to skip it will desync. The video will end up ahead of the sound. This mostly only happens to me on linux in my vm. But I imagine someone with a weaker pc might have this issue on windows.
It basically needs to keep the Dynamic Sound Interface fed with audio samples. I was trying to increase the buffer size sent to it. But if I sent something other than 32 samples (approx 128 bytes) it caused sound glitches. I'm unsure if there is a way to detect if my audio is behind.
Possible Solutions:
Just increase the amount pre buffered?
FFMPEG audio processing in it's own thread?
Something faster than Mashal.Copy to copy from the byte* to byte[];? //when I switched to using Marshal.Copy to copy to a byte[] then feed it to Dynamic Sound Interface it was noticeably slower. But when I filled a memorystream with the entire uncompressed audio it would eat a lot of ram and that ram wouldn't always release correctly. Maybe there is a middleground.
Currently all drawing methods lack rotation control, so there's no way of rotating independent entities like characters (they currently face the same direction as monsters)
TEX.TextureData.NumOfPalettes == 0
for Face_b00.TEX,Face_b01.TEX,Gf_big00.TEX,Gf_big01.TEX
So when I try to TEX.GetTexture(0)
exception is thrown for null texture. If I set pallet = -1
it displays garbage.
The LoadPNG()
works. I renamed the folder with the png textures to test the built in textures.
The UseBest()
basically sees if pngTex==null
use the built in texture.
Contents of TextureData:
| Name | Value | Type
-------------------------
| Height | 256 | uint
| NumOfPalettes | 0 | byte
| PaletteFlag | 0 | byte
| PaletteSize | 0 | uint
| Width | 256 | uint
| paletteData | null | byte[]
Code from Init in my TextureHandler
class I'm writing it to handle textures broken into chunks to support higher res.
ArchiveWorker aw = new ArchiveWorker(Memory.Archives.A_MENU);
string path = aw.GetListOfFiles().First(x => (x.IndexOf(string.Format(Filename, c + r * Cols + StartOffset), StringComparison.OrdinalIgnoreCase) >= 0));
tex = new TEX(ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU, path));
Texture2D pngTex = LoadPNG(path);
Textures[c, r] = (UseBest(tex, pngTex, out Vector2 scale));
Scales[c, r] = scale;
Code from UseBest()
public static Texture2D UseBest(TEX _old, Texture2D _new, out Vector2 scale, int pallet = 0)
{
if (_new == null)
{
scale = Vector2.One;
if (_old.TextureData.NumOfPalettes == 0)
return _old.GetTexture();
return _old.GetTexture(pallet);
}
else
{
scale = GetScale(_old, _new);
return _new;
}
}
I started writing support for JSM codes. I do it in a separate assembly, without changing the existing code. Currently ported Deling code to C#. I dunno how much is enough for me, but I hope to finish AST and nice formatting.
Investigation of Opcodes
⬛⬛⬛⬛⬛⬛⬜⬜⬜⬜ 60%
We have an article on the wiki, a ready-made Deling and Garden sources, topics on the Qhimm forum and reverse engineering. Half the opcodes aren't documented.
Disassembling of instructions
⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛ 100%
Handling the stack leads to a lot of errors. It is necessary to go from opcodes to a sequence of high-level instructions.
PSHN_L(0); PSHN_L(127); MUSICVOL => SetMusicVolume(channel: 0, volume: 127)
There was a lot of work done in Deling. Unfortunately, only basic instructions are described. The rest will have to finish. Currently, the stack sizes have been clarified for all instructions that were in valid files (several files don't correspond to the JSM standard or contain obvious errors [invalid jumps in test files], they will have to be processed separately).
Building of abstract syntax tree
⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛ 100%
The bulk of the work has already been done in Deling. It is necessary to eliminate crutches that hide bugs and remove spaghetti from the code.
Print decompiled sources
⬛⬛⬛⬛⬛⬛⬛⬛⬜⬜ 80%
Similar to the previous paragraph. Bugs less, spaghetti more. Need to refactor code.
Instead of pseudocode, it is better to use C# syntax.
if var622_ubyte == 128 begin
if var599_ubyte == 32 begin
var1041_ubyte = 1
end
else if var622_ubyte < 128 begin
if var622_ubyte > 1 begin
var622_ubyte = 2
else if var622_ubyte == 1 begin
var622_ubyte = 1
else if var617_ubyte > 1 begin
var622_ubyte = 2
else if var617_ubyte == 1 begin
var622_ubyte = 1
else if var618_ubyte > 1 begin
var622_ubyte = 2
else if var618_ubyte == 1 begin
var622_ubyte = 1
else if var620_ubyte > 1 begin
var622_ubyte = 2
else if var620_ubyte == 1 begin
var622_ubyte = 1
else if var621_ubyte > 1 begin
var622_ubyte = 2
else if var621_ubyte == 1 begin
var622_ubyte = 1
else if var616_ubyte > 1 begin
var622_ubyte = 2
else if var616_ubyte == 1 begin
var622_ubyte = 1
else
var599_ubyte = 32
end
end
ret(8)
Translate to expression tree / IL Code / Custom execution logic
⬛⬛⬛⬛⬛⬛⬛⬜⬜⬜ 60%
The easiest way to execute code without creating your own state machine is to translate instructions into IL code or Expressions. But to support such a thing is difficult. If we choose this path, it is necessary to cover each expression with tests.
But we can use Roslyn, after generating a C# code, and then parsing it.
Parsing of scripts
⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜ 0%
To support modifications, it is necessary to learn how to parse the text representation of scripts, which is easy for players to edit. If we can use .NET Core and Roslyn, the easiest way is to write scripts in C# and parse them as Syntax Tree.
Testing
⬛⬛⬛⬛⬜⬜⬜⬜⬜⬜ 40%
The current version enumerates all fileds and generates pseudo-code for them. There is one known bug that I am going to fix soon. In the future, it is necessary to cover with tests all the mechanisms for working with JSM, in order to eliminate bugs in this segment. Analyzing errors in it is VERY difficult.
http://forums.qhimm.com/index.php?topic=18656.msg263759#msg263759
CD 2000 version doesn't have lang-en folder. I guess all the files are in data that would be in that folder. Requested him to post a tree /f of his ff8 directory. I think we might need to change our main directory from to data or the ff8 main directory. Then we just check if lang-en exists.
Labeled as enhancement as it's adding support for another version of the game not really fixing a bug.
ADPCM + stereo + normal sample rate
Totally no idea why it's not playing. It's the only sound that is not playing at all.
Current workaround is to force PCM decoding on this chunk, but it will produce glitches
The larger windows will have thicker borders and extra stretched out background.
Smaller windows will have thin borders and extra squished out background.
wip
https://cdn.discordapp.com/attachments/552838120895283210/570316400732668027/unknown.png
I was unsure if this should be automatic. Currently the Strings class only stores where the strings are. It does not save the strings. It assumes what ever screen requires the strings is saving those to a variable.
But there are times like in Load Game screen where I don't save the string. I read it every time we draw. And with locations that is loading from MAIN and MENU for each fontrender call using these strings.
I was thinking I could have the Strings class save the string to a dictionary before giving it to the caller. Then it can check to see if it already has it for future calls.
Or we could just change the class to load every string at startup into ram.
Every entity rendered is not transforming vertices by position. This can cause behaviour, where enemy such as bat will fly in-place
Currently we don't seem to know correct formula for calculating PositionTypes. Some sources claim x*.015f, some x*15f- none of them proved to be ultimately valid
Awaiting for FluidSynth support for DLS
FluidSynth/fluidsynth#493 (comment)
This is the lib i'm using to interface C# to ffmpeg. It was the best I could find.
Maybe this is because it's working with the windows dlls. I just ran my code and it's throwing a dll not found for kernel32. For this line _format = ffmpeg.avformat_alloc_context();
I think it's the lib I got from NuGet FFmpeg.AutoGen 4.1.0.2 per their github it will work in linux. If I understand it, we need to compile it ourselves with exact locations of the ffmpeg libraries.
Strings read out of the data files is in byte[]. All our variables store them strings. So I when I went to draw special characters for VIII, it didn't draw anything.
So I'm now in process of changing the variables to store byte[]
wip
https://cdn.discordapp.com/attachments/552838120895283210/570316400732668027/unknown.png
real
https://cdn.discordapp.com/attachments/552838120895283210/570316487055769656/unknown.png
Entities lack shadow casting
Anyone have some idea of implementing a system for shadows? All I can think about at the moment is casual masked texture attached to the floor of bounding box
Monsters (and characters+weapons [probably]) scale is not parsed properly/not used. Therefore a bug may be bigger than trex and even whole final form of ultimecia (last ultimecia form actually forms the stage)
Right now the project doesn't have a license.
When you make a creative work (which includes code), the work is under exclusive copyright by default. Unless you include a license that specifies otherwise, nobody else can copy, distribute, or modify your work without being at risk of take-downs, shake-downs, or litigation. Once the work has other contributors (each a copyright holder), “nobody” starts including you.
If you find software that doesn’t have a license, that generally means you have no permission from the creators of the software to use, modify, or share the software. Although a code host such as GitHub may allow you to view and fork the code, this does not imply that you are permitted to use, modify, or share the software for any purpose.
I propose to choose one of the most open licenses, if it doesn't contradict the original plan.
The MIT License is short and to the point. It lets people do almost anything they want with the project.
Skydome in BS module is rendering at first, probably due to the fact of spritebatch manipulation for fade-in/out in overture implementation. Check the Memory.graphics.GraphicsDevice parameters
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.