6/20/2023 0 Comments The lost vikings blizzard client![]() The game uses processes to manage a number of things: the core game flow, each of the players, projectiles, background scrolling, and much more. I think it is unlikely that this mechanism was used however as it appears to have been limited to 8 user threads. Note that the Playstation programming environment did provide a co-operative threads implementation through the functions OpenTh, ChangeTh and CloseTh. This updates the sleep time for the currently running process and then switches to the main context, which will restore in the process_dispatch function, which will then select the next process to run. This is done by calling process_sleep:Ĭontext_switch(&main_context, current_proc->p_context) The multi-tasking is cooperative so a process must explicitly yield to allow another process to run. A similar task switching implementation by Stephen Brennan appeared on Hacker News recently. This is similar to how setjmp and longjmp work, except that each process will need its own stack. It saves the register state of the process being switched from and then restores the state of the process being switched to. ![]() The prototype likely has the meaning:Ĭontext_switch(CONTEXT *to, CONTEXT *from) The context_switch function is missing from the source (CONTEXT.S). * Pause dispatch, only look at pause class processes */ #define CREATE(id, func) process_create(id, func)Ĭontext_switch(current_proc->p_context, &main_context) The CREATE macro is defined in MKOS.H as: To start with let’s look at the process creation and dispatch. We’ll come back to the code for “unstacking switch processes”. To start with we’ll look at an interesting aspect of how the game is implemented: the process dispatcher: The main loop code is very large and does a lot of things. The game start up is fairly typical: various subsystems are initialised, resources are loaded, etc. The game starts in the main function in MKINIT.C. Minor content warning: some people may find some of the terms that the original source code uses offensive. However, I have left all function and variable names and comments as they were in the original source. This is mostly just cleaning up whitespace, removing unnecessary parens and casts, and omitting code and comments that are not relevant to the explanation. ![]() I have refactored code samples from the original source to make the code a bit clearer. The game also refers to all characters as “he”, “guys” (see MKGUYS.C) or “dudes”. There is a macro named MURDER and a function named eat_this_shit. The source code also turns out to be rather violent. The Mortal Kombat games were famously controversial for their excessive violence. My standout memory was getting repeatedly lightning bolted, and then roundhouse kicked right around the screen by my (younger) brother playing Rain. It was basically the same game with added characters and stages and some updated game features. I actually played many hours of Mortal Kombat Trilogy with my brother on his Playstation. ![]() In this review I’m going to look at some of the aspects of the implementation that I found interesting. I think more source code bases should have a function to test to see if this is a joke.Īn incomplete, non buildable, copy of the Playstation port of Ultimate Mortal Kombat source code is available at: If (q_is_this_a_joke() = SYSTEM_CARRY_SET) I think it was this snippet from MKBOSS.C that made me interested to read further: It’s also interesting to see how developers of the time approached building game engines for platforms with limited memory and performance.Īlso, sometimes the code is just amusing to read. I think there is something fascinating about projects that, while not the most elegant code, were often developed on tight time constraints, but still produced stable enough products for gamers to spend thousands of hours playing. I enjoy reading source code of old games.
0 Comments
Leave a Reply. |