Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Suyu
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Suyu
Commits
033b4625
There was an error fetching the commit references. Please try again later.
Commit
033b4625
authored
6 years ago
by
bunnei
Browse files
Options
Downloads
Patches
Plain Diff
macro_interpreter: Implement AddWithCarry and SubtractWithBorrow.
- Used by Undertale.
parent
bb175ab4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/video_core/macro_interpreter.cpp
+22
-7
22 additions, 7 deletions
src/video_core/macro_interpreter.cpp
src/video_core/macro_interpreter.h
+3
-1
3 additions, 1 deletion
src/video_core/macro_interpreter.h
with
25 additions
and
8 deletions
src/video_core/macro_interpreter.cpp
+
22
−
7
View file @
033b4625
...
@@ -35,6 +35,7 @@ void MacroInterpreter::Reset() {
...
@@ -35,6 +35,7 @@ void MacroInterpreter::Reset() {
// The next parameter index starts at 1, because $r1 already has the value of the first
// The next parameter index starts at 1, because $r1 already has the value of the first
// parameter.
// parameter.
next_parameter_index
=
1
;
next_parameter_index
=
1
;
carry_flag
=
false
;
}
}
bool
MacroInterpreter
::
Step
(
u32
offset
,
bool
is_delay_slot
)
{
bool
MacroInterpreter
::
Step
(
u32
offset
,
bool
is_delay_slot
)
{
...
@@ -135,14 +136,28 @@ MacroInterpreter::Opcode MacroInterpreter::GetOpcode(u32 offset) const {
...
@@ -135,14 +136,28 @@ MacroInterpreter::Opcode MacroInterpreter::GetOpcode(u32 offset) const {
return
{
macro_memory
[
offset
+
pc
/
sizeof
(
u32
)]};
return
{
macro_memory
[
offset
+
pc
/
sizeof
(
u32
)]};
}
}
u32
MacroInterpreter
::
GetALUResult
(
ALUOperation
operation
,
u32
src_a
,
u32
src_b
)
const
{
u32
MacroInterpreter
::
GetALUResult
(
ALUOperation
operation
,
u32
src_a
,
u32
src_b
)
{
switch
(
operation
)
{
switch
(
operation
)
{
case
ALUOperation
::
Add
:
case
ALUOperation
::
Add
:
{
return
src_a
+
src_b
;
const
u64
result
{
static_cast
<
u64
>
(
src_a
)
+
src_b
};
// TODO(Subv): Implement AddWithCarry
carry_flag
=
result
>
0xffffffff
;
case
ALUOperation
::
Subtract
:
return
static_cast
<
u32
>
(
result
);
return
src_a
-
src_b
;
}
// TODO(Subv): Implement SubtractWithBorrow
case
ALUOperation
::
AddWithCarry
:
{
const
u64
result
{
static_cast
<
u64
>
(
src_a
)
+
src_b
+
(
carry_flag
?
1ULL
:
0ULL
)};
carry_flag
=
result
>
0xffffffff
;
return
static_cast
<
u32
>
(
result
);
}
case
ALUOperation
::
Subtract
:
{
const
u64
result
{
static_cast
<
u64
>
(
src_a
)
-
src_b
};
carry_flag
=
result
<
0x100000000
;
return
static_cast
<
u32
>
(
result
);
}
case
ALUOperation
::
SubtractWithBorrow
:
{
const
u64
result
{
static_cast
<
u64
>
(
src_a
)
-
src_b
-
(
carry_flag
?
0ULL
:
1ULL
)};
carry_flag
=
result
<
0x100000000
;
return
static_cast
<
u32
>
(
result
);
}
case
ALUOperation
::
Xor
:
case
ALUOperation
::
Xor
:
return
src_a
^
src_b
;
return
src_a
^
src_b
;
case
ALUOperation
::
Or
:
case
ALUOperation
::
Or
:
...
...
This diff is collapsed.
Click to expand it.
src/video_core/macro_interpreter.h
+
3
−
1
View file @
033b4625
...
@@ -117,7 +117,7 @@ private:
...
@@ -117,7 +117,7 @@ private:
bool
Step
(
u32
offset
,
bool
is_delay_slot
);
bool
Step
(
u32
offset
,
bool
is_delay_slot
);
/// Calculates the result of an ALU operation. src_a OP src_b;
/// Calculates the result of an ALU operation. src_a OP src_b;
u32
GetALUResult
(
ALUOperation
operation
,
u32
src_a
,
u32
src_b
)
const
;
u32
GetALUResult
(
ALUOperation
operation
,
u32
src_a
,
u32
src_b
);
/// Performs the result operation on the input result and stores it in the specified register
/// Performs the result operation on the input result and stores it in the specified register
/// (if necessary).
/// (if necessary).
...
@@ -165,5 +165,7 @@ private:
...
@@ -165,5 +165,7 @@ private:
std
::
vector
<
u32
>
parameters
;
std
::
vector
<
u32
>
parameters
;
/// Index of the next parameter that will be fetched by the 'parm' instruction.
/// Index of the next parameter that will be fetched by the 'parm' instruction.
u32
next_parameter_index
=
0
;
u32
next_parameter_index
=
0
;
bool
carry_flag
{};
};
};
}
// namespace Tegra
}
// namespace Tegra
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment