From: sparky4 Date: Tue, 15 Jul 2014 19:32:58 +0000 (-0500) Subject: modified: 16/DOS_GFX.EXE X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=52275bd67b49fbf71b94d63d7d9e5d5a933744b7;p=16.git modified: 16/DOS_GFX.EXE modified: 16/Project 16.bfproject new file: 16/chikyuu.pcx modified: 16/dos_gfx.cpp modified: 16/dos_gfx.h new file: 16/lib/MODEX16.C new file: 16/lib/MODEX16.H new file: 16/lib/TYPES.H modified: 16/lib/lib_com.cpp modified: 16/lib/lib_com.h deleted: 16/modex16/MODEX16.OBJ modified: 16/modex16/PCXTEST.C modified: 16/modex16/PCXTEST.EXE deleted: 16/modex16/PCXTEST.OBJ deleted: 16/modex16/TEST.OBJ modified: 16/x.bat --- diff --git a/16/DOS_GFX.EXE b/16/DOS_GFX.EXE index 08b7ecdf..586644a4 100644 Binary files a/16/DOS_GFX.EXE and b/16/DOS_GFX.EXE differ diff --git a/16/Project 16.bfproject b/16/Project 16.bfproject index b971d1a7..2e220aa5 100644 --- a/16/Project 16.bfproject +++ b/16/Project 16.bfproject @@ -1,23 +1,19 @@ c2e.convert_special: 0 e2c.convert_num: 0 -openfiles: /dos/z/16/16/dos_gfx.cpp:9835:9075:0: -openfiles: /dos/z/16/16/dos_gfx.h:391:285:0: +openfiles: /dos/z/16/16/dos_gfx.cpp:150:0:0: +openfiles: /dos/z/16/16/dos_gfx.h:156:0:0: openfiles: /dos/z/16/16/dos_kb.c:1039:46:0: openfiles: /dos/z/16/16/dos_kb.h:23:0:0: -openfiles: /dos/z/16/16/lib/lib_com.cpp:0:0:0: -openfiles: /dos/z/16/16/lib/lib_com.h:2503:1416:0: +openfiles: /dos/z/16/16/lib/lib_com.cpp:2:0:0: +openfiles: /dos/z/16/16/lib/lib_com.h:160:0:0: openfiles: /dos/z/16/16/scroll.txt:5256:4537:0: openfiles: /dos/z/16/16/project16.txt:8063:6091:0: openfiles: /dos/z/16/16/16.txt:0:0:0: -openfiles: /dos/z/16/16/lib/x/MODEX.H:3164:2733:0: -openfiles: /dos/z/16/16/lib/intro/lib.c:2412:1757:0: -openfiles: /dos/z/16/src/lib/dos_gfx.cpp:2364:1106:0: -openfiles: /dos/z/16/src/lib/dos_gfx.h:0:0:0: -openfiles: /dos/z/16/16/lib/x/MXBB.ASM:559:0:0: -openfiles: /dos/z/16/16/scrasm/MAIN.ASM:4251:1619:0: -openfiles: /dos/z/16/16/modex16/PCXTEST.C:1106:518:0: -openfiles: /dos/z/16/16/modex16/MODEX16.C:3919:3533:1: -openfiles: /dos/z/16/16/modex16/MODEX16.H:1533:436:0: +openfiles: /dos/z/16/16/lib/x/MODEX.H:5511:4684:0: +openfiles: /dos/z/16/16/modex16/PCXTEST.C:1143:421:0: +openfiles: /dos/z/16/16/lib/MODEX16.C:141:0:0: +openfiles: /dos/z/16/16/lib/MODEX16.H:444:0:0: +openfiles: /dos/z/16/16/lib/TYPES.H:277:0:1: snr_recursion_level: 0 convertcolumn_horizontally: 0 adv_open_matchname: 0 @@ -29,10 +25,10 @@ view_left_panel: 0 default_mime_type: text/plain e2c.convert_xml: 1 c2e.convert_iso: 0 -opendir: file:///dos/z/16/16/modex16 +opendir: file:///dos/z/16/16/lib wrap_text_default: 0 bookmarks_filename_mode: 1 -ssearch_text: modexDrawBm +ssearch_text: bitmap_t snr_casesens: 0 view_blocks: 1 name: project 16 @@ -52,11 +48,6 @@ ssearch_regex: 0 e2c.convert_iso: 0 ssearch_casesens: 0 charmap_block: 1 -recent_files: file:///dos/z/4x4_16/tauron/C_SRC/MAINC.CPP -recent_files: file:///dos/z/4x4_16/tauron/C_SRC/PALETTE.INC -recent_files: file:///dos/z/4x4_16/tauron/C_SRC/TAURON.H -recent_files: file:///dos/z/4x4_16/tauron/C_SRC/CLEAR.CPP -recent_files: file:///dos/z/4x4_16/tauron/C_SRC/MODES_C.INC recent_files: file:///dos/z/4x4_16/tauron/C_SRC/TESTS.CPP recent_files: file:///dos/z/4x4_16/tauron/C_SRC/MODES.CPP recent_files: file:///dos/z/4x4_16/tauron/C_SRC/FONT1.H @@ -102,8 +93,13 @@ recent_files: file:///dos/z/16/16/lib/intro/lib.c recent_files: file:///dos/z/16/src/lib/dos_gfx.cpp recent_files: file:///dos/z/16/16/modex16/MODEX16.H recent_files: file:///dos/z/16/16/modex16/MODEX16.C +recent_files: file:///dos/z/4x4_16/w_modex/MODEX.CPP +recent_files: file:///dos/z/16/16/TYPES.H +recent_files: file:///dos/z/16/16/lib/MODEX16.H +recent_files: file:///dos/z/16/16/lib/TYPES.H +recent_files: file:///dos/z/16/16/lib/MODEX16.C snr_replacetype: 0 -savedir: file:///dos/z/16/16/modex16 +savedir: file:///dos/z/16/16/lib spell_check_default: 1 spell_insert_entities: 0 last_filefilter: @@ -113,21 +109,21 @@ snr_escape_chars: 0 htmlbar_view: 0 spell_lang: en ssearch_dotmatchall: 0 -searchlist: q -searchlist: sx -searchlist: bit -searchlist: mxBitBlt -searchlist: #ifdef TESTING -searchlist: BUFFMX -searchlist: (TILEWH*2)) -searchlist: VH -searchlist: mxSetClipRegion -searchlist: mxFillBox( -searchlist: OP_SET -searchlist: mxBitBlt( MXSINT sx, MXSINT sy, MXUINT width, MXUINT height, MXSINT dx, MXSINT dy ); -searchlist: mxpt -searchlist: printf -searchlist: modexDrawBm +searchlist: main +searchlist: word +searchlist: syte +searchlist: unsigned short +searchlist: syte +searchlist: unsigned int +searchlist: #include "src\\lib\\lib_com.h" +searchlist: word +searchlist: sy +searchlist: word +searchlist: VGA +searchlist: Page +searchlist: modexll +searchlist: load +searchlist: bitmap_t autocomplete: 1 outputb_show_all_output: 0 bookmarks_show_mode: 0 diff --git a/16/chikyuu.pcx b/16/chikyuu.pcx new file mode 100644 index 00000000..61eac4cc Binary files /dev/null and b/16/chikyuu.pcx differ diff --git a/16/dos_gfx.cpp b/16/dos_gfx.cpp index 7e3327b5..268b99ae 100644 --- a/16/dos_gfx.cpp +++ b/16/dos_gfx.cpp @@ -1,7 +1,8 @@ //DOS Graphics thingy by sparky4 licence GPL v2 //a special thanks to everyone to release source code for mode X /*src\lib\*/ -#include "dos_gfx.h" +#include "dos_gfx.h" +//#include "lib\modex16.h" //____ int old_mode; //color ‚Ä‚·‚Æ @@ -9,7 +10,7 @@ short gq = LGQ; //‚Ä‚·‚Æ short bakax = 0, bakay = 0; -syte xx = rand()&0%SW, yy = rand()&0%SH, sx = 0, sy = 0; +word xx = rand()&0%SW, yy = rand()&0%SH, sx = 0, sy = 0; byte coor; byte *vga = (byte *) MK_FP(0xA000, 0); @@ -284,7 +285,9 @@ short ding(int q){ */ int main(void) - { + { + //bitmap_t bmp; //____ + //bmp = modexLoadPcx("chikyuu.pcx"); //____ short key,d,xpos,ypos,xdir,ydir; int ch=0x0; // main variables @@ -294,7 +297,10 @@ int main(void) ypos=TILEWH*2; xdir=1; ydir=1; - setvideo(1); + setvideo(1); + //modexPalUpdate(bmp.palette); //____ + //modexDrawBmp(VGA, 0, 0, &bmp, 0); //____ + //getch(); //____ // screen savers /*while(d!=0){ // on! diff --git a/16/dos_gfx.h b/16/dos_gfx.h index 70bddb63..6c59aa78 100644 --- a/16/dos_gfx.h +++ b/16/dos_gfx.h @@ -3,7 +3,8 @@ #include #include #include "lib\lib_com.h" -#include "lib\x\modex.h" +#include "lib\x\modex.h" +//#include "lib\modex16.h" //____ #define NUM_COLORS 256 // number of colors in vga mode //static lgq=NUM_COLORS/(1/8) diff --git a/16/lib/MODEX16.C b/16/lib/MODEX16.C new file mode 100644 index 00000000..3bdc3fb7 --- /dev/null +++ b/16/lib/MODEX16.C @@ -0,0 +1,420 @@ +#include +#include +#include +#include +#include +#include +#include "lib\modex16.h" + + +byte far* VGA=(byte far*) 0xA0000000; /* this points to video memory. */ + +static void fadePalette(sbyte fade, sbyte start, word iter, byte *palette); +static byte tmppal[PAL_SIZE]; +static struct pcxHeader { + byte id; + byte version; + byte encoding; + byte bpp; + word xmin; + word ymin; + word xmax; + word ymax; + word hres; + word vres; + byte pal16[48]; + byte res1; + word bpplane; + word palType; + word hScreenSize; + word vScreenSize; + byte padding[54]; +}; + + +static void +vgaSetMode(byte mode) +{ + union REGS regs; + + regs.h.ah = SET_MODE; + regs.h.al = mode; + int86(VIDEO_INT, ®s, ®s); +} + + +/* -========================= Entry Points ==========================- */ +void +modexEnter() { + word i; + dword far*ptr=(dword far*)VGA; /* used for faster screen clearing */ + word CRTParms[] = { + 0x0d06, /* vertical total */ + 0x3e07, /* overflow (bit 8 of vertical counts) */ + 0x4109, /* cell height (2 to double-scan */ + 0xea10, /* v sync start */ + 0xac11, /* v sync end and protect cr0-cr7 */ + 0xdf12, /* vertical displayed */ + 0x0014, /* turn off dword mode */ + 0xe715, /* v blank start */ + 0x0616, /* v blank end */ + 0xe317 /* turn on byte mode */ + }; + int CRTParmCount = sizeof(CRTParms) / sizeof(CRTParms[0]); + + /* TODO save current video mode and palette */ + vgaSetMode(VGA_256_COLOR_MODE); + + /* 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 */ + outp(CRTC_DATA, 0x7f); /* get current write protect on varios regs */ + + /* send the CRTParms */ + for(i=0; iwidth; px+=4) { + offset=px; + for(py=0; pyheight; py++) { + if(!sprite || bmp->data[offset]) + page[PAGE_OFFSET(x+px, y+py)] = bmp->data[offset]; + offset+=bmp->width; + } + } + } +} + + +/* fade and flash */ +void +modexFadeOn(word fade, byte *palette) { + fadePalette(-fade, 64, 64/fade+1, palette); +} + + +void +modexFadeOff(word fade, byte *palette) { + fadePalette(fade, 0, 64/fade+1, palette); +} + + +void +modexFlashOn(word fade, byte *palette) { + fadePalette(fade, -64, 64/fade+1, palette); +} + + +void +modexFlashOff(word fade, byte *palette) { + fadePalette(-fade, 0, 64/fade+1, palette); +} + + +static void +fadePalette(sbyte fade, sbyte start, word iter, byte *palette) { + word i; + byte dim = start; + + /* handle the case where we just update */ + if(iter == 0) { + modexPalUpdate(palette); + return; + } + + while(iter > 0) { /* FadeLoop */ + for(i=0; i 127) { + tmppal[i] = 0; + } else if(tmppal[i] > 63) { + tmppal[i] = 63; + } + } + modexPalUpdate(tmppal); + iter--; + dim += fade; + } +} + + +/* save and load */ +void +modexPalSave(byte *palette) { + int i; + + outp(PAL_READ_REG, 0); /* start at palette entry 0 */ + for(i=0; i> 2; + } + } else { + /* use the 16 color palette */ + for(index=0; index<48; index++) { + result.palette[index] = head.pal16[index]; + } + } + + fclose(file); + + return result; +} diff --git a/16/lib/MODEX16.H b/16/lib/MODEX16.H new file mode 100644 index 00000000..880f2c8b --- /dev/null +++ b/16/lib/MODEX16.H @@ -0,0 +1,79 @@ +/* + * Functions for handling modex and doing other basic graphics stuff. + */ +#ifndef MODEX16_H +#define MODEX16_H +#include +#include "lib\types.h" + +/* -========================== Types & Macros ==========================- */ +#define PAGE_OFFSET(x,y) (((y)<<6)+((y)<<4)+((x)>>2)) +#define PLANE(x) (1<< (x&3)) +typedef byte far* page_t; +#define SELECT_ALL_PLANES() outpw(0x03c4, 0xff02) +typedef struct { + byte *data; + word width; + word height; + byte *palette; +} bitmap_t; + +/* -============================ Functions =============================- */ +/* mode switching, page, and plane functions */ +void modexEnter(); +void modexLeave(); +void modexShowPage(page_t page); +void modexPanPage(page_t *page, int dx, int dy); +void modexSelectPlane(byte plane); +void modexClearRegion(page_t page, int x, int y, int w, int h, byte color); +void modexDrawBmp(page_t page, int x, int y, bitmap_t *bmp, byte sprite); + +/* Palette fade and flash effects */ +void modexFadeOn(word fade, byte *palette); +void modexFadeOff(word fade, byte *palette); +void modexFlashOn(word fade, byte *palette); +void modexFlashOff(word fade, byte *palette); + +/* palette loading and saving */ +void modexPalSave(byte *palette); +byte *modexNewPal(); +void modexLoadPalFile(char *filename, byte **palette); +void modexSavePalFile(char *filename, byte *palette); + +/* fixed palette functions */ +void modexPalBlack(); +void modexPalWhite(); + +/* utility functions */ +void modexPalUpdate(byte *p); +void modexWaitBorder(); + +/* bitmap functions */ +bitmap_t modexLoadPcx(char *filename); + +/* -======================= Constants & Vars ==========================- */ +extern byte far* VGA; /* The VGA Memory */ +#define VIDEO_INT 0x10 +#define SET_MODE 0x00 +#define VGA_256_COLOR_MODE 0x13 +#define TEXT_MODE 0x03 +#define SCREEN_WIDTH 320 +#define SCREEN_HEIGHT 240 +#define PAGE_SIZE (word)(SCREEN_WIDTH/4 * SCREEN_HEIGHT) + +#define SC_INDEX 0x03c4 +#define SC_DATA 0x03c5 +#define CRTC_INDEX 0x03d4 +#define CRTC_DATA 0x03d5 +#define MISC_OUTPUT 0x03c2 +#define HIGH_ADDRESS 0x0C +#define LOW_ADDRESS 0x0D +#define VRETRACE 0x08 +#define INPUT_STATUS_1 0x03da +#define DISPLAY_ENABLE 0x01 +#define MAP_MASK 0x02 +#define PAL_READ_REG 0x03C7 /* Color register, read address */ +#define PAL_WRITE_REG 0x03C8 /* Color register, write address */ +#define PAL_DATA_REG 0x03C9 /* Color register, data port */ +#define PAL_SIZE (256 * 3) +#endif diff --git a/16/lib/TYPES.H b/16/lib/TYPES.H new file mode 100644 index 00000000..f6443b1b --- /dev/null +++ b/16/lib/TYPES.H @@ -0,0 +1,11 @@ +/* + * Just some handy typedefs that make it easier to think about the low + * level code + */ + +typedef unsigned char byte; +typedef unsigned short word; +typedef unsigned long dword; +typedef signed char sbyte; +typedef signed short sword; +typedef signed long sdword; diff --git a/16/lib/lib_com.cpp b/16/lib/lib_com.cpp index b9851613..19ad2ddf 100644 --- a/16/lib/lib_com.cpp +++ b/16/lib/lib_com.cpp @@ -1,4 +1,5 @@ -#include "src\lib\lib_com.h" +//#include "src\lib\lib_com.h" +#include "lib\lib_com.h" /* local function */ void wait(clock_t wait); diff --git a/16/lib/lib_com.h b/16/lib/lib_com.h index 90392ec6..56c957ef 100644 --- a/16/lib/lib_com.h +++ b/16/lib/lib_com.h @@ -3,7 +3,8 @@ #include #include #include // just for wait -#include // just for wait +#include // just for wait +#include "lib\types.h" /* Control codes for all keys on the keyboard */ //here temperarly @@ -96,9 +97,9 @@ #define KEY_MENU (0x75) -typedef unsigned char byte; -typedef unsigned int word; -typedef unsigned short syte; +//typedef unsigned char byte; +//typedef unsigned int word; +//typedef unsigned short syte; void wait(clock_t wait); diff --git a/16/modex16/MODEX16.OBJ b/16/modex16/MODEX16.OBJ deleted file mode 100644 index 2d064b07..00000000 Binary files a/16/modex16/MODEX16.OBJ and /dev/null differ diff --git a/16/modex16/PCXTEST.C b/16/modex16/PCXTEST.C index 0f2192bd..3e4f501d 100644 --- a/16/modex16/PCXTEST.C +++ b/16/modex16/PCXTEST.C @@ -29,12 +29,12 @@ void main() { /* don't show the drawing page */ // printf("=======\n"); - modexShowPage(VGA + PAGE_SIZE); + //modexShowPage(VGA + PAGE_SIZE); // printf("========\n"); /* clear and draw one sprite and one bitmap */ // printf("=========\n"); - modexClearRegion(VGA, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0); + //modexClearRegion(VGA, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0); // printf("==========\n"); /*modexDrawBmp(VGA, 20, 20, &bmp2, 0); modexDrawBmp(VGA, 180, 20, &bmp, 1); @@ -44,7 +44,7 @@ void main() { //modexDrawBmp(VGA, 100, 40, &bmp2, 1); //modexDrawBmp(VGA, 0, 20, &bmp3, 0); //modexDrawBmp(VGA, 120, 60, &bmp3, 1); - modexShowPage(VGA); + //modexShowPage(VGA); // for(index = 0; index<500; index++) { //while(1/*!kbhit()*/){ // conditions of screen saver while (!kbhit()){ /* Wait for a keystroke */ diff --git a/16/modex16/PCXTEST.EXE b/16/modex16/PCXTEST.EXE index 2001379d..05ff8048 100644 Binary files a/16/modex16/PCXTEST.EXE and b/16/modex16/PCXTEST.EXE differ diff --git a/16/modex16/PCXTEST.OBJ b/16/modex16/PCXTEST.OBJ deleted file mode 100644 index 7b6c1737..00000000 Binary files a/16/modex16/PCXTEST.OBJ and /dev/null differ diff --git a/16/modex16/TEST.OBJ b/16/modex16/TEST.OBJ deleted file mode 100644 index f0d58aec..00000000 Binary files a/16/modex16/TEST.OBJ and /dev/null differ diff --git a/16/x.bat b/16/x.bat index 5182f1c7..55c80547 100644 --- a/16/x.bat +++ b/16/x.bat @@ -1,3 +1,4 @@ -wpp /d1 /0 /ml dos_gfx +wpp /d2 /0 /ml dos_gfx +rem wcl -0 -d2 -ml -c lib\modex16.c wlink debug c option cvp file 'dos_gfx' library 'lib\x\modex.lib' name dos_gfx copy /y dos_gfx.exe c:\z\bakapi.exe