📄 vgacard.java
字号:
memoryRegistered = false; int len = input.readInt(); for (int i = 0; i< len; i++) expand4[i] = input.readInt(); len = input.readInt(); for (int i = 0; i< len; i++) expand2[i] = input.readInt(); len = input.readInt(); for (int i = 0; i< expand4to8.length; i++) expand4to8[i] = input.readInt(); latch = input.readInt(); sequencerRegisterIndex = input.readInt(); graphicsRegisterIndex = input.readInt(); attributeRegisterIndex = input.readInt(); crtRegisterIndex = input.readInt(); len = input.readInt(); sequencerRegister = new int[len]; for (int i = 0; i< sequencerRegister.length; i++) sequencerRegister[i] = input.readInt(); len = input.readInt(); graphicsRegister = new int[len]; for (int i = 0; i< graphicsRegister.length; i++) graphicsRegister[i] = input.readInt(); len = input.readInt(); attributeRegister = new int[len]; for (int i = 0; i< attributeRegister.length; i++) attributeRegister[i] = input.readInt(); len = input.readInt(); crtRegister = new int[len]; for (int i = 0; i< crtRegister.length; i++) crtRegister[i] = input.readInt(); attributeRegisterFlipFlop = input.readBoolean(); miscellaneousOutputRegister = input.readInt(); featureControlRegister = input.readInt(); st00 = input.readInt(); st01 = input.readInt(); dacReadIndex = input.readInt(); dacWriteIndex = input.readInt(); dacSubIndex = input.readInt(); dacState = input.readInt(); shiftControl = input.readInt(); doubleScan = input.readInt(); len = input.readInt(); dacCache = new int[len]; for (int i = 0; i< dacCache.length; i++) dacCache[i] = input.readInt(); len = input.readInt(); palette = new int[len]; for (int i = 0; i< palette.length; i++) palette[i] = input.readInt(); bankOffset = input.readInt(); vbeIndex = input.readInt(); len = input.readInt(); vbeRegs = new int[len]; for (int i = 0; i< vbeRegs.length; i++) vbeRegs[i] = input.readInt(); vbeStartAddress = input.readInt(); vbeLineOffset = input.readInt(); vbeBankMask = input.readInt(); len = input.readInt(); fontOffset = new int[len]; for (int i = 0; i< fontOffset.length; i++) fontOffset[i] = input.readInt(); graphicMode = input.readInt(); lineOffset = input.readInt(); lineCompare = input.readInt(); startAddress = input.readInt(); planeUpdated = input.readInt(); lastCW = input.readInt(); lastCH = input.readInt(); lastWidth = input.readInt(); lastHeight = input.readInt(); lastScreenWidth = input.readInt(); lastScreenHeight = input.readInt(); cursorStart = input.readInt(); cursorEnd = input.readInt(); cursorOffset = input.readInt(); len = input.readInt(); for (int i = 0; i< lastPalette.length; i++) lastPalette[i] = input.readInt(); len = input.readInt(); lastChar = new int[len]; for (int i = 0; i< lastChar.length; i++) lastChar[i] = input.readInt(); updatingScreen = input.readBoolean(); //load ioregion ioRegion = new VGARAMIORegion(); ioRegion.loadState(input); //load graphics updaters VGA_DRAW_LINE2.loadState(input); VGA_DRAW_LINE2D2.loadState(input); VGA_DRAW_LINE4.loadState(input); VGA_DRAW_LINE4D2.loadState(input); VGA_DRAW_LINE8D2.loadState(input); VGA_DRAW_LINE8.loadState(input); VGA_DRAW_LINE15.loadState(input); VGA_DRAW_LINE16.loadState(input); VGA_DRAW_LINE24.loadState(input); VGA_DRAW_LINE32.loadState(input); lowIORegion = new VGALowMemoryRegion(); } public void resizeDisplay(GraphicsDisplay device) { device.resizeDisplay(lastScreenWidth, lastScreenHeight); } private void setupArrays() { for (int i = 0; i < 256; i++) { int v = 0; for (int j = 0; j < 8; j++) { v |= ((i >>> j) & 1) << (j * 4); } expand4[i] = v; v = 0; for (int j = 0; j < 4; j++) { v |= ((i >>> (2 * j)) & 3) << (j * 4); } expand2[i] = v; } for (int i = 0; i < 16; i++) { int v = 0; for (int j = 0; j < 4; j++) { int b = ((i >>> j) & 1); v |= b << (2 * j); v |= b << (2 * j + 1); } expand4to8[i] = v; } } private void setupGraphicsModes() { VGA_DRAW_LINE2 = new DrawLine2(); VGA_DRAW_LINE2D2 = new DrawLine2d2(); VGA_DRAW_LINE4 = new DrawLine4(); VGA_DRAW_LINE4D2 = new DrawLine4d2(); VGA_DRAW_LINE8D2 = new DrawLine8d2(); VGA_DRAW_LINE8 = new DrawLine8(); VGA_DRAW_LINE15 = new DrawLine15(); VGA_DRAW_LINE16 = new DrawLine16(); VGA_DRAW_LINE24 = new DrawLine24(); VGA_DRAW_LINE32 = new DrawLine32(); } //PCIDevice Methods public IORegion[] getIORegions() { return new IORegion[]{ioRegion}; } public IORegion getIORegion(int index) { if(index == 0) return ioRegion; else return null; } //IOPortCapable Methods public void ioPortWriteByte(int address, int data) { //all byte accesses are vgaIOPort ones vgaIOPortWriteByte(address, data); } public void ioPortWriteWord(int address, int data) { switch(address) { case 0x1ce: case 0xff80: vbeIOPortWriteIndex(data); break; case 0x1cf: case 0xff81: vbeIOPortWriteData(data); break; default: ioPortWriteByte(address, 0xFF & data); ioPortWriteByte(address+1, 0xFF & (data >>> 8)); break; } } public void ioPortWriteLong(int address, int data) { ioPortWriteWord(address, 0xFFFF & data); ioPortWriteWord(address+2, data >>> 16); } public int ioPortReadByte(int address) { //all byte accesses are vgaIOPort ones return vgaIOPortReadByte(address); } public int ioPortReadWord(int address) { switch(address) { case 0x1ce: case 0xff80: return vbeIOPortReadIndex(); case 0x1cf: case 0xff81: return vbeIOPortReadData(); default: int b0 = 0xFF & ioPortReadByte(address); int b1 = 0xFF & ioPortReadByte(address+1); return b0 | (b1 << 8); } } public int ioPortReadLong(int address) { int b0 = 0xFFFF & ioPortReadWord(address); int b1 = 0xFFFF & ioPortReadWord(address+2); return b0 | (b1 << 16); } public int[] ioPortsRequested() { return new int[]{0x3b4, 0x3b5, 0x3ba, 0x3d4, 0x3d5, 0x3da, 0x3c0, 0x3c1, 0x3c2, 0x3c3, 0x3c4, 0x3c5, 0x3c6, 0x3c7, 0x3c8, 0x3c9, 0x3ca, 0x3cb, 0x3cc, 0x3cd, 0x3ce, 0x3cf, 0x1ce, 0x1cf, 0xff80, 0xff81 }; } private final void vgaIOPortWriteByte(int address, int data) { if ((address >= 0x3b0 && address <= 0x3bf && ((miscellaneousOutputRegister & MOR_COLOR_EMULATION) != 0)) || (address >= 0x3d0 && address <= 0x3df && ((miscellaneousOutputRegister & MOR_COLOR_EMULATION) == 0))) return; if ((data & ~0xff) != 0) System.err.println("Possible Bug With New INT Register"); switch(address) { case 0x3b4: case 0x3d4: crtRegisterIndex = data; break; case 0x3b5: case 0x3d5: if (crtRegisterIndex <= 7 && (crtRegister[CR_INDEX_VERT_RETRACE_END] & 0x80) != 0) { /* can always write bit 4 of CR_INDEX_OVERFLOW */ if (crtRegisterIndex == CR_INDEX_OVERFLOW) crtRegister[CR_INDEX_OVERFLOW] = (crtRegister[CR_INDEX_OVERFLOW] & ~0x10) | (data & 0x10); return; } crtRegister[crtRegisterIndex] = data; break; case 0x3ba: case 0x3da: featureControlRegister = data & 0x10; break; case 0x3c0: if (!attributeRegisterFlipFlop) { data &= 0x3f; attributeRegisterIndex = data; } else { int index = attributeRegisterIndex & 0x1f; switch(index) { case AR_INDEX_PALLETE_MIN: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case AR_INDEX_PALLETE_MAX: attributeRegister[index] = data & 0x3f; break; case AR_INDEX_ATTR_MODE_CONTROL: attributeRegister[AR_INDEX_ATTR_MODE_CONTROL] = data & ~0x10; break; case AR_INDEX_OVERSCAN_COLOR: attributeRegister[AR_INDEX_OVERSCAN_COLOR] = data; break; case AR_INDEX_COLOR_PLANE_ENABLE: attributeRegister[AR_INDEX_COLOR_PLANE_ENABLE] = data & ~0xc0; break; case AR_INDEX_HORIZ_PIXEL_PANNING: attributeRegister[AR_INDEX_HORIZ_PIXEL_PANNING] = data & ~0xf0; break; case AR_INDEX_COLOR_SELECT: attributeRegister[AR_INDEX_COLOR_SELECT] = data & ~0xf0; break; default: break; } } attributeRegisterFlipFlop = !attributeRegisterFlipFlop; break; case 0x3c2: miscellaneousOutputRegister = data & ~0x10; break; case 0x3c4: sequencerRegisterIndex = data & 0x7; break; case 0x3c5: sequencerRegister[sequencerRegisterIndex] = data & sequencerRegisterMask[sequencerRegisterIndex]; break; case 0x3c7: dacReadIndex = data; dacSubIndex = 0; dacState = 3; break; case 0x3c8: dacWriteIndex = data; dacSubIndex = 0; dacState = 0; break; case 0x3c9: dacCache[dacSubIndex] = data; if (++dacSubIndex == 3) { for (int i = 0; i < 3; i++) palette[((0xff & dacWriteIndex) * 3) + i] = dacCache[i]; dacSubIndex = 0; dacWriteIndex++; } break; case 0x3ce: graphicsRegisterIndex = data & 0x0f; break; case 0x3cf: graphicsRegister[graphicsRegisterIndex] = data & graphicsRegisterMask[graphicsRegisterIndex]; break; } } private final int vgaIOPortReadByte(int address) { if ((address >= 0x3b0 && address <= 0x3bf && ((miscellaneousOutputRegister & MOR_COLOR_EMULATION) != 0)) || (address >= 0x3d0 && address <= 0x3df && ((miscellaneousOutputRegister & MOR_COLOR_EMULATION) == 0))) return 0xff; switch (address) { case 0x3c0: if (!attributeRegisterFlipFlop) { return attributeRegisterIndex; } else { return 0; } case 0x3c1: int index = attributeRegisterIndex & 0x1f; if (index < 21) { return attributeRegister[index]; } else { return 0; } case 0x3c2: return st00; case 0x3c4: return sequencerRegisterIndex; case 0x3c5: return sequencerRegister[sequencerRegisterIndex]; case 0x3c7: return dacState; case 0x3c8: return dacWriteIndex; case 0x3c9: int val = palette[dacReadIndex * 3 + dacSubIndex]; if (++dacSubIndex == 3) { dacSubIndex = 0; dacReadIndex++; } return val; case 0x3ca: return featureControlRegister; case 0x3cc: return miscellaneousOutputRegister; case 0x3ce: return graphicsRegisterIndex; case 0x3cf: return graphicsRegister[graphicsRegisterIndex]; case 0x3b4: case 0x3d4: return crtRegisterIndex; case 0x3b5: case 0x3d5: return crtRegister[crtRegisterIndex]; case 0x3ba: case 0x3da: attributeRegisterFlipFlop = false; if (updatingScreen) { st01 &= ~ST01_V_RETRACE; //claim we are not in vertical retrace (in the process of screen refresh) st01 &= ~ST01_DISP_ENABLE; //is set when in h/v retrace (i.e. if e-beam is off, but we claim always on) } else { st01 ^= (ST01_V_RETRACE | ST01_DISP_ENABLE); //if not updating toggle to fool polling in some vga code } return st01; default: return 0x00; } } private final void vbeIOPortWriteIndex(int data) { vbeIndex = data;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -