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

001: /*
002:  Gestion des fichiers  2012 - LYNX - kit BLL (newcc65)
003:  problem : limit 11
004:  philippe toulouse
005:  26/01/2013
006:  */
007: #include <stdlib.h>
008: #include <lynx.h>
009: #include <lynxlib.h>
010: //#include "fond1.pal"
011: 
012: 
013: /* LYNX-specific #defines: */
014: #define JOY_RIGHT  0x10
015: #define JOY_LEFT  0x20
016: #define JOY_DOWN  0x40
017: #define JOY_UP   0x80
018: 
019: #define BUTTON_OPTION1 0x08
020: #define BUTTON_OPTION2 0x04
021: #define BUTB  0x02
022: #define BUTA 0x01
023: 
024: #define BUTTON_PAUSE 0x01
025: 
026: 
027: char SCREEN[8160]       at (MEMTOP-16320);
028: char RENDER[8160]       at (MEMTOP-8160);
029: 
030: char pal[]={
031:  0x00,0x0F,0x0D,0x0A,0x08,0x05,0x03,0x01,0x00,0x00,0x00,0x00,0x06,0x0B,0x0A,0x07,
032:  0x00,0xFF,0xCA,0xA8,0x86,0x53,0x63,0x41,0x36,0x5A,0x6F,0x0F,0x0F,0x0F,0xF0,0xC0};
033: 
034: 
035: extern char FileEntry[8];
036: /*_FileEntry : struct of 8 bytes
037: FileStartBlock ds 1
038: FileBlockOffset ds 2
039: FileExecFlag ds 1
040: FileDestAddr ds 2
041: FileFileLen ds 2
042: */
043: 
044: char mtil01[512];
045: char mtil02[512];
046: char mtil03[512];
047: char mtil04[512];
048: char mtil05[512];
049: char mtil06[512];
050: char mtil07[512];
051: char mtil08[512];
052: char mtil09[512];
053: char mtil10[512];
054: char mtil11[512];
055: char mtil12[512];
056: 
057: uchar *tatab[12] = { mtil01, mtil02, mtil03, mtil04, mtil05, mtil06, mtil07, mtil08, mtil09, mtil10, mtil11, mtil12};
058: 
059: /*
060: set image01=spta.bmp
061: 
062: SPRPCK -t6 -S024020 -r010001 -i240020 %image01% ta
063: cmd
064: */
065: 
066: 
067: extern char SCB1[];
068: #asm
069: _SCB1 dc.b $c7,$10,$20
070:    dc.w 0,0
071:    dc.w 0,0,$100,$100
072:    ; Because we didn't use -C when calling SPRPCK we can
073:    ; use the same colour palette indexes for all tiles
074:    dc.b $01,$23,$45,$67,$89,$Ab,$cd,$ef
075: #endasm
076: 
077: 
078: 
079: 
080: 
081: 
082: extern char SCM[122][11] at (0xfff8-20400-122*11);
083: //extern char SCM[122][11] at (0xfff8-24480-122*11);
084: 
085: 
086: 
087: // spr0 est le "mod�le" de sprite de 11 octet pour initialiser une occurence de SCB2[]
088: extern char spr0[11];
089: 
090: // init_scm est le premier sprite � afficher, en fait, il pointe sur un sprite vide
091: // j'aurais aussi pu le faire pointer vers le background
092: // l'important dans le _init_scm, c'est dc.w _SCB2
093: // qui fait pointer le sprite suivant vers le premier du tableau SCM
094: extern char init_scm[23];
095: 
096: #asm
097: ; init_scm est utilis� pour initialiser les registres du SpriteEngine
098: ; avec les param�tres ad�quats (palette...)
099: ; Using this trick, the 8*11 spr[]-SCMs only need 11 Bytes each!
100: _init_scm:
101:   dc.b $c1, $10, $20
102:   dc.w _SCM ; PTR_NEXT pointe vers le 1� sprite visible (SCM[0])
103:   dc.w dummy ; PTR_DATA pointe vers un sprite "inexistant"
104:   dc.w 200, 200 ; x,y -> on affiche en dehors de l'�cran
105:   dc.w $100, $100 ; pas de zoom
106:   dc.b $01, $23, $45, $67, $89, $ab, $cd, $ef
107: 
108: dummy: dc.b 0,0,0 ; le sprite "inexistant"
109: 
110: ; spr0 sert de mod�le au sprites du tableau SCM
111: _spr0: dc.b $c4, $08, $02 ; CTL0, CTL1 = r�utilise la palette, COLL
112:   dc.w 0, 0
113:   dc.w 0, 0
114: #endasm
115: 
116: 
117: 
118: 
119: 
120: 
121: 
122: 
123: 
124: /*********************/
125: /* wait for a button */
126: /*********************/
127: char WaitButton()
128: {
129: char key;
130: while (joystick);
131: while ( (key = joystick) != BUTA) ;
132: /* wait for the button to be released */
133: while ( joystick ) ;
134: return key;
135: }
136: 
137: // ------------------------------------
138: // clip du sprite chiffres, chacun d'une taille de 8*8: 0123456789.LEV
139: /*****************************************************************************
140: **  Ci-dessous, le contenu du fichier batchfile pour l'image bchiffres.bmp   **
141: 
142: set image01=bchiffres.bmp
143: SPRPCK -t6 -S008008 -r014001 -o000000 -i112008 -p0 %image01% bc
144: cmd
145: 
146: *****************************************************************************/
147: extern uchar bc000000[];
148: extern uchar bc000001[];
149: extern uchar bc000002[];
150: extern uchar bc000003[];
151: extern uchar bc000004[];
152: extern uchar bc000005[];
153: extern uchar bc000006[];
154: extern uchar bc000007[];
155: extern uchar bc000008[];
156: extern uchar bc000009[];
157: 
158: uchar *chiffrestab[10] = {bc000000, bc000001, bc000002, bc000003, bc000004, bc000005, bc000006, bc000007, bc000008, bc000009};
159: // ------------------------------------
160:  
161: int etp, brnbr, posx,posy,gbfrx,gbfry,briqy,scnum,stopy,scaelv,scrollx,scrolly,xlimit,ylimit;
162: int tempa,tempb,tempc,tempd,bspeed,comptx;
163: char drap1,drap2,zap,relach,relaci,gspause,gsbl, level;
164: int cptx, cpty, cpti, atest, unit, diza, cent, mill, dmil, scor;
165: // assembler vertical retrace syncronisation routine
166: void Vsync()
167: {
168: #asm
169: vretrace:
170:  lda $fd0a
171:  bne vretrace
172: #endasm
173: }
174: 
175: 
176: /*************** for VSYNC handling*******************/
177: uchar frames, lines;
178: 
179: extern uchar VBLflag;
180: #asm
181: _VBLflag = $a0
182: #endasm
183: 
184: #define VSYNC {++VBLflag;while( VBLflag );}
185: 
186: VBL() interrupt
187: {
188:    VBLflag = 0; /* indicates that a VBL has ocurred */
189: }
190: 
191: HBL() interrupt
192: {
193: }
194: /*****************************************************/
195: void Fmx(mlx,vlx) // coordonn�es X
196: int mlx,vlx;
197:  {
198:  SCBX(&SCM[mlx][0]) = vlx;
199:  };
200: 
201: void Fmy(mly,vly) // coordonn�es Y
202: int mly,vly;
203:  {
204:  SCBY(&SCM[mly][0]) = vly;
205:  };
206: void init_sprites()
207: {
208:  char i1;
209:  for (i1 = 0; i1 < 122; i1++) // 0 � 121 = 122
210:   {
211:   bcopy(&spr0[0], &SCM[i1][0], 11);
212:   SCBX(&SCM[i1][0]) = 0;
213:   SCBY(&SCM[i1][0]) = 300;
214:   SCBDATA(&SCM[i1][0])  = chiffrestab[0%10];
215:   SCBNEXT(&SCM[i1][0]) = &SCM[i1+1][0];
216:   }
217:  SCBNEXT(&SCM[121][0]) = 0;
218: };
219: 
220: /**************************************************************************
221: **                                                                       **
222: **                                                                       **
223: **************************************************************************/
224: char main()
225: {
226:  char i;
227:  InitIRQ();
228:  CLI;
229:  SetBuffers(SCREEN, RENDER ,0);
230:  InstallIRQ(2,VBL);
231: // InstallIRQ(0,HBL);
232:  EnableIRQ(2);
233: 
234: 
235:   /* set the palette */
236:  SetRGB(pal); //
237:  init_sprites();
238:  SCBNEXT(&SCM[121][0])= SCB1; // lier sprite mascote � tout les sprites d�j� chain�s... �a marche !
239:  
240: Fmx(106,150);Fmx(107,142);Fmx(108,134);Fmx(109,126);Fmx(110,118);
241: 
242:        for(cpty=106 ; cpty<111; cpty++) // de 98 � 103 (score et vie)
243:         {
244:         SCBY(&SCM[cpty][0]) = 90;
245:         }
246:  
247:  posx=63;
248:  posy=43;//-236;//posy=-73;//-236;//-236;
249:  tempa=0;tempb=0;tempc=0;tempd=0;drap1=0;bspeed=0;
250:  
251:  etp=0;
252:  gsbl=5;
253: 
254: 
255: /**************************************************************************
256: **                       BOUCLE PRINCIPALE                               ** |
257: **************************************************************************/    
258: 
259: while(1)
260: {
261:  Vsync();
262:  SwapBuffers();
263:  DrawFBox(0,0,160,102,0);
264:  
265:  --gsbl; // economie ressource machine --> certaines des conditions n'ont pas besoin d'�tre lu par la LYNX � chaque boucle.
266:  if (gsbl==1)
267:   {
268:   gsbl=5;
269:  
270:   scor = etp;//atest;
271:  
272:   /** affichage du score et nombre de vie:**/
273:    unit = scor % 10;
274:    diza = scor / 10 % 10;
275:    cent = scor / 100 % 10;
276:    mill = scor / 1000 % 10;
277:    dmil = scor / 10000 % 10;
278:    
279:   // unit�:  
280:    //SCBDATA(SCBscore1)
281:    SCBDATA(&SCM[106][0]) = chiffrestab[unit%10];
282:   // dizaine:  
283:    //SCBDATA(SCBscore2)
284:    SCBDATA(&SCM[107][0]) = chiffrestab[diza%10];
285:   // centaine:  
286:    //SCBDATA(SCBscore3)
287:    SCBDATA(&SCM[108][0]) = chiffrestab[cent%10];
288:   // millier:  
289:    //SCBDATA(SCBscore4)
290:    SCBDATA(&SCM[109][0]) = chiffrestab[mill%10];
291:    SCBDATA(&SCM[110][0]) = chiffrestab[dmil%10];
292:    
293:   }
294:    
295:    
296:  if (etp==0)
297:   {
298:   // 11 objets externes maximum, it's not cool !
299:   for(cpti=0 ; cpti<12; cpti++) // de 0 � 11 doit 12 tests
300:    {
301:    LoadCartDir(2+cpti);LoadCartBlock(FileEntry[0], tatab[cpti%12]);
302:    }
303:   for(cpti=0 ; cpti<6; cpti++) // de 0 � 5 soit 6 tests
304:    {
305:    SCBDATA(&SCM[cpti][0]) = tatab[cpti%12];SCBX(&SCM[cpti][0]) = cpti*24;SCBY(&SCM[cpti][0]) = 0;
306:    }
307:   SCBDATA(&SCM[6][0]) = tatab[6%12];SCBX(&SCM[6][0]) = 0;SCBY(&SCM[6][0]) = 20;
308:   SCBDATA(&SCM[7][0]) = tatab[7%12];SCBX(&SCM[7][0]) = 24;SCBY(&SCM[7][0]) = 20;
309:   SCBDATA(&SCM[8][0]) = tatab[8%12];SCBX(&SCM[8][0]) = 48;SCBY(&SCM[8][0]) = 20;
310:   SCBDATA(&SCM[9][0]) = tatab[9%12];SCBX(&SCM[9][0]) = 72;SCBY(&SCM[9][0]) = 20;
311:   SCBDATA(&SCM[10][0]) = tatab[10%12];SCBX(&SCM[10][0]) = 96;SCBY(&SCM[10][0]) = 20;
312:   SCBDATA(&SCM[11][0]) = tatab[11%12];SCBX(&SCM[11][0]) = 120;SCBY(&SCM[11][0]) = 20; // problem with lynxer !
313:  
314:   etp=1;level=1;
315:   }
316: 
317: // *********************************************************************************************
318: 
319:  DrawSprite(init_scm);
320: }
321:  
322: /**************************************************************************
323: **                     FIN de la BOUCLE PRINCIPALE                       **
324: **************************************************************************/  
325:  
326:  }