From: sparky4 Date: Sat, 15 Apr 2017 15:17:06 +0000 (-0500) Subject: p16 is being worked on a bunch by me wwww [16_ca needs huge amounts of work and I... X-Git-Url: http://git.osdn.net/view?p=proj16%2F16.git;a=commitdiff_plain;h=8402804d56a98a48de98aba30941670f6ac6c5a3 p16 is being worked on a bunch by me wwww [16_ca needs huge amounts of work and I should remember what needs to be done soon][OpenVGMFile needs to be ported to 16_snd.c]going to port rest of code to borland c some time so we can use the core components of id engine here [going to add 16_us.c eventually but the debug system and CA_ PM_ and MM_ usage is priority now]older zcroll renamed to xcroll][zcroll is now the pre menu game loop system with PROPER data usage with CAMMPM] MM_ShowMemory is quite buggy on real machines. i need to debug it and fix added a struct printer[gvar.mm is FUCKING HUGE 14402 bytes FAT\!]16_rf now compiles BT UNKNOWN ON WHAT IT DOSE\! text box creates a ghost because page 1 do not have bg info thus it is stored and saved.... wwww fizzfade being worked on and no idea how to make it work...[xcroll is fixed resuming fizzfade testings] also imf to xcroll is not work [did some testing wwww and added 0croll.c the original one] --- diff --git a/16/src/lib/bitmap.c b/16/src/lib/bitmap.c index 22bad981..6e496049 100755 --- a/16/src/lib/bitmap.c +++ b/16/src/lib/bitmap.c @@ -23,7 +23,7 @@ #include #include #include -#include "src/lib/bitmap.h" +#include "16/src/lib/bitmap.h" #include "src/lib/16_mm.h" #include "src/lib/16_pm.h" #include "src/lib/16_ca.h" @@ -197,3 +197,16 @@ bitmapLoadPcxTiles(char *filename, word twidth, word theight) { return ts; } + +byte * +modexNewPal() { + byte *ptr; + ptr = malloc(PAL_SIZE); + + // handle errors + if(!ptr) { + printf("Could not allocate palette.\n"); + } + + return ptr; +} diff --git a/16/src/lib/bitmap.h b/16/src/lib/bitmap.h index b35996d2..d87356b2 100755 --- a/16/src/lib/bitmap.h +++ b/16/src/lib/bitmap.h @@ -30,4 +30,5 @@ bitmap_t bitmapLoadPcx(char *filename, global_game_variables_t *gv); tileset_t bitmapLoadPcxTiles(char *filename, word twidth, word theight); +byte *modexNewPal(); #endif diff --git a/makefile b/makefile index 2fcfd8c4..334e47f2 100755 --- a/makefile +++ b/makefile @@ -136,8 +136,8 @@ LIBFLAGS=$(WLIBQ) -b -n # objects # VGMSNDOBJ = vgmSnd.$(OBJ) -#OLDLIBOBJS=bitmap.$(OBJ) 16render.$(OBJ) -GFXLIBOBJS = 16_vl.$(OBJ) 16_vl_1.$(OBJ) 16_vl_2.$(OBJ) 16_vlpal.$(OBJ) 16text.$(OBJ) bakapee.$(OBJ) scroll16.$(OBJ) 16_vrs.$(OBJ) 16_spri.$(OBJ) $(OLDLIBOBJS) +OLDLIBOBJS=bitmap.$(OBJ) 16render.$(OBJ) +GFXLIBOBJS = 16_vl.$(OBJ) 16_vl_1.$(OBJ) 16_vl_2.$(OBJ) 16_vlpal.$(OBJ) 16text.$(OBJ) bakapee.$(OBJ) scroll16.$(OBJ) 16_vrs.$(OBJ) 16_spri.$(OBJ) 16LIBOBJS = 16_mm.$(OBJ) 16_pm.$(OBJ) 16_ca.$(OBJ) 16_tail.$(OBJ) 16_head.$(OBJ) 16_enti.$(OBJ) 16_dbg.$(OBJ) 16_in.$(OBJ) kitten.$(OBJ) 16_hc.$(OBJ) 16_wcpu.$(OBJ) 16_timer.$(OBJ) jsmn.$(OBJ) 16_map.$(OBJ) 16text.$(OBJ) 16_sd.$(OBJ) 16_tail_.$(OBJ) 16_dbg_1.$(OBJ) DOSLIBOBJ = adlib.$(OBJ) 8254.$(OBJ) 8259.$(OBJ) dos.$(OBJ) cpu.$(OBJ) !ifeq DEBUGSERIAL 1 @@ -157,7 +157,7 @@ DOSLIB=doslib.lib # # Files locations # -.c : $(SRC);$(SRCLIB);$(MODEXLIB16);$(JSMNLIB);$(NYANLIB);$(VGMSNDLIB);$(WCPULIB);$(UTIL) +.c : $(SRC);$(SRCLIB);$(MODEXLIB16);$(JSMNLIB);$(NYANLIB);$(VGMSNDLIB);$(WCPULIB);$(UTIL);16/$(SRCLIB) .asm : $(MODEXLIB);$(UTIL) @@ -195,6 +195,7 @@ TESTEXEC = & vgmtest.exe & sountest.exe & xcroll.exe & + 0croll.exe & inputest.exe & vrstest.exe & tesuto.exe & @@ -255,6 +256,8 @@ bakapi.exe: bakapi.$(OBJ) 16_vl.$(OBJ) 16_vl_1.$(OBJ) 16text.$(OBJ) bakapee.$(O # # Test Executables! # +0croll.exe: 0croll.$(OBJ) $(16LIB) gfx.lib $(DOSLIB) $(OLDLIBOBJS) +0croll.$(OBJ): $(SRC)/0croll.c scroll.exe: scroll.$(OBJ) $(16LIB) gfx.lib $(DOSLIB) scroll.$(OBJ): $(SRC)/scroll.c xcroll.exe: xcroll.$(OBJ) $(16LIB) gfx.lib $(DOSLIB) @@ -381,7 +384,7 @@ bakapee.$(OBJ): $(SRCLIB)/bakapee.c $(SRCLIB)/bakapee.h 16planar.$(OBJ):$(MODEXLIB16)/16planar.c $(MODEXLIB16)/16planar.h 16_vrs.$(OBJ): $(SRCLIB)/16_vrs.c $(SRCLIB)/16_vrs.h $(DOSLIB) 16_spri.$(OBJ):$(SRCLIB)/16_spri.c $(SRCLIB)/16_spri.h -bitmap.$(OBJ): $(SRCLIB)/bitmap.c $(SRCLIB)/bitmap.h +bitmap.$(OBJ): 16/$(SRCLIB)/bitmap.c 16/$(SRCLIB)/bitmap.h planar.$(OBJ): $(SRCLIB)/planar.c $(SRCLIB)/planar.h scroll16.$(OBJ):$(SRCLIB)/scroll16.c $(SRCLIB)/scroll16.h 16text.$(OBJ): $(SRCLIB)/16text.c $(SRCLIB)/16text.h diff --git a/src/0croll.c b/src/0croll.c new file mode 100755 index 00000000..844dc995 --- /dev/null +++ b/src/0croll.c @@ -0,0 +1,369 @@ +//#include "modex16.h" +#include "src/lib/16_vl.h" +#include "16/src/lib/bitmap.h" +#include +#include +//#include "dos_kb.h" +#define SCREEN_WIDTH 320 +#define SCREEN_HEIGHT 240 + +//word far *clock= (word far*) 0x046C; /* 18.2hz clock */ + +typedef struct { + bitmap_t *data; + word tileHeight; + word tileWidth; + unsigned int rows; + unsigned int cols; + unsigned int tilex,tiley; // tile position on the map +} otiles_t; + + +typedef struct { + byte *data; + otiles_t *tiles; + int width; + int height; +} omap_t; + + +typedef struct { + omap_t *map; + page_t *page; + int tx; //???? appears to be the tile position on the viewable screen map + int ty; //???? appears to be the tile position on the viewable screen map + word dxThresh; //???? + word dyThresh; //???? +} omap_view_t; + +struct { + int tx; //player position on the viewable map + int ty; //player position on the viewable map +} player; + + +omap_t allocMap(int w, int h); +void oinitMap(omap_t *map); +void omapScrollRight(omap_view_t *mv, byte offset); +void omapScrollLeft(omap_view_t *mv, byte offest); +void omapScrollUp(omap_view_t *mv, byte offset); +void omapScrollDown(omap_view_t *mv, byte offset); +void omapGoTo(omap_view_t *mv, int tx, int ty); +void omapDrawTile(otiles_t *t, word i, page_t *page, word x, word y); +void omapDrawRow(omap_view_t *mv, int tx, int ty, word y); +void omapDrawCol(omap_view_t *mv, int tx, int ty, word x); + +//#define SWAP(a, b) tmp=a; a=b; b=tmp; +void main() { + static global_game_variables_t gvar; +// int show1=1; +// int tx, ty; +// int x, y; + //int ch=0x0; +// byte ch; +// int q=0; + page_t screen;//,screen2; + omap_t map; + omap_view_t mv;//, mv2; + omap_view_t *draw;//, *show, *tmp; + byte *ptr; + + //default player position on the viewable map + player.tx = 10; + player.ty = 8; + +// setkb(1); + IN_Startup(&gvar); + /* create the map */ + map = allocMap(160,120); //20x15 is the resolution of the screen you can make omapS smaller than 20x15 but the null space needs to be drawn properly + oinitMap(&map); + mv.map = ↦ +// mv2.map = ↦ + + /* draw the tiles */ + ptr = map.data; + modexEnter(1, 1, &gvar); + screen = modexDefaultPage(&screen, &gvar); + screen.width += (TILEWH*2); + mv.page = &screen; + omapGoTo(&mv, 16, 16); +// screen2=modexNextPage(mv.page); +// mv2.page = &screen2; +// omapGoTo(&mv2, 16, 16); +// modexShowPage(mv.page); + + /* set up paging */ +// show = &mv; +// draw = &mv2; + draw = &mv; + + //TODO: set player position data here according to the viewable map screen thingy + + while(!gvar.in.inst->Keyboard[sc_Escape]) { + //TODO: top left corner & bottem right corner of map veiw be set as map edge trigger since omapS 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 + while(!gvar.in.inst->Keyboard[77]){ +// for(q=0; qpage); +// omapScrollRight(draw, 1); +// SWAP(draw, show); +// } + } + + while(!gvar.in.inst->Keyboard[75]){ +// for(q=0; qpage); +// omapScrollLeft(show, 1); +// SWAP(draw, show); +// } + } + + while(!gvar.in.inst->Keyboard[80]){ +// for(q=0; qpage); +// omapScrollDown(show, 1); +// SWAP(draw, show); +// } + } + + while(!gvar.in.inst->Keyboard[72]){ +// for(q=0; qpage); +// omapScrollUp(show, 1); +// SWAP(draw, show); +// } + } + + //keyp(ch); + modexShowPage(draw->page); + + } + + modexLeave(); + +// setkb(0); + IN_Shutdown(&gvar); +} + + +omap_t +allocMap(int w, int h) { + omap_t result; + + result.width =w; + result.height=h; + result.data = malloc(sizeof(byte) * w * h); + + return result; +} + + +void +oinitMap(omap_t *map) { + /* just a place holder to fill out an alternating pattern */ + int x, y; + int i; + int tile = 1; + map->tiles = malloc(sizeof(otiles_t)); + + /* create the tile set */ + map->tiles->data = malloc(sizeof(bitmap_t)); + map->tiles->data->width = (TILEWH*2); + map->tiles->data->height= TILEWH; + map->tiles->data->data = malloc((TILEWH*2)*TILEWH); + map->tiles->tileHeight = TILEWH; + map->tiles->tileWidth =TILEWH; + map->tiles->rows = 1; + map->tiles->cols = 2; + + i=0; + for(y=0; ytiles->data->data[i] = 0x24; + else + map->tiles->data->data[i] = 0x34; + i++; + } + } + + i=0; + for(y=0; yheight; y++) { + for(x=0; xwidth; x++) { + map->data[i] = tile; + tile = tile ? 0 : 1; + i++; + } + tile = tile ? 0 : 1; + } +} + + +void +omapScrollRight(omap_view_t *mv, byte offset) { + word x;//, y; /* coordinate for drawing */ + + /* increment the pixel position and update the page */ + mv->page->dx += offset; + + /* check to see if this changes the tile */ + if(mv->page->dx >= mv->dxThresh ) { + /* go forward one tile */ + mv->tx++; + /* Snap the origin forward */ + mv->page->data += 4; + mv->page->dx = mv->map->tiles->tileWidth; + + + /* draw the next column */ + x= SCREEN_WIDTH + mv->map->tiles->tileWidth; + omapDrawCol(mv, mv->tx + 20 , mv->ty-1, x); + } +} + + +void +omapScrollLeft(omap_view_t *mv, byte offset) { + //word x, y; /* coordinate for drawing */ + + /* increment the pixel position and update the page */ + mv->page->dx -= offset; + + /* check to see if this changes the tile */ + if(mv->page->dx == 0) { + /* go backward one tile */ + mv->tx--; + + /* Snap the origin backward */ + mv->page->data -= 4; + mv->page->dx = mv->map->tiles->tileWidth; + + /* draw the next column */ + omapDrawCol(mv, mv->tx-1, mv->ty-1, 0); + } +} + + +void +omapScrollUp(omap_view_t *mv, byte offset) { + word /*x,*/ y; /* coordinate for drawing */ + + /* increment the pixel position and update the page */ + mv->page->dy -= offset; + + /* check to see if this changes the tile */ + if(mv->page->dy == 0 ) { + /* go down one tile */ + mv->ty--; + /* Snap the origin downward */ + mv->page->data -= mv->page->width*4; + mv->page->dy = mv->map->tiles->tileHeight; + + + /* draw the next row */ + y= 0; + omapDrawRow(mv, mv->tx-1 , mv->ty-1, y); + } +} + + +void +omapScrollDown(omap_view_t *mv, byte offset) { + word /*x,*/ y; /* coordinate for drawing */ + + /* increment the pixel position and update the page */ + mv->page->dy += offset; + + /* check to see if this changes the tile */ + if(mv->page->dy >= mv->dyThresh ) { + /* go down one tile */ + mv->ty++; + /* Snap the origin downward */ + mv->page->data += mv->page->width*4; + mv->page->dy = mv->map->tiles->tileHeight; + + + /* draw the next row */ + y= SCREEN_HEIGHT + mv->map->tiles->tileHeight; + omapDrawRow(mv, mv->tx-1 , mv->ty+15, y); + } + +} + + +void +omapGoTo(omap_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->dx = mv->map->tiles->tileWidth; + mv->page->dy = mv->map->tiles->tileHeight; + + /* set up the thresholds */ + mv->dxThresh = mv->map->tiles->tileWidth * 2; + mv->dyThresh = mv->map->tiles->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->ty-1; py < SCREEN_HEIGHT+mv->dyThresh && ty < mv->map->height; ty++, py+=mv->map->tiles->tileHeight) { + omapDrawRow(mv, tx-1, ty, py); + i+=mv->map->width - tx; + } +} + + +void +omapDrawTile(otiles_t *t, word i, page_t *page, word x, word y) { + word rx; + word ry; + rx = (i % t->cols) * t->tileWidth; + ry = (i / t->cols) * t->tileHeight; + modexDrawBmpRegion(page, x, y, rx, ry, t->tileWidth, t->tileHeight, t->data); +} + + +void +omapDrawRow(omap_view_t *mv, int tx, int ty, word y) { + word x; + int i; + + /* the position within the map array */ + i=ty * mv->map->width + tx; + for(x=0; xdxThresh && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) { + if(i>=0) { + /* we are in the map, so copy! */ + omapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y); + } + i++; /* next! */ + } +} + + +void +omapDrawCol(omap_view_t *mv, int tx, int ty, word x) { + int y; + int i; + + /* location in the map array */ + i=ty * mv->map->width + tx; + + /* We'll copy all of the columns in the screen, + i + 1 row above and one below */ + for(y=0; ydyThresh && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) { + if(i>=0) { + /* we are in the map, so copy away! */ + omapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y); + } + i += mv->map->width; + } +} diff --git a/src/lib/16_vl.h b/src/lib/16_vl.h index 9ad82384..64c309e7 100755 --- a/src/lib/16_vl.h +++ b/src/lib/16_vl.h @@ -180,7 +180,7 @@ page_t modexNextPageFlexibleSize(page_t *p, word x, word y); void modexCalcVmemRemain(video_t *video); void VL_Initofs(video_t *video); void modexHiganbanaPageSetup(global_game_variables_t *gvar); -//void modexShowPage(page_t *page); +void modexShowPage(page_t *page);//for 0croll.exe void VL_ShowPage(page_t *page, boolean vsync, boolean sr); void modexPanPage(page_t *page, int dx, int dy); void modexSelectPlane(byte plane); diff --git a/src/lib/16render.c b/src/lib/16render.c index 56abfb8f..d159c2a3 100755 --- a/src/lib/16render.c +++ b/src/lib/16render.c @@ -159,7 +159,7 @@ modexDrawBmpRegion(page_t *page, int x, int y, MOV ES, AX MOV DX, SC_INDEX ; point at the map mask register - MOV AL, MAP_MASK ; + MOV AL, SC_MAPMASK ; OUT DX, AL ; PLANE_LOOP: @@ -226,7 +226,7 @@ modexDrawSpriteRegion(page_t *page, int x, int y, MOV ES, AX MOV DX, SC_INDEX ; point at the map mask register - MOV AL, MAP_MASK ; + MOV AL, SC_MAPMASK ; OUT DX, AL ; PLANE_LOOP: @@ -305,7 +305,7 @@ modexDrawBmpPBufRegion(page_t *page, int x, int y, MOV ES, AX MOV DX, SC_INDEX ; point at the map mask register - MOV AL, MAP_MASK ; + MOV AL, SC_MAPMASK ; OUT DX, AL ; PLANE_LOOP: @@ -383,7 +383,7 @@ modexDrawSpritePBufRegion(page_t *page, int x, int y, MOV ES, AX MOV DX, SC_INDEX ; point at the map mask register - MOV AL, MAP_MASK ; + MOV AL, SC_MAPMASK ; OUT DX, AL ; PLANE_LOOP: