From: sparky4 Date: Mon, 24 Nov 2014 18:27:09 +0000 (-0600) Subject: modified: Project 16.bfproject X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=fef81dd6303c46812f27d4378e0af7c11e2073a8;p=16.git modified: Project 16.bfproject modified: README new file: SCROLL.SMP modified: doc/project.txt modified: makefile modified: modex16.c modified: pcxtest.exe modified: scroll.c modified: scroll.exe modified: test.exe modified: test2.exe --- diff --git a/Project 16.bfproject b/Project 16.bfproject index 39b70fd3..ce4249a0 100644 --- a/Project 16.bfproject +++ b/Project 16.bfproject @@ -1,13 +1,15 @@ c2e.convert_special: 0 e2c.convert_num: 0 -openfiles: /dos/z/16/doc/project.txt:102:0:0: -openfiles: /dos/z/16/scroll.c:12437:11784:1: -openfiles: /dos/z/16/modex16.c:9475:0:0: -openfiles: /dos/z/16/modex16.h:1512:344:0: -openfiles: /dos/z/16/pcxtest.c:1339:442:0: -openfiles: /dos/z/16/dos_kb.c:3759:2934:0: +openfiles: /dos/z/16/doc/project.txt:60:0:0: +openfiles: /dos/z/16/scroll.c:4879:4341:1: +openfiles: /dos/z/16/modex16.c:6319:6141:0: +openfiles: /dos/z/16/modex16.h:1057:344:0: +openfiles: /dos/z/16/pcxtest.c:795:442:0: +openfiles: /dos/z/16/dos_kb.c:3759:2467:0: openfiles: /dos/z/16/dos_kb.h:464:0:0: -openfiles: /dos/z/16/lib/lib_head.h:2319:1512:0: +openfiles: /dos/z/16/lib/lib_head.h:1738:1885:0: +openfiles: /dos/z/16/README:668:0:0: +openfiles: /dos/z/16/makefile:181:123:0: snr_recursion_level: 0 convertcolumn_horizontally: 0 adv_open_matchname: 0 @@ -19,19 +21,14 @@ view_left_panel: 0 default_mime_type: text/plain e2c.convert_xml: 1 c2e.convert_iso: 0 -opendir: file:///dos/z/16/lib +opendir: file:///dos/z/16 wrap_text_default: 0 bookmarks_filename_mode: 1 -ssearch_text: inc_ +ssearch_text: enter snr_casesens: 1 view_blocks: 1 name: project 16 -replacelist: screen2=modexNextPage(mv.page); -replacelist: spri->page=draw->page; -replacelist: mv -replacelist: src replacelist: mv->page, src->page, -replacelist: modexShowPage(spri replacelist: modexShowPage(draw replacelist: wPage(spri replacelist: 34); @@ -41,6 +38,11 @@ replacelist: animatePlayer(bg, spri, replacelist: qi=1 replacelist: qi<=( replacelist: \t\t\t\t +replacelist: animatePlayer(bg, spri, mask, 1 +replacelist: animatePlayer(bg, spri, mask, 0 +replacelist: modexShowPage(mask-> +replacelist: modexShowPage(spri +replacelist: player.tx == player.ty fb_show_hidden_f: 0 editor_tab_width: 4 show_visible_spacing: 1 @@ -54,8 +56,6 @@ ssearch_regex: 0 e2c.convert_iso: 0 ssearch_casesens: 0 charmap_block: 1 -recent_files: file:///dos/z/16/16/lib/x/MXCR.ASM -recent_files: file:///dos/z/4x4_16/modex/DEMO07.PAS recent_files: file:///dos/z/16/16/scrasm/MAIN.ASM recent_files: file:///dos/z/16/16/lib/x/MXBB.ASM recent_files: file:///dos/z/16/src/lib/dos_gfx.h @@ -104,6 +104,8 @@ recent_files: file:///dos/z/16/modex16.h recent_files: file:///dos/z/16/pcxtest.c recent_files: file:///dos/z/16/modex16.c recent_files: file:///dos/z/16/scroll.c +recent_files: file:///dos/z/16/README +recent_files: file:///dos/z/16/makefile snr_replacetype: 0 savedir: file:///dos/z/16 spell_check_default: 1 @@ -115,21 +117,21 @@ snr_escape_chars: 0 htmlbar_view: 0 spell_lang: en ssearch_dotmatchall: 0 +searchlist: modexShowPage(-> +searchlist: modexShowPage(m-> +searchlist: modexShowPage(ma-> +searchlist: modexShowPage(mas-> +searchlist: modexShowPage(mask-> +searchlist: ptr +searchlist: modexShowPage(mask +searchlist: mask +searchlist: draw +searchlist: modexDrawBmp +searchlist: mapDrawTile searchlist: draw -searchlist: 34) -searchlist: 0x3DA -searchlist: waitb -searchlist: mv -searchlist: animatePlayer(spri, bg, -searchlist: clearpl -searchlist: modexDrawSpriteRegion -searchlist: bg -searchlist: )*- -searchlist: qi=0 -searchlist: qi<( -searchlist: -searchlist: )*2 -searchlist: inc_ +searchlist: return +searchlist: enter +searchlist: bg->tx == bg->ty autocomplete: 1 outputb_show_all_output: 0 bookmarks_show_mode: 0 diff --git a/README b/README index 09a70158..9ba2ecad 100644 --- a/README +++ b/README @@ -16,7 +16,10 @@ DONE 5. sprite rendering 10. map and item interation 11. item inventory~ 12. Memory management (EMS + XMS) -13. case switch with keyboard code (when your holding 2 arrow keys and a key is released the keyboard controller dose not read input from the port anymore for some weired reason) +13. case switch with keyboard code (when your holding 2 arrow keys and a key is released the keyboard controller dose not read input from the port anymore for some weired reason) +14. masking layer! +15. 8088 detection to turn off vsync! +16. (very important!) optimize modexDrawBmpRegion so it can draw the bloody tiles and continue moving or make sure that you can move and draw the tiles at the same time To compile: You need Open Watcom stable to compile and just run wmake diff --git a/SCROLL.SMP b/SCROLL.SMP new file mode 100644 index 00000000..398f5786 Binary files /dev/null and b/SCROLL.SMP differ diff --git a/doc/project.txt b/doc/project.txt index 30b2ce87..9e64fcf0 100644 --- a/doc/project.txt +++ b/doc/project.txt @@ -1,4 +1,4 @@ Project 16 - 01 話の地球 //Story of Chikyuu + 彼岸花 Project 01 話の地球 //Higanbana Project 01: Story of Chikyuu to make an epic as fuck 2d 16bit DOS game 22 source files \ No newline at end of file diff --git a/makefile b/makefile index b11f89a0..50899315 100644 --- a/makefile +++ b/makefile @@ -1,4 +1,4 @@ -FLAGS=-0 +FLAGS=-0 -d2 all: test.exe pcxtest.exe test2.exe scroll.exe scroll.exe: scroll.obj modex16.obj dos_kb.obj bitmap.obj diff --git a/modex16.c b/modex16.c index 8828d9ec..aadbe523 100644 --- a/modex16.c +++ b/modex16.c @@ -236,7 +236,8 @@ modexDrawBmpRegion(page_t *page, int x, int y, word nextBmpRow = (word) bmp->width - width; word rowCounter; byte planeCounter = 4; - + + //code is a bit slow here __asm { MOV AX, SCREEN_SEG ; go to the VGA memory MOV ES, AX diff --git a/pcxtest.exe b/pcxtest.exe index de765ece..e2f80531 100644 Binary files a/pcxtest.exe and b/pcxtest.exe differ diff --git a/scroll.c b/scroll.c index 30b4b114..873c54b5 100644 --- a/scroll.c +++ b/scroll.c @@ -37,6 +37,8 @@ struct { int y; //player exact position on the viewable map int tx; //player tile position on the viewable map int ty; //player tile position on the viewable map + int triggerx; //player's trigger box tile position on the viewable map + int triggery; //player's trigger box tile position on the viewable map int hp; //hitpoints of the player } player; @@ -51,7 +53,7 @@ void mapGoTo(map_view_t *mv, int tx, int ty); void mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y); void mapDrawRow(map_view_t *mv, int tx, int ty, word y); void mapDrawCol(map_view_t *mv, int tx, int ty, word x); -void animatePlayer(map_view_t *src, map_view_t *dest, short d1, short d2, int x, int y, int ls, int lp, bitmap_t *bmp); +void animatePlayer(map_view_t *src, map_view_t *dest, /*map_view_t *top, */short d1, short d2, int x, int y, int ls, int lp, bitmap_t *bmp); #define TILEWH 16 #define QUADWH (TILEWH/4) @@ -60,15 +62,15 @@ void animatePlayer(map_view_t *src, map_view_t *dest, short d1, short d2, int x, //place holder definitions #define MAPX 40 #define MAPY 30 -#define SWAP(a, b) tmp=a; a=b; b=tmp; +//#define SWAP(a, b) tmp=a; a=b; b=tmp; void main() { bitmap_t ptmp; // player sprite int q=1; static int persist_aniframe = 0; /* gonna be increased to 1 before being used, so 0 is ok for default */ - page_t screen, screen2; + page_t screen, screen2, screen3; map_t map; - map_view_t mv, mv2; - map_view_t *bg, *spri, *tmp; + map_view_t mv, mv2, mv3; + map_view_t *bg, *spri, *mask;//, *tmp; byte *ptr; setkb(1); @@ -77,6 +79,7 @@ void main() { initMap(&map); mv.map = ↦ mv2.map = ↦ + mv3.map = ↦ /* draw the tiles */ ptr = map.data; @@ -85,18 +88,22 @@ void main() { modexPalUpdate(ptmp.palette); screen = modexDefaultPage(); screen.width += (TILEWH*2); - screen.height += (TILEWH*2); + screen.height += ((TILEWH*2)+QUADWH); mv.page = &screen; screen2 = modexNextPage(mv.page); mv2.page = &screen2; + screen3 = screen2; + mv3.page = &screen3; /* set up paging */ bg = &mv; spri = &mv2; + mask = &mv3; //TODO: LOAD map data and position the map in the middle of the screen if smaller then screen mapGoTo(bg, 0, 0); mapGoTo(spri, 0, 0); + //mapGoTo(mask, 0, 0); //TODO: put player in starting position of spot //default player position on the viewable map @@ -107,34 +114,68 @@ void main() { modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 64, 24, 32, &ptmp); modexCopyPageRegion(bg->page, spri->page, player.x-4, player.y-TILEWH, player.x-4, player.y-TILEWH, 24, 32); modexShowPage(bg->page); - while(!keyp(1)) + while(!keyp(1))//!keyp(1)) { //top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square //to stop scrolling and have the player position data move to the edge of the screen with respect to the direction //when player.tx or player.ty == 0 or player.tx == 20 or player.ty == 15 then stop because that is edge of map and you do not want to walk of the map - #define INC_PER_FRAME if(q&1) persist_aniframe++; if(persist_aniframe>4) persist_aniframe = 1; + #define INC_PER_FRAME if(q&1) persist_aniframe++; if(persist_aniframe>4) persist_aniframe = 1; + //temp testing + /*if(bg->tx >= 0 && bg->tx+20 < MAPX && player.tx == bg->tx + 10) + { + for(q=1; q<=(TILEWH/SPEED); q++) + { + //INC_PER_FRAME; + //animatePlayer(bg, spri, mask, 1, 1, player.x, player.y, persist_aniframe, q, &ptmp); + //animatePlayer(bg, spri, 1, 1, player.x, player.y, persist_aniframe, q, &ptmp); + mapScrollRight(bg, SPEED); + //mapScrollRight(spri, SPEED); + //mapScrollRight(mask, SPEED); + modexShowPage(bg->page); + } + player.tx++; + } + else if(player.tx < MAPX) + { + for(q=1; q<=(TILEWH/SPEED); q++) + { + INC_PER_FRAME; + player.x+=SPEED; + //animatePlayer(bg, spri, mask, 1, 0, player.x, player.y, persist_aniframe, q, &ptmp); + animatePlayer(bg, spri, 1, 0, player.x, player.y, persist_aniframe, q, &ptmp); + modexShowPage(spri->page); + } + player.tx++; + } + else + { +break; + }*/ if(keyp(77) && !keyp(75)) { - if(bg->tx >= 0 && bg->tx+20 < MAPX && player.tx == bg->tx + 10) + if(bg->tx >= 0 && bg->tx+20 < MAPX && player.tx == bg->tx + 10 && !(player.tx+1 == 2 && player.ty == 2)) { for(q=1; q<=(TILEWH/SPEED); q++) { INC_PER_FRAME; + //animatePlayer(bg, spri, mask, 1, 1, player.x, player.y, persist_aniframe, q, &ptmp); animatePlayer(bg, spri, 1, 1, player.x, player.y, persist_aniframe, q, &ptmp); mapScrollRight(bg, SPEED); mapScrollRight(spri, SPEED); + //mapScrollRight(mask, SPEED); modexShowPage(spri->page); } player.tx++; } - else if(player.tx < MAPX) + else if(player.tx < MAPX && !(player.tx+1 == 2 && player.ty == 2)) { for(q=1; q<=(TILEWH/SPEED); q++) { INC_PER_FRAME; player.x+=SPEED; + //animatePlayer(bg, spri, mask, 1, 0, player.x, player.y, persist_aniframe, q, &ptmp); animatePlayer(bg, spri, 1, 0, player.x, player.y, persist_aniframe, q, &ptmp); modexShowPage(spri->page); } @@ -146,28 +187,33 @@ void main() { modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 32, 24, 32, &ptmp); modexShowPage(spri->page); } + player.triggerx = player.tx+1; + player.triggery = player.ty; } if(keyp(75) && !keyp(77)) { - if(bg->tx > 0 && bg->tx+20 <= MAPX && player.tx == bg->tx + 10) + if(bg->tx > 0 && bg->tx+20 <= MAPX && player.tx == bg->tx + 10 && !(player.tx-1 == 2 && player.ty == 2)) { for(q=1; q<=(TILEWH/SPEED); q++) { INC_PER_FRAME; + //animatePlayer(bg, spri, mask, 3, 1, player.x, player.y, persist_aniframe, q, &ptmp); animatePlayer(bg, spri, 3, 1, player.x, player.y, persist_aniframe, q, &ptmp); mapScrollLeft(bg, SPEED); mapScrollLeft(spri, SPEED); + //mapScrollLeft(mask, SPEED); modexShowPage(spri->page); } player.tx--; } - else if(player.tx > 1) + else if(player.tx > 1 && !(player.tx-1 == 2 && player.ty == 2)) { for(q=1; q<=(TILEWH/SPEED); q++) { INC_PER_FRAME; player.x-=SPEED; + //animatePlayer(bg, spri, mask, 3, 0, player.x, player.y, persist_aniframe, q, &ptmp); animatePlayer(bg, spri, 3, 0, player.x, player.y, persist_aniframe, q, &ptmp); modexShowPage(spri->page); } @@ -179,28 +225,33 @@ void main() { modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 96, 24, 32, &ptmp); modexShowPage(spri->page); } + player.triggerx = player.tx-1; + player.triggery = player.ty; } if(keyp(80) && !keyp(72)) { - if(bg->ty >= 0 && bg->ty+15 < MAPY && player.ty == bg->ty + 8) + if(bg->ty >= 0 && bg->ty+15 < MAPY && player.ty == bg->ty + 8 && !(player.tx == 2 && player.ty+1 == 2)) { for(q=1; q<=(TILEWH/SPEED); q++) { INC_PER_FRAME; + //animatePlayer(bg, spri, mask, 2, 1, player.x, player.y, persist_aniframe, q, &ptmp); animatePlayer(bg, spri, 2, 1, player.x, player.y, persist_aniframe, q, &ptmp); mapScrollDown(bg, SPEED); mapScrollDown(spri, SPEED); + //mapScrollDown(mask, SPEED); modexShowPage(spri->page); } player.ty++; } - else if(player.ty < MAPY) + else if(player.ty < MAPY && !(player.tx == 2 && player.ty+1 == 2)) { for(q=1; q<=(TILEWH/SPEED); q++) { INC_PER_FRAME; player.y+=SPEED; + //animatePlayer(bg, spri, mask, 2, 0, player.x, player.y, persist_aniframe, q, &ptmp); animatePlayer(bg, spri, 2, 0, player.x, player.y, persist_aniframe, q, &ptmp); modexShowPage(spri->page); } @@ -212,30 +263,35 @@ void main() { modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 64, 24, 32, &ptmp); modexShowPage(spri->page); } + player.triggerx = player.tx; + player.triggery = player.ty+1; } if(keyp(72) && !keyp(80)) { - if(bg->ty > 0 && bg->ty+15 <= MAPY && player.ty == bg->ty + 8) + if(bg->ty > 0 && bg->ty+15 <= MAPY && player.ty == bg->ty + 8 && !(player.tx == 2 && player.ty-1 == 2)) { for(q=1; q<=(TILEWH/SPEED); q++) { INC_PER_FRAME; + //animatePlayer(bg, spri, mask, 0, 1, player.x, player.y, persist_aniframe, q, &ptmp); animatePlayer(bg, spri, 0, 1, player.x, player.y, persist_aniframe, q, &ptmp); mapScrollUp(bg, SPEED); mapScrollUp(spri, SPEED); + //mapScrollUp(mask, SPEED); modexShowPage(spri->page); } player.ty--; } - else if(player.ty > 1) + else if(player.ty > 1 && !(player.tx == 2 && player.ty-1 == 2)) { for(q=1; q<=(TILEWH/SPEED); q++) { INC_PER_FRAME; player.y-=SPEED; - animatePlayer(bg, spri, 0, 0, player.x, player.y, persist_aniframe, q, &ptmp); + //animatePlayer(bg, spri, mask, 0, 0, player.x, player.y, persist_aniframe, q, &ptmp); modexShowPage(spri->page); + animatePlayer(bg, spri, 0, 0, player.x, player.y, persist_aniframe, q, &ptmp); } player.ty--; } @@ -245,8 +301,19 @@ void main() { modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 0, 24, 32, &ptmp); modexShowPage(spri->page); } + player.triggerx = player.tx; + player.triggery = player.ty-1; + } + //modexClearRegion(mask->page, 66, 66, 2, 40, 0); + if((player.triggerx == 2 && player.triggery == 2) && keyp(KEY_ENTER)) + { + short i; + for(i=600; i>=400; i--) + { + sound(i); + } + nosound(); } - } modexLeave(); @@ -258,6 +325,8 @@ void main() { printf("player.y: %d\n", player.y); printf("player.tx: %d\n", player.tx); printf("player.ty: %d\n", player.ty); + printf("player.triggx: %d\n", player.triggerx); + printf("player.triggy: %d\n", player.triggery); } @@ -479,7 +548,7 @@ mapDrawCol(map_view_t *mv, int tx, int ty, word x) { } void -animatePlayer(map_view_t *src, map_view_t *dest, short d1, short d2, int x, int y, int ls, int lp, bitmap_t *bmp) +animatePlayer(map_view_t *src, map_view_t *dest, /*map_view_t *top, */short d1, short d2, int x, int y, int ls, int lp, bitmap_t *bmp) { short dire=32*d1; short qq; @@ -509,12 +578,14 @@ animatePlayer(map_view_t *src, map_view_t *dest, short d1, short d2, int x, int y=y-TILEWH; break; } - //TODO: make flexible animation thingy modexCopyPageRegion(dest->page, src->page, x-4, y-4, x-4, y-4, 28, 40); if(2>ls && ls>=1) { modexDrawSpriteRegion(dest->page, x, y, 48, dire, 24, 32, bmp); }else if(3>ls && ls>=2) { modexDrawSpriteRegion(dest->page, x, y, 24, dire, 24, 32, bmp); }else if(4>ls && ls>=3) { modexDrawSpriteRegion(dest->page, x, y, 0, dire, 24, 32, bmp); }else if(5>ls && ls>=4) { modexDrawSpriteRegion(dest->page, x, y, 24, dire, 24, 32, bmp); } + //TODO: mask copy //modexCopyPageRegion(dest->page, src->page, x-4, y-4, x-4, y-4, 28, 40); + //modexClearRegion(top->page, 66, 66, 2, 40, 0); + //modexCopyPageRegion(dest->page, top->page, 66, 66, 66, 66, 2, 40); //turn this off if XT modexWaitBorder(); } diff --git a/scroll.exe b/scroll.exe index e8064a50..33f0ed4b 100644 Binary files a/scroll.exe and b/scroll.exe differ diff --git a/test.exe b/test.exe index 99404b1a..640194bc 100644 Binary files a/test.exe and b/test.exe differ diff --git a/test2.exe b/test2.exe index 2b870eff..731dd1c6 100644 Binary files a/test2.exe and b/test2.exe differ