| 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 |
#include <stdio.h> |
| 23 |
#include "../../regstest.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 |
arm7comm_t arm7comm; |
| 34 |
|
| 35 |
int main(void) { |
| 36 |
consoleDemoInit(); |
| 37 |
|
| 38 |
//tell the arm7 where to store its stuff |
| 39 |
//(the arm7 needs to know a location in main memory (shared) to store its results) |
| 40 |
//(it could store its results in shared arm7 memory but we chose to do it this way since) |
| 41 |
//(I couldn't figure out how to specify storage there for a global in arm7.cpp. any suggestions?) |
| 42 |
fifoSendAddress(FIFO_USER_01,&arm7comm); |
| 43 |
|
| 44 |
//fog table entries should not be readable. they should return 0 |
| 45 |
for(int i=0;i<32;i++) |
| 46 |
{ |
| 47 |
GFX_FOG_TABLE[i] = 0xFF; |
| 48 |
//iprintf("%02X\n",GFX_FOG_TABLE[i]); |
| 49 |
myassert(GFX_FOG_TABLE[i] == 0x00,"test whether fog table entries are non-readable"); |
| 50 |
} |
| 51 |
|
| 52 |
//8bit vram reads should work. 8bit vram writes should fail |
| 53 |
vu8* bgmem8 = (vu8*)0x06000000; |
| 54 |
vu16* bgmem16 = (vu16*)0x06000000; |
| 55 |
vu32* bgmem32 = (vu32*)0x06000000; |
| 56 |
bgmem16[0] = 0x1234; |
| 57 |
bgmem16[1] = 0x5678; |
| 58 |
myassert(bgmem8[0] == 0x34 && bgmem8[1] == 0x12 && bgmem8[2] == 0x78 && bgmem8[3] == 0x56,"test 8bit vram reads"); |
| 59 |
bgmem8[0] = 0; |
| 60 |
myassert(bgmem8[0] == 0x34, "test 8bit vram writes"); |
| 61 |
|
| 62 |
//test OAM also |
| 63 |
vu8* oam8 = (vu8*)0x07000000; |
| 64 |
vu16* oam16 = (vu16*)0x07000000; |
| 65 |
vu32* oam32 = (vu32*)0x07000000; |
| 66 |
oam16[0] = 0x1234; |
| 67 |
oam16[1] = 0x5678; |
| 68 |
myassert(oam8[0] == 0x34 && oam8[1] == 0x12 && oam8[2] == 0x78 && oam8[3] == 0x56,"test 8bit oam reads"); |
| 69 |
oam8[0] = 0; |
| 70 |
myassert(oam8[0] == 0x34, "test 8bit oam writes"); |
| 71 |
|
| 72 |
//test pal also |
| 73 |
vu8* pal8 = (vu8*)0x05000000; |
| 74 |
vu16* pal16 = (vu16*)0x05000000; |
| 75 |
vu32* pal32 = (vu32*)0x05000000; |
| 76 |
pal16[0] = 0x1234; |
| 77 |
pal16[1] = 0x5678; |
| 78 |
myassert(pal8[0] == 0x34 && pal8[1] == 0x12 && pal8[2] == 0x78 && pal8[3] == 0x56,"test 8bit pal reads"); |
| 79 |
pal8[0] = 0; |
| 80 |
myassert(pal8[0] == 0x34, "test 8bit pal writes"); |
| 81 |
|
| 82 |
|
| 83 |
//------------------- |
| 84 |
iprintf("waiting for arm7 test to finish!\n"); |
| 85 |
|
| 86 |
for(;;) |
| 87 |
{ |
| 88 |
if(fifoCheckValue32(FIFO_USER_01)) |
| 89 |
break; |
| 90 |
swiWaitForVBlank(); |
| 91 |
} |
| 92 |
|
| 93 |
iprintf("firmwareID: %08X\n",arm7comm.firmwareId); |
| 94 |
iprintf("arm7 finish code: %d\n",arm7comm.code); |
| 95 |
|
| 96 |
if(arm7comm.code == 1) |
| 97 |
{ |
| 98 |
iprintf("arm7 test failed!\n"); |
| 99 |
iprintf("%s\n",arm7comm.message); |
| 100 |
iprintf("offending val: 0x%08X\n",arm7comm.offender); |
| 101 |
} |
| 102 |
else |
| 103 |
{ |
| 104 |
iprintf("all tests OK"); |
| 105 |
} |
| 106 |
|
| 107 |
for(;;) swiWaitForVBlank(); |
| 108 |
return 0; |
| 109 |
} |