Skip to content

Commit

Permalink
remove day-based versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
pinobatch committed Oct 20, 2018
1 parent 210db0b commit 4d26698
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -9,6 +9,8 @@
/map.txt
__pycache__/
*.pyc
/robotfindskitten-*.zip
/robotfindskitten.dbg

# this is NES homebrew, not DSiWare
*.DS_Store
Expand Down
14 changes: 14 additions & 0 deletions CHANGES.txt
@@ -0,0 +1,14 @@
0.10
* Update for recent coding standards (.inc not .h, Python 3, recent
ca65, etc.)
* Update DTE compression and VWF drawing from 240p Test Suite
* Add instructions to README
* Add provenance of most NKIs in comments
* No more zip bombing

0.09
* Expand to 48 NKIs per screen

0.05
* initial release at https://forums.nesdev.com/viewtopic.php?f=22&t=11943
* 16 NKIs per screen
61 changes: 43 additions & 18 deletions makefile
Expand Up @@ -10,15 +10,23 @@
#

# These are used in the title of the NES program and the zip file.
title = robotfindskitten
title:= robotfindskitten

# I started this project on Sun 2014-07-07 (base: 16258)
# but took a 100 day break to give forum.nesdev.com users
# time to evaluate Scoth42's implementation.
# After 100 days, I posted my own and corrected the
# effective starting point to 16358.
CURDAY := $(shell echo $$(( ($$(date -d 'now' '+%s') / 86400) - 16358 )))
version = day$(CURDAY)
# I abandoned this after day 9; begin normal version numbers at 0.10
#CURDAY := $(shell echo $$(( ($$(date -d 'now' '+%s') / 86400) - 16358 )))
#version := day$(CURDAY)

# But I need to split the major and minor version into ints so I can
# pass them to ca65
major_version := 0
minor_version := 10

version := $(major_version).$(minor_version)

# Assembly language files that make up the PRG ROM
align_sensitive_modules := vwf7 random
Expand All @@ -31,7 +39,7 @@ objlist := $(align_sensitive_modules) $(game_modules) \

AS65 = ca65
LD65 = ld65
CFLAGS65 = -DUSE_DAS=1
CFLAGS65 = -DUSE_DAS=1 -g -DMAJOR_VERSION=$(major_version) -DMINOR_VERSION=$(minor_version)
objdir = obj/nes
srcdir = src
imgdir = tilesets
Expand All @@ -51,21 +59,31 @@ CC = gcc
CFLAGS = -std=gnu99 -Wall -DNDEBUG -O

# Windows needs .exe suffixed to the names of executables; UNIX does
# not. COMSPEC will be set to the name of the shell on Windows and
# not defined on UNIX.
# not. Also the Windows Python installer puts py.exe in the path,
# but not python3.exe, which confuses MSYS Make. COMSPEC will be set
# to the name of the shell on Windows and not defined on UNIX.
ifdef COMSPEC
DOTEXE=.exe
DOTEXE:=.exe
PY:=py -3
else
DOTEXE=
DOTEXE:=
PY:=python3
endif

.PHONY: run dist zip clean
.PHONY: run debug all dist zip clean

run: $(title).nes
$(EMU) $<

