#include "d:\cips\cips.h" main() { int i, j, k; char response[80]; printf("\n\nHit return to start testVGA"); read_string(response); set_64_colors(); for(i=0; i<200; i++) for(j=0; j<200; j++) my_set_pixel(i, j, 12 + j/5); /********** for(i=0; i<400; i++){ for(j=0; j<20; j++){ my_set_pixel(i,j,0); } } for(i=0; i<400; i++){ for(j=20; j<40; j++){ my_set_pixel(i,j,1); } } for(i=0; i<400; i++){ for(j=40; j<60; j++){ my_set_pixel(i,j,4); } } for(i=0; i<400; i++){ for(j=60; j<80; j++){ my_set_pixel(i,j,5); } } for(i=0; i<400; i++){ for(j=80; j<100; j++){ my_set_pixel(i,j,8); } } for(i=0; i<400; i++){ for(j=100; j<120; j++){ my_set_pixel(i,j,2); } } for(i=0; i<400; i++){ for(j=120; j<140; j++){ my_set_pixel(i,j,6); } } for(i=0; i<400; i++){ for(j=140; j<160; j++){ my_set_pixel(i,j, 9); } } for(i=0; i<400; i++){ for(j=160; j<180; j++){ my_set_pixel(i,j, 3); } } for(i=0; i<400; i++){ for(j=180; j<200; j++){ my_set_pixel(i,j, 12); } } for(i=0; i<400; i++){ for(j=200; j<220; j++){ my_set_pixel(i,j,13); } } for(i=0; i<400; i++){ for(j=220; j<240; j++){ my_set_pixel(i,j, 7); } } for(i=0; i<400; i++){ for(j=240; j<260; j++){ my_set_pixel(i,j,10); } } for(i=0; i<400; i++){ for(j=260; j<280; j++){ my_set_pixel(i,j,11); } } for(i=0; i<400; i++){ for(j=280; j<300; j++){ my_set_pixel(i,j,14); } } for(i=0; i<400; i++){ for(j=300; j<320; j++){ my_set_pixel(i,j,15); } } *************/ read_string(response); clear_text_screen(); } /* ends main */ lookup(color) int color; { int table[16] = {0, 1, 4, 5, 8, 2, 6, 9, 3, 12, 13, 7, 10, 11, 14, 15}; return(table[color]); } /* ends lookup */ /********************************** * * Modes for the SigmaVGA Legend * (hex) * 10 - 640x350x64? * 12 - 640x480x16 * 29 - 800x600x16 * 30 - 800x600x256 * 38 - 1024x768x256 * ***********************************/ my_set_video_mode() { union REGS regs; regs.h.al = 0x29; /* mode */ regs.h.ah = 0x00; int86(0x10, ®s, ®s); } /* ends my_set_video_mode */ my_set_pixel(x, y, color) unsigned int x, y, color; { union REGS regs; char r[80]; int i; regs.h.ah = 0x0c; regs.x.dx = y; regs.x.cx = x; regs.h.al = color; regs.h.bh = 0x00; int86(0x10, ®s, ®s); } /* ends my_set_pixel */ my_set_colors() { _asm{ mov ax,0013h ; 800x600x16 int 10h mov ah,10h mov al,1bh mov bx,0h mov cx,100h int 10h } } /* ends my_set_colors */ put_pixel(ppx, ppy, color) int color, ppx, ppy; { int RW_Page=0x0ff; int W_Page=0x0ff; int R_Page=0x0ff; int PAGE_SEL_PORT=0x3cd; long page, offset; page = ((long)(ppy)*800L + (long)(ppx))/0x10000; offset = ((long)(ppy)*800L + (long)(ppx))%0x10000; /*printf("\ny=%d x=%d color=%d Page=%ld offset=%ld", ppy, ppx, color, page, offset);*/ _asm{ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; taken from file ; d:\supervga\256col\wpixel.asm ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUSH BP ;Preserve BP MOV BP,SP ;Preserve stack pointer PUSH ES ;Preserve segment and index registers PUSH DS PUSH DI PUSH SI ; Convert x,y pixel address to Page and Offset MOV AX,ppy ;Fetch y coordinate ;Video_Pitch=SCREEN_PITCH=800 MUL cs:800 ;multiply by width in bytes ADD AX,ppx ;add x coordinate to compute offset ADC DX,0 ;add overflow to upper 16 bits ;Graph_Seg=0aoooh MOV DS,CS:0a000h ;Put new address in DS:SI MOV DI,AX MOV AL,DL ;Copy page number into AL JMP Select_Page ;Select proper page Ret_Page: ; Set pixel to supplied value MOV AL,color ;Fetch color to use MOV [DI],AL ;Set the pixel ; Clean up and return POP SI ;Restore segment and index registers POP DI POP DS POP ES MOV SP,BP ;Restore stack pointer POP BP ;Restore BP JMP The_End Select_Page: CMP AL,CS:RW_Page ;Check if already selected JNE SP_Go JMP Ret_Page SP_Go: PUSH AX PUSH DX MOV DX,PAGE_SEL_PORT ;Fetch address of page select AND AL,7 ;Force page number into 0-7 MOV CS:RW_Page,AL ;Save most recently selected page MOV CS:R_Page,0FFh MOV CS:W_Page,0FFh MOV AH,AL ;Copy page into AH SHL AH,1 ;Shift page number SHL AH,1 SHL AH,1 OR AL,AH ;Move page number into "write" bits OR AL,40h ;Force bit 6 OUT DX,AL ;Write out the new page select POP DX POP AX JMP Ret_Page The_End: } /* ends _asm */ } /* ends put_pixel */ /******** This does not work ppp(long page, long offset, int color) { int RW_Page=0x0ff; int W_Page=0x0ff; int R_Page=0x0ff; int PAGE_SEL_PORT=0x3cd; _asm{ MOV AX,offset MOV DX,page ;Graph_Seg=0aoooh MOV DS,CS:0a000h ;Put new address in DS:SI MOV DI,AX MOV AL,DL ;Copy page number into AL JMP Select_Page ;Select proper page Ret_Page: ; Set pixel to supplied value MOV AL,color ;Fetch color to use MOV [DI],AL ;Set the pixel ; Clean up and return POP SI ;Restore segment and index registers POP DI POP DS POP ES MOV SP,BP ;Restore stack pointer POP BP ;Restore BP JMP The_End Select_Page: CMP AL,CS:RW_Page ;Check if already selected JNE SP_Go JMP Ret_Page SP_Go: PUSH AX PUSH DX MOV DX,PAGE_SEL_PORT ;Fetch address of page select AND AL,7 ;Force page number into 0-7 MOV CS:RW_Page,AL ;Save most recently selected page MOV CS:R_Page,0FFh MOV CS:W_Page,0FFh MOV AH,AL ;Copy page into AH SHL AH,1 ;Shift page number SHL AH,1 SHL AH,1 OR AL,AH ;Move page number into "write" bits OR AL,40h ;Force bit 6 OUT DX,AL ;Write out the new page select POP DX POP AX JMP Ret_Page The_End: } } ******************/ read_string(string) char *string; { int eof, letter, no_error; eof = -1; no_error = 0; while((letter = getchar()) != '\n' && letter != eof) *string++ = letter; *string = '\0'; return((letter == eof) ? eof : no_error); } /* ends read_string */ clear_buffer(string) char string[]; { int i; for(i=0; i