aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/video_core/command_processor.cpp
diff options
context:
space:
mode:
authorGravatar Tony Wasserka <NeoBrainX@gmail.com>2014-07-26 14:42:46 +0200
committerGravatar Tony Wasserka <NeoBrainX@gmail.com>2014-08-12 13:47:30 +0200
commit76a586de4952df6d8dd9db9d97716c00690cebdd (patch)
treead6a954780faa4ab7908780e4ab605952b7e400b /src/video_core/command_processor.cpp
parent98ad16a45b9441a54d80e67425ac3ddee24f08dc (diff)
Pica: Add command processor.
Diffstat (limited to 'src/video_core/command_processor.cpp')
-rw-r--r--src/video_core/command_processor.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp
new file mode 100644
index 00000000..515c407e
--- /dev/null
+++ b/src/video_core/command_processor.cpp
@@ -0,0 +1,60 @@
+// Copyright 2014 Citra Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#include "pica.h"
+#include "command_processor.h"
+
+
+namespace Pica {
+
+Regs registers;
+
+namespace CommandProcessor {
+
+static inline void WritePicaReg(u32 id, u32 value) {
+ u32 old_value = registers[id];
+ registers[id] = value;
+
+ switch(id) {
+ // TODO: Perform actions for anything which requires special treatment here...
+
+ default:
+ break;
+ }
+}
+
+static std::ptrdiff_t ExecuteCommandBlock(const u32* first_command_word) {
+ const CommandHeader& header = *(const CommandHeader*)(&first_command_word[1]);
+
+ u32* read_pointer = (u32*)first_command_word;
+
+ // TODO: Take parameter mask into consideration!
+
+ WritePicaReg(header.cmd_id, *read_pointer);
+ read_pointer += 2;
+
+ for (int i = 1; i < 1+header.extra_data_length; ++i) {
+ u32 cmd = header.cmd_id + ((header.group_commands) ? i : 0);
+ WritePicaReg(cmd, *read_pointer);
+ ++read_pointer;
+ }
+
+ // align read pointer to 8 bytes
+ if ((first_command_word - read_pointer) % 2)
+ ++read_pointer;
+
+ return read_pointer - first_command_word;
+}
+
+void ProcessCommandList(const u32* list, u32 size) {
+ u32* read_pointer = (u32*)list;
+
+ while (read_pointer < list + size) {
+ read_pointer += ExecuteCommandBlock(read_pointer);
+ }
+}
+
+} // namespace
+
+} // namespace