Author Topic: Has anyone experimented with the horizon parameter in jo_mode7?  (Read 80 times)

illinx

  • Newbie
  • *
  • Posts: 2
  • Karma: +1/-0
    • View Profile
I wanna work on a first-person flying game using jo_mode7 for an infinite floor plane. The mode7 sample includes panning left and right, as well as forward and back (depth), but doesn't do anything with height. I modified the draw function to look something like this:

Code: [Select]
if (need_redraw_background)
    {
        /* We notify that the event is handled */
        need_redraw_background = 0;
        /* We scroll the background (it's very fast) */
        jo_move_background(background_pos_x, 0);
        /* We scroll the mode7 output otherwise the floor will be truncated */
        mode7.output_left = background_pos_x;

mode7.horizon = horizon;

        /* This function updates the new output position */
        jo_update_screen_output_coord_for_mode7(&mode7);
        /* We draw the floor */
        jo_do_mode7_floor(&tile, background_pos_x, floor_pos_y, &mode7);

    }

Where I increment/decrement horizon based on user input. However, it seems like I'm missing something because the floor texture doesn't get stretched properly, and the background doesn't redraw over the floor if the value of horizon increases.

It seems like I'm forgetting to update a few parameters, but having not found any code where this works properly I'm at a loss for now. Does anybody have any ideas/working code?

Attached screenshot of what it looks like when I decrease the value of horizon a bit.

Thanks in advance!

ponut64

  • Full Member
  • ***
  • Posts: 207
  • Karma: +21/-0
    • View Profile
Re: Has anyone experimented with the horizon parameter in jo_mode7?
« Reply #1 on: April 21, 2019, 03:01:35 am »
What you want to use is RBG0 of VDP2.

RBG0 is a 3D rotating, scaling, and tiling plane.

In this thread, XL2 attached a demo that uses RBG0.
https://forum.jo-engine.org/index.php?topic=864.0

There are no Jo engine abstractions to use RBG0.
Here is a more direct example of the parameter setup for an RBG0 plane:
Code: [Select]
slRparaInitSet((void *)RBG0_PRA_ADR);
slMakeKtable((void *)RBG0_KTB_ADR);
slCharRbg0(COL_TYPE_256 , CHAR_SIZE_1x1);
slPageRbg0((void *)RBG0RB_CEL_ADR , 0 , PNB_1WORD|CN_12BIT);

slPlaneRA(PL_SIZE_1x1);
sl1MapRA((void *)RBG0RA_MAP_ADR);
slOverRA(0);
slKtableRA((void *)RBG0_KTB_ADR , K_MODE0 | K_FIX | K_LINE | K_2WORD | K_ON | K_LINECOL);
Cel2VRAM(tuti_cel , (void *)RBG0RA_CEL_ADR , 65536);
Map2VRAM(tuti_map , (void *)RBG0RA_MAP_ADR , 64 , 64 , 2 , 884);
Pal2CRAM(tuti_pal , (void *)RBG0RA_COL_ADR , 160);

slRparaMode(RA);
slBack1ColSet((void *)BACK_COL_ADR , 0);

    slColorCalc( CC_ADD | CC_TOP | NBG2ON | RBG0ON);
slColorCalcOn( NBG2ON | RBG0ON);
slScrTransparent(NBG2ON | RBG0ON);
slColRateLNCL(0x00);

To display & transform the RBG0 plane, you need to end the matrix it is in with the following:

Code: [Select]
		slCurRpara(RA);
slScrMatConv();
slScrMatSet();

slCurRpara sets RBG0's rotation parameter type.
slScrMatConv converts the matrix to a scroll screen matrix. (Note the consumes the matrix in the process, do not set polygons in this matrix)
slScrMatSet sets the converted matrix and sends it to VDP2 rather than VDP1.

In addition, you may note this command:
Code: [Select]
	
slScrAutoDisp(NBG0ON | RBG0ON );

slScrAutoDisp sets data inside of SGL (the development library) to notify VDP2 of which scroll screens are to be displayed automatically each frame.


I HIGHLY RECOMMEND YOU READ VDP2 USER'S MANUAL REGARDING THE SCROLL SCREEN, OR THE SEGA OF EUROPE TUTORIAL DOCUMENT.
Those can be found here:
https://antime.kapsi.fi/sega/docs.html
« Last Edit: April 21, 2019, 03:03:12 am by ponut64 »

ponut64

  • Full Member
  • ***
  • Posts: 207
  • Karma: +21/-0
    • View Profile
Re: Has anyone experimented with the horizon parameter in jo_mode7?
« Reply #2 on: April 21, 2019, 03:16:27 am »
If you have more questions (you will), please join the sega extreme discord server. https://discord.gg/hv3Z3s

illinx

  • Newbie
  • *
  • Posts: 2
  • Karma: +1/-0
    • View Profile
Re: Has anyone experimented with the horizon parameter in jo_mode7?
« Reply #3 on: April 21, 2019, 07:16:57 pm »
Thank you very much ponut, that's exactly what I was looking for. the VDP2 3d plane was what I wanted in the first place but as you noted, I couldn't find an abstraction at the joengine level that took advantage of it. I saw that the pseudo-mode7 demo was using vdp2 behind the scenes but the room_testing demo is exactly what I want. Thanks! I am gonna chip away at this and probably join the discord when I get it to a good place.

 

Sitemap 1 2 3 4 5 6 7 8 9 10 
SMF spam blocked by CleanTalk