ROM Hack About Stylus detection

Ben_j

Well-Known Member
OP
Member
Joined
Nov 13, 2005
Messages
696
Trophies
0
Age
35
Website
www.nintendo-gamers.net
XP
385
Country
France
I'm working on a MIDI application for the DS, and a Midi CC is sent when the screen is pressed, and another one when it's released. The only problem is that it's not sent all the time when it's released... And since I have to send only one message at the moment it's released, I can't send the message anytime the stylus isn't pressed. I've tried a lot of thing and I can't figure out why it's not working. Here's what I did :

if (Stylus.Newpress or Stylus.Held)
Send MIDI_CC 127
was_held = 1
else
if (was_held == 1 or Stylus.Released)
Send MIDI_CC 0
was_held = 0
 

AndreXL

Well-Known Member
Member
Joined
Dec 28, 2006
Messages
511
Trophies
0
Website
Visit site
XP
180
Country
I personally have not tried coding for DS...
Still actions under "if statement" should be contained either by brackets or indents and the "else if" statement should be on the same line, right?
 

Ben_j

Well-Known Member
OP
Member
Joined
Nov 13, 2005
Messages
696
Trophies
0
Age
35
Website
www.nintendo-gamers.net
XP
385
Country
France
duh
I know that It was simplified code...

If you really want C code here it is :

Code:
if (Stylus.Newpress || Stylus.Held)
{
ÂÂÂÂdsmi_write(MIDI_CC | channel, 0x00, cc_val_xy(Stylus.X, 'x'));
ÂÂÂÂdsmi_write(MIDI_CC | channel, 0x01, cc_val_xy(Stylus.Y, 'y'));
ÂÂÂÂdsmi_write(MIDI_CC | channel, 0x04, 127);
ÂÂÂÂwas_held = 1;
}
else
{
ÂÂÂÂif (was_held == 1)
ÂÂÂÂ{
Âdsmi_write(MIDI_CC | channel, 0x04, 0);
Âwas_held = 0;
ÂÂÂÂ}
}
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,347
Trophies
3
XP
27,315
Country
United Kingdom
I am not that familiar with midi (reading this http://www.u-he.com/vstsource/files/midiCtrl.h probably increased the knowledge I have of of it about 1000 times, can I assume your app is similar to this?).

The DS is set to poll the touchscreen at a certain frequency (2MHz as I understand it which is faster than anything a human can do as far as touching and releasing the screen is concerned), you said you are using PaLib in the release/discussion thread which is a fine library but for me it is the equivalent of Chinese whispers as far as low level coding is concerned. Therefore gbatek specs for the touchscreen: http://nocash.emubase.de/gbatek.htm#dstouc...encontrollertsc , for something so dependent on the touchscreen it may be worthwhile writing your own I/O routine (assuming it is just for this you effectively only have to read on value (not quite that simple as that as it should require messing with the SPI bus) and see what it is (FFF hex when reading the "Y" position is unreleased, GBATek explains all though).

I am not sure what language you are using there and I am a bit too busy to write and debug some ASM (not to mention make it compatible with what you have, nothing personal I just have a lot on right now).
My personal suggestion for a quick fix is to read the value and write it to a a position in the memory at every poll (or every few if it hits performance as much as I think it might: rough guess says 20 times a second (20Hz) is the realistic limit for audio but you might want to up that a bit just in case.
Now when the screen is read compare the current value to the one in the position you assigned (the nice thing about it being (0)FFF for released with all else below it is you can use a simple less than to compare).
Now you can play "when unreleased" as it will only send on the occasion that the memory location and the current read say what you need.

Edit: I did see your second reply, you may wish to ignore me until I revise my post.
 

Ben_j

Well-Known Member
OP
Member
Joined
Nov 13, 2005
Messages
696
Trophies
0
Age
35
Website
www.nintendo-gamers.net
XP
385
Country
France
I didn't understand everything in your post, but if you say to ignore it then I'll do for the moment
tongue.gif


Here's something else I tried. I think it seems to work a bit better...

Code:
if (Stylus.Held)
{
 Âdsmi_write(MIDI_CC | channel, 0x00, cc_val_xy(Stylus.X, 'x'));
 Âdsmi_write(MIDI_CC | channel, 0x01, cc_val_xy(Stylus.Y, 'y'));
 Âscreen_cc = 127;
 Âwas_held = 1;
}
else
 Âscreen_cc = 0;
if (!Stylus.Held && screen_cc == 127)
 Âscreen_cc = 0;
if (was_held == 1)
{
 Âdsmi_write(MIDI_CC | channel, 0x04, screen_cc);
   was_held = (screen_cc == 0 ? 0 : 1);
}
 
General chit-chat
Help Users
    Veho @ Veho: https://i.imgur.com/ISSVZv3.jpg