From ae69a754244c4e475c8d2591772ca8e005071d83 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 18 Feb 2019 11:55:41 +0100 Subject: Update to 5.42 --- hacks/Makefile.in | 227 +- hacks/abstractile.c | 9 + hacks/analogtv-cli.c | 967 + hacks/analogtv.c | 26 +- hacks/analogtv.h | 18 +- hacks/anemone.c | 3 + hacks/anemotaxis.c | 3 + hacks/apple2-main.c | 13 +- hacks/attraction.c | 5 + hacks/barcode.c | 12 +- hacks/binaryring.c | 10 +- hacks/blaster.c | 2 + hacks/blitspin.c | 21 +- hacks/boxfit.c | 6 + hacks/bsod.c | 600 +- hacks/bubbles.c | 36 +- hacks/bumps.c | 6 + hacks/ccurve.c | 5 + hacks/celtic.c | 11 +- hacks/check-configs.pl | 26 +- hacks/cloudlife.c | 11 + hacks/compass.c | 12 + hacks/compile_axp.com | 1 + hacks/compile_decc.com | 1 + hacks/config/README | 4 +- hacks/config/bsod.xml | 2 + hacks/config/handsy.xml | 58 + hacks/config/ripples.xml | 3 +- hacks/config/unknownpleasures.xml | 19 +- hacks/coral.c | 4 + hacks/critical.c | 9 +- hacks/cwaves.c | 5 + hacks/cynosure.c | 5 + hacks/decayscreen.c | 2 + hacks/deco.c | 2 + hacks/deluxe.c | 14 + hacks/distort.c | 37 +- hacks/epicycle.c | 4 + hacks/eruption.c | 17 +- hacks/filmleader.c | 31 +- hacks/fireworkx.c | 12 +- hacks/flag.c | 46 +- hacks/flame.c | 2 + hacks/fluidballs.c | 11 + hacks/fontglide.c | 31 +- hacks/fuzzyflakes.c | 5 + hacks/glx/Makefile.in | 125 +- hacks/glx/antinspect.c | 12 +- hacks/glx/antmaze.c | 16 +- hacks/glx/antspotlight.c | 15 +- hacks/glx/atlantis.c | 19 +- hacks/glx/atunnel.c | 10 +- hacks/glx/b_draw.c | 4 +- hacks/glx/b_lockglue.c | 7 +- hacks/glx/b_sphere.c | 4 +- hacks/glx/blinkbox.c | 17 +- hacks/glx/blocktube.c | 19 +- hacks/glx/boing.c | 13 +- hacks/glx/bouncingcow.c | 22 +- hacks/glx/boxed.c | 30 +- hacks/glx/bubble3d.c | 22 +- hacks/glx/cage.c | 11 +- hacks/glx/carousel.c | 27 +- hacks/glx/circuit.c | 10 +- hacks/glx/cityflow.c | 21 +- hacks/glx/companion.c | 20 +- hacks/glx/crackberg.c | 43 +- hacks/glx/crumbler.c | 12 +- hacks/glx/cube21.c | 12 +- hacks/glx/cubenetic.c | 24 +- hacks/glx/cubestack.c | 15 +- hacks/glx/cubestorm.c | 22 +- hacks/glx/cubetwist.c | 6 +- hacks/glx/cubicgrid.c | 14 +- hacks/glx/dangerball.c | 18 +- hacks/glx/discoball.c | 8 +- hacks/glx/dnalogo.c | 35 +- hacks/glx/dxf2gl.pl | 51 +- hacks/glx/dymaxionmap.c | 28 +- hacks/glx/endgame.c | 19 +- hacks/glx/energystream.c | 19 +- hacks/glx/engine.c | 17 +- hacks/glx/esper.c | 29 +- hacks/glx/extrusion.c | 14 +- hacks/glx/flipflop.c | 6 +- hacks/glx/flipscreen3d.c | 13 +- hacks/glx/fliptext.c | 22 +- hacks/glx/flurry-texture.c | 5 +- hacks/glx/flurry.c | 18 +- hacks/glx/flurry.h | 3 +- hacks/glx/flyingtoasters.c | 24 +- hacks/glx/fps-gl.c | 15 +- hacks/glx/gears.c | 21 +- hacks/glx/geodesic.c | 15 +- hacks/glx/geodesicgears.c | 14 +- hacks/glx/gflux.c | 12 +- hacks/glx/glblur.c | 26 +- hacks/glx/glcells.c | 34 +- hacks/glx/gleidescope.c | 19 +- hacks/glx/glforestfire.c | 15 +- hacks/glx/glhanoi.c | 47 +- hacks/glx/glknots.c | 16 +- hacks/glx/glmatrix.c | 14 +- hacks/glx/glplanet.c | 23 +- hacks/glx/glschool.c | 21 +- hacks/glx/glslideshow.c | 26 +- hacks/glx/glsnake.c | 17 +- hacks/glx/gltext.c | 12 +- hacks/glx/gltrackball.c | 7 + hacks/glx/gltrackball.h | 1 + hacks/glx/handsy.c | 1175 + hacks/glx/handsy.dxf | 67706 ++++++++++++++++++++++++++++++++++++ hacks/glx/handsy.man | 76 + hacks/glx/handsy_anim.h | 805 + hacks/glx/handsy_model.c | 6684 ++++ hacks/glx/hexstrut.c | 9 +- hacks/glx/hilbert.c | 27 +- hacks/glx/hydrostat.c | 22 +- hacks/glx/hypertorus.c | 14 +- hacks/glx/hypnowheel.c | 19 +- hacks/glx/jigglypuff.c | 148 +- hacks/glx/jigsaw.c | 19 +- hacks/glx/juggler3d.c | 14 +- hacks/glx/kaleidocycle.c | 16 +- hacks/glx/klein.c | 15 +- hacks/glx/lament.c | 20 +- hacks/glx/lavalite.c | 18 +- hacks/glx/lockward.c | 12 +- hacks/glx/maze3d.c | 12 +- hacks/glx/maze3d.man | 0 hacks/glx/menger.c | 18 +- hacks/glx/mirrorblob.c | 12 +- hacks/glx/moebius.c | 14 +- hacks/glx/moebiusgears.c | 15 +- hacks/glx/molecule.c | 56 +- hacks/glx/morph3d.c | 9 +- hacks/glx/noof.c | 14 +- hacks/glx/peepers.c | 22 +- hacks/glx/photopile.c | 22 +- hacks/glx/pinion.c | 22 +- hacks/glx/pipes.c | 77 +- hacks/glx/polyhedra-gl.c | 24 +- hacks/glx/polyhedra.c | 1 + hacks/glx/polytopes.c | 14 +- hacks/glx/projectiveplane.c | 15 +- hacks/glx/providence.c | 17 +- hacks/glx/pulsar.c | 5 +- hacks/glx/quasicrystal.c | 21 +- hacks/glx/queens.c | 17 +- hacks/glx/quickhull.h | 11 +- hacks/glx/raverhoop.c | 28 +- hacks/glx/razzledazzle.c | 6 +- hacks/glx/romanboy.c | 21 +- hacks/glx/rubik.c | 21 +- hacks/glx/rubikblocks.c | 16 +- hacks/glx/sballs.c | 34 +- hacks/glx/sierpinski3d.c | 21 +- hacks/glx/skytentacles.c | 28 +- hacks/glx/sonar-icmp.c | 8 + hacks/glx/sonar.c | 35 +- hacks/glx/spheremonics.c | 18 +- hacks/glx/splitflap.c | 28 +- hacks/glx/splodesic.c | 9 +- hacks/glx/sproingies.c | 2 +- hacks/glx/sproingiewrap.c | 11 +- hacks/glx/stairs.c | 11 +- hacks/glx/starwars.c | 18 +- hacks/glx/stonerview.c | 5 +- hacks/glx/superquadrics.c | 9 +- hacks/glx/surfaces.c | 15 +- hacks/glx/tangram.c | 14 +- hacks/glx/texfont.c | 3 +- hacks/glx/timetunnel.c | 28 +- hacks/glx/topblock.c | 23 +- hacks/glx/tronbit.c | 20 +- hacks/glx/unicrud.c | 16 +- hacks/glx/unknownpleasures.c | 698 +- hacks/glx/unknownpleasures.man | 32 +- hacks/glx/vigilance.c | 30 +- hacks/glx/voronoi.c | 20 +- hacks/glx/winduprobot.c | 30 +- hacks/glx/xlock-gl-utils.c | 1 + hacks/halftone.c | 11 + hacks/halo.c | 11 + hacks/helix.c | 1 + hacks/hexadrop.c | 4 +- hacks/hyperball.c | 5 + hacks/hypercube.c | 6 + hacks/ifs.c | 1 + hacks/images/dvd.png | Bin 0 -> 2727 bytes hacks/images/sun.png | Bin 0 -> 415 bytes hacks/imsmap.c | 7 +- hacks/interaggregate.c | 7 + hacks/interference.c | 7 +- hacks/intermomentary.c | 16 + hacks/juggle.c | 1 + hacks/kaleidescope.c | 25 +- hacks/kumppa.c | 2 + hacks/lmorph.c | 13 +- hacks/m6502.c | 2 + hacks/maze.c | 10 + hacks/memscroller.c | 47 +- hacks/metaballs.c | 25 +- hacks/moire.c | 7 + hacks/moire2.c | 6 + hacks/munch.c | 6 + hacks/nerverot.c | 4 + hacks/noseguy.c | 39 +- hacks/pacman.c | 5 + hacks/pedal.c | 3 + hacks/penetrate.c | 5 + hacks/petri.c | 12 +- hacks/phosphor.c | 26 +- hacks/piecewise.c | 39 +- hacks/pong.c | 2 + hacks/popsquares.c | 3 + hacks/pyro.c | 4 + hacks/qix.c | 37 +- hacks/rd-bomb.c | 11 + hacks/recanim.c | 64 +- hacks/ripples.c | 13 + hacks/rocks.c | 11 + hacks/rorschach.c | 1 + hacks/rotzoomer.c | 18 + hacks/screenhack.c | 34 +- hacks/screenhack.h | 5 +- hacks/screenhackI.h | 1 + hacks/shadebobs.c | 4 +- hacks/slidescreen.c | 2 + hacks/speedmine.c | 11 + hacks/squiral.c | 6 + hacks/starfish.c | 4 + hacks/strange.c | 2 +- hacks/substrate.c | 6 + hacks/t3d.c | 10 + hacks/tessellimage.c | 2 + hacks/truchet.c | 4 + hacks/twang.c | 8 + hacks/vermiculate.c | 28 +- hacks/vfeedback.c | 1 + hacks/wander.c | 1 + hacks/whirlwindwarp.c | 2 + hacks/whirlygig.c | 7 + hacks/wormhole.c | 29 +- hacks/xanalogtv.c | 50 +- hacks/xflame.c | 15 +- hacks/ximage-loader.c | 11 +- hacks/xjack.c | 3 + hacks/xlockmore.c | 3 + hacks/xlockmore.h | 6 +- hacks/xlockmoreI.h | 1 + hacks/xlyap.c | 9 + hacks/xmatrix.c | 19 +- hacks/xrayswarm.c | 5 + hacks/xspirograph.c | 1 + 255 files changed, 81642 insertions(+), 1251 deletions(-) create mode 100644 hacks/analogtv-cli.c create mode 100644 hacks/config/handsy.xml create mode 100644 hacks/glx/handsy.c create mode 100644 hacks/glx/handsy.dxf create mode 100644 hacks/glx/handsy.man create mode 100644 hacks/glx/handsy_anim.h create mode 100644 hacks/glx/handsy_model.c mode change 100755 => 100644 hacks/glx/maze3d.man create mode 100644 hacks/images/dvd.png create mode 100644 hacks/images/sun.png (limited to 'hacks') diff --git a/hacks/Makefile.in b/hacks/Makefile.in index 4556872..63e69be 100644 --- a/hacks/Makefile.in +++ b/hacks/Makefile.in @@ -115,15 +115,15 @@ SRCS = attraction.c blitspin.c bouboule.c braid.c bubbles.c \ euler2d.c juggle.c polyominoes.c thornbird.c fluidballs.c \ anemone.c halftone.c metaballs.c eruption.c popsquares.c \ barcode.c piecewise.c cloudlife.c fontglide.c apple2.c \ - apple2-main.c analogtv.c xanalogtv.c pong.c filmleader.c \ - wormhole.c pacman.c pacman_ai.c pacman_level.c \ + apple2-main.c analogtv.c analogtv-cli.c xanalogtv.c pong.c \ + filmleader.c wormhole.c pacman.c pacman_ai.c pacman_level.c \ fuzzyflakes.c anemotaxis.c memscroller.c substrate.c \ intermomentary.c fireworkx.c fiberlamp.c \ boxfit.c interaggregate.c celtic.c cwaves.c m6502.c \ asm6502.c abstractile.c lcdscrub.c hexadrop.c \ tessellimage.c delaunay.c recanim.c binaryring.c \ - glitchpeg.c vfeedback.c \ - webcollage-cocoa.m webcollage-helper-cocoa.m testx11.c + glitchpeg.c vfeedback.c webcollage-cocoa.m \ + webcollage-helper-cocoa.m testx11.c SCRIPTS = vidwhacker webcollage ljlatest # Programs that are mentioned in XScreenSaver.ad, and that have XML files, @@ -156,14 +156,15 @@ OBJS = attraction.o blitspin.o bouboule.o braid.o bubbles.o \ euler2d.o juggle.o polyominoes.o thornbird.o fluidballs.o \ anemone.o halftone.o metaballs.o eruption.o popsquares.o \ barcode.o piecewise.o cloudlife.o fontglide.o apple2.o \ - apple2-main.o analogtv.o xanalogtv.o pong.o filmleader.o \ - wormhole.o pacman.o pacman_ai.o pacman_level.o \ - fuzzyflakes.o anemotaxis.o memscroller.o substrate.o \ - intermomentary.o fireworkx.o fiberlamp.o boxfit.o \ - interaggregate.o celtic.o cwaves.o webcollage-cocoa.o \ - webcollage-helper-cocoa.o m6502.o asm6502.o abstractile.o \ - lcdscrub.o hexadrop.o tessellimage.o delaunay.o recanim.o \ - binaryring.o glitchpeg.o vfeedback.o testx11.o + apple2-main.o analogtv.o analogtv2.o analogtv-cli.o \ + xanalogtv.o pong.o filmleader.o wormhole.o pacman.o \ + pacman_ai.o pacman_level.o fuzzyflakes.o anemotaxis.o \ + memscroller.o substrate.o intermomentary.o fireworkx.o \ + fiberlamp.o boxfit.o interaggregate.o celtic.o cwaves.o \ + webcollage-cocoa.o webcollage-helper-cocoa.o m6502.o \ + asm6502.o abstractile.o lcdscrub.o hexadrop.o \ + tessellimage.o delaunay.o recanim.o binaryring.o \ + glitchpeg.o vfeedback.o testx11.o EXES = attraction blitspin bouboule braid decayscreen deco \ drift flame galaxy grav greynetic halo \ @@ -414,7 +415,9 @@ distdepend:: m6502.h -e 's@\.\./utils@$$(UTILS_SRC)@g' \ -e 's@ \([^$$]\)@ $$(srcdir)/\1@g' \ -e 's@ $$(srcdir)/\(.*config.h\)@ \1@g' \ - -e 's@ $$(srcdir)/\(m6502.h\)@ \1@g' ; \ + -e 's@ $$(srcdir)/\(m6502.h\)@ \1@g' \ + -e 's@ $$(srcdir)/\(images/gen/\)@ \1@g' \ + -e 's@ $$(HACK_SRC)/\(images/gen/\)@ \1@g' ; \ echo '' \ ) > /tmp/distdepend.$$$$ && \ mv /tmp/distdepend.$$$$ Makefile.in @@ -533,8 +536,9 @@ $(UTIL_OBJS): $(MAKE) $(@F) CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" # How we build object files in this directory. +HACK_CFLAGS_BASE=$(INCLUDES) $(DEFS) $(CPPFLAGS) $(CFLAGS) $(X_CFLAGS) .c.o: - $(CC) -c $(INCLUDES) $(DEFS) $(CPPFLAGS) $(CFLAGS) $(X_CFLAGS) $< + $(CC) -c $(HACK_CFLAGS_BASE) $< # Make sure these are regenerated when the version number ticks. @@ -564,11 +568,13 @@ xscreensaver-sgigl: xscreensaver-sgigl.c $(XMU_LIBS) -lX11 -lXext $(X_EXTRA_LIBS) -lm test-utf8wc: $(UTILS_SRC)/utf8wc.c - $(CC) $(INCLUDES) $(DEFS) $(CPPFLAGS) $(CFLAGS) $(X_CFLAGS) $(LDFLAGS)\ + $(CC) $(HACK_CFLAGS_BASE) $(LDFLAGS)\ -o $@ -DSELFTEST $< # Make sure the images have been packaged. This is the first one hit: -$(HACK_BIN)/images/gen/nose-f1_png.h: +images/gen/som_png.h: + cd $(srcdir)/images && $(MAKE) +images/gen/6x10font_png.h: cd $(srcdir)/images && $(MAKE) # The rules for those hacks which follow the `screenhack.c' API. @@ -691,6 +697,21 @@ apple2: apple2.o apple2-main.o $(HACK_OBJS) $(ATV) $(GRAB) $(TEXT) $(PN xanalogtv: xanalogtv.o $(HACK_OBJS) $(ATV) $(GRAB) $(PNG) $(CC_HACK) -o $@ $@.o $(HACK_OBJS) $(ATV) $(GRAB) $(PNG) $(PNG_LIBS) $(HACK_LIBS) $(THRL) +ATVCLI_CFLAGS=-DANALOGTV_SCALE=1 -DNO_CONSTRAIN_RATIO $(HACK_CFLAGS_BASE) +analogtv2.o: Makefile +analogtv2.o: images/gen/6x10font_png.h +analogtv2.o: $(srcdir)/analogtv.h +analogtv2.o: $(srcdir)/analogtv.c + $(CC) -o $@ -c $(ATVCLI_CFLAGS) $< +analogtv-cli.o: $(srcdir)/analogtv-cli.c + $(CC) -o $@ -c $(ATVCLI_CFLAGS) $< + +ATVCLI=analogtv2.o $(UTILS_BIN)/yarandom.o $(THRO) $(PNG) +analogtv-cli: analogtv-cli.o $(ATVCLI) + $(CC_HACK) -o $@ $@.o $(ATVCLI) $(THRL) $(PNG_LIBS) -lpng +clean:: + -rm -f analogtv-cli + distort: distort.o $(HACK_OBJS) $(GRAB) $(SHM) $(CC_HACK) -o $@ $@.o $(HACK_OBJS) $(GRAB) $(SHM) $(HACK_LIBS) $(THRL) @@ -1035,9 +1056,19 @@ abstractile.o: $(UTILS_SRC)/resources.h abstractile.o: $(UTILS_SRC)/usleep.h abstractile.o: $(UTILS_SRC)/visual.h abstractile.o: $(UTILS_SRC)/yarandom.h +analogtv-cli.o: $(srcdir)/analogtv.h +analogtv-cli.o: ../config.h +analogtv-cli.o: $(UTILS_SRC)/aligned_malloc.h +analogtv-cli.o: $(UTILS_SRC)/font-retry.h +analogtv-cli.o: $(UTILS_SRC)/resources.h +analogtv-cli.o: $(UTILS_SRC)/thread_util.h +analogtv-cli.o: $(UTILS_SRC)/visual.h +analogtv-cli.o: $(UTILS_SRC)/xshm.h +analogtv-cli.o: $(UTILS_SRC)/yarandom.h +analogtv-cli.o: $(srcdir)/ximage-loader.h analogtv.o: $(srcdir)/analogtv.h analogtv.o: ../config.h -analogtv.o: $(srcdir)/images/gen/6x10font_png.h +analogtv.o: images/gen/6x10font_png.h analogtv.o: $(UTILS_SRC)/aligned_malloc.h analogtv.o: $(UTILS_SRC)/font-retry.h analogtv.o: $(UTILS_SRC)/grabscreen.h @@ -1131,7 +1162,7 @@ apple2.o: $(srcdir)/analogtv.h apple2.o: $(srcdir)/apple2.h apple2.o: ../config.h apple2.o: $(srcdir)/fps.h -apple2.o: $(srcdir)/images/gen/apple2font_png.h +apple2.o: images/gen/apple2font_png.h apple2.o: $(srcdir)/recanim.h apple2.o: $(srcdir)/screenhackI.h apple2.o: $(UTILS_SRC)/aligned_malloc.h @@ -1204,7 +1235,7 @@ blaster.o: $(UTILS_SRC)/visual.h blaster.o: $(UTILS_SRC)/yarandom.h blitspin.o: ../config.h blitspin.o: $(srcdir)/fps.h -blitspin.o: $(srcdir)/images/gen/som_png.h +blitspin.o: images/gen/som_png.h blitspin.o: $(srcdir)/recanim.h blitspin.o: $(srcdir)/screenhackI.h blitspin.o: $(srcdir)/screenhack.h @@ -1266,17 +1297,19 @@ bsod.o: $(srcdir)/analogtv.h bsod.o: $(srcdir)/apple2.h bsod.o: ../config.h bsod.o: $(srcdir)/fps.h -bsod.o: $(srcdir)/images/gen/amiga_png.h -bsod.o: $(srcdir)/images/gen/android_png.h -bsod.o: $(srcdir)/images/gen/apple_png.h -bsod.o: $(srcdir)/images/gen/atari_png.h -bsod.o: $(srcdir)/images/gen/atm_png.h -bsod.o: $(srcdir)/images/gen/hmac_png.h -bsod.o: $(srcdir)/images/gen/macbomb_png.h -bsod.o: $(srcdir)/images/gen/mac_png.h -bsod.o: $(srcdir)/images/gen/osx_10_2_png.h -bsod.o: $(srcdir)/images/gen/osx_10_3_png.h -bsod.o: $(srcdir)/images/gen/ransomware_png.h +bsod.o: images/gen/amiga_png.h +bsod.o: images/gen/android_png.h +bsod.o: images/gen/apple_png.h +bsod.o: images/gen/atari_png.h +bsod.o: images/gen/atm_png.h +bsod.o: images/gen/dvd_png.h +bsod.o: images/gen/hmac_png.h +bsod.o: images/gen/macbomb_png.h +bsod.o: images/gen/mac_png.h +bsod.o: images/gen/osx_10_2_png.h +bsod.o: images/gen/osx_10_3_png.h +bsod.o: images/gen/ransomware_png.h +bsod.o: images/gen/sun_png.h bsod.o: $(srcdir)/recanim.h bsod.o: $(srcdir)/screenhackI.h bsod.o: $(srcdir)/screenhack.h @@ -1294,50 +1327,50 @@ bsod.o: $(UTILS_SRC)/yarandom.h bsod.o: $(srcdir)/ximage-loader.h bubbles-default.o: $(srcdir)/bubbles.h bubbles-default.o: ../config.h -bubbles-default.o: $(srcdir)/images/gen/blood10_png.h -bubbles-default.o: $(srcdir)/images/gen/blood11_png.h -bubbles-default.o: $(srcdir)/images/gen/blood1_png.h -bubbles-default.o: $(srcdir)/images/gen/blood2_png.h -bubbles-default.o: $(srcdir)/images/gen/blood3_png.h -bubbles-default.o: $(srcdir)/images/gen/blood4_png.h -bubbles-default.o: $(srcdir)/images/gen/blood5_png.h -bubbles-default.o: $(srcdir)/images/gen/blood6_png.h -bubbles-default.o: $(srcdir)/images/gen/blood7_png.h -bubbles-default.o: $(srcdir)/images/gen/blood8_png.h -bubbles-default.o: $(srcdir)/images/gen/blood9_png.h -bubbles-default.o: $(srcdir)/images/gen/blue10_png.h -bubbles-default.o: $(srcdir)/images/gen/blue11_png.h -bubbles-default.o: $(srcdir)/images/gen/blue1_png.h -bubbles-default.o: $(srcdir)/images/gen/blue2_png.h -bubbles-default.o: $(srcdir)/images/gen/blue3_png.h -bubbles-default.o: $(srcdir)/images/gen/blue4_png.h -bubbles-default.o: $(srcdir)/images/gen/blue5_png.h -bubbles-default.o: $(srcdir)/images/gen/blue6_png.h -bubbles-default.o: $(srcdir)/images/gen/blue7_png.h -bubbles-default.o: $(srcdir)/images/gen/blue8_png.h -bubbles-default.o: $(srcdir)/images/gen/blue9_png.h -bubbles-default.o: $(srcdir)/images/gen/glass10_png.h -bubbles-default.o: $(srcdir)/images/gen/glass11_png.h -bubbles-default.o: $(srcdir)/images/gen/glass1_png.h -bubbles-default.o: $(srcdir)/images/gen/glass2_png.h -bubbles-default.o: $(srcdir)/images/gen/glass3_png.h -bubbles-default.o: $(srcdir)/images/gen/glass4_png.h -bubbles-default.o: $(srcdir)/images/gen/glass5_png.h -bubbles-default.o: $(srcdir)/images/gen/glass6_png.h -bubbles-default.o: $(srcdir)/images/gen/glass7_png.h -bubbles-default.o: $(srcdir)/images/gen/glass8_png.h -bubbles-default.o: $(srcdir)/images/gen/glass9_png.h -bubbles-default.o: $(srcdir)/images/gen/jade10_png.h -bubbles-default.o: $(srcdir)/images/gen/jade11_png.h -bubbles-default.o: $(srcdir)/images/gen/jade1_png.h -bubbles-default.o: $(srcdir)/images/gen/jade2_png.h -bubbles-default.o: $(srcdir)/images/gen/jade3_png.h -bubbles-default.o: $(srcdir)/images/gen/jade4_png.h -bubbles-default.o: $(srcdir)/images/gen/jade5_png.h -bubbles-default.o: $(srcdir)/images/gen/jade6_png.h -bubbles-default.o: $(srcdir)/images/gen/jade7_png.h -bubbles-default.o: $(srcdir)/images/gen/jade8_png.h -bubbles-default.o: $(srcdir)/images/gen/jade9_png.h +bubbles-default.o: images/gen/blood10_png.h +bubbles-default.o: images/gen/blood11_png.h +bubbles-default.o: images/gen/blood1_png.h +bubbles-default.o: images/gen/blood2_png.h +bubbles-default.o: images/gen/blood3_png.h +bubbles-default.o: images/gen/blood4_png.h +bubbles-default.o: images/gen/blood5_png.h +bubbles-default.o: images/gen/blood6_png.h +bubbles-default.o: images/gen/blood7_png.h +bubbles-default.o: images/gen/blood8_png.h +bubbles-default.o: images/gen/blood9_png.h +bubbles-default.o: images/gen/blue10_png.h +bubbles-default.o: images/gen/blue11_png.h +bubbles-default.o: images/gen/blue1_png.h +bubbles-default.o: images/gen/blue2_png.h +bubbles-default.o: images/gen/blue3_png.h +bubbles-default.o: images/gen/blue4_png.h +bubbles-default.o: images/gen/blue5_png.h +bubbles-default.o: images/gen/blue6_png.h +bubbles-default.o: images/gen/blue7_png.h +bubbles-default.o: images/gen/blue8_png.h +bubbles-default.o: images/gen/blue9_png.h +bubbles-default.o: images/gen/glass10_png.h +bubbles-default.o: images/gen/glass11_png.h +bubbles-default.o: images/gen/glass1_png.h +bubbles-default.o: images/gen/glass2_png.h +bubbles-default.o: images/gen/glass3_png.h +bubbles-default.o: images/gen/glass4_png.h +bubbles-default.o: images/gen/glass5_png.h +bubbles-default.o: images/gen/glass6_png.h +bubbles-default.o: images/gen/glass7_png.h +bubbles-default.o: images/gen/glass8_png.h +bubbles-default.o: images/gen/glass9_png.h +bubbles-default.o: images/gen/jade10_png.h +bubbles-default.o: images/gen/jade11_png.h +bubbles-default.o: images/gen/jade1_png.h +bubbles-default.o: images/gen/jade2_png.h +bubbles-default.o: images/gen/jade3_png.h +bubbles-default.o: images/gen/jade4_png.h +bubbles-default.o: images/gen/jade5_png.h +bubbles-default.o: images/gen/jade6_png.h +bubbles-default.o: images/gen/jade7_png.h +bubbles-default.o: images/gen/jade8_png.h +bubbles-default.o: images/gen/jade9_png.h bubbles-default.o: $(UTILS_SRC)/yarandom.h bubbles.o: $(srcdir)/bubbles.h bubbles.o: ../config.h @@ -1701,7 +1734,7 @@ fireworkx.o: $(UTILS_SRC)/visual.h fireworkx.o: $(UTILS_SRC)/yarandom.h flag.o: ../config.h flag.o: $(srcdir)/fps.h -flag.o: $(srcdir)/images/gen/bob_png.h +flag.o: images/gen/bob_png.h flag.o: $(srcdir)/recanim.h flag.o: $(srcdir)/screenhackI.h flag.o: $(UTILS_SRC)/colors.h @@ -2232,8 +2265,8 @@ m6502.o: $(UTILS_SRC)/xshm.h m6502.o: $(UTILS_SRC)/yarandom.h maze.o: ../config.h maze.o: $(srcdir)/fps.h -maze.o: $(srcdir)/images/gen/logo-180_png.h -maze.o: $(srcdir)/images/gen/logo-50_png.h +maze.o: images/gen/logo-180_png.h +maze.o: images/gen/logo-50_png.h maze.o: $(srcdir)/recanim.h maze.o: $(srcdir)/screenhackI.h maze.o: $(srcdir)/screenhack.h @@ -2345,14 +2378,14 @@ nerverot.o: $(UTILS_SRC)/visual.h nerverot.o: $(UTILS_SRC)/yarandom.h noseguy.o: ../config.h noseguy.o: $(srcdir)/fps.h -noseguy.o: $(srcdir)/images/gen/nose-f1_png.h -noseguy.o: $(srcdir)/images/gen/nose-f2_png.h -noseguy.o: $(srcdir)/images/gen/nose-f3_png.h -noseguy.o: $(srcdir)/images/gen/nose-f4_png.h -noseguy.o: $(srcdir)/images/gen/nose-l1_png.h -noseguy.o: $(srcdir)/images/gen/nose-l2_png.h -noseguy.o: $(srcdir)/images/gen/nose-r1_png.h -noseguy.o: $(srcdir)/images/gen/nose-r2_png.h +noseguy.o: images/gen/nose-f1_png.h +noseguy.o: images/gen/nose-f2_png.h +noseguy.o: images/gen/nose-f3_png.h +noseguy.o: images/gen/nose-f4_png.h +noseguy.o: images/gen/nose-l1_png.h +noseguy.o: images/gen/nose-l2_png.h +noseguy.o: images/gen/nose-r1_png.h +noseguy.o: images/gen/nose-r2_png.h noseguy.o: $(srcdir)/recanim.h noseguy.o: $(srcdir)/screenhackI.h noseguy.o: $(srcdir)/screenhack.h @@ -2404,7 +2437,7 @@ pacman_level.o: $(srcdir)/ximage-loader.h pacman_level.o: $(srcdir)/xlockmoreI.h pacman.o: ../config.h pacman.o: $(srcdir)/fps.h -pacman.o: $(srcdir)/images/gen/pacman_png.h +pacman.o: images/gen/pacman_png.h pacman.o: $(srcdir)/pacman_ai.h pacman.o: $(srcdir)/pacman.h pacman.o: $(srcdir)/pacman_level.h @@ -2480,7 +2513,7 @@ petri.o: $(UTILS_SRC)/visual.h petri.o: $(UTILS_SRC)/yarandom.h phosphor.o: ../config.h phosphor.o: $(srcdir)/fps.h -phosphor.o: $(srcdir)/images/gen/6x10font_png.h +phosphor.o: images/gen/6x10font_png.h phosphor.o: $(srcdir)/recanim.h phosphor.o: $(srcdir)/screenhackI.h phosphor.o: $(srcdir)/screenhack.h @@ -2912,7 +2945,7 @@ tessellimage.o: $(UTILS_SRC)/yarandom.h testx11.o: ../config.h testx11.o: $(srcdir)/fps.h testx11.o: $(srcdir)/glx/rotator.h -testx11.o: $(srcdir)/images/gen/logo-180_png.h +testx11.o: images/gen/logo-180_png.h testx11.o: $(srcdir)/recanim.h testx11.o: $(srcdir)/screenhackI.h testx11.o: $(srcdir)/screenhack.h @@ -3116,10 +3149,10 @@ worm.o: $(srcdir)/xlockmore.h xanalogtv.o: $(srcdir)/analogtv.h xanalogtv.o: ../config.h xanalogtv.o: $(srcdir)/fps.h -xanalogtv.o: $(srcdir)/images/gen/logo-180_png.h -xanalogtv.o: $(srcdir)/images/gen/testcard_bbcf_png.h -xanalogtv.o: $(srcdir)/images/gen/testcard_pm5544_png.h -xanalogtv.o: $(srcdir)/images/gen/testcard_rca_png.h +xanalogtv.o: images/gen/logo-180_png.h +xanalogtv.o: images/gen/testcard_bbcf_png.h +xanalogtv.o: images/gen/testcard_pm5544_png.h +xanalogtv.o: images/gen/testcard_rca_png.h xanalogtv.o: $(srcdir)/recanim.h xanalogtv.o: $(srcdir)/screenhackI.h xanalogtv.o: $(srcdir)/screenhack.h @@ -3137,7 +3170,7 @@ xanalogtv.o: $(UTILS_SRC)/yarandom.h xanalogtv.o: $(srcdir)/ximage-loader.h xflame.o: ../config.h xflame.o: $(srcdir)/fps.h -xflame.o: $(srcdir)/images/gen/bob_png.h +xflame.o: images/gen/bob_png.h xflame.o: $(srcdir)/recanim.h xflame.o: $(srcdir)/screenhackI.h xflame.o: $(srcdir)/screenhack.h @@ -3196,10 +3229,10 @@ xlyap.o: $(UTILS_SRC)/visual.h xlyap.o: $(UTILS_SRC)/yarandom.h xmatrix.o: ../config.h xmatrix.o: $(srcdir)/fps.h -xmatrix.o: $(srcdir)/images/gen/matrix1b_png.h -xmatrix.o: $(srcdir)/images/gen/matrix1_png.h -xmatrix.o: $(srcdir)/images/gen/matrix2b_png.h -xmatrix.o: $(srcdir)/images/gen/matrix2_png.h +xmatrix.o: images/gen/matrix1b_png.h +xmatrix.o: images/gen/matrix1_png.h +xmatrix.o: images/gen/matrix2b_png.h +xmatrix.o: images/gen/matrix2_png.h xmatrix.o: $(srcdir)/recanim.h xmatrix.o: $(srcdir)/screenhackI.h xmatrix.o: $(srcdir)/screenhack.h diff --git a/hacks/abstractile.c b/hacks/abstractile.c index b4394f1..1b055c2 100644 --- a/hacks/abstractile.c +++ b/hacks/abstractile.c @@ -1485,6 +1485,7 @@ abstractile_init(Display *display, Window window) fprintf(stderr, "%s: unknown tile option %s\n", progname, tile); st->tile = TILE_RANDOM; } + if (tile) free (tile); st->speed = get_integer_resource(display, "speed", "Integer"); if (st->speed < 0) st->speed = 0; @@ -1579,6 +1580,14 @@ static void abstractile_free (Display *dpy, Window window, void *closure) { struct state *st = (struct state *) closure; + if (st->dline) free(st->dline); + if (st->eline) free(st->eline); + if (st->grid) free(st->grid); + if (st->zlist) free(st->zlist); + if (st->fdol) free(st->fdol); + if (st->odi) free(st->odi); + XFreeGC (dpy, st->fgc); + XFreeGC (dpy, st->bgc); free (st); } diff --git a/hacks/analogtv-cli.c b/hacks/analogtv-cli.c new file mode 100644 index 0000000..d70db1b --- /dev/null +++ b/hacks/analogtv-cli.c @@ -0,0 +1,967 @@ +/* xanalogtv-cli, Copyright (c) 2018 Jamie Zawinski + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. No representations are made about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * Performs the "Analog TV" transform on an image file, converting it to + * an MP4. The MP4 file will have the same dimensions as the input image. + * Requires 'ffmpeg' on $PATH. + * + * --duration Length in seconds of MP4. + * --powerup Do the power-on animation at the beginning. + * --logo FILE Small image overlayed onto the colorbars image. + * --audio FILE Add a soundtrack. Must be as long or longer. + * + * Created: 10-Dec-2018 by jwz. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "resources.h" +#include "visual.h" +#include "yarandom.h" +#include "font-retry.h" +#include "ximage-loader.h" +#include "thread_util.h" +#include "xshm.h" +#include "analogtv.h" + +#ifdef HAVE_LIBPNG +# include +#endif + +const char *progname; +const char *progclass; +int mono_p = 0; +static Bool verbose_p = 0; + +#define RANDSIGN() ((random() & 1) ? 1 : -1) + +enum { + N_CHANNELS=12, + MAX_MULTICHAN=2, + MAX_STATIONS=11 +}; + +typedef struct chansetting_s { + analogtv_reception recs[MAX_MULTICHAN]; + double noise_level; +} chansetting; + +struct state { + XImage *output_frame; + int frames_written; + char *framefile_fmt; + + Display *dpy; + Window window; + analogtv *tv; + analogtv_font ugly_font; + + int n_stations; + analogtv_input *stations[MAX_STATIONS]; + Bool image_loading_p; + XImage *logo, *logo_mask; + + int curinputi; + chansetting chansettings[N_CHANNELS]; + chansetting *cs; +}; + +static struct state global_state; + + +/* Since this program does not connect to an X server, or in fact link + with Xlib, we need stubs for the few X11 routines that analogtv.c calls. + Most are unused. It seems like I am forever implementing subsets of X11. + */ + +Status +XAllocColor (Display *dpy, Colormap cmap, XColor *c) +{ + abort(); +} + +int +XClearArea (Display *dpy, Window win, int x, int y, + unsigned int w, unsigned int h, Bool exp) +{ + return 0; +} + +int +XClearWindow (Display *dpy, Window window) +{ + return 0; +} + +GC +XCreateGC(Display *dpy, Drawable d, unsigned long mask, XGCValues *gcv) +{ + return 0; +} + +XImage * +XCreateImage (Display *dpy, Visual *v, unsigned int depth, + int format, int offset, char *data, + unsigned int width, unsigned int height, + int bitmap_pad, int bytes_per_line) +{ + XImage *ximage = (XImage *) calloc (1, sizeof(*ximage)); + unsigned long r, g, b; + + if (depth == 0) depth = 32; + + ximage->width = width; + ximage->height = height; + ximage->format = format; + ximage->data = data; + ximage->bitmap_unit = 8; + ximage->byte_order = LSBFirst; + ximage->bitmap_bit_order = ximage->byte_order; + ximage->bitmap_pad = bitmap_pad; + ximage->depth = depth; + visual_rgb_masks (0, v, &r, &g, &b); + ximage->red_mask = (depth == 1 ? 0 : r); + ximage->green_mask = (depth == 1 ? 0 : g); + ximage->blue_mask = (depth == 1 ? 0 : b); + ximage->bits_per_pixel = (depth == 1 ? 1 : visual_pixmap_depth (0, v)); + ximage->bytes_per_line = bytes_per_line; + + XInitImage (ximage); + if (! ximage->f.put_pixel) abort(); + return ximage; +} + +Pixmap +XCreatePixmap (Display *dpy, Drawable d, unsigned int width, + unsigned int height, unsigned int depth) +{ + abort(); +} + +Pixmap +XCreatePixmapFromBitmapData (Display *dpy, Drawable d, char *data, + unsigned int w, unsigned int h, + unsigned long fg, unsigned long bg, + unsigned int depth) +{ + abort(); +} + +int +XDrawString (Display *dpy, Drawable d, GC gc, int x, int y, const char *s, + int len) +{ + abort(); +} + +int +XFillRectangle (Display *dpy, Drawable d, GC gc, int x, int y, + unsigned int width, unsigned int height) +{ + abort(); +} + +int +XFreeColors (Display *dpy, Colormap cmap, unsigned long *px, int n, + unsigned long planes) +{ + abort(); +} + +int +XFreeGC (Display *dpy, GC gc) +{ + abort(); +} + +int +XFreePixmap (Display *dpy, Pixmap p) +{ + abort(); +} + +XImage * +XGetImage (Display *dpy, Drawable d, int x, int y, + unsigned int w, unsigned int h, + unsigned long pm, int fmt) +{ + abort(); +} + +Status +XGetWindowAttributes (Display *dpy, Window w, XWindowAttributes *xgwa) +{ + struct state *st = &global_state; + memset (xgwa, 0, sizeof(*xgwa)); + xgwa->width = st->output_frame->width; + xgwa->height = st->output_frame->height; + return True; +} + +int +XPutImage (Display *dpy, Drawable d, GC gc, XImage *image, + int src_x, int src_y, int dest_x, int dest_y, + unsigned int w, unsigned int h) +{ + struct state *st = &global_state; + XImage *out = st->output_frame; + int x, y; + for (y = 0; y < h; y++) { + int iy = src_y + y; + int oy = dest_y + y; + if (iy >= 0 && + oy >= 0 && + iy < image->height && + oy < out->height) + for (x = 0; x < w; x++) { + int ix = src_x + x; + int ox = dest_x + x; + if (ix >= 0 && + ox >= 0 && + ix < image->width && + ox < out->width) { + XPutPixel (out, ox, oy, XGetPixel (image, ix, iy)); + } + } + } + return 0; +} + +int +XQueryColor (Display *dpy, Colormap cmap, XColor *color) +{ + uint16_t r = (color->pixel & 0x00FF0000L) >> 16; + uint16_t g = (color->pixel & 0x0000FF00L) >> 8; + uint16_t b = (color->pixel & 0x000000FFL); + color->red = r | (r<<8); + color->green = g | (g<<8); + color->blue = b | (b<<8); + color->flags = DoRed|DoGreen|DoBlue; + return 0; +} + +int +XQueryColors (Display *dpy, Colormap cmap, XColor *c, int n) +{ + int i; + for (i = 0; i < n; i++) + XQueryColor (dpy, cmap, &c[i]); + return 0; +} + +int +XSetForeground (Display *dpy, GC gc, unsigned long fg) +{ + abort(); +} + +int +XSetWindowBackground (Display *dpy, Window win, unsigned long bg) +{ + return 0; +} + +XImage * +create_xshm_image (Display *dpy, Visual *visual, + unsigned int depth, + int format, XShmSegmentInfo *shm_info, + unsigned int width, unsigned int height) +{ +# undef BitmapPad +# define BitmapPad(dpy) 8 + XImage *image = XCreateImage (dpy, visual, depth, format, 0, NULL, + width, height, BitmapPad(dpy), 0); + int error = thread_malloc ((void **)&image->data, dpy, + image->height * image->bytes_per_line); + if (error) { + XDestroyImage (image); + image = NULL; + } else { + memset (image->data, 0, image->height * image->bytes_per_line); + } + + return image; +} + +void +destroy_xshm_image (Display *dpy, XImage *image, XShmSegmentInfo *shm_info) +{ + thread_free (image->data); + image->data = NULL; + XDestroyImage (image); +} + +Bool +get_boolean_resource (Display *dpy, char *name, char *class) +{ + if (!strcmp(name, "useThreads")) return True; + abort(); +} + +double +get_float_resource (Display *dpy, char *name, char *class) +{ + if (!strcmp(name, "TVTint")) return 5; + if (!strcmp(name, "TVColor")) return 70; + if (!strcmp(name, "TVBrightness")) return -15; + if (!strcmp(name, "TVContrast")) return 150; + abort(); +} + +int +get_integer_resource (Display *dpy, char *name, char *class) +{ + if (!strcmp(name, "use_cmap")) return 0; + abort(); +} + +unsigned int +get_pixel_resource (Display *dpy, Colormap cmap, char *name, char *class) +{ + if (!strcmp(name, "background")) return 0; + abort(); +} + +XFontStruct * +load_font_retry (Display *dpy, const char *xlfd) +{ + abort(); +} + +Bool +put_xshm_image (Display *dpy, Drawable d, GC gc, XImage *image, + int src_x, int src_y, int dest_x, int dest_y, + unsigned int width, unsigned int height, + XShmSegmentInfo *shm_info) +{ + return XPutImage (dpy, d, gc, image, src_x, src_y, dest_x, dest_y, + width, height); +} + +int +visual_class (Screen *s, Visual *v) +{ + return TrueColor; +} + +int +visual_pixmap_depth (Screen *s, Visual *v) +{ + return 32; +} + +void +visual_rgb_masks (Screen *screen, Visual *visual, + unsigned long *red_mask, + unsigned long *green_mask, + unsigned long *blue_mask) +{ + *red_mask = 0x00FF0000L; + *green_mask = 0x0000FF00L; + *blue_mask = 0x000000FFL; +} + + +static void +update_smpte_colorbars(analogtv_input *input) +{ + struct state *st = (struct state *) input->client_data; + int col; + int black_ntsc[4]; + + /* + SMPTE is the society of motion picture and television engineers, and + these are the standard color bars in the US. Following the partial spec + at http://broadcastengineering.com/ar/broadcasting_inside_color_bars/ + These are luma, chroma, and phase numbers for each of the 7 bars. + */ + double top_cb_table[7][3]={ + {75, 0, 0.0}, /* gray */ + {69, 31, 167.0}, /* yellow */ + {56, 44, 283.5}, /* cyan */ + {48, 41, 240.5}, /* green */ + {36, 41, 60.5}, /* magenta */ + {28, 44, 103.5}, /* red */ + {15, 31, 347.0} /* blue */ + }; + double mid_cb_table[7][3]={ + {15, 31, 347.0}, /* blue */ + {7, 0, 0}, /* black */ + {36, 41, 60.5}, /* magenta */ + {7, 0, 0}, /* black */ + {56, 44, 283.5}, /* cyan */ + {7, 0, 0}, /* black */ + {75, 0, 0.0} /* gray */ + }; + + analogtv_lcp_to_ntsc(0.0, 0.0, 0.0, black_ntsc); + + analogtv_setup_sync(input, 1, 0); + + for (col=0; col<7; col++) { + analogtv_draw_solid_rel_lcp(input, col*(1.0/7.0), (col+1)*(1.0/7.0), 0.00, 0.68, + top_cb_table[col][0], + top_cb_table[col][1], top_cb_table[col][2]); + + analogtv_draw_solid_rel_lcp(input, col*(1.0/7.0), (col+1)*(1.0/7.0), 0.68, 0.75, + mid_cb_table[col][0], + mid_cb_table[col][1], mid_cb_table[col][2]); + } + + analogtv_draw_solid_rel_lcp(input, 0.0, 1.0/6.0, + 0.75, 1.00, 7, 40, 303); /* -I */ + analogtv_draw_solid_rel_lcp(input, 1.0/6.0, 2.0/6.0, + 0.75, 1.00, 100, 0, 0); /* white */ + analogtv_draw_solid_rel_lcp(input, 2.0/6.0, 3.0/6.0, + 0.75, 1.00, 7, 40, 33); /* +Q */ + analogtv_draw_solid_rel_lcp(input, 3.0/6.0, 4.0/6.0, + 0.75, 1.00, 7, 0, 0); /* black */ + analogtv_draw_solid_rel_lcp(input, 12.0/18.0, 13.0/18.0, + 0.75, 1.00, 3, 0, 0); /* black -4 */ + analogtv_draw_solid_rel_lcp(input, 13.0/18.0, 14.0/18.0, + 0.75, 1.00, 7, 0, 0); /* black */ + analogtv_draw_solid_rel_lcp(input, 14.0/18.0, 15.0/18.0, + 0.75, 1.00, 11, 0, 0); /* black +4 */ + analogtv_draw_solid_rel_lcp(input, 5.0/6.0, 6.0/6.0, + 0.75, 1.00, 7, 0, 0); /* black */ + if (st->logo) + { + double aspect = (double) + st->output_frame->width / st->output_frame->height; + int w2 = st->tv->xgwa.width * 0.35; + int h2 = st->tv->xgwa.height * 0.35 * aspect; + analogtv_load_ximage (st->tv, input, st->logo, st->logo_mask, + (st->tv->xgwa.width - w2) / 2, + st->tv->xgwa.height * 0.20, + w2, h2); + } + + input->next_update_time += 1.0; +} + + + +static void +analogtv_save_frame (struct state *st, const char *outfile, + unsigned long frame) +{ + char *pngfile = malloc (strlen (st->framefile_fmt) + 40); + FILE *f; + + sprintf (pngfile, st->framefile_fmt, (int) frame); + f = fopen (pngfile, "wb"); + if (! f) { + fprintf (stderr, "%s: unable to write %s\n", progname, pngfile); + exit (1); + } + +# ifdef HAVE_LIBPNG + { + png_structp png_ptr; + png_infop info_ptr; + png_bytep row; + XImage *img = st->output_frame; + int x, y; + + png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, 0, 0, 0); + if (!png_ptr) abort(); + info_ptr = png_create_info_struct (png_ptr); + if (!info_ptr) abort(); + if (setjmp (png_jmpbuf (png_ptr))) abort(); + + png_init_io (png_ptr, f); + + png_set_IHDR (png_ptr, info_ptr, img->width, img->height, 8, + PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + png_write_info (png_ptr, info_ptr); + + row = (png_bytep) malloc (3 * img->width * sizeof(png_byte)); + if (!row) abort(); + for (y = 0 ; y < img->height ; y++) { + for (x = 0 ; x < img->width ; x++) { + unsigned long p = XGetPixel (img, x, y); + row[x*3+0] = (p & 0x000000FFL); + row[x*3+1] = (p & 0x0000FF00L) >> 8; + row[x*3+2] = (p & 0x00FF0000L) >> 16; + } + png_write_row (png_ptr, row); + } + + png_write_end (png_ptr, 0); + + png_free_data (png_ptr, info_ptr, PNG_FREE_ALL, -1); + png_destroy_write_struct (&png_ptr, 0); + free (row); + } +#else /* ! HAVE_LIBPNG */ +# error libpng required +# endif /* ! HAVE_LIBPNG */ + + fclose (f); + if (verbose_p > 1) + fprintf (stderr, "%s: wrote %s\n", progname, pngfile); + free (pngfile); +} + + +static void +delete_tmp_files(void) +{ + struct state *st = &global_state; + char outfile[2048]; + int i; + for (i = 0; i <= st->frames_written; i++) + { + sprintf (outfile, st->framefile_fmt, i); + if (verbose_p > 1) + fprintf (stderr, "%s: rm %s\n", progname, outfile); + unlink (outfile); + } +} + + +static RETSIGTYPE +analogtv_signal (int sig) +{ + signal (sig, SIG_DFL); + delete_tmp_files(); + kill (getpid (), sig); +} + + +static void +analogtv_write_mp4 (struct state *st, const char *outfile, + const char *audiofile, + unsigned long frames) +{ + char cmd[1024]; + struct stat ss; + + sprintf (cmd, + "ffmpeg" + " -hide_banner" + " -v 16" + " -framerate 30" /* rate of input: must be before -i */ + " -i '%s'" + " -r 30", /* rate of output: must be after -i */ + st->framefile_fmt); + if (audiofile) + sprintf (cmd + strlen(cmd), + " -i '%s'" + " -map 0:v:0" + " -map 1:a:0" + " -acodec aac" + " -shortest", + audiofile); + sprintf (cmd + strlen(cmd), + " -c:v libx264" + " -profile:v high" + " -crf 24" /* 18 is very high; 24 is good enough */ + " -pix_fmt yuv420p" + " '%s'" + " &-"*/, + outfile); + + if (verbose_p > 1) + fprintf (stderr, "%s: exec: %s\n", progname, cmd); + unlink (outfile); + system (cmd); + + delete_tmp_files(); + + if (stat (outfile, &ss)) + { + fprintf (stderr, "%s: %s was not created\n", progname, outfile); + exit (1); + } + + if (verbose_p) + fprintf (stderr, "%s: wrote %s (%dx%d, %lu sec, %.0f MB)\n", + progname, outfile, + st->output_frame->width, st->output_frame->height, + frames/30, + (float) ss.st_size / (1024*1024)); +} + + +static void +flip_ximage (XImage *ximage) +{ + char *data2, *in, *out; + int y; + + if (!ximage) return; + data2 = malloc (ximage->bytes_per_line * ximage->height); + if (!data2) abort(); + in = ximage->data; + out = data2 + ximage->bytes_per_line * (ximage->height - 1); + for (y = 0; y < ximage->height; y++) + { + memcpy (out, in, ximage->bytes_per_line); + in += ximage->bytes_per_line; + out -= ximage->bytes_per_line; + } + free (ximage->data); + ximage->data = data2; +} + + +static void +analogtv_convert (const char *infile, const char *outfile, + const char *audiofile, const char *logofile, + int duration, Bool powerp) +{ + struct state *st = &global_state; + XImage *ximage = file_to_ximage (0, 0, infile); + Display *dpy = 0; + Window window = 0; + int i; + unsigned long curticks = 0; + time_t lastlog = time((time_t *)0); + int frames_left; + int fps = 30; + + if (verbose_p) + fprintf (stderr, "%s: progname: loaded %s %dx%d\n", + progname, infile, ximage->width, ximage->height); + + flip_ximage (ximage); + + memset (st, 0, sizeof(*st)); + st->dpy = dpy; + st->window = window; + + st->output_frame = XCreateImage (dpy, 0, ximage->depth, ximage->format, 0, + NULL, + ximage->width & ~1, /* can't be odd */ + ximage->height & ~1, + ximage->bitmap_pad, 0); + st->output_frame->data = (char *) + calloc (st->output_frame->height, st->output_frame->bytes_per_line); + + { + char *s1, *s2; + st->framefile_fmt = malloc (strlen(outfile) + 100); + strcpy (st->framefile_fmt, outfile); + s1 = strrchr (st->framefile_fmt, '/'); + s2 = strrchr (st->framefile_fmt, '.'); + if (s2 && s2 > s1) *s2 = 0; + sprintf (st->framefile_fmt + strlen(st->framefile_fmt), + ".%08x.%%06d.png", (random() % 0xFFFFFFFF)); + } + + if (logofile) { + int x, y; + st->logo = file_to_ximage (0, 0, logofile); + if (verbose_p) + fprintf (stderr, "%s: progname: loaded %s %dx%d\n", + progname, logofile, st->logo->width, st->logo->height); + flip_ximage (st->logo); + /* Pull the alpha out of the logo and make a separate mask ximage. */ + st->logo_mask = XCreateImage (dpy, 0, st->logo->depth, st->logo->format, 0, + NULL, st->logo->width, st->logo->height, + st->logo->bitmap_pad, 0); + st->logo_mask->data = (char *) + calloc (st->logo_mask->height, st->logo_mask->bytes_per_line); + + for (y = 0; y < st->logo->height; y++) + for (x = 0; x < st->logo->width; x++) { + unsigned long p = XGetPixel (st->logo, x, y); + uint8_t a = (p & 0xFF000000L) >> 24; + XPutPixel (st->logo, x, y, (p & 0x00FFFFFFL)); + XPutPixel (st->logo_mask, x, y, (a ? 0x00FFFFFFL : 0)); + } + } + + + if (audiofile) { + struct stat ss; + if (stat (audiofile, &ss)) + { + fprintf (stderr, "%s: %s does not exist\n", progname, audiofile); + exit (1); + } + } + + /* Catch signals to delete tmp files before we start writing them. */ + + signal (SIGHUP, analogtv_signal); + signal (SIGINT, analogtv_signal); + signal (SIGQUIT, analogtv_signal); + signal (SIGILL, analogtv_signal); + signal (SIGTRAP, analogtv_signal); +# ifdef SIGIOT + signal (SIGIOT, analogtv_signal); +# endif + signal (SIGABRT, analogtv_signal); +# ifdef SIGEMT + signal (SIGEMT, analogtv_signal); +# endif + signal (SIGFPE, analogtv_signal); + signal (SIGBUS, analogtv_signal); + signal (SIGSEGV, analogtv_signal); +# ifdef SIGSYS + signal (SIGSYS, analogtv_signal); +# endif + signal (SIGTERM, analogtv_signal); +# ifdef SIGXCPU + signal (SIGXCPU, analogtv_signal); +# endif +# ifdef SIGXFSZ + signal (SIGXFSZ, analogtv_signal); +# endif +# ifdef SIGDANGER + signal (SIGDANGER, analogtv_signal); +# endif + + st->tv=analogtv_allocate(dpy, window); + + while (st->n_stations < MAX_STATIONS) { + analogtv_input *input=analogtv_input_allocate(); + st->stations[st->n_stations++]=input; + input->client_data = st; + } + + analogtv_set_defaults(st->tv, ""); + st->tv->need_clear=1; + + if (random()%4==0) { + st->tv->tint_control += pow(frand(2.0)-1.0, 7) * 180.0; + } + if (1) { + st->tv->color_control += frand(0.3) * RANDSIGN(); + } + if (random()%4==0) { + st->tv->brightness_control += frand(0.15); + } + if (random()%4==0) { + st->tv->contrast_control += frand(0.2) * RANDSIGN(); + } + + for (i=0; ichansettings[i], 0, sizeof(chansetting)); + + st->chansettings[i].noise_level = 0.06; + { + int last_station=42; + int stati; + for (stati=0; statichansettings[i].recs[stati]; + int station; + while (1) { + station=random()%st->n_stations; + if (station!=last_station) break; + if ((random()%10)==0) break; + } + last_station=station; + rec->input = st->stations[station]; + rec->level = pow(frand(1.0), 3.0) * 2.0 + 0.05; + rec->ofs=random()%ANALOGTV_SIGNAL_LEN; + if (random()%3) { + rec->multipath = frand(1.0); + } else { + rec->multipath=0.0; + } + if (stati) { + /* We only set a frequency error for ghosting stations, + because it doesn't matter otherwise */ + rec->freqerr = (frand(2.0)-1.0) * 3.0; + } + + if (rec->level > 0.3) break; + if (random()%4) break; + } + } + } + + st->curinputi=0; + st->cs = &st->chansettings[st->curinputi]; + frames_left = fps * (2 + frand(1.5)); + + st->tv->powerup=0.0; + + /* load_station_images() */ + + for (i = 0; i < MAX_STATIONS; i++) { + analogtv_input *input = st->stations[i]; + + if (i == 1) { /* station 0 is the unadulterated image. + station 1 is colorbars. */ + input->updater = update_smpte_colorbars; + } else { + int w = ximage->width * 0.815; /* underscan */ + int h = ximage->height * 0.970; + int x = (ximage->width - w) / 2; + int y = (ximage->height - h) / 2; + analogtv_input *input = st->stations[i]; + analogtv_setup_sync(input, 1, (random()%20)==0); + analogtv_load_ximage (st->tv, input, ximage, 0, x, y, w, h); + } + } + + + /* xanalogtv_draw() */ + + while (1) { + const analogtv_reception *recs[MAX_MULTICHAN]; + unsigned rec_count = 0; + double curtime=curticks*0.001; + + frames_left--; + if (frames_left <= 0) { + frames_left = fps * (0.5 + frand(2.5)); + + if (st->curinputi != 0 && !(random() % 3)) { + st->curinputi = 0; /* unadulterated image */ + } else { + st->curinputi = 1 + (random() % (N_CHANNELS - 1)); + } + + st->cs = &st->chansettings[st->curinputi]; + /* Set channel change noise flag */ + st->tv->channel_change_cycles=200000; + } + + for (i=0; ics->recs[i]; + analogtv_input *inp=rec->input; + if (!inp) continue; + + if (inp->updater) { + inp->next_update_time = curtime; + (inp->updater)(inp); + } + rec->ofs += rec->freqerr; + } + + st->tv->powerup=(powerp ? curtime : 9999); + + if (st->curinputi == 0) { + XPutImage (dpy, 0, 0, ximage, 0, 0, 0, 0, + ximage->width, ximage->height); + } else { + for (i=0; ics->recs[i]; + if (rec->input) { + analogtv_reception_update(rec); + recs[rec_count] = rec; + ++rec_count; + } + } + analogtv_draw (st->tv, st->cs->noise_level, recs, rec_count); + } + + analogtv_save_frame (st, outfile, st->frames_written); + + if (curtime >= duration) break; + + curticks += 1000/fps; + st->frames_written++; + + if (verbose_p) { + unsigned long now = time((time_t *)0); + if (now > lastlog + 5) { + fprintf (stderr, "%s: %2d%%...\n", progname, + (int) (curtime * 100 / duration)); + lastlog = now; + } + } + } + + analogtv_write_mp4 (st, outfile, audiofile, st->frames_written); +} + + +static void +usage(const char *err) +{ + if (err) fprintf (stderr, "%s: %s unknown\n", progname, err); + fprintf (stderr, "usage: %s [--verbose] [--duration secs]" + " [--audio mp3-file] [--no-powerup] infile.png outfile.mp4\n", + progname); + exit (1); +} + +int +main (int argc, char **argv) +{ + int i; + const char *infile = 0; + const char *outfile = 0; + int duration = 30; + Bool powerp = False; + char *audio = 0; + char *logo = 0; + + char *s = strrchr (argv[0], '/'); + progname = s ? s+1 : argv[0]; + progclass = progname; + + for (i = 1; i < argc; i++) + { + if (argv[i][0] == '-' && argv[i][1] == '-') + argv[i]++; + if (!strcmp(argv[i], "-v") || + !strcmp(argv[i], "-verbose")) + verbose_p++; + else if (!strcmp(argv[i], "-vv")) verbose_p += 2; + else if (!strcmp(argv[i], "-vvv")) verbose_p += 3; + else if (!strcmp(argv[i], "-vvvv")) verbose_p += 4; + else if (!strcmp(argv[i], "-vvvvv")) verbose_p += 5; + else if (!strcmp(argv[i], "-duration") && argv[i+1]) + { + char dummy; + i++; + if (1 != sscanf (argv[i], " %d %c", &duration, &dummy)) + usage(argv[i]); + } + else if (!strcmp(argv[i], "-audio") && argv[i+1]) + audio = argv[++i]; + else if (!strcmp(argv[i], "-logo") && argv[i+1]) + logo = argv[++i]; + else if (!strcmp(argv[i], "-powerup") || + !strcmp(argv[i], "-power")) + powerp = True; + else if (!strcmp(argv[i], "-no-powerup") || + !strcmp(argv[i], "-no-power")) + powerp = False; + else if (argv[i][0] == '-') + usage(argv[i]); + else if (!infile) + infile = argv[i]; + else if (!outfile) + outfile = argv[i]; + else + usage(argv[i]); + } + if (!infile) usage("input file"); + if (!outfile) usage("output file"); + +# undef ya_rand_init + ya_rand_init (0); + analogtv_convert (infile, outfile, audio, logo, duration, powerp); + exit (0); +} diff --git a/hacks/analogtv.c b/hacks/analogtv.c index fd7f504..8ef3c7d 100644 --- a/hacks/analogtv.c +++ b/hacks/analogtv.c @@ -329,7 +329,7 @@ analogtv_configure(analogtv *it) wlim = it->xgwa.width; ratio = wlim / (float) hlim; -#ifdef HAVE_MOBILE +#if defined(HAVE_MOBILE) || defined(NO_CONSTRAIN_RATIO) /* Fill the whole iPhone screen, even though that distorts the image. */ min_ratio = 0; max_ratio = 10; @@ -1002,7 +1002,7 @@ analogtv_setup_sync(analogtv_input *input, int do_cb, int do_ssavi) if (do_cb) { /* 9 cycles of colorburst */ - for (i=ANALOGTV_CB_START; irx_signal + lineno*ANALOGTV_H + cur_hsync;*/ - for (i=-32; i<32; i++) { + for (i=-32*ANALOGTV_SCALE; i<32*ANALOGTV_SCALE; i++) { lineno = (cur_vsync + i + ANALOGTV_V) % ANALOGTV_V; sp = it->rx_signal + lineno*ANALOGTV_H; filt=0.0f; - for (j=0; jagclevel; @@ -1039,11 +1039,11 @@ analogtv_sync(analogtv *it) for (lineno=0; lineno5 && lineno5*ANALOGTV_SCALE && linenorx_signal + lineno2*ANALOGTV_H + cur_hsync; - for (i=-8; i<8; i++) { + for (i=-8*ANALOGTV_SCALE; i<8*ANALOGTV_SCALE; i++) { osc = (float)(ANALOGTV_H+i)/(float)ANALOGTV_H; filt=(sp[i-3]+sp[i-2]+sp[i-1]+sp[i]) * it->agclevel; @@ -1061,9 +1061,9 @@ analogtv_sync(analogtv *it) cycles. */ - if (lineno>15) { + if (lineno>15*ANALOGTV_SCALE) { sp = it->rx_signal + lineno*ANALOGTV_H + (cur_hsync&~3); - for (i=ANALOGTV_CB_START+8; icb_phase[i&3] = it->cb_phase[i&3]*(1.0f-cbfc) + sp[i]*it->agclevel*cbfc; } @@ -2009,7 +2009,7 @@ analogtv_load_ximage(analogtv *it, analogtv_input *input, unsigned long black = 0; /* not BlackPixelOfScreen (it->xgwa.screen); */ int x_length=ANALOGTV_PIC_LEN; - int y_overscan=5; /* overscan this much top and bottom */ + int y_overscan=5*ANALOGTV_SCALE; /* overscan this much top and bottom */ int y_scanlength=ANALOGTV_VISLINES+2*y_overscan; if (target_w > 0) x_length = x_length * target_w / it->xgwa.width; @@ -2297,8 +2297,8 @@ analogtv_make_font(Display *dpy, Window window, analogtv_font *f, f->text_im->bytes_per_line); } - f->x_mult=4; - f->y_mult=2; + f->x_mult=4 * ANALOGTV_SCALE; + f->y_mult=2 * ANALOGTV_SCALE; } int @@ -2415,7 +2415,7 @@ analogtv_draw_string(analogtv_input *input, analogtv_font *f, { while (*s) { analogtv_draw_char(input, f, *s, x, y, ntsc); - x += f->char_w * 4; + x += f->char_w * f->x_mult; s++; } } @@ -2424,7 +2424,7 @@ void analogtv_draw_string_centered(analogtv_input *input, analogtv_font *f, char *s, int x, int y, int ntsc[4]) { - int width=strlen(s) * f->char_w * 4; + int width=strlen(s) * f->char_w * f->x_mult; x -= width/2; analogtv_draw_string(input, f, s, x, y, ntsc); diff --git a/hacks/analogtv.h b/hacks/analogtv.h index e3170f1..4b11b58 100644 --- a/hacks/analogtv.h +++ b/hacks/analogtv.h @@ -19,21 +19,29 @@ # define HAVE_MOBILE #endif +/* To simulate an NTSC CRT monitor with way more scanlines, and thus + apply an ahistorical tv-like effect to a larger image, increase + this resolution multiplier. + */ +#ifndef ANALOGTV_SCALE +# define ANALOGTV_SCALE 1 +#endif + /* You'll need these to generate standard NTSC TV signals */ enum { /* We don't handle interlace here */ - ANALOGTV_V=262, - ANALOGTV_TOP=30, - ANALOGTV_VISLINES=200, + ANALOGTV_V=262*ANALOGTV_SCALE, + ANALOGTV_TOP=30*ANALOGTV_SCALE, + ANALOGTV_VISLINES=200*ANALOGTV_SCALE, ANALOGTV_BOT=ANALOGTV_TOP + ANALOGTV_VISLINES, /* This really defines our sampling rate, 4x the colorburst frequency. Handily equal to the Apple II's dot clock. You could also make a case for using 3x the colorburst freq, but 4x isn't hard to deal with. */ - ANALOGTV_H=912, + ANALOGTV_H=912*ANALOGTV_SCALE, /* Each line is 63500 nS long. The sync pulse is 4700 nS long, etc. Define sync, back porch, colorburst, picture, and front porch @@ -54,7 +62,7 @@ enum { ANALOGTV_VIS_END=ANALOGTV_PIC_START + (ANALOGTV_PIC_LEN*7/8), ANALOGTV_VIS_LEN=ANALOGTV_VIS_END-ANALOGTV_VIS_START, - ANALOGTV_HASHNOISE_LEN=6, + ANALOGTV_HASHNOISE_LEN=6*ANALOGTV_SCALE, ANALOGTV_GHOSTFIR_LEN=4, diff --git a/hacks/anemone.c b/hacks/anemone.c index deedb27..f0ea5e8 100644 --- a/hacks/anemone.c +++ b/hacks/anemone.c @@ -409,6 +409,9 @@ anemone_free (Display *dpy, Window window, void *closure) struct state *st = (struct state *) closure; if (st->vPendage) free (st->vPendage); if (st->appD) free (st->appD); + XFreeGC (dpy, st->gcDraw); + XFreeGC (dpy, st->gcClear); + free (st->colors); free (st); } diff --git a/hacks/anemotaxis.c b/hacks/anemotaxis.c index 9f240e8..04c12e3 100644 --- a/hacks/anemotaxis.c +++ b/hacks/anemotaxis.c @@ -722,6 +722,9 @@ anemotaxis_free (Display *dpy, Window window, void *closure) if (st->searcher[i]) destroy_searcher (st->searcher[i]); free (st->searcher); } + XFreeGC (dpy, st->gcDraw); + XFreeGC (dpy, st->gcClear); + free (st->colors); free (st); } diff --git a/hacks/apple2-main.c b/hacks/apple2-main.c index 3063b58..c30be1f 100644 --- a/hacks/apple2-main.c +++ b/hacks/apple2-main.c @@ -813,7 +813,7 @@ struct terminal_controller_data { /* The structure of closure linkage throughout this code is so amazingly baroque that I can't get to the 'struct state' from where I need it. */ -static const char *global_program; +static char *global_program; static Bool global_fast_p; @@ -1825,8 +1825,10 @@ apple2_init (Display *dpy, Window window) } if (s) free (s); - global_program = get_string_resource (dpy, "program", "Program"); - global_fast_p = get_boolean_resource (dpy, "fast", "Boolean"); + if (!global_program) { + global_program = get_string_resource (dpy, "program", "Program"); + global_fast_p = get_boolean_resource (dpy, "fast", "Boolean"); + } /* Kludge for MacOS standalone mode: see OSX/SaverRunner.m. */ @@ -1836,7 +1838,8 @@ apple2_init (Display *dpy, Window window) { st->controller = terminal_controller; st->random_p = False; - global_program = getenv ("SHELL"); + if (global_program) free (global_program); + global_program = strdup (getenv ("SHELL")); global_fast_p = True; } } @@ -1906,6 +1909,8 @@ apple2_free (Display *dpy, Window window, void *closure) if (apple2_one_frame (st->sim)) abort(); /* should have freed! */ } + if (global_program) free (global_program); + global_program = 0; free (st); } diff --git a/hacks/attraction.c b/hacks/attraction.c index 4fe22c2..25bc3b0 100644 --- a/hacks/attraction.c +++ b/hacks/attraction.c @@ -227,6 +227,7 @@ attraction_init (Display *dpy, Window window) progname, mode_str); exit (1); } + if (mode_str) free (mode_str); graph_mode_str = get_string_resource (dpy, "graphmode", "Mode"); if (! graph_mode_str) st->graph_mode = graph_none; @@ -241,6 +242,7 @@ attraction_init (Display *dpy, Window window) progname, graph_mode_str); exit (1); } + if (graph_mode_str) free (graph_mode_str); /* only allocate memory if it is needed */ if(st->graph_mode != graph_none) @@ -1044,6 +1046,9 @@ attraction_free (Display *dpy, Window window, void *closure) if (st->colors) free (st->colors); if (st->spl) free_spline (st->spl); + XFreeGC (dpy, st->draw_gc); + XFreeGC (dpy, st->erase_gc); + free (st); } diff --git a/hacks/barcode.c b/hacks/barcode.c index 31574bd..2ce609e 100644 --- a/hacks/barcode.c +++ b/hacks/barcode.c @@ -391,14 +391,12 @@ static void bitmapClear (Bitmap *b) memset (b->buf, 0, b->widthBytes * b->height); } -#if 0 /* free a bitmap */ static void bitmapFree (Bitmap *b) { free (b->buf); free (b); } -#endif /* get the byte value at the given byte-offset coordinates in the given @@ -1913,6 +1911,16 @@ barcode_reshape (Display *dpy, Window window, void *closure, static void barcode_free (Display *dpy, Window window, void *closure) { + struct state *st = (struct state *) closure; + int i; + XFreeGC (dpy, st->theGC); + st->theImage->data = 0; + XDestroyImage (st->theImage); + bitmapFree (st->theBitmap); + for (i = 0; i < st->barcode_max; i++) + bitmapFree (st->barcodes[i].bitmap); + free (st->barcodes); + free (st); } diff --git a/hacks/binaryring.c b/hacks/binaryring.c index 3cbaec2..755a1b4 100644 --- a/hacks/binaryring.c +++ b/hacks/binaryring.c @@ -554,10 +554,12 @@ static void binaryring_free ( Display* display, Window win, void *closure ) { XWindowAttributes tmp; XGetWindowAttributes(display, win, &tmp); - free( st->buffer ); - free( st->particles ); - - free ( st ); + if (st->gc) XFreeGC (display, st->gc); + if (st->pix) XFreePixmap (display, st->pix); + if (st->buf) XDestroyImage (st->buf); + free (st->buffer); + free (st->particles); + free (st); } diff --git a/hacks/blaster.c b/hacks/blaster.c index a60351a..5ab3741 100644 --- a/hacks/blaster.c +++ b/hacks/blaster.c @@ -1083,6 +1083,8 @@ blaster_free (Display *dpy, Window window, void *closure) if (st->l_color1) XFreeGC (dpy, st->l_color1); if (st->s_color) XFreeGC (dpy, st->s_color); if (st->black) XFreeGC (dpy, st->black); + if (st->EXPLODE_COLOR_1) XFreeGC (dpy, st->EXPLODE_COLOR_1); + if (st->EXPLODE_COLOR_2) XFreeGC (dpy, st->EXPLODE_COLOR_2); if (st->stars) free (st->stars); if (st->mother) { free (st->mother->lasers); diff --git a/hacks/blitspin.c b/hacks/blitspin.c index d27271d..00d9109 100644 --- a/hacks/blitspin.c +++ b/hacks/blitspin.c @@ -256,11 +256,13 @@ blitspin_init (Display *d_arg, Window w_arg) bitmap_name = get_string_resource (st->dpy, "bitmap", "Bitmap"); if (! bitmap_name || !*bitmap_name) - bitmap_name = "(default)"; + bitmap_name = strdup ("(default)"); if (!strcasecmp (bitmap_name, "(default)") || - !strcasecmp (bitmap_name, "default")) - bitmap_name = "(screen)"; + !strcasecmp (bitmap_name, "default")) { + free (bitmap_name); + bitmap_name = strdup ("(screen)"); + } if (!strcasecmp (bitmap_name, "(builtin)") || !strcasecmp (bitmap_name, "builtin")) @@ -309,6 +311,7 @@ blitspin_init (Display *d_arg, Window w_arg) blitspin_init_2 (st); } + if (bitmap_name) free (bitmap_name); return st; } @@ -421,6 +424,18 @@ blitspin_event (Display *dpy, Window window, void *closure, XEvent *event) static void blitspin_free (Display *dpy, Window window, void *closure) { + struct state *st = (struct state *) closure; +# ifdef USE_XCOPYAREA + if (st->gc_set) XFreeGC (dpy, st->gc_set); + if (st->gc_clear) XFreeGC (dpy, st->gc_clear); + if (st->gc_copy) XFreeGC (dpy, st->gc_copy); + if (st->gc_and) XFreeGC (dpy, st->gc_and); + if (st->gc_or) XFreeGC (dpy, st->gc_or); + if (st->gc_xor) XFreeGC (dpy, st->gc_xor); +# endif + if (st->gc) XFreeGC (dpy, st->gc); + XFreePixmap (dpy, st->bitmap); + free (st); } diff --git a/hacks/boxfit.c b/hacks/boxfit.c index 1b1d0d7..09d2ef7 100644 --- a/hacks/boxfit.c +++ b/hacks/boxfit.c @@ -88,6 +88,7 @@ reset_boxes (state *st) progname, s); exit (1); } + free (s); } if (st->mode == -1) @@ -514,6 +515,11 @@ boxfit_event (Display *dpy, Window window, void *closure, XEvent *event) static void boxfit_free (Display *dpy, Window window, void *closure) { + state *st = (state *) closure; + if (st->boxes) free (st->boxes); + if (st->colors) free (st->colors); + XFreeGC (dpy, st->gc); + free (st); } diff --git a/hacks/bsod.c b/hacks/bsod.c index ff6c359..f3af911 100644 --- a/hacks/bsod.c +++ b/hacks/bsod.c @@ -61,6 +61,8 @@ #include "images/gen/macbomb_png.h" #include "images/gen/apple_png.h" #include "images/gen/atm_png.h" +#include "images/gen/sun_png.h" +#include "images/gen/dvd_png.h" #undef countof #define countof(x) (sizeof((x))/sizeof((*x))) @@ -481,8 +483,14 @@ draw_char (struct bsod_state *bst, char c) { int dir, ascent, descent; XCharStruct ov; + Bool cursorp = (c == '\033'); /* apparently \e is non-standard now! */ + + if (cursorp) c = ' '; XTextExtents (bst->font, &c, 1, &dir, &ascent, &descent, &ov); + if (bst->x < bst->left_margin) + bst->x = bst->left_margin; + if ((bst->wrap_p || bst->word_wrap_p) && bst->x + ov.width > bst->xgwa.width - bst->right_margin - bst->xoff) { @@ -518,8 +526,30 @@ draw_char (struct bsod_state *bst, char c) } } + /* We render the character ESC as an inverted space (block cursor). */ + + if (cursorp) + { + unsigned long swap = bst->fg; + bst->fg = bst->bg; + bst->bg = swap; + XSetForeground (bst->dpy, bst->gc, bst->fg); + XSetBackground (bst->dpy, bst->gc, bst->bg); + } + XDrawImageString (bst->dpy, bst->window, bst->gc, bst->x, bst->y, &c, 1); + + if (cursorp) + { + unsigned long swap = bst->fg; + bst->fg = bst->bg; + bst->bg = swap; + XSetForeground (bst->dpy, bst->gc, bst->fg); + XSetBackground (bst->dpy, bst->gc, bst->bg); + c = ' '; + } + bst->x += ov.width; if (bst->word_wrap_p) @@ -670,6 +700,11 @@ bsod_pop (struct bsod_state *bst) int h = (long) bst->queue[bst->pos].arg4; int tox = (long) bst->queue[bst->pos].arg5; int toy = (long) bst->queue[bst->pos].arg6; + + /* If ~0, place pixmap at current text pos */ + if (tox == ~0) tox = bst->x; + if (toy == ~0) toy = bst->y - bst->font->ascent; + if (type == PIXMAP && bst->mask) { XSetClipMask (bst->dpy, bst->gc, bst->mask); @@ -838,7 +873,7 @@ make_bsod_state (Display *dpy, Window window, char buf1[1024], buf2[1024]; char buf5[1024], buf6[1024]; char buf7[1024], buf8[1024]; - const char *font1, *font3, *font4; + char *font1, *font3, *font4; bst = (struct bsod_state *) calloc (1, sizeof (*bst)); bst->queue_size = 10; @@ -939,6 +974,11 @@ make_bsod_state (Display *dpy, Window window, bst->y = bst->font->ascent + bst->left_margin + bst->yoff; XSetWindowBackground (dpy, window, gcv.background); + + if (font1) free (font1); + if (font3) free (font3); + if (font4) free (font4); + return bst; } @@ -956,6 +996,8 @@ free_bsod_state (struct bsod_state *bst) XFreePixmap(bst->dpy, bst->mask); XFreeFont (bst->dpy, bst->font); + if (bst->fontB && bst->fontB != bst->font) XFreeFont (bst->dpy, bst->fontB); + if (bst->fontC && bst->fontC != bst->font) XFreeFont (bst->dpy, bst->fontC); XFreeGC (bst->dpy, bst->gc); for (i = 0; i < bst->queue_size; i++) @@ -3217,6 +3259,36 @@ sparc_solaris (Display *dpy, Window window) { struct bsod_state *bst = make_bsod_state (dpy, window, "solaris", "Solaris"); int i; + int pix_w = 0, pix_h = 0; + int char_width; + Pixmap mask = 0; + Pixmap pixmap = image_data_to_pixmap (dpy, window, + sun_png, sizeof(sun_png), + &pix_w, &pix_h, &mask); +# if 0 + if (pixmap && + pix_w < bst->xgwa.width / 2 && + pix_h < bst->xgwa.height / 2) + { + int i, n = 1; + if (bst->xgwa.width > 2560) n++; /* Retina displays */ + for (i = 0; i < n; i++) + { + pixmap = double_pixmap (dpy, bst->xgwa.visual, + bst->xgwa.depth, pixmap, pix_w, pix_h); + mask = double_pixmap (dpy, bst->xgwa.visual, 1, mask, pix_w, pix_h); + pix_w *= 2; + pix_h *= 2; + } + } +# endif + + char_width = (bst->font->per_char + ? bst->font->per_char['n'-bst->font->min_char_or_byte2].width + : bst->font->min_bounds.width); + + bst->pixmap = pixmap; + bst->mask = mask; bst->scroll_p = True; bst->wrap_p = True; @@ -3224,8 +3296,14 @@ sparc_solaris (Display *dpy, Window window) bst->top_margin = bst->bottom_margin = bst->xgwa.height * 0.07; bst->y = bst->top_margin + bst->yoff + bst->font->ascent; +# if 0 + /* This looks correct if we have a desktop image behind it, but doesn't + make sense if it's a photo. So let's skip it. */ BSOD_IMG (bst); BSOD_PAUSE (bst, 3000000); +# endif + + BSOD_LINE_DELAY (bst, 20000); BSOD_INVERT(bst); BSOD_RECT (bst, True, @@ -3260,30 +3338,359 @@ sparc_solaris (Display *dpy, Window window) " 100131480 10012a6e0 0\n" "End traceback...\n" "panic[cpu0]/thread=30000953a20: trap\n" - "syncing file systems..."); + "syncing file systems...\033"); BSOD_PAUSE (bst, 3000000); - BSOD_TEXT (bst, LEFT, " 1 done\n"); - BSOD_TEXT (bst, LEFT, "dumping to /dev/dsk/c0t0d0s3, offset 26935296\n"); + BSOD_TEXT (bst, LEFT, "\b 1 done\n"); + BSOD_TEXT (bst, LEFT, "dumping to /dev/dsk/c0t0d0s3, offset 26935296\n\033"); BSOD_PAUSE (bst, 2000000); - + BSOD_TEXT (bst, LEFT, "\b"); for (i = 1; i <= 100; ++i) { char buf[100]; - sprintf (buf, "\b\b\b\b\b\b\b\b\b\b\b%3d%% done", i); + sprintf (buf, "\r %3d%% done\033", i); BSOD_TEXT (bst, LEFT, buf); BSOD_PAUSE (bst, 100000); } BSOD_TEXT (bst, LEFT, - ": 2803 pages dumped, compression ratio 2.88, dump succeeded\n"); + "\b: 2803 pages dumped, compression ratio 2.88, dump succeeded\n\033"); BSOD_PAUSE (bst, 2000000); BSOD_TEXT (bst, LEFT, - "rebooting...\n" - "Resetting ..."); + "\brebooting...\n" + "Resetting ...\n\033"); + + BSOD_PAUSE (bst, 3000000); + + BSOD_INVERT(bst); + BSOD_RECT (bst, True, + bst->left_margin, bst->top_margin, + bst->xgwa.width - bst->left_margin - bst->right_margin, + bst->xgwa.height - bst->top_margin - bst->bottom_margin); + BSOD_INVERT(bst); + BSOD_MOVETO (bst, bst->left_margin, bst->top_margin + bst->font->ascent); + BSOD_PAUSE (bst, 1000000); + + BSOD_TEXT (bst, LEFT, + "Starting real time clock...\n" + "Probing /sbus@1,f8000000 at 0,0 dma esp sd st le\n" + "Probing /sbus@1,f8000000 at 1,0 Invalid FCode start byte at ffe70000\n" + "Probing /sbus@1,f8000000 at 2,0 Invalid FCode start byte at ffe70000\n" + "Probing /sbus@1,f8000000 at 3,0 bwtwo\n" + "\n"); + + BSOD_PIXMAP (bst, 0, 0, pix_w, pix_h, ~0, ~0); + BSOD_MARGINS (bst, + bst->left_margin + char_width * 12, + bst->top_margin); + BSOD_TEXT (bst, LEFT, + "SPARCstation IPC, Keyboard Present\n" + "ROM Rev. 2.9, 16 MB memory installed, Serial #12648190.\n" + "Ethernet address 8:0:20:37:1:87, Host ID: 52c0fefe.\n"); + BSOD_MARGINS (bst, bst->left_margin, bst->top_margin); + + BSOD_TEXT (bst, LEFT, "\n\n\033"); + BSOD_PAUSE (bst, 3000000); + BSOD_TEXT (bst, LEFT, "\r"); + + BSOD_TEXT (bst, LEFT, "Testing 16 megs of memory. Still to go \033 16"); + + for (i = 16; i > 0; i--) + { + char buf[100]; + sprintf (buf, "\b\b%2d", i); + BSOD_TEXT (bst, LEFT, buf); + BSOD_PAUSE (bst, 100000); + } + BSOD_TEXT (bst, LEFT, "\b\b\b\b 0\n" + "Initializing 16 megs of memory at addr 0\033 16"); + for (i = 16; i >= 0; i--) + { + char buf[100]; + sprintf (buf, "\b\b%2d", i); + BSOD_TEXT (bst, LEFT, buf); + BSOD_PAUSE (bst, 30000); + } + BSOD_TEXT (bst, LEFT, "\r" + " \r" + "Boot device: /sbus/le@0,c00000 File and args:\n\033"); + + { + int n = (random() % 10); + for (i = 0; i < n; i++) + { + BSOD_PAUSE (bst, 3000000); + BSOD_TEXT (bst, LEFT, "\rTimeout waiting for ARP/RARP packet\n\033"); + } + } + BSOD_TEXT (bst, LEFT, "\r"); + + BSOD_TEXT (bst, LEFT, + "Internal loopback test -- Wrong packet length;" + " expected 36, observed 1600\n" + "Can't open boot device\n" + "\n" + "Type b (boot), c (continue), or n (new command mode)\n" + ">"); + BSOD_CURSOR (bst, CURSOR_BLOCK, 500000, 10); + BSOD_TEXT (bst, LEFT, "n\n"); + BSOD_PAUSE (bst, 500000); + BSOD_TEXT (bst, LEFT, "Type help for more information\n" + "ok "); + + BSOD_CURSOR (bst, CURSOR_BLOCK, 500000, 4); + BSOD_CHAR_DELAY (bst, 80000); + BSOD_TEXT (bst, LEFT, /* "test net" */ + "t\033\be\033\bs\033\bt\033\b \033\bn\033\be\033\bt\033\b"); + BSOD_CURSOR (bst, CURSOR_BLOCK, 500000, 2); + BSOD_TEXT (bst, LEFT, "\n\033"); + BSOD_CHAR_DELAY (bst, 0); + + BSOD_PAUSE (bst, 1000000); + BSOD_TEXT (bst, LEFT, "\r Lance register test -- succeeded.\n\033"); + BSOD_PAUSE (bst, 1000000); + BSOD_TEXT (bst, LEFT, "\r Internal loopback test -- succeeded.\n\033"); + BSOD_PAUSE (bst, 1000000); + BSOD_TEXT (bst, LEFT, "\r External loopback test -- succeeded.\n" + "ok "); + BSOD_CURSOR (bst, CURSOR_BLOCK, 500000, 8); + + BSOD_TEXT (bst, LEFT, "\rok "); + BSOD_CURSOR (bst, CURSOR_BLOCK, 500000, 4); + BSOD_CHAR_DELAY (bst, 80000); + BSOD_TEXT (bst, LEFT, /* "boot cdrom" */ + "b\033\bo\033\bo\033\bt\033\b \033\bc\033\bd\033\br\033\bo\033\bm\033\b"); + BSOD_TEXT (bst, LEFT, " \n"); + BSOD_CHAR_DELAY (bst, 0); + BSOD_TEXT (bst, LEFT, + "\rBoot device: /sbus/esp@0,800000/sd@6,0:c File and args:\n\033"); + BSOD_PAUSE (bst, 1000000); + BSOD_TEXT (bst, LEFT, + "\rroot on fstype 4.3\n" + "Boot: vmunix\n\033"); + + BSOD_TEXT (bst, LEFT, "\rSize: 696320+"); + BSOD_CHAR_DELAY (bst, 5000); + BSOD_INVERT(bst); + BSOD_TEXT (bst, LEFT, /* spinner */ + "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" + "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" + "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" + "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" + "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" + "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" + "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" + "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" + "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" + "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" + "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" + "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" + "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" + "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" + "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" + "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/" "\b-\b\\\b|\b/"); + BSOD_INVERT(bst); + BSOD_TEXT (bst, LEFT, "\b+"); + BSOD_CHAR_DELAY (bst, 0); + BSOD_TEXT (bst, LEFT, + "2218504+28056 bytes\n\033"); + BSOD_PAUSE (bst, 1000000); + + i = random() % 3; + + if (i == 0) + { + BSOD_TEXT (bst, LEFT, + "\rSunOS Release 4.1.1 (MUNIX) #1: Thu Oct 11 11:22:48 PDT 1990\n" + "Copyright (c) 1983-1990, Sun Microsystems, Inc.\n" + "mem = 16384K (0x1000000)\n" + "avail mem = 12865536\n" + "Ethernet address = 8:0:20:37:1:87\n" + "No FPU in configuration\n" + "cpu = SUNW,Sun 4/40\n" + "zs0 at obio 0xf1000000 pri 12\n" + "zs1 at obio 0xf0000000 pri 12\n" + "sbus0 at SBus slot 0 0x0\n" + "dma0 at SBus slot 0 0x400000\n" + "esp0 at SBus slot 0 0x800000 pri 3\n" + "\033"); + } + else if (i == 1) + { + BSOD_TEXT (bst, LEFT, + "\rSunOS Release 5.6 Version Generic [UNIX(R) System V Release 4.0]\n" + "Copyright (c) 1983-1997, Sun Microsystems, Inc.\n" + "No FPU in configuration\n" + "WARNING: kbd: Unknown keyboard type, Type 3 assumed.\n" + "WARNING: kbd: Unknown keyboard type, Type 3 assumed.\n" + "Configuring devices...\n" + "\033"); + BSOD_PAUSE (bst, 1000000); + BSOD_TEXT (bst, LEFT, + "\rWARNING: /sbus@1,f8000000/esp@0,800000/sd@6,0 (sd6):\n" + " incomplete read- retrying\n" + "\n" + "loadkeys: ioctl(KIOCLAYOUT): Invalid argument\n" + "\033"); + } + else + { + BSOD_TEXT (bst, LEFT, + "\rSunOS Release 5.3 Version Generic [UNIX(R) System V Release 4.0]\n" + "Copyright (c) 1983-1993, Sun Microsystems, Inc.\n" + "No FPU in configuration\n" + "WARNING: /sbus@1,f8000000/esp@0,800000/sd@3,0 (sd3):\n" + " corrupt label - wrong magic number\n" + "\n" + "\\ unexpected data phase\n\033"); + for (i = 0; i < 3; i++) + { + BSOD_PAUSE (bst, 3000000); + if (i > 0) + BSOD_TEXT (bst, LEFT, + "\r polled command timeout\n"); + BSOD_TEXT (bst, LEFT, + "\resp: State=DATA Last State=UNKNOWN\n" + "esp: Latched stat=0x11 intr=0x10" + " fifo 0x0\n" + "esp: lst msg out: IDENTIFY; lst msg in: COMMAND COMPLETE\n" + "esp: DMA csr=0x10\n" + "esp: addr=fff0100f dmacnt=8000 last=fff01008 last_cnt=7\n" + "esp: Cmd dump for Target 6 Lun 0:\n" + "esp: cdblen=6, cdb=[ 0x0 0x0 0x0 0x0 0x1 0x0 ]\n" + "esp: pkt_state 0x3 pkt_flags 0x10000" + " pkt_statistics 0x0\n" + "esp: cmd_flags=0x10022 cmd_timeout=120\n" + "\033"); + } + BSOD_PAUSE (bst, 3000000); + BSOD_TEXT (bst, LEFT, + "\rWARNING: /sbus@1,f8000000/esp@0,800000/sd@6,0 (sd6):\n" + " incomplete read- retrying\n" + "\n" + "loadkeys: ioctl(KIOCLAYOUT): Invalid argument\n" + "\033"); + } + + BSOD_PAUSE (bst, 1000000); + BSOD_TEXT (bst, LEFT, + "\rsd1 at esp0 target 1 lun 0\n" + "sd1: corrupt label - wrong magic number\n" + "sd1: Vendor ' SEAGAT', product ' ', 786432 512 byte blocks\n" + "sr0: Unrecongized vendor 'Sony '," + " product 'CDU-76S 'sr0 at esp0 target 6 lun 0\n" + "le0 at SBus slot 0 0xc00000 pri 5\n" + "fd0 at obio 0xf7200000 pri 11\n\033"); + BSOD_PAUSE (bst, 1000000); + BSOD_TEXT (bst, LEFT, + "\rrd0: using preloaded munixfs\n" + "WARNING: TOD clock not initialized -- CHECK AND RESET THE DATE!\n" + "root on rd0a fstype 4.2\n" + "swap on ns0b fstype spec size 12480K\n" + "dump on ns0b fstype spec size 12468K\n" + "\033"); + BSOD_PAUSE (bst, 4000000); + + i = random() % 3; + + if (i == 0) + { + BSOD_TEXT (bst, LEFT, + "\rStarting OpenWindows...\n" + "\n" + "\n" + "waiting for X server to begin accepting connections \033"); + BSOD_PAUSE (bst, 2500000); + BSOD_TEXT (bst, LEFT, "\b.\033"); + BSOD_PAUSE (bst, 2500000); + BSOD_TEXT (bst, LEFT, "\b \n.\033"); + for (i = 0; i < 10; i++) + { + BSOD_PAUSE (bst, 2500000); + BSOD_TEXT (bst, LEFT, "\b.\033"); + BSOD_PAUSE (bst, 2500000); + BSOD_TEXT (bst, LEFT, "\b \n.\033"); + } + } + else if (i == 1) + { + BSOD_TEXT (bst, LEFT, + "\rCan't invoke /sbin/init, error 13\n" + "Can't invoke /etc/init, error 13\n" + "Can't invoke /bin/init, error 13\n" + "Can't invoke /usr/etc/init, error 13\n" + "Can't invoke /usr/bin/init, error 13\n" + "panic: icode\n" + "syncing file systems...\033"); + BSOD_PAUSE (bst, 2000000); + BSOD_TEXT (bst, LEFT, "\b done\n"); + BSOD_TEXT (bst, LEFT, + "00000 low-memory static kernel pages\n" + "00888 additional static and sysmap kernel pages\n" + "00000 dynamic kernel data pages\n" + "00008 additional user structure pages\n" + "00000 segmap kernel pages\n" + "00000 segvn kernel pages\n" + "00000 current user process pages\n" + "00000 user stack pages\n" + "00896 total pages (896 chunks)\n" + "\n" + "dumping to vp ff007dd4, offset 17768\n" + "0 total pages, dump failed: error 19\n" + "rebooting...\n"); + } + else + { + BSOD_TEXT (bst, LEFT, + "\r \n" + "What would you like to do?\n" + " 1 - install SunOS mini-root\n" + " 2 - exit to single user shell\n" + "Enter a 1 or 2: "); + BSOD_CURSOR (bst, CURSOR_BLOCK, 500000, 4); + BSOD_TEXT (bst, LEFT, + "2\n" + "you may restart this script by typing \n# "); + BSOD_CURSOR (bst, CURSOR_BLOCK, 500000, 4); + BSOD_CHAR_DELAY (bst, 80000); + BSOD_TEXT (bst, LEFT, "l\033\bs\033\b"); + BSOD_TEXT (bst, LEFT, " \n"); + BSOD_CHAR_DELAY (bst, 0); + BSOD_TEXT (bst, LEFT, + ".MUNIXFS bin extract stand\n" + ".profile dev lib tmp\n" + "README etc sbin usr\n" + "# "); + BSOD_CURSOR (bst, CURSOR_BLOCK, 500000, 4); + BSOD_CHAR_DELAY (bst, 80000); + BSOD_TEXT (bst, LEFT, /* ". extract" */ + ".\033\b \033\be\033\bx\033\bt\033\br\033\ba\033\bc\033\bt\033\b"); + BSOD_TEXT (bst, LEFT, " \n"); + BSOD_CHAR_DELAY (bst, 0); + BSOD_TEXT (bst, LEFT, + "using cdrom partition number 2\n" + "esp0: data transfer overrun\n" + " State=DATA Last State=DATA_DNE\n" + " Latched stat=0x11 intr=0x10 fifo 0x0\n" + " lst msg out: EXTENDED; lst msg in: COMMAND COMPLETE\n" + " DMA csr=0x10\n" + " addr=fff026d0 last=fff024d0 last_count=200\n" + " Cmd dump for Target 6 Lun 0:\n" + " cdb=[ 0x8 0x0 0x0 0x0 0x1 0x0 ]\n" + " pkt_state 0xf pkt_flags 0x0" + " pkt_statistics 0x0\n" + " Mapped Dma Space:\n" + " Base = 0x24d0 Count = 0x200\n" + " Transfer History:\n" + " Base = 0x24d0 Count = 0x200\n"); + } + + BSOD_CURSOR (bst, CURSOR_BLOCK, 500000, 8); + + XClearWindow(dpy, window); return bst; } @@ -5023,6 +5430,122 @@ apple2ransomware (Display *dpy, Window window) +static void +a2controller_encom (apple2_sim_t *sim, int *stepno, + double *next_actiontime) +{ + apple2_state_t *st=sim->st; + + struct mydata { + const char *str; + Bool bold_p; + } *mine; + + if (!sim->controller_data) + sim->controller_data = calloc(sizeof(struct mydata),1); + mine=(struct mydata *) sim->controller_data; + + switch(*stepno) { + case 0: + + st->gr_mode |= A2_GR_FULL; + a2_cls(st); + a2_goto(st,0,35); + a2_prints(st, "ENCOM"); + a2_goto(st,23,0); + *stepno = 10; + *next_actiontime += 6; + break; + + case 10: + a2_cls(st); + a2_goto(st,0,0); + *stepno = 11; + *next_actiontime += 1; + break; + + case 11: + a2_goto(st, 1, 0); + *stepno = 12; + mine->str = ("\n" + "\r\n" + "\r\n" + "\r\n" + "\r\n" + "\r\n" + "\r\n" + "\r\n" + "\r\n" + "SEPT 22, 18:32:21 PM\n" + "\n" + " YOUR ACCESS SUSPENDED\n" + " PLEASE REPORT TO DILLINGER\n" + " IMMEDIATELY\n" + " AUTHORIZATION: MASTER CONTROL\n" + " PROGRAM\n" + "\n" + "\r\r\r\r\r" + " END OF LINE\n" + "\n" + "\n" + "\n" + "\n"); + break; + + case 12: + { + char c = *mine->str; + mine->str++; + + if (c == 0) + { + *next_actiontime += 30; + *stepno = 0; + } + else + { + if (c == '\r') + *next_actiontime += 0.2; + if (mine->bold_p) + c |= 0xC0; + a2_printc_noscroll(st, c); + } + } + break; + + case A2CONTROLLER_FREE: + return; + } +} + + +static int +a2_encom_draw (struct bsod_state *bst) +{ + apple2_sim_t *sim = (apple2_sim_t *) bst->closure; + if (! sim) { + sim = apple2_start (bst->dpy, bst->window, 9999999, + a2controller_encom); + bst->closure = sim; + } + + if (! apple2_one_frame (sim)) { + bst->closure = 0; + } + + return 10000; +} + +static struct bsod_state * +encom (Display *dpy, Window window) +{ + struct bsod_state *bst = make_bsod_state (dpy, window, "encom", "Encom"); + bst->draw_cb = a2_encom_draw; + bst->free_cb = a2_free; + return bst; +} + + /* A crash spotted on a cash machine circa 2006, by jwz. I didn't note what model it was; probably a Tranax Mini-Bank 1000 or similar vintage. */ @@ -5080,6 +5603,56 @@ atm (Display *dpy, Window window) } +static struct bsod_state * +dvd (Display *dpy, Window window) +{ + struct bsod_state *bst = make_bsod_state (dpy, window, "dvd", "DVD"); + int pix_w, pix_h; + float scale = 0.15; + Pixmap mask = 0; + Pixmap pixmap = image_data_to_pixmap (dpy, window, + dvd_png, sizeof(dvd_png), + &pix_w, &pix_h, &mask); + int i = 0; + int x, y, dx, dy; + int steps = 10000; + + XClearWindow (dpy, window); + + while (pix_w <= bst->xgwa.width * scale && + pix_h <= bst->xgwa.height * scale) + { + pixmap = double_pixmap (dpy, bst->xgwa.visual, bst->xgwa.depth, + pixmap, pix_w, pix_h); + mask = double_pixmap (dpy, bst->xgwa.visual, 1, mask, pix_w, pix_h); + pix_w *= 2; + pix_h *= 2; + i++; + } + + bst->pixmap = pixmap; + bst->mask = mask; + x = random() % (bst->xgwa.width - pix_w); + y = random() % (bst->xgwa.height - pix_h); + dx = random() & 1 ? 1 : -1; + dy = random() & 1 ? 1 : -1; + + BSOD_INVERT(bst); + for (i = 0; i < steps; i++) + { + BSOD_RECT (bst, True, x, y, pix_w, pix_h); + if (x + dx < 0 || x + dx + pix_w > bst->xgwa.width) dx = -dx; + if (y + dy < 0 || y + dy + pix_h > bst->xgwa.height) dy = -dy; + x += dx; + y += dy; + BSOD_PIXMAP (bst, 0, 0, pix_w, pix_h, x, y); + BSOD_PAUSE (bst, 1000000 / 30.0); + } + + return bst; +} + + /* An Android phone boot loader, by jwz. */ static struct bsod_state * @@ -5355,6 +5928,8 @@ static const struct { { "GLaDOS", glados }, { "Android", android }, { "VMware", vmware }, + { "Encom", encom }, + { "DVD", dvd }, }; @@ -5385,6 +5960,7 @@ hack_title (struct driver_state *dst) XStoreName (dst->bst->dpy, dst->bst->window, nname); free (nname); } + if (oname) free (oname); # endif /* !HAVE_JWXYZ */ } @@ -5673,6 +6249,8 @@ static const char *bsod_defaults [] = { "*doGLaDOS: True", "*doAndroid: True", "*doVMware: True", + "*doEncom: True", + "*doDVD: True", ".foreground: White", ".background: Black", @@ -6000,6 +6578,10 @@ static const XrmOptionDescRec bsod_options [] = { { "-no-android", ".doAndroid", XrmoptionNoArg, "False" }, { "-vmware", ".doVMware", XrmoptionNoArg, "True" }, { "-no-vmware", ".doVMware", XrmoptionNoArg, "False" }, + { "-encom", ".doEncom", XrmoptionNoArg, "True" }, + { "-no-encom", ".doEncom", XrmoptionNoArg, "False" }, + { "-dvd", ".doDVD", XrmoptionNoArg, "True" }, + { "-no-dvd", ".doDVD", XrmoptionNoArg, "False" }, ANALOGTV_OPTIONS { 0, 0, 0, 0 } }; diff --git a/hacks/bubbles.c b/hacks/bubbles.c index 9cb2678..eefe048 100644 --- a/hacks/bubbles.c +++ b/hacks/bubbles.c @@ -129,7 +129,7 @@ struct state { #ifdef FANCY_BUBBLES int num_bubble_pixmaps; - Bubble_Step **step_pixmaps; + Bubble_Step **step_pixmaps, **def_list; #endif Bool simple; @@ -1214,6 +1214,8 @@ default_to_pixmaps (struct state *st) init_default_bubbles(); + st->def_list = (Bubble_Step **)xmalloc((num_default_bubbles + 1) * + sizeof(Bubble_Step *)); for (i = 0; i < num_default_bubbles; i++) { newpix = (Bubble_Step *)xmalloc(sizeof(Bubble_Step)); make_pixmap_from_default(st, @@ -1221,6 +1223,7 @@ default_to_pixmaps (struct state *st) default_bubbles[i].size, newpix); /* Now add to list */ + st->def_list[i] = newpix; if (pixmap_list == (Bubble_Step *)NULL) { pixmap_list = newpix; } else { @@ -1278,6 +1281,8 @@ get_resources(struct state *st) else fprintf (stderr, "%s: bogus mode: \"%s\"\n", progname, s); + if (s) free (s); + st->trails = get_boolean_resource(st->dpy, "trails", "Boolean"); st->drop_dir = (st->drop ? 1 : -1); if (st->drop || rise) @@ -1427,10 +1432,39 @@ bubbles_event (Display *dpy, Window window, void *closure, XEvent *event) return False; } +static void +free_bubble (Display *dpy, Bubble_Step *b) +{ + if (b->ball) XFreePixmap (dpy, b->ball); + if (b->shape_mask) XFreePixmap (dpy, b->shape_mask); + if (b->draw_gc) XFreeGC (dpy, b->draw_gc); + if (b->erase_gc) XFreeGC (dpy, b->erase_gc); + free (b); +} + static void bubbles_free (Display *dpy, Window window, void *closure) { struct state *st = (struct state *) closure; + int i; + + /* #### The lifetime of objects in this program is fucking incomprehensible. + I give up. */ + + /* for (i = 0; i < num_default_bubbles; i++) + free_bubble (dpy, st->def_list[i]); */ + for (i = 0; i < st->num_bubble_pixmaps; i++) + free_bubble (dpy, st->step_pixmaps[i]); + for (i = 0; i < st->mesh_cells; i++) + free (st->adjacent_list[i]); + /* for (i = 0; i < st->mesh_cells; i++) + free_bubble (dpy, st->mesh[i]); */ + if (st->draw_gc) XFreeGC (dpy, st->draw_gc); + if (st->erase_gc) XFreeGC (dpy, st->erase_gc); + free (st->adjacent_list); + free (st->def_list); + free (st->step_pixmaps); + free (st->mesh); free (st); } diff --git a/hacks/bumps.c b/hacks/bumps.c index fa728e6..d24ce00 100644 --- a/hacks/bumps.c +++ b/hacks/bumps.c @@ -376,6 +376,8 @@ static void SetPalette(Display *dpy, SBumps *pBumps, XWindowAttributes *pXWinAtt #endif /* VERBOSE */ XSetWindowBackground( pBumps->dpy, pBumps->Win, pBumps->aColors[ 0 ] ); + + if (sColor) free (sColor); } @@ -418,6 +420,7 @@ static void InitBumpMap_2(Display *dpy, SBumps *pBumps) XClearWindow (pBumps->dpy, pBumps->Win); XSync (pBumps->dpy, 0); + if (pBumps->aBumpMap) free (pBumps->aBumpMap); pBumps->aBumpMap = malloc( pBumps->iWinWidth * pBumps->iWinHeight * sizeof(uint16_t) ); nSoften = get_integer_resource(dpy, "soften", "Integer" ); @@ -606,9 +609,12 @@ static void DestroySpotLight( SSpotLight *pSpotLight ) { free( pSpotLight->aLigh static void DestroyBumps( SBumps *pBumps ) { DestroySpotLight( &pBumps->SpotLight ); + free (pBumps->xColors); free( pBumps->aColors ); free( pBumps->aBumpMap ); destroy_xshm_image( pBumps->dpy, pBumps->pXImage, &pBumps->XShmInfo ); + XFreeGC (pBumps->dpy, pBumps->GraphicsContext); + free(pBumps); } diff --git a/hacks/ccurve.c b/hacks/ccurve.c index 23b53e8..a4423b2 100644 --- a/hacks/ccurve.c +++ b/hacks/ccurve.c @@ -733,6 +733,7 @@ ccurve_draw (Display *dpy, Window window, void *closure) { st->draw_segment_count = lengths [random () % (sizeof (lengths) / sizeof (int))]; + if (st->draw_segments) free (st->draw_segments); st->draw_segments = (Segment*)(malloc ((st->draw_segment_count) * sizeof (Segment))); select_pattern (st->draw_segment_count, st->draw_segments); @@ -839,6 +840,10 @@ ccurve_event (Display *dpy, Window window, void *closure, XEvent *event) static void ccurve_free (Display *dpy, Window window, void *closure) { + struct state *st = (struct state *) closure; + XFreeGC (dpy, st->context); + if (st->draw_segments) free (st->draw_segments); + free (st); } diff --git a/hacks/celtic.c b/hacks/celtic.c index 890b398..232adb6 100644 --- a/hacks/celtic.c +++ b/hacks/celtic.c @@ -911,6 +911,7 @@ celtic_init (Display *d_arg, Window w_arg) XGetWindowAttributes (st->dpy, st->window, &st->xgwa); + if (st->colors) free (st->colors); assert(st->colors = (XColor *) calloc (st->ncolors,sizeof(XColor))); if (get_boolean_resource(st->dpy, "mono", "Boolean")) @@ -983,7 +984,8 @@ celtic_draw (Display *dpy, Window window, void *closure) pattern_del(st->pattern); } st->pattern = NULL; - graph_del(st->graph); + if (st->graph) graph_del(st->graph); + st->graph = NULL; /* recolor each time */ st->ncolors = get_integer_resource (st->dpy, "ncolors", "Integer"); @@ -1124,6 +1126,13 @@ static void celtic_free (Display *dpy, Window window, void *closure) { struct state *st = (struct state *) closure; + XFreeGC (dpy, st->gc); + XFreeGC (dpy, st->shadow_gc); + XFreeGC (dpy, st->gc_graph); + if (st->pattern) pattern_del (st->pattern); + st->pattern = 0; + if (st->graph) graph_del (st->graph); + if (st->eraser) eraser_free (st->eraser); free (st); } diff --git a/hacks/check-configs.pl b/hacks/check-configs.pl index 7a7d0bb..7cc60b4 100755 --- a/hacks/check-configs.pl +++ b/hacks/check-configs.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# Copyright © 2008-2017 Jamie Zawinski +# Copyright © 2008-2018 Jamie Zawinski # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that @@ -21,7 +21,7 @@ use diagnostics; use strict; my $progname = $0; $progname =~ s@.*/@@g; -my ($version) = ('$Revision: 1.26 $' =~ m/\s(\d[.\d]+)\s/s); +my ($version) = ('$Revision: 1.28 $' =~ m/\s(\d[.\d]+)\s/s); my $verbose = 0; my $debug_p = 0; @@ -997,17 +997,17 @@ sub build_android(@) { $write_files{"$xml_dir/${saver_underscore}_wallpaper.xml"} = $wallpaper; $daydream_java .= - (" public static class $saver_class extends org.jwz.xscreensaver.Daydream {\n" . + (" public static class $saver_class extends $package.Daydream {\n" . " }\n" . "\n"); $wallpaper_java .= - (" public static class $saver_class extends org.jwz.xscreensaver.Wallpaper {\n" . + (" public static class $saver_class extends $package.Wallpaper {\n" . " }\n" . "\n"); $settings_java .= - (" public static class $saver_class extends org.jwz.xscreensaver.Settings\n" . + (" public static class $saver_class extends $package.Settings\n" . " implements SharedPreferences.OnSharedPreferenceChangeListener {\n" . " }\n" . "\n"); @@ -1035,7 +1035,7 @@ sub build_android(@) { $manifest .= "\n"; $manifest .= ("\n" . " \n" . @@ -1056,7 +1056,7 @@ sub build_android(@) { $manifest .= ("\n" . " \n" . @@ -1091,7 +1091,7 @@ sub build_android(@) { " android:versionCode=\"$versb\"\n" . " android:versionName=\"$vers\">\n" . - " \n" . " \n" . "\n"); - $daydream_java = ("package org.jwz.xscreensaver.gen;\n" . + $daydream_java = ("package $package.gen;\n" . "\n" . - "import org.jwz.xscreensaver.jwxyz;\n" . + "import $package.jwxyz;\n" . "\n" . "public class Daydream {\n" . $daydream_java . "}\n"); - $wallpaper_java = ("package org.jwz.xscreensaver.gen;\n" . + $wallpaper_java = ("package $package.gen;\n" . "\n" . - "import org.jwz.xscreensaver.jwxyz;\n" . + "import $package.jwxyz;\n" . "\n" . "public class Wallpaper {\n" . $wallpaper_java . "}\n"); - $settings_java = ("package org.jwz.xscreensaver.gen;\n" . + $settings_java = ("package $package.gen;\n" . "\n" . "import android.content.SharedPreferences;\n" . "\n" . diff --git a/hacks/cloudlife.c b/hacks/cloudlife.c index 4b65f9e..123dd13 100644 --- a/hacks/cloudlife.c +++ b/hacks/cloudlife.c @@ -382,6 +382,11 @@ cloudlife_event (Display *dpy, Window window, void *closure, XEvent *event) { XClearWindow (dpy, window); st->cycles = 0; + if (st->field) { + free (st->field->cells); + free (st->field->new_cells); + free (st->field); + } st->field = init_field(st); return True; } @@ -392,6 +397,12 @@ static void cloudlife_free (Display *dpy, Window window, void *closure) { struct state *st = (struct state *) closure; + free (st->field->cells); + free (st->field->new_cells); + free (st->field); + free (st->colors); + XFreeGC (dpy, st->fgc); + XFreeGC (dpy, st->bgc); free (st); } diff --git a/hacks/compass.c b/hacks/compass.c index 1dc1d3e..1678ca9 100644 --- a/hacks/compass.c +++ b/hacks/compass.c @@ -957,6 +957,18 @@ compass_event (Display *dpy, Window window, void *closure, XEvent *event) static void compass_free (Display *dpy, Window window, void *closure) { + struct state *st = (struct state *) closure; + int i; + XFreeGC (dpy, st->ptr_gc); + XFreeGC (dpy, st->erase_gc); + for (i = 0; i < 4; i++) + if (st->discs[i]) { + XFreeGC (dpy, st->discs[i]->gc); + free (st->discs[i]); + } + if (st->ba) XFreePixmap (dpy, st->ba); + if (st->bb) XFreePixmap (dpy, st->bb); + free (st); } diff --git a/hacks/compile_axp.com b/hacks/compile_axp.com index c50e0f9..9fab007 100644 --- a/hacks/compile_axp.com +++ b/hacks/compile_axp.com @@ -1,5 +1,6 @@ $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) ABSTRACTILE.C $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) ANALOGTV.C +$ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) ANALOGTV-CLI.C $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) ANEMONE.C $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) ANEMOTAXIS.C $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) ANT.C diff --git a/hacks/compile_decc.com b/hacks/compile_decc.com index c50e0f9..9fab007 100644 --- a/hacks/compile_decc.com +++ b/hacks/compile_decc.com @@ -1,5 +1,6 @@ $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) ABSTRACTILE.C $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) ANALOGTV.C +$ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) ANALOGTV-CLI.C $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) ANEMONE.C $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) ANEMOTAXIS.C $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) ANT.C diff --git a/hacks/config/README b/hacks/config/README index 9771a89..5981463 100644 --- a/hacks/config/README +++ b/hacks/config/README @@ -4,8 +4,8 @@ a screen saver and locker for the X window system by Jamie Zawinski - version 5.40 - 12-Aug-2018 + version 5.42 + 28-Dec-2018 https://www.jwz.org/xscreensaver/ diff --git a/hacks/config/bsod.xml b/hacks/config/bsod.xml index ef18e21..0d18218 100644 --- a/hacks/config/bsod.xml +++ b/hacks/config/bsod.xml @@ -40,12 +40,14 @@ + + diff --git a/hacks/config/handsy.xml b/hacks/config/handsy.xml new file mode 100644 index 0000000..2ff9608 --- /dev/null +++ b/hacks/config/handsy.xml @@ -0,0 +1,58 @@ + + + + + + + diff --git a/hacks/config/ripples.xml b/hacks/config/ripples.xml index 191e041..8a2e1be 100644 --- a/hacks/config/ripples.xml +++ b/hacks/config/ripples.xml @@ -24,8 +24,7 @@ + low="0" high="16" default="6"/> diff --git a/hacks/config/unknownpleasures.xml b/hacks/config/unknownpleasures.xml index 7ef79ac..0730599 100644 --- a/hacks/config/unknownpleasures.xml +++ b/hacks/config/unknownpleasures.xml @@ -4,7 +4,7 @@ -