Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <dos.h>
- #include <stdlib.h>
- #include <stdio.h>
- unsigned char far *Video = (unsigned char far *)MK_FP(0xA000, 0x0000);
- unsigned short loopbreak = 0;
- unsigned incx = 0;
- unsigned incy = 0;
- unsigned short inccolor = 0;
- void setpixel(unsigned x, unsigned y, unsigned char color){
- /*set initial values for what segment to write to*/
- unsigned int segment = 0xA000;
- unsigned int offset = 0x0000;
- /* first ensure that the pixel is within bounds */
- if(x > 319 || y > 199){
- return;
- }
- /* now calculate segments and offset for x and y */
- segment = segment + (20 * y);
- offset = x;
- /* now set the pointer to the needed location and write the pixel*/
- Video = (unsigned short int far *)MK_FP(segment, offset);
- *Video = color;
- }
- void gameloop(){
- FILE *fimg;
- unsigned char imgr[256];
- unsigned char incx = 0;
- unsigned char incy = 0;
- unsigned short inca = 0;
- fimg = fopen("C:/IMGOUT.VGA", "rb");
- fread(imgr, 1, 256, fimg);
- fclose(fimg);
- while(1 == 1){
- setpixel(incx, incy, imgr[inca]);
- inca++;
- if(inca >= 256){
- break;
- }
- if(incx == 15){
- incy++;
- incx = 0;
- }else incx++;
- }
- loopbreak = 1;
- }
- int main(void){
- unsigned short incpal = 1;
- /* do initializations*/
- printf("\nThis test will place a bitmap in the screen corner.");
- printf("\nPress enter to continue...");
- getchar();
- _AH = 0x00;
- _AL = 0x13;
- geninterrupt(0x10);
- while(loopbreak == 0){
- gameloop();
- }
- getchar();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement