Fenix Manual
Fenix Manual
Introduction

Notes
Considered Optimisations

Notes
Last Modified: May 30, 2005 10:05AM
(0.83)
Description

Main curl of FXI 0.83

The following scheme illustrates the operation of the main curl of the FXI [ instange_go_all ] in version 0.83:

While some process is assets:

It examines all the active processes:

)con creates one lists(ilist all those that have equal STATUS to 2 and FRAME_PERCENT smaller to 100

It initializes variables TYPE_SCAN and ID_SCAN (accountants for GET_ID and COLLISION)

If the list is empty:

It destroys all the processes that have equal STATUS to 1

Delay until it is moment for beginning following frame [ gr_wait_frame ]

[ draws following frame in screen gr_draw_frame ]:

It gathers the events of keyboard and mouse of SDL, updating the corresponding global variables [ do_events ]


If flag is activated to jump frame present, it does not do nothing else

If flag of change of trowel is activated, gr_refresh_palette updates [ ]

[ blocks the access to screen gr_lock_screen ]. This function creates bitmap "false" whose leader to data in fact aims at the video buffer (way to doble_buffer or in window), or creates bitmap in memory for the screen (way 2xscale or complete screen without doble_buffer).

[ draws frame complete gr_draw_screen ] in bitmap (scrbitmap) prepared by gr_lock_screen:

In case [ is not scroll to complete screen gr_scroll_is_fullscreen ], flock the screen: putting it to black if there is no bottom, or copying the bottom graph, that can be of 8 or 16 bits.

It creates a list of objects to draw, with:

All the processes where CTYPE is worth 0, its state is 2 either 4, and have a number different from 0 in GRAPH or XGRAPH.

All the objects registered by DLL [ gr_new_object ]. This includes the graphs primitive type created like objects [ gr_drawing_new ]

The text drawing, like unique object [ draw_texts ]

The drawing of the mouse, like unique object [ draw_mouse ]

The drawing of the present FLI, like unique object [ draw_fli ]

Any plane of scroll, like unique object [ draw_scroll ]

Any plane of way 7, like unique object [ draw_mode7 ]

It orders the list based on coordinate Z with qsort

Llama to the function that draws each object, by order

(aim of gr_draw_screen) Returned to gr_draw_frame:

If there is fade active, it updates its position and optionally [ colors scrbitmap gr_fade_step ]

[ unblocks the access to screen gr_unlock_screen ].

In way 2xscale, this function moves the content of scrbitmap to the real screen (they screen) using the AdMame2x function and next a SDL_UpdateRect() does of all the screen.

In way double buffer or window, is limited to unblock bitmap "false" and to make a SDL_Flip.

In way without double buffer, it copies the content of scrbitmap to screen and makes a SDL_UpdateRect. In addition, in 16 bits it supports the "filtrate" - f, that mixes each color with the one of its right when doing the copy.

It returns to gather events of SDL for the second time (ideally it would be enough with doing it here) [ do_events ]
(aim of gr_draw_frame) Returned to instance_go_all:

Subtraction 100 to the FRAME_PERCENT of all the processes that have equal STATUS to 2

[ advances the time accountants gr_advance_timers ]

It leaves the main curl if a condition of exit exists (ej. executed EXIT)

It returns in the beginning from the main curl

It orders the list of active processes (ilist) by variable PRIORITY

It executes the processes one by one, by the order issued by the list [ instance_go ]

The list of processes crosses of principle to aim several times by frame: one to obtain the list of processes to execute, other to destuir the affected processes, and other to reduce 100 to the FRAME_PERCENT of the processes. In addition, the list of active processes is created and it is ordered once like minimum by frame, even although there are no changes with respect to the previous execution.


Proposal again main curl
The new main curl is nourished of the following concepts:

Two curls of execution of processes exist:

Curl primary that it executes at the beginning of each frame and considers all processes that exists at the beginning of the FRAME (even those that is not susceptible to execute itself), executing those that needs it. This curl also reduces the value of FRAME_PERCENT.


A secondary curl that is executed immediately later and can execute several times, and that only considers those processes that after the execution of a previous curl east frame still has time of frame to exhaust, as well as those processes that are created but do not exhaust all their time of frame during the first execution.

Five global lists exist that stay doubly like connected lists. The five lists are:

Primary list of execution: for the primary curl. It even contains all the existing processes ordered by PRIORITY, those that are slept, so that the primary curl can observe that they have waked up. Nevertheless, when creating a new process [ instance_new ] this is not added to the list, since it would disturb the execution of this frame (the primary curl only must consider processes that existed when initiating frame).

Secondary list of execution: a process that after executing [ instance_go ] does not end a FRAME_PERCENT of 100 more or must return to execute in a later secondary curl, so it is added to this list, being maintained an order by PRIORITY. This also includes the new processes, created during this frame.

List of new processes: a new process [ instance_new ] adds to this list disordered instead of a the primary one. The main curl will be in charge to update the primary list being moved the content of this, before initiating new frame.

List of processes to kill: as much the main curl as the secondary one will so add to this disordered list any process that, before or after executing it, = 1 ends STATUS. The main curl will make the destruction effective of the processes that appear in this right list after drawing frame present, before beginning the following one.

List of objects. Is not a list of processes itself, since it can contain objects, texts, primitive graphs and objects of DLL. But the processes must be added to this list if they are susceptible to be drawn. As much the main curl as the secondary one must verify data of the process to add it to this list, to erase it of her, or to update their position in the same one (before a variation of coordinate Z).

Proposal of drawing system
At the moment each frame whole is being drawn, when the screen graph scrbitmap is even false and it would be possible to be maintained between frames. It would have to be allowed to modify the modality of operation based on the necessity of the game, like in DIV, being supported variables DUMP_TYPE and RESTORE_TYPE with the following combinations:

DUMP_TYPE = COMPLETE_DUMP; RESTORE_TYPE = COMPLETE_RESTORE

Present operation. Each new frame, flock all the screen (or the bottom is copied on scrbitmap) and go to draw all the objects and processes by order of coordinate Z. Compatible with double buffer (drawing directly on the video buffer).


DUMP_TYPE = COMPLETE_DUMP; RESTORE_TYPE = NO_RESTORE

The screen is not copied the bottom nor flock, and all the processes and objects are drawn upon "which is". This is only useful with scrolls to complete screen. Compatible with double buffer.


DUMP_TYPE = PARTIAL_DUMP; RESTORE_TYPE = PARTIAL_RESTORE

A search becomes of "dirty" rectangles to redibujar... Basically, one is to ennumerar the rectangles that contain to any process that has changed one of the variables, GRAPH, CASES OUT, X, and, SIZE, ANGLE, SIZE_X or SIZE_Y from last frame which they were drawn. The DLL will have to register a function that provides these rectangles each frame. Next, these zones are drawn selectively only (first erase or a bottom piece is copied on them; soon the precise processes and objects are drawn with clipping).

The greater disadvantage is than the rectangles would not have to be superposed, and can have an elevated number of such.

So that he is compatible with the double buffer would be necessary to keep the positions from the processes as they were drawn separately by each one of buffers, to be able to verify if there are variations. It would be necessary to consult the SDL to see if the double buffer leaves backbuffer us with the correct data as they were drawn, or its content is indetermine.


DUMP_TYPE = PARTIAL_DUMP; RESTORE_TYPE = NO_RESTORE

Just as the previous step, but the rectangles nor copy do not erase on them the bottom. It only is useful in games with scrolls that are not to complete screen. Compatible with double buffer without having to make nothing special. A game that has normal processes and uses east way will not work correctly.

In addition some additional variables would have to exist:


GRAPH_MODE |= MODE_HARDWARE;

This flag would allow to choose when it is drawn directly on the buffer of video of the graphical card or reserves bitmap in memory. In theory the previous ways would have to be compatible with both possibilities. Nevertheless, this way is incompatible with 2XSCALE.


GRAPH_MODE |= MODE_DOUBLEBUFFER;

This flag would activate the way of double buffer. In theory it would not have to be incompatible with the previous one.

User Contributed Notes
Notes
Add Notes About Notes
There are no user contributed notes for this page.
Last updated: Sun, 29 May 2005 - 11:58:23

Manual © 2005 By Gary Moncrieff(Dazzy), Notes belong to their respective posters