Sega Saturn Development > General Jo Engine Help

How to autoload game after video

<< < (2/4) > >>

SaturnTeam:
Yeah. That's something I've come across while working on this. I think I'm getting close to solving it. I was making progress last night. I'm going to work on it today. If I don't get it working, I'll post the code that I'm using so I can get more eyeballs on the code. If I get it working, I'll post how I did it. One of the problems I've run across is that, compared to how it's noted in the source document, different coding sites give slightly different implementation examples. Some of the coding tutorials conform to C and others to C++.

SaturnTeam:
Update: I think I have most of the right code, but I still can't figure it out.

EXECUTION CODE IN MAIN.C:

--- Code: ---
#include "video.h"

#define jo_extended_ram_cartridge_type(CART_32MBits)

void     jo_main(void)
{
    jo_core_init(JO_COLOR_Black);
    jo_core_suspend();
//    jo_malloc(sizeof(int));
    jo_core_add_callback(my_draw2);
    jo_core_add_callback(my_video_stopped);
    jo_core_add_callback(jo_main2);
if (jo_video_open_file("SAMPLE.CPK"))
        jo_video_play(my_video_stopped);
    jo_free((void*) video);
    jo_core_suspend();
...blablabla
}

--- End code ---

HEADER FILE:

--- Code: ---
#ifndef __VIDEO_H__
# define __VIDEO_H__


#include <jo/jo.h>

#define jo_extended_ram_cartridge_type(CART_32MBits)

const int *video;

void     my_draw2(void)
{
    video = jo_video_open_file; //0x06024970 0x044   0x80   0x013  0x1F8
    const int *video = (const int*) jo_malloc(268000*sizeof(int));
    if(video == NULL)
    {
        jo_printf(1, 2, "Unable to allocate memory", jo_get_last_error());
//        jo_printf(0, 1, "Address of video variable: %d\n", *video);
//        return JO_NULL;
    }
    // Yes, it consume a lot of memory during playing :)
    jo_printf(0, 0, "Dynamic memory usage: %d%%  ", jo_memory_usage_percent());

    jo_sprite_draw3D(jo_get_video_sprite(), 0, 0, 170);
}

void                my_video_stopped(void)
{
    jo_printf(0, 1, "Done.");
}

void     jo_main2(void)
{
jo_core_init(JO_COLOR_Transparent);
jo_core_add_callback(my_draw2);
// if (jo_video_open_file("SAMPLE.CPK"))
//        jo_video_play(my_video_stopped);
jo_core_run();
}
#endif /* !__VIDEO_H__ */

/*
** END OF FILE
*/

--- End code ---

Other than that, I added JO_COMPILE_WITH_RAM_CARD_SUPPORT to my makefile. I think I'll start working on a different approach. I think if I make it a separate video C file in a different folder, I might be able to get it to work. I'm just about done for today. I had to make one of the background colors transparent, because most of the time the error information was getting covered by black all over the screen. I am getting two errors: NULL pointer in jo_free, and GFS cannot determine file size.

SaturnTeam:
My attempt to run it from another C file failed. Now, I've been trying to run everything from the main file. I keep getting the error: in_jo_fs_get_file_size(): GFS_Open() failed. I've tried setting a max malloc size in the makefile, enabling ram card support, and turning on sgl. Nothing works. I have no clue what to do. I have Yabuase set to use the 4MB ram cart. My game disc data is close to 4MB total.

ponut64:
At this point, you're going to have to look over the SBL GFS documentation (and the way Jo engine loads the file) so you can make your own function to load the CPK without a malloc. By doing that, when Jo engine loads something else, it won't try to append it to the end of the allocated area.
Relatively simple, you just need to identify the struct that jo engine wants the CPK in and read up on how GFS_Load works.

SaturnTeam:
I am still working on this. I have been reading through the engine code to see how the videos are loaded and played. Before, it was getting hung up on just finding the file and reading the size. Now, I have everything in one file and have moved most of the video code to the top of the file. Before, most of the code was mixed in lower parts of the file. In the demo, the video is loaded in jo_main with a function up above that signifies the stopping of the video. Of course, the demo is just running one asset, so there is no confusion. Now that I have moved the code into a new function at the top of the file, I am no longer getting the first errors in the error list the code is supposed to run through, which was finding the file and getting the size. It has moved down the list to the error for creating the video before it plays. I can get it to the point where I can see the multicolor lines on the screen where it is trying to play the video, but the game freezes underneath it.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Sitemap 1 2 3 4 5 6 7 8 9 10 
Go to full version