Debian Codegraph @

tools/ds_tests/vram/source/main.cpp

raw
1 /* regs IO test
2
3 Copyright 2010 DeSmuME team
4
5 This file is part of DeSmuME
6
7 DeSmuME is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 DeSmuME 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 DeSmuME; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21 #include <nds.h>
22
23 #include <stdio.h>
24
25 #define myassert(e,msg) ((e) ? (void)0 : _myassert(__FILE__, __LINE__, #e, msg))
26
27 void _myassert(const char *fileName, int lineNumber, const char* conditionString, const char* message)
28 {
29 iprintf("---\nAssertion failed!\n\x1b[39mFile: \n%s\n\nLine: %d\n\nCondition:\n%s\n\n\x1b[41m%s",fileName, lineNumber, conditionString, message);
30 for(;;) swiWaitForVBlank();
31 }
32
33 int main(void) {
34 consoleDemoInit();
35
36 for(int i=0;i<32;i++)
37 {
38 GFX_FOG_TABLE[i] = 0xFF;
39 iprintf("%02X\n",GFX_FOG_TABLE[i]);
40 myassert(GFX_FOG_TABLE[i] == 0x00,"test whether fog table entries are writeable");
41 }
42
43 //test what happens when you do 8bit reads and writes to OAM
44 vu16* const oam16 = (vu16*)0x07000000;
45 vu8* const oam8 = (vu8*)0x07000000;
46 vu8* const oam8b = (vu8*)0x07000001;
47 *oam16 = 0;
48 myassert(*oam16 == 0x00,"oam access A");
49 myassert(*oam8 == 0x00,"oam access B");
50 myassert(*oam8b == 0x00,"oam access C");
51 *oam16 = 0x1234;
52 myassert(*oam16 == 0x1234,"oam access D");
53 myassert(*oam8 == 0x34,"oam access E");
54 myassert(*oam8b == 0x12,"oam access F");
55 *oam8 = 0xFF;
56 *oam8b = 0xEE;
57 myassert(*oam16 == 0x1234,"oam access G");
58 myassert(*oam8 == 0x34,"oam access H");
59 myassert(*oam8b == 0x12,"oam access I");
60
61 iprintf("all tests OK");
62 for(;;) swiWaitForVBlank();
63 return 0;
64 }