Jo Engine  2023.08.26
Jo Sega Saturn Engine
vdp1_command_pipeline.h
Go to the documentation of this file.
1 /*
2 ** Jo Sega Saturn Engine
3 ** Copyright (c) 2012-2020, Johannes Fetz (johannesfetz@gmail.com)
4 ** All rights reserved.
5 **
6 ** Redistribution and use in source and binary forms, with or without
7 ** modification, are permitted provided that the following conditions are met:
8 ** * Redistributions of source code must retain the above copyright
9 ** notice, this list of conditions and the following disclaimer.
10 ** * Redistributions in binary form must reproduce the above copyright
11 ** notice, this list of conditions and the following disclaimer in the
12 ** documentation and/or other materials provided with the distribution.
13 ** * Neither the name of the Johannes Fetz nor the
14 ** names of its contributors may be used to endorse or promote products
15 ** derived from this software without specific prior written permission.
16 **
17 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 ** DISCLAIMED. IN NO EVENT SHALL Johannes Fetz BE LIABLE FOR ANY
21 ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
35 #ifndef __JO_VDP1_COMMAND_PIPELINE_H__
36 # define __JO_VDP1_COMMAND_PIPELINE_H__
37 
38 #if !JO_COMPILE_USING_SGL
39 
43 extern unsigned int __jo_vdp1_command_index;
44 
46 typedef enum __attribute__ ((__packed__))
47 {
48  DrawNormalSprite = 0x0,
49  DrawScaledSprite = 0x1,
50  DrawDistortedSprite = 0x2,
51  DrawPolygon = 0x4,
52  DrawPolylines = 0x5,
53  DrawLine = 0x6,
54  SetUserClipping = 0x8,
55  SetSystemClipping = 0x9,
56  SetLocalCoordinates = 0xA,
57  DrawEnd = 0x8000,
58  __force_unsigned_short__ = 0xFFFFU
59 }
60 jo_vdp1_command_control;
61 
63 typedef struct
64 {
65  jo_vdp1_command_control ctrl;
66  unsigned short link;
67  unsigned short pmod;
68  unsigned short colr;
69  unsigned short srca;
70  unsigned short size;
71  short xa;
72  short ya;
73  short xb;
74  short yb;
75  short xc;
76  short yc;
77  short xd;
78  short yd;
79  unsigned short grda;
80  short jo_engine_reserved;
81 } jo_vdp1_command;
82 
83 static __jo_force_inline jo_vdp1_command *jo_vdp1_get_command_entry_from_link(unsigned short link)
84 {
85  return (link ? (jo_vdp1_command *)(JO_VDP1_VRAM + (unsigned int)link * 0x8) : JO_NULL);
86 }
87 static __jo_force_inline unsigned short jo_vdp1_command_index_to_link(int command_index)
88 {
89  return ((JO_VDP1_VRAM + JO_MULT_BY_32(command_index)) / 0x8);
90 }
91 static __jo_force_inline jo_vdp1_command *jo_vdp1_get_command_entry(int command_index)
92 {
93  return (jo_vdp1_command *)(JO_VDP1_VRAM + JO_MULT_BY_32(command_index));
94 }
95 static __jo_force_inline unsigned short jo_vdp1_command_to_link(jo_vdp1_command *command)
96 {
97  return (command ? (((unsigned int)command - (unsigned int)JO_VDP1_VRAM) / 0x8) : 0);
98 }
99 
100 jo_vdp1_command* jo_vdp1_create_command(void);
101 
102 #endif
103 
104 #endif /* !__JO_VDP1_COMMAND_PIPELINE_H__ */
105 
106 /*
107 ** END OF FILE
108 */
JO_VDP1_VRAM
#define JO_VDP1_VRAM
VDP1 VRAM (512 kilobytes)
Definition: sega_saturn.h:90
JO_MULT_BY_32
#define JO_MULT_BY_32(X)
Multiply a variable by 32.
Definition: math.h:90
JO_NULL
#define JO_NULL
NULL implementation.
Definition: tools.h:170
__jo_force_inline
#define __jo_force_inline
force inline attribute (and prevent Doxygen prototype parsing bug)
Definition: types.h:39