From: Jonathan Campbell Date: Fri, 8 Apr 2016 13:53:04 +0000 (-0700) Subject: Merge remote-tracking branch 'upstream/master' X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=7f10a2f8adaea4ec69576c0a8905fde6809ee27d;hp=be588c0302f1248c7100cd97ad5effe2af3563cf;p=16.git Merge remote-tracking branch 'upstream/master' --- diff --git a/design.txt b/design.txt index 3de430a7..a7ff175f 100755 --- a/design.txt +++ b/design.txt @@ -28,3 +28,32 @@ model, overriding certain functions as being near. In this manner, the stack ch in any code group, which the other code groups can still access. Alternatively, a command-line switch may be used to turn off stack checking, so no stack checking routines get called. " + + +00:00:19 joncampbell123 | okay you're makefile is already using -zu, -zff and other options that I'm │ + | sure would tell Watcom C to separate stack from data segment, but the MAP file │ + | says it's still associating STACK with DGROUP :( │ +00:08:56 joncampbell123 | argh │ +00:10:04 joncampbell123 | sparky, it's probably better to refactor your code not to require so much │ + | stack │ +00:10:20 joncampbell123 | in most of doslib I test and dev the code against far smaller stack sizes, │ + | usually 8KB │ +00:11:03 joncampbell123 | besides you don't want a stack that occupies 1/10th of all conventional memory │ + | in DOS, right? ^^ │ +00:11:50 joncampbell123 | 64KB is a more appropriate stack size if you're targeting 32-bit DOS or Win32, │ + | not 16-bit DOS │ +00:12:34 joncampbell123 | if you need so much storage please try using global variables or memory │ + | allocation, but don't eat up your stack like that │ +00:13:59 joncampbell123 | don't forget you can move a char[] declaration within your function off the │ + | stack by declaring it static │ +00:14:17 joncampbell123 | then it's a local variable that lives in the data segment, not stack + + +00:19:40 joncampbell123 | meaning you go through your functions, locate ones that declare a lot of local │ + | stack storage, │ +00:19:53 joncampbell123 | and refactor them to put the storage elsewhere, other than the stack │ +00:20:03 sparky4_derpy4 | joncampbell123: ah ok ^^ i will!!! │ +00:20:16 sparky4_derpy4 | joncampbell123: look for large variables too? ww │ +00:20:21 joncampbell123 | yes. │ +00:20:29 sparky4_derpy4 | scroll16 needs a bunch of work │ +00:20:29 joncampbell123 | the less you declare on the stack, the less stack the function needs. diff --git a/makefile b/makefile index e33d63e4..9da99872 100755 --- a/makefile +++ b/makefile @@ -64,7 +64,7 @@ UPXQ=-qqq AFLAGS=-mh -0 -d1 16FLAGS=-fh=16.hed BAKAPIFLAGS=-fh=bakapi.hed -SFLAGS=-sg -st -of+ -zu -zdf -zff -zgf -k55808#60000#32768 +SFLAGS=-sg -st -of+ -zu -zdf -zff -zgf -k40000#55808#60000#32768 DFLAGS=-DTARGET_MSDOS=16 -DMSDOS=1 $(SFLAGS) ZFLAGS=-zk0 -zc -zp8 $(WCLQ) ## -zm CFLAGS=$(AFLAGS) $(IFLAGS)-lr -l=dos -wo -i$(DOSLIB)##wwww @@ -433,8 +433,6 @@ clean: .symbolic @$(REMOVECOMMAND) *.MAP @$(REMOVECOMMAND) *.map @$(REMOVECOMMAND) *.err - @$(COPYCOMMAND) .git$(DIRSEP)config git_con.fig - @$(COPYCOMMAND) .gitmodules git_modu.les @cd $(DOSLIB) #@./buildall.sh clean @cd $(PDIR)$(PDIR)$(PDIR) @@ -448,6 +446,10 @@ clean: .symbolic # @echo $(watcom) # @echo $(INCLUDE) +backupconfig: .symbolic + @$(COPYCOMMAND) .git$(DIRSEP)config git_con.fig + @$(COPYCOMMAND) .gitmodules git_modu.les + comp: .symbolic @upx -9 $(EXEC) diff --git a/src/bakapi.c b/src/bakapi.c index c6ae3ce3..6d04e547 100755 --- a/src/bakapi.c +++ b/src/bakapi.c @@ -36,6 +36,8 @@ main(int argc, char *argvar[]) { char *a; int i; + word panq=1, pand=0; + boolean panswitch=0; // allow changing default mode from command line for (i=1;i < argc;) { @@ -123,18 +125,75 @@ main(int argc, char *argvar[]) #ifdef BOINK while(d>0) // on! { + int c; /* run screensaver routine until keyboard input */ while (key > 0) { if (kbhit()) { - getch(); // eat keyboard input - break; + if(!panswitch) + { + getch(); // eat keyboard input + break; + }else c=getch(); } - ding(&gvar.video.page[0], &bakapee, key); + if(!panswitch) ding(&gvar.video.page[0], &bakapee, key); + else ding(&gvar.video.page[0], &bakapee, 2); + if(panswitch!=0) + { + //right movement + if((c==0x4d && pand == 0) || pand == 2) + { + if(pand == 0){ pand = 2; } + if(panq<=(TILEWH/(4))) + { + gvar.video.page[0].dx++; + modexShowPage(&gvar.video.page[0]); + panq++; + } else { panq = 1; pand = 0; } + } + //left movement + if((c==0x4b && pand == 0) || pand == 4) + { + if(pand == 0){ pand = 4; } + if(panq<=(TILEWH/(4))) + { + gvar.video.page[0].dx--; + modexShowPage(&gvar.video.page[0]); + panq++; + } else { panq = 1; pand = 0; } + } + //down movement + if((c==0x50 && pand == 0) || pand == 3) + { + if(pand == 0){ pand = 3; } + if(panq<=(TILEWH/(4))) + { + gvar.video.page[0].dy++; + modexShowPage(&gvar.video.page[0]); + panq++; + } else { panq = 1; pand = 0; } + } + //up movement + if((c==0x48 && pand == 0) || pand == 1) + { + if(pand == 0){ pand = 1; } + if(panq<=(TILEWH/(4))) + { + gvar.video.page[0].dy--; + modexShowPage(&gvar.video.page[0]); + panq++; + } else { panq = 1; pand = 0; } + } + if(c==0x71 || c==0xb1 || c=='p') + { + //getch(); // eat keyboard input + panswitch=0; + break; // 'q' or 'ESC' or 'p' + } + } } { - int c; // this code is written around modex16 which so far is a better fit than using DOSLIB vga directly, so leave MXLIB code in. // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C. @@ -143,6 +202,17 @@ main(int argc, char *argvar[]) //fprintf(stderr, "xx=%d yy=%d tile=%d\n", bakapee.xx, bakapee.yy, bakapee.tile); printf("Tiled mode is "); switch (bakapee.tile) + { + case 0: + printf("off. "); + break; + case 1: + printf("on. "); + break; + } + //printf("\n"); + printf("Pan mode is "); + switch (panswitch) { case 0: printf("off.\n"); @@ -152,13 +222,25 @@ main(int argc, char *argvar[]) break; } printf("Enter 1, 2, 3, 4, 5, 6, 8, or 9 to run a screensaver, or enter 0 to quit.\n"); - +pee: c = getch(); switch (c) { case 27: /* Escape key */ case '0': d=0; break; + case 'p': // test pan + switch (panswitch) + { + case 0: + panswitch=1; + break; + case 1: + panswitch=0; + break; + } + goto pee; + break; case 'b': // test tile change switch (bakapee.tile) { @@ -200,77 +282,33 @@ main(int argc, char *argvar[]) // TODO: This is a testing sextion for textrendering and panning for project 16 --sparky4 while(1) { // conditions of screen saver - while(!kbhit()) - { - ding(&gvar.video.page[0], &bakapee, key); - } +// while(!kbhit()) +// { +// ding(&gvar.video.page[0], &bakapee, key); +// } //end of screen savers - /*for(int x = 0; x < gvar.video.page[0].width; ++x) - { - modexputPixel(&page, x, 0, 15); - mxPutPixel(x, gvar.video.page[0].height-1, 15); - } - for (int y = 0; y < VH; ++y) - { - mxPutPixel(0, y, 15); - mxPutPixel(gvar.video.page[0].width-1, y, 15); - } - for (int x = 0; x < VW; ++x) - { - mxPutPixel(x, 0, 15); - mxPutPixel(x, VH-1, 15); - } - for (int y = 240; y < VH; ++y) - { - mxPutPixel(0, y, 15); - mxPutPixel(VW-1, y, 15); - }*/ - pdump(&gvar.video.page[0]); - getch(); - //text box - /*++++mxBitBlt(xpos, ypos+(TILEWH*12), gvar.video.page[0].width, TILEWH*BUFFMX, 0, BS); //copy background - mxFillBox(xpos, ypos+(TILEWH*12), gvar.video.page[0].width, TILEWH*BUFFMX, 0, OP_SET); // background for text box - //+(QUADWH*6) - mxOutText(xpos+1, ypos+gvar.video.page[0].height-48, "========================================"); - mxOutText(xpos+1, ypos+gvar.video.page[0].height-40, "| |Chikyuu:$line1"); - mxOutText(xpos+1, ypos+gvar.video.page[0].height-32, "| |$line2"); - mxOutText(xpos+1, ypos+gvar.video.page[0].height-24, "| |$line3"); - mxOutText(xpos+1, ypos+gvar.video.page[0].height-16, "| |$line4"); - mxOutText(xpos+1, ypos+gvar.video.page[0].height-8, "========================================"); - mxFillBox(xpos+QUADWH, ypos+QUADWH+(TILEWH*12), TILEWH*2, TILEWH*2, 9, OP_SET); //portriat~ - getch(); - mxBitBlt(0, BS, gvar.video.page[0].width, TILEWH*BUFFMX, xpos, ypos+(TILEWH*12)); //copy background - getch();++++*/ - while(!kbhit()) - { - //for(int i=0;i(VW-gvar.video.page[0].width-1)) || (xpos<1))delay(500); - //mxWaitRetrace(); -//mxBitBlt(32, (gvar.video.page[0].height+32), gvar.video.page[0].width, gvar.video.page[0].height, xpos, ypos); -//++++mxBitBlt(TILEWH*2, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, TILEWH*2, TILEWH*2); -//xpos=ypos=TILEWH*2; - //????modexPanPage(&gvar.video.page[0], 32, 32); - //} - if( (xpos>(VW-gvar.video.page[0].width-1)) || (xpos<1)){xdir=-xdir;} - if( (ypos>(BH-gvar.video.page[0].height-1)) || (ypos<1)){ydir=-ydir;} // { Hit a boundry, change - //}// direction! -//mxBitBlt(32, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, xpos, ypos); -//mxBitBlt(TILEWH*2, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, TILEWH*2, TILEWH*2); - } - ch=getch(); + //pdump(&gvar.video.page[0]); + +// mxOutText(xpos+1, ypos+gvar.video.page[0].height-48, "========================================"); +// mxOutText(xpos+1, ypos+gvar.video.page[0].height-40, "| |Chikyuu:$line1"); +// mxOutText(xpos+1, ypos+gvar.video.page[0].height-32, "| |$line2"); +// mxOutText(xpos+1, ypos+gvar.video.page[0].height-24, "| |$line3"); +// mxOutText(xpos+1, ypos+gvar.video.page[0].height-16, "| |$line4"); +// mxOutText(xpos+1, ypos+gvar.video.page[0].height-8, "========================================"); + + ding(&gvar.video.page[0], &bakapee, key); + modexPanPage(&gvar.video.page[0], xpos, ypos); + c = getch(); + +// xpos+=xdir; +// ypos+=ydir; +// if( (xpos>(VW-gvar.video.page[0].width-1)) || (xpos<1)){xdir=-xdir;} +// if( (ypos>(BH-gvar.video.page[0].height-1)) || (ypos<1)){ydir=-ydir;} +// ch=getch(); if(ch==0x71)break; // 'q' if(ch==0x1b)break; // 'ESC' } -// VGAmodeX(0, &gvar); + VGAmodeX(0, 1, &gvar); #endif // defined(BOINK) printf("bakapi ver. 1.04.16.04\nis made by sparky4i†ƒÖ…j feel free to use it ^^\nLicence: GPL v3\n"); printf("compiled on 2016/04/04\n"); diff --git a/src/bakapi.h b/src/bakapi.h index 70b2f2ab..729e3b19 100755 --- a/src/bakapi.h +++ b/src/bakapi.h @@ -25,6 +25,7 @@ #include "src/lib/bakapee.h" +//project 16 testing define switch for veiwing the contents of the video memory #define BOINK // what does this mean? --J.C. #endif /*__BAKAPI_H_*/ diff --git a/src/inputest.c b/src/inputest.c index edd86d62..44195363 100755 --- a/src/inputest.c +++ b/src/inputest.c @@ -31,7 +31,7 @@ main(int argc, char *argv[]) player_t player[MaxPlayers]; //extern struct inconfig inpu; testkeyin=0; - testcontrolnoisy=1; + testcontrolnoisy=0; testctrltype=1; IN_Startup(); IN_Default(0,&player,ctrl_Joystick1); diff --git a/src/lib/doslib b/src/lib/doslib index b84bf02a..3c110fd2 160000 --- a/src/lib/doslib +++ b/src/lib/doslib @@ -1 +1 @@ -Subproject commit b84bf02ac8fffdfc6ff569a36efe57ed3a450ef0 +Subproject commit 3c110fd249406b11b5301568b7c69d961fb91e79 diff --git a/src/lib/modex16.c b/src/lib/modex16.c index 0d106037..a2152825 100755 --- a/src/lib/modex16.c +++ b/src/lib/modex16.c @@ -62,11 +62,7 @@ void VGAmodeX(sword vq, boolean cmem, global_game_variables_t *gv) static void vgaSetMode(byte mode) { - union REGS regs; - - regs.h.ah = SET_MODE; - regs.h.al = mode; - int86(VIDEO_INT, ®s, ®s); + int10_setmode(mode); } //--------------------------------------------------- @@ -74,15 +70,10 @@ vgaSetMode(byte mode) // Use the bios to get the current video mode // -long +long/*FIXME: why long? "long" is 32-bit datatype, VGA modes are 8-bit numbers. */ vgaGetMode() { - union REGS rg; - - rg.h.ah = 0x0f; - int86(VIDEO_INT, &rg, &rg); - - return rg.h.al; + return int10_getmode(); } /* -========================= Entry Points ==========================- */ @@ -90,9 +81,13 @@ void modexEnter(sword vq, boolean cmem, global_game_variables_t *gv) { word i; dword far*ptr=(dword far*)VGA; /* used for faster screen clearing */ + struct vga_mode_params cm; int CRTParmCount; - /* common mode X initiation stuff~ */ - modexsetBaseXMode(); + + vgaSetMode(VGA_256_COLOR_MODE); + vga_enable_256color_modex(); + update_state_from_vga(); + vga_read_crtc_mode(&cm); switch(vq) { @@ -102,106 +97,46 @@ void modexEnter(sword vq, boolean cmem, global_game_variables_t *gv) gv->video.page[0].sw=vga_state.vga_width = 320; // VGA lib currently does not update this gv->video.page[0].sh=vga_state.vga_height = 240; // VGA lib currently does not update this - /* send the CRTParms */ - /*for(i=0; ivideo.page[0].sw=120; - gv->video.page[0].sh=160; - - /* send the CRTParms */ - for(i=0; ivideo.page[0].sw=320; - gv->video.page[0].sh=200; - - /* send the CRTParms */ - for(i=0; ivideo.page[0].sw=192; - gv->video.page[0].sh=144; - - /* send the CRTParms */ - for(i=0; ivideo.page[0].sw=256; - gv->video.page[0].sh=192; - - /* send the CRTParms */ - for(i=0; ivideo.page[0].tilesw = gv->video.page[0].sw/TILEWH; @@ -218,46 +153,13 @@ modexLeave() { vgaSetMode(TEXT_MODE); } -// setBaseXMode() does the initialization to make the VGA ready to -// accept any combination of configuration register settings. This -// involves enabling writes to index 0 to 7 of the CRT controller (port -// 0x3D4), by clearing the most significant bit (bit 7) of index 0x11. -void -modexsetBaseXMode() -{ - /* TODO save current video mode and palette */ - vgaSetMode(VGA_256_COLOR_MODE); - - vga_enable_256color_modex(); - - /* disable chain4 mode */ - //outpw(SC_INDEX, 0x0604); - - /* synchronous reset while setting Misc Output */ - //outpw(SC_INDEX, 0x0100); - - /* select 25 MHz dot clock & 60 Hz scanning rate */ - outp(MISC_OUTPUT, 0xe3); - - /* undo reset (restart sequencer) */ - //outpw(SC_INDEX, 0x0300); - - /* reprogram the CRT controller */ - outp(CRTC_INDEX, 0x11); /* VSync End reg contains register write prot */ -// temp = inp(CRTC_DATA) & 0x7F; -// outp(CRTC_INDEX, 0x11); - outp(CRTC_DATA, 0x7f); /* get current write protect on varios regs */ -// outp(CRTC_DATA, temp); /* get current write protect on varios regs */ - update_state_from_vga(); -} - page_t modexDefaultPage(page_t *p) { page_t page; /* default page values */ - page.data = VGA; + page.data = vga_state.vga_graphics_ram;//VGA; page.dx = 0; page.dy = 0; page.sw = p->sw; diff --git a/src/lib/modex16.h b/src/lib/modex16.h index fff256c3..94a69ad5 100755 --- a/src/lib/modex16.h +++ b/src/lib/modex16.h @@ -31,20 +31,17 @@ #include "src/lib/modex16/16planar.h" #include "src/lib/16text.h" #include "src/lib/modex16/16render.h" -#include "src/lib/modex16/320x240.h" -#include "src/lib/modex16/320x200.h" -#include "src/lib/modex16/256x192.h" -#include "src/lib/modex16/192x144_.h" -#include "src/lib/modex16/160x120.h" +// #include "src/lib/modex16/320x240.h" +// #include "src/lib/modex16/320x200.h" +// #include "src/lib/modex16/256x192.h" +// #include "src/lib/modex16/192x144_.h" +// #include "src/lib/modex16/160x120.h" #include #include #include #include -//TODO dos lib vga implementation ^^ -//#define DOSLIBVGA - static struct pcxHeader { byte id; byte version; diff --git a/src/scroll.c b/src/scroll.c index 5b480cf8..53b86d6b 100755 --- a/src/scroll.c +++ b/src/scroll.c @@ -64,6 +64,27 @@ void main(int argc, char *argv[]) if(argv[1]) bakapee = atoi(argv[1]); else bakapee = 1; + // DOSLIB: check our environment + probe_dos(); + + // DOSLIB: what CPU are we using? + // NTS: I can see from the makefile Sparky4 intends this to run on 8088 by the -0 switch in CFLAGS. + // So this code by itself shouldn't care too much what CPU it's running on. Except that other + // parts of this project (DOSLIB itself) rely on CPU detection to know what is appropriate for + // the CPU to carry out tasks. --J.C. + cpu_probe(); + + // DOSLIB: check for VGA + if (!probe_vga()) { + printf("VGA probe failed\n"); + return; + } + // hardware must be VGA or higher! + if (!(vga_state.vga_flags & VGA_IS_VGA)) { + printf("This program requires VGA or higher graphics hardware\n"); + return; + } + testcontrolnoisy=0; player[0].persist_aniframe=0; @@ -73,7 +94,6 @@ void main(int argc, char *argv[]) printf("starting timer "); start_timer(&gvar); printf("ok\n"); - //extern struct inconfig inpu; // atexit(qclean()); @@ -93,14 +113,14 @@ void main(int argc, char *argv[]) //mappalptr = map.tiles->btdata->palette; /* data */ - p = bitmapLoadPcx("data/ptmp.pcx"); // load sprite + //++++p = bitmapLoadPcx("data/ptmp.pcx"); // load sprite //npctmp = bitmapLoadPcx("ptmp1.pcx"); // load sprite /* create the planar buffer */ ////++++ (player[0].data) = *planar_buf_from_bitmap(&p); - printf("load pee!! "); + /*++++printf("load pee!! "); pp = planar_buf_from_bitmap(&p); - printf("done!\n"); + printf("done!\n");*/ #endif /* input! */