]> 4ch.mooo.com Git - 16.git/commitdiff
new file: 16/BANKBLIT.C
authorsparky4 <sparky4@4ch.maidlab.jp>
Sun, 4 May 2014 01:46:19 +0000 (20:46 -0500)
committersparky4 <sparky4@4ch.maidlab.jp>
Sun, 4 May 2014 01:46:19 +0000 (20:46 -0500)
new file:   16/BANKBLIT.EXE
modified:   16/DOS_GFX.EXE
modified:   16/Project 16.bfproject
new file:   16/Q.BAT
modified:   16/dos_gfx.cpp
modified:   16/dos_gfx.h

16/BANKBLIT.C [new file with mode: 0644]
16/BANKBLIT.EXE [new file with mode: 0644]
16/DOS_GFX.EXE
16/Project 16.bfproject
16/Q.BAT [new file with mode: 0644]
16/W [new file with mode: 0644]
16/dos_gfx.cpp
16/dos_gfx.h

diff --git a/16/BANKBLIT.C b/16/BANKBLIT.C
new file mode 100644 (file)
index 0000000..306f6c4
--- /dev/null
@@ -0,0 +1,415 @@
+/*----------------------------------------------------------------------------\r
+blit() function for VBE 1.x banked framebuffer\r
+Chris Giese    <geezer@execpc.com>     http://my.execpc.com/~geezer/\r
+This code is public domain (no copyright).\r
+You can do whatever you want with it.\r
+\r
+Compile with any of the following DOS compilers:\r
+- Turbo C++ 1.0\r
+- Borland C++ 3.1\r
+- 16-bit Watcom C\r
+- DJGPP\r
+\r
+April 4, 2008\r
+- Initial release\r
+\r
+More notes:\r
+- The 'BPP' macro can be changed to 2, 3, or 4 to work with color\r
+  depths 16, 24, and 32, respectively. BPP can also be a run-\r
+  time variable; letting you use the same blit() function for\r
+  various color depths.\r
+- Some video boards (Intel i810 integrated video) report compliance\r
+  with VBE 2.x but _still_ do not support a linear framebuffer\r
+- Left as an exercise for the reader: it should be easy to convert\r
+  blit_mem_to_fb() to blit_fb_to_mem()\r
+- Left as an exercise for the reader: it should be easy to convert\r
+  blit_mem_to_fb() to blot_fb(); a function that draws a solid\r
+  filled rectangle. (Hint: replace MEMCPY()s with MEMSET()s)\r
+- To handle arbitrary blitting in a system with a banked framebuffer,\r
+  you need four functions: blit_mem_to_mem(), blit_mem_to_fb(),\r
+  blit_fb_to_mem(), and blit_fb_to_fb()\r
+----------------------------------------------------------------------------*/\r
+#include <string.h> /* memset(), [_f]memcpy() */\r
+/* EOF, FILE, fopen(), fwrite(), fputc(), fclose(), remove(), printf() */\r
+#include <stdio.h>\r
+#include <conio.h> /* getch(), outp[ortb]() */\r
+/* union REGS, struct SREGS, int86(), int86x() */\r
+#include <dos.h> /* FP_SEG(), FP_OFF(), MK_FP() */\r
+#if 0\r
+/* C99 fixed-width types */\r
+#include <stdint.h>\r
+#else\r
+typedef unsigned char  uint8_t;\r
+typedef unsigned short uint16_t;\r
+typedef unsigned long  uint32_t;\r
+#endif\r
+\r
+#if defined(__TURBOC__)\r
+#if __TURBOC__==0x401\r
+#error Sorry, 'huge' is broken in Turbo C++ 3.0\r
+#endif\r
+\r
+/* This code exposes some bugs in Borland C++ 3.1, so... */\r
+#if __TURBOC__==0x410\r
+#pragma option -Od /* ...disable all optimizations */\r
+#endif\r
+\r
+#define        HUGE            huge\r
+#define        MEMCPY(D,S,N)   _fmemcpy(D,S,N)\r
+#define        MEMSET(D,C,N)   _fmemset(D,C,N)\r
+\r
+#elif defined(__WATCOMC__)&&!defined(__386__)\r
+#define        outportb(P,V)   outp(P,V)\r
+#define        HUGE            huge\r
+#define        MEMCPY(D,S,N)   _fmemcpy(D,S,N)\r
+#define        MEMSET(D,C,N)   _fmemset(D,C,N)\r
+\r
+#elif defined(__DJGPP__)\r
+/* __djgpp_conventional_base, __djgpp_nearptr_enable() */\r
+#include <sys/nearptr.h>\r
+#include <dpmi.h> /* __dpmi_regs, __dpmi_int(), __dpmi_allocate_dos_memory() */\r
+#include <crt0.h> /* _CRT0_FLAG_NEARPTR, _crt0_startup_flags */\r
+\r
+#define        __386__         1\r
+#define        HUGE            /* nothing */\r
+#define        MEMCPY(D,S,N)   memcpy(D,S,N)\r
+#define        MEMSET(D,C,N)   memset(D,C,N)\r
+\r
+#else\r
+#error Sorry, unsupported compiler\r
+#endif\r
+\r
+#define MIN(X,Y)       (((X) < (Y)) ? (X) : (Y))\r
+\r
+/* structure used by INT 10h AX=4F01h */\r
+#pragma pack(1)\r
+typedef struct\r
+{\r
+       uint16_t mode_attrib;    /* b5=1 for non-VGA mode */\r
+       uint8_t win_a_attrib;\r
+       uint8_t win_b_attrib;\r
+       uint16_t k_per_gran;\r
+       uint16_t win_size;\r
+       uint16_t win_a_seg;\r
+       uint16_t win_b_seg;\r
+       char reserved1[4];\r
+/* this is not always the expected value;\r
+rounded up to the next power of 2 for some video boards: */\r
+       uint16_t bytes_per_row;\r
+/* OEM modes and VBE 1.2 only: */\r
+       uint16_t wd;\r
+       uint16_t ht;\r
+       uint8_t char_wd;\r
+       uint8_t char_ht;\r
+       uint8_t planes;\r
+       uint8_t depth;\r
+       uint8_t banks;\r
+       uint8_t memory_model;\r
+       uint8_t k_per_bank;\r
+       uint8_t num_pages;       /* ? */\r
+       char reserved2;\r
+/* VBE 1.2 only */\r
+       uint8_t red_width;\r
+       uint8_t red_shift;\r
+       uint8_t green_width;\r
+       uint8_t green_shift;\r
+       uint8_t blue_width;\r
+       uint8_t blue_shift;\r
+       char reserved3[3];\r
+       uint32_t lfb_adr;\r
+       char reserved4[212];\r
+} vbe_mode_info_t;\r
+\r
+typedef struct\r
+{\r
+       unsigned wd, ht;\r
+       unsigned long bytes_per_row;\r
+       unsigned char HUGE *raster;\r
+} img_t;\r
+\r
+typedef struct\r
+{\r
+       int src_x, src_y, dst_x, dst_y;\r
+       unsigned wd, ht;\r
+} clip_t;\r
+\r
+static img_t g_fb;\r
+static unsigned g_use_win_a, g_gran_per_64k;\r
+/*****************************************************************************\r
+no _fmemcpy() in Turbo C++ 1.0\r
+*****************************************************************************/\r
+#if defined(__TURBOC__)\r
+#if __TURBOC__<0x300\r
+void far * far _fmemcpy(void far *dst_ptr, const void far *src_ptr,\r
+               unsigned n)\r
+{\r
+       unsigned char huge *dst = dst_ptr;\r
+       unsigned char huge *src = src_ptr;\r
+\r
+       for(; n != 0; n--)\r
+       {\r
+               *dst = *src;\r
+               dst++;\r
+               src++;\r
+       }\r
+       return dst_ptr;\r
+}\r
+#endif\r
+#endif\r
+/*****************************************************************************\r
+*****************************************************************************/\r
+static void set_bank(unsigned b)\r
+{\r
+       static unsigned curr_bank = -1u;\r
+/**/\r
+       union REGS regs;\r
+\r
+       if(b == curr_bank)\r
+               return;\r
+       curr_bank = b;\r
+       regs.x.ax = 0x4F05;\r
+/* g_use_win_a and g_gran_per_64k were set by INT 10h AX=4F01h */\r
+       regs.x.bx = g_use_win_a ? 0x0000 : 0x0001;\r
+       regs.x.dx = b * g_gran_per_64k;\r
+       int86(0x10, &regs, &regs);\r
+}\r
+/*****************************************************************************\r
+If using Borland C, compile this without optimizations.\r
+Even without optimizations, it probably won't work with Turbo C++ 3.0\r
+*****************************************************************************/\r
+#define BPP    1 /* bytes per pixel */\r
+static void blit_mem_to_fb(img_t *src_img, clip_t *clip)\r
+{\r
+       unsigned bank, y, row_with_bank_switch, max_y;\r
+       unsigned char HUGE *src;\r
+       unsigned long off32;\r
+       uint16_t off16, i;\r
+\r
+       src = src_img->raster +\r
+               src_img->bytes_per_row * clip->src_y + clip->src_x * BPP;\r
+/* calculate 32-bit offset into framebuffer corresponding to\r
+(clip->dst_x, clip->dst_y) */\r
+       off32 = g_fb.bytes_per_row * clip->dst_y + clip->dst_x * BPP;\r
+/* use low 16 bits for offset into 64K bank; use top 16 bits for bank */\r
+       off16 = (uint16_t)off32;\r
+       off32 >>= 16;\r
+       bank = (uint16_t)off32;\r
+/* set bank and increment bank number */\r
+       set_bank(bank);\r
+       bank++;\r
+       for(y = clip->dst_y; ; )\r
+       {\r
+/* in which row does the next bank-switch occur? */\r
+               off32 = bank;\r
+               off32 <<= 16;\r
+               row_with_bank_switch = (unsigned)\r
+                       (off32 / g_fb.bytes_per_row);\r
+/* blit until we reach that row or until we reach (clip->dst_y + clip->ht) */\r
+               max_y = MIN(clip->dst_y + clip->ht, row_with_bank_switch);\r
+               for(; y < max_y; y++)\r
+               {\r
+                       MEMCPY(g_fb.raster + off16, src, clip->wd * BPP);\r
+                       off16 += g_fb.bytes_per_row;\r
+                       src += src_img->bytes_per_row;\r
+               }\r
+/* exit now if done */\r
+               if(y >= clip->dst_y + clip->ht)\r
+                       break;\r
+/* else it's a row with bank switch. There are 3 possibilities:\r
+line of pixels in this row starts AFTER bank switch */\r
+               if(off16 < g_fb.bytes_per_row) /* overflowed 64K (clever!) */\r
+               {\r
+                       set_bank(bank);\r
+                       MEMCPY(g_fb.raster + off16, src, clip->wd * BPP);\r
+               }\r
+/* line of pixels in this row ends BEFORE bank switch */\r
+               else if(off16 + (unsigned long)clip->wd * BPP <= 0x10000L)\r
+               {\r
+                       MEMCPY(g_fb.raster + off16, src, clip->wd * BPP);\r
+                       set_bank(bank);\r
+               }\r
+/* line of pixels in this row STRADDLES bank switch */\r
+               else\r
+               {\r
+                       i = (uint16_t)(0x10000uL - off16);\r
+                       MEMCPY(g_fb.raster + off16, src + 0,\r
+                               i);\r
+                       set_bank(bank);\r
+                       MEMCPY(g_fb.raster + 0    , src + i,\r
+                               clip->wd * BPP - i);\r
+               }\r
+               off16 += g_fb.bytes_per_row;\r
+               src += src_img->bytes_per_row;\r
+               bank++;\r
+               y++;\r
+       }\r
+}\r
+/*****************************************************************************\r
+*****************************************************************************/\r
+int main(void)\r
+{\r
+       static const unsigned vbe_mode_num = 0x101; /* 640x480x256 */\r
+/* 14x14 test bitmap */\r
+       static unsigned char raster[] =\r
+               "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D"\r
+               "\x01\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D"\r
+               "\x02\x02\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D"\r
+               "\x03\x03\x03\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D"\r
+               "\x04\x04\x04\x04\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D"\r
+               "\x05\x05\x05\x05\x05\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D"\r
+               "\x06\x06\x06\x06\x06\x06\x06\x07\x08\x09\x0A\x0B\x0C\x0D"\r
+               "\x07\x07\x07\x07\x07\x07\x07\x07\x08\x09\x0A\x0B\x0C\x0D"\r
+               "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x09\x0A\x0B\x0C\x0D"\r
+               "\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x0A\x0B\x0C\x0D"\r
+               "\x0A\x0A\x0A\x0A\x0A\x0A\x0A\x0A\x0A\x0A\x0A\x0B\x0C\x0D"\r
+               "\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0C\x0D"\r
+               "\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0D"\r
+               "\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D";\r
+/**/\r
+       union REGS regs;\r
+       unsigned i;\r
+       clip_t clip;\r
+       img_t img;\r
+\r
+#if !defined(__386__)\r
+       static vbe_mode_info_t vbe_mode_info;\r
+       struct SREGS sregs;\r
+\r
+/* get info for VBE mode */\r
+       regs.x.ax = 0x4F01;\r
+       regs.x.cx = vbe_mode_num;\r
+       sregs.es = FP_SEG(&vbe_mode_info);\r
+       regs.x.di = FP_OFF(&vbe_mode_info);\r
+       int86x(0x10, &regs, &regs, &sregs);\r
+       if(regs.x.ax != 0x004F)\r
+       {\r
+               printf("Error getting info for VBE mode 0x%X\n",\r
+                       vbe_mode_num);\r
+               return 1;\r
+       }\r
+/* init g_fb */\r
+       g_fb.wd = vbe_mode_info.wd;\r
+       g_fb.ht = vbe_mode_info.ht;\r
+       g_fb.bytes_per_row = vbe_mode_info.bytes_per_row;\r
+       g_gran_per_64k = 64 / vbe_mode_info.k_per_gran;\r
+       if(vbe_mode_info.win_a_attrib == 7)\r
+       {\r
+               g_fb.raster = (unsigned char HUGE *)\r
+                       MK_FP(vbe_mode_info.win_a_seg, 0);\r
+               g_use_win_a = 1;\r
+       }\r
+       else if(vbe_mode_info.win_b_attrib == 7)\r
+       {\r
+               g_fb.raster = (unsigned char HUGE *)\r
+                       MK_FP(vbe_mode_info.win_b_seg, 0);\r
+               g_use_win_a = 0;\r
+       }\r
+       else\r
+       {\r
+               printf("Error locating banked framebuffer "\r
+                       "for VBE mode 0x%X\n", vbe_mode_num);\r
+               return -1;\r
+       }\r
+#else /* if defined(__DJGPP__) */\r
+       vbe_mode_info_t *vbe_mode_info;\r
+       int conv_mem_seg, conv_mem_sel;\r
+       __dpmi_regs dregs;\r
+\r
+/* turn off data segment limit, for nearptr access */\r
+       if(!(_crt0_startup_flags & _CRT0_FLAG_NEARPTR))\r
+       {\r
+               if(!__djgpp_nearptr_enable())\r
+               {\r
+                       printf("Error: can't enable near pointer "\r
+                               "access to framebuffer (WinNT/2k/XP?)\n");\r
+                       return 1;\r
+               }\r
+       }\r
+/* allocate conventional memory for INT 10h AX=4F01h buffer */\r
+       conv_mem_seg = __dpmi_allocate_dos_memory(256 / 16, &conv_mem_sel);\r
+       if(conv_mem_seg == -1)\r
+       {\r
+               printf("Error: can't allocate conventional memory\n");\r
+               return 1;\r
+       }\r
+       vbe_mode_info = (vbe_mode_info_t *)\r
+               (conv_mem_seg * 16uL + __djgpp_conventional_base);\r
+printf("vbe_mode_info: sel=0x%X, real-mode seg=0x%X, linear=0x%lX, near=0x%p\n",\r
+ conv_mem_sel, conv_mem_seg, conv_mem_seg * 16uL, vbe_mode_info);\r
+/* get info for VBE mode */\r
+       dregs.x.ax = 0x4F01;\r
+       dregs.x.cx = vbe_mode_num;\r
+       dregs.x.es = conv_mem_seg;\r
+       dregs.x.di = 0;\r
+       __dpmi_int(0x10, &dregs);\r
+       if(dregs.x.ax != 0x004F)\r
+       {\r
+               printf("Error getting info for VBE mode 0x%X\n",\r
+                       vbe_mode_num);\r
+               return 1;\r
+       }\r
+/* init g_fb */\r
+       g_fb.wd = vbe_mode_info->wd;\r
+       g_fb.ht = vbe_mode_info->ht;\r
+       g_fb.bytes_per_row = vbe_mode_info->bytes_per_row;\r
+       g_gran_per_64k = 64 / vbe_mode_info->k_per_gran;\r
+       if(vbe_mode_info->win_a_attrib == 7)\r
+       {\r
+               g_fb.raster = (unsigned char HUGE *)\r
+                       (vbe_mode_info->win_a_seg * 16uL +\r
+                               __djgpp_conventional_base);\r
+               g_use_win_a = 1;\r
+       }\r
+       else if(vbe_mode_info->win_b_attrib == 7)\r
+       {\r
+               g_fb.raster = (unsigned char HUGE *)\r
+                       (vbe_mode_info->win_b_seg * 16uL +\r
+                               __djgpp_conventional_base);\r
+               g_use_win_a = 0;\r
+       }\r
+       else\r
+       {\r
+               printf("Error locating banked framebuffer "\r
+                       "for VBE mode 0x%X\n", vbe_mode_num);\r
+               return -1;\r
+       }\r
+#endif\r
+/* init img */\r
+       img.wd = 14;\r
+       img.ht = 14;\r
+       img.bytes_per_row = img.wd;\r
+       img.raster = raster;\r
+/* init clip_t */\r
+       clip.wd = img.wd;\r
+       clip.ht = img.ht;\r
+       clip.src_x = 0;\r
+       clip.src_y = 0;\r
+/* set graphics mode */\r
+       regs.x.bx = vbe_mode_num;\r
+       regs.x.ax = 0x4F02;\r
+       int86(0x10, &regs, &regs);\r
+/* green palette */\r
+#define        VGA_DAC_WRITE_INDEX     0x3C8\r
+#define        VGA_DAC_DATA            0x3C9\r
+       outportb(VGA_DAC_WRITE_INDEX, 0);\r
+       for(i = 0; i < 16; i++)\r
+       {\r
+               outportb(VGA_DAC_DATA, /* red= */0 >> 2);\r
+               outportb(VGA_DAC_DATA, /* green= */i * 3);\r
+               outportb(VGA_DAC_DATA, /* blue= */0 >> 2);\r
+       }\r
+/* test banked blit function */\r
+       clip.dst_y = 0;\r
+       for(; clip.dst_y + clip.ht < g_fb.ht; clip.dst_y += clip.ht)\r
+       {\r
+               clip.dst_x = 0;\r
+               for(; clip.dst_x + clip.wd < g_fb.wd; clip.dst_x += clip.wd)\r
+                       blit_mem_to_fb(&img, &clip);\r
+       }\r
+       if(getch() == 0)\r
+               (void)getch();\r
+/* set text mode */\r
+       regs.x.ax = 0x0003;\r
+       int86(0x10, &regs, &regs);\r
+       return 0;\r
+}\r
diff --git a/16/BANKBLIT.EXE b/16/BANKBLIT.EXE
new file mode 100644 (file)
index 0000000..98f92de
Binary files /dev/null and b/16/BANKBLIT.EXE differ
index bbd903d70e6c01ac04ab7536b1b7ef5340068b49..1cdab2127cd3011d68964db88afab1ceecbaf207 100644 (file)
Binary files a/16/DOS_GFX.EXE and b/16/DOS_GFX.EXE differ
index b0ae9e9783c4d4ed8389a421d60073a72938d296..7521911864dc3446681c09461290d9591f023dfb 100644 (file)
@@ -1,13 +1,21 @@
 c2e.convert_special: 0
 e2c.convert_num: 0
