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;
120 //next page with defined dimentions~
122 modexNextPage0(page_t *p, word x, word y)
126 result.data = p->data + (p->width/4)*p->height; /* compute the offset */
137 modexShowPage(page_t *page) {
143 /* calculate offset */
144 offset = (word) page->data;
145 offset += page->dy * (page->width >> 2 );
146 offset += page->dx >> 2;
148 /* calculate crtcOffset according to virtual width */
149 crtcOffset = page->width >> 3;
151 high_address = HIGH_ADDRESS | (offset & 0xff00);
152 low_address = LOW_ADDRESS | (offset << 8);
154 /* wait for appropriate timing and then program CRTC */
155 while ((inp(INPUT_STATUS_1) & DISPLAY_ENABLE));
156 outpw(CRTC_INDEX, high_address);
157 outpw(CRTC_INDEX, low_address);
158 outp(CRTC_INDEX, 0x13);
159 outp(CRTC_DATA, crtcOffset);
161 /* wait for one retrace */
162 while (!(inp(INPUT_STATUS_1) & VRETRACE));
164 /* do PEL panning here */
165 outp(AC_INDEX, 0x33);
166 outp(AC_INDEX, (page->dx & 0x03) << 1);
171 modexPanPage(page_t *page, int dx, int dy) {
178 modexSelectPlane(byte plane) {
179 outp(SC_INDEX, MAP_MASK); /* select plane */
180 outp(SC_DATA, plane);
185 modexClearRegion(page_t *page, int x, int y, int w, int h, byte color) {
186 word pageOff = (word) page->data;
187 word xoff=x/4; /* xoffset that begins each row */
188 word scanCount=w/4; /* number of iterations per row (excluding right clip)*/
189 word poffset = pageOff + y*(page->width/4) + xoff; /* starting offset */
190 word nextRow = page->width/4-scanCount-1; /* loc of next row */
191 byte lclip[] = {0x0f, 0x0e, 0x0c, 0x08}; /* clips for rectangles not on 4s */
192 byte rclip[] = {0x00, 0x01, 0x03, 0x07};
193 byte left = lclip[x&0x03];
194 byte right = rclip[(x+w)&0x03];
196 /* handle the case which requires an extra group */
197 if((x & 0x03) && !((x+w) & 0x03)) {
202 MOV AX, SCREEN_SEG ; go to the VGA memory
204 MOV DI, poffset ; go to the first pixel
205 MOV DX, SC_INDEX ; point to the map mask
209 MOV AL, color ; get ready to write colors
211 MOV CX, scanCount ; count the line
212 MOV BL, AL ; remember color
213 MOV AL, left ; do the left clip
214 OUT DX, AL ; set the left clip
215 MOV AL, BL ; restore color
216 STOSB ; write the color
218 JZ SCAN_DONE ; handle 1 group stuff
220 ;-- write the main body of the scanline
221 MOV BL, AL ; remember color
222 MOV AL, 0x0f ; write to all pixels
224 MOV AL, BL ; restore color
225 REP STOSB ; write the color
227 MOV BL, AL ; remeber color
229 OUT DX, AL ; do the right clip
230 MOV AL, BL ; restore color
232 ADD DI, nextRow ; go to the next row
240 oldDrawBmp(byte far* page, int x, int y, bitmap_t *bmp, byte sprite)
246 /* TODO Make this fast. It's SLOOOOOOW */
\r
247 for(plane=0; plane < 4; plane++) {
\r
248 modexSelectPlane(PLANE(plane+x));
\r
249 for(px = plane; px < bmp->width; px+=4) {
\r
251 for(py=0; py<bmp->height; py++) {
\r
252 if(!sprite || bmp->data[offset])
\r
253 page[PAGE_OFFSET(x+px, y+py)] = bmp->data[offset];
\r
254 offset+=bmp->width;
\r
262 modexDrawBmp(page_t *page, int x, int y, bitmap_t *bmp) {
263 /* draw the region (the entire freakin bitmap) */
264 modexDrawBmpRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);
269 modexDrawBmpRegion(page_t *page, int x, int y,
270 int rx, int ry, int rw, int rh, bitmap_t *bmp) {
271 word poffset = (word) page->data + y*(page->width/4) + x/4;
272 byte *data = bmp->data;//+bmp->offset;
273 word bmpOffset = (word) data + ry * bmp->width + rx;
276 byte plane = 1 << ((byte) x & 0x03);
277 word scanCount = width/4 + (width%4 ? 1 :0);
278 word nextPageRow = page->width/4 - scanCount;
279 word nextBmpRow = (word) bmp->width - width;
281 byte planeCounter = 4;
283 //code is a bit slow here
285 MOV AX, SCREEN_SEG ; go to the VGA memory
288 MOV DX, SC_INDEX ; point at the map mask register
293 MOV DX, SC_DATA ; select the current plane
297 ;-- begin plane painting
298 MOV AX, height ; start the row counter
300 MOV DI, poffset ; go to the first pixel
301 MOV SI, bmpOffset ; go to the bmp pixel
303 MOV CX, width ; count the columns
305 MOVSB ; copy the pixel
306 SUB CX, 3 ; we skip the next 3
307 ADD SI, 3 ; skip the bmp pixels
308 LOOP SCAN_LOOP ; finish the scan
311 ADD DI, AX ; go to the next row on screen
313 ADD SI, AX ; go to the next row on bmp
316 JNZ ROW_LOOP ; do all the rows
317 ;-- end plane painting
319 MOV AL, plane ; advance to the next plane
321 AND AL, 0x0f ; mask the plane properly
322 MOV plane, AL ; store the plane
324 INC bmpOffset ; start bmp at the right spot
327 JNZ PLANE_LOOP ; do all 4 planes
333 modexDrawPlanarBuf(page_t *page, int x, int y, planar_buf_t *bmp) {
334 /* TODO - adapt from test code */
336 for(plane=0; plane < 4; plane++)
344 modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp) {
345 /* draw the whole sprite */
346 modexDrawSpriteRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);
350 modexDrawSpriteRegion(page_t *page, int x, int y,
351 int rx, int ry, int rw, int rh, bitmap_t *bmp) {
352 word poffset = (word)page->data + y*(page->width/4) + x/4;
353 byte *data = bmp->data;//+bmp->offset;
354 word bmpOffset = (word) data + ry * bmp->width + rx;
357 byte plane = 1 << ((byte) x & 0x03);
358 word scanCount = width/4 + (width%4 ? 1 :0);
359 word nextPageRow = page->width/4 - scanCount;
360 word nextBmpRow = (word) bmp->width - width;
362 byte planeCounter = 4;
365 MOV AX, SCREEN_SEG ; go to the VGA memory
368 MOV DX, SC_INDEX ; point at the map mask register
373 MOV DX, SC_DATA ; select the current plane
377 ;-- begin plane painting
378 MOV AX, height ; start the row counter
380 MOV DI, poffset ; go to the first pixel
381 MOV SI, bmpOffset ; go to the bmp pixel
383 MOV CX, width ; count the columns
388 JNE DRAW_PIXEL ; draw non-zero pixels
390 INC DI ; skip the transparent pixel
394 MOVSB ; copy the pixel
396 SUB CX, 3 ; we skip the next 3
397 ADD SI, 3 ; skip the bmp pixels
398 LOOP SCAN_LOOP ; finish the scan
401 ADD DI, AX ; go to the next row on screen
403 ADD SI, AX ; go to the next row on bmp
406 JNZ ROW_LOOP ; do all the rows
407 ;-- end plane painting
409 MOV AL, plane ; advance to the next plane
411 AND AL, 0x0f ; mask the plane properly
412 MOV plane, AL ; store the plane
414 INC bmpOffset ; start bmp at the right spot
417 JNZ PLANE_LOOP ; do all 4 planes
422 /* copy a region of video memory from one page to another.
423 * It assumes that the left edge of the tile is the same on both
424 * regions and the memory areas do not overlap.
427 modexCopyPageRegion(page_t *dest, page_t *src,
430 word width, word height)
432 word doffset = (word)dest->data + dy*(dest->width/4) + dx/4;
433 word soffset = (word)src->data + sy*(src->width/4) + sx/4;
434 word scans = width/4;
435 word nextSrcRow = src->width/4 - scans - 1;
436 word nextDestRow = dest->width/4 - scans - 1;
437 byte lclip[] = {0x0f, 0x0e, 0x0c, 0x08}; /* clips for rectangles not on 4s */
438 byte rclip[] = {0x0f, 0x01, 0x03, 0x07};
439 byte left = lclip[sx&0x03];
440 byte right = rclip[(sx+width)&0x03];
443 MOV AX, SCREEN_SEG ; work in the vga space
448 MOV DX, GC_INDEX ; turn off cpu bits
452 MOV AX, SC_INDEX ; point to the mask register
462 MOV CX, scans ; the number of latches
464 MOV AL, left ; do the left column
469 MOV AL, 0fh ; do the inner columns
471 REP MOVSB ; copy the pixels
473 MOV AL, right ; do the right column
478 MOV AX, SI ; go the start of the next row
482 ADD AX, nextDestRow ;
485 DEC height ; do the rest of the actions
488 MOV DX, GC_INDEX+1 ; go back to CPU data
489 MOV AL, 0ffh ; none from latches
497 modexFadeOn(word fade, byte *palette) {
498 fadePalette(-fade, 64, 64/fade+1, palette);
503 modexFadeOff(word fade, byte *palette) {
504 fadePalette(fade, 0, 64/fade+1, palette);
509 modexFlashOn(word fade, byte *palette) {
510 fadePalette(fade, -64, 64/fade+1, palette);
515 modexFlashOff(word fade, byte *palette) {
516 fadePalette(-fade, 0, 64/fade+1, palette);
521 fadePalette(sbyte fade, sbyte start, word iter, byte *palette) {
525 /* handle the case where we just update */
527 modexPalUpdate1(palette);
531 while(iter > 0) { /* FadeLoop */
532 for(i=0; i<PAL_SIZE; i++) { /* loadpal_loop */
533 tmppal[i] = palette[i] - dim;
534 if(tmppal[i] > 127) {
536 } else if(tmppal[i] > 63) {
540 modexPalUpdate1(tmppal);
549 modexPalSave(byte *palette) {
552 outp(PAL_READ_REG, 0); /* start at palette entry 0 */
553 for(i=0; i<PAL_SIZE; i++) {
554 palette[i] = inp(PAL_DATA_REG); /* read the palette data */
562 ptr = malloc(PAL_SIZE);
566 printf("Could not allocate palette.\n");
575 modexLoadPalFile(byte *filename, byte **palette) {
579 /* free the palette if it exists */
584 /* allocate the new palette */
585 *palette = modexNewPal();
588 file = fopen(filename, "rb");
590 printf("Could not open palette file: %s\n", filename);
597 *ptr++ = fgetc(file);
605 modexSavePalFile(char *filename, byte *pal) {
609 /* open the file for writing */
610 file = fopen(filename, "wb");
612 printf("Could not open %s for writing\n", filename);
616 /* write the data to the file */
617 fwrite(pal, 1, PAL_SIZE, file);
625 fadePalette(-1, 64, 1, tmppal);
631 fadePalette(-1, -64, 1, tmppal);
637 modexPalUpdate(bitmap_t *bmp, word *i, word qp, word aqoffset)
639 byte *p = bmp->palette;
643 static word a[PAL_SIZE]; //palette array of change values!
644 word z=0, aq=0, aa=0, pp=0;
649 memset(a, -1, sizeof(a));
650 outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */
660 // printf("q: %02d\n", (q));
661 // printf("qq: %02d\n", (qq));
662 //printf(" (*i)-q=%02d\n", (*i)-q);
663 outp(PAL_WRITE_REG, qq); /* start at the beginning of palette */
665 if((*i)<PAL_SIZE/2 && w==0)
667 for(; (*i)<PAL_SIZE/2; (*i)++)
669 //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]))
670 //____ 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
671 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]))
676 else if(qp>0 && (*i)>=(qp) && (*i)<((qp)+3))
678 //printf("qp=%d\n", qp);
679 //printf(" (*i)=%d a[%d]=%d\n", (*i), qp, a[qp]);
680 printf(" %d's color=%d\n", (*i), (a[qp])-(bmp->offset*3)+qp);
681 //outp(PAL_DATA_REG, p[((a[qp])-(bmp->offset*3)+qp)]);// fix this shit!
682 if((*i)+1==(qp)+3){ w++; /*(*i)++;*/ break; }
686 if(bmp->offset==0 && (*i)<3 && q==0) outp(PAL_DATA_REG, 0);
688 if(qp==0) outp(PAL_DATA_REG, p[(*i)-q]);
689 else{ //outp(PAL_DATA_REG, p[((*i)-(bmp->offset*3)+qp)]);
690 printf("p[]=%d qp=%d p[]-qp=%d\n", ((*i)-(bmp->offset*3)), qp, ((*i)-(bmp->offset*3))+qp); }
693 //if(qp>0) printf("qp=%d\n", qp);
694 //if(qp>0) printf(" (*i)=%d\n", (*i)/3);
696 modexWaitBorder(); /* waits one retrace -- less flicker */
697 if((*i)>=PAL_SIZE/2 && w==0)
699 for(; (*i)<PAL_SIZE; (*i)++)
701 //____ 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
702 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]))
707 else if(qp>0 && (*i)>=(qp) && (*i)<((qp)+3))
709 //printf("qp=%d\n", qp);
710 //printf(" (*i)=%d a[%d]=%d\n", (*i), qp, a[qp]);
711 printf(" %d's color=%d\n", (*i), (a[qp]-(bmp->offset*3)+qp));
712 //outp(PAL_DATA_REG, p[((a[qp])-(bmp->offset*3)+qp)]);// fix this shit!
713 if((*i)+1==(qp)+3){ w++; /*(*i)++;*/ break; }
717 if(qp==0) outp(PAL_DATA_REG, p[(*i)-q]);
718 else{ //outp(PAL_DATA_REG, p[((*i)-(bmp->offset*3)+qp)]);
719 printf("p[]=%d qp=%d p[]-qp=%d\n", ((*i)-(bmp->offset*3)), qp, ((*i)-(bmp->offset*3))+qp); }
722 //printf(" (*i)=%d\n", (*i)/3);
725 printf("\nqqqqqqqq\n\n");
731 long bufSize = (bmp->width * bmp->height);
733 //printf("1(*i)=%02d\n", (*i)/3);
734 //printf("1z=%02d\n", z/3);
735 chkcolor(bmp, &q, &a, &aa, &z, i);
736 //printf("2(*i)=%02d\n", (*i)/3);
737 //printf("2z=%02d\n", z/3);
742 // printf("a[%02d]=(%d)\n", aq, a[aq]);
744 else { aqoffset++; break; }
746 //update the image data here!
747 for(lq=0; lq<bufSize; lq++)
751 use a[qp] instead of bmp->offset for this spot!
756 Facking bloody point the values of the changed palette to correct values.... major confusion! wwww
759 //(offset/bmp->offset)*bmp->offset
762 //printf("%02d ",bmp->data[lq]+bmp->offset);
763 //if(lq > 0 && lq%bmp->width==0) printf("\n");
764 //printf("%02d_", bmp->data[lq]+bmp->offset);
765 /*if(bmp->data[lq]+bmp->offset==aq)
767 //printf("%02d", bmp->data[lq]);
768 //printf("\n%02d\n", bmp->offset);
769 printf("aq=%02d ", aq);
770 printf("a[aq]=%02d ", a[aq]);
771 printf("a[aq]+aqpp=%02d ", a[aq]+aqpp);
772 printf("a[aq]-aqpp=%02d\n", a[aq]-aqpp);
773 //bmp->data[lq]=((bmp->data[lq]+bmp->offset)-a[aq]);
774 //++++ bmp->data[lq]=a[aq]-aqpp;
775 // printf("_%d ", bmp->data[lq]);
776 //if(lq > 0 && lq%bmp->width==0) printf("\n");
778 else if(bmp->data[lq]+bmp->offset < ((*i)/3)-aqpp)
780 if(bmp->data[lq]+bmp->offset >= aq)
782 bmp->data[lq]=(bmp->data[lq]+bmp->offset)-aqpp;//-((z-(*i))/3);
783 //printf("_%d ", bmp->data[lq]+bmp->offset)-aqpp-((z-(*i))/3);
785 else bmp->data[lq]+=(bmp->offset-aqpp);
788 //printf("%02d`", bmp->data[lq]);
789 //if(lq > 0 && lq%bmp->width==0) printf("\n");
792 //printf(" aq=%02d\n", aq);
793 //printf(" aa=%02d\n", aa);
795 //update the palette~
796 modexPalUpdate(bmp, &pp, aq, aqoffset);
799 if(aq<aa){ pp=q; aq++; goto aqpee; }
804 modexPalUpdate1(byte *p)
808 outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */
809 for(i=0; i<PAL_SIZE/2; i++)
811 outp(PAL_DATA_REG, p[i]);
813 modexWaitBorder(); /* waits one retrace -- less flicker */
814 for(; i<PAL_SIZE; i++)
816 outp(PAL_DATA_REG, p[(i)]);
821 modexPalUpdate0(byte *p)
825 outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */
826 for(i=0; i<PAL_SIZE/2; i++)
828 outp(PAL_DATA_REG, rand());
830 modexWaitBorder(); /* waits one retrace -- less flicker */
831 for(; i<PAL_SIZE; i++)
833 outp(PAL_DATA_REG, rand());
838 //i want to make another vesion that checks the palette when the palette is being appened~
839 void chkcolor(bitmap_t *bmp, word *q, word *a, word *aa, word *z, word *i/*, word *offset*/)
845 //printf("q: %02d\n", (*q));
846 printf("chkcolor start~\n");
847 printf("1 (*z): %d\n", (*z)/3);
848 printf("1 (*i): %d\n", (*i)/3);
849 // printf("1 offset of color in palette (*q): %d\n", (*q)/3);
850 printf("wwwwwwwwwwwwwwww\n");
851 //check palette for dups
852 for(; (*z)<PAL_SIZE; (*z)+=3)
854 //printf("\n z: %d\n", (*z));
855 //printf(" q: %d\n", (*q));
856 //printf(" z+q: %d\n\n", ((*z)+(*q)));
859 //---- if(pal[(*z)]==pal[(*z)+3] && pal[(*z)+1]==pal[(*z)+4] && pal[(*z)+2]==pal[(*z)+5])
862 // printf("\n%d [%02d][%02d][%02d]\n", (*z), pal[(*z)], pal[(*z)+1], pal[(*z)+2]);
863 // printf("%d [%02d][%02d][%02d]\n\n", (*z)+3, pal[(*z)+3], pal[(*z)+4], pal[(*z)+5]);
867 else for(zz=0; zz<(*q); zz+=3)
869 //printf("zz: %02d\n", zz/3);
872 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
876 // printf("\nzq1:%d[%02d][%02d][%02d]\n", (zz+q), pal[(zz+q)], pal[(zz+q)+1], pal[(zz+q)+2]);
877 // printf("zq2:%d[%02d][%02d][%02d]\n\n", (zz+q)+3, pal[(zz+q)+3], pal[(zz+q)+4], pal[(zz+q)+5]);
880 else if(pal[zz]==pal[((*z)+(*q))] && pal[zz+1]==pal[((*z)+(*q))+1] && pal[zz+2]==pal[((*z)+(*q))+2])
882 // printf("\n\nwwwwwwwwwwwwwwww\n");
883 // 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]);
884 // 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]);
885 // //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]);
886 // printf(" z : %d [%02d][%02d][%02d] offset value~\n", (*z)/3, pal[(*z)], pal[(*z)+1], pal[(*z)+2]);
891 planned features that i plan to implement~
892 image that has values on the pallete list!
894 no... wait.... no wwww
896 //for(zzii=0; zzii<3; zzii++)
898 //printf("z+q: %d\n\n", ((*z)+(*q)));
902 printf("!! a[%02d]: %d\n", (((*z)+(*q))/3), zz/3);
903 // printf("\n aa: %d\n\n", (*aa));
904 // printf(" a[%02d]=(%02d) offset array i think the palette should be updated again~\n", ((*z)+(*q))/3, a[((*z)+(*q))/3]);
905 // printf("wwwwwwwwwwwwwwww\n\n");
909 printf("================\n");
910 printf("zq: %d [%02d][%02d][%02d]\n", ((*z)+(*q))/3, pal[((*z)+(*q))], pal[((*z)+(*q))+1], pal[((*z)+(*q))+2]);
911 printf("zz: %d [%02d][%02d][%02d]\n", (zz)/3, pal[zz], pal[zz+1], pal[zz+2]);
912 printf("z : %d [%02d][%02d][%02d]\n", (*z)/3, pal[(*z)], pal[(*z)+1], pal[(*z)+2]);
913 printf("================\n");
915 //printf("[%d]", (zz+q));
919 printf("wwwwwwwwwwwwwwww\n");
920 printf("2 (*z): %d\n", (*z)/3);
921 printf("2 (*i): %d\n", (*i)/3);
922 // printf("2 offset of color in palette (*q): %d\n", (*q)/3);
923 printf("chkcolor end~\n");
929 while(inp(INPUT_STATUS_1) & 8) {
933 while(!(inp(INPUT_STATUS_1) & 8)) {
938 /*****************************************************************************
\r
939 find 8x8 font in VGA BIOS ROM
\r
940 *****************************************************************************/
\r
941 byte far *bios_8x8_font(void)
\r
946 /* use BIOS INT 10h AX=1130h to find font #3 (8x8) in ROM */
\r
947 memset(®s, 0, sizeof(regs)); /* for Watcom C */
\r
948 regs.w.ax = 0x1130;
\r
949 regs.w.bx = 0x0300;
\r
951 font = (byte far *)MK_FP(regs.w.es, regs.w.bp);
\r
955 /*****************************************************************************
\r
956 *****************************************************************************/
\r
957 void bputs(page_t *pee, int x, int y, const byte far *s)
\r
964 font = bios_8x8_font();
965 //skip = 2 - ((pee->width/4) << 3);
966 //printf("font=%Fp\n", font);
\r
967 for(; *s != '\0'; s++)
\r
969 //src.raster = font + 8 * (*s);
970 //BLOODY!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!111111111111!!!11!!11!111!11!!1111!!111!11!!1!!!11!11!!1!!111!11!!
971 // (*(bmp->data)) = (*(font + 8 * (*s)));
972 font_pntr = font + 8 * (*s);
973 // font_pntr = font + (c << 3);
976 // temp = *font_pntr++;
\r
977 // outpw(SC_INDEX, text_mask[temp & 0x0F]);
\r
978 //*vga_ptr++ = color;
\r
980 // outpw(SC_INDEX, text_mask[temp >> 4]);
\r
981 //*vga_ptr-- = color;
\r
982 //vga_ptr += widthBytes;
\r
985 //printf("fontoffset=%Fp\n", font + 8 * (*s));
986 //printf("*fontoffset=%s\n", *(font + 8 * (*s)));
987 //printf("w.data=%Fp\n", (w.data));
988 //printf("*w.data=%s\n", *(w.data));
989 //blit1(&src, bmp, x, y);
990 // modexDrawSprite(page, x, y, bmp);
991 // modexDrawBmp(page, x, y, bmp);
992 // printf("%x\n", (*(font + 8 * (*s))));
993 //_fmemset(VGA, *(font + 8 * (*s)), _msize(font));
996 modexClearRegion(pee, x, y, 8, 8, 4);