View Single Post
djazz djazz's Avatar

JCF Member

Joined: Feb 2009

Posts: 257

djazz is OFF DA CHARTdjazz is OFF DA CHARTdjazz is OFF DA CHART

Jan 2, 2010, 10:23 AM
djazz is offline
Reply With Quote
J2L - Event Map, Events in general and the Generator Event

Quote:
Originally Posted by Neobeo View Post
The J2L format
...
Data2 - The Event Map
Each event is a long (4 bytes long), so this buffer should be (Layer4Width * Layer4Height * 4) bytes long.
I've done testings and research about this and this is what I have found so far:

Each event looks like this (4 bytes):
Code:
struct Event {
	char EventID;
	char Unknown[3];
}
Where unknown are the event parameters. If there are no parameters, all three are 0.

I've done some deeper research about the Generator event (216), and found out this:
If the Event is 12 (Belt AccR) and the Delay is 3, the structure of the Event Data is:
Code:
216 192 48 0
192 / 16 = 12
48 / 16 = 3

But this ONLY applies when Event or Delay is below 15.
Example with values above 15:
Event: 58 (TNT)
Delay: 29

And we get the following result:
Code:
216 160 211 1
As you can see, the Event and Delay are more hard coded than before.
I've made a PHP script that calculates the Delay:
PHP Code:
<?php
$event
=chr(216).chr(160).chr(211).chr(1);
$delay intval(ceil(((ord(substr($event,2,1)))/16)+(ord(substr($event,3,1))*15)));
?>
Where $event is the four byte part from the Event Map, and this code sets $delay to 29, which is the correct delay.
This code isn't tested with all the combinations of event and delays, as there are a lot of combinations:
256*32 = 8192
All I know it works with the most event and delays, and there may be some exceptions.


If we/someone will make a new JCS or make a JCS patch, or something else related to events, please help me/us.
If this information was useful, or you got any questions/suggestions/further knowledge, please let me know.
Comments are appreciated!
__________________
WebJCS 2 (new and in progress)
WebJCS 1 (old but complete)
SGIP Simple Games in Progress list
Level Packer v2 - With a GUI!
PHP Tileset Compiler

Last edited by djazz; Jan 2, 2010 at 01:13 PM.