]> 4ch.mooo.com Git - 16.git/blob - src/lib/16_enti.c
inconsistancy with wmake on 1.9 and 2.0 on both linux and dos is giving me issues...
[16.git] / src / lib / 16_enti.c
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2019 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;//loop var\r
35         enti->d =               2;//dir var\r
36         enti->pred =    4;//previous dir\r
37         enti->hp =              4;//hit points\r
38         enti->spt =     4;//walkspeed\r
39         enti->persist_aniframe = enti->q;\r
40         enti->spt=(TILEWH/(enti->spt)); //speed per tile wwww\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->vga_state.bgps){\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
53                 h = enti->y + 32;\r
54 \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
62         }//else{\r
63                 //w=h=o=i=o2=0;\r
64                 //modexCopyPageRegion(&video->page[2], &video->page[0], enti->x, enti->y, 0, 0, 24, 32);\r
65         //}\r
66 }\r
67 \r
68 //init player!\r
69 void EN_initPlayer(player_t *player, video_t *video)\r
70 {\r
71         EN_initentity(&player->enti, video);\r
72         player->enti.spri.x = player[0].enti.x-4;\r
73         player->enti.spri.y = player[0].enti.y-16;\r
74         player->walktype=0;\r
75         player->enti.dire=30;\r
76         vga_state.vga_draw_stride_limit = vga_state.vga_draw_stride = video->page[0].stridew;//skewing bug\r
77 \r
78         video->sprifilei =      set_anim_by_id(&player->enti.spri, player->enti.dire);\r
79         animate_spri(&player->enti, video);\r
80 \r
81         //print_anim_ids(player[0].enti.spri);\r
82 /*      player[0].info.x = player[0].tx;\r
83         player[0].info.xaxis = player[0].tx*TILEWH;\r
84         player[0].info.y = player[0].ty;\r
85         player[0].info.yaxis = player[0].ty*TILEWH;*/\r
86 }\r