1 /* Project 16 Source Code~
2 * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669
4 * This file is part of Project 16.
6 * Project 16 is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * Project 16 is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>, or
18 * write to the Free Software Foundation, Inc., 51 Franklin Street,
19 * Fifth Floor, Boston, MA 02110-1301 USA.
29 #include "src/lib/modex16.h"
31 byte far* VGA=(byte far*) 0xA0000000; /* this points to video memory. */
32 /*word text_mask[16] = {
33 0x0002, 0x0102, 0x0202, 0x0302,
34 0x0402, 0x0502, 0x0602, 0x0702,
35 0x0802, 0x0902, 0x0A02, 0x0B02,
36 0x0C02, 0x0D02, 0x0E02, 0x0F02
39 static void fadePalette(sbyte fade, sbyte start, word iter, byte *palette);
40 static byte tmppal[PAL_SIZE];
49 int86(VIDEO_INT, ®s, ®s);
53 /* -========================= Entry Points ==========================- */
57 dword far*ptr=(dword far*)VGA; /* used for faster screen clearing */
59 0x0d06, /* vertical total */
60 0x3e07, /* overflow (bit 8 of vertical counts) */
61 0x4109, /* cell height (2 to double-scan */
62 0xea10, /* v sync start */
63 0xac11, /* v sync end and protect cr0-cr7 */
64 0xdf12, /* vertical displayed */
65 0x0014, /* turn off dword mode */
66 0xe715, /* v blank start */
67 0x0616, /* v blank end */
68 0xe317 /* turn on byte mode */
70 int CRTParmCount = sizeof(CRTParms) / sizeof(CRTParms[0]);
72 /* TODO save current video mode and palette */
73 vgaSetMode(VGA_256_COLOR_MODE);
75 /* disable chain4 mode */
76 outpw(SC_INDEX, 0x0604);
78 /* synchronous reset while setting Misc Output */
79 outpw(SC_INDEX, 0x0100);
81 /* select 25 MHz dot clock & 60 Hz scanning rate */
82 outp(MISC_OUTPUT, 0xe3);
84 /* undo reset (restart sequencer) */
85 outpw(SC_INDEX, 0x0300);
87 /* reprogram the CRT controller */
88 outp(CRTC_INDEX, 0x11); /* VSync End reg contains register write prot */
89 outp(CRTC_DATA, 0x7f); /* get current write protect on varios regs */
91 /* send the CRTParms */
92 for(i=0; i<CRTParmCount; i++) {
93 outpw(CRTC_INDEX, CRTParms[i]);
96 /* clear video memory */
97 outpw(SC_INDEX, 0x0f02);
98 for(i=0; i<0x8000; i++) {
106 /* TODO restore original mode and palette */
107 vgaSetMode(TEXT_MODE);
115 /* default page values */
119 page.width = SCREEN_WIDTH;
120 page.height = SCREEN_HEIGHT;
126 /* returns the next page in contiguous memory
127 * the next page will be the same size as p, by default
130 modexNextPage(page_t *p) {
133 result.data = p->data + (p->width/4)*p->height; /* compute the offset */
136 result.width = p->width;
137 result.height = p->height;
143 //next page with defined dimentions~
145 modexNextPage0(page_t *p, word x, word y)
149 result.data = p->data + (p->width/4)*p->height; /* compute the offset */
161 modexShowPage(page_t *page) {
167 /* calculate offset */
168 offset = (word) page->data;
169 offset += page->dy * (page->width >> 2 );
170 offset += page->dx >> 2;
172 /* calculate crtcOffset according to virtual width */
173 crtcOffset = page->width >> 3;
175 high_address = HIGH_ADDRESS | (offset & 0xff00);
176 low_address = LOW_ADDRESS | (offset << 8);
178 /* wait for appropriate timing and then program CRTC */
179 while ((inp(INPUT_STATUS_1) & DISPLAY_ENABLE));
180 outpw(CRTC_INDEX, high_address);
181 outpw(CRTC_INDEX, low_address);
182 outp(CRTC_INDEX, 0x13);
183 outp(CRTC_DATA, crtcOffset);
185 /* wait for one retrace */
186 while (!(inp(INPUT_STATUS_1) & VRETRACE));
188 /* do PEL panning here */
189 outp(AC_INDEX, 0x33);
190 outp(AC_INDEX, (page->dx & 0x03) << 1);
195 modexPanPage(page_t *page, int dx, int dy) {
202 modexSelectPlane(byte plane) {
203 outp(SC_INDEX, MAP_MASK); /* select plane */
204 outp(SC_DATA, plane);
209 modexClearRegion(page_t *page, int x, int y, int w, int h, byte color) {
210 word pageOff = (word) page->data;
211 word xoff=x/4; /* xoffset that begins each row */
212 word scanCount=w/4; /* number of iterations per row (excluding right clip)*/
213 word poffset = pageOff + y*(page->width/4) + xoff; /* starting offset */
214 word nextRow = page->width/4-scanCount-1; /* loc of next row */
215 byte lclip[] = {0x0f, 0x0e, 0x0c, 0x08}; /* clips for rectangles not on 4s */
216 byte rclip[] = {0x00, 0x01, 0x03, 0x07};
217 byte left = lclip[x&0x03];
218 byte right = rclip[(x+w)&0x03];
220 /* handle the case which requires an extra group */
221 if((x & 0x03) && !((x+w) & 0x03)) {
226 MOV AX, SCREEN_SEG ; go to the VGA memory
228 MOV DI, poffset ; go to the first pixel
229 MOV DX, SC_INDEX ; point to the map mask
233 MOV AL, color ; get ready to write colors
235 MOV CX, scanCount ; count the line
236 MOV BL, AL ; remember color
237 MOV AL, left ; do the left clip
238 OUT DX, AL ; set the left clip
239 MOV AL, BL ; restore color
240 STOSB ; write the color
242 JZ SCAN_DONE ; handle 1 group stuff
244 ;-- write the main body of the scanline
245 MOV BL, AL ; remember color
246 MOV AL, 0x0f ; write to all pixels
248 MOV AL, BL ; restore color
249 REP STOSB ; write the color
251 MOV BL, AL ; remeber color
253 OUT DX, AL ; do the right clip
254 MOV AL, BL ; restore color
256 ADD DI, nextRow ; go to the next row
264 oldDrawBmp(byte far* page, int x, int y, bitmap_t *bmp, byte sprite)
270 /* TODO Make this fast. It's SLOOOOOOW */
271 for(plane=0; plane < 4; plane++) {
272 modexSelectPlane(PLANE(plane+x));
273 for(px = plane; px < bmp->width; px+=4) {
275 for(py=0; py<bmp->height; py++) {
276 if(!sprite || bmp->data[offset])
277 page[PAGE_OFFSET(x+px, y+py)] = bmp->data[offset];
286 modexDrawBmp(page_t *page, int x, int y, bitmap_t *bmp) {
287 /* draw the region (the entire freakin bitmap) */
288 modexDrawBmpRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);
293 modexDrawBmpRegion(page_t *page, int x, int y,
294 int rx, int ry, int rw, int rh, bitmap_t *bmp) {
295 word poffset = (word) page->data + y*(page->width/4) + x/4;
296 byte *data = bmp->data;//+bmp->offset;
297 word bmpOffset = (word) data + ry * bmp->width + rx;
300 byte plane = 1 << ((byte) x & 0x03);
301 word scanCount = width/4 + (width%4 ? 1 :0);
302 word nextPageRow = page->width/4 - scanCount;
303 word nextBmpRow = (word) bmp->width - width;
305 byte planeCounter = 4;
307 //code is a bit slow here
309 MOV AX, SCREEN_SEG ; go to the VGA memory
312 MOV DX, SC_INDEX ; point at the map mask register
317 MOV DX, SC_DATA ; select the current plane
321 ;-- begin plane painting
322 MOV AX, height ; start the row counter
324 MOV DI, poffset ; go to the first pixel
325 MOV SI, bmpOffset ; go to the bmp pixel
327 MOV CX, width ; count the columns
329 MOVSB ; copy the pixel
330 SUB CX, 3 ; we skip the next 3
331 ADD SI, 3 ; skip the bmp pixels
332 LOOP SCAN_LOOP ; finish the scan
335 ADD DI, AX ; go to the next row on screen
337 ADD SI, AX ; go to the next row on bmp
340 JNZ ROW_LOOP ; do all the rows
341 ;-- end plane painting
343 MOV AL, plane ; advance to the next plane
345 AND AL, 0x0f ; mask the plane properly
346 MOV plane, AL ; store the plane
348 INC bmpOffset ; start bmp at the right spot
351 JNZ PLANE_LOOP ; do all 4 planes
357 modexDrawPlanarBuf(page_t *page, int x, int y, planar_buf_t *bmp) {
358 /* TODO - adapt from test code */
360 for(plane=0; plane < 4; plane++)
368 modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp) {
369 /* draw the whole sprite */
370 modexDrawSpriteRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);
374 modexDrawSpriteRegion(page_t *page, int x, int y,
375 int rx, int ry, int rw, int rh, bitmap_t *bmp) {
376 word poffset = (word)page->data + y*(page->width/4) + x/4;
377 byte *data = bmp->data;//+bmp->offset;
378 word bmpOffset = (word) data + ry * bmp->width + rx;
381 byte plane = 1 << ((byte) x & 0x03);
382 word scanCount = width/4 + (width%4 ? 1 :0);
383 word nextPageRow = page->width/4 - scanCount;
384 word nextBmpRow = (word) bmp->width - width;
386 byte planeCounter = 4;
389 MOV AX, SCREEN_SEG ; go to the VGA memory
392 MOV DX, SC_INDEX ; point at the map mask register
397 MOV DX, SC_DATA ; select the current plane
401 ;-- begin plane painting
402 MOV AX, height ; start the row counter
404 MOV DI, poffset ; go to the first pixel
405 MOV SI, bmpOffset ; go to the bmp pixel
407 MOV CX, width ; count the columns
412 JNE DRAW_PIXEL ; draw non-zero pixels
414 INC DI ; skip the transparent pixel
418 MOVSB ; copy the pixel
420 SUB CX, 3 ; we skip the next 3
421 ADD SI, 3 ; skip the bmp pixels
422 LOOP SCAN_LOOP ; finish the scan
425 ADD DI, AX ; go to the next row on screen
427 ADD SI, AX ; go to the next row on bmp
430 JNZ ROW_LOOP ; do all the rows
431 ;-- end plane painting
433 MOV AL, plane ; advance to the next plane
435 AND AL, 0x0f ; mask the plane properly
436 MOV plane, AL ; store the plane
438 INC bmpOffset ; start bmp at the right spot
441 JNZ PLANE_LOOP ; do all 4 planes
446 /* copy a region of video memory from one page to another.
447 * It assumes that the left edge of the tile is the same on both
448 * regions and the memory areas do not overlap.
451 modexCopyPageRegion(page_t *dest, page_t *src,
454 word width, word height)
456 word doffset = (word)dest->data + dy*(dest->width/4) + dx/4;
457 word soffset = (word)src->data + sy*(src->width/4) + sx/4;
458 word scans = width/4;
459 word nextSrcRow = src->width/4 - scans - 1;
460 word nextDestRow = dest->width/4 - scans - 1;
461 byte lclip[] = {0x0f, 0x0e, 0x0c, 0x08}; /* clips for rectangles not on 4s */
462 byte rclip[] = {0x0f, 0x01, 0x03, 0x07};
463 byte left = lclip[sx&0x03];
464 byte right = rclip[(sx+width)&0x03];
467 MOV AX, SCREEN_SEG ; work in the vga space
472 MOV DX, GC_INDEX ; turn off cpu bits
476 MOV AX, SC_INDEX ; point to the mask register
486 MOV CX, scans ; the number of latches
488 MOV AL, left ; do the left column
493 MOV AL, 0fh ; do the inner columns
495 REP MOVSB ; copy the pixels
497 MOV AL, right ; do the right column
502 MOV AX, SI ; go the start of the next row
506 ADD AX, nextDestRow ;
509 DEC height ; do the rest of the actions
512 MOV DX, GC_INDEX+1 ; go back to CPU data
513 MOV AL, 0ffh ; none from latches
521 modexFadeOn(word fade, byte *palette) {
522 fadePalette(-fade, 64, 64/fade+1, palette);
527 modexFadeOff(word fade, byte *palette) {
528 fadePalette(fade, 0, 64/fade+1, palette);
533 modexFlashOn(word fade, byte *palette) {
534 fadePalette(fade, -64, 64/fade+1, palette);
539 modexFlashOff(word fade, byte *palette) {
540 fadePalette(-fade, 0, 64/fade+1, palette);
545 fadePalette(sbyte fade, sbyte start, word iter, byte *palette) {
549 /* handle the case where we just update */
551 modexPalUpdate1(palette);
555 while(iter > 0) { /* FadeLoop */
556 for(i=0; i<PAL_SIZE; i++) { /* loadpal_loop */
557 tmppal[i] = palette[i] - dim;
558 if(tmppal[i] > 127) {
560 } else if(tmppal[i] > 63) {
564 modexPalUpdate1(tmppal);
573 modexPalSave(byte *palette) {
576 outp(PAL_READ_REG, 0); /* start at palette entry 0 */
577 for(i=0; i<PAL_SIZE; i++) {
578 palette[i] = inp(PAL_DATA_REG); /* read the palette data */
586 ptr = malloc(PAL_SIZE);
590 printf("Could not allocate palette.\n");
599 modexLoadPalFile(byte *filename, byte **palette) {
603 /* free the palette if it exists */
608 /* allocate the new palette */
609 *palette = modexNewPal();
612 file = fopen(filename, "rb");
614 printf("Could not open palette file: %s\n", filename);
621 *ptr++ = fgetc(file);
629 modexSavePalFile(char *filename, byte *pal) {
633 /* open the file for writing */
634 file = fopen(filename, "wb");
636 printf("Could not open %s for writing\n", filename);
640 /* write the data to the file */
641 fwrite(pal, 1, PAL_SIZE, file);
649 fadePalette(-1, 64, 1, tmppal);
655 fadePalette(-1, -64, 1, tmppal);
661 modexPalUpdate(bitmap_t *bmp, word *i, word qp, word aqoffset)
663 byte *p = bmp->palette;
667 static word a[PAL_SIZE]; //palette array of change values!
668 word z=0, aq=0, aa=0, pp=0;
673 memset(a, -1, sizeof(a));
674 outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */
684 // printf("q: %02d\n", (q));
685 // printf("qq: %02d\n", (qq));
686 //printf(" (*i)-q=%02d\n", (*i)-q);
687 outp(PAL_WRITE_REG, qq); /* start at the beginning of palette */
689 if((*i)<PAL_SIZE/2 && w==0)
691 for(; (*i)<PAL_SIZE/2; (*i)++)
693 //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]))
694 //____ 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
695 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]))
700 else if(qp>0 && (*i)>=(qp) && (*i)<((qp)+3))
702 //printf("qp=%d\n", qp);
703 //printf(" (*i)=%d a[%d]=%d\n", (*i), qp, a[qp]);
704 printf(" %d's color=%d\n", (*i), (a[qp])-(bmp->offset*3)+qp);
705 //outp(PAL_DATA_REG, p[((a[qp])-(bmp->offset*3)+qp)]);// fix this shit!
706 if((*i)+1==(qp)+3){ w++; /*(*i)++;*/ break; }
710 if(bmp->offset==0 && (*i)<3 && q==0) outp(PAL_DATA_REG, 0);
712 if(qp==0) outp(PAL_DATA_REG, p[(*i)-q]);
713 else{ //outp(PAL_DATA_REG, p[((*i)-(bmp->offset*3)+qp)]);
714 printf("p[]=%d qp=%d p[]-qp=%d\n", ((*i)-(bmp->offset*3)), qp, ((*i)-(bmp->offset*3))+qp); }
717 //if(qp>0) printf("qp=%d\n", qp);
718 //if(qp>0) printf(" (*i)=%d\n", (*i)/3);
720 modexWaitBorder(); /* waits one retrace -- less flicker */
721 if((*i)>=PAL_SIZE/2 && w==0)
723 for(; (*i)<PAL_SIZE; (*i)++)
725 //____ 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
726 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]))
731 else if(qp>0 && (*i)>=(qp) && (*i)<((qp)+3))
733 //printf("qp=%d\n", qp);
734 //printf(" (*i)=%d a[%d]=%d\n", (*i), qp, a[qp]);
735 printf(" %d's color=%d\n", (*i), (a[qp]-(bmp->offset*3)+qp));
736 //outp(PAL_DATA_REG, p[((a[qp])-(bmp->offset*3)+qp)]);// fix this shit!
737 if((*i)+1==(qp)+3){ w++; /*(*i)++;*/ break; }
741 if(qp==0) outp(PAL_DATA_REG, p[(*i)-q]);
742 else{ //outp(PAL_DATA_REG, p[((*i)-(bmp->offset*3)+qp)]);
743 printf("p[]=%d qp=%d p[]-qp=%d\n", ((*i)-(bmp->offset*3)), qp, ((*i)-(bmp->offset*3))+qp); }
746 //printf(" (*i)=%d\n", (*i)/3);
749 printf("\nqqqqqqqq\n\n");
755 long bufSize = (bmp->width * bmp->height);
757 //printf("1(*i)=%02d\n", (*i)/3);
758 //printf("1z=%02d\n", z/3);
759 chkcolor(bmp, &q, &a, &aa, &z, i);
760 //printf("2(*i)=%02d\n", (*i)/3);
761 //printf("2z=%02d\n", z/3);
766 // printf("a[%02d]=(%d)\n", aq, a[aq]);
768 else { aqoffset++; break; }
770 //update the image data here!
771 for(lq=0; lq<bufSize; lq++)
775 use a[qp] instead of bmp->offset for this spot!
780 Facking bloody point the values of the changed palette to correct values.... major confusion! wwww
783 //(offset/bmp->offset)*bmp->offset
786 //printf("%02d ",bmp->data[lq]+bmp->offset);
787 //if(lq > 0 && lq%bmp->width==0) printf("\n");
788 //printf("%02d_", bmp->data[lq]+bmp->offset);
789 /*if(bmp->data[lq]+bmp->offset==aq)
791 //printf("%02d", bmp->data[lq]);
792 //printf("\n%02d\n", bmp->offset);
793 printf("aq=%02d ", aq);
794 printf("a[aq]=%02d ", a[aq]);
795 printf("a[aq]+aqpp=%02d ", a[aq]+aqpp);
796 printf("a[aq]-aqpp=%02d\n", a[aq]-aqpp);
797 //bmp->data[lq]=((bmp->data[lq]+bmp->offset)-a[aq]);
798 //++++ bmp->data[lq]=a[aq]-aqpp;
799 // printf("_%d ", bmp->data[lq]);
800 //if(lq > 0 && lq%bmp->width==0) printf("\n");
802 else if(bmp->data[lq]+bmp->offset < ((*i)/3)-aqpp)
804 if(bmp->data[lq]+bmp->offset >= aq)
806 bmp->data[lq]=(bmp->data[lq]+bmp->offset)-aqpp;//-((z-(*i))/3);
807 //printf("_%d ", bmp->data[lq]+bmp->offset)-aqpp-((z-(*i))/3);
809 else bmp->data[lq]+=(bmp->offset-aqpp);
812 //printf("%02d`", bmp->data[lq]);
813 //if(lq > 0 && lq%bmp->width==0) printf("\n");
816 //printf(" aq=%02d\n", aq);
817 //printf(" aa=%02d\n", aa);
819 //update the palette~
820 modexPalUpdate(bmp, &pp, aq, aqoffset);
823 if(aq<aa){ pp=q; aq++; goto aqpee; }
828 modexPalUpdate1(byte *p)
832 outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */
833 for(i=0; i<PAL_SIZE/2; i++)
835 outp(PAL_DATA_REG, p[i]);
837 modexWaitBorder(); /* waits one retrace -- less flicker */
838 for(; i<PAL_SIZE; i++)
840 outp(PAL_DATA_REG, p[(i)]);
845 modexPalUpdate0(byte *p)
849 outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */
850 for(i=0; i<PAL_SIZE/2; i++)
852 outp(PAL_DATA_REG, rand());
854 modexWaitBorder(); /* waits one retrace -- less flicker */
855 for(; i<PAL_SIZE; i++)
857 outp(PAL_DATA_REG, rand());
862 //i want to make another vesion that checks the palette when the palette is being appened~
863 void chkcolor(bitmap_t *bmp, word *q, word *a, word *aa, word *z, word *i/*, word *offset*/)
869 //printf("q: %02d\n", (*q));
870 printf("chkcolor start~\n");
871 printf("1 (*z): %d\n", (*z)/3);
872 printf("1 (*i): %d\n", (*i)/3);
873 // printf("1 offset of color in palette (*q): %d\n", (*q)/3);
874 printf("wwwwwwwwwwwwwwww\n");
875 //check palette for dups
876 for(; (*z)<PAL_SIZE; (*z)+=3)
878 //printf("\n z: %d\n", (*z));
879 //printf(" q: %d\n", (*q));
880 //printf(" z+q: %d\n\n", ((*z)+(*q)));
883 //---- if(pal[(*z)]==pal[(*z)+3] && pal[(*z)+1]==pal[(*z)+4] && pal[(*z)+2]==pal[(*z)+5])
886 // printf("\n%d [%02d][%02d][%02d]\n", (*z), pal[(*z)], pal[(*z)+1], pal[(*z)+2]);
887 // printf("%d [%02d][%02d][%02d]\n\n", (*z)+3, pal[(*z)+3], pal[(*z)+4], pal[(*z)+5]);
891 else for(zz=0; zz<(*q); zz+=3)
893 //printf("zz: %02d\n", zz/3);
896 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
900 // printf("\nzq1:%d[%02d][%02d][%02d]\n", (zz+q), pal[(zz+q)], pal[(zz+q)+1], pal[(zz+q)+2]);
901 // printf("zq2:%d[%02d][%02d][%02d]\n\n", (zz+q)+3, pal[(zz+q)+3], pal[(zz+q)+4], pal[(zz+q)+5]);
904 else if(pal[zz]==pal[((*z)+(*q))] && pal[zz+1]==pal[((*z)+(*q))+1] && pal[zz+2]==pal[((*z)+(*q))+2])
906 // printf("\n\nwwwwwwwwwwwwwwww\n");
907 // 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]);
908 // 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]);
909 // //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]);
910 // printf(" z : %d [%02d][%02d][%02d] offset value~\n", (*z)/3, pal[(*z)], pal[(*z)+1], pal[(*z)+2]);
915 planned features that i plan to implement~
916 image that has values on the pallete list!
918 no... wait.... no wwww
920 //for(zzii=0; zzii<3; zzii++)
922 //printf("z+q: %d\n\n", ((*z)+(*q)));
926 printf("!! a[%02d]: %d\n", (((*z)+(*q))/3), zz/3);
927 // printf("\n aa: %d\n\n", (*aa));
928 // printf(" a[%02d]=(%02d) offset array i think the palette should be updated again~\n", ((*z)+(*q))/3, a[((*z)+(*q))/3]);
929 // printf("wwwwwwwwwwwwwwww\n\n");
933 printf("================\n");
934 printf("zq: %d [%02d][%02d][%02d]\n", ((*z)+(*q))/3, pal[((*z)+(*q))], pal[((*z)+(*q))+1], pal[((*z)+(*q))+2]);
935 printf("zz: %d [%02d][%02d][%02d]\n", (zz)/3, pal[zz], pal[zz+1], pal[zz+2]);
936 printf("z : %d [%02d][%02d][%02d]\n", (*z)/3, pal[(*z)], pal[(*z)+1], pal[(*z)+2]);
937 printf("================\n");
939 //printf("[%d]", (zz+q));
943 printf("wwwwwwwwwwwwwwww\n");
944 printf("2 (*z): %d\n", (*z)/3);
945 printf("2 (*i): %d\n", (*i)/3);
946 // printf("2 offset of color in palette (*q): %d\n", (*q)/3);
947 printf("chkcolor end~\n");
953 while(inp(INPUT_STATUS_1) & 8) {
957 while(!(inp(INPUT_STATUS_1) & 8)) {
962 /*****************************************************************************
963 find 8x8 font in VGA BIOS ROM
964 *****************************************************************************/
965 byte far *bios_8x8_font(void)
970 /* use BIOS INT 10h AX=1130h to find font #3 (8x8) in ROM */
971 memset(®s, 0, sizeof(regs)); /* for Watcom C */
975 font = (byte far *)MK_FP(regs.w.es, regs.w.bp);
979 /*****************************************************************************
980 *****************************************************************************/
981 void bputs(page_t *pee, int x, int y, const byte far *s)
988 font = bios_8x8_font();
989 //skip = 2 - ((pee->width/4) << 3);
990 //printf("font=%Fp\n", font);
991 for(; *s != '\0'; s++)
993 //src.raster = font + 8 * (*s);
994 //BLOODY!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!111111111111!!!11!!11!111!11!!1111!!111!11!!1!!!11!11!!1!!111!11!!
995 // (*(bmp->data)) = (*(font + 8 * (*s)));
996 font_pntr = font + 8 * (*s);
997 // font_pntr = font + (c << 3);
1000 // temp = *font_pntr++;
1001 // outpw(SC_INDEX, text_mask[temp & 0x0F]);
1002 //*vga_ptr++ = color;
1004 // outpw(SC_INDEX, text_mask[temp >> 4]);
1005 //*vga_ptr-- = color;
1006 //vga_ptr += widthBytes;
1009 //printf("fontoffset=%Fp\n", font + 8 * (*s));
1010 //printf("*fontoffset=%s\n", *(font + 8 * (*s)));
1011 //printf("w.data=%Fp\n", (w.data));
1012 //printf("*w.data=%s\n", *(w.data));
1013 //blit1(&src, bmp, x, y);
1014 // modexDrawSprite(page, x, y, bmp);
1015 // modexDrawBmp(page, x, y, bmp);
1016 // printf("%x\n", (*(font + 8 * (*s))));
1017 //_fmemset(VGA, *(font + 8 * (*s)), _msize(font));
1018 //draw text?!?! wwww
1020 modexClearRegion(pee, x, y, 8, 8, 4);