22726e4d |
1 | /****************************************************************************** |
2 | * Arachnoid Graphics Plugin for Mupen64Plus |
3 | * http://bitbucket.org/wahrhaft/mupen64plus-video-arachnoid/ |
4 | * |
5 | * Copyright (C) 2007 Kristofer Karlsson, Rickard Niklasson |
6 | * |
7 | * This program is free software; you can redistribute it and/or |
8 | * modify it under the terms of the GNU General Public License |
9 | * as published by the Free Software Foundation; either version 2 |
10 | * of the License, or (at your option) any later version. |
11 | * |
12 | * This program is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * GNU General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU General Public License |
18 | * along with this program; if not, write to the Free Software |
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
20 | *****************************************************************************/ |
21 | |
22 | #ifndef DISPLAYLIST_PARSER_H_ |
23 | #define DISPLAYLIST_PARSER_H_ |
24 | |
25 | //Forward declaration |
26 | class Memory; |
27 | class RSP; |
28 | class RDP; |
29 | class GBI; |
30 | |
31 | #define MAX_DL_COUNT 100000 //!< Maximum display list count |
32 | #define TASK_ADDRESS_RELATIVE_DMEM 0x0FC0 |
33 | //----------------------------------------------------------------------------- |
34 | //! The display list PC stack. |
35 | //----------------------------------------------------------------------------- |
36 | typedef struct |
37 | { |
38 | unsigned int pc; |
39 | int countdown; |
40 | } DListStack; |
41 | |
42 | //***************************************************************************** |
43 | //* DisplayListParser |
44 | //! Class for parsing and managing the displaylist |
45 | //***************************************************************************** |
46 | class DisplayListParser |
47 | { |
48 | public: |
49 | //Constructor / Destructor |
50 | DisplayListParser(); |
51 | ~DisplayListParser(); |
52 | |
53 | //Initialize |
54 | bool initialize(RSP* rsp, RDP* rdp, GBI* gbi, Memory* memory); |
55 | |
56 | //Process/Parse the display list |
57 | void processDisplayList(); |
58 | |
59 | //Display list funcitons |
60 | void branchDisplayList(unsigned int dl); |
61 | void displayList(unsigned int segmentAddress); |
62 | void DMADisplayList( unsigned int w0, unsigned int w1 ); |
63 | //! End display list |
64 | void endDisplayList() { --m_DListStackPointer; } |
65 | |
66 | //! Get Program Counter |
67 | unsigned int getPC() { return m_DlistStack[m_DListStackPointer].pc; } |
68 | |
69 | //! Set Program Counter |
70 | void setPC(unsigned int pc) { m_DlistStack[m_DListStackPointer].pc = pc; } |
71 | |
72 | //! Increase Program Counter |
73 | void increasePC(int increment) { m_DlistStack[m_DListStackPointer].pc += increment; } |
74 | |
75 | //Get Next Word |
76 | unsigned int getNextWord(); |
77 | |
78 | //! Get Current Display List |
79 | DListStack& getCurrentDlist() { return m_DlistStack[m_DListStackPointer]; } |
80 | |
81 | private: |
82 | |
83 | //Pointers |
84 | RSP* m_rsp; //! Pointer to Reality Signal Processor |
85 | RDP* m_rdp; //! Pointer to Reality Drawing Processor |
86 | GBI* m_gbi; //! Pointer to Graphics Binary Interface |
87 | Memory* m_memory; //! Pointer to Memory |
88 | |
89 | //Stack used for processing the Display List |
90 | int m_DListStackPointer; //!< Current size of Display List stack |
91 | static const int MAX_DL_STACK_SIZE = 32; //!< Maximum size of Display List stack |
92 | DListStack m_DlistStack[MAX_DL_STACK_SIZE]; //!< Stack used for processing the Display List |
93 | }; |
94 | |
95 | #endif |