1: /*
2: * Guitar-ZyX(tm)::MasterControlProgram - portable guitar F/X controller
3: * Copyright (C) 2009 Douglas McClendon
4: *
5: * This program is free software: you can redistribute it and/or modify
6: * it under the terms of the GNU General Public License as published by
7: * the Free Software Foundation, version 3 of the License.
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: /*
18: #############################################################################
19: #############################################################################
20: ##
21: ## gzmcpc::arm7_main: arm7 code (generally administrative)
22: ##
23: #############################################################################
24: ##
25: ## Copyright 2009 Douglas McClendon <dmc AT filteredperception DOT org>
26: ##
27: #############################################################################
28: #############################################################################
29: #
30: */
31:
32:
33:
34: #include <nds.h>
35:
36: #include <dswifi7.h>
37:
38: #include <maxmod7.h>
39:
40: #include "arm7_main.h"
41:
42:
43:
44:
45:
46:
47:
48: int main(void) {
49:
50: // retrieve user customization/configuration data from non volatile memory
51: readUserSettings();
52:
53: // power on the sound subsystem
54: powerOn(POWER_SOUND);
55:
56: // initialize interrupt requests
57: irqInit();
58:
59: // disable(?) wifi irq at first
60: irqSet(IRQ_WIFI, 0);
61:
62: // initialize interprocessor communication pipe
63: fifoInit();
64:
65: // ?? set the point during screen refresh when vblank handler is called ??
66: SetYtrigger(80);
67:
68: // set up interprocessor sound data pipe
69: installSoundFIFO();
70:
71: // set up interprocessor wifi data pipe
72: installWifiFIFO();
73:
74: // set up interprocessor highlevel audio (maxmod) data pipe
75: mmInstall(FIFO_MAXMOD);
76:
77: // set up interprocessor generic data pipe
78: installSystemFIFO();
79:
80: // every vertical blank(?), process any new input
81: irqSet(IRQ_VCOUNT, inputGetAndSend);
82:
83: // every vertical blank, process wifi transactions
84: irqSet(IRQ_VBLANK, Wifi_Update);
85:
86: // set up the Real Time Clock handler
87: initClockIRQ();
88:
89: // actually enable the now set up interrupt handlers
90: irqEnable( IRQ_VBLANK | IRQ_VCOUNT | IRQ_NETWORK );
91:
92: // other than handling interrupts, just check for reset request
93: while (1) {
94:
95: checkForAndHandleResetRequest();
96:
97: // only run the rest of the loop once per vert refresh
98: swiWaitForVBlank();
99:
100: }
101:
102: // execution never reaches here
103: return 0;
104:
105: }
106:
107:
108: void checkForAndHandleResetRequest(void) {
109:
110: // did the arm9 request a reset?
111: if (*((vu32*)0x027ffe24) == (u32)0x027ffe04) {
112:
113: // cease running interrupt handlers
114: irqDisable(IRQ_ALL);
115:
116: // passme loop (?) magic incantation
117: *((vu32*)0x027ffe34) = (u32)0x06000000;
118:
119: // reset
120: swiSoftReset();
121:
122: }
123:
124: }
125: