From: yakui-lover Date: Fri, 25 Nov 2016 17:54:22 +0000 (+0900) Subject: See WHAT_WAS_CHANGED for details X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=c8dd189c61a9d0e0ef34224be609f1c8f590be7c;p=16.git See WHAT_WAS_CHANGED for details --- diff --git a/WHAT_WAS_CHANGED b/WHAT_WAS_CHANGED new file mode 100644 index 00000000..b081de53 --- /dev/null +++ b/WHAT_WAS_CHANGED @@ -0,0 +1,10 @@ +Please, refer for the actual diff for the commit the file was introoduced. + +Basically, I was aiming to: +1. Rewrite scroll16 to use only one player, instead of 1 of 4 possible. +2. Group panning and movement functions togeather, instead of using different functions for each move. +3. Make map struct store the initial map, and the current map to be stored in map_view struct. That is calculated based on several layers of original map and NPC movement. Current map is (potentially) of 1 layer only, and directly represents what is to be drawn (applied z-ordering! Yay!). +4. Also, I have tried to clean zcroll.c a bit. +5. Also also, tried to separate movement functions from player and to generalize it to a movable npc/entity. +6. Instead of drawing map as a rectangle of tiles and a few strips to fill the black area of partially visible tiles, draw just a slightly bigger rectangle, with it's edges a bit out of the screen. That shouldn't be too resourse-consuming, I believe, but requires less explicit calls and reads. Probably. +7. As stuff did not quite initialize properly, I have disabled keyboard interrupt vector override to be able to shut down program prematurely in case something goes wrong. So, in case you just want to replace these new files with the older and working ones, please remember to re-enable that, or you won't be able to controll the game without it. diff --git a/makefile b/makefile index 2d44a1b8..705665de 100755 --- a/makefile +++ b/makefile @@ -106,7 +106,7 @@ LIBFLAGS=$(WLIBQ) -b -n # objects # VGMSNDOBJ = vgmSnd.$(OBJ) 16_snd.$(OBJ) -GFXLIBOBJS = modex16.$(OBJ) bitmap.$(OBJ) 16text.$(OBJ) bakapee.$(OBJ) scroll16.$(OBJ) 16render.$(OBJ) 16_vrs.$(OBJ) 16_sprit.$(OBJ) +GFXLIBOBJS = modex16.$(OBJ) bitmap.$(OBJ) 16text.$(OBJ) bakapee.$(OBJ) zcroll16.$(OBJ) 16render.$(OBJ) 16_vrs.$(OBJ) 16_sprit.$(OBJ) 16LIBOBJS = 16_mm.$(OBJ) 16_pm.$(OBJ) 16_ca.$(OBJ) 16_tail.$(OBJ) 16_in.$(OBJ) 16_head.$(OBJ) 16_dbg.$(OBJ) kitten.$(OBJ) 16_hc.$(OBJ) wcpu.$(OBJ) 16_timer.$(OBJ) #16planar.$(OBJ) planar.$(OBJ) DOSLIBOBJ = adlib.$(OBJ) 8254.$(OBJ) 8259.$(OBJ) dos.$(OBJ) cpu.$(OBJ) @@ -193,7 +193,7 @@ bakapi.exe: bakapi.$(OBJ) gfx.lib $(DOSLIBLIBS) # scroll.exe: scroll.$(OBJ) mapread.$(OBJ) jsmn.$(OBJ) $(16LIB) gfx.lib $(DOSLIBLIBS) scroll.$(OBJ): $(SRC)/scroll.c -zcroll.exe: zcroll.$(OBJ) mapread.$(OBJ) jsmn.$(OBJ) $(16LIB) gfx.lib $(DOSLIBLIBS) +zcroll.exe: zcroll.$(OBJ) 16_map.$(OBJ) jsmn.$(OBJ) $(16LIB) gfx.lib $(DOSLIBLIBS) zcroll.$(OBJ): $(SRC)/zcroll.c tesuto.exe: tesuto.$(OBJ) 16_head.$(OBJ) gfx.lib $(DOSLIBLIBS) tesuto.$(OBJ): $(SRC)/tesuto.c @@ -286,8 +286,9 @@ bakapee.$(OBJ): $(SRCLIB)/bakapee.c $(SRCLIB)/bakapee.h 16_sprit.$(OBJ): $(SRCLIB)/16_sprit.c $(SRCLIB)/16_sprit.h bitmap.$(OBJ): $(SRCLIB)/bitmap.c $(SRCLIB)/bitmap.h planar.$(OBJ): $(SRCLIB)/planar.c $(SRCLIB)/planar.h -scroll16.$(OBJ): $(SRCLIB)/scroll16.c $(SRCLIB)/scroll16.h 16text.$(OBJ): $(SRCLIB)/16text.c +scroll16.$(OBJ): $(SRCLIB)/scroll16.c $(SRCLIB)/scroll16.h +zcroll16.$(OBJ): $(SRCLIB)/zcroll16.c $(SRCLIB)/zcroll16.h mapread.$(OBJ): $(SRCLIB)/mapread.c $(SRCLIB)/mapread.h 16_map.$(OBJ): $(SRCLIB)/16_map.c $(SRCLIB)/16_map.h 16_timer.$(OBJ): $(SRCLIB)/16_timer.c $(SRCLIB)/16_timer.h diff --git a/src/lib/16_entity.h b/src/lib/16_entity.h new file mode 100644 index 00000000..17ee10fa --- /dev/null +++ b/src/lib/16_entity.h @@ -0,0 +1,25 @@ +#ifndef __16_NPC__ +#define __16_NPC__ + +#include "src/lib/16_sprit.h" +#include "src/lib/16_head.h" +#include "src/lib/16_in.h" + + +typedef struct +{ + int x; // exact position on the viewable map + int y; // exact position on the viewable map + int tx; // tile position on the viewable map + int ty; // tile position on the viewable map + int triggerx; // trigger box tile position on the viewable map + int triggery; // trigger box tile position on the viewable map + byte d; // direction the NPC faces + struct sprite *spri; // sprite used by NPC + sword hp; // hitpoints of the NPC + byte near pdir; // previous direction~ + word speed; // NPC's speed + word spt; // speed per tile +} entity_t; + +#endif diff --git a/src/lib/16_in.c b/src/lib/16_in.c index 85709c5e..363b588b 100755 --- a/src/lib/16_in.c +++ b/src/lib/16_in.c @@ -51,8 +51,8 @@ boolean dbg_testkeyin=0,dbg_testcontrolnoisy=0; */ struct inconfig { - boolean MousePresent; - boolean JoysPresent[MaxJoys]; + boolean MousePresent; + boolean JoysPresent[MaxJoys]; boolean Keyboard[NumCodes]; boolean Paused; char LastASCII; @@ -508,7 +508,7 @@ INL_StartKbd() IN_ClearKeysDown(); OldKeyVect = _dos_getvect(KeyInt); - _dos_setvect(KeyInt,INL_KeyService); + //_dos_setvect(KeyInt,INL_KeyService); } /////////////////////////////////////////////////////////////////////////// @@ -703,9 +703,8 @@ IN_Default(boolean gotit,player_t *player,ControlType nt) //in.KbdDefs[0].downleft = 0x4f; inpu.KbdDefs[0].down = 0x50; //in.KbdDefs[0].downright = 0x51; - IN_SetControlType(0,player,nt); - for(i=0; i>MaxPlayers;i++) - player[i].d=2; + IN_SetControlType(player,nt); + player->d=2; } /////////////////////////////////////////////////////////////////////////// @@ -816,7 +815,7 @@ IN_ReadCursor(CursorInfo *info) // /////////////////////////////////////////////////////////////////////////// void near -IN_ReadControl(int pn,player_t *player) +IN_ReadControl(player_t *player) { boolean realdelta; byte dbyte; @@ -854,7 +853,7 @@ register KeyboardDef *def; else { #endif - switch (type = player[pn].Controls) + switch (type = player->Controls) { case ctrl_Keyboard1: case ctrl_Keyboard2: @@ -869,7 +868,7 @@ register KeyboardDef *def; else if (Keyboard[def->downright]) mx = motion_Right,my = motion_Down;*/ //TODO: make this into a function that the joystick AND keyboard can use wwww - if(DIRECTIONIFELSE)//(player[pn].info.dir == 2) + if(DIRECTIONIFELSE)//(player->info.dir == 2) { if(!inpu.Keyboard[def->left] && !inpu.Keyboard[def->right]){ if((inpu.Keyboard[def->up] && !inpu.Keyboard[def->down])) @@ -882,7 +881,7 @@ register KeyboardDef *def; if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left])) mx = motion_Right; }else{ //2 keys pressed - switch (player[pn].pdir) + switch (player->pdir) { case 0: case 4: @@ -898,7 +897,7 @@ register KeyboardDef *def; break; } #ifdef __DEBUG_InputMgr__ - //if(dbg_testcontrolnoisy > 0){ printf("dir=%c ", dirchar(dir)); printf("pdir=%c ", dirchar(player[pn].pdir)); } + //if(dbg_testcontrolnoisy > 0){ printf("dir=%c ", dirchar(dir)); printf("pdir=%c ", dirchar(player->pdir)); } #endif } } @@ -936,23 +935,23 @@ register KeyboardDef *def; dy = my;// * 127; } - player[pn].info.x = dx; - player[pn].info.xaxis = mx; - player[pn].info.y = dy; - player[pn].info.yaxis = my; - player[pn].info.button0 = buttons & (1 << 0); - player[pn].info.button1 = buttons & (1 << 1); - player[pn].info.button2 = buttons & (1 << 2); - player[pn].info.button3 = buttons & (1 << 3); -// player[pn].info.dir = DirTable[((my + 1) * 3) + (mx + 1)]; + player->info.x = dx; + player->info.xaxis = mx; + player->info.y = dy; + player->info.yaxis = my; + player->info.button0 = buttons & (1 << 0); + player->info.button1 = buttons & (1 << 1); + player->info.button2 = buttons & (1 << 2); + player->info.button3 = buttons & (1 << 3); +// player->info.dir = DirTable[((my + 1) * 3) + (mx + 1)]; conpee=(((my + 1) * 2) + (mx + 1))-1; - player[pn].info.dir = DirTable[conpee]; + player->info.dir = DirTable[conpee]; - if(DirTable[conpee]!=2) player[pn].pdir=DirTable[conpee]; - if(player[pn].q==1 &&( dir!=2 || (mx!=motion_None || my!=motion_None))) + if(DirTable[conpee]!=2) player->pdir=DirTable[conpee]; + if(player->q==1 &&( dir!=2 || (mx!=motion_None || my!=motion_None))) { - if(dir==2) player[pn].d = player[pn].info.dir; - else player[pn].d = DirTable[dir]; + if(dir==2) player->d = player->info.dir; + else player->d = DirTable[dir]; } #if DEMO0 @@ -982,13 +981,13 @@ register KeyboardDef *def; #endif #ifdef __DEBUG_InputMgr__ if(dbg_testcontrolnoisy > 0) -if(player[pn].info.dir!=2/*(inpu.Keyboard[def->up] || inpu.Keyboard[def->down] || inpu.Keyboard[def->left] || inpu.Keyboard[def->right])*/ || player[pn].q>1) +if(player->info.dir!=2/*(inpu.Keyboard[def->up] || inpu.Keyboard[def->down] || inpu.Keyboard[def->left] || inpu.Keyboard[def->right])*/ || player->q>1) { - //printf("b1=%u b2=%u b3=%u b4=%u ", player[pn].info.button0, player[pn].info.button1, player[pn].info.button2, player[pn].info.button3); - //printf("q=%d ", player[pn].q); + //printf("b1=%u b2=%u b3=%u b4=%u ", player->info.button0, player->info.button1, player->info.button2, player->info.button3); + //printf("q=%d ", player->q); //printf("cpee=%c ", dirchar(conpee)); - printf("pdir=%c d=%c dir=%c ", dirchar(player[pn].pdir), dirchar(player[pn].d), dirchar(player[pn].info.dir)); - /*if(realdelta) */printf("dx=%d dy=%d mx=%d my=%d", player[pn].info.x, player[pn].info.y, player[pn].info.xaxis, player[pn].info.yaxis); + printf("pdir=%c d=%c dir=%c ", dirchar(player->pdir), dirchar(player->d), dirchar(player->info.dir)); + /*if(realdelta) */printf("dx=%d dy=%d mx=%d my=%d", player->info.x, player->info.y, player->info.xaxis, player->info.yaxis); //else if(!realdelta) printf("%c%d %c%d %c%d %c%d", dirchar(0), inpu.Keyboard[def->up], dirchar(4), inpu.Keyboard[def->down], dirchar(1), inpu.Keyboard[def->left], dirchar(3), inpu.Keyboard[def->right]); printf("\n"); } @@ -1002,10 +1001,10 @@ if(player[pn].info.dir!=2/*(inpu.Keyboard[def->up] || inpu.Keyboard[def->down] | // /////////////////////////////////////////////////////////////////////////// void -IN_SetControlType(word pn,player_t *player,ControlType type) +IN_SetControlType(player_t *player,ControlType type) { // DEBUG - check that requested type is present? - player[pn].Controls = type; + player->Controls = type; } #if DEMO0 @@ -1267,20 +1266,16 @@ boolean IN_qb(byte kee) } //init player! -void IN_initplayer(player_t *player, word pn) +void IN_initplayer(player_t *player) { - player[pn].x = player[pn].tx*TILEWH; - player[pn].y = player[pn].ty*TILEWH; - player[pn].triggerx = player[pn].tx; - player[pn].triggery = player[pn].ty+1; -/* player[0].info.x = player[0].tx; - player[0].info.xaxis = player[0].tx*TILEWH; - player[0].info.y = player[0].ty; - player[0].info.yaxis = player[0].ty*TILEWH;*/ - player[pn].q=1; - player[pn].d=2; - player[pn].hp=4; - player[pn].speed=4; - player[pn].persist_aniframe=0; - player[pn].spt=(TILEWH/(player[pn].speed)); //speed per tile wwww + player->x = player->tx*TILEWH; + player->y = player->ty*TILEWH; + player->triggerx = player->tx; + player->triggery = player->ty+1; + player->q=1; + player->d=2; + player->hp=4; + player->speed=4; + player->persist_aniframe=0; + player->spt=(TILEWH/(player->speed)); //speed per tile wwww } diff --git a/src/lib/16_in.h b/src/lib/16_in.h index 29ecc130..b2170176 100755 --- a/src/lib/16_in.h +++ b/src/lib/16_in.h @@ -32,8 +32,9 @@ #include "src/lib/16_timer.h" #ifdef __WATCOMC__ //borland C BCEXMM.EXE #include "src/lib/16_dbg.h" -#include "src/lib/16_sprit.h" #include "src/lib/bitmap.h" //old format +#include "src/lib/16_sprit.h" +#include "src/lib/16_entity.h" #endif #ifdef __DEBUG__ #define __DEBUG_InputMgr__ @@ -41,10 +42,7 @@ extern boolean dbg_testkeyin,dbg_testcontrolnoisy; #endif //if else for gfxtesting and direction -//player[pn].d == 2 || -//player[pn].d != 2 || -#define DIRECTIONIFELSE (player[pn].info.dir == 2) -//#define NDIRECTIONIFELSE (player[pn].info.dir != 2) +#define DIRECTIONIFELSE (player->info.dir == 2) #define KeyInt 9 // The keyboard ISR number @@ -53,7 +51,7 @@ extern boolean dbg_testkeyin,dbg_testcontrolnoisy; #define JoyScaleShift 8 #define MaxJoyValue 5000 -#define MaxPlayers 4 +#define MaxPlayers 1 #define MaxKbds 2 #define MaxJoys 2 #define MaxPads 2 @@ -234,6 +232,8 @@ typedef struct int persist_aniframe; /* gonna be increased to 1 before being used, so 0 is ok for default */ CursorInfo info; ControlType Controls; + entity_t *ent; + int dx, dy, delta; } player_t; /* @@ -286,8 +286,8 @@ extern void IN_SetKeyHook(void (*hook)()); extern void IN_ClearKeysDown(); //static void INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy); extern void IN_ReadCursor(CursorInfo *info); -extern void near IN_ReadControl(int pn,player_t *player); -extern void IN_SetControlType(word pn,player_t *player,ControlType type); +extern void near IN_ReadControl(player_t *player); +extern void IN_SetControlType(player_t *player,ControlType type); #if DEMO0 extern boolean IN_StartDemoRecord(word bufsize); extern void IN_StartDemoPlayback(byte /*__segment*/ *buffer,word bufsize); @@ -304,6 +304,6 @@ extern boolean IN_UserInput(dword delay,boolean clear); extern boolean IN_KeyDown(byte code); extern void IN_ClearKey(byte code); extern boolean IN_qb(byte kee); -void IN_initplayer(player_t *player, word pn); +void IN_initplayer(player_t *player); #endif diff --git a/src/lib/16_map.h b/src/lib/16_map.h index cd3f9349..4fd04429 100755 --- a/src/lib/16_map.h +++ b/src/lib/16_map.h @@ -39,10 +39,10 @@ typedef struct { word tileWidth; unsigned int rows; unsigned int cols; -#ifdef __DEBUG__ + #ifdef __DEBUG__ boolean debug_text; //show the value of the tile! wwww byte *debug_data; -#endif + #endif } tiles_t; //TODO: 16_mm and 16_ca must handle this @@ -52,7 +52,7 @@ typedef struct { //unsigned planelength[3]; byte * huge *data; //TODO: 16_mm and 16_ca must handle this tiles_t **tiles; //TODO: 16_mm and 16_ca must handle this - int width, height; //this has to be signed! + unsigned int width, height; //this has to be positive char name[16]; } map_t; diff --git a/src/lib/16_sprit.c b/src/lib/16_sprit.c index c59590ce..89d38906 100755 --- a/src/lib/16_sprit.c +++ b/src/lib/16_sprit.c @@ -66,11 +66,11 @@ void print_anim_ids(struct sprite *spri) vrs->offset_table[VRS_HEADER_OFFSET_ANIMATION_ID_LIST]); if(!anim_ids[new_anim_index]) - exit(3); + return; // Loop through animation id untill match or end of list while(iter_id = anim_ids[new_anim_index]) { - // Return on successful match + printf("s%d ", iter_id); new_anim_index++; } } diff --git a/src/lib/tst.c b/src/lib/tst.c new file mode 100644 index 00000000..44100e6f --- /dev/null +++ b/src/lib/tst.c @@ -0,0 +1,102 @@ +#include "stdio.h" +#include "stdlib.h" +#include "jsmn/jsmn.h" + +static int dump(const char *js, jsmntok_t *t, size_t count, int indent) { + int i, j, k; + if (count == 0) { + return 0; + } + if (t->type == JSMN_PRIMITIVE) { + printf("%.*s", t->end - t->start, js+t->start); + return 1; + } else if (t->type == JSMN_STRING) { + printf("'%.*s'", t->end - t->start, js+t->start); + return 1; + } else if (t->type == JSMN_OBJECT) { + printf("\n"); + j = 0; + for (i = 0; i < t->size; i++) { + for (k = 0; k < indent; k++) printf(" "); + j += dump(js, t+1+j, count-j, indent+1); + printf(": "); + j += dump(js, t+1+j, count-j, indent+1); + printf("\n"); + } + return j+1; + } else if (t->type == JSMN_ARRAY) { + j = 0; + printf("\n"); + for (i = 0; i < t->size; i++) { + for (k = 0; k < indent-1; k++) printf(" "); + printf(" - "); + j += dump(js, t+1+j, count-j, indent+1); + printf("\n"); + } + return j+1; + } + return 0; +} + +long int +filesize(FILE *fp) +{ + long int save_pos, size_of_file; + + save_pos = ftell(fp); + fseek(fp, 0L, SEEK_END); + size_of_file = ftell(fp); + fseek(fp, save_pos, SEEK_SET); + return(size_of_file); +} + + +int loadmap(char *mn/*, map_t *map*/) +{ + char *js; + char js_ss[16]; + + jsmn_parser p; + jsmntok_t *tok = NULL; + size_t tokcount, file_s; + + FILE *fh = fopen(mn, "r"); + + /* Prepare parser */ + jsmn_init(&p); + + file_s = filesize(fh); + js = malloc(file_s); + if(js == NULL){ + fprintf(stderr, "malloc(): errno = %d", 2); + fclose(fh); + return 3; + } + if(fread(js, 1, file_s, fh) != file_s){ + fprintf(stderr, "Map read error"); + free(js); + fclose(fh); + return 1; + } + + tokcount = jsmn_parse(&p, js, file_s, NULL, 0); + tok = malloc(tokcount*sizeof(jsmntok_t)); + jsmn_parse(&p, js, file_s, tok, tokcount); + #ifdef DEBUG_DUMPVARS + fprintf(stdout, "running dump~\n"); + #endif + dump(js, tok, p.toknext, 0); + + free(js); + free(tok); + fclose(fh); + + return 0; +} + +int main() +{ + puts("3"); + loadmap("../../data/0es0.map"); + return 0; +} diff --git a/src/lib/typdefst.h b/src/lib/typdefst.h index 32aaed26..4242f6c4 100755 --- a/src/lib/typdefst.h +++ b/src/lib/typdefst.h @@ -64,11 +64,12 @@ typedef struct { byte *palette; } planar_buf_t; + +enum direction {STOP, UP, DOWN, LEFT, RIGHT}; typedef struct { + int dx, dy; //backwards compait word id; /* the Identification number of the page~ For layering~ */ byte far* data; /* the data for the page */ - word dx; /* col we are viewing on the virtual screen */ - word dy; /* row we are viewing on the virtual screen */ word sw; /* screen width */ word sh; /* screen heigth */ word tw; /* screen width in tiles */ @@ -84,8 +85,9 @@ typedef struct { word stridew; /*width/4*/ word pagesize; /* page size */ word pi; /* incremention page by this much to preserve location */ + word delta; // How much should we shift the page for smooth scrolling + enum direction d; // Direction we should shift the page } page_t; - typedef struct { //sprite .... diff --git a/src/lib/zcroll16.c b/src/lib/zcroll16.c index 12a5ee1b..52182f2b 100755 --- a/src/lib/zcroll16.c +++ b/src/lib/zcroll16.c @@ -30,17 +30,16 @@ boolean boundary_check(int x, int y, int dx, int dy, int h, int w){ boolean coll_check(int x, int y, int dx, int dy, map_view_t *map_v){ // Assume everything crosses at most 1 tile at once - return dx && crossable_tile(x + dx, map_v) || dy && crossable_tile(y + dy, map_v); + return dx && 1;//crossable_tile(x + dx, map_v) || dy && crossable_tile(y + dy, map_v); } -boolean walk(entity_t *ent, map_view_t *map_v) -{ +boolean walk(entity_t *ent, map_view_t *map_v){ + return 1; int dx = 1; int dy = 1; - switch(ent->d) - { + switch(ent->d){ case STOP: - return; + return 0; case LEFT: dx = -dx; case RIGHT: @@ -58,18 +57,23 @@ boolean walk(entity_t *ent, map_view_t *map_v) // Start animation // Mark next tile as occupied // Mark this tile as vacant - return true; + return 1; } - return false; + return 0; } void player_walk(player_t *player, map_view_t *map_v){ + int dx, dy; if(walk(player->ent, map_v) && boundary_check(map_v->tx, map_v->ty, dx, dy, map_v->map->width - 2*map_v->page->tilesw, map_v->map->height - 2*map_v->page->tilesh)){ mapScroll(map_v, player); // (Un)load stuff? } } +void mapGoTo(map_view_t *mv, int tx, int ty) +{ + return; +} void near mapScroll(map_view_t *mv, player_t *player){ word x, y; /* coordinate for drawing */ @@ -106,24 +110,10 @@ void near mapScroll(map_view_t *mv, player_t *player){ sword chkmap(map_t *map, word q) { + /* // bitmap_t bp; static byte x[(MAPW*MAPH)+1] = { 1, 2, 3, 4, 0, 3, 3, 3, 3, 3, 3, 3, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 6, 7, 8, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 10, 11, 12, 4, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 1, 2, 3, 4 };*/ //check for failed to load map if((map->width == map->height == 0) && (q>0)) { @@ -143,46 +133,11 @@ sword chkmap(map_t *map, word q) map->tiles->cols = 1; map->tiles->debug_text = true; } - else map->tiles->debug_text = false; + else map->tiles->debug_text = false;*/ return 0; } //TODO: player position here -void mapGoTo(map_view_t *mv, int tx, int ty) -{ - int px, py; - unsigned int i; - - /* set up the coordinates */ - mv->tx = tx; - mv->ty = ty; - mv->page->delta = 0; - - /* set up the thresholds */ - mv->dxThresh = mv->map->tiles[0]->tileWidth * 2; - mv->dyThresh = mv->map->tiles[0]->tileHeight * 2; - - /* draw the tiles */ - modexClearRegion(mv->page, 0, 0, mv->page->width, mv->page->height, 0); - py=0; - i=mv->ty * mv->map->width + mv->tx; -/* for(ty=mv[0].ty-1; py < mv[0].page->sh+mv->dyThresh && ty < mv[0].map->height; ty++, py+=mv[0].map->tiles->tileHeight) { - mapDrawWRow(&mv[0], tx-1, ty, py); - i+=mv->map->width - tx; - } - if(!pageploop) modexCopyPageRegion(mv[1].page, mv[0].page, 0, 0, 0, 0, mv[0].page->width, mv[0].page->height); -// { -// unsigned int k,j,o; -// // fill screen with a distinctive pattern -// for (k=0;k < vga_state.vga_width;k++) { -// o = k >> 2; -// vga_write_sequencer(0x02/*map mask*//*,1 << (k&3)); -// for (j=0;j < (mv[0].page->height)+(mv[1].page->height)+(mv[2].page->height)+(mv[3].page->height);j++,o += vga_state.vga_stride) -// vga_state.vga_graphics_ram[o] = (k^j)&15; // VRL samples put all colors in first 15! -// } -// } - modexCopyPageRegion(mv[3].page, mv[0].page, 0, 0, 0, 0, 24, 32);*/ -} void near mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y) @@ -261,14 +216,15 @@ void shinku(global_game_variables_t *gv) gv->kurokku.frames_per_second=60; break; } + /* if(pageflipflop){ - if(gv->video.r){ - if(!pageploop) modexCopyPageRegion(&(gv->video.page[(gv->video.p)]), &(gv->video.page[(!gv->video.p)]), 0, 0, 0, 0, gv->video.page[gv->video.p].width, gv->video.page[!gv->video.p].height); - modexShowPage(&(gv->video.page[gv->video.p])); - if(!pageploop) gv->video.p=!gv->video.p; - gv->video.r=!gv->video.r; - } - } + if(gv->video.r){ + if(!pageploop) modexCopyPageRegion(&(gv->video.page[(gv->video.p)]), &(gv->video.page[(!gv->video.p)]), 0, 0, 0, 0, gv->video.page[gv->video.p].width, gv->video.page[!gv->video.p].height); + modexShowPage(&(gv->video.page[gv->video.p])); + if(!pageploop) gv->video.p=!gv->video.p; + gv->video.r=!gv->video.r; + } + }*/ } void near animatePlayer(map_view_t *pip, player_t *player, sword scrollswitch) @@ -291,7 +247,7 @@ void near animatePlayer(map_view_t *pip, player_t *player, sword scrollswitch) break; } //x-=4; - y-=pip->map->tiles->tileHeight; + //y-=pip->map->tiles->tileHeight; switch (player->d) { case 0: diff --git a/src/lib/zcroll16.h b/src/lib/zcroll16.h index 6f663429..8e07c2c0 100755 --- a/src/lib/zcroll16.h +++ b/src/lib/zcroll16.h @@ -24,6 +24,7 @@ #define __ZCROLL16_H_ #include "src/lib/16_head.h" +#include "src/lib/16_entity.h" //#include "src/lib/bakapee.h" #include "src/lib/modex16.h" //#include "src/lib/16_in.h" @@ -46,6 +47,13 @@ #define PBUFBFUN modexDrawBmpRegion #define PLAYERBMPDATA player->data + +#define MAPW 40 +#define MAPH 30 + +extern boolean pageflipflop, pageploop; +extern unsigned char shinku_fps_indicator_page; + typedef struct { map_t *map; page_t *page; @@ -55,36 +63,8 @@ typedef struct { word dyThresh; //Threshold for physical tile switch video_t *video; //pointer to game variables of the video pan_t *pan; //pointer the the page panning debug system + int dx, dy, delta, d; } map_view_t; - -#define MAPW 40 -#define MAPH 30 - -enum direction {STOP, UP, DOWN, LEFT, RIGHT}; -typedef struct { - word id; /* the Identification number of the page~ For layering~ */ - byte far* data; /* the data for the page */ - word sw; /* screen width */ - word sh; /* screen heigth */ - word tw; /* screen width in tiles */ - word th; /* screen height in tiles */ - word width; /* virtual width of the page */ - word height; /* virtual height of the page */ - word tilesw; /* virtual screen width in tiles */ - word tilesh; /* virtual screen height in tiles */ - sword tilemidposscreenx; /* middle tile position */ - sword tilemidposscreeny; /* middle tile position */ - sword tileplayerposscreenx; /* player position on screen */ - sword tileplayerposscreeny; /* player position on screen */ - word stridew; /*width/4*/ - word pagesize; /* page size */ - word pi; /* incremention page by this much to preserve location */ - word delta; // How much should we shift the page for smooth scrolling - direction d; // Direction we should shift the page -} page_t; -extern boolean pageflipflop, pageploop; -extern unsigned char shinku_fps_indicator_page; - /* Map is presumed to: * 1. Have all the required layers and tilesets within itself * 2. Have a 'fence' around accessible blocks to simplify boundary logic diff --git a/src/zcroll.c b/src/zcroll.c index 31623367..f7603e8d 100755 --- a/src/zcroll.c +++ b/src/zcroll.c @@ -20,140 +20,129 @@ * */ -#include "src/lib/scroll16.h" +#include "src/lib/zcroll16.h" #include "src/lib/16_timer.h" #include "src/lib/wcpu/wcpu.h" -//word far *clock= (word far*) 0x046C; /* 18.2hz clock */ -//bitmap_t *p; global_game_variables_t gvar; static map_t map; -player_t player[MaxPlayers]; -map_view_t mv[4]; -//word pn=0; //i forgot ww +player_t *player; +map_view_t *mv; float t; sword bakapee; pan_t pan; //debugswitches boolean panswitch=0,baka=0; //extern boolean pageflipflop=1; - unsigned int i; - const char *cpus; - //static int persist_aniframe = 0; /* gonna be increased to 1 before being used, so 0 is ok for default */ +unsigned int i; +const char *cpus; +//static int persist_aniframe = 0; /* gonna be increased to 1 before being used, so 0 is ok for default */ - //map_view_db_t pgid[4]; - word pg; +//map_view_db_t pgid[4]; +word pg; //#ifdef FADE - static word paloffset=0; - byte *dpal; +static word paloffset=0; +byte *dpal; //#endif - byte *gpal; - byte *ptr; - byte *mappalptr; +byte *gpal; +byte *ptr; +memptr pal; void main(int argc, char *argv[]) { byte *mesg=malloc(sizeof(dword)); + int i; if(argv[1]) bakapee = atoi(argv[1]); else bakapee = 1; Startup16(&gvar); - pan.pn=1; + pan.pn=0; + player = malloc(sizeof(player_t)); + player->ent = malloc(sizeof(entity_t)); + player->ent->spri = malloc(sizeof(struct sprite)); + player->ent->spri->spritesheet = malloc(sizeof(struct vrs_container)); - /* create the map */ + // create the map fprintf(stderr, "testing map load~ "); loadmap("data/test.map", &map); chkmap(&map, 0); printf("chkmap ok "); fprintf(stderr, "yay map loaded~~\n"); - /* draw the tiles */ - ptr = map.data; - //mappalptr = map.tiles->btdata->palette; + // data + read_vrs(&gvar, "data/spri/chikyuu.vrs", player->ent->spri->spritesheet); - /* data */ - if(CA_LoadFile("data/spri/chikyuu.vrs", &(player[0].gr), &gvar)) baka=1; else baka=0; + // input! + IN_Default(0, player,ctrl_Joystick); - /* create the planar buffer */ -////++++ (player[0].data) = *planar_buf_from_bitmap(&p); - /*++++printf("load pee!! "); - pp = planar_buf_from_bitmap(&p); - printf("done!\n");*/ - - /* input! */ - IN_Default(0,&player,ctrl_Joystick); - //IN_Default(1,&player,ctrl_Joystick); - - /* save the palette */ + // save the palette dpal = modexNewPal(); modexPalSave(dpal); modexFadeOff(4, dpal); textInit(); VGAmodeX(bakapee, 1, &gvar); -// printf("%dx%d\n", gvar.video.page[0].sw, gvar.video.page[0].sh); modexPalBlack(); //reset the palette~ -// printf("Total used @ before palette initiation: %zu\n", oldfreemem-GetFreeSize()); -//++++ player[0].data.offset=(paloffset/3); -//++++ modexPalUpdate1(&player[0].data, &paloffset, 0, 0); - modexPalUpdate1(player[0].data->palette); -//++++0000 modexPalUpdate1(map.tiles->btdata->palette); - //printf(" %d\n", sizeof(ptmp->data)); - //printf("1: %d\n", paloffset); -//++++ map.tiles->data->offset=(paloffset/3); - //XTmodexPalUpdate(map.tiles->data, &paloffset, 0, 0); -// printf("\n====\n"); -// printf("0 paloffset= %d\n", paloffset/3); -// printf("====\n\n"); + CA_LoadFile("data/spri/chikyuu.pal", &pal, &gvar); + modexPalUpdate1(pal); gpal = modexNewPal(); modexPalSave(gpal); modexSavePalFile("data/g.pal", gpal); modexPalBlack(); //so player will not see loadings~ - - /* setup camera and screen~ */ + // setup camera and screen~ modexHiganbanaPageSetup(&gvar.video); - for(i=0;ipage = &gvar.video.page[0]; + mv->map = ↦ + mv->video = &gvar.video; + mv->pan = &pan; + player->ent->spri->x = player->ent->spri->y = 20; - /* set up paging */ + // set up paging //TODO: LOAD map data and position the map in the middle of the screen if smaller then screen mapGoTo(mv, 0, 0); - //_fmemcpy(mv[1].page->data, mv[0].page->data, mv[0].page->pagesize); + //_fmemcpy(mv[1].page->data, mv->page->data, mv->page->pagesize); //TODO: put player in starting position of spot //default player position on the viewable map - player[0].tx = mv[0].tx + mv[0].page->tilemidposscreenx; - player[0].ty = mv[0].ty + mv[0].page->tilemidposscreeny; - IN_initplayer(&player, 0); + player->tx = mv->tx + mv->page->tilemidposscreenx; + player->ty = mv->ty + mv->page->tilemidposscreeny; + IN_initplayer(player); //IN_initplayer(&player, 1); #ifndef SPRITE - modexClearRegion(mv[0].page, player[0].x, player[0].y-TILEWH, 16, 32, 15); - //modexClearRegion(mv[1].page, player[0].x, player[0].y-TILEWH, 16, 32, 15); + modexClearRegion(mv->page, player->x, player->y-TILEWH, 16, 32, 15); + //modexClearRegion(mv[1].page, player->x, player->y-TILEWH, 16, 32, 15); #else - //PBUFSFUN(mv[1].page, player[0].x, player[0].y-TILEWH, 16, 64, 24, 32, PLAYERBMPDATA); - PBUFSFUN(mv[0].page, player[0].x, player[0].y-TILEWH, 16, 64, 16, 32, player[0].data); + //PBUFSFUN(mv[1].page, player->x, player->y-TILEWH, 16, 64, 24, 32, PLAYERBMPDATA); +// PBUFSFUN(mv->page, player->x, player->y-TILEWH, 16, 64, 16, 32, player->data); + i = set_anim_by_id(player->ent->spri, 11); + print_anim_ids(player->ent->spri); + if (i == -1) + { + modexFadeOff(4, gpal); + VGAmodeX(0, 1, &gvar); + Shutdown16(&gvar); + printf("Wrong"); + modexFadeOn(4, dpal); +return; + } +return; + //animate_spri(&(player->ent->spri)); #endif - if(!pageflipflop) modexShowPage(mv[1].page); - else modexShowPage(mv[0].page);//!(gvar.video.p) - shinku_fps_indicator_page = 0; // we're on page 1 now, shinku(). follow along please or it will not be visible. + modexShowPage(mv->page);//!(gvar.video.p) + shinku_fps_indicator_page = 0; // we're on page 1 now, shinku(). follow along please or it will not be visible. - /* buffer pages */ + // buffer pages // modexClearRegion(mv[2].page, 0, 0, mv[2].page->width, mv[2].page->height, 47); // modexClearRegion(mv[3].page, 0, 0, mv[3].page->width, mv[3].page->height, 45); // { // unsigned int k,j,o; -// /* fill screen with a distinctive pattern */ +// // fill screen with a distinctive pattern // for (k=0;k < vga_state.vga_width;k++) { // o = k >> 2; // vga_write_sequencer(0x02/*map mask*/,1 << (k&3)); @@ -161,97 +150,77 @@ void main(int argc, char *argv[]) // vga_state.vga_graphics_ram[o] = (k^j)&15; // VRL samples put all colors in first 15! // } // } - modexClearRegion(mv[3].page, 0, 128, 24, 36, 15); - modexFadeOn(4, gpal); - while(!IN_KeyDown(sc_Escape) && player[0].hp>0) +// modexFadeOn(4, gpal);*/ + while(!IN_KeyDown(sc_Escape) && player->hp>0) { shinku(&gvar); - //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[0].tx or player[0].ty == 0 or player[0].tx == 20 or player[0].ty == 15 then stop because that is edge of map and you do not want to walk of the map + //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 - //player movement - IN_ReadControl(0,&player); - if(!panswitch){ - walk(mv, player, 0); - }else{ - panpagemanual(mv, player, 0); - //printf(" player[0].q: %d", player[0].q); printf(" player[0].d: %d\n", player[0].d); - } + //player movement + IN_ReadControl(player); + if(!panswitch){ + walk(player->ent, mv); + } - //the scripting stuff.... - //if(((player[0].triggerx == TRIGGX && player[0].triggery == TRIGGY) && IN_KeyDown(0x1C))||(player[0].tx == 5 && player[0].ty == 5)) - if(((mv[0].map->data[(player[0].triggerx-1)+(map.width*(player[0].triggery-1))] == 0) && IN_KeyDown(0x1C))||(player[0].tx == 5 && player[0].ty == 5)) - { - short i; - for(i=800; i>=400; i--) + //the scripting stuff.... +/* if(((mv->map->data[(player->triggerx-1)+(map.width*(player->triggery-1))] == 0) && IN_KeyDown(0x1C))||(player->tx == 5 && player->ty == 5)) { - sound(i); + short i; + for(i=800; i>=400; i--) + { + sound(i); + } + nosound(); + } + if(player->q == (TILEWH/(player->speed))+1 && player->info.dir != 2 && (player->triggerx == 5 && player->triggery == 5)){ player->hp--; } +*/ //debugging binds! + if(IN_KeyDown(2)){ modexShowPage(mv->page); pan.pn=0; } + if(IN_KeyDown(25)){ modexpdump(mv->page); + IN_UserInput(1,1); + } //p + if(IN_KeyDown(24)){ modexPalUpdate0(gpal); paloffset=0; modexpdump(mv->page); IN_UserInput(1,1); } + if(IN_KeyDown(22)){ + printf("2paloffset = %d\n", paloffset/3); + IN_UserInput(1,1); } - nosound(); - } - if(player[0].q == (TILEWH/(player[0].speed))+1 && player[0].info.dir != 2 && (player[0].triggerx == 5 && player[0].triggery == 5)){ player[0].hp--; } - //debugging binds! - if(IN_KeyDown(2)){ modexShowPage(mv[0].page); pan.pn=0; } - if(IN_KeyDown(3)){ modexShowPage(mv[1].page); pan.pn=1; } - if(IN_KeyDown(4)){ modexShowPage(mv[2].page); pan.pn=2; } - if(IN_KeyDown(4+1)){ modexShowPage(mv[3].page); pan.pn=3; } - if(IN_KeyDown(25)){ modexpdump(mv[0].page); modexpdump(mv[1].page); - IN_UserInput(1,1); - } //p - if(IN_KeyDown(24)){ modexPalUpdate0(gpal); paloffset=0; modexpdump(mv[0].page); modexpdump(mv[1].page); IN_UserInput(1,1); } - if(IN_KeyDown(22)){ - paloffset=0; modexPalBlack(); modexPalUpdate(player[0].data, &paloffset, 0, 0); - printf("2paloffset = %d\n", paloffset/3); - modexpdump(mv[0].page); modexpdump(mv[1].page); - IN_UserInput(1,1); - } - //pan switch - if(IN_KeyDown(88)){panswitch=!panswitch; IN_UserInput(1,1);} //f12 - if(IN_KeyDown(87)) //f11 - { - pageflipflop=!pageflipflop; - IN_UserInput(1,1); -// VGAmodeX(0, 0, &gvar); -// IN_Shutdown(); -// __asm -// { -// mov ah,31h -// int 21h -// } - } - if(IN_KeyDown(68)) //f10 - { - gvar.kurokku.fpscap=!gvar.kurokku.fpscap; - IN_UserInput(1,1); - } - if(IN_KeyDown(67)) //f9 - { - modexClearRegion(mv[1].page, 0, 0, mv[1].page->width, mv[1].page->height, 2); - modexClearRegion(mv[2].page, 0, 0, mv[2].page->width, mv[2].page->height, 3); - modexClearRegion(mv[3].page, 0, 0, mv[3].page->width, mv[3].page->height, 4); - modexClearRegion(mv[3].page, 0, 0, 20, 36, 15); - //IN_UserInput(1,1); - } - if(IN_KeyDown(66)) //f8 - { -// modexDrawSprite(mv[0].page, 16, 16, p); - modexDrawSprite(mv[0].page, 32+48, 16, (player[0].data)); - } - //TODO fmemtest into page - /*if(IN_KeyDown(4+1)) //4 - { - pg=1; - SELECT_ALL_PLANES(); - _fmemset(((mv[pg].page->data+4)+(16*(mv[pg].page->width/4))), 15, 4); - }*/ + //pan switch + if(IN_KeyDown(88)){panswitch=!panswitch; IN_UserInput(1,1);} //f12 + if(IN_KeyDown(87)) //f11 + { + pageflipflop=!pageflipflop; + IN_UserInput(1,1); + } + if(IN_KeyDown(68)) //f10 + { + gvar.kurokku.fpscap=!gvar.kurokku.fpscap; + IN_UserInput(1,1); + } + if(IN_KeyDown(67)) //f9 + { + modexClearRegion(mv->page, 0, 0, mv->page->width, mv->page->height, 2); + } + if(IN_KeyDown(66)) //f8 + { + // modexDrawSprite(mv->page, 16, 16, p); + modexDrawSprite(mv->page, 32+48, 16, (player->data)); + } + //TODO fmemtest into page + /*if(IN_KeyDown(4+1)) //4 + { + pg=1; + SELECT_ALL_PLANES(); + _fmemset(((mv[pg].page->data+4)+(16*(mv[pg].page->width/4))), 15, 4); + }*/ - //9 - if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate1(dpal); IN_UserInput(1,1); } - //if(IN_KeyDown(11)){ modexPalOverscan(15); } - if((player[0].q==1) && !(player[0].x%TILEWH==0 && player[0].y%TILEWH==0)) break; //incase things go out of sync! + //9 + if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate1(dpal); IN_UserInput(1,1); } + //if(IN_KeyDown(11)){ modexPalOverscan(15); } + if((player->q==1) && !(player->x%TILEWH==0 && player->y%TILEWH==0)) break; //incase things go out of sync! + player->hp = 0; } /* fade back to text mode */ @@ -263,18 +232,18 @@ void main(int argc, char *argv[]) Shutdown16(&gvar); printf("\nProject 16 scroll.exe. This is just a test file!\n"); printf("version %s\n", VERSION); - printf("tx: %d ", mv[0].tx); - printf("ty: %d\n", mv[0].ty); + printf("tx: %d ", mv->tx); + printf("ty: %d\n", mv->ty); printf("\n"); printf("player vars:\n"); - printf(" x: %d", player[0].x); printf(" y: %d\n", player[0].y); - //if(player[0].hp==0) printf("%d wwww\n", player[0].y+8); - //else printf("\nplayer[0].y: %d\n", player[0].y); - printf(" tx: %d", player[0].tx); printf(" ty: %d\n", player[0].ty); - printf(" triggx: %d", player[0].triggerx); printf(" triggy: %d\n", player[0].triggery); - printf(" hp: %d", (player[0].hp)); printf(" q: %d", player[0].q); printf(" player.info.dir: %d", player[0].info.dir); printf(" player.d: %d ", player[0].d); - printf(" pdir=%d\n", player[0].pdir); - printf(" tile data value at player trigger position: %d\n\n", mv[0].map->data[(player[0].triggerx-1)+(map.width*(player[0].triggery-1))]); + printf(" x: %d", player->x); printf(" y: %d\n", player->y); + //if(player->hp==0) printf("%d wwww\n", player->y+8); + //else printf("\nplayer->y: %d\n", player->y); + printf(" tx: %d", player->tx); printf(" ty: %d\n", player->ty); + printf(" triggx: %d", player->triggerx); printf(" triggy: %d\n", player->triggery); + printf(" hp: %d", (player->hp)); printf(" q: %d", player->q); printf(" player.info.dir: %d", player->info.dir); printf(" player.d: %d ", player->d); + printf(" pdir=%d\n", player->pdir); + printf(" tile data value at player trigger position: %d\n\n", mv->map->data[(player->triggerx-1)+(map.width*(player->triggery-1))]); printf("Virtual Screen: %dx", gvar.video.page[0].width); printf("%d ", gvar.video.page[0].height); printf("Screen: %dx", gvar.video.page[0].sw); printf("%d\n", gvar.video.page[0].sh); printf("virtual tile resolution: %dx", gvar.video.page[0].tilesw); printf("%d ", gvar.video.page[0].tilesh); @@ -287,7 +256,7 @@ void main(int argc, char *argv[]) //0000printf("\ngvar.video.tickclk=%f\n", gvar.video.tickclk); //0000printf("gvar.video.clk=%f", gvar.video.clk); printf("\n"); - //printf("map.width=%d map.height=%d map.data[0]=%d\n", mv[0].map->width, mv[0].map->height, mv[0].map->data[0]); + //printf("map.width=%d map.height=%d map.data[0]=%d\n", mv->map->width, mv->map->height, mv->map->data[0]); printf("\n"); switch(detectcpu())