working dos vga writes!
This commit is contained in:
1 parent
5789cafd4e
commit
55ac075e4d
25 files changed
+454
-149
No files matched your search
+22
-31
@@ -1,3 +1,4 @@
|
||||
#include "../../Common/def.h"
|
||||
#include "display.h"
|
||||
#include <fcntl.h>
|
||||
#include <stdbool.h>
|
||||
@@ -259,6 +260,17 @@ static inline bool set_segment_rights(uint16_t selector, bool read,
|
||||
return !carry_clear;
|
||||
}
|
||||
|
||||
static inline intptr_t get_segment_base_address(uint16_t selector) {
|
||||
bool carry_clear;
|
||||
uint16_t high, low;
|
||||
__asm__ volatile("int $0x31"
|
||||
: "=@ccnc"(carry_clear), "=c"(high), "=d"(low)
|
||||
: "a"(0x0006), "b"(selector)
|
||||
: "memory", "cc");
|
||||
// return carry_clear ? 0 : (((intptr_t)high << 16) | (intptr_t)low);
|
||||
return ((intptr_t)high << 16) | (intptr_t)low;
|
||||
}
|
||||
|
||||
static inline void use_segment(uint16_t selector) {
|
||||
__asm__ volatile("" : "=S"(selector)::);
|
||||
}
|
||||
@@ -271,40 +283,19 @@ static inline void print_to_console(char *const str) {
|
||||
|
||||
static uint32_t test = 0x1420124;
|
||||
|
||||
// extern int plr_display_dos_main(int argc, char *argv[]) {
|
||||
extern int plr_display_dos_main(void) {
|
||||
print_to_console("Fuck you stupid shit");
|
||||
return -1;
|
||||
|
||||
uint16_t base = alloc_ldt_descriptor();
|
||||
if (!base) {
|
||||
print_to_console("Cannot allocate LDT descriptor");
|
||||
/* Fat DS trick, see __djgpp_nearptr_enable() */
|
||||
unsigned short ds_selector;
|
||||
asm("movw %%ds, %0" : "=r"(ds_selector));
|
||||
set_segment_limit(ds_selector, 0xFFFFFFFF);
|
||||
intptr_t baseaddr = get_segment_base_address(ds_selector);
|
||||
if (baseaddr == 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!set_segment_base_address(base, 0xA0000)) {
|
||||
print_to_console("Cannot set LDT base address");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!set_segment_limit(base, 0x10000)) {
|
||||
print_to_console("Cannot set LDT limit");
|
||||
return -1;
|
||||
}
|
||||
|
||||
use_segment(base);
|
||||
|
||||
// char *volatile buf = (void *)(intptr_t)0xA0000; // VGA memory address
|
||||
// char *buf = map_physical_address(0xA0000, 0x10000); // VGA memory
|
||||
char *buf = map_physical_address(0xA0000, 0x10000); // VGA memory
|
||||
// address
|
||||
if (!buf)
|
||||
return -1;
|
||||
int x, y;
|
||||
|
||||
// if (!buf)
|
||||
// return -1;
|
||||
unsigned char *volatile buf =
|
||||
(unsigned char *)((intptr_t)0xA0000 - baseaddr); // VGA memory address
|
||||
|
||||
/* TODO: Make VESA work for sweet sweet 640x480. */
|
||||
// unsigned char saved_mode = get_video_mode(); // Save original mode
|
||||
// set_vesa_video_mode(MODE_VESA_640_480_8); // Set our VGA mode
|
||||
set_video_mode(MODE_VGA_320_200_8); // Set our VGA mode
|
||||
@@ -327,6 +318,7 @@ extern int plr_display_dos_main(void) {
|
||||
// wait_for_key();
|
||||
// set_video_mode(saved_mode); // Restore original mode
|
||||
|
||||
int x, y;
|
||||
while (1) {
|
||||
for (y = 0; y < HEIGHT; y++) {
|
||||
for (x = 0; x < WIDTH; x++) {
|
||||
@@ -339,7 +331,6 @@ extern int plr_display_dos_main(void) {
|
||||
}
|
||||
}
|
||||
// writetest();
|
||||
__asm__ volatile("int $0x16" : : "a"(0x00) : "memory", "cc");
|
||||
}
|
||||
|
||||
// dpmi_regs = (struct dpmi_regs){.eax = 0x00004C00};
|
||||
|
||||
Reference in new issue
Block a user