Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void vr_synch(void) {
- asm mov dx,3DAh;
- vr1:
- asm in al,dx;
- asm test al,8;
- asm jne vr1;
- vr2:
- asm in al,dx;
- asm test al,8;
- asm je vr2;
- }
- void mcga(void) {
- asm {
- mov ax, 13h // load the mode to the ax register
- int 10h // interupt 10h
- }
- }
- long i(int x, int y) {
- return ((y * 320) + x);
- }
- void putpixel(int x_coordinate, int y_coordinate, char color) {
- asm mov ax,0a000h;
- asm mov es,ax;
- asm mov di,[y_coordinate];
- asm mov ax,[y_coordinate];
- asm shl di,8;
- asm shl ax,6;
- asm add di,ax;
- asm add di,[x_coordinate];
- asm xor ax,ax;
- asm mov al,[color];
- asm mov [es:di],al;
- }
- void drawscreen(char *sbuffer) {
- vr_synch();
- for (int y = 0; y < 200; y++)
- for (int x = 0; x < 320; x++)
- putpixel(x, y, sbuffer[(y * 200) + x]);
- }
- void setpal(char r, char g, char b, char location) {
- asm push dx; // save dx
- asm mov dx,3c8h; // 3c8h is the setting of the number
- // (0-255) in which the color will
- // be held in the pallette
- asm mov al,[location]; // move the pallette location into al
- asm out dx,al; // output al to dx (3c8h)
- asm inc dx; // increase dx to become 3c9h. This
- // is the setting that controls the
- // RGB values of the pallette number
- asm mov al,r; // move red value to al
- asm out dx,al; // output al to dx, setting the red value
- asm mov al,g; // move green value to al
- asm out dx,al; // output al to dx, setting the green value
- asm mov al,b; // move blue value to al
- asm out dx,al; // output al to dx, settign the blue value
- // wh00p, all done!
- asm pop dx; // put back dx
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement