Skip to content

Commit d304f8d

Browse files
added touch input
1 parent 056e019 commit d304f8d

7 files changed

Lines changed: 118 additions & 24 deletions

File tree

FSPDS.cbp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<Add option="-Wall" />
3434
</Compiler>
3535
<ExtraCommands>
36-
<Add after='cmd /c copy &quot;FSPDS.nds&quot; &quot;D:\Archive\Files\Nintendo\NDS\flash\R4wood\FSPDS.nds&quot;' />
36+
<Add after='cmd /c copy &quot;FSPDS.nds&quot; &quot;C:\DeSmuMe\R4wood\FSPDS.nds&quot;' />
3737
</ExtraCommands>
3838
<Unit filename="Makefile" />
3939
<Unit filename="arm7/Makefile" />
@@ -50,10 +50,8 @@
5050
<Unit filename="arm9/source/main.c">
5151
<Option compilerVar="CC" />
5252
</Unit>
53+
<Unit filename="include/common.h" />
5354
<Extensions>
54-
<code_completion />
55-
<envvars />
56-
<debugger />
5755
<lib_finder disable_auto="1" />
5856
</Extensions>
5957
</Project>

arm7/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ include $(DEVKITARM)/ds_rules
1717
TARGET := FSPDS
1818
BUILD := build
1919
SOURCES := source
20-
INCLUDES := include
20+
INCLUDES := include ../include
2121

2222
#---------------------------------------------------------------------------------
2323
# options for code generation

arm7/source/main.c

Lines changed: 77 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,83 @@
1+
/*---------------------------------------------------------------------------------
2+
3+
default ARM7 core
4+
5+
Copyright (C) 2005 - 2010
6+
Michael Noland (joat)
7+
Jason Rogers (dovoto)
8+
Dave Murphy (WinterMute)
9+
10+
This software is provided 'as-is', without any express or implied
11+
warranty. In no event will the authors be held liable for any
12+
damages arising from the use of this software.
13+
14+
Permission is granted to anyone to use this software for any
15+
purpose, including commercial applications, and to alter it and
16+
redistribute it freely, subject to the following restrictions:
17+
18+
1. The origin of this software must not be misrepresented; you
19+
must not claim that you wrote the original software. If you use
20+
this software in a product, an acknowledgment in the product
21+
documentation would be appreciated but is not required.
22+
23+
2. Altered source versions must be plainly marked as such, and
24+
must not be misrepresented as being the original software.
25+
26+
3. This notice may not be removed or altered from any source
27+
distribution.
28+
29+
---------------------------------------------------------------------------------*/
30+
/// To process touch input and (hopefully) sound
131
#include <nds.h>
32+
#include <maxmod7.h>
33+
34+
void VblankHandler(void) { }
35+
36+
void VcountHandler() {
37+
inputGetAndSend();
38+
}
39+
40+
volatile bool exitflag = false;
241

3-
int main(int argc, char **argv)
4-
{
5-
while(1)
6-
{
42+
void powerButtonCB() {
43+
exitflag = true;
44+
}
45+
46+
int main() {
47+
// clear sound registers
48+
dmaFillWords(0, (void*)0x04000400, 0x100);
49+
50+
REG_SOUNDCNT |= SOUND_ENABLE;
51+
writePowerManagement(PM_CONTROL_REG, ( readPowerManagement(PM_CONTROL_REG) & ~PM_SOUND_MUTE ) | PM_SOUND_AMP );
52+
powerOn(POWER_SOUND);
53+
54+
readUserSettings();
55+
ledBlink(0);
56+
57+
irqInit();
58+
// Start the RTC tracking IRQ
59+
initClockIRQ();
60+
fifoInit();
61+
touchInit();
62+
63+
SetYtrigger(80);
64+
65+
installSoundFIFO();
66+
67+
installSystemFIFO();
68+
69+
irqSet(IRQ_VCOUNT, VcountHandler);
70+
irqSet(IRQ_VBLANK, VblankHandler);
71+
72+
irqEnable( IRQ_VBLANK | IRQ_VCOUNT | IRQ_NETWORK);
73+
74+
setPowerButtonCB(powerButtonCB);
75+
76+
while (!exitflag) {
77+
if ( 0 == (REG_KEYINPUT & (KEY_SELECT | KEY_START | KEY_L | KEY_R))) {
78+
exitflag = true;
79+
}
780
swiWaitForVBlank();
881
}
982
return 0;
1083
}
11-

arm9/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ TARGET := FSPDS
1717
#---------------------------------------------------------------------------------
1818
BUILD := build
1919
SOURCES := source
20-
INCLUDES := include
20+
INCLUDES := include ../include
2121
DATA :=
2222

2323
#---------------------------------------------------------------------------------

arm9/include/tabsystem.h

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ struct ConsoleTab
1212
void (*loadingProc)();
1313
void (*drawingProc)();
1414
void (*keyDownProc)(uint32);
15+
void (*touchRdProc)();
1516
void (*leavingProc)();
1617
};
1718

@@ -103,26 +104,38 @@ void PlayTabDrawing()
103104
iprintf(PlayerState ? PlayButton : PauseButton);
104105
}
105106

107+
void PlayTabPlayButtonPressed()
108+
{
109+
s16 index=7*CurrentPage+PageSelection;
110+
if(PlayerLoadedFileIndex!=index)
111+
{
112+
c_goto(18,10);
113+
iprintf("Loading...");
114+
ppm_loadAnimationData();
115+
c_goto(18,10);
116+
iprintf(" ");
117+
PlayerLoadedFileIndex=index;
118+
}
119+
PlayerState=1-PlayerState;
120+
iprintf(PlayerState ? PlayButton : PauseButton);
121+
PlayerThumbnailNeedsRedraw=true;
122+
}
123+
106124
void PlayTabKeyDown(uint32 input)
107125
{
108126
if(input & KEY_A)
109127
{
110-
s16 index=7*CurrentPage+PageSelection;
111-
if(PlayerLoadedFileIndex!=index)
112-
{
113-
c_goto(18,10);
114-
iprintf("Loading...");
115-
ppm_loadAnimationData();
116-
c_goto(18,10);
117-
iprintf(" ");
118-
PlayerLoadedFileIndex=index;
119-
}
120-
PlayerState=1-PlayerState;
121-
iprintf(PlayerState ? PlayButton : PauseButton);
122-
PlayerThumbnailNeedsRedraw=true;
128+
PlayTabPlayButtonPressed();
123129
}
124130
}
125131

132+
void PlayTabRdTouch()
133+
{
134+
if(104<=touch.px && touch.px<152 && 72<=touch.py && touch.py<120)
135+
PlayTabPlayButtonPressed();
136+
137+
}
138+
126139
void PlayTabLeaving()
127140
{
128141
PlayerState=PAUSED;
@@ -141,20 +154,23 @@ void initTabs()
141154
FilesTab.loadingProc=TabNoAction;
142155
FilesTab.drawingProc=FilesTabDrawing;
143156
FilesTab.keyDownProc=FilesTabKeyDown;
157+
FilesTab.touchRdProc=TabNoAction;
144158
FilesTab.leavingProc=TabNoAction;
145159
FilesTab.left=&PlayTab;
146160
FilesTab.right=&InfoTab;
147161

148162
InfoTab.loadingProc=InfoTabLoading;
149163
InfoTab.drawingProc=InfoTabDrawing;
150164
InfoTab.keyDownProc=TabNoAction;
165+
InfoTab.touchRdProc=TabNoAction;
151166
InfoTab.leavingProc=TabNoAction;
152167
InfoTab.left=&FilesTab;
153168
InfoTab.right=&PlayTab;
154169

155170
PlayTab.loadingProc=PlayTabLoading;
156171
PlayTab.drawingProc=PlayTabDrawing;
157172
PlayTab.keyDownProc=PlayTabKeyDown;
173+
PlayTab.touchRdProc=PlayTabRdTouch;
158174
PlayTab.leavingProc=PlayTabLeaving;
159175
PlayTab.left=&InfoTab;
160176
PlayTab.right=&FilesTab;

arm9/include/vars.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#ifndef FSPDS_VARS_H_INCLUDED
22
#define FSPDS_VARS_H_INCLUDED
33

4+
#include <nds.h>
45
/// Filesystem variables
56

7+
touchPosition touch;
8+
69
#define MAXFILESCOUNT 1024
710
int filescount=0;
811
char files[MAXFILESCOUNT][29];

arm9/source/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ int main(int argc, char ** argv)
4949
CurrentTab->loadingProc();
5050
CurrentTab->drawingProc();
5151
}
52+
else if (input & KEY_TOUCH)
53+
{
54+
touchRead(&touch);
55+
CurrentTab->touchRdProc();
56+
}
5257
else
5358
{
5459
CurrentTab->keyDownProc(input);

0 commit comments

Comments
 (0)