File: main.c - Tab length: 1 2 4 8 - Lines: on off - No wrap: on off

#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <input.h>
#include <DATlib.h>
#include "externs.h"
#include "sound.h"

#define FRONT_START_X 157
#define FRONT_START_Y 0
#define FRONT_MIN_X 8
#define FRONT_MAX_X 624
#define FRONT_MIN_Y 0
#define FRONT_MAX_Y 0

#define BACK_MIN_X 8
#define BACK_MAX_X 149
#define BACK_MIN_Y 5
#define BACK_MAX_Y 8

int breast_frame=0;

int action=0;
int choice=0;
int wherefrom=0;
int miniGame=0;
int controlON=0;
int success=0;
bool button_available;
short curs_x=0;
short curs_y=0;
int frame=0;
int sec=0;
int min=0;
picture testPict;

typedef struct bkp_ram_info {
  WORD debug_dips;
  BYTE stuff[254];
  //256 bytes
} bkp_ram_info;

bkp_ram_info bkp_data;

extern uint _end;
BYTE p1,p2,ps,p1e,p2e;
uint callBackCounter;

//fix palettes for text
static const ushort fixPalettes[]= {
  0x8000, 0xefb8, 0x0222, 0x5fa7, 0xde85, 0x2c74, 0x2a52, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
  0x8000, 0xebea, 0x0041, 0xa9d8, 0x57c7, 0xf6b5, 0x43a4, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
  0x8000, 0x014c, 0x9113, 0xb15e, 0x317f, 0x119f, 0x11af, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
  0x8000, 0xeb21, 0x0111, 0xee21, 0x6f31, 0x6f51, 0x6f61, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
  0x8000, 0xed31, 0xc311, 0xee51, 0x4f81, 0x4fa1, 0x4fc1, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
  0x8000, 0xbad3, 0x0111, 0x09c0, 0xe7b0, 0xc580, 0xe250, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
  0x8000, 0xefb8, 0x0111, 0xde96, 0x3c75, 0x2950, 0x4720, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
  0x8000, 0x8444, 0x0111, 0xf555, 0xf666, 0x7777, 0x8888, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000 };
 
#define CLIPPING 5

void scrollerInitClipped(scroller *s, scrollerInfo *si, ushort baseSprite, ushort basePalette, short posX, short posY, ushort clipping) {
  ushort i,addr,pos;

  scrollerInit(s,si,baseSprite,basePalette,posX,posY);
  addr=VRAM_POSY_ADDR(baseSprite);
  //pos=((YSHIFT-(0-posY))<<7)|(clipping&0x3f);
  pos=VRAM_POSY(-posY,SPR_UNLINK,clipping);
  for(i=0;i<21;i++)
    SC234Put(addr++,pos);
}

void scrollerSetPosClipped(scroller *s, short toX, short toY, ushort clipping) {
  ushort i,addr,pos;

  if(s->scrlPosY!=toY) {  //Y moved ?
    scrollerSetPos(s,toX,toY);
   
    addr=VRAM_POSY_ADDR(s->baseSprite);
    //pos=((YSHIFT-(0-toY))<<7)|(clipping&0x3f);
    pos=VRAM_POSY(-toY,SPR_UNLINK,clipping);
    for(i=0;i<21;i++)
      SC234Put(addr++,pos);
    //s->scrlPosY=toY;
  } else scrollerSetPos(s,toX,toY);
}

void sortSprites(aSprite *list[], int count) {
  //insertion sort
  int x,y;
  aSprite *tmp;
 
  for(x=1;x<count;x++) {
    y=x;
    while(y>0 && (list[y]->posY < list[y-1]->posY)) {
      tmp=list[y];
      list[y]=list[y-1];
      list[y-1]=tmp;
      y--;
    }
  }
}

#define POOL_MODE
#define LOTS

const char sinTable[]={ 32,34,35,37,38,40,41,43,44,46,47,48,50,51,52,53,
            55,56,57,58,59,59,60,61,62,62,63,63,63,64,64,64,
            64,64,64,64,63,63,63,62,62,61,60,59,59,58,57,56,
            55,53,52,51,50,48,47,46,44,43,41,40,38,37,35,34,
            32,30,29,27,26,24,23,21,20,18,17,16,14,13,12,11,
            9,8,7,6,5,5,4,3,2,2,1,1,1,0,0,0,
            0,0,0,0,1,1,1,2,2,3,4,5,5,6,7,8,
            9,11,12,13,14,16,17,18,20,21,23,24,26,27,29,30};

//misc fix maps
static const ushort fadeData0[15]={0x03f0,0x03f0,0x03f0,0x03f0,0x03f0,0x03f0,0x03f0,0x03f0,0x03f0,0x03f0,0x03f0,0x03f0,0x03f0,0x03f0,0x0000};
static const ushort fadeData1[15]={0x03f1,0x03f1,0x03f1,0x03f1,0x03f1,0x03f1,0x03f1,0x03f1,0x03f1,0x03f1,0x03f1,0x03f1,0x03f1,0x03f1,0x0000};
static const ushort fadeData2[15]={0x03f2,0x03f2,0x03f2,0x03f2,0x03f2,0x03f2,0x03f2,0x03f2,0x03f2,0x03f2,0x03f2,0x03f2,0x03f2,0x03f2,0x0000};
static const ushort fadeData3[15]={0x03f3,0x03f3,0x03f3,0x03f3,0x03f3,0x03f3,0x03f3,0x03f3,0x03f3,0x03f3,0x03f3,0x03f3,0x03f3,0x03f3,0x0000};
static const ushort fadeData4[15]={0x03f4,0x03f4,0x03f4,0x03f4,0x03f4,0x03f4,0x03f4,0x03f4,0x03f4,0x03f4,0x03f4,0x03f4,0x03f4,0x03f4,0x0000};
static const ushort fadeData5[15]={0x03f5,0x03f5,0x03f5,0x03f5,0x03f5,0x03f5,0x03f5,0x03f5,0x03f5,0x03f5,0x03f5,0x03f5,0x03f5,0x03f5,0x0000};
static const ushort fadeData6[15]={0x03f6,0x03f6,0x03f6,0x03f6,0x03f6,0x03f6,0x03f6,0x03f6,0x03f6,0x03f6,0x03f6,0x03f6,0x03f6,0x03f6,0x0000};
static const ushort fadeData7[15]={0x03f7,0x03f7,0x03f7,0x03f7,0x03f7,0x03f7,0x03f7,0x03f7,0x03f7,0x03f7,0x03f7,0x03f7,0x03f7,0x03f7,0x0000};
static const ushort fadeData8[15]={0x03f8,0x03f8,0x03f8,0x03f8,0x03f8,0x03f8,0x03f8,0x03f8,0x03f8,0x03f8,0x03f8,0x03f8,0x03f8,0x03f8,0x0000};
static const ushort fadeData9[15]={0x03f9,0x03f9,0x03f9,0x03f9,0x03f9,0x03f9,0x03f9,0x03f9,0x03f9,0x03f9,0x03f9,0x03f9,0x03f9,0x03f9,0x0000};
static const ushort fadeDataA[15]={0x03fa,0x03fa,0x03fa,0x03fa,0x03fa,0x03fa,0x03fa,0x03fa,0x03fa,0x03fa,0x03fa,0x03fa,0x03fa,0x03fa,0x0000};
static const uint fadeData[11]={(uint)fadeData0,(uint)fadeData1,(uint)fadeData2,(uint)fadeData3,(uint)fadeData4,(uint)fadeData5,(uint)fadeData6,(uint)fadeData7,(uint)fadeData8,(uint)fadeData9,(uint)fadeDataA};
static const ushort logo_95[78]={ 0x0500,0x0501,0x0502,0x0503,0x0504,0x0505,0x0506,0x0507,0x0508,0x0509,0x050a,0x050b,0x0000,
                  0x0510,0x0511,0x0512,0x0513,0x0514,0x0515,0x0516,0x0517,0x0518,0x0519,0x051a,0x051b,0x0000,
                  0x0520,0x0521,0x0522,0x0523,0x0524,0x0525,0x0526,0x0527,0x0528,0x0529,0x052a,0x052b,0x0000,
                  0x0530,0x0531,0x0532,0x0533,0x0534,0x0535,0x0536,0x0537,0x0538,0x0539,0x053a,0x053b,0x0000,
                  0x0540,0x0541,0x0542,0x0543,0x0544,0x0545,0x0546,0x0547,0x0548,0x0549,0x054a,0x054b,0x0000,
                  0x0550,0x0551,0x0552,0x0553,0x0554,0x0555,0x0556,0x0557,0x0558,0x0559,0x055a,0x055b,0x0000 };
