vga-logic-processor-examples/main.c

104 lines
2.1 KiB
C

#include <stdio.h>
#include <i86.h>
#include <conio.h>
#include <dos.h>
extern void __cdecl enableUnchainedVGAMode();
extern void __cdecl enableTextMode();
extern void __cdecl fillScreen(int);
extern void __cdecl latchCopyCube(
char offset,
int writtenValue,
int writeMode,
int setResetRegister,
int enableSetResetRegister
);
extern void __cdecl writeCube(
char offset,
int writeMode,
int setResetRegister,
int enableSetResetRegister
);
extern void __cdecl drawColorCube(
char offset,
int color
);
extern int __cdecl paramTest(int wow);
extern void far interrupt keyboardHandler();
extern char keyboardPressed;
extern char lastScancode;
char far *VGA = (char*)0xA0000;
#define PLANE_WIDTH (320 / 4)
void far (interrupt *int9Save)();
void populateExampleCube(void) {
int y, x;
outp(0x3c4, 0x02);
for (y = 0; y < 16; ++y) {
for (x = 0; x < 16; ++x) {
outp(0x3c5, 1 << (x % 4));
VGA[y * PLANE_WIDTH + x / 4] = y * 16 + x;
}
}
}
int main(void) {
// activate unchained vga mode
// set up 8 very clear colors
// place some data into video memory to be latch copied
// show off the following
// * latch copies
// * masking
// * barrel shifting
int i,j;
int9Save = _dos_getvect(9);
_dos_setvect(9, keyboardHandler);
enableUnchainedVGAMode();
outp(0x3c8, 255);
outp(0x3c9, 63);
outp(0x3c9, 63);
outp(0x3c9, 63);
fillScreen(0);
/*
populateExampleCube();
latchCopyCube(8, 0, 0x00, 0, 0);
latchCopyCube(12, 127, 0x00, 0, 0);
latchCopyCube(16, 0, 0x08, 0, 0);
latchCopyCube(20, 127, 0x08, 0, 0);
latchCopyCube(24, 0, 0x10, 0, 0);
latchCopyCube(28, 127, 0x10, 0, 0);
latchCopyCube(32, 0, 0x18, 0, 0);
latchCopyCube(36, 127, 0x18, 0, 0);
latchCopyCube(40, 0, 0x18 + 0x04, 0, 0);
latchCopyCube(44, 127, 0x18 + 0x04, 0, 0);
latchCopyCube(64, 0, 0x10, 7, 7);
latchCopyCube(68, 0, 0x10, 7, 0);
latchCopyCube(72, 0, 0x10, 0, 7);
*/
writeCube(0, 0x10, 0, 0);
writeCube(4, 0x10, 7, 0);
writeCube(8, 0x10, 7, 7);
writeCube(12, 0x10, 0, 7);
while (keyboardPressed == 0);
_dos_setvect(9, int9Save);
enableTextMode();
return 0;
}