1 /* Project 16 Source Code~
\r
2 * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover
\r
4 * This file is part of Project 16.
\r
6 * Project 16 is free software; you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation; either version 3 of the License, or
\r
9 * (at your option) any later version.
\r
11 * Project 16 is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with this program. If not, see <http://www.gnu.org/licenses/>, or
\r
18 * write to the Free Software Foundation, Inc., 51 Franklin Street,
\r
19 * Fifth Floor, Boston, MA 02110-1301 USA.
\r
23 #include "src/lib/scroll16.h"
\r
24 #include "src/lib/16_timer.h"
\r
25 #include "src/lib/16_dbg.h"
\r
28 #define MODEX //this is for mode x initiating
\r
34 boolean panswitch=0;//1
\r
35 //extern boolean pageflipflop=1;
\r
36 extern boolean pagenorendermap;
\r
39 static word paloffset=0;
\r
40 byte *gvar.video.dpal;
\r
45 void main(int argc, char *argv[])
\r
47 static global_game_variables_t gvar;
\r
48 if(argv[1]) bakapee = atoi(argv[1]);
\r
53 /* create the map */
\r
54 // fprintf(stderr, "testing map load~ ");
\r
55 CA_loadmap("data/test.map", &map, &gvar);
\r
57 // printf("chkmap ok ");
\r
58 // fprintf(stderr, "yay map loaded~~\n");
\r
60 /* draw the tiles */
\r
63 // mappalptr = map.tiles->btdata->palette;
\r
66 PCXBMP = bitmapLoadPcx("data/chikyuu.pcx", &gvar); // load sprite
\r
70 IN_Default(0, &gvar.gvar.player[0],ctrl_Keyboard1);
\r
72 /* save the palette */
\r
75 gvar.video.dpal = modexNewPal();
\r
76 modexPalSave(gvar.video.dpal);
\r
77 modexFadeOff(4, gvar.video.dpal);
\r
80 VGAmodeX(bakapee, 1, &gvar);
\r
82 /* fix up the palette and everything */
\r
84 modexPalBlack(); //reset the palette~
\r
87 //++++ PCXBMPVAR.offset=(paloffset/3);
\r
88 //++++ modexPalUpdate(&PCXBMPVAR, &paloffset, 0, 0);
\r
89 modexPalUpdate(&PCXBMP->palette);
\r
90 //++++0000 modexPalUpdate(map.tiles->btdata->palette);
\r
91 //printf(" %d\n", sizeof(ptmp->data));
\r
92 //printf("1: %d\n", paloffset);
\r
93 //++++ map.tiles->data->offset=(paloffset/3);
\r
94 //XTmodexPalUpdate(map.tiles->data, &paloffset, 0, 0);
\r
95 // printf("\n====\n");
\r
96 // printf("0 paloffset= %d\n", paloffset/3);
\r
97 // printf("====\n\n");
\r
100 &gvar.video.palette = modexNewPal();
\r
101 modexPalSave(&gvar.video.palette);
\r
102 modexSavePalFile("data/g.pal", &gvar.video.palette);
\r
103 modexPalBlack(); //so gvar.player will not see loadings~
\r
107 /* setup camera and screen~ */
\r
108 modexHiganbanaPageSetup(&gvar.video);
\r
109 ZC_MVSetup(&gvar.mv, &map, &gvar);
\r
114 /* set up paging */
\r
115 //TODO: LOAD map data and position the map in the middle of the screen if smaller then screen
\r
116 mapGoTo(&gvar.mv, 0, 0);
\r
118 ZC_gvar.playerXYpos(0, 0, &gvar.player, &gvar.mv, 0, 1);
\r
119 EN_initgvar.player(&gvar.player, 0, &gvar.video);
\r
120 if (gvar.video.sprifilei == -1)
\r
123 modexFadeOff(4, &gvar.video.palette);
\r
125 Quit(&gvar, "Wrong");
\r
127 modexFadeOn(4, gvar.video.dpal);
\r
132 modexClearRegion(gvar.mv[0].page, gvar.player[0].enti.x, gvar.player[0].enti.y-TILEWH, 16, 32, 15);
\r
134 modexDrawSpriteRegion(&gvar.video.page[0], gvar.player[0].enti.x, gvar.player[0].enti.y-TILEWH, 16, 64, 16, 32, PCXBMPPTR);
\r
137 //if(!pageflipflop)
\r
138 VL_ShowPage(gvar.mv[1].page, 0, 0);//modexShowPage(gvar.mv[1].page);
\r
139 //else ZC_ShowMV(&gvar.mv, 0, 0);//modexShowPage(gvar.mv[0].page);//!(gvar.video.p)
\r
141 //modexDrawBmp(&gvar.video.page[0], 16, 16, PCXBMPPTR);
\r
143 // modexClearRegion(gvar.mv[2].page, 0, 0, gvar.mv[2].page->width, gvar.mv[2].page->height, 47);
\r
144 // modexClearRegion(gvar.mv[3].page, 0, 0, gvar.mv[3].page->width, gvar.mv[3].page->height, 45);
\r
146 // unsigned int k,j,o;
\r
147 // /* fill screen with a distinctive pattern */
\r
148 // for (k=0;k < vga_state.vga_width;k++) {
\r
150 // vga_write_sequencer(0x02/*map mask*/,1 << (k&3));
\r
151 // for (j=0;j < vga_state.vga_height;j++,o += vga_state.vga_stride)
\r
152 // vga_state.vga_graphics_ram[o] = (k^j)&15; // VRL samples put all colors in first 15!
\r
155 modexClearRegion(gvar.mv[3].page, 0, 128, 24, 36, 15);
\r
159 modexFadeOn(4, &gvar.video.palette);
\r
162 while(!IN_KeyDown(sc_Escape) && gvar.player[0].enti.hp>0)
\r
165 //top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square
\r
166 //to stop scrolling and have the gvar.player position data move to the edge of the screen with respect to the direction
\r
167 //when gvar.player[0].enti.tx or gvar.player[0].enti.ty == 0 or gvar.player[0].enti.tx == 20 or gvar.player[0].enti.ty == 15 then stop because that is edge of map and you do not want to walk of the map
\r
169 //gvar.player movement
\r
170 IN_ReadControl(0, &gvar.player);
\r
172 ZC_walk(&gvar.mv, &gvar.player, 0);
\r
174 PANKEYFUNZC;//panPageManual(&gvar.mv, &gvar.player, 0);
\r
175 //printf(" gvar.player[0].enti.q: %d", gvar.player[0].enti.q); printf(" gvar.player[0].d: %d\n", gvar.player[0].d);
\r
178 //the scripting stuff....
\r
179 //if(((gvar.player[0].enti.triggerx == TRIGGX && gvar.player[0].enti.triggery == TRIGGY) && IN_KeyDown(0x1C))||(gvar.player[0].enti.tx == 5 && gvar.player[0].enti.ty == 5))
\r
180 if(((gvar.mv[0].map->layerdata[0].data[(gvar.player[0].enti.triggerx-1)+(map.width*(gvar.player[0].enti.triggery-1))] == 0) && IN_KeyDown(0x1C))||(gvar.player[0].enti.tx == 5 && gvar.player[0].enti.ty == 5))
\r
183 for(i=800; i>=400; i--)
\r
189 if(gvar.player[0].enti.q == (TILEWH/(gvar.player[0].enti.speed))+1 && gvar.player[0].info.dir != 2 && (gvar.player[0].enti.triggerx == 5 && gvar.player[0].enti.triggery == 5)){ gvar.player[0].enti.hp--; }
\r
193 if(IN_KeyDown(24)){ modexPalUpdate0(&gvar.video.palette); paloffset=0; modexpdump(gvar.mv[0].page); modexpdump(gvar.mv[1].page); IN_UserInput(1); } //p
\r
194 /*if(IN_KeyDown(22)){
\r
195 paloffset=0; modexPalBlack(); modexPalUpdate(PCXBMPVAR, &paloffset, 0, 0);
\r
196 printf("1paloffset = %d\n", paloffset/3);
\r
197 modexPalUpdate(map.tiles->data, &paloffset, 0, 0);
\r
198 printf("2paloffset = %d\n", paloffset/3);
\r
199 modexpdump(gvar.mv[0].page); modexpdump(gvar.mv[1].page);
\r
205 if(IN_KeyDown(62)) //f3
\r
207 modexClearRegion(gvar.mv[1].page, 0, 0, gvar.mv[1].page->width, gvar.mv[1].page->height, 2);
\r
208 modexClearRegion(gvar.mv[2].page, 0, 0, gvar.mv[2].page->width, gvar.mv[2].page->height, 3);
\r
209 modexClearRegion(gvar.mv[3].page, 0, 0, gvar.mv[3].page->width, gvar.mv[3].page->height, 4);
\r
210 modexClearRegion(gvar.mv[3].page, 0, 0, 20, 36, 15);
\r
214 FUNCTIONKEYFUNCTIONS
\r
215 FUNCTIONKEYDRAWJUNK
\r
216 if(IN_KeyDown(sc_L)){ modexClearRegion(&gvar.video.page[0], gvar.player[0].enti.x, gvar.player[0].enti.y, 16, 16, 1); }
\r
220 if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate(gvar.video.dpal); IN_UserInput(1); }
\r
222 if(IN_KeyDown(sc_R)){ modexPalOverscan(rand()%56); } //r
\r
224 if((gvar.player[0].enti.q==1) && !(gvar.player[0].enti.x%TILEWH==0 && gvar.player[0].enti.y%TILEWH==0)) break; //incase things go out of sync!
\r
227 /* fade back to text mode */
\r
228 /* but 1st lets save the game palette~ */
\r
231 modexPalSave(&gvar.video.palette);
\r
232 modexSavePalFile("data/g.pal", &gvar.video.palette);
\r
233 modexFadeOff(4, &gvar.video.palette);
\r
235 VGAmodeX(0, 1, &gvar);
\r
238 printf("\nProject 16 scroll.exe. This is just a test file!\n");
\r
239 printf("version %s\n", VERSION);
\r
244 modexFadeOn(4, gvar.video.dpal);
\r