static const ushort logo_96[78]={ 0x0560,0x0561,0x0562,0x0563,0x0564,0x0565,0x0566,0x0567,0x0568,0x0569,0x056a,0x056b,0x0000,
                  0x0570,0x0571,0x0572,0x0573,0x0574,0x0575,0x0576,0x0577,0x0578,0x0579,0x057a,0x057b,0x0000,
                  0x0580,0x0581,0x0582,0x0583,0x0584,0x0585,0x0586,0x0587,0x0588,0x0589,0x058a,0x058b,0x0000,
                  0x0590,0x0591,0x0592,0x0593,0x0594,0x0595,0x0596,0x0597,0x0598,0x0599,0x059a,0x059b,0x0000,
                  0x05a0,0x05a1,0x05a2,0x05a3,0x05a4,0x05a5,0x05a6,0x05a7,0x05a8,0x05a9,0x05aa,0x05ab,0x0000,
                  0x05b0,0x05b1,0x05b2,0x05b3,0x05b4,0x05b5,0x05b6,0x05b7,0x05b8,0x05b9,0x05ba,0x05bb,0x0000 };
static const ushort logo_97[78]={ 0x0600,0x0601,0x0602,0x0603,0x0604,0x0605,0x0606,0x0607,0x0608,0x0609,0x060a,0x060b,0x0000,
                  0x0610,0x0611,0x0612,0x0613,0x0614,0x0615,0x0616,0x0617,0x0618,0x0619,0x061a,0x061b,0x0000,
                  0x0620,0x0621,0x0622,0x0623,0x0624,0x0625,0x0626,0x0627,0x0628,0x0629,0x062a,0x062b,0x0000,
                  0x0630,0x0631,0x0632,0x0633,0x0634,0x0635,0x0636,0x0637,0x0638,0x0639,0x063a,0x063b,0x0000,
                  0x0640,0x0641,0x0642,0x0643,0x0644,0x0645,0x0646,0x0647,0x0648,0x0649,0x064a,0x064b,0x0000,
                  0x0650,0x0651,0x0652,0x0653,0x0654,0x0655,0x0656,0x0657,0x0658,0x0659,0x065a,0x065b,0x0000 };
static const ushort logo_98[78]={ 0x0660,0x0661,0x0662,0x0663,0x0664,0x0665,0x0666,0x0667,0x0668,0x0669,0x066a,0x066b,0x0000,
                  0x0670,0x0671,0x0672,0x0673,0x0674,0x0675,0x0676,0x0677,0x0678,0x0679,0x067a,0x067b,0x0000,
                  0x0680,0x0681,0x0682,0x0683,0x0684,0x0685,0x0686,0x0687,0x0688,0x0689,0x068a,0x068b,0x0000,
                  0x0690,0x0691,0x0692,0x0693,0x0694,0x0695,0x0696,0x0697,0x0698,0x0699,0x069a,0x069b,0x0000,
                  0x06a0,0x06a1,0x06a2,0x06a3,0x06a4,0x06a5,0x06a6,0x06a7,0x06a8,0x06a9,0x06aa,0x06ab,0x0000,
                  0x06b0,0x06b1,0x06b2,0x06b3,0x06b4,0x06b5,0x06b6,0x06b7,0x06b8,0x06b9,0x06ba,0x06bb,0x0000 };

//#define TIME 120

void Control_Sub()
{
  p1=volMEMBYTE(P1_CURRENT);
  ps=volMEMBYTE(PS_CURRENT);
  p1e=volMEMBYTE(P1_EDGE);
 
  if(button_available==true)
  {
    if(miniGame==1)
    {
      controlON=0;
     
      if((p1&JOY_LEFT)&&curs_x>0)
      {
        curs_x-=2;
        controlON=1;
      }
      if((p1&JOY_RIGHT)&&curs_x<304)
      {
        curs_x+=2;
        controlON=1;
      }
      if((p1&JOY_UP)&&curs_y>0)
      {
        curs_y-=2;
        controlON=1;
      }
      if((p1&JOY_DOWN)&&curs_y<192)
      {
        curs_y+=2;
        controlON=1;
      }
    }
    else
    {
      if((p1e&JOY_A)||(p1e&JOY_B)||(p1e&JOY_C))
      {
        clearSprites(22,3);
        clearFixLayer();
        action++;
      }
    }
  }
}

void avatar(int character, int textheight)
{
  if(character==0)
  {
    pictureInit(&testPict, &Avatar1,22,16,8,176-(textheight*8),FLIP_NONE);
    palJobPut(16, Avatar1.palInfo->count, Avatar1.palInfo->data);
  }
  if(character==1)
  {
    pictureInit(&testPict, &Avatar2,22,16,8,176-(textheight*8),FLIP_NONE);
    palJobPut(16, Avatar2.palInfo->count, Avatar2.palInfo->data);
  }
  if(character==2)
  {
    pictureInit(&testPict, &Avatar3,22,16,8,176-(textheight*8),FLIP_NONE);
    palJobPut(16, Avatar3.palInfo->count, Avatar3.palInfo->data);
  }
  if(character==3)
  {
    pictureInit(&testPict, &Avatar4,22,16,8,176-(textheight*8),FLIP_NONE);
    palJobPut(16, Avatar4.palInfo->count, Avatar4.palInfo->data);
  }
  if(character==4)
  {
    pictureInit(&testPict, &Avatar5,22,16,8,176-(textheight*8),FLIP_NONE);
    palJobPut(16, Avatar5.palInfo->count, Avatar5.palInfo->data);
  }
}

void GameOver()
{
  int screenTimer=0;
  button_available=false;
 
  send_sound_command(ADPCM_GAMEOVER);
 
  if(success==0)
  {
    fixPrint(15,15,4,3,"GAME OVER");
  }
  else
  {
    fixPrint(16,15,4,3,"YOU WIN!");
  }
 
  while(1) {
    SCClose();
    waitVBlank();
   
    if(++screenTimer==780)
    {
      screenTimer=0;
      miniGame=0;
      success=0;
      clearSprites(1,21);
      SCClose();
      waitVBlank();
      main();
    }
  }
}

void TimerEd()
{
  frame++;
  if(frame==60)
  {
    sec--;
    frame=0;
  }
  if(sec==60)
  {
    min--;
    sec=0;
  }
}

void Lose1() {
  scroller sc;
  // short posX=0;
  // short posY=0;
  // ushort *data;
  // ushort flipMode=0;
  button_available=true;
 
  clearFixLayer();
  scrollerInit(&sc,&BkgA,1,23,0,0);
  palJobPut(23, BkgA.palInfo->count, BkgA.palInfo->data);

  while(1) {
    SCClose();
    waitVBlank();
    Control_Sub();
     
    if(action==0)
    {
      fixPrint(1,27,4,3,"Unfortunately, she's not here anymore.");
      fixPrint(1,28,4,3,"It's a catastrophe!");
    }
    if(action==1)
    {
      fixPrint(1,27,4,3,"Looks like I'm gonna spend this night");
      fixPrint(1,28,4,3,"all alone.");
    }
    if(action==2)
    {
      fixPrint(1,27,4,3,"The most awful that this incident can");
      fixPrint(1,28,4,3,"destroy my career! Oh, shit...");
    }
    if(action==3)
    {
      GameOver();
    }
   
    //scrollerSetPos(&sc,posX,posY);
  }
}

void Lose2() {
  scroller sc;
  // short posX=0;
  // short posY=0;
  // ushort *data;
  // ushort flipMode=0;
  button_available=true;
 
  clearFixLayer();
  scrollerInit(&sc,&BkgA,1,23,0,0);
  palJobPut(23, BkgA.palInfo->count, BkgA.palInfo->data);

  while(1) {
    SCClose();
    waitVBlank();
    Control_Sub();
     
    if(action==0)
    {
      fixPrint(1,28,4,3,"It's just a catastrophe!");
    }
    if(action==1)
    {
      fixPrint(1,27,4,3,"Looks like I'm gonna spend this night");
      fixPrint(1,28,4,3,"all alone.");
    }
    if(action==2)
    {
      fixPrint(1,27,4,3,"The most awful that this incident can");
      fixPrint(1,28,4,3,"destroy my career! Oh, shit...");
    }
    if(action==3)
    {
      GameOver();
    }
   
    //scrollerSetPos(&sc,posX,posY);
  }
}

