OSDN Git Service

bg preservation still in works
[proj16/16.git] / src / lib / 16_enti.c
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
3  *\r
4  * This file is part of Project 16.\r
5  *\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
10  *\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
15  *\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
20  *\r
21  */\r
22 \r
23 #include "src/lib/16_enti.h"\r
24 \r
25 void EN_initentity(entity_t *enti, video_t *video)\r
26 {\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
33 \r
34         enti->q = 1;\r
35         enti->d =2;\r
36         enti->hp=4;\r
37         enti->speed=4;\r
38         enti->persist_aniframe = enti->q;\r
39         enti->spt=(TILEWH/(enti->speed));       //speed per tile wwww\r
40         enti->pred = enti->d;\r
41         enti->overdraww=0;\r
42         enti->overdrawh=4;\r
43 \r
44         VL_Initofs(video);\r
45 \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
49         if(!video->bgps)\r
50         {\r
51                 //video->ofs.pattern_ofs=(uint16_t)video->page[0].data;\r
52                 //video->ofs.offscreen_ofs=(uint16_t)video->page[3].data;\r
53                 w = (enti->x + 24) & (~3);\r
54                 h = enti->y + 32;\r
55 \r
56                 // block copy pattern to where we will draw the sprite\r
57                 vga_setup_wm1_block_copy();\r
58                 o2 = video->ofs.offscreen_ofs;                                                                          //dest\r
59                 o = video->ofs.pattern_ofs + (enti->y * video->page[0].stridew) + (enti->x >> 2);       // source\r
60                 for (i=0;i < h;i++,o += video->page[0].stridew,o2 += (w >> 2)) vga_wm1_mem_block_copy(o2,o,w >> 2);\r
61                 // must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally\r
62                 vga_restore_rm0wm0();\r
63         }else{\r
64                 w=h=o=i=o2=0;\r
65                 modexCopyPageRegion(&video->page[2], &video->page[0], enti->x, enti->y, 0, 0, 24, 32);\r
66         }\r
67 }\r
68 \r
69 //init player!\r
70 void EN_initplayer(player_t *player, word pn, video_t *video)\r
71 {\r
72         EN_initentity(&player[pn].enti, video);\r
73 /*      player[0].info.x = player[0].tx;\r
74         player[0].info.xaxis = player[0].tx*TILEWH;\r
75         player[0].info.y = player[0].ty;\r
76         player[0].info.yaxis = player[0].ty*TILEWH;*/\r
77 }\r