OSDN Git Service

p16 is being worked on a bunch by me wwww [16_ca needs huge amounts of work and I...
authorsparky4 <sparky4@cock.li>
Sat, 15 Apr 2017 15:17:06 +0000 (10:17 -0500)
committersparky4 <sparky4@cock.li>
Sat, 15 Apr 2017 15:17:06 +0000 (10:17 -0500)
16/src/lib/bitmap.c
16/src/lib/bitmap.h
makefile
src/0croll.c [new file with mode: 0755]
src/lib/16_vl.h
src/lib/16render.c

index 22bad98..6e49604 100755 (executable)
@@ -23,7 +23,7 @@
 #include <stdio.h>\r
 #include <stdlib.h>\r
 #include <malloc.h>\r
-#include "src/lib/bitmap.h"\r
+#include "16/src/lib/bitmap.h"\r
 #include "src/lib/16_mm.h"\r
 #include "src/lib/16_pm.h"\r
 #include "src/lib/16_ca.h"\r
@@ -197,3 +197,16 @@ bitmapLoadPcxTiles(char *filename, word twidth, word theight) {
 \r
        return ts;\r
 }\r
+\r
+byte *\r
+modexNewPal() {\r
+       byte *ptr;\r
+       ptr = malloc(PAL_SIZE);\r
+\r
+       // handle errors\r
+       if(!ptr) {\r
+               printf("Could not allocate palette.\n");\r
+       }\r
+\r
+       return ptr;\r
+}\r
index b35996d..d87356b 100755 (executable)
@@ -30,4 +30,5 @@
 \r
 bitmap_t bitmapLoadPcx(char *filename, global_game_variables_t *gv);\r
 tileset_t bitmapLoadPcxTiles(char *filename, word twidth, word theight);\r
+byte *modexNewPal();\r
 #endif\r
index 2fcfd8c..334e47f 100755 (executable)
--- 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 (executable)
index 0000000..844dc99
--- /dev/null
@@ -0,0 +1,369 @@
+//#include "modex16.h"\r
+#include "src/lib/16_vl.h"\r
+#include "16/src/lib/bitmap.h"\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+//#include "dos_kb.h"\r
+#define SCREEN_WIDTH 320\r
+#define SCREEN_HEIGHT 240\r
+\r
+//word far *clock= (word far*) 0x046C; /* 18.2hz clock */\r
+\r
+typedef struct {\r
+       bitmap_t *data;\r
+       word tileHeight;\r
+       word tileWidth;\r
+       unsigned int rows;\r
+       unsigned int cols;\r
+       unsigned int tilex,tiley; // tile position on the map\r
+} otiles_t;\r
+\r
+\r
+typedef struct {\r
+       byte    *data;\r
+       otiles_t *tiles;\r
+       int width;\r
+       int height;\r
+} omap_t;\r
+\r
+\r
+typedef struct {\r
+       omap_t *map;\r
+       page_t *page;\r
+       int tx; //???? appears to be the tile position on the viewable screen map\r
+       int ty; //???? appears to be the tile position on the viewable screen map\r
+       word dxThresh; //????\r
+       word dyThresh; //????\r
+} omap_view_t;\r
+\r
+struct {\r
+       int tx; //player position on the viewable map\r
+       int ty; //player position on the viewable map\r
+} player;\r
+\r
+\r
+omap_t allocMap(int w, int h);\r
+void oinitMap(omap_t *map);\r
+void omapScrollRight(omap_view_t *mv, byte offset);\r
+void omapScrollLeft(omap_view_t *mv, byte offest);\r
+void omapScrollUp(omap_view_t *mv, byte offset);\r
+void omapScrollDown(omap_view_t *mv, byte offset);\r
+void omapGoTo(omap_view_t *mv, int tx, int ty);\r
+void omapDrawTile(otiles_t *t, word i, page_t *page, word x, word y);\r
+void omapDrawRow(omap_view_t *mv, int tx, int ty, word y);\r
+void omapDrawCol(omap_view_t *mv, int tx, int ty, word x);\r
+\r
+//#define SWAP(a, b) tmp=a; a=b; b=tmp;\r
+void main() {\r
+       static global_game_variables_t gvar;\r
+//     int show1=1;\r
+//     int tx, ty;\r
+//     int x, y;\r
+       //int ch=0x0;\r
+//     byte ch;\r
+//     int q=0;\r
+       page_t screen;//,screen2;\r
+       omap_t map;\r
+       omap_view_t mv;//, mv2;\r
+       omap_view_t *draw;//, *show, *tmp;\r
+       byte *ptr;\r
+\r
+       //default player position on the viewable map\r
+       player.tx = 10;\r
+       player.ty = 8;\r
+\r
+//     setkb(1);\r
+       IN_Startup(&gvar);\r
+       /* create the map */\r
+       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\r
+       oinitMap(&map);\r
+       mv.map = &map;\r
+//     mv2.map = &map;\r
+\r
+       /* draw the tiles */\r
+       ptr = map.data;\r
+       modexEnter(1, 1, &gvar);\r
+       screen = modexDefaultPage(&screen, &gvar);\r
+       screen.width += (TILEWH*2);\r
+       mv.page = &screen;\r
+       omapGoTo(&mv, 16, 16);\r
+//     screen2=modexNextPage(mv.page);\r
+//     mv2.page = &screen2;\r
+//     omapGoTo(&mv2, 16, 16);\r
+//     modexShowPage(mv.page);\r
+\r
+       /* set up paging */\r
+//     show = &mv;\r
+//     draw = &mv2;\r
+       draw = &mv;\r
+\r
+       //TODO: set player position data here according to the viewable map screen thingy\r
+\r
+       while(!gvar.in.inst->Keyboard[sc_Escape]) {\r
+       //TODO: top left corner & bottem right corner of map veiw be set as map edge trigger since omapS are actually square\r
+       //to stop scrolling and have the player position data move to the edge of the screen with respect to the direction\r
+       //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\r
+       while(!gvar.in.inst->Keyboard[77]){\r
+//             for(q=0; q<TILEWH; q++) {\r
+               omapScrollRight(draw, 1);\r
+//             modexShowPage(draw->page);\r
+//             omapScrollRight(draw, 1);\r
+//             SWAP(draw, show);\r
+//             }\r
+       }\r
+\r
+       while(!gvar.in.inst->Keyboard[75]){\r
+//             for(q=0; q<TILEWH; q++) {\r
+               omapScrollLeft(draw, 1);\r
+//             modexShowPage(draw->page);\r
+//             omapScrollLeft(show, 1);\r
+//             SWAP(draw, show);\r
+//             }\r
+       }\r
+\r
+       while(!gvar.in.inst->Keyboard[80]){\r
+//             for(q=0; q<TILEWH; q++) {\r
+               omapScrollDown(draw, 1);\r
+//             modexShowPage(draw->page);\r
+//             omapScrollDown(show, 1);\r
+//             SWAP(draw, show);\r
+//             }\r
+       }\r
+\r
+       while(!gvar.in.inst->Keyboard[72]){\r
+//             for(q=0; q<TILEWH; q++) {\r
+               omapScrollUp(draw, 1);\r
+//             modexShowPage(draw->page);\r
+//             omapScrollUp(show, 1);\r
+//             SWAP(draw, show);\r
+//             }\r
+       }\r
+\r
+       //keyp(ch);\r
+       modexShowPage(draw->page);\r
+\r
+       }\r
+\r
+       modexLeave();\r
+\r
+//     setkb(0);\r
+       IN_Shutdown(&gvar);\r
+}\r
+\r
+\r
+omap_t\r
+allocMap(int w, int h) {\r
+       omap_t result;\r
+\r
+       result.width =w;\r
+       result.height=h;\r
+       result.data = malloc(sizeof(byte) * w * h);\r
+\r
+       return result;\r
+}\r
+\r
+\r
+void\r
+oinitMap(omap_t *map) {\r
+       /* just a place holder to fill out an alternating pattern */\r
+       int x, y;\r
+       int i;\r
+       int tile = 1;\r
+       map->tiles = malloc(sizeof(otiles_t));\r
+\r
+       /* create the tile set */\r
+       map->tiles->data = malloc(sizeof(bitmap_t));\r
+       map->tiles->data->width = (TILEWH*2);\r
+       map->tiles->data->height= TILEWH;\r
+       map->tiles->data->data = malloc((TILEWH*2)*TILEWH);\r
+       map->tiles->tileHeight = TILEWH;\r
+       map->tiles->tileWidth =TILEWH;\r
+       map->tiles->rows = 1;\r
+       map->tiles->cols = 2;\r
+\r
+       i=0;\r
+       for(y=0; y<TILEWH; y++) {\r
+       for(x=0; x<(TILEWH*2); x++) {\r
+               if(x<TILEWH)\r
+                 map->tiles->data->data[i] = 0x24;\r
+               else\r
+                 map->tiles->data->data[i] = 0x34;\r
+               i++;\r
+       }\r
+       }\r
+\r
+       i=0;\r
+       for(y=0; y<map->height; y++) {\r
+               for(x=0; x<map->width; x++) {\r
+                       map->data[i] = tile;\r
+                       tile = tile ? 0 : 1;\r
+                       i++;\r
+               }\r
+               tile = tile ? 0 : 1;\r
+       }\r
+}\r
+\r
+\r
+void\r
+omapScrollRight(omap_view_t *mv, byte offset) {\r
+       word x;//, y;  /* coordinate for drawing */\r
+\r
+       /* increment the pixel position and update the page */\r
+       mv->page->dx += offset;\r
+\r
+       /* check to see if this changes the tile */\r
+       if(mv->page->dx >= mv->dxThresh ) {\r
+       /* go forward one tile */\r
+       mv->tx++;\r
+       /* Snap the origin forward */\r
+       mv->page->data += 4;\r
+       mv->page->dx = mv->map->tiles->tileWidth;\r
+\r
+\r
+       /* draw the next column */\r
+       x= SCREEN_WIDTH + mv->map->tiles->tileWidth;\r
+               omapDrawCol(mv, mv->tx + 20 , mv->ty-1, x);\r
+       }\r
+}\r
+\r
+\r
+void\r
+omapScrollLeft(omap_view_t *mv, byte offset) {\r
+       //word x, y;  /* coordinate for drawing */\r
+\r
+       /* increment the pixel position and update the page */\r
+       mv->page->dx -= offset;\r
+\r
+       /* check to see if this changes the tile */\r
+       if(mv->page->dx == 0) {\r
+       /* go backward one tile */\r
+       mv->tx--;\r
+\r
+       /* Snap the origin backward */\r
+       mv->page->data -= 4;\r
+       mv->page->dx = mv->map->tiles->tileWidth;\r
+\r
+       /* draw the next column */\r
+               omapDrawCol(mv, mv->tx-1, mv->ty-1, 0);\r
+       }\r
+}\r
+\r
+\r
+void\r
+omapScrollUp(omap_view_t *mv, byte offset) {\r
+       word /*x,*/ y;  /* coordinate for drawing */\r
+\r
+       /* increment the pixel position and update the page */\r
+       mv->page->dy -= offset;\r
+\r
+       /* check to see if this changes the tile */\r
+       if(mv->page->dy == 0 ) {\r
+       /* go down one tile */\r
+       mv->ty--;\r
+       /* Snap the origin downward */\r
+       mv->page->data -= mv->page->width*4;\r
+       mv->page->dy = mv->map->tiles->tileHeight;\r
+\r
+\r
+       /* draw the next row */\r
+       y= 0;\r
+               omapDrawRow(mv, mv->tx-1 , mv->ty-1, y);\r
+       }\r
+}\r
+\r
+\r
+void\r
+omapScrollDown(omap_view_t *mv, byte offset) {\r
+       word /*x,*/ y;  /* coordinate for drawing */\r
+\r
+       /* increment the pixel position and update the page */\r
+       mv->page->dy += offset;\r
+\r
+       /* check to see if this changes the tile */\r
+       if(mv->page->dy >= mv->dyThresh ) {\r
+       /* go down one tile */\r
+       mv->ty++;\r
+       /* Snap the origin downward */\r
+       mv->page->data += mv->page->width*4;\r
+       mv->page->dy = mv->map->tiles->tileHeight;\r
+\r
+\r
+       /* draw the next row */\r
+       y= SCREEN_HEIGHT + mv->map->tiles->tileHeight;\r
+               omapDrawRow(mv, mv->tx-1 , mv->ty+15, y);\r
+       }\r
+\r
+}\r
+\r
+\r
+void\r
+omapGoTo(omap_view_t *mv, int tx, int ty) {\r
+       int /*px,*/ py;\r
+       unsigned int i;\r
+\r
+       /* set up the coordinates */\r
+       mv->tx = tx;\r
+       mv->ty = ty;\r
+       mv->page->dx = mv->map->tiles->tileWidth;\r
+       mv->page->dy = mv->map->tiles->tileHeight;\r
+\r
+       /* set up the thresholds */\r
+       mv->dxThresh = mv->map->tiles->tileWidth * 2;\r
+       mv->dyThresh = mv->map->tiles->tileHeight * 2;\r
+\r
+       /* draw the tiles */\r
+       modexClearRegion(mv->page, 0, 0, mv->page->width, mv->page->height, 0);\r
+       py=0;\r
+       i=mv->ty * mv->map->width + mv->tx;\r
+       for(ty=mv->ty-1; py < SCREEN_HEIGHT+mv->dyThresh && ty < mv->map->height; ty++, py+=mv->map->tiles->tileHeight) {\r
+               omapDrawRow(mv, tx-1, ty, py);\r
+       i+=mv->map->width - tx;\r
+       }\r
+}\r
+\r
+\r
+void\r
+omapDrawTile(otiles_t *t, word i, page_t *page, word x, word y) {\r
+       word rx;\r
+       word ry;\r
+       rx = (i % t->cols) * t->tileWidth;\r
+       ry = (i / t->cols) * t->tileHeight;\r
+       modexDrawBmpRegion(page, x, y, rx, ry, t->tileWidth, t->tileHeight, t->data);\r
+}\r
+\r
+\r
+void\r
+omapDrawRow(omap_view_t *mv, int tx, int ty, word y) {\r
+       word x;\r
+       int i;\r
+\r
+       /* the position within the map array */\r
+       i=ty * mv->map->width + tx;\r
+       for(x=0; x<SCREEN_WIDTH+mv->dxThresh && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {\r
+       if(i>=0) {\r
+               /* we are in the map, so copy! */\r
+               omapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);\r
+       }\r
+       i++; /* next! */\r
+       }\r
+}\r
+\r
+\r
+void\r
+omapDrawCol(omap_view_t *mv, int tx, int ty, word x) {\r
+       int y;\r
+       int i;\r
+\r
+       /* location in the map array */\r
+       i=ty * mv->map->width + tx;\r
+\r
+       /* We'll copy all of the columns in the screen,\r
+          i + 1 row above and one below */\r
+       for(y=0; y<SCREEN_HEIGHT+mv->dyThresh && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {\r
+       if(i>=0) {\r
+               /* we are in the map, so copy away! */\r
+               omapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);\r
+       }\r
+       i += mv->map->width;\r
+       }\r
+}\r
index 9ad8238..64c309e 100755 (executable)
@@ -180,7 +180,7 @@ page_t modexNextPageFlexibleSize(page_t *p, word x, word y);
 void modexCalcVmemRemain(video_t *video);\r
 void VL_Initofs(video_t *video);\r
 void modexHiganbanaPageSetup(global_game_variables_t *gvar);\r
-//void modexShowPage(page_t *page);\r
+void modexShowPage(page_t *page);//for 0croll.exe\r
 void VL_ShowPage(page_t *page, boolean vsync, boolean sr);\r
 void modexPanPage(page_t *page, int dx, int dy);\r
 void modexSelectPlane(byte plane);\r
index 56abfb8..d159c2a 100755 (executable)
@@ -159,7 +159,7 @@ modexDrawBmpRegion(page_t *page, int x, int y,
                MOV ES, AX\r
 \r
                MOV DX, SC_INDEX        ; point at the map mask register\r
-               MOV AL, MAP_MASK        ;\r
+               MOV AL, SC_MAPMASK      ;\r
                OUT DX, AL            ;\r
 \r
        PLANE_LOOP:\r
@@ -226,7 +226,7 @@ modexDrawSpriteRegion(page_t *page, int x, int y,
                MOV ES, AX\r
 \r
                MOV DX, SC_INDEX        ; point at the map mask register\r
-               MOV AL, MAP_MASK        ;\r
+               MOV AL, SC_MAPMASK      ;\r
                OUT DX, AL            ;\r
 \r
        PLANE_LOOP:\r
@@ -305,7 +305,7 @@ modexDrawBmpPBufRegion(page_t *page, int x, int y,
                MOV ES, AX\r
 \r
                MOV DX, SC_INDEX        ; point at the map mask register\r
-               MOV AL, MAP_MASK        ;\r
+               MOV AL, SC_MAPMASK      ;\r
                OUT DX, AL            ;\r
 \r
        PLANE_LOOP:\r
@@ -383,7 +383,7 @@ modexDrawSpritePBufRegion(page_t *page, int x, int y,
                MOV ES, AX\r
 \r
                MOV DX, SC_INDEX        ; point at the map mask register\r
-               MOV AL, MAP_MASK        ;\r
+               MOV AL, SC_MAPMASK      ;\r
                OUT DX, AL            ;\r
 \r
        PLANE_LOOP:\r