void Lose3() {
  scroller sc;
  // short posX=0;
  // short posY=0;
  // ushort *data;
  // ushort flipMode=0;
  button_available=true;
 
  clearFixLayer();
  scrollerInit(&sc,&BkgA,1,23,0,0);
  palJobPut(23, BkgA.palInfo->count, BkgA.palInfo->data);

  while(1) {
    SCClose();
    waitVBlank();
    Control_Sub();
     
    if(action==0)
    {
      fixPrint(1,27,4,3,"The chicks go out. I wasn't expecting");
      fixPrint(1,28,4,3,"that.");
    }
    if(action==1)
    {
      fixPrint(1,28,4,3,"To be honest, I'm a bit disappointed.");
    }
    if(action==2)
    {
      fixPrint(1,27,4,3,"Looks like I'm gonna spend another");
      fixPrint(1,28,4,3,"night alone.");
    }
    if(action==3)
    {
      GameOver();
    }
   
    //scrollerSetPos(&sc,posX,posY);
  }
}

void Scene6() {
  scroller sc;
  picture Timer;
  picture Cursor;
  aSprite sp1, sp2, sp3, sp4, sp5;
  int score=0;
  int eyes1_frame=0;
  int eyes2_frame=0;
  int lips_frame=0;
  int hand_frame=0;
  // short posX=0;
  // short posY=0;
  // ushort *data;
  // ushort flipMode=0;
  button_available=true;
  curs_x=160;
  curs_y=112;
 
  send_sound_command(ADPCM_JUST_ONE_NIGHT);
 
  clearFixLayer();
  scrollerInit(&sc,&BkgJ,1,89,0,0);
  palJobPut(89, BkgJ.palInfo->count, BkgJ.palInfo->data);

  while(1) {
    SCClose();
    waitVBlank();
    Control_Sub();
   
    fixPrintf1(6,3,3,3,"%d:",controlON);
     
    if(action==0)
    {
      fixPrint(1,28,4,3,"Girls haven't wasted their time.");
    }
    if(action==1)
    {
      avatar(1,2);
      fixPrint(1,27,3,3,"Oh, finally you're back! We need your");
      fixPrint(1,28,3,3,"help.");
    }
    if(action==2)
    {
      fixPrint(1,28,4,3,"OK, but what do you want me to do?");
    }
    if(action==3)
    {
      avatar(1,1);
      fixPrint(1,28,3,3,"I want you to warm her up a bit ;)");
    }
    if(action==4)
    {
      fixPrint(1,28,4,3,"I can do relaxing massage for you.");
    }
    if(action==5)
    {
      avatar(3,2);
      fixPrint(1,27,3,3,"Wow! That sounds hot! Now show me why");
      fixPrint(1,28,3,3,"they call you Casanova.");
    }
    if(action==6)
    {
     
     
      if(miniGame==0)
      {
        frame=0;
        sec=20;
       
        pictureInit(&Timer, &Clock,25,23,0,0,FLIP_NONE);
      palJobPut(23, Clock.palInfo->count, Clock.palInfo->data);
      pictureInit(&Cursor, &Cur,56,34,curs_x,curs_y,FLIP_NONE);
      palJobPut(34, Cur.palInfo->count, Cur.palInfo->data);
      aSpriteInit(&sp1,&eyes1_spr,30,35,174,48,0,FLIP_NONE,AS_FLAGS_DEFAULT);
      palJobPut(35,eyes1_spr.palInfo->count,&eyes1_spr.palInfo->data);
      aSpriteInit(&sp2,&eyes2_spr,34,45,128,59,0,FLIP_NONE,AS_FLAGS_DEFAULT);
      palJobPut(45,eyes2_spr.palInfo->count,&eyes2_spr.palInfo->data);
      aSpriteInit(&sp3,&lips_spr,37,52,184,72,0,FLIP_NONE,AS_FLAGS_DEFAULT);
      palJobPut(52,lips_spr.palInfo->count,&lips_spr.palInfo->data);
      aSpriteInit(&sp4,&hand_spr,39,56,96,216,0,FLIP_NONE,AS_FLAGS_DEFAULT);
      palJobPut(56,hand_spr.palInfo->count,&hand_spr.palInfo->data);
      aSpriteInit(&sp5,&breast_spr,44,63,106,104,0,FLIP_NONE,AS_FLAGS_DEFAULT);
      palJobPut(63,breast_spr.palInfo->count,&breast_spr.palInfo->data);
     
        /*pictureInit(&Timer, &Clock,25,23,0,0,FLIP_NONE);
        palJobPut(23, Clock.palInfo->count, Clock.palInfo->data);
        pictureInit(&Cursor, &Cur,29,34,curs_x,curs_y,FLIP_NONE);
        palJobPut(34, Cur.palInfo->count, Cur.palInfo->data);
        aSpriteInit(&sp1,&eyes1_spr,30,35,168,32,0,FLIP_NONE,AS_FLAGS_DEFAULT);
        palJobPut(35,eyes1_spr.palInfo->count,&eyes1_spr.palInfo->data);
        aSpriteInit(&sp2,&eyes2_spr,34,45,128,48,0,FLIP_NONE,AS_FLAGS_DEFAULT);
        palJobPut(45,eyes2_spr.palInfo->count,&eyes2_spr.palInfo->data);
        aSpriteInit(&sp3,&lips_spr,37,52,184,64,0,FLIP_NONE,AS_FLAGS_DEFAULT);
        palJobPut(52,lips_spr.palInfo->count,&lips_spr.palInfo->data);
        aSpriteInit(&sp4,&hand_spr,39,56,96,216,0,FLIP_NONE,AS_FLAGS_DEFAULT);
        palJobPut(56,hand_spr.palInfo->count,&hand_spr.palInfo->data);
        aSpriteInit(&sp5,&breast_spr,44,63,104,96,0,FLIP_NONE,AS_FLAGS_DEFAULT);
        palJobPut(63,breast_spr.palInfo->count,&breast_spr.palInfo->data);*/

       
        miniGame=1;
      }
     
      fixPrintf1(1,5,7,3,"%d:",min);
      fixPrintf1(3,5,7,3,"%d",sec);
     
      pictureSetPos(&Cursor,curs_x,curs_y);
     
      if(miniGame==1)
      {
       
        if(controlON==1)
        {
          if((curs_x>104)&&(curs_y>96))
          {
            if((curs_x<208)&&(curs_y>136))
            {
              // aSpriteAnimate(&sp5);
              // if(frame%10==3) boobs();
             
              aSpriteSetStep(&sp5, breast_frame);
 
              if(breast_frame<5) breast_frame++;
              else breast_frame=0;
 
              if(frame==55) score++;
             
              aSpriteSetStep(&sp1, eyes1_frame);
              aSpriteSetStep(&sp2, eyes2_frame);
              aSpriteSetStep(&sp3, lips_frame);
              aSpriteSetStep(&sp4, hand_frame);
             
              aSpriteAnimate(&sp1);
              aSpriteAnimate(&sp2);
              aSpriteAnimate(&sp3);
              aSpriteAnimate(&sp4);
              aSpriteAnimate(&sp5);
       
       
            }
          }
        }
       
        if((min==0)&&(sec==0)&&(frame==0))
        {
          miniGame=2;
          clearSprites(25,60);
          if(score>=21) choice=0;
          if(score<=15) choice=1;
          if((score>15)&&(score<21))  choice=2;
          action++;
        }
      }
     
    }
   
    if(action==17)
    {
      fixPrint(1,27,4,3,"Girls are pissed off with me. They say");
      fixPrint(1,28,4,3,"that I highly disappointed them.");
    }
    if(action==18)
    {
      action=0;
      Lose3();
    }
   
    if(choice==0)
    {
      if(action==7)
      {
        fixPrint(1,28,4,3,"I shoudn't have done it that fast.");
      }
      if(action==8)
      {
        action=17;
      }
    }
    if(choice==1)
    {
      if(action==7)
      {
        fixPrint(1,28,4,3,"I was doing it too slow.");
      }
      if(action==8)
      {
        action=17;
      }
    }
    if(choice==2)
    {
      if(action==7)
      {
        fixPrint(1,28,4,3,"Looks like she liked it!");
      }
      if(action==8)
      {
        fixPrint(1,27,4,3,"She's ready to spend a whole night");
        fixPrint(1,28,4,3,"with me!");
      }
      if(action==9)
      {
        scrollerInit(&sc,&BkgK,1,23,0,0);
        palJobPut(23, BkgK.palInfo->count, BkgK.palInfo->data);
       
        fixPrint(1,28,4,3,"Man, that's gonna be epic!");
      }
      if(action==10)
      {
        avatar(3,1);
        fixPrint(1,28,3,3,"Come here, Casanova...");
      }
      if(action==11)
      {
        fixPrint(1,28,4,3,"That's the ticket!");
      }
      if(action==12)
      {
        avatar(1,2);
        fixPrint(1,27,3,3,"Come, play with us! There's plenty of");
        fixPrint(1,28,3,3,"room.");
      }
      if(action==13)
      {
        fixPrint(1,27,4,3,"I want to show you my gratitude - the");
        fixPrint(1,28,4,3,"hot chicks just can't wait.");
      }
      if(action==14)
      {
        fixPrint(1,28,4,3,"I recommend you to play again.");
      }
      if(action==15)
      {
        fixPrint(1,27,4,3,"Make sure you didn't miss out on");
        fixPrint(1,28,4,3,"anything interesting!");
      }
      if(action==16)
      {
        success=1;
        GameOver();
      }
    }
   
    if(miniGame==1) TimerEd();
   
    //scrollerSetPos(&sc,posX,posY);
  }
}