debug: $(title).nes
$(DEBUGEMU) $<
debug2: $(title).nes
$(DEBUGEMU2) $<
all: $(title).nes
dist: zip
zip: $(title)-$(version).zip
clean:
-rm $(objdir)/*.o $(objdir)/*.chr $(objdir)/*.ov53 $(objdir)/*.sav $(objdir)/*.pb53 $(objdir)/*.s
-rm $(objdir)/*.o $(objdir)/*.chr $(objdir)/*.s
-rm map.txt

# Rule to create or update the distribution zipfile by adding all
# files listed in zip.in. Actually the zipfile depends on every
Expand All @@ -74,30 +92,37 @@ clean:
# changed. It won't see changes to docs or tools, but usually when
# docs changes, README also changes, and when tools changes, the
# makefile changes.
dist: zip
zip: $(title)-$(version).zip
$(title)-$(version).zip: zip.in $(title).nes README.txt $(objdir)/index.txt
zip -9 -u $@ -@ < $<
$(PY) tools/zipup.py $< $(title)-$(version) -o $@

# Build zip.in from the list of files in the Git tree
zip.in:
git ls-files | grep -e "^[^.]" > $@
echo $(title).nes >> $@
echo zip.in >> $@

# Force creation of empty folder
$(objdir)/index.txt: makefile
echo Files produced by build tools go here, but caulk goes where? > $@
echo "Files produced by build tools go here." > $@

# Rules for PRG ROM

objlistntsc = $(foreach o,$(objlist),$(objdir)/$(o).o)

map.txt $(title).nes: rfk.x $(objlistntsc)
$(LD65) -o $(title).nes -C $^ -m map.txt
$(LD65) -o $(title).nes -m map.txt --dbgfile $(title).dbg -C $^

$(objdir)/%.o: $(srcdir)/%.s $(srcdir)/nes.h $(srcdir)/rfk.h $(srcdir)/mbyt.h
$(objdir)/%.o: $(srcdir)/%.s $(srcdir)/nes.inc $(srcdir)/rfk.inc $(srcdir)/mbyt.inc
$(AS65) $(CFLAGS65) $< -o $@

$(objdir)/%.o: $(objdir)/%.s
$(AS65) $(CFLAGS65) $< -o $@

# .incbin dependencies

$(objdir)/title.o: $(srcdir)/uctions1.txt
# title.s depends on instructions
# it also depends on the version number
$(objdir)/title.o: $(srcdir)/uctions1.txt makefile

# Generate lookup tables

Expand Down
4 changes: 2 additions & 2 deletions src/rfk.inc
Expand Up @@ -53,8 +53,8 @@ LF = 10
; this counts kitten but not robots
NUM_ITEMS = 48
.globalzp CRCHI, CRCLO
.globalzp item_x, item_y, item_color, item_shape, item_typelo
.global item_typehi
.globalzp item_x, item_y, item_color, item_typelo
.global item_typehi, item_shape
.global rand_crc, randomize_item_locs, collision_check
.global nkilru_init, nkilru_get, nkilru_shuffle, nkilru_buf

Expand Down
3 changes: 1 addition & 2 deletions src/title.s
Expand Up @@ -2,7 +2,6 @@
.include "rfk.inc"
.include "mbyt.inc"

NUM_PAGES = 5
.segment "CODE"

.proc display_instructions
Expand Down Expand Up @@ -249,7 +248,7 @@ titleguy_pb53:
.incbin "obj/nes/titleguy.chr.pb53"
.endif
uctions1_txt:
.byte .sprintf("robotfindskitten 0.%d.", BUILDDAY)
.byte .sprintf("robotfindskitten %d.%d.", MAJOR_VERSION, MINOR_VERSION)
.byte '0'|<(NUM_NKIS / 100 .MOD 10)
.byte '0'|<(NUM_NKIS / 10 .MOD 10)
.byte '0'|<(NUM_NKIS .MOD 10),LF
Expand Down
80 changes: 80 additions & 0 deletions tools/zipup.py
@@ -0,0 +1,80 @@
#!/usr/bin/env python3
import sys
import os
import argparse
import zipfile
import tarfile

def make_zipfile(outname, filenames, prefix):
with zipfile.ZipFile(outname, "w", zipfile.ZIP_DEFLATED) as z:
for filename in filenames:
z.write(filename, prefix+filename)

def make_tarfile(outname, filenames, prefix, mode="w"):
with tarfile.open(outname, "w", zipfile.ZIP_DEFLATED) as z:
for filename in filenames:
z.add(filename, prefix+filename)

def make_tarfile_gz(outname, filenames, prefix):
return make_tarfile(outname, filenames, prefix, mode="w:gz")

def make_tarfile_bz2(outname, filenames, foldername):
return make_tarfile(outname, filenames, prefix, mode="w:bz2")

def make_tarfile_xz(outname, filenames, foldername):
return make_tarfile(outname, filenames, prefix, mode="w:xz")

formathandlers = [
(".zip", make_zipfile),
(".tar", make_tarfile),
(".tgz", make_tarfile_gz),
(".tar.gz", make_tarfile_gz),
(".tbz", make_tarfile_bz2),
(".tar.bz2", make_tarfile_bz2),
(".txz", make_tarfile_xz),
(".tar.xz", make_tarfile_xz),
]

tophelptext = """
Make a zip or tar archive containing specified files without a tar bomb.
"""
bottomhelptext = """
Supported output formats: """+", ".join(x[0] for x in formathandlers)

def parse_argv(argv):
p = argparse.ArgumentParser(
description=tophelptext, epilog=bottomhelptext
)
p.add_argument("filelist",
help="name of file containing newline-separated relative "
"paths to files to include, or - for standard input")
p.add_argument("foldername",
help="name of folder in archive (e.g. hello-1.2.5)")
p.add_argument("-o", "--output",
help="path of archive (default: foldername + .zip)")
return p.parse_args(argv[1:])

def get_writerfunc(outname):
outbaselower = os.path.basename(outname).lower()
for ext, writerfunc in formathandlers:
if outbaselower.endswith(ext):
return writerfunc
raise KeyError(os.path.splitext(outbaselower)[1])

def main(argv=None):
args = parse_argv(argv or sys.argv)
if args.filelist == '-':
filenames = set(sys.stdin)
else:
with open(args.filelist, "r") as infp:
filenames = set(infp)
filenames = set(x.strip() for x in filenames)
filenames = sorted(x for x in filenames if x)

outname = args.output or args.foldername + ".zip"
writerfunc = get_writerfunc(outname)
writerfunc(outname, filenames, args.foldername+"/")

if __name__=='__main__':
main()

0 comments on commit 4d26698

Please sign in to comment.