diff --git a/.gitattributes b/.gitattributes index acf75d69..f1b476bc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -19,7 +19,9 @@ # Denote all files that are truly binary and should not be modified. *.png binary diff=hex *.bin binary diff=hex +*.lz.match binary diff=hex # these are generated but just in case *.2bpp binary diff=hex *.1bpp binary diff=hex +*.lz binary diff=hex diff --git a/.gitignore b/.gitignore index 8a5dcde3..368003a2 100644 --- a/.gitignore +++ b/.gitignore @@ -22,5 +22,8 @@ *.2bpp *.pal +# compressed data +*.lz + # *disasm.py output file *disasm_output.asm diff --git a/Makefile b/Makefile index 3a5e8105..ab1ac833 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,10 @@ clean: tidy -o -iname '*.pal' \) \ -delete + find src/data \ + \( -iname '*.lz' \) \ + -delete + tidy: $(RM) $(rom) \ $(rom:.gbc=.sym) \ @@ -158,3 +162,7 @@ src/gfx/titlescreen/title_screen_cgb.2bpp: rgbgfx += -x 12 $(RGBGFX) $(rgbgfx) -d1 -o $@ $< $(if $(tools/gfx),\ tools/gfx $(tools/gfx) -d1 -o $@ $@) + +# remove -m if you don't care for matching +%.lz: % + tools/compressor -m $(tools/compressor) $< $@ diff --git a/src/data/maps/permissions/challenge_hall.bin b/src/data/maps/permissions/challenge_hall.bin index ab54f1c4..f96f651a 100644 Binary files a/src/data/maps/permissions/challenge_hall.bin and b/src/data/maps/permissions/challenge_hall.bin differ diff --git a/src/data/maps/permissions/challenge_hall.bin.lz.match b/src/data/maps/permissions/challenge_hall.bin.lz.match new file mode 100644 index 00000000..ab54f1c4 Binary files /dev/null and b/src/data/maps/permissions/challenge_hall.bin.lz.match differ diff --git a/src/data/maps/permissions/challenge_hall_cgb.bin b/src/data/maps/permissions/challenge_hall_cgb.bin index ab54f1c4..f96f651a 100644 Binary files a/src/data/maps/permissions/challenge_hall_cgb.bin and b/src/data/maps/permissions/challenge_hall_cgb.bin differ diff --git a/src/data/maps/permissions/challenge_hall_cgb.bin.lz.match b/src/data/maps/permissions/challenge_hall_cgb.bin.lz.match new file mode 100644 index 00000000..ab54f1c4 Binary files /dev/null and b/src/data/maps/permissions/challenge_hall_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/challenge_hall_entrance.bin b/src/data/maps/permissions/challenge_hall_entrance.bin index 76a9ae13..c4590ec0 100644 Binary files a/src/data/maps/permissions/challenge_hall_entrance.bin and b/src/data/maps/permissions/challenge_hall_entrance.bin differ diff --git a/src/data/maps/permissions/challenge_hall_entrance.bin.lz.match b/src/data/maps/permissions/challenge_hall_entrance.bin.lz.match new file mode 100644 index 00000000..76a9ae13 Binary files /dev/null and b/src/data/maps/permissions/challenge_hall_entrance.bin.lz.match differ diff --git a/src/data/maps/permissions/challenge_hall_entrance_cgb.bin b/src/data/maps/permissions/challenge_hall_entrance_cgb.bin index 76a9ae13..c4590ec0 100644 Binary files a/src/data/maps/permissions/challenge_hall_entrance_cgb.bin and b/src/data/maps/permissions/challenge_hall_entrance_cgb.bin differ diff --git a/src/data/maps/permissions/challenge_hall_entrance_cgb.bin.lz.match b/src/data/maps/permissions/challenge_hall_entrance_cgb.bin.lz.match new file mode 100644 index 00000000..76a9ae13 Binary files /dev/null and b/src/data/maps/permissions/challenge_hall_entrance_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/challenge_machine_map_event.bin b/src/data/maps/permissions/challenge_machine_map_event.bin index 26b782d0..6decae2f 100644 Binary files a/src/data/maps/permissions/challenge_machine_map_event.bin and b/src/data/maps/permissions/challenge_machine_map_event.bin differ diff --git a/src/data/maps/permissions/challenge_machine_map_event_cgb.bin b/src/data/maps/permissions/challenge_machine_map_event_cgb.bin index 26b782d0..6decae2f 100644 Binary files a/src/data/maps/permissions/challenge_machine_map_event_cgb.bin and b/src/data/maps/permissions/challenge_machine_map_event_cgb.bin differ diff --git a/src/data/maps/permissions/club_lobby.bin b/src/data/maps/permissions/club_lobby.bin index f79c177e..058db94c 100644 Binary files a/src/data/maps/permissions/club_lobby.bin and b/src/data/maps/permissions/club_lobby.bin differ diff --git a/src/data/maps/permissions/club_lobby.bin.lz.match b/src/data/maps/permissions/club_lobby.bin.lz.match new file mode 100644 index 00000000..f79c177e Binary files /dev/null and b/src/data/maps/permissions/club_lobby.bin.lz.match differ diff --git a/src/data/maps/permissions/club_lobby_cgb.bin b/src/data/maps/permissions/club_lobby_cgb.bin index f79c177e..058db94c 100644 Binary files a/src/data/maps/permissions/club_lobby_cgb.bin and b/src/data/maps/permissions/club_lobby_cgb.bin differ diff --git a/src/data/maps/permissions/club_lobby_cgb.bin.lz.match b/src/data/maps/permissions/club_lobby_cgb.bin.lz.match new file mode 100644 index 00000000..f79c177e Binary files /dev/null and b/src/data/maps/permissions/club_lobby_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/deck_machine_map_event.bin b/src/data/maps/permissions/deck_machine_map_event.bin index 7f65eebd..f8834a2a 100644 --- a/src/data/maps/permissions/deck_machine_map_event.bin +++ b/src/data/maps/permissions/deck_machine_map_event.bin @@ -1 +1 @@ -À€€ \ No newline at end of file +€€ \ No newline at end of file diff --git a/src/data/maps/permissions/deck_machine_map_event_cgb.bin b/src/data/maps/permissions/deck_machine_map_event_cgb.bin index 7f65eebd..f8834a2a 100644 --- a/src/data/maps/permissions/deck_machine_map_event_cgb.bin +++ b/src/data/maps/permissions/deck_machine_map_event_cgb.bin @@ -1 +1 @@ -À€€ \ No newline at end of file +€€ \ No newline at end of file diff --git a/src/data/maps/permissions/deck_machine_room.bin b/src/data/maps/permissions/deck_machine_room.bin index d1c4beba..84f3e892 100644 Binary files a/src/data/maps/permissions/deck_machine_room.bin and b/src/data/maps/permissions/deck_machine_room.bin differ diff --git a/src/data/maps/permissions/deck_machine_room.bin.lz.match b/src/data/maps/permissions/deck_machine_room.bin.lz.match new file mode 100644 index 00000000..d1c4beba Binary files /dev/null and b/src/data/maps/permissions/deck_machine_room.bin.lz.match differ diff --git a/src/data/maps/permissions/deck_machine_room_cgb.bin b/src/data/maps/permissions/deck_machine_room_cgb.bin index d1c4beba..84f3e892 100644 Binary files a/src/data/maps/permissions/deck_machine_room_cgb.bin and b/src/data/maps/permissions/deck_machine_room_cgb.bin differ diff --git a/src/data/maps/permissions/deck_machine_room_cgb.bin.lz.match b/src/data/maps/permissions/deck_machine_room_cgb.bin.lz.match new file mode 100644 index 00000000..d1c4beba Binary files /dev/null and b/src/data/maps/permissions/deck_machine_room_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/fighting_club.bin b/src/data/maps/permissions/fighting_club.bin index 2b3f72fc..3f9bf0d4 100644 Binary files a/src/data/maps/permissions/fighting_club.bin and b/src/data/maps/permissions/fighting_club.bin differ diff --git a/src/data/maps/permissions/fighting_club.bin.lz.match b/src/data/maps/permissions/fighting_club.bin.lz.match new file mode 100644 index 00000000..2b3f72fc Binary files /dev/null and b/src/data/maps/permissions/fighting_club.bin.lz.match differ diff --git a/src/data/maps/permissions/fighting_club_cgb.bin b/src/data/maps/permissions/fighting_club_cgb.bin index 2b3f72fc..3f9bf0d4 100644 Binary files a/src/data/maps/permissions/fighting_club_cgb.bin and b/src/data/maps/permissions/fighting_club_cgb.bin differ diff --git a/src/data/maps/permissions/fighting_club_cgb.bin.lz.match b/src/data/maps/permissions/fighting_club_cgb.bin.lz.match new file mode 100644 index 00000000..2b3f72fc Binary files /dev/null and b/src/data/maps/permissions/fighting_club_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/fighting_club_entrance.bin b/src/data/maps/permissions/fighting_club_entrance.bin index 76a9ae13..c4590ec0 100644 Binary files a/src/data/maps/permissions/fighting_club_entrance.bin and b/src/data/maps/permissions/fighting_club_entrance.bin differ diff --git a/src/data/maps/permissions/fighting_club_entrance.bin.lz.match b/src/data/maps/permissions/fighting_club_entrance.bin.lz.match new file mode 100644 index 00000000..76a9ae13 Binary files /dev/null and b/src/data/maps/permissions/fighting_club_entrance.bin.lz.match differ diff --git a/src/data/maps/permissions/fighting_club_entrance_cgb.bin b/src/data/maps/permissions/fighting_club_entrance_cgb.bin index 76a9ae13..c4590ec0 100644 Binary files a/src/data/maps/permissions/fighting_club_entrance_cgb.bin and b/src/data/maps/permissions/fighting_club_entrance_cgb.bin differ diff --git a/src/data/maps/permissions/fighting_club_entrance_cgb.bin.lz.match b/src/data/maps/permissions/fighting_club_entrance_cgb.bin.lz.match new file mode 100644 index 00000000..76a9ae13 Binary files /dev/null and b/src/data/maps/permissions/fighting_club_entrance_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/fire_club.bin b/src/data/maps/permissions/fire_club.bin index e2b6e527..903ed171 100644 Binary files a/src/data/maps/permissions/fire_club.bin and b/src/data/maps/permissions/fire_club.bin differ diff --git a/src/data/maps/permissions/fire_club.bin.lz.match b/src/data/maps/permissions/fire_club.bin.lz.match new file mode 100644 index 00000000..e2b6e527 Binary files /dev/null and b/src/data/maps/permissions/fire_club.bin.lz.match differ diff --git a/src/data/maps/permissions/fire_club_cgb.bin b/src/data/maps/permissions/fire_club_cgb.bin index e2b6e527..903ed171 100644 Binary files a/src/data/maps/permissions/fire_club_cgb.bin and b/src/data/maps/permissions/fire_club_cgb.bin differ diff --git a/src/data/maps/permissions/fire_club_cgb.bin.lz.match b/src/data/maps/permissions/fire_club_cgb.bin.lz.match new file mode 100644 index 00000000..e2b6e527 Binary files /dev/null and b/src/data/maps/permissions/fire_club_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/fire_club_entrance.bin b/src/data/maps/permissions/fire_club_entrance.bin index 76a9ae13..c4590ec0 100644 Binary files a/src/data/maps/permissions/fire_club_entrance.bin and b/src/data/maps/permissions/fire_club_entrance.bin differ diff --git a/src/data/maps/permissions/fire_club_entrance.bin.lz.match b/src/data/maps/permissions/fire_club_entrance.bin.lz.match new file mode 100644 index 00000000..76a9ae13 Binary files /dev/null and b/src/data/maps/permissions/fire_club_entrance.bin.lz.match differ diff --git a/src/data/maps/permissions/fire_club_entrance_cgb.bin b/src/data/maps/permissions/fire_club_entrance_cgb.bin index 76a9ae13..c4590ec0 100644 Binary files a/src/data/maps/permissions/fire_club_entrance_cgb.bin and b/src/data/maps/permissions/fire_club_entrance_cgb.bin differ diff --git a/src/data/maps/permissions/fire_club_entrance_cgb.bin.lz.match b/src/data/maps/permissions/fire_club_entrance_cgb.bin.lz.match new file mode 100644 index 00000000..76a9ae13 Binary files /dev/null and b/src/data/maps/permissions/fire_club_entrance_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/grass_club.bin b/src/data/maps/permissions/grass_club.bin index dbe8ade4..46f87f05 100644 Binary files a/src/data/maps/permissions/grass_club.bin and b/src/data/maps/permissions/grass_club.bin differ diff --git a/src/data/maps/permissions/grass_club.bin.lz.match b/src/data/maps/permissions/grass_club.bin.lz.match new file mode 100644 index 00000000..dbe8ade4 Binary files /dev/null and b/src/data/maps/permissions/grass_club.bin.lz.match differ diff --git a/src/data/maps/permissions/grass_club_cgb.bin b/src/data/maps/permissions/grass_club_cgb.bin index dbe8ade4..46f87f05 100644 Binary files a/src/data/maps/permissions/grass_club_cgb.bin and b/src/data/maps/permissions/grass_club_cgb.bin differ diff --git a/src/data/maps/permissions/grass_club_cgb.bin.lz.match b/src/data/maps/permissions/grass_club_cgb.bin.lz.match new file mode 100644 index 00000000..dbe8ade4 Binary files /dev/null and b/src/data/maps/permissions/grass_club_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/grass_club_entrance.bin b/src/data/maps/permissions/grass_club_entrance.bin index 76a9ae13..c4590ec0 100644 Binary files a/src/data/maps/permissions/grass_club_entrance.bin and b/src/data/maps/permissions/grass_club_entrance.bin differ diff --git a/src/data/maps/permissions/grass_club_entrance.bin.lz.match b/src/data/maps/permissions/grass_club_entrance.bin.lz.match new file mode 100644 index 00000000..76a9ae13 Binary files /dev/null and b/src/data/maps/permissions/grass_club_entrance.bin.lz.match differ diff --git a/src/data/maps/permissions/grass_club_entrance_cgb.bin b/src/data/maps/permissions/grass_club_entrance_cgb.bin index 76a9ae13..c4590ec0 100644 Binary files a/src/data/maps/permissions/grass_club_entrance_cgb.bin and b/src/data/maps/permissions/grass_club_entrance_cgb.bin differ diff --git a/src/data/maps/permissions/grass_club_entrance_cgb.bin.lz.match b/src/data/maps/permissions/grass_club_entrance_cgb.bin.lz.match new file mode 100644 index 00000000..76a9ae13 Binary files /dev/null and b/src/data/maps/permissions/grass_club_entrance_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/hall_of_honor.bin b/src/data/maps/permissions/hall_of_honor.bin index a59ca31a..ffb2e92b 100644 Binary files a/src/data/maps/permissions/hall_of_honor.bin and b/src/data/maps/permissions/hall_of_honor.bin differ diff --git a/src/data/maps/permissions/hall_of_honor.bin.lz.match b/src/data/maps/permissions/hall_of_honor.bin.lz.match new file mode 100644 index 00000000..a59ca31a Binary files /dev/null and b/src/data/maps/permissions/hall_of_honor.bin.lz.match differ diff --git a/src/data/maps/permissions/hall_of_honor_cgb.bin b/src/data/maps/permissions/hall_of_honor_cgb.bin index a59ca31a..ffb2e92b 100644 Binary files a/src/data/maps/permissions/hall_of_honor_cgb.bin and b/src/data/maps/permissions/hall_of_honor_cgb.bin differ diff --git a/src/data/maps/permissions/hall_of_honor_cgb.bin.lz.match b/src/data/maps/permissions/hall_of_honor_cgb.bin.lz.match new file mode 100644 index 00000000..a59ca31a Binary files /dev/null and b/src/data/maps/permissions/hall_of_honor_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/hall_of_honor_door_map_event.bin b/src/data/maps/permissions/hall_of_honor_door_map_event.bin index 10bc8dac..593f4708 100644 Binary files a/src/data/maps/permissions/hall_of_honor_door_map_event.bin and b/src/data/maps/permissions/hall_of_honor_door_map_event.bin differ diff --git a/src/data/maps/permissions/hall_of_honor_door_map_event_cgb.bin b/src/data/maps/permissions/hall_of_honor_door_map_event_cgb.bin index 10bc8dac..593f4708 100644 Binary files a/src/data/maps/permissions/hall_of_honor_door_map_event_cgb.bin and b/src/data/maps/permissions/hall_of_honor_door_map_event_cgb.bin differ diff --git a/src/data/maps/permissions/ishihara.bin b/src/data/maps/permissions/ishihara.bin index c1b17c26..641a3712 100644 Binary files a/src/data/maps/permissions/ishihara.bin and b/src/data/maps/permissions/ishihara.bin differ diff --git a/src/data/maps/permissions/ishihara.bin.lz.match b/src/data/maps/permissions/ishihara.bin.lz.match new file mode 100644 index 00000000..c1b17c26 Binary files /dev/null and b/src/data/maps/permissions/ishihara.bin.lz.match differ diff --git a/src/data/maps/permissions/ishihara_cgb.bin b/src/data/maps/permissions/ishihara_cgb.bin index c1b17c26..641a3712 100644 Binary files a/src/data/maps/permissions/ishihara_cgb.bin and b/src/data/maps/permissions/ishihara_cgb.bin differ diff --git a/src/data/maps/permissions/ishihara_cgb.bin.lz.match b/src/data/maps/permissions/ishihara_cgb.bin.lz.match new file mode 100644 index 00000000..c1b17c26 Binary files /dev/null and b/src/data/maps/permissions/ishihara_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/lightning_club.bin b/src/data/maps/permissions/lightning_club.bin index 20d4b9f8..f2a87dfa 100644 Binary files a/src/data/maps/permissions/lightning_club.bin and b/src/data/maps/permissions/lightning_club.bin differ diff --git a/src/data/maps/permissions/lightning_club.bin.lz.match b/src/data/maps/permissions/lightning_club.bin.lz.match new file mode 100644 index 00000000..20d4b9f8 Binary files /dev/null and b/src/data/maps/permissions/lightning_club.bin.lz.match differ diff --git a/src/data/maps/permissions/lightning_club_cgb.bin b/src/data/maps/permissions/lightning_club_cgb.bin index 20d4b9f8..f2a87dfa 100644 Binary files a/src/data/maps/permissions/lightning_club_cgb.bin and b/src/data/maps/permissions/lightning_club_cgb.bin differ diff --git a/src/data/maps/permissions/lightning_club_cgb.bin.lz.match b/src/data/maps/permissions/lightning_club_cgb.bin.lz.match new file mode 100644 index 00000000..20d4b9f8 Binary files /dev/null and b/src/data/maps/permissions/lightning_club_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/lightning_club_entrance.bin b/src/data/maps/permissions/lightning_club_entrance.bin index 76a9ae13..c4590ec0 100644 Binary files a/src/data/maps/permissions/lightning_club_entrance.bin and b/src/data/maps/permissions/lightning_club_entrance.bin differ diff --git a/src/data/maps/permissions/lightning_club_entrance.bin.lz.match b/src/data/maps/permissions/lightning_club_entrance.bin.lz.match new file mode 100644 index 00000000..76a9ae13 Binary files /dev/null and b/src/data/maps/permissions/lightning_club_entrance.bin.lz.match differ diff --git a/src/data/maps/permissions/lightning_club_entrance_cgb.bin b/src/data/maps/permissions/lightning_club_entrance_cgb.bin index 76a9ae13..c4590ec0 100644 Binary files a/src/data/maps/permissions/lightning_club_entrance_cgb.bin and b/src/data/maps/permissions/lightning_club_entrance_cgb.bin differ diff --git a/src/data/maps/permissions/lightning_club_entrance_cgb.bin.lz.match b/src/data/maps/permissions/lightning_club_entrance_cgb.bin.lz.match new file mode 100644 index 00000000..76a9ae13 Binary files /dev/null and b/src/data/maps/permissions/lightning_club_entrance_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/mason_laboratory.bin b/src/data/maps/permissions/mason_laboratory.bin index e19760c0..39f0936a 100644 Binary files a/src/data/maps/permissions/mason_laboratory.bin and b/src/data/maps/permissions/mason_laboratory.bin differ diff --git a/src/data/maps/permissions/mason_laboratory.bin.lz.match b/src/data/maps/permissions/mason_laboratory.bin.lz.match new file mode 100644 index 00000000..e19760c0 Binary files /dev/null and b/src/data/maps/permissions/mason_laboratory.bin.lz.match differ diff --git a/src/data/maps/permissions/mason_laboratory_cgb.bin b/src/data/maps/permissions/mason_laboratory_cgb.bin index e19760c0..39f0936a 100644 Binary files a/src/data/maps/permissions/mason_laboratory_cgb.bin and b/src/data/maps/permissions/mason_laboratory_cgb.bin differ diff --git a/src/data/maps/permissions/mason_laboratory_cgb.bin.lz.match b/src/data/maps/permissions/mason_laboratory_cgb.bin.lz.match new file mode 100644 index 00000000..e19760c0 Binary files /dev/null and b/src/data/maps/permissions/mason_laboratory_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/pokemon_dome.bin b/src/data/maps/permissions/pokemon_dome.bin index 4640de50..e34666f5 100644 Binary files a/src/data/maps/permissions/pokemon_dome.bin and b/src/data/maps/permissions/pokemon_dome.bin differ diff --git a/src/data/maps/permissions/pokemon_dome.bin.lz.match b/src/data/maps/permissions/pokemon_dome.bin.lz.match new file mode 100644 index 00000000..4640de50 Binary files /dev/null and b/src/data/maps/permissions/pokemon_dome.bin.lz.match differ diff --git a/src/data/maps/permissions/pokemon_dome_cgb.bin b/src/data/maps/permissions/pokemon_dome_cgb.bin index 4640de50..e34666f5 100644 Binary files a/src/data/maps/permissions/pokemon_dome_cgb.bin and b/src/data/maps/permissions/pokemon_dome_cgb.bin differ diff --git a/src/data/maps/permissions/pokemon_dome_cgb.bin.lz.match b/src/data/maps/permissions/pokemon_dome_cgb.bin.lz.match new file mode 100644 index 00000000..4640de50 Binary files /dev/null and b/src/data/maps/permissions/pokemon_dome_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/pokemon_dome_door_map_event.bin b/src/data/maps/permissions/pokemon_dome_door_map_event.bin index 10bc8dac..593f4708 100644 Binary files a/src/data/maps/permissions/pokemon_dome_door_map_event.bin and b/src/data/maps/permissions/pokemon_dome_door_map_event.bin differ diff --git a/src/data/maps/permissions/pokemon_dome_door_map_event_cgb.bin b/src/data/maps/permissions/pokemon_dome_door_map_event_cgb.bin index 10bc8dac..593f4708 100644 Binary files a/src/data/maps/permissions/pokemon_dome_door_map_event_cgb.bin and b/src/data/maps/permissions/pokemon_dome_door_map_event_cgb.bin differ diff --git a/src/data/maps/permissions/pokemon_dome_entrance.bin b/src/data/maps/permissions/pokemon_dome_entrance.bin index f5fab0cf..fbbbf412 100644 Binary files a/src/data/maps/permissions/pokemon_dome_entrance.bin and b/src/data/maps/permissions/pokemon_dome_entrance.bin differ diff --git a/src/data/maps/permissions/pokemon_dome_entrance.bin.lz.match b/src/data/maps/permissions/pokemon_dome_entrance.bin.lz.match new file mode 100644 index 00000000..f5fab0cf Binary files /dev/null and b/src/data/maps/permissions/pokemon_dome_entrance.bin.lz.match differ diff --git a/src/data/maps/permissions/pokemon_dome_entrance_cgb.bin b/src/data/maps/permissions/pokemon_dome_entrance_cgb.bin index f5fab0cf..fbbbf412 100644 Binary files a/src/data/maps/permissions/pokemon_dome_entrance_cgb.bin and b/src/data/maps/permissions/pokemon_dome_entrance_cgb.bin differ diff --git a/src/data/maps/permissions/pokemon_dome_entrance_cgb.bin.lz.match b/src/data/maps/permissions/pokemon_dome_entrance_cgb.bin.lz.match new file mode 100644 index 00000000..f5fab0cf Binary files /dev/null and b/src/data/maps/permissions/pokemon_dome_entrance_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/psychic_club.bin b/src/data/maps/permissions/psychic_club.bin index 60ec1cba..3cf3248c 100644 Binary files a/src/data/maps/permissions/psychic_club.bin and b/src/data/maps/permissions/psychic_club.bin differ diff --git a/src/data/maps/permissions/psychic_club.bin.lz.match b/src/data/maps/permissions/psychic_club.bin.lz.match new file mode 100644 index 00000000..60ec1cba Binary files /dev/null and b/src/data/maps/permissions/psychic_club.bin.lz.match differ diff --git a/src/data/maps/permissions/psychic_club_cgb.bin b/src/data/maps/permissions/psychic_club_cgb.bin index 60ec1cba..3cf3248c 100644 Binary files a/src/data/maps/permissions/psychic_club_cgb.bin and b/src/data/maps/permissions/psychic_club_cgb.bin differ diff --git a/src/data/maps/permissions/psychic_club_cgb.bin.lz.match b/src/data/maps/permissions/psychic_club_cgb.bin.lz.match new file mode 100644 index 00000000..60ec1cba Binary files /dev/null and b/src/data/maps/permissions/psychic_club_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/psychic_club_entrance.bin b/src/data/maps/permissions/psychic_club_entrance.bin index 76a9ae13..c4590ec0 100644 Binary files a/src/data/maps/permissions/psychic_club_entrance.bin and b/src/data/maps/permissions/psychic_club_entrance.bin differ diff --git a/src/data/maps/permissions/psychic_club_entrance.bin.lz.match b/src/data/maps/permissions/psychic_club_entrance.bin.lz.match new file mode 100644 index 00000000..76a9ae13 Binary files /dev/null and b/src/data/maps/permissions/psychic_club_entrance.bin.lz.match differ diff --git a/src/data/maps/permissions/psychic_club_entrance_cgb.bin b/src/data/maps/permissions/psychic_club_entrance_cgb.bin index 76a9ae13..c4590ec0 100644 Binary files a/src/data/maps/permissions/psychic_club_entrance_cgb.bin and b/src/data/maps/permissions/psychic_club_entrance_cgb.bin differ diff --git a/src/data/maps/permissions/psychic_club_entrance_cgb.bin.lz.match b/src/data/maps/permissions/psychic_club_entrance_cgb.bin.lz.match new file mode 100644 index 00000000..76a9ae13 Binary files /dev/null and b/src/data/maps/permissions/psychic_club_entrance_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/rock_club.bin b/src/data/maps/permissions/rock_club.bin index 67977046..890a11cc 100644 Binary files a/src/data/maps/permissions/rock_club.bin and b/src/data/maps/permissions/rock_club.bin differ diff --git a/src/data/maps/permissions/rock_club.bin.lz.match b/src/data/maps/permissions/rock_club.bin.lz.match new file mode 100644 index 00000000..67977046 Binary files /dev/null and b/src/data/maps/permissions/rock_club.bin.lz.match differ diff --git a/src/data/maps/permissions/rock_club_cgb.bin b/src/data/maps/permissions/rock_club_cgb.bin index 67977046..890a11cc 100644 Binary files a/src/data/maps/permissions/rock_club_cgb.bin and b/src/data/maps/permissions/rock_club_cgb.bin differ diff --git a/src/data/maps/permissions/rock_club_cgb.bin.lz.match b/src/data/maps/permissions/rock_club_cgb.bin.lz.match new file mode 100644 index 00000000..67977046 Binary files /dev/null and b/src/data/maps/permissions/rock_club_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/rock_club_entrance.bin b/src/data/maps/permissions/rock_club_entrance.bin index 76a9ae13..c4590ec0 100644 Binary files a/src/data/maps/permissions/rock_club_entrance.bin and b/src/data/maps/permissions/rock_club_entrance.bin differ diff --git a/src/data/maps/permissions/rock_club_entrance.bin.lz.match b/src/data/maps/permissions/rock_club_entrance.bin.lz.match new file mode 100644 index 00000000..76a9ae13 Binary files /dev/null and b/src/data/maps/permissions/rock_club_entrance.bin.lz.match differ diff --git a/src/data/maps/permissions/rock_club_entrance_cgb.bin b/src/data/maps/permissions/rock_club_entrance_cgb.bin index 76a9ae13..c4590ec0 100644 Binary files a/src/data/maps/permissions/rock_club_entrance_cgb.bin and b/src/data/maps/permissions/rock_club_entrance_cgb.bin differ diff --git a/src/data/maps/permissions/rock_club_entrance_cgb.bin.lz.match b/src/data/maps/permissions/rock_club_entrance_cgb.bin.lz.match new file mode 100644 index 00000000..76a9ae13 Binary files /dev/null and b/src/data/maps/permissions/rock_club_entrance_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/science_club.bin b/src/data/maps/permissions/science_club.bin index 66ccc024..4a3f1e52 100644 Binary files a/src/data/maps/permissions/science_club.bin and b/src/data/maps/permissions/science_club.bin differ diff --git a/src/data/maps/permissions/science_club.bin.lz.match b/src/data/maps/permissions/science_club.bin.lz.match new file mode 100644 index 00000000..66ccc024 Binary files /dev/null and b/src/data/maps/permissions/science_club.bin.lz.match differ diff --git a/src/data/maps/permissions/science_club_cgb.bin b/src/data/maps/permissions/science_club_cgb.bin index 66ccc024..4a3f1e52 100644 Binary files a/src/data/maps/permissions/science_club_cgb.bin and b/src/data/maps/permissions/science_club_cgb.bin differ diff --git a/src/data/maps/permissions/science_club_cgb.bin.lz.match b/src/data/maps/permissions/science_club_cgb.bin.lz.match new file mode 100644 index 00000000..66ccc024 Binary files /dev/null and b/src/data/maps/permissions/science_club_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/science_club_entrance.bin b/src/data/maps/permissions/science_club_entrance.bin index 76a9ae13..c4590ec0 100644 Binary files a/src/data/maps/permissions/science_club_entrance.bin and b/src/data/maps/permissions/science_club_entrance.bin differ diff --git a/src/data/maps/permissions/science_club_entrance.bin.lz.match b/src/data/maps/permissions/science_club_entrance.bin.lz.match new file mode 100644 index 00000000..76a9ae13 Binary files /dev/null and b/src/data/maps/permissions/science_club_entrance.bin.lz.match differ diff --git a/src/data/maps/permissions/science_club_entrance_cgb.bin b/src/data/maps/permissions/science_club_entrance_cgb.bin index 76a9ae13..c4590ec0 100644 Binary files a/src/data/maps/permissions/science_club_entrance_cgb.bin and b/src/data/maps/permissions/science_club_entrance_cgb.bin differ diff --git a/src/data/maps/permissions/science_club_entrance_cgb.bin.lz.match b/src/data/maps/permissions/science_club_entrance_cgb.bin.lz.match new file mode 100644 index 00000000..76a9ae13 Binary files /dev/null and b/src/data/maps/permissions/science_club_entrance_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/water_club.bin b/src/data/maps/permissions/water_club.bin index ca1332de..62bc0d59 100644 Binary files a/src/data/maps/permissions/water_club.bin and b/src/data/maps/permissions/water_club.bin differ diff --git a/src/data/maps/permissions/water_club.bin.lz.match b/src/data/maps/permissions/water_club.bin.lz.match new file mode 100644 index 00000000..ca1332de Binary files /dev/null and b/src/data/maps/permissions/water_club.bin.lz.match differ diff --git a/src/data/maps/permissions/water_club_cgb.bin b/src/data/maps/permissions/water_club_cgb.bin index ca1332de..62bc0d59 100644 Binary files a/src/data/maps/permissions/water_club_cgb.bin and b/src/data/maps/permissions/water_club_cgb.bin differ diff --git a/src/data/maps/permissions/water_club_cgb.bin.lz.match b/src/data/maps/permissions/water_club_cgb.bin.lz.match new file mode 100644 index 00000000..ca1332de Binary files /dev/null and b/src/data/maps/permissions/water_club_cgb.bin.lz.match differ diff --git a/src/data/maps/permissions/water_club_entrance.bin b/src/data/maps/permissions/water_club_entrance.bin index 76a9ae13..c4590ec0 100644 Binary files a/src/data/maps/permissions/water_club_entrance.bin and b/src/data/maps/permissions/water_club_entrance.bin differ diff --git a/src/data/maps/permissions/water_club_entrance.bin.lz.match b/src/data/maps/permissions/water_club_entrance.bin.lz.match new file mode 100644 index 00000000..76a9ae13 Binary files /dev/null and b/src/data/maps/permissions/water_club_entrance.bin.lz.match differ diff --git a/src/data/maps/permissions/water_club_entrance_cgb.bin b/src/data/maps/permissions/water_club_entrance_cgb.bin index 76a9ae13..c4590ec0 100644 Binary files a/src/data/maps/permissions/water_club_entrance_cgb.bin and b/src/data/maps/permissions/water_club_entrance_cgb.bin differ diff --git a/src/data/maps/permissions/water_club_entrance_cgb.bin.lz.match b/src/data/maps/permissions/water_club_entrance_cgb.bin.lz.match new file mode 100644 index 00000000..76a9ae13 Binary files /dev/null and b/src/data/maps/permissions/water_club_entrance_cgb.bin.lz.match differ diff --git a/src/data/maps/tilemaps.asm b/src/data/maps/tilemaps.asm index bf666367..31fbf6ed 100644 --- a/src/data/maps/tilemaps.asm +++ b/src/data/maps/tilemaps.asm @@ -3,363 +3,363 @@ OverworldMapTilemap:: db $12 ; height dw NULL db FALSE ; cgb mode - INCBIN "data/maps/tiles/overworld_map.bin" + INCBIN "data/maps/tiles/overworld_map.bin.lz" OverworldMapCGBTilemap:: db $14 ; width db $12 ; height dw NULL db TRUE ; cgb mode - INCBIN "data/maps/tiles/overworld_map_cgb.bin" + INCBIN "data/maps/tiles/overworld_map_cgb.bin.lz" MasonLaboratoryTilemap:: db $1c ; width db $1e ; height dw MasonLaboratoryPermissions db FALSE ; cgb mode - INCBIN "data/maps/tiles/mason_laboratory.bin" + INCBIN "data/maps/tiles/mason_laboratory.bin.lz" MasonLaboratoryPermissions: - INCBIN "data/maps/permissions/mason_laboratory.bin" + INCBIN "data/maps/permissions/mason_laboratory.bin.lz" MasonLaboratoryCGBTilemap:: db $1c ; width db $1e ; height dw MasonLaboratoryCGBPermissions db TRUE ; cgb mode - INCBIN "data/maps/tiles/mason_laboratory_cgb.bin" + INCBIN "data/maps/tiles/mason_laboratory_cgb.bin.lz" MasonLaboratoryCGBPermissions: - INCBIN "data/maps/permissions/mason_laboratory_cgb.bin" + INCBIN "data/maps/permissions/mason_laboratory_cgb.bin.lz" ChallengeMachineMapEventTilemap:: db $04 ; width db $06 ; height dw ChallengeMachineMapEventPermissions db FALSE ; cgb mode - INCBIN "data/maps/tiles/challenge_machine_map_event.bin" + INCBIN "data/maps/tiles/challenge_machine_map_event.bin.lz" ChallengeMachineMapEventPermissions: - INCBIN "data/maps/permissions/challenge_machine_map_event.bin" + INCBIN "data/maps/permissions/challenge_machine_map_event.bin.lz" ChallengeMachineMapEventCGBTilemap:: db $04 ; width db $06 ; height dw ChallengeMachineMapEventCGBPermissions db TRUE ; cgb mode - INCBIN "data/maps/tiles/challenge_machine_map_event_cgb.bin" + INCBIN "data/maps/tiles/challenge_machine_map_event_cgb.bin.lz" ChallengeMachineMapEventCGBPermissions: - INCBIN "data/maps/permissions/challenge_machine_map_event_cgb.bin" + INCBIN "data/maps/permissions/challenge_machine_map_event_cgb.bin.lz" DeckMachineRoomTilemap:: db $18 ; width db $1e ; height dw DeckMachineRoomPermissions db FALSE ; cgb mode - INCBIN "data/maps/tiles/deck_machine_room.bin" + INCBIN "data/maps/tiles/deck_machine_room.bin.lz" DeckMachineRoomPermissions: - INCBIN "data/maps/permissions/deck_machine_room.bin" + INCBIN "data/maps/permissions/deck_machine_room.bin.lz" DeckMachineRoomCGBTilemap:: db $18 ; width db $1e ; height dw DeckMachineRoomCGBPermissions db TRUE ; cgb mode - INCBIN "data/maps/tiles/deck_machine_room_cgb.bin" + INCBIN "data/maps/tiles/deck_machine_room_cgb.bin.lz" DeckMachineRoomCGBPermissions: - INCBIN "data/maps/permissions/deck_machine_room_cgb.bin" + INCBIN "data/maps/permissions/deck_machine_room_cgb.bin.lz" DeckMachineMapEventTilemap:: db $04 ; width db $01 ; height dw DeckMachineMapEventPermissions db FALSE ; cgb mode - INCBIN "data/maps/tiles/deck_machine_map_event.bin" + INCBIN "data/maps/tiles/deck_machine_map_event.bin.lz" DeckMachineMapEventPermissions: - INCBIN "data/maps/permissions/deck_machine_map_event.bin" + INCBIN "data/maps/permissions/deck_machine_map_event.bin.lz" DeckMachineMapEventCGBTilemap:: db $04 ; width db $01 ; height dw DeckMachineMapEventCGBPermissions db TRUE ; cgb mode - INCBIN "data/maps/tiles/deck_machine_map_event_cgb.bin" + INCBIN "data/maps/tiles/deck_machine_map_event_cgb.bin.lz" DeckMachineMapEventCGBPermissions: - INCBIN "data/maps/permissions/deck_machine_map_event_cgb.bin" + INCBIN "data/maps/permissions/deck_machine_map_event_cgb.bin.lz" IshiharaTilemap:: db $14 ; width db $18 ; height dw IshiharaPermissions db FALSE ; cgb mode - INCBIN "data/maps/tiles/ishihara.bin" + INCBIN "data/maps/tiles/ishihara.bin.lz" IshiharaPermissions: - INCBIN "data/maps/permissions/ishihara.bin" + INCBIN "data/maps/permissions/ishihara.bin.lz" IshiharaCGBTilemap:: db $14 ; width db $18 ; height dw IshiharaCGBPermissions db TRUE ; cgb mode - INCBIN "data/maps/tiles/ishihara_cgb.bin" + INCBIN "data/maps/tiles/ishihara_cgb.bin.lz" IshiharaCGBPermissions: - INCBIN "data/maps/permissions/ishihara_cgb.bin" + INCBIN "data/maps/permissions/ishihara_cgb.bin.lz" FightingClubEntranceTilemap:: db $14 ; width db $12 ; height dw FightingClubEntrancePermissions db FALSE ; cgb mode - INCBIN "data/maps/tiles/fighting_club_entrance.bin" + INCBIN "data/maps/tiles/fighting_club_entrance.bin.lz" FightingClubEntrancePermissions: - INCBIN "data/maps/permissions/fighting_club_entrance.bin" + INCBIN "data/maps/permissions/fighting_club_entrance.bin.lz" FightingClubEntranceCGBTilemap:: db $14 ; width db $12 ; height dw FightingClubEntranceCGBPermissions db TRUE ; cgb mode - INCBIN "data/maps/tiles/fighting_club_entrance_cgb.bin" + INCBIN "data/maps/tiles/fighting_club_entrance_cgb.bin.lz" FightingClubEntranceCGBPermissions: - INCBIN "data/maps/permissions/fighting_club_entrance_cgb.bin" + INCBIN "data/maps/permissions/fighting_club_entrance_cgb.bin.lz" RockClubEntranceTilemap:: db $14 ; width db $12 ; height dw RockClubEntrancePermissions db FALSE ; cgb mode - INCBIN "data/maps/tiles/rock_club_entrance.bin" + INCBIN "data/maps/tiles/rock_club_entrance.bin.lz" RockClubEntrancePermissions: - INCBIN "data/maps/permissions/rock_club_entrance.bin" + INCBIN "data/maps/permissions/rock_club_entrance.bin.lz" RockClubEntranceCGBTilemap:: db $14 ; width db $12 ; height dw RockClubEntranceCGBPermissions db TRUE ; cgb mode - INCBIN "data/maps/tiles/rock_club_entrance_cgb.bin" + INCBIN "data/maps/tiles/rock_club_entrance_cgb.bin.lz" RockClubEntranceCGBPermissions: - INCBIN "data/maps/permissions/rock_club_entrance_cgb.bin" + INCBIN "data/maps/permissions/rock_club_entrance_cgb.bin.lz" WaterClubEntranceTilemap:: db $14 ; width db $12 ; height dw WaterClubEntrancePermissions db FALSE ; cgb mode - INCBIN "data/maps/tiles/water_club_entrance.bin" + INCBIN "data/maps/tiles/water_club_entrance.bin.lz" WaterClubEntrancePermissions: - INCBIN "data/maps/permissions/water_club_entrance.bin" + INCBIN "data/maps/permissions/water_club_entrance.bin.lz" WaterClubEntranceCGBTilemap:: db $14 ; width db $12 ; height dw WaterClubEntranceCGBPermissions db TRUE ; cgb mode - INCBIN "data/maps/tiles/water_club_entrance_cgb.bin" + INCBIN "data/maps/tiles/water_club_entrance_cgb.bin.lz" WaterClubEntranceCGBPermissions: - INCBIN "data/maps/permissions/water_club_entrance_cgb.bin" + INCBIN "data/maps/permissions/water_club_entrance_cgb.bin.lz" LightningClubEntranceTilemap:: db $14 ; width db $12 ; height dw LightningClubEntrancePermissions db FALSE ; cgb mode - INCBIN "data/maps/tiles/lightning_club_entrance.bin" + INCBIN "data/maps/tiles/lightning_club_entrance.bin.lz" LightningClubEntrancePermissions: - INCBIN "data/maps/permissions/lightning_club_entrance.bin" + INCBIN "data/maps/permissions/lightning_club_entrance.bin.lz" LightningClubEntranceCGBTilemap:: db $14 ; width db $12 ; height dw LightningClubEntranceCGBPermissions db TRUE ; cgb mode - INCBIN "data/maps/tiles/lightning_club_entrance_cgb.bin" + INCBIN "data/maps/tiles/lightning_club_entrance_cgb.bin.lz" LightningClubEntranceCGBPermissions: - INCBIN "data/maps/permissions/lightning_club_entrance_cgb.bin" + INCBIN "data/maps/permissions/lightning_club_entrance_cgb.bin.lz" GrassClubEntranceTilemap:: db $14 ; width db $12 ; height dw GrassClubEntrancePermissions db FALSE ; cgb mode - INCBIN "data/maps/tiles/grass_club_entrance.bin" + INCBIN "data/maps/tiles/grass_club_entrance.bin.lz" GrassClubEntrancePermissions: - INCBIN "data/maps/permissions/grass_club_entrance.bin" + INCBIN "data/maps/permissions/grass_club_entrance.bin.lz" GrassClubEntranceCGBTilemap:: db $14 ; width db $12 ; height dw GrassClubEntranceCGBPermissions db TRUE ; cgb mode - INCBIN "data/maps/tiles/grass_club_entrance_cgb.bin" + INCBIN "data/maps/tiles/grass_club_entrance_cgb.bin.lz" GrassClubEntranceCGBPermissions: - INCBIN "data/maps/permissions/grass_club_entrance_cgb.bin" + INCBIN "data/maps/permissions/grass_club_entrance_cgb.bin.lz" PsychicClubEntranceTilemap:: db $14 ; width db $12 ; height dw PsychicClubEntrancePermissions db FALSE ; cgb mode - INCBIN "data/maps/tiles/psychic_club_entrance.bin" + INCBIN "data/maps/tiles/psychic_club_entrance.bin.lz" PsychicClubEntrancePermissions: - INCBIN "data/maps/permissions/psychic_club_entrance.bin" + INCBIN "data/maps/permissions/psychic_club_entrance.bin.lz" PsychicClubEntranceCGBTilemap:: db $14 ; width db $12 ; height dw PsychicClubEntranceCGBPermissions db TRUE ; cgb mode - INCBIN "data/maps/tiles/psychic_club_entrance_cgb.bin" + INCBIN "data/maps/tiles/psychic_club_entrance_cgb.bin.lz" PsychicClubEntranceCGBPermissions: - INCBIN "data/maps/permissions/psychic_club_entrance_cgb.bin" + INCBIN "data/maps/permissions/psychic_club_entrance_cgb.bin.lz" ScienceClubEntranceTilemap:: db $14 ; width db $12 ; height dw ScienceClubEntrancePermissions db FALSE ; cgb mode - INCBIN "data/maps/tiles/science_club_entrance.bin" + INCBIN "data/maps/tiles/science_club_entrance.bin.lz" ScienceClubEntrancePermissions: - INCBIN "data/maps/permissions/science_club_entrance.bin" + INCBIN "data/maps/permissions/science_club_entrance.bin.lz" ScienceClubEntranceCGBTilemap:: db $14 ; width db $12 ; height dw ScienceClubEntranceCGBPermissions db TRUE ; cgb mode - INCBIN "data/maps/tiles/science_club_entrance_cgb.bin" + INCBIN "data/maps/tiles/science_club_entrance_cgb.bin.lz" ScienceClubEntranceCGBPermissions: - INCBIN "data/maps/permissions/science_club_entrance_cgb.bin" + INCBIN "data/maps/permissions/science_club_entrance_cgb.bin.lz" FireClubEntranceTilemap:: db $14 ; width db $12 ; height dw FireClubEntrancePermissions db FALSE ; cgb mode - INCBIN "data/maps/tiles/fire_club_entrance.bin" + INCBIN "data/maps/tiles/fire_club_entrance.bin.lz" FireClubEntrancePermissions: - INCBIN "data/maps/permissions/fire_club_entrance.bin" + INCBIN "data/maps/permissions/fire_club_entrance.bin.lz" FireClubEntranceCGBTilemap:: db $14 ; width db $12 ; height dw FireClubEntranceCGBPermissions db TRUE ; cgb mode - INCBIN "data/maps/tiles/fire_club_entrance_cgb.bin" + INCBIN "data/maps/tiles/fire_club_entrance_cgb.bin.lz" FireClubEntranceCGBPermissions: - INCBIN "data/maps/permissions/fire_club_entrance_cgb.bin" + INCBIN "data/maps/permissions/fire_club_entrance_cgb.bin.lz" ChallengeHallEntranceTilemap:: db $14 ; width db $12 ; height dw ChallengeHallEntrancePermissions db FALSE ; cgb mode - INCBIN "data/maps/tiles/challenge_hall_entrance.bin" + INCBIN "data/maps/tiles/challenge_hall_entrance.bin.lz" ChallengeHallEntrancePermissions: - INCBIN "data/maps/permissions/challenge_hall_entrance.bin" + INCBIN "data/maps/permissions/challenge_hall_entrance.bin.lz" ChallengeHallEntranceCGBTilemap:: db $14 ; width db $12 ; height dw ChallengeHallEntranceCGBPermissions db TRUE ; cgb mode - INCBIN "data/maps/tiles/challenge_hall_entrance_cgb.bin" + INCBIN "data/maps/tiles/challenge_hall_entrance_cgb.bin.lz" ChallengeHallEntranceCGBPermissions: - INCBIN "data/maps/permissions/challenge_hall_entrance_cgb.bin" + INCBIN "data/maps/permissions/challenge_hall_entrance_cgb.bin.lz" ClubLobbyTilemap:: db $1c ; width db $1a ; height dw ClubLobbyPermissions db FALSE ; cgb mode - INCBIN "data/maps/tiles/club_lobby.bin" + INCBIN "data/maps/tiles/club_lobby.bin.lz" ClubLobbyPermissions: - INCBIN "data/maps/permissions/club_lobby.bin" + INCBIN "data/maps/permissions/club_lobby.bin.lz" ClubLobbyCGBTilemap:: db $1c ; width db $1a ; height dw ClubLobbyCGBPermissions db TRUE ; cgb mode - INCBIN "data/maps/tiles/club_lobby_cgb.bin" + INCBIN "data/maps/tiles/club_lobby_cgb.bin.lz" ClubLobbyCGBPermissions: - INCBIN "data/maps/permissions/club_lobby_cgb.bin" + INCBIN "data/maps/permissions/club_lobby_cgb.bin.lz" FightingClubTilemap:: db $18 ; width db $12 ; height dw FightingClubPermissions db FALSE ; cgb mode - INCBIN "data/maps/tiles/fighting_club.bin" + INCBIN "data/maps/tiles/fighting_club.bin.lz" FightingClubPermissions: - INCBIN "data/maps/permissions/fighting_club.bin" + INCBIN "data/maps/permissions/fighting_club.bin.lz" FightingClubCGBTilemap:: db $18 ; width db $12 ; height dw FightingClubCGBPermissions db TRUE ; cgb mode - INCBIN "data/maps/tiles/fighting_club_cgb.bin" + INCBIN "data/maps/tiles/fighting_club_cgb.bin.lz" FightingClubCGBPermissions: - INCBIN "data/maps/permissions/fighting_club_cgb.bin" + INCBIN "data/maps/permissions/fighting_club_cgb.bin.lz" RockClubTilemap:: db $1c ; width db $1e ; height dw RockClubPermissions db FALSE ; cgb mode - INCBIN "data/maps/tiles/rock_club.bin" + INCBIN "data/maps/tiles/rock_club.bin.lz" RockClubPermissions: - INCBIN "data/maps/permissions/rock_club.bin" + INCBIN "data/maps/permissions/rock_club.bin.lz" RockClubCGBTilemap:: db $1c ; width db $1e ; height dw RockClubCGBPermissions db TRUE ; cgb mode - INCBIN "data/maps/tiles/rock_club_cgb.bin" + INCBIN "data/maps/tiles/rock_club_cgb.bin.lz" RockClubCGBPermissions: - INCBIN "data/maps/permissions/rock_club_cgb.bin" + INCBIN "data/maps/permissions/rock_club_cgb.bin.lz" PokemonDomeDoorMapEventTilemap:: db $04 ; width db $03 ; height dw PokemonDomeDoorMapEventPermissions db FALSE ; cgb mode - INCBIN "data/maps/tiles/pokemon_dome_door_map_event.bin" + INCBIN "data/maps/tiles/pokemon_dome_door_map_event.bin.lz" PokemonDomeDoorMapEventPermissions: - INCBIN "data/maps/permissions/pokemon_dome_door_map_event.bin" + INCBIN "data/maps/permissions/pokemon_dome_door_map_event.bin.lz" PokemonDomeDoorMapEventCGBTilemap:: db $04 ; width db $03 ; height dw PokemonDomeDoorMapEventCGBPermissions db TRUE ; cgb mode - INCBIN "data/maps/tiles/pokemon_dome_door_map_event_cgb.bin" + INCBIN "data/maps/tiles/pokemon_dome_door_map_event_cgb.bin.lz" PokemonDomeDoorMapEventCGBPermissions: - INCBIN "data/maps/permissions/pokemon_dome_door_map_event_cgb.bin" + INCBIN "data/maps/permissions/pokemon_dome_door_map_event_cgb.bin.lz" HallOfHonorDoorMapEventTilemap:: db $04 ; width db $03 ; height dw HallOfHonorDoorMapEventPermissions db FALSE ; cgb mode - INCBIN "data/maps/tiles/hall_of_honor_door_map_event.bin" + INCBIN "data/maps/tiles/hall_of_honor_door_map_event.bin.lz" HallOfHonorDoorMapEventPermissions: - INCBIN "data/maps/permissions/hall_of_honor_door_map_event.bin" + INCBIN "data/maps/permissions/hall_of_honor_door_map_event.bin.lz" HallOfHonorDoorMapEventCGBTilemap:: db $04 ; width db $03 ; height dw HallOfHonorDoorMapEventCGBPermissions db TRUE ; cgb mode - INCBIN "data/maps/tiles/hall_of_honor_door_map_event_cgb.bin" + INCBIN "data/maps/tiles/hall_of_honor_door_map_event_cgb.bin.lz" HallOfHonorDoorMapEventCGBPermissions: - INCBIN "data/maps/permissions/hall_of_honor_door_map_event_cgb.bin" + INCBIN "data/maps/permissions/hall_of_honor_door_map_event_cgb.bin.lz" GrassMedalTilemap:: db $03 ; width db $03 ; height dw NULL db TRUE ; cgb mode - INCBIN "data/maps/tiles/grass_medal.bin" + INCBIN "data/maps/tiles/grass_medal.bin.lz" AnimData1:: frame_table AnimFrameTable0 diff --git a/src/data/maps/tiles/aerodactyl_intro.bin b/src/data/maps/tiles/aerodactyl_intro.bin index 0380a45f..85c0458f 100644 --- a/src/data/maps/tiles/aerodactyl_intro.bin +++ b/src/data/maps/tiles/aerodactyl_intro.bin @@ -1 +1 @@ -ÿ€‚ƒ„…†‡ÿ‘’“”•–—ÿ ¡¢£¤¥¦§ÿ°±²³´µ¶·ÿÀÁÂÃÄÅÆÇÿÐÑÒÓÔÕÖ×ÿˆ‰Š‹ŒŽÿ˜™š›œžŸÿ¨©ª«¬­®¯ÿ¸¹º»¼½¾¿ÿÈÉÊËÌÍÎÏÿØÙÚÛÜÝÞß \ No newline at end of file +€‚ƒ„…†‡‘’“”•–— ¡¢£¤¥¦§°±²³´µ¶·ÀÁÂÃÄÅÆÇÐÑÒÓÔÕÖ׈‰Š‹ŒŽ˜™š›œžŸ¨©ª«¬­®¯¸¹º»¼½¾¿ÈÉÊËÌÍÎÏØÙÚÛÜÝÞß \ No newline at end of file diff --git a/src/data/maps/tiles/aerodactyl_intro_cgb.bin b/src/data/maps/tiles/aerodactyl_intro_cgb.bin index 20714537..1d2a1c76 100644 Binary files a/src/data/maps/tiles/aerodactyl_intro_cgb.bin and b/src/data/maps/tiles/aerodactyl_intro_cgb.bin differ diff --git a/src/data/maps/tiles/aerodactyl_intro_cgb.bin.lz.match b/src/data/maps/tiles/aerodactyl_intro_cgb.bin.lz.match new file mode 100644 index 00000000..20714537 Binary files /dev/null and b/src/data/maps/tiles/aerodactyl_intro_cgb.bin.lz.match differ diff --git a/src/data/maps/tiles/card_pop.bin b/src/data/maps/tiles/card_pop.bin index e29cc7bb..932cac41 100644 Binary files a/src/data/maps/tiles/card_pop.bin and b/src/data/maps/tiles/card_pop.bin differ diff --git a/src/data/maps/tiles/card_pop.bin.lz.match b/src/data/maps/tiles/card_pop.bin.lz.match new file mode 100644 index 00000000..e29cc7bb Binary files /dev/null and b/src/data/maps/tiles/card_pop.bin.lz.match differ diff --git a/src/data/maps/tiles/card_pop_cgb.bin b/src/data/maps/tiles/card_pop_cgb.bin index 5dcb25ef..c1d21829 100644 Binary files a/src/data/maps/tiles/card_pop_cgb.bin and b/src/data/maps/tiles/card_pop_cgb.bin differ diff --git a/src/data/maps/tiles/card_pop_cgb.bin.lz.match b/src/data/maps/tiles/card_pop_cgb.bin.lz.match new file mode 100644 index 00000000..5dcb25ef Binary files /dev/null and b/src/data/maps/tiles/card_pop_cgb.bin.lz.match differ diff --git a/src/data/maps/tiles/challenge_hall.bin b/src/data/maps/tiles/challenge_hall.bin index 6143f36c..ddf9e077 100644 Binary files a/src/data/maps/tiles/challenge_hall.bin and b/src/data/maps/tiles/challenge_hall.bin differ diff --git a/src/data/maps/tiles/challenge_hall.bin.lz.match b/src/data/maps/tiles/challenge_hall.bin.lz.match new file mode 100644 index 00000000..6143f36c Binary files /dev/null and b/src/data/maps/tiles/challenge_hall.bin.lz.match differ diff --git a/src/data/maps/tiles/challenge_hall_cgb.bin b/src/data/maps/tiles/challenge_hall_cgb.bin index 55a8d573..c7cbd6bf 100644 Binary files a/src/data/maps/tiles/challenge_hall_cgb.bin and b/src/data/maps/tiles/challenge_hall_cgb.bin differ diff --git a/src/data/maps/tiles/challenge_hall_cgb.bin.lz.match b/src/data/maps/tiles/challenge_hall_cgb.bin.lz.match new file mode 100644 index 00000000..55a8d573 Binary files /dev/null and b/src/data/maps/tiles/challenge_hall_cgb.bin.lz.match differ diff --git a/src/data/maps/tiles/challenge_hall_entrance.bin b/src/data/maps/tiles/challenge_hall_entrance.bin index d7c74850..e5d81ae2 100644 --- a/src/data/maps/tiles/challenge_hall_entrance.bin +++ b/src/data/maps/tiles/challenge_hall_entrance.bin @@ -1 +1 @@ -ƒñ#†“”•ß–…ñ‘„Š‡£ú¤¥££ ÷  ³´µ³³¢°÷°#-󗘘™-@ˆ‹-HA¢¡A‡²½±Uÿ‡ššªj›Û›©~ÿ««‘‡‚Ù„¨i¸àá)ioâ»ãÉäåÝñæµç=ƒ "†-…z 3’‹¢£ _$º ¡²³02°_°°0E±€C_&C \ No newline at end of file +‚‰ƒƒƒƒƒ†“”•–…ƒƒƒƒƒ‘„Š‡£¤¥££ “”•– ££¤¥£Š‡Š‡³´µ³³°“”•–°³³´µ³Š‡Š‡—˜˜™Š‡ˆ‹Š‡¢¡Š‡²±Š‡ššªŠ‡››©Š‡««©Š‡‚„¨àኇŠ‡â㊇Š‡ä劇Š‡æ犇ˆƒƒƒƒƒ†…ƒƒƒƒƒ’‹¢££££££  ££££££¡²³³³³³³°°³³³³³³±€€€€€€€€€€€€€€€€ \ No newline at end of file diff --git a/src/data/maps/tiles/challenge_hall_entrance.bin.lz.match b/src/data/maps/tiles/challenge_hall_entrance.bin.lz.match new file mode 100644 index 00000000..d7c74850 --- /dev/null +++ b/src/data/maps/tiles/challenge_hall_entrance.bin.lz.match @@ -0,0 +1 @@ +ƒñ#†“”•ß–…ñ‘„Š‡£ú¤¥££ ÷  ³´µ³³¢°÷°#-󗘘™-@ˆ‹-HA¢¡A‡²½±Uÿ‡ššªj›Û›©~ÿ««‘‡‚Ù„¨i¸àá)ioâ»ãÉäåÝñæµç=ƒ "†-…z 3’‹¢£ _$º ¡²³02°_°°0E±€C_&C \ No newline at end of file diff --git a/src/data/maps/tiles/challenge_hall_entrance_cgb.bin b/src/data/maps/tiles/challenge_hall_entrance_cgb.bin index dba4a85e..3f8455e8 100644 Binary files a/src/data/maps/tiles/challenge_hall_entrance_cgb.bin and b/src/data/maps/tiles/challenge_hall_entrance_cgb.bin differ diff --git a/src/data/maps/tiles/challenge_hall_entrance_cgb.bin.lz.match b/src/data/maps/tiles/challenge_hall_entrance_cgb.bin.lz.match new file mode 100644 index 00000000..dba4a85e Binary files /dev/null and b/src/data/maps/tiles/challenge_hall_entrance_cgb.bin.lz.match differ diff --git a/src/data/maps/tiles/challenge_machine_map_event.bin b/src/data/maps/tiles/challenge_machine_map_event.bin index 1793914c..7ef8ed47 100644 --- a/src/data/maps/tiles/challenge_machine_map_event.bin +++ b/src/data/maps/tiles/challenge_machine_map_event.bin @@ -1 +1 @@ -ÿÐÑÒÓÔÕÖ×ÿÜÝÞßðñòóøôõö÷ \ No newline at end of file +ÐÑÒÓÔÕÖ×ÜÝÞßðñòóôõö÷ \ No newline at end of file diff --git a/src/data/maps/tiles/challenge_machine_map_event_cgb.bin b/src/data/maps/tiles/challenge_machine_map_event_cgb.bin index 2a021bb7..764e29a8 100644 --- a/src/data/maps/tiles/challenge_machine_map_event_cgb.bin +++ b/src/data/maps/tiles/challenge_machine_map_event_cgb.bin @@ -1 +1 @@ -ûÐÑÒÓóÔÕßÖ×óÜÝÞß}ðñòó ôèõö÷ ! \ No newline at end of file +ÐÑÒÓÔÕÖ×ÜÝÞßðñòóôõö÷ \ No newline at end of file diff --git a/src/data/maps/tiles/challenge_machine_map_event_cgb.bin.lz.match b/src/data/maps/tiles/challenge_machine_map_event_cgb.bin.lz.match new file mode 100644 index 00000000..2a021bb7 --- /dev/null +++ b/src/data/maps/tiles/challenge_machine_map_event_cgb.bin.lz.match @@ -0,0 +1 @@ +ûÐÑÒÓóÔÕßÖ×óÜÝÞß}ðñòó ôèõö÷ ! \ No newline at end of file diff --git a/src/data/maps/tiles/charizard_intro.bin b/src/data/maps/tiles/charizard_intro.bin index 0380a45f..85c0458f 100644 --- a/src/data/maps/tiles/charizard_intro.bin +++ b/src/data/maps/tiles/charizard_intro.bin @@ -1 +1 @@ -ÿ€‚ƒ„…†‡ÿ‘’“”•–—ÿ ¡¢£¤¥¦§ÿ°±²³´µ¶·ÿÀÁÂÃÄÅÆÇÿÐÑÒÓÔÕÖ×ÿˆ‰Š‹ŒŽÿ˜™š›œžŸÿ¨©ª«¬­®¯ÿ¸¹º»¼½¾¿ÿÈÉÊËÌÍÎÏÿØÙÚÛÜÝÞß \ No newline at end of file +€‚ƒ„…†‡‘’“”•–— ¡¢£¤¥¦§°±²³´µ¶·ÀÁÂÃÄÅÆÇÐÑÒÓÔÕÖ׈‰Š‹ŒŽ˜™š›œžŸ¨©ª«¬­®¯¸¹º»¼½¾¿ÈÉÊËÌÍÎÏØÙÚÛÜÝÞß \ No newline at end of file diff --git a/src/data/maps/tiles/charizard_intro_cgb.bin b/src/data/maps/tiles/charizard_intro_cgb.bin index 37fa4707..a4d4498d 100644 Binary files a/src/data/maps/tiles/charizard_intro_cgb.bin and b/src/data/maps/tiles/charizard_intro_cgb.bin differ diff --git a/src/data/maps/tiles/charizard_intro_cgb.bin.lz.match b/src/data/maps/tiles/charizard_intro_cgb.bin.lz.match new file mode 100644 index 00000000..37fa4707 Binary files /dev/null and b/src/data/maps/tiles/charizard_intro_cgb.bin.lz.match differ diff --git a/src/data/maps/tiles/club_lobby.bin b/src/data/maps/tiles/club_lobby.bin index 98fdcc5f..e1ca6245 100644 Binary files a/src/data/maps/tiles/club_lobby.bin and b/src/data/maps/tiles/club_lobby.bin differ diff --git a/src/data/maps/tiles/club_lobby.bin.lz.match b/src/data/maps/tiles/club_lobby.bin.lz.match new file mode 100644 index 00000000..98fdcc5f Binary files /dev/null and b/src/data/maps/tiles/club_lobby.bin.lz.match differ diff --git a/src/data/maps/tiles/club_lobby_cgb.bin b/src/data/maps/tiles/club_lobby_cgb.bin index ccc91482..76896973 100644 --- a/src/data/maps/tiles/club_lobby_cgb.bin +++ b/src/data/maps/tiles/club_lobby_cgb.bin @@ -1 +1 @@ -ç‚Šƒñôø’„? ø‡ˆ“””•ñÀÀ¤¥-1/"–Œ—;'E€K/W"%½aÐдµleôõeB¦§sAÎÖQ™tö÷™As‡µ‡µñ™˜°™™B¶·ã±ÀKÁÿÒ™Oé1’•ÊÊÉPCÌC¨ôÿÿN1ùš›¨¨Ë{|©gï_8vª«¾Y³¿¯‘“4ºº˜» ‚ÂÁË1¬3̼¹ðó¿ÒÑû8(ô¿ÝÜÜËD{@ŽŒWö¿Þààsÿ„Ìñ¦áá«ÿ¼âþãŒêæç”àß‚„ãÄ!ñ¦Uÿä圞žŸèéÒ ÿ÷ë5`¦œÀŸÒÆQWLë5`ñ¬ë®¯ ¿P™âì¼í;¼¸¸¹C áNÁÏüˆîï{¶@‰:l?ðñ¶QÁ/ on it reads 0xXY and stores it, -; then repeats (0x0X + 2) bytes from the offset starting at 0xZZ; +; - if off -> on it reads 0xYZ and stores it, +; then repeats (0x0Y + 2) bytes from the offset starting at 0xXX; ; - if on -> off, then the data only provides the offset, -; and the previous byte read for number of bytes to repeat, 0xXY, is reused -; in which case (0x0Y + 2) bytes are repeated starting from the offset. +; and the previous byte read for number of bytes to repeat, 0xYZ, is reused +; in which case (0x0Z + 2) bytes are repeated starting from the offset. .Decompress:: ld hl, wDecompNumBytesToRepeat ld a, [hl] diff --git a/tools/.gitignore b/tools/.gitignore index 8016fb67..0db9d952 100644 --- a/tools/.gitignore +++ b/tools/.gitignore @@ -1,4 +1,5 @@ scan_includes gfx +compressor *.exe diff --git a/tools/Makefile b/tools/Makefile index c235feef..d5b35f9a 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -3,7 +3,7 @@ CC := gcc CFLAGS := -O3 -std=c99 -Wall -Wextra -pedantic -tools := scan_includes gfx +tools := scan_includes gfx compressor all: $(tools) @: diff --git a/tools/compressed_data_extractor.py b/tools/compressed_data_extractor.py deleted file mode 100644 index 17ae8d2c..00000000 --- a/tools/compressed_data_extractor.py +++ /dev/null @@ -1,168 +0,0 @@ -import argparse -import mmap -from math import floor as floor - -parser = argparse.ArgumentParser(description='Extracts compressed data.') -parser.add_argument('offsets', metavar='offsets', type=str, nargs='+', - help='start offset(s) of the compressed data') -parser.add_argument('-s', metavar='suffix', dest='suffix', type=str, nargs=1, default=[], - help='suffix for output file names') -parser.add_argument('-d', dest='decompress', action='store_true', - help='whether the output file should be decompressed') - -args = parser.parse_args() - -def getByteString(offset, len): - with open('baserom.gbc') as rom: - romMap = mmap.mmap(rom.fileno(), 0, access=mmap.ACCESS_READ) - return romMap[offset : offset + len] - -def getByte(offset): - return getByteString(offset, 1)[0] - -def getFormattedOffset(offset): - return '{:0x}'.format(offset) - -def convertWordToInt(byteArr): - assert(len(byteArr) == 2) - return byteArr[1] * 0x100 + byteArr[0] - -def getCompressedData(offset): - data = [] - pos = offset # init current position - repeatToggle = False - lenByte = 0x00 - - size = convertWordToInt(getByteString(pos, 2)) - #data.extend(getByteString(pos, 2)) don't append size bytes to output - pos += 2 - - while (size > 0): - cmdByte = getByte(pos) - pos += 1 - data.append(cmdByte) - print('{:0x}'.format(cmdByte)) - - for bit in range(8): - if (cmdByte & (1 << (7 - bit)) != 0): - # copy one byte literally - data.append(getByte(pos)) - pos += 1 - size -= 1 - else: - # copy previous sequence - data.append(getByte(pos)) - pos += 1 - - repeatToggle = not repeatToggle - if (repeatToggle): - # sequence length - lenByte = getByte(pos) - data.append(lenByte) - pos += 1 - size -= (lenByte >> 4) + 2 - else: - # no sequence length byte if toggle is off - size -= (lenByte & 0x0f) + 2 - - assert(size >= 0) - - # the decompression might finish while still - # reading command bits, so break early when this happens - if (size == 0): - if not repeatToggle: - # extra bytes to match source - data.append(getByte(pos)) - data.append(getByte(pos + 1)) - - break - - return bytes(data) - -def decompressData(source): - buffer = [0x00 for i in range(0x100)] - sourcePos = 0 - bufferPos = 0xef - lenByte = 0x00 - repeatToggle = False - - decompData = [] # final decompressed data that will be output - - while True: - if sourcePos >= len(source): - # got to the end of the data - break - - cmdByte = source[sourcePos] - sourcePos += 1 - - for cmdBit in range(8): - if sourcePos >= len(source): - # got to the end of the data - break - - if (cmdByte & (1 << (7 - cmdBit)) != 0): - # copy one byte literally - byteToCopy = source[sourcePos] - - decompData.append(byteToCopy) - buffer[bufferPos] = byteToCopy - sourcePos += 1 - bufferPos = (bufferPos + 1) % 0x100 - else: - # copy previous sequence - repeatToggle = not repeatToggle - - if (repeatToggle): - # sequence length - offsetToCopy = source[sourcePos] - lenByte = source[sourcePos + 1] - bytesToCopy = [] - - curLen = (lenByte >> 4) + 2 - for i in range(curLen): - buffer[bufferPos] = buffer[offsetToCopy] - bytesToCopy.append(buffer[offsetToCopy]) - offsetToCopy = (offsetToCopy + 1) % 0x100 - bufferPos = (bufferPos + 1) % 0x100 - - decompData.extend(bytesToCopy) - sourcePos += 2 - else: - # no sequence length byte if toggle is off - offsetToCopy = source[sourcePos] - bytesToCopy = [] - - curLen = (lenByte & 0x0f) + 2 - for i in range(curLen): - buffer[bufferPos] = buffer[offsetToCopy] - bytesToCopy.append(buffer[offsetToCopy]) - offsetToCopy = (offsetToCopy + 1) % 0x100 - bufferPos = (bufferPos + 1) % 0x100 - - decompData.extend(bytesToCopy) - sourcePos += 1 - - return bytes(decompData) - -def outputData(offset, filename, decompress): - comprData = getCompressedData(offset) - data = [] - if decompress: - data = decompressData(comprData) - else: - data = comprData - - with open(filename + '.bin', 'wb') as outFile: - outFile.write(data) - -n = 1 -for offsetStr in args.offsets: - offset = int(offsetStr, 16) - filename = 'compressed_data_' + getFormattedOffset(offset) - if (args.suffix): - filename = args.suffix[0] - if (len(args.offsets) > 1): - filename = filename + str(n) - outputData(offset, filename, args.decompress) - n += 1 diff --git a/tools/compressor.c b/tools/compressor.c new file mode 100644 index 00000000..a3270eae --- /dev/null +++ b/tools/compressor.c @@ -0,0 +1,268 @@ +#include +#include +#include +#include +#include + +#define MAX_FILE_SIZE 0x8000 +#define BUFFER_SIZE 0x100 +#define INITIAL_POS 0xef +#define MAX_RUN_LENGTH (0xf + 2) + +enum Mode +{ + LOOK_BACK, + LITERAL_COPY +}; + +struct Command +{ + enum Mode mode; + unsigned length; + int data; // either the offset or the byte to copy +}; + +void usage(const char *programName) +{ + fprintf(stderr, "Usage: %s [] \n\n", programName); + fputs("Compression options:\n", stderr); + fputs(" -m, --matching Uses matching compressed data instead of\n", stderr); + fputs(" generating it. This will detect a corresponding\n", stderr); + fputs(" \"*.match\" file in the same directory for matching.\n", stderr); +} + +void fileCopy(FILE *f1, FILE *f2) +{ + while (true) + { + int c = fgetc(f1); + if (feof(f1)) + break; + fputc(c, f2); + } +} + +int *readFileToBuffer(const char *inFilename, unsigned *fileSize) +{ + FILE *fi = fopen(inFilename, "rb"); + if (fi == NULL) + return NULL; + + int *fileBuffer = (int*) malloc(MAX_FILE_SIZE * sizeof(int)); + for (unsigned i = 0; i < MAX_FILE_SIZE; i++) + { + int c = fgetc(fi); + if (feof(fi)) + { + *fileSize = i; + break; + } + fileBuffer[i] = c; + } + + fclose(fi); + return fileBuffer; +} + +struct Command* generateCommands(int *fileBuffer, unsigned fileSize, unsigned *numCmds) +{ + struct Command *cmds = (struct Command*) malloc(0x10 * BUFFER_SIZE * sizeof(struct Command)); + *numCmds = 0; + + int *uncompressedBuffer = (int*) calloc(BUFFER_SIZE, sizeof(int)); + int *tempUncompressedBuffer = (int*) malloc(BUFFER_SIZE * sizeof(int)); + unsigned pos = 0; + + while (true) + { + if (pos == fileSize) + break; + + unsigned maxRunLen = 0; + unsigned maximalOffset = 0; + + for (unsigned i = 1; i < BUFFER_SIZE; i++) + { + unsigned curRunLen = 0; + memcpy(tempUncompressedBuffer, uncompressedBuffer, BUFFER_SIZE * sizeof(int)); + + for (unsigned j = 0; j < MAX_RUN_LENGTH; j++) + { + if (pos + j == fileSize) + break; + + if (fileBuffer[pos + j] != tempUncompressedBuffer[(pos + INITIAL_POS - i + j) % BUFFER_SIZE]) + break; + + tempUncompressedBuffer[(pos + INITIAL_POS + j) % BUFFER_SIZE] = fileBuffer[pos + j]; + curRunLen++; + } + + if (curRunLen > maxRunLen) + { + maxRunLen = curRunLen; + maximalOffset = (pos + INITIAL_POS - i) % BUFFER_SIZE; + } + } + + // store this new command + struct Command cmd; + if (maxRunLen >= 2) + { + cmd.mode = LOOK_BACK; + cmd.length = maxRunLen; + cmd.data = maximalOffset; + } + else + { + cmd.mode = LITERAL_COPY; + cmd.data = fileBuffer[pos]; + } + + cmds[(*numCmds)++] = cmd; + + // update uncompressed buffer + if (maxRunLen >= 2) + { + for (unsigned i = 0; i < maxRunLen; i++) + { + uncompressedBuffer[(pos + INITIAL_POS + i) % BUFFER_SIZE] = fileBuffer[pos + i]; + } + pos += maxRunLen; + } + else + { + uncompressedBuffer[(pos + INITIAL_POS) % BUFFER_SIZE] = fileBuffer[pos]; + pos++; + } + } + + free(uncompressedBuffer); + free(tempUncompressedBuffer); + return cmds; +} + +void outputCompressedData(int *fileBuffer, unsigned fileSize, const char *outFilename) +{ + unsigned numCmds; + struct Command *cmds = generateCommands(fileBuffer, fileSize, &numCmds); + + // store command bytes + const unsigned numCmdBytes = ((numCmds % 8) == 0) + ? numCmds / 8 + : (numCmds / 8) + 1; + int *cmdBytes = (int*) malloc(numCmdBytes * sizeof(int)); + int *lookBackLengths = (int*) malloc(numCmds * sizeof(int)); + unsigned numLookBacks = 0; + + for (unsigned i = 0; i < numCmdBytes; i++) + { + int cmdByte = 0x00; + for (unsigned j = 0; j < 8; j++) + { + const unsigned index = 8*i + j; + if (index >= numCmds) + break; + + switch (cmds[index].mode) + { + case LITERAL_COPY: + cmdByte |= (1 << (7 - j)); + break; + case LOOK_BACK: + lookBackLengths[numLookBacks++] = cmds[index].length; + break; + } + } + + cmdBytes[i] = cmdByte; + } + + FILE *fo = fopen(outFilename, "wb"); + + unsigned curLookBack = 0; + + for (unsigned i = 0; i < numCmds; i++) + { + if (i % 8 == 0) + fputc(cmdBytes[i / 8], fo); + + switch (cmds[i].mode) + { + case LITERAL_COPY: + { + fputc(cmds[i].data, fo); + } + break; + case LOOK_BACK: + { + fputc(cmds[i].data, fo); + + if (curLookBack % 2 == 0) + { + int lengthByte = (lookBackLengths[curLookBack] - 2) << 4; + if (curLookBack + 1 < numLookBacks) + lengthByte |= lookBackLengths[curLookBack + 1] - 2; + fputc(lengthByte, fo); + } + + curLookBack++; + } + break; + } + } + + fclose(fo); + + free(cmds); + free(cmdBytes); + free(lookBackLengths); +} + +int main(int argc, char *argv[]) +{ + const char *programName = argv[0]; + + if (argc < 3 || argc > 4) + { + usage(programName); + return 1; + } + + const bool matching = (strcmp(argv[1], "-m") == 0) || (strcmp(argv[1], "--matching") == 0); + const char *inFilename = argv[argc - 2]; + const char *outFilename = argv[argc - 1]; + + if (matching) + { + char *matchFilename = (char*) malloc((strlen(outFilename) + strlen(".match") + 1) * sizeof(char)); + strcpy(matchFilename, outFilename); + strcat(matchFilename, ".match"); + + FILE *fm = fopen(matchFilename, "rb"); + if (fm != NULL) + { + FILE *fo = fopen(outFilename, "wb"); + fileCopy(fm, fo); + fclose(fm); + fclose(fo); + return 0; + } + + free(matchFilename); + } + + unsigned fileSize; + int *fileBuffer = readFileToBuffer(inFilename, &fileSize); + if (fileBuffer == NULL) + { + printf("Error: %d (%s)\n", errno, strerror(errno)); + return 1; + } + + outputCompressedData(fileBuffer, fileSize, outFilename); + + free(fileBuffer); + + return 0; +} diff --git a/tools/decompress.py b/tools/decompress.py new file mode 100644 index 00000000..8d8567d7 --- /dev/null +++ b/tools/decompress.py @@ -0,0 +1,78 @@ +import os +import argparse + +parser = argparse.ArgumentParser(description='Decompresses compressed files.') +parser.add_argument('filenames', metavar='filenames', type=str, nargs='+') + +args = parser.parse_args() + +def decompressData(source): + buffer = [0x00 for i in range(0x100)] + sourcePos = 0 + bufferPos = 0xef + lenByte = 0x00 + repeatToggle = False + + decompData = [] # final decompressed data that will be output + + while True: + if sourcePos >= len(source): + # got to the end of the data + break + + cmdByte = source[sourcePos] + sourcePos += 1 + + for cmdBit in range(8): + if sourcePos >= len(source): + # got to the end of the data + break + + if (cmdByte & (1 << (7 - cmdBit)) != 0): + # copy one byte literally + byteToCopy = source[sourcePos] + + decompData.append(byteToCopy) + buffer[bufferPos] = byteToCopy + sourcePos += 1 + bufferPos = (bufferPos + 1) % 0x100 + else: + # copy previous sequence + repeatToggle = not repeatToggle + + if (repeatToggle): + # sequence length + offsetToCopy = source[sourcePos] + lenByte = source[sourcePos + 1] + bytesToCopy = [] + + curLen = (lenByte >> 4) + 2 + for i in range(curLen): + buffer[bufferPos] = buffer[offsetToCopy] + bytesToCopy.append(buffer[offsetToCopy]) + offsetToCopy = (offsetToCopy + 1) % 0x100 + bufferPos = (bufferPos + 1) % 0x100 + + decompData.extend(bytesToCopy) + sourcePos += 2 + else: + # no sequence length byte if toggle is off + offsetToCopy = source[sourcePos] + bytesToCopy = [] + + curLen = (lenByte & 0x0f) + 2 + for i in range(curLen): + buffer[bufferPos] = buffer[offsetToCopy] + bytesToCopy.append(buffer[offsetToCopy]) + offsetToCopy = (offsetToCopy + 1) % 0x100 + bufferPos = (bufferPos + 1) % 0x100 + + decompData.extend(bytesToCopy) + sourcePos += 1 + + return bytes(decompData) + +for filename in args.filenames: + source = bytearray(open(filename, 'rb').read()) + with open(os.path.splitext(filename)[0], 'wb') as outFile: + outFile.write(decompressData(source))