void Home1() {
  scroller sc;
  // short posX=0;
  // short posY=0;
  // ushort *data;
  // ushort flipMode=0;
  button_available=true;
 
  clearFixLayer();
  scrollerInit(&sc,&BkgG,1,23,0,0);
  palJobPut(23, BkgG.palInfo->count, BkgG.palInfo->data);

  while(1) {
    SCClose();
    waitVBlank();
    Control_Sub();
   
////////////Control////////////
//Select Options Action=3
    if(action==3)
    {
      if(p1e&JOY_UP)
      {
        if(choice==1) choice--;
      }
      if(p1e&JOY_DOWN)
      {
        if(choice==0) choice++;
      }
    }
    //Select Options Action=10
    if(action==10)
    {
      if(p1e&JOY_UP)
      {
        if(choice==1) choice--;
      }
      if(p1e&JOY_DOWN)
      {
        if(choice==0) choice++;
      }
    }
////////////Control////////////
     
    if(action==0)
    {
      fixPrint(1,27,4,3,"Girls quickly find a common");
      fixPrint(1,28,4,3,"language...");
    }
    if(action==1)
    {
      avatar(1,1);
      fixPrint(1,28,3,3,"Come closer, honey... Don't be shy.");
    }
    if(action==2)
    {
      fixPrint(1,27,4,3,"I need to create an atmosphere full of");
      fixPrint(1,28,4,3,"love, lust and joy.");
    }
    if(action==3)
    {
      avatar(0,5);
      fixPrint(1,24,4,3,"But how?");
      fixPrint(3,25,choice==0?2:6,3,"LIGHT UP THE CANDLES AND POUR SOME");
      fixPrint(3,26,choice==0?2:6,3,"WINE");
      fixPrint(3,27,choice==1?2:6,3,"TURN OFF THE LIGHTS AND TURN ON SOME");
      fixPrint(3,28,choice==1?2:6,3,"MUSIC");
    }
    if(action==5)
    {
      fixPrint(1,28,4,3,"A joyful melody starts playing.");
    }
    if(action==6)
    {
      avatar(1,2);
      fixPrint(1,27,3,3,"I got an idea... How about going to a");
      fixPrint(1,28,3,3,"club?");
    }
    if(action==7)
    {
      fixPrint(1,27,4,3,"The girl from the park doesn't mind.");
      fixPrint(1,28,4,3,"The model says...");
    }
    if(action==8)
    {
      avatar(1,1);
      fixPrint(1,28,3,3,"Thanks for everything! Bye!");
    }
    if(action==9)
    {
      action=0;
      Lose3();
    }
    if(action==10)
    {
      avatar(0,5);
      fixPrint(1,24,4,3,"But I ran out of wine! Should I leave");
      fixPrint(1,25,4,3,"the girls and go to the local liqueur");
      fixPrint(1,26,4,3,"store?");
      fixPrint(3,27,choice==0?2:6,3,"NO. STAY HOME.");
      fixPrint(3,28,choice==1?2:6,3,"YES. GO TO THE STORE.");
    }
   
    if(choice==0)
    {
      if(action==4)
      {
        action=10;
        choice=0;
      }
      if(action==11)
      {
        fixPrint(1,28,4,3,"The model turns on the radio.");
      }
      if(action==12)
      {
        action=5;
      }
    }
    if(choice==1)
    {
      if(action==4)
      {
        fixPrint(1,28,4,3,"I turn on the radio.");
      }
      if(action==11)
      {
        wherefrom=0;
        fixPrint(1,28,4,3,"I take my wallet and go out.");
      }
      if(action==12)
      {
        action=0;
        Scene5();
      }
    }
   
    //scrollerSetPos(&sc,posX,posY);
  }
}

void Home2() {
  scroller sc;
  // short posX=0;
  // short posY=0;
  // ushort *data;
  // ushort flipMode=0;
  button_available=true;
 
  clearFixLayer();
  scrollerInit(&sc,&BkgD,1,23,0,0);
  palJobPut(23, BkgD.palInfo->count, BkgD.palInfo->data);

  while(1) {
    SCClose();
    waitVBlank();
    Control_Sub();
     
    if(action==0)
    {
      fixPrint(1,26,4,3,"Unfortunately, the girl from the club");
      fixPrint(1,27,4,3,"changed her mind when you weren't");
      fixPrint(1,28,4,3,"there.");
    }
    if(action==1)
    {
      avatar(2,2);
      fixPrint(1,27,3,3,"Sorry, but I gotta go. I hope you");
      fixPrint(1,28,3,3,"understand...");
    }
    if(action==2)
    {
      fixPrint(1,28,4,3,"The model is disappointed.");
    }
    if(action==3)
    {
      avatar(1,3);
      fixPrint(1,26,4,3,"If she leaves, then I'm gonna go with");
      fixPrint(1,27,4,3,"her. I thought I could count on you,");
      fixPrint(1,28,4,3,"but I was wrong.");
    }
    if(action==4)
    {
      action=0;
      Lose2();
    }
   
    //scrollerSetPos(&sc,posX,posY);
  }
}

