gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Help - not drawing pixels on touchscreen when screen...

#66169 - Linkiboy - Sun Jan 08, 2006 6:52 pm

Hi, I am having a problem with making the touch screen draw pixels when it's touched. (Note I'm using an emulator, I can't afford a PassMe/GBMP2...yet). My makefile compiles the code fine; no errors, but when I run it in a emulator it doesn't work. Here is the source code:

ARM9:
Code:
#include "..\nds.h"
#include "..\ipc.h"
#include "..\memory.h"
#include "..\screen.h"
#include "..\system.h"

int main()
{
u16 x,y;
powerON(POWER_ALL);
videoSetMode(MODE_FB0);
VRAM_BANK_A(VRAM_LCD);
lcdSwap();
while(1)
{
x = IPC[0];
y = IPC[1];
VRAM_A[y * SCREEN_WIDTH + x] = RGB(31,0,0);
}
}


ARM7:

Code:
#include "..\nds.h"
#include "..\ipc.h"
#include "..\serial.h"
#include "..\touch.h"

int main()
{
while(1)
{
IPC[0] = (touchRead(TOUCH_X) - TOUCH_CAL_X1) * (TOUCH_CNTRL_X2 - TOUCH_CNTRL_X1) / (TOUCH_CAL_X2 - TOUCH_CAL_X1) + TOUCH_CNTRL_X1;
IPC[1] = (touchRead(TOUCH_Y) - TOUCH_CAL_Y1) * (TOUCH_CNTRL_Y2 - TOUCH_CNTRL_Y1) / (TOUCH_CAL_Y2 - TOUCH_CAL_Y1) + TOUCH_CNTRL_Y1;
}
}


What Am I doing wrong?

#66186 - LiraNuna - Sun Jan 08, 2006 10:13 pm

Why are you using the IPC struct as an array? if you don't need special stuff, try to use the stab ARM7 binary (altho i don't like it) and get your touch readings from IPC->touchXpx and IPC->touchYpx.

#66190 - Linkiboy - Sun Jan 08, 2006 10:49 pm

I used the IPC as an array because thats what the tutorial I'm following told me :P

So what would be the best way to do this?

#66223 - wintermute - Mon Jan 09, 2006 3:20 am

Look at the touchtest example provided with devkitARM

#66229 - Linkiboy - Mon Jan 09, 2006 4:57 am

wintermute wrote:
Look at the touchtest example provided with devkitARM
Sadly, that made me more confused :P

Mostly because it's more complicated than what I already know,, and doesn't use arm7.c an d arm9.c, just one main.c file, so now I don't know what goes into what when I'm amking something more complex.

#66247 - tepples - Mon Jan 09, 2006 6:51 am

If you're using one main.c then it's probably an arm9.c file used with a "standardized" ARM7 binary.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#66345 - Linkiboy - Mon Jan 09, 2006 11:37 pm

Meh. I give up. I'll just notify the creater of the tutorial to correct it.

#66511 - Maverick - Wed Jan 11, 2006 2:21 pm

This code works on hardware

Which emulators have you tried it on?
_________________
http://downtou.ne1.net/

#66563 - Linkiboy - Wed Jan 11, 2006 11:32 pm

Maverick wrote:
This code works on hardware

Which emulators have you tried it on?
All but Ensata...