-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathheadhunter_pic.bms
90 lines (86 loc) · 2.42 KB
/
headhunter_pic.bms
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Headhunter (PS2) - *.pic->*.tga
open FDDE "pic" 0
get pic_path fullname
get pic_name basename
get pic_size asize
math pic_offset = 8
get pic_color_map_entries short
get pic_height short
get pic_width short
get pic_04 short
xmath raw_image_offset "(pic_color_map_entries << 2)"
xmath raw_image_size "(pic_size - pic_offset) - raw_image_offset"
math pic_offset + raw_image_offset
if pic_color_map_entries == 0
xmath pixel_entries "raw_image_size >> 2"
else
math pixel_entries = raw_image_size
endif
for i = 0 < pic_color_map_entries
get color_map_info long
xmath attribute "(color_map_info >> 24) & 0xff"
putarray 4 i attribute
xmath blue "(color_map_info >> 16) & 0xff"
putarray 3 i blue
xmath green "(color_map_info >> 8) & 0xff"
putarray 2 i green
xmath red "color_map_info & 0xff"
putarray 1 i red
next i
log MEMORY_FILE 0 0
put 0 byte MEMORY_FILE
put 0 byte MEMORY_FILE
put 2 byte MEMORY_FILE
put 0 short MEMORY_FILE
put 0 short MEMORY_FILE
put 0x20 byte MEMORY_FILE
put 0 short MEMORY_FILE
put 0 short MEMORY_FILE
put pic_height short MEMORY_FILE
put pic_width short MEMORY_FILE
put 0x20 byte MEMORY_FILE
xmath image_descriptor "(0 << 6) | (1 << 5) | (0 << 4) | 8"
put image_descriptor byte MEMORY_FILE
goto pic_offset
for px = 0 < pixel_entries
if pic_color_map_entries == 0
get red byte
get green byte
get blue byte
get attribute byte
put blue byte MEMORY_FILE
put green byte MEMORY_FILE
put red byte MEMORY_FILE
put attribute byte MEMORY_FILE
elif pic_color_map_entries == 0x10
get image_byte byte
for nibble = 0 < 2
if nibble = 0
xmath image_nibble "(image_byte >> 4) & 0x0f"
elif nibble = 1
xmath image_nibble "image_byte & 0x0f"
endif
getarray red 1 image_nibble
getarray green 2 image_nibble
getarray blue 3 image_nibble
getarray attribute 4 image_nibble
put blue byte MEMORY_FILE
put green byte MEMORY_FILE
put red byte MEMORY_FILE
put attribute byte MEMORY_FILE
next nibble
elif pic_color_map_entries == 0x100
get image_byte byte
getarray red 1 image_byte
getarray green 2 image_byte
getarray blue 3 image_byte
getarray attribute 4 image_byte
put blue byte MEMORY_FILE
put green byte MEMORY_FILE
put red byte MEMORY_FILE
put attribute byte MEMORY_FILE
endif
next px
string tga_name p "%s.TGA" pic_name
get tga_size asize MEMORY_FILE
log tga_name 0 tga_size MEMORY_FILE