Commit 69b406f5 authored by Hugo Hörnquist's avatar Hugo Hörnquist
Browse files

Made parse-map into propper script.

parent aed5a2fe
#!/usr/bin/guile \
-e main -s
;;; Commentary
;; This is a parser for the Wolfenstein 3d mapdata
......@@ -233,21 +237,21 @@ else insert the value as given"
(define (main args)
(chdir "/home/hugo/wolf/full/")
(let* ((maphead
(call-with-input-file "MAPHEAD.WL6"
parse-maphead #:binary #t))
(call-with-input-file "GAMEMAPS.WL6"
(lambda (port)
(let ((map-metadata (parse-map-metadata maphead port)))
(fold (lambda (m t) (and t (= 64 (get-width m) (get-height m))))
#t map-metadata))
(map (lambda (m) (parse-map-data m port))
(list (car map-metadata)))))
#:binary #t)))
(assert (= #xABCD (get-rlew maphead)))
(display-tilemap (tile-list->tilemap (car (car mapdata))))))
(let* ((maphead (call-with-input-file "MAPHEAD.WL6"
parse-maphead #:binary #t))
(mapmeta (call-with-input-file "GAMEMAPS.WL6"
(lambda (port) (parse-map-metadata maphead port)) #:binary #t)))
(when (or (= 1 (length args))
(member (cadr args) '("--help" "-h" "-?" "--list" "-l")))
(format #t "Available maps:~%")
(for-each (lambda (i m) (format #t "~2,a : ~a~%" i (get-name m)))
(iota (length mapmeta))
(let* ((maph (list-ref mapmeta (string->number (cadr args))))
(data (call-with-input-file "GAMEMAPS.WL6"
(lambda (port) (parse-map-data maph port))
#:binary #t)))
(-> data car tile-list->tilemap display-tilemap))))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment