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

0001: #include <stdio.h>
0002: #include <stdio.h>
0003: #include <stdlib.h>
0004: #include <input.h>
0005: #include <DATlib.h>
0006: #include "externs.h"
0007: 
0008: #define FRONT_START_X 157
0009: #define FRONT_START_Y 0
0010: #define FRONT_MIN_X 8
0011: #define FRONT_MAX_X 624
0012: #define FRONT_MIN_Y 0
0013: #define FRONT_MAX_Y 0
0014: 
0015: #define BACK_MIN_X 8
0016: #define BACK_MAX_X 149
0017: #define BACK_MIN_Y 5
0018: #define BACK_MAX_Y 8
0019: 
0020: int action=0;
0021: int choice=0;
0022: bool button_available;
0023: bool text_visible;
0024: 
0025: typedef struct bkp_ram_info {
0026:  WORD debug_dips;
0027:  BYTE stuff[254];
0028:  //256 bytes
0029: } bkp_ram_info;
0030: 
0031: bkp_ram_info bkp_data;
0032: 
0033: extern uint _end;
0034: BYTE p1,p2,ps,p1e,p2e;
0035: uint callBackCounter;
0036: 
0037: //fix palettes for text
0038: static const ushort fixPalettes[]= {
0039:  0x8000, 0xefb8, 0x0222, 0x5fa7, 0xde85, 0x2c74, 0x2a52, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
0040:  0x8000, 0xebea, 0x0041, 0xa9d8, 0x57c7, 0xf6b5, 0x43a4, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
0041:  0x8000, 0x014c, 0x9113, 0xb15e, 0x317f, 0x119f, 0x11af, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
0042:  0x8000, 0xeb21, 0x0111, 0xee21, 0x6f31, 0x6f51, 0x6f61, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
0043:  0x8000, 0xed31, 0xc311, 0xee51, 0x4f81, 0x4fa1, 0x4fc1, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
0044:  0x8000, 0xbad3, 0x0111, 0x09c0, 0xe7b0, 0xc580, 0xe250, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
0045:  0x8000, 0xefb8, 0x0111, 0xde96, 0x3c75, 0x2950, 0x4720, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
0046:  0x8000, 0x8444, 0x0111, 0xf555, 0xf666, 0x7777, 0x8888, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000 };
0047:  
0048: #define CLIPPING 5
0049: 
0050: void scrollerInitClipped(scroller *s, scrollerInfo *si, ushort baseSprite, ushort basePalette, short posX, short posY, ushort clipping) {
0051:  ushort i,addr,pos;
0052: 
0053:  scrollerInit(s,si,baseSprite,basePalette,posX,posY);
0054:  addr=VRAM_POSY_ADDR(baseSprite);
0055:  //pos=((YSHIFT-(0-posY))<<7)|(clipping&0x3f);
0056:  pos=VRAM_POSY(-posY,SPR_UNLINK,clipping);
0057:  for(i=0;i<21;i++)
0058:   SC234Put(addr++,pos);
0059: }
0060: 
0061: void scrollerSetPosClipped(scroller *s, short toX, short toY, ushort clipping) {
0062:  ushort i,addr,pos;
0063: 
0064:  if(s->scrlPosY!=toY) { //Y moved ?
0065:   scrollerSetPos(s,toX,toY);
0066:  
0067:   addr=VRAM_POSY_ADDR(s->baseSprite);
0068:   //pos=((YSHIFT-(0-toY))<<7)|(clipping&0x3f);
0069:   pos=VRAM_POSY(-toY,SPR_UNLINK,clipping);
0070:   for(i=0;i<21;i++)
0071:    SC234Put(addr++,pos);
0072:   //s->scrlPosY=toY;
0073:  } else scrollerSetPos(s,toX,toY);
0074: }
0075: 
0076: void sortSprites(aSprite *list[], int count) {
0077:  //insertion sort
0078:  int x,y;
0079:  aSprite *tmp;
0080:  
0081:  for(x=1;x<count;x++) {
0082:   y=x;
0083:   while(y>0 && (list[y]->posY < list[y-1]->posY)) {
0084:    tmp=list[y];
0085:    list[y]=list[y-1];
0086:    list[y-1]=tmp;
0087:    y--;
0088:   }
0089:  }
0090: }
0091: 
0092: #define POOL_MODE
0093: #define LOTS
0094: 
0095: const char sinTable[]={ 32,34,35,37,38,40,41,43,44,46,47,48,50,51,52,53,
0096:       55,56,57,58,59,59,60,61,62,62,63,63,63,64,64,64,
0097:       64,64,64,64,63,63,63,62,62,61,60,59,59,58,57,56,
0098:       55,53,52,51,50,48,47,46,44,43,41,40,38,37,35,34,
0099:       32,30,29,27,26,24,23,21,20,18,17,16,14,13,12,11,
0100:       9,8,7,6,5,5,4,3,2,2,1,1,1,0,0,0,
0101:       0,0,0,0,1,1,1,2,2,3,4,5,5,6,7,8,
0102:       9,11,12,13,14,16,17,18,20,21,23,24,26,27,29,30};
0103: 
0104: #define SCROLLSPEED 1.06
0105: void rasterScrollDemo() {
0106:  BYTE p1,ps;
0107:  pictureInfo frontLayerInfo, backLayerInfo;
0108:  picture frontLayer, backLayer;
0109:  short posY=-192;
0110:  ushort rasterData0[256],rasterData1[256];
0111:  ushort *rasterData;
0112:  float scrollAcc;
0113:  int scrollPos[34];
0114:  int scrollValues[34];
0115:  ushort backAddr=0x8401;
0116:  ushort frontAddr=0x8421;
0117:  int x,y;
0118:  short frontPosX[13],backPosX[13];
0119:  ushort skipY;
0120:  ushort firstLine;
0121:  ushort zeroval;
0122: 
0123:  //layers were merged to save up tiles/palettes
0124:  frontLayerInfo.stripSize=tf4layers.stripSize;
0125:  backLayerInfo.stripSize=tf4layers.stripSize;
0126:  frontLayerInfo.tileWidth=32;
0127:  backLayerInfo.tileWidth=32;
0128:  frontLayerInfo.tileHeight=tf4layers.tileHeight;
0129:  backLayerInfo.tileHeight=tf4layers.tileHeight;
0130:  //only using first map
0131:  frontLayerInfo.maps[0]=tf4layers.maps[0];
0132:  backLayerInfo.maps[0]=tf4layers.maps[0]+(tf4layers.stripSize*(32/2)); //bytesize but ushort* declaration, so /2
0133: 
0134: 
0135:  clearFixLayer();
0136:  initGfx();
0137:  jobMeterSetup(true);
0138:  loadTIirq(TI_MODE_DUAL_DATA);
0139:  TInextTable=0;
0140: 
0141:  scrollValues[0]=1024;
0142:  scrollPos[0]=0;
0143:  scrollAcc=1024;
0144:  for(x=1;x<34;x++) {
0145:   scrollAcc*=SCROLLSPEED;
0146:   scrollValues[x]=(int)(scrollAcc+0.5);
0147:   scrollPos[x]=0;
0148:  }
0149: 
0150:  pictureInit(&backLayer, &backLayerInfo,1,16,0,0,FLIP_NONE);
0151:  pictureInit(&frontLayer, &frontLayerInfo,33,16,0,0,FLIP_NONE);
0152:  palJobPut(16,tf4layers.palInfo->count,tf4layers.palInfo->data);
0153: 
0154:  backgroundColor(0x38db);
0155:  fixPrint(0,1,0,0,"                                       ");
0156:  fixPrint(0,30,0,0,"                                       ");
0157:  
0158:  fixPrint(2,3,4,3,"1P \x12\x13: Scroll Up/Down");
0159:  fixPrint(2,4,4,3,"1P A+\x12\x13: Adjust timer (line)");
0160:  fixPrint(2,5,4,3,"1P A+\x10\x11: Adjust timer (unit)");
0161:  
0162:  zeroval=TI_ZERO;
0163: 
0164:  while(1) {
0165:   SCClose();
0166:   waitVBlank();
0167: 
0168:   while((volMEMWORD(0x3c0006)>>7)!=0x120); //line 16
0169:   jobMeterColor(JOB_BLUE);
0170:  
0171:   p1=volMEMBYTE(P1_CURRENT);
0172:   p1e=volMEMBYTE(P1_EDGE);
0173:   ps=volMEMBYTE(PS_CURRENT);
0174: 
0175:   if(ps&P1_START) {
0176:    clearSprites(1, 64);
0177:    TInextTable=0;
0178:    SCClose();
0179:    waitVBlank();
0180:    unloadTIirq();
0181:    return;
0182:   }
0183: 
0184:   fixPrintf2(2,7,5,3,"TIbase: %d (0x%04x)   ",zeroval,zeroval);
0185:  
0186:   if(p1&JOY_A) {
0187:    if(p1e&JOY_UP)  zeroval-=384;
0188:    if(p1e&JOY_DOWN) zeroval+=384;
0189:    if(p1&JOY_RIGHT) zeroval++;
0190:    if(p1&JOY_LEFT)  zeroval--;
0191:   } else {
0192:    if(p1&JOY_UP) if(posY<0) posY++;
0193:    if(p1&JOY_DOWN) if(posY>-288) posY--;
0194:   }
0195: 
0196:   //update scroll values
0197:   for(x=0;x<34;x++) scrollPos[x]+=scrollValues[x];
0198:   frontPosX[0]=        (short)(0-(scrollPos[32]>>3));
0199:   frontPosX[1]=frontPosX[2]=     (short)(0-(scrollPos[24]>>3));
0200:   frontPosX[3]=frontPosX[4]=     (short)(0-(scrollPos[16]>>3));
0201:   frontPosX[5]=        (short)(0-(scrollPos[8]>>3));
0202:   frontPosX[6]=frontPosX[7]=frontPosX[8]=  (short)(0-(scrollPos[0]>>3));
0203:   frontPosX[9]=frontPosX[10]=frontPosX[11]= (short)(0-(scrollPos[1]>>3));
0204:   frontPosX[12]=        (short)(0-(scrollPos[32]>>3));
0205: 
0206:   backPosX[0]=        (short)(0-(scrollPos[24]>>3));
0207:   backPosX[1]=backPosX[2]=     (short)(0-(scrollPos[16]>>3));
0208:   backPosX[3]=backPosX[4]=     (short)(0-(scrollPos[8]>>3));
0209:   backPosX[5]=        (short)(0-(scrollPos[0]>>3));
0210:   backPosX[6]=backPosX[7]=backPosX[8]=  (short)(0-(scrollPos[0]>>4));
0211:   backPosX[9]=backPosX[10]=backPosX[11]=  (short)(0-(scrollPos[0]>>3));
0212:   backPosX[12]=        (short)(0-(scrollPos[1]>>3));
0213: 
0214:   skipY=0-posY;
0215:   x=skipY>>5;
0216:   firstLine=32-(skipY&0x1f);
0217: 
0218:   //TIbase=TI_ZERO+(384*firstLine); //timing to first raster line
0219:   TIbase=zeroval+(384*firstLine); //timing to first raster line
0220:   TInextTable=(TInextTable==rasterData0)?rasterData1:rasterData0;
0221:   rasterData=TInextTable;
0222: 
0223:   pictureSetPos(&frontLayer,frontPosX[x]>>7,posY);
0224:   pictureSetPos(&backLayer,backPosX[x]>>7,posY);
0225:   //might need to force the update if base scroll position didn't change
0226:   SC234Put(frontAddr,frontPosX[x]);
0227:   SC234Put(backAddr,backPosX[x]);
0228: 
0229:   if(skipY<164) { //can we see water?
0230:    TIreload=384*32; //nope, 32px chunks
0231:    for(x++;x<13;x++) {
0232:     *rasterData++=frontAddr;
0233:     *rasterData++=frontPosX[x];
0234:     *rasterData++=backAddr;
0235:     *rasterData++=backPosX[x];
0236:     firstLine+=32;
0237:     if(firstLine>=224) break;
0238:    }
0239:   } else {
0240:    TIreload=384*4;  //yup, 4px chunks
0241:    for(x++;x<12;x++) {
0242:     for(y=0;y<8;y++) {
0243:      *rasterData++=frontAddr;
0244:      *rasterData++=frontPosX[x];
0245:      *rasterData++=backAddr;
0246:      *rasterData++=backPosX[x];
0247:     }
0248:     firstLine+=32;
0249:    }
0250:    x=1;
0251:    while(firstLine<224) {
0252:     *rasterData++=frontAddr;
0253:     *rasterData++=frontPosX[12];
0254:     *rasterData++=backAddr;
0255:     *rasterData++=0-(scrollPos[x++]>>3);
0256:     firstLine+=4;
0257:    }
0258:   }
0259:   *rasterData++=0x0000;
0260:   *rasterData++=0x0000;
0261:   jobMeterColor(JOB_GREEN);
0262:   SCClose();
0263:  }
0264: }
0265: 
0266: void tempTests() {
0267:  int x=0;
0268:  int y=0;
0269:  int c;
0270:  uint *ptr;
0271:  scroller scroll;
0272: 
0273:  backgroundColor(0x7bbb);
0274:  clearFixLayer();
0275:  initGfx();
0276:  jobMeterSetup(true);
0277: 
0278:  scrollerInit(&scroll, &wohd, 1, 16, x, y);
0279:  palJobPut(16, wohd.palInfo->count, wohd.palInfo->data);
0280:  
0281:  //fixPrintf1(2,3,4,3,"0x%06x",&scroll);
0282:  //dbg init
0283:  scroll.config[23+4]=scroll.config[23+5]=scroll.config[23+6]=scroll.config[23+7]=scroll.config[23+8]=0;
0284: 
0285:  while(1) {
0286:   SCClose();
0287:   waitVBlank();
0288: 
0289:   p1=volMEMBYTE(P1_CURRENT);
0290:   p1e=volMEMBYTE(P1_EDGE);
0291:   ps=volMEMBYTE(PS_CURRENT);
0292:  
0293:   if((ps&P1_START)&&(ps&P2_START)) {
0294:    clearSprites(1, 21);
0295:    SCClose();
0296:    waitVBlank();
0297:    return;
0298:   }
0299: 
0300:   if(p1&JOY_UP)  y--;
0301:   if(p1&JOY_DOWN)  y++;
0302:   if(p1&JOY_LEFT)  x--;
0303:   if(p1&JOY_RIGHT) x++;
0304: 
0305:   while((volMEMWORD(0x3c0006)>>7)!=0x120); //wait raster line 16
0306:   jobMeterColor(JOB_BLUE);
0307: 
0308:   if(p1e&JOY_D)
0309:    scrollerInit(&scroll, &wohd, 1, 16, x, y);
0310: 
0311:   if(p1&JOY_A) scrollerSetPos(&scroll, x, y);
0312: 
0313:   jobMeterColor(JOB_GREEN);
0314:   fixPrintf2(2,4,4,3,"%04d\xff%04d\xff\xff",x,y);
0315: 
0316:   fixPrintf2(2,6,2,3,"TileIndex:  %04d ",scroll.config[23+2]);
0317:   fixPrintf2(2,7,2,3,"DataIndex:  %04d ",scroll.config[23+1]);
0318:   fixPrintf2(2,8,2,3,"DataLength: %04d ",scroll.config[23+3]);
0319:   fixPrintf2(2,9,2,3,"DataIndex2: %04d ",scroll.config[23+0]);
0320: 
0321:   fixPrintf2(2,11,2,3,"TileIndex:  %04d ",scroll.config[23+4]);
0322:   fixPrintf2(2,12,2,3,"DataIndex:  %04d ",scroll.config[23+5]);
0323:   fixPrintf2(2,13,2,3,"DataLength: %04d ",scroll.config[23+6]);
0324:   fixPrintf2(2,14,2,3,"DataIndex2: %04d ",scroll.config[23+7]);
0325:   fixPrintf2(2,15,2,3,"DataLength2:%04d ",scroll.config[23+8]);
0326:   fixPrintf2(2,16,2,3,"RefillSize: %04d ",scroll.config[23+6]+scroll.config[23+8]);
0327: 
0328:   c=0;
0329:   ptr=SC1;
0330:   while(ptr!=SC1ptr) {
0331:    c+=(*ptr++)&0x3fc0000;
0332:    ptr++;
0333:   }
0334:   c>>=18;
0335:   fixPrintf1(2,18,2,3,"Jobs: %04d/%04d",(SC234ptr-SC234)>>1,c);
0336:  }
0337: }
0338: 
0339: //misc fix maps
0340: static const ushort fadeData0[15]={0x03f0,0x03f0,0x03f0,0x03f0,0x03f0,0x03f0,0x03f0,0x03f0,0x03f0,0x03f0,0x03f0,0x03f0,0x03f0,0x03f0,0x0000};
0341: static const ushort fadeData1[15]={0x03f1,0x03f1,0x03f1,0x03f1,0x03f1,0x03f1,0x03f1,0x03f1,0x03f1,0x03f1,0x03f1,0x03f1,0x03f1,0x03f1,0x0000};
0342: static const ushort fadeData2[15]={0x03f2,0x03f2,0x03f2,0x03f2,0x03f2,0x03f2,0x03f2,0x03f2,0x03f2,0x03f2,0x03f2,0x03f2,0x03f2,0x03f2,0x0000};
0343: static const ushort fadeData3[15]={0x03f3,0x03f3,0x03f3,0x03f3,0x03f3,0x03f3,0x03f3,0x03f3,0x03f3,0x03f3,0x03f3,0x03f3,0x03f3,0x03f3,0x0000};
0344: static const ushort fadeData4[15]={0x03f4,0x03f4,0x03f4,0x03f4,0x03f4,0x03f4,0x03f4,0x03f4,0x03f4,0x03f4,0x03f4,0x03f4,0x03f4,0x03f4,0x0000};
0345: static const ushort fadeData5[15]={0x03f5,0x03f5,0x03f5,0x03f5,0x03f5,0x03f5,0x03f5,0x03f5,0x03f5,0x03f5,0x03f5,0x03f5,0x03f5,0x03f5,0x0000};
0346: static const ushort fadeData6[15]={0x03f6,0x03f6,0x03f6,0x03f6,0x03f6,0x03f6,0x03f6,0x03f6,0x03f6,0x03f6,0x03f6,0x03f6,0x03f6,0x03f6,0x0000};
0347: static const ushort fadeData7[15]={0x03f7,0x03f7,0x03f7,0x03f7,0x03f7,0x03f7,0x03f7,0x03f7,0x03f7,0x03f7,0x03f7,0x03f7,0x03f7,0x03f7,0x0000};
0348: static const ushort fadeData8[15]={0x03f8,0x03f8,0x03f8,0x03f8,0x03f8,0x03f8,0x03f8,0x03f8,0x03f8,0x03f8,0x03f8,0x03f8,0x03f8,0x03f8,0x0000};
0349: static const ushort fadeData9[15]={0x03f9,0x03f9,0x03f9,0x03f9,0x03f9,0x03f9,0x03f9,0x03f9,0x03f9,0x03f9,0x03f9,0x03f9,0x03f9,0x03f9,0x0000};
0350: static const ushort fadeDataA[15]={0x03fa,0x03fa,0x03fa,0x03fa,0x03fa,0x03fa,0x03fa,0x03fa,0x03fa,0x03fa,0x03fa,0x03fa,0x03fa,0x03fa,0x0000};
0351: 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};
0352: static const ushort logo_95[78]={ 0x0500,0x0501,0x0502,0x0503,0x0504,0x0505,0x0506,0x0507,0x0508,0x0509,0x050a,0x050b,0x0000,
0353:          0x0510,0x0511,0x0512,0x0513,0x0514,0x0515,0x0516,0x0517,0x0518,0x0519,0x051a,0x051b,0x0000,
0354:          0x0520,0x0521,0x0522,0x0523,0x0524,0x0525,0x0526,0x0527,0x0528,0x0529,0x052a,0x052b,0x0000,
0355:          0x0530,0x0531,0x0532,0x0533,0x0534,0x0535,0x0536,0x0537,0x0538,0x0539,0x053a,0x053b,0x0000,
0356:          0x0540,0x0541,0x0542,0x0543,0x0544,0x0545,0x0546,0x0547,0x0548,0x0549,0x054a,0x054b,0x0000,
0357:          0x0550,0x0551,0x0552,0x0553,0x0554,0x0555,0x0556,0x0557,0x0558,0x0559,0x055a,0x055b,0x0000 };
0358: static const ushort logo_96[78]={ 0x0560,0x0561,0x0562,0x0563,0x0564,0x0565,0x0566,0x0567,0x0568,0x0569,0x056a,0x056b,0x0000,
0359:          0x0570,0x0571,0x0572,0x0573,0x0574,0x0575,0x0576,0x0577,0x0578,0x0579,0x057a,0x057b,0x0000,
0360:          0x0580,0x0581,0x0582,0x0583,0x0584,0x0585,0x0586,0x0587,0x0588,0x0589,0x058a,0x058b,0x0000,
0361:          0x0590,0x0591,0x0592,0x0593,0x0594,0x0595,0x0596,0x0597,0x0598,0x0599,0x059a,0x059b,0x0000,
0362:          0x05a0,0x05a1,0x05a2,0x05a3,0x05a4,0x05a5,0x05a6,0x05a7,0x05a8,0x05a9,0x05aa,0x05ab,0x0000,
0363:          0x05b0,0x05b1,0x05b2,0x05b3,0x05b4,0x05b5,0x05b6,0x05b7,0x05b8,0x05b9,0x05ba,0x05bb,0x0000 };
0364: static const ushort logo_97[78]={ 0x0600,0x0601,0x0602,0x0603,0x0604,0x0605,0x0606,0x0607,0x0608,0x0609,0x060a,0x060b,0x0000,
0365:          0x0610,0x0611,0x0612,0x0613,0x0614,0x0615,0x0616,0x0617,0x0618,0x0619,0x061a,0x061b,0x0000,
0366:          0x0620,0x0621,0x0622,0x0623,0x0624,0x0625,0x0626,0x0627,0x0628,0x0629,0x062a,0x062b,0x0000,
0367:          0x0630,0x0631,0x0632,0x0633,0x0634,0x0635,0x0636,0x0637,0x0638,0x0639,0x063a,0x063b,0x0000,
0368:          0x0640,0x0641,0x0642,0x0643,0x0644,0x0645,0x0646,0x0647,0x0648,0x0649,0x064a,0x064b,0x0000,
0369:          0x0650,0x0651,0x0652,0x0653,0x0654,0x0655,0x0656,0x0657,0x0658,0x0659,0x065a,0x065b,0x0000 };
0370: static const ushort logo_98[78]={ 0x0660,0x0661,0x0662,0x0663,0x0664,0x0665,0x0666,0x0667,0x0668,0x0669,0x066a,0x066b,0x0000,
0371:          0x0670,0x0671,0x0672,0x0673,0x0674,0x0675,0x0676,0x0677,0x0678,0x0679,0x067a,0x067b,0x0000,
0372:          0x0680,0x0681,0x0682,0x0683,0x0684,0x0685,0x0686,0x0687,0x0688,0x0689,0x068a,0x068b,0x0000,
0373:          0x0690,0x0691,0x0692,0x0693,0x0694,0x0695,0x0696,0x0697,0x0698,0x0699,0x069a,0x069b,0x0000,
0374:          0x06a0,0x06a1,0x06a2,0x06a3,0x06a4,0x06a5,0x06a6,0x06a7,0x06a8,0x06a9,0x06aa,0x06ab,0x0000,
0375:          0x06b0,0x06b1,0x06b2,0x06b3,0x06b4,0x06b5,0x06b6,0x06b7,0x06b8,0x06b9,0x06ba,0x06bb,0x0000 };
0376: 
0377: //#define TIME 120
0378: 
0379: void Control_Sub()
0380: {
0381:  p1=volMEMBYTE(P1_CURRENT);
0382:  ps=volMEMBYTE(PS_CURRENT);
0383:  p1e=volMEMBYTE(P1_EDGE);
0384:  
0385:  if(button_available==true)
0386:  {
0387:   if((p1e&JOY_A)||(p1e&JOY_B)||(p1e&JOY_C))
0388:   {
0389:    clearFixLayer();
0390:    action++;
0391:   }
0392:  }
0393: }
0394: 
0395: /*void Position_Cursor_2_1()
0396: {
0397:  
0398: }*/
0399: 
0400: void interval(TIME)
0401: {
0402:  BYTE textTimer=0;
0403:  button_available=false;
0404:  text_visible=false;
0405:  
0406:  while(1)
0407:  {
0408:   waitVBlank();
0409:  
0410:   if(++textTimer==TIME)
0411:   {
0412:    textTimer=0;
0413:    button_available=true;
0414:    text_visible=true;
0415:   }
0416:  }
0417: }
0418: 
0419: void introducion() {
0420:  scroller sc;
0421:  short posX=0;
0422:  short posY=0;
0423:  ushort *data;
0424:  ushort flipMode=0;
0425:  //BYTE textTimer=0;
0426:  button_available=true;
0427:  
0428:  clearFixLayer();
0429:  scrollerInit(&sc,&streamScroll,1,16,0,0);
0430:  palJobPut(16, streamScroll.palInfo->count, streamScroll.palInfo->data);
0431: 
0432:  while(1) {
0433:   SCClose();
0434:   waitVBlank();
0435:   Control_Sub();
0436:  
0437:   /*if(++textTimer==TIME)
0438:   {
0439:    textTimer=0;
0440:    fixPrintf1(1,26,3,3,"                 ");
0441:   }*/
0442:  
0443:   /*if(ps&P1_START) {
0444:    clearSprites(1,21);
0445:    SCClose();
0446:    waitVBlank();
0447:    return;
0448:   }*/
0449:    
0450:   if(action==0)
0451:   {
0452:    fixPrint(1,3,0,1,"��� ���������� ������� ���� ���.");
0453:    fixPrint(1,4,0,1,"������ ���� ���� � �� ��.");
0454:    fixPrint(1,5,0,1,"��, ��� � ���! ��-���������� ��������");
0455:    fixPrint(1,6,0,1,"���� ����������, ����� � ����������.");
0456:   }
0457:  
0458:   if(action==1)
0459:   {
0460:    clearSprites(1,21);
0461:    scrollerInit(&sc,&BG_SS_ExtCampEntranceSunset,1,16,0,0);
0462:    palJobPut(16, BG_SS_ExtCampEntranceSunset.palInfo->count, BG_SS_ExtCampEntranceSunset.palInfo->data);
0463:    
0464:    fixPrint(1,3,0,1,"� ��� ��������� ���� � ���� ��������");
0465:    fixPrint(1,4,0,1,"������, ���� �����������.");
0466:    fixPrint(1,5,0,1,"����� ������ � �������������� ����.");
0467:    fixPrint(1,6,0,1,"���������� ��������... � ��������");
0468:    fixPrint(1,7,0,1,"���������.");
0469:    fixPrint(1,8,0,1,"��� ��� ��-������ ��� ����, ��� ��-");
0470:    fixPrint(1,9,0,1,"������� - ��� ����� ���-�� ��������");
0471:    fixPrint(1,10,0,1,"��� ��� ���������. � ������� ����");
0472:    fixPrint(1,11,0,1,"�������������: ��� ���� �������!");
0473:    fixPrint(1,12,0,1,"�� ��� �����, ��� ������� �����");
0474:    fixPrint(1,13,0,1,"���������� ����, � ����� ��� � �������");
0475:    fixPrint(1,14,0,1,"�������! ��������, � ���� ������� ���");
0476:    fixPrint(1,15,0,1,"������ � ���������� ��� ��� ������,");
0477:    fixPrint(1,16,0,1,"����� � ���������� � ��� �� ������.");
0478:   }
0479:  
0480:   if(action==2)
0481:   {
0482:    clearSprites(1,21);
0483:    scrollerInit(&sc,&BG_ExtSquareSunset,1,16,0,0);
0484:    palJobPut(16, BG_ExtSquareSunset.palInfo->count, BG_ExtSquareSunset.palInfo->data);
0485:    
0486:    fixPrint(1,3,0,1,"��������, �� ��� ��� �������, ��");
0487:    fixPrint(1,4,0,1,"��������� �� ��� �������������");
0488:    fixPrint(1,5,0,1,"����������. � ��� �� �? ���� � � ����");
0489:    fixPrint(1,6,0,1,"��������?");
0490:    fixPrint(1,7,0,1,"���-�� �������, ��� ����. � ���� ���");
0491:    fixPrint(1,8,0,1,"���������� ���� ����������? � �� �� ��");
0492:    fixPrint(1,9,0,1,"�����, ��� �� ��� ������ �� ����. � �");
0493:    fixPrint(1,10,0,1,"�� ����� ���-�� ���������, ������ ���");
0494:    fixPrint(1,11,0,1,"������ ��� ����� ������.");
0495:    fixPrint(1,12,0,1,"�������, ��� � ����� �� �����������,");
0496:    fixPrint(1,13,0,1,"�� ���� ���-���� ���������� �������� �");
0497:    fixPrint(1,14,0,1,"������... ��� �������, ����");
0498:    fixPrint(1,15,0,1,"������������.");
0499:    fixPrint(1,16,0,1,"���� ��� ��� ����� �������������");
0500:    fixPrint(1,17,0,1,"������, ������ ������� ����������, ���");
0501:    fixPrint(1,18,0,1,"������������ �������� ��� ����� ��");
0502:    fixPrint(1,19,0,1,"������. ��� ���������� ���� �����.");
0503:    fixPrint(1,20,0,1,"��� ��� �� ����� �����? �� �� �����,");
0504:    fixPrint(1,21,0,1,"��������� ������� � ���, ��� ���-��");
0505:    fixPrint(1,22,0,1,"�������? �������, � �� ������ �����");
0506:    fixPrint(1,23,0,1,"�����. � �� ������ ����� ������, �");
0507:    fixPrint(1,24,0,1,"��������... ��� ���� �����");
0508:    fixPrint(1,25,0,1,"�����������. ��� ��� ��������?");
0509:   }
0510:  
0511:   if(action==3)
0512:   {
0513:    clearSprites(1,21);
0514:    scrollerInit(&sc,&BG_ExtDiningHallAwaySunset,1,16,0,0);
0515:    palJobPut(16, BG_ExtDiningHallAwaySunset.palInfo->count, BG_ExtDiningHallAwaySunset.palInfo->data);
0516:    
0517:    fixPrint(1,3,0,1,"�� ���. ������ ��������� � ���� ���� �");
0518:    fixPrint(1,4,0,1,"�������. ����� �� ������ ������ ���.");
0519:    fixPrint(1,5,0,1,"��� ��� �������, � ��� ������ ��� ����");
0520:    fixPrint(1,6,0,1,"��������, ��� ������ � ����������.");
0521:    fixPrint(1,7,0,1,"� ���� ���������. � ��� ����� ������ �");
0522:    fixPrint(1,8,0,1,"�����, ��� ����� ���� ��� ������. ���");
0523:    fixPrint(1,9,0,1,"� �����!");
0524:   }
0525:  
0526:   if(action==4)
0527:   {
0528:    clearSprites(1,21);
0529:    SCClose();
0530:    waitVBlank();
0531:    action=0;
0532:    Day1();
0533:   }
0534:  
0535:   scrollerSetPos(&sc,posX,posY);
0536:  }
0537: }
0538: 
0539: void Day1() {
0540:  scroller sc;
0541:  picture testPict;
0542:  short posX=0;
0543:  short posY=0;
0544:  ushort *data;
0545:  ushort flipMode=0;
0546:  //BYTE textTimer=0;
0547:  button_available=true;
0548:  
0549:  clearFixLayer();
0550:  scrollerInit(&sc,&BG_ExtHouseOfMTSunset,1,16,0,0);
0551:  palJobPut(16, BG_ExtHouseOfMTSunset.palInfo->count, BG_ExtHouseOfMTSunset.palInfo->data);
0552: 
0553:  while(1) {
0554:   SCClose();
0555:   waitVBlank();
0556:   Control_Sub();
0557:  
0558: ////////////Control////////////
0559: //Select Options Action=2
0560:   if(action==14)
0561:   {
0562:    if(p1e&JOY_UP)
0563:    {
0564:     if(choice>=1) choice--;
0565:    }
0566:    if(p1e&JOY_DOWN)
0567:    {
0568:     if(choice<2) choice++;
0569:    }
0570:   }
0571: ////////////Control////////////
0572:  
0573:   /*if(++textTimer==TIME)
0574:   {
0575:    textTimer=0;
0576:    fixPrintf1(1,26,3,3,"                 ");
0577:   }*/
0578:  
0579:   /*if(ps&P1_START) {
0580:    clearSprites(1,21);
0581:    SCClose();
0582:    waitVBlank();
0583:    return;
0584:   }*/
0585:    
0586:   if(action==0)
0587:   {
0588:    fixPrint(1,27,0,1,"����� ���������� ����... �����");
0589:    fixPrint(1,28,0,1,"�������� ��� � ������.");
0590:   }
0591:   if(action==1)
0592:   {
0593:    clearSprites(1,21);
0594:    scrollerInit(&sc,&BG_IntHouseOfMTDay,1,16,0,0);
0595:    palJobPut(16, BG_IntHouseOfMTDay.palInfo->count, BG_IntHouseOfMTDay.palInfo->data);
0596:    
0597:    fixPrint(1,26,0,1,"��������� ��������� ���� �� ��� ���� �");
0598:    fixPrint(1,27,0,1,"��� �������� ������� �����");
0599:    fixPrint(1,28,0,1,"�����������. � ���������� �������.");
0600:   }
0601:   if(action==2)
0602:   {
0603:    fixPrint(1,25,0,1,"���� � ���� � ������� ����������,");
0604:    fixPrint(1,26,0,1,"�������. ������� ����� ��� �� ����");
0605:    fixPrint(1,27,0,1,"����� �� ������... �� ����� ���� �");
0606:    fixPrint(1,28,0,1,"���?");
0607:   }
0608:   if(action==3)
0609:   {
0610:    fixPrint(1,27,0,1,"���� ��� ������ �� ��������. �� � ����");
0611:    fixPrint(1,28,0,1,"��������� ��������...");
0612:   }
0613:   if(action==4)
0614:   {
0615:    clearSprites(1,21);
0616:    scrollerInit(&sc,&CGD2_Mirror,1,16,0,0);
0617:    palJobPut(16, CGD2_Mirror.palInfo->count, CGD2_Mirror.palInfo->data);
0618:    
0619:    fixPrint(1,27,0,1,"����� �� �������� � �����! �� ��, ���");
0620:    fixPrint(1,28,0,1,"���-��� ����������... �� �� ����!");
0621:   }
0622:   if(action==5)
0623:   {
0624:    clearSprites(1,21);
0625:    scrollerInit(&sc,&BG_IntHouseOfMTDay,1,16,0,0);
0626:    palJobPut(16, BG_IntHouseOfMTDay.palInfo->count, BG_IntHouseOfMTDay.palInfo->data);
0627:    
0628:    fixPrint(1,26,0,1,"������, ����� ����� �����. ���� ������");
0629:    fixPrint(1,27,0,1,"��� ����� ���������� �� ������ ���");
0630:    fixPrint(1,28,0,1,"����� �����-������ �������.");
0631:   }
0632:   if(action==6)
0633:   {
0634:    fixPrint(1,27,0,1,"������� ��� ������ ��� ������");
0635:    fixPrint(1,28,0,1,"��������. ��� ����� ���� �� � �����.");
0636:   }
0637:   if(action==7)
0638:   {
0639:    fixPrint(1,25,0,1,"� �� ���� �������� �������,");
0640:    fixPrint(1,26,0,1,"����������� ������. ��������� ������,");
0641:    fixPrint(1,27,0,1,"������� - ����� ������ ��� ���");
0642:    fixPrint(1,28,0,1,"����������.");
0643:   }
0644:   if(action==8)
0645:   {
0646:    fixPrint(1,27,0,1,"��� �� ��� ������ � �������, ��");
0647:    fixPrint(1,28,0,1,"��������� �� �� �����.");
0648:   }
0649:   if(action==9)
0650:   {
0651:    clearSprites(1,21);
0652:    scrollerInit(&sc,&BG_ExtHouseOfMTSunset,1,16,0,0);
0653:    palJobPut(16, BG_ExtHouseOfMTSunset.palInfo->count, BG_ExtHouseOfMTSunset.palInfo->data);
0654:    pictureInit(&testPict, &MTSmilePanamaPioneer,22, 16 + BG_ExtHouseOfMTSunset.palInfo->count, 104, 0,FLIP_NONE);
0655:    palJobPut(16 + BG_ExtHouseOfMTSunset.palInfo->count, MTSmilePanamaPioneer.palInfo->count, MTSmilePanamaPioneer.palInfo->data);
0656:    
0657:    fixPrint(1,28,0,1,"������ ���������.");
0658:   }
0659:   if(action==10)
0660:   {
0661:    fixPrint(1,26,0,1,"����� ����������:");
0662:    fixPrint(1,28,1,1,"�����, ��� ���������?");
0663:   }
0664:   if(action==11)
0665:   {
0666:    fixPrint(1,26,0,1,"�����:");
0667:    fixPrint(1,28,0,1,"��...");
0668:   }
0669:   if(action==12)
0670:   {
0671:    fixPrint(1,25,0,1,"����� ����������:");
0672:    fixPrint(1,27,1,1,"������, � �� �������� �� ������");
0673:    fixPrint(1,28,1,1,"����������?");
0674:   }
0675:   if(action==13)
0676:   {
0677:    fixPrint(1,24,0,1,"�� �� ��� \"��������\". �� ������� �");
0678:    fixPrint(1,25,0,1,"����! ���� �������� �������� ��.");
0679:    fixPrint(1,26,0,1,"����� ���������� � �����, ��������.");
0680:    fixPrint(1,27,0,1,"��������� ������������ ���� �� ��");
0681:    fixPrint(1,28,0,1,"�����.");
0682:   }
0683:   if(action==14)
0684:   {
0685:    fixPrint(3,25,choice==0?2:4,1,"������-�� ����.");
0686:    fixPrint(3,27,choice==1?2:4,1,"�����-�����.");
0687:    fixPrint(3,28,choice==2?2:4,1,"�� ����.");
0688:   }
0689:   if(action==19)
0690:   {
0691:    fixPrint(1,23,0,1,"����� ����������:");
0692:    fixPrint(1,25,1,1,"��� � �������! �� ��� ���������.");
0693:    fixPrint(1,26,1,1,"� ��� � ������ ���������... ��");
0694:    fixPrint(1,27,1,1,"��������!");
0695:    fixPrint(1,28,1,1,"�������! ����!");
0696:   }
0697:   if(action==20)
0698:   {
0699:    fixPrint(1,27,0,1,"��� ������ �������... �� ��� ��� ���,");
0700:    fixPrint(1,28,0,1,"�����-������ ������������? ������?");
0701:   }
0702:   if(action==21)
0703:   {
0704:    fixPrint(1,26,0,1,"� ����� ������ ���������� ����");
0705:    fixPrint(1,27,0,1,"�������?");
0706:    fixPrint(1,28,0,1,"� �����, ��� �������� ��������?");
0707:   }
0708:   if(action==22)
0709:   {
0710:    fixPrint(1,25,0,1,"���� ���, �� �������� ���� ��");
0711:    fixPrint(1,26,0,1,"�������������� - ������� �����");
0712:    fixPrint(1,27,0,1,"�������� �� ��������. ����� ����������");
0713:    fixPrint(1,28,0,1,"���������.");
0714:   }
0715:   if(action==23)
0716:   {
0717:    fixPrint(1,26,0,1,"�����:");
0718:    fixPrint(1,28,0,1,"���! �� ������?");
0719:   }
0720:   if(action==24)
0721:   {
0722:    clearSprites(22,7);
0723:    pictureInit(&testPict, &MTLaughPanamaPioneer,22, 16 + BG_ExtHouseOfMTSunset.palInfo->count, 104, 0,FLIP_NONE);
0724:    palJobPut(16 + BG_ExtHouseOfMTSunset.palInfo->count, MTLaughPanamaPioneer.palInfo->count, MTLaughPanamaPioneer.palInfo->data);
0725:    
0726:    fixPrint(1,25,0,1,"����� ����������:");
0727:    fixPrint(1,27,1,1,"��������� - ���! ����������� �������!");
0728:    fixPrint(1,28,1,1,"� �� ������ � ������ �������!");
0729:   }
0730:   if(action==25)
0731:   {
0732:    clearSprites(22,7);
0733:    pictureInit(&testPict, &MTSmilePanamaPioneer,22, 16 + BG_ExtHouseOfMTSunset.palInfo->count, 104, 0,FLIP_NONE);
0734:    palJobPut(16 + BG_ExtHouseOfMTSunset.palInfo->count, MTSmilePanamaPioneer.palInfo->count, MTSmilePanamaPioneer.palInfo->data);
0735:    
0736:    fixPrint(1,27,0,1,"��-��! ����� ��� ����� �������? �");
0737:    fixPrint(1,28,0,1,"������ �����? ���� �������� �� ������?");
0738:   }
0739:   if(action==26)
0740:   {
0741:    clearSprites(22,7);
0742:    pictureInit(&testPict, &MTSurprisePanamaPioneer,22, 16 + BG_ExtHouseOfMTSunset.palInfo->count, 104, 0,FLIP_NONE);
0743:    palJobPut(16 + BG_ExtHouseOfMTSunset.palInfo->count, MTSurprisePanamaPioneer.palInfo->count, MTSurprisePanamaPioneer.palInfo->data);
0744:    
0745:    fixPrint(1,26,0,1,"����� ����������:");
0746:    fixPrint(1,28,1,1,"��� �����?");
0747:   }
0748:   if(action==27)
0749:   {
0750:    clearSprites(22,7);
0751:    pictureInit(&testPict, &MTNormalPanamaPioneer,22, 16 + BG_ExtHouseOfMTSunset.palInfo->count, 104, 0,FLIP_NONE);
0752:    palJobPut(16 + BG_ExtHouseOfMTSunset.palInfo->count, MTNormalPanamaPioneer.palInfo->count, MTNormalPanamaPioneer.palInfo->data);
0753:    
0754:    fixPrint(1,25,0,1,"�����:");
0755:    fixPrint(1,27,1,1,"�� ������... �� �������� �� � ������.");
0756:    fixPrint(1,28,1,1,"� �������� ��� ���-�� ����������...");
0757:   }
0758:   if(action==28)
0759:   {
0760:    fixPrint(1,26,0,1,"����� ����������:");
0761:    fixPrint(1,28,1,1,"��� �� ��� ���������.");
0762:   }
0763:   if(action==29)
0764:   {
0765:    fixPrint(1,25,0,1,"�����:");
0766:    fixPrint(1,27,1,1,"���! ����� �� ���������. ����� ��");
0767:    fixPrint(1,28,1,1,"���������.");
0768:   }
0769:   if(action==30)
0770:   {
0771:    clearSprites(22,7);
0772:    pictureInit(&testPict, &MTSurprisePanamaPioneer,22, 16 + BG_ExtHouseOfMTSunset.palInfo->count, 104, 0,FLIP_NONE);
0773:    palJobPut(16 + BG_ExtHouseOfMTSunset.palInfo->count, MTSurprisePanamaPioneer.palInfo->count, MTSurprisePanamaPioneer.palInfo->data);
0774:    
0775:    fixPrint(1,26,0,1,"����� ����������:");
0776:    fixPrint(1,28,1,1,"������...");
0777:   }
0778:   if(action==31)
0779:   {
0780:    fixPrint(1,24,0,1,"�����:");
0781:    fixPrint(1,26,1,1,"��������� ��� ����� ����� ��� ����");
0782:    fixPrint(1,27,1,1,"��������. ������� ��������� ������");
0783:    fixPrint(1,28,1,1,"�����.");
0784:   }
0785:   if(action==32)
0786:   {
0787:    clearSprites(22,7);
0788:    pictureInit(&testPict, &MTSmilePanamaPioneer,22, 16 + BG_ExtHouseOfMTSunset.palInfo->count, 104, 0,FLIP_NONE);
0789:    palJobPut(16 + BG_ExtHouseOfMTSunset.palInfo->count, MTSmilePanamaPioneer.palInfo->count, MTSmilePanamaPioneer.palInfo->data);
0790:    
0791:    fixPrint(1,25,0,1,"����� ����������:");
0792:    fixPrint(1,27,1,1,"�� �� �����, ������� ����������� ��");
0793:    fixPrint(1,28,1,1,"�����! � ���� ��� ����.");
0794:   }
0795:   if(action==33)
0796:   {
0797:    fixPrint(1,26,0,1,"�����:");
0798:    fixPrint(1,28,1,1,"�, �� ������...");
0799:   }
0800:   if(action==34)
0801:   {
0802:    fixPrint(1,26,0,1,"���������, ������ �� �����.");
0803:    fixPrint(1,27,0,1,"�������� ��� ����, ��� ��? ��� ����");
0804:    fixPrint(1,28,0,1,"����� �����?");
0805:   }
0806:   if(action==35)
0807:   {
0808:    fixPrint(1,26,0,1,"� ��� ��� ���� �����, ����������?");
0809:    fixPrint(1,27,0,1,"������� �����-�� ���������. ��������");
0810:    fixPrint(1,28,0,1,"������������ �����...");
0811:   }
0812:   if(action==36)
0813:   {
0814:    fixPrint(1,26,0,1,"���������� ��������? ����������� ��");
0815:    fixPrint(1,27,0,1,"��� ��� �������. � ������ �� ���");
0816:    fixPrint(1,28,0,1,"���������! �� ����� � �������!");
0817:   }
0818:   if(action==37)
0819:   {
0820:    clearSprites(22,7);
0821:    pictureInit(&testPict, &MTNormalPanamaPioneer,22, 16 + BG_ExtHouseOfMTSunset.palInfo->count, 104, 0,FLIP_NONE);
0822:    palJobPut(16 + BG_ExtHouseOfMTSunset.palInfo->count, MTNormalPanamaPioneer.palInfo->count, MTNormalPanamaPioneer.palInfo->data);
0823:    
0824:    fixPrint(1,26,0,1,"����� ����������:");
0825:    fixPrint(1,28,1,1,"�����, �� ��������?");
0826:   }
0827:   if(action==38)
0828:   {
0829:    fixPrint(1,20,0,1,"����� ����������:");
0830:    fixPrint(1,22,1,1,"��� ���. � ������� ���, ��� �� ������,");
0831:    fixPrint(1,23,1,1,"������� �������� � ������. �� ��� ��");
0832:    fixPrint(1,24,1,1,"��� ��������� �� ����� �����");
0833:    fixPrint(1,25,1,1,"����������, � ��� �����. �� � ������");
0834:    fixPrint(1,26,1,1,"��� ��� ����� ������. � � ���� ����");
0835:    fixPrint(1,27,1,1,"��� ������� ��� ���������,");
0836:    fixPrint(1,28,1,1,"�������������?");
0837:   }
0838:   if(action==39)
0839:   {
0840:    fixPrint(1,21,0,1,"����� ����������:");
0841:    fixPrint(1,23,1,1,"�� ���������� ��������� ����� �����");
0842:    fixPrint(1,24,1,1,"������, ��� ����� �� �������� ������");
0843:    fixPrint(1,25,1,1,"���������� ������� ������. ����");
0844:    fixPrint(1,26,1,1,"����������� ������ ���� ���� �� �����,");
0845:    fixPrint(1,27,1,1,"�� � ��� ���� ����� - ������ ����� �");
0846:    fixPrint(1,28,1,1,"�������.");
0847:   }
0848:   if(action==40)
0849:   {
0850:    fixPrint(1,26,0,1,"�����:");
0851:    fixPrint(1,28,1,1,"�� �������...");
0852:   }
0853:   if(action==41)
0854:   {
0855:    clearSprites(22,7);
0856:    pictureInit(&testPict, &MTSmilePanamaPioneer,22, 16 + BG_ExtHouseOfMTSunset.palInfo->count, 104, 0,FLIP_NONE);
0857:    palJobPut(16 + BG_ExtHouseOfMTSunset.palInfo->count, MTSmilePanamaPioneer.palInfo->count, MTSmilePanamaPioneer.palInfo->data);
0858:    
0859:    fixPrint(1,23,0,1,"����� ����������:");
0860:    fixPrint(1,25,1,1,"���� ���� �������! ����������, �����,");
0861:    fixPrint(1,26,1,1,"������ �� ����������! ������ ������� �");
0862:    fixPrint(1,27,1,1,"��������������� ����! �� ������� ����,");
0863:    fixPrint(1,28,1,1,"���� �� ������ ���� ������.");
0864:   }
0865:   if(action==42)
0866:   {
0867:    fixPrint(1,24,0,1,"�����:");
0868:    fixPrint(1,26,1,1,"��������� �������� - � ��� ���� ��");
0869:    fixPrint(1,27,1,1,"����������. ���� ���������, ������. ��");
0870:    fixPrint(1,28,1,1,"����� �� ���� ����������...");
0871:   }
0872:   if(action==43)
0873:   {
0874:    fixPrint(1,26,0,1,"����� ����������:");
0875:    fixPrint(1,28,1,1,"������, � ����� ����������� �������.");
0876:   }
0877:   if(action==44)
0878:   {
0879:    clearSprites(22,7);
0880:    pictureInit(&testPict, &MTNormalPanamaPioneer,22, 16 + BG_ExtHouseOfMTSunset.palInfo->count, 104, 0,FLIP_NONE);
0881:    palJobPut(16 + BG_ExtHouseOfMTSunset.palInfo->count, MTNormalPanamaPioneer.palInfo->count, MTNormalPanamaPioneer.palInfo->data);
0882:    
0883:    fixPrint(1,25,0,1,"�����:");
0884:    fixPrint(1,27,1,1,"��, �����... � ������������ ����������");
0885:    fixPrint(1,28,1,1,"� ������ ����!");
0886:   }
0887:   if(action==45)
0888:   {
0889:    clearSprites(22,7);
0890:    pictureInit(&testPict, &MTAngryPanamaPioneer,22, 16 + BG_ExtHouseOfMTSunset.palInfo->count, 80, 0,FLIP_NONE);
0891:    palJobPut(16 + BG_ExtHouseOfMTSunset.palInfo->count, MTAngryPanamaPioneer.palInfo->count, MTAngryPanamaPioneer.palInfo->data);
0892:  
0893:    fixPrint(1,25,0,1,"����� ����������:");
0894:    fixPrint(1,27,1,1,"�� �� ������, �����. � ��� ���� -");
0895:    fixPrint(1,28,1,1,"��������� ���������� �������.");
0896:   }
0897:   if(action==46)
0898:   {
0899:    fixPrint(1,25,0,1,"�����:");
0900:    fixPrint(1,27,1,1,"������� �� �������, ��... � ��");
0901:    fixPrint(1,28,1,1,"�������� ����� ���������������.");
0902:   }
0903:   if(action==47)
0904:   {
0905:    fixPrint(1,23,0,1,"����� ����������:");
0906:    fixPrint(1,25,1,1,"���������� ������. ������� ����������,");
0907:    fixPrint(1,26,1,1,"������ ����������, ����������� ������");
0908:    fixPrint(1,27,1,1,"� ������� ������ �������� - ���������");
0909:    fixPrint(1,28,1,1,"����������� ����!");
0910:   }
0911:   if(action==48)
0912:   {
0913:    fixPrint(1,26,0,1,"�����:");
0914:    fixPrint(1,28,1,1,"�� ���������. ������� ���������?");
0915:   }
0916:   if(action==49)
0917:   {
0918:    clearSprites(22,10);
0919:    pictureInit(&testPict, &MTSmilePanamaPioneer,22, 16 + BG_ExtHouseOfMTSunset.palInfo->count, 104, 0,FLIP_NONE);
0920:    palJobPut(16 + BG_ExtHouseOfMTSunset.palInfo->count, MTSmilePanamaPioneer.palInfo->count, MTSmilePanamaPioneer.palInfo->data);
0921:    
0922:    fixPrint(1,26,0,1,"����� ����������:");
0923:    fixPrint(1,28,1,1,"���-�� �����!");
0924:   }
0925:   if(action==50)
0926:   {
0927:    clearSprites(22,7);
0928:    interval(12);
0929:    
0930:    if(text_visible==true)
0931:    {
0932:     fixPrint(1,26,0,1,"�����:");
0933:     fixPrint(1,28,1,1,"�� � �� ��� ������...");
0934:    }
0935:   }
0936:   if(action==51)
0937:   {
0938:    fixPrint(1,27,0,1,"������� ��� ����������� � ���������");
0939:    fixPrint(1,28,0,1,"������� ���-�� � ����� ��������.");
0940:   }
0941:   if(action==52)
0942:   {
0943:    fixPrint(1,26,0,1,"����� ����������:");
0944:    fixPrint(1,28,1,1,"���, �����?");
0945:   }
0946:   if(action==53)
0947:   {
0948:    fixPrint(1,26,0,1,"�����:");
0949:    fixPrint(1,28,1,1,"������...");
0950:   }
0951:   if(action==54)
0952:   {
0953:    interval(24);
0954:    
0955:    if(text_visible==true)
0956:    {
0957:     fixPrint(1,22,0,1,"� ��� ���� ������ ����? ��� ���-��");
0958:     fixPrint(1,23,0,1,"������� ��� ����������. �������, ����");
0959:     fixPrint(1,24,0,1,"������� � ���� �����-�� �������");
0960:     fixPrint(1,25,0,1,"�����������? � ��� ���� ������������");
0961:     fixPrint(1,26,0,1,"�������� �� �������, ��������");
0962:     fixPrint(1,27,0,1,"��������� ���������? �������������");
0963:     fixPrint(1,28,0,1,"�������.");
0964:    }
0965:   }
0966:   if(action==55)
0967:   {
0968:    pictureInit(&testPict, &MTSmilePanamaPioneer,22, 16 + BG_ExtHouseOfMTSunset.palInfo->count, 104, 0,FLIP_NONE);
0969:    palJobPut(16 + BG_ExtHouseOfMTSunset.palInfo->count, MTSmilePanamaPioneer.palInfo->count, MTSmilePanamaPioneer.palInfo->data);
0970:    
0971:    fixPrint(1,25,0,1,"����� ����������:");
0972:    fixPrint(1,27,1,1,"���� ���� ������ ���������. ��� �����");
0973:    fixPrint(1,28,1,1,"������, ��� ���� ����������.");
0974:   }
0975:   if(action==56)
0976:   {
0977:    clearSprites(22,7);
0978:    pictureInit(&testPict, &MTGrinPanamaPioneer,22, 16 + BG_ExtHouseOfMTSunset.palInfo->count, 104, 0,FLIP_NONE);
0979:    palJobPut(16 + BG_ExtHouseOfMTSunset.palInfo->count, MTGrinPanamaPioneer.palInfo->count, MTGrinPanamaPioneer.palInfo->data);
0980:    
0981:    fixPrint(1,26,0,1,"����� ����������:");
0982:    fixPrint(1,28,1,1,"�� � �� � ��� ���� ���������.");
0983:   }
0984:   if(action==57)
0985:   {
0986:    fixPrint(1,28,0,1,"� ��� ��� ���?! ��� � �����������!");
0987:   }
0988:   if(action==58)
0989:   {
0990:    clearSprites(22,7);
0991:    pictureInit(&testPict, &MTSmilePanamaPioneer,22, 16 + BG_ExtHouseOfMTSunset.palInfo->count, 104, 0,FLIP_NONE);
0992:    palJobPut(16 + BG_ExtHouseOfMTSunset.palInfo->count, MTSmilePanamaPioneer.palInfo->count, MTSmilePanamaPioneer.palInfo->data);
0993:    
0994:    fixPrint(1,26,0,1,"����� ����������:");
0995:    fixPrint(1,28,1,1,"������!");
0996:   }
0997:   /*
0998:   if(action==59)
0999:   {
1000:    interval(12);
1001:    
1002:    if(text_visible==true)
1003:    {
1004:     action++;
1005:    }
1006:   }
1007:   if(action==60)
1008:   {
1009:    clearSprites(22,7);
1010:    interval(36);
1011:    
1012:    if(text_visible==true)
1013:    {
1014:     action++;
1015:    }
1016:   }
1017:   */
1018:   if(action==59)
1019:   {
1020:    clearSprites(1,28);
1021:    scrollerInit(&sc,&BG_ExtNoBus,1,16,0,0);
1022:    palJobPut(16, BG_ExtNoBus.palInfo->count, BG_ExtNoBus.palInfo->data);
1023:    
1024:    fixPrint(1,25,0,1,"��������� ������ ���������� ����������");
1025:    fixPrint(1,26,0,1,"� ���������� ���������. � ��������,");
1026:    fixPrint(1,27,0,1,"��� ��� � �� ������, �� � ����");
1027:    fixPrint(1,28,0,1,"�������� ���������.");
1028:   }
1029:  
1030:   if(choice==0)
1031:   {
1032:    if(action==15)
1033:    {
1034:     fixPrint(1,25,0,1,"����� �� ������� ���� ����� ��");
1035:     fixPrint(1,26,0,1,"���������. ������ �������� �� �����");
1036:     fixPrint(1,27,0,1,"������ �������� �� ������� � �����");
1037:     fixPrint(1,28,0,1,"���������.");
1038:    }
1039:    if(action==16)
1040:    {
1041:     fixPrint(1,27,0,1,"�������, �� ������� �������� ������");
1042:     fixPrint(1,28,0,1,"������� \"�������\" � �����.");
1043:    }
1044:    if(action==17)
1045:    {
1046:     action=19;
1047:    }
1048:   }
1049:   if(choice==1)
1050:   {
1051:    if(action==15)
1052:    {
1053:     fixPrint(1,28,0,1,"����� ����������.");
1054:    }
1055:    if(action==16)
1056:    {
1057:     choice=0;
1058:     action=19;
1059:    }
1060:   }
1061:   if(choice==2)
1062:   {
1063:    if(action==15)
1064:    {
1065:     fixPrint(1,26,0,1,"����� ������� � �� ������������, � ��");
1066:     fixPrint(1,27,0,1,"��� �������� �������� ��������� ��");
1067:     fixPrint(1,28,0,1,"�������, ��� ���-�� � ���� ����.");
1068:    }
1069:    if(action==16)
1070:    {
1071:     clearSprites(22,7);
1072:     pictureInit(&testPict, &MTAngryPanamaPioneerClose,22, 16 + BG_ExtHouseOfMTSunset.palInfo->count, 64, 0,FLIP_NONE);
1073:     palJobPut(16 + BG_ExtHouseOfMTSunset.palInfo->count, MTAngryPanamaPioneerClose.palInfo->count, MTAngryPanamaPioneerClose.palInfo->data);
1074:    
1075:     fixPrint(1,23,0,1,"����� ����������:");
1076:     fixPrint(1,25,1,1,"�����! �� �� �����������? � ���� ���");
1077:     fixPrint(1,26,1,1,"��������� ���� �� ����������.");
1078:     fixPrint(1,27,1,1,"������, ��� ����� ����� � ������, � �");
1079:     fixPrint(1,28,1,1,"������ �� ���� �����. ��?");
1080:    }
1081:    if(action==17)
1082:    {
1083:     fixPrint(1,26,0,1,"�����:");
1084:     fixPrint(1,28,0,1,"...� � ��� ���� ����?");
1085:    }
1086:    if(action==18)
1087:    {
1088:     clearSprites(22,12);
1089:     pictureInit(&testPict, &MTSmilePanamaPioneer,22, 16 + BG_ExtHouseOfMTSunset.palInfo->count, 104, 0,FLIP_NONE);
1090:     palJobPut(16 + BG_ExtHouseOfMTSunset.palInfo->count, MTSmilePanamaPioneer.palInfo->count, MTSmilePanamaPioneer.palInfo->data);
1091:     choice=0;
1092:     action++;
1093:    }
1094:   }
1095:  
1096:   scrollerSetPos(&sc,posX,posY);
1097:  }
1098: }
1099: 
1100: void colorStreamDemoB() {
1101:  scroller sc;
1102:  colorStream stream;
1103:  short posX=0;
1104:  short posY=0;
1105:  uint *plj;
1106:  ushort lastJobs=0,jobs=0;
1107: 
1108:  
1109:  clearFixLayer();
1110:  scrollerInit(&sc,&SNKLogoStrip,1,16,0,0);
1111:  colorStreamInit(&stream,&SNKLogoStrip_colorStream,16,COLORSTREAM_STARTCONFIG);
1112: 
1113:  fixPrint(2,3,4,3,"1P \x12\x13: scroll");
1114:  fixPrint(2,29,6,3,"(Sequence formatted by MegaShocked)");
1115:  
1116:  while(1) {
1117:   SCClose();
1118:  
1119:   //check palJobs load
1120:   if(jobs!=0) lastJobs=jobs;
1121:   jobs=0;
1122:   plj=PALJOBS;
1123:   while(*plj!=0xffffffff) {
1124:    jobs+=((*plj++)>>16)+1;
1125:    plj++;
1126:   }
1127:   //fixPrintf1(0,2,3,3,"Jobs:%d (last:%d)   ",jobs,lastJobs);
1128: 
1129:   waitVBlank();
1130: 
1131:   p1=volMEMBYTE(P1_CURRENT);
1132:   ps=volMEMBYTE(PS_CURRENT);
1133:   p1e=volMEMBYTE(P1_EDGE);
1134:  
1135:   if(ps&P1_START) {
1136:    clearSprites(1,21);
1137:    SCClose();
1138:    waitVBlank();
1139:    return;
1140:   }
1141:  
1142:   if(p1&JOY_B) {
1143:    if(p1e&JOY_UP) posY-=224;
1144:    if(p1e&JOY_DOWN)posY+=224;
1145:   } else {
1146:    if(p1&JOY_UP) posY-=p1&JOY_A?224:1;
1147:    if(p1&JOY_DOWN) posY+=p1&JOY_A?224:1;
1148:   }
1149:   if(posY<0) posY=0;
1150:   if(posY>(SNKLogoStrip.mapHeight-14)<<4) posY=(SNKLogoStrip.mapHeight-14)<<4;
1151:  
1152:   //fixPrintf1(0,1,3,3,"%d    ",posY);
1153:  
1154:   scrollerSetPos(&sc,posX,posY);
1155:   colorStreamSetPos(&stream,posY);
1156:  }
1157: }
1158: 
1159: int main(void) {
1160:  int scrl_x=0;
1161:  int scrl_y=0;
1162:  short showdebug=false;
1163:  scroller frontScroll;
1164:  ushort *data;
1165:  ushort flipMode=0;
1166:  
1167:  clearFixLayer();
1168:  initGfx();
1169: 
1170:  palJobPut(0,8,fixPalettes);
1171: 
1172:  //if(setup4P())
1173:  // fixPrint(2,4,7,3,"4P! :)");
1174:  //else fixPrint(2,4,7,3,"no 4P :(");
1175: 
1176:  backgroundColor(0x7bbb);
1177:  jobMeterSetup(true);
1178: 
1179:  scrollerInit(&frontScroll, &ffbg_b, 1, 16, scrl_x, scrl_y);
1180:  //scrollerInitClipped(&frontScroll, &ffbg_b, 22, 16 + ffbg_a.palInfo->count, x, y, CLIPPING);
1181:  palJobPut(16, ffbg_b.palInfo->count, ffbg_b.palInfo->data);
1182: 
1183:  data=dbgTags.maps[0];
1184:  palJobPut(200,dbgTags.palInfo->count,&dbgTags.palInfo->data);
1185:  SC234Put(VRAM_POSX_ADDR(200),VRAM_POSX(0));
1186:  SC234Put(VRAM_POSY_ADDR(200),VRAM_POSY(224,SPR_UNLINK,0));
1187:  SC234Put(VRAM_SPR_ADDR(200),data[4<<1]);
1188:  SC234Put(VRAM_SPR_ADDR(200)+1,200<<8);
1189:  SC234Put(VRAM_POSX_ADDR(201),VRAM_POSX(0));
1190:  SC234Put(VRAM_POSY_ADDR(201),VRAM_POSY(224,SPR_UNLINK,0));
1191:  SC234Put(VRAM_SPR_ADDR(201),data[40<<1]);
1192:  SC234Put(VRAM_SPR_ADDR(201)+1,200<<8);
1193:  SC234Put(VRAM_POSX_ADDR(202),VRAM_POSX(0));
1194:  SC234Put(VRAM_POSY_ADDR(202),VRAM_POSY(224,SPR_UNLINK,0));
1195:  SC234Put(VRAM_SPR_ADDR(202),data[40<<1]);
1196:  SC234Put(VRAM_SPR_ADDR(202)+1,(200<<8)|FLIP_X);
1197:  SC234Put(VRAM_POSX_ADDR(203),VRAM_POSX(0));
1198:  SC234Put(VRAM_POSY_ADDR(203),VRAM_POSY(224,SPR_UNLINK,0));
1199:  SC234Put(VRAM_SPR_ADDR(203),data[40<<1]);
1200:  SC234Put(VRAM_SPR_ADDR(203)+1,(200<<8)|FLIP_Y);
1201:  SC234Put(VRAM_POSX_ADDR(204),VRAM_POSX(0));
1202:  SC234Put(VRAM_POSY_ADDR(204),VRAM_POSY(224,SPR_UNLINK,0));
1203:  SC234Put(VRAM_SPR_ADDR(204),data[40<<1]);
1204:  SC234Put(VRAM_SPR_ADDR(204)+1,(200<<8)|FLIP_XY);
1205:  
1206:  fixPrint(14,20,4,3,"PRESS START");
1207:  
1208:  while(1) {
1209:   SCClose();
1210:   waitVBlank();
1211: 
1212:   p1=volMEMBYTE(P1_CURRENT);
1213:   p1e=volMEMBYTE(P1_EDGE);
1214:   ps=volMEMBYTE(PS_EDGE);
1215:  
1216:   while((volMEMWORD(0x3c0006)>>7)!=0x120); //wait raster line 16
1217:   jobMeterColor(JOB_BLUE);
1218: 
1219:   /*if((p1&JOY_UP)&&y>=176) y--;
1220:   if((p1&JOY_DOWN)&&y<=220) y++;
1221:   if((p1&JOY_LEFT)&&x>=32)
1222:   {
1223:    x--;
1224:    flipMode|=FLIP_X;
1225:    aSpriteSetFlip(&demoSpr,flipMode);
1226:   }
1227:   if((p1&JOY_RIGHT)&&x<=288)
1228:   {
1229:    x++;
1230:    flipMode&=~FLIP_X;
1231:    aSpriteSetFlip(&demoSpr,flipMode);
1232:   }*/
1233:  
1234:   if(ps&P1_START) {
1235:    clearSprites(1, 42);
1236:    SCClose();
1237:    waitVBlank();
1238:    introducion();
1239:   }
1240:  
1241:   if(p1e&JOY_D) {
1242:    if(showdebug) {
1243:     //move debug stuff offscreen
1244:     SC234Put(VRAM_POSY_ADDR(200),VRAM_POSY(224,SPR_UNLINK,0));
1245:     SC234Put(VRAM_POSY_ADDR(201),VRAM_POSY(224,SPR_UNLINK,0));
1246:     SC234Put(VRAM_POSY_ADDR(202),VRAM_POSY(224,SPR_UNLINK,0));
1247:     SC234Put(VRAM_POSY_ADDR(203),VRAM_POSY(224,SPR_UNLINK,0));
1248:     SC234Put(VRAM_POSY_ADDR(204),VRAM_POSY(224,SPR_UNLINK,0));
1249:     fixJobPut(0,25,FIX_LINE_WRITE,0,_fixBlankLine);
1250:     fixJobPut(0,26,FIX_LINE_WRITE,0,_fixBlankLine);
1251:     fixJobPut(0,27,FIX_LINE_WRITE,0,_fixBlankLine);
1252:     fixJobPut(0,28,FIX_LINE_WRITE,0,_fixBlankLine);
1253:    }
1254:    showdebug^=1;
1255:   }
1256: 
1257:   //aSprite debug info
1258:   /*if(showdebug) {
1259:    jobMeterColor(JOB_BLACK);
1260:    if(!(demoSpr.flags&AS_FLAG_STRICT_COORDS)) {
1261:     if(demoSpr.currentFlip&FLIP_X) relX=x-((demoSpr.currentFrame->tileWidth<<4)+demoSpr.currentStep->shiftX)+1;
1262:      else relX=x+demoSpr.currentStep->shiftX;
1263:     if(demoSpr.currentFlip&FLIP_Y) relY=y-((demoSpr.currentFrame->tileHeight<<4)+demoSpr.currentStep->shiftY)+1;
1264:      else relY=y+demoSpr.currentStep->shiftY;
1265:    } else {
1266:     relX=demoSpr.posX;
1267:     relY=demoSpr.posY;
1268:    }
1269:    SC234Put(VRAM_POSX_ADDR(200),VRAM_POSX(x-3));
1270:    SC234Put(VRAM_POSY_ADDR(200),VRAM_POSY(y-3,SPR_UNLINK,1));
1271:    SC234Put(VRAM_POSX_ADDR(201),VRAM_POSX(relX));
1272:    SC234Put(VRAM_POSY_ADDR(201),VRAM_POSY(relY,SPR_UNLINK,1));
1273:    SC234Put(VRAM_POSX_ADDR(202),VRAM_POSX(relX+((demoSpr.currentFrame->tileWidth-1)<<4)));
1274:    SC234Put(VRAM_POSY_ADDR(202),VRAM_POSY(relY,SPR_UNLINK,1));
1275:    SC234Put(VRAM_POSX_ADDR(203),VRAM_POSX(relX));
1276:    SC234Put(VRAM_POSY_ADDR(203),VRAM_POSY(relY+((demoSpr.currentFrame->tileHeight-1)<<4),SPR_UNLINK,1));
1277:    SC234Put(VRAM_POSX_ADDR(204),VRAM_POSX(relX+((demoSpr.currentFrame->tileWidth-1)<<4)));
1278:    SC234Put(VRAM_POSY_ADDR(204),VRAM_POSY(relY+((demoSpr.currentFrame->tileHeight-1)<<4),SPR_UNLINK,1));
1279:    
1280:    //debug live update prints = 1 frame ahead. meh.
1281:    jobMeterColor(JOB_GREY);
1282:    fixPrintf1(3,25,2,3,"Anim data: A:%02d S:%02d R:%02d   ",demoSpr.currentAnim,demoSpr.stepNum,demoSpr.repeats);
1283:    fixPrintf1(3,26,2,3,"Step data: Frame:0x%06x",bmary_spr.anims[demoSpr.currentAnim][demoSpr.stepNum].frame);
1284:    fixPrintf1(14,27,2,3,"SX:%04d SY:%04d D:%02d",
1285:     bmary_spr.anims[demoSpr.currentAnim][demoSpr.stepNum].shiftX,
1286:     bmary_spr.anims[demoSpr.currentAnim][demoSpr.stepNum].shiftY,
1287:     bmary_spr.anims[demoSpr.currentAnim][demoSpr.stepNum].duration
1288:    );
1289:    fixPrintf1(2,28,2,3,"Frame data: W:%02d H:%02d TMAP:0x%06x",
1290:     ((sprFrame*)(bmary_spr.anims[demoSpr.currentAnim][demoSpr.stepNum].frame))->tileWidth,
1291:     ((sprFrame*)(bmary_spr.anims[demoSpr.currentAnim][demoSpr.stepNum].frame))->tileHeight,
1292:     ((sprFrame*)(bmary_spr.anims[demoSpr.currentAnim][demoSpr.stepNum].frame))->maps[demoSpr.currentFlip]
1293:    );
1294:   }*/
1295:  
1296:   scrollerSetPos(&frontScroll, scrl_x, scrl_y);
1297:   //scrollerSetPosClipped(&frontScroll, x, y, CLIPPING);
1298: 
1299:   jobMeterColor(JOB_GREEN);
1300:  }
1301: }