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 > Tic Tac Toe Touch game

#40571 - chrissieboy - Wed Apr 20, 2005 2:25 pm

Hi all, im busy with the game tac tac toe with touchscreen.

But before i go further i wanna know if it works on hardware.

It's not done already.
.

So can somebody test my code to see if it works on hardware?

this is the emu version :
http://members1.chello.nl/~c.la.mark/tictactoe.bin

And this is the passme version:
http://members1.chello.nl/~c.la.mark/tictactoe.ds.gba



For all people who teach me alot THANK YOU ALL!

#40576 - McDee - Wed Apr 20, 2005 3:11 pm

chrissieboy wrote:

So can somebody test my code to see if it works on hardware?


sorry, but it doesn`t work on hardware. flashed it, booted it, and after the nintendo-logo the screens remain white. nothing comes up.

mcdee

#40577 - Lynx - Wed Apr 20, 2005 3:16 pm

Same here.. (doesn't work)

Here is what I would suggest.. Compile the template and let one of us test it, you might have a problem with your ndslib or devarmkit that would cause all of your .ds.gba's to not work.

Then, if your compiled template works on hardware, compare what you are doing (or not doing) to the template, which will be a confirmed working program on hardware.

#40584 - chrissieboy - Wed Apr 20, 2005 4:24 pm

hi thanx for your comment!!

My template for this game was :

http://rorexrobots.com/ds/drops


i only kicked some code out of it , or modified it.

The only things i changed were some if statements.
For what to do when touched on the screen.

I saw on this forum that the water drops demo works on hardware,
so my opinion was that this MUST work.

But now it didn't???? AARG

This makes me really mad all things i made doesn't works on hardware??

here's my code nothing weird i thought??



Code:

//////////////////////////////////////////////////////////////////////
// Simple ARM9 demo (touch screen controls the colors)
// -- joat
//////////////////////////////////////////////////////////////////////

#include <NDS/NDS.h>
#include <NDS/memory.h>
#include <NDS/ARM9/rand.h>
#include <NDS/ARM9/video.h>
#include <NDS/ARM9/trig_lut.h>

//////////////////////////////////////////////////////////////////////
void pltpoint(int x, int y, int c, uint16 *vram);
void circle(int x, int y, int r, int c, uint16 *vram);

volatile unsigned int counter = 0;
void InterruptHandler(void) {

  if (IF & IRQ_VBLANK) {
    counter++;

    IF = IRQ_VBLANK;
  }
}

//////////////////////////////////////////////////////////////////////

#define KEY_TOUCH (((~IPC->buttons) << 6) & (1<<12))

int main(int argc, char ** argv) {
  // Red main screen, blue sub-screen
  PALETTE[0] = RGB15(0, 0, 31);
  PALETTE[512] = RGB15(0, 0, 31);

  // Turn on the screens and 2D cores and switch to mode 0
  POWER_CR = POWER_ALL_2D;
  DISPLAY_CR = MODE_FB0;
  SUB_DISPLAY_CR = MODE_0_2D | DISPLAY_BG0_ACTIVE;

  SUB_BG0_CR = BG_COLOR_256 | (1 << SCREEN_SHIFT);
  SUB_BG1_CR = BG_COLOR_256 | (2 << SCREEN_SHIFT);

  vramSetMainBanks(VRAM_A_LCD,VRAM_B_LCD,VRAM_C_SUB_BG,VRAM_D_SUB_SPRITE);

  // Enable the V-blank interrupt
  IME = 0;
  IRQ_HANDLER = &InterruptHandler;
  IE = IRQ_VBLANK;
  IF = ~0;
  DISP_SR = DISP_VBLANK_IRQ;
  IME = 1;

  int tx=64;
  int ty=157;

  int touched=0;

  // Touchscreen calibration
  int divx = 14;
  int divy = 18;
  int subx = 00;
  int suby = 12;
  uint16* vram = VRAM_A;

  while (1)
  {

      if(counter > 0)
      {
          counter = 0;
       
          if(KEY_TOUCH)
          {
              if(0 == 0)
              {
                  touched = 1;
                  tx = IPC->touchX / divx - subx;
                  ty = IPC->touchY / divy - suby;

              }
          }
        else
      touched = 0;
       
   





 
      dmaCopyWords(3, (uint32 *)VRAM_C, (uint32 *)vram, 256*192*2);
             
      if (tx > 33 & ty > 3 & tx < 96 & ty <65 ) { circle(64,35,29,         RGB15(0, 0, 31), vram); }
      if (tx > 97 & ty > 3 & tx < 159 & ty < 65) { circle(126,35,29,         RGB15(0, 0, 31), vram); }
      if (tx > 160 & ty > 3 & tx < 222 & ty < 65) { circle(188,35,29,         RGB15(0, 0, 31), vram); }
      
      if (tx > 33 & ty > 3+62 & tx < 96 & ty <65+62 ) { circle(64,34+62,29,         RGB15(0, 0, 31), vram); }
      if (tx > 97 & ty > 3+62 & tx < 159 & ty < 65+62) { circle(126,34+62,29,         RGB15(0, 0, 31), vram); }
      if (tx > 160 & ty > 3+62 & tx < 222 & ty < 65+62) { circle(188,34+62,29,         RGB15(0, 0, 31), vram); }
      
      if (tx > 33 & ty > 3+62+62 & tx < 96 & ty <65+62+62 ) { circle(64,34+62+61,29,         RGB15(0, 0, 31), vram); }
      if (tx > 97 & ty > 3+62+62 & tx < 159 & ty < 65+62+62) { circle(126,34+62+61,29,         RGB15(0, 0, 31), vram); }
      if (tx > 160 & ty > 3+62+62 & tx < 222 & ty < 65+62+62) { circle(188,34+62+61,29,         RGB15(0, 0, 31), vram); }
 
 
  // geef touchscreen achtergrond een andere kleur
  /*
  for(int i=0; i<256*192; i++)
  {
      VRAM_C[i] = RGB15(15,15,15);
  }*/
  //---------------------------------------------------------------------
  // my space
 
   for(int n=34; n<220; n++) { vram[n+4*256] = RGB15(31,0,0); }
   for(int n=34; n<220; n++) { vram[n+65*256] = RGB15(31,0,0); }
   for(int n=34; n<220; n++) { vram[n+126*256] = RGB15(31,0,0); }
   for(int n=34; n<220; n++) { vram[n+187*256] = RGB15(31,0,0); }
   for(int n=4; n<187; n++) { vram[n*256+33] = RGB15(31,0,0); }
   for(int n=4; n<187; n++) { vram[n*256+95] = RGB15(31,0,0); }
   for(int n=4; n<187; n++) { vram[n*256+157] = RGB15(31,0,0); }
   for(int n=4; n<187; n++) { vram[n*256+219] = RGB15(31,0,0); }
 
  //myspace
  //---------------------------------------------------------------------
 

      }
  }
  return 0;
}

void circle(int x, int y, int r, int c, uint16 *vram)
{
    for(int a=0; a<512; a+=4)
    {
            pltpoint(x+((COS[a]*r)>>12),y+((SIN[a]*r)>>12),c,vram);
    }
}

inline void pltpoint(int x, int y, int c, uint16 *vram)
{
    int n = y*256+x;
    if(n > 256*192 || n<0)
        return;
    vram[y*256 + x] = c;
}
//////////////////////////////////////////////////////////////////////


many thanx for your help!!

#40586 - chrissieboy - Wed Apr 20, 2005 4:33 pm

http://members1.chello.nl/~c.la.mark/template.ds.gba

i changed the name of the file so it was template.ds.gba

here up it is.

Can that be the error?

Or totaly not??

#40588 - Ethos - Wed Apr 20, 2005 5:01 pm

The name means nothing :)

#40594 - Theodore104 - Wed Apr 20, 2005 7:19 pm

The "drops" demo doesn't have an entire project, just the arm9 main.cpp; what template are you using for the rest of the project (the arm7 main.cpp, the bootloader, etcetera)?

Might the changes to boot/main.cpp described here be what's needed?

- Theo

#40761 - FourScience - Fri Apr 22, 2005 5:33 am

chrissieboy wrote:
http://members1.chello.nl/~c.la.mark/template.ds.gba

i changed the name of the file so it was template.ds.gba


Is that code you modified or the original template? I recommend compiling someone else's unchanged demo or the original template and letting us see how that runs. Then maybe we can see if there's a problem with your development environment or your source code.

Keep at it!