2024-03-20 13:02:47 +00:00
|
|
|
#include <stdio.h>
|
2024-03-19 12:18:55 +00:00
|
|
|
#include <i86.h>
|
|
|
|
#include <conio.h>
|
2024-03-20 23:19:49 +00:00
|
|
|
#include <dos.h>
|
2024-03-19 12:18:55 +00:00
|
|
|
|
|
|
|
extern void __cdecl enableUnchainedVGAMode();
|
|
|
|
extern void __cdecl enableTextMode();
|
2024-03-20 02:08:42 +00:00
|
|
|
extern void __cdecl fillScreen(int);
|
2024-03-20 23:19:49 +00:00
|
|
|
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
|
|
|
|
);
|
2024-03-20 13:02:47 +00:00
|
|
|
extern int __cdecl paramTest(int wow);
|
|
|
|
|
2024-03-20 23:19:49 +00:00
|
|
|
extern void far interrupt keyboardHandler();
|
2024-03-20 13:02:47 +00:00
|
|
|
extern char keyboardPressed;
|
2024-03-20 23:19:49 +00:00
|
|
|
extern char lastScancode;
|
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)
|
|
|
|
|
2024-03-20 13:02:47 +00:00
|
|
|
void far (interrupt *int9Save)();
|
|
|
|
|
2024-03-20 02:08:42 +00:00
|
|
|
void populateExampleCube(void) {
|
|
|
|
int y, x;
|
|
|
|
|
|
|
|
outp(0x3c4, 0x02);
|
|
|
|
|
2024-03-20 13:02:47 +00:00
|
|
|
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;
|
|
|
|
|
2024-03-20 13:02:47 +00:00
|
|
|
int9Save = _dos_getvect(9);
|
|
|
|
_dos_setvect(9, keyboardHandler);
|
|
|
|
|
2024-03-19 12:18:55 +00:00
|
|
|
enableUnchainedVGAMode();
|
|
|
|
|
2024-03-20 23:19:49 +00:00
|
|
|
outp(0x3c8, 255);
|
|
|
|
outp(0x3c9, 63);
|
|
|
|
outp(0x3c9, 63);
|
|
|
|
outp(0x3c9, 63);
|
2024-03-20 02:08:42 +00:00
|
|
|
|
2024-03-20 23:19:49 +00:00
|
|
|
fillScreen(0);
|
2024-03-20 02:08:42 +00:00
|
|
|
|
|
|
|
/*
|
2024-03-20 23:19:49 +00:00
|
|
|
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);
|
|
|
|
*/
|
2024-03-20 02:08:42 +00:00
|
|
|
|
2024-03-20 23:19:49 +00:00
|
|
|
writeCube(0, 0x10, 0, 0);
|
|
|
|
writeCube(4, 0x10, 7, 0);
|
|
|
|
writeCube(8, 0x10, 7, 7);
|
|
|
|
writeCube(12, 0x10, 0, 7);
|
2024-03-19 12:18:55 +00:00
|
|
|
|
2024-03-20 23:19:49 +00:00
|
|
|
while (keyboardPressed == 0);
|
2024-03-19 12:18:55 +00:00
|
|
|
|
2024-03-20 23:19:49 +00:00
|
|
|
_dos_setvect(9, int9Save);
|
2024-03-19 12:18:55 +00:00
|
|
|
|
|
|
|
enableTextMode();
|
2024-03-20 23:19:49 +00:00
|
|
|
|
|
|
|
return 0;
|
2024-03-19 12:18:55 +00:00
|
|
|
}
|