7 #include "src/lib/modex16.h"
10 byte far* VGA=(byte far*) 0xA0000000; /* this points to video memory. */
11 /*word text_mask[16] = {
12 0x0002, 0x0102, 0x0202, 0x0302,
13 0x0402, 0x0502, 0x0602, 0x0702,
14 0x0802, 0x0902, 0x0A02, 0x0B02,
15 0x0C02, 0x0D02, 0x0E02, 0x0F02
18 static void fadePalette(sbyte fade, sbyte start, word iter, byte *palette);
19 static byte tmppal[PAL_SIZE];
28 int86(VIDEO_INT, ®s, ®s);
32 /* -========================= Entry Points ==========================- */
36 dword far*ptr=(dword far*)VGA; /* used for faster screen clearing */
38 0x0d06, /* vertical total */
39 0x3e07, /* overflow (bit 8 of vertical counts) */
40 0x4109, /* cell height (2 to double-scan */
41 0xea10, /* v sync start */
42 0xac11, /* v sync end and protect cr0-cr7 */
43 0xdf12, /* vertical displayed */
44 0x0014, /* turn off dword mode */
45 0xe715, /* v blank start */
46 0x0616, /* v blank end */
47 0xe317 /* turn on byte mode */
49 int CRTParmCount = sizeof(CRTParms) / sizeof(CRTParms[0]);
51 /* TODO save current video mode and palette */
52 vgaSetMode(VGA_256_COLOR_MODE);
54 /* disable chain4 mode */
55 outpw(SC_INDEX, 0x0604);
57 /* synchronous reset while setting Misc Output */
58 outpw(SC_INDEX, 0x0100);
60 /* select 25 MHz dot clock & 60 Hz scanning rate */
61 outp(MISC_OUTPUT, 0xe3);
63 /* undo reset (restart sequencer) */
64 outpw(SC_INDEX, 0x0300);
66 /* reprogram the CRT controller */
67 outp(CRTC_INDEX, 0x11); /* VSync End reg contains register write prot */
68 outp(CRTC_DATA, 0x7f); /* get current write protect on varios regs */
70 /* send the CRTParms */
71 for(i=0; i<CRTParmCount; i++) {
72 outpw(CRTC_INDEX, CRTParms[i]);
75 /* clear video memory */
76 outpw(SC_INDEX, 0x0f02);
77 for(i=0; i<0x8000; i++) {
85 /* TODO restore original mode and palette */
86 vgaSetMode(TEXT_MODE);
94 /* default page values */
98 page.width = SCREEN_WIDTH;
99 page.height = SCREEN_HEIGHT;
105 /* returns the next page in contiguous memory
106 * the next page will be the same size as p, by default
109 modexNextPage(page_t *p) {
112 result.data = p->data + (p->width/4)*p->height; /* compute the offset */
115 result.width = p->width;
116 result.height = p->height;
122 //next page with defined dimentions~
124 modexNextPage0(page_t *p, word x, word y)
128 result.data = p->data + (p->width/4)*p->height; /* compute the offset */
140 modexShowPage(page_t *page) {
146 /* calculate offset */
147 offset = (word) page->data;
148 offset += page->dy * (page->width >> 2 );
149 offset += page->dx >> 2;
151 /* calculate crtcOffset according to virtual width */
152 crtcOffset = page->width >> 3;
154 high_address = HIGH_ADDRESS | (offset & 0xff00);
155 low_address = LOW_ADDRESS | (offset << 8);
157 /* wait for appropriate timing and then program CRTC */
158 while ((inp(INPUT_STATUS_1) & DISPLAY_ENABLE));
159 outpw(CRTC_INDEX, high_address);
160 outpw(CRTC_INDEX, low_address);
161 outp(CRTC_INDEX, 0x13);
162 outp(CRTC_DATA, crtcOffset);
164 /* wait for one retrace */
165 while (!(inp(INPUT_STATUS_1) & VRETRACE));
167 /* do PEL panning here */
168 outp(AC_INDEX, 0x33);
169 outp(AC_INDEX, (page->dx & 0x03) << 1);
174 modexPanPage(page_t *page, int dx, int dy) {
181 modexSelectPlane(byte plane) {
182 outp(SC_INDEX, MAP_MASK); /* select plane */
183 outp(SC_DATA, plane);
188 modexClearRegion(page_t *page, int x, int y, int w, int h, byte color) {
189 word pageOff = (word) page->data;
190 word xoff=x/4; /* xoffset that begins each row */
191 word scanCount=w/4; /* number of iterations per row (excluding right clip)*/
192 word poffset = pageOff + y*(page->width/4) + xoff; /* starting offset */
193 word nextRow = page->width/4-scanCount-1; /* loc of next row */
194 byte lclip[] = {0x0f, 0x0e, 0x0c, 0x08}; /* clips for rectangles not on 4s */
195 byte rclip[] = {0x00, 0x01, 0x03, 0x07};
196 byte left = lclip[x&0x03];
197 byte right = rclip[(x+w)&0x03];
199 /* handle the case which requires an extra group */
200 if((x & 0x03) && !((x+w) & 0x03)) {
205 MOV AX, SCREEN_SEG ; go to the VGA memory
207 MOV DI, poffset ; go to the first pixel
208 MOV DX, SC_INDEX ; point to the map mask
212 MOV AL, color ; get ready to write colors
214 MOV CX, scanCount ; count the line
215 MOV BL, AL ; remember color
216 MOV AL, left ; do the left clip
217 OUT DX, AL ; set the left clip
218 MOV AL, BL ; restore color
219 STOSB ; write the color
221 JZ SCAN_DONE ; handle 1 group stuff
223 ;-- write the main body of the scanline
224 MOV BL, AL ; remember color
225 MOV AL, 0x0f ; write to all pixels
227 MOV AL, BL ; restore color
228 REP STOSB ; write the color
230 MOV BL, AL ; remeber color
232 OUT DX, AL ; do the right clip
233 MOV AL, BL ; restore color
235 ADD DI, nextRow ; go to the next row
243 oldDrawBmp(byte far* page, int x, int y, bitmap_t *bmp, byte sprite)
249 /* TODO Make this fast. It's SLOOOOOOW */
250 for(plane=0; plane < 4; plane++) {
251 modexSelectPlane(PLANE(plane+x));
252 for(px = plane; px < bmp->width; px+=4) {
254 for(py=0; py<bmp->height; py++) {
255 if(!sprite || bmp->data[offset])
256 page[PAGE_OFFSET(x+px, y+py)] = bmp->data[offset];
265 modexDrawBmp(page_t *page, int x, int y, bitmap_t *bmp) {
266 /* draw the region (the entire freakin bitmap) */
267 modexDrawBmpRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);
272 modexDrawBmpRegion(page_t *page, int x, int y,
273 int rx, int ry, int rw, int rh, bitmap_t *bmp) {
274 word poffset = (word) page->data + y*(page->width/4) + x/4;
275 byte *data = bmp->data;//+bmp->offset;
276 word bmpOffset = (word) data + ry * bmp->width + rx;
279 byte plane = 1 << ((byte) x & 0x03);
280 word scanCount = width/4 + (width%4 ? 1 :0);
281 word nextPageRow = page->width/4 - scanCount;
282 word nextBmpRow = (word) bmp->width - width;
284 byte planeCounter = 4;
286 //code is a bit slow here
288 MOV AX, SCREEN_SEG ; go to the VGA memory
291 MOV DX, SC_INDEX ; point at the map mask register
296 MOV DX, SC_DATA ; select the current plane
300 ;-- begin plane painting
301 MOV AX, height ; start the row counter
303 MOV DI, poffset ; go to the first pixel
304 MOV SI, bmpOffset ; go to the bmp pixel
306 MOV CX, width ; count the columns
308 MOVSB ; copy the pixel
309 SUB CX, 3 ; we skip the next 3
310 ADD SI, 3 ; skip the bmp pixels
311 LOOP SCAN_LOOP ; finish the scan
314 ADD DI, AX ; go to the next row on screen
316 ADD SI, AX ; go to the next row on bmp
319 JNZ ROW_LOOP ; do all the rows
320 ;-- end plane painting
322 MOV AL, plane ; advance to the next plane
324 AND AL, 0x0f ; mask the plane properly
325 MOV plane, AL ; store the plane
327 INC bmpOffset ; start bmp at the right spot
330 JNZ PLANE_LOOP ; do all 4 planes
336 modexDrawPlanarBuf(page_t *page, int x, int y, planar_buf_t *bmp) {
337 /* TODO - adapt from test code */
339 for(plane=0; plane < 4; plane++)
347 modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp) {
348 /* draw the whole sprite */
349 modexDrawSpriteRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);
353 modexDrawSpriteRegion(page_t *page, int x, int y,
354 int rx, int ry, int rw, int rh, bitmap_t *bmp) {
355 word poffset = (word)page->data + y*(page->width/4) + x/4;
356 byte *data = bmp->data;//+bmp->offset;
357 word bmpOffset = (word) data + ry * bmp->width + rx;
360 byte plane = 1 << ((byte) x & 0x03);
361 word scanCount = width/4 + (width%4 ? 1 :0);
362 word nextPageRow = page->width/4 - scanCount;
363 word nextBmpRow = (word) bmp->width - width;
365 byte planeCounter = 4;
368 MOV AX, SCREEN_SEG ; go to the VGA memory
371 MOV DX, SC_INDEX ; point at the map mask register
376 MOV DX, SC_DATA ; select the current plane
380 ;-- begin plane painting
381 MOV AX, height ; start the row counter
383 MOV DI, poffset ; go to the first pixel
384 MOV SI, bmpOffset ; go to the bmp pixel
386 MOV CX, width ; count the columns
391 JNE DRAW_PIXEL ; draw non-zero pixels
393 INC DI ; skip the transparent pixel
397 MOVSB ; copy the pixel
399 SUB CX, 3 ; we skip the next 3
400 ADD SI, 3 ; skip the bmp pixels
401 LOOP SCAN_LOOP ; finish the scan
404 ADD DI, AX ; go to the next row on screen
406 ADD SI, AX ; go to the next row on bmp
409 JNZ ROW_LOOP ; do all the rows
410 ;-- end plane painting
412 MOV AL, plane ; advance to the next plane
414 AND AL, 0x0f ; mask the plane properly
415 MOV plane, AL ; store the plane
417 INC bmpOffset ; start bmp at the right spot
420 JNZ PLANE_LOOP ; do all 4 planes
425 /* copy a region of video memory from one page to another.
426 * It assumes that the left edge of the tile is the same on both
427 * regions and the memory areas do not overlap.
430 modexCopyPageRegion(page_t *dest, page_t *src,
433 word width, word height)
435 word doffset = (word)dest->data + dy*(dest->width/4) + dx/4;
436 word soffset = (word)src->data + sy*(src->width/4) + sx/4;
437 word scans = width/4;
438 word nextSrcRow = src->width/4 - scans - 1;
439 word nextDestRow = dest->width/4 - scans - 1;
440 byte lclip[] = {0x0f, 0x0e, 0x0c, 0x08}; /* clips for rectangles not on 4s */
441 byte rclip[] = {0x0f, 0x01, 0x03, 0x07};
442 byte left = lclip[sx&0x03];
443 byte right = rclip[(sx+width)&0x03];
446 MOV AX, SCREEN_SEG ; work in the vga space
451 MOV DX, GC_INDEX ; turn off cpu bits
455 MOV AX, SC_INDEX ; point to the mask register
465 MOV CX, scans ; the number of latches
467 MOV AL, left ; do the left column
472 MOV AL, 0fh ; do the inner columns
474 REP MOVSB ; copy the pixels
476 MOV AL, right ; do the right column
481 MOV AX, SI ; go the start of the next row
485 ADD AX, nextDestRow ;
488 DEC height ; do the rest of the actions
491 MOV DX, GC_INDEX+1 ; go back to CPU data
492 MOV AL, 0ffh ; none from latches
500 modexFadeOn(word fade, byte *palette) {
501 fadePalette(-fade, 64, 64/fade+1, palette);
506 modexFadeOff(word fade, byte *palette) {
507 fadePalette(fade, 0, 64/fade+1, palette);
512 modexFlashOn(word fade, byte *palette) {
513 fadePalette(fade, -64, 64/fade+1, palette);
518 modexFlashOff(word fade, byte *palette) {
519 fadePalette(-fade, 0, 64/fade+1, palette);
524 fadePalette(sbyte fade, sbyte start, word iter, byte *palette) {
528 /* handle the case where we just update */
530 modexPalUpdate1(palette);
534 while(iter > 0) { /* FadeLoop */
535 for(i=0; i<PAL_SIZE; i++) { /* loadpal_loop */
536 tmppal[i] = palette[i] - dim;
537 if(tmppal[i] > 127) {
539 } else if(tmppal[i] > 63) {
543 modexPalUpdate1(tmppal);
552 modexPalSave(byte *palette) {
555 outp(PAL_READ_REG, 0); /* start at palette entry 0 */
556 for(i=0; i<PAL_SIZE; i++) {
557 palette[i] = inp(PAL_DATA_REG); /* read the palette data */
565 ptr = malloc(PAL_SIZE);
569 printf("Could not allocate palette.\n");
578 modexLoadPalFile(byte *filename, byte **palette) {
582 /* free the palette if it exists */
587 /* allocate the new palette */
588 *palette = modexNewPal();
591 file = fopen(filename, "rb");
593 printf("Could not open palette file: %s\n", filename);
600 *ptr++ = fgetc(file);
608 modexSavePalFile(char *filename, byte *pal) {
612 /* open the file for writing */
613 file = fopen(filename, "wb");
615 printf("Could not open %s for writing\n", filename);
619 /* write the data to the file */
620 fwrite(pal, 1, PAL_SIZE, file);
628 fadePalette(-1, 64, 1, tmppal);
634 fadePalette(-1, -64, 1, tmppal);
640 modexPalUpdate(bitmap_t *bmp, word *i, word qp, word aqoffset)
642 byte *p = bmp->palette;
646 static word a[PAL_SIZE]; //palette array of change values!
647 word z=0, aq=0, aa=0, pp=0;
652 memset(a, -1, sizeof(a));
653 outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */
663 // printf("q: %02d\n", (q));
664 // printf("qq: %02d\n", (qq));
665 //printf(" (*i)-q=%02d\n", (*i)-q);
666 outp(PAL_WRITE_REG, qq); /* start at the beginning of palette */
668 if((*i)<PAL_SIZE/2 && w==0)
670 for(; (*i)<PAL_SIZE/2; (*i)++)
672 //if(i%3==0 && (p[i+5]==p[i+4] && p[i+4]==p[i+3] && p[i+3]==p[i+2] && p[i+2]==p[i+1] && p[i+1]==p[i] && p[i+5]==p[i]))
673 //____ if((qp>0)&&((*i)-q)%3==0 && (p[((*i)-q)]==p[((*i)-q)+3] && p[((*i)-q)+1]==p[((*i)-q)+4] && p[((*i)-q)+2]==p[((*i)-q)+5])) outp(PAL_DATA_REG, p[(*i)-q]); else
674 if(((((*i)-q)%3==0)) && (p[((*i)-q)]==p[((*i)-q)+3] && p[((*i)-q)+1]==p[((*i)-q)+4] && p[((*i)-q)+2]==p[((*i)-q)+5]))
679 else if(qp>0 && (*i)>=(qp) && (*i)<((qp)+3))
681 //printf("qp=%d\n", qp);
682 //printf(" (*i)=%d a[%d]=%d\n", (*i), qp, a[qp]);
683 printf(" %d's color=%d\n", (*i), (a[qp])-(bmp->offset*3)+qp);
684 //outp(PAL_DATA_REG, p[((a[qp])-(bmp->offset*3)+qp)]);// fix this shit!
685 if((*i)+1==(qp)+3){ w++; /*(*i)++;*/ break; }
689 if(bmp->offset==0 && (*i)<3 && q==0) outp(PAL_DATA_REG, 0);
691 if(qp==0) outp(PAL_DATA_REG, p[(*i)-q]);
692 else{ //outp(PAL_DATA_REG, p[((*i)-(bmp->offset*3)+qp)]);
693 printf("p[]=%d qp=%d p[]-qp=%d\n", ((*i)-(bmp->offset*3)), qp, ((*i)-(bmp->offset*3))+qp); }
696 //if(qp>0) printf("qp=%d\n", qp);
697 //if(qp>0) printf(" (*i)=%d\n", (*i)/3);
699 modexWaitBorder(); /* waits one retrace -- less flicker */
700 if((*i)>=PAL_SIZE/2 && w==0)
702 for(; (*i)<PAL_SIZE; (*i)++)
704 //____ if((qp>0)&&((*i)-q)%3==0 && (p[((*i)-q)]==p[((*i)-q)+3] && p[((*i)-q)+1]==p[((*i)-q)+4] && p[((*i)-q)+2]==p[((*i)-q)+5])) outp(PAL_DATA_REG, p[(*i)-q]); else
705 if(((((*i)-q)%3==0)) && (p[((*i)-q)]==p[((*i)-q)+3] && p[((*i)-q)+1]==p[((*i)-q)+4] && p[((*i)-q)+2]==p[((*i)-q)+5]))
710 else if(qp>0 && (*i)>=(qp) && (*i)<((qp)+3))
712 //printf("qp=%d\n", qp);
713 //printf(" (*i)=%d a[%d]=%d\n", (*i), qp, a[qp]);
714 printf(" %d's color=%d\n", (*i), (a[qp]-(bmp->offset*3)+qp));
715 //outp(PAL_DATA_REG, p[((a[qp])-(bmp->offset*3)+qp)]);// fix this shit!
716 if((*i)+1==(qp)+3){ w++; /*(*i)++;*/ break; }
720 if(qp==0) outp(PAL_DATA_REG, p[(*i)-q]);
721 else{ //outp(PAL_DATA_REG, p[((*i)-(bmp->offset*3)+qp)]);
722 printf("p[]=%d qp=%d p[]-qp=%d\n", ((*i)-(bmp->offset*3)), qp, ((*i)-(bmp->offset*3))+qp); }
725 //printf(" (*i)=%d\n", (*i)/3);
728 printf("\nqqqqqqqq\n\n");
734 long bufSize = (bmp->width * bmp->height);
736 //printf("1(*i)=%02d\n", (*i)/3);
737 //printf("1z=%02d\n", z/3);
738 chkcolor(bmp, &q, &a, &aa, &z, i);
739 //printf("2(*i)=%02d\n", (*i)/3);
740 //printf("2z=%02d\n", z/3);
745 // printf("a[%02d]=(%d)\n", aq, a[aq]);
747 else { aqoffset++; break; }
749 //update the image data here!
750 for(lq=0; lq<bufSize; lq++)
754 use a[qp] instead of bmp->offset for this spot!
759 Facking bloody point the values of the changed palette to correct values.... major confusion! wwww
762 //(offset/bmp->offset)*bmp->offset
765 //printf("%02d ",bmp->data[lq]+bmp->offset);
766 //if(lq > 0 && lq%bmp->width==0) printf("\n");
767 //printf("%02d_", bmp->data[lq]+bmp->offset);
768 /*if(bmp->data[lq]+bmp->offset==aq)
770 //printf("%02d", bmp->data[lq]);
771 //printf("\n%02d\n", bmp->offset);
772 printf("aq=%02d ", aq);
773 printf("a[aq]=%02d ", a[aq]);
774 printf("a[aq]+aqpp=%02d ", a[aq]+aqpp);
775 printf("a[aq]-aqpp=%02d\n", a[aq]-aqpp);
776 //bmp->data[lq]=((bmp->data[lq]+bmp->offset)-a[aq]);
777 //++++ bmp->data[lq]=a[aq]-aqpp;
778 // printf("_%d ", bmp->data[lq]);
779 //if(lq > 0 && lq%bmp->width==0) printf("\n");
781 else if(bmp->data[lq]+bmp->offset < ((*i)/3)-aqpp)
783 if(bmp->data[lq]+bmp->offset >= aq)
785 bmp->data[lq]=(bmp->data[lq]+bmp->offset)-aqpp;//-((z-(*i))/3);
786 //printf("_%d ", bmp->data[lq]+bmp->offset)-aqpp-((z-(*i))/3);
788 else bmp->data[lq]+=(bmp->offset-aqpp);
791 //printf("%02d`", bmp->data[lq]);
792 //if(lq > 0 && lq%bmp->width==0) printf("\n");
795 //printf(" aq=%02d\n", aq);
796 //printf(" aa=%02d\n", aa);
798 //update the palette~
799 modexPalUpdate(bmp, &pp, aq, aqoffset);
802 if(aq<aa){ pp=q; aq++; goto aqpee; }
807 modexPalUpdate1(byte *p)
811 outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */
812 for(i=0; i<PAL_SIZE/2; i++)
814 outp(PAL_DATA_REG, p[i]);
816 modexWaitBorder(); /* waits one retrace -- less flicker */
817 for(; i<PAL_SIZE; i++)
819 outp(PAL_DATA_REG, p[(i)]);
824 modexPalUpdate0(byte *p)
828 outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */
829 for(i=0; i<PAL_SIZE/2; i++)
831 outp(PAL_DATA_REG, rand());
833 modexWaitBorder(); /* waits one retrace -- less flicker */
834 for(; i<PAL_SIZE; i++)
836 outp(PAL_DATA_REG, rand());
841 //i want to make another vesion that checks the palette when the palette is being appened~
842 void chkcolor(bitmap_t *bmp, word *q, word *a, word *aa, word *z, word *i/*, word *offset*/)
848 //printf("q: %02d\n", (*q));
849 printf("chkcolor start~\n");
850 printf("1 (*z): %d\n", (*z)/3);
851 printf("1 (*i): %d\n", (*i)/3);
852 // printf("1 offset of color in palette (*q): %d\n", (*q)/3);
853 printf("wwwwwwwwwwwwwwww\n");
854 //check palette for dups
855 for(; (*z)<PAL_SIZE; (*z)+=3)
857 //printf("\n z: %d\n", (*z));
858 //printf(" q: %d\n", (*q));
859 //printf(" z+q: %d\n\n", ((*z)+(*q)));
862 //---- if(pal[(*z)]==pal[(*z)+3] && pal[(*z)+1]==pal[(*z)+4] && pal[(*z)+2]==pal[(*z)+5])
865 // printf("\n%d [%02d][%02d][%02d]\n", (*z), pal[(*z)], pal[(*z)+1], pal[(*z)+2]);
866 // printf("%d [%02d][%02d][%02d]\n\n", (*z)+3, pal[(*z)+3], pal[(*z)+4], pal[(*z)+5]);
870 else for(zz=0; zz<(*q); zz+=3)
872 //printf("zz: %02d\n", zz/3);
875 if(pal[((*z)+(*q))]==pal[((*z)+(*q))+3] && pal[((*z)+(*q))+1]==pal[((*z)+(*q))+4] && pal[((*z)+(*q))+2]==pal[((*z)+(*q))+5]) //break if duplicate colors found in palette because it have reached the end of the current data of the palette
879 // printf("\nzq1:%d[%02d][%02d][%02d]\n", (zz+q), pal[(zz+q)], pal[(zz+q)+1], pal[(zz+q)+2]);
880 // printf("zq2:%d[%02d][%02d][%02d]\n\n", (zz+q)+3, pal[(zz+q)+3], pal[(zz+q)+4], pal[(zz+q)+5]);
883 else if(pal[zz]==pal[((*z)+(*q))] && pal[zz+1]==pal[((*z)+(*q))+1] && pal[zz+2]==pal[((*z)+(*q))+2])
885 // printf("\n\nwwwwwwwwwwwwwwww\n");
886 // printf(" zq: %d [%02d][%02d][%02d] value that is needing to be changed~\n", ((*z)+(*q))/3, pal[((*z)+(*q))], pal[((*z)+(*q))+1], pal[((*z)+(*q))+2]);
887 // printf(" zz: %d [%02d][%02d][%02d] value that the previous value is going to change to~\n", (zz)/3, pal[zz], pal[zz+1], pal[zz+2]);
888 // //printf(" zv: %d [%02d][%02d][%02d] wwww\n", (zz-z+q)/3, pal[(zz-z+q)], pal[(zz-z+q)+1], pal[(zz-z+q)+2]);
889 // printf(" z : %d [%02d][%02d][%02d] offset value~\n", (*z)/3, pal[(*z)], pal[(*z)+1], pal[(*z)+2]);
894 planned features that i plan to implement~
895 image that has values on the pallete list!
897 no... wait.... no wwww
899 //for(zzii=0; zzii<3; zzii++)
901 //printf("z+q: %d\n\n", ((*z)+(*q)));
905 printf("!! a[%02d]: %d\n", (((*z)+(*q))/3), zz/3);
906 // printf("\n aa: %d\n\n", (*aa));
907 // printf(" a[%02d]=(%02d) offset array i think the palette should be updated again~\n", ((*z)+(*q))/3, a[((*z)+(*q))/3]);
908 // printf("wwwwwwwwwwwwwwww\n\n");
912 printf("================\n");
913 printf("zq: %d [%02d][%02d][%02d]\n", ((*z)+(*q))/3, pal[((*z)+(*q))], pal[((*z)+(*q))+1], pal[((*z)+(*q))+2]);
914 printf("zz: %d [%02d][%02d][%02d]\n", (zz)/3, pal[zz], pal[zz+1], pal[zz+2]);
915 printf("z : %d [%02d][%02d][%02d]\n", (*z)/3, pal[(*z)], pal[(*z)+1], pal[(*z)+2]);
916 printf("================\n");
918 //printf("[%d]", (zz+q));
922 printf("wwwwwwwwwwwwwwww\n");
923 printf("2 (*z): %d\n", (*z)/3);
924 printf("2 (*i): %d\n", (*i)/3);
925 // printf("2 offset of color in palette (*q): %d\n", (*q)/3);
926 printf("chkcolor end~\n");
932 while(inp(INPUT_STATUS_1) & 8) {
936 while(!(inp(INPUT_STATUS_1) & 8)) {
941 /*****************************************************************************
942 find 8x8 font in VGA BIOS ROM
943 *****************************************************************************/
944 byte far *bios_8x8_font(void)
949 /* use BIOS INT 10h AX=1130h to find font #3 (8x8) in ROM */
950 memset(®s, 0, sizeof(regs)); /* for Watcom C */
954 font = (byte far *)MK_FP(regs.w.es, regs.w.bp);
958 /*****************************************************************************
959 *****************************************************************************/
960 void bputs(page_t *pee, int x, int y, const byte far *s)
967 font = bios_8x8_font();
968 //skip = 2 - ((pee->width/4) << 3);
969 //printf("font=%Fp\n", font);
970 for(; *s != '\0'; s++)
972 //src.raster = font + 8 * (*s);
973 //BLOODY!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!111111111111!!!11!!11!111!11!!1111!!111!11!!1!!!11!11!!1!!111!11!!
974 // (*(bmp->data)) = (*(font + 8 * (*s)));
975 font_pntr = font + 8 * (*s);
976 // font_pntr = font + (c << 3);
979 // temp = *font_pntr++;
980 // outpw(SC_INDEX, text_mask[temp & 0x0F]);
981 //*vga_ptr++ = color;
983 // outpw(SC_INDEX, text_mask[temp >> 4]);
984 //*vga_ptr-- = color;
985 //vga_ptr += widthBytes;
988 //printf("fontoffset=%Fp\n", font + 8 * (*s));
989 //printf("*fontoffset=%s\n", *(font + 8 * (*s)));
990 //printf("w.data=%Fp\n", (w.data));
991 //printf("*w.data=%s\n", *(w.data));
992 //blit1(&src, bmp, x, y);
993 // modexDrawSprite(page, x, y, bmp);
994 // modexDrawBmp(page, x, y, bmp);
995 // printf("%x\n", (*(font + 8 * (*s))));
996 //_fmemset(VGA, *(font + 8 * (*s)), _msize(font));
999 modexClearRegion(pee, x, y, 8, 8, 4);