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
6422fc42
Commit
6422fc42
authored
6 years ago
by
Hugo Hörnquist
Browse files
Options
Downloads
Patches
Plain Diff
Clean up existing parts of map parser.
parent
55f103e4
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
parse-map.scm
+38
-32
38 additions, 32 deletions
parse-map.scm
with
38 additions
and
32 deletions
parse-map.scm
+
38
−
32
View file @
6422fc42
...
...
@@ -3,7 +3,9 @@
(
ice-9
iconv
)
(
rnrs
bytevectors
)
(
srfi
srfi-1
)
(
srfi
srfi-4
)
(
srfi
srfi-9
)
(
srfi
srfi-9
gnu
)
)
...
...
@@ -11,40 +13,46 @@
;;; long => 4
;;; int => 2
(
begin
(
define
long
int32
)
(
define
unsigned
uint16
)
(
define
int
int16
)
(
define
char
uint8
)
(
define
NUMMAPS
60
)
(
define
MAPPLANES
2
)
(
define
MAPPLANES
2
)
)
(
chdir
"/home/hugo/wolf/WOLF3D/"
)
(
chdir
"/home/hugo/wolf
3d
/WOLF3D
-D
/"
)
(
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-record-type
<maphead>
(
make-maphead
rlew
headeroffsets
)
maphead?
(
rlew
get-rlew
)
(
headeroffsets
get-offsets
))
(
set-record-type-printer!
<maphead>
(
lambda
(
r
p
)
(
format
p
"#<<maphead> RLEW: #x~:@(~x~), offsets: (~{#x~:@(~4,'0x~)~^ ~})>"
(
get-rlew
r
)
(
take-while
(
negate
zero?
)
(
get-offsets
r
)))))
(
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
(
byte
vector-
>int
(
get-bytevector-n
port
2
)
#
:width
2
)
(
byte
vector->
int-
list
(
get-bytevector-all
port
)
#
:veclen
100
)))
(
make-maphead
(
u16
vector-
ref
(
get-bytevector-n
port
2
)
0
)
(
u32
vector->list
(
get-bytevector-all
port
))))
#
:binary
#t
))
(
=
#xABCD
(
get-rlew
maphead
))
(
define
maptype
(
list
(
make-list
3
long
)
; planestart
(
make-list
3
unsigned
)
; planelength
...
...
@@ -66,25 +74,23 @@
(
call-with-input-file
"GAMEMAPS.WL1"
(
lambda
(
port
)
(
filter-map
(
lambda
(
pos
i
)
(
lambda
(
pos
)
(
if
(
=
pos
0
)
#f
(
begin
(
seek
port
pos
SEEK_SET
)
;; planestart
(
make-maptype
(
byte
vector->
int-
list
(
get-bytevector-n
port
(
*
3
(
sizeof
long
)))
#
:veclen
3
)
(
byte
vector->
int-
list
(
get-bytevector-n
port
(
*
3
(
sizeof
unsigned
)))
#
:veclen
3
#
:intwidth
2
)
(
byte
vector-
>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
)))))
(
u32
vector->list
; planestart
(
get-bytevector-n
port
(
*
3
(
sizeof
long
)))
)
(
u16
vector->list
; planelength
(
get-bytevector-n
port
(
*
3
(
sizeof
unsigned
)))
)
(
u16
vector-
ref
(
get-bytevector-n
port
(
sizeof
unsigned
))
0
)
; width
(
u16vector-ref
(
get-bytevector-n
port
(
sizeof
unsigned
))
0
)
; height
(
string-filter
; name
(
bytevector->string
(
get-bytevector-n
port
16
)
"ASCII"
)
(
lambda
(
c
)
(
not
(
eq?
c
#\nul
))))
;;
(bytevector->
string
(get-bytevector-n port
4) "ASCII") ; "!ID!"
))))
(
cadr
maphead
)
(
iota
NUMMAPS
)))
(
get-offsets
maphead
)))
#
:binary
#t
))
(
let
((
m
(
car
maps
)))
...
...
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