-openfiles: /dos/z/16/16/dos_gfx.h:0:0:0:
+openfiles: /dos/z/16/16/dos_gfx.cpp:6903:6589:1:
+openfiles: /dos/z/16/16/dos_gfx.h:1122:268:0:
+openfiles: /dos/z/16/16/dos_kb.c:1870:1395:0:
 openfiles: /dos/z/16/16/dos_kb.h:0:0:0:
-openfiles: /dos/z/16/16/lib_com.h:0:0:0:
-openfiles: /dos/z/16/16/dos_kb.c:0:0:0:
-openfiles: /dos/z/16/16/dos_gfx.cpp:0:0:0:
 openfiles: /dos/z/16/16/lib_com.cpp:0:0:0:
+openfiles: /dos/z/16/16/lib_com.h:0:0:0:
 openfiles: /dos/z/16/16/16.txt:0:0:0:
-openfiles: /dos/z/16/16/project16.txt:0:0:1:
+openfiles: /dos/z/16/16/project16.txt:1737:476:0:
+openfiles: /dos/z/4x4_16/tauron/C_SRC/FONT1.H:0:0:0:
+openfiles: /dos/z/4x4_16/tauron/C_SRC/FONT2.H:0:0:0:
+openfiles: /dos/z/4x4_16/tauron/C_SRC/TAURON.H:0:0:0:
+openfiles: /dos/z/4x4_16/tauron/C_SRC/MODES_C.INC:0:7495:0:
+openfiles: /dos/z/4x4_16/tauron/C_SRC/PALETTE.INC:1213:2412:0:
+openfiles: /dos/z/4x4_16/tauron/C_SRC/CLEAR.CPP:1394:2142:0:
+openfiles: /dos/z/4x4_16/tauron/C_SRC/MODES.CPP:0:0:0:
+openfiles: /dos/z/4x4_16/tauron/C_SRC/TESTS.CPP:3437:3167:0:
 snr_recursion_level: 0
 convertcolumn_horizontally: 0
 adv_open_matchname: 0
@@ -19,12 +27,14 @@ view_left_panel: 0
 default_mime_type: text/plain
 e2c.convert_xml: 1
 c2e.convert_iso: 0
-opendir: file:///dos/z/16/16
+opendir: file:///dos/z/4x4_16/tauron/C_SRC
 wrap_text_default: 0
 bookmarks_filename_mode: 1
+ssearch_text: fill_plane(
 snr_casesens: 0
 view_blocks: 1
 name: project 16
+replacelist: てすと
 fb_show_hidden_f: 0
 editor_tab_width: 4
 show_visible_spacing: 1
@@ -38,10 +48,27 @@ ssearch_regex: 0
 e2c.convert_iso: 0
 ssearch_casesens: 0
 charmap_block: 1
-recent_files: file:///dos/z/16/16/16.txt
+recent_files: file:///dos/z/16/16/dos_gfx.h
+recent_files: file:///dos/z/16/16/lib_com.cpp
+recent_files: file:///dos/z/16/16/lib_com.h
+recent_files: file:///dos/z/16/16/dos_kb.h
+recent_files: file:///dos/z/16/16/dos_kb.c
+recent_files: file:///dos/z/16/16/dos_gfx.cpp
 recent_files: file:///dos/z/16/16/project16.txt
+recent_files: file:///dos/z/16/16/16.txt
+recent_files: file:///dos/z/grdemo.c
+recent_files: file:///dos/z/4x4_16/tauron/C_SRC/PALETTE.INC
+recent_files: file:///dos/z/4x4_16/tauron/C_SRC/DUAL.CPP
+recent_files: file:///dos/z/4x4_16/tauron/C_SRC/TAURON.H
+recent_files: file:///dos/z/4x4_16/tauron/C_SRC/MAINC.CPP
+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/FONT2.H
+recent_files: file:///dos/z/4x4_16/tauron/C_SRC/FONT1.H
+recent_files: file:///dos/z/4x4_16/tauron/C_SRC/TESTS.CPP
+recent_files: file:///dos/z/4x4_16/tauron/C_SRC/MODES.CPP
 snr_replacetype: 0
-savedir: file:///dos/z/4x4_16/tweak16/XINTRO
+savedir: file:///dos/z/16/16
 spell_check_default: 1
 spell_insert_entities: 0
 last_filefilter: 
@@ -51,15 +78,45 @@ snr_escape_chars: 0
 htmlbar_view: 1
 spell_lang: en
 ssearch_dotmatchall: 0
+searchlist: \82Ä\82·\82Æ
+searchlist: LGQ
+searchlist: plot
+searchlist: out
+searchlist: put
+searchlist: put
+searchlist: print
+searchlist: d put
+searchlist: print
+searchlist: tile
+searchlist: fill_plane
+searchlist: red
+searchlist: rext
+searchlist: rect`-
+searchlist: fill_plane(
 autocomplete: 1
 outputb_show_all_output: 0
 bookmarks_show_mode: 0
 snippets_show_as_menu: 1
 adv_open_recursive: 0
-encoding: UTF-8
+encoding: SHIFT_JIS
 e2c.convert_special: 0
 autoindent: 1
 fb_viewmode: 0
+filegloblist: *.txt
+filegloblist: *.shtml
+filegloblist: *.py
+filegloblist: *.pl
+filegloblist: *.php
+filegloblist: *.js
+filegloblist: *.java
+filegloblist: *.htm
+filegloblist: *.html
+filegloblist: *.h
+filegloblist: *.css
+filegloblist: *.cpp
+filegloblist: *.cgi
+filegloblist: *.c
+filegloblist: *
 recent_dirs: file:///dos/z/16/16
 fb_focus_follow: 1
 ssearch_unescape: 0
diff --git a/16/Q.BAT b/16/Q.BAT
new file mode 100644 (file)
index 0000000..5d1b584
--- /dev/null
+++ b/16/Q.BAT
@@ -0,0 +1,5 @@
+call hres\r
+vi dos_gfx.cpp\r
+call x\r
+pause\r
+dos_gfx.exe\r
diff --git a/16/W b/16/W
new file mode 100644 (file)
index 0000000..f5334d4
--- /dev/null
+++ b/16/W
@@ -0,0 +1,5 @@
+3\r
+Where to next?  It's your move! wwww\r
+bakapi ver. 1.04.09a\r
+is made by sparky4\81i\81\86\83Ö\81\85\81j feel free to use it ^^\r
+Licence: GPL v2\r
index 76ab683a93eba88210376c083c514c50a6e18522..5f31ad4ef6faf3d55eda112fbe71e8a5695e19c3 100644 (file)
@@ -36,6 +36,8 @@
  */\r
 \r
 \r
+\r
+\r
 /*\r
  * We 'require' a large data model simply to get rid of explicit 'far'\r
  * pointers and compiler specific '_fmemset()' functions and the likes.\r
@@ -240,6 +242,63 @@ void set320x240x256_X(void)
        height = 240;\r
 \r
        }\r
+
+
+/*tile*/
+// This is Bresenham's Line Drawing Algorithm\r
+void drawline(int x1, int y1, int x2, int y2, char col)\r
+{\r
+       int d, x, y, ax, ay, sx, sy, dx, dy;\r
+\r
+       dx = x2-x1;\r
+       ax = ABS(dx) << 1;\r
+       sx = SGN(dx);\r
+       dy = y2-y1;\r
+       ay = ABS(dy) << 1;\r
+       sy = SGN(dy);\r
+\r
+       x = x1;\r
+       y = y1;\r
+       if( ax > ay )\r
+       {\r
+               d = ay - (ax >> 1);\r
+               while( x != x2 )\r
+               {\r
+                       putPixel_X( x, y, col );\r
+                       if( d >= 0 )\r
+                       {\r
+                               y += sy;\r
+                               d -= ax;\r
+                       }\r
+               x += sx;\r
+               d += ay;\r
+               }\r
+       }\r
+       else\r
+       {\r
+               d = ax - (ay >> 1);\r
+               while( y != y2 )\r
+               {\r
+                       putPixel_X( x, y, col );\r
+                       if( d >= 0 )\r
+                       {\r
+                               x += sx;\r
+                               d -= ay;\r
+                       }\r
+                       y += sy;\r
+                       d += ax;\r
+               }\r
+       }\r
+       return;\r
+}\r
+\r
+void drawrect(int x1, int y1, int x2, int y2, char color)\r
+{
+       drawline(x1,y1,x2,y1,color);\r
+       drawline(x1,y2,x2,y2,color);\r
+       drawline(x1,y1,x1,y2,color);\r
+       drawline(x2,y1,x2,y2+1,color);\r
+}
 \r
 \r
 /*-----------XXXX-------------*/\r
@@ -379,8 +438,9 @@ int ding(int q){
        int d3y;\r
 \r
 //++++ if(q <= 4 && q!=2 && gq == BONK-1) coor = rand()%HGQ;\r
-       if((q == 2
-       ||q==4
+       if((q == 2\r
+       ||q==4\r
+       ||q==16\r
        ) && gq == BONK-1){\r
                        if(coor < HGQ && coor < LGQ) coor = LGQ;\r
                        if(coor < HGQ-1){\r
@@ -408,7 +468,7 @@ int ding(int q){
                        gq++;\r
                }else gq = LGQ;\r
        }\r
-       if(q<5 && gq<BONK){ // the number variable make the colors more noticable\r
+       if((q<5 && gq<BONK) || (q==16 && gq<BONK)){ // the number variable make the colors more noticable\r
                if(q==1){\r
                        if(xx==width){bakax=0;}\r
                        if(xx==0){bakax=1;}\r
@@ -440,29 +500,56 @@ int ding(int q){
                                xx++;\r
                        }\r
                }else{\r
-                       if(!bakax){\r
-                               xx--;\r
-                       }else if(bakax>1){\r
-                               xx++;\r
-                       }\r
-                       if(!bakay){\r
-                               yy--;\r
-                       }else if(bakay>1){\r
-                               yy++;\r
+                       if(q==16)\r
+                       {\r
+                               if(!bakax){\r
+                                       xx--;//=TILEWH;\r
+                               }else if(bakax>0){\r
+                                       xx++;//=TILEWH;\r
+                               }\r
+                               if(!bakay){\r
+                                       yy--;//=TILEWH;\r
+                               }else if(bakay>0){\r
+                                       yy++;//=TILEWH;\r
+                               }\r
+                       }else{\r
+                               if(!bakax){\r
+                                       xx-=TILEWH;\r
+                               }else if(bakax>1){\r
+                                       xx+=TILEWH;\r
+                               }\r
+                               if(!bakay){\r
+                                       yy-=TILEWH;\r
+                               }else if(bakay>1){\r
+                                       yy+=TILEWH;\r
+                               }\r
                        }\r
                }\r
                // fixer\r
-               /*if(xx<0) xx=width;\r
-               if(yy<0) yy=height;\r
-               if(xx>width) xx=0;\r
-               if(yy>height) yy=0;*/\r
+               if(q!=16){\r
+                       if(xx<0) xx=width;\r
+                       if(yy<0) yy=height;\r
+                       if(xx>width) xx=0;\r
+                       if(yy>height) yy=0;\r
+               }\r
+\r
+//interesting effects\r
+               if(q==16)\r
+               {\r
+               int tx=0,ty=0;\r
+               tx+=xx+16;\r
+               ty+=yy+16;\r
+               putPixel_X(tx, ty, coor);
+               //drawrect(tx, ty, tx+TILEWH, ty+TILEWH, coor);\r
+               //printf("%d %d %d %d %d %d\n", xx, yy, tx, ty, TILEWH);\r
 \r
                // plot the pixel\r
 //----         ppf(xx, yy, coor, vga);\r
-               putPixel_X(xx, yy, coor);\r
+//++++0000             putPixel_X(xx, yy, coor);\r
+               }else drawrect(xx, yy, xx+TILEWH-1, yy+TILEWH-1, coor);\r
 //----         if(q==2) ppf(rand()%, rand()%height, 0, vga);\r
-               if(q==2) putPixel_X(rand()%width, rand()%height, 0);\r
-               if(q==2||q==4){ bakax = rand()%3; bakay = rand()%3; }\r
+               if(q==2||q==16) putPixel_X(rand()%width, rand()%height, 0);\r
+               if(q==2||q==4||q==16){ bakax = rand()%3; bakay = rand()%3; }\r
                gq++;\r
 //if(xx<0||xx>320||yy<0||yy>240)\r
 //     printf("%d %d %d %d %d %d\n", xx, yy, coor, bakax, bakay, getPixel_X(xx,yy));\r
@@ -489,38 +576,38 @@ void doTest(void)
        int p, x, y, pages;\r
 \r
        /* This is the way to calculate the number of pages available. */\r
-       pages = 65536L/(widthBytes*height); // apparently this takes the A000 address
+       pages = 65536L/(widthBytes*height); // apparently this takes the A000 address\r
+\r
+       printf("%d\n", pages);\r
 \r
-       printf("%d\n", pages);
-
        for (p = 0; p <= pages; ++p)\r
                {\r
                setActivePage(p);\r
 \r
                /* On each page draw a single colored border, and dump the palette\r
-                  onto a small square about the middle of the page. */
-                  
+                  onto a small square about the middle of the page. */\r
+                  \r
                   //{\r
                        for (x = 0; x <= width; ++x)\r
                                {\r
                                putPixel_X(x, 0, p+1);\r
-                               if(p!=pages) putPixel_X(x, height-1, p+1);
+                               if(p!=pages) putPixel_X(x, height-1, p+1);\r
                                        else putPixel_X(x, 99-1, p+1);\r
                                }\r
 \r
                        for (y = 0; y <= height; ++y)\r
                                {\r
                                putPixel_X(0, y, p+1);\r
-                               if(p!=pages) putPixel_X(width-1, y, p+1);
+                               if(p!=pages) putPixel_X(width-1, y, p+1);\r
                                        else putPixel_X(width-1, y, p+1);\r
                                }\r
 \r
                        for (x = 0; x < 16; ++x)\r
                                for (y = 0; y < 16; ++y)\r
                                        putPixel_X(x+(p+2)*16, y+(p+2)*16, x + y*16);\r
-                       //}
-
-               drawText(0, 0, 15, p);
+                       //}\r
+\r
+               drawText(0, 0, 15, p);\r
 \r
                }\r
 \r
@@ -528,7 +615,7 @@ void doTest(void)
           through all the pages by pressing a key. */\r
        for (p = 0; p <= pages; ++p)\r
                {\r
-               setVisiblePage(p);
+               setVisiblePage(p);\r
                //drawText(0, 240, 15, "bakapi");\r
                getch();\r
                }\r
@@ -574,9 +661,9 @@ int main(void)
                }\r
        }*/ // else off\r
        while(!kbhit()){ // conditions of screen saver\r
-               ding(4);
-       }
-       //end of screen savers
+               ding(4);\r
+       }\r
+       //end of screen savers\r
        doTest();\r
        setvideo(0);\r
        puts("Where to next?  It's your move! wwww");\r
index 08908b04084a7f19ef4d2638eb4719c30dc92007..b95f0159732d133716ec9d8bbb4583793c8210ac 100644 (file)
@@ -9,7 +9,10 @@
 //static hgq=NUM_COLORS/(1/8)\r
 #define BONK            400\r
 #define LGQ             32\r
-#define HGQ             56\r
+#define HGQ             56
+#define TILEWH                         16
+#define ABS(a)   ((a < 0) ? -a : a)\r
+#define SGN(a)   ((a < 0) ? -1 : 1)\r
 //#define VMEM            0xA000 // = vga\r
 //int width = 320;\r
 //int height = 240;\r
@@ -22,7 +25,9 @@ void setvideo(/*byte mode, */int vq);
 void cls(byte color, byte *Where);\r
 //void clearscr();\r
 //void plotpixel(int x, int y, byte color, byte *Where);\r
-//void plotpixelfast(int x, int y, byte color, byte *Where);\r
+//void plotpixelfast(int x, int y, byte color, byte *Where);
+void putPixel_X(int x, int y, byte color);
+void putTile(int x, int y, byte color);\r
 //void BlockMove();\r
 //void eraseplayer(int x, int y);\r
 //void drawplayer(int x, int y, int color);\r