From ce0e8d8019f8922dfa6cdf3dc2567e326edce055 Mon Sep 17 00:00:00 2001 From: sparky4 Date: Sun, 4 May 2014 23:23:36 -0500 Subject: [PATCH] modified: 16/16.txt modified: 16/DOS_GFX.EXE modified: 16/Project 16.bfproject deleted: 16/W modified: 16/dos_gfx.cpp modified: 16/dos_gfx.h --- 16/16.txt | 340 ++++++++-------- 16/DOS_GFX.EXE | Bin 27972 -> 27959 bytes 16/Project 16.bfproject | 49 +-- 16/W | 5 - 16/dos_gfx.cpp | 861 ++++++++++++++++++++-------------------- 16/dos_gfx.h | 12 +- 6 files changed, 632 insertions(+), 635 deletions(-) delete mode 100644 16/W diff --git a/16/16.txt b/16/16.txt index 17cae053..0b7a3e91 100644 --- a/16/16.txt +++ b/16/16.txt @@ -20,190 +20,190 @@ Something like #define TILES_X = NTILES_X - 1 #define TILES_Y = NTILES_Y - 1 struct vp_node { - uint8_t tile; - struct vp_node *up; - struct vp_node *right; - struct vp_node *down; - struct vp_node *left; + uint8_t tile; + struct vp_node *up; + struct vp_node *right; + struct vp_node *down; + struct vp_node *left; }; struct viewport { - uint8_t offset_x; //X offset in pixels - uint8_t offset_y; //Y offset in pixels - uint16_t world_offset_x; - uint16_t world_offset_y; - struct vp_node *upper_left; //pointer to the upper left tile + uint8_t offset_x; //X offset in pixels + uint8_t offset_y; //Y offset in pixels + uint16_t world_offset_x; + uint16_t world_offset_y; + struct vp_node *upper_left; //pointer to the upper left tile }; void initvp(struct viewport *vp, uint8_t **world_matrix, uint16_t offset_x, uint16_t offset_y) { - int i, j; - struct vp_node *vp_tmp[NTILES_Y][NTILES_X]; //i'd like to copy it - for(i=0; itile = world_matrix[offset_x + i][offset_y + j]; - } - } - // i for line, j for column - // linking neighbouring tiles - // wait, do we need links to left and up? - for(i=0; iup = vp_tmp[i-1][j]; - else vp_tmp[i][j]->up = NULL; - if(j) vp_tmp[i][j]->left = vp_tmp[i][j-1]; - else vp_tmp[i][j]->left = NULL; - if(i<20) vp_tmp[i][j]->down = vp_tmp[i+1][j]; - else vp_tmp[i][j]->down = NULL; - if(j<15) vp_tmp[i][j]->right = vp_tmp[i][j+1]; - else vp_tmp[i][j]->right = NULL; - } - } - vp = malloc(sizeof(struct viewport)); - vp->offset_x = 0; - vp->offset_y = 0; - vp->world_offset_x = offset_x; - vp->world_offset_y = offset_y; - vp->upper_left = vp_tmp[0][0]; + int i, j; + struct vp_node *vp_tmp[NTILES_Y][NTILES_X]; //i'd like to copy it + for(i=0; itile = world_matrix[offset_x + i][offset_y + j]; + } + } + // i for line, j for column + // linking neighbouring tiles + // wait, do we need links to left and up? + for(i=0; iup = vp_tmp[i-1][j]; + else vp_tmp[i][j]->up = NULL; + if(j) vp_tmp[i][j]->left = vp_tmp[i][j-1]; + else vp_tmp[i][j]->left = NULL; + if(i<20) vp_tmp[i][j]->down = vp_tmp[i+1][j]; + else vp_tmp[i][j]->down = NULL; + if(j<15) vp_tmp[i][j]->right = vp_tmp[i][j+1]; + else vp_tmp[i][j]->right = NULL; + } + } + vp = malloc(sizeof(struct viewport)); + vp->offset_x = 0; + vp->offset_y = 0; + vp->world_offset_x = offset_x; + vp->world_offset_y = offset_y; + vp->upper_left = vp_tmp[0][0]; } void scroll(struct viewport *vp, uint8_t **world_matrix, int8_t offset_x, int8_t offset_y) { - int8_t offset_x_total = offset_x + vp->offset_x; - int8_t offset_y_total = offset_y + vp->offset_y; - if(offset_x_total > 15) shift_right(vp, world_matrix); - if(offset_x_total < 0) shift_left(vp, world_matrix); - if(offset_y_total > 15) shift_down(vp, world_matrix); - if(offset_y_total < 0) shift_up(vp, world_matrix); - vp->offset_x = offset_x_total % 16; - vp->offset_y = offset_y_total % 16; + int8_t offset_x_total = offset_x + vp->offset_x; + int8_t offset_y_total = offset_y + vp->offset_y; + if(offset_x_total > 15) shift_right(vp, world_matrix); + if(offset_x_total < 0) shift_left(vp, world_matrix); + if(offset_y_total > 15) shift_down(vp, world_matrix); + if(offset_y_total < 0) shift_up(vp, world_matrix); + vp->offset_x = offset_x_total % 16; + vp->offset_y = offset_y_total % 16; } void shift_right(struct viewport *vp, uint8_t **world_matrix) { - vp->world_offset_x += 1; - struct vp_node *tmp = vp->upper_left; - vp->upper_left = vp->upper_left->right; - while(tmp->down) { - tmp->right->left = NULL; - tmp = tmp->down; - free(tmp->up); - } - tmp->right->left = NULL; - free(tmp); - // Starting from the upper left corner - tmp = vp->upper_left; - // Looking up the rightmost tile - while(tmp->right) tmp = tmp->right; - // Here and below: allocating and linking new neighbouring tiles - int i=0; - tmp->right = malloc(sizeof(struct vp_node)); - tmp->right->tile = world_matrix[vp->world_offset_y + i++][vp->world_offset_x +20]; - tmp->right->left = tmp; - tmp->right->up = NULL; - tmp->right->right = NULL; - while(tmp->down) { - tmp = tmp->down; - tmp->right = malloc(sizeof(struct vp_node)); - tmp->right->tile = world_matrix[vp->world_offset_y + i++][vp->world_offset_x + 20]; - tmp->right->left = tmp; - tmp->right->up = tmp->up->right; - tmp->up->right->down = tmp->right; - tmp->right->right = NULL; - } - tmp->right->down = NULL; - // looks like we've just added a column + vp->world_offset_x += 1; + struct vp_node *tmp = vp->upper_left; + vp->upper_left = vp->upper_left->right; + while(tmp->down) { + tmp->right->left = NULL; + tmp = tmp->down; + free(tmp->up); + } + tmp->right->left = NULL; + free(tmp); + // Starting from the upper left corner + tmp = vp->upper_left; + // Looking up the rightmost tile + while(tmp->right) tmp = tmp->right; + // Here and below: allocating and linking new neighbouring tiles + int i=0; + tmp->right = malloc(sizeof(struct vp_node)); + tmp->right->tile = world_matrix[vp->world_offset_y + i++][vp->world_offset_x +20]; + tmp->right->left = tmp; + tmp->right->up = NULL; + tmp->right->right = NULL; + while(tmp->down) { + tmp = tmp->down; + tmp->right = malloc(sizeof(struct vp_node)); + tmp->right->tile = world_matrix[vp->world_offset_y + i++][vp->world_offset_x + 20]; + tmp->right->left = tmp; + tmp->right->up = tmp->up->right; + tmp->up->right->down = tmp->right; + tmp->right->right = NULL; + } + tmp->right->down = NULL; + // looks like we've just added a column } void shift_left(struct viewport *vp, uint8_t **world_matrix) { - vp->world_offset_x -= 1; - // Removing the rightmost column first - struct vp_node *tmp = vp->upper_left; - while(tmp->right) tmp = tmp->right; - while(tmp->down) { - tmp->left->right = NULL; - tmp = tmp->down; - free(tmp->up); - } - tmp->left->right = NULL; - free(tmp); - // Now we need to add a new column to the left - tmp = vp->upper_left; - // Here and below: allocating and linking new neighbouring tiles - int i=0; - tmp->left = malloc(sizeof(struct vp_node)); - tmp->left->tile = world_matrix[vp->world_offset_y + i++][vp->world_offset_x]; - tmp->left->right = tmp; - tmp->left->up = NULL; - tmp->left->left = NULL; - while(tmp->down) { - tmp = tmp->down; - tmp->left = malloc(sizeof(struct vp_node)); - tmp->left->tile = world_matrix[vp->world_offset_y + i++][vp->world_offset_x]; - tmp->left->right = tmp; - tmp->left->up = tmp->up->left; - tmp->up->left->down = tmp->left; - tmp->left->left = NULL; - } - tmp->left->down = NULL; - // looks like we've just added a column to the left + vp->world_offset_x -= 1; + // Removing the rightmost column first + struct vp_node *tmp = vp->upper_left; + while(tmp->right) tmp = tmp->right; + while(tmp->down) { + tmp->left->right = NULL; + tmp = tmp->down; + free(tmp->up); + } + tmp->left->right = NULL; + free(tmp); + // Now we need to add a new column to the left + tmp = vp->upper_left; + // Here and below: allocating and linking new neighbouring tiles + int i=0; + tmp->left = malloc(sizeof(struct vp_node)); + tmp->left->tile = world_matrix[vp->world_offset_y + i++][vp->world_offset_x]; + tmp->left->right = tmp; + tmp->left->up = NULL; + tmp->left->left = NULL; + while(tmp->down) { + tmp = tmp->down; + tmp->left = malloc(sizeof(struct vp_node)); + tmp->left->tile = world_matrix[vp->world_offset_y + i++][vp->world_offset_x]; + tmp->left->right = tmp; + tmp->left->up = tmp->up->left; + tmp->up->left->down = tmp->left; + tmp->left->left = NULL; + } + tmp->left->down = NULL; + // looks like we've just added a column to the left } void shift_down(struct viewport *vp, uint8_t **world_matrix) { - vp->world_offset_y += 1; - // Removing the upper row first - struct vp_node *tmp = vp->upper_left->down; - vp->upper_left = tmp; - do { - free(tmp->up); - tmp->up = NULL; - } while(tmp->right); - // Now we need to add a new column to the bottom - tmp = vp->upper_left; - while(tmp->down) tmp = tmp->down; - // Here and below: allocating and linking new neighbouring tiles - int i=0; - tmp->down = malloc(sizeof(struct vp_node)); - tmp->dpwn->tile = world_matrix[vp->world_offset_y + i++][vp->world_offset_x]; - tmp->down->left = NULL; - tmp->down->up = tmp; - tmp->down->down = NULL; - while(tmp->right) { - tmp = tmp->right; - tmp->down = malloc(sizeof(struct vp_node)); - tmp->down->tile = world_matrix[vp->world_offset_y + i++][vp->world_offset_x]; - tmp->down->up = tmp; - tmp->down->left = tmp->left->down; - tmp->left->down->right = tmp->down; - tmp->down->down = NULL; - } - tmp->down->right = NULL; - // looks like we've just added a row to the bottom + vp->world_offset_y += 1; + // Removing the upper row first + struct vp_node *tmp = vp->upper_left->down; + vp->upper_left = tmp; + do { + free(tmp->up); + tmp->up = NULL; + } while(tmp->right); + // Now we need to add a new column to the bottom + tmp = vp->upper_left; + while(tmp->down) tmp = tmp->down; + // Here and below: allocating and linking new neighbouring tiles + int i=0; + tmp->down = malloc(sizeof(struct vp_node)); + tmp->dpwn->tile = world_matrix[vp->world_offset_y + i++][vp->world_offset_x]; + tmp->down->left = NULL; + tmp->down->up = tmp; + tmp->down->down = NULL; + while(tmp->right) { + tmp = tmp->right; + tmp->down = malloc(sizeof(struct vp_node)); + tmp->down->tile = world_matrix[vp->world_offset_y + i++][vp->world_offset_x]; + tmp->down->up = tmp; + tmp->down->left = tmp->left->down; + tmp->left->down->right = tmp->down; + tmp->down->down = NULL; + } + tmp->down->right = NULL; + // looks like we've just added a row to the bottom } void shift_up(struct viewport *vp, uint8_t **world_matrix) { - vp->world_offset_y += 1; - // Removing the bottom row first - struct vp_node *tmp = vp->upper_left; - while(tmp->down) tmp = tmp->down; - while(tmp->right) { - tmp->up->down = NULL; - tmp = tmp->right; - free(tmp->left); - } - tmp->up->down = NULL; - free(tmp); - // Now we need to add a new row to the top - tmp = vp->upper_left; - // Here and below: allocating and linking new neighbouring tiles - int i=0; - tmp->up = malloc(sizeof(struct vp_node)); - tmp->up->tile = world_matrix[vp->world_offset_y + i++][vp->world_offset_x]; - tmp->up->left = NULL; - tmp->up->down = tmp; - tmp->up->up = NULL; - while(tmp->right) { - tmp = tmp->right; - tmp->up = malloc(sizeof(struct vp_node)); - tmp->up->tile = world_matrix[vp->world_offset_y + i++][vp->world_offset_x]; - tmp->up->down = tmp; - tmp->up->left = tmp->left->up; - tmp->left->up->right = tmp->up; - tmp->up->up = NULL; - } - tmp->up->right = NULL; - // looks like we've just added a row to the top + vp->world_offset_y += 1; + // Removing the bottom row first + struct vp_node *tmp = vp->upper_left; + while(tmp->down) tmp = tmp->down; + while(tmp->right) { + tmp->up->down = NULL; + tmp = tmp->right; + free(tmp->left); + } + tmp->up->down = NULL; + free(tmp); + // Now we need to add a new row to the top + tmp = vp->upper_left; + // Here and below: allocating and linking new neighbouring tiles + int i=0; + tmp->up = malloc(sizeof(struct vp_node)); + tmp->up->tile = world_matrix[vp->world_offset_y + i++][vp->world_offset_x]; + tmp->up->left = NULL; + tmp->up->down = tmp; + tmp->up->up = NULL; + while(tmp->right) { + tmp = tmp->right; + tmp->up = malloc(sizeof(struct vp_node)); + tmp->up->tile = world_matrix[vp->world_offset_y + i++][vp->world_offset_x]; + tmp->up->down = tmp; + tmp->up->left = tmp->left->up; + tmp->left->up->right = tmp->up; + tmp->up->up = NULL; + } + tmp->up->right = NULL; + // looks like we've just added a row to the top } void render_vp(struct viewport *vp); diff --git a/16/DOS_GFX.EXE b/16/DOS_GFX.EXE index 1cdab2127cd3011d68964db88afab1ceecbaf207..d3df3f89e3dbf4dfcca1123e0ce6f53b21ad9b54 100644 GIT binary patch delta 7833 zcmZ8m3tW^{+CT5b8LlJ9{UUd{CQ%HfcePC6`=57aKpTGl!~0y$bDr~@=RD`U zGY3y|yH0a!ifY=qII@Psk*CSf&;*fq5JLP2iNQbi@%JKRi8moD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Ab=thu qvslGDKm{!QI&<8;!}@{oReoRH#MB2aReoKOpQ5MgB=I1A-2Q)T5J&+4 diff --git a/16/Project 16.bfproject b/16/Project 16.bfproject index 75219118..25b9d51e 100644 --- a/16/Project 16.bfproject +++ b/16/Project 16.bfproject @@ -1,21 +1,13 @@ c2e.convert_special: 0 e2c.convert_num: 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.cpp:0:0:0: +openfiles: /dos/z/16/16/dos_gfx.cpp:8340:8091:1: +openfiles: /dos/z/16/16/dos_gfx.h:941:268:0: +openfiles: /dos/z/16/16/dos_kb.c:759:642:0: +openfiles: /dos/z/16/16/dos_kb.h:179:0:0: +openfiles: /dos/z/16/16/lib_com.cpp:164: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: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: +openfiles: /dos/z/16/16/project16.txt:1755:1676:0: snr_recursion_level: 0 convertcolumn_horizontally: 0 adv_open_matchname: 0 @@ -30,11 +22,12 @@ c2e.convert_iso: 0 opendir: file:///dos/z/4x4_16/tauron/C_SRC wrap_text_default: 0 bookmarks_filename_mode: 1 -ssearch_text: fill_plane( +ssearch_text: fmem snr_casesens: 0 view_blocks: 1 name: project 16 replacelist: てすと +replacelist: \t fb_show_hidden_f: 0 editor_tab_width: 4 show_visible_spacing: 1 @@ -48,25 +41,25 @@ ssearch_regex: 0 e2c.convert_iso: 0 ssearch_casesens: 0 charmap_block: 1 +recent_files: file:///dos/z/grdemo.c +recent_files: file:///dos/z/4x4_16/tauron/C_SRC/DUAL.CPP +recent_files: file:///dos/z/4x4_16/tauron/C_SRC/MAINC.CPP +recent_files: file:///dos/z/16/16/dos_gfx.cpp 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/lib_com.h +recent_files: file:///dos/z/16/16/lib_com.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 +recent_files: file:///dos/z/4x4_16/tauron/C_SRC/FONT1.H +recent_files: file:///dos/z/4x4_16/tauron/C_SRC/FONT2.H snr_replacetype: 0 savedir: file:///dos/z/16/16 spell_check_default: 1 @@ -78,11 +71,6 @@ snr_escape_chars: 0 htmlbar_view: 1 spell_lang: en ssearch_dotmatchall: 0 -searchlist: ‚Ä‚·‚Æ -searchlist: LGQ -searchlist: plot -searchlist: out -searchlist: put searchlist: put searchlist: print searchlist: d put @@ -93,6 +81,11 @@ searchlist: red searchlist: rext searchlist: rect`- searchlist: fill_plane( +searchlist: fmemset +searchlist: se +searchlist: +searchlist: rect +searchlist: fmem autocomplete: 1 outputb_show_all_output: 0 bookmarks_show_mode: 0 diff --git a/16/W b/16/W deleted file mode 100644 index f5334d49..00000000 --- a/16/W +++ /dev/null @@ -1,5 +0,0 @@ -3 -Where to next? It's your move! wwww -bakapi ver. 1.04.09a -is made by sparky4i†ƒÖ…j feel free to use it ^^ -Licence: GPL v2 diff --git a/16/dos_gfx.cpp b/16/dos_gfx.cpp index 5f31ad4e..c1d9f135 100644 --- a/16/dos_gfx.cpp +++ b/16/dos_gfx.cpp @@ -6,20 +6,20 @@ * * Simple graphics library to accompany the article * - * INTRODUCTION TO MODE X. + * INTRODUCTION TO MODE X. * * This library provides the basic functions for initializing and using * unchained (planar) 256-color VGA modes. Currently supported are: * - * - 320x200 - * - 320x240 + * - 320x200 + * - 320x240 * * Functions are provided for: * - * - initializing one of the available modes - * - setting the start address of the VGA refresh data - * - setting active and visible display pages - * - writing and reading a single pixel to/from video memory + * - initializing one of the available modes + * - setting the start address of the VGA refresh data + * - setting active and visible display pages + * - writing and reading a single pixel to/from video memory * * The library is provided as a demonstration only, and is not claimed * to be particularly efficient or suited for any purpose. It has only @@ -76,10 +76,10 @@ byte coor; /* * Define the port addresses of some VGA registers. */ -#define CRTC_ADDR 0x3d4 /* Base port of the CRT Controller (color) */ +#define CRTC_ADDR 0x3d4 /* Base port of the CRT Controller (color) */ -#define SEQU_ADDR 0x3c4 /* Base port of the Sequencer */ -#define GRAC_ADDR 0x3ce /* Base port of the Graphics Controller */ +#define SEQU_ADDR 0x3c4 /* Base port of the Sequencer */ +#define GRAC_ADDR 0x3ce /* Base port of the Graphics Controller */ /* @@ -105,56 +105,56 @@ unsigned actStart, visStart; /* * set320x200x256_X() - * sets mode 13h, then turns it into an unchained (planar), 4-page - * 320x200x256 mode. + * sets mode 13h, then turns it into an unchained (planar), 4-page + * 320x200x256 mode. */ void set320x200x256_X(void) - { - union REGS r; + { + union REGS r; - /* Set VGA BIOS mode 13h: */ - r.x.ax = 0x0013; - int86(0x10, &r, &r); + /* Set VGA BIOS mode 13h: */ + r.x.ax = 0x0013; + int86(0x10, &r, &r); - /* Turn off the Chain-4 bit (bit 3 at index 4, port 0x3c4): */ - outpw(SEQU_ADDR, 0x0604); + /* Turn off the Chain-4 bit (bit 3 at index 4, port 0x3c4): */ + outpw(SEQU_ADDR, 0x0604); - /* Turn off word mode, by setting the Mode Control register - of the CRT Controller (index 0x17, port 0x3d4): */ - outpw(CRTC_ADDR, 0xE317); + /* Turn off word mode, by setting the Mode Control register + of the CRT Controller (index 0x17, port 0x3d4): */ + outpw(CRTC_ADDR, 0xE317); - /* Turn off doubleword mode, by setting the Underline Location - register (index 0x14, port 0x3d4): */ - outpw(CRTC_ADDR, 0x0014); + /* Turn off doubleword mode, by setting the Underline Location + register (index 0x14, port 0x3d4): */ + outpw(CRTC_ADDR, 0x0014); - /* Clear entire video memory, by selecting all four planes, then - writing 0 to entire segment. */ - outpw(SEQU_ADDR, 0x0F02); - memset(vga+1, 0, 0xffff); /* stupid size_t exactly 1 too small */ - vga[0] = 0; + /* Clear entire video memory, by selecting all four planes, then + writing 0 to entire segment. */ + outpw(SEQU_ADDR, 0x0F02); + memset(vga+1, 0, 0xffff); /* stupid size_t exactly 1 too small */ + vga[0] = 0; - /* Update the global variables to reflect dimensions of this - mode. This is needed by most future drawing operations. */ - width = 320; - height = 200; + /* Update the global variables to reflect dimensions of this + mode. This is needed by most future drawing operations. */ + width = 320; + height = 200; - /* Each byte addresses four pixels, so the width of a scan line - in *bytes* is one fourth of the number of pixels on a line. */ - widthBytes = width / 4; + /* Each byte addresses four pixels, so the width of a scan line + in *bytes* is one fourth of the number of pixels on a line. */ + widthBytes = width / 4; - /* By default we want screen refreshing and drawing operations - to be based at offset 0 in the video segment. */ - actStart = visStart = 0; - } + /* By default we want screen refreshing and drawing operations + to be based at offset 0 in the video segment. */ + actStart = visStart = 0; + } /* * setActiveStart() tells our graphics operations which address in video * memory should be considered the top left corner. */ void setActiveStart(unsigned offset) - { - actStart = offset; - } + { + actStart = offset; + } /* * setVisibleStart() tells the VGA from which byte to fetch the first @@ -165,13 +165,13 @@ void setActiveStart(unsigned offset) * set, but before the low byte is set, which produces a bad flicker. */ void setVisibleStart(unsigned offset) - { - visStart = offset; - outpw(CRTC_ADDR, 0x0C); /* set high byte */ - outpw(CRTC_ADDR+1, visStart >> 8); - outpw(CRTC_ADDR, 0x0D); /* set low byte */ - outpw(CRTC_ADDR+1, visStart & 0xff); - } + { + visStart = offset; + outpw(CRTC_ADDR, 0x0C); /* set high byte */ + outpw(CRTC_ADDR+1, visStart >> 8); + outpw(CRTC_ADDR, 0x0D); /* set low byte */ + outpw(CRTC_ADDR+1, visStart & 0xff); + } /* * setXXXPage() sets the specified page by multiplying the page number @@ -180,125 +180,134 @@ void setVisibleStart(unsigned offset) * function. The first page is number 0. */ void setActivePage(int page) - { - setActiveStart(page * widthBytes * height); - } + { + setActiveStart(page * widthBytes * height); + } void setVisiblePage(int page) - { - setVisibleStart(page * widthBytes * height); - } + { + setVisibleStart(page * widthBytes * height); + } void putPixel_X(int x, int y, byte color) - { - /* Each address accesses four neighboring pixels, so set - Write Plane Enable according to which pixel we want - to modify. The plane is determined by the two least - significant bits of the x-coordinate: */ - outp(0x3c4, 0x02); - outp(0x3c5, 0x01 << (x & 3)); - - /* The offset of the pixel into the video segment is - offset = (width * y + x) / 4, and write the given - color to the plane we selected above. Heed the active - page start selection. */ - vga[(unsigned)(widthBytes * y) + (x / 4) + actStart] = color; - - } + { + /* Each address accesses four neighboring pixels, so set + Write Plane Enable according to which pixel we want + to modify. The plane is determined by the two least + significant bits of the x-coordinate: */ + outp(0x3c4, 0x02); + outp(0x3c5, 0x01 << (x & 3)); + + /* The offset of the pixel into the video segment is + offset = (width * y + x) / 4, and write the given + color to the plane we selected above. Heed the active + page start selection. */ + vga[(unsigned)(widthBytes * y) + (x / 4) + actStart] = color; + + } byte getPixel_X(int x, int y) - { - /* Select the plane from which we must read the pixel color: */ - outpw(GRAC_ADDR, 0x04); - outpw(GRAC_ADDR+1, x & 3); + { + /* Select the plane from which we must read the pixel color: */ + outpw(GRAC_ADDR, 0x04); + outpw(GRAC_ADDR+1, x & 3); - return vga[(unsigned)(widthBytes * y) + (x / 4) + actStart]; + return vga[(unsigned)(widthBytes * y) + (x / 4) + actStart]; - } + } void set320x240x256_X(void) - { - /* Set the unchained version of mode 13h: */ - set320x200x256_X(); - - /* Modify the vertical sync polarity bits in the Misc. Output - Register to achieve square aspect ratio: */ - outp(0x3C2, 0xE3); - - /* Modify the vertical timing registers to reflect the increased - vertical resolution, and to center the image as good as - possible: */ - outpw(0x3D4, 0x2C11); /* turn off write protect */ - outpw(0x3D4, 0x0D06); /* vertical total */ - outpw(0x3D4, 0x3E07); /* overflow register */ - outpw(0x3D4, 0xEA10); /* vertical retrace start */ - outpw(0x3D4, 0xAC11); /* vertical retrace end AND wr.prot */ - outpw(0x3D4, 0xDF12); /* vertical display enable end */ - outpw(0x3D4, 0xE715); /* start vertical blanking */ - outpw(0x3D4, 0x0616); /* end vertical blanking */ - - /* Update mode info, so future operations are aware of the - resolution */ - height = 240; - - } - - -/*tile*/ + { + /* Set the unchained version of mode 13h: */ + set320x200x256_X(); + + /* Modify the vertical sync polarity bits in the Misc. Output + Register to achieve square aspect ratio: */ + outp(0x3C2, 0xE3); + + /* Modify the vertical timing registers to reflect the increased + vertical resolution, and to center the image as good as + possible: */ + outpw(0x3D4, 0x2C11); /* turn off write protect */ + outpw(0x3D4, 0x0D06); /* vertical total */ + outpw(0x3D4, 0x3E07); /* overflow register */ + outpw(0x3D4, 0xEA10); /* vertical retrace start */ + outpw(0x3D4, 0xAC11); /* vertical retrace end AND wr.prot */ + outpw(0x3D4, 0xDF12); /* vertical display enable end */ + outpw(0x3D4, 0xE715); /* start vertical blanking */ + outpw(0x3D4, 0x0616); /* end vertical blanking */ + + /* Update mode info, so future operations are aware of the + resolution */ + height = 240; + + } + + +/*tile*/ // This is Bresenham's Line Drawing Algorithm void drawline(int x1, int y1, int x2, int y2, char col) { - int d, x, y, ax, ay, sx, sy, dx, dy; - - dx = x2-x1; - ax = ABS(dx) << 1; - sx = SGN(dx); - dy = y2-y1; - ay = ABS(dy) << 1; - sy = SGN(dy); - - x = x1; - y = y1; - if( ax > ay ) - { - d = ay - (ax >> 1); - while( x != x2 ) + int d, x, y, ax, ay, sx, sy, dx, dy; + + dx = x2-x1; + ax = ABS(dx) << 1; + sx = SGN(dx); + dy = y2-y1; + ay = ABS(dy) << 1; + sy = SGN(dy); + + x = x1; + y = y1; + if( ax > ay ) { - putPixel_X( x, y, col ); - if( d >= 0 ) - { - y += sy; - d -= ax; - } - x += sx; - d += ay; + d = ay - (ax >> 1); + while( x != x2 ) + { + putPixel_X( x, y, col ); + if( d >= 0 ) + { + y += sy; + d -= ax; + } + x += sx; + d += ay; + } } - } - else - { - d = ax - (ay >> 1); - while( y != y2 ) + else { - putPixel_X( x, y, col ); - if( d >= 0 ) - { - x += sx; - d -= ay; - } - y += sy; - d += ax; + d = ax - (ay >> 1); + while( y != y2 ) + { + putPixel_X( x, y, col ); + if( d >= 0 ) + { + x += sx; + d -= ay; + } + y += sy; + d += ax; + } } - } - return; + return; } void drawrect(int x1, int y1, int x2, int y2, char color) -{ - drawline(x1,y1,x2,y1,color); +{ + /*drawline(x1,y1,x2,y1,color); drawline(x1,y2,x2,y2,color); drawline(x1,y1,x1,y2,color); - drawline(x2,y1,x2,y2+1,color); -} + drawline(x2,y1,x2,y2+1,color);*/ + //_fmemset(vga+x1+y2, color, 16*16); + byte far *p; + + p=vga+y1*width+x1; // make p point to the start of the line + while((y2-y1)) // repeat for entire line height + { + _fmemset(p, color, x2-x1); // set one line + p+=width; // move down one row + } +} /*-----------XXXX-------------*/ @@ -312,252 +321,252 @@ void drawrect(int x1, int y1, int x2, int y2, char color) int far * getFont() { - union REGPACK rg; - int seg; - int off; - memset(&rg, 0, sizeof(rg)); - - rg.w.ax = 0x1130; - rg.h.bh = 0x03; - intr(0x10, &rg); - seg = rg.w.es; - off = rg.w.bp; - - - return (int far *)MK_FP(seg, off); + union REGPACK rg; + int seg; + int off; + memset(&rg, 0, sizeof(rg)); + + rg.w.ax = 0x1130; + rg.h.bh = 0x03; + intr(0x10, &rg); + seg = rg.w.es; + off = rg.w.bp; + + + return (int far *)MK_FP(seg, off); } void drawChar(int x, int y, int color, byte c) { - int i, j; - int mask; - int far *font = getFont() + (c * 8); - - for (i = 0; i < 8; i++) - { - mask = *font; - for (j = 0; j < 8; j++) + int i, j; + int mask; + int far *font = getFont() + (c * 8); + + for (i = 0; i < 8; i++) { - if (mask & 0x80) - { - //pixel(x + j, y + i, color); - putPixel_X(x + j, y + i, color); - } - mask <<= 1; + mask = *font; + for (j = 0; j < 8; j++) + { + if (mask & 0x80) + { + //pixel(x + j, y + i, color); + putPixel_X(x + j, y + i, color); + } + mask <<= 1; + } + font++; } - font++; - } } void drawText(int x, int y, int color, byte string) { - while (string) - { - drawChar(x, y, color, string); - x += 8; - string++; - } + while (string) + { + drawChar(x, y, color, string); + x += 8; + string++; + } } ///////////////////////////////////////////////////////////////////////////// -// // -// setvideo() - This function Manages the video modes // -// // +// // +// setvideo() - This function Manages the video modes // +// // ///////////////////////////////////////////////////////////////////////////// void setvideo(/*byte mode, */int vq){ - union REGS in, out; - - if(!vq){ // deinit the video - // change to the video mode we were in before we switched to mode 13h - in.h.ah = 0x00; - in.h.al = old_mode; - int86(0x10, &in, &out); - - }else if(vq == 1){ // init the video - // get old video mode - in.h.ah = 0xf; - int86(0x10, &in, &out); - old_mode = out.h.al; - - // enter mode - set320x240x256_X(); - } + union REGS in, out; + + if(!vq){ // deinit the video + // change to the video mode we were in before we switched to mode 13h + in.h.ah = 0x00; + in.h.al = old_mode; + int86(0x10, &in, &out); + + }else if(vq == 1){ // init the video + // get old video mode + in.h.ah = 0xf; + int86(0x10, &in, &out); + old_mode = out.h.al; + + // enter mode + set320x240x256_X(); + } } ///////////////////////////////////////////////////////////////////////////// -// // +// // // cls() - This clears the screen to the specified color, on the VGA or on // -// the Virtual screen. // -// // +// the Virtual screen. // +// // ///////////////////////////////////////////////////////////////////////////// void cls(byte color, byte *Where){ - _fmemset(Where, color, width*height); + _fmemset(Where, color, width*(height*17)); } //color ‚Ä‚·‚Æ int colortest(){ - if(gq < NUM_COLORS){ - cls(gq, vga); - gq++; - }else gq = 0; - return gq; + if(gq < NUM_COLORS){ + cls(gq, vga); + gq++; + }else gq = 0; + return gq; } //color ‚Ä‚·‚Æ int colorz(){ - if(gq < HGQ){ -//---- cls(gq, vaddr); - cls(gq, vga); - gq++; - }else gq = LGQ; - return gq; + if(gq < HGQ){ +//---- cls(gq, vaddr); + cls(gq, vga); + gq++; + }else gq = LGQ; + return gq; } //slow spectrum down void ssd(int svq){ - if(sy < height+1){ - if(sx < width+1){ - //plotpixel(xx, yy, coor, vga); - //ppf(sx, sy, coor, vga); - putPixel_X(sx, sy, coor); - //printf("%d %d %d %d\n", sx, sy, svq, coor); - sx++; - }else sx = 0; - if(sx == width){ - sy++; - if(svq == 7) coor++; - if(sy == height && svq == 8) coor = rand()%NUM_COLORS; - } - }else sy = 0; + if(sy < height+1){ + if(sx < width+1){ + //plotpixel(xx, yy, coor, vga); + //ppf(sx, sy, coor, vga); + putPixel_X(sx, sy, coor); + //printf("%d %d %d %d\n", sx, sy, svq, coor); + sx++; + }else sx = 0; + if(sx == width){ + sy++; + if(svq == 7) coor++; + if(sy == height && svq == 8) coor = rand()%NUM_COLORS; + } + }else sy = 0; } /*-----------ding-------------*/ int ding(int q){ - setActivePage(0); - setVisiblePage(0); - int d3y; - -//++++ if(q <= 4 && q!=2 && gq == BONK-1) coor = rand()%HGQ; - if((q == 2 - ||q==4 - ||q==16 - ) && gq == BONK-1){ - if(coor < HGQ && coor < LGQ) coor = LGQ; - if(coor < HGQ-1){ - coor++; - }else{ coor = LGQ; - bakax = rand()%3; bakay = rand()%3; + setActivePage(0); + setVisiblePage(0); + int d3y; + +//++++ if(q <= 4 && q!=2 && gq == BONK-1) coor = rand()%HGQ; + if((q == 2 + ||q==4 + ||q==16 + ) && gq == BONK-1){ + if(coor < HGQ && coor < LGQ) coor = LGQ; + if(coor < HGQ-1){ + coor++; + }else{ coor = LGQ; + bakax = rand()%3; bakay = rand()%3; + } } - } - - if(q == 5){ colortest(); return gq; } - if(q == 10){ colorz(); return gq; } - if(q == 11){ colorz(); delay(100); return gq; } - if(q == 8){ ssd(q); /*printf("%d\n", coor);*/ } - if(q == 6){ - coor = rand()%NUM_COLORS; -//---- cls(coor, vaddr); - cls(coor, vga); - //updatevbuff(); - } - - if(q == 7 || q== 9){ - if(gq < HGQ){ - if(q == 7) ssd(q); - if(q == 9){ ssd(q); coor++; } - gq++; - }else gq = LGQ; - } - if((q<5 && gq0){ - yy++; - d3y--; - } - } - if(bakax<0){ - xx--; - }else - if(bakax>0){ - xx++; - } - }else{ - if(q==16) - { - if(!bakax){ - xx--;//=TILEWH; - }else if(bakax>0){ - xx++;//=TILEWH; - } - if(!bakay){ - yy--;//=TILEWH; - }else if(bakay>0){ - yy++;//=TILEWH; + + if(q == 7 || q== 9){ + if(gq < HGQ){ + if(q == 7) ssd(q); + if(q == 9){ ssd(q); coor++; } + gq++; + }else gq = LGQ; + } + if((q<5 && gq1){ - xx+=TILEWH; + if(q==3){ + if(d3y){ + if(bakay<0){ + yy--; + d3y--; + }else + if(bakay>0){ + yy++; + d3y--; + } + } + if(bakax<0){ + xx--; + }else + if(bakax>0){ + xx++; + } + }else{ + if(q==16) + { + if(!bakax){ + xx--;//=TILEWH; + }else if(bakax>0){ + xx++;//=TILEWH; + } + if(!bakay){ + yy--;//=TILEWH; + }else if(bakay>0){ + yy++;//=TILEWH; + } + }else{ + if(!bakax){ + xx-=TILEWH; + }else if(bakax>1){ + xx+=TILEWH; + } + if(!bakay){ + yy-=TILEWH; + }else if(bakay>1){ + yy+=TILEWH; + } + } } - if(!bakay){ - yy-=TILEWH; - }else if(bakay>1){ - yy+=TILEWH; + // fixer + if(q!=16){ + if(xx<0) xx=width; + if(yy<0) yy=height; + if(xx>width) xx=0; + if(yy>height) yy=0; } - } - } - // fixer - if(q!=16){ - if(xx<0) xx=width; - if(yy<0) yy=height; - if(xx>width) xx=0; - if(yy>height) yy=0; - } //interesting effects - if(q==16) - { - int tx=0,ty=0; - tx+=xx+16; - ty+=yy+16; - putPixel_X(tx, ty, coor); - //drawrect(tx, ty, tx+TILEWH, ty+TILEWH, coor); - //printf("%d %d %d %d %d %d\n", xx, yy, tx, ty, TILEWH); - - // plot the pixel -//---- ppf(xx, yy, coor, vga); -//++++0000 putPixel_X(xx, yy, coor); - }else drawrect(xx, yy, xx+TILEWH-1, yy+TILEWH-1, coor); -//---- if(q==2) ppf(rand()%, rand()%height, 0, vga); - if(q==2||q==16) putPixel_X(rand()%width, rand()%height, 0); - if(q==2||q==4||q==16){ bakax = rand()%3; bakay = rand()%3; } - gq++; + if(q==16) + { + int tx=0,ty=0; + tx+=xx+16; + ty+=yy+16; + putPixel_X(tx, ty, coor); + //drawrect(tx, ty, tx+TILEWH, ty+TILEWH, coor); + //printf("%d %d %d %d %d %d\n", xx, yy, tx, ty, TILEWH); + + // plot the pixel +//---- ppf(xx, yy, coor, vga); +//++++0000 putPixel_X(xx, yy, coor); + }else drawrect(xx, yy, xx+TILEWH-1, yy+TILEWH-1, coor); +//---- if(q==2) ppf(rand()%, rand()%height, 0, vga); + if(q==2||q==16) putPixel_X(rand()%width, rand()%height, 0); + if(q==2||q==4||q==16){ bakax = rand()%3; bakay = rand()%3; } + gq++; //if(xx<0||xx>320||yy<0||yy>240) -// printf("%d %d %d %d %d %d\n", xx, yy, coor, bakax, bakay, getPixel_X(xx,yy)); -// printf("%d\n", getPixel_X(xx,yy)); +// printf("%d %d %d %d %d %d\n", xx, yy, coor, bakax, bakay, getPixel_X(xx,yy)); +// printf("%d\n", getPixel_X(xx,yy)); //0000 -// drawText(0, 0, 15, getPixel_X(xx,yy)); - }else gq = LGQ; - return gq; +// drawText(0, 0, 15, getPixel_X(xx,yy)); + }else gq = LGQ; + return gq; } @@ -572,103 +581,103 @@ int ding(int q){ #include void doTest(void) - { - int p, x, y, pages; - - /* This is the way to calculate the number of pages available. */ - pages = 65536L/(widthBytes*height); // apparently this takes the A000 address + { + int p, x, y, pages; - printf("%d\n", pages); + /* This is the way to calculate the number of pages available. */ + pages = 65536L/(widthBytes*height); // apparently this takes the A000 address - for (p = 0; p <= pages; ++p) - { - setActivePage(p); + printf("%d\n", pages); - /* On each page draw a single colored border, and dump the palette - onto a small square about the middle of the page. */ - - //{ - for (x = 0; x <= width; ++x) + for (p = 0; p <= pages; ++p) { - putPixel_X(x, 0, p+1); - if(p!=pages) putPixel_X(x, height-1, p+1); - else putPixel_X(x, 99-1, p+1); - } + setActivePage(p); - for (y = 0; y <= height; ++y) - { - putPixel_X(0, y, p+1); - if(p!=pages) putPixel_X(width-1, y, p+1); - else putPixel_X(width-1, y, p+1); - } + /* On each page draw a single colored border, and dump the palette + onto a small square about the middle of the page. */ - for (x = 0; x < 16; ++x) - for (y = 0; y < 16; ++y) - putPixel_X(x+(p+2)*16, y+(p+2)*16, x + y*16); - //} + //{ + for (x = 0; x <= width; ++x) + { + putPixel_X(x, 0, p+1); + if(p!=pages) putPixel_X(x, height-1, p+1); + else putPixel_X(x, 99-1, p+1); + } - drawText(0, 0, 15, p); + for (y = 0; y <= height; ++y) + { + putPixel_X(0, y, p+1); + if(p!=pages) putPixel_X(width-1, y, p+1); + else putPixel_X(width-1, y, p+1); + } - } + for (x = 0; x < 16; ++x) + for (y = 0; y < 16; ++y) + putPixel_X(x+(p+2)*16, y+(p+2)*16, x + y*16); + //} - /* Each pages will now contain a different image. Let the user cycle - through all the pages by pressing a key. */ - for (p = 0; p <= pages; ++p) - { - setVisiblePage(p); - //drawText(0, 240, 15, "bakapi"); - getch(); - } + drawText(0, 0, 15, p); - } + } + + /* Each pages will now contain a different image. Let the user cycle + through all the pages by pressing a key. */ + for (p = 0; p <= pages; ++p) + { + setVisiblePage(p); + //drawText(0, 240, 15, "bakapi"); + getch(); + } + + } /* * Library test (program) entry point. */ int main(void) - { - int key,d; - // main variables - d=1; // switch variable - key=4; // default screensaver number -// puts("First, have a look at the 320x200 mode. I will draw some rubbish"); -// puts("on all of the four pages, then let you cycle through them by"); -// puts("hitting a key on each page."); -// puts("Press a key when ready..."); -// getch(); - -// doTest(); - -// puts("Then, check out Mode X, 320x240 with 3 (and a half) pages."); -// puts("Press a key when ready..."); -// getch(); - - setvideo(1); + { + int key,d; + // main variables + d=1; // switch variable + key=4; // default screensaver number +// puts("First, have a look at the 320x200 mode. I will draw some rubbish"); +// puts("on all of the four pages, then let you cycle through them by"); +// puts("hitting a key on each page."); +// puts("Press a key when ready..."); +// getch(); + +// doTest(); + +// puts("Then, check out Mode X, 320x240 with 3 (and a half) pages."); +// puts("Press a key when ready..."); +// getch(); + + setvideo(1); // screen savers /*while(d!=0){ // on! - if(!kbhit()){ // conditions of screen saver - ding(key); - }else{ - setvideo(0); - // user imput switch - printf("Enter 1, 2, 3, 4, or 6 to run a screensaver, or enter 5 to quit.\n", getch()); // prompt the user - scanf("%d", &key); - //if(key==3){xx=yy=0;} // crazy screen saver wwww - if(key==5) d=0; - setvideo(1); + if(!kbhit()){ // conditions of screen saver + ding(key); + }else{ + setvideo(0); + // user imput switch + printf("Enter 1, 2, 3, 4, or 6 to run a screensaver, or enter 5 to quit.\n", getch()); // prompt the user + scanf("%d", &key); + //if(key==3){xx=yy=0;} // crazy screen saver wwww + if(key==5) d=0; + setvideo(1); + } + }*/ // else off + while(!kbhit()){ // conditions of screen saver + ding(4); + } + //end of screen savers + doTest(); + setvideo(0); + puts("Where to next? It's your move! wwww"); + printf("bakapi ver. 1.04.09a\nis made by sparky4i†ƒÖ…j feel free to use it ^^\nLicence: GPL v2\n"); + return 0; } - }*/ // else off - while(!kbhit()){ // conditions of screen saver - ding(4); - } - //end of screen savers - doTest(); - setvideo(0); - puts("Where to next? It's your move! wwww"); - printf("bakapi ver. 1.04.09a\nis made by sparky4i†ƒÖ…j feel free to use it ^^\nLicence: GPL v2\n"); - return 0; - } #endif diff --git a/16/dos_gfx.h b/16/dos_gfx.h index b95f0159..1036e362 100644 --- a/16/dos_gfx.h +++ b/16/dos_gfx.h @@ -9,14 +9,14 @@ //static hgq=NUM_COLORS/(1/8) #define BONK 400 #define LGQ 32 -#define HGQ 56 -#define TILEWH 16 +#define HGQ 56 +#define TILEWH 16 #define ABS(a) ((a < 0) ? -a : a) #define SGN(a) ((a < 0) ? -1 : 1) //#define VMEM 0xA000 // = vga //int width = 320; //int height = 240; - + void drawChar(int x, int y, int color, byte c); void drawText(int x, int y, int color, byte string); void setvideo(/*byte mode, */int vq); @@ -25,9 +25,9 @@ void setvideo(/*byte mode, */int vq); void cls(byte color, byte *Where); //void clearscr(); //void plotpixel(int x, int y, byte color, byte *Where); -//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); +//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); //void BlockMove(); //void eraseplayer(int x, int y); //void drawplayer(int x, int y, int color); -- 2.39.5