ZED Online - a fork of the Zod Engine

Post here about the Z remake "Zed Online" by DaMarkov

Moderator: Brad

DaMarkov
Major
Major
Posts: 180
Joined: 2018-12-20, 16:17
Are you a spam bot?: No
Contact:

Re: ZED Online - a fork of the Zod Engine

Post by DaMarkov » 2019-03-05, 00:16

BallWin wrote:
2019-03-04, 22:15
DaMarkov wrote:
2019-03-04, 21:32
Works great so far! (I have only tested total_save_frames_as_bmp() and total_save_as() yet).
Decoding the video takes quite a while (seems like 5 to 10s), so I have to put the decoding step in an extra thread, but that shouldn't be an problem.
No, no. You don't need to save files to disk! This only allows you to change the resolution (remake) in HD, get screenshots and so on.
These functions are not needed for display.
Yeah sure, I know. It was just the first thing I tried.
The decoder is only slow in Debug build (about 10s t decode one video) in Release build it takes about 1s, so it's fine.

Some suggestions:

The main loop of the example should contain something like

Code: Select all

SDL_Event evt;
while (SDL_PollEvent(&evt))
{
	switch (evt.type)
	{
	case SDL_QUIT:
		quit = true;
	}
}

if (quit)
	break;
Otherwise the window is unresponsive and hangs.

You calculated the pause between frames as follows:

Code: Select all

long rate_frame_ms = static_cast<long>(std::floor(playback_ms*1. / v_buff_frames.size() + 0.5));
with your example video the result is 111ms, which is wrong it should be 84ms (12 fps) which you can also simpley get from JV_FileHeader::rate

Also there is now really a need to create a surface for every frame, but OK I guess you wanted to write a simple example.
DaMarkov
Major
Major
Posts: 180
Joined: 2018-12-20, 16:17
Are you a spam bot?: No
Contact:

Re: ZED Online - a fork of the Zod Engine

Post by DaMarkov » 2019-03-05, 00:45

APC wrote:
2019-03-04, 22:31
Da Markov, unfortunately the v.0.1.4 works on my laptop in sense of graphic modes worse as v0.1.3. The fullscreen is completely confused. Also when I set 1024x768 resolution in Win10 the F5/F8 switching makes troubles and ALT+TAB is needed. In fullscreen resolution also SHIFT waypoints doesn't work. (In starcraft control - it works like old Z control). During F8 switching modes also part of border In windowed mode things are much better.

You repaired the active zone of minimap, but now the MENU button in bottom right corner doesn't have active zone.

https://drive.google.com/open?id=1utA7D ... gNi4t7LaW0
Ah ok switching from "direct copy" screen mode to "fit" I forgot the to put the black bar in.
Menu button I will investigate.
SHIFT waypoints: I didn't change anything. What doesn't work?

More importantly: If you fix all the graphics settings and don't press F5 and F8 during gameplay do you still have the blackscreen bug?
BallWin
General
General
Posts: 252
Joined: 2006-10-24, 02:24
Location: Russia
Contact:

Re: ZED Online - a fork of the Zod Engine

Post by BallWin » 2019-03-05, 17:37

DaMarkov wrote:
2019-03-05, 00:16
The decoder is only slow in Debug build (about 10s t decode one video) in Release build it takes about 1s, so it's fine.
It's long. Need to do buffering. Load the first 50 frames into a separate buffer. To continue to load the rest from another thread.
DaMarkov wrote:
2019-03-05, 00:16
Some suggestions:
The main loop of the example should contain something like
I can do it now.
APC
Lieutenant
Lieutenant
Posts: 74
Joined: 2008-11-07, 16:18
Location: SLOVAKIA

Re: ZED Online - a fork of the Zod Engine

Post by APC » 2019-03-05, 20:09

DaMarkov wrote:
2019-03-05, 00:45
SHIFT waypoints: I didn't change anything. What doesn't work?

