Use tables for ega modes, new memory handler
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@171
This commit is contained in:
parent
76ab53be5c
commit
a1ed02efa3
1 changed files with 42 additions and 16 deletions
|
@ -29,6 +29,8 @@
|
|||
VGA_Type vga;
|
||||
Bit32u CGAWriteTable[256];
|
||||
Bit32u ExpandTable[256];
|
||||
Bit32u Expand16Table[4][16];
|
||||
Bit32u Expand16BigTable[0x10000];
|
||||
|
||||
Bit32u FillTable[16]={
|
||||
0x00000000,0x000000ff,0x0000ff00,0x0000ffff,
|
||||
|
@ -37,7 +39,7 @@ Bit32u FillTable[16]={
|
|||
0xffff0000,0xffff00ff,0xffffff00,0xffffffff
|
||||
};
|
||||
|
||||
static PageEntry VGA_PageEntry;
|
||||
|
||||
|
||||
void VGA_Render_GFX_2(Bit8u * * data);
|
||||
void VGA_Render_GFX_4(Bit8u * * data);
|
||||
|
@ -48,8 +50,7 @@ void VGA_Render_TEXT_16(Bit8u * * data);
|
|||
|
||||
void VGA_FindSettings(void) {
|
||||
/* Sets up the correct memory handler from the vga.mode setting */
|
||||
MEMORY_ResetHandler(0xA0000/4096,128*1024/4096);
|
||||
VGA_PageEntry.type=MEMORY_HANDLER;
|
||||
MEM_ClearPageHandlers(PAGE_COUNT(0xa0000),PAGE_COUNT(0x20000));
|
||||
/* Detect the kind of video mode this is */
|
||||
if (vga.config.gfxmode) {
|
||||
if (vga.config.vga_enabled) {
|
||||
|
@ -60,27 +61,20 @@ void VGA_FindSettings(void) {
|
|||
} else {
|
||||
/* 256 color unchained vga */
|
||||
vga.mode=GFX_256U;
|
||||
VGA_PageEntry.base=0xA0000;
|
||||
VGA_PageEntry.handler.read=VGA_NormalReadHandler;
|
||||
VGA_PageEntry.handler.write=VGA_GFX_256U_WriteHandler;
|
||||
MEMORY_SetupHandler(0xA0000/4096,16,&VGA_PageEntry);
|
||||
MEM_SetupPageHandlers(PAGE_COUNT(0xa0000),PAGE_COUNT(0x10000),
|
||||
&VGA_NormalReadHandler,&VGA_GFX_256U_WriteHandler);
|
||||
}
|
||||
} else if (vga.config.cga_enabled) {
|
||||
/* 4 color cga */
|
||||
//TODO Detect hercules modes, probably set them up in bios too
|
||||
if (vga.config.pixel_double) vga.mode=GFX_4;
|
||||
else vga.mode=GFX_2;
|
||||
// VGA_PageEntry.base=0xB8000;
|
||||
// VGA_PageEntry.handler.read=VGA_GFX_4_ReadHandler;
|
||||
// VGA_PageEntry.handler.write=VGA_GFX_4_WriteHandler;
|
||||
// MEMORY_SetupHandler(0xB8000/4096,8,&VGA_PageEntry);
|
||||
//TODO Maybe also use a page handler for cga mode
|
||||
} else {
|
||||
/* 16 color ega */
|
||||
vga.mode=GFX_16;
|
||||
VGA_PageEntry.base=0xA0000;
|
||||
VGA_PageEntry.handler.read=VGA_NormalReadHandler;
|
||||
VGA_PageEntry.handler.write=VGA_GFX_16_WriteHandler;
|
||||
MEMORY_SetupHandler(0xA0000/4096,16,&VGA_PageEntry);
|
||||
MEM_SetupPageHandlers(PAGE_COUNT(0xa0000),PAGE_COUNT(0x10000),
|
||||
&VGA_NormalReadHandler,&VGA_GFX_16_WriteHandler);
|
||||
}
|
||||
} else {
|
||||
vga.mode=TEXT_16;
|
||||
|
@ -161,10 +155,42 @@ void VGA_Init() {
|
|||
VGA_SetupSEQ();
|
||||
VGA_SetupAttr();
|
||||
/* Generate tables */
|
||||
Bit32u i;
|
||||
Bitu i,j;
|
||||
for (i=0;i<256;i++) {
|
||||
ExpandTable[i]=i | (i << 8)| (i <<16) | (i << 24);
|
||||
CGAWriteTable[i]=((i>>6)&3) | (((i>>4)&3) << 8)| (((i>>2)&3) <<16) | (((i>>0)&3) << 24);
|
||||
}
|
||||
for (j=0;j<4;j++) {
|
||||
for (i=0;i<16;i++) {
|
||||
Expand16Table[j][i] =
|
||||
((i & 1) ? 1 << (24 + j) : 0) |
|
||||
((i & 2) ? 1 << (16 + j) : 0) |
|
||||
((i & 4) ? 1 << (8 + j) : 0) |
|
||||
((i & 8) ? 1 << j : 0);
|
||||
}
|
||||
}
|
||||
for (i=0;i<0x10000;i++) {
|
||||
Bit32u val=0;
|
||||
if (i & 0x1) val|=0x1 << 24;
|
||||
if (i & 0x2) val|=0x1 << 16;
|
||||
if (i & 0x4) val|=0x1 << 8;
|
||||
if (i & 0x8) val|=0x1 << 0;
|
||||
|
||||
if (i & 0x10) val|=0x4 << 24;
|
||||
if (i & 0x20) val|=0x4 << 16;
|
||||
if (i & 0x40) val|=0x4 << 8;
|
||||
if (i & 0x80) val|=0x4 << 0;
|
||||
|
||||
if (i & 0x100) val|=0x2 << 24;
|
||||
if (i & 0x200) val|=0x2 << 16;
|
||||
if (i & 0x400) val|=0x2 << 8;
|
||||
if (i & 0x800) val|=0x2 << 0;
|
||||
|
||||
if (i & 0x1000) val|=0x8 << 24;
|
||||
if (i & 0x2000) val|=0x8 << 16;
|
||||
if (i & 0x4000) val|=0x8 << 8;
|
||||
if (i & 0x8000) val|=0x8 << 0;
|
||||
Expand16BigTable[i]=val;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue