Commit: 6194447301bef89c55f95c9222202ae022bc2c56 Parent: 526cc55cca0149b17d83b9a6ee27b55ef623ba51 Author: Vi Grey Date: 2018-02-21 17:18 UTC Summary: Allow .gitignore in Makefile, update buffer Modify Makefile to allow the .gitignore file to be included in the ZIP file. Add hackaday post mention. Update PRG safety buffer to include last 6 bytes of PRG ROM insteady of the last 8 bytes. Use global variable for the Host OS value. Makefile | 2 +- README.md | 4 +++- neszip.py | 10 ++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 7f22461..bbf3dd5 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ all: mkdir -p $(CURRENTDIR)/bin; \ mkdir -p $(CURRENTDIR)/pkg; \ cd $(CURRENTDIR)..; \ - zip $(CURRENTDIR)pkg/$(PKG_NAME).zip -r $(DIRNAME) -x "$(DIRNAME)/bin/*" -x "$(DIRNAME)/pkg/*" -x "$(DIRNAME)/.git*"; \ + zip $(CURRENTDIR)pkg/$(PKG_NAME).zip -r $(DIRNAME) -x "$(DIRNAME)/bin/*" -x "$(DIRNAME)/pkg/*" -x "$(DIRNAME)/.git/*"; \ cd $(CURRENTDIR)src; \ asm $(PKG_NAME).asm ../bin/$(PKG_NAME).nes; \ cd ..; \ diff --git a/README.md b/README.md index 070fa1d..9c9cd3f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ An NES ROM that is also a ZIP file that contains its own source code to make a n **_neszip Example is created by Vi Grey (https://vigrey.com) and is licensed under the BSD 2-Clause License. Read LICENSE for license text._** -#### A blog post with details about how this works can be found at https://vigrey.com/blog/this-nes-rom-also-zip-file +#### A blog post with details about how this project works can be found at https://vigrey.com/blog/this-nes-rom-also-zip-file + +This projects was also featured on [Hackaday](https://hackaday.com/2018/02/06/this-nes-rom-is-a-zip-of-its-source) #### Description: diff --git a/neszip.py b/neszip.py index 16e1ac7..88204b5 100755 --- a/neszip.py +++ b/neszip.py @@ -30,6 +30,8 @@ import struct import sys VERSION = '0.0.3' +HOSTOS = b'\x05' + # Check if help or version flag was passed as an argument if len(sys.argv) >= 2: @@ -62,7 +64,7 @@ def reoffset_zip(n, z, i): new_z += z[z_cursor: next_file_index] z_cursor = next_file_index new_z += z[z_cursor: z_cursor + 5] - new_z += b'\x05' + new_z += HOSTOS new_z += z[z_cursor + 6: z_cursor + 42] old_z_offset = struct.unpack('= 16384: - # 16392 gives an 8 byte buffer for end of PRG - i = n.rfind(b'\x00' * len(z), 16, 16392) + if len(n) - 8214 >= 16378: + # 16394 gives a 6 byte buffer for end of PRG + i = n.rfind(b'\x00' * len(z), 16, 16394) if i != -1: new_nes_contents += n[:i] z_reoffset = reoffset_zip(n, z, i)