/* mode 13h functions */ static void m13h_setmode( void ) { int i; uint8_t regs[] = { /* MISC */ 0x63, /* SEQ */ 0x03, 0x01, 0x0F, 0x00, 0x0E, /* CRTC */ 0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9C, 0x0E, 0x8F, 0x28, 0x40, 0x96, 0xB9, 0xA3, 0xFF, /* GC */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF, /* AC */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x41, 0x00, 0x0F, 0x00, 0x00, }; int rg = 0; uint8_t reg; /* MISC */ outport_b(VGA_MSCOUTW,regs[rg]); rg++; /* SEQ */ for ( i=0; i<5; i++ ) setvgareg(VGA_SEQ,i,regs[rg++]); /* need to unlock CRTC here */ reg = getvgareg(VGA_CRTC,VGA_CRTC_EHBLNK); reg |= 0x80; setvgareg(VGA_CRTC,VGA_CRTC_EHBLNK,reg); reg = getvgareg(VGA_CRTC,VGA_CRTC_VTRTEN); reg &= ~0x80; setvgareg(VGA_CRTC,VGA_CRTC_VTRTEN,reg); /* keep 'em unlocked */ regs[rg+VGA_CRTC_EHBLNK] |= 0x80; regs[rg+VGA_CRTC_VTRTEN] &= ~0x80; /* CRTC */ for ( i=0; i<25; i++ ) setvgareg(VGA_CRTC,i,regs[rg++]); /* GC */ for ( i=0; i<9; i++ ) setvgareg(VGA_GC,i,regs[rg++]); /* AC */ for ( i=0; i<9; i++ ) { inport_b(VGA_INSTAT1); outport_b(VGA_AC_I,i); outport_b(VGA_AC_W,regs[rg++]); } /* unblank display and lock palette */ inport_b(VGA_INSTAT1); outport_b(VGA_AC_I,0x20); /* clear video memory */ memset(m13h_mem,0x00,64000); }
/* get the value of a VGA register */ uint8_t getvgareg( uint16_t port, uint8_t index ) { uint8_t save = inport_b(port); outport_b(port,index); uint8_t data = inport_b(port+1); outport_b(port,save); return data; }
static void m13h_getpal( uint8_t* pal ) { int i; for ( i=0; i<256; i++ ) { outport_b(VGA_DAC_ADRM,i); *(pal++) = inport_b(VGA_DAC_DATA); *(pal++) = inport_b(VGA_DAC_DATA); *(pal++) = inport_b(VGA_DAC_DATA); } }
uint8_t serial_transmit_empty( uint16_t dev ) { return inport_b(dev+5)&0x20; }
char serial_recv_async( uint16_t dev ) { return inport_b(dev); }
char serial_recv( uint16_t dev ) { while ( serial_recv_d(dev) == 0 ); return inport_b(dev); }
uint8_t serial_recv_d( uint16_t dev ) { return inport_b(dev+5)&1; }