more latch copy fun, write asm kb interrupt handler bc why not
This commit is contained in:
parent
51625bb432
commit
4f85bd4b1b
43
main.c
43
main.c
@ -1,22 +1,29 @@
|
|||||||
|
#include <stdio.h>
|
||||||
#include <i86.h>
|
#include <i86.h>
|
||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
|
|
||||||
extern void __cdecl enableUnchainedVGAMode();
|
extern void __cdecl enableUnchainedVGAMode();
|
||||||
extern void __cdecl enableTextMode();
|
extern void __cdecl enableTextMode();
|
||||||
extern void __cdecl fillScreen(int);
|
extern void __cdecl fillScreen(int);
|
||||||
extern void __cdecl latchCopyCube();
|
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;
|
||||||
|
|
||||||
char far *VGA = (char*)0xA0000;
|
char far *VGA = (char*)0xA0000;
|
||||||
|
|
||||||
#define PLANE_WIDTH (320 / 4)
|
#define PLANE_WIDTH (320 / 4)
|
||||||
|
|
||||||
|
void far (interrupt *int9Save)();
|
||||||
|
|
||||||
void populateExampleCube(void) {
|
void populateExampleCube(void) {
|
||||||
int y, x;
|
int y, x;
|
||||||
|
|
||||||
outp(0x3c4, 0x02);
|
outp(0x3c4, 0x02);
|
||||||
|
|
||||||
for (y = 0; y < 15; ++y) {
|
for (y = 0; y < 16; ++y) {
|
||||||
for (x = 0; x < 15; ++x) {
|
for (x = 0; x < 16; ++x) {
|
||||||
outp(0x3c5, 1 << (x % 4));
|
outp(0x3c5, 1 << (x % 4));
|
||||||
VGA[y * PLANE_WIDTH + x / 4] = y * 16 + x;
|
VGA[y * PLANE_WIDTH + x / 4] = y * 16 + x;
|
||||||
}
|
}
|
||||||
@ -34,14 +41,40 @@ int main(void) {
|
|||||||
|
|
||||||
int i,j;
|
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;
|
||||||
|
|
||||||
enableUnchainedVGAMode();
|
enableUnchainedVGAMode();
|
||||||
|
|
||||||
fillScreen(0);
|
fillScreen(0);
|
||||||
|
|
||||||
populateExampleCube();
|
populateExampleCube();
|
||||||
latchCopyCube();
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
delay(2000);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
79
vga.asm
79
vga.asm
@ -2,6 +2,9 @@ PUBLIC _enableUnchainedVGAMode
|
|||||||
PUBLIC _enableTextMode
|
PUBLIC _enableTextMode
|
||||||
PUBLIC _fillScreen
|
PUBLIC _fillScreen
|
||||||
PUBLIC _latchCopyCube
|
PUBLIC _latchCopyCube
|
||||||
|
PUBLIC _paramTest
|
||||||
|
PUBLIC _keyboardPressed
|
||||||
|
PUBLIC _keyboardHandler
|
||||||
|
|
||||||
DISPLAY_MODE_VGA equ 13h
|
DISPLAY_MODE_VGA equ 13h
|
||||||
DISPLAY_MODE_TEXT equ 03h
|
DISPLAY_MODE_TEXT equ 03h
|
||||||
@ -23,8 +26,42 @@ VGA_CRT_CONTROLLER_MODE_CONTROL equ 0x17
|
|||||||
.386
|
.386
|
||||||
.model flat,c
|
.model flat,c
|
||||||
|
|
||||||
|
.DATA
|
||||||
|
|
||||||
|
_keyboardPressed dd 0
|
||||||
|
|
||||||
.CODE
|
.CODE
|
||||||
|
|
||||||
|
_keyboardHandler:
|
||||||
|
cli
|
||||||
|
push eax
|
||||||
|
push ebx
|
||||||
|
|
||||||
|
in al, 0x60
|
||||||
|
mov bl, al
|
||||||
|
|
||||||
|
; acknowledge keyboard
|
||||||
|
in al, 0x61
|
||||||
|
mov ah, al
|
||||||
|
or al, 0x80
|
||||||
|
out 0x61, al
|
||||||
|
xchg ah, al
|
||||||
|
out 0x61, al
|
||||||
|
|
||||||
|
and bl,0x80
|
||||||
|
jne _keyboardHandler_notKeydown
|
||||||
|
|
||||||
|
mov [_keyboardPressed], 1
|
||||||
|
_keyboardHandler_notKeydown:
|
||||||
|
; acknowledge interrupt
|
||||||
|
mov al, 0x20
|
||||||
|
out 0x20, al
|
||||||
|
|
||||||
|
pop ebx
|
||||||
|
pop eax
|
||||||
|
sti
|
||||||
|
iretd
|
||||||
|
|
||||||
_enableUnchainedVGAMode:
|
_enableUnchainedVGAMode:
|
||||||
mov ax,0x0013;
|
mov ax,0x0013;
|
||||||
int 0x10
|
int 0x10
|
||||||
@ -76,24 +113,49 @@ _fillScreen_loop:
|
|||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
_paramTest:
|
||||||
|
push ebp
|
||||||
|
mov ebp,esp
|
||||||
|
|
||||||
|
mov eax,0
|
||||||
|
mov al, BYTE PTR [ebp+8]
|
||||||
|
|
||||||
|
mov esp,ebp
|
||||||
|
pop ebp
|
||||||
|
ret
|
||||||
|
|
||||||
_latchCopyCube:
|
_latchCopyCube:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp,esp
|
mov ebp,esp
|
||||||
; we need a y variable
|
; we need a y variable
|
||||||
sub esp,4 ; y
|
sub esp,4 ; y
|
||||||
|
|
||||||
; enable latch reads
|
push edx
|
||||||
|
push ebx
|
||||||
|
|
||||||
|
; accept a mode
|
||||||
|
; accept a mix value
|
||||||
|
; accept an x offset
|
||||||
|
|
||||||
|
; [ebp+8] is x offset
|
||||||
|
; [ebp+12] is written value
|
||||||
|
; [ebp+16] is data rotate register
|
||||||
|
|
||||||
|
; enable latch reads on all planes
|
||||||
mov dx, VGA_SEQUENCE_CONTROLLER_INDEX
|
mov dx, VGA_SEQUENCE_CONTROLLER_INDEX
|
||||||
mov al, VGA_SEQUENCE_CONTROLLER_MAP_MASK_MODE
|
mov al, VGA_SEQUENCE_CONTROLLER_MAP_MASK_MODE
|
||||||
mov ah, 0xf
|
mov ah, 0xf
|
||||||
out dx, ax
|
out dx, ax
|
||||||
|
|
||||||
|
; enable OR writes
|
||||||
mov dx, VGA_GRAPHICS_MODE_INDEX
|
mov dx, VGA_GRAPHICS_MODE_INDEX
|
||||||
mov al, 0x08
|
mov al, 0x03
|
||||||
mov ah, 0x00
|
mov ah, [ebp+16]
|
||||||
out dx, ax
|
out dx, ax
|
||||||
|
|
||||||
mov DWORD PTR [ebp-4],16
|
mov dh, [ebp+12]
|
||||||
|
|
||||||
|
mov DWORD PTR [ebp-4],16 ; y
|
||||||
; read across the cube, should take 4 * 16 reads
|
; read across the cube, should take 4 * 16 reads
|
||||||
mov cx,[ebp-4]
|
mov cx,[ebp-4]
|
||||||
_latchCopyCube_yLoop:
|
_latchCopyCube_yLoop:
|
||||||
@ -106,14 +168,17 @@ _latchCopyCube_yLoop:
|
|||||||
mul bl ; number of lines
|
mul bl ; number of lines
|
||||||
add eax,0xa0000 ; vga base address
|
add eax,0xa0000 ; vga base address
|
||||||
|
|
||||||
|
; keep our index handy
|
||||||
|
mov ebx, [ebp+8]
|
||||||
|
|
||||||
; start x loop
|
; start x loop
|
||||||
mov cx,4
|
mov cx,4
|
||||||
_latchCopyCube_xLoop:
|
_latchCopyCube_xLoop:
|
||||||
; fill latches via memory read
|
; fill latches via memory read
|
||||||
mov bl, BYTE PTR [eax]
|
mov dl, BYTE PTR [eax]
|
||||||
|
|
||||||
; write blank
|
; write blank
|
||||||
mov [eax+12],0
|
mov BYTE PTR [eax+ebx], dh
|
||||||
|
|
||||||
; increment vga pointer
|
; increment vga pointer
|
||||||
inc eax
|
inc eax
|
||||||
@ -128,6 +193,8 @@ _latchCopyCube_xLoop:
|
|||||||
loop _latchCopyCube_yLoop
|
loop _latchCopyCube_yLoop
|
||||||
|
|
||||||
; put things back
|
; put things back
|
||||||
|
pop ebx
|
||||||
|
pop edx
|
||||||
mov esp,ebp
|
mov esp,ebp
|
||||||
pop ebp
|
pop ebp
|
||||||
ret
|
ret
|
||||||
|
Loading…
Reference in New Issue
Block a user