Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wolf3d
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hugo Hörnquist
wolf3d
Commits
55f103e4
Commit
55f103e4
authored
Jun 16, 2019
by
Hugo Hörnquist
Browse files
Options
Downloads
Patches
Plain Diff
Start map parser.
parent
5f5d1bbf
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
parse-map.scm
+104
-0
104 additions, 0 deletions
parse-map.scm
with
104 additions
and
0 deletions
parse-map.scm
0 → 100644
+
104
−
0
View file @
55f103e4
(
use-modules
(
system
foreign
)
(
ice-9
binary-ports
)
(
ice-9
iconv
)
(
rnrs
bytevectors
)
(
srfi
srfi-1
)
(
srfi
srfi-9
)
)
;;; sizeof:
;;; long => 4
;;; int => 2
(
define
long
int32
)
(
define
unsigned
uint16
)
(
define
int
int16
)
(
define
char
uint8
)
(
define
NUMMAPS
60
)
(
define
MAPPLANES
2
)
(
chdir
"/home/hugo/wolf/WOLF3D/"
)
(
define
mapfiletype
(
list
unsigned
; RLEWtag
(
make-list
100
long
)
; headeroffsets
'
()
))
;;; ID_CA.C, 960
(
define*
(
bytevector->int
bv
#
:key
(
offset
0
)
(
width
4
))
(
reduce
logior
0
(
map
(
lambda
(
i
)
(
ash
(
bytevector-u8-ref
bv
(
+
offset
i
))
(
*
i
8
)))
(
iota
width
))))
(
define*
(
bytevector->int-list
bv
#
:key
(
intwidth
4
)
veclen
)
(
map
(
lambda
(
i
)
(
bytevector->int
bv
#
:offset
i
#
:width
intwidth
))
(
iota
veclen
0
intwidth
)))
(
define
maphead
(
call-with-input-file
"MAPHEAD.WL1"
(
lambda
(
port
)
(
list
(
bytevector->int
(
get-bytevector-n
port
2
)
#
:width
2
)
(
bytevector->int-list
(
get-bytevector-all
port
)
#
:veclen
100
)))
#
:binary
#t
))
(
define
maptype
(
list
(
make-list
3
long
)
; planestart
(
make-list
3
unsigned
)
; planelength
unsigned
unsigned
; width, height
(
make-list
16
char
)))
; name
(
define-record-type
<maptype>
(
make-maptype
planestart
planelength
width
height
name
)
maptype?
(
planestart
get-planestart
)
(
planelength
get-planelength
)
(
width
get-width
)
(
height
get-height
)
(
name
get-name
))
;;; ID_CA.C, 1000
(
define
maps
(
call-with-input-file
"GAMEMAPS.WL1"
(
lambda
(
port
)
(
filter-map
(
lambda
(
pos
i
)
(
if
(
=
pos
0
)
#f
(
begin
(
seek
port
pos
SEEK_SET
)
;; planestart
(
make-maptype
(
bytevector->int-list
(
get-bytevector-n
port
(
*
3
(
sizeof
long
)))
#
:veclen
3
)
(
bytevector->int-list
(
get-bytevector-n
port
(
*
3
(
sizeof
unsigned
)))
#
:veclen
3
#
:intwidth
2
)
(
bytevector->int
(
get-bytevector-n
port
(
sizeof
unsigned
))
#
:width
2
)
(
bytevector->int
(
get-bytevector-n
port
(
sizeof
unsigned
))
#
:width
2
)
(
map
integer->char
(
bytevector->u8-list
(
get-bytevector-n
port
(
*
16
(
sizeof
char
)))))
))))
(
cadr
maphead
)
(
iota
NUMMAPS
)))
#
:binary
#t
))
(
let
((
m
(
car
maps
)))
(
map
(
lambda
(
plane
)
(
let
((
pos
(
list-ref
(
get-planestart
m
)
plane
))
(
compressed
(
list-ref
(
get-planelength
m
)
plane
)))
(
call-with-input-file
"GAMEMAPS.WL1"
(
lambda
(
port
)
(
seek
port
pos
SEEK_SET
)
(
let
((
source
(
get-bytevector-n
port
compressed
)))
(
let
((
expanded
(
bytevector->int
source
)))
;; ID_CA.C, 1474
;; aaaaahhhhhh
)
))
#
:binary
#t
)))
(
iota
MAPPLANES
)))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment