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,
\r
13 0x0402, 0x0502, 0x0602, 0x0702,
\r
14 0x0802, 0x0902, 0x0A02, 0x0B02,
\r
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;
104 /* returns the next page in contiguous memory
105 * the next page will be the same size as p, by default
108 modexNextPage(page_t *p) {
111 result.data = p->data + (p->width/4)*p->height; /* compute the offset */
114 result.width = p->width;
115 result.height = p->height;
122 modexShowPage(page_t *page) {
128 /* calculate offset */
129 offset = (word) page->data;
130 offset += page->dy * (page->width >> 2 );
131 offset += page->dx >> 2;
133 /* calculate crtcOffset according to virtual width */
134 crtcOffset = page->width >> 3;
136 high_address = HIGH_ADDRESS | (offset & 0xff00);
137 low_address = LOW_ADDRESS | (offset << 8);
139 /* wait for appropriate timing and then program CRTC */
140 while ((inp(INPUT_STATUS_1) & DISPLAY_ENABLE));
141 outpw(CRTC_INDEX, high_address);
142 outpw(CRTC_INDEX, low_address);
143 outp(CRTC_INDEX, 0x13);
144 outp(CRTC_DATA, crtcOffset);
146 /* wait for one retrace */
147 while (!(inp(INPUT_STATUS_1) & VRETRACE));
149 /* do PEL panning here */
150 outp(AC_INDEX, 0x33);
151 outp(AC_INDEX, (page->dx & 0x03) << 1);
156 modexPanPage(page_t *page, int dx, int dy) {
163 modexSelectPlane(byte plane) {
164 outp(SC_INDEX, MAP_MASK); /* select plane */
165 outp(SC_DATA, plane);
170 modexClearRegion(page_t *page, int x, int y, int w, int h, byte color) {
171 word pageOff = (word) page->data;
172 word xoff=x/4; /* xoffset that begins each row */
173 word scanCount=w/4; /* number of iterations per row (excluding right clip)*/
174 word poffset = pageOff + y*(page->width/4) + xoff; /* starting offset */
175 word nextRow = page->width/4-scanCount-1; /* loc of next row */
176 byte lclip[] = {0x0f, 0x0e, 0x0c, 0x08}; /* clips for rectangles not on 4s */
177 byte rclip[] = {0x00, 0x01, 0x03, 0x07};
178 byte left = lclip[x&0x03];
179 byte right = rclip[(x+w)&0x03];
181 /* handle the case which requires an extra group */
182 if((x & 0x03) && !((x+w) & 0x03)) {
187 MOV AX, SCREEN_SEG ; go to the VGA memory
189 MOV DI, poffset ; go to the first pixel
190 MOV DX, SC_INDEX ; point to the map mask
194 MOV AL, color ; get ready to write colors
196 MOV CX, scanCount ; count the line
197 MOV BL, AL ; remember color
198 MOV AL, left ; do the left clip
199 OUT DX, AL ; set the left clip
200 MOV AL, BL ; restore color
201 STOSB ; write the color
203 JZ SCAN_DONE ; handle 1 group stuff
205 ;-- write the main body of the scanline
206 MOV BL, AL ; remember color
207 MOV AL, 0x0f ; write to all pixels
209 MOV AL, BL ; restore color
210 REP STOSB ; write the color
212 MOV BL, AL ; remeber color
214 OUT DX, AL ; do the right clip
215 MOV AL, BL ; restore color
217 ADD DI, nextRow ; go to the next row
225 modexDrawBmp(page_t *page, int x, int y, bitmap_t *bmp) {
226 /* draw the region (the entire freakin bitmap) */
227 modexDrawBmpRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);
232 modexDrawBmpRegion(page_t *page, int x, int y,
233 int rx, int ry, int rw, int rh, bitmap_t *bmp) {
234 word poffset = (word) page->data + y*(page->width/4) + x/4;
235 byte *data = bmp->data;//+bmp->offset;
236 word bmpOffset = (word) data + ry * bmp->width + rx;
239 byte plane = 1 << ((byte) x & 0x03);
240 word scanCount = width/4 + (width%4 ? 1 :0);
241 word nextPageRow = page->width/4 - scanCount;
242 word nextBmpRow = (word) bmp->width - width;
244 byte planeCounter = 4;
246 //code is a bit slow here
248 MOV AX, SCREEN_SEG ; go to the VGA memory
251 MOV DX, SC_INDEX ; point at the map mask register
256 MOV DX, SC_DATA ; select the current plane
260 ;-- begin plane painting
261 MOV AX, height ; start the row counter
263 MOV DI, poffset ; go to the first pixel
264 MOV SI, bmpOffset ; go to the bmp pixel
266 MOV CX, width ; count the columns
268 MOVSB ; copy the pixel
269 SUB CX, 3 ; we skip the next 3
270 ADD SI, 3 ; skip the bmp pixels
271 LOOP SCAN_LOOP ; finish the scan
274 ADD DI, AX ; go to the next row on screen
276 ADD SI, AX ; go to the next row on bmp
279 JNZ ROW_LOOP ; do all the rows
280 ;-- end plane painting
282 MOV AL, plane ; advance to the next plane
284 AND AL, 0x0f ; mask the plane properly
285 MOV plane, AL ; store the plane
287 INC bmpOffset ; start bmp at the right spot
290 JNZ PLANE_LOOP ; do all 4 planes
296 modexDrawPlanarBuf(page_t *page, int x, int y, planar_buf_t *bmp) {
297 /* TODO - adapt from test code */
299 for(plane=0; plane < 4; plane++)
307 modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp) {
308 /* draw the whole sprite */
309 modexDrawSpriteRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);
313 modexDrawSpriteRegion(page_t *page, int x, int y,
314 int rx, int ry, int rw, int rh, bitmap_t *bmp) {
315 word poffset = (word)page->data + y*(page->width/4) + x/4;
316 byte *data = bmp->data;//+bmp->offset;
317 word bmpOffset = (word) data + ry * bmp->width + rx;
320 byte plane = 1 << ((byte) x & 0x03);
321 word scanCount = width/4 + (width%4 ? 1 :0);
322 word nextPageRow = page->width/4 - scanCount;
323 word nextBmpRow = (word) bmp->width - width;
325 byte planeCounter = 4;
328 MOV AX, SCREEN_SEG ; go to the VGA memory
331 MOV DX, SC_INDEX ; point at the map mask register
336 MOV DX, SC_DATA ; select the current plane
340 ;-- begin plane painting
341 MOV AX, height ; start the row counter
343 MOV DI, poffset ; go to the first pixel
344 MOV SI, bmpOffset ; go to the bmp pixel
346 MOV CX, width ; count the columns
351 JNE DRAW_PIXEL ; draw non-zero pixels
353 INC DI ; skip the transparent pixel
357 MOVSB ; copy the pixel
359 SUB CX, 3 ; we skip the next 3
360 ADD SI, 3 ; skip the bmp pixels
361 LOOP SCAN_LOOP ; finish the scan
364 ADD DI, AX ; go to the next row on screen
366 ADD SI, AX ; go to the next row on bmp
369 JNZ ROW_LOOP ; do all the rows
370 ;-- end plane painting
372 MOV AL, plane ; advance to the next plane
374 AND AL, 0x0f ; mask the plane properly
375 MOV plane, AL ; store the plane
377 INC bmpOffset ; start bmp at the right spot
380 JNZ PLANE_LOOP ; do all 4 planes
385 /* copy a region of video memory from one page to another.
386 * It assumes that the left edge of the tile is the same on both
387 * regions and the memory areas do not overlap.
390 modexCopyPageRegion(page_t *dest, page_t *src,
393 word width, word height)
395 word doffset = (word)dest->data + dy*(dest->width/4) + dx/4;
396 word soffset = (word)src->data + sy*(src->width/4) + sx/4;
397 word scans = width/4;
398 word nextSrcRow = src->width/4 - scans - 1;
399 word nextDestRow = dest->width/4 - scans - 1;
400 byte lclip[] = {0x0f, 0x0e, 0x0c, 0x08}; /* clips for rectangles not on 4s */
401 byte rclip[] = {0x0f, 0x01, 0x03, 0x07};
402 byte left = lclip[sx&0x03];
403 byte right = rclip[(sx+width)&0x03];
406 MOV AX, SCREEN_SEG ; work in the vga space
411 MOV DX, GC_INDEX ; turn off cpu bits
415 MOV AX, SC_INDEX ; point to the mask register
425 MOV CX, scans ; the number of latches
427 MOV AL, left ; do the left column
432 MOV AL, 0fh ; do the inner columns
434 REP MOVSB ; copy the pixels
436 MOV AL, right ; do the right column
441 MOV AX, SI ; go the start of the next row
445 ADD AX, nextDestRow ;
448 DEC height ; do the rest of the actions
451 MOV DX, GC_INDEX+1 ; go back to CPU data
452 MOV AL, 0ffh ; none from latches
460 modexFadeOn(word fade, byte *palette) {
461 fadePalette(-fade, 64, 64/fade+1, palette);
466 modexFadeOff(word fade, byte *palette) {
467 fadePalette(fade, 0, 64/fade+1, palette);
472 modexFlashOn(word fade, byte *palette) {
473 fadePalette(fade, -64, 64/fade+1, palette);
478 modexFlashOff(word fade, byte *palette) {
479 fadePalette(-fade, 0, 64/fade+1, palette);
484 fadePalette(sbyte fade, sbyte start, word iter, byte *palette) {
488 /* handle the case where we just update */
490 modexPalUpdate1(palette);
494 while(iter > 0) { /* FadeLoop */
495 for(i=0; i<PAL_SIZE; i++) { /* loadpal_loop */
496 tmppal[i] = palette[i] - dim;
497 if(tmppal[i] > 127) {
499 } else if(tmppal[i] > 63) {
503 modexPalUpdate1(tmppal);
512 modexPalSave(byte *palette) {
515 outp(PAL_READ_REG, 0); /* start at palette entry 0 */
516 for(i=0; i<PAL_SIZE; i++) {
517 palette[i] = inp(PAL_DATA_REG); /* read the palette data */
525 ptr = malloc(PAL_SIZE);
529 printf("Could not allocate palette.\n");
538 modexLoadPalFile(byte *filename, byte **palette) {
542 /* free the palette if it exists */
547 /* allocate the new palette */
548 *palette = modexNewPal();
551 file = fopen(filename, "rb");
553 printf("Could not open palette file: %s\n", filename);
560 *ptr++ = fgetc(file);
568 modexSavePalFile(char *filename, byte *pal) {
572 /* open the file for writing */
573 file = fopen(filename, "wb");
575 printf("Could not open %s for writing\n", filename);
579 /* write the data to the file */
580 fwrite(pal, 1, PAL_SIZE, file);
588 fadePalette(-1, 64, 1, tmppal);
594 fadePalette(-1, -64, 1, tmppal);
600 modexPalUpdate(bitmap_t *bmp, word *i, word qp, word aqoffset)
602 byte *p = bmp->palette;
606 static word a[PAL_SIZE]; //palette array of change values!
607 word z=0, aq=0, aa=0, pp=0;
612 memset(a, -1, sizeof(a));
613 outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */
623 // printf("q: %02d\n", (q));
624 // printf("qq: %02d\n", (qq));
625 //printf(" (*i)-q=%02d\n", (*i)-q);
626 outp(PAL_WRITE_REG, qq); /* start at the beginning of palette */
628 if((*i)<PAL_SIZE/2 && w==0)
630 for(; (*i)<PAL_SIZE/2; (*i)++)
632 //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]))
633 //____ 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
634 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]))
639 else if(qp>0 && (*i)>=(qp) && (*i)<((qp)+3))
641 //printf("qp=%d\n", qp);
642 //printf(" (*i)=%d a[%d]=%d\n", (*i), qp, a[qp]);
643 printf(" %d's color=%d\n", (*i), (a[qp])-(bmp->offset*3)+qp);
644 //outp(PAL_DATA_REG, p[((a[qp])-(bmp->offset*3)+qp)]);// fix this shit!
645 if((*i)+1==(qp)+3){ w++; /*(*i)++;*/ break; }
649 if(bmp->offset==0 && (*i)<3 && q==0) outp(PAL_DATA_REG, 0);
651 if(qp==0) outp(PAL_DATA_REG, p[(*i)-q]);
652 else{ //outp(PAL_DATA_REG, p[((*i)-(bmp->offset*3)+qp)]);
653 printf("p[]=%d qp=%d p[]-qp=%d\n", ((*i)-(bmp->offset*3)), qp, ((*i)-(bmp->offset*3))+qp); }
656 //if(qp>0) printf("qp=%d\n", qp);
657 //if(qp>0) printf(" (*i)=%d\n", (*i)/3);
659 modexWaitBorder(); /* waits one retrace -- less flicker */
660 if((*i)>=PAL_SIZE/2 && w==0)
662 for(; (*i)<PAL_SIZE; (*i)++)
664 //____ 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
665 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]))
670 else if(qp>0 && (*i)>=(qp) && (*i)<((qp)+3))
672 //printf("qp=%d\n", qp);
673 //printf(" (*i)=%d a[%d]=%d\n", (*i), qp, a[qp]);
674 printf(" %d's color=%d\n", (*i), (a[qp]-(bmp->offset*3)+qp));
675 //outp(PAL_DATA_REG, p[((a[qp])-(bmp->offset*3)+qp)]);// fix this shit!
676 if((*i)+1==(qp)+3){ w++; /*(*i)++;*/ break; }
680 if(qp==0) outp(PAL_DATA_REG, p[(*i)-q]);
681 else{ //outp(PAL_DATA_REG, p[((*i)-(bmp->offset*3)+qp)]);
682 printf("p[]=%d qp=%d p[]-qp=%d\n", ((*i)-(bmp->offset*3)), qp, ((*i)-(bmp->offset*3))+qp); }
685 //printf(" (*i)=%d\n", (*i)/3);
688 printf("\nqqqqqqqq\n\n");
694 long bufSize = (bmp->width * bmp->height);
696 //printf("1(*i)=%02d\n", (*i)/3);
697 //printf("1z=%02d\n", z/3);
698 chkcolor(bmp, &q, &a, &aa, &z, i);
699 //printf("2(*i)=%02d\n", (*i)/3);
700 //printf("2z=%02d\n", z/3);
705 // printf("a[%02d]=(%d)\n", aq, a[aq]);
707 else { aqoffset++; break; }
709 //update the image data here!
710 for(lq=0; lq<bufSize; lq++)
714 use a[qp] instead of bmp->offset for this spot!
719 Facking bloody point the values of the changed palette to correct values.... major confusion! wwww
722 //(offset/bmp->offset)*bmp->offset
725 //printf("%02d ",bmp->data[lq]+bmp->offset);
726 //if(lq > 0 && lq%bmp->width==0) printf("\n");
727 //printf("%02d_", bmp->data[lq]+bmp->offset);
728 /*if(bmp->data[lq]+bmp->offset==aq)
730 //printf("%02d", bmp->data[lq]);
731 //printf("\n%02d\n", bmp->offset);
732 printf("aq=%02d ", aq);
733 printf("a[aq]=%02d ", a[aq]);
734 printf("a[aq]+aqpp=%02d ", a[aq]+aqpp);
735 printf("a[aq]-aqpp=%02d\n", a[aq]-aqpp);
736 //bmp->data[lq]=((bmp->data[lq]+bmp->offset)-a[aq]);
737 //++++ bmp->data[lq]=a[aq]-aqpp;
738 // printf("_%d ", bmp->data[lq]);
739 //if(lq > 0 && lq%bmp->width==0) printf("\n");
741 else if(bmp->data[lq]+bmp->offset < ((*i)/3)-aqpp)
743 if(bmp->data[lq]+bmp->offset >= aq)
745 bmp->data[lq]=(bmp->data[lq]+bmp->offset)-aqpp;//-((z-(*i))/3);
746 //printf("_%d ", bmp->data[lq]+bmp->offset)-aqpp-((z-(*i))/3);
748 else bmp->data[lq]+=(bmp->offset-aqpp);
751 //printf("%02d`", bmp->data[lq]);
752 //if(lq > 0 && lq%bmp->width==0) printf("\n");
755 //printf(" aq=%02d\n", aq);
756 //printf(" aa=%02d\n", aa);
758 //update the palette~
759 modexPalUpdate(bmp, &pp, aq, aqoffset);
762 if(aq<aa){ pp=q; aq++; goto aqpee; }
767 modexPalUpdate1(byte *p)
771 outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */
772 for(i=0; i<PAL_SIZE/2; i++)
774 outp(PAL_DATA_REG, p[i]);
776 modexWaitBorder(); /* waits one retrace -- less flicker */
777 for(; i<PAL_SIZE; i++)
779 outp(PAL_DATA_REG, p[(i)]);
784 modexPalUpdate0(byte *p)
788 outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */
789 for(i=0; i<PAL_SIZE/2; i++)
791 outp(PAL_DATA_REG, rand());
793 modexWaitBorder(); /* waits one retrace -- less flicker */
794 for(; i<PAL_SIZE; i++)
796 outp(PAL_DATA_REG, rand());
801 //i want to make another vesion that checks the palette when the palette is being appened~
802 void chkcolor(bitmap_t *bmp, word *q, word *a, word *aa, word *z, word *i/*, word *offset*/)
808 //printf("q: %02d\n", (*q));
809 printf("chkcolor start~\n");
810 printf("1 (*z): %d\n", (*z)/3);
811 printf("1 (*i): %d\n", (*i)/3);
812 // printf("1 offset of color in palette (*q): %d\n", (*q)/3);
813 printf("wwwwwwwwwwwwwwww\n");
814 //check palette for dups
815 for(; (*z)<PAL_SIZE; (*z)+=3)
817 //printf("\n z: %d\n", (*z));
818 //printf(" q: %d\n", (*q));
819 //printf(" z+q: %d\n\n", ((*z)+(*q)));
822 //---- if(pal[(*z)]==pal[(*z)+3] && pal[(*z)+1]==pal[(*z)+4] && pal[(*z)+2]==pal[(*z)+5])
825 // printf("\n%d [%02d][%02d][%02d]\n", (*z), pal[(*z)], pal[(*z)+1], pal[(*z)+2]);
826 // printf("%d [%02d][%02d][%02d]\n\n", (*z)+3, pal[(*z)+3], pal[(*z)+4], pal[(*z)+5]);
830 else for(zz=0; zz<(*q); zz+=3)
832 //printf("zz: %02d\n", zz/3);
835 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
839 // printf("\nzq1:%d[%02d][%02d][%02d]\n", (zz+q), pal[(zz+q)], pal[(zz+q)+1], pal[(zz+q)+2]);
840 // printf("zq2:%d[%02d][%02d][%02d]\n\n", (zz+q)+3, pal[(zz+q)+3], pal[(zz+q)+4], pal[(zz+q)+5]);
843 else if(pal[zz]==pal[((*z)+(*q))] && pal[zz+1]==pal[((*z)+(*q))+1] && pal[zz+2]==pal[((*z)+(*q))+2])
845 // printf("\n\nwwwwwwwwwwwwwwww\n");
846 // 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]);
847 // 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]);
848 // //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]);
849 // printf(" z : %d [%02d][%02d][%02d] offset value~\n", (*z)/3, pal[(*z)], pal[(*z)+1], pal[(*z)+2]);
854 planned features that i plan to implement~
855 image that has values on the pallete list!
857 no... wait.... no wwww
859 //for(zzii=0; zzii<3; zzii++)
861 //printf("z+q: %d\n\n", ((*z)+(*q)));
865 printf("!! a[%02d]: %d\n", (((*z)+(*q))/3), zz/3);
866 // printf("\n aa: %d\n\n", (*aa));
867 // printf(" a[%02d]=(%02d) offset array i think the palette should be updated again~\n", ((*z)+(*q))/3, a[((*z)+(*q))/3]);
868 // printf("wwwwwwwwwwwwwwww\n\n");
872 printf("================\n");
873 printf("zq: %d [%02d][%02d][%02d]\n", ((*z)+(*q))/3, pal[((*z)+(*q))], pal[((*z)+(*q))+1], pal[((*z)+(*q))+2]);
874 printf("zz: %d [%02d][%02d][%02d]\n", (zz)/3, pal[zz], pal[zz+1], pal[zz+2]);
875 printf("z : %d [%02d][%02d][%02d]\n", (*z)/3, pal[(*z)], pal[(*z)+1], pal[(*z)+2]);
876 printf("================\n");
878 //printf("[%d]", (zz+q));
882 printf("wwwwwwwwwwwwwwww\n");
883 printf("2 (*z): %d\n", (*z)/3);
884 printf("2 (*i): %d\n", (*i)/3);
885 // printf("2 offset of color in palette (*q): %d\n", (*q)/3);
886 printf("chkcolor end~\n");
892 while(inp(INPUT_STATUS_1) & 8) {
896 while(!(inp(INPUT_STATUS_1) & 8)) {
901 /*****************************************************************************
\r
902 find 8x8 font in VGA BIOS ROM
\r
903 *****************************************************************************/
\r
904 byte far *bios_8x8_font(void)
\r
909 /* use BIOS INT 10h AX=1130h to find font #3 (8x8) in ROM */
\r
910 memset(®s, 0, sizeof(regs)); /* for Watcom C */
\r
911 regs.w.ax = 0x1130;
\r
912 regs.w.bx = 0x0300;
\r
914 font = (byte far *)MK_FP(regs.w.es, regs.w.bp);
\r
918 /*****************************************************************************
\r
919 *****************************************************************************/
\r
920 void bputs(page_t *pee, int x, int y, const char *s)
\r
927 font = bios_8x8_font();
928 //skip = 2 - ((pee->width/4) << 3);
929 //printf("font=%Fp\n", font);
\r
930 for(; *s != '\0'; s++)
\r
932 //src.raster = font + 8 * (*s);
933 //BLOODY!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!111111111111!!!11!!11!111!11!!1111!!111!11!!1!!!11!11!!1!!111!11!!
934 // (*(bmp->data)) = (*(font + 8 * (*s)));
935 font_pntr = (*(font + 8 * (*s)));
936 // font_pntr = font + (c << 3);
939 // temp = *font_pntr++;
\r
940 // outpw(SC_INDEX, text_mask[temp & 0x0F]);
\r
941 //*vga_ptr++ = color;
\r
943 // outpw(SC_INDEX, text_mask[temp >> 4]);
\r
944 //*vga_ptr-- = color;
\r
945 //vga_ptr += widthBytes;
\r
948 //printf("fontoffset=%Fp\n", font + 8 * (*s));
949 //printf("*fontoffset=%s\n", *(font + 8 * (*s)));
950 //printf("w.data=%Fp\n", (w.data));
951 //printf("*w.data=%s\n", *(w.data));
952 //blit1(&src, bmp, x, y);
953 // modexDrawSprite(page, x, y, bmp);
954 // modexDrawBmp(page, x, y, bmp);
955 // printf("%x\n", (*(font + 8 * (*s))));
956 //_fmemset(VGA, *(font + 8 * (*s)), _msize(font));
959 modexClearRegion(pee, x, y, 8, 8, 4);