-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbmp.fs
39 lines (33 loc) · 755 Bytes
/
bmp.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
: bmp-info { f n | buf fp aw ah ac } ( c-addr u -- n1 n2 u )
18 chars allocate throw to buf
f n r/o bin open-file throw to fp
buf 18 fp read-file throw drop
1 cells allocate throw to aw
aw 4 fp read-file throw drop
aw 3 + c@ if
aw 4 + $ff swap c!
aw 5 + $ff swap c!
aw 6 + $ff swap c!
aw 7 + $ff swap c!
then
1 cells allocate throw to ah
ah 4 fp read-file throw drop
ah 3 + c@ if
ah 4 + $ff swap c!
ah 5 + $ff swap c!
ah 6 + $ff swap c!
ah 7 + $ff swap c!
then
buf 2 fp read-file throw drop
1 cells allocate throw to ac
ac 2 fp read-file throw drop
aw @
ah @
ac @
fp close-file throw
aw free throw
ah free throw
ac free throw
buf free throw
;
s" sunflower.bmp" bmp-info .s