More importantly: If you fix all the graphics settings and don't press F5 and F8 during gameplay do you still have the blackscreen bug?
Also in case I make settings in the yellow main manu, the fullscreen checkbox is activated, save setting, start game (and don't use F5/F8), the black screen bug is there.

About the not working SHIFT waypoints - in v0.1.4 in fullscreen the starcraft control works for me as "original Z control". In windowed mode it works normal. I understand it is unbelievable. But I made test again and it works the same.
DaMarkov
Major
Major
Posts: 180
Joined: 2018-12-20, 16:17
Are you a spam bot?: No
Contact:

Re: ZED Online - a fork of the Zod Engine

Post by DaMarkov » 2019-03-05, 21:10

BallWin wrote:
2019-03-05, 17:37
DaMarkov wrote:
2019-03-05, 00:16
The decoder is only slow in Debug build (about 10s t decode one video) in Release build it takes about 1s, so it's fine.
It's long. Need to do buffering. Load the first 50 frames into a separate buffer. To continue to load the rest from another thread.
DaMarkov wrote:
2019-03-05, 00:16
Some suggestions:
The main loop of the example should contain something like
I can do it now.
In release build your decoder decodes about twice as fast at video playback rate, so it's fine. I build a wrapper class that decodes only the chunks that are necessary for the next video frame and that works fine.

Small coding tip. You can create the surface at the beginning an then refill it with data like that:

Code: Select all

memcpy(surface->pixels, ptr_frame.get(), surface->pitch*surface->h);
There is one problem though. When compiling against SDL2 video works fine, but the audio sound corrupted.
The team behind SDL claimed they didn't change anything, but apparently they did.
You don't have to fix that since I think I will use the .wav format for audio. I only one to save the video files once and then the audio for every language separately.
But if you have time you might wanna look into that. When I finished my wrapper class I can send you the code.
BallWin
General
General
Posts: 252
Joined: 2006-10-24, 02:24
Location: Russia
Contact:

Re: ZED Online - a fork of the Zod Engine

Post by BallWin » 2019-03-05, 21:49

Ok.. I did everything you asked. Maybe a little more though... Added parameters to the command line. You can set the decoded video file, set the task to save files, etc.
https://github.com/BallWin/Qt_ZodEngine ... readme.txt
Important point - you can set the desired FPS. The synchronization code has changed to perform this task. Check the code.

About your question-send the code. Please describe the problem in more detail. I do not know much English and was not familiar with (at least for now) with SDL2 :P
DaMarkov
Major
Major
Posts: 180
Joined: 2018-12-20, 16:17
Are you a spam bot?: No
Contact:

Re: ZED Online - a fork of the Zod Engine

Post by DaMarkov » 2019-03-05, 23:27

BallWin wrote:
2019-03-05, 21:49
Ok.. I did everything you asked. Maybe a little more though... Added parameters to the command line. You can set the decoded video file, set the task to save files, etc.
https://github.com/BallWin/Qt_ZodEngine ... readme.txt
Important point - you can set the desired FPS. The synchronization code has changed to perform this task. Check the code.

About your question-send the code. Please describe the problem in more detail. I do not know much English and was not familiar with (at least for now) with SDL2 :P
Here's an exmaple: https://zedonline.sourceforge.io/jv_decoder_bug.cpp

This code works fine in SDL 1.2 but the audio is corrupted in SDL2.
Take your time, you have done so much already. Thanks again for the decoder library.
User avatar
SteelGhost
Sergeant
Sergeant
Posts: 54
Joined: 2017-09-19, 00:28
Are you a spam bot?: No

Re: ZED Online - a fork of the Zod Engine

Post by SteelGhost » 2019-03-06, 13:33

DaMarkov wrote:
2019-03-03, 22:34
Image

- Added all the palettes for the jeep and APC (Thanks SteelGhost!)
Splendid!
[SteelGhost - Z DOS fan]

Z Wiki - Contribute now!
BallWin
General
General
Posts: 252
Joined: 2006-10-24, 02:24
Location: Russia
Contact:

Re: ZED Online - a fork of the Zod Engine

Post by BallWin » 2019-03-06, 19:28

DaMarkov wrote:
2019-03-05, 23:27
This code works fine in SDL 1.2 but the audio is corrupted in SDL2.
I installed SDL2 and copied the code from jv_decoder_bug.cpp.
My version https://github.com/BallWin/Qt_ZodEngine ... ag_wav.cpp
works without problems. Sound plays.
When copying the code found a non-critical bug. The total_war_buff() function is written in the style of Error-Message-Instead-Comment. Such functions always return true if there are no errors! Therefore, this line of code can only work if there is an error:

Code: Select all

if (m_audio.total_wav_buff(m_audio_data, &error))
I looked at myself and saw the same thing. I forgot to put '!' in the beginning. This only worked because the function reported an incorrect size of the last data record. :lol:
I fixed it. Update files https://github.com/BallWin/Qt_ZodEngine ... o_proc.cpp. Or the AudioWorker_JV::total_wav_buff function code from this file.
However, this bug has nothing to do with any problems. The required amount of memory was allocated. It's funny.
Here

Code: Select all

#include "/audio_proc.h"
do you really need the "/" symbol?
DaMarkov
Major
Major
Posts: 180
Joined: 2018-12-20, 16:17
Are you a spam bot?: No
Contact:

Re: ZED Online - a fork of the Zod Engine

Post by DaMarkov » 2019-03-07, 01:59

BallWin wrote:
2019-03-06, 19:28
DaMarkov wrote:
2019-03-05, 23:27
This code works fine in SDL 1.2 but the audio is corrupted in SDL2.
I installed SDL2 and copied the code from jv_decoder_bug.cpp.
My version https://github.com/BallWin/Qt_ZodEngine ... ag_wav.cpp
works without problems. Sound plays.
Interesting ...
BallWin wrote:
2019-03-06, 19:28
When copying the code found a non-critical bug. The total_war_buff() function is written in the style of Error-Message-Instead-Comment. Such functions always return true if there are no errors! Therefore, this line of code can only work if there is an error:

Code: Select all

if (m_audio.total_wav_buff(m_audio_data, &error))
I looked at myself and saw the same thing. I forgot to put '!' in the beginning. This only worked because the function reported an incorrect size of the last data record. :lol:
I fixed it. Update files https://github.com/BallWin/Qt_ZodEngine ... o_proc.cpp. Or the AudioWorker_JV::total_wav_buff function code from this file.
Thanks! Fixed it in my copy.
BallWin wrote:
2019-03-06, 19:28
Here

Code: Select all

#include "/audio_proc.h"
do you really need the "/" symbol?
Nope, just a tiny mistake by me.

Here is a better example of the bug:

https://zedonline.sourceforge.io/jv_decoder_bug2.cpp

If I compile this file against SDL_mixer.lib everything works. If I link to SDL2_mixer.lib sound is corrupted.
Do you also link to SDL2_mixer.lib after switching from SDL1 to SDL2?


As a bonus: Here is your decoder is action: https://www.youtube.com/watch?v=aqGshjI ... e=youtu.be
BallWin
General
General
Posts: 252
Joined: 2006-10-24, 02:24
Location: Russia
Contact:

Re: ZED Online - a fork of the Zod Engine

Post by BallWin » 2019-03-07, 14:16

DaMarkov wrote:
2019-03-07, 01:59
As a bonus: Here is your decoder is action: https://www.youtube.com/watch?v=aqGshjI ... e=youtu.be
Сool :cheers:
DaMarkov wrote:
2019-03-07, 01:59
Here is a better example of the bug:
https://zedonline.sourceforge.io/jv_decoder_bug2.cpp
If I compile this file against SDL_mixer.lib everything works. If I link to SDL2_mixer.lib sound is corrupted.
Do you also link to SDL2_mixer.lib after switching from SDL1 to SDL2?
Ok.
This #pragma comment preprocessor directive is for Visual Studio only.
This is not part of The C++ language. Connecting libraries is done for you (SDL, SDL2) through the Property Pages dialog box.
In my case for QtCreator, I have to set the path to the /lib folder and the /include folder - where the header files and binary implementation files are located. This is only if the library was not installed on OS (in my case on Ubuntu). Then I have to specify which libraries from the /lib folder I'm going to use.
It looks complicated. However, in fact, everything is simple.
A text file is automatically created for each project ".pro". To specify paths (if the library has special paths) in this file, write:
LIBS += -L"/../path_to_folder/lib"
INCLUDEPATH += "/../path_to_foder/include"
Then connect what we need:
LIBS += \
-lSDL2 \
-lSDL2_image \
-lSDL2_mixer \

Instead of the character 'l' in the beginning when you compile is automatically populated with "lib" - that is, here are the connection libSDL2, libSDL2_image, libSDL2_mixer.
Respectively for SDL (1.2..) that would be:
LIBS += \
-lSDL \
-lSDL_image \
-lSDL_mixer \
The project will be built with the libraries that were installed in the operating system and specified in the text file PRO. An error can occur if your library has the same name as another library in OS.
However, this is not the case with SDL (libSDL != libSDL2).
In the code, it is enough to specify the connection of the header of the used library.
For example #include <SDL2/SDL.h>.
What happens if we forget to include the necessary library in the PRO file (for example libSDL2_mixer)? When building the project, we get a compilation error like:
--------------------------------------------------------------------------------------------------------
g++ -o bin/sdl2_bag_sound objs/main.o objs/audio_proc.o objs/bitstream.o objs/jv_format.o objs/video_proc.o -lSDL2 -lSDL2_image
objs/main.o: In function `main':
/home/.../SDL/Testing_SDL2/Sound/sdl2_bag_sound/main.cpp:73: undefined reference to `Mix_OpenAudio'
/home/.../SDL/Testing_SDL2/Sound/sdl2_bag_sound/main.cpp:78: undefined reference to `Mix_Volume'

Makefile:255: recipe for target 'bin/sdl2_bag_sound' failed
/home/.../SDL/Testing_SDL2/Sound/sdl2_bag_sound/main.cpp:94: undefined reference to `Mix_QuickLoad_WAV'
/home/.../SDL/Testing_SDL2/Sound/sdl2_bag_sound/main.cpp:103: undefined reference to `Mix_PlayChannelTimed'
collect2: error: ld returned 1 exit status
make: *** [bin/sdl2_bag_sound] Error 1

--------------------------------------------------------------------------------------------------------
The possibility of using SDL libraries instead of SDL2 is excluded.
(I have a cold and can spend more time on Z) :lazy:
DaMarkov
Major
Major
Posts: 180
Joined: 2018-12-20, 16:17
Are you a spam bot?: No
Contact:

Re: ZED Online - a fork of the Zod Engine

Post by DaMarkov » 2019-03-07, 14:34

OK, you definitely linking to SDL_mixer2. Maybe my version of SDL2 is old and has a bug.
I will redownload SDL2 and compile again.
Are you compiling to 32 bit or 64 bit?
BallWin
General
General
Posts: 252
Joined: 2006-10-24, 02:24
Location: Russia
Contact:

Re: ZED Online - a fork of the Zod Engine

Post by BallWin » 2019-03-07, 15:15

DaMarkov wrote:
2019-03-07, 14:34
OK, you definitely linking to SDL_mixer2. Maybe my version of SDL2 is old and has a bug.
I will redownload SDL2 and compile again.
Are you compiling to 32 bit or 64 bit?
My system
Image
therefore 64 bit.
Information concerning the installed versions of the libraries SDL2 (via Synaptic)
Image
In my opinion in this case 64 or 32 bits should not affect the result. You can test the functionality without reinstalling the library. I have to go to the doctor now. We'll discuss it later.
BallWin
General
General
Posts: 252
Joined: 2006-10-24, 02:24
Location: Russia
Contact:

Re: ZED Online - a fork of the Zod Engine

Post by BallWin » 2019-03-07, 15:42

Before I go... Copy the compiler output from a failed build (where error messages are contained). Will post it here.
DaMarkov
Major
Major
Posts: 180
Joined: 2018-12-20, 16:17
Are you a spam bot?: No
Contact:

Re: ZED Online - a fork of the Zod Engine

Post by DaMarkov » 2019-03-08, 08:22

I have downloaded SDL2 2.0.9 and SDL2_mixer 2.0.4. Everything works now!

Quick questions though:
I need to set:

Code: Select all

Mix_OpenAudio(11025, AUDIO_U8, 1, 4096);
for your decoder, but I also have sounds that require:

Code: Select all

Mix_OpenAudio(22050, AUDIO_S16, 1, 4096);
Is there a good way to change the audio format in SDL mixer?

EDIT: Found the solution!
@Ballwin: You mgiht one to replace

Code: Select all

wav_chunk = Mix_QuickLoad_WAV(audio_data.ptr_data.get());
by

Code: Select all

SDL_RWops *audio_data2 = SDL_RWFromMem(audio_data.ptr_data.get(), audio_data.size_data);
wav_chunk = Mix_LoadWAV_RW(audio_data2, 1);
Mix_QuickLoad_WAV() seems to ignore the WAV header. Mix_LoadWAV_RW() works better. With that everything now works perfectly!
Post Reply