-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphoto.h
111 lines (90 loc) · 3.61 KB
/
photo.h
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* tab:8
*
* photo.h - photo display header file
*
* "Copyright (c) 2011 by Steven S. Lumetta."
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice and the following
* two paragraphs appear in all copies of this software.
*
* IN NO EVENT SHALL THE AUTHOR OR THE UNIVERSITY OF ILLINOIS BE LIABLE TO
* ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
* DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
* EVEN IF THE AUTHOR AND/OR THE UNIVERSITY OF ILLINOIS HAS BEEN ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE AUTHOR AND THE UNIVERSITY OF ILLINOIS SPECIFICALLY DISCLAIM ANY
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
* PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND NEITHER THE AUTHOR NOR
* THE UNIVERSITY OF ILLINOIS HAS ANY OBLIGATION TO PROVIDE MAINTENANCE,
* SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Author: Steve Lumetta
* Version: 3
* Creation Date: Fri Sep 9 21:45:34 2011
* Filename: photo.h
* History:
* SL 1 Fri Sep 9 21:45:34 2011
* First written.
* SL 2 Sun Sep 11 09:59:23 2011
* Completed initial implementation.
* SL 3 Wed Sep 14 21:56:08 2011
* Cleaned up code for distribution.
*/
#ifndef PHOTO_H
#define PHOTO_H
#include <stdint.h>
#include "types.h"
#include "modex.h"
#include "photo_headers.h"
#include "world.h"
/* limits on allowed size of room photos and object images */
#define MAX_PHOTO_WIDTH 1024
#define MAX_PHOTO_HEIGHT 1024
#define MAX_OBJECT_WIDTH 160
#define MAX_OBJECT_HEIGHT 100
#define red_blue_mask 0x1F // RGB = 5:6:5,red and blue need 5 bit
#define green_mask 0x3F // RGB = 5:6:5, green need 6 bit
#define level2_mask 0x3 // RGB = 2:2:2
#define fourbit_mask 0xF // RGB = 4:4:4
struct octree {
size_t node_number;
size_t pixel_loop_counter;
size_t red_sum;
size_t green_sum;
size_t blue_sum;
};
// compare function for qsort
extern int compare_function(const void *a, const void *b);
/* Fill a buffer with the pixels for a horizontal line of current room. */
extern void fill_horiz_buffer (int x, int y, unsigned char buf[SCROLL_X_DIM]);
/* Fill a buffer with the pixels for a vertical line of current room. */
extern void fill_vert_buffer (int x, int y, unsigned char buf[SCROLL_Y_DIM]);
/* Get height of object image in pixels. */
extern uint32_t image_height (const image_t* im);
/* Get width of object image in pixels. */
extern uint32_t image_width (const image_t* im);
/* Get height of room photo in pixels. */
extern uint32_t photo_height (const photo_t* p);
/* Get width of room photo in pixels. */
extern uint32_t photo_width (const photo_t* p);
/*
* Prepare room for display (record pointer for use by callbacks, set up
* VGA palette, etc.).
*/
extern void prep_room (const room_t* r);
/* Read object image from a file into a dynamically allocated structure. */
extern image_t* read_obj_image (const char* fname);
/* Read room photo from a file into a dynamically allocated structure. */
extern photo_t* read_photo (const char* fname);
/*
* N.B. I'm aware that Valgrind and similar tools will report the fact that
* I chose not to bother freeing image data before terminating the program.
* It's probably a bad habit, but ... maybe in a future release (FIXME).
* (The data are needed until the program terminates, and all data are freed
* when a program terminates.)
*/
#endif /* PHOTO_H */