,'___...---~~~\n\\r
";\r
// static byte *rosa;\r
- static word chx, chy, colpee;\r
- static word z;\r
+ static word chx, chy, colpee, addr;\r
textInit();\r
\r
// DOSLIB: check our environment\r
return;\r
}\r
VGAmodeX(1, 1, &gvar);\r
-// __asm{\r
-// mov AH,12H\r
-// mov BL,30h\r
-// mov AL,04h\r
-// int 10\r
-// mov ax,1123h\r
-// int 10h\r
-// ;mov ax,1112h ; load 8x8 character set into RAM\r
-// ;int 10h\r
-// }\r
/* setup camera and screen~ */\r
gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);\r
gvar.video.page[0].width += (16*2);\r
gvar.video.page[0].height += (16*2);\r
modexShowPage(&gvar.video.page[0]);\r
+ addr = (gvar.video.page[0].width/4) * chy + (chx / 4) + ((word)gvar.video.page[0].data); /* at start of function */\r
vga_read_crtc_mode(&cm);\r
// NTS: We're in Mode-X now. printf() is useless. Do not use printf(). Or INT 10h text printing. Or DOS console output.\r
//modexprint(16, 16, 1, 15, "wwww");\r
//getch();\r
chx=0;\r
chy=0;\r
-// colpee=32;\r
+ colpee=32;\r
// bios_cls();\r
/* position the cursor to home */\r
// vga_moveto(0,0);\r
// vga_sync_bios_cursor();\r
- for(e=0x00, z=0; e<=0xFE; e++, z++)\r
+ for(e=0x00; e<=0xFE; e++)\r
{\r
- //if(chx+8>(gvar.video.page[0].width/2))\r
- if((z)+1>16)\r
+ if(chx+8>(gvar.video.page[0].width/2))\r
{\r
chx=0;\r
chy+=8;\r
sprintf(pee,"%u", colpee);\r
- modexprint(&gvar.video.page[0], 200, 200, 1, 47, 0, &pee, 1);\r
- z=0;\r
-// printf("\n");\r
+ modexprint(&gvar.video.page[0], 200, 200, 1, 47, 0, &pee, addr, 1);\r
//getch();\r
}\r
sprintf(pee, "%zc", e);\r
- modexprint(&gvar.video.page[0], chx, chy, 1, 0, colpee, &e, 1);\r
+ modexprint(&gvar.video.page[0], chx, chy, 1, 0, colpee, &e, addr, 1);\r
chx+=9;\r
colpee++;\r
-// if(colpee>=32+24) colpee=32;\r
+ if(colpee>=32+24) colpee=32;\r
}\r
getch();\r
//modexprint(100, 100, 1, 47, 0, "wwww");\r
break;
case 8:
colorz(page, pee);
- modexprint(page, page->sw/2, page->sh/2, 1, 47, 0, "bakapi", 1);
+ modexprint(page, page->sw/2, page->sh/2, 1, 47, 0, "bakapi", (page[0].width/4) * pee->yy + (pee->xx / 4) + ((word)page[0].data), 1);
break;
case 9:
if(pee->coor <= HGQ)
\r
}\r
\r
-void modexhlin(page_t *page, word xl, word xh, word y, word color)\r
-{\r
- word x;\r
- word yy=0;\r
-\r
- for(x=0;x<xh*4;x+=4)\r
- {\r
- if(x+4>=page[0].sw-1){ x=0; yy+=4; }\r
- modexClearRegion(page, x+xl, y+yy, 4, 4, color);\r
- }\r
- //modexputPixel(page, x+xl, y, color);\r
-}\r
-\r
-void modexprint(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str, boolean q)\r
+void modexprint(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str, word addrq, boolean q)\r
{\r
word s, o, w;\r
word addr = (word) romFontsData.l;\r
JNZ L1\r
}\r
//TODO: OPTIMIZE THIS!!!!\r
- modexDrawCharPBuf(page, x, y, t, col, bgcol, q);\r
+ modexDrawCharPBuf(page, x, y, t, col, bgcol, addrq, q);\r
\r
//if(!q) getch();\r
}\r
byte blue;
} rgb_t;
+/* -======================= Constants & Vars ==========================- */
+extern byte far* VGA; /* The VGA Memory */
+#define SCREEN_SEG 0xa000
+#define VIDEO_INT 0x10
+#define SET_MODE 0x00
+#define VGA_256_COLOR_MODE 0x13
+#define TEXT_MODE 0x03
+
+#define AC_INDEX 0x03c0
+#define SC_INDEX 0x03c4
+#define SC_DATA 0x03c5
+#define CRTC_INDEX 0x03d4
+#define CRTC_DATA 0x03d5
+#define GC_INDEX 0x03ce
+#define MISC_OUTPUT 0x03c2
+#define HIGH_ADDRESS 0x0C
+#define LOW_ADDRESS 0x0D
+#define VRETRACE 0x08
+//#define INPUT_STATUS_1 0x03da defined in 16_head
+#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)
+
/* -============================ Functions =============================- */
/* mode switching, page, and plane functions */
void VGAmodeX(sword vq, boolean cmem, global_game_variables_t *gv);
void modexchkcolor(bitmap_t *bmp, word *q, word *a, word *aa, word *z, word *i/*, word *offset*/);
void modexputPixel(page_t *page, int x, int y, byte color);
byte modexgetPixel(page_t *page, int x, int y);
-void modexhlin(page_t *page, word xl, word xh, word y, word color);
-void modexprint(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str, boolean q);
+static inline void modexwritepixel(page_t *page, int x, int y, word addr, 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: */
+ modexSelectPlane(PLANE(x));
+ //outp(SC_INDEX, 0x02);
+ //outp(SC_DATA, 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_state.vga_graphics_ram[addr] = color;
+}
+static inline byte modexreadPixel(page_t *page, int x, int y, word addr)
+{
+ /* Select the plane from which we must read the pixel color: */
+ outpw(GC_INDEX, 0x04);
+ outpw(GC_INDEX+1, x & 3);
+ return vga_state.vga_graphics_ram[addr];
+}
+void modexprint(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str, word addrq, boolean q);
void modexprintbig(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str);
void modexpdump(page_t *pee);
void modexcls(page_t *page, byte color, byte *Where);
//void modexWaitBorder();
void bios_cls();
-/* -======================= Constants & Vars ==========================- */
-extern byte far* VGA; /* The VGA Memory */
-#define SCREEN_SEG 0xa000
-#define VIDEO_INT 0x10
-#define SET_MODE 0x00
-#define VGA_256_COLOR_MODE 0x13
-#define TEXT_MODE 0x03
-
-#define AC_INDEX 0x03c0
-#define SC_INDEX 0x03c4
-#define SC_DATA 0x03c5
-#define CRTC_INDEX 0x03d4
-#define CRTC_DATA 0x03d5
-#define GC_INDEX 0x03ce
-#define MISC_OUTPUT 0x03c2
-#define HIGH_ADDRESS 0x0C
-#define LOW_ADDRESS 0x0D
-#define VRETRACE 0x08
-//#define INPUT_STATUS_1 0x03da defined in 16_head
-#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
}\r
}\r
\r
-void modexDrawCharPBuf(page_t *page, int x, int y, word t, word col, word bgcol, boolean q)\r
+void modexDrawCharPBuf(page_t *page, int x, int y, word t, word col, word bgcol, word addr, boolean q)\r
{\r
word i, j, k;\r
for(i=0; i<romFonts[t].charSize; i++)\r
{\r
if(q)\r
//_fmemcpy(page->data + (((page->width/4) * (y+i)) + ((x+romFontsData.chw+k) / 4)), romFontsData.l[i] & j ? col:bgcol, 2);\r
- modexputPixel(page, x+k+romFontsData.chw, y+i, romFontsData.l[i] & j ? col:bgcol);\r
+ modexwritepixel(page, x+k+romFontsData.chw, y+i, addr, romFontsData.l[i] & j ? col:bgcol);\r
else\r
//printf("l[i]=%c j=%02u l[i] & j=%02u %c\n", l[i] , j, l[i] & j, l[i] & j ? '*':' ');\r
//printf("%c", l[i] & j ? '*':' ');\r
void modexDrawBmpPBufRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, planar_buf_t *bmp);\r
void modexDrawSpritePBuf(page_t *page, int x, int y, planar_buf_t *bmp);\r
void modexDrawSpritePBufRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, planar_buf_t *bmp);\r
-void modexDrawCharPBuf(page_t *page, int x, int y, word t, word col, word bgcol, boolean q);\r
+void modexDrawCharPBuf(page_t *page, int x, int y, word t, word col, word bgcol, word addr, boolean q);\r
\r
#endif\r
{\r
\r
byte l[1024];\r
- static byte e;\r
- static word chx, chy, colpee;\r
byte pee[2];\r
\r
//w=0;\r
}\r
}\r
\r
- chx=0;\r
- chy=0;\r
- colpee=32;\r
- for(e=0x00; e<=0xFE; e++)\r
- {\r
- if(chx+8>(gvar.video.page[0].width/2))\r
- {\r
- chx=0;\r
- chy+=8;\r
- sprintf(pee,"%u", colpee);\r
- modexprint(&gvar.video.page[0], 200, 200, 1, 47, 0, &pee, 0);\r
- //getch();\r
- }\r
- modexprint(&gvar.video.page[0], chx, chy, 1, 0, colpee, &e, 0);\r
- chx+=9;\r
- colpee++;\r
- if(colpee>=32+24) colpee=32;\r
- }\r
-\r
fprintf(stderr,"Project 16 planrpcx.exe. This is just a test file!\n");\r
fprintf(stderr,"version %s\n", VERSION);\r
fprintf(stderr,"%d\n", sizeof(p.plane));\r