void Scene5() {
  scroller sc;
  // short posX=0;
  // short posY=0;
  // ushort *data;
  // ushort flipMode=0;
  button_available=true;
 
  clearFixLayer();
  scrollerInit(&sc,&BkgH,1,23,0,0);
  palJobPut(23, BkgH.palInfo->count, BkgH.palInfo->data);

  while(1) {
    SCClose();
    waitVBlank();
    Control_Sub();
   
////////////Control////////////
//Select Options Action=3
    if(action==3)
    {
      if(p1e&JOY_UP)
      {
        if(choice==1) choice--;
      }
      if(p1e&JOY_DOWN)
      {
        if(choice==0) choice++;
      }
    }
////////////Control////////////
     
    if(action==0)
    {
      fixPrint(1,26,4,3,"Fortunately, the liqueur store is");
      fixPrint(1,27,4,3,"across the road. I take a bottle and");
      fixPrint(1,28,4,3,"go to the checkout.");
    }
    if(action==1)
    {
      avatar(4,2);
      fixPrint(1,27,3,3,"You sure you don't want anything else,");
      fixPrint(1,28,3,3,"handsome?");
    }
    if(action==2)
    {
      fixPrint(1,27,4,3,"A young, pretty cashier winks at me. I");
      fixPrint(1,28,4,3,"got her...");
    }
    if(action==3)
    {
      avatar(0,3);
      fixPrint(1,26,4,3,"What should I do?");
      fixPrint(3,27,choice==0?2:6,3,"PAY FOR THE WINE AND GO HOME");
      fixPrint(3,28,choice==1?2:6,3,"FLIRT WITH HER");
    }
   
    if(choice==0)
    {
      if(action==4)
      {
        fixPrint(1,28,4,3,"Going back home.");
      }
      if(action==5)
      {
        if(wherefrom==1)
        {
          action=0;
          Home2();
        }
        if(wherefrom==0)
        {
          action=0;
          Scene6();
        }
      }
    }
    if(choice==1)
    {
      if(action==4)
      {
        fixPrint(1,27,4,3,"The cashier grabs my hand and leads me");
        fixPrint(1,28,4,3,"to the storeroom where...");
      }
      if(action==5)
      {
        scrollerInit(&sc,&BkgI,1,23,0,0);
        palJobPut(23, BkgI.palInfo->count, BkgI.palInfo->data);
       
        fixPrint(1,28,4,3,"... well, you can see for yourself ;)");
      }
      if(action==6)
      {
        avatar(4,1);
        fixPrint(1,28,3,3,"I can't believe it!");
      }
      if(action==7)
      {
        fixPrint(1,27,4,3,"She's quite hot. The girl whispers in");
        fixPrint(1,28,4,3,"my ear...");
      }
      if(action==8)
      {
        avatar(4,1);
        fixPrint(1,28,3,3,"Do you like it, honey?");
      }
      if(action==9)
      {
        fixPrint(1,28,4,3,"You bet I do!");
      }
      if(action==10)
      {
        avatar(4,1);
        fixPrint(1,28,3,3,"You're such a good kisser!");
      }
      if(action==11)
      {
        fixPrint(1,27,4,3,"I think I'm gonna shop here more");
        fixPrint(1,28,4,3,"often. ;)");
      }
      if(action==12)
      {
        fixPrint(1,27,4,3,"Not all of our customers get such a");
        fixPrint(1,28,4,3,"service.");
      }
      if(action==13)
      {
        fixPrint(1,27,4,3,"They're simply not as good looking as");
        fixPrint(1,28,4,3,"me ;)");
      }
      if(action==14)
      {
        avatar(4,1);
        fixPrint(1,28,3,3,"Let's go to your place.");
      }
      if(action==15)
      {
        fixPrint(1,26,4,3,"Wait, oh shit... I completely forgot");
        fixPrint(1,27,4,3,"about it! The girls are still waiting");
        fixPrint(1,28,4,3,"for me in my apartment.");
      }
      if(action==16)
      {
        fixPrint(1,27,4,3,"Gotta hurry up! I hope the model is");
        fixPrint(1,28,4,3,"still there.");
      }
      if(action==17)
      {
        action=0;
        Lose1();
      }
    }
   
    //scrollerSetPos(&sc,posX,posY);
  }
}

void Scene4() {
  scroller sc;
  // short posX=0;
  // short posY=0;
  // ushort *data;
  // ushort flipMode=0;
  button_available=true;
 
  clearFixLayer();
  scrollerInit(&sc,&BkgF,1,23,0,0);
  palJobPut(23, BkgF.palInfo->count, BkgF.palInfo->data);

  while(1) {
    SCClose();
    waitVBlank();
    Control_Sub();
   
////////////Control////////////
//Select Options Action=5
    if(action==5)
    {
      if(p1e&JOY_UP)
      {
        if(choice==1) choice--;
      }
      if(p1e&JOY_DOWN)
      {
        if(choice==0) choice++;
      }
    }
//Select Options Action=7
    if(action==7)
    {
      if(p1e&JOY_UP)
      {
        if(choice==1) choice--;
      }
      if(p1e&JOY_DOWN)
      {
        if(choice==0) choice++;
      }
    }
////////////Control////////////
     
    if(action==0)
    {
      fixPrint(1,28,4,3,"I sit down next to a pretty girl.");
    }
    if(action==1)
    {
      avatar(4,1);
      fixPrint(1,28,3,3,"Can I help you?");
    }
    if(action==2)
    {
      fixPrint(1,28,4,3,"I tell her about the model.");
    }
    if(action==3)
    {
      avatar(4,2);
      fixPrint(1,27,3,3,"I would love to meet her... But you");
      fixPrint(1,28,3,3,"have to do something for me.");
    }
    if(action==4)
    {
      fixPrint(1,27,4,3,"She probably means a present or");
      fixPrint(1,28,4,3,"something...");
    }
    if(action==5)
    {
      avatar(0,3);
      fixPrint(1,26,4,3,"What can I offer her?");
      fixPrint(3,27,choice==0?2:6,3,"A FREE PHOTO SHOOT");
      fixPrint(3,28,choice==1?2:6,3,"A DINNER AT A FANCY RESTAURANT");
    }
    if(action==6)
    {
      choice=0;
      action=7;
    }
    if(action==7)
    {
      avatar(4,4);
      fixPrint(1,25,3,3,"How_about_something_more...");
      fixPrint(1,26,3,3,"Impressive?");
      fixPrint(3,27,choice==0?2:6,3,"AN EXOTIC TRIP");
      fixPrint(3,28,choice==1?2:6,3,"MEET A CELEBRITY");
    }
    if(action==9)
    {
      fixPrint(1,26,4,3,"Well, there's nothing else I can do...");
      fixPrint(1,27,4,3,"I call the model and tell her that I");
      fixPrint(1,28,4,3,"can't find a girl for her.");
    }
    if(action==10)
    {
      fixPrint(1,27,4,3,"She's extremely disappointed. Probably");
      fixPrint(1,28,4,3,"doesn't want to work with me anymore.");
    }
    if(action==11)
    {
      fixPrint(1,28,4,3,"What a bummer!");
    }
    if(action==12)
    {
      fixPrint(1,27,4,3,"Looks like I'm gonna spend another");
      fixPrint(1,28,4,3,"night alone.");
    }
    if(action==13)
    {
      fixPrint(1,27,4,3,"And the worst is that it might hurt my");
      fixPrint(1,28,4,3,"reputation! Damn...");
    }
    if(action==14)
    {
      GameOver();
    }
   
    if(choice==0)
    {
      if(action==8)
      {
        avatar(4,1);
        fixPrint(1,28,3,3,"No, I'm not interested.");
      }
    }
    if(choice==1)
    {
      if(action==6)
      {
        avatar(4,2);
        fixPrint(1,27,3,3,"Sorry, but I don't think you know any");
        fixPrint(1,28,3,3,"famous people.");
      }
    }
   
    //scrollerSetPos(&sc,posX,posY);
  }
}

void Scene3() {
  scroller sc;
  // short posX=0;
  // short posY=0;
  // ushort *data;
  // ushort flipMode=0;
  button_available=true;
 
  clearFixLayer();
  scrollerInit(&sc,&BkgC,1,23,0,0);
  palJobPut(23, BkgC.palInfo->count, BkgC.palInfo->data);

  while(1) {
    SCClose();
    waitVBlank();
    Control_Sub();
   
////////////Control////////////
//Select Options Action=5
    if(action==5)
    {
      if(p1e&JOY_UP)
      {
        if(choice==1) choice--;
      }
      if(p1e&JOY_DOWN)
      {
        if(choice==0) choice++;
      }
    }
//Select Options Action=10
    if(action==10)
    {
      if(p1e&JOY_UP)
      {
        if(choice==1) choice--;
      }
      if(p1e&JOY_DOWN)
      {
        if(choice==0) choice++;
      }
    }
//Select Options Action=15
    if(action==15)
    {
      if(p1e&JOY_UP)
      {
        if(choice==1) choice--;
      }
      if(p1e&JOY_DOWN)
      {
        if(choice==0) choice++;
      }
    }
////////////Control////////////
     
    if(action==0)
    {
      fixPrint(1,28,4,3,"She catches my eye immediately.");
    }
    if(action==1)
    {
      avatar(2,1);
      fixPrint(1,28,3,3,"Hi! How's it going?");
    }
    if(action==2)
    {
      fixPrint(1,28,4,3,"I explain her the situation.");
    }
    if(action==3)
    {
      fixPrint(1,27,4,3,"She doesn't mind. The girl obviously");
      fixPrint(1,28,4,3,"likes me.");
    }
    if(action==4)
    {
      fixPrint(1,27,4,3,"Should I get to know her better when");
      fixPrint(1,28,4,3,"it's not too late?");
    }
    if(action==5)
    {
      avatar(0,3);
      fixPrint(1,26,4,3,"What do you think?");
      fixPrint(3,27,choice==0?2:6,3,"KEEP GOING TO YOUR PLACE");
      fixPrint(3,28,choice==1?2:6,3,"STAY HERE WITH HER");
    }
    if(action==10)
    {
      avatar(0,6);
      fixPrint(1,23,4,3,"Maybe I can do something to make her");
      fixPrint(1,24,4,3,"feel better?");
      fixPrint(3,25,choice==0?2:6,3,"LIGHT UP THE CANDLES AND POUR HER");
      fixPrint(3,26,choice==0?2:6,3,"SOME WINE");
      fixPrint(3,27,choice==1?2:6,3,"TURN OFF THE LIGHTS AND TURN ON");
      fixPrint(3,28,choice==1?2:6,3,"SOME MUSIC");
    }
    if(action==15)
    {
      avatar(0,5);
      fixPrint(1,24,4,3,"But I ran out of wine! Should I leave");
      fixPrint(1,25,4,3,"the girls and go to the local liqueur");
      fixPrint(1,26,4,3,"store?");
      fixPrint(3,27,choice==0?2:6,3,"NO. STAY HOME.");
      fixPrint(3,28,choice==1?2:6,3,"YES. GO TO THE STORE.");
    }
    if(action==17)
    {
      fixPrint(1,28,4,3,"The model is disappointed.");
    }
    if(action==18)
    {
      avatar(1,3);
      fixPrint(1,26,3,3,"If she leaves, then I'm gonna go with");
      fixPrint(1,27,3,3,"her. I thought I could count on you,");
      fixPrint(1,28,3,3,"but I was wrong.");
    }
    if(action==19)
    {
      action=0;
      Lose2();
    }
    if(action==20)
    {
      fixPrint(1,26,4,3,"Now I realize how much time has");
      fixPrint(1,27,4,3,"passed. I left the poor thing all");
      fixPrint(1,28,4,3,"alone!");
    }
    if(action==21)
    {
      fixPrint(1,27,4,3,"I run back home, hoping she's still");
      fixPrint(1,28,4,3,"there.");
    }
    if(action==22)
    {
      action=0;
      Lose1();
    }
   
    if(choice==0)
    {
      if(action==6)
      {
        fixPrint(1,28,4,3,"I pay and we go out.");
      }
      if(action==7)
      {
        scrollerInit(&sc,&BkgD,1,23,0,0);
        palJobPut(23, BkgD.palInfo->count, BkgD.palInfo->data);
       
        fixPrint(1,28,4,3,"The model is all horny, ready to play.");
      }
      if(action==8)
      {
        avatar(1,2);
        fixPrint(1,27,3,3,"I like your style! Come closer,");
        fixPrint(1,28,3,3,"baby...");
      }
      if(action==9)
      {
        fixPrint(1,27,4,3,"The chick from the club is a little");
        fixPrint(1,28,4,3,"timid.");
      }
      if(action==11)
      {
        action=15;
        choice=0;
      }
      if(action==16)
      {
        fixPrint(1,28,4,3,"''Sorry, I gotta go'', she says.");
      }
    }
    if(choice==1)
    {
      if(action==6)
      {
        fixPrint(1,27,4,3,"I'm flirting with her. She really does");
        fixPrint(1,28,4,3,"like me!");
      }
      if(action==7)
      {
        fixPrint(1,27,4,3,"We talk for a while. I tell her about");
        fixPrint(1,28,4,3,"my job. She seems interested.");
      }
      if(action==8)
      {  
        fixPrint(1,28,4,3,"Then she orders her favorite cocktail.");
      }
      if(action==9)
      {
        action=20;
      }
      if(action==11)
      {
        fixPrint(1,26,4,3,"It wouldn't change anything. She says");
        fixPrint(1,27,4,3,"''sorry, but I gotta go. It's too late");
        fixPrint(1,28,4,3,"now''.");
      }
      if(action==12)
      {
        action=17;
      }
      if(action==16)
      {
        action=23;
        wherefrom=1;  
        fixPrint(1,28,4,3,"I take my wallet and go out.");
      }
      if(action==24)
      {
        action=0;
        Scene5();
      }
    }
    if(choice==2)
    {
      if(action==15)
      {
        action=7;
        choice=0;
      }
    }
   
    //scrollerSetPos(&sc,posX,posY);
  }
}

void Scene2() {
  scroller sc;
  // short posX=0;
  // short posY=0;
  // ushort *data;
  // ushort flipMode=0;
  button_available=true;
 
  clearFixLayer();
  scrollerInit(&sc,&BkgE,1,23,0,0);
  palJobPut(23, BkgE.palInfo->count, BkgE.palInfo->data);

  while(1) {
    SCClose();
    waitVBlank();
    Control_Sub();
   
////////////Control////////////
//Select Options Action=5
    if(action==5)
    {
      if(p1e&JOY_UP)
      {
        if(choice==1) choice--;
      }
      if(p1e&JOY_DOWN)
      {
        if(choice==0) choice++;
      }
    }
//Select Options Action=11
    if(action==11)
    {
      if(p1e&JOY_UP)
      {
        if(choice==1) choice--;
      }
      if(p1e&JOY_DOWN)
      {
        if(choice==0) choice++;
      }
    }
//Select Options Action=14
    if(action==14)
    {
      if(p1e&JOY_UP)
      {
        if(choice>=1) choice--;
      }
      if(p1e&JOY_DOWN)
      {
        if(choice<2)  choice++;
      }
    }
////////////Control////////////
     
    if(action==0)
    {
      fixPrint(1,28,4,3,"I come across a sexy gal.");
    }
    if(action==1)
    {
      avatar(3,1);
      fixPrint(1,28,3,3,"Hey! How are you?");
    }
    if(action==2)
    {
      fixPrint(1,28,4,3,"I explain her the situation.");
    }
    if(action==3)
    {
      avatar(3,2);
      fixPrint(1,27,3,3,"OK, I got it... Looks like your friend");
      fixPrint(1,28,3,3,"want to have some fun.");
    }
    if(action==4)
    {
      fixPrint(1,27,4,3,"She thinks for a minute... But, no.");
      fixPrint(1,28,4,3,"She's not interested.");
    }
    if(action==5)
    {
      avatar(0,3);
      fixPrint(1,26,4,3,"What now?");
      fixPrint(3,27,choice==0?2:6,3,"FIND ANOTHER GAL");
      fixPrint(3,28,choice==1?2:6,3,"TRY TO CONVINCE HER");
    }
    if(action==7)
    {
      avatar(3,1);
      fixPrint(1,28,3,3,"Well, if you insist...");
    }
    if(action==8)
    {
      fixPrint(1,28,4,3,"I think my stubbornness turns her on.");
    }
    if(action==9)
    {
      avatar(3,3);
      fixPrint(1,26,3,3,"Honestly, I was just about to go to");
      fixPrint(1,27,3,3,"bed... But why not? It's gonna be fun");
      fixPrint(1,28,3,3,"I guess.");
    }
    if(action==10)
    {
      action=0;
      Home1();
    }
    if(action==11)
    {
      avatar(0,3);
      fixPrint(1,26,4,3,"Where to now?");
      fixPrint(3,27,choice==0?2:6,3,"TO THE CLUB");
      fixPrint(3,28,choice==1?2:6,3,"TO THE CAFE");
    }
    if(action==14)
    {
      avatar(0,5);
      fixPrint(1,24,4,3,"I try, but doesn't work out. Gotta");
      fixPrint(1,25,4,3,"find another girl. But where?");
      fixPrint(3,26,choice==0?2:6,3,"TO THE CLUB");
      fixPrint(3,27,choice==1?2:6,3,"TO THE CAFE");
      fixPrint(3,28,choice==2?2:6,3,"STAY IN THE PARK");
    }
   
    if(choice==0)
    {
      if(action==6)
      {
        action=11;
      }
      if(action==12)
      {
        fixPrint(1,28,4,3,"I go there.");
      }
      if(action==13)
      {
        action=0;
        Scene3();
      }
      if(action==15)
      {
        fixPrint(1,28,4,3,"It's not that far. Good.");
      }
      if(action==16)
      {
        action=0;
        Scene3();
      }
    }
    if(choice==1)
    {
      if(action==6)
      {
        action=14;
        choice=0;
      }
      if(action==12)
      {
        fixPrint(1,28,4,3,"I go there.");
      }
      if(action==13)
      {  
        action=0;
        Scene4();
      }
      if(action==15)
      {
        fixPrint(1,28,4,3,"It's not that far. Good.");
      }
      if(action==16)
      {
        action=0;
        Scene4();
      }
    }
    if(choice==2)
    {
      if(action==15)
      {
        action=7;
        choice=0;
      }
    }
   
    //scrollerSetPos(&sc,posX,posY);
  }
}

void Scene1() {
  scroller sc;
  // short posX=0;
  // short posY=0;
  // ushort *data;
  // ushort flipMode=0;
  button_available=true;
 
  clearFixLayer();
  scrollerInit(&sc,&BkgB,1,23,0,0);
  palJobPut(23, BkgB.palInfo->count, BkgB.palInfo->data);

  while(1) {
    SCClose();
    waitVBlank();
    Control_Sub();
   
////////////Control////////////
//Select Options Action=2
    if(action==2)
    {
      if(p1e&JOY_UP)
      {
        if(choice==1) choice--;
      }
      if(p1e&JOY_DOWN)
      {
        if(choice==0) choice++;
      }
    }
//Select Options Action=8
    if(action==8)
    {
      if(p1e&JOY_UP)
      {
        if(choice==1) choice--;
      }
      if(p1e&JOY_DOWN)
      {
        if(choice==0) choice++;
      }
    }
//Select Options Action=14
    if(action==14)
    {
      if(p1e&JOY_UP)
      {
        if(choice>=1) choice--;
      }
      if(p1e&JOY_DOWN)
      {
        if(choice<2)  choice++;
      }
    }
////////////Control////////////
     
    if(action==0)
    {
      fixPrint(1,27,4,3,"Jeez! She's even more hot in person");
      fixPrint(1,28,4,3,"than she was in the pictures!");
    }
    if(action==1)
    {
      fixPrint(1,27,4,3,"I wonder if she would go with me on a");
      fixPrint(1,28,4,3,"date...");
    }
    if(action==2)
    {
      avatar(0,3);
      fixPrint(1,26,4,3,"What do you think I should do?");
      fixPrint(3,27,choice==0?2:6,3,"FLIRT WITH HER");
      fixPrint(3,28,choice==1?2:6,3,"CONCENTRATE ON WORK");
    }
    if(action==8)
    {
      avatar(0,4);
      fixPrint(1,25,4,3,"Damn it! Should I ask her to go");
      fixPrint(1,26,4,3,"somewhere chill instead?");
      fixPrint(3,27,choice==0?2:6,3,"DO IT.");
      fixPrint(3,28,choice==1?2:6,3,"NOT NOW. JUST LEAVE HER ALONE.");
    }
    if(action==14)
    {
      avatar(0,4);
      fixPrint(1,25,4,3,"Now where can I find a girl?");
      fixPrint(3,26,choice==0?2:6,3,"GO TO THE PARK");
      fixPrint(3,27,choice==1?2:6,3,"GO TO A CLUB");
      fixPrint(3,28,choice==2?2:6,3,"GO TO A CAFE");
    }
    if(action==15)
    {
      fixPrint(1,28,4,3,"I'm starting right away.");
    }
    if(action==16)
    {
      action=0;
      if(choice==0) Scene2();
      if(choice==1) Scene3();
      if(choice==2) Scene4();
    }
   
    if(choice==0)
    {
      if(action==3)
      {
        fixPrint(1,27,4,3,"I tell her that she has a gorgeous");
        fixPrint(1,28,4,3,"body.");
      }
      if(action==4)
      {
        fixPrint(1,25,4,3,"She seems to ignore my compliment. Of");
        fixPrint(1,26,4,3,"course she does! She probably hears");
        fixPrint(1,27,4,3,"those kinds of compliments all the");
        fixPrint(1,28,4,3,"time.");
      }
      if(action==5)
      {
        fixPrint(1,27,4,3,"Ok then. Let's just start doing my job");
        fixPrint(1,28,4,3,"before it gets even worse.");
      }
      if(action==6)
      {
        choice=1;
        action=3;
      }
      if(action==9)
      {
        fixPrint(1,27,4,3,"I smile at her warmly and promise her");
        fixPrint(1,28,4,3,"a night she'll never forget.");
      }
      if(action==10)
      {
        avatar(1,2);
        fixPrint(1,27,3,3,"Excuse me?! Don't you know that I");
        fixPrint(1,28,3,3,"don't do boys?!");
      }
      if(action==11)
      {
        fixPrint(1,26,4,3,"Looks like I really pissed her off.");
        fixPrint(1,27,4,3,"Now there's no chance I'm gonna seduce");
        fixPrint(1,28,4,3,"her.");
      }
      if(action==12)
      {
        fixPrint(1,27,4,3,"Bad move, buddy. Such things can ruin");
        fixPrint(1,28,4,3,"my entire carrier.");
      }
      if(action==13)
      {
        //clearFixLayer();
        GameOver();
      }
    }
    if(choice==1)
    {
      if(action==3)
      {
        fixPrint(1,27,4,3,"I'm setting up the camera and starting");
        fixPrint(1,28,4,3,"taking pictures.");
      }
      if(action==4)
      {
        fixPrint(1,26,4,3,"Now everything goes smoothly. Oh boy...");
        fixPrint(1,27,4,3,"She's such a beauty! And so");
        fixPrint(1,28,4,3,"professional!");
      }
      if(action==5)
      {  
        fixPrint(1,27,4,3,"After we're done I ask her what she's");
        fixPrint(1,28,4,3,"doing tonight.");
      }
      if(action==6)
      {
        avatar(1,2);
        fixPrint(1,27,3,3,"I'm looking for something hot ");
        fixPrint(1,28,3,3,"tonight... If you know what I mean.");
      }
      if(action==7)
      {
        choice=0;
        action=8;
      }
      if(action==9)
      {
        fixPrint(1,26,4,3,"She asks me if I know some hot girls.");
        fixPrint(1,27,4,3,"Oh my... Who would've thought she was");
        fixPrint(1,28,4,3,"into chicks?!");
      }
      if(action==10)
      {
        fixPrint(1,26,4,3,"I'm telling her that she can stay at");
        fixPrint(1,27,4,3,"my place while I go out and find her");
        fixPrint(1,28,4,3,"some pretty girl.");
      }
      if(action==11)
      {
        choice=0;
        action=14;
      }
    }
   
    //scrollerSetPos(&sc,posX,posY);
  }
}

void Scene0() {
  scroller sc;
  // short posX=0;
  // short posY=0;
  // ushort *data;
  // ushort flipMode=0;
  button_available=true;
  choice=0;
  action=0;
 
  clearFixLayer();
  scrollerInit(&sc,&BkgA,1,16,0,0);
  palJobPut(16, BkgA.palInfo->count, BkgA.palInfo->data);

  while(1) {
    SCClose();
    waitVBlank();
    Control_Sub();
     
    if(action==0)
    {
      fixPrint(1,27,4,3,"Hi! It's me, Casanova - a natural born");
      fixPrint(1,28,4,3,"pick-up artist!");
    }
   
    if(action==1)
    {
      fixPrint(1,27,4,3,"Not so long ago I became a");
      fixPrint(1,28,4,3,"professional photographer.");
    }
   
    if(action==2)
    {
      fixPrint(1,27,4,3,"And today I'm going to have a photo");
      fixPrint(1,28,4,3,"shoot with a famous fashion model.");
    }
   
    if(action==3)
    {
      fixPrint(1,26,4,3,"Well... Looks like I gotta go. It is");
      fixPrint(1,27,4,3,"extremely important and I can't be");  
      fixPrint(1,28,4,3,"late.");
    }
   
    if(action==4)
    {
      clearSprites(1,21);
      SCClose();
      waitVBlank();
      action=0;
      Scene1();
    }
   
    //scrollerSetPos(&sc,posX,posY);
  }
}

int main(void) {
  int scrl_x=0;
  int scrl_y=0;
  short showdebug=false;
  scroller frontScroll;
  ushort *data;
  // ushort flipMode=0;
 
  send_sound_command(ADPCM_DR_LOVE);
 
  clearFixLayer();
  initGfx();

  palJobPut(0,8,fixPalettes);

  //if(setup4P())
  //  fixPrint(2,4,7,3,"4P! :)");
  //else fixPrint(2,4,7,3,"no 4P :(");

  backgroundColor(0x7bbb);
  jobMeterSetup(true);

  scrollerInit(&frontScroll, &ffbg_b, 1, 16, scrl_x, scrl_y);
  //scrollerInitClipped(&frontScroll, &ffbg_b, 22, 16 + ffbg_a.palInfo->count, x, y, CLIPPING);
  palJobPut(16, ffbg_b.palInfo->count, ffbg_b.palInfo->data);

  data=dbgTags.maps[0];
  palJobPut(200,dbgTags.palInfo->count,&dbgTags.palInfo->data);
  SC234Put(VRAM_POSX_ADDR(200),VRAM_POSX(0));
  SC234Put(VRAM_POSY_ADDR(200),VRAM_POSY(224,SPR_UNLINK,0));
  SC234Put(VRAM_SPR_ADDR(200),data[4<<1]);
  SC234Put(VRAM_SPR_ADDR(200)+1,200<<8);
  SC234Put(VRAM_POSX_ADDR(201),VRAM_POSX(0));
  SC234Put(VRAM_POSY_ADDR(201),VRAM_POSY(224,SPR_UNLINK,0));
  SC234Put(VRAM_SPR_ADDR(201),data[40<<1]);
  SC234Put(VRAM_SPR_ADDR(201)+1,200<<8);
  SC234Put(VRAM_POSX_ADDR(202),VRAM_POSX(0));
  SC234Put(VRAM_POSY_ADDR(202),VRAM_POSY(224,SPR_UNLINK,0));
  SC234Put(VRAM_SPR_ADDR(202),data[40<<1]);
  SC234Put(VRAM_SPR_ADDR(202)+1,(200<<8)|FLIP_X);
  SC234Put(VRAM_POSX_ADDR(203),VRAM_POSX(0));
  SC234Put(VRAM_POSY_ADDR(203),VRAM_POSY(224,SPR_UNLINK,0));
  SC234Put(VRAM_SPR_ADDR(203),data[40<<1]);
  SC234Put(VRAM_SPR_ADDR(203)+1,(200<<8)|FLIP_Y);
  SC234Put(VRAM_POSX_ADDR(204),VRAM_POSX(0));
  SC234Put(VRAM_POSY_ADDR(204),VRAM_POSY(224,SPR_UNLINK,0));
  SC234Put(VRAM_SPR_ADDR(204),data[40<<1]);
  SC234Put(VRAM_SPR_ADDR(204)+1,(200<<8)|FLIP_XY);
 
  fixPrint(14,20,4,3,"PRESS START");
 
  while(1) {
    SCClose();
    waitVBlank();

    p1=volMEMBYTE(P1_CURRENT);
    p1e=volMEMBYTE(P1_EDGE);
    ps=volMEMBYTE(PS_EDGE);
   
    while((volMEMWORD(0x3c0006)>>7)!=0x120); //wait raster line 16
    jobMeterColor(JOB_BLUE);

    /*if((p1&JOY_UP)&&y>=176) y--;
    if((p1&JOY_DOWN)&&y<=220) y++;
    if((p1&JOY_LEFT)&&x>=32)
    {
      x--;
      flipMode|=FLIP_X;
      aSpriteSetFlip(&demoSpr,flipMode);
    }
    if((p1&JOY_RIGHT)&&x<=288)
    {
      x++;
      flipMode&=~FLIP_X;
      aSpriteSetFlip(&demoSpr,flipMode);
    }*/

   
    if(ps&P1_START) {
      clearSprites(1, 42);
      SCClose();
      waitVBlank();
      Scene6();
    }
   
    if(p1e&JOY_D) {
      if(showdebug) {
        //move debug stuff offscreen
        SC234Put(VRAM_POSY_ADDR(200),VRAM_POSY(224,SPR_UNLINK,0));
        SC234Put(VRAM_POSY_ADDR(201),VRAM_POSY(224,SPR_UNLINK,0));
        SC234Put(VRAM_POSY_ADDR(202),VRAM_POSY(224,SPR_UNLINK,0));
        SC234Put(VRAM_POSY_ADDR(203),VRAM_POSY(224,SPR_UNLINK,0));
        SC234Put(VRAM_POSY_ADDR(204),VRAM_POSY(224,SPR_UNLINK,0));
        fixJobPut(0,25,FIX_LINE_WRITE,0,_fixBlankLine);
        fixJobPut(0,26,FIX_LINE_WRITE,0,_fixBlankLine);
        fixJobPut(0,27,FIX_LINE_WRITE,0,_fixBlankLine);
        fixJobPut(0,28,FIX_LINE_WRITE,0,_fixBlankLine);
      }
      showdebug^=1;
    }

    //aSprite debug info
    /*if(showdebug) {
      jobMeterColor(JOB_BLACK);
      if(!(demoSpr.flags&AS_FLAG_STRICT_COORDS)) {
        if(demoSpr.currentFlip&FLIP_X) relX=x-((demoSpr.currentFrame->tileWidth<<4)+demoSpr.currentStep->shiftX)+1;
          else relX=x+demoSpr.currentStep->shiftX;
        if(demoSpr.currentFlip&FLIP_Y) relY=y-((demoSpr.currentFrame->tileHeight<<4)+demoSpr.currentStep->shiftY)+1;
          else relY=y+demoSpr.currentStep->shiftY;
      } else {
        relX=demoSpr.posX;
        relY=demoSpr.posY;
      }
      SC234Put(VRAM_POSX_ADDR(200),VRAM_POSX(x-3));
      SC234Put(VRAM_POSY_ADDR(200),VRAM_POSY(y-3,SPR_UNLINK,1));
      SC234Put(VRAM_POSX_ADDR(201),VRAM_POSX(relX));
      SC234Put(VRAM_POSY_ADDR(201),VRAM_POSY(relY,SPR_UNLINK,1));
      SC234Put(VRAM_POSX_ADDR(202),VRAM_POSX(relX+((demoSpr.currentFrame->tileWidth-1)<<4)));
      SC234Put(VRAM_POSY_ADDR(202),VRAM_POSY(relY,SPR_UNLINK,1));
      SC234Put(VRAM_POSX_ADDR(203),VRAM_POSX(relX));
      SC234Put(VRAM_POSY_ADDR(203),VRAM_POSY(relY+((demoSpr.currentFrame->tileHeight-1)<<4),SPR_UNLINK,1));
      SC234Put(VRAM_POSX_ADDR(204),VRAM_POSX(relX+((demoSpr.currentFrame->tileWidth-1)<<4)));
      SC234Put(VRAM_POSY_ADDR(204),VRAM_POSY(relY+((demoSpr.currentFrame->tileHeight-1)<<4),SPR_UNLINK,1));
     
      //debug live update prints = 1 frame ahead. meh.
      jobMeterColor(JOB_GREY);
      fixPrintf1(3,25,2,3,"Anim data: A:%02d S:%02d R:%02d   ",demoSpr.currentAnim,demoSpr.stepNum,demoSpr.repeats);
      fixPrintf1(3,26,2,3,"Step data: Frame:0x%06x",bmary_spr.anims[demoSpr.currentAnim][demoSpr.stepNum].frame);
      fixPrintf1(14,27,2,3,"SX:%04d SY:%04d D:%02d",
        bmary_spr.anims[demoSpr.currentAnim][demoSpr.stepNum].shiftX,
        bmary_spr.anims[demoSpr.currentAnim][demoSpr.stepNum].shiftY,
        bmary_spr.anims[demoSpr.currentAnim][demoSpr.stepNum].duration
      );
      fixPrintf1(2,28,2,3,"Frame data: W:%02d H:%02d TMAP:0x%06x",
        ((sprFrame*)(bmary_spr.anims[demoSpr.currentAnim][demoSpr.stepNum].frame))->tileWidth,
        ((sprFrame*)(bmary_spr.anims[demoSpr.currentAnim][demoSpr.stepNum].frame))->tileHeight,
        ((sprFrame*)(bmary_spr.anims[demoSpr.currentAnim][demoSpr.stepNum].frame))->maps[demoSpr.currentFlip]
      );
    }*/

   
    //scrollerSetPos(&frontScroll, scrl_x, scrl_y);
    //scrollerSetPosClipped(&frontScroll, x, y, CLIPPING);

    jobMeterColor(JOB_GREEN);
  }
}