the
This commit is contained in:
parent
6273915154
commit
dca0762251
6 changed files with 218 additions and 6948 deletions
|
|
@ -11,4 +11,8 @@
|
|||
"label": "Test run (gojo)",
|
||||
"command": "odin run . -- ../Satoru-Gojo-Needle/Satoru-Gojo-Needle.yyp ../Satoru-Gojo-Needle/rooms/rSatoru/rSatoru.yy jmap.jmap jmap_config.json5 -x:1600 -y:608 -clear_area"
|
||||
},
|
||||
{
|
||||
"label": "Diff (gojo)",
|
||||
"command": "diff rSatoru-original.yy ../Satoru-Gojo-Needle/rooms/rSatoru/rSatoru.yy"
|
||||
}
|
||||
]
|
||||
|
|
|
|||
13
debug.raddbg
13
debug.raddbg
|
|
@ -4,6 +4,15 @@ target:
|
|||
{
|
||||
executable: gamemaker_jmap_import
|
||||
working_directory: ""
|
||||
enabled: 1
|
||||
arguments: "../Satoru-Gojo-Needle/Satoru-Gojo-Needle.yyp jmap.jmap jmap_config.json5"
|
||||
arguments: "../Satoru-Gojo-Needle/Satoru-Gojo-Needle.yyp ../Satoru-Gojo-Needle/rooms/rSatoru/rSatoru.yy jmap.jmap jmap_config.json5 -x:1600 -y:608 -clear_area"
|
||||
enabled: 0
|
||||
label: "Test gojo"
|
||||
}
|
||||
target:
|
||||
{
|
||||
executable: gamemaker_jmap_import
|
||||
working_directory: ""
|
||||
arguments: "project.yyp rSatoru.yy jmap.jmap jmap_config.json5 -x:1600 -y:608 -clear_area"
|
||||
label: Test
|
||||
enabled: 1
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,9 +1,10 @@
|
|||
{
|
||||
instance_layer: "Instances"
|
||||
tile_layer: "Tiles"
|
||||
mappings: {
|
||||
"block": {
|
||||
object_name: "objBlock",
|
||||
type: "tile",
|
||||
object_name: "objBlock"
|
||||
type: "tile"
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
90
main.odin
90
main.odin
|
|
@ -306,7 +306,11 @@ GamemakerTilemap :: struct {
|
|||
}
|
||||
|
||||
/*
|
||||
NOTE (synthas):
|
||||
GameMaker compresses their tile data stored in the room resource
|
||||
-2147483648 is a null-tile, 0 is a nothing tile.
|
||||
But when erased 0 is used instead.
|
||||
|
||||
Imagine the following data:
|
||||
-4,-2147483648,1,6,-4,-2147483648,4,6,-2147483648,-2147483648,6,-3,-2147483648,1,6,
|
||||
It represents tile data for the following tilemap:
|
||||
|
|
@ -325,28 +329,27 @@ resource_room_tile_layer_decompress :: proc(layer: json.Object, allocator := con
|
|||
tilemap_grid_x := int(layer["gridX"].(json.Integer))
|
||||
tilemap_grid_y := int(layer["gridY"].(json.Integer))
|
||||
tilemap_data := layer["tiles"].(json.Object)
|
||||
tilemap_width := int(layer["SerializeWidth"].(json.Integer))
|
||||
tilemap_height := int(layer["SerializeHeight"].(json.Integer))
|
||||
tilemap_compressed := layer["TileCompressedData"].(json.Array)
|
||||
tilemap_width := int(tilemap_data["SerialiseWidth"].(json.Integer))
|
||||
tilemap_height := int(tilemap_data["SerialiseHeight"].(json.Integer))
|
||||
tilemap_compressed := tilemap_data["TileCompressedData"].(json.Array)
|
||||
tilemap.data = make([dynamic]i64, tilemap_width * tilemap_height, allocator = allocator)
|
||||
tilemap_tile_index := 0
|
||||
for i := 0; i < len(tilemap_compressed); {
|
||||
value := int(tilemap_compressed[i].(json.Integer))
|
||||
i += 1
|
||||
switch math.sign(value) {
|
||||
case 1:
|
||||
tile_count := value
|
||||
i += 1
|
||||
for j in 0..<tile_count {
|
||||
tilemap.data[tilemap_tile_index] = tilemap_compressed[i + j].(json.Integer)
|
||||
tilemap_tile_index += 1
|
||||
tilemap.data[tilemap_tile_index + j] = tilemap_compressed[i + j].(json.Integer)
|
||||
}
|
||||
tilemap_tile_index += tile_count
|
||||
i += tile_count
|
||||
case -1:
|
||||
tile_count := abs(value)
|
||||
i += 1
|
||||
tile := tilemap_compressed[i].(json.Integer)
|
||||
for j in 0..<tile_count {
|
||||
tilemap.data[tilemap_tile_index] = tile
|
||||
tilemap.data[tilemap_tile_index + j] = tile
|
||||
}
|
||||
tilemap_tile_index += tile_count
|
||||
i += 1
|
||||
|
|
@ -354,9 +357,64 @@ resource_room_tile_layer_decompress :: proc(layer: json.Object, allocator := con
|
|||
panic("Weirdo tile data what the fuck")
|
||||
}
|
||||
}
|
||||
fmt.println(tilemap.data[52:100])
|
||||
return tilemap
|
||||
}
|
||||
|
||||
resource_room_tile_layer_compress :: proc(tilemap: ^GamemakerTilemap, allocator := context.allocator) -> json.Array {
|
||||
tilemap_compressed := make(json.Array, allocator)
|
||||
for i := 0; i < len(tilemap.data);{
|
||||
remaining := len(tilemap.data) - i
|
||||
if remaining < 3 {
|
||||
append(&tilemap_compressed, i64(remaining))
|
||||
for value in tilemap.data[i:] {
|
||||
append(&tilemap_compressed, value)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
tile := tilemap.data[i]
|
||||
if tilemap.data[i + 1] == tile && tilemap.data[i + 2] == tile {
|
||||
tilemap_index := i + 3
|
||||
for ; tilemap_index < len(tilemap.data); tilemap_index += 1 {
|
||||
if tilemap.data[tilemap_index] != tile {
|
||||
break
|
||||
}
|
||||
}
|
||||
append_elems(&tilemap_compressed, i64((tilemap_index - i) * -1), tile)
|
||||
i = tilemap_index
|
||||
} else {
|
||||
combo := 0
|
||||
combo_tile_current_index := i
|
||||
combo_tile_current := tilemap.data[i]
|
||||
tilemap_index := i + 1
|
||||
for ; i < len(tilemap.data); tilemap_index += 1 {
|
||||
if tilemap.data[tilemap_index] == combo_tile_current {
|
||||
combo += 1
|
||||
if combo > 2 {
|
||||
break
|
||||
}
|
||||
} else {
|
||||
combo_tile_current = tilemap.data[tilemap_index]
|
||||
combo_tile_current_index = tilemap_index
|
||||
}
|
||||
}
|
||||
append(&tilemap_compressed, i64(combo_tile_current_index - i))
|
||||
for value in tilemap.data[i:combo_tile_current_index] {
|
||||
append(&tilemap_compressed, value)
|
||||
}
|
||||
i = tilemap_index
|
||||
}
|
||||
}
|
||||
|
||||
return tilemap_compressed
|
||||
}
|
||||
|
||||
resource_room_tile_layer_set_tiles :: proc(room_layer: ^json.Object, tilemap: ^GamemakerTilemap, allocator := context.allocator) {
|
||||
tile_data := &(&room_layer["tiles"]).(json.Object)
|
||||
tile_data["TileCompressedData"] = resource_room_tile_layer_compress(tilemap)
|
||||
}
|
||||
|
||||
resource_room_layer_tile_is_empty :: proc(mask: GamemakerTile) -> bool {
|
||||
return mask == min(GamemakerTile)
|
||||
}
|
||||
|
|
@ -370,9 +428,9 @@ resource_room_tile_layer_insert_tile :: proc(tilemap: json.Array, tilemap_width,
|
|||
tilemap[index] = i64(tile)
|
||||
}
|
||||
|
||||
resource_room_tile_layer_clear_area :: proc(tilemap: json.Array, tilemap_width, x, y, width, height, tile_width, tile_height: int) {
|
||||
assert(len(tilemap) % tilemap_width == 0, "Wrong tilemap width")
|
||||
tilemap_height := len(tilemap) / tilemap_width
|
||||
resource_room_tile_layer_clear_area :: proc(tilemap: ^GamemakerTilemap, tilemap_width, x, y, width, height, tile_width, tile_height: int) {
|
||||
assert(len(tilemap.data) % tilemap_width == 0, "Wrong tilemap width")
|
||||
tilemap_height := len(tilemap.data) / tilemap_width
|
||||
tilemap_area_x := x / tile_width
|
||||
tilemap_area_y := y / tile_height
|
||||
tilemap_area_width := width / tile_width
|
||||
|
|
@ -386,7 +444,7 @@ resource_room_tile_layer_clear_area :: proc(tilemap: json.Array, tilemap_width,
|
|||
for x in tilemap_area_x..<tilemap_area_x2 {
|
||||
for y in tilemap_area_y..<tilemap_area_y2 {
|
||||
index := x + y * tilemap_width
|
||||
tilemap[index] = i64(min(GamemakerTile))
|
||||
tilemap.data[index] = i64(min(GamemakerTile))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -609,14 +667,14 @@ program :: proc(yyp_project_path, room_resource_path, jmap_path, jmap_config_pat
|
|||
return program_error_create(ProgramErrorError.RoomLayerNotInstance, fmt.aprint("Found instance layer '", jmap_config.instance_layer, "'. but it was not an instance layer", sep = ""))
|
||||
}
|
||||
|
||||
room_tile_layer, room_tile_layer_found := resource_room_layer_get_by_name(room_layers, jmap_config.instance_layer)
|
||||
room_tile_layer, room_tile_layer_found := resource_room_layer_get_by_name(room_layers, jmap_config.tile_layer)
|
||||
room_tilemap: GamemakerTilemap
|
||||
if room_tile_layer_found {
|
||||
if room_tile_layer_type := resource_room_layer_get_type(room_tile_layer^); room_tile_layer_type != .Tile {
|
||||
return program_error_create(ProgramErrorError.RoomLayerNotTile, fmt.aprint("Found tile layer '", jmap_config.tile_layer, "' But it was not a tile layer", sep = ""))
|
||||
return program_error_create(ProgramErrorError.RoomLayerNotTile, fmt.aprint("Found layer '", jmap_config.tile_layer, "' But it was not a tile layer (", room_tile_layer_type, ")", sep = ""))
|
||||
}
|
||||
|
||||
|
||||
room_tilemap = resource_room_tile_layer_decompress(room_tile_layer^, context.allocator)
|
||||
resource_room_tile_layer_set_tiles(room_tile_layer, &room_tilemap, context.allocator)
|
||||
}
|
||||
|
||||
room_layer_instances := &((&room_instance_layer["instances"]).(json.Array))
|
||||
|
|
|
|||
6992
rSatoru.yy
6992
rSatoru.yy
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue