Untitled

 avatar
unknown
plain_text
a year ago
984 B
7
Indexable
#define PLANE_SIZE (640 / 8) * 480

unsigned char *bitplane_r, *bitplane_g, *bitplane_b, *bitplane_i;

int InitBitplanes(void)
{
	if ((bitplane_r = (unsigned char *) calloc(1, PLANE_SIZE)) == NULL) return(0);
	if ((bitplane_g = (unsigned char *) calloc(1, PLANE_SIZE)) == NULL) return(0);
	if ((bitplane_b = (unsigned char *) calloc(1, PLANE_SIZE)) == NULL) return(0);
	if ((bitplane_i = (unsigned char *) calloc(1, PLANE_SIZE)) == NULL) return(0);

	return(1);
}

void CopyBitplanes(void)
{
	asm {
		push ds

		mov ax, 0xA000
		mov es, ax
		xor di, di
		mov dx, VGA_ADD_REG

		mov ax, 0x0102
		out dx, ax
		lds si, [bitplane_b]
		mov cx, PLANE_SIZE
		rep movsb

		xor di, di
        mov ax, 0x0202
		out dx, ax
		lds si, [bitplane_g]
		mov cx, PLANE_SIZE
		rep movsb

		xor di, di
		mov ax, 0x0402
		out dx, ax
		lds si, [bitplane_r]
		mov cx, PLANE_SIZE
		rep movsb

		xor di, di
		mov ax, 0x0802
		out dx, ax
		lds si, [bitplane_i]
		mov cx, PLANE_SIZE
		rep movsb

		pop ds
	}
}

Editor is loading...
Leave a Comment