Skip to content

Commit 5665f79

Browse files
committed
Implementado cambio de Zonas: Zona 0 (solo una puerta, sin planoA), Zona 1 y Zona 2 enorme
Aun por arreglar las coordenadas de Zonas grandes como el 2
1 parent 44308bb commit 5665f79

10 files changed

Lines changed: 129 additions & 63 deletions

File tree

inc/global.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ u16 paleta64[64]; //copia Paletas 0,1,2,3 ,para fades completos
1818
void TITUTLO();
1919
void ZoneMap();
2020

21+
u8 ZONA_NUM;
22+
u8 old_musica;
2123

2224
typedef struct {
2325
const bool const PlanA;
2426
const u8 const musica;
27+
const u8 const Xtop;
2528
const u8 const *casillas;
2629
const u8 const top_blxpri;
2730
const u16 const *blockpri;

inc/zona1dat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define _ZONA1DAT_H
33

44

5-
#define TOP_ZONAS 2
5+
#define TOP_ZONAS 3
66

77
const u8 const casillas_0[];
88
const u16 const blxpri_0[];

res/Zona1/h0.png

3.17 KB
Loading

res/Zona1/h2.png

7.92 KB
Loading

res/zona1.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#ifndef _RES_ZONA1_H_
22
#define _RES_ZONA1_H_
33

4+
extern const TileSet z1h0_t;
45
extern const TileSet z1h1_t;
56
extern const TileSet z1h1b_t;
7+
extern const TileSet z1h2_t;
8+
extern const MapDefinition z1h0;
69
extern const MapDefinition z1h1;
710
extern const MapDefinition z1h1b;
11+
extern const MapDefinition z1h2;
812

913
#endif // _RES_ZONA1_H_

res/zona1.res

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
TILESET z1h0_t "Zona1/h0.png" BEST
2+
MAP z1h0 "Zona1/h0.png" z1h0_t BEST
3+
14
TILESET z1h1_t "Zona1/h1.png" BEST
25
MAP z1h1 "Zona1/h1.png" z1h1_t BEST
36

47
TILESET z1h1b_t "Zona1/h1b.png" BEST
5-
MAP z1h1b "Zona1/h1b.png" z1h1b_t BEST
8+
MAP z1h1b "Zona1/h1b.png" z1h1b_t BEST
9+
10+
TILESET z1h2_t "Zona1/h2.png" BEST
11+
MAP z1h2 "Zona1/h2.png" z1h2_t BEST

src/logos-titulo.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ void TITUTLO(){
143143
VDP_setTextPalette(PAL0);
144144
VDP_setScrollingMode(HSCROLL_PLANE,VSCROLL_PLANE);
145145

146-
XGM_stopPlay();
147-
SYS_doVBlankProcess();//necesita VSync para parar la musica por completo
146+
//XGM_stopPlay();SYS_doVBlankProcess();//necesita VSync para parar la musica por completo
148147

149148

150149
}

src/main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ void main(){
2525
void play_music(u8 indice){
2626
switch(indice){
2727
case 1:XGM_startPlay(M_titulo);break;
28-
case 2:XGM_startPlay(M_zone1);
28+
case 2:XGM_startPlay(M_zone1);break;
29+
default: XGM_stopPlay();
2930
}
3031
}
3132

src/zona1dat.c

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,44 @@
55

66

77
const u8 const casillas_0[] = {
8+
0,7,7,7,7,7,7,0,//0-7
9+
9,1,1,1,1,1,1,0,//8-15
10+
9,1,1,1,1,1,1,0,//16-23
11+
9,1,1,1,1,1,1,1,//24-31
12+
9,1,1,1,1,1,1,0,//32-39
13+
9,1,1,1,1,1,1,0,//40-47
14+
0
15+
//--0,1,2,3,4,5,6,7 = 8
16+
};
17+
18+
const u8 const casillas_1[] = {
819
0,7,7,7,7,7,7,0,//0-7
920
9,1,1,1,1,1,1,0,//8-15
1021
9,1,1,0,0,0,0,0,//16-23
1122
1,1,1,1,1,1,1,1,//24-31
1223
9,1,1,1,1,1,1,0,//32-39
1324
9,1,1,1,1,1,1,0,//40-47
14-
0,0,0,0,0,0,0,0 //48-55
25+
0
1526
//--0,1,2,3,4,5,6,7 = 8
1627
};
1728

29+
const u8 const casillas_2[] = {
30+
0,0,0,0,0,0,0,0,0,0 ,6,3,1,6,6,0,
31+
0,0,0,0,0,0,0,0,0,10,1,1,1,1,1,0,
32+
0,0,0,0,0,0,0,0,0,10,1,1,1,1,1,0,
33+
0,0,0,0,0,0,0,0,0,10,1,1,1,1,1,0,
34+
0,0,0,0,0,0,0,0,0,10,1,1,1,1,1,0,
35+
0,0,0,0,0,0,0,0,0,10,1,1,1,1,1,0,
36+
0,7,7,7,7,7,7,7,7,7 ,1,1,1,1,1,0,
37+
9,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,0,
38+
4,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,0,
39+
1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,
40+
9,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,0,
41+
9,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,0,
42+
0
43+
//--0,1,2,3,4,5,6,7,8,9 ,0,1,2,3,4,5 = 16
44+
};
45+
1846
const u16 const blxpri_0[] = {
1947
159,143,//0,1 puerta
2048
319,159,//2,3 bloque
@@ -25,19 +53,29 @@ const u16 const blxpri_0[] = {
2553

2654
const t_zona zona1dat[TOP_ZONAS] = {
2755
{
28-
TRUE, //PlanA
56+
FALSE, //PlanA
57+
2,//musica
58+
8,//Xtop
59+
casillas_0,//casillas /* 0 = null*/
60+
0,//top_blxpri
61+
0 //blockpri
62+
},
63+
{
64+
TRUE, //PlanA
2965
2, //musica
30-
casillas_0, //casillas
66+
8,//Xtop
67+
casillas_1,//casillas
3168
9, //top_blxpri
3269
blxpri_0 //blockpri
3370

3471
},
3572
{
36-
FALSE, //PlanA
37-
2,//musica
38-
0,//casillas /* 0 = null*/
39-
0,//top_blxpri
40-
0 //blockpri
73+
FALSE, //PlanA
74+
1, //musica
75+
16,//Xtop
76+
casillas_2,//casillas
77+
0, //top_blxpri
78+
0 //blockpri
4179

4280
}
4381
};

src/zone-jugpri.c

Lines changed: 65 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
//---------------Zona 1---------------------------------
99
#include "../inc/zona1dat.h"
1010
#include "../res/zona1.h"//res ficheros
11-
const MapDefinition* const zona1[] = {&z1h1};
11+
const MapDefinition* const zona1[] = {&z1h0,&z1h1,&z1h2};
1212
Map* bgb; //PLANO B (Fondo del nivel Prioridad Baja(*Puertas Altas...))
1313

14-
const MapDefinition* const zona1b[] = {&z1h1b};
14+
const MapDefinition* const zona1b[] = {0,&z1h1b,0};
1515
Map* bga; //PLANO A (Capa superior Prioridad Alta)
1616
//-----------------------------------------------------------
1717

@@ -33,7 +33,6 @@ const s8 STARTYT=-32;
3333
u8 jugcontrol=3;//0=diagonales, 1=UP=UP+>>, 2=UP=UP+<<, 3=0+1
3434

3535
//------------------------------------------------------------------------------------------
36-
bool SPR_ACT;
3736

3837
Sprite* penguinsp; //atributo tipo Sprite
3938
const u8 VELPING=2;
@@ -89,10 +88,8 @@ void ZoneMap(){
8988

9089
SPR_init();
9190

92-
9391
penguinsp=SPR_addSprite(&penguin,160-12,112-26,TILE_ATTR(1,jugpri,0,0));
9492

95-
9693
//pdirc=pdircm=1;//up+>>
9794
pdirc=pdircm=4;//down+>>
9895
//pdirc=pdircm=2;//up+<<
@@ -110,44 +107,63 @@ void ZoneMap(){
110107

111108
jug2diso();
112109

113-
loadzona();pintarAB();
114-
115-
SYS_doVBlankProcess();//fix (60Hrz) pintarAB Se necesita ciclos de procesamiento para pintar Sprites
116-
SPR_update();
117-
118-
SPR_ACT=FALSE;
119-
120-
play_music(zona1dat[0].musica);
121-
122-
PAL_fadeInAll(paleta64,20,TRUE);
110+
ZONA_NUM=0;
111+
old_musica=0;
123112

124113
//SYS_showFrameLoad(TRUE);
125114

126-
bool gat=TRUE;
115+
bool gat;
127116
while(1){//LOOP BASICO(NUNCA SE SALE!)
117+
118+
VDP_drawInt(ZONA_NUM,0,0,26);
119+
VDP_drawInt(zona1dat[ZONA_NUM].Xtop,2,0,27);
120+
121+
loadzona();pintarAB();
128122

129-
jugpenguin();
123+
SYS_doVBlankProcess();//fix (60Hrz) pintarAB Se necesita ciclos de procesamiento para pintar Sprites
124+
SPR_update();
130125

131-
//VDP_drawInt(move_scroll,0,0,26);
132-
if(move_scroll) pintarAB();
126+
if(zona1dat[ZONA_NUM].musica!=old_musica){
127+
old_musica=zona1dat[ZONA_NUM].musica;
128+
play_music(zona1dat[ZONA_NUM].musica);
129+
}
130+
131+
PAL_fadeInAll(paleta64,20,FALSE);
133132

134133

135134

136-
if(!gat){
135+
gat=TRUE;
136+
do{
137137

138-
if(BUTTONS[8]){ gat=TRUE;
139-
jugcontrol++;if(jugcontrol==4)jugcontrol=0;
140-
VDP_drawInt(jugcontrol,0,39,26);
141-
}
138+
jugpenguin();
142139

143-
}else if(!BUTTONS[0]) gat=FALSE;
140+
if(!gat){
141+
142+
if(BUTTONS[8]){ gat=TRUE;
143+
jugcontrol++; if(jugcontrol==4) jugcontrol=0;
144+
145+
}
146+
147+
}else if(!BUTTONS[0]) gat=FALSE;
148+
149+
//VDP_drawInt(move_scroll,0,0,26);
150+
if(move_scroll) pintarAB();
151+
152+
VDP_drawInt(SYS_getCPULoad(),2,38,27);
153+
SYS_doVBlankProcess(); // Renderizamos la pantalla
154+
if(BUTTONS[8] && BUTTONS[5]) SYS_hardReset();
155+
156+
}while(!BUTTONS[7] || gat);
144157

158+
PAL_fadeOutAll(10,FALSE);
145159

146-
VDP_drawInt(SYS_getCPULoad(),2,38,27);
147-
SYS_doVBlankProcess(); // Renderizamos la pantalla
160+
MEM_free(bgb);
161+
if(zona1dat[ZONA_NUM].PlanA){
162+
MEM_free(bga);VDP_clearPlane(BG_A,TRUE);
163+
}
148164

149-
if(BUTTONS[8] && BUTTONS[5]) SYS_hardReset();
150-
165+
ZONA_NUM++;
166+
if(ZONA_NUM==TOP_ZONAS) ZONA_NUM=0;
151167
}
152168
}
153169

@@ -184,7 +200,7 @@ static void pintarAB(){
184200
//VDP_drawInt(posX,3,5,26);VDP_drawInt(posY,3,5,27);
185201
MAP_scrollTo(bgb,posX,posY);
186202

187-
if(zona1dat[0].PlanA) MAP_scrollTo(bga,posX,posY);
203+
if(zona1dat[ZONA_NUM].PlanA) MAP_scrollTo(bga,posX,posY);
188204
move_scroll=FALSE;
189205

190206
u8 i;
@@ -199,11 +215,11 @@ static void pintarAB(){
199215
//VDP_drawInt(-posY,3,0,27);
200216

201217
jugpri=TRUE;
202-
if(zona1dat[0].top_blxpri>0){
218+
if(zona1dat[ZONA_NUM].top_blxpri>0){
203219
posXt=posX+160;posYt=posY+112;//centro de la pantalla
204220
//VDP_drawInt(posXt,3,10,26);VDP_drawInt(posYt,3,10,27);
205-
for(i=0;i<zona1dat[0].top_blxpri;i+=2){
206-
if(posXt+48>zona1dat[0].blockpri[i] && posXt-48<zona1dat[0].blockpri[i] && posYt+48>zona1dat[0].blockpri[i+1] && posYt<=zona1dat[0].blockpri[i+1]){
221+
for(i=0;i<zona1dat[ZONA_NUM].top_blxpri;i+=2){
222+
if(posXt+48>zona1dat[ZONA_NUM].blockpri[i] && posXt-48<zona1dat[ZONA_NUM].blockpri[i] && posYt+48>zona1dat[ZONA_NUM].blockpri[i+1] && posYt<=zona1dat[ZONA_NUM].blockpri[i+1]){
207223
jugpri=FALSE; break;
208224
}
209225
}
@@ -218,19 +234,21 @@ static void pintarAB(){
218234

219235
static void loadzona(){
220236

221-
memcpy(&paleta64[0],zona1[0]->palette->data,16*2);
237+
memcpy(&paleta64[0],zona1[ZONA_NUM]->palette->data,16*2);
222238
paleta64[0]=0;//colro de fondo 100% negro
223239
paleta64[15]=RGB24_TO_VDPCOLOR(0xFFFFFF);//color 15 (texo...) Blanco
224240

225-
u8 ind=0;
226-
VDP_loadTileSet(zona1[0]->tileset,ind,DMA);
227-
bgb=MAP_create(zona1[0],BG_B,ind);
228-
ind+=zona1[0]->tileset->numTile;
229241

230-
if(zona1dat[0].PlanA){
231-
VDP_loadTileSet(zona1b[0]->tileset,ind,DMA);
232-
bga=MAP_create(zona1b[0],BG_A,TILE_ATTR_FULL(0,1,0,0,ind));//PLANO A SIEMPRE PRIORIDAD ALTA!
233-
//ind+=zona1b[0]->tileset->numTile;
242+
VDP_loadTileSet(zona1[ZONA_NUM]->tileset,0,DMA);
243+
bgb=MAP_create(zona1[ZONA_NUM],BG_B,0);
244+
245+
246+
if(zona1dat[ZONA_NUM].PlanA){
247+
u8 ind;
248+
ind=zona1[ZONA_NUM]->tileset->numTile;
249+
VDP_loadTileSet(zona1b[ZONA_NUM]->tileset,ind,DMA);
250+
bga=MAP_create(zona1b[ZONA_NUM],BG_A,TILE_ATTR_FULL(0,1,0,0,ind));//PLANO A SIEMPRE PRIORIDAD ALTA!
251+
//ind+=zona1b[ZONA_NUM]->tileset->numTile;
234252
}
235253

236254
//-------------------------------------------
@@ -314,15 +332,12 @@ static void jugpenguin(){
314332
break;
315333
case 4:{SPR_setAnim(penguinsp,0);pflag=FALSE;}
316334
}
317-
318335
SPR_setHFlip(penguinsp,pflag);
319-
SPR_ACT=TRUE;
320336
}
321337

322338
panim--;
323339
if(panim==0){panim=3;
324340
SPR_nextFrame(penguinsp);
325-
SPR_ACT=TRUE;
326341
}
327342
//---------------------------------------------------------------------
328343

@@ -336,27 +351,27 @@ static void jugpenguin(){
336351
if(PY>0){ PY-=VELPING;
337352
if(PY>15){ PY32--;
338353
//VDP_drawInt(zona1dat[0].casillas[PX32+(PY32*8)],0,2,27);
339-
if(zona1dat[0].casillas[PX32+(PY32*8)]!=1 && PY-(PY32*32)<32) PY=PYC;
354+
if(zona1dat[ZONA_NUM].casillas[PX32+(PY32*zona1dat[ZONA_NUM].Xtop)]!=1 && PY-(PY32*32)<32) PY=PYC;
340355
}
341356
}
342357
break;
343358
case 2:
344359
PY+=VELPING;PY32++;
345360
//VDP_drawInt(zona1dat[0].casillas[PX32+(PY32*8)],0,2,27);
346-
if(zona1dat[0].casillas[PX32+(PY32*8)]!=1 && (PY32*32)-PY<32) PY=PYC;
361+
if(zona1dat[ZONA_NUM].casillas[PX32+(PY32*zona1dat[ZONA_NUM].Xtop)]!=1 && (PY32*32)-PY<32) PY=PYC;
347362
break;
348363
case 3:
349364
if(PX>0){ PX-=VELPING;
350365
if(PX>15){ PX32--;
351366
//VDP_drawInt(zona1dat[0].casillas[PX32+(PY32*8)],0,2,27);
352-
if(zona1dat[0].casillas[PX32+(PY32*8)]!=1 && PX-(PX32*32)<32) PX=PXC;
367+
if(zona1dat[ZONA_NUM].casillas[PX32+(PY32*zona1dat[ZONA_NUM].Xtop)]!=1 && PX-(PX32*32)<32) PX=PXC;
353368
}
354369
}
355370
break;
356371
case 4:
357372
PX+=VELPING;PX32++;
358373
//VDP_drawInt(zona1dat[0].casillas[PX32+(PY32*8)],0,2,27);
359-
if(zona1dat[0].casillas[PX32+(PY32*8)]!=1 && (PX32*32)-PX<32) PX=PXC;
374+
if(zona1dat[ZONA_NUM].casillas[PX32+(PY32*zona1dat[ZONA_NUM].Xtop)]!=1 && (PX32*32)-PX<32) PX=PXC;
360375
}
361376

362377
//VDP_drawInt(PX32,0,10,26);VDP_drawInt(PY32,0,12,26);
@@ -369,7 +384,7 @@ static void jugpenguin(){
369384
move_scroll=TRUE;
370385

371386
}else if(penguinsp->frameInd!=1){
372-
SPR_setFrame(penguinsp,1);SPR_ACT=TRUE;
387+
SPR_setFrame(penguinsp,1);
373388
panim=3;
374389
}
375390

0 commit comments

Comments
 (0)