vga-logic-processor-examples/main.c

96 lines
1.7 KiB
C
Raw Normal View History

#include <stdio.h>
2024-03-19 12:18:55 +00:00
#include <i86.h>
#include <conio.h>
extern void __cdecl enableUnchainedVGAMode();
extern void __cdecl enableTextMode();
2024-03-20 02:08:42 +00:00
extern void __cdecl fillScreen(int);
extern void __cdecl latchCopyCube(char offset, int writtenValue, int writeMode);
extern int __cdecl paramTest(int wow);
extern void __cdecl far interrupt keyboardHandler();
extern char keyboardPressed;
2024-03-19 12:18:55 +00:00
char far *VGA = (char*)0xA0000;
2024-03-20 02:08:42 +00:00
#define PLANE_WIDTH (320 / 4)
void far (interrupt *int9Save)();
2024-03-20 02:08:42 +00:00
void populateExampleCube(void) {
int y, x;
outp(0x3c4, 0x02);
for (y = 0; y < 16; ++y) {
for (x = 0; x < 16; ++x) {
2024-03-20 02:08:42 +00:00
outp(0x3c5, 1 << (x % 4));
VGA[y * PLANE_WIDTH + x / 4] = y * 16 + x;
}
}
}
2024-03-19 12:18:55 +00:00
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);
printf("%p\n", keyboardHandler);
while (keyboardPressed == 0) {
printf("%d\n", keyboardPressed);
}
printf("wow\n");
delay(200);
_dos_setvect(9, int9Save);
return 0;
2024-03-19 12:18:55 +00:00
enableUnchainedVGAMode();
2024-03-20 02:08:42 +00:00
fillScreen(0);
populateExampleCube();
latchCopyCube(8, 0, 0x00);
latchCopyCube(12, 127, 0x00);
latchCopyCube(16, 0, 0x08);
latchCopyCube(20, 127, 0x08);
latchCopyCube(24, 0, 0x10);
latchCopyCube(28, 127, 0x10);
latchCopyCube(32, 0, 0x18);
latchCopyCube(36, 127, 0x18);
while (keyboardPressed == 0) {
delay(1);
}
2024-03-20 02:08:42 +00:00
/*
2024-03-19 12:18:55 +00:00
outp(0x3c4, 0x02);
for (i = 0; i < 200; ++i) {
for (j = 0; j < 4; ++j) {
outp(0x3c5, 1 << j);
VGA[i] = j + 1;
}
}
2024-03-20 02:08:42 +00:00
*/
//delay(3000);
2024-03-19 12:18:55 +00:00
enableTextMode();
}