1 | /* |
---|
2 | * Abuse - dark 2D side-scrolling platform game |
---|
3 | * Copyright (c) 1995 Crack dot Com |
---|
4 | * Copyright (c) 2005-2013 Sam Hocevar <sam@hocevar.net> |
---|
5 | * |
---|
6 | * This software was released into the Public Domain. As with most public |
---|
7 | * domain software, no warranty is made or implied by Crack dot Com, by |
---|
8 | * Jonathan Clark, or by Sam Hocevar. |
---|
9 | */ |
---|
10 | |
---|
11 | #ifndef LIGHT_HPP |
---|
12 | #define LIGHT_HPP |
---|
13 | |
---|
14 | #include "imlib/image.h" |
---|
15 | #include "imlib/palette.h" |
---|
16 | |
---|
17 | #include "configuration.h" |
---|
18 | #include "crc.h" |
---|
19 | |
---|
20 | #define TTINTS 9 |
---|
21 | extern uint8_t *tints[TTINTS]; |
---|
22 | extern uint8_t *white_light,*white_light_initial,*green_light,*trans_table; |
---|
23 | extern int16_t ambient_ramp; |
---|
24 | #define REVERSE_GREEN_TINT 8 |
---|
25 | |
---|
26 | extern int16_t shutdown_lighting_value,shutdown_lighting; |
---|
27 | |
---|
28 | class LightSource |
---|
29 | { |
---|
30 | public: |
---|
31 | LightSource(char Type, ivec2 pos, int32_t inner_r, int32_t outer_r, |
---|
32 | ivec2 shift, LightSource *next); |
---|
33 | LightSource *Copy(); |
---|
34 | void CalcRange(); |
---|
35 | |
---|
36 | ivec2 m_pos, m_shift; |
---|
37 | int32_t m_type; |
---|
38 | int32_t m_outer_radius, mul_div, m_inner_radius; |
---|
39 | |
---|
40 | ivec2 m_p1, m_p2; |
---|
41 | char known; |
---|
42 | LightSource *m_next; |
---|
43 | }; |
---|
44 | |
---|
45 | class LightPatch |
---|
46 | { |
---|
47 | public: |
---|
48 | LightPatch(ivec2 p1, ivec2 p2, LightPatch *next) |
---|
49 | : m_p1(p1), |
---|
50 | m_p2(p2), |
---|
51 | m_next(next) |
---|
52 | { |
---|
53 | } |
---|
54 | |
---|
55 | void AddLight(ivec2 p1, ivec2 p2, LightSource *who); |
---|
56 | LightPatch *Copy(LightPatch *next); |
---|
57 | |
---|
58 | ivec2 m_p1, m_p2; |
---|
59 | array<LightSource *> m_lights; |
---|
60 | |
---|
61 | /* FIXME: this should disappear */ |
---|
62 | LightPatch *m_next; |
---|
63 | }; |
---|
64 | |
---|
65 | void delete_all_lights(); |
---|
66 | void delete_light(LightSource *which); |
---|
67 | LightSource *AddLightSource(char type, ivec2 pos, int32_t inner, |
---|
68 | int32_t outer, ivec2 shift); |
---|
69 | |
---|
70 | void add_light_spec(SpecDir *sd, char const *level_name); |
---|
71 | void write_lights(bFILE *fp); |
---|
72 | void read_lights(SpecDir *sd, bFILE *fp, char const *level_name); |
---|
73 | |
---|
74 | void light_screen(AImage *sc, int32_t screenx, int32_t screeny, uint8_t *light_lookup, uint16_t ambient); |
---|
75 | |
---|
76 | void calc_light_table(Palette *pal); |
---|
77 | extern LightSource *first_light_source; |
---|
78 | extern int light_detail; |
---|
79 | |
---|
80 | extern int32_t light_to_number(LightSource *l); |
---|
81 | extern LightSource *number_to_light(int32_t x); |
---|
82 | |
---|
83 | #endif |
---|