#include <stdio.h>

unsigned char ah,al,bh,bl,ch,cl,dh,dl,buff[256],mess[2];
unsigned char stack1[256],stack2[256],stack3[1024],stack4[256];
unsigned int ax,bx,cx,dx,si,di,bp,ds,es;
int i,d,fd;

main(){
	mess[1]=0;
	service_00();
	service_01(0x0101);
	service_01(0x0103);
	service_03();
	service_04_0(0x0001);
	service_04_0(0x0002);
	service_04_0(0x0004);
	service_04_0(0x0008);
	while(1){
		d=csts();
		if(d==0x1b) break;
	}
	bx=&stack1; service_04_1(0x0001);
	bx=&stack2; service_04_1(0x0002);
	bx=&stack3; service_04_1(0x0004);
	bx=&stack4; service_04_1(0x0008);

	service_02(0x0101);

	while(1){
		d=csts();
		if(d==0x1b) break;
	}
	bx=&stack1; service_04_2(0x0001);
	bx=&stack2; service_04_2(0x0002);
	bx=&stack3; service_04_2(0x0004);
	bx=&stack4; service_04_2(0x0008);
	while(1){
		d=csts();
		if(d==0x1b) break;
	}
}

service_04_2(ddd)
	unsigned int ddd;
{
	es=_showds();
	cx=ddd;
#asm
	push	es
	push	ds
	mov	dl,2
	mov	es,word es_
	mov	bx,word bx_
	mov	cx,word cx_
	mov	ah,79
	mov	al,4
	int 10h
	mov	word ax_,ax
	pop	ds
	pop	es
#
	printf("\nBIOS#4:\tmode = 1 , type = %04x , result = %04x , ",cx,ax);
}

service_04_1(ddd)
	unsigned int ddd;
{
	es=_showds();
	cx=ddd;
#asm
	push	es
	push	ds
	mov	dl,1
	mov	es,word es_
	mov	bx,word bx_
	mov	cx,word cx_
	mov	ah,79
	mov	al,4
	int 10h
	mov	word ax_,ax
	pop	ds
	pop	es
#
	printf("\nBIOS#4:\tmode = 1 , type = %04x , result = %04x , ",cx,ax);
}

service_04_0(ddd)
	unsigned int ddd;
{
	cx=ddd;
#asm
	push	ds
	mov	dl,0
	mov	cx,word cx_
	mov	ah,79
	mov	al,4
	int 10h
	mov	word ax_,ax
	mov	word bx_,bx
	pop	ds
#
	printf("\nBIOS#4:\tmode = 0 , result = %04x , ",ax);
	printf("type = %04x , buffer size = %04x",cx,bx);
}

service_03(){
#asm
	push	ds
	mov	ah,79
	mov	al,3
	int 10h
	mov	word ax_,ax
	mov	word bx_,bx
	pop	ds
#
	printf("\nBIOS#3:\tresult = %04x , current mode = %04x",ax,bx);
}

service_02(ddd)
	unsigned int ddd;
{
	bx=ddd;
#asm
	push	ds
	mov	bx,word bx_
	mov	ah,79
	mov	al,2
	int 10h
	mov	word ax_,ax
	pop	ds
#
	printf("\n\nBIOS#2:\tset mode = %04x , result = %04x",bx,ax);
}

service_01(ddd)
	unsigned int ddd;
{
	di=&buff;
	es=_showds();
	cx=ddd;
#asm
	push	es
	push	ds
	mov	di,word di_
	mov	es,word es_
	mov	cx,word cx_
	mov	ah,79
	mov	al,1
	int 10h
	mov	word ax_,ax
	pop	ds
	pop	es
#
	printf("\nBIOS#1:\tmode = %04x , result = %04x , ",cx,ax);
	printf("mode = %02x%02x",buff[1],buff[0]);
	printf("\n\twindow[A] = %02x , ",buff[2]);
	printf("window[B] = %02x , ",buff[3]);
	printf("grain = %02x%02x",buff[5],buff[4]);
	printf("\n\twindow size = %02x%02x , ",buff[7],buff[6]);
	printf("segment[A] = %02x%02x , ",buff[9],buff[8]);
	printf("segment[B] = %02x%02x",buff[11],buff[10]);
}

service_00(){
	di=&buff;
	es=_showds();
#asm
	push	es
	push	ds
	mov	di,word di_
	mov	es,word es_
	mov	ah,79
	mov	al,0
	int 10h
	mov	word ax_,ax
	pop	ds
	pop	es
#
	printf("\nBIOS#0:\tresult = %04x , ID = ",ax);
	for(i=0;i<4;i++){ mess[0]=buff[i]; printf("%s",mess); }
	printf(" , version = %02x%02x",buff[5],buff[4]);
}

