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/16_enti.h"
\r
25 void EN_initentity(entity_t *enti, video_t *video)
\r
27 unsigned int i,o,o2,w,h;
\r
28 //tx and ty inited by map
\r
29 enti->x = enti->tx*TILEWH;
\r
30 enti->y = enti->ty*TILEWH;
\r
31 enti->triggerx = enti->tx;
\r
32 enti->triggery = enti->ty+1; //south
\r
34 enti->q = 1;//loop var
\r
35 enti->d = 2;//dir var
\r
36 enti->hp = 4;//hit points
\r
37 enti->speed = 4;//walkspeed
\r
38 enti->persist_aniframe = enti->q;
\r
39 enti->spt=(TILEWH/(enti->speed)); //speed per tile wwww
\r
40 enti->pred=enti->d;//previous dir
\r
41 enti->overdraww = 0;
\r
42 enti->overdrawh = 4;
\r
46 // modexClearRegion(&video->page[0], enti->x, enti->y, 16, 16, 2);
\r
47 // modexClearRegion(&video->page[2], 0, 0, video->page[2].sw, video->page[2].sh, 45);
\r
48 // modexClearRegion(&video->page[3], 0, 0, video->page[3].sw, video->page[3].sh, 47);
\r
50 //video->ofs.pattern_ofs=(uint16_t)video->page[0].data;
\r
51 //video->ofs.offscreen_ofs=(uint16_t)video->page[3].data;
\r
52 w = (enti->x + 24) & (~3);
\r
55 // block copy pattern to where we will draw the sprite
\r
56 vga_setup_wm1_block_copy();
\r
57 o2 = video->ofs.offscreen_ofs; //dest
\r
58 o = video->ofs.pattern_ofs + (enti->y * video->page[0].stridew) + (enti->x >> 2); // source
\r
59 for (i=0;i < h;i++,o += video->page[0].stridew,o2 += (w >> 2)) vga_wm1_mem_block_copy(o2,o,w >> 2);
\r
60 // must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally
\r
61 vga_restore_rm0wm0();
\r
64 //modexCopyPageRegion(&video->page[2], &video->page[0], enti->x, enti->y, 0, 0, 24, 32);
\r
69 void EN_initplayer(player_t *player, word pn, video_t *video)
\r
71 EN_initentity(&player[pn].enti, video);
\r
72 player[pn].enti.spri->x = player[0].enti.x-4;
\r
73 player[pn].enti.spri->y = player[0].enti.y-16;
\r
74 player[pn].walktype=0;
\r
75 player[pn].enti.dire=30;
\r
77 video->sprifilei = set_anim_by_id(player[pn].enti.spri, player[pn].enti.dire);
\r
78 animate_spri(&player[pn].enti, video);
\r
80 //run to fully init sprite
\r
81 //modexCopyPageRegion(&video->page[0], &video->page[1], 0, player[pn].enti.y, 0, player[pn].enti.y, video->page[0].width, 40);
\r
82 modexCopyPageRegion(&video->page[0], &video->page[1], 0, 0, 0, 0, video->page[0].width, video->page[0].height);
\r
83 animate_spri(&player[pn].enti, video);
\r
86 //print_anim_ids(player[0].enti.spri);
\r
87 /* player[0].info.x = player[0].tx;
\r
88 player[0].info.xaxis = player[0].tx*TILEWH;
\r
89 player[0].info.y = player[0].ty;
\r
90 player[0].info.yaxis = player[0].ty*TILEWH;*/
\r