#define HF_BANK_NO	0xc0

#define hf_io_enable()            outportb(0xee,HF_BANK_NO)
#define hf_io_disable()           outportb(0xee,0x00)

#define hf_enable()        outportb(0xd0,inportb(0xd0)|0x80)
#define hf_disable()       outportb(0xd0,inportb(0xd0)&0x7f)

#define hf_io()            outportb(0xd0,inportb(0xd0)|0x01)
#define hf_bank()          outportb(0xd0,inportb(0xd0)&0xfe)

#define hf_fbuf_on() hf_setregister_a(0x1b,0xcc)
#define hf_fbuf_off() hf_setregister_a(0x1b,0)

#define hf_impose_on()     outportb(0xd0,inportb(0xd0)|0x20)
#define hf_impose_off()    outportb(0xd0,inportb(0xd0)&0xdf)

#define hf_register_on()        outportb(0xd0,inportb(0xd0)|0x40)
#define hf_register_off()       outportb(0xd0,inportb(0xd0)&0xbf)

#define hf_16color_on()        outportb(0xd3,inportb(0xd0)|0x80)
#define hf_16color_off()       outportb(0xd3,inportb(0xd0)&0x7f)

#define hf_select_register(n) hf_putpixel(0x80,0x193,0,n,0)

#define hf_setregister_a(n,v) hf_putpixel(0x80+(n),0x193,0,v,0)
#define hf_setregister_b(n,v) hf_putpixel(0x180+(n),0x191,v,v,v)
#define hf_scroll(x,y) (hf_setregister_a(4,(x)&0xff),\
			hf_setregister_a(5,((x)>>8)&0x03),\
			hf_setregister_a(6,(y)&0xff),\
			hf_setregister_a(7,((y)>>8)&0x01))

#define hf_zoom(z) hf_setregister_a(3,((z)&0x03)|(((z)&0x03)<<2))

#define hf_putpixel(x,y,r,g,b) \
	(outportb(0xd4,(x)&0xff), \
	outportb(0xd5,((x)>>8)&0x03), \
	outportb(0xd6,(y)&0xff), \
	outportb(0xd7,((y)>>8)&0x01), \
	outportb(0xd8,r), \
	outportb(0xda,g), \
	outportb(0xdc,b))
