Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libmeteor/source/debug.cpp
2 views
1
// Meteor - A Nintendo Gameboy Advance emulator
2
// Copyright (C) 2009-2011 Philippe Daouadi
3
//
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17
#include "debug.hpp"
18
#include "ameteor/cpu.hpp"
19
#include "globals.hpp"
20
#include "ameteor.hpp"
21
22
#include <sstream>
23
#include <map>
24
25
namespace AMeteor
26
{
27
// TODO make this more guidelined (like the above assert)
28
void debug_bits(uint32_t u)
29
{
30
#if defined METDEBUG && defined METDEBUGLOG
31
for (register int8_t c = 31; c >= 0; --c)
32
{
33
STDBG << !!(u & (((uint32_t)0x1) << c));
34
if (!(c % 8))
35
STDBG << ' ';
36
}
37
STDBG << std::endl;
38
#else
39
(void)u;
40
#endif
41
}
42
43
void debug_bits_16(uint16_t u)
44
{
45
#if defined METDEBUG && defined METDEBUGLOG
46
for (register int8_t c = 15; c >= 0; --c)
47
{
48
STDBG << !!(u & (((uint32_t)0x1) << c));
49
if (!(c % 8))
50
STDBG << ' ';
51
}
52
STDBG << std::endl;
53
#else
54
(void)u;
55
#endif
56
}
57
58
#ifdef MET_REGS_DEBUG
59
void PrintRegs ()
60
{
61
static uint32_t regs[17] = {0};
62
63
for (uint8_t c = 0; c <= 15; ++c)
64
if (R(c) != regs[c])
65
{
66
STDBG << "R" << std::setbase(10) << (int)c << " = " << IOS_ADD << R(c) << '\n';
67
regs[c] = R(c);
68
}
69
CPU.UpdateCpsr();
70
if (CPSR != regs[16])
71
{
72
STDBG << "R16 = " << IOS_ADD << CPSR << '\n';
73
regs[16] = CPSR;
74
}
75
}
76
77
void PrintStack (uint32_t stackadd)
78
{
79
uint32_t add = stackadd;
80
debug("Stack : " << IOS_ADD << add);
81
for (; add < 0x03008000; add += 4)
82
debug(IOS_ADD << MEM.Read32(add));
83
}
84
#endif
85
}
86
87